Skip to content

Commit

Permalink
Bug fixing mass simus (#323)
Browse files Browse the repository at this point in the history
* specify pv production in kpis

* fix pytest electricity meter

* fix kpi error due to error in postprocessingflag of hp hplib thermal power

* fix pytest builing sizer pp-option

* add some of new kpis to scneario processing list

* small fix

* remove rounding in electricity meter

* enable heating by devices

* chaanges on building

* smaller changes

* add stacked bar plot and flow and return temps in kpis and scenario evaluation

* order bar plots

* fix mypy

* prospector

* try to fix tests

* more explanation for heating test

* fix pytests and prospector

* fix rounding error in kpis

* add some building kpis

* add some more building outputs

* add more outputs and kpis for building for testing purposes

* small change

* plotting improvement

* sort kpis

* fix pytest electricity meter

* implement hds flow and return temperatures as kpis

* some important changes

* more change

* use ems and battery only when pv is used in cluster system setup

* some more dev on scenario evaluation

* make tofromgrid output in Wh for em

* fix pytest

* fix pytest

* fix pylint

* keep electricity availabe in watt

* code qualy

* add some more inputs to advanced hp for cooling validation

* add some more hplib kpis

* fix hplib test

* add some more hplib kpis

* fix pytest

* fix pytest

* fix pylint

* make cluster system setup run

* code qualy

* some more changes

* some more changes

* save x_y_plot_data

* small improvement in plotting

* slight changes on scenario evaluation

* Add files via upload

* Debug ems (#326)

* ems renaming variables

* use more default connections for ems

* use more default connections for ems

* some more renaming

* some more cleaning up ems

* more tidying up and chnages on ems outputs, try to investiagte grid dependency of each component

* fix pytest

* some more renaming

* some more renaming

* some more renaming

* Windturbine and additional parameters/function in weather modell (#277)

* more advanced heat pump model, example and tester

* tester for more advanced heatpump

* units for pressure
todo: automatische änderung bei plots von hPa in bar etc.

* weather model ergänzt um druck aus-/übergabe

* model ergänzt um druck für ggf zukünftige erweiterung von windkraftanlage modell

* pressure output angepasst

* pressure ergänzt

* anpassen auf SI-Einheit für Druck

* anpassen auf SI-Einheit für Druck

* anpassen auf SI-Einheit für Druck

* modell ergänzt um pressure output für windkraftanlage,
vorbereitung funktion zum beziehen von wetterdaten vom dwd (10min aflösung) durch extra modell --> aktuelle reale wetterdaten für ein jahr

* test

* wettermodell update

* hisim uodate

* wp modell nicht für diesen Branche!
Hier nur Windkraft und wetter

* New Modell of a Windturbine based on windpowerlib https://github.com/wind-python/windpowerlib/tree/dev

* test for generic windturbine

* gehört nicht zum branche für windkraftanlage

* manuell auf aktuelle hisim version kopiert

* erst zu mein branche, wenn komplett fertig und abgenommen

* - implement windpowerlib in requirements.txt
- fix pytest issues

* - Preparation for external weather data retrieval of DWD and era5 data

- Function for era5 data added

- function for dwd retrieval corrected

- variables and function renamed for better overview (DWD to DWD_TRY)

--> Script for data retrieval from dwd/era5 database will follow after consultation

* geändert auf original weather model

* NOTE: NEW MODEL FOR WEATHER DATA IMPORT (weather_data_import.py) --> PLEASE CHECK ALSO FOR MERGING

- fixing testing issues
- implement new test setups for data request
- add new python lib to test/requirement files

* a small change to make the variable "name" flexible --> "name" is now specified in the config class. Enables the integration of several weather objects in the simulation (particularly helpful for wind turbine applications, as they often have a different location than buildings)

* update and fix merge conflicts

* - updated nsrdb_15min files: parameter "pressure" and "wind direction" were added due to new parameters in weather.py model (error with "old" files due to missing parameters if using nsrdb_15min)

- todo: push branch again when "Fix utsp tests" is merged into main to pass tests

---------

Co-authored-by: noah80 <[email protected]>
Co-authored-by: Hoppe-J <[email protected]>
  • Loading branch information
3 people authored Apr 16, 2024
1 parent e91cc8b commit 7ae883a
Show file tree
Hide file tree
Showing 8 changed files with 473 additions and 282 deletions.
67 changes: 55 additions & 12 deletions hisim/components/advanced_heat_pump_hplib.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def get_scaled_advanced_hp_lib(
) -> "HeatPumpHplibConfig":
"""Gets a default heat pump with scaling according to heating load of the building."""

set_thermal_output_power_in_watt = heating_load_of_building_in_watt
set_thermal_output_power_in_watt: Quantity[float, Watt] = heating_load_of_building_in_watt

return HeatPumpHplibConfig(
name="AdvancedHeatPumpHPLib",
Expand Down Expand Up @@ -176,12 +176,15 @@ class HeatPumpHplib(Component):
ThermalOutputPower = "ThermalOutputPower" # W
ThermalOutputEnergy = "ThermalOutputEnergy" # Wh
ElectricalInputPower = "ElectricalInputPower" # W
ElectricalInputPowerForHeating = "ElectricalInputPowerForHeating" # W
ElectricalInputPowerForCooling = "ElectricalInputPowerForCooling" # W
ElectricalInputEnergy = "ElectricalInputEnergy" # Wh
COP = "COP" # -
EER = "EER" # -
TemperatureOutput = "TemperatureOutput" # °C
MassFlowOutput = "MassFlowOutput" # kg/s
TimeOn = "TimeOn" # s
TimeOnHeating = "TimeOnHeating" # s
TimeOnCooling = "TimeOnCooling" # s
TimeOff = "TimeOff" # s

def __init__(
Expand Down Expand Up @@ -239,7 +242,7 @@ def __init__(

# Component has states
self.state = HeatPumpState(
time_on=0, time_off=0, time_on_cooling=0, on_off_previous=0
time_on_heating=0, time_off=0, time_on_cooling=0, on_off_previous=0
)
self.previous_state = self.state.self_copy()

Expand Down Expand Up @@ -312,6 +315,28 @@ def __init__(
],
output_description="Electricity input power in Watt",
)
self.p_el_heating: ComponentOutput = self.add_output(
object_name=self.component_name,
field_name=self.ElectricalInputPowerForHeating,
load_type=LoadTypes.ELECTRICITY,
unit=Units.WATT,
postprocessing_flag=[
InandOutputType.ELECTRICITY_CONSUMPTION_UNCONTROLLED,
OutputPostprocessingRules.DISPLAY_IN_WEBTOOL,
],
output_description="Electricity input power for heating in Watt",
)
self.p_el_cooling: ComponentOutput = self.add_output(
object_name=self.component_name,
field_name=self.ElectricalInputPowerForCooling,
load_type=LoadTypes.ELECTRICITY,
unit=Units.WATT,
postprocessing_flag=[
InandOutputType.ELECTRICITY_CONSUMPTION_UNCONTROLLED,
OutputPostprocessingRules.DISPLAY_IN_WEBTOOL,
],
output_description="Electricity input power for cooling in Watt",
)

self.e_el: ComponentOutput = self.add_output(
object_name=self.component_name,
Expand Down Expand Up @@ -363,12 +388,22 @@ def __init__(
output_description="Mass flow output",
)

self.time_on: ComponentOutput = self.add_output(
self.time_on_heating: ComponentOutput = self.add_output(
object_name=self.component_name,
field_name=self.TimeOnHeating,
load_type=LoadTypes.TIME,
unit=Units.SECONDS,
output_description="Time turned on for heating",
postprocessing_flag=[
OutputPostprocessingRules.DISPLAY_IN_WEBTOOL,
],
)
self.time_on_cooling: ComponentOutput = self.add_output(
object_name=self.component_name,
field_name=self.TimeOn,
field_name=self.TimeOnCooling,
load_type=LoadTypes.TIME,
unit=Units.SECONDS,
output_description="Time turned on",
output_description="Time turned on for cooling",
postprocessing_flag=[
OutputPostprocessingRules.DISPLAY_IN_WEBTOOL,
],
Expand Down Expand Up @@ -481,7 +516,7 @@ def i_simulate(
t_in_primary = stsv.get_input_value(self.t_in_primary)
t_in_secondary = stsv.get_input_value(self.t_in_secondary)
t_amb = stsv.get_input_value(self.t_amb)
time_on_heating = self.state.time_on
time_on_heating = self.state.time_on_heating
time_on_cooling = self.state.time_on_cooling
time_off = self.state.time_off

Expand Down Expand Up @@ -526,6 +561,8 @@ def i_simulate(
p_th = results["P_th"].values[0]
q_th = p_th * self.my_simulation_parameters.seconds_per_timestep / 3600
p_el = results["P_el"].values[0]
p_el_heating = p_el
p_el_cooling = 0
e_el = p_el * self.my_simulation_parameters.seconds_per_timestep / 3600
cop = results["COP"].values[0]
eer = results["EER"].values[0]
Expand All @@ -550,6 +587,8 @@ def i_simulate(
p_th = results["P_th"].values[0]
q_th = p_th * self.my_simulation_parameters.seconds_per_timestep / 3600
p_el = results["P_el"].values[0]
p_el_heating = 0
p_el_cooling = p_el
e_el = p_el * self.my_simulation_parameters.seconds_per_timestep / 3600
cop = results["COP"].values[0]
eer = results["EER"].values[0]
Expand All @@ -559,13 +598,14 @@ def i_simulate(
time_on_cooling + self.my_simulation_parameters.seconds_per_timestep
)
time_on_heating = 0
time_on_heating = 0
time_off = 0
elif on_off == 0:
# Calulate outputs for off mode
p_th = 0
q_th = 0
p_el = 0
p_el_heating = 0
p_el_cooling = 0
e_el = 0
# None values or nans will cause troubles in post processing, that is why there are not used here
# cop = None
Expand All @@ -585,16 +625,19 @@ def i_simulate(
stsv.set_output_value(self.p_th, p_th)
stsv.set_output_value(self.q_th, q_th)
stsv.set_output_value(self.p_el, p_el)
stsv.set_output_value(self.p_el_heating, p_el_heating)
stsv.set_output_value(self.p_el_cooling, p_el_cooling)
stsv.set_output_value(self.e_el, e_el)
stsv.set_output_value(self.cop, cop)
stsv.set_output_value(self.eer, eer)
stsv.set_output_value(self.t_out, t_out)
stsv.set_output_value(self.m_dot, m_dot)
stsv.set_output_value(self.time_on, time_on_heating)
stsv.set_output_value(self.time_on_heating, time_on_heating)
stsv.set_output_value(self.time_on_cooling, time_on_cooling)
stsv.set_output_value(self.time_off, time_off)

# write values to state
self.state.time_on = time_on_heating
self.state.time_on_heating = time_on_heating
self.state.time_on_cooling = time_on_cooling
self.state.time_off = time_off
self.state.on_off_previous = on_off
Expand Down Expand Up @@ -674,7 +717,7 @@ def get_cached_results_or_run_hplib_simulation(
class HeatPumpState:
"""HeatPumpState class."""

time_on: int = 0
time_on_heating: int = 0
time_off: int = 0
time_on_cooling: int = 0
on_off_previous: float = 0
Expand All @@ -684,7 +727,7 @@ def self_copy(
):
"""Copy the Heat Pump State."""
return HeatPumpState(
self.time_on, self.time_off, self.time_on_cooling, self.on_off_previous
self.time_on_heating, self.time_off, self.time_on_cooling, self.on_off_previous
)


Expand Down
25 changes: 19 additions & 6 deletions hisim/components/electricity_meter.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class ElectricityMeter(DynamicComponent):

# Outputs
ElectricityAvailable = "ElectricityAvailable"
ElectricityToAndFromGrid = "ElectricityToAndFromGrid"
ElectricityToGrid = "ElectricityToGrid"
ElectricityFromGrid = "ElectricityFromGrid"
ElectricityConsumption = "ElectricityConsumption"
Expand Down Expand Up @@ -89,15 +90,23 @@ def __init__(
self.previous_state = self.state.self_copy()

# Outputs
self.electricity_available: cp.ComponentOutput = self.add_output(
self.electricity_available_channel: cp.ComponentOutput = self.add_output(
object_name=self.component_name,
field_name=self.ElectricityAvailable,
load_type=lt.LoadTypes.ELECTRICITY,
unit=lt.Units.WATT,
sankey_flow_direction=False,
output_description=f"here a description for {self.ElectricityAvailable} will follow.",
)
self.electricity_to_grid: cp.ComponentOutput = self.add_output(
self.electricity_to_and_from_grid_channel: cp.ComponentOutput = self.add_output(
object_name=self.component_name,
field_name=self.ElectricityToAndFromGrid,
load_type=lt.LoadTypes.ELECTRICITY,
unit=lt.Units.WATT_HOUR,
sankey_flow_direction=False,
output_description=f"here a description for {self.ElectricityToAndFromGrid} will follow.",
)
self.electricity_to_grid_channel: cp.ComponentOutput = self.add_output(
object_name=self.component_name,
field_name=self.ElectricityToGrid,
load_type=lt.LoadTypes.ELECTRICITY,
Expand All @@ -106,7 +115,7 @@ def __init__(
output_description=f"here a description for {self.ElectricityToGrid} will follow.",
postprocessing_flag=[lt.OutputPostprocessingRules.DISPLAY_IN_WEBTOOL],
)
self.electricity_from_grid: cp.ComponentOutput = self.add_output(
self.electricity_from_grid_channel: cp.ComponentOutput = self.add_output(
object_name=self.component_name,
field_name=self.ElectricityFromGrid,
load_type=lt.LoadTypes.ELECTRICITY,
Expand Down Expand Up @@ -324,11 +333,15 @@ def i_simulate(self, timestep: int, stsv: cp.SingleTimeStepValues, force_converg

# set outputs
stsv.set_output_value(
self.electricity_available,
self.electricity_available_channel,
difference_between_production_and_consumption_in_watt,
)
stsv.set_output_value(self.electricity_to_grid, electricity_to_grid_in_watt_hour)
stsv.set_output_value(self.electricity_from_grid, electricity_from_grid_in_watt_hour)
stsv.set_output_value(
self.electricity_to_and_from_grid_channel,
difference_between_production_and_consumption_in_watt_hour,
)
stsv.set_output_value(self.electricity_to_grid_channel, electricity_to_grid_in_watt_hour)
stsv.set_output_value(self.electricity_from_grid_channel, electricity_from_grid_in_watt_hour)
stsv.set_output_value(
self.electricity_consumption_channel,
consumption_uncontrolled_in_watt_hour,
Expand Down
Loading

0 comments on commit 7ae883a

Please sign in to comment.