-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathbasic_household.py
177 lines (145 loc) · 6.79 KB
/
basic_household.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
""" Basic household system setup. Shows how to set up a standard system. """
# clean
from typing import Optional, Any
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 generic_heat_pump
from hisim.components import electricity_meter
from hisim import loadtypes
__authors__ = "Vitor Hugo Bellotto Zago, Noah Pflugradt"
__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
"""Basic household system setup.
This setup function emulates an household including the basic components. Here the residents have their
electricity and heating needs covered by the photovoltaic system and the heat pump.
- Simulation Parameters
- Components
- Occupancy (Residents' Demands)
- Weather
- Photovoltaic System
- Building
- Heat Pump
"""
# =================================================================================================================================
# Set System Parameters
# Set Simulation Parameters
year = 2021
seconds_per_timestep = 60
# Set Heat Pump Controller
temperature_air_heating_in_celsius = 19.0
temperature_air_cooling_in_celsius = 24.0
offset = 0.5
hp_mode = 2
# =================================================================================================================================
# Build Components
# Build Simulation Parameters
if my_simulation_parameters is None:
my_simulation_parameters = SimulationParameters.full_year_with_only_plots(
year=year, seconds_per_timestep=seconds_per_timestep
)
my_sim.set_simulation_parameters(my_simulation_parameters)
# Build Building
my_building_config = building.BuildingConfig.get_default_german_single_family_home()
my_building = building.Building(config=my_building_config, my_simulation_parameters=my_simulation_parameters)
# Build Occupancy
my_occupancy_config = loadprofilegenerator_utsp_connector.UtspLpgConnectorConfig.get_default_utsp_connector_config()
my_occupancy = loadprofilegenerator_utsp_connector.UtspLpgConnector(
config=my_occupancy_config, my_simulation_parameters=my_simulation_parameters
)
# Build Weather
my_weather_config = weather.WeatherConfig.get_default(location_entry=weather.LocationEnum.AACHEN)
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 = generic_pv_system.PVSystem(
config=my_photovoltaic_system_config,
my_simulation_parameters=my_simulation_parameters,
)
# 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 Heat Pump Controller
my_heat_pump_controller = generic_heat_pump.GenericHeatPumpController(
config=generic_heat_pump.GenericHeatPumpControllerConfig(
name="GenericHeatPumpController",
temperature_air_heating_in_celsius=temperature_air_heating_in_celsius,
temperature_air_cooling_in_celsius=temperature_air_cooling_in_celsius,
offset=offset,
mode=hp_mode,
),
my_simulation_parameters=my_simulation_parameters,
)
# Build Heat Pump
my_heat_pump = generic_heat_pump.GenericHeatPump(
config=generic_heat_pump.GenericHeatPumpConfig.get_default_generic_heat_pump_config(),
my_simulation_parameters=my_simulation_parameters,
)
# =================================================================================================================================
# Connect Component Inputs with Outputs
my_photovoltaic_system.connect_only_predefined_connections(my_weather)
# Electricity Grid
my_electricity_meter.add_component_input_and_connect(
source_object_name=my_photovoltaic_system.component_name,
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_weight=999,
)
my_electricity_meter.add_component_input_and_connect(
source_object_name=my_occupancy.component_name,
source_component_output=my_occupancy.ElectricityOutput,
source_load_type=loadtypes.LoadTypes.ELECTRICITY,
source_unit=loadtypes.Units.WATT,
source_tags=[loadtypes.InandOutputType.ELECTRICITY_CONSUMPTION_UNCONTROLLED],
source_weight=999,
)
my_electricity_meter.add_component_input_and_connect(
source_object_name=my_heat_pump.component_name,
source_component_output=my_heat_pump.ElectricityOutput,
source_load_type=loadtypes.LoadTypes.ELECTRICITY,
source_unit=loadtypes.Units.WATT,
source_tags=[
loadtypes.ComponentType.HEAT_PUMP,
loadtypes.InandOutputType.ELECTRICITY_CONSUMPTION_UNCONTROLLED,
],
source_weight=999,
)
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_heat_pump_controller.connect_only_predefined_connections(my_building)
my_heat_pump_controller.connect_input(
my_heat_pump_controller.ElectricityInput,
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.get_default_connections_heatpump_controller()
# =================================================================================================================================
# Add Components to Simulation Parameters
my_sim.add_component(my_occupancy)
my_sim.add_component(my_weather)
my_sim.add_component(my_photovoltaic_system)
my_sim.add_component(my_electricity_meter)
my_sim.add_component(my_building)
my_sim.add_component(my_heat_pump_controller)
my_sim.add_component(my_heat_pump)