From 99e9c7eeb95b784ba40330b9f6a84cf239022a9b Mon Sep 17 00:00:00 2001 From: Kevin Knosala <58529976+k-knosala@users.noreply.github.com> Date: Thu, 23 May 2024 13:48:06 +0200 Subject: [PATCH] Updates for webtool (#327) * Make pv actually optional * Add relvant building load types * Change PV module type * Reduce lifetime of simple_hot_water_storage * Revert "Change PV module type" This reverts commit 19bf3b2d9dbf5890c1fcd458fc60dcaf5f0a187e. * Add operation results to docker image * Remove redundancy * Ignore `possibly-used-before-assignment` in linting * Fix linting * Fix deprecated get_cmap --- hisim/components/building.py | 2 ++ hisim/components/generic_car.py | 5 +++++ hisim/components/generic_heat_pump_modular.py | 4 +++- hisim/components/generic_rsoc.py | 10 +++++----- hisim/components/simple_hot_water_storage.py | 2 +- hisim/postprocessing/charts.py | 2 +- hisim/postprocessing/postprocessing_main.py | 1 + pylintrc-critical-only | 3 ++- 8 files changed, 20 insertions(+), 9 deletions(-) diff --git a/hisim/components/building.py b/hisim/components/building.py index 532074a6b..695c61622 100644 --- a/hisim/components/building.py +++ b/hisim/components/building.py @@ -406,6 +406,7 @@ def __init__( lt.LoadTypes.HEATING, lt.Units.WATT, output_description=f"here a description for {self.HeatLossFromTransmission} will follow.", + postprocessing_flag=[OutputPostprocessingRules.DISPLAY_IN_WEBTOOL] ) self.heat_loss_from_ventilation_channel: cp.ComponentOutput = self.add_output( self.component_name, @@ -413,6 +414,7 @@ def __init__( lt.LoadTypes.HEATING, lt.Units.WATT, output_description=f"here a description for {self.HeatLossFromVentilation} will follow.", + postprocessing_flag=[OutputPostprocessingRules.DISPLAY_IN_WEBTOOL] ) self.heat_demand_according_to_tabula_channel: cp.ComponentOutput = self.add_output( diff --git a/hisim/components/generic_car.py b/hisim/components/generic_car.py index 3030863c1..e6b2ba2c6 100644 --- a/hisim/components/generic_car.py +++ b/hisim/components/generic_car.py @@ -208,6 +208,8 @@ def get_cost_opex( postprocessing_results: pd.DataFrame, ) -> OpexCostDataClass: """Calculate OPEX costs, consisting of energy and maintenance costs.""" + opex_cost_per_simulated_period_in_euro = None + co2_per_simulated_period_in_kg = None for index, output in enumerate(all_outputs): if output.component_name == self.config.name + "_w" + str(self.config.source_weight): if output.unit == lt.Units.LITER: @@ -234,6 +236,9 @@ def get_cost_opex( opex_cost_per_simulated_period_in_euro = self.calc_maintenance_cost() co2_per_simulated_period_in_kg = 0.0 + if opex_cost_per_simulated_period_in_euro is None or co2_per_simulated_period_in_kg is None: + raise ValueError("Could not calculate OPEX for Car component.") + opex_cost_data_class = OpexCostDataClass( opex_cost=opex_cost_per_simulated_period_in_euro, co2_footprint=co2_per_simulated_period_in_kg, diff --git a/hisim/components/generic_heat_pump_modular.py b/hisim/components/generic_heat_pump_modular.py index b3f3221fd..71ed5e89d 100644 --- a/hisim/components/generic_heat_pump_modular.py +++ b/hisim/components/generic_heat_pump_modular.py @@ -378,8 +378,10 @@ def i_simulate(self, timestep: int, stsv: cp.SingleTimeStepValues, force_converg # calculate modulation if target_percentage > 0: power_modifier = target_percentage - if target_percentage == 0: + elif target_percentage == 0: power_modifier = 0 + else: + raise ValueError("`target_modifiert` needs to be a positive number.") power_modifier = min(1, power_modifier) diff --git a/hisim/components/generic_rsoc.py b/hisim/components/generic_rsoc.py index 3bb44d115..e65c93e91 100644 --- a/hisim/components/generic_rsoc.py +++ b/hisim/components/generic_rsoc.py @@ -572,6 +572,9 @@ def i_simulate(self, timestep: int, stsv: SingleTimeStepValues, force_convergenc # calculating load input new_load = abs(power_to_soec - self.current_state_soec) + current_sys_eff_soec = 0.0 + h2_production_rate = 0.0 + if rsoc_state == 1: """the ramping process""" if new_load == nominal_load: @@ -616,16 +619,13 @@ def i_simulate(self, timestep: int, stsv: SingleTimeStepValues, force_convergenc self.total_ramp_down_count_state_soec += 0 self.current_state_soec = 2.315 - current_sys_eff_soec = 0.0 - h2_production_rate = 0.0 - elif rsoc_state == -1: self.total_ramp_up_count_state_soec += 0 self.total_ramp_down_count_state_soec += 0 self.current_state_soec = 0.0 - current_sys_eff_soec = 0.0 - h2_production_rate = 0.0 + else: + raise ValueError("`rsoc_state` needs to be one of [-1, 0, 1]") # current_sys_eff_soec = self.soec_efficiency(name, self.current_state_soec, min_load, self.max_load_soec) # h2_production_rate = self.h2_production_rate(current_sys_eff_soec, self.current_state_soec) diff --git a/hisim/components/simple_hot_water_storage.py b/hisim/components/simple_hot_water_storage.py index 43b776e0b..087ae1f79 100644 --- a/hisim/components/simple_hot_water_storage.py +++ b/hisim/components/simple_hot_water_storage.py @@ -76,7 +76,7 @@ def get_default_simplehotwaterstorage_config( heat_exchanger_is_present=True, # until now stratified mode is causing problems, so heat exchanger mode is recommended co2_footprint=100, # Todo: check value cost=volume_heating_water_storage_in_liter * 14.51, # value from emission_factros_and_costs_devices.csv - lifetime=100, # value from emission_factros_and_costs_devices.csv + lifetime=25, # value from emission_factors_and_costs_devices.csv maintenance_cost_as_percentage_of_investment=0.0, # Todo: set correct value ) return config diff --git a/hisim/postprocessing/charts.py b/hisim/postprocessing/charts.py index a39d1ac3f..026ee0cc8 100644 --- a/hisim/postprocessing/charts.py +++ b/hisim/postprocessing/charts.py @@ -62,7 +62,7 @@ def plot(self, xdims: int, data: Any) -> ReportImageEntry: axis = fig.add_subplot(111) mycolors = "viridis" - color_map = plt.cm.get_cmap(mycolors) + color_map = mpl.colormaps.get_cmap(mycolors) plot = axis.pcolormesh(plot_data, cmap=color_map) plt.colorbar(plot).set_label(self.units, fontsize=self.fontsize_label) diff --git a/hisim/postprocessing/postprocessing_main.py b/hisim/postprocessing/postprocessing_main.py index dbf3c0d97..fa0b54ac4 100644 --- a/hisim/postprocessing/postprocessing_main.py +++ b/hisim/postprocessing/postprocessing_main.py @@ -75,6 +75,7 @@ def run(self, ppdt: PostProcessingDataTransfer) -> None: # noqa: MC0001 PostProcessingOptions.COMPUTE_OPEX, PostProcessingOptions.COMPUTE_CAPEX, PostProcessingOptions.MAKE_RESULT_JSON_FOR_WEBTOOL, + PostProcessingOptions.MAKE_OPERATION_RESULTS_FOR_WEBTOOL, PostProcessingOptions.WRITE_COMPONENT_CONFIGS_TO_JSON, PostProcessingOptions.WRITE_ALL_KPIS_TO_JSON, } diff --git a/pylintrc-critical-only b/pylintrc-critical-only index 998ff17c1..4ccb1e82b 100644 --- a/pylintrc-critical-only +++ b/pylintrc-critical-only @@ -189,7 +189,8 @@ disable=raw-checker-failed, broad-exception-raised, cyclic-import, consider-using-generator, - broad-except + broad-except, + possibly-used-before-assignment