Skip to content

Commit 1d1d3b7

Browse files
authored
Merge pull request #841 from RWTH-EBC/839-fix-besmod-export [PYPI-RELEASE]
839 fix besmod export
2 parents 8e98d6a + 9248c7e commit 1d1d3b7

File tree

10 files changed

+118
-55
lines changed

10 files changed

+118
-55
lines changed

docs/jupyter_notebooks/e11_export_besmod_models.ipynb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,14 @@
9292
{
9393
"cell_type": "markdown",
9494
"metadata": {},
95-
"source": "In the examples, the parameters for BESMod.Systems.UserProfiles.TEASERProfiles are configured,\nincluding internal gains and heating profiles for each zone.\nBESMod requires 24-hour heating profiles, which are used\nto define the parameters of the `setBakTSetZone` Pulse block.\nBy default, the TEASER profiles are applied, but these can be customized if needed.\n"
95+
"source": "In the examples, the parameters for BESMod.Systems.UserProfiles.TEASERProfiles are configured,\nincluding internal gains and heating profiles for each zone.\nBESMod requires 24-hour heating profiles in the export here, which are used\nto define the set-back parameters. Setting these parameters directly or the use of TSet file\nis not supported in the export here. Either override them later or use the custom export option shown below.\nBy default, the TEASER profiles are applied, but these can be customized if needed.\nFor example, we modify the heating profile of the first thermal zone of the first building here:\n"
96+
},
97+
{
98+
"cell_type": "code",
99+
"execution_count": null,
100+
"metadata": {},
101+
"outputs": [],
102+
"source": "prj.buildings[0].thermal_zones[0].use_conditions.heating_profile = [\n 290.15, #0-1\n 290.15, #1-2\n 290.15, #2-3\n 290.15, #3-4\n 290.15, #4-5\n 293.15, #5-6\n 293.15, #6-7\n 293.15, #7-8\n 293.15, #8-9\n 293.15, #9-10\n 293.15, #10-11\n 293.15, #11-12\n 293.15, #12-13\n 293.15, #13-14\n 293.15, #14-15\n 293.15, #15-16\n 293.15, #16-17\n 293.15, #17-18\n 293.15, #18-19\n 293.15, #19-20\n 293.15, #20-21\n 293.15, #21-22\n 290.15, #22-23\n 290.15 #23-24\n ]\n"
96103
},
97104
{
98105
"cell_type": "markdown",
@@ -167,7 +174,7 @@
167174
{
168175
"cell_type": "markdown",
169176
"metadata": {},
170-
"source": "Custom template\n```\n< %namespace file = \"/modelica_language/\" import=\"get_list\" / >\nwithin ${bldg.parent.name}.${bldg.name};\nmodel ModelicaConferencePaper${bldg.name}\n extends BESMod.Examples.ModelicaConferencePaper.PartialModelicaConferenceUseCase(\n redeclare ${bldg.name} building,\n redeclare BESMod.Systems.UserProfiles.TEASERProfiles\n userProfiles(fileNameIntGains=Modelica.Utilities.Files.loadResource(\n \"modelica://${bldg.parent.name}/${bldg.name}/InternalGains_${bldg.name}.txt\"),\n setBakTSetZone(amplitude=${get_list(setBakTSetZone_amplitude)},\n width =${get_list(setBakTSetZone_width)},\n startTime =${get_list(setBakTSetZone_startTime)})),\n systemParameters(nZones=${len(bldg.thermal_zones)},\n QBui_flow_nominal = building.QRec_flow_nominal,\n TOda_nominal =${TOda_nominal},\n TSetZone_nominal =${get_list(TSetZone_nominal)},\n THydSup_nominal =${THydSup_nominal},\n QBuiOld_flow_design =${QBuiOld_flow_design},\n THydSupOld_design =${THydSupOld_design},\n filNamWea = Modelica.Utilities.Files.loadResource(\n \"modelica://${bldg.parent.name}/Resources/${bldg.parent.weather_file_name}\")));\n\n extends Modelica.Icons.Example;\n\n annotation(experiment(StopTime=172800,\n Interval=600,\n Tolerance=1e-06),\n __Dymola_Commands(file=\n \"Resources/Scripts/Dymola/${bldg.name}/ModelicaConferencePaper${bldg.name}.mos\"\n \"Simulate and plot\"));\nend\nModelicaConferencePaper${bldg.name};\n```\n"
177+
"source": "Custom template\n```\n< %namespace file = \"/modelica_language/\" import=\"get_list\" / >\nwithin ${bldg.parent.name}.${bldg.name};\nmodel ModelicaConferencePaper${bldg.name}\n extends BESMod.Examples.ModelicaConferencePaper.PartialModelicaConferenceUseCase(\n redeclare ${bldg.name} building,\n redeclare BESMod.Systems.UserProfiles.TEASERProfiles\n userProfiles(fileNameIntGains=Modelica.Utilities.Files.loadResource(\n \"modelica://${bldg.parent.name}/${bldg.name}/InternalGains_${bldg.name}.txt\"),\n dTSetBack=${get_list(dTSetBack)},\n hoursSetBack=${get_list(hoursSetBack)},\n startTimeSetBack=${get_list(startTimeSetBack)})),\n systemParameters(nZones=${len(bldg.thermal_zones)},\n QBui_flow_nominal = building.QRec_flow_nominal,\n TOda_nominal =${TOda_nominal},\n TSetZone_nominal =${get_list(TSetZone_nominal)},\n THydSup_nominal =${THydSup_nominal},\n QBuiOld_flow_design =${QBuiOld_flow_design},\n THydSupOld_design =${THydSupOld_design},\n filNamWea = Modelica.Utilities.Files.loadResource(\n \"modelica://${bldg.parent.name}/Resources/${bldg.parent.weather_file_name}\")));\n\n extends Modelica.Icons.Example;\n\n annotation(experiment(StopTime=172800,\n Interval=600,\n Tolerance=1e-06),\n __Dymola_Commands(file=\n \"Resources/Scripts/Dymola/${bldg.name}/ModelicaConferencePaper${bldg.name}.mos\"\n \"Simulate and plot\"));\nend\nModelicaConferencePaper${bldg.name};\n```\n"
171178
},
172179
{
173180
"cell_type": "code",

docs/source/examples/e11_export_besmod_models.md

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,40 @@ THydSup_nominal = {
8989

9090
In the examples, the parameters for BESMod.Systems.UserProfiles.TEASERProfiles are configured,
9191
including internal gains and heating profiles for each zone.
92-
BESMod requires 24-hour heating profiles, which are used
93-
to define the parameters of the `setBakTSetZone` Pulse block.
92+
BESMod requires 24-hour heating profiles in the export here, which are used
93+
to define the set-back parameters. Setting these parameters directly or the use of TSet file
94+
is not supported in the export here. Either override them later or use the custom export option shown below.
9495
By default, the TEASER profiles are applied, but these can be customized if needed.
96+
For example, we modify the heating profile of the first thermal zone of the first building here:
97+
98+
```python
99+
prj.buildings[0].thermal_zones[0].use_conditions.heating_profile = [
100+
290.15, #0-1
101+
290.15, #1-2
102+
290.15, #2-3
103+
290.15, #3-4
104+
290.15, #4-5
105+
293.15, #5-6
106+
293.15, #6-7
107+
293.15, #7-8
108+
293.15, #8-9
109+
293.15, #9-10
110+
293.15, #10-11
111+
293.15, #11-12
112+
293.15, #12-13
113+
293.15, #13-14
114+
293.15, #14-15
115+
293.15, #15-16
116+
293.15, #16-17
117+
293.15, #17-18
118+
293.15, #18-19
119+
293.15, #19-20
120+
293.15, #20-21
121+
293.15, #21-22
122+
290.15, #22-23
123+
290.15 #23-24
124+
]
125+
```
95126

96127
Additionally, location-specific parameters must be set, which can be achieved using the following function.
97128
The default values provided here correspond to Mannheim.
@@ -180,9 +211,9 @@ model ModelicaConferencePaper${bldg.name}
180211
redeclare BESMod.Systems.UserProfiles.TEASERProfiles
181212
userProfiles(fileNameIntGains=Modelica.Utilities.Files.loadResource(
182213
"modelica://${bldg.parent.name}/${bldg.name}/InternalGains_${bldg.name}.txt"),
183-
setBakTSetZone(amplitude=${get_list(setBakTSetZone_amplitude)},
184-
width =${get_list(setBakTSetZone_width)},
185-
startTime =${get_list(setBakTSetZone_startTime)})),
214+
dTSetBack=${get_list(dTSetBack)},
215+
hoursSetBack=${get_list(hoursSetBack)},
216+
startTimeSetBack=${get_list(startTimeSetBack)})),
186217
systemParameters(nZones=${len(bldg.thermal_zones)},
187218
QBui_flow_nominal = building.QRec_flow_nominal,
188219
TOda_nominal =${TOda_nominal},

teaser/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import sys
88
import os
99

10-
__version__ = "1.3.0"
10+
__version__ = "1.3.1"
1111

1212

1313
new_path = os.path.join(os.path.expanduser('~'), ("TEASEROutput"))

teaser/data/output/besmod_output.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -163,16 +163,16 @@ def export_besmod(
163163
for i, bldg in enumerate(buildings):
164164
bldg.bldg_height = bldg.number_of_floors * bldg.height_of_floors
165165
start_time_zones = []
166-
width_zones = []
167-
amplitude_zones = []
166+
hours_set_back_zones = []
167+
d_temp_set_back_zones = []
168168
t_set_zone_nominal = []
169169
for tz in bldg.thermal_zones:
170170
heating_profile = tz.use_conditions.heating_profile
171-
t_set_nominal, start_time, width, amplitude = _convert_heating_profile(heating_profile)
171+
t_set_nominal, start_time, hours_set_back, d_temp_set_back = _convert_heating_profile(heating_profile)
172172
t_set_zone_nominal.append(t_set_nominal)
173-
amplitude_zones.append(amplitude)
173+
d_temp_set_back_zones.append(d_temp_set_back)
174174
start_time_zones.append(start_time)
175-
width_zones.append(width)
175+
hours_set_back_zones.append(hours_set_back)
176176

177177
bldg_path = os.path.join(path, bldg.name)
178178
utilities.create_path(bldg_path)
@@ -195,9 +195,9 @@ def write_example_mo(example_template, example):
195195
TSetZone_nominal=t_set_zone_nominal,
196196
QBuiOld_flow_design=QBuiOld_flow_design[bldg.name],
197197
THydSupOld_design=t_hyd_sup_old_design_bldg[bldg.name],
198-
setBakTSetZone_amplitude=amplitude_zones,
199-
setBakTSetZone_startTime=start_time_zones,
200-
setBakTSetZone_width=width_zones))
198+
dTSetBack=d_temp_set_back_zones,
199+
startTimeSetBack=start_time_zones,
200+
hoursSetBack=hours_set_back_zones))
201201
model_file.close()
202202

203203
for exp in examples:
@@ -370,8 +370,8 @@ def _convert_heating_profile(heating_profile):
370370
This function analyzes a 24-hour heating profile to extract:
371371
- The nominal temperature.
372372
- Start time of setbacks (if any).
373-
- Width of setback intervals.
374-
- Amplitude of the heating variation.
373+
- hours_set_back of setback intervals.
374+
- d_temp_set_back of the heating variation.
375375
376376
Parameters
377377
----------
@@ -384,10 +384,10 @@ def _convert_heating_profile(heating_profile):
384384
Maximum temperature in the profile, used as the nominal set point.
385385
start_time : int
386386
Start time of the setback interval in seconds.
387-
width : float
388-
Width of the setback interval as a percentage of the day.
389-
amplitude : float
390-
Difference between the minimum and nominal temperatures.
387+
hours_set_back : float
388+
hours of the setback interval in h.
389+
d_temp_set_back : float
390+
Absolute difference between the minimum and nominal temperatures.
391391
392392
Raises
393393
------
@@ -404,25 +404,25 @@ def _convert_heating_profile(heating_profile):
404404
change_count += 1
405405
change_indexes.append(i)
406406
t_set_zone_nominal = max(heating_profile)
407-
amplitude = min(heating_profile) - t_set_zone_nominal
407+
d_temp_set_back = abs(min(heating_profile) - t_set_zone_nominal)
408408
if change_count == 0:
409-
amplitude = 0
409+
d_temp_set_back = 0
410410
start_time = 0
411-
width = 1e-50
411+
hours_set_back = 0
412412
elif change_count == 1:
413413
if heating_profile[0] < heating_profile[-1]:
414414
start_time = 0
415-
width = 100 * change_indexes[0] / 24
415+
hours_set_back = change_indexes[0]
416416
else:
417417
start_time = change_indexes[0] * 3600
418-
width = 100 * (24 - change_indexes[0]) / 24
418+
hours_set_back = (24 - change_indexes[0])
419419
elif change_count == 2:
420420
start_time = change_indexes[1] * 3600
421-
width = 100 * (24 - change_indexes[1] + change_indexes[0]) / 24
421+
hours_set_back = (24 - change_indexes[1] + change_indexes[0])
422422
else:
423423
raise ValueError("You have more than two temperature intervals in the heating profile."
424424
"BESMod can only handel one heating set back.")
425-
return t_set_zone_nominal, start_time, width, amplitude
425+
return t_set_zone_nominal, start_time, hours_set_back, d_temp_set_back
426426

427427

428428
def _get_next_higher_year_value(years_dict, given_year):

teaser/data/output/modelicatemplate/BESMod/Example_GasBoilerBuildingOnly

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@ model GasBoilerBuildingOnly${bldg.name}
55
redeclare ${bldg.name} building,
66
userProfiles(fileNameIntGains=Modelica.Utilities.Files.loadResource(
77
"modelica://${bldg.parent.name}/${bldg.name}/InternalGains_${bldg.name}.txt"),
8-
setBakTSetZone(
9-
amplitude=${get_list(setBakTSetZone_amplitude)},
10-
width=${get_list(setBakTSetZone_width)},
11-
startTime=${get_list(setBakTSetZone_startTime)})),
8+
dTSetBack=${get_list(dTSetBack)},
9+
hoursSetBack=${get_list(hoursSetBack)},
10+
startTimeSetBack=${get_list(startTimeSetBack)}),
1211
systemParameters(nZones=${len(bldg.thermal_zones)},
1312
TSetZone_nominal=${get_list(TSetZone_nominal)},
1413
TOda_nominal=${TOda_nominal},

teaser/data/output/modelicatemplate/BESMod/Example_HeatPumpMonoenergetic

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ model HeatPumpMonoenergetic${bldg.name}
77
energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial),
88
userProfiles(fileNameIntGains=Modelica.Utilities.Files.loadResource(
99
"modelica://${bldg.parent.name}/${bldg.name}/InternalGains_${bldg.name}.txt"),
10-
setBakTSetZone(
11-
amplitude=${get_list(setBakTSetZone_amplitude)},
12-
width=${get_list(setBakTSetZone_width)},
13-
startTime=${get_list(setBakTSetZone_startTime)})),
10+
dTSetBack=${get_list(dTSetBack)},
11+
hoursSetBack=${get_list(hoursSetBack)},
12+
startTimeSetBack=${get_list(startTimeSetBack)}),
1413
systemParameters(
1514
nZones=${len(bldg.thermal_zones)},
1615
TSetZone_nominal=${get_list(TSetZone_nominal)},

teaser/data/output/modelicatemplate/BESMod/Example_TEASERHeatLoadCalculation

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ model TEASERHeatLoadCalculation${bldg.name}
66
userProfiles(
77
fileNameIntGains=Modelica.Utilities.Files.loadResource(
88
"modelica://${bldg.parent.name}/${bldg.name}/InternalGains_${bldg.name}.txt"),
9-
setBakTSetZone(
10-
amplitude=${get_list(setBakTSetZone_amplitude)},
11-
width=${get_list(setBakTSetZone_width)},
12-
startTime=${get_list(setBakTSetZone_startTime)})),
9+
dTSetBack=${get_list(dTSetBack)},
10+
hoursSetBack=${get_list(hoursSetBack)},
11+
startTimeSetBack=${get_list(startTimeSetBack)}),
1312
systemParameters(nZones=${len(bldg.thermal_zones)},
1413
TSetZone_nominal=${get_list(TSetZone_nominal)},
1514
TOda_nominal=${TOda_nominal},

teaser/examples/e11_export_besmod_models.py

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,37 @@ def example_export_besmod():
7474

7575
# In the examples, the parameters for BESMod.Systems.UserProfiles.TEASERProfiles are configured,
7676
# including internal gains and heating profiles for each zone.
77-
# BESMod requires 24-hour heating profiles, which are used
78-
# to define the parameters of the `setBakTSetZone` Pulse block.
77+
# BESMod requires 24-hour heating profiles in the export here, which are used
78+
# to define the set-back parameters. Setting these parameters directly or the use of TSet file
79+
# is not supported in the export here. Either override them later or use the custom export option shown below.
7980
# By default, the TEASER profiles are applied, but these can be customized if needed.
81+
# For example, we modify the heating profile of the first thermal zone of the first building here:
82+
prj.buildings[0].thermal_zones[0].use_conditions.heating_profile = [
83+
290.15, #0-1
84+
290.15, #1-2
85+
290.15, #2-3
86+
290.15, #3-4
87+
290.15, #4-5
88+
293.15, #5-6
89+
293.15, #6-7
90+
293.15, #7-8
91+
293.15, #8-9
92+
293.15, #9-10
93+
293.15, #10-11
94+
293.15, #11-12
95+
293.15, #12-13
96+
293.15, #13-14
97+
293.15, #14-15
98+
293.15, #15-16
99+
293.15, #16-17
100+
293.15, #17-18
101+
293.15, #18-19
102+
293.15, #19-20
103+
293.15, #20-21
104+
293.15, #21-22
105+
290.15, #22-23
106+
290.15 #23-24
107+
]
80108

81109
# Additionally, location-specific parameters must be set, which can be achieved using the following function.
82110
# The default values provided here correspond to Mannheim.
@@ -151,9 +179,9 @@ def example_export_besmod():
151179
# redeclare BESMod.Systems.UserProfiles.TEASERProfiles
152180
# userProfiles(fileNameIntGains=Modelica.Utilities.Files.loadResource(
153181
# "modelica://${bldg.parent.name}/${bldg.name}/InternalGains_${bldg.name}.txt"),
154-
# setBakTSetZone(amplitude=${get_list(setBakTSetZone_amplitude)},
155-
# width =${get_list(setBakTSetZone_width)},
156-
# startTime =${get_list(setBakTSetZone_startTime)})),
182+
# dTSetBack=${get_list(dTSetBack)},
183+
# hoursSetBack=${get_list(hoursSetBack)},
184+
# startTimeSetBack=${get_list(startTimeSetBack)})),
157185
# systemParameters(nZones=${len(bldg.thermal_zones)},
158186
# QBui_flow_nominal = building.QRec_flow_nominal,
159187
# TOda_nominal =${TOda_nominal},

teaser/logic/buildingobjects/calculation/aixlib.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ def __init__(self, parent):
6464
self.file_set_t_cool = "TsetCool_" + self.parent.name + ".txt"
6565
self.file_ahu = "AHU_" + self.parent.name + ".txt"
6666
self.file_internal_gains = "InternalGains_" + self.parent.name + ".txt"
67-
self.version = "2.1.1"
68-
self.besmod_version = "0.6.0"
67+
self.version = "3.0.0"
68+
self.besmod_version = "0.7.0"
6969
self.total_surface_area = None
7070
self.consider_heat_capacity = True
7171
self.use_set_back = True

tests/test_besmod_output.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def test_convert_heating_profile(self):
171171
t_set_zone_nominal, start_time, width, amplitude = _convert_heating_profile(heating_profile)
172172
self.assertEqual(t_set_zone_nominal, 293.15)
173173
self.assertAlmostEqual(start_time, 0)
174-
self.assertAlmostEqual(width, 1e-50)
174+
self.assertAlmostEqual(width, 0)
175175
self.assertEqual(amplitude, 0)
176176
heating_profile = [290.15,
177177
290.15,
@@ -200,8 +200,8 @@ def test_convert_heating_profile(self):
200200
t_set_zone_nominal, start_time, width, amplitude = _convert_heating_profile(heating_profile)
201201
self.assertEqual(t_set_zone_nominal, 293.15)
202202
self.assertAlmostEqual(start_time, 0)
203-
self.assertAlmostEqual(width, 6 / 24 * 100)
204-
self.assertEqual(amplitude, -3)
203+
self.assertAlmostEqual(width, 6)
204+
self.assertEqual(amplitude, 3)
205205
heating_profile = [293.15,
206206
293.15,
207207
293.15,
@@ -229,8 +229,8 @@ def test_convert_heating_profile(self):
229229
t_set_zone_nominal, start_time, width, amplitude = _convert_heating_profile(heating_profile)
230230
self.assertEqual(t_set_zone_nominal, 293.15)
231231
self.assertAlmostEqual(start_time, 20 * 3600)
232-
self.assertAlmostEqual(width, 4 / 24 * 100)
233-
self.assertEqual(amplitude, -3)
232+
self.assertAlmostEqual(width, 4)
233+
self.assertEqual(amplitude, 3)
234234
heating_profile = [290.15,
235235
293.15,
236236
293.15,
@@ -258,5 +258,5 @@ def test_convert_heating_profile(self):
258258
t_set_zone_nominal, start_time, width, amplitude = _convert_heating_profile(heating_profile)
259259
self.assertEqual(t_set_zone_nominal, 293.15)
260260
self.assertAlmostEqual(start_time, 23 * 3600)
261-
self.assertAlmostEqual(width, 2 / 24 * 100)
262-
self.assertEqual(amplitude, -3)
261+
self.assertAlmostEqual(width, 2)
262+
self.assertEqual(amplitude, 3)

0 commit comments

Comments
 (0)