Coverage for teaser/data/input/teaserjson_input.py: 100%
232 statements
« prev ^ index » next coverage.py v7.4.4, created at 2025-04-29 16:01 +0000
« prev ^ index » next coverage.py v7.4.4, created at 2025-04-29 16:01 +0000
1"""Load Projects in the proprietary TEASER file format .json."""
3from teaser.logic.buildingobjects.building import Building
4from teaser.logic.archetypebuildings.tabula.de.apartmentblock import ApartmentBlock
5from teaser.logic.archetypebuildings.tabula.de.multifamilyhouse import MultiFamilyHouse
6from teaser.logic.archetypebuildings.tabula.de.singlefamilyhouse import (
7 SingleFamilyHouse,
8)
9from teaser.logic.archetypebuildings.tabula.de.terracedhouse import TerracedHouse
10from teaser.logic.archetypebuildings.bmvbs.office import Office
11from teaser.logic.archetypebuildings.bmvbs.singlefamilydwelling import (
12 SingleFamilyDwelling,
13)
14from teaser.logic.archetypebuildings.bmvbs.custom.institute import Institute
15from teaser.logic.archetypebuildings.bmvbs.custom.institute4 import Institute4
16from teaser.logic.archetypebuildings.bmvbs.custom.institute8 import Institute8
17from teaser.logic.buildingobjects.thermalzone import ThermalZone
18from teaser.logic.buildingobjects.buildingsystems.buildingahu import BuildingAHU
19from teaser.logic.buildingobjects.useconditions import UseConditions
20from teaser.logic.buildingobjects.buildingphysics.outerwall import OuterWall
21from teaser.logic.buildingobjects.buildingphysics.layer import Layer
22from teaser.logic.buildingobjects.buildingphysics.material import Material
23from teaser.logic.buildingobjects.buildingphysics.rooftop import Rooftop
24from teaser.logic.buildingobjects.buildingphysics.groundfloor import GroundFloor
25from teaser.logic.buildingobjects.buildingphysics.innerwall import InnerWall
26from teaser.logic.buildingobjects.buildingphysics.ceiling import Ceiling
27from teaser.logic.buildingobjects.buildingphysics.floor import Floor
28from teaser.logic.buildingobjects.buildingphysics.interzonalwall import (
29 InterzonalWall
30)
31from teaser.logic.buildingobjects.buildingphysics.interzonalceiling import (
32 InterzonalCeiling
33)
34from teaser.logic.buildingobjects.buildingphysics.interzonalfloor import (
35 InterzonalFloor
36)
37from teaser.logic.buildingobjects.buildingphysics.window import Window
38from teaser.logic.buildingobjects.buildingphysics.door import Door
39import json
40import collections
41import teaser
42import warnings
45def load_teaser_json(path, project):
46 """Load a project from json.
48 TEASERs internal file format to store information.
50 Parameters
51 ----------
52 path: string
53 path of teaserjson file
55 project: Project()
56 Teaser instance of Project()
59 """
60 __building_class = {
61 "Office": {"construction_data": "iwu_heavy", "teaser_class": Office},
62 "Institute": {"construction_data": "iwu_heavy", "teaser_class": Institute},
63 "Institute4": {"construction_data": "iwu_heavy", "teaser_class": Institute4},
64 "Institute8": {"construction_data": "iwu_heavy", "teaser_class": Institute8},
65 "Building": {"construction_data": "undefined", "teaser_class": Building},
66 "SingleFamilyDwelling": {"construction_data": "iwu_heavy", "teaser_class": SingleFamilyDwelling},
67 "SingleFamilyHouse": {"construction_data": "tabula_de_standard", "teaser_class": SingleFamilyHouse},
68 "TerracedHouse": {"construction_data": "tabula_de_standard", "teaser_class": TerracedHouse},
69 "MultiFamilyHouse": {"construction_data": "tabula_de_standard", "teaser_class": MultiFamilyHouse},
70 "ApartmentBlock": {"construction_data": "tabula_de_standard", "teaser_class": ApartmentBlock},
71 }
72 with open(path, "r+") as f:
73 prj_in = json.load(f, object_pairs_hook=collections.OrderedDict)
74 json_version = prj_in["project"]["version"]
75 teaser_version = teaser.__version__
77 if json_version != teaser_version:
78 warnings.warn(
79 f"TEASER version mismatch: JSON version {json_version} "
80 f"does not match current TEASER version {teaser_version}")
82 project.name = prj_in["project"]["name"]
83 project.weather_file_path = prj_in["project"]["weather_file_path"]
84 try:
85 project.t_soil_mode = prj_in["project"]["t_soil_mode"]
86 project.t_soil_file_path = prj_in["project"]["t_soil_file_path"]
87 except KeyError:
88 pass
89 project.number_of_elements_calc = prj_in["project"]["number_of_elements_calc"]
90 project.merge_windows_calc = prj_in["project"]["merge_windows_calc"]
91 project.used_library_calc = prj_in["project"]["used_library_calc"]
92 project.modelica_info.start_time = prj_in["project"]["modelica_info"]["start_time"]
93 project.modelica_info.stop_time = prj_in["project"]["modelica_info"]["stop_time"]
94 project.modelica_info.interval_output = prj_in["project"]["modelica_info"][
95 "interval_output"
96 ]
97 project.modelica_info.current_solver = prj_in["project"]["modelica_info"][
98 "current_solver"
99 ]
100 project.modelica_info.equidistant_output = prj_in["project"]["modelica_info"][
101 "equidistant_output"
102 ]
103 project.modelica_info.results_at_events = prj_in["project"]["modelica_info"][
104 "results_at_events"
105 ]
106 project.modelica_info.version = prj_in["project"]["modelica_info"]["version"]
108 for bldg_name, bldg_in in prj_in["project"]["buildings"].items():
109 bl_class = __building_class[bldg_in["classification"]["class"]]["teaser_class"]
110 bldg = bl_class(parent=project)
111 bldg.name = bldg_name
112 bldg.street_name = bldg_in["street_name"]
113 bldg.city = bldg_in["city"]
114 bldg.year_of_construction = bldg_in["year_of_construction"]
115 bldg.year_of_retrofit = bldg_in["year_of_retrofit"]
116 bldg.number_of_floors = bldg_in["number_of_floors"]
117 bldg.height_of_floors = bldg_in["height_of_floors"]
118 # bldg.net_leased_area = bldg_in["net_leased_area"]
119 bldg.outer_area = bldg_in["outer_area"]
120 bldg.window_area = bldg_in["window_area"]
121 try:
122 bldg.inner_wall_approximation_approach = bldg_in["inner_wall_approximation_approach"]
123 except KeyError:
124 pass
126 try:
127 ahu_in = bldg_in["central_ahu"]
128 bldg.central_ahu = BuildingAHU(parent=bldg)
129 bldg.central_ahu.heating = ahu_in["heating"]
130 bldg.central_ahu.cooling = ahu_in["cooling"]
131 bldg.central_ahu.dehumidification = ahu_in["dehumidification"]
132 bldg.central_ahu.humidification = ahu_in["humidification"]
133 bldg.central_ahu.heat_recovery = ahu_in["heat_recovery"]
134 bldg.central_ahu.by_pass_dehumidification = ahu_in[
135 "by_pass_dehumidification"
136 ]
137 bldg.central_ahu.efficiency_recovery = ahu_in[
138 "efficiency_recovery"
139 ]
140 bldg.central_ahu.efficiency_recovery_false = ahu_in[
141 "efficiency_recovery_false"
142 ]
143 bldg.central_ahu.min_relative_humidity_profile = ahu_in[
144 "min_relative_humidity_profile"
145 ]
146 bldg.central_ahu.max_relative_humidity_profile = ahu_in[
147 "max_relative_humidity_profile"
148 ]
149 bldg.central_ahu.v_flow_profile = ahu_in["v_flow_profile"]
150 bldg.central_ahu.temperature_profile = ahu_in[
151 "temperature_profile"
152 ]
153 except KeyError:
154 pass
156 zones_created = dict()
157 for tz_name, zone_in in bldg_in["thermal_zones"].items():
158 tz = ThermalZone(parent=bldg)
159 tz.name = tz_name
160 zones_created[tz_name] = tz
161 tz.area = zone_in["area"]
162 tz.volume = zone_in["volume"]
163 try:
164 tz.number_of_floors = zone_in["number_of_floors"]
165 tz.height_of_floors = zone_in["height_of_floors"]
166 tz.t_ground = zone_in["t_ground"]
167 tz.t_ground_amplitude = zone_in["t_ground_amplitude"]
168 tz.time_to_minimal_t_ground = zone_in["time_to_minimal_t_ground"]
169 except KeyError:
170 pass
171 tz.use_conditions = UseConditions(parent=tz)
172 tz.use_conditions.usage = zone_in["use_conditions"]["usage"]
173 tz.use_conditions.typical_length = zone_in["use_conditions"][
174 "typical_length"
175 ]
176 tz.use_conditions.typical_width = zone_in["use_conditions"]["typical_width"]
177 tz.use_conditions.with_heating = zone_in["use_conditions"]["with_heating"]
178 tz.use_conditions.with_cooling = zone_in["use_conditions"]["with_cooling"]
179 tz.use_conditions.with_ideal_thresholds = zone_in["use_conditions"][
180 "with_ideal_thresholds"
181 ]
182 tz.use_conditions.T_threshold_heating = zone_in["use_conditions"][
183 "T_threshold_heating"
184 ]
185 tz.use_conditions.T_threshold_cooling = zone_in["use_conditions"][
186 "T_threshold_cooling"
187 ]
188 tz.use_conditions.fixed_heat_flow_rate_persons = zone_in["use_conditions"][
189 "fixed_heat_flow_rate_persons"
190 ]
191 tz.use_conditions.activity_degree_persons = zone_in["use_conditions"][
192 "activity_degree_persons"
193 ]
194 tz.use_conditions.persons = zone_in["use_conditions"]["persons"]
195 tz.use_conditions.internal_gains_moisture_no_people = zone_in[
196 "use_conditions"
197 ]["internal_gains_moisture_no_people"]
198 tz.use_conditions.ratio_conv_rad_persons = zone_in["use_conditions"][
199 "ratio_conv_rad_persons"
200 ]
201 tz.use_conditions.machines = zone_in["use_conditions"]["machines"]
202 tz.use_conditions.ratio_conv_rad_machines = zone_in["use_conditions"][
203 "ratio_conv_rad_machines"
204 ]
205 tz.use_conditions.lighting_power = zone_in["use_conditions"][
206 "fixed_lighting_power"
207 ]
208 tz.use_conditions.fixed_lighting_power = zone_in["use_conditions"][
209 "fixed_lighting_power"
210 ]
211 tz.use_conditions.use_maintained_illuminance = zone_in["use_conditions"][
212 "use_maintained_illuminance"
213 ]
214 tz.use_conditions.ratio_conv_rad_lighting = zone_in["use_conditions"][
215 "ratio_conv_rad_lighting"
216 ]
217 tz.use_conditions.maintained_illuminance = zone_in["use_conditions"][
218 "maintained_illuminance"
219 ]
220 tz.use_conditions.lighting_efficiency_lumen = zone_in["use_conditions"][
221 "lighting_efficiency_lumen"
222 ]
223 tz.use_conditions.use_constant_infiltration = zone_in["use_conditions"][
224 "use_constant_infiltration"
225 ]
226 tz.use_conditions.base_infiltration = zone_in["use_conditions"][
227 "base_infiltration"
228 ]
229 tz.use_conditions.max_user_infiltration = zone_in["use_conditions"][
230 "max_user_infiltration"
231 ]
232 tz.use_conditions.max_overheating_infiltration = zone_in["use_conditions"][
233 "max_overheating_infiltration"
234 ]
235 tz.use_conditions.max_summer_infiltration = zone_in["use_conditions"][
236 "max_summer_infiltration"
237 ]
238 tz.use_conditions.winter_reduction_infiltration = zone_in["use_conditions"][
239 "winter_reduction_infiltration"
240 ]
241 tz.use_conditions.min_ahu = zone_in["use_conditions"]["min_ahu"]
242 tz.use_conditions.max_ahu = zone_in["use_conditions"]["max_ahu"]
243 tz.use_conditions.with_ahu = zone_in["use_conditions"]["with_ahu"]
244 tz.use_conditions.heating_profile = zone_in["use_conditions"][
245 "heating_profile"
246 ]
247 tz.use_conditions.cooling_profile = zone_in["use_conditions"][
248 "cooling_profile"
249 ]
250 tz.use_conditions.persons_profile = zone_in["use_conditions"][
251 "persons_profile"
252 ]
253 tz.use_conditions.machines_profile = zone_in["use_conditions"][
254 "machines_profile"
255 ]
256 tz.use_conditions.lighting_profile = zone_in["use_conditions"][
257 "lighting_profile"
258 ]
260 for wall_name, wall_in in zone_in["outer_walls"].items():
261 out_wall = OuterWall(parent=tz)
262 out_wall.name = wall_name
263 set_basic_data_teaser(wall_in, out_wall)
264 set_layer_data_teaser(wall_in, out_wall)
265 for door_name, door_in in zone_in["doors"].items():
266 door = Door(parent=tz)
267 door.name = door_name
268 set_basic_data_teaser(door_in, door)
269 set_layer_data_teaser(door_in, door)
270 for roof_name, roof_in in zone_in["rooftops"].items():
271 roof = Rooftop(parent=tz)
272 roof.name = roof_name
273 set_basic_data_teaser(roof_in, roof)
274 set_layer_data_teaser(roof_in, roof)
275 for gf_name, gf_in in zone_in["ground_floors"].items():
276 gf = GroundFloor(parent=tz)
277 gf.name = gf_name
278 set_basic_data_teaser(gf_in, gf)
279 set_layer_data_teaser(gf_in, gf)
280 for win_name, win_in in zone_in["windows"].items():
281 win = Window(parent=tz)
282 win.name = win_name
283 set_basic_data_teaser(win_in, win)
284 set_layer_data_teaser(win_in, win)
285 for iw_name, iw_in in zone_in["inner_walls"].items():
286 in_wall = InnerWall(parent=tz)
287 in_wall.name = iw_name
288 set_basic_data_teaser(iw_in, in_wall)
289 set_layer_data_teaser(iw_in, in_wall)
290 for fl_name, fl_in in zone_in["floors"].items():
291 floor = Floor(parent=tz)
292 floor.name = fl_name
293 set_basic_data_teaser(fl_in, floor)
294 set_layer_data_teaser(fl_in, floor)
295 for cl_name, cl_in in zone_in["ceilings"].items():
296 ceil = Ceiling(parent=tz)
297 ceil.name = cl_name
298 set_basic_data_teaser(cl_in, ceil)
299 set_layer_data_teaser(cl_in, ceil)
300 for izw_name, izw_in in zone_in.get(
301 "interzonal_walls", dict()
302 ).items():
303 iz_wall = InterzonalWall(parent=tz)
304 iz_wall.name = izw_name
305 set_basic_data_teaser(izw_in, iz_wall)
306 set_layer_data_teaser(izw_in, iz_wall)
307 for izf_name, izf_in in zone_in.get(
308 "interzonal_floors", dict()
309 ).items():
310 izf = InterzonalFloor(parent=tz)
311 izf.name = izf_name
312 set_basic_data_teaser(izf_in, izf)
313 set_layer_data_teaser(izf_in, izf)
314 for izc_name, izc_in in zone_in.get(
315 "interzonal_ceilings", dict()
316 ).items():
317 izc = InterzonalCeiling(parent=tz)
318 izc.name = izc_name
319 set_basic_data_teaser(izc_in, izc)
320 set_layer_data_teaser(izc_in, izc)
322 # fill other_side attribute of interzonal elements
323 for tz, (tz_name, zone_in) in zip(bldg.thermal_zones,
324 bldg_in["thermal_zones"].items()):
325 for iz_wall, (izw_name, izw_in) in zip(
326 tz.interzonal_walls,
327 zone_in.get("interzonal_walls", dict()).items()
328 ):
329 iz_wall.other_side = zones_created[izw_in["other_side"]]
330 for iz_floor, (izf_name, izf_in) in zip(
331 tz.interzonal_floors,
332 zone_in.get("interzonal_floors", dict()).items()
333 ):
334 iz_floor.other_side = zones_created[izf_in["other_side"]]
335 for iz_ceiling, (izc_name, izc_in) in zip(
336 tz.interzonal_ceilings,
337 zone_in.get("interzonal_ceilings", dict()).items()
338 ):
339 iz_ceiling.other_side = zones_created[izc_in["other_side"]]
342def set_basic_data_teaser(wall_in, element):
343 """Set basic data for a building element.
345 Helper function.
347 Parameters
348 ----------
349 wall_in : collection.OrderedDict
350 OrderedDict for walls
351 element : TEASERClass
352 teaser class representation of a building element
354 """
355 element.area = wall_in["area"]
356 element.tilt = wall_in["tilt"]
357 element.orientation = wall_in["orientation"]
358 element.inner_radiation = wall_in["inner_radiation"]
359 element.inner_convection = wall_in["inner_convection"]
360 element.year_of_construction = wall_in["year_of_construction"]
361 element.year_of_retrofit = wall_in["year_of_retrofit"]
362 element.construction_data = wall_in["construction_data"]
364 if (
365 type(element).__name__ == "OuterWall"
366 or type(element).__name__ == "Rooftop"
367 or type(element).__name__ == "Door"
368 or type(element).__name__ == "InterzonalWall"
369 or type(element).__name__ == "InterzonalCeiling"
370 or type(element).__name__ == "InterzonalFloor"
371 ):
373 element.outer_radiation = wall_in["outer_radiation"]
374 element.outer_convection = wall_in["outer_convection"]
376 elif type(element).__name__ == "Window":
378 element.outer_radiation = wall_in["outer_radiation"]
379 element.outer_convection = wall_in["outer_convection"]
380 element.g_value = wall_in["g_value"]
381 element.a_conv = wall_in["a_conv"]
382 element.shading_g_total = wall_in["shading_g_total"]
383 element.shading_max_irr = wall_in["shading_max_irr"]
386def set_layer_data_teaser(wall_in, element):
387 """Set layer data of a building element.
389 Helper function.
391 Parameters
392 ----------
393 wall_in : collection.OrderedDict
394 OrderedDict for walls
395 element : TEASERClass
396 teaser class representation of a building element
398 """
399 for lay_id, layer_in in wall_in["layer"].items():
400 layer = Layer(element)
402 layer.id = int(lay_id)
403 layer.thickness = layer_in["thickness"]
405 Material(layer)
407 layer.material.name = layer_in["material"]["name"]
408 layer.material.density = layer_in["material"]["density"]
409 layer.material.thermal_conduc = layer_in["material"]["thermal_conduc"]
410 layer.material.heat_capac = layer_in["material"]["heat_capac"]
411 layer.material.solar_absorp = layer_in["material"]["solar_absorp"]
412 layer.material.ir_emissivity = layer_in["material"]["ir_emissivity"]