Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimization hds and hp for system setups without hot water storage #332

Merged
merged 25 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b9713d2
optimization of hds model
Hoppe-J Apr 9, 2024
3feb9e6
only restructuring and renaming
Hoppe-J Apr 10, 2024
864181b
running function for massflow=0, more literature and tsting
Hoppe-J Apr 12, 2024
d580203
additional inputs and equations for calculating heat transfer without…
Hoppe-J Apr 17, 2024
3a46c2f
Merge branch 'main' into optimization_HDS
Hoppe-J Apr 19, 2024
ea77c43
back to "original" if-condition for state_controller == 0
Hoppe-J Apr 24, 2024
536ed67
calculation of heat_resistance_coefficient_hds_pipe_to_air with heigh…
Hoppe-J Apr 24, 2024
4ac1401
Merge branch 'main' into optimization_HDS
Hoppe-J Apr 26, 2024
cd8e5ed
- restructuring hds model
Hoppe-J Apr 26, 2024
b0b34f0
- get flow rate of hds part of simple_hot_water_storage.py from outpu…
Hoppe-J Apr 29, 2024
b6a0d93
adapt system setups and tests to hot water storage model
Hoppe-J Apr 29, 2024
8ed1ab8
use parameters of task 44 iea Annex 38 for calculation of heat transfer
Hoppe-J May 2, 2024
0b73c1a
clear code
Hoppe-J May 2, 2024
edd358c
dateiname mit "00" beginnen, damit im result ornder ganz oben und sch…
Hoppe-J May 2, 2024
2ac8ba6
Merge branch 'main' into optimization_HDS
Hoppe-J May 5, 2024
1f158dc
- add new fuctions in hp model for simulating system setups without h…
Hoppe-J May 6, 2024
b9c07ae
- some renaming
Hoppe-J May 8, 2024
45ccdb4
fix parameters in system setup household 1b
Hoppe-J May 8, 2024
e04f6e6
- use nominal water massflow in dhw part also, if there is no paralle…
Hoppe-J May 13, 2024
4384b3f
Merge branch 'main' into optimization_HDS
Hoppe-J May 23, 2024
71f7770
- rename parameter if system setup have hot water storage
Hoppe-J May 23, 2024
155cb9a
correction in comments of PositionHotWaterStorageInSystemSetup class
Hoppe-J May 23, 2024
2657390
correction in calculation of dhw --> p_el_cooling was missing
Hoppe-J May 24, 2024
bb25b63
some debugging for dhw
Hoppe-J May 24, 2024
ec220f2
- add new output in hp
Hoppe-J Jun 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
372 changes: 263 additions & 109 deletions hisim/components/heat_distribution_system.py

Large diffs are not rendered by default.

455 changes: 333 additions & 122 deletions hisim/components/more_advanced_heat_pump_hplib.py

Large diffs are not rendered by default.

99 changes: 65 additions & 34 deletions hisim/components/simple_hot_water_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ class HotWaterStorageSizingEnum(Enum):
SIZE_ACCORDING_TO_GENERAL_HEATING_SYSTEM = 2


class PositionWaterStorageInSystemEnum(Enum):

"""Set Simple Hot Water Storage Position options."""

PARALLEL_TO_HEAT_PUMP = 1
SERIE_TO_HEAT_PUMP = 2


@dataclass_json
@dataclass
class SimpleHotWaterStorageConfig(cp.ConfigBase):
Expand All @@ -50,9 +58,9 @@ def get_main_classname(cls):
volume_heating_water_storage_in_liter: float
heat_transfer_coefficient_in_watt_per_m2_per_kelvin: float
heat_exchanger_is_present: bool
position_of_storage_in_system: PositionWaterStorageInSystemEnum
# it should be checked how much energy the storage lost during the simulated period (see guidelines below, p.2, accepted loss in kWh/days)
# https://www.bdh-industrie.de/fileadmin/user_upload/ISH2019/Infoblaetter/Infoblatt_Nr_74_Energetische_Bewertung_Warmwasserspeicher.pdf
water_mass_flow_rate_from_hds_in_kg_per_second: float
#: CO2 footprint of investment in kg
co2_footprint: float
#: cost for investment in Euro
Expand All @@ -64,16 +72,16 @@ def get_main_classname(cls):

@classmethod
def get_default_simplehotwaterstorage_config(
cls, water_mass_flow_rate_from_hds_in_kg_per_second: float
cls,
) -> "SimpleHotWaterStorageConfig":
"""Get a default simplehotwaterstorage config."""
volume_heating_water_storage_in_liter: float = 500
config = SimpleHotWaterStorageConfig(
name="SimpleHotWaterStorage",
volume_heating_water_storage_in_liter=volume_heating_water_storage_in_liter,
water_mass_flow_rate_from_hds_in_kg_per_second=water_mass_flow_rate_from_hds_in_kg_per_second,
heat_transfer_coefficient_in_watt_per_m2_per_kelvin=2.0,
heat_exchanger_is_present=True, # until now stratified mode is causing problems, so heat exchanger mode is recommended
position_of_storage_in_system=PositionWaterStorageInSystemEnum.PARALLEL_TO_HEAT_PUMP,
co2_footprint=100, # Todo: check value
cost=volume_heating_water_storage_in_liter * 14.51, # value from emission_factros_and_costs_devices.csv
lifetime=25, # value from emission_factors_and_costs_devices.csv
Expand All @@ -85,9 +93,8 @@ def get_default_simplehotwaterstorage_config(
def get_scaled_hot_water_storage(
cls,
max_thermal_power_in_watt_of_heating_system: float,
water_mass_flow_rate_from_hds_in_kg_per_second: float,
temperature_difference_between_flow_and_return_in_celsius: float = 7.0,
sizing_option: HotWaterStorageSizingEnum = HotWaterStorageSizingEnum.SIZE_ACCORDING_TO_GENERAL_HEATING_SYSTEM
sizing_option: HotWaterStorageSizingEnum = HotWaterStorageSizingEnum.SIZE_ACCORDING_TO_GENERAL_HEATING_SYSTEM,
) -> "SimpleHotWaterStorageConfig":
"""Gets a default storage with scaling according to heating load of the building.

Expand Down Expand Up @@ -126,10 +133,10 @@ def get_scaled_hot_water_storage(

config = SimpleHotWaterStorageConfig(
name="SimpleHotWaterStorage",
water_mass_flow_rate_from_hds_in_kg_per_second=water_mass_flow_rate_from_hds_in_kg_per_second,
volume_heating_water_storage_in_liter=volume_heating_water_storage_in_liter,
heat_transfer_coefficient_in_watt_per_m2_per_kelvin=2.0,
heat_exchanger_is_present=True, # until now stratified mode is causing problems, so heat exchanger mode is recommended
position_of_storage_in_system=PositionWaterStorageInSystemEnum.PARALLEL_TO_HEAT_PUMP,
co2_footprint=100, # Todo: check value
cost=volume_heating_water_storage_in_liter * 14.51, # value from emission_factros_and_costs_devices.csv
lifetime=100, # value from emission_factros_and_costs_devices.csv
Expand Down Expand Up @@ -163,6 +170,7 @@ class SimpleHotWaterStorage(cp.Component):
WaterTemperatureFromHeatDistribution = "WaterTemperatureFromHeatDistribution"
WaterTemperatureFromHeatGenerator = "WaterTemperaturefromHeatGenerator"
WaterMassFlowRateFromHeatGenerator = "WaterMassFlowRateFromHeatGenerator"
WaterMassFlowRateFromHeatDistributionSystem = "WaterMassFlowRateFromHeatDistributionSystem"
State = "State"

# Output
Expand Down Expand Up @@ -202,17 +210,14 @@ def __init__(

self.mean_water_temperature_in_water_storage_in_celsius: float = 21

self.water_mass_flow_rate_from_heat_distribution_system_in_kg_per_second = (
self.waterstorageconfig.water_mass_flow_rate_from_hds_in_kg_per_second
)

if SingletonSimRepository().exist_entry(key=SingletonDictKeyEnum.WATERMASSFLOWRATEOFHEATGENERATOR):
self.water_mass_flow_rate_from_heat_generator_in_kg_per_second_from_singleton_sim_repo = (
SingletonSimRepository().get_entry(key=SingletonDictKeyEnum.WATERMASSFLOWRATEOFHEATGENERATOR)
)
else:
self.water_mass_flow_rate_from_heat_generator_in_kg_per_second_from_singleton_sim_repo = None

self.position_of_storage_in_system = self.waterstorageconfig.position_of_storage_in_system
self.build(heat_exchanger_is_present=self.waterstorageconfig.heat_exchanger_is_present)

self.state: SimpleHotWaterStorageState = SimpleHotWaterStorageState(
Expand All @@ -231,21 +236,31 @@ def __init__(
lt.Units.CELSIUS,
True,
)
self.water_temperature_heat_generator_input_channel: ComponentInput = self.add_input(
self.component_name,
self.WaterTemperatureFromHeatGenerator,
lt.LoadTypes.TEMPERATURE,
lt.Units.CELSIUS,
True,
)
self.water_mass_flow_rate_heat_generator_input_channel: ComponentInput = self.add_input(
self.water_mass_flow_rate_heat_distribution_system_input_channel: ComponentInput = self.add_input(
self.component_name,
self.WaterMassFlowRateFromHeatGenerator,
self.WaterMassFlowRateFromHeatDistributionSystem,
lt.LoadTypes.WARM_WATER,
lt.Units.KG_PER_SEC,
False,
)

if self.position_of_storage_in_system == PositionWaterStorageInSystemEnum.PARALLEL_TO_HEAT_PUMP:
self.water_temperature_heat_generator_input_channel: ComponentInput = self.add_input(
self.component_name,
self.WaterTemperatureFromHeatGenerator,
lt.LoadTypes.TEMPERATURE,
lt.Units.CELSIUS,
True,
)

self.water_mass_flow_rate_heat_generator_input_channel: ComponentInput = self.add_input(
self.component_name,
self.WaterMassFlowRateFromHeatGenerator,
lt.LoadTypes.WARM_WATER,
lt.Units.KG_PER_SEC,
False,
)

self.state_channel: cp.ComponentInput = self.add_input(
self.component_name, self.State, lt.LoadTypes.ANY, lt.Units.ANY, False
)
Expand Down Expand Up @@ -337,6 +352,13 @@ def get_default_connections_from_heat_distribution_system(
component_class.WaterTemperatureOutput,
)
)
connections.append(
cp.ComponentConnection(
SimpleHotWaterStorage.WaterMassFlowRateFromHeatDistributionSystem,
hds_classname,
component_class.WaterMassFlowHDS,
)
)
return connections

def get_default_connections_from_advanced_heat_pump(
Expand Down Expand Up @@ -421,19 +443,28 @@ def i_simulate(self, timestep: int, stsv: SingleTimeStepValues, force_convergenc
water_temperature_from_heat_distribution_system_in_celsius = stsv.get_input_value(
self.water_temperature_heat_distribution_system_input_channel
)
water_temperature_from_heat_generator_in_celsius = stsv.get_input_value(
self.water_temperature_heat_generator_input_channel

water_mass_flow_rate_from_hds_in_kg_per_second = stsv.get_input_value(
self.water_mass_flow_rate_heat_distribution_system_input_channel
)

# get water mass flow rate of heat generator either from singleton sim repo or from input value
if self.water_mass_flow_rate_from_heat_generator_in_kg_per_second_from_singleton_sim_repo is not None:
water_mass_flow_rate_from_heat_generator_in_kg_per_second = (
self.water_mass_flow_rate_from_heat_generator_in_kg_per_second_from_singleton_sim_repo
if self.position_of_storage_in_system == PositionWaterStorageInSystemEnum.PARALLEL_TO_HEAT_PUMP:
water_temperature_from_heat_generator_in_celsius = stsv.get_input_value(
self.water_temperature_heat_generator_input_channel
)

# get water mass flow rate of heat generator either from singleton sim repo or from input value
if self.water_mass_flow_rate_from_heat_generator_in_kg_per_second_from_singleton_sim_repo is not None:
water_mass_flow_rate_from_heat_generator_in_kg_per_second = (
self.water_mass_flow_rate_from_heat_generator_in_kg_per_second_from_singleton_sim_repo
)
else:
water_mass_flow_rate_from_heat_generator_in_kg_per_second = stsv.get_input_value(
self.water_mass_flow_rate_heat_generator_input_channel
)
else:
water_mass_flow_rate_from_heat_generator_in_kg_per_second = stsv.get_input_value(
self.water_mass_flow_rate_heat_generator_input_channel
)
water_temperature_from_heat_generator_in_celsius = 0
water_mass_flow_rate_from_heat_generator_in_kg_per_second = 0

# Water Temperature Limit Check --------------------------------------------------------------------------------------------------------

Expand All @@ -454,7 +485,7 @@ def i_simulate(self, timestep: int, stsv: SingleTimeStepValues, force_convergenc
water_mass_from_heat_distribution_system_in_kg,
) = self.calculate_masses_of_water_flows(
water_mass_flow_rate_from_heat_generator_in_kg_per_second=water_mass_flow_rate_from_heat_generator_in_kg_per_second,
water_mass_flow_rate_from_heat_distribution_system_in_kg_per_second=self.water_mass_flow_rate_from_heat_distribution_system_in_kg_per_second,
water_mass_flow_rate_from_heat_distribution_system_in_kg_per_second=water_mass_flow_rate_from_hds_in_kg_per_second,
seconds_per_timestep=self.seconds_per_timestep,
)

Expand Down Expand Up @@ -537,11 +568,11 @@ def i_simulate(self, timestep: int, stsv: SingleTimeStepValues, force_convergenc
raise ValueError("unknown storage controller state.")

# Set outputs -------------------------------------------------------------------------------------------------------

stsv.set_output_value(
self.water_temperature_heat_distribution_system_output_channel,
water_temperature_to_heat_distribution_system_in_celsius,
)
if self.position_of_storage_in_system == PositionWaterStorageInSystemEnum.PARALLEL_TO_HEAT_PUMP:
stsv.set_output_value(
self.water_temperature_heat_distribution_system_output_channel,
water_temperature_to_heat_distribution_system_in_celsius,
)

stsv.set_output_value(
self.water_temperature_heat_generator_output_channel,
Expand Down
6 changes: 3 additions & 3 deletions hisim/postprocessing/compute_kpis.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from hisim.components.building import Building
from hisim.components.loadprofilegenerator_utsp_connector import UtspLpgConnector
from hisim.components.more_advanced_heat_pump_hplib import HeatPumpHplibWithTwoOutputs
from hisim.components.simple_hot_water_storage import SimpleHotWaterStorage
# from hisim.components.simple_hot_water_storage import SimpleHotWaterStorage
from hisim.components.electricity_meter import ElectricityMeter
from hisim.components.generic_heat_pump_modular import ModularHeatPump
from hisim.components.controller_l2_energy_management_system import L2GenericEnergyManagementSystem
Expand Down Expand Up @@ -1288,7 +1288,7 @@ def get_heat_distribution_system_kpis(self, building_conditioned_floor_area_in_m
min_temperature_difference_between_flow_and_return_in_celsius,
) = self.get_flow_and_return_temperatures(
results=self.results,
output_name_flow_temperature=SimpleHotWaterStorage.WaterTemperatureToHeatDistribution,
output_name_flow_temperature=HeatDistribution.WaterTemperatureInlet,
output_name_return_temperature=HeatDistribution.WaterTemperatureOutput,
)

Expand Down Expand Up @@ -1628,7 +1628,7 @@ def get_space_heating_heat_pump_kpis(
) = self.get_flow_and_return_temperatures(
results=self.results,
output_name_flow_temperature=HeatPumpHplibWithTwoOutputs.TemperatureOutputSH,
output_name_return_temperature=SimpleHotWaterStorage.WaterTemperatureToHeatGenerator
output_name_return_temperature=HeatPumpHplibWithTwoOutputs.TemperatureInputSH
)

break
Expand Down
3 changes: 1 addition & 2 deletions system_setups/automatic_default_connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def setup_function(my_sim: Any, my_simulation_parameters: Optional[SimulationPar
# 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,
temperature_difference_between_flow_and_return_in_celsius=my_hds_controller_information.temperature_difference_between_flow_and_return_in_celsius,
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,
Expand All @@ -143,7 +143,6 @@ def setup_function(my_sim: Any, my_simulation_parameters: Optional[SimulationPar
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=simple_hot_water_storage.HotWaterStorageSizingEnum.SIZE_ACCORDING_TO_HEAT_PUMP,
water_mass_flow_rate_from_hds_in_kg_per_second=my_hds_controller_information.water_mass_flow_rate_in_kp_per_second,
)
my_simple_hot_water_storage = simple_hot_water_storage.SimpleHotWaterStorage(
config=my_simple_heat_water_storage_config,
Expand Down
3 changes: 1 addition & 2 deletions system_setups/household_1_advanced_hp_diesel_car.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ def get_scaled_default(
hds_controller_config=hds_controller_config,
hds_config=(
heat_distribution_system.HeatDistributionConfig.get_default_heatdistributionsystem_config(
temperature_difference_between_flow_and_return_in_celsius=my_hds_controller_information.temperature_difference_between_flow_and_return_in_celsius,
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
)
),
hp_controller_config=advanced_heat_pump_hplib.HeatPumpHplibControllerL1Config.get_default_generic_heat_pump_controller_config(
Expand All @@ -151,7 +151,6 @@ def get_scaled_default(
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=simple_hot_water_storage.HotWaterStorageSizingEnum.SIZE_ACCORDING_TO_HEAT_PUMP,
water_mass_flow_rate_from_hds_in_kg_per_second=my_hds_controller_information.water_mass_flow_rate_in_kp_per_second,
),
dhw_heatpump_config=generic_heat_pump_modular.HeatPumpConfig.get_scaled_waterheating_to_number_of_apartments(
number_of_apartments=int(my_building_information.number_of_apartments)
Expand Down
5 changes: 2 additions & 3 deletions system_setups/household_1b_more_advanced_hp_diesel_car.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ def get_scaled_default(
hds_controller_config=hds_controller_config,
hds_config=(
heat_distribution_system.HeatDistributionConfig.get_default_heatdistributionsystem_config(
temperature_difference_between_flow_and_return_in_celsius=my_hds_controller_information.temperature_difference_between_flow_and_return_in_celsius,
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
)
),
sh_controller_config=more_advanced_heat_pump_hplib.HeatPumpHplibControllerSpaceHeatingConfig.get_default_space_heating_controller_config(
Expand All @@ -151,7 +151,6 @@ def get_scaled_default(
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=simple_hot_water_storage.HotWaterStorageSizingEnum.SIZE_ACCORDING_TO_HEAT_PUMP,
water_mass_flow_rate_from_hds_in_kg_per_second=my_hds_controller_information.water_mass_flow_rate_in_kp_per_second,
),
dhw_heatpump_controller_config=more_advanced_heat_pump_hplib.HeatPumpHplibControllerDHWConfig.get_default_dhw_controller_config(),
dhw_storage_config=generic_hot_water_storage_modular.StorageConfig.get_scaled_config_for_boiler_to_number_of_apartments(
Expand Down Expand Up @@ -357,7 +356,7 @@ def setup_function(

#################################
my_heat_distribution_controller.connect_only_predefined_connections(
my_weather, my_building, my_hot_water_storage
my_weather, my_building
)

my_heat_distribution.connect_only_predefined_connections(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

from system_setups.modular_example import cleanup_old_lpg_requests


__authors__ = ["Markus Blasberg", "Kevin Knosala"]
__copyright__ = "Copyright 2023, FZJ-IEK-3"
__credits__ = ["Noah Pflugradt"]
Expand Down Expand Up @@ -138,8 +139,8 @@ def get_scaled_default(
hds_controller_config=hds_controller_config,
hds_config=(
heat_distribution_system.HeatDistributionConfig.get_default_heatdistributionsystem_config(
temperature_difference_between_flow_and_return_in_celsius=my_hds_controller_information.temperature_difference_between_flow_and_return_in_celsius,
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
)
),
hp_controller_config=more_advanced_heat_pump_hplib.HeatPumpHplibControllerSpaceHeatingConfig.get_default_space_heating_controller_config(
Expand All @@ -157,7 +158,6 @@ def get_scaled_default(
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=simple_hot_water_storage.HotWaterStorageSizingEnum.SIZE_ACCORDING_TO_HEAT_PUMP,
water_mass_flow_rate_from_hds_in_kg_per_second=my_hds_controller_information.water_mass_flow_rate_in_kp_per_second,
),
dhw_heatpump_config=generic_heat_pump_modular.HeatPumpConfig.get_scaled_waterheating_to_number_of_apartments(
number_of_apartments=int(my_building_information.number_of_apartments)
Expand Down