From c976e55238853d0841766e6fd29d6bbb08335734 Mon Sep 17 00:00:00 2001 From: k-rieck <115997059+k-rieck@users.noreply.github.com> Date: Thu, 24 Oct 2024 13:12:37 +0200 Subject: [PATCH] Refs/heads/more prep for building sizer (#366) * split building sizer setups into two setups * prepare two system setups for building sizer * more households for building sizer * fix mypy and pytest * code qualy * code qualy * code qualy+ * black on system setups * put gas heater controller in gas heater component * some fixing * some fixing * some fixing * some fixing * some fixing * some fixing * some fixing * some fixing * make one default config for water heating for generic heat source * fixing * fixing * fixing * more changes on generic heat source * kpis and opex/capex costs in generic_heat_source * code qualy * some fixing * some fixing * some more fixing --- ... => example_modular_household_config.json} | 2 +- .../modular_household_config.py | 44 +- .../interface_configs/system_config.py | 20 +- .../controller_l1_generic_gas_heater.py | 436 ------------ hisim/components/generic_district_heating.py | 644 ++++++++++++++++++ hisim/components/generic_gas_heater.py | 377 +++++++++- hisim/components/generic_heat_source.py | 224 +++--- hisim/components/heat_distribution_system.py | 162 ++--- .../component_connections.py | 7 +- .../kpi_computation/kpi_structure.py | 6 +- ...conditioned_house_a_with_mpc_controller.py | 81 +-- ...conditioned_house_b_with_pid_controller.py | 4 +- ...nditioned_house_c_with_onoff_controller.py | 4 +- .../automatic_default_connections.py | 32 +- system_setups/basic_household.py | 12 +- system_setups/basic_household_only_heating.py | 24 +- ...sic_household_with_weather_data_request.py | 27 +- ..._energy_netw_pv_bat_hydro_system_hp_pem.py | 54 +- ...energy_netw_pv_bat_hydro_system_hp_rsoc.py | 64 +- system_setups/default_connections.py | 12 +- .../district_system_setup/simple_district.py | 28 +- .../simple_generic_household.py | 91 +-- system_setups/dynamic_components.py | 21 +- system_setups/electrolyzer_with_renewables.py | 18 +- .../household_1_advanced_hp_diesel_car.py | 34 +- ...ousehold_1b_more_advanced_hp_diesel_car.py | 87 +-- ...d_1c_more_advanced_hp_dhw_hp_diesel_car.py | 34 +- ...advanced_hp_dhw_hp_no_hot_water_storage.py | 41 +- ...usehold_1e_more_advanced_dhw_hp_storage.py | 80 +-- .../household_2_advanced_hp_diesel_car_pv.py | 48 +- ...old_3_advanced_hp_diesel_car_pv_battery.py | 60 +- ..._4a_with_car_priority_advanced_hp_ev_pv.py | 72 +- ...ith_heatpump_priority_advanced_hp_ev_pv.py | 66 +- ..._car_priority_advanced_hp_ev_pv_battery.py | 80 +-- ...tery_priority_advanced_hp_ev_pv_battery.py | 70 +- ...usehold_district_heating_building_sizer.py | 509 ++++++++++++++ system_setups/household_gas_building_sizer.py | 531 +++++++++++++++ system_setups/household_gas_heater.py | 14 +- system_setups/household_heat_pump.py | 5 +- ...y => household_heatpump_building_sizer.py} | 206 ++---- .../household_hp_hws_hds_pv_battery_ems.py | 38 +- ...usehold_reference_gas_heater_diesel_car.py | 32 +- ...with_advanced_hp_hws_hds_pv_battery_ems.py | 42 +- ...ehold_with_more_advanced_hp_hws_dhw_hds.py | 29 +- system_setups/modular_example.py | 36 +- ...ransformation_battery_electrolyzer_grid.py | 15 +- ...sformation_battery_electrolyzer_no_grid.py | 15 +- system_setups/simple_system_setup_one.py | 11 +- system_setups/simple_system_setup_two.py | 10 +- tests/test_gas_meter.py | 12 +- tests/test_generic_dhw_boiler.py | 7 +- tests/test_system_setups_household_cluster.py | 36 - ...em_setups_households_for_building_sizer.py | 85 +++ 53 files changed, 2921 insertions(+), 1778 deletions(-) rename hisim/building_sizer_utils/interface_configs/{example_config.json => example_modular_household_config.json} (95%) delete mode 100644 hisim/components/controller_l1_generic_gas_heater.py create mode 100644 hisim/components/generic_district_heating.py create mode 100644 system_setups/household_district_heating_building_sizer.py create mode 100644 system_setups/household_gas_building_sizer.py rename system_setups/{household_gas_or_heatpump.py => household_heatpump_building_sizer.py} (74%) delete mode 100644 tests/test_system_setups_household_cluster.py create mode 100644 tests/test_system_setups_households_for_building_sizer.py diff --git a/hisim/building_sizer_utils/interface_configs/example_config.json b/hisim/building_sizer_utils/interface_configs/example_modular_household_config.json similarity index 95% rename from hisim/building_sizer_utils/interface_configs/example_config.json rename to hisim/building_sizer_utils/interface_configs/example_modular_household_config.json index bea7700f9..1efcc96be 100644 --- a/hisim/building_sizer_utils/interface_configs/example_config.json +++ b/hisim/building_sizer_utils/interface_configs/example_modular_household_config.json @@ -1,6 +1,6 @@ { "energy_system_config_": { - "heating_system": "HeatPump", + "heating_system": "GasHeating", "share_of_maximum_pv_potential": 1.0 }, "archetype_config_": { diff --git a/hisim/building_sizer_utils/interface_configs/modular_household_config.py b/hisim/building_sizer_utils/interface_configs/modular_household_config.py index 2866ea0f9..1a02b5386 100644 --- a/hisim/building_sizer_utils/interface_configs/modular_household_config.py +++ b/hisim/building_sizer_utils/interface_configs/modular_household_config.py @@ -31,9 +31,29 @@ class ModularHouseholdConfig(SystemSetupConfigBase): archetype_config_: Optional[archetype_config.ArcheTypeConfig] = None @classmethod - def get_default(cls): + def get_default_config_for_household_gas(cls): """Get default ModularHouseholdConfig.""" - energy_system_config_ = system_config.EnergySystemConfig() + energy_system_config_ = system_config.EnergySystemConfig.get_default_config_for_energy_system_gas() + archetype_config_ = archetype_config.ArcheTypeConfig() + household_config = ModularHouseholdConfig( + energy_system_config_=energy_system_config_, archetype_config_=archetype_config_ + ) + return household_config + + @classmethod + def get_default_config_for_household_heatpump(cls): + """Get default ModularHouseholdConfig.""" + energy_system_config_ = system_config.EnergySystemConfig.get_default_config_for_energy_system_heatpump() + archetype_config_ = archetype_config.ArcheTypeConfig() + household_config = ModularHouseholdConfig( + energy_system_config_=energy_system_config_, archetype_config_=archetype_config_ + ) + return household_config + + @classmethod + def get_default_config_for_household_district_heating(cls): + """Get default ModularHouseholdConfig.""" + energy_system_config_ = system_config.EnergySystemConfig.get_default_config_for_energy_system_district_heating() archetype_config_ = archetype_config.ArcheTypeConfig() household_config = ModularHouseholdConfig( energy_system_config_=energy_system_config_, archetype_config_=archetype_config_ @@ -56,24 +76,22 @@ def write_config(config: ModularHouseholdConfig) -> None: file.write(config.to_json()) # type: ignore -def read_in_configs(pathname: str) -> ModularHouseholdConfig: +def read_in_configs(pathname: str) -> Optional[ModularHouseholdConfig]: """Reads in ModularHouseholdConfig file and loads default if file cannot be found.""" + # try to read modular household config from path + household_config: Optional[ModularHouseholdConfig] try: with open(pathname, encoding="utf8") as config_file: household_config_dict = json.load(config_file) # type: ignore - household_config: ModularHouseholdConfig = ModularHouseholdConfig.from_dict(household_config_dict) + household_config = ModularHouseholdConfig.from_dict(household_config_dict) log.information(f"Read modular household config from {pathname}") + assert household_config is not None if (household_config.energy_system_config_ is None) and (household_config.archetype_config_ is None): - raise ValueError() + raise ValueError("Energy system and archetype configs are None.") + + # get default modular household config except Exception: - household_config = ModularHouseholdConfig() - log.warning(f"Could not read the modular household config from '{pathname}'. Using a default config instead.") - - # set default configs - if household_config.energy_system_config_ is None: - household_config.energy_system_config_ = system_config.EnergySystemConfig() - if household_config.archetype_config_ is None: - household_config.archetype_config_ = archetype_config.ArcheTypeConfig() + household_config = None return household_config diff --git a/hisim/building_sizer_utils/interface_configs/system_config.py b/hisim/building_sizer_utils/interface_configs/system_config.py index 733ae805f..c5d87ee93 100644 --- a/hisim/building_sizer_utils/interface_configs/system_config.py +++ b/hisim/building_sizer_utils/interface_configs/system_config.py @@ -49,5 +49,23 @@ class EnergySystemConfig: # charging_station: JsonReference = field( # default_factory=lambda: ChargingStationSets.Charging_At_Home_with_03_7_kW # type: ignore # ) - heating_system: HeatingSystems = HeatingSystems.HEAT_PUMP + heating_system: HeatingSystems = HeatingSystems.DISTRICT_HEATING share_of_maximum_pv_potential: float = 1.0 + + @classmethod + def get_default_config_for_energy_system_gas(cls): + """Get default energy system config.""" + energy_system_config = EnergySystemConfig(heating_system=HeatingSystems.GAS_HEATING, share_of_maximum_pv_potential=1.0) + return energy_system_config + + @classmethod + def get_default_config_for_energy_system_heatpump(cls): + """Get default energy system config.""" + energy_system_config = EnergySystemConfig(heating_system=HeatingSystems.HEAT_PUMP, share_of_maximum_pv_potential=1.0) + return energy_system_config + + @classmethod + def get_default_config_for_energy_system_district_heating(cls): + """Get default energy system config.""" + energy_system_config = EnergySystemConfig(heating_system=HeatingSystems.DISTRICT_HEATING, share_of_maximum_pv_potential=1.0) + return energy_system_config diff --git a/hisim/components/controller_l1_generic_gas_heater.py b/hisim/components/controller_l1_generic_gas_heater.py deleted file mode 100644 index d3efc89f8..000000000 --- a/hisim/components/controller_l1_generic_gas_heater.py +++ /dev/null @@ -1,436 +0,0 @@ -"""Controller for generic_gas_heater according to advanced_heat_pump-Controller.""" - -# clean - -# Import packages from standard library or the environment e.g. pandas, numpy etc. -from typing import Any, List, Optional -from dataclasses import dataclass -from dataclasses_json import dataclass_json -import pandas as pd - -# Import modules from HiSim -from hisim.component import ( - Component, - ComponentInput, - ComponentOutput, - SingleTimeStepValues, - ConfigBase, - ComponentConnection, - DisplayConfig, - OpexCostDataClass, - CapexCostDataClass -) -from hisim.loadtypes import LoadTypes, Units -from hisim.simulationparameters import SimulationParameters -from hisim.components.simple_water_storage import SimpleHotWaterStorage -from hisim.components.weather import Weather -from hisim.components.heat_distribution_system import HeatDistributionController -from hisim.postprocessing.kpi_computation.kpi_structure import KpiEntry - -# from hisim.components.generic_gas_heater import GasHeater - -__authors__ = "Markus Blasberg" -__copyright__ = "Copyright 2021, the House Infrastructure Project" -__credits__ = "..." -__license__ = "MIT" -__version__ = "0.1" -__maintainer__ = "Markus Blasberg" -__email__ = "m.blasberg@fz-juelich.de" -__status__ = "development" - - -@dataclass_json -@dataclass -class GenericGasHeaterControllerL1Config(ConfigBase): - """Gas-heater Controller Config Class.""" - - @classmethod - def get_main_classname(cls): - """Returns the full class name of the base class.""" - return GenericGasHeaterControllerL1.get_full_classname() - - building_name: str - name: str - mode: int - set_heating_threshold_outside_temperature_in_celsius: Optional[float] - minimal_thermal_power_in_watt: float # [W] - maximal_thermal_power_in_watt: float # [W] - set_temperature_difference_for_full_power: float - - @classmethod - def get_default_generic_gas_heater_controller_config( - cls, - building_name: str = "BUI1", - ) -> "GenericGasHeaterControllerL1Config": - """Gets a default Generic Heat Pump Controller.""" - return GenericGasHeaterControllerL1Config( - building_name=building_name, - name="GenericGasHeaterController", - mode=1, - set_heating_threshold_outside_temperature_in_celsius=16.0, - minimal_thermal_power_in_watt=1_000, # [W] # Todo: get information from GasHeater.gasheater_config.minimal_thermal_power_in_watt - maximal_thermal_power_in_watt=12_000, # [W] # Todo: get information fromGasHeater.gasheater_config.maximal_thermal_power_in_watt - set_temperature_difference_for_full_power=5.0, # [K] # 5.0 leads to acceptable results - ) - - @classmethod - def get_scaled_generic_gas_heater_controller_config( - cls, - heating_load_of_building_in_watt: float, - building_name: str = "BUI1", - ) -> "GenericGasHeaterControllerL1Config": - """Gets a default Generic Heat Pump Controller.""" - maximal_thermal_power_in_watt = heating_load_of_building_in_watt - return GenericGasHeaterControllerL1Config( - building_name=building_name, - name="GenericGasHeaterController", - mode=1, - set_heating_threshold_outside_temperature_in_celsius=16.0, - minimal_thermal_power_in_watt=1_000, # [W] # Todo: get information from GasHeater.gasheater_config.minimal_thermal_power_in_watt - maximal_thermal_power_in_watt=maximal_thermal_power_in_watt, # [W] - set_temperature_difference_for_full_power=5.0, # [K] # 5.0 leads to acceptable results - ) - - -class GenericGasHeaterControllerL1(Component): - """Gas Heater Controller based on HeatPumpHplibControllerL1 (in advanced_heat_oump_hplib). - - It takes data from other - components and sends signal to the generic_gas_heater for - activation or deactivation. - Modulating Power with respect to water temperature from storage. - - Parameters - ---------- - mode : int - Mode index for operation type for this heat pump--> should be 1 only for gas_heater - - - Components to connect to: - (1) generic_gas_heater (control_signal) - - """ - - # Inputs - WaterTemperatureInputFromHeatWaterStorage = "WaterTemperatureInputFromHeatWaterStorage" - - # set heating flow temperature - HeatingFlowTemperatureFromHeatDistributionSystem = "HeatingFlowTemperatureFromHeatDistributionSystem" - - DailyAverageOutsideTemperature = "DailyAverageOutsideTemperature" - - # Outputs - ControlSignalToGasHeater = "ControlSignalToGasHeater" - - def __init__( - self, - my_simulation_parameters: SimulationParameters, - config: GenericGasHeaterControllerL1Config, - my_display_config: DisplayConfig = DisplayConfig(), - ) -> None: - """Construct all the neccessary attributes.""" - self.gas_heater_controller_config = config - self.my_simulation_parameters = my_simulation_parameters - self.config = config - component_name = self.get_component_name() - super().__init__( - name=component_name, - my_simulation_parameters=my_simulation_parameters, - my_config=config, - my_display_config=my_display_config, - ) - - self.build( - mode=self.gas_heater_controller_config.mode, - ) - - # input channel - self.water_temperature_input_channel: ComponentInput = self.add_input( - self.component_name, - self.WaterTemperatureInputFromHeatWaterStorage, - LoadTypes.TEMPERATURE, - Units.CELSIUS, - True, - ) - - self.heating_flow_temperature_from_heat_distribution_system_channel: ComponentInput = self.add_input( - self.component_name, - self.HeatingFlowTemperatureFromHeatDistributionSystem, - LoadTypes.TEMPERATURE, - Units.CELSIUS, - True, - ) - self.daily_avg_outside_temperature_input_channel: ComponentInput = self.add_input( - self.component_name, - self.DailyAverageOutsideTemperature, - LoadTypes.TEMPERATURE, - Units.CELSIUS, - True, - ) - - self.control_signal_to_gasheater_channel: ComponentOutput = self.add_output( - self.component_name, - self.ControlSignalToGasHeater, - LoadTypes.ANY, - Units.PERCENT, - output_description=f"here a description for {self.ControlSignalToGasHeater} will follow.", - ) - - self.controller_gasheatermode: Any - self.previous_gasheater_mode: Any - - self.add_default_connections(self.get_default_connections_from_weather()) - self.add_default_connections(self.get_default_connections_from_simple_hot_water_storage()) - self.add_default_connections(self.get_default_connections_from_heat_distribution_controller()) - - def get_default_connections_from_simple_hot_water_storage( - self, - ): - """Get simple_water_storage default connections.""" - - connections = [] - storage_classname = SimpleHotWaterStorage.get_classname() - connections.append( - ComponentConnection( - GenericGasHeaterControllerL1.WaterTemperatureInputFromHeatWaterStorage, - storage_classname, - SimpleHotWaterStorage.WaterTemperatureToHeatGenerator, - ) - ) - return connections - - def get_default_connections_from_weather( - self, - ): - """Get simple_water_storage default connections.""" - - connections = [] - weather_classname = Weather.get_classname() - connections.append( - ComponentConnection( - GenericGasHeaterControllerL1.DailyAverageOutsideTemperature, - weather_classname, - Weather.DailyAverageOutsideTemperatures, - ) - ) - return connections - - def get_default_connections_from_heat_distribution_controller( - self, - ): - """Get heat distribution controller default connections.""" - - connections = [] - hds_controller_classname = HeatDistributionController.get_classname() - connections.append( - ComponentConnection( - GenericGasHeaterControllerL1.HeatingFlowTemperatureFromHeatDistributionSystem, - hds_controller_classname, - HeatDistributionController.HeatingFlowTemperature, - ) - ) - return connections - - def build( - self, - mode: float, - ) -> None: - """Build function. - - The function sets important constants and parameters for the calculations. - """ - # Sth - self.controller_gasheatermode = "off" - self.previous_gasheater_mode = self.controller_gasheatermode - - # Configuration - self.mode = mode - - def i_prepare_simulation(self) -> None: - """Prepare the simulation.""" - pass - - def i_save_state(self) -> None: - """Save the current state.""" - self.previous_gasheater_mode = self.controller_gasheatermode - - def i_restore_state(self) -> None: - """Restore the previous state.""" - self.controller_gasheatermode = self.previous_gasheater_mode - - def i_doublecheck(self, timestep: int, stsv: SingleTimeStepValues) -> None: - """Doublecheck.""" - pass - - def write_to_report( - self, - ) -> List[str]: - """Write important variables to report.""" - return self.gas_heater_controller_config.get_string_dict() - - def i_simulate(self, timestep: int, stsv: SingleTimeStepValues, force_convergence: bool) -> None: - """Simulate the Gas Heater comtroller.""" - - if force_convergence: - pass - else: - # Retrieves inputs - - water_temperature_input_from_heat_water_storage_in_celsius = stsv.get_input_value( - self.water_temperature_input_channel - ) - - heating_flow_temperature_from_heat_distribution_system = stsv.get_input_value( - self.heating_flow_temperature_from_heat_distribution_system_channel - ) - - daily_avg_outside_temperature_in_celsius = stsv.get_input_value( - self.daily_avg_outside_temperature_input_channel - ) - - # turning gas_heater off when the average daily outside temperature is above a certain threshold (if threshold is set in the config) - summer_heating_mode = self.summer_heating_condition( - daily_average_outside_temperature_in_celsius=daily_avg_outside_temperature_in_celsius, - set_heating_threshold_temperature_in_celsius=self.gas_heater_controller_config.set_heating_threshold_outside_temperature_in_celsius, - ) - - # mode 1 is on/off controller - if self.mode == 1: - self.conditions_on_off( - water_temperature_input_in_celsius=water_temperature_input_from_heat_water_storage_in_celsius, - set_heating_flow_temperature_in_celsius=heating_flow_temperature_from_heat_distribution_system, - summer_heating_mode=summer_heating_mode, - ) - - else: - raise ValueError("Gas Heater has no cooling. Set mode==1") - - if self.controller_gasheatermode == "heating": - control_signal = self.modulate_power( - water_temperature_input_in_celsius=water_temperature_input_from_heat_water_storage_in_celsius, - set_heating_flow_temperature_in_celsius=heating_flow_temperature_from_heat_distribution_system, - ) - elif self.controller_gasheatermode == "off": - control_signal = 0 - else: - raise ValueError("Gas Heater Controller control_signal unknown.") - - stsv.set_output_value(self.control_signal_to_gasheater_channel, control_signal) - - def modulate_power( - self, - water_temperature_input_in_celsius: float, - set_heating_flow_temperature_in_celsius: float, - ) -> float: - """Modulate linear between minimial_thermal_power and max_thermal_power of Gas Heater. - - only used if gasheatermode is "heating". - """ - - minimal_percentage = ( - self.gas_heater_controller_config.minimal_thermal_power_in_watt - / self.gas_heater_controller_config.maximal_thermal_power_in_watt - ) - if ( - water_temperature_input_in_celsius - < set_heating_flow_temperature_in_celsius - - self.gas_heater_controller_config.set_temperature_difference_for_full_power - ): - percentage = 1.0 - return percentage - if water_temperature_input_in_celsius < set_heating_flow_temperature_in_celsius: - linear_fit = 1 - ( - ( - self.gas_heater_controller_config.set_temperature_difference_for_full_power - - (set_heating_flow_temperature_in_celsius - water_temperature_input_in_celsius) - ) - / self.gas_heater_controller_config.set_temperature_difference_for_full_power - ) - percentage = max(minimal_percentage, linear_fit) - return percentage - if ( - water_temperature_input_in_celsius <= set_heating_flow_temperature_in_celsius + 0.5 - ): # use same hysteresis like in conditions_on_off() - percentage = minimal_percentage - return percentage - - # if something went wrong - raise ValueError("modulation of Gas Heater needs some adjustments") - - def conditions_on_off( - self, - water_temperature_input_in_celsius: float, - set_heating_flow_temperature_in_celsius: float, - summer_heating_mode: str, - ) -> None: - """Set conditions for the gas heater controller mode.""" - - if self.controller_gasheatermode == "heating": - if ( - water_temperature_input_in_celsius > (set_heating_flow_temperature_in_celsius + 0.5) - or summer_heating_mode == "off" - ): # + 1: - self.controller_gasheatermode = "off" - return - - elif self.controller_gasheatermode == "off": - # gas heater is only turned on if the water temperature is below the flow temperature - # and if the avg daily outside temperature is cold enough (summer mode on) - if ( - water_temperature_input_in_celsius < (set_heating_flow_temperature_in_celsius - 1.0) - and summer_heating_mode == "on" - ): # - 1: - self.controller_gasheatermode = "heating" - return - - else: - raise ValueError("unknown mode") - - def summer_heating_condition( - self, - daily_average_outside_temperature_in_celsius: float, - set_heating_threshold_temperature_in_celsius: Optional[float], - ) -> str: - """Set conditions for the gas_heater.""" - - # if no heating threshold is set, the gas_heater is always on - if set_heating_threshold_temperature_in_celsius is None: - heating_mode = "on" - - # it is too hot for heating - elif daily_average_outside_temperature_in_celsius > set_heating_threshold_temperature_in_celsius: - heating_mode = "off" - - # it is cold enough for heating - elif daily_average_outside_temperature_in_celsius < set_heating_threshold_temperature_in_celsius: - heating_mode = "on" - - else: - raise ValueError( - f"daily average temperature {daily_average_outside_temperature_in_celsius}°C" - f"or heating threshold temperature {set_heating_threshold_temperature_in_celsius}°C is not acceptable." - ) - return heating_mode - - def get_cost_opex( - self, - all_outputs: List, - postprocessing_results: pd.DataFrame, - ) -> OpexCostDataClass: - """Calculate OPEX costs, consisting of electricity costs and revenues.""" - opex_cost_data_class = OpexCostDataClass.get_default_opex_cost_data_class() - return opex_cost_data_class - - @staticmethod - def get_cost_capex(config: GenericGasHeaterControllerL1Config, simulation_parameters: SimulationParameters) -> CapexCostDataClass: # pylint: disable=unused-argument - """Returns investment cost, CO2 emissions and lifetime.""" - capex_cost_data_class = CapexCostDataClass.get_default_capex_cost_data_class() - return capex_cost_data_class - - def get_component_kpi_entries( - self, - all_outputs: List, - postprocessing_results: pd.DataFrame, - ) -> List[KpiEntry]: - """Calculates KPIs for the respective component and return all KPI entries as list.""" - return [] diff --git a/hisim/components/generic_district_heating.py b/hisim/components/generic_district_heating.py new file mode 100644 index 000000000..e6ebcdce9 --- /dev/null +++ b/hisim/components/generic_district_heating.py @@ -0,0 +1,644 @@ +"""district heating Module.""" + +# clean +# Owned +# import importlib +from dataclasses import dataclass +from typing import List, Any, Optional + +import pandas as pd +from dataclasses_json import dataclass_json + +from hisim.loadtypes import LoadTypes, Units +from hisim.component import ( + Component, + ComponentConnection, + SingleTimeStepValues, + ComponentInput, + ComponentOutput, + ConfigBase, + OpexCostDataClass, + DisplayConfig, + CapexCostDataClass, +) +from hisim.components.heat_distribution_system import HeatDistributionController, HeatDistribution +from hisim.components.weather import Weather +# from hisim.components.configuration import EmissionFactorsAndCostsForFuelsConfig +from hisim.simulationparameters import SimulationParameters +from hisim.postprocessing.kpi_computation.kpi_structure import KpiEntry # , KpiTagEnumClass + +__authors__ = "Katharina Rieck" +__copyright__ = "Copyright 2021, the House Infrastructure Project" +__credits__ = ["Noah Pflugradt"] +__license__ = "" +__version__ = "" +__maintainer__ = "Katharina Rieck" +__email__ = "k.rieck@fz-juelich.de" +__status__ = "" + + +@dataclass_json +@dataclass +class DistrictHeatingConfig(ConfigBase): + """Configuration of the District Heating class.""" + + @classmethod + def get_main_classname(cls): + """Return the full class name of the base class.""" + return DistrictHeating.get_full_classname() + + building_name: str + name: str + is_modulating: bool + minimal_thermal_power_in_watt: float # [W] + maximal_thermal_power_in_watt: float # [W] + eff_th_min: float # [-] + eff_th_max: float # [-] + delta_temperature_in_celsius: float # [°C] + maximal_mass_flow_in_kilogram_per_second: float # kg/s ## -> ~0.07 P_th_max / (4180 * delta_T) + maximal_temperature_in_celsius: float # [°C] + temperature_delta_in_celsius: float # [°C] + maximal_power_in_watt: float # [W] + #: CO2 footprint of investment in kg + co2_footprint: float + #: cost for investment in Euro + cost: float + #: lifetime in years + lifetime: float + # maintenance cost as share of investment [0..1] + maintenance_cost_as_percentage_of_investment: float + #: consumption of the car in kWh or l + consumption_in_kilowatt_hour: float + + @classmethod + def get_default_district_heating_config(cls, building_name: str = "BUI1",) -> Any: + """Get a default building_name.""" + maximal_power_in_watt: float = 12_000 # W + config = DistrictHeatingConfig( + building_name=building_name, + name="DistrictHeating", + temperature_delta_in_celsius=10, + maximal_power_in_watt=maximal_power_in_watt, + is_modulating=True, + minimal_thermal_power_in_watt=1_000, # [W] + maximal_thermal_power_in_watt=maximal_power_in_watt, # [W] + eff_th_min=0.60, # [-] + eff_th_max=0.90, # [-] + delta_temperature_in_celsius=25, + maximal_mass_flow_in_kilogram_per_second=maximal_power_in_watt + / (4180 * 25), # kg/s ## -> ~0.07 P_th_max / (4180 * delta_T) + maximal_temperature_in_celsius=80, # [°C]) + co2_footprint=maximal_power_in_watt * 1e-3 * 49.47, # value from emission_factros_and_costs_devices.csv + cost=1, # value from emission_factros_and_costs_devices.csv + lifetime=1, # value from emission_factros_and_costs_devices.csv + maintenance_cost_as_percentage_of_investment=0.03, # source: VDI2067-1 + consumption_in_kilowatt_hour=0, + ) + return config + + @classmethod + def get_scaled_district_heating_config( + cls, heating_load_of_building_in_watt: float, building_name: str = "BUI1", + ) -> Any: + """Get a default building_name.""" + maximal_power_in_watt: float = heating_load_of_building_in_watt # W + config = DistrictHeatingConfig( + building_name=building_name, + name="DistrictHeating", + temperature_delta_in_celsius=10, + maximal_power_in_watt=maximal_power_in_watt, + is_modulating=True, + minimal_thermal_power_in_watt=1_000, # [W] + maximal_thermal_power_in_watt=maximal_power_in_watt, # [W] + eff_th_min=0.60, # [-] + eff_th_max=0.90, # [-] + delta_temperature_in_celsius=25, + maximal_mass_flow_in_kilogram_per_second=maximal_power_in_watt + / (4180 * 25), # kg/s ## -> ~0.07 P_th_max / (4180 * delta_T) + maximal_temperature_in_celsius=80, # [°C]) + co2_footprint=maximal_power_in_watt * 1e-3 * 49.47, # value from emission_factros_and_costs_devices.csv + cost=1, # value from emission_factros_and_costs_devices.csv + lifetime=1, # value from emission_factros_and_costs_devices.csv + maintenance_cost_as_percentage_of_investment=0.03, # source: VDI2067-1 + consumption_in_kilowatt_hour=0, + ) + return config + + +class DistrictHeating(Component): + """District Heating class. + + Get Control Signal and calculate on base of it Massflow and Temperature of Massflow. + """ + + # Input + ControlSignal = "ControlSignal" # at which Procentage is the District heating modulating [0..1] + WaterInputTemperature = "WaterInputTemperature" + + # Output + WaterMassflowOutput = "WaterMassflowOutput" + WaterOutputTemperature = "WaterOutputTemperature" + ThermalOutputPower = "ThermalOutputPower" + + # @utils.graph_call_path_factory(max_depth=2, memory_flag=True, file_name="call_path") + def __init__( + self, + my_simulation_parameters: SimulationParameters, + config: DistrictHeatingConfig, + my_display_config: DisplayConfig = DisplayConfig(display_in_webtool=True), + ) -> None: + """Construct all the neccessary attributes.""" + self.district_heating_config = config + self.my_simulation_parameters = my_simulation_parameters + self.config = config + component_name = self.get_component_name() + super().__init__( + name=component_name, + my_simulation_parameters=my_simulation_parameters, + my_config=config, + my_display_config=my_display_config, + ) + self.control_signal_channel: ComponentInput = self.add_input( + self.component_name, DistrictHeating.ControlSignal, LoadTypes.ANY, Units.PERCENT, True, + ) + self.water_input_tempertaure_channel: ComponentInput = self.add_input( + self.component_name, DistrictHeating.WaterInputTemperature, LoadTypes.WATER, Units.CELSIUS, True, + ) + + self.water_mass_flow_output_channel: ComponentOutput = self.add_output( + self.component_name, + DistrictHeating.WaterMassflowOutput, + LoadTypes.WATER, + Units.KG_PER_SEC, + output_description=f"here a description for {self.WaterMassflowOutput} will follow.", + ) + self.water_output_temperature_channel: ComponentOutput = self.add_output( + self.component_name, + DistrictHeating.WaterOutputTemperature, + LoadTypes.WATER, + Units.CELSIUS, + output_description=f"here a description for {self.WaterOutputTemperature} will follow.", + ) + self.thermal_output_power_channel: ComponentOutput = self.add_output( + object_name=self.component_name, + field_name=self.ThermalOutputPower, + load_type=LoadTypes.HEATING, + unit=Units.WATT, + output_description=f"here a description for {self.ThermalOutputPower} will follow.", + ) + + self.minimal_thermal_power_in_watt = self.district_heating_config.minimal_thermal_power_in_watt + self.maximal_thermal_power_in_watt = self.district_heating_config.maximal_power_in_watt + self.eff_th_min = self.district_heating_config.eff_th_min + self.eff_th_max = self.district_heating_config.eff_th_max + self.maximal_temperature_in_celsius = self.district_heating_config.maximal_temperature_in_celsius + self.temperature_delta_in_celsius = self.district_heating_config.temperature_delta_in_celsius + + self.add_default_connections(self.get_default_connections_from_district_heating_controller()) + self.add_default_connections(self.get_default_connections_from_heat_distribution_system()) + + def get_default_connections_from_district_heating_controller(self,): + """Get Controller District Heating default connections.""" + # use importlib for importing the other component in order to avoid circular-import errors + component_class = DistrictHeatingController + connections = [] + l1_controller_classname = component_class.get_classname() + connections.append( + ComponentConnection( + DistrictHeating.ControlSignal, l1_controller_classname, component_class.ControlSignalToDistrictHeating, + ) + ) + return connections + + def get_default_connections_from_heat_distribution_system(self,): + """Get heat distribution system default connections.""" + + component_class = HeatDistribution + connections = [] + hws_classname = component_class.get_classname() + connections.append( + ComponentConnection( + DistrictHeating.WaterInputTemperature, hws_classname, component_class.WaterTemperatureOutput, + ) + ) + return connections + + def i_prepare_simulation(self) -> None: + """Prepare the simulation.""" + pass + + def write_to_report(self) -> List[str]: + """Write a report.""" + return self.district_heating_config.get_string_dict() + + def i_save_state(self) -> None: + """Save the current state.""" + pass + + def i_restore_state(self) -> None: + """Restore the previous state.""" + pass + + def i_doublecheck(self, timestep: int, stsv: SingleTimeStepValues) -> None: + """Doublecheck.""" + pass + + def i_simulate(self, timestep: int, stsv: SingleTimeStepValues, force_convergence: bool) -> None: + """Simulate the district heating.""" + control_signal = stsv.get_input_value(self.control_signal_channel) + if control_signal > 1: + raise Exception("Expected a control signal between 0 and 1") + if control_signal < 0: + raise Exception("Expected a control signal between 0 and 1") + + # Calculate Eff + d_eff_th = self.eff_th_max - self.eff_th_min + + if control_signal * self.maximal_thermal_power_in_watt < self.minimal_thermal_power_in_watt: + maximum_power = self.minimal_thermal_power_in_watt + eff_th_real = self.eff_th_min + else: + maximum_power = control_signal * self.maximal_thermal_power_in_watt + eff_th_real = self.eff_th_min + d_eff_th * control_signal + + thermal_power_in_watt = maximum_power * eff_th_real * control_signal + c_w = 4182 + mass_flow_out_temperature_in_celsius = self.temperature_delta_in_celsius + stsv.get_input_value( + self.water_input_tempertaure_channel + ) + mass_flow_out_in_kg_per_s = thermal_power_in_watt / (c_w * self.temperature_delta_in_celsius) + + stsv.set_output_value(self.thermal_output_power_channel, thermal_power_in_watt) # efficiency + stsv.set_output_value( + self.water_output_temperature_channel, mass_flow_out_temperature_in_celsius, + ) # efficiency + stsv.set_output_value(self.water_mass_flow_output_channel, mass_flow_out_in_kg_per_s) # efficiency + + def get_cost_opex(self, all_outputs: List, postprocessing_results: pd.DataFrame,) -> OpexCostDataClass: + """Calculate OPEX costs, consisting of electricity costs and revenues.""" + opex_cost_data_class = OpexCostDataClass.get_default_opex_cost_data_class() + return opex_cost_data_class + + @staticmethod + def get_cost_capex( + config: DistrictHeatingConfig, simulation_parameters: SimulationParameters + ) -> CapexCostDataClass: # pylint: disable=unused-argument + """Returns investment cost, CO2 emissions and lifetime.""" + capex_cost_data_class = CapexCostDataClass.get_default_capex_cost_data_class() + return capex_cost_data_class + + def get_component_kpi_entries(self, all_outputs: List, postprocessing_results: pd.DataFrame,) -> List[KpiEntry]: + """Calculates KPIs for the respective component and return all KPI entries as list.""" + return [] + + +@dataclass_json +@dataclass +class DistrictHeatingControllerConfig(ConfigBase): + """District Heating Controller Config Class.""" + + @classmethod + def get_main_classname(cls): + """Returns the full class name of the base class.""" + return DistrictHeatingController.get_full_classname() + + building_name: str + name: str + set_heating_threshold_outside_temperature_in_celsius: Optional[float] + minimal_thermal_power_in_watt: float # [W] + maximal_thermal_power_in_watt: float # [W] + set_temperature_difference_for_full_power: float + + @classmethod + def get_default_district_heating_controller_config( + cls, building_name: str = "BUI1", + ) -> "DistrictHeatingControllerConfig": + """Gets a default Generic District Heating Controller.""" + return DistrictHeatingControllerConfig( + building_name=building_name, + name="DistrictHeatingController", + set_heating_threshold_outside_temperature_in_celsius=16.0, + minimal_thermal_power_in_watt=1000, # [W] + maximal_thermal_power_in_watt=6200, # [W] + set_temperature_difference_for_full_power=5.0, # [K] # 5.0 leads to acceptable results + ) + + @classmethod + def get_scaled_district_heating_controller_config( + cls, heating_load_of_building_in_watt: float, building_name: str = "BUI1", + ) -> "DistrictHeatingControllerConfig": + """Gets a default Generic Heat Pump Controller.""" + maximal_thermal_power_in_watt = heating_load_of_building_in_watt + return DistrictHeatingControllerConfig( + building_name=building_name, + name="DistrictHeatingController", + set_heating_threshold_outside_temperature_in_celsius=16.0, + minimal_thermal_power_in_watt=1_000, # [W] + maximal_thermal_power_in_watt=maximal_thermal_power_in_watt, # [W] + set_temperature_difference_for_full_power=5.0, # [K] # 5.0 leads to acceptable results + ) + + +class DistrictHeatingController(Component): + """District Heating Controller. + + It takes data from other + components and sends signal to the generic_gas_heater for + activation or deactivation. + Modulating Power with respect to water temperature from heat distribution system. + + Parameters + ---------- + Components to connect to: + (1) generic_district_heating + + """ + + # Inputs + WaterTemperatureInputFromHeatDistributionSystem = "WaterTemperatureInputFromHeatDistributionSystem" + # set heating flow temperature + HeatingFlowTemperatureFromHeatDistributionSystem = "HeatingFlowTemperatureFromHeatDistributionSystem" + + DailyAverageOutsideTemperature = "DailyAverageOutsideTemperature" + + # Outputs + ControlSignalToDistrictHeating = "ControlSignalToDistrictHeating" + + def __init__( + self, + my_simulation_parameters: SimulationParameters, + config: DistrictHeatingControllerConfig, + my_display_config: DisplayConfig = DisplayConfig(), + ) -> None: + """Construct all the neccessary attributes.""" + self.district_heating_controller_config = config + self.my_simulation_parameters = my_simulation_parameters + self.config = config + component_name = self.get_component_name() + super().__init__( + name=component_name, + my_simulation_parameters=my_simulation_parameters, + my_config=config, + my_display_config=my_display_config, + ) + + self.build() + + # input channel + self.water_temperature_input_channel: ComponentInput = self.add_input( + self.component_name, + self.WaterTemperatureInputFromHeatDistributionSystem, + LoadTypes.TEMPERATURE, + Units.CELSIUS, + True, + ) + + self.heating_flow_temperature_from_heat_distribution_system_channel: ComponentInput = self.add_input( + self.component_name, + self.HeatingFlowTemperatureFromHeatDistributionSystem, + LoadTypes.TEMPERATURE, + Units.CELSIUS, + True, + ) + self.daily_avg_outside_temperature_input_channel: ComponentInput = self.add_input( + self.component_name, self.DailyAverageOutsideTemperature, LoadTypes.TEMPERATURE, Units.CELSIUS, True, + ) + + self.control_signal_to_district_heating_channel: ComponentOutput = self.add_output( + self.component_name, + self.ControlSignalToDistrictHeating, + LoadTypes.ANY, + Units.PERCENT, + output_description=f"here a description for {self.ControlSignalToDistrictHeating} will follow.", + ) + + self.controller_mode: Any + self.previous_controller_mode: Any + + self.add_default_connections(self.get_default_connections_from_weather()) + self.add_default_connections(self.get_default_connections_from_heat_distribution()) + self.add_default_connections(self.get_default_connections_from_heat_distribution_controller()) + + def get_default_connections_from_heat_distribution(self,): + """Get heat ditribution default connections.""" + + connections = [] + source_classname = HeatDistribution.get_classname() + connections.append( + ComponentConnection( + DistrictHeatingController.WaterTemperatureInputFromHeatDistributionSystem, + source_classname, + HeatDistribution.WaterTemperatureOutput, + ) + ) + return connections + + def get_default_connections_from_weather(self,): + """Get simple_water_storage default connections.""" + + connections = [] + weather_classname = Weather.get_classname() + connections.append( + ComponentConnection( + DistrictHeatingController.DailyAverageOutsideTemperature, + weather_classname, + Weather.DailyAverageOutsideTemperatures, + ) + ) + return connections + + def get_default_connections_from_heat_distribution_controller(self,): + """Get heat distribution controller default connections.""" + + connections = [] + hds_controller_classname = HeatDistributionController.get_classname() + connections.append( + ComponentConnection( + DistrictHeatingController.HeatingFlowTemperatureFromHeatDistributionSystem, + hds_controller_classname, + HeatDistributionController.HeatingFlowTemperature, + ) + ) + return connections + + def build(self,) -> None: + """Build function. + + The function sets important constants and parameters for the calculations. + """ + # Sth + self.controller_mode = "off" + self.previous_controller_mode = self.controller_mode + + def i_prepare_simulation(self) -> None: + """Prepare the simulation.""" + pass + + def i_save_state(self) -> None: + """Save the current state.""" + self.previous_controller_mode = self.controller_mode + + def i_restore_state(self) -> None: + """Restore the previous state.""" + self.controller_mode = self.previous_controller_mode + + def i_doublecheck(self, timestep: int, stsv: SingleTimeStepValues) -> None: + """Doublecheck.""" + pass + + def write_to_report(self,) -> List[str]: + """Write important variables to report.""" + return self.district_heating_controller_config.get_string_dict() + + def i_simulate(self, timestep: int, stsv: SingleTimeStepValues, force_convergence: bool) -> None: + """Simulate the district heating comtroller.""" + + if force_convergence: + pass + else: + # Retrieves inputs + + water_temperature_input_from_heat_distibution_in_celsius = stsv.get_input_value( + self.water_temperature_input_channel + ) + + heating_flow_temperature_from_heat_distribution_system = stsv.get_input_value( + self.heating_flow_temperature_from_heat_distribution_system_channel + ) + + daily_avg_outside_temperature_in_celsius = stsv.get_input_value( + self.daily_avg_outside_temperature_input_channel + ) + + # turning district heating off when the average daily outside temperature is above a certain threshold (if threshold is set in the config) + summer_heating_mode = self.summer_heating_condition( + daily_average_outside_temperature_in_celsius=daily_avg_outside_temperature_in_celsius, + set_heating_threshold_temperature_in_celsius=self.district_heating_controller_config.set_heating_threshold_outside_temperature_in_celsius, + ) + + # on/off controller + self.conditions_on_off( + water_temperature_input_in_celsius=water_temperature_input_from_heat_distibution_in_celsius, + set_heating_flow_temperature_in_celsius=heating_flow_temperature_from_heat_distribution_system, + summer_heating_mode=summer_heating_mode, + ) + + if self.controller_mode == "heating": + control_signal = self.modulate_power( + water_temperature_input_in_celsius=water_temperature_input_from_heat_distibution_in_celsius, + set_heating_flow_temperature_in_celsius=heating_flow_temperature_from_heat_distribution_system, + ) + elif self.controller_mode == "off": + control_signal = 0 + else: + raise ValueError("District Heating Controller control_signal unknown.") + + stsv.set_output_value(self.control_signal_to_district_heating_channel, control_signal) + + def modulate_power( + self, water_temperature_input_in_celsius: float, set_heating_flow_temperature_in_celsius: float, + ) -> float: + """Modulate linear between minimial_thermal_power and max_thermal_power of District Heating.""" + + minimal_percentage = ( + self.district_heating_controller_config.minimal_thermal_power_in_watt + / self.district_heating_controller_config.maximal_thermal_power_in_watt + ) + if ( + water_temperature_input_in_celsius + < set_heating_flow_temperature_in_celsius + - self.district_heating_controller_config.set_temperature_difference_for_full_power + ): + percentage = 1.0 + return percentage + + if water_temperature_input_in_celsius < set_heating_flow_temperature_in_celsius: + linear_fit = 1 - ( + ( + self.district_heating_controller_config.set_temperature_difference_for_full_power + - (set_heating_flow_temperature_in_celsius - water_temperature_input_in_celsius) + ) + / self.district_heating_controller_config.set_temperature_difference_for_full_power + ) + percentage = max(minimal_percentage, linear_fit) + return percentage + if ( + water_temperature_input_in_celsius <= set_heating_flow_temperature_in_celsius + 0.5 + ): # use same hysteresis like in conditions_on_off() + percentage = minimal_percentage + return percentage + + # if something went wrong + raise ValueError("modulation of district heating needs some adjustments") + + def conditions_on_off( + self, + water_temperature_input_in_celsius: float, + set_heating_flow_temperature_in_celsius: float, + summer_heating_mode: str, + ) -> None: + """Set conditions for the district heating controller mode.""" + + if self.controller_mode == "heating": + if ( + water_temperature_input_in_celsius > (set_heating_flow_temperature_in_celsius + 0.5) + or summer_heating_mode == "off" + ): # + 1: + self.controller_mode = "off" + return + + elif self.controller_mode == "off": + # district heating is only turned on if the water temperature is below the flow temperature + # and if the avg daily outside temperature is cold enough (summer mode on) + if ( + water_temperature_input_in_celsius < (set_heating_flow_temperature_in_celsius - 1.0) + and summer_heating_mode == "on" + ): # - 1: + self.controller_mode = "heating" + return + + else: + raise ValueError("unknown mode") + + def summer_heating_condition( + self, + daily_average_outside_temperature_in_celsius: float, + set_heating_threshold_temperature_in_celsius: Optional[float], + ) -> str: + """Set conditions for the district heating.""" + + # if no heating threshold is set, the gas_heater is always on + if set_heating_threshold_temperature_in_celsius is None: + heating_mode = "on" + + # it is too hot for heating + elif daily_average_outside_temperature_in_celsius > set_heating_threshold_temperature_in_celsius: + heating_mode = "off" + + # it is cold enough for heating + elif daily_average_outside_temperature_in_celsius < set_heating_threshold_temperature_in_celsius: + heating_mode = "on" + + else: + raise ValueError( + f"daily average temperature {daily_average_outside_temperature_in_celsius}°C" + f"or heating threshold temperature {set_heating_threshold_temperature_in_celsius}°C is not acceptable." + ) + return heating_mode + + def get_cost_opex(self, all_outputs: List, postprocessing_results: pd.DataFrame,) -> OpexCostDataClass: + """Calculate OPEX costs, consisting of electricity costs and revenues.""" + opex_cost_data_class = OpexCostDataClass.get_default_opex_cost_data_class() + return opex_cost_data_class + + @staticmethod + def get_cost_capex( + config: DistrictHeatingControllerConfig, simulation_parameters: SimulationParameters + ) -> CapexCostDataClass: # pylint: disable=unused-argument + """Returns investment cost, CO2 emissions and lifetime.""" + capex_cost_data_class = CapexCostDataClass.get_default_capex_cost_data_class() + return capex_cost_data_class + + def get_component_kpi_entries(self, all_outputs: List, postprocessing_results: pd.DataFrame,) -> List[KpiEntry]: + """Calculates KPIs for the respective component and return all KPI entries as list.""" + return [] diff --git a/hisim/components/generic_gas_heater.py b/hisim/components/generic_gas_heater.py index 4cd8820b2..7bdb45bf2 100644 --- a/hisim/components/generic_gas_heater.py +++ b/hisim/components/generic_gas_heater.py @@ -21,11 +21,14 @@ DisplayConfig, CapexCostDataClass ) +from hisim.components.simple_water_storage import SimpleHotWaterStorage +from hisim.components.weather import Weather +from hisim.components.heat_distribution_system import HeatDistributionController from hisim.components.configuration import EmissionFactorsAndCostsForFuelsConfig from hisim.simulationparameters import SimulationParameters from hisim.postprocessing.kpi_computation.kpi_structure import KpiEntry, KpiTagEnumClass -__authors__ = "Frank Burkrad, Maximilian Hillen" +__authors__ = "Frank Burkrad, Maximilian Hillen, Markus Blasberg" __copyright__ = "Copyright 2021, the House Infrastructure Project" __credits__ = ["Noah Pflugradt"] __license__ = "" @@ -144,7 +147,6 @@ class GasHeater(Component): GasDemand = "GasDemand" ThermalOutputPower = "ThermalOutputPower" - # @utils.graph_call_path_factory(max_depth=2, memory_flag=True, file_name="call_path") def __init__( self, my_simulation_parameters: SimulationParameters, @@ -226,10 +228,7 @@ def get_default_connections_from_controller_l1_generic_gas_heater( self, ): """Get Controller L1 Gas Heater default connections.""" - # use importlib for importing the other component in order to avoid circular-import errors - component_module_name = "hisim.components.controller_l1_generic_gas_heater" - component_module = importlib.import_module(name=component_module_name) - component_class = getattr(component_module, "GenericGasHeaterControllerL1") + component_class = GenericGasHeaterControllerL1 connections = [] l1_controller_classname = component_class.get_classname() connections.append( @@ -391,3 +390,369 @@ def get_component_kpi_entries( ) list_of_kpi_entries.append(my_kpi_entry) return list_of_kpi_entries + + +@dataclass_json +@dataclass +class GenericGasHeaterControllerL1Config(ConfigBase): + """Gas-heater Controller Config Class.""" + + @classmethod + def get_main_classname(cls): + """Returns the full class name of the base class.""" + return GenericGasHeaterControllerL1.get_full_classname() + + building_name: str + name: str + set_heating_threshold_outside_temperature_in_celsius: Optional[float] + minimal_thermal_power_in_watt: float # [W] + maximal_thermal_power_in_watt: float # [W] + set_temperature_difference_for_full_power: float + + @classmethod + def get_default_generic_gas_heater_controller_config( + cls, + maximal_thermal_power_in_watt: float, + minimal_thermal_power_in_watt: float = 1000, + building_name: str = "BUI1", + ) -> "GenericGasHeaterControllerL1Config": + """Gets a default Generic Gas Heater Controller.""" + return GenericGasHeaterControllerL1Config( + building_name=building_name, + name="GenericGasHeaterController", + set_heating_threshold_outside_temperature_in_celsius=16.0, + # get min and max thermal power from gas heater config + minimal_thermal_power_in_watt=minimal_thermal_power_in_watt, + maximal_thermal_power_in_watt=maximal_thermal_power_in_watt, + set_temperature_difference_for_full_power=5.0, # [K] # 5.0 leads to acceptable results + ) + + +class GenericGasHeaterControllerL1(Component): + """Gas Heater Controller. + + It takes data from other + components and sends signal to the generic_gas_heater for + activation or deactivation. + Modulating Power with respect to water temperature from storage. + + Parameters + ---------- + Components to connect to: + (1) generic_gas_heater (control_signal) + + """ + + # Inputs + WaterTemperatureInputFromHeatWaterStorage = "WaterTemperatureInputFromHeatWaterStorage" + + # set heating flow temperature + HeatingFlowTemperatureFromHeatDistributionSystem = "HeatingFlowTemperatureFromHeatDistributionSystem" + + DailyAverageOutsideTemperature = "DailyAverageOutsideTemperature" + + # Outputs + ControlSignalToGasHeater = "ControlSignalToGasHeater" + + def __init__( + self, + my_simulation_parameters: SimulationParameters, + config: GenericGasHeaterControllerL1Config, + my_display_config: DisplayConfig = DisplayConfig(), + ) -> None: + """Construct all the neccessary attributes.""" + self.gas_heater_controller_config = config + self.my_simulation_parameters = my_simulation_parameters + self.config = config + component_name = self.get_component_name() + super().__init__( + name=component_name, + my_simulation_parameters=my_simulation_parameters, + my_config=config, + my_display_config=my_display_config, + ) + + self.build() + + # input channel + self.water_temperature_input_channel: ComponentInput = self.add_input( + self.component_name, + self.WaterTemperatureInputFromHeatWaterStorage, + lt.LoadTypes.TEMPERATURE, + lt.Units.CELSIUS, + True, + ) + + self.heating_flow_temperature_from_heat_distribution_system_channel: ComponentInput = self.add_input( + self.component_name, + self.HeatingFlowTemperatureFromHeatDistributionSystem, + lt.LoadTypes.TEMPERATURE, + lt.Units.CELSIUS, + True, + ) + self.daily_avg_outside_temperature_input_channel: ComponentInput = self.add_input( + self.component_name, + self.DailyAverageOutsideTemperature, + lt.LoadTypes.TEMPERATURE, + lt.Units.CELSIUS, + True, + ) + + self.control_signal_to_gasheater_channel: ComponentOutput = self.add_output( + self.component_name, + self.ControlSignalToGasHeater, + lt.LoadTypes.ANY, + lt.Units.PERCENT, + output_description=f"here a description for {self.ControlSignalToGasHeater} will follow.", + ) + + self.controller_gasheatermode: Any + self.previous_gasheater_mode: Any + + self.add_default_connections(self.get_default_connections_from_weather()) + self.add_default_connections(self.get_default_connections_from_simple_hot_water_storage()) + self.add_default_connections(self.get_default_connections_from_heat_distribution_controller()) + + def get_default_connections_from_simple_hot_water_storage( + self, + ): + """Get simple_water_storage default connections.""" + + connections = [] + storage_classname = SimpleHotWaterStorage.get_classname() + connections.append( + ComponentConnection( + GenericGasHeaterControllerL1.WaterTemperatureInputFromHeatWaterStorage, + storage_classname, + SimpleHotWaterStorage.WaterTemperatureToHeatGenerator, + ) + ) + return connections + + def get_default_connections_from_weather( + self, + ): + """Get simple_water_storage default connections.""" + + connections = [] + weather_classname = Weather.get_classname() + connections.append( + ComponentConnection( + GenericGasHeaterControllerL1.DailyAverageOutsideTemperature, + weather_classname, + Weather.DailyAverageOutsideTemperatures, + ) + ) + return connections + + def get_default_connections_from_heat_distribution_controller( + self, + ): + """Get heat distribution controller default connections.""" + + connections = [] + hds_controller_classname = HeatDistributionController.get_classname() + connections.append( + ComponentConnection( + GenericGasHeaterControllerL1.HeatingFlowTemperatureFromHeatDistributionSystem, + hds_controller_classname, + HeatDistributionController.HeatingFlowTemperature, + ) + ) + return connections + + def build( + self, + ) -> None: + """Build function. + + The function sets important constants and parameters for the calculations. + """ + # Sth + self.controller_gasheatermode = "off" + self.previous_gasheater_mode = self.controller_gasheatermode + + def i_prepare_simulation(self) -> None: + """Prepare the simulation.""" + pass + + def i_save_state(self) -> None: + """Save the current state.""" + self.previous_gasheater_mode = self.controller_gasheatermode + + def i_restore_state(self) -> None: + """Restore the previous state.""" + self.controller_gasheatermode = self.previous_gasheater_mode + + def i_doublecheck(self, timestep: int, stsv: SingleTimeStepValues) -> None: + """Doublecheck.""" + pass + + def write_to_report( + self, + ) -> List[str]: + """Write important variables to report.""" + return self.gas_heater_controller_config.get_string_dict() + + def i_simulate(self, timestep: int, stsv: SingleTimeStepValues, force_convergence: bool) -> None: + """Simulate the Gas Heater comtroller.""" + + if force_convergence: + pass + else: + # Retrieves inputs + + water_temperature_input_from_heat_water_storage_in_celsius = stsv.get_input_value( + self.water_temperature_input_channel + ) + + heating_flow_temperature_from_heat_distribution_system = stsv.get_input_value( + self.heating_flow_temperature_from_heat_distribution_system_channel + ) + + daily_avg_outside_temperature_in_celsius = stsv.get_input_value( + self.daily_avg_outside_temperature_input_channel + ) + + # turning gas_heater off when the average daily outside temperature is above a certain threshold (if threshold is set in the config) + summer_heating_mode = self.summer_heating_condition( + daily_average_outside_temperature_in_celsius=daily_avg_outside_temperature_in_celsius, + set_heating_threshold_temperature_in_celsius=self.gas_heater_controller_config.set_heating_threshold_outside_temperature_in_celsius, + ) + + # on/off controller + self.conditions_on_off( + water_temperature_input_in_celsius=water_temperature_input_from_heat_water_storage_in_celsius, + set_heating_flow_temperature_in_celsius=heating_flow_temperature_from_heat_distribution_system, + summer_heating_mode=summer_heating_mode, + ) + + if self.controller_gasheatermode == "heating": + control_signal = self.modulate_power( + water_temperature_input_in_celsius=water_temperature_input_from_heat_water_storage_in_celsius, + set_heating_flow_temperature_in_celsius=heating_flow_temperature_from_heat_distribution_system, + ) + elif self.controller_gasheatermode == "off": + control_signal = 0 + else: + raise ValueError("Gas Heater Controller control_signal unknown.") + + stsv.set_output_value(self.control_signal_to_gasheater_channel, control_signal) + + def modulate_power( + self, + water_temperature_input_in_celsius: float, + set_heating_flow_temperature_in_celsius: float, + ) -> float: + """Modulate linear between minimial_thermal_power and max_thermal_power of Gas Heater. + + only used if gasheatermode is "heating". + """ + + minimal_percentage = ( + self.gas_heater_controller_config.minimal_thermal_power_in_watt + / self.gas_heater_controller_config.maximal_thermal_power_in_watt + ) + if ( + water_temperature_input_in_celsius + < set_heating_flow_temperature_in_celsius + - self.gas_heater_controller_config.set_temperature_difference_for_full_power + ): + percentage = 1.0 + return percentage + if water_temperature_input_in_celsius < set_heating_flow_temperature_in_celsius: + linear_fit = 1 - ( + ( + self.gas_heater_controller_config.set_temperature_difference_for_full_power + - (set_heating_flow_temperature_in_celsius - water_temperature_input_in_celsius) + ) + / self.gas_heater_controller_config.set_temperature_difference_for_full_power + ) + percentage = max(minimal_percentage, linear_fit) + return percentage + if ( + water_temperature_input_in_celsius <= set_heating_flow_temperature_in_celsius + 0.5 + ): # use same hysteresis like in conditions_on_off() + percentage = minimal_percentage + return percentage + + # if something went wrong + raise ValueError("modulation of Gas Heater needs some adjustments") + + def conditions_on_off( + self, + water_temperature_input_in_celsius: float, + set_heating_flow_temperature_in_celsius: float, + summer_heating_mode: str, + ) -> None: + """Set conditions for the gas heater controller mode.""" + + if self.controller_gasheatermode == "heating": + if ( + water_temperature_input_in_celsius > (set_heating_flow_temperature_in_celsius + 0.5) + or summer_heating_mode == "off" + ): # + 1: + self.controller_gasheatermode = "off" + return + + elif self.controller_gasheatermode == "off": + # gas heater is only turned on if the water temperature is below the flow temperature + # and if the avg daily outside temperature is cold enough (summer mode on) + if ( + water_temperature_input_in_celsius < (set_heating_flow_temperature_in_celsius - 1.0) + and summer_heating_mode == "on" + ): # - 1: + self.controller_gasheatermode = "heating" + return + + else: + raise ValueError("unknown mode") + + def summer_heating_condition( + self, + daily_average_outside_temperature_in_celsius: float, + set_heating_threshold_temperature_in_celsius: Optional[float], + ) -> str: + """Set conditions for the gas_heater.""" + + # if no heating threshold is set, the gas_heater is always on + if set_heating_threshold_temperature_in_celsius is None: + heating_mode = "on" + + # it is too hot for heating + elif daily_average_outside_temperature_in_celsius > set_heating_threshold_temperature_in_celsius: + heating_mode = "off" + + # it is cold enough for heating + elif daily_average_outside_temperature_in_celsius < set_heating_threshold_temperature_in_celsius: + heating_mode = "on" + + else: + raise ValueError( + f"daily average temperature {daily_average_outside_temperature_in_celsius}°C" + f"or heating threshold temperature {set_heating_threshold_temperature_in_celsius}°C is not acceptable." + ) + return heating_mode + + def get_cost_opex( + self, + all_outputs: List, + postprocessing_results: pd.DataFrame, + ) -> OpexCostDataClass: + """Calculate OPEX costs, consisting of electricity costs and revenues.""" + opex_cost_data_class = OpexCostDataClass.get_default_opex_cost_data_class() + return opex_cost_data_class + + @staticmethod + def get_cost_capex(config: GenericGasHeaterControllerL1Config, simulation_parameters: SimulationParameters) -> CapexCostDataClass: # pylint: disable=unused-argument + """Returns investment cost, CO2 emissions and lifetime.""" + capex_cost_data_class = CapexCostDataClass.get_default_capex_cost_data_class() + return capex_cost_data_class + + def get_component_kpi_entries( + self, + all_outputs: List, + postprocessing_results: pd.DataFrame, + ) -> List[KpiEntry]: + """Calculates KPIs for the respective component and return all KPI entries as list.""" + return [] diff --git a/hisim/components/generic_heat_source.py b/hisim/components/generic_heat_source.py index 92ffce1dc..fc25e24de 100644 --- a/hisim/components/generic_heat_source.py +++ b/hisim/components/generic_heat_source.py @@ -62,51 +62,32 @@ def get_main_classname(cls): @classmethod def get_default_config_heating( - cls, - building_name: str = "BUI1", + cls, building_name: str = "BUI1", thermal_power_in_watt: float = 6200.0, name: str = "HeatingHeatSource" ) -> "HeatSourceConfig": """Returns default configuration of a Heat Source used for heating.""" config = HeatSourceConfig( building_name=building_name, - name="HeatingHeatSource", + name=name, source_weight=1, fuel=lt.LoadTypes.DISTRICTHEATING, - power_th=6200.0, + power_th=thermal_power_in_watt, water_vs_heating=lt.InandOutputType.HEATING, efficiency=1.0, co2_footprint=0, cost=0, - lifetime=1 - ) - return config - - @classmethod - def get_default_config_waterheating_with_district_heating( - cls, - building_name: str = "BUI1", - ) -> "HeatSourceConfig": - """Returns default configuration of a Heat Source used for water heating (DHW).""" - config = HeatSourceConfig( - building_name=building_name, - name="DHWHeatSource", - source_weight=1, - fuel=lt.LoadTypes.DISTRICTHEATING, - power_th=3000.0, - water_vs_heating=lt.InandOutputType.WATER_HEATING, - efficiency=1.0, - co2_footprint=0, - cost=0, - lifetime=1 + lifetime=1, ) return config @classmethod - def get_default_config_waterheating_with_gas( + def get_default_config_waterheating( cls, + heating_system: lt.HeatingSystems, max_warm_water_demand_in_liter: float, scaling_factor_according_to_number_of_apartments: float, seconds_per_timestep: int, building_name: str = "BUI1", + name: str = "DHWHeatSource" ) -> "HeatSourceConfig": """Returns default configuration of a Heat Source used for water heating (DHW).""" # use importlib for importing the other component in order to avoid circular-import errors @@ -127,20 +108,32 @@ def get_default_config_waterheating_with_gas( * scaling_factor_according_to_number_of_apartments ) efficiency = get_heating_system_efficiency( - heating_system_installed=lt.HeatingSystems.GAS_HEATING, - water_vs_heating=lt.InandOutputType.HEATING, + heating_system_installed=heating_system, water_vs_heating=lt.InandOutputType.WATER_HEATING, ) + + if heating_system == lt.HeatingSystems.GAS_HEATING: + fuel = lt.LoadTypes.GAS + elif heating_system == lt.HeatingSystems.OIL_HEATING: + fuel = lt.LoadTypes.OIL + elif heating_system == lt.HeatingSystems.DISTRICT_HEATING: + fuel = lt.LoadTypes.DISTRICTHEATING + else: + raise ValueError( + f"Heating sytem {heating_system} not acceptable for generic heat source component. Muste be ags, oil or district heating." + ) + config = HeatSourceConfig( building_name=building_name, - name="DHWHeatSource", + name=name, source_weight=1, - fuel=lt.LoadTypes.GAS, + fuel=fuel, power_th=thermal_power_in_watt, water_vs_heating=lt.InandOutputType.WATER_HEATING, efficiency=efficiency, - co2_footprint=thermal_power_in_watt * 1e-3 * 49.47, # value from emission_factros_and_costs_devices.csv - cost=7416, # value from emission_factros_and_costs_devices.csv - lifetime=20, # value from emission_factros_and_costs_devices.csv + # costs, footprint and lifetime will be determined later in opex and capex ost calculation + co2_footprint=0, + cost=0, + lifetime=1, ) return config @@ -198,11 +191,7 @@ def __init__( # Inputs - Mandatories self.l1_heatsource_taget_percentage: cp.ComponentInput = self.add_input( - self.component_name, - self.L1HeatSourceTargetPercentage, - lt.LoadTypes.ANY, - lt.Units.PERCENT, - mandatory=True, + self.component_name, self.L1HeatSourceTargetPercentage, lt.LoadTypes.ANY, lt.Units.PERCENT, mandatory=True, ) # Outputs @@ -219,11 +208,7 @@ def __init__( field_name=self.FuelDelivered, load_type=self.config.fuel, unit=lt.Units.ANY, - postprocessing_flag=[ - lt.InandOutputType.FUEL_CONSUMPTION, - config.fuel, - config.water_vs_heating, - ], + postprocessing_flag=[lt.InandOutputType.FUEL_CONSUMPTION, config.fuel, config.water_vs_heating], output_description="Fuel Delivered", ) @@ -234,9 +219,7 @@ def __init__( self.add_default_connections(self.get_default_connections_controller_l1_heatpump()) - def get_default_connections_controller_l1_heatpump( - self, - ) -> List[cp.ComponentConnection]: + def get_default_connections_controller_l1_heatpump(self,) -> List[cp.ComponentConnection]: """Sets default connections of heat source controller.""" log.information("setting l1 default connections in Generic Heat Source") connections = [] @@ -293,8 +276,7 @@ def i_simulate(self, timestep: int, stsv: cp.SingleTimeStepValues, force_converg power_modifier = min(power_modifier, 1) stsv.set_output_value( - self.thermal_power_delivered_channel, - self.config.power_th * power_modifier * self.config.efficiency, + self.thermal_power_delivered_channel, self.config.power_th * power_modifier * self.config.efficiency, ) if self.config.fuel == lt.LoadTypes.OIL: @@ -316,75 +298,125 @@ def i_simulate(self, timestep: int, stsv: cp.SingleTimeStepValues, force_converg @staticmethod def get_cost_capex(config: HeatSourceConfig, simulation_parameters: SimulationParameters) -> CapexCostDataClass: """Returns investment cost, CO2 emissions and lifetime.""" - if config.fuel == lt.LoadTypes.GAS: - seconds_per_year = 365 * 24 * 60 * 60 - capex_per_simulated_period = (config.cost / config.lifetime) * ( - simulation_parameters.duration.total_seconds() / seconds_per_year - ) - device_co2_footprint_per_simulated_period = (config.co2_footprint / config.lifetime) * ( - simulation_parameters.duration.total_seconds() / seconds_per_year - ) + seconds_per_year = 365 * 24 * 60 * 60 + capex_per_simulated_period = (config.cost / config.lifetime) * ( + simulation_parameters.duration.total_seconds() / seconds_per_year + ) + device_co2_footprint_per_simulated_period = (config.co2_footprint / config.lifetime) * ( + simulation_parameters.duration.total_seconds() / seconds_per_year + ) + capex_cost_data_class = CapexCostDataClass( + capex_investment_cost_in_euro=config.cost, + device_co2_footprint_in_kg=config.co2_footprint, + lifetime_in_years=config.lifetime, + capex_investment_cost_for_simulated_period_in_euro=capex_per_simulated_period, + device_co2_footprint_for_simulated_period_in_kg=device_co2_footprint_per_simulated_period, + ) + if config.fuel == lt.LoadTypes.GAS and config.water_vs_heating == lt.InandOutputType.WATER_HEATING: + capex_cost_data_class.kpi_tag = KpiTagEnumClass.GAS_HEATER_DOMESTIC_HOT_WATER + elif config.fuel == lt.LoadTypes.GAS and config.water_vs_heating == lt.InandOutputType.HEATING: + capex_cost_data_class.kpi_tag = KpiTagEnumClass.GAS_HEATER_SPACE_HEATING + elif config.fuel == lt.LoadTypes.OIL and config.water_vs_heating == lt.InandOutputType.WATER_HEATING: + capex_cost_data_class.kpi_tag = KpiTagEnumClass.OIL_HEATER_DOMESTIC_HOT_WATER + elif config.fuel == lt.LoadTypes.OIL and config.water_vs_heating == lt.InandOutputType.HEATING: + capex_cost_data_class.kpi_tag = KpiTagEnumClass.OIL_HEATER_SPACE_HEATING + elif ( + config.fuel == lt.LoadTypes.DISTRICTHEATING and config.water_vs_heating == lt.InandOutputType.WATER_HEATING + ): + capex_cost_data_class.kpi_tag = KpiTagEnumClass.DISTRICT_HEATING_DOMESTIC_HOT_WATER + elif config.fuel == lt.LoadTypes.DISTRICTHEATING and config.water_vs_heating == lt.InandOutputType.HEATING: + capex_cost_data_class.kpi_tag = KpiTagEnumClass.DISTRICT_HEATING_SPACE_HEATING + else: + capex_cost_data_class = CapexCostDataClass.get_default_capex_cost_data_class() - capex_cost_data_class = CapexCostDataClass( - capex_investment_cost_in_euro=config.cost, - device_co2_footprint_in_kg=config.co2_footprint, - lifetime_in_years=config.lifetime, - capex_investment_cost_for_simulated_period_in_euro=capex_per_simulated_period, - device_co2_footprint_for_simulated_period_in_kg=device_co2_footprint_per_simulated_period, - kpi_tag=KpiTagEnumClass.GAS_HEATER_DOMESTIC_HOT_WATER - ) - return capex_cost_data_class - return NotImplemented + return capex_cost_data_class - def get_cost_opex( - self, - all_outputs: List, - postprocessing_results: pd.DataFrame, - ) -> OpexCostDataClass: + def get_cost_opex(self, all_outputs: List, postprocessing_results: pd.DataFrame,) -> OpexCostDataClass: """Calculate OPEX costs, consisting of energy and maintenance costs.""" - gas_consumption_in_kilowatt_hour: Optional[float] = None - for index, output in enumerate(all_outputs): - if output.component_name == self.component_name and output.load_type == lt.LoadTypes.GAS: - gas_consumption_in_kilowatt_hour = round(sum(postprocessing_results.iloc[:, index]) * 1e-3, 1) - if gas_consumption_in_kilowatt_hour is not None: + fuel_consumption_in_kilowatt_hour_or_liter: Optional[float] = None + fuel_consumption_in_kilowatt_hour: Optional[float] = None + output: Optional[cp.ComponentOutput] = None + kpi_tag = None + for index, output_ in enumerate(all_outputs): + if output_.component_name == self.component_name and output_.field_name == self.FuelDelivered: + fuel_consumption_in_kilowatt_hour_or_liter = round(sum(postprocessing_results.iloc[:, index]) * 1e-3, 1) + output = output_ + break + + if fuel_consumption_in_kilowatt_hour_or_liter is not None and output is not None: emissions_and_cost_factors = EmissionFactorsAndCostsForFuelsConfig.get_values_for_year( self.my_simulation_parameters.year ) - co2_per_unit = emissions_and_cost_factors.gas_footprint_in_kg_per_kwh - co2_per_simulated_period_in_kg = gas_consumption_in_kilowatt_hour * co2_per_unit + if output.load_type == lt.LoadTypes.GAS: + co2_per_unit = emissions_and_cost_factors.gas_footprint_in_kg_per_kwh + euro_per_unit = emissions_and_cost_factors.gas_costs_in_euro_per_kwh + fuel_consumption_in_kilowatt_hour = fuel_consumption_in_kilowatt_hour_or_liter + if self.config.water_vs_heating == lt.InandOutputType.WATER_HEATING: + kpi_tag = KpiTagEnumClass.GAS_HEATER_DOMESTIC_HOT_WATER + elif self.config.water_vs_heating == lt.InandOutputType.HEATING: + kpi_tag = KpiTagEnumClass.GAS_HEATER_SPACE_HEATING + + elif output.load_type == lt.LoadTypes.OIL: + co2_per_unit = emissions_and_cost_factors.oil_footprint_in_kg_per_l + euro_per_unit = emissions_and_cost_factors.oil_costs_in_euro_per_l + # calculate fuel consumption from liter to kWh for oil + # https://www.energieheld.de/heizung/ratgeber/durchschnittliche-heizkosten#:~:text=Zur%20Veranschaulichung%3A%20Heiz%C3%B6l%20wird%20meistens,etwa%209%2C8%20Kilowattstunden%20Heizenergie. + # 1l oil = 10 kWh + fuel_consumption_in_kilowatt_hour = fuel_consumption_in_kilowatt_hour_or_liter * 10 + if self.config.water_vs_heating == lt.InandOutputType.WATER_HEATING: + kpi_tag = KpiTagEnumClass.OIL_HEATER_DOMESTIC_HOT_WATER + elif self.config.water_vs_heating == lt.InandOutputType.HEATING: + kpi_tag = KpiTagEnumClass.OIL_HEATER_SPACE_HEATING + + elif output.load_type == lt.LoadTypes.DISTRICTHEATING: + co2_per_unit = emissions_and_cost_factors.contracting_heating_footprint_in_kg_per_kwh + euro_per_unit = emissions_and_cost_factors.contracting_heating_costs_in_euro_per_kwh + fuel_consumption_in_kilowatt_hour = fuel_consumption_in_kilowatt_hour_or_liter + if self.config.water_vs_heating == lt.InandOutputType.WATER_HEATING: + kpi_tag = KpiTagEnumClass.DISTRICT_HEATING_DOMESTIC_HOT_WATER + elif self.config.water_vs_heating == lt.InandOutputType.HEATING: + kpi_tag = KpiTagEnumClass.DISTRICT_HEATING_SPACE_HEATING + else: + raise ValueError("This loadtype is not implemented for the generic heat source.") # energy costs and co2 and everything will be considered in gas meter + co2_per_simulated_period_in_kg = fuel_consumption_in_kilowatt_hour_or_liter * co2_per_unit + opex_energy_cost_per_simulated_period_in_euro = fuel_consumption_in_kilowatt_hour_or_liter * euro_per_unit opex_cost_data_class = OpexCostDataClass( - opex_energy_cost_in_euro=0, + opex_energy_cost_in_euro=opex_energy_cost_per_simulated_period_in_euro, opex_maintenance_cost_in_euro=0, # TODO: needs o be implemented still co2_footprint_in_kg=co2_per_simulated_period_in_kg, - consumption_in_kwh=gas_consumption_in_kilowatt_hour, - loadtype=lt.LoadTypes.GAS, - kpi_tag=KpiTagEnumClass.GAS_HEATER_DOMESTIC_HOT_WATER + consumption_in_kwh=fuel_consumption_in_kilowatt_hour, + loadtype=output.load_type, + kpi_tag=kpi_tag, ) else: opex_cost_data_class = OpexCostDataClass.get_default_opex_cost_data_class() return opex_cost_data_class - def get_component_kpi_entries( - self, - all_outputs: List, - postprocessing_results: pd.DataFrame, - ) -> List[KpiEntry]: + def get_component_kpi_entries(self, all_outputs: List, postprocessing_results: pd.DataFrame,) -> List[KpiEntry]: """Calculates KPIs for the respective component and return all KPI entries as list.""" - gas_consumption_in_kilowatt_hour: Optional[float] = None + # gas_consumption_in_kilowatt_hour: Optional[float] = None list_of_kpi_entries: List[KpiEntry] = [] - for index, output in enumerate(all_outputs): - if output.component_name == self.component_name: - if output.field_name == self.FuelDelivered and output.load_type == lt.LoadTypes.GAS: - gas_consumption_in_kilowatt_hour = round(postprocessing_results.iloc[:, index].sum() * 1e-3, 1) - break + # for index, output in enumerate(all_outputs): + # if output.component_name == self.component_name: + # if output.field_name == self.FuelDelivered and output.load_type == lt.LoadTypes.GAS: + # gas_consumption_in_kilowatt_hour = round(postprocessing_results.iloc[:, index].sum() * 1e-3, 1) + # break + # my_kpi_entry = KpiEntry( + # name="Gas consumption for domestic hot water", + # unit="kWh", + # value=gas_consumption_in_kilowatt_hour, + # tag=KpiTagEnumClass.GAS_HEATER_DOMESTIC_HOT_WATER, + # description=self.component_name, + # ) + opex_dataclass = self.get_cost_opex(all_outputs=all_outputs, postprocessing_results=postprocessing_results) my_kpi_entry = KpiEntry( - name="Gas consumption for domestic hot water", + name=f"{opex_dataclass.loadtype.value} consumption for {self.config.water_vs_heating.value}", unit="kWh", - value=gas_consumption_in_kilowatt_hour, - tag=KpiTagEnumClass.GAS_HEATER_DOMESTIC_HOT_WATER, + value=opex_dataclass.consumption_in_kwh, + tag=opex_dataclass.kpi_tag, description=self.component_name, ) diff --git a/hisim/components/heat_distribution_system.py b/hisim/components/heat_distribution_system.py index ae6abbc9f..90717e478 100644 --- a/hisim/components/heat_distribution_system.py +++ b/hisim/components/heat_distribution_system.py @@ -135,7 +135,7 @@ class HeatDistribution(cp.Component): WaterTemperatureInput = "WaterTemperatureInput" TheoreticalThermalBuildingDemand = "TheoreticalThermalBuildingDemand" ResidenceTemperatureIndoorAir = "ResidenceTemperatureIndoorAir" - WaterMassFlow = "WaterMassFlow" + WaterMassFlowInput = "WaterMassFlowInput" # Outputs WaterTemperatureInlet = "WaterTemperatureInlet" @@ -196,27 +196,15 @@ def __init__( ) self.theoretical_thermal_building_demand_channel: cp.ComponentInput = self.add_input( - self.component_name, - self.TheoreticalThermalBuildingDemand, - lt.LoadTypes.HEATING, - lt.Units.WATT, - True, + self.component_name, self.TheoreticalThermalBuildingDemand, lt.LoadTypes.HEATING, lt.Units.WATT, True, ) self.water_temperature_input_channel: cp.ComponentInput = self.add_input( - self.component_name, - self.WaterTemperatureInput, - lt.LoadTypes.WATER, - lt.Units.CELSIUS, - True, + self.component_name, self.WaterTemperatureInput, lt.LoadTypes.WATER, lt.Units.CELSIUS, True, ) self.residence_temperature_input_channel: cp.ComponentInput = self.add_input( - self.component_name, - self.ResidenceTemperatureIndoorAir, - lt.LoadTypes.TEMPERATURE, - lt.Units.CELSIUS, - True, + self.component_name, self.ResidenceTemperatureIndoorAir, lt.LoadTypes.TEMPERATURE, lt.Units.CELSIUS, True, ) if self.position_hot_water_storage_in_system in [ @@ -225,11 +213,7 @@ def __init__( ]: # just important for heating system without parallel bufferstorage self.water_mass_flow_rate_hp_in_kg_per_second_channel: cp.ComponentInput = self.add_input( - self.component_name, - self.WaterMassFlow, - lt.LoadTypes.WATER, - lt.Units.KG_PER_SEC, - True, + self.component_name, self.WaterMassFlowInput, lt.LoadTypes.WATER, lt.Units.KG_PER_SEC, True, ) # Outputs @@ -271,28 +255,21 @@ def __init__( self.add_default_connections(self.get_default_connections_from_heat_distribution_controller()) self.add_default_connections(self.get_default_connections_from_building()) + self.add_default_connections(self.get_default_connections_from_district_heating()) if self.position_hot_water_storage_in_system == PositionHotWaterStorageInSystemSetup.PARALLEL: self.add_default_connections(self.get_default_connections_from_simple_hot_water_storage()) - def get_default_connections_from_heat_distribution_controller( - self, - ): + def get_default_connections_from_heat_distribution_controller(self,): """Get heat distribution controller default connections.""" connections = [] hdsc_classname = HeatDistributionController.get_classname() connections.append( - cp.ComponentConnection( - HeatDistribution.State, - hdsc_classname, - HeatDistributionController.State, - ) + cp.ComponentConnection(HeatDistribution.State, hdsc_classname, HeatDistributionController.State,) ) return connections - def get_default_connections_from_building( - self, - ): + def get_default_connections_from_building(self,): """Get building default connections.""" connections = [] @@ -307,16 +284,12 @@ def get_default_connections_from_building( connections.append( cp.ComponentConnection( - HeatDistribution.ResidenceTemperatureIndoorAir, - building_classname, - Building.TemperatureIndoorAir, + HeatDistribution.ResidenceTemperatureIndoorAir, building_classname, Building.TemperatureIndoorAir, ) ) return connections - def get_default_connections_from_simple_hot_water_storage( - self, - ): + def get_default_connections_from_simple_hot_water_storage(self,): """Get simple hot water storage default connections.""" # use importlib for importing the other component in order to avoid circular-import errors component_module_name = "hisim.components.simple_water_storage" @@ -333,9 +306,26 @@ def get_default_connections_from_simple_hot_water_storage( ) return connections - def build( - self, - ) -> None: + def get_default_connections_from_district_heating(self,): + """Get distrct heating default connections.""" + # use importlib for importing the other component in order to avoid circular-import errors + # for district heating as heating source no + component_module_name = "hisim.components.generic_district_heating" + component_module = importlib.import_module(name=component_module_name) + component_class = getattr(component_module, "DistrictHeating") + connections = [] + classname = component_class.get_classname() + connections.append( + cp.ComponentConnection( + HeatDistribution.WaterTemperatureInput, classname, component_class.WaterOutputTemperature, + ) + ) + connections.append( + cp.ComponentConnection(HeatDistribution.WaterMassFlowInput, classname, component_class.WaterMassflowOutput,) + ) + return connections + + def build(self,) -> None: """Build function. The function sets important constants and parameters for the calculations. @@ -439,8 +429,7 @@ def i_simulate(self, timestep: int, stsv: cp.SingleTimeStepValues, force_converg # thermal_power_delivered_in_watt, ) stsv.set_output_value( - self.water_mass_flow_channel, - water_mass_flow_rate_in_kg_per_second, + self.water_mass_flow_channel, water_mass_flow_rate_in_kg_per_second, ) # write values to state @@ -449,8 +438,7 @@ def i_simulate(self, timestep: int, stsv: cp.SingleTimeStepValues, force_converg self.state.thermal_power_delivered_in_watt = thermal_power_delivered_in_watt def determine_water_temperature_input_output_effective_thermal_power_without_massflow( - self, - residence_temperature_in_celsius: float, + self, residence_temperature_in_celsius: float, ) -> Any: """Calculate cooled or heated water temperature due to free convection after heat exchange between heat distribution system and building without massflow.""" @@ -524,8 +512,7 @@ def determine_water_temperature_output_after_heat_exchange_with_building_and_eff if water_temperature_input_in_celsius > residence_temperature_in_celsius: # prevent that water output temperature in hds gets colder than residence temperature in building when heating water_temperature_output_in_celsius = max( - water_temperature_output_in_celsius, - residence_temperature_in_celsius, + water_temperature_output_in_celsius, residence_temperature_in_celsius, ) thermal_power_delivered_effective_in_watt = ( self.specific_heat_capacity_of_water_in_joule_per_kilogram_per_celsius @@ -542,8 +529,7 @@ def determine_water_temperature_output_after_heat_exchange_with_building_and_eff if water_temperature_input_in_celsius < residence_temperature_in_celsius: # prevent that water output temperature in hds gets hotter than residence temperature in building when cooling water_temperature_output_in_celsius = min( - water_temperature_output_in_celsius, - residence_temperature_in_celsius, + water_temperature_output_in_celsius, residence_temperature_in_celsius, ) thermal_power_delivered_effective_in_watt = ( self.specific_heat_capacity_of_water_in_joule_per_kilogram_per_celsius @@ -570,7 +556,9 @@ def determine_water_temperature_output_after_heat_exchange_with_building_and_eff ) @staticmethod - def get_cost_capex(config: HeatDistributionConfig, simulation_parameters: SimulationParameters) -> CapexCostDataClass: + def get_cost_capex( + config: HeatDistributionConfig, simulation_parameters: SimulationParameters + ) -> CapexCostDataClass: """Returns investment cost, CO2 emissions and lifetime.""" seconds_per_year = 365 * 24 * 60 * 60 capex_per_simulated_period = (config.cost / config.lifetime) * ( @@ -586,15 +574,11 @@ def get_cost_capex(config: HeatDistributionConfig, simulation_parameters: Simula lifetime_in_years=config.lifetime, capex_investment_cost_for_simulated_period_in_euro=capex_per_simulated_period, device_co2_footprint_for_simulated_period_in_kg=device_co2_footprint_per_simulated_period, - kpi_tag=KpiTagEnumClass.HEAT_DISTRIBUTION_SYSTEM + kpi_tag=KpiTagEnumClass.HEAT_DISTRIBUTION_SYSTEM, ) return capex_cost_data_class - def get_cost_opex( - self, - all_outputs: List, - postprocessing_results: pd.DataFrame, - ) -> OpexCostDataClass: + def get_cost_opex(self, all_outputs: List, postprocessing_results: pd.DataFrame,) -> OpexCostDataClass: # pylint: disable=unused-argument """Calculate OPEX costs, consisting of maintenance costs for Heat Distribution System.""" opex_cost_data_class = OpexCostDataClass( @@ -603,16 +587,12 @@ def get_cost_opex( co2_footprint_in_kg=0, consumption_in_kwh=0, loadtype=lt.LoadTypes.ANY, - kpi_tag=KpiTagEnumClass.HEAT_DISTRIBUTION_SYSTEM + kpi_tag=KpiTagEnumClass.HEAT_DISTRIBUTION_SYSTEM, ) return opex_cost_data_class - def get_component_kpi_entries( - self, - all_outputs: List, - postprocessing_results: pd.DataFrame, - ) -> List[KpiEntry]: + def get_component_kpi_entries(self, all_outputs: List, postprocessing_results: pd.DataFrame,) -> List[KpiEntry]: """Calculates KPIs for the respective component and return all KPI entries as list.""" thermal_output_energy_in_kilowatt_hour: Optional[float] = None @@ -866,18 +846,10 @@ def __init__( # Inputs self.theoretical_thermal_building_demand_channel: cp.ComponentInput = self.add_input( - self.component_name, - self.TheoreticalThermalBuildingDemand, - lt.LoadTypes.HEATING, - lt.Units.WATT, - True, + self.component_name, self.TheoreticalThermalBuildingDemand, lt.LoadTypes.HEATING, lt.Units.WATT, True, ) self.daily_avg_outside_temperature_input_channel: cp.ComponentInput = self.add_input( - self.component_name, - self.DailyAverageOutsideTemperature, - lt.LoadTypes.TEMPERATURE, - lt.Units.CELSIUS, - True, + self.component_name, self.DailyAverageOutsideTemperature, lt.LoadTypes.TEMPERATURE, lt.Units.CELSIUS, True, ) self.building_temperature_modifier_channel: cp.ComponentInput = self.add_input( self.component_name, @@ -923,9 +895,7 @@ def __init__( self.add_default_connections(self.get_default_connections_from_weather()) self.add_default_connections(self.get_default_connections_from_energy_management_system()) - def get_default_connections_from_weather( - self, - ): + def get_default_connections_from_weather(self,): """Get weather default connections.""" connections = [] @@ -939,9 +909,7 @@ def get_default_connections_from_weather( ) return connections - def get_default_connections_from_building( - self, - ): + def get_default_connections_from_building(self,): """Get building default connections.""" connections = [] @@ -955,9 +923,7 @@ def get_default_connections_from_building( ) return connections - def get_default_connections_from_energy_management_system( - self, - ): + def get_default_connections_from_energy_management_system(self,): """Get energy management system default connections.""" # use importlib for importing the other component in order to avoid circular-import errors component_module_name = "hisim.components.controller_l2_energy_management_system" @@ -1040,10 +1006,8 @@ def i_simulate(self, timestep: int, stsv: cp.SingleTimeStepValues, force_converg ) self.building_temperature_modifier = stsv.get_input_value(self.building_temperature_modifier_channel) - list_of_heating_distribution_system_flow_and_return_temperatures = ( - self.calc_heat_distribution_flow_and_return_temperatures( - daily_avg_outside_temperature_in_celsius=daily_avg_outside_temperature_in_celsius - ) + list_of_heating_distribution_system_flow_and_return_temperatures = self.calc_heat_distribution_flow_and_return_temperatures( + daily_avg_outside_temperature_in_celsius=daily_avg_outside_temperature_in_celsius ) self.conditions_for_opening_or_shutting_heat_distribution( @@ -1093,8 +1057,7 @@ def i_simulate(self, timestep: int, stsv: cp.SingleTimeStepValues, force_converg ) def conditions_for_opening_or_shutting_heat_distribution( - self, - theoretical_thermal_building_demand_in_watt: float, + self, theoretical_thermal_building_demand_in_watt: float, ) -> None: """Set conditions for the valve in heat distribution.""" @@ -1115,9 +1078,7 @@ def conditions_for_opening_or_shutting_heat_distribution( raise ValueError("unknown hds controller mode.") def summer_heating_condition( - self, - daily_average_outside_temperature_in_celsius: float, - set_heating_threshold_temperature_in_celsius: float, + self, daily_average_outside_temperature_in_celsius: float, set_heating_threshold_temperature_in_celsius: float, ) -> str: """Set conditions for the valve in heat distribution.""" @@ -1214,26 +1175,20 @@ def calc_heat_distribution_flow_and_return_temperatures( return list_of_heating_flow_and_return_temperature_in_celsius - def get_cost_opex( - self, - all_outputs: List, - postprocessing_results: pd.DataFrame, - ) -> cp.OpexCostDataClass: + def get_cost_opex(self, all_outputs: List, postprocessing_results: pd.DataFrame,) -> cp.OpexCostDataClass: """Calculate OPEX costs, consisting of electricity costs and revenues.""" opex_cost_data_class = cp.OpexCostDataClass.get_default_opex_cost_data_class() return opex_cost_data_class @staticmethod - def get_cost_capex(config: HeatDistributionControllerConfig, simulation_parameters: SimulationParameters) -> CapexCostDataClass: # pylint: disable=unused-argument + def get_cost_capex( + config: HeatDistributionControllerConfig, simulation_parameters: SimulationParameters + ) -> CapexCostDataClass: # pylint: disable=unused-argument """Returns investment cost, CO2 emissions and lifetime.""" capex_cost_data_class = CapexCostDataClass.get_default_capex_cost_data_class() return capex_cost_data_class - def get_component_kpi_entries( - self, - all_outputs: List, - postprocessing_results: pd.DataFrame, - ) -> List[KpiEntry]: + def get_component_kpi_entries(self, all_outputs: List, postprocessing_results: pd.DataFrame,) -> List[KpiEntry]: """Calculates KPIs for the respective component and return all KPI entries as list.""" return [] @@ -1318,10 +1273,7 @@ def prepare_calc_heating_dist_temperature( self.max_flow_temperature_in_celsius - self.max_return_temperature_in_celsius ) - def calc_heating_distribution_system_water_mass_flow_rate( - self, - max_thermal_building_demand_in_watt: float, - ) -> Any: + def calc_heating_distribution_system_water_mass_flow_rate(self, max_thermal_building_demand_in_watt: float,) -> Any: """Calculate water mass flow between heating distribution system and hot water storage.""" specific_heat_capacity_of_water_in_joule_per_kg_per_celsius = ( PhysicsConfig.water_specific_heat_capacity_in_joule_per_kilogram_per_kelvin diff --git a/hisim/modular_household/component_connections.py b/hisim/modular_household/component_connections.py index de4f71131..a865dd2f0 100644 --- a/hisim/modular_household/component_connections.py +++ b/hisim/modular_household/component_connections.py @@ -464,7 +464,12 @@ def configure_water_heating( lt.HeatingSystems.OIL_HEATING: lt.LoadTypes.OIL, lt.HeatingSystems.DISTRICT_HEATING: lt.LoadTypes.DISTRICTHEATING, } - heater_config = generic_heat_source.HeatSourceConfig.get_default_config_waterheating_with_district_heating() + heater_config = generic_heat_source.HeatSourceConfig.get_default_config_waterheating( + heating_system=water_heating_system_installed, + max_warm_water_demand_in_liter=my_occupancy.max_hot_water_demand, + scaling_factor_according_to_number_of_apartments=my_occupancy.scaling_factor_according_to_number_of_apartments, + seconds_per_timestep=my_simulation_parameters.seconds_per_timestep, + ) heater_config.fuel = fuel_translator[water_heating_system_installed] heater_config.efficiency = get_heating_system_efficiency( heating_system_installed=water_heating_system_installed, water_vs_heating=lt.InandOutputType.HEATING diff --git a/hisim/postprocessing/kpi_computation/kpi_structure.py b/hisim/postprocessing/kpi_computation/kpi_structure.py index cf192aedb..d1181e39e 100644 --- a/hisim/postprocessing/kpi_computation/kpi_structure.py +++ b/hisim/postprocessing/kpi_computation/kpi_structure.py @@ -40,7 +40,11 @@ class KpiTagEnumClass(Enum): COSTS_DISTRICT_GRID = "Costs Of District Grid" EMISSIONS_DISTRICT_GRID = "Emissions Of District Grid" CONTRACTING = "Contracting" - GENERIC_HEAT_SOURCE = "Generic Heat Source" + OIL_HEATER_SPACE_HEATING = "Oil Heater For Space Heating" + OIL_HEATER_DOMESTIC_HOT_WATER = "Oil Heater For Domestic Hot Water" + DISTRICT_HEATING_SPACE_HEATING = "District Heating For Space Heating" + DISTRICT_HEATING_DOMESTIC_HOT_WATER = "District Heating For Domestic Hot Water" + GENERIC_HEAT_SOURCE = "Generic Heat Source" # used in simple_heat_source.py @dataclass diff --git a/system_setups/air_conditioned_house_a_with_mpc_controller.py b/system_setups/air_conditioned_house_a_with_mpc_controller.py index ec62b44b9..d84611025 100644 --- a/system_setups/air_conditioned_house_a_with_mpc_controller.py +++ b/system_setups/air_conditioned_house_a_with_mpc_controller.py @@ -33,9 +33,7 @@ def setup_function(my_sim: Simulator, my_simulation_parameters: Optional[Simulat def air_conditioned_house( - my_sim: Simulator, - control: str, - my_simulation_parameters: Optional[SimulationParameters] = None, + my_sim: Simulator, control: str, my_simulation_parameters: Optional[SimulationParameters] = None, ) -> None: """Household Model. @@ -228,10 +226,7 @@ def air_conditioned_house( enable_opening_windows=enable_opening_windows, max_thermal_building_demand_in_watt=None, ) - my_building = building.Building( - config=my_building_config, - my_simulation_parameters=my_simulation_parameters, - ) + my_building = building.Building(config=my_building_config, my_simulation_parameters=my_simulation_parameters,) """ Occupancy Profile """ my_occupancy_config = loadprofilegenerator_utsp_connector.UtspLpgConnectorConfig.get_default_utsp_connector_config() @@ -240,8 +235,7 @@ def air_conditioned_house( my_occupancy_config.predictive = predictive my_occupancy = loadprofilegenerator_utsp_connector.UtspLpgConnector( - config=my_occupancy_config, - my_simulation_parameters=my_simulation_parameters, + config=my_occupancy_config, my_simulation_parameters=my_simulation_parameters, ) my_sim.add_component(my_occupancy) @@ -249,10 +243,7 @@ def air_conditioned_house( my_weather_config = weather.WeatherConfig.get_default(location_entry=weather.LocationEnum.SEVILLE) my_weather_config.predictive_control = predictive_control - my_weather = weather.Weather( - config=my_weather_config, - my_simulation_parameters=my_simulation_parameters, - ) + my_weather = weather.Weather(config=my_weather_config, my_simulation_parameters=my_simulation_parameters,) my_sim.add_component(my_weather) """Photovoltaic System""" @@ -278,11 +269,10 @@ def air_conditioned_house( predictive=predictive, prediction_horizon=prediction_horizon, predictive_control=predictive_control, - share_of_maximum_pv_potential=1.0 + share_of_maximum_pv_potential=1.0, ) my_photovoltaic_system = generic_pv_system.PVSystem( - config=my_photovoltaic_system_config, - my_simulation_parameters=my_simulation_parameters, + config=my_photovoltaic_system_config, my_simulation_parameters=my_simulation_parameters, ) my_photovoltaic_system.connect_only_predefined_connections(my_weather) my_sim.add_component(my_photovoltaic_system) @@ -306,8 +296,7 @@ def air_conditioned_house( predictive_control=predictive_control, ) my_price_signal = generic_price_signal.PriceSignal( - config=my_price_signal_config, - my_simulation_parameters=my_simulation_parameters, + config=my_price_signal_config, my_simulation_parameters=my_simulation_parameters, ) my_sim.add_component(my_price_signal) @@ -322,18 +311,13 @@ def air_conditioned_house( control=control, ) my_air_conditioner = air_conditioner.AirConditioner( - config=my_air_conditioner_config, - my_simulation_parameters=my_simulation_parameters, + config=my_air_conditioner_config, my_simulation_parameters=my_simulation_parameters, ) my_air_conditioner.connect_input( - my_air_conditioner.TemperatureOutside, - my_weather.component_name, - my_weather.TemperatureOutside, + my_air_conditioner.TemperatureOutside, my_weather.component_name, my_weather.TemperatureOutside, ) my_air_conditioner.connect_input( - my_air_conditioner.TemperatureMean, - my_building.component_name, - my_building.TemperatureMeanThermalMass, + my_air_conditioner.TemperatureMean, my_building.component_name, my_building.TemperatureMeanThermalMass, ) my_sim.add_component(my_air_conditioner) @@ -349,8 +333,7 @@ def air_conditioned_house( predictive=predictive, ) my_battery = generic_battery.GenericBattery( - config=my_battery_config, - my_simulation_parameters=my_simulation_parameters, + config=my_battery_config, my_simulation_parameters=my_simulation_parameters, ) my_sim.add_component(my_battery) @@ -410,19 +393,14 @@ def air_conditioned_house( ) my_mpc_controller = controller_mpc.MpcController( - config=my_mpc_controller_config, - my_simulation_parameters=my_simulation_parameters, + config=my_mpc_controller_config, my_simulation_parameters=my_simulation_parameters, ) my_mpc_controller.connect_input( - my_mpc_controller.TemperatureMean, - my_building.component_name, - my_building.TemperatureMeanThermalMass, + my_mpc_controller.TemperatureMean, my_building.component_name, my_building.TemperatureMeanThermalMass, ) my_sim.add_component(my_mpc_controller) my_battery.connect_input( - my_battery.State, - my_mpc_controller.component_name, - my_mpc_controller.BatteryControlState, + my_battery.State, my_mpc_controller.component_name, my_mpc_controller.BatteryControlState, ) my_battery.connect_input( my_battery.ElectricityInput, @@ -430,42 +408,29 @@ def air_conditioned_house( my_mpc_controller.BatteryChargingDischargingPower, ) my_battery.connect_input( - my_battery.ElectricityInput, - my_mpc_controller.component_name, - my_mpc_controller.Battery2Load, + my_battery.ElectricityInput, my_mpc_controller.component_name, my_mpc_controller.Battery2Load, ) """PID controller""" # pid if control == "PID": my_pid_controller_config = controller_pid.PIDControllerConfig.get_default_config() pid_controller = controller_pid.PIDController( - config=my_pid_controller_config, - my_simulation_parameters=my_simulation_parameters, + config=my_pid_controller_config, my_simulation_parameters=my_simulation_parameters, ) pid_controller.connect_input( - pid_controller.TemperatureMean, - my_building.component_name, - my_building.TemperatureMeanThermalMass, + pid_controller.TemperatureMean, my_building.component_name, my_building.TemperatureMeanThermalMass, ) pid_controller.connect_input( - pid_controller.HeatFluxThermalMassNode, - my_building.component_name, - my_building.HeatFluxThermalMassNode, + pid_controller.HeatFluxThermalMassNode, my_building.component_name, my_building.HeatFluxThermalMassNode, ) pid_controller.connect_input( - pid_controller.HeatFluxWallNode, - my_building.component_name, - my_building.HeatFluxWallNode, + pid_controller.HeatFluxWallNode, my_building.component_name, my_building.HeatFluxWallNode, ) my_air_conditioner.connect_input( - my_air_conditioner.FeedForwardSignal, - pid_controller.component_name, - pid_controller.FeedForwardSignal, + my_air_conditioner.FeedForwardSignal, pid_controller.component_name, pid_controller.FeedForwardSignal, ) my_air_conditioner.connect_input( - my_air_conditioner.ThermalPowerPID, - pid_controller.component_name, - pid_controller.ThermalPowerPID, + my_air_conditioner.ThermalPowerPID, pid_controller.component_name, pid_controller.ThermalPowerPID, ) my_sim.add_component(pid_controller) @@ -517,7 +482,5 @@ def air_conditioned_house( # ) my_building.connect_input( - my_building.ThermalPowerDelivered, - my_air_conditioner.component_name, - my_air_conditioner.ThermalEnergyDelivered, + my_building.ThermalPowerDelivered, my_air_conditioner.component_name, my_air_conditioner.ThermalEnergyDelivered, ) diff --git a/system_setups/air_conditioned_house_b_with_pid_controller.py b/system_setups/air_conditioned_house_b_with_pid_controller.py index a9ceaf908..83b34a777 100644 --- a/system_setups/air_conditioned_house_b_with_pid_controller.py +++ b/system_setups/air_conditioned_house_b_with_pid_controller.py @@ -3,9 +3,7 @@ # clean from typing import Optional -from system_setups.air_conditioned_house_a_with_mpc_controller import ( - air_conditioned_house, -) +from system_setups.air_conditioned_house_a_with_mpc_controller import air_conditioned_house from hisim.simulator import SimulationParameters from hisim.simulator import Simulator diff --git a/system_setups/air_conditioned_house_c_with_onoff_controller.py b/system_setups/air_conditioned_house_c_with_onoff_controller.py index ee1fa5b20..28fa1bc1a 100644 --- a/system_setups/air_conditioned_house_c_with_onoff_controller.py +++ b/system_setups/air_conditioned_house_c_with_onoff_controller.py @@ -3,9 +3,7 @@ # clean from typing import Optional -from system_setups.air_conditioned_house_a_with_mpc_controller import ( - air_conditioned_house, -) +from system_setups.air_conditioned_house_a_with_mpc_controller import air_conditioned_house from hisim.simulator import SimulationParameters from hisim.simulator import Simulator diff --git a/system_setups/automatic_default_connections.py b/system_setups/automatic_default_connections.py index 259511cf9..def4a2a59 100644 --- a/system_setups/automatic_default_connections.py +++ b/system_setups/automatic_default_connections.py @@ -87,8 +87,7 @@ def setup_function(my_sim: Any, my_simulation_parameters: Optional[SimulationPar rooftop_area_in_m2=my_building_information.scaled_rooftop_area_in_m2 ) my_photovoltaic_system = generic_pv_system.PVSystem( - config=my_photovoltaic_system_config, - my_simulation_parameters=my_simulation_parameters, + config=my_photovoltaic_system_config, my_simulation_parameters=my_simulation_parameters, ) # ================================================================================================================================= # Build Energy System Components @@ -102,8 +101,7 @@ def setup_function(my_sim: Any, my_simulation_parameters: Optional[SimulationPar ) my_heat_distribution_controller = heat_distribution_system.HeatDistributionController( - my_simulation_parameters=my_simulation_parameters, - config=my_heat_distribution_controller_config, + my_simulation_parameters=my_simulation_parameters, config=my_heat_distribution_controller_config, ) my_hds_controller_information = heat_distribution_system.HeatDistributionControllerInformation( config=my_heat_distribution_controller_config @@ -124,18 +122,16 @@ def setup_function(my_sim: Any, my_simulation_parameters: Optional[SimulationPar ) my_heat_pump = advanced_heat_pump_hplib.HeatPumpHplib( - config=my_heat_pump_config, - my_simulation_parameters=my_simulation_parameters, + config=my_heat_pump_config, my_simulation_parameters=my_simulation_parameters, ) # Build Heat Distribution System my_heat_distribution_system_config = heat_distribution_system.HeatDistributionConfig.get_default_heatdistributionsystem_config( water_mass_flow_rate_in_kg_per_second=my_hds_controller_information.water_mass_flow_rate_in_kp_per_second, - absolute_conditioned_floor_area_in_m2=my_building_information.scaled_conditioned_floor_area_in_m2 + absolute_conditioned_floor_area_in_m2=my_building_information.scaled_conditioned_floor_area_in_m2, ) my_heat_distribution_system = heat_distribution_system.HeatDistribution( - config=my_heat_distribution_system_config, - my_simulation_parameters=my_simulation_parameters, + config=my_heat_distribution_system_config, my_simulation_parameters=my_simulation_parameters, ) # Build Heat Water Storage @@ -145,8 +141,7 @@ def setup_function(my_sim: Any, my_simulation_parameters: Optional[SimulationPar sizing_option=simple_water_storage.HotWaterStorageSizingEnum.SIZE_ACCORDING_TO_HEAT_PUMP, ) my_simple_hot_water_storage = simple_water_storage.SimpleHotWaterStorage( - config=my_simple_heat_water_storage_config, - my_simulation_parameters=my_simulation_parameters, + config=my_simple_heat_water_storage_config, my_simulation_parameters=my_simulation_parameters, ) # Build DHW (this is taken from household_3_advanced_hp_diesel-car_pv_battery.py) @@ -154,16 +149,12 @@ def setup_function(my_sim: Any, my_simulation_parameters: Optional[SimulationPar number_of_apartments=my_building_information.number_of_apartments ) - my_dhw_heatpump_controller_config = ( - controller_l1_heatpump.L1HeatPumpConfig.get_default_config_heat_source_controller_dhw( - name="DHWHeatpumpController" - ) + my_dhw_heatpump_controller_config = controller_l1_heatpump.L1HeatPumpConfig.get_default_config_heat_source_controller_dhw( + name="DHWHeatpumpController" ) - my_dhw_storage_config = ( - generic_hot_water_storage_modular.StorageConfig.get_scaled_config_for_boiler_to_number_of_apartments( - number_of_apartments=my_building_information.number_of_apartments - ) + my_dhw_storage_config = generic_hot_water_storage_modular.StorageConfig.get_scaled_config_for_boiler_to_number_of_apartments( + number_of_apartments=my_building_information.number_of_apartments ) my_dhw_storage_config.compute_default_cycle( temperature_difference_in_kelvin=my_dhw_heatpump_controller_config.t_max_heating_in_celsius @@ -175,8 +166,7 @@ def setup_function(my_sim: Any, my_simulation_parameters: Optional[SimulationPar ) my_domnestic_hot_water_heatpump_controller = controller_l1_heatpump.L1HeatPumpController( - my_simulation_parameters=my_simulation_parameters, - config=my_dhw_heatpump_controller_config, + my_simulation_parameters=my_simulation_parameters, config=my_dhw_heatpump_controller_config, ) my_domnestic_hot_water_heatpump = generic_heat_pump_modular.ModularHeatPump( diff --git a/system_setups/basic_household.py b/system_setups/basic_household.py index aa7fed57a..5be447430 100644 --- a/system_setups/basic_household.py +++ b/system_setups/basic_household.py @@ -81,8 +81,7 @@ def setup_function( my_photovoltaic_system_config = generic_pv_system.PVSystemConfig.get_default_pv_system() my_photovoltaic_system = generic_pv_system.PVSystem( - config=my_photovoltaic_system_config, - my_simulation_parameters=my_simulation_parameters, + config=my_photovoltaic_system_config, my_simulation_parameters=my_simulation_parameters, ) # Build Electricity Meter @@ -121,10 +120,7 @@ def setup_function( source_component_output=my_photovoltaic_system.ElectricityOutput, source_load_type=loadtypes.LoadTypes.ELECTRICITY, source_unit=loadtypes.Units.WATT, - source_tags=[ - loadtypes.ComponentType.PV, - loadtypes.InandOutputType.ELECTRICITY_PRODUCTION, - ], + source_tags=[loadtypes.ComponentType.PV, loadtypes.InandOutputType.ELECTRICITY_PRODUCTION,], source_weight=999, ) @@ -152,9 +148,7 @@ def setup_function( my_building.connect_only_predefined_connections(my_weather, my_occupancy) my_building.connect_input( - my_building.ThermalPowerDelivered, - my_heat_pump.component_name, - my_heat_pump.ThermalPowerDelivered, + my_building.ThermalPowerDelivered, my_heat_pump.component_name, my_heat_pump.ThermalPowerDelivered, ) my_heat_pump_controller.connect_only_predefined_connections(my_building) diff --git a/system_setups/basic_household_only_heating.py b/system_setups/basic_household_only_heating.py index 80ba0a16b..4793e33f7 100644 --- a/system_setups/basic_household_only_heating.py +++ b/system_setups/basic_household_only_heating.py @@ -104,9 +104,7 @@ def setup_function(my_sim: Any, my_simulation_parameters: Optional[SimulationPar my_building.connect_only_predefined_connections(my_weather, my_occupancy) my_building.connect_input( - my_building.ThermalPowerDelivered, - my_storage.component_name, - my_storage.RealHeatForBuilding, + my_building.ThermalPowerDelivered, my_storage.component_name, my_storage.RealHeatForBuilding, ) my_storage.connect_input( @@ -120,9 +118,7 @@ def setup_function(my_sim: Any, my_simulation_parameters: Optional[SimulationPar my_controller_heat.ControlSignalChooseStorage, ) my_storage.connect_input( - my_storage.ThermalInputPower1, - my_gas_heater.component_name, - my_gas_heater.ThermalOutputPower, + my_storage.ThermalInputPower1, my_gas_heater.component_name, my_gas_heater.ThermalOutputPower, ) my_storage_controller.connect_input( @@ -131,9 +127,7 @@ def setup_function(my_sim: Any, my_simulation_parameters: Optional[SimulationPar my_storage.WaterOutputTemperatureHeatingWater, ) my_storage_controller.connect_input( - my_storage_controller.BuildingTemperature, - my_building.component_name, - my_building.TemperatureMeanThermalMass, + my_storage_controller.BuildingTemperature, my_building.component_name, my_building.TemperatureMeanThermalMass, ) # my_storage_controller.connect_input( # my_storage_controller.ReferenceMaxHeatBuildingDemand, @@ -150,20 +144,14 @@ def setup_function(my_sim: Any, my_simulation_parameters: Optional[SimulationPar ) my_controller_heat.connect_input( - my_controller_heat.ResidenceTemperature, - my_building.component_name, - my_building.TemperatureMeanThermalMass, + my_controller_heat.ResidenceTemperature, my_building.component_name, my_building.TemperatureMeanThermalMass, ) my_gas_heater.connect_input( - my_gas_heater.ControlSignal, - my_controller_heat.component_name, - my_controller_heat.ControlSignalGasHeater, + my_gas_heater.ControlSignal, my_controller_heat.component_name, my_controller_heat.ControlSignalGasHeater, ) my_gas_heater.connect_input( - my_gas_heater.MassflowInputTemperature, - my_storage.component_name, - my_storage.WaterOutputStorageforHeaters, + my_gas_heater.MassflowInputTemperature, my_storage.component_name, my_storage.WaterOutputStorageforHeaters, ) # ================================================================================================================================= diff --git a/system_setups/basic_household_with_weather_data_request.py b/system_setups/basic_household_with_weather_data_request.py index 3e28b12a1..419aff1b0 100644 --- a/system_setups/basic_household_with_weather_data_request.py +++ b/system_setups/basic_household_with_weather_data_request.py @@ -111,20 +111,16 @@ def setup_function( location=location, source_path=weather_data_import.csv_path, data_source=weather_data_import.weather_data_source, - predictive_control=False, ) - - my_weather = weather.Weather( - config=my_weather_config, my_simulation_parameters=my_simulation_parameters + predictive_control=False, ) + my_weather = weather.Weather(config=my_weather_config, my_simulation_parameters=my_simulation_parameters) + # Build PV - my_photovoltaic_system_config = ( - generic_pv_system.PVSystemConfig.get_default_pv_system() - ) + my_photovoltaic_system_config = generic_pv_system.PVSystemConfig.get_default_pv_system() my_photovoltaic_system = generic_pv_system.PVSystem( - config=my_photovoltaic_system_config, - my_simulation_parameters=my_simulation_parameters, + config=my_photovoltaic_system_config, my_simulation_parameters=my_simulation_parameters, ) # Build Electricity Meter @@ -163,10 +159,7 @@ def setup_function( source_component_output=my_photovoltaic_system.ElectricityOutput, source_load_type=loadtypes.LoadTypes.ELECTRICITY, source_unit=loadtypes.Units.WATT, - source_tags=[ - loadtypes.ComponentType.PV, - loadtypes.InandOutputType.ELECTRICITY_PRODUCTION, - ], + source_tags=[loadtypes.ComponentType.PV, loadtypes.InandOutputType.ELECTRICITY_PRODUCTION,], source_weight=999, ) @@ -194,9 +187,7 @@ def setup_function( my_building.connect_only_predefined_connections(my_weather, my_occupancy) my_building.connect_input( - my_building.ThermalPowerDelivered, - my_heat_pump.component_name, - my_heat_pump.ThermalPowerDelivered, + my_building.ThermalPowerDelivered, my_heat_pump.component_name, my_heat_pump.ThermalPowerDelivered, ) my_heat_pump_controller.connect_only_predefined_connections(my_building) @@ -206,9 +197,7 @@ def setup_function( my_electricity_meter.component_name, my_electricity_meter.ElectricityAvailable, ) - my_heat_pump.connect_only_predefined_connections( - my_weather, my_heat_pump_controller - ) + my_heat_pump.connect_only_predefined_connections(my_weather, my_heat_pump_controller) my_heat_pump.get_default_connections_heatpump_controller() # ================================================================================================================================= # Add Components to Simulation Parameters diff --git a/system_setups/decentralized_energy_netw_pv_bat_hydro_system_hp_pem.py b/system_setups/decentralized_energy_netw_pv_bat_hydro_system_hp_pem.py index f6049478e..6fe7d083c 100644 --- a/system_setups/decentralized_energy_netw_pv_bat_hydro_system_hp_pem.py +++ b/system_setups/decentralized_energy_netw_pv_bat_hydro_system_hp_pem.py @@ -101,7 +101,9 @@ def setup_function( my_fuel_cell_controller_l2 = XTPController( my_simulation_parameters=my_simulation_parameters, - config=XTPControllerConfig.control_fuel_cell(fuel_cell_name=fuel_cell_name, operation_mode=operation_mode, building_name="BUI1",), + config=XTPControllerConfig.control_fuel_cell( + fuel_cell_name=fuel_cell_name, operation_mode=operation_mode, building_name="BUI1", + ), ) my_fuel_cell_controller = FuelCellController( my_simulation_parameters=my_simulation_parameters, @@ -115,9 +117,7 @@ def setup_function( my_electrolyzer_controller_l2 = PTXController( my_simulation_parameters=my_simulation_parameters, config=PTXControllerConfig.control_electrolyzer( - building_name="BUI1", - electrolyzer_name=electrolyzer_name, - operation_mode=operation_mode, + building_name="BUI1", electrolyzer_name=electrolyzer_name, operation_mode=operation_mode, ), ) # buffer bat test end @@ -153,8 +153,7 @@ def setup_function( my_photovoltaic_system_config.cost = pv_cost my_photovoltaic_system = generic_pv_system.PVSystem( - my_simulation_parameters=my_simulation_parameters, - config=my_photovoltaic_system_config, + my_simulation_parameters=my_simulation_parameters, config=my_photovoltaic_system_config, ) my_photovoltaic_system.connect_only_predefined_connections(my_weather) # hp test start @@ -180,7 +179,7 @@ def setup_function( set_heating_temperature_in_celsius=19.0, set_cooling_temperature_in_celsius=24.0, enable_opening_windows=False, - max_thermal_building_demand_in_watt=None + max_thermal_building_demand_in_watt=None, ), my_simulation_parameters=my_simulation_parameters, ) @@ -232,10 +231,7 @@ def setup_function( source_component_output=my_heat_pump.ElectricityOutput, source_load_type=lt.LoadTypes.ELECTRICITY, source_unit=lt.Units.WATT, - source_tags=[ - lt.ComponentType.HEAT_PUMP, - lt.InandOutputType.ELECTRICITY_CONSUMPTION_UNCONTROLLED, - ], + source_tags=[lt.ComponentType.HEAT_PUMP, lt.InandOutputType.ELECTRICITY_CONSUMPTION_UNCONTROLLED,], source_weight=999, ) @@ -243,16 +239,12 @@ def setup_function( my_building.connect_only_predefined_connections(my_occupancy) my_building.connect_input( - my_building.ThermalPowerDelivered, - my_heat_pump.component_name, - my_heat_pump.ThermalPowerDelivered, + my_building.ThermalPowerDelivered, my_heat_pump.component_name, my_heat_pump.ThermalPowerDelivered, ) my_heat_pump_controller.connect_only_predefined_connections(my_building) my_heat_pump_controller.connect_input( - my_heat_pump_controller.ElectricityInput, - my_cl2.component_name, - my_cl2.TotalElectricityToOrFromGrid, + my_heat_pump_controller.ElectricityInput, my_cl2.component_name, my_cl2.TotalElectricityToOrFromGrid, ) my_heat_pump.connect_only_predefined_connections(my_weather, my_heat_pump_controller) my_heat_pump.get_default_connections_heatpump_controller() @@ -272,10 +264,7 @@ def setup_function( source_component_output=my_electrolyzer.CurrentLoad, source_load_type=lt.LoadTypes.ELECTRICITY, source_unit=lt.Units.WATT, - source_tags=[ - lt.ComponentType.ELECTROLYZER, - lt.InandOutputType.ELECTRICITY_CONSUMPTION_EMS_CONTROLLED, - ], + source_tags=[lt.ComponentType.ELECTROLYZER, lt.InandOutputType.ELECTRICITY_CONSUMPTION_EMS_CONTROLLED,], source_weight=1, ) @@ -289,18 +278,14 @@ def setup_function( ) electricity_to_electrolyzer_target = my_cl2.add_component_output( source_output_name=lt.InandOutputType.ELECTRICITY_TARGET, - source_tags=[ - lt.ComponentType.ELECTROLYZER, - lt.InandOutputType.ELECTRICITY_TARGET, - ], + source_tags=[lt.ComponentType.ELECTROLYZER, lt.InandOutputType.ELECTRICITY_TARGET,], source_weight=1, source_load_type=lt.LoadTypes.ELECTRICITY, source_unit=lt.Units.WATT, output_description="Target electricity to electrolyzer. ", ) my_fuel_cell_controller_l2.connect_dynamic_input( - input_fieldname=my_fuel_cell_controller_l2.DemandLoad, - src_object=electricity_from_fuel_cell_target_1, + input_fieldname=my_fuel_cell_controller_l2.DemandLoad, src_object=electricity_from_fuel_cell_target_1, ) my_fuel_cell_controller.connect_input( input_fieldname=my_fuel_cell_controller.DemandProfile, @@ -309,8 +294,7 @@ def setup_function( ) # buffer bat test start my_electrolyzer_controller_l2.connect_dynamic_input( - input_fieldname=my_electrolyzer_controller_l2.RESLoad, - src_object=electricity_to_electrolyzer_target, + input_fieldname=my_electrolyzer_controller_l2.RESLoad, src_object=electricity_to_electrolyzer_target, ) my_electrolyzer_controller.connect_input( input_fieldname=my_electrolyzer_controller.ProvidedLoad, @@ -321,14 +305,10 @@ def setup_function( # buffer bat test end my_fuel_cell.connect_input( - my_fuel_cell.DemandProfile, - my_fuel_cell_controller.component_name, - my_fuel_cell_controller.PowerTarger, + my_fuel_cell.DemandProfile, my_fuel_cell_controller.component_name, my_fuel_cell_controller.PowerTarger, ) my_fuel_cell.connect_input( - my_fuel_cell.ControlSignal, - my_fuel_cell_controller.component_name, - my_fuel_cell_controller.CurrentMode, + my_fuel_cell.ControlSignal, my_fuel_cell_controller.component_name, my_fuel_cell_controller.CurrentMode, ) my_electrolyzer.connect_input( @@ -338,9 +318,7 @@ def setup_function( ) my_electrolyzer.connect_input( - my_electrolyzer.InputState, - my_electrolyzer_controller.component_name, - my_electrolyzer_controller.CurrentMode, + my_electrolyzer.InputState, my_electrolyzer_controller.component_name, my_electrolyzer_controller.CurrentMode, ) """ my_cl2.add_component_input_and_connect( diff --git a/system_setups/decentralized_energy_netw_pv_bat_hydro_system_hp_rsoc.py b/system_setups/decentralized_energy_netw_pv_bat_hydro_system_hp_rsoc.py index c3701a3bf..bbff08b9c 100644 --- a/system_setups/decentralized_energy_netw_pv_bat_hydro_system_hp_rsoc.py +++ b/system_setups/decentralized_energy_netw_pv_bat_hydro_system_hp_rsoc.py @@ -86,29 +86,20 @@ def setup_function(my_sim: Any, my_simulation_parameters: Optional[SimulationPar my_advanced_battery_config_1.source_weight = 1 my_advanced_battery_1 = advanced_battery_bslib.Battery( - my_simulation_parameters=my_simulation_parameters, - config=my_advanced_battery_config_1, + my_simulation_parameters=my_simulation_parameters, config=my_advanced_battery_config_1, ) # buffer bat test start my_rsoc_controller_l2 = RsocBatteryController( my_simulation_parameters=my_simulation_parameters, - config=RsocBatteryControllerConfig.confic_rsoc_name( - rsoc_name=rsoc_name, - operation_mode=operation_mode_rsoc, - ), + config=RsocBatteryControllerConfig.confic_rsoc_name(rsoc_name=rsoc_name, operation_mode=operation_mode_rsoc,), ) my_rsoc_controller_l1 = RsocController( my_simulation_parameters=my_simulation_parameters, - config=RsocControllerConfig.config_rsoc( - rsoc_name=rsoc_name, - ), + config=RsocControllerConfig.config_rsoc(rsoc_name=rsoc_name,), ) my_rsoc = Rsoc( - my_simulation_parameters=my_simulation_parameters, - config=RsocConfig.config_rsoc( - rsoc_name=rsoc_name, - ), + my_simulation_parameters=my_simulation_parameters, config=RsocConfig.config_rsoc(rsoc_name=rsoc_name,), ) # buffer bat test end @@ -134,8 +125,7 @@ def setup_function(my_sim: Any, my_simulation_parameters: Optional[SimulationPar my_photovoltaic_system_config.cost = pv_cost my_photovoltaic_system = generic_pv_system.PVSystem( - my_simulation_parameters=my_simulation_parameters, - config=my_photovoltaic_system_config, + my_simulation_parameters=my_simulation_parameters, config=my_photovoltaic_system_config, ) my_photovoltaic_system.connect_only_predefined_connections(my_weather) @@ -154,7 +144,7 @@ def setup_function(my_sim: Any, my_simulation_parameters: Optional[SimulationPar set_heating_temperature_in_celsius=19.0, set_cooling_temperature_in_celsius=24.0, enable_opening_windows=False, - max_thermal_building_demand_in_watt=None + max_thermal_building_demand_in_watt=None, ), my_simulation_parameters=my_simulation_parameters, ) @@ -207,27 +197,20 @@ def setup_function(my_sim: Any, my_simulation_parameters: Optional[SimulationPar source_component_output=my_heat_pump.ElectricityOutput, source_load_type=lt.LoadTypes.ELECTRICITY, source_unit=lt.Units.WATT, - source_tags=[ - lt.ComponentType.HEAT_PUMP, - lt.InandOutputType.ELECTRICITY_CONSUMPTION_UNCONTROLLED, - ], + source_tags=[lt.ComponentType.HEAT_PUMP, lt.InandOutputType.ELECTRICITY_CONSUMPTION_UNCONTROLLED,], source_weight=999, ) my_building.connect_only_predefined_connections(my_weather) my_building.connect_only_predefined_connections(my_occupancy) my_building.connect_input( - my_building.ThermalPowerDelivered, - my_heat_pump.component_name, - my_heat_pump.ThermalPowerDelivered, + my_building.ThermalPowerDelivered, my_heat_pump.component_name, my_heat_pump.ThermalPowerDelivered, ) my_heat_pump_controller.connect_only_predefined_connections(my_building) my_heat_pump_controller.connect_input( - my_heat_pump_controller.ElectricityInput, - my_cl2.component_name, - my_cl2.TotalElectricityToOrFromGrid, + my_heat_pump_controller.ElectricityInput, my_cl2.component_name, my_cl2.TotalElectricityToOrFromGrid, ) my_heat_pump.connect_only_predefined_connections(my_weather, my_heat_pump_controller) my_heat_pump.get_default_connections_heatpump_controller() @@ -237,10 +220,7 @@ def setup_function(my_sim: Any, my_simulation_parameters: Optional[SimulationPar source_component_output=my_rsoc.SOFCCurrentOutput, source_load_type=lt.LoadTypes.ELECTRICITY, source_unit=lt.Units.WATT, - source_tags=[ - lt.ComponentType.FUEL_CELL, - lt.InandOutputType.ELECTRICITY_PRODUCTION, - ], + source_tags=[lt.ComponentType.FUEL_CELL, lt.InandOutputType.ELECTRICITY_PRODUCTION,], source_weight=2, ) @@ -249,10 +229,7 @@ def setup_function(my_sim: Any, my_simulation_parameters: Optional[SimulationPar source_component_output=my_rsoc.SOECCurrentLoad, source_load_type=lt.LoadTypes.ELECTRICITY, source_unit=lt.Units.WATT, - source_tags=[ - lt.ComponentType.ELECTROLYZER, - lt.InandOutputType.ELECTRICITY_CONSUMPTION_EMS_CONTROLLED, - ], + source_tags=[lt.ComponentType.ELECTROLYZER, lt.InandOutputType.ELECTRICITY_CONSUMPTION_EMS_CONTROLLED,], source_weight=1, # maybe change the weigth ) @@ -266,10 +243,7 @@ def setup_function(my_sim: Any, my_simulation_parameters: Optional[SimulationPar ) electricity_to_electrolyzer_target = my_cl2.add_component_output( source_output_name=lt.InandOutputType.ELECTRICITY_TARGET, - source_tags=[ - lt.ComponentType.ELECTROLYZER, - lt.InandOutputType.ELECTRICITY_TARGET, - ], + source_tags=[lt.ComponentType.ELECTROLYZER, lt.InandOutputType.ELECTRICITY_TARGET,], source_weight=1, source_load_type=lt.LoadTypes.ELECTRICITY, source_unit=lt.Units.WATT, @@ -277,12 +251,10 @@ def setup_function(my_sim: Any, my_simulation_parameters: Optional[SimulationPar ) my_rsoc_controller_l2.connect_dynamic_input( - input_fieldname=my_rsoc_controller_l2.Demand, - src_object=electricity_from_rsofc_target_1, + input_fieldname=my_rsoc_controller_l2.Demand, src_object=electricity_from_rsofc_target_1, ) my_rsoc_controller_l2.connect_dynamic_input( - input_fieldname=my_rsoc_controller_l2.RESLoad, - src_object=electricity_to_electrolyzer_target, + input_fieldname=my_rsoc_controller_l2.RESLoad, src_object=electricity_to_electrolyzer_target, ) my_rsoc_controller_l1.connect_input( @@ -293,14 +265,10 @@ def setup_function(my_sim: Any, my_simulation_parameters: Optional[SimulationPar # buffer bat test end my_rsoc.connect_input( - my_rsoc.PowerInput, - my_rsoc_controller_l1.component_name, - my_rsoc_controller_l1.PowerVsDemand, + my_rsoc.PowerInput, my_rsoc_controller_l1.component_name, my_rsoc_controller_l1.PowerVsDemand, ) my_rsoc.connect_input( - my_rsoc.RSOCInputState, - my_rsoc_controller_l1.component_name, - my_rsoc_controller_l1.StateToRSOC, + my_rsoc.RSOCInputState, my_rsoc_controller_l1.component_name, my_rsoc_controller_l1.StateToRSOC, ) my_cl2.add_component_input_and_connect( diff --git a/system_setups/default_connections.py b/system_setups/default_connections.py index caf15c453..579fed85c 100644 --- a/system_setups/default_connections.py +++ b/system_setups/default_connections.py @@ -76,8 +76,7 @@ def setup_function(my_sim: Any, my_simulation_parameters: Optional[SimulationPar # Build PV my_photovoltaic_system_config = generic_pv_system.PVSystemConfig.get_default_pv_system() my_photovoltaic_system = generic_pv_system.PVSystem( - config=my_photovoltaic_system_config, - my_simulation_parameters=my_simulation_parameters, + config=my_photovoltaic_system_config, my_simulation_parameters=my_simulation_parameters, ) my_sim.add_component(my_photovoltaic_system) my_photovoltaic_system.connect_only_predefined_connections(my_weather) @@ -123,10 +122,7 @@ def setup_function(my_sim: Any, my_simulation_parameters: Optional[SimulationPar source_component_output=my_photovoltaic_system.ElectricityOutput, source_load_type=loadtypes.LoadTypes.ELECTRICITY, source_unit=loadtypes.Units.WATT, - source_tags=[ - loadtypes.ComponentType.PV, - loadtypes.InandOutputType.ELECTRICITY_PRODUCTION, - ], + source_tags=[loadtypes.ComponentType.PV, loadtypes.InandOutputType.ELECTRICITY_PRODUCTION,], source_weight=999, ) @@ -154,7 +150,5 @@ def setup_function(my_sim: Any, my_simulation_parameters: Optional[SimulationPar # depending on type of heating device, hard to define default connections my_building.connect_input( - my_building.ThermalPowerDelivered, - my_heat_pump.component_name, - my_heat_pump.ThermalPowerDelivered, + my_building.ThermalPowerDelivered, my_heat_pump.component_name, my_heat_pump.ThermalPowerDelivered, ) diff --git a/system_setups/district_system_setup/simple_district.py b/system_setups/district_system_setup/simple_district.py index 17e7c8292..7fcf8458a 100644 --- a/system_setups/district_system_setup/simple_district.py +++ b/system_setups/district_system_setup/simple_district.py @@ -214,12 +214,14 @@ def setup_function( else: pass - district_list.append(simple_generic_household.GenericBuilding( - my_sim=my_sim, - my_simulation_parameters=my_simulation_parameters, - config=bui_config, - location=my_config.location_district, - )) + district_list.append( + simple_generic_household.GenericBuilding( + my_sim=my_sim, + my_simulation_parameters=my_simulation_parameters, + config=bui_config, + location=my_config.location_district, + ) + ) # ================================================================================================================================= # Build districts PV @@ -249,8 +251,7 @@ def setup_function( ) my_photovoltaic_system_district = generic_pv_system.PVSystem( - config=my_photovoltaic_system_district_config, - my_simulation_parameters=my_simulation_parameters, + config=my_photovoltaic_system_district_config, my_simulation_parameters=my_simulation_parameters, ) my_sim.add_component(my_photovoltaic_system_district, connect_automatically=True) @@ -258,8 +259,7 @@ def setup_function( # Build electricity grid of district my_electricity_meter_district_config = electricity_meter.ElectricityMeterConfig( - building_name=my_config.district_name, - name="ElectricityMeter", + building_name=my_config.district_name, name="ElectricityMeter", ) my_electricity_meter_district = electricity_meter.ElectricityMeter( @@ -287,8 +287,7 @@ def setup_function( ) my_ems_district = controller_l2_district_energy_management_system.L2GenericDistrictEnergyManagementSystem( - config=my_ems_district_config, - my_simulation_parameters=my_simulation_parameters, + config=my_ems_district_config, my_simulation_parameters=my_simulation_parameters, ) my_ems_district.add_component_input_and_connect( @@ -347,9 +346,6 @@ def setup_function( source_component_output=my_photovoltaic_system_district.ElectricityOutput, source_load_type=loadtypes.LoadTypes.ELECTRICITY, source_unit=loadtypes.Units.WATT, - source_tags=[ - loadtypes.ComponentType.PV, - loadtypes.InandOutputType.ELECTRICITY_PRODUCTION, - ], + source_tags=[loadtypes.ComponentType.PV, loadtypes.InandOutputType.ELECTRICITY_PRODUCTION,], source_weight=999, ) diff --git a/system_setups/district_system_setup/simple_generic_household.py b/system_setups/district_system_setup/simple_generic_household.py index a6e17a8e3..091ebc8a4 100644 --- a/system_setups/district_system_setup/simple_generic_household.py +++ b/system_setups/district_system_setup/simple_generic_household.py @@ -161,10 +161,8 @@ def __init__( my_sim.add_component(my_building, connect_automatically=True) # Build Occupancy - my_occupancy_config = ( - loadprofilegenerator_utsp_connector.UtspLpgConnectorConfig.get_default_utsp_connector_config( - building_name=building_name, - ) + my_occupancy_config = loadprofilegenerator_utsp_connector.UtspLpgConnectorConfig.get_default_utsp_connector_config( + building_name=building_name, ) my_occupancy_config.data_acquisition_mode = loadprofilegenerator_utsp_connector.LpgDataAcquisitionMode.USE_UTSP my_occupancy_config.household = lpg_households @@ -195,8 +193,7 @@ def __init__( my_photovoltaic_system_config.tilt = tilt my_photovoltaic_system = generic_pv_system.PVSystem( - config=my_photovoltaic_system_config, - my_simulation_parameters=my_simulation_parameters, + config=my_photovoltaic_system_config, my_simulation_parameters=my_simulation_parameters, ) # Add to simulator my_sim.add_component(my_photovoltaic_system, connect_automatically=True) @@ -212,8 +209,7 @@ def __init__( # my_heat_distribution_controller_config.heating_system = heat_distribution_system.HeatDistributionSystemType.RADIATOR my_heat_distribution_controller = heat_distribution_system.HeatDistributionController( - my_simulation_parameters=my_simulation_parameters, - config=my_heat_distribution_controller_config, + my_simulation_parameters=my_simulation_parameters, config=my_heat_distribution_controller_config, ) my_hds_controller_information = heat_distribution_system.HeatDistributionControllerInformation( config=my_heat_distribution_controller_config @@ -225,17 +221,14 @@ def __init__( sizing_option = simple_water_storage.HotWaterStorageSizingEnum.SIZE_ACCORDING_TO_HEAT_PUMP # Build Heat Pump Controller - my_heat_pump_controller_config = ( - advanced_heat_pump_hplib.HeatPumpHplibControllerL1Config.get_default_generic_heat_pump_controller_config( - heat_distribution_system_type=my_hds_controller_information.heat_distribution_system_type, - building_name=building_name, - ) + my_heat_pump_controller_config = advanced_heat_pump_hplib.HeatPumpHplibControllerL1Config.get_default_generic_heat_pump_controller_config( + heat_distribution_system_type=my_hds_controller_information.heat_distribution_system_type, + building_name=building_name, ) my_heat_pump_controller_config.mode = hp_controller_mode my_heat_pump_controller = advanced_heat_pump_hplib.HeatPumpHplibController( - config=my_heat_pump_controller_config, - my_simulation_parameters=my_simulation_parameters, + config=my_heat_pump_controller_config, my_simulation_parameters=my_simulation_parameters, ) # Add to simulator my_sim.add_component(my_heat_pump_controller, connect_automatically=True) @@ -250,32 +243,24 @@ def __init__( ) my_heat_pump = advanced_heat_pump_hplib.HeatPumpHplib( - config=my_heat_pump_config, - my_simulation_parameters=my_simulation_parameters, + config=my_heat_pump_config, my_simulation_parameters=my_simulation_parameters, ) # Add to simulator my_sim.add_component(my_heat_pump, connect_automatically=True) # Build DHW (this is taken from household_3_advanced_hp_diesel-car_pv_battery.py) - my_dhw_heatpump_config = ( - generic_heat_pump_modular.HeatPumpConfig.get_scaled_waterheating_to_number_of_apartments( - number_of_apartments=my_building_information.number_of_apartments, - default_power_in_watt=6000, - building_name=building_name, - ) + my_dhw_heatpump_config = generic_heat_pump_modular.HeatPumpConfig.get_scaled_waterheating_to_number_of_apartments( + number_of_apartments=my_building_information.number_of_apartments, + default_power_in_watt=6000, + building_name=building_name, ) - my_dhw_heatpump_controller_config = ( - controller_l1_heatpump.L1HeatPumpConfig.get_default_config_heat_source_controller_dhw( - name="DHWHeatpumpController", - building_name=building_name, - ) + my_dhw_heatpump_controller_config = controller_l1_heatpump.L1HeatPumpConfig.get_default_config_heat_source_controller_dhw( + name="DHWHeatpumpController", building_name=building_name, ) - my_dhw_storage_config = ( - generic_hot_water_storage_modular.StorageConfig.get_scaled_config_for_boiler_to_number_of_apartments( - number_of_apartments=my_building_information.number_of_apartments, - default_volume_in_liter=450, - building_name=building_name, - ) + my_dhw_storage_config = generic_hot_water_storage_modular.StorageConfig.get_scaled_config_for_boiler_to_number_of_apartments( + number_of_apartments=my_building_information.number_of_apartments, + default_volume_in_liter=450, + building_name=building_name, ) my_dhw_storage_config.compute_default_cycle( temperature_difference_in_kelvin=my_dhw_heatpump_controller_config.t_max_heating_in_celsius @@ -285,8 +270,7 @@ def __init__( my_simulation_parameters=my_simulation_parameters, config=my_dhw_storage_config ) my_domnestic_hot_water_heatpump_controller = controller_l1_heatpump.L1HeatPumpController( - my_simulation_parameters=my_simulation_parameters, - config=my_dhw_heatpump_controller_config, + my_simulation_parameters=my_simulation_parameters, config=my_dhw_heatpump_controller_config, ) my_domnestic_hot_water_heatpump = generic_heat_pump_modular.ModularHeatPump( config=my_dhw_heatpump_config, my_simulation_parameters=my_simulation_parameters @@ -304,8 +288,7 @@ def __init__( building_name=building_name, ) my_simple_hot_water_storage = simple_water_storage.SimpleHotWaterStorage( - config=my_simple_heat_water_storage_config, - my_simulation_parameters=my_simulation_parameters, + config=my_simple_heat_water_storage_config, my_simulation_parameters=my_simulation_parameters, ) # Add to simulator my_sim.add_component(my_simple_hot_water_storage, connect_automatically=True) @@ -317,8 +300,7 @@ def __init__( building_name=building_name, ) my_heat_distribution_system = heat_distribution_system.HeatDistribution( - config=my_heat_distribution_system_config, - my_simulation_parameters=my_simulation_parameters, + config=my_heat_distribution_system_config, my_simulation_parameters=my_simulation_parameters, ) # Add to simulator my_sim.add_component(my_heat_distribution_system, connect_automatically=True) @@ -340,18 +322,15 @@ def __init__( ) my_electricity_controller = controller_l2_energy_management_system.L2GenericEnergyManagementSystem( - my_simulation_parameters=my_simulation_parameters, - config=my_electricity_controller_config, + my_simulation_parameters=my_simulation_parameters, config=my_electricity_controller_config, ) # Build Battery my_advanced_battery_config = advanced_battery_bslib.BatteryConfig.get_scaled_battery( - total_pv_power_in_watt_peak=my_photovoltaic_system_config.power_in_watt, - building_name=building_name, + total_pv_power_in_watt_peak=my_photovoltaic_system_config.power_in_watt, building_name=building_name, ) my_advanced_battery = advanced_battery_bslib.Battery( - my_simulation_parameters=my_simulation_parameters, - config=my_advanced_battery_config, + my_simulation_parameters=my_simulation_parameters, config=my_advanced_battery_config, ) # ----------------------------------------------------------------------------------------------------------------- @@ -387,10 +366,7 @@ def __init__( ) my_electricity_controller.add_component_output( source_output_name=f"ElectricityToOrFromGridOf{my_occupancy.get_classname()}_", - source_tags=[ - lt.ComponentType.RESIDENTS, - lt.InandOutputType.ELECTRICITY_TARGET, - ], + source_tags=[lt.ComponentType.RESIDENTS, lt.InandOutputType.ELECTRICITY_TARGET,], source_weight=1, source_load_type=lt.LoadTypes.ELECTRICITY, source_unit=lt.Units.WATT, @@ -413,10 +389,7 @@ def __init__( my_electricity_controller.add_component_output( source_output_name=f"ElectricityToOrFromGridOfDHW{my_domnestic_hot_water_heatpump.get_classname()}_", - source_tags=[ - lt.ComponentType.HEAT_PUMP_DHW, - lt.InandOutputType.ELECTRICITY_TARGET, - ], + source_tags=[lt.ComponentType.HEAT_PUMP_DHW, lt.InandOutputType.ELECTRICITY_TARGET,], source_weight=2, source_load_type=lt.LoadTypes.ELECTRICITY, source_unit=lt.Units.WATT, @@ -443,10 +416,7 @@ def __init__( my_electricity_controller.add_component_output( source_output_name=f"ElectricityToOrFromGridOfSH{my_heat_pump.get_classname()}_", - source_tags=[ - lt.ComponentType.HEAT_PUMP_BUILDING, - lt.InandOutputType.ELECTRICITY_TARGET, - ], + source_tags=[lt.ComponentType.HEAT_PUMP_BUILDING, lt.InandOutputType.ELECTRICITY_TARGET,], source_weight=3, source_load_type=lt.LoadTypes.ELECTRICITY, source_unit=lt.Units.WATT, @@ -464,10 +434,7 @@ def __init__( loading_power_input_for_battery_in_watt = my_electricity_controller.add_component_output( source_output_name=f"ElectricityToOrFrom{my_advanced_battery.get_classname()}_", - source_tags=[ - lt.ComponentType.BATTERY, - lt.InandOutputType.ELECTRICITY_TARGET, - ], + source_tags=[lt.ComponentType.BATTERY, lt.InandOutputType.ELECTRICITY_TARGET,], source_weight=5, source_load_type=lt.LoadTypes.ELECTRICITY, source_unit=lt.Units.WATT, diff --git a/system_setups/dynamic_components.py b/system_setups/dynamic_components.py index a8cd85397..2eb64e88a 100644 --- a/system_setups/dynamic_components.py +++ b/system_setups/dynamic_components.py @@ -62,12 +62,10 @@ def setup_function(my_sim: Any, my_simulation_parameters: Optional[SimulationPar my_advanced_battery_config_2.source_weight = 2 my_advanced_battery_1 = advanced_battery_bslib.Battery( - my_simulation_parameters=my_simulation_parameters, - config=my_advanced_battery_config_1, + my_simulation_parameters=my_simulation_parameters, config=my_advanced_battery_config_1, ) my_advanced_battery_2 = advanced_battery_bslib.Battery( - my_simulation_parameters=my_simulation_parameters, - config=my_advanced_battery_config_2, + my_simulation_parameters=my_simulation_parameters, config=my_advanced_battery_config_2, ) my_advanced_fuel_cell_config_1 = advanced_fuel_cell.CHPConfig.get_default_config() @@ -76,12 +74,10 @@ def setup_function(my_sim: Any, my_simulation_parameters: Optional[SimulationPar my_advanced_fuel_cell_config_2.name = "CHP2" my_advanced_fuel_cell_1 = advanced_fuel_cell.CHP( - my_simulation_parameters=my_simulation_parameters, - config=my_advanced_fuel_cell_config_1, + my_simulation_parameters=my_simulation_parameters, config=my_advanced_fuel_cell_config_1, ) my_advanced_fuel_cell_2 = advanced_fuel_cell.CHP( - my_simulation_parameters=my_simulation_parameters, - config=my_advanced_fuel_cell_config_2, + my_simulation_parameters=my_simulation_parameters, config=my_advanced_fuel_cell_config_2, ) my_cl2_config = cl2.EMSConfig.get_default_config_ems() my_cl2 = cl2.L2GenericEnergyManagementSystem( @@ -99,8 +95,7 @@ def setup_function(my_sim: Any, my_simulation_parameters: Optional[SimulationPar my_photovoltaic_system_config = generic_pv_system.PVSystemConfig.get_default_pv_system() my_photovoltaic_system = generic_pv_system.PVSystem( - my_simulation_parameters=my_simulation_parameters, - config=my_photovoltaic_system_config, + my_simulation_parameters=my_simulation_parameters, config=my_photovoltaic_system_config, ) my_photovoltaic_system.connect_only_predefined_connections(my_weather) @@ -198,12 +193,10 @@ def setup_function(my_sim: Any, my_simulation_parameters: Optional[SimulationPar ) my_advanced_fuel_cell_1.connect_dynamic_input( - input_fieldname=advanced_fuel_cell.CHP.ElectricityFromCHPTarget, - src_object=electricity_from_fuel_cell_target_1, + input_fieldname=advanced_fuel_cell.CHP.ElectricityFromCHPTarget, src_object=electricity_from_fuel_cell_target_1, ) my_advanced_fuel_cell_2.connect_dynamic_input( - input_fieldname=advanced_fuel_cell.CHP.ElectricityFromCHPTarget, - src_object=electricity_from_fuel_cell_target_2, + input_fieldname=advanced_fuel_cell.CHP.ElectricityFromCHPTarget, src_object=electricity_from_fuel_cell_target_2, ) my_sim.add_component(my_advanced_battery_1) diff --git a/system_setups/electrolyzer_with_renewables.py b/system_setups/electrolyzer_with_renewables.py index 1a1f5573e..3254969d8 100644 --- a/system_setups/electrolyzer_with_renewables.py +++ b/system_setups/electrolyzer_with_renewables.py @@ -104,11 +104,7 @@ def setup_function(my_sim: Simulator, my_simulation_parameters: Optional[Simulat # Setup the transformer and rectifier unit my_transformer = Transformer( my_simulation_parameters=my_simulation_parameters, - config=TransformerConfig( - building_name=building_name, - name=name, - efficiency=efficiency, - ), + config=TransformerConfig(building_name=building_name, name=name, efficiency=efficiency,), ) # Setup the controller @@ -130,21 +126,15 @@ def setup_function(my_sim: Simulator, my_simulation_parameters: Optional[Simulat my_transformer.connect_input(my_transformer.TransformerInput, csv_loader.component_name, csv_loader.Output1) my_controller.connect_input( - my_controller.ProvidedLoad, - my_transformer.component_name, - my_transformer.TransformerOutput, + my_controller.ProvidedLoad, my_transformer.component_name, my_transformer.TransformerOutput, ) my_electrolyzer.connect_input( - my_electrolyzer.InputState, - my_controller.component_name, - my_controller.CurrentMode, + my_electrolyzer.InputState, my_controller.component_name, my_controller.CurrentMode, ) my_electrolyzer.connect_input( - my_electrolyzer.LoadInput, - my_controller.component_name, - my_controller.DistributedLoad, + my_electrolyzer.LoadInput, my_controller.component_name, my_controller.DistributedLoad, ) # ================================================================================================================================= diff --git a/system_setups/household_1_advanced_hp_diesel_car.py b/system_setups/household_1_advanced_hp_diesel_car.py index 9e0f8c558..162fdf6a8 100644 --- a/system_setups/household_1_advanced_hp_diesel_car.py +++ b/system_setups/household_1_advanced_hp_diesel_car.py @@ -134,15 +134,19 @@ def get_scaled_default( hds_config=( heat_distribution_system.HeatDistributionConfig.get_default_heatdistributionsystem_config( water_mass_flow_rate_in_kg_per_second=my_hds_controller_information.water_mass_flow_rate_in_kp_per_second, - absolute_conditioned_floor_area_in_m2=my_building_information.scaled_conditioned_floor_area_in_m2 + absolute_conditioned_floor_area_in_m2=my_building_information.scaled_conditioned_floor_area_in_m2, ) ), hp_controller_config=advanced_heat_pump_hplib.HeatPumpHplibControllerL1Config.get_default_generic_heat_pump_controller_config( heat_distribution_system_type=my_hds_controller_information.heat_distribution_system_type ), hp_config=advanced_heat_pump_hplib.HeatPumpHplibConfig.get_scaled_advanced_hp_lib( - heating_load_of_building_in_watt=Quantity(my_building_information.max_thermal_building_demand_in_watt, Watt), - heating_reference_temperature_in_celsius=Quantity(my_building_information.heating_reference_temperature_in_celsius, Celsius), + heating_load_of_building_in_watt=Quantity( + my_building_information.max_thermal_building_demand_in_watt, Watt + ), + heating_reference_temperature_in_celsius=Quantity( + my_building_information.heating_reference_temperature_in_celsius, Celsius + ), ), simple_hot_water_storage_config=simple_water_storage.SimpleHotWaterStorageConfig.get_scaled_hot_water_storage( max_thermal_power_in_watt_of_heating_system=my_building_information.max_thermal_building_demand_in_watt, @@ -186,8 +190,7 @@ def get_scaled_default( def setup_function( - my_sim: Any, - my_simulation_parameters: Optional[SimulationParameters] = None, + my_sim: Any, my_simulation_parameters: Optional[SimulationParameters] = None, ) -> None: # noqa: too-many-statements """System setup with advanced hp and diesel car. @@ -239,8 +242,7 @@ def setup_function( # Build heat Distribution System Controller my_heat_distribution_controller = heat_distribution_system.HeatDistributionController( - config=my_config.hds_controller_config, - my_simulation_parameters=my_simulation_parameters, + config=my_config.hds_controller_config, my_simulation_parameters=my_simulation_parameters, ) # Build Occupancy @@ -257,8 +259,7 @@ def setup_function( # Build Building my_building = building.Building( - config=my_config.building_config, - my_simulation_parameters=my_simulation_parameters, + config=my_config.building_config, my_simulation_parameters=my_simulation_parameters, ) # Build Heat Distribution System @@ -271,8 +272,7 @@ def setup_function( my_heat_pump_controller_config.name = "HeatPumpHplibController" my_heat_pump_controller = advanced_heat_pump_hplib.HeatPumpHplibController( - config=my_heat_pump_controller_config, - my_simulation_parameters=my_simulation_parameters, + config=my_heat_pump_controller_config, my_simulation_parameters=my_simulation_parameters, ) # Build Heat Pump @@ -280,14 +280,12 @@ def setup_function( my_heat_pump_config.name = "HeatPumpHPLib" my_heat_pump = advanced_heat_pump_hplib.HeatPumpHplib( - config=my_heat_pump_config, - my_simulation_parameters=my_simulation_parameters, + config=my_heat_pump_config, my_simulation_parameters=my_simulation_parameters, ) # Build Heat Water Storage my_simple_hot_water_storage = simple_water_storage.SimpleHotWaterStorage( - config=my_config.simple_hot_water_storage_config, - my_simulation_parameters=my_simulation_parameters, + config=my_config.simple_hot_water_storage_config, my_simulation_parameters=my_simulation_parameters, ) # Build DHW @@ -314,8 +312,7 @@ def setup_function( ) my_domnestic_hot_water_heatpump_controller = controller_l1_heatpump.L1HeatPumpController( - my_simulation_parameters=my_simulation_parameters, - config=my_dhw_heatpump_controller_config, + my_simulation_parameters=my_simulation_parameters, config=my_dhw_heatpump_controller_config, ) my_domnestic_hot_water_heatpump = generic_heat_pump_modular.ModularHeatPump( @@ -343,8 +340,7 @@ def setup_function( # Build Electricity Meter my_electricity_meter = electricity_meter.ElectricityMeter( - my_simulation_parameters=my_simulation_parameters, - config=my_config.electricity_meter_config, + my_simulation_parameters=my_simulation_parameters, config=my_config.electricity_meter_config, ) # ================================================================================================================================= diff --git a/system_setups/household_1b_more_advanced_hp_diesel_car.py b/system_setups/household_1b_more_advanced_hp_diesel_car.py index fb597bd56..7c55a8221 100644 --- a/system_setups/household_1b_more_advanced_hp_diesel_car.py +++ b/system_setups/household_1b_more_advanced_hp_diesel_car.py @@ -89,9 +89,9 @@ def get_default(cls) -> "HouseholdMoreAdvancedHPDieselCarConfig": @classmethod def get_scaled_default( - cls, - building_config: building.BuildingConfig, - options: HouseholdMoreAdvancedHPDieselCarOptions = HouseholdMoreAdvancedHPDieselCarOptions() + cls, + building_config: building.BuildingConfig, + options: HouseholdMoreAdvancedHPDieselCarOptions = HouseholdMoreAdvancedHPDieselCarOptions(), ) -> "HouseholdMoreAdvancedHPDieselCarConfig": """Get scaled default HouseholdMoreAdvancedHPDieselCarConfig.""" @@ -130,18 +130,19 @@ def get_scaled_default( hds_config=( heat_distribution_system.HeatDistributionConfig.get_default_heatdistributionsystem_config( water_mass_flow_rate_in_kg_per_second=my_hds_controller_information.water_mass_flow_rate_in_kp_per_second, - absolute_conditioned_floor_area_in_m2=my_building_information.scaled_conditioned_floor_area_in_m2 + absolute_conditioned_floor_area_in_m2=my_building_information.scaled_conditioned_floor_area_in_m2, ) ), sh_controller_config=more_advanced_heat_pump_hplib.MoreAdvancedHeatPumpHPLibControllerSpaceHeatingConfig.get_default_space_heating_controller_config( heat_distribution_system_type=my_hds_controller_information.heat_distribution_system_type ), hp_config=more_advanced_heat_pump_hplib.MoreAdvancedHeatPumpHPLibConfig.get_scaled_advanced_hp_lib( - heating_load_of_building_in_watt=Quantity(my_building_information.max_thermal_building_demand_in_watt, - Watt), + heating_load_of_building_in_watt=Quantity( + my_building_information.max_thermal_building_demand_in_watt, Watt + ), heating_reference_temperature_in_celsius=Quantity( - my_building_information.heating_reference_temperature_in_celsius, Celsius), - + my_building_information.heating_reference_temperature_in_celsius, Celsius + ), ), simple_hot_water_storage_config=simple_water_storage.SimpleHotWaterStorageConfig.get_scaled_hot_water_storage( max_thermal_power_in_watt_of_heating_system=my_building_information.max_thermal_building_demand_in_watt, @@ -158,9 +159,7 @@ def get_scaled_default( # adjust HeatPump household_config.hp_config.group_id = 1 # use modulating heatpump as default - household_config.sh_controller_config.mode = ( - 2 # use heating and cooling as default - ) + household_config.sh_controller_config.mode = 2 # use heating and cooling as default household_config.hp_config.minimum_idle_time_in_seconds = Quantity( 900, Seconds # default value leads to switching on-off very often ) @@ -183,8 +182,7 @@ def get_scaled_default( def setup_function( - my_sim: Any, - my_simulation_parameters: Optional[SimulationParameters] = None, + my_sim: Any, my_simulation_parameters: Optional[SimulationParameters] = None, ) -> None: # noqa: too-many-statements """System setup with more advanced hp and diesel car. @@ -235,8 +233,7 @@ def setup_function( # Build heat Distribution System Controller my_heat_distribution_controller = heat_distribution_system.HeatDistributionController( - config=my_config.hds_controller_config, - my_simulation_parameters=my_simulation_parameters, + config=my_config.hds_controller_config, my_simulation_parameters=my_simulation_parameters, ) # Build Occupancy @@ -253,8 +250,7 @@ def setup_function( # Build Building my_building = building.Building( - config=my_config.building_config, - my_simulation_parameters=my_simulation_parameters, + config=my_config.building_config, my_simulation_parameters=my_simulation_parameters, ) # Build Heat Distribution System @@ -266,16 +262,14 @@ def setup_function( my_heatpump_controller_sh_config.name = "HeatPumpControllerSH" my_heatpump_controller_space_heating = more_advanced_heat_pump_hplib.MoreAdvancedHeatPumpHPLibControllerSpaceHeating( - config=my_heatpump_controller_sh_config, - my_simulation_parameters=my_simulation_parameters + config=my_heatpump_controller_sh_config, my_simulation_parameters=my_simulation_parameters ) # Build Heat Pump Controller for dhw my_heatpump_controller_dhw_config = my_config.dhw_heatpump_controller_config my_heatpump_controller_dhw = more_advanced_heat_pump_hplib.MoreAdvancedHeatPumpHPLibControllerDHW( - config=my_heatpump_controller_dhw_config, - my_simulation_parameters=my_simulation_parameters + config=my_heatpump_controller_dhw_config, my_simulation_parameters=my_simulation_parameters ) # Build Heat Pump @@ -283,21 +277,17 @@ def setup_function( my_heatpump_config.name = "HeatPumpHPLib" my_heatpump = more_advanced_heat_pump_hplib.MoreAdvancedHeatPumpHPLib( - config=my_heatpump_config, - my_simulation_parameters=my_simulation_parameters, + config=my_heatpump_config, my_simulation_parameters=my_simulation_parameters, ) # Build Heat Water Storage my_hot_water_storage = simple_water_storage.SimpleHotWaterStorage( - config=my_config.simple_hot_water_storage_config, - my_simulation_parameters=my_simulation_parameters, + config=my_config.simple_hot_water_storage_config, my_simulation_parameters=my_simulation_parameters, ) my_dhw_storage_config = my_config.dhw_storage_config my_dhw_storage_config.name = "DHWStorage" - my_dhw_storage_config.compute_default_cycle( - temperature_difference_in_kelvin=60 - 40 # default values - ) + my_dhw_storage_config.compute_default_cycle(temperature_difference_in_kelvin=60 - 40) # default values my_dhw_storage = generic_hot_water_storage_modular.HotWaterStorage( my_simulation_parameters=my_simulation_parameters, config=my_dhw_storage_config @@ -324,8 +314,7 @@ def setup_function( # Build Electricity Meter my_electricity_meter = electricity_meter.ElectricityMeter( - my_simulation_parameters=my_simulation_parameters, - config=my_config.electricity_meter_config, + my_simulation_parameters=my_simulation_parameters, config=my_config.electricity_meter_config, ) # ================================================================================================================================= @@ -341,34 +330,36 @@ def setup_function( ) ################################# - my_heat_distribution_controller.connect_only_predefined_connections( - my_weather, my_building - ) + my_heat_distribution_controller.connect_only_predefined_connections(my_weather, my_building) my_heat_distribution.connect_only_predefined_connections( - my_building, my_heat_distribution_controller, my_hot_water_storage) + my_building, my_heat_distribution_controller, my_hot_water_storage + ) ################################# my_heatpump.connect_only_predefined_connections( - my_heatpump_controller_space_heating, my_heatpump_controller_dhw, my_weather, my_hot_water_storage, - my_dhw_storage) + my_heatpump_controller_space_heating, + my_heatpump_controller_dhw, + my_weather, + my_hot_water_storage, + my_dhw_storage, + ) # Verknüpfung mit Luft als Umgebungswärmequelle - if my_heatpump.parameters['Group'].iloc[0] == 1.0 or my_heatpump.parameters['Group'].iloc[0] == 4.0: + if my_heatpump.parameters["Group"].iloc[0] == 1.0 or my_heatpump.parameters["Group"].iloc[0] == 4.0: my_heatpump.connect_input( - my_heatpump.TemperatureInputPrimary, - my_weather.component_name, - my_weather.DailyAverageOutsideTemperatures, + my_heatpump.TemperatureInputPrimary, my_weather.component_name, my_weather.DailyAverageOutsideTemperatures, ) else: raise KeyError( - "Wasser oder Sole als primäres Wärmeträgermedium muss über extra Wärmenetz-Modell noch bereitgestellt werden") + "Wasser oder Sole als primäres Wärmeträgermedium muss über extra Wärmenetz-Modell noch bereitgestellt werden" + ) # todo: Water and Brine Connection - my_heatpump_controller_space_heating.connect_only_predefined_connections(my_heat_distribution_controller, - my_weather, - my_hot_water_storage) + my_heatpump_controller_space_heating.connect_only_predefined_connections( + my_heat_distribution_controller, my_weather, my_hot_water_storage + ) my_heatpump_controller_dhw.connect_only_predefined_connections(my_dhw_storage) @@ -395,9 +386,7 @@ def setup_function( my_dhw_storage.connect_only_predefined_connections(my_occupancy) my_dhw_storage.connect_input( - my_dhw_storage.ThermalPowerDelivered, - my_heatpump.component_name, - my_heatpump.ThermalOutputPowerDHW, + my_dhw_storage.ThermalPowerDelivered, my_heatpump.component_name, my_heatpump.ThermalOutputPowerDHW, ) ################################ @@ -416,9 +405,7 @@ def setup_function( source_component_output=my_heatpump.ElectricalInputPowerTotal, source_load_type=lt.LoadTypes.ELECTRICITY, source_unit=lt.Units.WATT, - source_tags=[ - lt.InandOutputType.ELECTRICITY_CONSUMPTION_UNCONTROLLED, - ], + source_tags=[lt.InandOutputType.ELECTRICITY_CONSUMPTION_UNCONTROLLED,], source_weight=999, ) diff --git a/system_setups/household_1c_more_advanced_hp_dhw_hp_diesel_car.py b/system_setups/household_1c_more_advanced_hp_dhw_hp_diesel_car.py index c47f2be45..c7d397fa8 100644 --- a/system_setups/household_1c_more_advanced_hp_dhw_hp_diesel_car.py +++ b/system_setups/household_1c_more_advanced_hp_dhw_hp_diesel_car.py @@ -136,7 +136,7 @@ def get_scaled_default( hds_config=( heat_distribution_system.HeatDistributionConfig.get_default_heatdistributionsystem_config( water_mass_flow_rate_in_kg_per_second=my_hds_controller_information.water_mass_flow_rate_in_kp_per_second, - absolute_conditioned_floor_area_in_m2=my_building_information.scaled_conditioned_floor_area_in_m2 + absolute_conditioned_floor_area_in_m2=my_building_information.scaled_conditioned_floor_area_in_m2, ) ), hp_controller_config=more_advanced_heat_pump_hplib.MoreAdvancedHeatPumpHPLibControllerSpaceHeatingConfig.get_default_space_heating_controller_config( @@ -193,8 +193,7 @@ def get_scaled_default( def setup_function( - my_sim: Any, - my_simulation_parameters: Optional[SimulationParameters] = None, + my_sim: Any, my_simulation_parameters: Optional[SimulationParameters] = None, ) -> None: # noqa: too-many-statements """System setup with advanced hp and diesel car. @@ -246,8 +245,7 @@ def setup_function( # Build heat Distribution System Controller my_heat_distribution_controller = heat_distribution_system.HeatDistributionController( - config=my_config.hds_controller_config, - my_simulation_parameters=my_simulation_parameters, + config=my_config.hds_controller_config, my_simulation_parameters=my_simulation_parameters, ) # Build Occupancy @@ -264,8 +262,7 @@ def setup_function( # Build Building my_building = building.Building( - config=my_config.building_config, - my_simulation_parameters=my_simulation_parameters, + config=my_config.building_config, my_simulation_parameters=my_simulation_parameters, ) # Build Heat Distribution System @@ -278,8 +275,7 @@ def setup_function( my_heat_pump_controller_config.name = "HeatPumpHplibController" my_heat_pump_controller = more_advanced_heat_pump_hplib.MoreAdvancedHeatPumpHPLibControllerSpaceHeating( - config=my_heat_pump_controller_config, - my_simulation_parameters=my_simulation_parameters, + config=my_heat_pump_controller_config, my_simulation_parameters=my_simulation_parameters, ) # Build Heat Pump @@ -287,14 +283,12 @@ def setup_function( my_heat_pump_config.name = "HeatPumpHPLib" my_heat_pump = more_advanced_heat_pump_hplib.MoreAdvancedHeatPumpHPLib( - config=my_heat_pump_config, - my_simulation_parameters=my_simulation_parameters, + config=my_heat_pump_config, my_simulation_parameters=my_simulation_parameters, ) # Build Heat Water Storage my_simple_hot_water_storage = simple_water_storage.SimpleHotWaterStorage( - config=my_config.simple_hot_water_storage_config, - my_simulation_parameters=my_simulation_parameters, + config=my_config.simple_hot_water_storage_config, my_simulation_parameters=my_simulation_parameters, ) # Build DHW @@ -321,8 +315,7 @@ def setup_function( ) my_domnestic_hot_water_heatpump_controller = controller_l1_heatpump.L1HeatPumpController( - my_simulation_parameters=my_simulation_parameters, - config=my_dhw_heatpump_controller_config, + my_simulation_parameters=my_simulation_parameters, config=my_dhw_heatpump_controller_config, ) my_domnestic_hot_water_heatpump = generic_heat_pump_modular.ModularHeatPump( @@ -350,8 +343,7 @@ def setup_function( # Build Electricity Meter my_electricity_meter = electricity_meter.ElectricityMeter( - my_simulation_parameters=my_simulation_parameters, - config=my_config.electricity_meter_config, + my_simulation_parameters=my_simulation_parameters, config=my_config.electricity_meter_config, ) my_heat_pump.connect_only_predefined_connections(my_heat_pump_controller, my_weather, my_simple_hot_water_storage) @@ -359,9 +351,7 @@ def setup_function( # Verknüpfung mit Luft als Umgebungswärmequelle if my_heat_pump.parameters["Group"].iloc[0] == 1.0 or my_heat_pump.parameters["Group"].iloc[0] == 4.0: my_heat_pump.connect_input( - my_heat_pump.TemperatureInputPrimary, - my_weather.component_name, - my_weather.DailyAverageOutsideTemperatures, + my_heat_pump.TemperatureInputPrimary, my_weather.component_name, my_weather.DailyAverageOutsideTemperatures, ) else: raise KeyError( @@ -391,9 +381,7 @@ def setup_function( source_component_output=my_heat_pump.ElectricalInputPowerTotal, source_load_type=lt.LoadTypes.ELECTRICITY, source_unit=lt.Units.WATT, - source_tags=[ - lt.InandOutputType.ELECTRICITY_CONSUMPTION_UNCONTROLLED, - ], + source_tags=[lt.InandOutputType.ELECTRICITY_CONSUMPTION_UNCONTROLLED,], source_weight=999, ) # ================================================================================================================================= diff --git a/system_setups/household_1d_more_advanced_hp_dhw_hp_no_hot_water_storage.py b/system_setups/household_1d_more_advanced_hp_dhw_hp_no_hot_water_storage.py index 2b477572a..dabef8916 100644 --- a/system_setups/household_1d_more_advanced_hp_dhw_hp_no_hot_water_storage.py +++ b/system_setups/household_1d_more_advanced_hp_dhw_hp_no_hot_water_storage.py @@ -174,7 +174,9 @@ def get_scaled_default( 900, Seconds # default value leads to switching on-off very often ) household_config.hp_config.with_domestic_hot_water_preparation = False - household_config.hp_config.position_hot_water_storage_in_system = more_advanced_heat_pump_hplib.PositionHotWaterStorageInSystemSetup.NO_STORAGE + household_config.hp_config.position_hot_water_storage_in_system = ( + more_advanced_heat_pump_hplib.PositionHotWaterStorageInSystemSetup.NO_STORAGE + ) household_config.hp_config.cycling_mode = False # set same heating threshold @@ -192,8 +194,7 @@ def get_scaled_default( def setup_function( - my_sim: Any, - my_simulation_parameters: Optional[SimulationParameters] = None, + my_sim: Any, my_simulation_parameters: Optional[SimulationParameters] = None, ) -> None: # noqa: too-many-statements """System setup with advanced hp and diesel car. @@ -245,8 +246,7 @@ def setup_function( # Build heat Distribution System Controller my_heat_distribution_controller = heat_distribution_system.HeatDistributionController( - config=my_config.hds_controller_config, - my_simulation_parameters=my_simulation_parameters, + config=my_config.hds_controller_config, my_simulation_parameters=my_simulation_parameters, ) # Build Occupancy @@ -263,8 +263,7 @@ def setup_function( # Build Building my_building = building.Building( - config=my_config.building_config, - my_simulation_parameters=my_simulation_parameters, + config=my_config.building_config, my_simulation_parameters=my_simulation_parameters, ) # Build Heat Distribution System @@ -277,8 +276,7 @@ def setup_function( my_heat_pump_controller_config.name = "HeatPumpHplibController" my_heat_pump_controller = more_advanced_heat_pump_hplib.MoreAdvancedHeatPumpHPLibControllerSpaceHeating( - config=my_heat_pump_controller_config, - my_simulation_parameters=my_simulation_parameters, + config=my_heat_pump_controller_config, my_simulation_parameters=my_simulation_parameters, ) # Build Heat Pump @@ -286,8 +284,7 @@ def setup_function( my_heat_pump_config.name = "HeatPumpHPLib" my_heat_pump = more_advanced_heat_pump_hplib.MoreAdvancedHeatPumpHPLib( - config=my_heat_pump_config, - my_simulation_parameters=my_simulation_parameters, + config=my_heat_pump_config, my_simulation_parameters=my_simulation_parameters, ) # Build DHW @@ -314,8 +311,7 @@ def setup_function( ) my_domnestic_hot_water_heatpump_controller = controller_l1_heatpump.L1HeatPumpController( - my_simulation_parameters=my_simulation_parameters, - config=my_dhw_heatpump_controller_config, + my_simulation_parameters=my_simulation_parameters, config=my_dhw_heatpump_controller_config, ) my_domnestic_hot_water_heatpump = generic_heat_pump_modular.ModularHeatPump( @@ -343,8 +339,7 @@ def setup_function( # Build Electricity Meter my_electricity_meter = electricity_meter.ElectricityMeter( - my_simulation_parameters=my_simulation_parameters, - config=my_config.electricity_meter_config, + my_simulation_parameters=my_simulation_parameters, config=my_config.electricity_meter_config, ) my_heat_pump.connect_only_predefined_connections(my_heat_pump_controller, my_weather) @@ -352,9 +347,7 @@ def setup_function( # Verknüpfung mit Luft als Umgebungswärmequelle if my_heat_pump.parameters["Group"].iloc[0] == 1.0 or my_heat_pump.parameters["Group"].iloc[0] == 4.0: my_heat_pump.connect_input( - my_heat_pump.TemperatureInputPrimary, - my_weather.component_name, - my_weather.DailyAverageOutsideTemperatures, + my_heat_pump.TemperatureInputPrimary, my_weather.component_name, my_weather.DailyAverageOutsideTemperatures, ) else: raise KeyError("Water/Water HP or Brine/Water HP will follow.") @@ -380,15 +373,11 @@ def setup_function( ) my_heat_distribution.connect_input( - my_heat_distribution.WaterTemperatureInput, - my_heat_pump.component_name, - my_heat_pump.TemperatureOutputSH, + my_heat_distribution.WaterTemperatureInput, my_heat_pump.component_name, my_heat_pump.TemperatureOutputSH, ) my_heat_distribution.connect_input( - my_heat_distribution.WaterMassFlow, - my_heat_pump.component_name, - my_heat_pump.MassFlowOutputSH, + my_heat_distribution.WaterMassFlowInput, my_heat_pump.component_name, my_heat_pump.MassFlowOutputSH, ) my_electricity_meter.add_component_input_and_connect( @@ -396,9 +385,7 @@ def setup_function( source_component_output=my_heat_pump.ElectricalInputPowerTotal, source_load_type=lt.LoadTypes.ELECTRICITY, source_unit=lt.Units.WATT, - source_tags=[ - lt.InandOutputType.ELECTRICITY_CONSUMPTION_UNCONTROLLED, - ], + source_tags=[lt.InandOutputType.ELECTRICITY_CONSUMPTION_UNCONTROLLED,], source_weight=999, ) # ================================================================================================================================= diff --git a/system_setups/household_1e_more_advanced_dhw_hp_storage.py b/system_setups/household_1e_more_advanced_dhw_hp_storage.py index a6664b1e8..cc1f670f8 100644 --- a/system_setups/household_1e_more_advanced_dhw_hp_storage.py +++ b/system_setups/household_1e_more_advanced_dhw_hp_storage.py @@ -82,15 +82,17 @@ def get_default(cls) -> "HouseholdMoreAdvancedHPDieselCarDHWStorageConfig": household_config.hp_config.set_thermal_output_power_in_watt = Quantity( 6000, Watt # default value leads to switching on-off very often ) - household_config.dhw_storage_config.volume_heating_water_storage_in_liter = 100 # default(volume = 230) leads to an error + household_config.dhw_storage_config.volume_heating_water_storage_in_liter = ( + 100 # default(volume = 230) leads to an error + ) return household_config @classmethod def get_scaled_default( - cls, - building_config: building.BuildingConfig, - options: HouseholdMoreAdvancedHPDieselCarDHWStorageOptions = HouseholdMoreAdvancedHPDieselCarDHWStorageOptions() + cls, + building_config: building.BuildingConfig, + options: HouseholdMoreAdvancedHPDieselCarDHWStorageOptions = HouseholdMoreAdvancedHPDieselCarDHWStorageOptions(), ) -> "HouseholdMoreAdvancedHPDieselCarDHWStorageConfig": """Get scaled default HouseholdMoreAdvancedHPDieselCarConfig.""" @@ -129,18 +131,19 @@ def get_scaled_default( hds_config=( heat_distribution_system.HeatDistributionConfig.get_default_heatdistributionsystem_config( water_mass_flow_rate_in_kg_per_second=my_hds_controller_information.water_mass_flow_rate_in_kp_per_second, - absolute_conditioned_floor_area_in_m2=my_building_information.scaled_conditioned_floor_area_in_m2 + absolute_conditioned_floor_area_in_m2=my_building_information.scaled_conditioned_floor_area_in_m2, ) ), sh_controller_config=more_advanced_heat_pump_hplib.MoreAdvancedHeatPumpHPLibControllerSpaceHeatingConfig.get_default_space_heating_controller_config( heat_distribution_system_type=my_hds_controller_information.heat_distribution_system_type ), hp_config=more_advanced_heat_pump_hplib.MoreAdvancedHeatPumpHPLibConfig.get_scaled_advanced_hp_lib( - heating_load_of_building_in_watt=Quantity(my_building_information.max_thermal_building_demand_in_watt, - Watt), + heating_load_of_building_in_watt=Quantity( + my_building_information.max_thermal_building_demand_in_watt, Watt + ), heating_reference_temperature_in_celsius=Quantity( - my_building_information.heating_reference_temperature_in_celsius, Celsius), - + my_building_information.heating_reference_temperature_in_celsius, Celsius + ), ), simple_hot_water_storage_config=simple_water_storage.SimpleHotWaterStorageConfig.get_scaled_hot_water_storage( max_thermal_power_in_watt_of_heating_system=my_building_information.max_thermal_building_demand_in_watt, @@ -155,9 +158,7 @@ def get_scaled_default( # adjust HeatPump household_config.hp_config.group_id = 1 # use modulating heatpump as default - household_config.sh_controller_config.mode = ( - 2 # use heating and cooling as default - ) + household_config.sh_controller_config.mode = 2 # use heating and cooling as default household_config.hp_config.minimum_idle_time_in_seconds = Quantity( 900, Seconds # default value leads to switching on-off very often ) @@ -180,8 +181,7 @@ def get_scaled_default( def setup_function( - my_sim: Any, - my_simulation_parameters: Optional[SimulationParameters] = None, + my_sim: Any, my_simulation_parameters: Optional[SimulationParameters] = None, ) -> None: # noqa: too-many-statements """System setup with more advanced hp and diesel car. @@ -232,8 +232,7 @@ def setup_function( # Build heat Distribution System Controller my_heat_distribution_controller = heat_distribution_system.HeatDistributionController( - config=my_config.hds_controller_config, - my_simulation_parameters=my_simulation_parameters, + config=my_config.hds_controller_config, my_simulation_parameters=my_simulation_parameters, ) # Build Occupancy @@ -250,8 +249,7 @@ def setup_function( # Build Building my_building = building.Building( - config=my_config.building_config, - my_simulation_parameters=my_simulation_parameters, + config=my_config.building_config, my_simulation_parameters=my_simulation_parameters, ) # Build Heat Distribution System @@ -263,16 +261,14 @@ def setup_function( my_heatpump_controller_sh_config.name = "HeatPumpControllerSH" my_heatpump_controller_space_heating = more_advanced_heat_pump_hplib.MoreAdvancedHeatPumpHPLibControllerSpaceHeating( - config=my_heatpump_controller_sh_config, - my_simulation_parameters=my_simulation_parameters + config=my_heatpump_controller_sh_config, my_simulation_parameters=my_simulation_parameters ) # Build Heat Pump Controller for dhw my_heatpump_controller_dhw_config = my_config.dhw_heatpump_controller_config my_heatpump_controller_dhw = more_advanced_heat_pump_hplib.MoreAdvancedHeatPumpHPLibControllerDHW( - config=my_heatpump_controller_dhw_config, - my_simulation_parameters=my_simulation_parameters + config=my_heatpump_controller_dhw_config, my_simulation_parameters=my_simulation_parameters ) # Build Heat Pump @@ -280,14 +276,12 @@ def setup_function( my_heatpump_config.name = "HeatPumpHPLib" my_heatpump = more_advanced_heat_pump_hplib.MoreAdvancedHeatPumpHPLib( - config=my_heatpump_config, - my_simulation_parameters=my_simulation_parameters, + config=my_heatpump_config, my_simulation_parameters=my_simulation_parameters, ) # Build Heat Water Storage my_hot_water_storage = simple_water_storage.SimpleHotWaterStorage( - config=my_config.simple_hot_water_storage_config, - my_simulation_parameters=my_simulation_parameters, + config=my_config.simple_hot_water_storage_config, my_simulation_parameters=my_simulation_parameters, ) my_dhw_storage_config = my_config.dhw_storage_config @@ -318,8 +312,7 @@ def setup_function( # Build Electricity Meter my_electricity_meter = electricity_meter.ElectricityMeter( - my_simulation_parameters=my_simulation_parameters, - config=my_config.electricity_meter_config, + my_simulation_parameters=my_simulation_parameters, config=my_config.electricity_meter_config, ) # ================================================================================================================================= @@ -335,16 +328,16 @@ def setup_function( ) ################################# - my_heat_distribution_controller.connect_only_predefined_connections( - my_weather, my_building - ) + my_heat_distribution_controller.connect_only_predefined_connections(my_weather, my_building) my_heat_distribution.connect_only_predefined_connections( - my_building, my_heat_distribution_controller, my_hot_water_storage) + my_building, my_heat_distribution_controller, my_hot_water_storage + ) ################################# - my_heatpump.connect_only_predefined_connections(my_heatpump_controller_space_heating, - my_heatpump_controller_dhw, my_weather, my_hot_water_storage,) + my_heatpump.connect_only_predefined_connections( + my_heatpump_controller_space_heating, my_heatpump_controller_dhw, my_weather, my_hot_water_storage, + ) my_heatpump.connect_input( my_heatpump.TemperatureInputSecondary_DHW, @@ -353,21 +346,20 @@ def setup_function( ) # Verknüpfung mit Luft als Umgebungswärmequelle - if my_heatpump.parameters['Group'].iloc[0] == 1.0 or my_heatpump.parameters['Group'].iloc[0] == 4.0: + if my_heatpump.parameters["Group"].iloc[0] == 1.0 or my_heatpump.parameters["Group"].iloc[0] == 4.0: my_heatpump.connect_input( - my_heatpump.TemperatureInputPrimary, - my_weather.component_name, - my_weather.DailyAverageOutsideTemperatures, + my_heatpump.TemperatureInputPrimary, my_weather.component_name, my_weather.DailyAverageOutsideTemperatures, ) else: raise KeyError( - "Wasser oder Sole als primäres Wärmeträgermedium muss über extra Wärmenetz-Modell noch bereitgestellt werden") + "Wasser oder Sole als primäres Wärmeträgermedium muss über extra Wärmenetz-Modell noch bereitgestellt werden" + ) # todo: Water and Brine Connection - my_heatpump_controller_space_heating.connect_only_predefined_connections(my_heat_distribution_controller, - my_weather, - my_hot_water_storage) + my_heatpump_controller_space_heating.connect_only_predefined_connections( + my_heat_distribution_controller, my_weather, my_hot_water_storage + ) my_heatpump_controller_dhw.connect_input( my_heatpump_controller_dhw.WaterTemperatureInputFromDHWStorage, @@ -414,9 +406,7 @@ def setup_function( source_component_output=my_heatpump.ElectricalInputPowerTotal, source_load_type=lt.LoadTypes.ELECTRICITY, source_unit=lt.Units.WATT, - source_tags=[ - lt.InandOutputType.ELECTRICITY_CONSUMPTION_UNCONTROLLED, - ], + source_tags=[lt.InandOutputType.ELECTRICITY_CONSUMPTION_UNCONTROLLED,], source_weight=999, ) diff --git a/system_setups/household_2_advanced_hp_diesel_car_pv.py b/system_setups/household_2_advanced_hp_diesel_car_pv.py index e97fcc7c2..20d941662 100644 --- a/system_setups/household_2_advanced_hp_diesel_car_pv.py +++ b/system_setups/household_2_advanced_hp_diesel_car_pv.py @@ -126,7 +126,7 @@ def get_default(cls): hds_config=( heat_distribution_system.HeatDistributionConfig.get_default_heatdistributionsystem_config( water_mass_flow_rate_in_kg_per_second=my_hds_controller_information.water_mass_flow_rate_in_kp_per_second, - absolute_conditioned_floor_area_in_m2=my_building_information.scaled_conditioned_floor_area_in_m2 + absolute_conditioned_floor_area_in_m2=my_building_information.scaled_conditioned_floor_area_in_m2, ) ), hp_controller_config=advanced_heat_pump_hplib.HeatPumpHplibControllerL1Config.get_default_generic_heat_pump_controller_config( @@ -134,7 +134,9 @@ def get_default(cls): ), hp_config=( advanced_heat_pump_hplib.HeatPumpHplibConfig.get_scaled_advanced_hp_lib( - heating_load_of_building_in_watt=Quantity(my_building_information.max_thermal_building_demand_in_watt, Watt), + heating_load_of_building_in_watt=Quantity( + my_building_information.max_thermal_building_demand_in_watt, Watt + ), heating_reference_temperature_in_celsius=Quantity( heating_reference_temperature_in_celsius, Celsius ), @@ -247,8 +249,7 @@ def setup_function( # Build heat Distribution System Controller my_heat_distribution_controller = heat_distribution_system.HeatDistributionController( - config=my_config.hds_controller_config, - my_simulation_parameters=my_simulation_parameters, + config=my_config.hds_controller_config, my_simulation_parameters=my_simulation_parameters, ) # Build Occupancy @@ -265,14 +266,12 @@ def setup_function( # Build PV my_photovoltaic_system = generic_pv_system.PVSystem( - config=my_config.pv_config, - my_simulation_parameters=my_simulation_parameters, + config=my_config.pv_config, my_simulation_parameters=my_simulation_parameters, ) # Build Building my_building = building.Building( - config=my_config.building_config, - my_simulation_parameters=my_simulation_parameters, + config=my_config.building_config, my_simulation_parameters=my_simulation_parameters, ) # Build Heat Distribution System @@ -285,8 +284,7 @@ def setup_function( my_heat_pump_controller_config.name = "HeatPumpHplibController" my_heat_pump_controller = advanced_heat_pump_hplib.HeatPumpHplibController( - config=my_heat_pump_controller_config, - my_simulation_parameters=my_simulation_parameters, + config=my_heat_pump_controller_config, my_simulation_parameters=my_simulation_parameters, ) # Build Heat Pump @@ -294,14 +292,12 @@ def setup_function( my_heat_pump_config.name = "HeatPumpHPLib" my_heat_pump = advanced_heat_pump_hplib.HeatPumpHplib( - config=my_heat_pump_config, - my_simulation_parameters=my_simulation_parameters, + config=my_heat_pump_config, my_simulation_parameters=my_simulation_parameters, ) # Build Heat Water Storage my_simple_hot_water_storage = simple_water_storage.SimpleHotWaterStorage( - config=my_config.simple_hot_water_storage_config, - my_simulation_parameters=my_simulation_parameters, + config=my_config.simple_hot_water_storage_config, my_simulation_parameters=my_simulation_parameters, ) # Build DHW @@ -320,8 +316,7 @@ def setup_function( ) my_domnestic_hot_water_heatpump_controller = controller_l1_heatpump.L1HeatPumpController( - my_simulation_parameters=my_simulation_parameters, - config=my_dhw_heatpump_controller_config, + my_simulation_parameters=my_simulation_parameters, config=my_dhw_heatpump_controller_config, ) my_domnestic_hot_water_heatpump = generic_heat_pump_modular.ModularHeatPump( @@ -349,14 +344,12 @@ def setup_function( # Build Electricity Meter my_electricity_meter = electricity_meter.ElectricityMeter( - my_simulation_parameters=my_simulation_parameters, - config=my_config.electricity_meter_config, + my_simulation_parameters=my_simulation_parameters, config=my_config.electricity_meter_config, ) # Build EMS my_electricity_controller = controller_l2_energy_management_system.L2GenericEnergyManagementSystem( - my_simulation_parameters=my_simulation_parameters, - config=my_config.electricity_controller_config, + my_simulation_parameters=my_simulation_parameters, config=my_config.electricity_controller_config, ) # ----------------------------------------------------------------------------------------------------------------- @@ -383,20 +376,14 @@ def setup_function( source_component_output=my_domnestic_hot_water_heatpump.ElectricityOutput, source_load_type=lt.LoadTypes.ELECTRICITY, source_unit=lt.Units.WATT, - source_tags=[ - lt.ComponentType.HEAT_PUMP_DHW, - lt.InandOutputType.ELECTRICITY_CONSUMPTION_EMS_CONTROLLED, - ], + source_tags=[lt.ComponentType.HEAT_PUMP_DHW, lt.InandOutputType.ELECTRICITY_CONSUMPTION_EMS_CONTROLLED,], # source_weight=my_dhw_heatpump_config.source_weight, source_weight=2, ) my_electricity_controller.add_component_output( source_output_name=lt.InandOutputType.ELECTRICITY_TARGET, - source_tags=[ - lt.ComponentType.HEAT_PUMP_DHW, - lt.InandOutputType.ELECTRICITY_TARGET, - ], + source_tags=[lt.ComponentType.HEAT_PUMP_DHW, lt.InandOutputType.ELECTRICITY_TARGET,], # source_weight=my_domnestic_hot_water_heatpump.config.source_weight, source_weight=2, source_load_type=lt.LoadTypes.ELECTRICITY, @@ -436,10 +423,7 @@ def setup_function( my_electricity_controller.add_component_output( source_output_name=lt.InandOutputType.ELECTRICITY_TARGET, - source_tags=[ - lt.ComponentType.HEAT_PUMP_BUILDING, - lt.InandOutputType.ELECTRICITY_TARGET, - ], + source_tags=[lt.ComponentType.HEAT_PUMP_BUILDING, lt.InandOutputType.ELECTRICITY_TARGET,], source_weight=3, source_load_type=lt.LoadTypes.ELECTRICITY, source_unit=lt.Units.WATT, diff --git a/system_setups/household_3_advanced_hp_diesel_car_pv_battery.py b/system_setups/household_3_advanced_hp_diesel_car_pv_battery.py index e24f563aa..75e7a83bc 100644 --- a/system_setups/household_3_advanced_hp_diesel_car_pv_battery.py +++ b/system_setups/household_3_advanced_hp_diesel_car_pv_battery.py @@ -128,7 +128,7 @@ def get_default(cls): hds_config=( heat_distribution_system.HeatDistributionConfig.get_default_heatdistributionsystem_config( water_mass_flow_rate_in_kg_per_second=my_hds_controller_information.water_mass_flow_rate_in_kp_per_second, - absolute_conditioned_floor_area_in_m2=my_building_information.scaled_conditioned_floor_area_in_m2 + absolute_conditioned_floor_area_in_m2=my_building_information.scaled_conditioned_floor_area_in_m2, ) ), hp_controller_config=advanced_heat_pump_hplib.HeatPumpHplibControllerL1Config.get_default_generic_heat_pump_controller_config( @@ -136,8 +136,12 @@ def get_default(cls): ), hp_config=( advanced_heat_pump_hplib.HeatPumpHplibConfig.get_scaled_advanced_hp_lib( - heating_load_of_building_in_watt=Quantity(my_building_information.max_thermal_building_demand_in_watt, Watt), - heating_reference_temperature_in_celsius=Quantity(heating_reference_temperature_in_celsius, Celsius), + heating_load_of_building_in_watt=Quantity( + my_building_information.max_thermal_building_demand_in_watt, Watt + ), + heating_reference_temperature_in_celsius=Quantity( + heating_reference_temperature_in_celsius, Celsius + ), ) ), simple_hot_water_storage_config=( @@ -250,8 +254,7 @@ def setup_function( # Build heat Distribution System Controller my_heat_distribution_controller = heat_distribution_system.HeatDistributionController( - config=my_config.hds_controller_config, - my_simulation_parameters=my_simulation_parameters, + config=my_config.hds_controller_config, my_simulation_parameters=my_simulation_parameters, ) # Build Occupancy @@ -268,14 +271,12 @@ def setup_function( # Build PV my_photovoltaic_system = generic_pv_system.PVSystem( - config=my_config.pv_config, - my_simulation_parameters=my_simulation_parameters, + config=my_config.pv_config, my_simulation_parameters=my_simulation_parameters, ) # Build Building my_building = building.Building( - config=my_config.building_config, - my_simulation_parameters=my_simulation_parameters, + config=my_config.building_config, my_simulation_parameters=my_simulation_parameters, ) # Build Heat Distribution System @@ -288,8 +289,7 @@ def setup_function( my_heat_pump_controller_config.name = "HeatPumpHplibController" my_heat_pump_controller = advanced_heat_pump_hplib.HeatPumpHplibController( - config=my_heat_pump_controller_config, - my_simulation_parameters=my_simulation_parameters, + config=my_heat_pump_controller_config, my_simulation_parameters=my_simulation_parameters, ) # Build Heat Pump @@ -297,14 +297,12 @@ def setup_function( my_heat_pump_config.name = "HeatPumpHPLib" my_heat_pump = advanced_heat_pump_hplib.HeatPumpHplib( - config=my_heat_pump_config, - my_simulation_parameters=my_simulation_parameters, + config=my_heat_pump_config, my_simulation_parameters=my_simulation_parameters, ) # Build Heat Water Storage my_simple_hot_water_storage = simple_water_storage.SimpleHotWaterStorage( - config=my_config.simple_hot_water_storage_config, - my_simulation_parameters=my_simulation_parameters, + config=my_config.simple_hot_water_storage_config, my_simulation_parameters=my_simulation_parameters, ) # Build DHW @@ -323,8 +321,7 @@ def setup_function( ) my_domnestic_hot_water_heatpump_controller = controller_l1_heatpump.L1HeatPumpController( - my_simulation_parameters=my_simulation_parameters, - config=my_dhw_heatpump_controller_config, + my_simulation_parameters=my_simulation_parameters, config=my_dhw_heatpump_controller_config, ) my_domnestic_hot_water_heatpump = generic_heat_pump_modular.ModularHeatPump( @@ -352,20 +349,17 @@ def setup_function( # Build Electricity Meter my_electricity_meter = electricity_meter.ElectricityMeter( - my_simulation_parameters=my_simulation_parameters, - config=my_config.electricity_meter_config, + my_simulation_parameters=my_simulation_parameters, config=my_config.electricity_meter_config, ) # Build EMS my_electricity_controller = controller_l2_energy_management_system.L2GenericEnergyManagementSystem( - my_simulation_parameters=my_simulation_parameters, - config=my_config.electricity_controller_config, + my_simulation_parameters=my_simulation_parameters, config=my_config.electricity_controller_config, ) # Build Battery my_advanced_battery = advanced_battery_bslib.Battery( - my_simulation_parameters=my_simulation_parameters, - config=my_config.advanced_battery_config, + my_simulation_parameters=my_simulation_parameters, config=my_config.advanced_battery_config, ) # ----------------------------------------------------------------------------------------------------------------- @@ -392,20 +386,14 @@ def setup_function( source_component_output=my_domnestic_hot_water_heatpump.ElectricityOutput, source_load_type=lt.LoadTypes.ELECTRICITY, source_unit=lt.Units.WATT, - source_tags=[ - lt.ComponentType.HEAT_PUMP_DHW, - lt.InandOutputType.ELECTRICITY_CONSUMPTION_EMS_CONTROLLED, - ], + source_tags=[lt.ComponentType.HEAT_PUMP_DHW, lt.InandOutputType.ELECTRICITY_CONSUMPTION_EMS_CONTROLLED,], # source_weight=my_dhw_heatpump_config.source_weight, source_weight=2, ) my_electricity_controller.add_component_output( source_output_name=lt.InandOutputType.ELECTRICITY_TARGET, - source_tags=[ - lt.ComponentType.HEAT_PUMP_DHW, - lt.InandOutputType.ELECTRICITY_TARGET, - ], + source_tags=[lt.ComponentType.HEAT_PUMP_DHW, lt.InandOutputType.ELECTRICITY_TARGET,], # source_weight=my_domnestic_hot_water_heatpump.config.source_weight, source_weight=2, source_load_type=lt.LoadTypes.ELECTRICITY, @@ -445,10 +433,7 @@ def setup_function( my_electricity_controller.add_component_output( source_output_name=lt.InandOutputType.ELECTRICITY_TARGET, - source_tags=[ - lt.ComponentType.HEAT_PUMP_BUILDING, - lt.InandOutputType.ELECTRICITY_TARGET, - ], + source_tags=[lt.ComponentType.HEAT_PUMP_BUILDING, lt.InandOutputType.ELECTRICITY_TARGET,], source_weight=3, source_load_type=lt.LoadTypes.ELECTRICITY, source_unit=lt.Units.WATT, @@ -500,10 +485,7 @@ def setup_function( electricity_to_or_from_battery_target = my_electricity_controller.add_component_output( source_output_name=lt.InandOutputType.ELECTRICITY_TARGET, - source_tags=[ - lt.ComponentType.BATTERY, - lt.InandOutputType.ELECTRICITY_TARGET, - ], + source_tags=[lt.ComponentType.BATTERY, lt.InandOutputType.ELECTRICITY_TARGET,], source_weight=4, source_load_type=lt.LoadTypes.ELECTRICITY, source_unit=lt.Units.WATT, diff --git a/system_setups/household_4a_with_car_priority_advanced_hp_ev_pv.py b/system_setups/household_4a_with_car_priority_advanced_hp_ev_pv.py index 352eb1875..ed2e6efa1 100644 --- a/system_setups/household_4a_with_car_priority_advanced_hp_ev_pv.py +++ b/system_setups/household_4a_with_car_priority_advanced_hp_ev_pv.py @@ -132,7 +132,7 @@ def get_default(cls): hds_config=( heat_distribution_system.HeatDistributionConfig.get_default_heatdistributionsystem_config( water_mass_flow_rate_in_kg_per_second=my_hds_controller_information.water_mass_flow_rate_in_kp_per_second, - absolute_conditioned_floor_area_in_m2=my_building_information.scaled_conditioned_floor_area_in_m2 + absolute_conditioned_floor_area_in_m2=my_building_information.scaled_conditioned_floor_area_in_m2, ) ), hp_controller_config=advanced_heat_pump_hplib.HeatPumpHplibControllerL1Config.get_default_generic_heat_pump_controller_config( @@ -140,8 +140,12 @@ def get_default(cls): ), hp_config=( advanced_heat_pump_hplib.HeatPumpHplibConfig.get_scaled_advanced_hp_lib( - heating_load_of_building_in_watt=Quantity(my_building_information.max_thermal_building_demand_in_watt, Watt), - heating_reference_temperature_in_celsius=Quantity(heating_reference_temperature_in_celsius, Celsius), + heating_load_of_building_in_watt=Quantity( + my_building_information.max_thermal_building_demand_in_watt, Watt + ), + heating_reference_temperature_in_celsius=Quantity( + heating_reference_temperature_in_celsius, Celsius + ), ) ), simple_hot_water_storage_config=( @@ -268,8 +272,7 @@ def setup_function( # Build heat Distribution System Controller my_heat_distribution_controller = heat_distribution_system.HeatDistributionController( - config=my_config.hds_controller_config, - my_simulation_parameters=my_simulation_parameters, + config=my_config.hds_controller_config, my_simulation_parameters=my_simulation_parameters, ) # Build Occupancy @@ -286,14 +289,12 @@ def setup_function( # Build PV my_photovoltaic_system = generic_pv_system.PVSystem( - config=my_config.pv_config, - my_simulation_parameters=my_simulation_parameters, + config=my_config.pv_config, my_simulation_parameters=my_simulation_parameters, ) # Build Building my_building = building.Building( - config=my_config.building_config, - my_simulation_parameters=my_simulation_parameters, + config=my_config.building_config, my_simulation_parameters=my_simulation_parameters, ) # Build Heat Distribution System @@ -306,8 +307,7 @@ def setup_function( my_heat_pump_controller_config.name = "HeatPumpHplibController" my_heat_pump_controller = advanced_heat_pump_hplib.HeatPumpHplibController( - config=my_heat_pump_controller_config, - my_simulation_parameters=my_simulation_parameters, + config=my_heat_pump_controller_config, my_simulation_parameters=my_simulation_parameters, ) # Build Heat Pump @@ -315,14 +315,12 @@ def setup_function( my_heat_pump_config.name = "HeatPumpHPLib" my_heat_pump = advanced_heat_pump_hplib.HeatPumpHplib( - config=my_heat_pump_config, - my_simulation_parameters=my_simulation_parameters, + config=my_heat_pump_config, my_simulation_parameters=my_simulation_parameters, ) # Build Heat Water Storage my_simple_hot_water_storage = simple_water_storage.SimpleHotWaterStorage( - config=my_config.simple_hot_water_storage_config, - my_simulation_parameters=my_simulation_parameters, + config=my_config.simple_hot_water_storage_config, my_simulation_parameters=my_simulation_parameters, ) # Build DHW @@ -341,8 +339,7 @@ def setup_function( ) my_domnestic_hot_water_heatpump_controller = controller_l1_heatpump.L1HeatPumpController( - my_simulation_parameters=my_simulation_parameters, - config=my_dhw_heatpump_controller_config, + my_simulation_parameters=my_simulation_parameters, config=my_dhw_heatpump_controller_config, ) my_domnestic_hot_water_heatpump = generic_heat_pump_modular.ModularHeatPump( @@ -377,8 +374,7 @@ def setup_function( my_car_battery_config.source_weight = car.config.source_weight my_car_battery_config.name = f"CarBattery_{car_number}" my_car_battery = advanced_ev_battery_bslib.CarBattery( - my_simulation_parameters=my_simulation_parameters, - config=my_car_battery_config, + my_simulation_parameters=my_simulation_parameters, config=my_car_battery_config, ) my_car_batteries.append(my_car_battery) @@ -391,8 +387,7 @@ def setup_function( my_car_battery_controller_config.battery_set = 0.4 my_car_battery_controller = controller_l1_generic_ev_charge.L1Controller( - my_simulation_parameters=my_simulation_parameters, - config=my_car_battery_controller_config, + my_simulation_parameters=my_simulation_parameters, config=my_car_battery_controller_config, ) my_car_battery_controllers.append(my_car_battery_controller) @@ -400,14 +395,12 @@ def setup_function( # Build Electricity Meter my_electricity_meter = electricity_meter.ElectricityMeter( - my_simulation_parameters=my_simulation_parameters, - config=my_config.electricity_meter_config, + my_simulation_parameters=my_simulation_parameters, config=my_config.electricity_meter_config, ) # Build EMS my_electricity_controller = controller_l2_energy_management_system.L2GenericEnergyManagementSystem( - my_simulation_parameters=my_simulation_parameters, - config=my_config.electricity_controller_config, + my_simulation_parameters=my_simulation_parameters, config=my_config.electricity_controller_config, ) # ----------------------------------------------------------------------------------------------------------------- @@ -424,20 +417,14 @@ def setup_function( source_component_output=car_battery_controller.BatteryChargingPowerToEMS, source_load_type=lt.LoadTypes.ELECTRICITY, source_unit=lt.Units.WATT, - source_tags=[ - lt.ComponentType.CAR_BATTERY, - lt.InandOutputType.ELECTRICITY_CONSUMPTION_EMS_CONTROLLED, - ], + source_tags=[lt.ComponentType.CAR_BATTERY, lt.InandOutputType.ELECTRICITY_CONSUMPTION_EMS_CONTROLLED,], # source_weight=car_battery.source_weight, source_weight=1, ) electricity_target = my_electricity_controller.add_component_output( source_output_name=lt.InandOutputType.ELECTRICITY_TARGET, - source_tags=[ - lt.ComponentType.CAR_BATTERY, - lt.InandOutputType.ELECTRICITY_TARGET, - ], + source_tags=[lt.ComponentType.CAR_BATTERY, lt.InandOutputType.ELECTRICITY_TARGET,], # source_weight=car_battery_controller.source_weight, source_weight=1, source_load_type=lt.LoadTypes.ELECTRICITY, @@ -455,9 +442,7 @@ def setup_function( source_component_output=car_battery_controller.BatteryChargingPowerToEMS, source_load_type=lt.LoadTypes.ELECTRICITY, source_unit=lt.Units.WATT, - source_tags=[ - lt.InandOutputType.ELECTRICITY_CONSUMPTION_UNCONTROLLED, - ], + source_tags=[lt.InandOutputType.ELECTRICITY_CONSUMPTION_UNCONTROLLED,], source_weight=999, ) @@ -485,20 +470,14 @@ def setup_function( source_component_output=my_domnestic_hot_water_heatpump.ElectricityOutput, source_load_type=lt.LoadTypes.ELECTRICITY, source_unit=lt.Units.WATT, - source_tags=[ - lt.ComponentType.HEAT_PUMP_DHW, - lt.InandOutputType.ELECTRICITY_CONSUMPTION_EMS_CONTROLLED, - ], + source_tags=[lt.ComponentType.HEAT_PUMP_DHW, lt.InandOutputType.ELECTRICITY_CONSUMPTION_EMS_CONTROLLED,], # source_weight=my_dhw_heatpump_config.source_weight, source_weight=2, ) my_electricity_controller.add_component_output( source_output_name=lt.InandOutputType.ELECTRICITY_TARGET, - source_tags=[ - lt.ComponentType.HEAT_PUMP_DHW, - lt.InandOutputType.ELECTRICITY_TARGET, - ], + source_tags=[lt.ComponentType.HEAT_PUMP_DHW, lt.InandOutputType.ELECTRICITY_TARGET,], # source_weight=my_domnestic_hot_water_heatpump.config.source_weight, source_weight=2, source_load_type=lt.LoadTypes.ELECTRICITY, @@ -538,10 +517,7 @@ def setup_function( my_electricity_controller.add_component_output( source_output_name=lt.InandOutputType.ELECTRICITY_TARGET, - source_tags=[ - lt.ComponentType.HEAT_PUMP_BUILDING, - lt.InandOutputType.ELECTRICITY_TARGET, - ], + source_tags=[lt.ComponentType.HEAT_PUMP_BUILDING, lt.InandOutputType.ELECTRICITY_TARGET,], source_weight=3, source_load_type=lt.LoadTypes.ELECTRICITY, source_unit=lt.Units.WATT, diff --git a/system_setups/household_4b_with_heatpump_priority_advanced_hp_ev_pv.py b/system_setups/household_4b_with_heatpump_priority_advanced_hp_ev_pv.py index 390e98c1b..45ce48b97 100644 --- a/system_setups/household_4b_with_heatpump_priority_advanced_hp_ev_pv.py +++ b/system_setups/household_4b_with_heatpump_priority_advanced_hp_ev_pv.py @@ -20,9 +20,7 @@ from hisim.components import controller_l1_generic_ev_charge from hisim.components import controller_l2_energy_management_system from hisim import loadtypes as lt -from system_setups.household_4a_with_car_priority_advanced_hp_ev_pv import ( - HouseholdAdvancedHPEvPvConfig, -) +from system_setups.household_4a_with_car_priority_advanced_hp_ev_pv import HouseholdAdvancedHPEvPvConfig __authors__ = "Markus Blasberg" __copyright__ = "Copyright 2023, FZJ-IEK-3" @@ -89,8 +87,7 @@ def setup_function( # Build heat Distribution System Controller my_heat_distribution_controller = heat_distribution_system.HeatDistributionController( - config=my_config.hds_controller_config, - my_simulation_parameters=my_simulation_parameters, + config=my_config.hds_controller_config, my_simulation_parameters=my_simulation_parameters, ) # Build Occupancy @@ -107,14 +104,12 @@ def setup_function( # Build PV my_photovoltaic_system = generic_pv_system.PVSystem( - config=my_config.pv_config, - my_simulation_parameters=my_simulation_parameters, + config=my_config.pv_config, my_simulation_parameters=my_simulation_parameters, ) # Build Building my_building = building.Building( - config=my_config.building_config, - my_simulation_parameters=my_simulation_parameters, + config=my_config.building_config, my_simulation_parameters=my_simulation_parameters, ) # Build Heat Distribution System @@ -127,8 +122,7 @@ def setup_function( my_heat_pump_controller_config.name = "HeatPumpHplibController" my_heat_pump_controller = advanced_heat_pump_hplib.HeatPumpHplibController( - config=my_heat_pump_controller_config, - my_simulation_parameters=my_simulation_parameters, + config=my_heat_pump_controller_config, my_simulation_parameters=my_simulation_parameters, ) # Build Heat Pump @@ -136,14 +130,12 @@ def setup_function( my_heat_pump_config.name = "HeatPumpHPLib" my_heat_pump = advanced_heat_pump_hplib.HeatPumpHplib( - config=my_heat_pump_config, - my_simulation_parameters=my_simulation_parameters, + config=my_heat_pump_config, my_simulation_parameters=my_simulation_parameters, ) # Build Heat Water Storage my_simple_hot_water_storage = simple_water_storage.SimpleHotWaterStorage( - config=my_config.simple_hot_water_storage_config, - my_simulation_parameters=my_simulation_parameters, + config=my_config.simple_hot_water_storage_config, my_simulation_parameters=my_simulation_parameters, ) # Build DHW @@ -162,8 +154,7 @@ def setup_function( ) my_domnestic_hot_water_heatpump_controller = controller_l1_heatpump.L1HeatPumpController( - my_simulation_parameters=my_simulation_parameters, - config=my_dhw_heatpump_controller_config, + my_simulation_parameters=my_simulation_parameters, config=my_dhw_heatpump_controller_config, ) my_domnestic_hot_water_heatpump = generic_heat_pump_modular.ModularHeatPump( @@ -198,8 +189,7 @@ def setup_function( my_car_battery_config.source_weight = car.config.source_weight my_car_battery_config.name = f"CarBattery_{car_number}" my_car_battery = advanced_ev_battery_bslib.CarBattery( - my_simulation_parameters=my_simulation_parameters, - config=my_car_battery_config, + my_simulation_parameters=my_simulation_parameters, config=my_car_battery_config, ) my_car_batteries.append(my_car_battery) @@ -212,8 +202,7 @@ def setup_function( my_car_battery_controller_config.battery_set = 0.4 my_car_battery_controller = controller_l1_generic_ev_charge.L1Controller( - my_simulation_parameters=my_simulation_parameters, - config=my_car_battery_controller_config, + my_simulation_parameters=my_simulation_parameters, config=my_car_battery_controller_config, ) my_car_battery_controllers.append(my_car_battery_controller) @@ -221,14 +210,12 @@ def setup_function( # Build Electricity Meter my_electricity_meter = electricity_meter.ElectricityMeter( - my_simulation_parameters=my_simulation_parameters, - config=my_config.electricity_meter_config, + my_simulation_parameters=my_simulation_parameters, config=my_config.electricity_meter_config, ) # Build EMS my_electricity_controller = controller_l2_energy_management_system.L2GenericEnergyManagementSystem( - my_simulation_parameters=my_simulation_parameters, - config=my_config.electricity_controller_config, + my_simulation_parameters=my_simulation_parameters, config=my_config.electricity_controller_config, ) # ----------------------------------------------------------------------------------------------------------------- @@ -245,20 +232,14 @@ def setup_function( source_component_output=car_battery_controller.BatteryChargingPowerToEMS, source_load_type=lt.LoadTypes.ELECTRICITY, source_unit=lt.Units.WATT, - source_tags=[ - lt.ComponentType.CAR_BATTERY, - lt.InandOutputType.ELECTRICITY_CONSUMPTION_EMS_CONTROLLED, - ], + source_tags=[lt.ComponentType.CAR_BATTERY, lt.InandOutputType.ELECTRICITY_CONSUMPTION_EMS_CONTROLLED,], # source_weight=car_battery.source_weight, source_weight=3, ) electricity_target = my_electricity_controller.add_component_output( source_output_name=lt.InandOutputType.ELECTRICITY_TARGET, - source_tags=[ - lt.ComponentType.CAR_BATTERY, - lt.InandOutputType.ELECTRICITY_TARGET, - ], + source_tags=[lt.ComponentType.CAR_BATTERY, lt.InandOutputType.ELECTRICITY_TARGET,], # source_weight=car_battery_controller.source_weight, source_weight=3, source_load_type=lt.LoadTypes.ELECTRICITY, @@ -276,9 +257,7 @@ def setup_function( source_component_output=car_battery_controller.BatteryChargingPowerToEMS, source_load_type=lt.LoadTypes.ELECTRICITY, source_unit=lt.Units.WATT, - source_tags=[ - lt.InandOutputType.ELECTRICITY_CONSUMPTION_UNCONTROLLED, - ], + source_tags=[lt.InandOutputType.ELECTRICITY_CONSUMPTION_UNCONTROLLED,], source_weight=999, ) @@ -306,20 +285,14 @@ def setup_function( source_component_output=my_domnestic_hot_water_heatpump.ElectricityOutput, source_load_type=lt.LoadTypes.ELECTRICITY, source_unit=lt.Units.WATT, - source_tags=[ - lt.ComponentType.HEAT_PUMP_DHW, - lt.InandOutputType.ELECTRICITY_CONSUMPTION_EMS_CONTROLLED, - ], + source_tags=[lt.ComponentType.HEAT_PUMP_DHW, lt.InandOutputType.ELECTRICITY_CONSUMPTION_EMS_CONTROLLED,], # source_weight=my_dhw_heatpump_config.source_weight, source_weight=2, ) my_electricity_controller.add_component_output( source_output_name=lt.InandOutputType.ELECTRICITY_TARGET, - source_tags=[ - lt.ComponentType.HEAT_PUMP_DHW, - lt.InandOutputType.ELECTRICITY_TARGET, - ], + source_tags=[lt.ComponentType.HEAT_PUMP_DHW, lt.InandOutputType.ELECTRICITY_TARGET,], # source_weight=my_domnestic_hot_water_heatpump.config.source_weight, source_weight=2, source_load_type=lt.LoadTypes.ELECTRICITY, @@ -359,10 +332,7 @@ def setup_function( my_electricity_controller.add_component_output( source_output_name=lt.InandOutputType.ELECTRICITY_TARGET, - source_tags=[ - lt.ComponentType.HEAT_PUMP_BUILDING, - lt.InandOutputType.ELECTRICITY_TARGET, - ], + source_tags=[lt.ComponentType.HEAT_PUMP_BUILDING, lt.InandOutputType.ELECTRICITY_TARGET,], source_weight=1, source_load_type=lt.LoadTypes.ELECTRICITY, source_unit=lt.Units.WATT, diff --git a/system_setups/household_5a_with_car_priority_advanced_hp_ev_pv_battery.py b/system_setups/household_5a_with_car_priority_advanced_hp_ev_pv_battery.py index 7c28a9e3e..e47854289 100644 --- a/system_setups/household_5a_with_car_priority_advanced_hp_ev_pv_battery.py +++ b/system_setups/household_5a_with_car_priority_advanced_hp_ev_pv_battery.py @@ -136,7 +136,7 @@ def get_default(cls): hds_config=( heat_distribution_system.HeatDistributionConfig.get_default_heatdistributionsystem_config( water_mass_flow_rate_in_kg_per_second=my_hds_controller_information.water_mass_flow_rate_in_kp_per_second, - absolute_conditioned_floor_area_in_m2=my_building_information.scaled_conditioned_floor_area_in_m2 + absolute_conditioned_floor_area_in_m2=my_building_information.scaled_conditioned_floor_area_in_m2, ) ), hp_controller_config=advanced_heat_pump_hplib.HeatPumpHplibControllerL1Config.get_default_generic_heat_pump_controller_config( @@ -144,8 +144,12 @@ def get_default(cls): ), hp_config=( advanced_heat_pump_hplib.HeatPumpHplibConfig.get_scaled_advanced_hp_lib( - heating_load_of_building_in_watt=Quantity(my_building_information.max_thermal_building_demand_in_watt, Watt), - heating_reference_temperature_in_celsius=Quantity(heating_reference_temperature_in_celsius, Celsius), + heating_load_of_building_in_watt=Quantity( + my_building_information.max_thermal_building_demand_in_watt, Watt + ), + heating_reference_temperature_in_celsius=Quantity( + heating_reference_temperature_in_celsius, Celsius + ), ) ), simple_hot_water_storage_config=( @@ -276,8 +280,7 @@ def setup_function( # Build heat Distribution System Controller my_heat_distribution_controller = heat_distribution_system.HeatDistributionController( - config=my_config.hds_controller_config, - my_simulation_parameters=my_simulation_parameters, + config=my_config.hds_controller_config, my_simulation_parameters=my_simulation_parameters, ) # Build Occupancy @@ -294,14 +297,12 @@ def setup_function( # Build PV my_photovoltaic_system = generic_pv_system.PVSystem( - config=my_config.pv_config, - my_simulation_parameters=my_simulation_parameters, + config=my_config.pv_config, my_simulation_parameters=my_simulation_parameters, ) # Build Building my_building = building.Building( - config=my_config.building_config, - my_simulation_parameters=my_simulation_parameters, + config=my_config.building_config, my_simulation_parameters=my_simulation_parameters, ) # Build Heat Distribution System @@ -314,8 +315,7 @@ def setup_function( my_heat_pump_controller_config.name = "HeatPumpHplibController" my_heat_pump_controller = advanced_heat_pump_hplib.HeatPumpHplibController( - config=my_heat_pump_controller_config, - my_simulation_parameters=my_simulation_parameters, + config=my_heat_pump_controller_config, my_simulation_parameters=my_simulation_parameters, ) # Build Heat Pump @@ -323,14 +323,12 @@ def setup_function( my_heat_pump_config.name = "HeatPumpHPLib" my_heat_pump = advanced_heat_pump_hplib.HeatPumpHplib( - config=my_heat_pump_config, - my_simulation_parameters=my_simulation_parameters, + config=my_heat_pump_config, my_simulation_parameters=my_simulation_parameters, ) # Build Heat Water Storage my_simple_hot_water_storage = simple_water_storage.SimpleHotWaterStorage( - config=my_config.simple_hot_water_storage_config, - my_simulation_parameters=my_simulation_parameters, + config=my_config.simple_hot_water_storage_config, my_simulation_parameters=my_simulation_parameters, ) # Build DHW @@ -349,8 +347,7 @@ def setup_function( ) my_domnestic_hot_water_heatpump_controller = controller_l1_heatpump.L1HeatPumpController( - my_simulation_parameters=my_simulation_parameters, - config=my_dhw_heatpump_controller_config, + my_simulation_parameters=my_simulation_parameters, config=my_dhw_heatpump_controller_config, ) my_domnestic_hot_water_heatpump = generic_heat_pump_modular.ModularHeatPump( @@ -385,8 +382,7 @@ def setup_function( my_car_battery_config.source_weight = car.config.source_weight my_car_battery_config.name = f"CarBattery_{car_number}" my_car_battery = advanced_ev_battery_bslib.CarBattery( - my_simulation_parameters=my_simulation_parameters, - config=my_car_battery_config, + my_simulation_parameters=my_simulation_parameters, config=my_car_battery_config, ) my_car_batteries.append(my_car_battery) @@ -399,8 +395,7 @@ def setup_function( my_car_battery_controller_config.battery_set = 0.4 my_car_battery_controller = controller_l1_generic_ev_charge.L1Controller( - my_simulation_parameters=my_simulation_parameters, - config=my_car_battery_controller_config, + my_simulation_parameters=my_simulation_parameters, config=my_car_battery_controller_config, ) my_car_battery_controllers.append(my_car_battery_controller) @@ -408,20 +403,17 @@ def setup_function( # Build Electricity Meter my_electricity_meter = electricity_meter.ElectricityMeter( - my_simulation_parameters=my_simulation_parameters, - config=my_config.electricity_meter_config, + my_simulation_parameters=my_simulation_parameters, config=my_config.electricity_meter_config, ) # Build EMS my_electricity_controller = controller_l2_energy_management_system.L2GenericEnergyManagementSystem( - my_simulation_parameters=my_simulation_parameters, - config=my_config.electricity_controller_config, + my_simulation_parameters=my_simulation_parameters, config=my_config.electricity_controller_config, ) # Build Battery my_advanced_battery = advanced_battery_bslib.Battery( - my_simulation_parameters=my_simulation_parameters, - config=my_config.advanced_battery_config, + my_simulation_parameters=my_simulation_parameters, config=my_config.advanced_battery_config, ) # ----------------------------------------------------------------------------------------------------------------- @@ -438,20 +430,14 @@ def setup_function( source_component_output=car_battery_controller.BatteryChargingPowerToEMS, source_load_type=lt.LoadTypes.ELECTRICITY, source_unit=lt.Units.WATT, - source_tags=[ - lt.ComponentType.CAR_BATTERY, - lt.InandOutputType.ELECTRICITY_CONSUMPTION_EMS_CONTROLLED, - ], + source_tags=[lt.ComponentType.CAR_BATTERY, lt.InandOutputType.ELECTRICITY_CONSUMPTION_EMS_CONTROLLED,], # source_weight=car_battery.source_weight, source_weight=1, ) electricity_target = my_electricity_controller.add_component_output( source_output_name=lt.InandOutputType.ELECTRICITY_TARGET, - source_tags=[ - lt.ComponentType.CAR_BATTERY, - lt.InandOutputType.ELECTRICITY_TARGET, - ], + source_tags=[lt.ComponentType.CAR_BATTERY, lt.InandOutputType.ELECTRICITY_TARGET,], # source_weight=car_battery_controller.source_weight, source_weight=1, source_load_type=lt.LoadTypes.ELECTRICITY, @@ -469,9 +455,7 @@ def setup_function( source_component_output=car_battery_controller.BatteryChargingPowerToEMS, source_load_type=lt.LoadTypes.ELECTRICITY, source_unit=lt.Units.WATT, - source_tags=[ - lt.InandOutputType.ELECTRICITY_CONSUMPTION_UNCONTROLLED, - ], + source_tags=[lt.InandOutputType.ELECTRICITY_CONSUMPTION_UNCONTROLLED,], source_weight=999, ) @@ -499,20 +483,14 @@ def setup_function( source_component_output=my_domnestic_hot_water_heatpump.ElectricityOutput, source_load_type=lt.LoadTypes.ELECTRICITY, source_unit=lt.Units.WATT, - source_tags=[ - lt.ComponentType.HEAT_PUMP_DHW, - lt.InandOutputType.ELECTRICITY_CONSUMPTION_EMS_CONTROLLED, - ], + source_tags=[lt.ComponentType.HEAT_PUMP_DHW, lt.InandOutputType.ELECTRICITY_CONSUMPTION_EMS_CONTROLLED,], # source_weight=my_dhw_heatpump_config.source_weight, source_weight=2, ) my_electricity_controller.add_component_output( source_output_name=lt.InandOutputType.ELECTRICITY_TARGET, - source_tags=[ - lt.ComponentType.HEAT_PUMP_DHW, - lt.InandOutputType.ELECTRICITY_TARGET, - ], + source_tags=[lt.ComponentType.HEAT_PUMP_DHW, lt.InandOutputType.ELECTRICITY_TARGET,], # source_weight=my_domnestic_hot_water_heatpump.config.source_weight, source_weight=2, source_load_type=lt.LoadTypes.ELECTRICITY, @@ -552,10 +530,7 @@ def setup_function( my_electricity_controller.add_component_output( source_output_name=lt.InandOutputType.ELECTRICITY_TARGET, - source_tags=[ - lt.ComponentType.HEAT_PUMP_BUILDING, - lt.InandOutputType.ELECTRICITY_TARGET, - ], + source_tags=[lt.ComponentType.HEAT_PUMP_BUILDING, lt.InandOutputType.ELECTRICITY_TARGET,], source_weight=3, source_load_type=lt.LoadTypes.ELECTRICITY, source_unit=lt.Units.WATT, @@ -607,10 +582,7 @@ def setup_function( electricity_to_or_from_battery_target = my_electricity_controller.add_component_output( source_output_name=lt.InandOutputType.ELECTRICITY_TARGET, - source_tags=[ - lt.ComponentType.BATTERY, - lt.InandOutputType.ELECTRICITY_TARGET, - ], + source_tags=[lt.ComponentType.BATTERY, lt.InandOutputType.ELECTRICITY_TARGET,], source_weight=4, source_load_type=lt.LoadTypes.ELECTRICITY, source_unit=lt.Units.WATT, diff --git a/system_setups/household_5b_with_battery_priority_advanced_hp_ev_pv_battery.py b/system_setups/household_5b_with_battery_priority_advanced_hp_ev_pv_battery.py index b980a429d..e8b19a28e 100644 --- a/system_setups/household_5b_with_battery_priority_advanced_hp_ev_pv_battery.py +++ b/system_setups/household_5b_with_battery_priority_advanced_hp_ev_pv_battery.py @@ -22,9 +22,7 @@ from hisim.components import controller_l1_generic_ev_charge from hisim.components import controller_l2_energy_management_system from hisim import loadtypes as lt -from system_setups.household_5a_with_car_priority_advanced_hp_ev_pv_battery import ( - HouseholdAdvancedHpEvPvBatteryConfig, -) +from system_setups.household_5a_with_car_priority_advanced_hp_ev_pv_battery import HouseholdAdvancedHpEvPvBatteryConfig __authors__ = "Markus Blasberg" __copyright__ = "Copyright 2023, FZJ-IEK-3" @@ -92,8 +90,7 @@ def setup_function( # Build heat Distribution System Controller my_heat_distribution_controller = heat_distribution_system.HeatDistributionController( - config=my_config.hds_controller_config, - my_simulation_parameters=my_simulation_parameters, + config=my_config.hds_controller_config, my_simulation_parameters=my_simulation_parameters, ) # Build Occupancy @@ -110,14 +107,12 @@ def setup_function( # Build PV my_photovoltaic_system = generic_pv_system.PVSystem( - config=my_config.pv_config, - my_simulation_parameters=my_simulation_parameters, + config=my_config.pv_config, my_simulation_parameters=my_simulation_parameters, ) # Build Building my_building = building.Building( - config=my_config.building_config, - my_simulation_parameters=my_simulation_parameters, + config=my_config.building_config, my_simulation_parameters=my_simulation_parameters, ) # Build Heat Distribution System @@ -130,8 +125,7 @@ def setup_function( my_heat_pump_controller_config.name = "HeatPumpHplibController" my_heat_pump_controller = advanced_heat_pump_hplib.HeatPumpHplibController( - config=my_heat_pump_controller_config, - my_simulation_parameters=my_simulation_parameters, + config=my_heat_pump_controller_config, my_simulation_parameters=my_simulation_parameters, ) # Build Heat Pump @@ -139,14 +133,12 @@ def setup_function( my_heat_pump_config.name = "HeatPumpHPLib" my_heat_pump = advanced_heat_pump_hplib.HeatPumpHplib( - config=my_heat_pump_config, - my_simulation_parameters=my_simulation_parameters, + config=my_heat_pump_config, my_simulation_parameters=my_simulation_parameters, ) # Build Heat Water Storage my_simple_hot_water_storage = simple_water_storage.SimpleHotWaterStorage( - config=my_config.simple_hot_water_storage_config, - my_simulation_parameters=my_simulation_parameters, + config=my_config.simple_hot_water_storage_config, my_simulation_parameters=my_simulation_parameters, ) # Build DHW @@ -165,8 +157,7 @@ def setup_function( ) my_domnestic_hot_water_heatpump_controller = controller_l1_heatpump.L1HeatPumpController( - my_simulation_parameters=my_simulation_parameters, - config=my_dhw_heatpump_controller_config, + my_simulation_parameters=my_simulation_parameters, config=my_dhw_heatpump_controller_config, ) my_domnestic_hot_water_heatpump = generic_heat_pump_modular.ModularHeatPump( @@ -195,7 +186,7 @@ def setup_function( my_car = generic_car.Car( my_simulation_parameters=my_simulation_parameters, config=my_car_config, - data_dict_with_car_information=car_information_dict + data_dict_with_car_information=car_information_dict, ) my_cars.append(my_car) # Build Electric Vehicle Batteries @@ -217,20 +208,17 @@ def setup_function( # Build Electricity Meter my_electricity_meter = electricity_meter.ElectricityMeter( - my_simulation_parameters=my_simulation_parameters, - config=my_config.electricity_meter_config, + my_simulation_parameters=my_simulation_parameters, config=my_config.electricity_meter_config, ) # Build EMS my_electricity_controller = controller_l2_energy_management_system.L2GenericEnergyManagementSystem( - my_simulation_parameters=my_simulation_parameters, - config=my_config.electricity_controller_config, + my_simulation_parameters=my_simulation_parameters, config=my_config.electricity_controller_config, ) # Build Battery my_advanced_battery = advanced_battery_bslib.Battery( - my_simulation_parameters=my_simulation_parameters, - config=my_config.advanced_battery_config, + my_simulation_parameters=my_simulation_parameters, config=my_config.advanced_battery_config, ) # ----------------------------------------------------------------------------------------------------------------- @@ -247,20 +235,14 @@ def setup_function( source_component_output=car_battery_controller.BatteryChargingPowerToEMS, source_load_type=lt.LoadTypes.ELECTRICITY, source_unit=lt.Units.WATT, - source_tags=[ - lt.ComponentType.CAR_BATTERY, - lt.InandOutputType.ELECTRICITY_CONSUMPTION_EMS_CONTROLLED, - ], + source_tags=[lt.ComponentType.CAR_BATTERY, lt.InandOutputType.ELECTRICITY_CONSUMPTION_EMS_CONTROLLED,], # source_weight=car_battery.source_weight, source_weight=4, ) electricity_target = my_electricity_controller.add_component_output( source_output_name=lt.InandOutputType.ELECTRICITY_TARGET, - source_tags=[ - lt.ComponentType.CAR_BATTERY, - lt.InandOutputType.ELECTRICITY_TARGET, - ], + source_tags=[lt.ComponentType.CAR_BATTERY, lt.InandOutputType.ELECTRICITY_TARGET,], # source_weight=car_battery_controller.source_weight, source_weight=4, source_load_type=lt.LoadTypes.ELECTRICITY, @@ -278,9 +260,7 @@ def setup_function( source_component_output=car_battery_controller.BatteryChargingPowerToEMS, source_load_type=lt.LoadTypes.ELECTRICITY, source_unit=lt.Units.WATT, - source_tags=[ - lt.InandOutputType.ELECTRICITY_CONSUMPTION_UNCONTROLLED, - ], + source_tags=[lt.InandOutputType.ELECTRICITY_CONSUMPTION_UNCONTROLLED,], source_weight=999, ) @@ -308,20 +288,14 @@ def setup_function( source_component_output=my_domnestic_hot_water_heatpump.ElectricityOutput, source_load_type=lt.LoadTypes.ELECTRICITY, source_unit=lt.Units.WATT, - source_tags=[ - lt.ComponentType.HEAT_PUMP_DHW, - lt.InandOutputType.ELECTRICITY_CONSUMPTION_EMS_CONTROLLED, - ], + source_tags=[lt.ComponentType.HEAT_PUMP_DHW, lt.InandOutputType.ELECTRICITY_CONSUMPTION_EMS_CONTROLLED,], # source_weight=my_dhw_heatpump_config.source_weight, source_weight=3, ) my_electricity_controller.add_component_output( source_output_name=lt.InandOutputType.ELECTRICITY_TARGET, - source_tags=[ - lt.ComponentType.HEAT_PUMP_DHW, - lt.InandOutputType.ELECTRICITY_TARGET, - ], + source_tags=[lt.ComponentType.HEAT_PUMP_DHW, lt.InandOutputType.ELECTRICITY_TARGET,], # source_weight=my_domnestic_hot_water_heatpump.config.source_weight, source_weight=3, source_load_type=lt.LoadTypes.ELECTRICITY, @@ -361,10 +335,7 @@ def setup_function( my_electricity_controller.add_component_output( source_output_name=lt.InandOutputType.ELECTRICITY_TARGET, - source_tags=[ - lt.ComponentType.HEAT_PUMP_BUILDING, - lt.InandOutputType.ELECTRICITY_TARGET, - ], + source_tags=[lt.ComponentType.HEAT_PUMP_BUILDING, lt.InandOutputType.ELECTRICITY_TARGET,], source_weight=2, source_load_type=lt.LoadTypes.ELECTRICITY, source_unit=lt.Units.WATT, @@ -416,10 +387,7 @@ def setup_function( electricity_to_or_from_battery_target = my_electricity_controller.add_component_output( source_output_name=lt.InandOutputType.ELECTRICITY_TARGET, - source_tags=[ - lt.ComponentType.BATTERY, - lt.InandOutputType.ELECTRICITY_TARGET, - ], + source_tags=[lt.ComponentType.BATTERY, lt.InandOutputType.ELECTRICITY_TARGET,], source_weight=1, source_load_type=lt.LoadTypes.ELECTRICITY, source_unit=lt.Units.WATT, diff --git a/system_setups/household_district_heating_building_sizer.py b/system_setups/household_district_heating_building_sizer.py new file mode 100644 index 000000000..b5b7b0f15 --- /dev/null +++ b/system_setups/household_district_heating_building_sizer.py @@ -0,0 +1,509 @@ +""" Basic household new system setup. """ + +# clean + +from typing import Optional, Any, Union, List +import re +import os +from utspclient.helpers.lpgdata import ( + ChargingStationSets, + Households, +) +from utspclient.helpers.lpgpythonbindings import JsonReference +from hisim.simulator import SimulationParameters +from hisim.components import loadprofilegenerator_utsp_connector +from hisim.components import weather +from hisim.components import generic_pv_system +from hisim.components import building +from hisim.components import ( + advanced_battery_bslib, + controller_l2_energy_management_system, + heat_distribution_system, + generic_district_heating, + generic_hot_water_storage_modular, + controller_l1_heatpump, + electricity_meter, + advanced_ev_battery_bslib, + controller_l1_generic_ev_charge, + generic_car, + generic_heat_source, +) +from hisim.components.heat_distribution_system import PositionHotWaterStorageInSystemSetup +from hisim.result_path_provider import ResultPathProviderSingleton, SortingOptionEnum +from hisim.sim_repository_singleton import SingletonSimRepository, SingletonDictKeyEnum +from hisim.postprocessingoptions import PostProcessingOptions +from hisim import loadtypes as lt +from hisim.loadtypes import HeatingSystems +from hisim.building_sizer_utils.interface_configs.modular_household_config import ( + read_in_configs, + ModularHouseholdConfig, +) +from hisim import log + +__authors__ = "Katharina Rieck" +__copyright__ = "Copyright 2022, FZJ-IEK-3" +__credits__ = ["Noah Pflugradt"] +__license__ = "MIT" +__version__ = "1.0" +__maintainer__ = "Noah Pflugradt" +__status__ = "development" + + +def setup_function( + my_sim: Any, my_simulation_parameters: Optional[SimulationParameters] = None +) -> None: # noqa: too-many-statements + """Household system setup. + + This setup function emulates an household including the following components: + + - Simulation Parameters + - Components + - Occupancy (Residents' Demands) + - Weather + - Photovoltaic System + - Building + - District Heating + - Heat Distribution System + - Heat Distribution Controller + - Battery + - Energy Management System + - Electricity Meter + - Electric Vehicles (including car batteries and car battery controllers) + """ + + # ================================================================================================================================= + # Set System Parameters from Config + + # household-pv-config + config_filename = my_sim.my_module_config + # try reading energ system and archetype configs + my_config = read_in_configs(my_sim.my_module_config) + + if my_config is None: + my_config = ModularHouseholdConfig().get_default_config_for_household_district_heating() + log.warning( + f"Could not read the modular household config from path '{config_filename}'. Using the district heating household default config instead." + ) + assert my_config.archetype_config_ is not None + assert my_config.energy_system_config_ is not None + arche_type_config_ = my_config.archetype_config_ + energy_system_config_ = my_config.energy_system_config_ + + # Set Simulation Parameters + if my_simulation_parameters is None: + year = 2021 + seconds_per_timestep = 60 * 15 + my_simulation_parameters = SimulationParameters.full_year(year=year, seconds_per_timestep=seconds_per_timestep) + cache_dir_path_simuparams = "/benchtop/2024-k-rieck-hisim/hisim_inputs_cache/" + if os.path.exists(cache_dir_path_simuparams): + my_simulation_parameters.cache_dir_path = cache_dir_path_simuparams + my_simulation_parameters.post_processing_options.append( + PostProcessingOptions.PREPARE_OUTPUTS_FOR_SCENARIO_EVALUATION + ) + my_simulation_parameters.post_processing_options.append(PostProcessingOptions.COMPUTE_OPEX) + my_simulation_parameters.post_processing_options.append(PostProcessingOptions.COMPUTE_CAPEX) + my_simulation_parameters.post_processing_options.append(PostProcessingOptions.COMPUTE_KPIS) + my_simulation_parameters.post_processing_options.append(PostProcessingOptions.WRITE_KPIS_TO_JSON) + my_simulation_parameters.post_processing_options.append( + PostProcessingOptions.WRITE_KPIS_TO_JSON_FOR_BUILDING_SIZER + ) + my_simulation_parameters.post_processing_options.append(PostProcessingOptions.MAKE_NETWORK_CHARTS) + my_simulation_parameters.post_processing_options.append(PostProcessingOptions.PLOT_LINE) + my_simulation_parameters.post_processing_options.append(PostProcessingOptions.PLOT_CARPET) + # my_simulation_parameters.post_processing_options.append(PostProcessingOptions.EXPORT_TO_CSV) + # my_simulation_parameters.logging_level = 4 + + my_sim.set_simulation_parameters(my_simulation_parameters) + + # ================================================================================================================================= + # Set System Parameters + + # Set heating systems for space heating and domestic hot water + heating_system = energy_system_config_.heating_system + if heating_system != HeatingSystems.DISTRICT_HEATING: + raise ValueError( + f"Heating system was set as {heating_system} but needs to be {HeatingSystems.DISTRICT_HEATING.value} for this system setup." + ) + + heating_reference_temperature_in_celsius = -7.0 + + # Set Weather + weather_location = arche_type_config_.weather_location + + # Set Photovoltaic System + azimuth = arche_type_config_.pv_azimuth + tilt = arche_type_config_.pv_tilt + if arche_type_config_.pv_rooftop_capacity_in_kilowatt is not None: + pv_power_in_watt = arche_type_config_.pv_rooftop_capacity_in_kilowatt * 1000 + else: + pv_power_in_watt = None + share_of_maximum_pv_potential = energy_system_config_.share_of_maximum_pv_potential + + # Set Building (scale building according to total base area and not absolute floor area) + building_code = arche_type_config_.building_code + total_base_area_in_m2 = None + absolute_conditioned_floor_area_in_m2 = arche_type_config_.conditioned_floor_area_in_m2 + number_of_apartments = arche_type_config_.number_of_dwellings_per_building + if arche_type_config_.norm_heating_load_in_kilowatt is not None: + max_thermal_building_demand_in_watt = arche_type_config_.norm_heating_load_in_kilowatt * 1000 + else: + max_thermal_building_demand_in_watt = None + + # Set Occupancy + # try to get profiles from cluster directory + cache_dir_path_utsp: Optional[str] = "/benchtop/2024-k-rieck-hisim/lpg-utsp-cache" + if cache_dir_path_utsp is not None and os.path.exists(cache_dir_path_utsp): + pass + # else use default specific cache_dir_path + else: + cache_dir_path_utsp = None + + # get household attribute jsonreferences from list of strings + lpg_households: Union[JsonReference, List[JsonReference]] + if isinstance(arche_type_config_.lpg_households, List): + if len(arche_type_config_.lpg_households) == 1: + lpg_households = getattr(Households, arche_type_config_.lpg_households[0]) + elif len(arche_type_config_.lpg_households) > 1: + lpg_households = [] + for household_string in arche_type_config_.lpg_households: + if hasattr(Households, household_string): + lpg_household = getattr(Households, household_string) + lpg_households.append(lpg_household) + print(lpg_household) + else: + raise ValueError("Config list with lpg household is empty.") + else: + raise TypeError(f"Type {type(arche_type_config_.lpg_households)} is incompatible. Should be List[str].") + + # Set Electric Vehicle + charging_station_set = ChargingStationSets.Charging_At_Home_with_11_kW + charging_power = float((charging_station_set.Name or "").split("with ")[1].split(" kW")[0]) + + # ================================================================================================================================= + # Build Basic Components + # Build Building + my_building_config = building.BuildingConfig.get_default_german_single_family_home( + heating_reference_temperature_in_celsius=heating_reference_temperature_in_celsius, + max_thermal_building_demand_in_watt=max_thermal_building_demand_in_watt, + ) + my_building_config.building_code = building_code + my_building_config.total_base_area_in_m2 = total_base_area_in_m2 + my_building_config.absolute_conditioned_floor_area_in_m2 = absolute_conditioned_floor_area_in_m2 + my_building_config.number_of_apartments = number_of_apartments + my_building_config.enable_opening_windows = True + my_building_information = building.BuildingInformation(config=my_building_config) + my_building = building.Building(config=my_building_config, my_simulation_parameters=my_simulation_parameters) + # Add to simulator + my_sim.add_component(my_building, connect_automatically=True) + + # Build Occupancy + my_occupancy_config = loadprofilegenerator_utsp_connector.UtspLpgConnectorConfig.get_default_utsp_connector_config() + my_occupancy_config.data_acquisition_mode = loadprofilegenerator_utsp_connector.LpgDataAcquisitionMode.USE_UTSP + my_occupancy_config.household = lpg_households + my_occupancy_config.cache_dir_path = cache_dir_path_utsp + + my_occupancy = loadprofilegenerator_utsp_connector.UtspLpgConnector( + config=my_occupancy_config, my_simulation_parameters=my_simulation_parameters + ) + # Add to simulator + my_sim.add_component(my_occupancy) + + # Build Weather + my_weather_config = weather.WeatherConfig.get_default(location_entry=weather_location) + my_weather = weather.Weather(config=my_weather_config, my_simulation_parameters=my_simulation_parameters) + # Add to simulator + my_sim.add_component(my_weather) + + # Build PV + if pv_power_in_watt is None: + my_photovoltaic_system_config = generic_pv_system.PVSystemConfig.get_scaled_pv_system( + rooftop_area_in_m2=my_building_information.scaled_rooftop_area_in_m2, + share_of_maximum_pv_potential=share_of_maximum_pv_potential, + location=weather_location, + ) + else: + my_photovoltaic_system_config = generic_pv_system.PVSystemConfig.get_default_pv_system( + power_in_watt=pv_power_in_watt, + share_of_maximum_pv_potential=share_of_maximum_pv_potential, + location=weather_location, + ) + + my_photovoltaic_system_config.azimuth = azimuth + my_photovoltaic_system_config.tilt = tilt + + my_photovoltaic_system = generic_pv_system.PVSystem( + config=my_photovoltaic_system_config, my_simulation_parameters=my_simulation_parameters, + ) + # Add to simulator + my_sim.add_component(my_photovoltaic_system, connect_automatically=True) + + # Build Heat Distribution Controller + my_heat_distribution_controller_config = heat_distribution_system.HeatDistributionControllerConfig.get_default_heat_distribution_controller_config( + set_heating_temperature_for_building_in_celsius=my_building_information.set_heating_temperature_for_building_in_celsius, + set_cooling_temperature_for_building_in_celsius=my_building_information.set_cooling_temperature_for_building_in_celsius, + heating_load_of_building_in_watt=my_building_information.max_thermal_building_demand_in_watt, + heating_reference_temperature_in_celsius=heating_reference_temperature_in_celsius, + ) + # my_heat_distribution_controller_config.heating_system = heat_distribution_system.HeatDistributionSystemType.RADIATOR + + my_heat_distribution_controller = heat_distribution_system.HeatDistributionController( + my_simulation_parameters=my_simulation_parameters, config=my_heat_distribution_controller_config, + ) + my_hds_controller_information = heat_distribution_system.HeatDistributionControllerInformation( + config=my_heat_distribution_controller_config + ) + # Add to simulator + my_sim.add_component(my_heat_distribution_controller, connect_automatically=True) + + # Build district heating controller + my_district_heating_controller_sh_config = generic_district_heating.DistrictHeatingControllerConfig.get_scaled_district_heating_controller_config( + heating_load_of_building_in_watt=my_building_information.max_thermal_building_demand_in_watt + ) + my_district_heating_controller = generic_district_heating.DistrictHeatingController( + my_simulation_parameters=my_simulation_parameters, config=my_district_heating_controller_sh_config + ) + my_sim.add_component(my_district_heating_controller, connect_automatically=True) + + # Build district heating For Space Heating + my_district_heating_sh_config = generic_district_heating.DistrictHeatingConfig.get_scaled_district_heating_config( + heating_load_of_building_in_watt=my_building_information.max_thermal_building_demand_in_watt + ) + my_district_heating = generic_district_heating.DistrictHeating( + config=my_district_heating_sh_config, my_simulation_parameters=my_simulation_parameters + ) + my_sim.add_component(my_district_heating, connect_automatically=True) + + # Build district heating for DHW + my_district_heating_for_dhw_config = generic_heat_source.HeatSourceConfig.get_default_config_waterheating( + heating_system=lt.HeatingSystems.DISTRICT_HEATING, + max_warm_water_demand_in_liter=my_occupancy.max_hot_water_demand, + scaling_factor_according_to_number_of_apartments=my_occupancy.scaling_factor_according_to_number_of_apartments, + seconds_per_timestep=my_simulation_parameters.seconds_per_timestep, + name="DHW" + lt.HeatingSystems.DISTRICT_HEATING.value + ) + my_district_heating_controller_dhw_config = controller_l1_heatpump.L1HeatPumpConfig.get_default_config_heat_source_controller_dhw( + "DHW" + lt.HeatingSystems.DISTRICT_HEATING.value + "Controller" + ) + my_boiler_config = generic_hot_water_storage_modular.StorageConfig.get_scaled_config_for_boiler_to_number_of_apartments( + number_of_apartments=my_building_information.number_of_apartments + ) + my_boiler_config.compute_default_cycle( + temperature_difference_in_kelvin=my_district_heating_controller_dhw_config.t_max_heating_in_celsius + - my_district_heating_controller_dhw_config.t_min_heating_in_celsius + ) + + my_boiler_for_dhw = generic_hot_water_storage_modular.HotWaterStorage( + my_simulation_parameters=my_simulation_parameters, config=my_boiler_config + ) + + my_district_heating_controller_for_dhw = controller_l1_heatpump.L1HeatPumpController( + my_simulation_parameters=my_simulation_parameters, config=my_district_heating_controller_dhw_config + ) + + my_district_heating_for_dhw = generic_heat_source.HeatSource( + config=my_district_heating_for_dhw_config, my_simulation_parameters=my_simulation_parameters + ) + my_sim.add_component(my_district_heating_for_dhw, connect_automatically=True) + my_sim.add_component(my_boiler_for_dhw, connect_automatically=True) + my_sim.add_component(my_district_heating_controller_for_dhw, connect_automatically=True) + + # Build Heat Distribution System + my_heat_distribution_system_config = heat_distribution_system.HeatDistributionConfig.get_default_heatdistributionsystem_config( + water_mass_flow_rate_in_kg_per_second=my_hds_controller_information.water_mass_flow_rate_in_kp_per_second, + absolute_conditioned_floor_area_in_m2=my_building_information.scaled_conditioned_floor_area_in_m2, + position_hot_water_storage_in_system=PositionHotWaterStorageInSystemSetup.NO_STORAGE, + ) + my_heat_distribution_system = heat_distribution_system.HeatDistribution( + config=my_heat_distribution_system_config, my_simulation_parameters=my_simulation_parameters, + ) + # Add to simulator + my_sim.add_component(my_heat_distribution_system, connect_automatically=True) + + # Build Electricity Meter + my_electricity_meter = electricity_meter.ElectricityMeter( + my_simulation_parameters=my_simulation_parameters, + config=electricity_meter.ElectricityMeterConfig.get_electricity_meter_default_config(), + ) + + # Build Electric Vehicle Configs and Car Battery Configs + my_car_config = generic_car.CarConfig.get_default_ev_config() + my_car_battery_config = advanced_ev_battery_bslib.CarBatteryConfig.get_default_config() + my_car_battery_controller_config = controller_l1_generic_ev_charge.ChargingStationConfig.get_default_config( + charging_station_set=charging_station_set + ) + # set car config name + my_car_config.name = "ElectricCar" + # set charging power from battery and controller to same value, to reduce error in simulation of battery + my_car_battery_config.p_inv_custom = charging_power * 1e3 + # lower threshold for soc of car battery in clever case. This enables more surplus charging. Surplus control of car + my_car_battery_controller_config.battery_set = 0.6 + # Build Electric Vehicles + my_car_information = generic_car.GenericCarInformation(my_occupancy_instance=my_occupancy) + my_cars: List[generic_car.Car] = [] + my_car_batteries: List[advanced_ev_battery_bslib.CarBattery] = [] + my_car_battery_controllers: List[controller_l1_generic_ev_charge.L1Controller] = [] + # iterate over all cars + car_number = 1 + for car_information_dict in my_car_information.data_dict_for_car_component.values(): + # Build Electric Vehicles + my_car_config.name = f"ElectricCar_{car_number}" + my_car = generic_car.Car( + my_simulation_parameters=my_simulation_parameters, + config=my_car_config, + data_dict_with_car_information=car_information_dict, + ) + my_cars.append(my_car) + # Build Electric Vehicle Batteries + my_car_battery_config.source_weight = my_car.config.source_weight + my_car_battery_config.name = f"CarBattery_{car_number}" + my_car_battery = advanced_ev_battery_bslib.CarBattery( + my_simulation_parameters=my_simulation_parameters, config=my_car_battery_config, + ) + my_car_batteries.append(my_car_battery) + # Build Electric Vehicle Battery Controller + my_car_battery_controller_config.source_weight = my_car.config.source_weight + my_car_battery_controller_config.name = f"L1EVChargeControl_{car_number}" + + my_car_battery_controller = controller_l1_generic_ev_charge.L1Controller( + my_simulation_parameters=my_simulation_parameters, config=my_car_battery_controller_config, + ) + my_car_battery_controllers.append(my_car_battery_controller) + car_number += 1 + + # Connect Electric Vehicles and Car Batteries + zip_car_battery_controller_lists = list(zip(my_cars, my_car_batteries, my_car_battery_controllers)) + for car, car_battery, car_battery_controller in zip_car_battery_controller_lists: + car_battery_controller.connect_only_predefined_connections(car) + car_battery_controller.connect_only_predefined_connections(car_battery) + car_battery.connect_only_predefined_connections(car_battery_controller) + + # use ems and battery only when PV is used + if share_of_maximum_pv_potential != 0: + + # Build EMS + my_electricity_controller_config = controller_l2_energy_management_system.EMSConfig.get_default_config_ems() + + my_electricity_controller = controller_l2_energy_management_system.L2GenericEnergyManagementSystem( + my_simulation_parameters=my_simulation_parameters, config=my_electricity_controller_config, + ) + + # Build Battery + my_advanced_battery_config = advanced_battery_bslib.BatteryConfig.get_scaled_battery( + total_pv_power_in_watt_peak=my_photovoltaic_system_config.power_in_watt + ) + my_advanced_battery = advanced_battery_bslib.Battery( + my_simulation_parameters=my_simulation_parameters, config=my_advanced_battery_config, + ) + + # ----------------------------------------------------------------------------------------------------------------- + # Add outputs to EMS + loading_power_input_for_battery_in_watt = my_electricity_controller.add_component_output( + source_output_name="LoadingPowerInputForBattery_", + source_tags=[lt.ComponentType.BATTERY, lt.InandOutputType.ELECTRICITY_TARGET], + source_weight=4, + source_load_type=lt.LoadTypes.ELECTRICITY, + source_unit=lt.Units.WATT, + output_description="Target electricity for Battery Control. ", + ) + + # ----------------------------------------------------------------------------------------------------------------- + # Connect Battery + my_advanced_battery.connect_dynamic_input( + input_fieldname=advanced_battery_bslib.Battery.LoadingPowerInput, + src_object=loading_power_input_for_battery_in_watt, + ) + + # ----------------------------------------------------------------------------------------------------------------- + # Connect Electricity Meter + my_electricity_meter.add_component_input_and_connect( + source_object_name=my_electricity_controller.component_name, + source_component_output=my_electricity_controller.TotalElectricityToOrFromGrid, + source_load_type=lt.LoadTypes.ELECTRICITY, + source_unit=lt.Units.WATT, + source_tags=[lt.InandOutputType.ELECTRICITY_PRODUCTION], + source_weight=999, + ) + + # ----------------------------------------------------------------------------------------------------------------- + # Connect Electric Vehicle and Car Battery with EMS for surplus control + + for car, car_battery, car_battery_controller in list(zip_car_battery_controller_lists): + + my_electricity_controller.add_component_input_and_connect( + source_object_name=car_battery_controller.component_name, + source_component_output=car_battery_controller.BatteryChargingPowerToEMS, + source_load_type=lt.LoadTypes.ELECTRICITY, + source_unit=lt.Units.WATT, + source_tags=[lt.ComponentType.CAR_BATTERY, lt.InandOutputType.ELECTRICITY_CONSUMPTION_EMS_CONTROLLED], + source_weight=5, + ) + + electricity_target = my_electricity_controller.add_component_output( + source_output_name=lt.InandOutputType.ELECTRICITY_TARGET, + source_tags=[lt.ComponentType.CAR_BATTERY, lt.InandOutputType.ELECTRICITY_TARGET], + source_weight=5, + source_load_type=lt.LoadTypes.ELECTRICITY, + source_unit=lt.Units.WATT, + output_description="Target Electricity for EV Battery Controller. ", + ) + + car_battery_controller.connect_dynamic_input( + input_fieldname=controller_l1_generic_ev_charge.L1Controller.ElectricityTarget, + src_object=electricity_target, + ) + + # ================================================================================================================================= + # Add Remaining Components to Simulation Parameters + + my_sim.add_component(my_electricity_meter) + my_sim.add_component(my_advanced_battery) + my_sim.add_component(my_electricity_controller, connect_automatically=True) + + # when no PV is used, connect electricty meter automatically + else: + my_sim.add_component(my_electricity_meter, connect_automatically=True) + + # Connect Electric Vehicles and Car Batteries + for car in my_cars: + my_sim.add_component(car) + for car_battery in my_car_batteries: + my_sim.add_component(car_battery) + for car_battery_controller in my_car_battery_controllers: + my_sim.add_component(car_battery_controller) + + # Set Results Path + # if config_filename is given, get hash number and sampling mode for result path + if config_filename is not None: + config_filename_splitted = config_filename.split("/") + + try: + scenario_hash_string = re.findall(r"\-?\d+", config_filename_splitted[-1])[0] + sorting_option = SortingOptionEnum.MASS_SIMULATION_WITH_HASH_ENUMERATION + except Exception: + scenario_hash_string = "-" + sorting_option = SortingOptionEnum.MASS_SIMULATION_WITH_INDEX_ENUMERATION + try: + further_result_folder_description = config_filename_splitted[-2] + except Exception: + further_result_folder_description = "-" + + # if config_filename is not given, make result path with index enumeration + else: + scenario_hash_string = "default_scenario" + sorting_option = SortingOptionEnum.MASS_SIMULATION_WITH_INDEX_ENUMERATION + further_result_folder_description = "default_config" + + SingletonSimRepository().set_entry( + key=SingletonDictKeyEnum.RESULT_SCENARIO_NAME, entry=f"{scenario_hash_string}", + ) + + if my_simulation_parameters.result_directory == "": + + ResultPathProviderSingleton().set_important_result_path_information( + module_directory=my_sim.module_directory, # "/storage_cluster/projects/2024_waage/01_hisim_results", + model_name=my_sim.module_filename, + further_result_folder_description=os.path.join(*[further_result_folder_description]), + variant_name="_", + scenario_hash_string=scenario_hash_string, + sorting_option=sorting_option, + ) diff --git a/system_setups/household_gas_building_sizer.py b/system_setups/household_gas_building_sizer.py new file mode 100644 index 000000000..1859dd48b --- /dev/null +++ b/system_setups/household_gas_building_sizer.py @@ -0,0 +1,531 @@ +""" Basic household new system setup. """ + +# clean + +from typing import Optional, Any, Union, List +import re +import os +from utspclient.helpers.lpgdata import ( + ChargingStationSets, + Households, +) +from utspclient.helpers.lpgpythonbindings import JsonReference +from hisim.simulator import SimulationParameters +from hisim.components import loadprofilegenerator_utsp_connector +from hisim.components import weather +from hisim.components import generic_pv_system +from hisim.components import building +from hisim.components import ( + advanced_battery_bslib, + controller_l2_energy_management_system, + simple_water_storage, + heat_distribution_system, + generic_hot_water_storage_modular, + controller_l1_heatpump, + electricity_meter, + advanced_ev_battery_bslib, + controller_l1_generic_ev_charge, + generic_car, + generic_gas_heater, + generic_heat_source, + gas_meter, +) + +from hisim.result_path_provider import ResultPathProviderSingleton, SortingOptionEnum +from hisim.sim_repository_singleton import SingletonSimRepository, SingletonDictKeyEnum +from hisim.postprocessingoptions import PostProcessingOptions +from hisim import loadtypes as lt +from hisim.loadtypes import HeatingSystems +from hisim.building_sizer_utils.interface_configs.modular_household_config import ( + read_in_configs, + ModularHouseholdConfig, +) +from hisim import log + +__authors__ = "Katharina Rieck" +__copyright__ = "Copyright 2022, FZJ-IEK-3" +__credits__ = ["Noah Pflugradt"] +__license__ = "MIT" +__version__ = "1.0" +__maintainer__ = "Noah Pflugradt" +__status__ = "development" + + +def setup_function( + my_sim: Any, my_simulation_parameters: Optional[SimulationParameters] = None +) -> None: # noqa: too-many-statements + """Household system setup. + + This setup function emulates an household including the following components: + + - Simulation Parameters + - Components + - Occupancy (Residents' Demands) + - Weather + - Photovoltaic System + - Building + - Gas Heater + - Gas Heater Controller + - Heat Distribution System + - Heat Distribution Controller + - Heat Water Storage + - Battery + - Energy Management System + - Electricity Meter + - Electric Vehicles (including car batteries and car battery controllers) + """ + + # ================================================================================================================================= + # Set System Parameters from Config + + # household-pv-config + config_filename = my_sim.my_module_config + # try reading energ system and archetype configs + my_config = read_in_configs(my_sim.my_module_config) + if my_config is None: + my_config = ModularHouseholdConfig().get_default_config_for_household_gas() + log.warning( + f"Could not read the modular household config from path '{config_filename}'. Using the gas household default config instead." + ) + assert my_config.archetype_config_ is not None + assert my_config.energy_system_config_ is not None + arche_type_config_ = my_config.archetype_config_ + energy_system_config_ = my_config.energy_system_config_ + + # Set Simulation Parameters + if my_simulation_parameters is None: + year = 2021 + seconds_per_timestep = 60 * 15 + my_simulation_parameters = SimulationParameters.full_year(year=year, seconds_per_timestep=seconds_per_timestep) + cache_dir_path_simuparams = "/benchtop/2024-k-rieck-hisim/hisim_inputs_cache/" + if os.path.exists(cache_dir_path_simuparams): + my_simulation_parameters.cache_dir_path = cache_dir_path_simuparams + my_simulation_parameters.post_processing_options.append( + PostProcessingOptions.PREPARE_OUTPUTS_FOR_SCENARIO_EVALUATION + ) + my_simulation_parameters.post_processing_options.append(PostProcessingOptions.COMPUTE_OPEX) + my_simulation_parameters.post_processing_options.append(PostProcessingOptions.COMPUTE_CAPEX) + my_simulation_parameters.post_processing_options.append(PostProcessingOptions.COMPUTE_KPIS) + my_simulation_parameters.post_processing_options.append(PostProcessingOptions.WRITE_KPIS_TO_JSON) + my_simulation_parameters.post_processing_options.append( + PostProcessingOptions.WRITE_KPIS_TO_JSON_FOR_BUILDING_SIZER + ) + my_simulation_parameters.post_processing_options.append(PostProcessingOptions.MAKE_NETWORK_CHARTS) + my_simulation_parameters.post_processing_options.append(PostProcessingOptions.PLOT_LINE) + my_simulation_parameters.post_processing_options.append(PostProcessingOptions.PLOT_CARPET) + # my_simulation_parameters.post_processing_options.append(PostProcessingOptions.EXPORT_TO_CSV) + # my_simulation_parameters.logging_level = 4 + + my_sim.set_simulation_parameters(my_simulation_parameters) + + # ================================================================================================================================= + # Set System Parameters + + # Set heating systems for space heating and domestic hot water + heating_system = energy_system_config_.heating_system + if heating_system != HeatingSystems.GAS_HEATING: + raise ValueError("Heating system needs to be gas heater for this system setup.") + + heating_reference_temperature_in_celsius = -7.0 + + # Set Weather + weather_location = arche_type_config_.weather_location + + # Set Photovoltaic System + azimuth = arche_type_config_.pv_azimuth + tilt = arche_type_config_.pv_tilt + if arche_type_config_.pv_rooftop_capacity_in_kilowatt is not None: + pv_power_in_watt = arche_type_config_.pv_rooftop_capacity_in_kilowatt * 1000 + else: + pv_power_in_watt = None + share_of_maximum_pv_potential = energy_system_config_.share_of_maximum_pv_potential + + # Set Building (scale building according to total base area and not absolute floor area) + building_code = arche_type_config_.building_code + total_base_area_in_m2 = None + absolute_conditioned_floor_area_in_m2 = arche_type_config_.conditioned_floor_area_in_m2 + number_of_apartments = arche_type_config_.number_of_dwellings_per_building + if arche_type_config_.norm_heating_load_in_kilowatt is not None: + max_thermal_building_demand_in_watt = arche_type_config_.norm_heating_load_in_kilowatt * 1000 + else: + max_thermal_building_demand_in_watt = None + + # Set Occupancy + # try to get profiles from cluster directory + cache_dir_path_utsp: Optional[str] = "/benchtop/2024-k-rieck-hisim/lpg-utsp-cache" + if cache_dir_path_utsp is not None and os.path.exists(cache_dir_path_utsp): + pass + # else use default specific cache_dir_path + else: + cache_dir_path_utsp = None + + # get household attribute jsonreferences from list of strings + lpg_households: Union[JsonReference, List[JsonReference]] + if isinstance(arche_type_config_.lpg_households, List): + if len(arche_type_config_.lpg_households) == 1: + lpg_households = getattr(Households, arche_type_config_.lpg_households[0]) + elif len(arche_type_config_.lpg_households) > 1: + lpg_households = [] + for household_string in arche_type_config_.lpg_households: + if hasattr(Households, household_string): + lpg_household = getattr(Households, household_string) + lpg_households.append(lpg_household) + print(lpg_household) + else: + raise ValueError("Config list with lpg household is empty.") + else: + raise TypeError(f"Type {type(arche_type_config_.lpg_households)} is incompatible. Should be List[str].") + + # Set Electric Vehicle + charging_station_set = ChargingStationSets.Charging_At_Home_with_11_kW + charging_power = float((charging_station_set.Name or "").split("with ")[1].split(" kW")[0]) + + # ================================================================================================================================= + # Build Basic Components + # Build Building + my_building_config = building.BuildingConfig.get_default_german_single_family_home( + heating_reference_temperature_in_celsius=heating_reference_temperature_in_celsius, + max_thermal_building_demand_in_watt=max_thermal_building_demand_in_watt, + ) + my_building_config.building_code = building_code + my_building_config.total_base_area_in_m2 = total_base_area_in_m2 + my_building_config.absolute_conditioned_floor_area_in_m2 = absolute_conditioned_floor_area_in_m2 + my_building_config.number_of_apartments = number_of_apartments + my_building_config.enable_opening_windows = True + my_building_information = building.BuildingInformation(config=my_building_config) + my_building = building.Building(config=my_building_config, my_simulation_parameters=my_simulation_parameters) + # Add to simulator + my_sim.add_component(my_building, connect_automatically=True) + + # Build Occupancy + my_occupancy_config = loadprofilegenerator_utsp_connector.UtspLpgConnectorConfig.get_default_utsp_connector_config() + my_occupancy_config.data_acquisition_mode = loadprofilegenerator_utsp_connector.LpgDataAcquisitionMode.USE_UTSP + my_occupancy_config.household = lpg_households + my_occupancy_config.cache_dir_path = cache_dir_path_utsp + + my_occupancy = loadprofilegenerator_utsp_connector.UtspLpgConnector( + config=my_occupancy_config, my_simulation_parameters=my_simulation_parameters + ) + # Add to simulator + my_sim.add_component(my_occupancy) + + # Build Weather + my_weather_config = weather.WeatherConfig.get_default(location_entry=weather_location) + my_weather = weather.Weather(config=my_weather_config, my_simulation_parameters=my_simulation_parameters) + # Add to simulator + my_sim.add_component(my_weather) + + # Build PV + if pv_power_in_watt is None: + my_photovoltaic_system_config = generic_pv_system.PVSystemConfig.get_scaled_pv_system( + rooftop_area_in_m2=my_building_information.scaled_rooftop_area_in_m2, + share_of_maximum_pv_potential=share_of_maximum_pv_potential, + location=weather_location, + ) + else: + my_photovoltaic_system_config = generic_pv_system.PVSystemConfig.get_default_pv_system( + power_in_watt=pv_power_in_watt, + share_of_maximum_pv_potential=share_of_maximum_pv_potential, + location=weather_location, + ) + + my_photovoltaic_system_config.azimuth = azimuth + my_photovoltaic_system_config.tilt = tilt + + my_photovoltaic_system = generic_pv_system.PVSystem( + config=my_photovoltaic_system_config, my_simulation_parameters=my_simulation_parameters, + ) + # Add to simulator + my_sim.add_component(my_photovoltaic_system, connect_automatically=True) + + # Build Heat Distribution Controller + my_heat_distribution_controller_config = heat_distribution_system.HeatDistributionControllerConfig.get_default_heat_distribution_controller_config( + set_heating_temperature_for_building_in_celsius=my_building_information.set_heating_temperature_for_building_in_celsius, + set_cooling_temperature_for_building_in_celsius=my_building_information.set_cooling_temperature_for_building_in_celsius, + heating_load_of_building_in_watt=my_building_information.max_thermal_building_demand_in_watt, + heating_reference_temperature_in_celsius=heating_reference_temperature_in_celsius, + ) + # my_heat_distribution_controller_config.heating_system = heat_distribution_system.HeatDistributionSystemType.RADIATOR + + my_heat_distribution_controller = heat_distribution_system.HeatDistributionController( + my_simulation_parameters=my_simulation_parameters, config=my_heat_distribution_controller_config, + ) + my_hds_controller_information = heat_distribution_system.HeatDistributionControllerInformation( + config=my_heat_distribution_controller_config + ) + # Add to simulator + my_sim.add_component(my_heat_distribution_controller, connect_automatically=True) + + # Set sizing option for Hot water Storage + sizing_option = simple_water_storage.HotWaterStorageSizingEnum.SIZE_ACCORDING_TO_GAS_HEATER + + # Build Gas heater For Space Heating + my_gas_heater_config = generic_gas_heater.GenericGasHeaterConfig.get_scaled_gasheater_config( + heating_load_of_building_in_watt=my_building_information.max_thermal_building_demand_in_watt + ) + my_gas_heater = generic_gas_heater.GasHeater( + config=my_gas_heater_config, my_simulation_parameters=my_simulation_parameters, + ) + my_sim.add_component(my_gas_heater, connect_automatically=True) + + # Build Gas Heater Controller + my_gas_heater_controller_config = generic_gas_heater.GenericGasHeaterControllerL1Config.get_default_generic_gas_heater_controller_config( + minimal_thermal_power_in_watt=my_gas_heater_config.minimal_thermal_power_in_watt, maximal_thermal_power_in_watt=my_gas_heater_config.maximal_thermal_power_in_watt + ) + my_gas_heater_controller = generic_gas_heater.GenericGasHeaterControllerL1( + my_simulation_parameters=my_simulation_parameters, config=my_gas_heater_controller_config, + ) + my_sim.add_component(my_gas_heater_controller, connect_automatically=True) + + # Build Gas Heater for DHW + my_gas_heater_for_dhw_config = generic_heat_source.HeatSourceConfig.get_default_config_waterheating( + heating_system=lt.HeatingSystems.GAS_HEATING, + max_warm_water_demand_in_liter=my_occupancy.max_hot_water_demand, + scaling_factor_according_to_number_of_apartments=my_occupancy.scaling_factor_according_to_number_of_apartments, + seconds_per_timestep=my_simulation_parameters.seconds_per_timestep, + name="DHW" + lt.HeatingSystems.GAS_HEATING.value + ) + my_gas_heater_controller_l1_config = controller_l1_heatpump.L1HeatPumpConfig.get_default_config_heat_source_controller_dhw( + "DHW" + lt.HeatingSystems.GAS_HEATING.value + "Controller" + ) + my_boiler_config = generic_hot_water_storage_modular.StorageConfig.get_scaled_config_for_boiler_to_number_of_apartments( + number_of_apartments=my_building_information.number_of_apartments + ) + my_boiler_config.compute_default_cycle( + temperature_difference_in_kelvin=my_gas_heater_controller_l1_config.t_max_heating_in_celsius + - my_gas_heater_controller_l1_config.t_min_heating_in_celsius + ) + + my_boiler_for_dhw = generic_hot_water_storage_modular.HotWaterStorage( + my_simulation_parameters=my_simulation_parameters, config=my_boiler_config + ) + + my_heater_controller_l1_for_dhw = controller_l1_heatpump.L1HeatPumpController( + my_simulation_parameters=my_simulation_parameters, config=my_gas_heater_controller_l1_config + ) + + my_gas_heater_for_dhw = generic_heat_source.HeatSource( + config=my_gas_heater_for_dhw_config, my_simulation_parameters=my_simulation_parameters + ) + my_sim.add_component(my_gas_heater_for_dhw, connect_automatically=True) + my_sim.add_component(my_boiler_for_dhw, connect_automatically=True) + my_sim.add_component(my_heater_controller_l1_for_dhw, connect_automatically=True) + + # Build Heat Water Storage + my_simple_heat_water_storage_config = simple_water_storage.SimpleHotWaterStorageConfig.get_scaled_hot_water_storage( + max_thermal_power_in_watt_of_heating_system=my_building_information.max_thermal_building_demand_in_watt, + temperature_difference_between_flow_and_return_in_celsius=my_hds_controller_information.temperature_difference_between_flow_and_return_in_celsius, + sizing_option=sizing_option, + ) + my_simple_water_storage = simple_water_storage.SimpleHotWaterStorage( + config=my_simple_heat_water_storage_config, my_simulation_parameters=my_simulation_parameters, + ) + # Add to simulator + my_sim.add_component(my_simple_water_storage, connect_automatically=True) + + # Build Heat Distribution System + my_heat_distribution_system_config = heat_distribution_system.HeatDistributionConfig.get_default_heatdistributionsystem_config( + water_mass_flow_rate_in_kg_per_second=my_hds_controller_information.water_mass_flow_rate_in_kp_per_second, + absolute_conditioned_floor_area_in_m2=my_building_information.scaled_conditioned_floor_area_in_m2, + ) + my_heat_distribution_system = heat_distribution_system.HeatDistribution( + config=my_heat_distribution_system_config, my_simulation_parameters=my_simulation_parameters, + ) + # Add to simulator + my_sim.add_component(my_heat_distribution_system, connect_automatically=True) + + # Build Electricity Meter + my_electricity_meter = electricity_meter.ElectricityMeter( + my_simulation_parameters=my_simulation_parameters, + config=electricity_meter.ElectricityMeterConfig.get_electricity_meter_default_config(), + ) + + # Build Gas Meter + my_gas_meter = gas_meter.GasMeter( + my_simulation_parameters=my_simulation_parameters, + config=gas_meter.GasMeterConfig.get_gas_meter_default_config(), + ) + my_sim.add_component(my_gas_meter, connect_automatically=True) + + # Build Electric Vehicle Configs and Car Battery Configs + my_car_config = generic_car.CarConfig.get_default_ev_config() + my_car_battery_config = advanced_ev_battery_bslib.CarBatteryConfig.get_default_config() + my_car_battery_controller_config = controller_l1_generic_ev_charge.ChargingStationConfig.get_default_config( + charging_station_set=charging_station_set + ) + # set car config name + my_car_config.name = "ElectricCar" + # set charging power from battery and controller to same value, to reduce error in simulation of battery + my_car_battery_config.p_inv_custom = charging_power * 1e3 + # lower threshold for soc of car battery in clever case. This enables more surplus charging. Surplus control of car + my_car_battery_controller_config.battery_set = 0.6 + # Build Electric Vehicles + my_car_information = generic_car.GenericCarInformation(my_occupancy_instance=my_occupancy) + my_cars: List[generic_car.Car] = [] + my_car_batteries: List[advanced_ev_battery_bslib.CarBattery] = [] + my_car_battery_controllers: List[controller_l1_generic_ev_charge.L1Controller] = [] + # iterate over all cars + car_number = 1 + for car_information_dict in my_car_information.data_dict_for_car_component.values(): + # Build Electric Vehicles + my_car_config.name = f"ElectricCar_{car_number}" + my_car = generic_car.Car( + my_simulation_parameters=my_simulation_parameters, + config=my_car_config, + data_dict_with_car_information=car_information_dict, + ) + my_cars.append(my_car) + # Build Electric Vehicle Batteries + my_car_battery_config.source_weight = my_car.config.source_weight + my_car_battery_config.name = f"CarBattery_{car_number}" + my_car_battery = advanced_ev_battery_bslib.CarBattery( + my_simulation_parameters=my_simulation_parameters, config=my_car_battery_config, + ) + my_car_batteries.append(my_car_battery) + # Build Electric Vehicle Battery Controller + my_car_battery_controller_config.source_weight = my_car.config.source_weight + my_car_battery_controller_config.name = f"L1EVChargeControl_{car_number}" + + my_car_battery_controller = controller_l1_generic_ev_charge.L1Controller( + my_simulation_parameters=my_simulation_parameters, config=my_car_battery_controller_config, + ) + my_car_battery_controllers.append(my_car_battery_controller) + car_number += 1 + + # Connect Electric Vehicles and Car Batteries + zip_car_battery_controller_lists = list(zip(my_cars, my_car_batteries, my_car_battery_controllers)) + for car, car_battery, car_battery_controller in zip_car_battery_controller_lists: + car_battery_controller.connect_only_predefined_connections(car) + car_battery_controller.connect_only_predefined_connections(car_battery) + car_battery.connect_only_predefined_connections(car_battery_controller) + + # use ems and battery only when PV is used + if share_of_maximum_pv_potential != 0: + + # Build EMS + my_electricity_controller_config = controller_l2_energy_management_system.EMSConfig.get_default_config_ems() + + my_electricity_controller = controller_l2_energy_management_system.L2GenericEnergyManagementSystem( + my_simulation_parameters=my_simulation_parameters, config=my_electricity_controller_config, + ) + + # Build Battery + my_advanced_battery_config = advanced_battery_bslib.BatteryConfig.get_scaled_battery( + total_pv_power_in_watt_peak=my_photovoltaic_system_config.power_in_watt + ) + my_advanced_battery = advanced_battery_bslib.Battery( + my_simulation_parameters=my_simulation_parameters, config=my_advanced_battery_config, + ) + + # ----------------------------------------------------------------------------------------------------------------- + # Add outputs to EMS + loading_power_input_for_battery_in_watt = my_electricity_controller.add_component_output( + source_output_name="LoadingPowerInputForBattery_", + source_tags=[lt.ComponentType.BATTERY, lt.InandOutputType.ELECTRICITY_TARGET], + source_weight=4, + source_load_type=lt.LoadTypes.ELECTRICITY, + source_unit=lt.Units.WATT, + output_description="Target electricity for Battery Control. ", + ) + + # ----------------------------------------------------------------------------------------------------------------- + # Connect Battery + my_advanced_battery.connect_dynamic_input( + input_fieldname=advanced_battery_bslib.Battery.LoadingPowerInput, + src_object=loading_power_input_for_battery_in_watt, + ) + + # ----------------------------------------------------------------------------------------------------------------- + # Connect Electricity Meter + my_electricity_meter.add_component_input_and_connect( + source_object_name=my_electricity_controller.component_name, + source_component_output=my_electricity_controller.TotalElectricityToOrFromGrid, + source_load_type=lt.LoadTypes.ELECTRICITY, + source_unit=lt.Units.WATT, + source_tags=[lt.InandOutputType.ELECTRICITY_PRODUCTION], + source_weight=999, + ) + + # ----------------------------------------------------------------------------------------------------------------- + # Connect Electric Vehicle and Car Battery with EMS for surplus control + + for car, car_battery, car_battery_controller in list(zip_car_battery_controller_lists): + + my_electricity_controller.add_component_input_and_connect( + source_object_name=car_battery_controller.component_name, + source_component_output=car_battery_controller.BatteryChargingPowerToEMS, + source_load_type=lt.LoadTypes.ELECTRICITY, + source_unit=lt.Units.WATT, + source_tags=[lt.ComponentType.CAR_BATTERY, lt.InandOutputType.ELECTRICITY_CONSUMPTION_EMS_CONTROLLED], + source_weight=5, + ) + + electricity_target = my_electricity_controller.add_component_output( + source_output_name=lt.InandOutputType.ELECTRICITY_TARGET, + source_tags=[lt.ComponentType.CAR_BATTERY, lt.InandOutputType.ELECTRICITY_TARGET], + source_weight=5, + source_load_type=lt.LoadTypes.ELECTRICITY, + source_unit=lt.Units.WATT, + output_description="Target Electricity for EV Battery Controller. ", + ) + + car_battery_controller.connect_dynamic_input( + input_fieldname=controller_l1_generic_ev_charge.L1Controller.ElectricityTarget, + src_object=electricity_target, + ) + + # ================================================================================================================================= + # Add Remaining Components to Simulation Parameters + + my_sim.add_component(my_electricity_meter) + my_sim.add_component(my_advanced_battery) + my_sim.add_component(my_electricity_controller, connect_automatically=True) + + # when no PV is used, connect electricty meter automatically + else: + my_sim.add_component(my_electricity_meter, connect_automatically=True) + + # Connect Electric Vehicles and Car Batteries + for car in my_cars: + my_sim.add_component(car) + for car_battery in my_car_batteries: + my_sim.add_component(car_battery) + for car_battery_controller in my_car_battery_controllers: + my_sim.add_component(car_battery_controller) + + # Set Results Path + # if config_filename is given, get hash number and sampling mode for result path + if config_filename is not None: + config_filename_splitted = config_filename.split("/") + + try: + scenario_hash_string = re.findall(r"\-?\d+", config_filename_splitted[-1])[0] + sorting_option = SortingOptionEnum.MASS_SIMULATION_WITH_HASH_ENUMERATION + except Exception: + scenario_hash_string = "-" + sorting_option = SortingOptionEnum.MASS_SIMULATION_WITH_INDEX_ENUMERATION + try: + further_result_folder_description = config_filename_splitted[-2] + except Exception: + further_result_folder_description = "-" + + # if config_filename is not given, make result path with index enumeration + else: + scenario_hash_string = "default_scenario" + sorting_option = SortingOptionEnum.MASS_SIMULATION_WITH_INDEX_ENUMERATION + further_result_folder_description = "default_config" + + SingletonSimRepository().set_entry( + key=SingletonDictKeyEnum.RESULT_SCENARIO_NAME, entry=f"{scenario_hash_string}", + ) + + if my_simulation_parameters.result_directory == "": + + ResultPathProviderSingleton().set_important_result_path_information( + module_directory=my_sim.module_directory, # "/storage_cluster/projects/2024_waage/01_hisim_results", + model_name=my_sim.module_filename, + further_result_folder_description=os.path.join(*[further_result_folder_description,]), + variant_name="_", + scenario_hash_string=scenario_hash_string, + sorting_option=sorting_option, + ) diff --git a/system_setups/household_gas_heater.py b/system_setups/household_gas_heater.py index e5fbd1fdf..42b9a395c 100644 --- a/system_setups/household_gas_heater.py +++ b/system_setups/household_gas_heater.py @@ -18,7 +18,6 @@ from hisim.components import loadprofilegenerator_utsp_connector from hisim.components import weather from hisim.components import generic_gas_heater -from hisim.components import controller_l1_generic_gas_heater from hisim.components import heat_distribution_system from hisim.components import building from hisim.components import simple_water_storage @@ -65,7 +64,7 @@ class HouseholdGasHeaterConfig(SystemSetupConfigBase): occupancy_config: loadprofilegenerator_utsp_connector.UtspLpgConnectorConfig hds_controller_config: heat_distribution_system.HeatDistributionControllerConfig hds_config: heat_distribution_system.HeatDistributionConfig - gas_heater_controller_config: controller_l1_generic_gas_heater.GenericGasHeaterControllerL1Config + gas_heater_controller_config: generic_gas_heater.GenericGasHeaterControllerL1Config gas_heater_config: generic_gas_heater.GenericGasHeaterConfig simple_hot_water_storage_config: simple_water_storage.SimpleHotWaterStorageConfig dhw_heatpump_config: generic_heat_pump_modular.HeatPumpConfig @@ -142,8 +141,7 @@ def get_scaled_default( predictive=False, ), pv_config=generic_pv_system.PVSystemConfig.get_scaled_pv_system( - rooftop_area_in_m2=my_building_information.scaled_rooftop_area_in_m2, - location=weather_location + rooftop_area_in_m2=my_building_information.scaled_rooftop_area_in_m2, location=weather_location ) if options.photovoltaic else None, @@ -153,12 +151,12 @@ def get_scaled_default( hds_config=( heat_distribution_system.HeatDistributionConfig.get_default_heatdistributionsystem_config( water_mass_flow_rate_in_kg_per_second=my_hds_controller_information.water_mass_flow_rate_in_kp_per_second, - absolute_conditioned_floor_area_in_m2=my_building_information.scaled_conditioned_floor_area_in_m2 + absolute_conditioned_floor_area_in_m2=my_building_information.scaled_conditioned_floor_area_in_m2, ) ), gas_heater_controller_config=( - controller_l1_generic_gas_heater.GenericGasHeaterControllerL1Config.get_scaled_generic_gas_heater_controller_config( - heating_load_of_building_in_watt=my_building_information.max_thermal_building_demand_in_watt + generic_gas_heater.GenericGasHeaterControllerL1Config.get_default_generic_gas_heater_controller_config( + maximal_thermal_power_in_watt=my_building_information.max_thermal_building_demand_in_watt ) ), gas_heater_config=generic_gas_heater.GenericGasHeaterConfig.get_scaled_gasheater_config( @@ -252,7 +250,7 @@ def setup_function( ) # Gas Heater Controller - my_gas_heater_controller = controller_l1_generic_gas_heater.GenericGasHeaterControllerL1( + my_gas_heater_controller = generic_gas_heater.GenericGasHeaterControllerL1( my_simulation_parameters=my_simulation_parameters, config=my_config.gas_heater_controller_config, ) diff --git a/system_setups/household_heat_pump.py b/system_setups/household_heat_pump.py index e8f0b633f..26c9b5742 100644 --- a/system_setups/household_heat_pump.py +++ b/system_setups/household_heat_pump.py @@ -152,8 +152,7 @@ def get_scaled_default( predictive=False, ), pv_config=generic_pv_system.PVSystemConfig.get_scaled_pv_system( - rooftop_area_in_m2=my_building_information.scaled_rooftop_area_in_m2, - location=weather_location + rooftop_area_in_m2=my_building_information.scaled_rooftop_area_in_m2, location=weather_location ) if options.photovoltaic else None, @@ -163,7 +162,7 @@ def get_scaled_default( hds_config=( heat_distribution_system.HeatDistributionConfig.get_default_heatdistributionsystem_config( water_mass_flow_rate_in_kg_per_second=my_hds_controller_information.water_mass_flow_rate_in_kp_per_second, - absolute_conditioned_floor_area_in_m2=my_building_information.scaled_conditioned_floor_area_in_m2 + absolute_conditioned_floor_area_in_m2=my_building_information.scaled_conditioned_floor_area_in_m2, ) ), hp_controller_config=advanced_heat_pump_hplib.HeatPumpHplibControllerL1Config.get_default_generic_heat_pump_controller_config( diff --git a/system_setups/household_gas_or_heatpump.py b/system_setups/household_heatpump_building_sizer.py similarity index 74% rename from system_setups/household_gas_or_heatpump.py rename to system_setups/household_heatpump_building_sizer.py index 46b00f0fb..c3f4fb84c 100644 --- a/system_setups/household_gas_or_heatpump.py +++ b/system_setups/household_heatpump_building_sizer.py @@ -28,10 +28,6 @@ advanced_ev_battery_bslib, controller_l1_generic_ev_charge, generic_car, - controller_l1_generic_gas_heater, - generic_gas_heater, - generic_heat_source, - gas_meter, ) from hisim.result_path_provider import ResultPathProviderSingleton, SortingOptionEnum @@ -40,7 +36,12 @@ from hisim import loadtypes as lt from hisim.units import Quantity, Celsius, Watt from hisim.loadtypes import HeatingSystems -from hisim.building_sizer_utils.interface_configs.modular_household_config import read_in_configs +from hisim.building_sizer_utils.interface_configs.modular_household_config import ( + read_in_configs, + ModularHouseholdConfig, +) +from hisim import log + __authors__ = "Katharina Rieck" __copyright__ = "Copyright 2022, FZJ-IEK-3" @@ -83,7 +84,11 @@ def setup_function( config_filename = my_sim.my_module_config # try reading energ system and archetype configs my_config = read_in_configs(my_sim.my_module_config) - + if my_config is None: + my_config = ModularHouseholdConfig().get_default_config_for_household_heatpump() + log.warning( + f"Could not read the modular household config from path '{config_filename}'. Using the heatpump household default config instead." + ) assert my_config.archetype_config_ is not None assert my_config.energy_system_config_ is not None arche_type_config_ = my_config.archetype_config_ @@ -93,9 +98,7 @@ def setup_function( if my_simulation_parameters is None: year = 2021 seconds_per_timestep = 60 * 15 - my_simulation_parameters = SimulationParameters.full_year( - year=year, seconds_per_timestep=seconds_per_timestep - ) + my_simulation_parameters = SimulationParameters.full_year(year=year, seconds_per_timestep=seconds_per_timestep) cache_dir_path_simuparams = "/benchtop/2024-k-rieck-hisim/hisim_inputs_cache/" if os.path.exists(cache_dir_path_simuparams): my_simulation_parameters.cache_dir_path = cache_dir_path_simuparams @@ -106,7 +109,9 @@ def setup_function( my_simulation_parameters.post_processing_options.append(PostProcessingOptions.COMPUTE_CAPEX) my_simulation_parameters.post_processing_options.append(PostProcessingOptions.COMPUTE_KPIS) my_simulation_parameters.post_processing_options.append(PostProcessingOptions.WRITE_KPIS_TO_JSON) - my_simulation_parameters.post_processing_options.append(PostProcessingOptions.WRITE_KPIS_TO_JSON_FOR_BUILDING_SIZER) + my_simulation_parameters.post_processing_options.append( + PostProcessingOptions.WRITE_KPIS_TO_JSON_FOR_BUILDING_SIZER + ) my_simulation_parameters.post_processing_options.append(PostProcessingOptions.MAKE_NETWORK_CHARTS) my_simulation_parameters.post_processing_options.append(PostProcessingOptions.PLOT_LINE) my_simulation_parameters.post_processing_options.append(PostProcessingOptions.PLOT_CARPET) @@ -120,11 +125,11 @@ def setup_function( # Set heating systems for space heating and domestic hot water heating_system = energy_system_config_.heating_system + if heating_system != HeatingSystems.HEAT_PUMP: + raise ValueError("Heating system needs to be heat pump for this system setup.") # Set Heat Pump Controller hp_controller_mode = 2 # mode 1 for heating/off and mode 2 for heating/cooling/off heating_reference_temperature_in_celsius = -7.0 - # Set gas meter (default is False, is set true when gas heaters are used) - use_gas_meter: bool = False # Set Weather weather_location = arche_type_config_.weather_location @@ -254,121 +259,60 @@ def setup_function( # Add to simulator my_sim.add_component(my_heat_distribution_controller, connect_automatically=True) - if heating_system == HeatingSystems.HEAT_PUMP: - # Set sizing option for Hot water Storage - sizing_option = simple_water_storage.HotWaterStorageSizingEnum.SIZE_ACCORDING_TO_HEAT_PUMP - - # Build Heat Pump Controller - my_heat_pump_controller_config = advanced_heat_pump_hplib.HeatPumpHplibControllerL1Config.get_default_generic_heat_pump_controller_config( - heat_distribution_system_type=my_hds_controller_information.heat_distribution_system_type - ) - my_heat_pump_controller_config.mode = hp_controller_mode - - my_heat_pump_controller = advanced_heat_pump_hplib.HeatPumpHplibController( - config=my_heat_pump_controller_config, my_simulation_parameters=my_simulation_parameters, - ) - # Add to simulator - my_sim.add_component(my_heat_pump_controller, connect_automatically=True) - - # Build Heat Pump - my_heat_pump_config = advanced_heat_pump_hplib.HeatPumpHplibConfig.get_scaled_advanced_hp_lib( - heating_load_of_building_in_watt=Quantity( - my_building_information.max_thermal_building_demand_in_watt, Watt - ), - heating_reference_temperature_in_celsius=Quantity(heating_reference_temperature_in_celsius, Celsius), - ) - - my_heat_pump = advanced_heat_pump_hplib.HeatPumpHplib( - config=my_heat_pump_config, my_simulation_parameters=my_simulation_parameters, - ) - # Add to simulator - my_sim.add_component(my_heat_pump, connect_automatically=True) + # Set sizing option for Hot water Storage + sizing_option = simple_water_storage.HotWaterStorageSizingEnum.SIZE_ACCORDING_TO_HEAT_PUMP - # Build DHW (this is taken from household_3_advanced_hp_diesel-car_pv_battery.py) - my_dhw_heatpump_config = generic_heat_pump_modular.HeatPumpConfig.get_scaled_waterheating_to_number_of_apartments( - number_of_apartments=my_building_information.number_of_apartments, default_power_in_watt=6000, - ) - my_dhw_heatpump_controller_config = controller_l1_heatpump.L1HeatPumpConfig.get_default_config_heat_source_controller_dhw( - name="DHWHeatpumpController" - ) - my_dhw_storage_config = generic_hot_water_storage_modular.StorageConfig.get_scaled_config_for_boiler_to_number_of_apartments( - number_of_apartments=my_building_information.number_of_apartments, default_volume_in_liter=450, - ) - my_dhw_storage_config.compute_default_cycle( - temperature_difference_in_kelvin=my_dhw_heatpump_controller_config.t_max_heating_in_celsius - - my_dhw_heatpump_controller_config.t_min_heating_in_celsius - ) - my_domnestic_hot_water_storage = generic_hot_water_storage_modular.HotWaterStorage( - my_simulation_parameters=my_simulation_parameters, config=my_dhw_storage_config - ) - my_domnestic_hot_water_heatpump_controller = controller_l1_heatpump.L1HeatPumpController( - my_simulation_parameters=my_simulation_parameters, config=my_dhw_heatpump_controller_config, - ) - my_domnestic_hot_water_heatpump = generic_heat_pump_modular.ModularHeatPump( - config=my_dhw_heatpump_config, my_simulation_parameters=my_simulation_parameters - ) - # Add to simulator - my_sim.add_component(my_domnestic_hot_water_storage, connect_automatically=True) - my_sim.add_component(my_domnestic_hot_water_heatpump_controller, connect_automatically=True) - my_sim.add_component(my_domnestic_hot_water_heatpump, connect_automatically=True) - - elif heating_system == HeatingSystems.GAS_HEATING: - # Set sizing option for Hot water Storage - sizing_option = simple_water_storage.HotWaterStorageSizingEnum.SIZE_ACCORDING_TO_GAS_HEATER - # Set gas meter - use_gas_meter = True - - # Build Gas Heater Controller - my_gas_heater_controller_config = controller_l1_generic_gas_heater.GenericGasHeaterControllerL1Config.get_scaled_generic_gas_heater_controller_config( - heating_load_of_building_in_watt=my_building_information.max_thermal_building_demand_in_watt - ) - my_gas_heater_controller = controller_l1_generic_gas_heater.GenericGasHeaterControllerL1( - my_simulation_parameters=my_simulation_parameters, config=my_gas_heater_controller_config, - ) - my_sim.add_component(my_gas_heater_controller, connect_automatically=True) - - # Build Gas heater For Space Heating - my_gas_heater_config = generic_gas_heater.GenericGasHeaterConfig.get_scaled_gasheater_config( - heating_load_of_building_in_watt=my_building_information.max_thermal_building_demand_in_watt - ) - my_gas_heater = generic_gas_heater.GasHeater( - config=my_gas_heater_config, my_simulation_parameters=my_simulation_parameters, - ) - my_sim.add_component(my_gas_heater, connect_automatically=True) + # Build Heat Pump Controller + my_heat_pump_controller_config = advanced_heat_pump_hplib.HeatPumpHplibControllerL1Config.get_default_generic_heat_pump_controller_config( + heat_distribution_system_type=my_hds_controller_information.heat_distribution_system_type + ) + my_heat_pump_controller_config.mode = hp_controller_mode - # Build Gas Heater for DHW - my_gas_heater_for_dhw_config = generic_heat_source.HeatSourceConfig.get_default_config_waterheating_with_gas( - max_warm_water_demand_in_liter=my_occupancy.max_hot_water_demand, - scaling_factor_according_to_number_of_apartments=my_occupancy.scaling_factor_according_to_number_of_apartments, - seconds_per_timestep=my_simulation_parameters.seconds_per_timestep, - ) - my_gas_heater_controller_l1_config = controller_l1_heatpump.L1HeatPumpConfig.get_default_config_heat_source_controller_dhw( - "DHW" + lt.HeatingSystems.GAS_HEATING.value - ) - my_boiler_config = generic_hot_water_storage_modular.StorageConfig.get_scaled_config_for_boiler_to_number_of_apartments( - number_of_apartments=my_building_information.number_of_apartments - ) - my_boiler_config.compute_default_cycle( - temperature_difference_in_kelvin=my_gas_heater_controller_l1_config.t_max_heating_in_celsius - - my_gas_heater_controller_l1_config.t_min_heating_in_celsius - ) + my_heat_pump_controller = advanced_heat_pump_hplib.HeatPumpHplibController( + config=my_heat_pump_controller_config, my_simulation_parameters=my_simulation_parameters, + ) + # Add to simulator + my_sim.add_component(my_heat_pump_controller, connect_automatically=True) - my_boiler_for_dhw = generic_hot_water_storage_modular.HotWaterStorage( - my_simulation_parameters=my_simulation_parameters, config=my_boiler_config - ) + # Build Heat Pump + my_heat_pump_config = advanced_heat_pump_hplib.HeatPumpHplibConfig.get_scaled_advanced_hp_lib( + heating_load_of_building_in_watt=Quantity(my_building_information.max_thermal_building_demand_in_watt, Watt), + heating_reference_temperature_in_celsius=Quantity(heating_reference_temperature_in_celsius, Celsius), + ) - my_heater_controller_l1_for_dhw = controller_l1_heatpump.L1HeatPumpController( - my_simulation_parameters=my_simulation_parameters, config=my_gas_heater_controller_l1_config - ) + my_heat_pump = advanced_heat_pump_hplib.HeatPumpHplib( + config=my_heat_pump_config, my_simulation_parameters=my_simulation_parameters, + ) + # Add to simulator + my_sim.add_component(my_heat_pump, connect_automatically=True) - my_gas_heater_for_dhw = generic_heat_source.HeatSource( - config=my_gas_heater_for_dhw_config, my_simulation_parameters=my_simulation_parameters - ) - my_sim.add_component(my_gas_heater_for_dhw, connect_automatically=True) - my_sim.add_component(my_boiler_for_dhw, connect_automatically=True) - my_sim.add_component(my_heater_controller_l1_for_dhw, connect_automatically=True) - else: - raise ValueError(f"Heating system {heating_system} not recognized.") + # Build DHW (this is taken from household_3_advanced_hp_diesel-car_pv_battery.py) + my_dhw_heatpump_config = generic_heat_pump_modular.HeatPumpConfig.get_scaled_waterheating_to_number_of_apartments( + number_of_apartments=my_building_information.number_of_apartments, default_power_in_watt=6000, + ) + my_dhw_heatpump_controller_config = controller_l1_heatpump.L1HeatPumpConfig.get_default_config_heat_source_controller_dhw( + name="DHWHeatpumpController" + ) + my_dhw_storage_config = generic_hot_water_storage_modular.StorageConfig.get_scaled_config_for_boiler_to_number_of_apartments( + number_of_apartments=my_building_information.number_of_apartments, default_volume_in_liter=450, + ) + my_dhw_storage_config.compute_default_cycle( + temperature_difference_in_kelvin=my_dhw_heatpump_controller_config.t_max_heating_in_celsius + - my_dhw_heatpump_controller_config.t_min_heating_in_celsius + ) + my_domnestic_hot_water_storage = generic_hot_water_storage_modular.HotWaterStorage( + my_simulation_parameters=my_simulation_parameters, config=my_dhw_storage_config + ) + my_domnestic_hot_water_heatpump_controller = controller_l1_heatpump.L1HeatPumpController( + my_simulation_parameters=my_simulation_parameters, config=my_dhw_heatpump_controller_config, + ) + my_domnestic_hot_water_heatpump = generic_heat_pump_modular.ModularHeatPump( + config=my_dhw_heatpump_config, my_simulation_parameters=my_simulation_parameters + ) + # Add to simulator + my_sim.add_component(my_domnestic_hot_water_storage, connect_automatically=True) + my_sim.add_component(my_domnestic_hot_water_heatpump_controller, connect_automatically=True) + my_sim.add_component(my_domnestic_hot_water_heatpump, connect_automatically=True) # Build Heat Water Storage my_simple_heat_water_storage_config = simple_water_storage.SimpleHotWaterStorageConfig.get_scaled_hot_water_storage( @@ -376,11 +320,11 @@ def setup_function( temperature_difference_between_flow_and_return_in_celsius=my_hds_controller_information.temperature_difference_between_flow_and_return_in_celsius, sizing_option=sizing_option, ) - my_simple_hot_water_storage = simple_water_storage.SimpleHotWaterStorage( + my_simple_water_storage = simple_water_storage.SimpleHotWaterStorage( config=my_simple_heat_water_storage_config, my_simulation_parameters=my_simulation_parameters, ) # Add to simulator - my_sim.add_component(my_simple_hot_water_storage, connect_automatically=True) + my_sim.add_component(my_simple_water_storage, connect_automatically=True) # Build Heat Distribution System my_heat_distribution_system_config = heat_distribution_system.HeatDistributionConfig.get_default_heatdistributionsystem_config( @@ -398,13 +342,6 @@ def setup_function( my_simulation_parameters=my_simulation_parameters, config=electricity_meter.ElectricityMeterConfig.get_electricity_meter_default_config(), ) - if use_gas_meter: - # Build Gas Meter - my_gas_meter = gas_meter.GasMeter( - my_simulation_parameters=my_simulation_parameters, - config=gas_meter.GasMeterConfig.get_gas_meter_default_config(), - ) - my_sim.add_component(my_gas_meter, connect_automatically=True) # Build Electric Vehicle Configs and Car Battery Configs my_car_config = generic_car.CarConfig.get_default_ev_config() @@ -583,12 +520,7 @@ def setup_function( ResultPathProviderSingleton().set_important_result_path_information( module_directory=my_sim.module_directory, # "/storage_cluster/projects/2024_waage/01_hisim_results", model_name=my_sim.module_filename, - further_result_folder_description=os.path.join( - *[ - further_result_folder_description, - - ] - ), + further_result_folder_description=os.path.join(*[further_result_folder_description,]), variant_name="_", scenario_hash_string=scenario_hash_string, sorting_option=sorting_option, diff --git a/system_setups/household_hp_hws_hds_pv_battery_ems.py b/system_setups/household_hp_hws_hds_pv_battery_ems.py index 734273c15..4abe2889d 100644 --- a/system_setups/household_hp_hws_hds_pv_battery_ems.py +++ b/system_setups/household_hp_hws_hds_pv_battery_ems.py @@ -99,8 +99,7 @@ def setup_function( ) my_photovoltaic_system = generic_pv_system.PVSystem( - config=my_photovoltaic_system_config, - my_simulation_parameters=my_simulation_parameters, + config=my_photovoltaic_system_config, my_simulation_parameters=my_simulation_parameters, ) # Build Heat Distribution Controller my_heat_distribution_controller_config = heat_distribution_system.HeatDistributionControllerConfig.get_default_heat_distribution_controller_config( @@ -111,8 +110,7 @@ def setup_function( ) my_heat_distribution_controller = heat_distribution_system.HeatDistributionController( - my_simulation_parameters=my_simulation_parameters, - config=my_heat_distribution_controller_config, + my_simulation_parameters=my_simulation_parameters, config=my_heat_distribution_controller_config, ) my_hds_controller_information = heat_distribution_system.HeatDistributionControllerInformation( config=my_heat_distribution_controller_config @@ -140,18 +138,16 @@ def setup_function( my_heat_pump_config.flow_temperature_in_celsius = Quantity(flow_temperature_in_celsius, Celsius) my_heat_pump = advanced_heat_pump_hplib.HeatPumpHplib( - config=my_heat_pump_config, - my_simulation_parameters=my_simulation_parameters, + config=my_heat_pump_config, my_simulation_parameters=my_simulation_parameters, ) # Build Heat Distribution System my_heat_distribution_system_config = heat_distribution_system.HeatDistributionConfig.get_default_heatdistributionsystem_config( water_mass_flow_rate_in_kg_per_second=my_hds_controller_information.water_mass_flow_rate_in_kp_per_second, - absolute_conditioned_floor_area_in_m2=my_building_information.scaled_conditioned_floor_area_in_m2 + absolute_conditioned_floor_area_in_m2=my_building_information.scaled_conditioned_floor_area_in_m2, ) my_heat_distribution_system = heat_distribution_system.HeatDistribution( - config=my_heat_distribution_system_config, - my_simulation_parameters=my_simulation_parameters, + config=my_heat_distribution_system_config, my_simulation_parameters=my_simulation_parameters, ) # Build Heat Water Storage @@ -161,15 +157,13 @@ def setup_function( temperature_difference_between_flow_and_return_in_celsius=my_hds_controller_information.temperature_difference_between_flow_and_return_in_celsius, ) my_simple_hot_water_storage = simple_water_storage.SimpleHotWaterStorage( - config=my_simple_heat_water_storage_config, - my_simulation_parameters=my_simulation_parameters, + config=my_simple_heat_water_storage_config, my_simulation_parameters=my_simulation_parameters, ) # Build EMS my_electricity_controller_config = controller_l2_energy_management_system.EMSConfig.get_default_config_ems() my_electricity_controller = controller_l2_energy_management_system.L2GenericEnergyManagementSystem( - my_simulation_parameters=my_simulation_parameters, - config=my_electricity_controller_config, + my_simulation_parameters=my_simulation_parameters, config=my_electricity_controller_config, ) # Build Battery @@ -177,8 +171,7 @@ def setup_function( total_pv_power_in_watt_peak=my_photovoltaic_system_config.power_in_watt ) my_advanced_battery = advanced_battery_bslib.Battery( - my_simulation_parameters=my_simulation_parameters, - config=my_advanced_battery_config, + my_simulation_parameters=my_simulation_parameters, config=my_advanced_battery_config, ) # ----------------------------------------------------------------------------------------------------------------- @@ -186,10 +179,7 @@ def setup_function( my_electricity_controller.add_component_output( source_output_name=lt.InandOutputType.ELECTRICITY_TARGET, - source_tags=[ - lt.ComponentType.HEAT_PUMP_DHW, - lt.InandOutputType.ELECTRICITY_TARGET, - ], + source_tags=[lt.ComponentType.HEAT_PUMP_DHW, lt.InandOutputType.ELECTRICITY_TARGET,], source_weight=1, source_load_type=lt.LoadTypes.ELECTRICITY, source_unit=lt.Units.WATT, @@ -198,10 +188,7 @@ def setup_function( my_electricity_controller.add_component_output( source_output_name=lt.InandOutputType.ELECTRICITY_TARGET, - source_tags=[ - lt.ComponentType.HEAT_PUMP_BUILDING, - lt.InandOutputType.ELECTRICITY_TARGET, - ], + source_tags=[lt.ComponentType.HEAT_PUMP_BUILDING, lt.InandOutputType.ELECTRICITY_TARGET,], source_weight=2, source_load_type=lt.LoadTypes.ELECTRICITY, source_unit=lt.Units.WATT, @@ -210,10 +197,7 @@ def setup_function( electricity_to_or_from_battery_target = my_electricity_controller.add_component_output( source_output_name=lt.InandOutputType.ELECTRICITY_TARGET, - source_tags=[ - lt.ComponentType.BATTERY, - lt.InandOutputType.ELECTRICITY_TARGET, - ], + source_tags=[lt.ComponentType.BATTERY, lt.InandOutputType.ELECTRICITY_TARGET,], source_weight=3, source_load_type=lt.LoadTypes.ELECTRICITY, source_unit=lt.Units.WATT, diff --git a/system_setups/household_reference_gas_heater_diesel_car.py b/system_setups/household_reference_gas_heater_diesel_car.py index a1d711591..ae908b848 100644 --- a/system_setups/household_reference_gas_heater_diesel_car.py +++ b/system_setups/household_reference_gas_heater_diesel_car.py @@ -17,7 +17,6 @@ from hisim.components import loadprofilegenerator_utsp_connector from hisim.components import weather from hisim.components import generic_gas_heater -from hisim.components import controller_l1_generic_gas_heater from hisim.components import heat_distribution_system from hisim.components import building from hisim.components import simple_water_storage @@ -51,7 +50,7 @@ class ReferenceHouseholdConfig(SystemSetupConfigBase): building_config: building.BuildingConfig hds_controller_config: heat_distribution_system.HeatDistributionControllerConfig hds_config: heat_distribution_system.HeatDistributionConfig - gasheater_controller_config: controller_l1_generic_gas_heater.GenericGasHeaterControllerL1Config + gasheater_controller_config: generic_gas_heater.GenericGasHeaterControllerL1Config gasheater_config: generic_gas_heater.GenericGasHeaterConfig simple_hot_water_storage_config: simple_water_storage.SimpleHotWaterStorageConfig dhw_heatpump_config: generic_heat_pump_modular.HeatPumpConfig @@ -104,12 +103,12 @@ def get_default(cls): hds_config=( heat_distribution_system.HeatDistributionConfig.get_default_heatdistributionsystem_config( water_mass_flow_rate_in_kg_per_second=my_hds_controller_information.water_mass_flow_rate_in_kp_per_second, - absolute_conditioned_floor_area_in_m2=my_building_information.scaled_conditioned_floor_area_in_m2 + absolute_conditioned_floor_area_in_m2=my_building_information.scaled_conditioned_floor_area_in_m2, ) ), gasheater_controller_config=( - controller_l1_generic_gas_heater.GenericGasHeaterControllerL1Config.get_scaled_generic_gas_heater_controller_config( - heating_load_of_building_in_watt=my_building_information.max_thermal_building_demand_in_watt + generic_gas_heater.GenericGasHeaterControllerL1Config.get_default_generic_gas_heater_controller_config( + maximal_thermal_power_in_watt=my_building_information.max_thermal_building_demand_in_watt ) ), gasheater_config=generic_gas_heater.GenericGasHeaterConfig.get_scaled_gasheater_config( @@ -202,8 +201,7 @@ def setup_function( # Build heat Distribution System Controller my_heat_distribution_controller = heat_distribution_system.HeatDistributionController( - config=my_config.hds_controller_config, - my_simulation_parameters=my_simulation_parameters, + config=my_config.hds_controller_config, my_simulation_parameters=my_simulation_parameters, ) # Build Occupancy @@ -220,20 +218,17 @@ def setup_function( # Build Building my_building = building.Building( - config=my_config.building_config, - my_simulation_parameters=my_simulation_parameters, + config=my_config.building_config, my_simulation_parameters=my_simulation_parameters, ) # Build Gas Heater Controller - my_gasheater_controller = controller_l1_generic_gas_heater.GenericGasHeaterControllerL1( - my_simulation_parameters=my_simulation_parameters, - config=my_config.gasheater_controller_config, + my_gasheater_controller = generic_gas_heater.GenericGasHeaterControllerL1( + my_simulation_parameters=my_simulation_parameters, config=my_config.gasheater_controller_config, ) # Build Gasheater my_gasheater = generic_gas_heater.GasHeater( - config=my_config.gasheater_config, - my_simulation_parameters=my_simulation_parameters, + config=my_config.gasheater_config, my_simulation_parameters=my_simulation_parameters, ) # Build Heat Distribution System @@ -243,8 +238,7 @@ def setup_function( # Build Heat Water Storage my_simple_hot_water_storage = simple_water_storage.SimpleHotWaterStorage( - config=my_config.simple_hot_water_storage_config, - my_simulation_parameters=my_simulation_parameters, + config=my_config.simple_hot_water_storage_config, my_simulation_parameters=my_simulation_parameters, ) # Build DHW @@ -263,8 +257,7 @@ def setup_function( ) my_domnestic_hot_water_heatpump_controller = controller_l1_heatpump.L1HeatPumpController( - my_simulation_parameters=my_simulation_parameters, - config=my_dhw_heatpump_controller_config, + my_simulation_parameters=my_simulation_parameters, config=my_dhw_heatpump_controller_config, ) my_domnestic_hot_water_heatpump = generic_heat_pump_modular.ModularHeatPump( @@ -292,8 +285,7 @@ def setup_function( # Build Electricity Meter my_electricity_meter = electricity_meter.ElectricityMeter( - my_simulation_parameters=my_simulation_parameters, - config=my_config.electricity_meter_config, + my_simulation_parameters=my_simulation_parameters, config=my_config.electricity_meter_config, ) # ================================================================================================================================= diff --git a/system_setups/household_with_advanced_hp_hws_hds_pv_battery_ems.py b/system_setups/household_with_advanced_hp_hws_hds_pv_battery_ems.py index dbfb34b24..2d32c30ab 100644 --- a/system_setups/household_with_advanced_hp_hws_hds_pv_battery_ems.py +++ b/system_setups/household_with_advanced_hp_hws_hds_pv_battery_ems.py @@ -99,8 +99,7 @@ def setup_function( ) my_photovoltaic_system = generic_pv_system.PVSystem( - config=my_photovoltaic_system_config, - my_simulation_parameters=my_simulation_parameters, + config=my_photovoltaic_system_config, my_simulation_parameters=my_simulation_parameters, ) # Build Heat Distribution Controller my_heat_distribution_controller_config = heat_distribution_system.HeatDistributionControllerConfig.get_default_heat_distribution_controller_config( @@ -111,8 +110,7 @@ def setup_function( ) my_heat_distribution_controller = heat_distribution_system.HeatDistributionController( - my_simulation_parameters=my_simulation_parameters, - config=my_heat_distribution_controller_config, + my_simulation_parameters=my_simulation_parameters, config=my_heat_distribution_controller_config, ) my_hds_controller_information = heat_distribution_system.HeatDistributionControllerInformation( config=my_heat_distribution_controller_config @@ -134,24 +132,22 @@ def setup_function( # Build Heat Pump my_heat_pump_config = advanced_heat_pump_hplib.HeatPumpHplibConfig.get_scaled_advanced_hp_lib( heating_load_of_building_in_watt=Quantity(my_building_information.max_thermal_building_demand_in_watt, Watt), - heating_reference_temperature_in_celsius=Quantity(heating_reference_temperature_in_celsius, Celsius) + heating_reference_temperature_in_celsius=Quantity(heating_reference_temperature_in_celsius, Celsius), ) my_heat_pump_config.group_id = group_id my_heat_pump_config.flow_temperature_in_celsius = Quantity(float(flow_temperature_in_celsius), Celsius) my_heat_pump = advanced_heat_pump_hplib.HeatPumpHplib( - config=my_heat_pump_config, - my_simulation_parameters=my_simulation_parameters, + config=my_heat_pump_config, my_simulation_parameters=my_simulation_parameters, ) # Build Heat Distribution System my_heat_distribution_system_config = heat_distribution_system.HeatDistributionConfig.get_default_heatdistributionsystem_config( water_mass_flow_rate_in_kg_per_second=my_hds_controller_information.water_mass_flow_rate_in_kp_per_second, - absolute_conditioned_floor_area_in_m2=my_building_information.scaled_conditioned_floor_area_in_m2 + absolute_conditioned_floor_area_in_m2=my_building_information.scaled_conditioned_floor_area_in_m2, ) my_heat_distribution_system = heat_distribution_system.HeatDistribution( - config=my_heat_distribution_system_config, - my_simulation_parameters=my_simulation_parameters, + config=my_heat_distribution_system_config, my_simulation_parameters=my_simulation_parameters, ) # Build Heat Water Storage @@ -161,15 +157,13 @@ def setup_function( temperature_difference_between_flow_and_return_in_celsius=my_hds_controller_information.temperature_difference_between_flow_and_return_in_celsius, ) my_simple_hot_water_storage = simple_water_storage.SimpleHotWaterStorage( - config=my_simple_heat_water_storage_config, - my_simulation_parameters=my_simulation_parameters, + config=my_simple_heat_water_storage_config, my_simulation_parameters=my_simulation_parameters, ) # Build EMS my_electricity_controller_config = controller_l2_energy_management_system.EMSConfig.get_default_config_ems() my_electricity_controller = controller_l2_energy_management_system.L2GenericEnergyManagementSystem( - my_simulation_parameters=my_simulation_parameters, - config=my_electricity_controller_config, + my_simulation_parameters=my_simulation_parameters, config=my_electricity_controller_config, ) # Build Battery @@ -177,8 +171,7 @@ def setup_function( total_pv_power_in_watt_peak=my_photovoltaic_system_config.power_in_watt ) my_advanced_battery = advanced_battery_bslib.Battery( - my_simulation_parameters=my_simulation_parameters, - config=my_advanced_battery_config, + my_simulation_parameters=my_simulation_parameters, config=my_advanced_battery_config, ) # ----------------------------------------------------------------------------------------------------------------- @@ -206,10 +199,7 @@ def setup_function( source_component_output=my_heat_pump.ElectricalInputPower, source_load_type=lt.LoadTypes.ELECTRICITY, source_unit=lt.Units.WATT, - source_tags=[ - lt.ComponentType.HEAT_PUMP_BUILDING, - lt.InandOutputType.ELECTRICITY_CONSUMPTION_EMS_CONTROLLED, - ], + source_tags=[lt.ComponentType.HEAT_PUMP_BUILDING, lt.InandOutputType.ELECTRICITY_CONSUMPTION_EMS_CONTROLLED,], source_weight=2, ) @@ -228,15 +218,12 @@ def setup_function( source_load_type=lt.LoadTypes.ELECTRICITY, source_unit=lt.Units.WATT, source_tags=[lt.ComponentType.RESIDENTS, lt.InandOutputType.ELECTRICITY_CONSUMPTION_EMS_CONTROLLED], - source_weight=1 + source_weight=1, ) my_electricity_controller.add_component_output( source_output_name=f"ElectricityToOrFromGridOf{my_occupancy.get_classname()}_", - source_tags=[ - lt.ComponentType.RESIDENTS, - lt.InandOutputType.ELECTRICITY_TARGET, - ], + source_tags=[lt.ComponentType.RESIDENTS, lt.InandOutputType.ELECTRICITY_TARGET,], source_weight=1, source_load_type=lt.LoadTypes.ELECTRICITY, source_unit=lt.Units.WATT, @@ -248,10 +235,7 @@ def setup_function( source_component_output=my_photovoltaic_system.ElectricityOutput, source_load_type=lt.LoadTypes.ELECTRICITY, source_unit=lt.Units.WATT, - source_tags=[ - lt.ComponentType.PV, - lt.InandOutputType.ELECTRICITY_PRODUCTION, - ], + source_tags=[lt.ComponentType.PV, lt.InandOutputType.ELECTRICITY_PRODUCTION,], source_weight=999, ) diff --git a/system_setups/household_with_more_advanced_hp_hws_dhw_hds.py b/system_setups/household_with_more_advanced_hp_hws_dhw_hds.py index bc30b5d48..542166a6a 100644 --- a/system_setups/household_with_more_advanced_hp_hws_dhw_hds.py +++ b/system_setups/household_with_more_advanced_hp_hws_dhw_hds.py @@ -102,8 +102,7 @@ def setup_function( ) my_heat_distribution_controller = heat_distribution_system.HeatDistributionController( - my_simulation_parameters=my_simulation_parameters, - config=my_heat_distribution_controller_config, + my_simulation_parameters=my_simulation_parameters, config=my_heat_distribution_controller_config, ) my_hds_controller_information = heat_distribution_system.HeatDistributionControllerInformation( config=my_heat_distribution_controller_config @@ -150,19 +149,17 @@ def setup_function( my_heatpump_config.with_domestic_hot_water_preparation = with_domestic_hot_water_preparation my_heatpump = more_advanced_heat_pump_hplib.MoreAdvancedHeatPumpHPLib( - config=my_heatpump_config, - my_simulation_parameters=my_simulation_parameters, + config=my_heatpump_config, my_simulation_parameters=my_simulation_parameters, ) # Build Heat Distribution System my_heat_distribution_config = heat_distribution_system.HeatDistributionConfig.get_default_heatdistributionsystem_config( water_mass_flow_rate_in_kg_per_second=my_hds_controller_information.water_mass_flow_rate_in_kp_per_second, - absolute_conditioned_floor_area_in_m2=my_building_information.scaled_conditioned_floor_area_in_m2 + absolute_conditioned_floor_area_in_m2=my_building_information.scaled_conditioned_floor_area_in_m2, ) my_heat_distribution = heat_distribution_system.HeatDistribution( - config=my_heat_distribution_config, - my_simulation_parameters=my_simulation_parameters, + config=my_heat_distribution_config, my_simulation_parameters=my_simulation_parameters, ) # Build Heat Water Storage @@ -173,16 +170,14 @@ def setup_function( ) my_hot_water_storage = simple_water_storage.SimpleHotWaterStorage( - config=my_hot_water_storage_config, - my_simulation_parameters=my_simulation_parameters, + config=my_hot_water_storage_config, my_simulation_parameters=my_simulation_parameters, ) # Build DHW Storage my_dhw_storage_config = generic_hot_water_storage_modular.StorageConfig.get_default_config_for_boiler() my_dhw_storage = generic_hot_water_storage_modular.HotWaterStorage( - config=my_dhw_storage_config, - my_simulation_parameters=my_simulation_parameters, + config=my_dhw_storage_config, my_simulation_parameters=my_simulation_parameters, ) # ================================================================================================================================= @@ -211,9 +206,7 @@ def setup_function( # Verknüpfung mit Luft als Umgebungswärmeqzuelle if my_heatpump.parameters["Group"].iloc[0] == 1.0 or my_heatpump.parameters["Group"].iloc[0] == 4.0: my_heatpump.connect_input( - my_heatpump.TemperatureInputPrimary, - my_weather.component_name, - my_weather.DailyAverageOutsideTemperatures, + my_heatpump.TemperatureInputPrimary, my_weather.component_name, my_weather.DailyAverageOutsideTemperatures, ) else: raise KeyError( @@ -251,9 +244,7 @@ def setup_function( my_dhw_storage.connect_only_predefined_connections(my_occupancy) my_dhw_storage.connect_input( - my_dhw_storage.ThermalPowerDelivered, - my_heatpump.component_name, - my_heatpump.ThermalOutputPowerDHW, + my_dhw_storage.ThermalPowerDelivered, my_heatpump.component_name, my_heatpump.ThermalOutputPowerDHW, ) ################################ @@ -272,9 +263,7 @@ def setup_function( source_component_output=my_heatpump.ElectricalInputPowerTotal, source_load_type=lt.LoadTypes.ELECTRICITY, source_unit=lt.Units.WATT, - source_tags=[ - lt.InandOutputType.ELECTRICITY_CONSUMPTION_UNCONTROLLED, - ], + source_tags=[lt.InandOutputType.ELECTRICITY_CONSUMPTION_UNCONTROLLED,], source_weight=999, ) diff --git a/system_setups/modular_example.py b/system_setups/modular_example.py index f947773d7..759928e5c 100644 --- a/system_setups/modular_example.py +++ b/system_setups/modular_example.py @@ -24,9 +24,7 @@ generic_smart_device, ) from hisim.modular_household import component_connections -from hisim.modular_household.interface_configs.modular_household_config import ( - read_in_configs, -) +from hisim.modular_household.interface_configs.modular_household_config import read_in_configs from hisim.postprocessingoptions import PostProcessingOptions from hisim.simulator import SimulationParameters @@ -54,9 +52,7 @@ def cleanup_old_lpg_requests(): os.remove(full_file_path) -def get_heating_reference_temperature_and_season_from_location( - location: str, -) -> Tuple[float, List[int]]: +def get_heating_reference_temperature_and_season_from_location(location: str,) -> Tuple[float, List[int]]: """Reads in temperature of coldest day for sizing of heating system and heating season for control of the heating system. Both relies on the location. @@ -183,10 +179,9 @@ def setup_function( my_sim.add_component(my_weather) # Build building - ( - reference_temperature, - heating_season, - ) = get_heating_reference_temperature_and_season_from_location(location=location) + (reference_temperature, heating_season,) = get_heating_reference_temperature_and_season_from_location( + location=location + ) my_building_config = building.BuildingConfig( name="Building_1", @@ -202,7 +197,7 @@ def setup_function( set_heating_temperature_in_celsius=19.0, set_cooling_temperature_in_celsius=24.0, enable_opening_windows=False, - max_thermal_building_demand_in_watt=None + max_thermal_building_demand_in_watt=None, ) my_building_information = building.BuildingInformation(config=my_building_config) my_building = building.Building(config=my_building_config, my_simulation_parameters=my_simulation_parameters) @@ -233,12 +228,11 @@ def setup_function( profile_with_washing_machine_and_dishwasher=not smart_devices_included, predictive_control=False, predictive=False, - building_name="BUI1" + building_name="BUI1", ) my_occupancy = loadprofilegenerator_utsp_connector.UtspLpgConnector( - config=my_occupancy_config, - my_simulation_parameters=my_simulation_parameters, + config=my_occupancy_config, my_simulation_parameters=my_simulation_parameters, ) else: @@ -248,8 +242,7 @@ def setup_function( ) my_occupancy = loadprofilegenerator_utsp_connector.UtspLpgConnector( - config=my_occupancy_config, - my_simulation_parameters=my_simulation_parameters, + config=my_occupancy_config, my_simulation_parameters=my_simulation_parameters, ) my_building.connect_only_predefined_connections(my_weather, my_occupancy) @@ -312,8 +305,7 @@ def setup_function( ): my_electricity_controller_config = controller_l2_energy_management_system.EMSConfig.get_default_config_ems() my_electricity_controller = controller_l2_energy_management_system.L2GenericEnergyManagementSystem( - my_simulation_parameters=my_simulation_parameters, - config=my_electricity_controller_config, + my_simulation_parameters=my_simulation_parameters, config=my_electricity_controller_config, ) my_electricity_controller.add_component_inputs_and_connect( @@ -351,8 +343,7 @@ def setup_function( # use clever controller if smart devices are included and do not use it if it is false if smart_devices_included and controllable and utsp_connected: component_connections.configure_smart_controller_for_smart_devices( - my_electricity_controller=my_electricity_controller, - my_smart_devices=my_smart_devices, + my_electricity_controller=my_electricity_controller, my_smart_devices=my_smart_devices, ) # """WATERHEATING""" @@ -538,9 +529,6 @@ def needs_ems( # pylint: disable=R0911 if heating_system_installed in [ lt.HeatingSystems.HEAT_PUMP, lt.HeatingSystems.ELECTRIC_HEATING, - ] or water_heating_system_installed in [ - lt.HeatingSystems.HEAT_PUMP, - lt.HeatingSystems.ELECTRIC_HEATING, - ]: + ] or water_heating_system_installed in [lt.HeatingSystems.HEAT_PUMP, lt.HeatingSystems.ELECTRIC_HEATING,]: return True return False diff --git a/system_setups/power_to_x_transformation_battery_electrolyzer_grid.py b/system_setups/power_to_x_transformation_battery_electrolyzer_grid.py index afbc0e651..b3236d4e9 100644 --- a/system_setups/power_to_x_transformation_battery_electrolyzer_grid.py +++ b/system_setups/power_to_x_transformation_battery_electrolyzer_grid.py @@ -118,8 +118,7 @@ def setup_function(my_sim: Simulator, my_simulation_parameters: Optional[Simulat csv_loader = CSVLoader(my_csv_loader, my_simulation_parameters=my_simulation_parameters) my_transformer = Transformer( - my_simulation_parameters=my_simulation_parameters, - config=TransformerConfig.get_default_transformer(), + my_simulation_parameters=my_simulation_parameters, config=TransformerConfig.get_default_transformer(), ) # Setup the battery """ @@ -163,9 +162,7 @@ def setup_function(my_sim: Simulator, my_simulation_parameters: Optional[Simulat my_transformer.connect_input(my_transformer.TransformerInput, csv_loader.component_name, csv_loader.Output1) my_ptx_controller.connect_input( - my_ptx_controller.RESLoad, - my_transformer.component_name, - my_transformer.TransformerOutput, + my_ptx_controller.RESLoad, my_transformer.component_name, my_transformer.TransformerOutput, ) """ my_ptx_controller.connect_input( @@ -181,9 +178,7 @@ def setup_function(my_sim: Simulator, my_simulation_parameters: Optional[Simulat ) """ my_electrolyzer_controller.connect_input( - my_electrolyzer_controller.ProvidedLoad, - my_ptx_controller.component_name, - my_ptx_controller.PowerToSystem, + my_electrolyzer_controller.ProvidedLoad, my_ptx_controller.component_name, my_ptx_controller.PowerToSystem, ) my_electrolyzer.connect_input( @@ -193,9 +188,7 @@ def setup_function(my_sim: Simulator, my_simulation_parameters: Optional[Simulat ) my_electrolyzer.connect_input( - my_electrolyzer.InputState, - my_electrolyzer_controller.component_name, - my_electrolyzer_controller.CurrentMode, + my_electrolyzer.InputState, my_electrolyzer_controller.component_name, my_electrolyzer_controller.CurrentMode, ) # ================================================================================================================================= diff --git a/system_setups/power_to_x_transformation_battery_electrolyzer_no_grid.py b/system_setups/power_to_x_transformation_battery_electrolyzer_no_grid.py index 79ffc144d..ad18b7f62 100644 --- a/system_setups/power_to_x_transformation_battery_electrolyzer_no_grid.py +++ b/system_setups/power_to_x_transformation_battery_electrolyzer_no_grid.py @@ -117,8 +117,7 @@ def setup_function(my_sim: Simulator, my_simulation_parameters: Optional[Simulat csv_loader = CSVLoader(my_csv_loader, my_simulation_parameters=my_simulation_parameters) my_transformer = Transformer( - my_simulation_parameters=my_simulation_parameters, - config=TransformerConfig.get_default_transformer(), + my_simulation_parameters=my_simulation_parameters, config=TransformerConfig.get_default_transformer(), ) # Setup the battery """ @@ -162,9 +161,7 @@ def setup_function(my_sim: Simulator, my_simulation_parameters: Optional[Simulat my_transformer.connect_input(my_transformer.TransformerInput, csv_loader.component_name, csv_loader.Output1) my_ptx_controller.connect_input( - my_ptx_controller.RESLoad, - my_transformer.component_name, - my_transformer.TransformerOutput, + my_ptx_controller.RESLoad, my_transformer.component_name, my_transformer.TransformerOutput, ) """ my_ptx_controller.connect_input( @@ -180,9 +177,7 @@ def setup_function(my_sim: Simulator, my_simulation_parameters: Optional[Simulat ) """ my_electrolyzer_controller.connect_input( - my_electrolyzer_controller.ProvidedLoad, - my_ptx_controller.component_name, - my_ptx_controller.PowerToSystem, + my_electrolyzer_controller.ProvidedLoad, my_ptx_controller.component_name, my_ptx_controller.PowerToSystem, ) my_electrolyzer.connect_input( @@ -192,9 +187,7 @@ def setup_function(my_sim: Simulator, my_simulation_parameters: Optional[Simulat ) my_electrolyzer.connect_input( - my_electrolyzer.InputState, - my_electrolyzer_controller.component_name, - my_electrolyzer_controller.CurrentMode, + my_electrolyzer.InputState, my_electrolyzer_controller.component_name, my_electrolyzer_controller.CurrentMode, ) # ================================================================================================================================= diff --git a/system_setups/simple_system_setup_one.py b/system_setups/simple_system_setup_one.py index cf7138b59..e5c30d6cd 100644 --- a/system_setups/simple_system_setup_one.py +++ b/system_setups/simple_system_setup_one.py @@ -59,18 +59,13 @@ def setup_function(my_sim: Simulator, my_simulation_parameters: Optional[Simulat # Create sum builder object my_sum = SumBuilderForTwoInputs( - config=SumBuilderConfig.get_sumbuilder_default_config(), - my_simulation_parameters=my_simulation_parameters, + config=SumBuilderConfig.get_sumbuilder_default_config(), my_simulation_parameters=my_simulation_parameters, ) # Connect inputs from sum object to both previous outputs my_sum.connect_input( - input_fieldname=my_sum.SumInput1, - src_object_name=my_rn1.component_name, - src_field_name=my_rn1.RandomOutput, + input_fieldname=my_sum.SumInput1, src_object_name=my_rn1.component_name, src_field_name=my_rn1.RandomOutput, ) my_sum.connect_input( - input_fieldname=my_sum.SumInput2, - src_object_name=my_rn2.component_name, - src_field_name=my_rn2.RandomOutput, + input_fieldname=my_sum.SumInput2, src_object_name=my_rn2.component_name, src_field_name=my_rn2.RandomOutput, ) my_sim.add_component(my_sum) diff --git a/system_setups/simple_system_setup_two.py b/system_setups/simple_system_setup_two.py index ca4766ecb..02e542c40 100644 --- a/system_setups/simple_system_setup_two.py +++ b/system_setups/simple_system_setup_two.py @@ -66,8 +66,7 @@ def setup_function(my_sim: Simulator, my_simulation_parameters: Optional[Simulat # Create new Transformer object # my_transformer = Transformer(name="MyTransformer", my_simulation_parameters=my_simulation_parameters) my_transformer = ExampleTransformer( - config=ExampleTransformerConfig.get_default_transformer(), - my_simulation_parameters=my_simulation_parameters, + config=ExampleTransformerConfig.get_default_transformer(), my_simulation_parameters=my_simulation_parameters, ) my_transformer.connect_input( input_fieldname=my_transformer.TransformerInput, # Connect input from my transformer @@ -78,14 +77,11 @@ def setup_function(my_sim: Simulator, my_simulation_parameters: Optional[Simulat # Create sum builder object my_sum = SumBuilderForTwoInputs( - config=SumBuilderConfig.get_sumbuilder_default_config(), - my_simulation_parameters=my_simulation_parameters, + config=SumBuilderConfig.get_sumbuilder_default_config(), my_simulation_parameters=my_simulation_parameters, ) # Connect inputs from sum object to both previous outputs my_sum.connect_input( - input_fieldname=my_sum.SumInput1, - src_object_name=my_rn1.component_name, - src_field_name=my_rn1.RandomOutput, + input_fieldname=my_sum.SumInput1, src_object_name=my_rn1.component_name, src_field_name=my_rn1.RandomOutput, ) my_sum.connect_input( input_fieldname=my_sum.SumInput2, diff --git a/tests/test_gas_meter.py b/tests/test_gas_meter.py index 1736c80f2..c05832919 100644 --- a/tests/test_gas_meter.py +++ b/tests/test_gas_meter.py @@ -16,7 +16,6 @@ electricity_meter, gas_meter, generic_gas_heater, - controller_l1_generic_gas_heater, generic_heat_source, controller_l1_heatpump, generic_hot_water_storage_modular, @@ -141,10 +140,10 @@ def test_house( ) # Build Gas Heater Controller - my_gas_heater_controller_config = controller_l1_generic_gas_heater.GenericGasHeaterControllerL1Config.get_scaled_generic_gas_heater_controller_config( - heating_load_of_building_in_watt=my_building_information.max_thermal_building_demand_in_watt + my_gas_heater_controller_config = generic_gas_heater.GenericGasHeaterControllerL1Config.get_default_generic_gas_heater_controller_config( + maximal_thermal_power_in_watt=my_building_information.max_thermal_building_demand_in_watt ) - my_gas_heater_controller = controller_l1_generic_gas_heater.GenericGasHeaterControllerL1( + my_gas_heater_controller = generic_gas_heater.GenericGasHeaterControllerL1( my_simulation_parameters=my_simulation_parameters, config=my_gas_heater_controller_config, ) @@ -158,7 +157,8 @@ def test_house( my_simulation_parameters=my_simulation_parameters, ) # Build Gas Heater for DHW - my_gas_heater_for_dhw_config = generic_heat_source.HeatSourceConfig.get_default_config_waterheating_with_gas( + my_gas_heater_for_dhw_config = generic_heat_source.HeatSourceConfig.get_default_config_waterheating( + heating_system=loadtypes.HeatingSystems.GAS_HEATING, max_warm_water_demand_in_liter=my_occupancy.max_hot_water_demand, scaling_factor_according_to_number_of_apartments=my_occupancy.scaling_factor_according_to_number_of_apartments, seconds_per_timestep=seconds_per_timestep, @@ -243,7 +243,7 @@ def test_house( "Gas consumption for space heating" ].get("value") gas_consumption_for_domestic_hot_water_in_kilowatt_hour = jsondata["Gas Heater For Domestic Hot Water"][ - "Gas consumption for domestic hot water" + "Gas consumption for WaterHeating" ].get("value") opex_costs_for_gas_in_euro = jsondata["Gas Meter"]["Opex costs of gas consumption from grid"].get("value") diff --git a/tests/test_generic_dhw_boiler.py b/tests/test_generic_dhw_boiler.py index f30007859..1f696ceea 100644 --- a/tests/test_generic_dhw_boiler.py +++ b/tests/test_generic_dhw_boiler.py @@ -28,8 +28,11 @@ def test_simple_bucket_boiler_state(): generic_hot_water_storage_modular.StorageConfig.get_default_config_for_boiler() ) boiler_config.volume = 200 - heater_config = ( - generic_heat_source.HeatSourceConfig.get_default_config_waterheating_with_district_heating() + heater_config = generic_heat_source.HeatSourceConfig.get_default_config_waterheating( + heating_system=lt.HeatingSystems.DISTRICT_HEATING, + max_warm_water_demand_in_liter=200, + scaling_factor_according_to_number_of_apartments=1, + seconds_per_timestep=seconds_per_timestep, ) # definition of outputs diff --git a/tests/test_system_setups_household_cluster.py b/tests/test_system_setups_household_cluster.py deleted file mode 100644 index 0d6add16e..000000000 --- a/tests/test_system_setups_household_cluster.py +++ /dev/null @@ -1,36 +0,0 @@ -""" Tests for the cluster system setups. - -These system setups can only be tested on cluster because so far they need access to a certain cluster directory. -""" -# clean -import os -import pytest - -from hisim import hisim_main -from hisim.simulationparameters import SimulationParameters -from hisim import log -from hisim import utils -from hisim.postprocessingoptions import PostProcessingOptions - - -@pytest.mark.system_setups -@utils.measure_execution_time -def test_cluster_household_with_pv_battery_and_ems(): - """Single day.""" - path = "../system_setups/household_gas_or_heatpump.py" - - my_simulation_parameters = SimulationParameters.one_day_only(year=2021, seconds_per_timestep=60) - - my_simulation_parameters.post_processing_options.append(PostProcessingOptions.PLOT_LINE) - - my_simulation_parameters.post_processing_options.append( - PostProcessingOptions.PREPARE_OUTPUTS_FOR_SCENARIO_EVALUATION - ) - - my_simulation_parameters.post_processing_options.append(PostProcessingOptions.COMPUTE_KPIS) - my_simulation_parameters.post_processing_options.append(PostProcessingOptions.WRITE_KPIS_TO_JSON) - my_simulation_parameters.post_processing_options.append(PostProcessingOptions.OPEN_DIRECTORY_IN_EXPLORER) - my_simulation_parameters.post_processing_options.append(PostProcessingOptions.MAKE_NETWORK_CHARTS) - - hisim_main.main(path, my_simulation_parameters) - log.information(os.getcwd()) diff --git a/tests/test_system_setups_households_for_building_sizer.py b/tests/test_system_setups_households_for_building_sizer.py new file mode 100644 index 000000000..11a062edd --- /dev/null +++ b/tests/test_system_setups_households_for_building_sizer.py @@ -0,0 +1,85 @@ +""" Tests for the cluster system setups. + +These system setups can only be tested on cluster because so far they need access to a certain cluster directory. +""" +# clean +import os +import pytest + +from hisim import hisim_main +from hisim.simulationparameters import SimulationParameters +from hisim import log +from hisim import utils +from hisim.postprocessingoptions import PostProcessingOptions + + +@pytest.mark.system_setups +@utils.measure_execution_time +def test_household_gas(): + """Single day.""" + path = "../system_setups/household_gas_building_sizer.py" + + my_simulation_parameters = SimulationParameters.one_day_only(year=2021, seconds_per_timestep=60) + + my_simulation_parameters.post_processing_options.append(PostProcessingOptions.PLOT_LINE) + + my_simulation_parameters.post_processing_options.append( + PostProcessingOptions.PREPARE_OUTPUTS_FOR_SCENARIO_EVALUATION + ) + my_simulation_parameters.post_processing_options.append(PostProcessingOptions.COMPUTE_OPEX) + my_simulation_parameters.post_processing_options.append(PostProcessingOptions.COMPUTE_CAPEX) + my_simulation_parameters.post_processing_options.append(PostProcessingOptions.COMPUTE_KPIS) + my_simulation_parameters.post_processing_options.append(PostProcessingOptions.WRITE_KPIS_TO_JSON) + my_simulation_parameters.post_processing_options.append(PostProcessingOptions.OPEN_DIRECTORY_IN_EXPLORER) + my_simulation_parameters.post_processing_options.append(PostProcessingOptions.MAKE_NETWORK_CHARTS) + + hisim_main.main(path, my_simulation_parameters) + log.information(os.getcwd()) + + +@pytest.mark.system_setups +@utils.measure_execution_time +def test_household_heatpump(): + """Single day.""" + path = "../system_setups/household_heatpump_building_sizer.py" + + my_simulation_parameters = SimulationParameters.one_day_only(year=2021, seconds_per_timestep=60) + + my_simulation_parameters.post_processing_options.append(PostProcessingOptions.PLOT_LINE) + + my_simulation_parameters.post_processing_options.append( + PostProcessingOptions.PREPARE_OUTPUTS_FOR_SCENARIO_EVALUATION + ) + my_simulation_parameters.post_processing_options.append(PostProcessingOptions.COMPUTE_OPEX) + my_simulation_parameters.post_processing_options.append(PostProcessingOptions.COMPUTE_CAPEX) + my_simulation_parameters.post_processing_options.append(PostProcessingOptions.COMPUTE_KPIS) + my_simulation_parameters.post_processing_options.append(PostProcessingOptions.WRITE_KPIS_TO_JSON) + my_simulation_parameters.post_processing_options.append(PostProcessingOptions.OPEN_DIRECTORY_IN_EXPLORER) + my_simulation_parameters.post_processing_options.append(PostProcessingOptions.MAKE_NETWORK_CHARTS) + + hisim_main.main(path, my_simulation_parameters) + log.information(os.getcwd()) + + +@pytest.mark.system_setups +@utils.measure_execution_time +def test_household_district_heating(): + """Single day.""" + path = "../system_setups/household_district_heating_building_sizer.py" + + my_simulation_parameters = SimulationParameters.one_day_only(year=2021, seconds_per_timestep=60) + + my_simulation_parameters.post_processing_options.append(PostProcessingOptions.PLOT_LINE) + + my_simulation_parameters.post_processing_options.append( + PostProcessingOptions.PREPARE_OUTPUTS_FOR_SCENARIO_EVALUATION + ) + my_simulation_parameters.post_processing_options.append(PostProcessingOptions.COMPUTE_OPEX) + my_simulation_parameters.post_processing_options.append(PostProcessingOptions.COMPUTE_CAPEX) + my_simulation_parameters.post_processing_options.append(PostProcessingOptions.COMPUTE_KPIS) + my_simulation_parameters.post_processing_options.append(PostProcessingOptions.WRITE_KPIS_TO_JSON) + my_simulation_parameters.post_processing_options.append(PostProcessingOptions.OPEN_DIRECTORY_IN_EXPLORER) + my_simulation_parameters.post_processing_options.append(PostProcessingOptions.MAKE_NETWORK_CHARTS) + + hisim_main.main(path, my_simulation_parameters) + log.information(os.getcwd())