Skip to content

Commit

Permalink
Updates for webtool (#327)
Browse files Browse the repository at this point in the history
* 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 19bf3b2.

* Add operation results to docker image

* Remove redundancy

* Ignore `possibly-used-before-assignment` in linting

* Fix linting

* Fix deprecated get_cmap
  • Loading branch information
k-knosala authored May 23, 2024
1 parent 81a8ba7 commit 99e9c7e
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 9 deletions.
2 changes: 2 additions & 0 deletions hisim/components/building.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,13 +406,15 @@ 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,
self.HeatLossFromVentilation,
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(
Expand Down
5 changes: 5 additions & 0 deletions hisim/components/generic_car.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion hisim/components/generic_heat_pump_modular.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
10 changes: 5 additions & 5 deletions hisim/components/generic_rsoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion hisim/components/simple_hot_water_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion hisim/postprocessing/charts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions hisim/postprocessing/postprocessing_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
3 changes: 2 additions & 1 deletion pylintrc-critical-only
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ disable=raw-checker-failed,
broad-exception-raised,
cyclic-import,
consider-using-generator,
broad-except
broad-except,
possibly-used-before-assignment



Expand Down

0 comments on commit 99e9c7e

Please sign in to comment.