First working version of the thermal_demand_dynamic_simulation

This commit is contained in:
Pilar 2021-08-27 17:48:07 -04:00
parent 096cec2503
commit 07afa0eed1
2 changed files with 106 additions and 75 deletions

View File

@ -169,9 +169,7 @@ class ThermalDemandDynamicSimulation:
number_of_windows = []
for i_zone, thermal_zone in enumerate(building.thermal_zones):
n_window = 0
print('1', thermal_zone.id)
thermal_zone.ordinate_number = i_zone
print(thermal_zone.ordinate_number)
for thermal_boundary in thermal_zone.thermal_boundaries:
n_window += len(thermal_boundary.thermal_openings)
number_of_windows.append(n_window)
@ -344,69 +342,8 @@ class ThermalDemandDynamicSimulation:
file = Insel.add_block(file, i_block, 'SUM', inputs)
# Surfaces
for i_tb, thermal_boundary in enumerate(building.thermal_boundaries):
i_block += 1
inputs = [f"{n_gain_moy}.1"]
if (thermal_boundary.surface.type == cte.WALL) or (thermal_boundary.surface.type == cte.ROOF):
print('aa')
for tz in thermal_boundary.delimits:
print('2', tz.id)
inputs.append(f"{n_zone[int(thermal_boundary.delimits[0].ordinate_number)] + 8}.{i_tb}")
inputs.append(f"{n_zone[int(thermal_boundary.delimits[0].ordinate_number)] + 6}.{i_tb}")
inputs.append(f"{n_ig}.{int(thermal_boundary.delimits[0].ordinate_number) * 5 + 2}")
inputs.append(f"{i_block + 2}.1")
inputs.append(f"{n_weather}.1")
inputs.append(f"{n_weather}.2")
print('bb')
inputs.append(f"{n_weather}.{int(thermal_boundary.surface.id) * 3 + 6}")
inputs.append(f"{n_zone[thermal_boundary.delimits[0].ordinate_number] + 1}.1")
parameters = [f"{thermal_boundary.hi} % [ConvCoefiW]",
f"{thermal_boundary.he} % [ConvCoefeW1]",
f"0 % [ConvCoefeW2]",
f"{thermal_boundary.radiative_coefficient} % [RadCoefeW]",
f"{len(thermal_boundary.layers)} % [Nlay]"]
for layer in thermal_boundary.layers:
material = layer.material
if material.no_mass:
parameters.append(f"1 {1 / float(material.thermal_resistance)} 1 1 % [thick] + [lambda ] +[rho] +[cp]")
else:
parameters.append(f"{layer.thickness} {material.conductivity} {material.density} {material.specific_heat}"
f" % [thick] + [lambda ] +[rho] +[cp]")
file = Insel.add_block(file, i_block, 'UBWALLXV2', inputs=inputs, parameters=parameters)
i_block += 1
inputs = [f"{i_block - 1}.3"]
parameters = [f"{thermal_boundary.area} % [AreaW]"]
file = Insel.add_block(file, i_block, 'GAIN', inputs=inputs, parameters=parameters)
i_block += 1
inputs = [f"{n_weather}.{int(thermal_boundary.surface.id) * 3 + 2}"]
parameters = [f"{thermal_boundary.outside_solar_absorptance} %[AbsorptionCoef]"]
file = Insel.add_block(file, i_block, 'GAIN', inputs=inputs, parameters=parameters)
elif (thermal_boundary.surface.type == cte.GROUND) or (thermal_boundary.surface.type == cte.GROUND_WALL):
inputs.append(f"{n_zone[thermal_boundary.delimits[0].ordinate_number] + 8}.{i_tb}")
inputs.append(f"{n_zone[thermal_boundary.delimits[0].ordinate_number] + 6}.{i_tb}")
inputs.append(f"{n_ig}.{thermal_boundary.delimits[0].ordinate_number * 5 + 2}")
inputs.append(f"{n_weather}.3")
inputs.append(f"{n_zone[thermal_boundary.delimits[0].ordinate_number] + 1}.1")
parameters = [f"{thermal_boundary.hi} % [ConvCoefiW]",
f"{len(thermal_boundary.layers)} %[Nlay]"]
for layer in thermal_boundary.layers:
material = layer.material
if material.no_mass:
parameters.append(f"1 {1 / float(material.thermal_resistance)} 1 1 % [thick] + [lambda ] +[rho] +[cp]")
else:
parameters.append(f"{layer.thickness} {material.conductivity} {material.density} {material.specific_heat}"
f" % [thick] + [lambda ] +[rho] +[cp]")
parameters.append(f"1 1.3 1500 800 %[thick] + [lambda] + [rho] + [cp]")
file = Insel.add_block(file, i_block, 'UBWALLGV2', inputs=inputs, parameters=parameters)
i_block += 1
inputs = [f"{i_block - 1}.3"]
parameters = [f"{thermal_boundary.area} % [AreaW]"]
file = Insel.add_block(file, i_block, 'GAIN', inputs=inputs, parameters=parameters)
return file
"""
i_weather = 3
i_weather_window = 3
for i_tz, thermal_zone in enumerate(building.thermal_zones):
i_surface = 0
for thermal_boundary in thermal_zone.thermal_boundaries:
@ -531,5 +468,103 @@ class ThermalDemandDynamicSimulation:
i_weather_window += 5
else:
i_weather_window += 2
"""
return file
"""
# Surfaces
for i_tb, thermal_boundary in enumerate(building.thermal_boundaries):
i_block += 1
inputs = [f"{n_gain_moy}.1"]
if (thermal_boundary.surface.type == cte.WALL) or (thermal_boundary.surface.type == cte.ROOF):
inputs.append(f"{n_zone[int(thermal_boundary.thermal_zones[0].ordinate_number)] + 8}.{i_tb + 1}")
inputs.append(f"{n_zone[int(thermal_boundary.thermal_zones[0].ordinate_number)] + 6}.{i_tb + 1}")
inputs.append(f"{n_ig}.{int(thermal_boundary.thermal_zones[0].ordinate_number) * 5 + 2}")
inputs.append(f"{i_block + 2}.1")
inputs.append(f"{n_weather}.1")
inputs.append(f"{n_weather}.2")
inputs.append(f"{n_weather}.{int(thermal_boundary.surface.id) * 3 + 6}")
inputs.append(f"{n_zone[thermal_boundary.thermal_zones[0].ordinate_number] + 1}.1")
parameters = [f"{thermal_boundary.hi} % [ConvCoefiW]",
f"{thermal_boundary.he} % [ConvCoefeW1]",
f"0 % [ConvCoefeW2]",
f"{thermal_boundary.radiative_coefficient} % [RadCoefeW]",
f"{len(thermal_boundary.layers)} % [Nlay]"]
for layer in thermal_boundary.layers:
material = layer.material
if material.no_mass:
parameters.append(f"1 {1 / float(material.thermal_resistance)} 1 1 % [thick] + [lambda ] +[rho] +[cp]")
else:
parameters.append(f"{layer.thickness} {material.conductivity} {material.density} {material.specific_heat}"
f" % [thick] + [lambda ] +[rho] +[cp]")
file = Insel.add_block(file, i_block, 'UBWALLXV2', inputs=inputs, parameters=parameters)
i_block += 1
inputs = [f"{i_block - 1}.3"]
parameters = [f"{thermal_boundary.area} % [AreaW]"]
file = Insel.add_block(file, i_block, 'GAIN', inputs=inputs, parameters=parameters)
i_block += 1
inputs = [f"{n_weather}.{int(thermal_boundary.surface.id) * 3 + 4}"]
parameters = [f"{thermal_boundary.outside_solar_absorptance} %[AbsorptionCoef]"]
file = Insel.add_block(file, i_block, 'GAIN', inputs=inputs, parameters=parameters)
elif (thermal_boundary.surface.type == cte.GROUND) or (thermal_boundary.surface.type == cte.GROUND_WALL):
inputs.append(f"{n_zone[thermal_boundary.thermal_zones[0].ordinate_number] + 8}.{i_tb + 1}")
inputs.append(f"{n_zone[thermal_boundary.thermal_zones[0].ordinate_number] + 6}.{i_tb + 1}")
inputs.append(f"{n_ig}.{thermal_boundary.thermal_zones[0].ordinate_number * 5 + 2}")
inputs.append(f"{n_weather}.3")
inputs.append(f"{n_zone[thermal_boundary.thermal_zones[0].ordinate_number] + 1}.1")
parameters = [f"{thermal_boundary.hi} % [ConvCoefiW]",
f"{len(thermal_boundary.layers)} %[Nlay]"]
for layer in thermal_boundary.layers:
material = layer.material
if material.no_mass:
parameters.append(f"1 {1 / float(material.thermal_resistance)} 1 1 % [thick] + [lambda ] +[rho] +[cp]")
else:
parameters.append(f"{layer.thickness} {material.conductivity} {material.density} {material.specific_heat}"
f" % [thick] + [lambda ] +[rho] +[cp]")
parameters.append(f"1 1.3 1500 800 %[thick] + [lambda] + [rho] + [cp]")
file = Insel.add_block(file, i_block, 'UBWALLGV2', inputs=inputs, parameters=parameters)
i_block += 1
inputs = [f"{i_block - 1}.3"]
parameters = [f"{thermal_boundary.area} % [AreaW]"]
file = Insel.add_block(file, i_block, 'GAIN', inputs=inputs, parameters=parameters)
# Windows
# todo: it is missing the windows counter but the question is, do I place all windows at the end of the file or at
# the end of each thermal zone????? -> at theend of each tehrmal zone!!!!
for thermal_boundary in building.thermal_boundaries:
for thermal_opening in thermal_boundary.thermal_openings:
i_block += 1
inputs = [f"{n_gain_moy}.1",
f"{i_block + 2}.1",
f"{n_zero}.1",
f"{n_weather}.{int(thermal_boundary.surface.id) * 3 + 4}",
f"{n_weather}.{int(thermal_boundary.surface.id) * 3 + 5}",
f"{n_weather}.1",
f"{n_weather}.2",
f"{n_weather}.{int(thermal_boundary.surface.id) * 3 + 6}",
f"{n_zone[int(thermal_boundary.thermal_zones[0].ordinate_number)] + 1}.1",
f"{n_zero}.1",
f"{n_zero}.1"]
parameters = [f"{thermal_opening.hi} % [ConvCoefiW]",
f"{thermal_opening.he} % [ConvCoefeW1]",
f"0 % [ConvCoefeW2]",
f"{thermal_opening.radiative_coefficient} % [RadCoefeW]",
f"0 % [Ubi]",
f"1 % [Nlay]"]
layer_conductivity = float(thermal_opening.thickness) / ((1/float(thermal_opening.overall_u_value)) -
(1/float(thermal_opening.hi)) -
(1/float(thermal_opening.he)))
parameters_layer = f"{thermal_opening.thickness} {layer_conductivity} 1000 750 " \
f"% [thick] + [lambda ] +[rho] +[cp]"
parameters.append(parameters_layer)
file = Insel.add_block(file, i_block, 'UBWDYNV2', inputs=inputs, parameters=parameters)
i_block += 1
inputs = [f"{i_block - 1}.3"]
parameters = [f"{thermal_opening.area} %[AreaWindow]"]
file = Insel.add_block(file, i_block, 'GAIN', inputs=inputs, parameters=parameters)
i_block += 1
inputs = [f"{n_zone[int(thermal_boundary.thermal_zones[0].ordinate_number)] + 6}."
f"{len(thermal_boundary.thermal_zones[0].thermal_boundaries) + i_win + 1}",
f"{n_ig}.{int(thermal_boundary.thermal_zones[0].ordinate_number) * 5 + 2}"]
file = Insel.add_block(file, i_block, 'SUM', inputs=inputs)
"""

14
main.py
View File

@ -31,13 +31,6 @@ pickle_file = 'tests/tests_data/one_building_in_kelowna.pickle'
if not pickle_created:
city = GeometryFactory('citygml', full_path_gml).city
# Assumptions for this workflow
for building in city.buildings:
for thermal_zone in building.thermal_zones:
for thermal_boundary in thermal_zone.thermal_boundaries:
thermal_boundary.hi = 3.5
thermal_boundary.he = 20
weather_format = 'epw'
city.climate_reference_city = climate_reference_city
city.climate_file = (tmp_path / f'{climate_reference_city}.cli').resolve()
@ -83,10 +76,13 @@ else:
# Assign user defined parameters
if not pickle_created:
for building in city.buildings:
print(len(building.storeys))
print(building.storeys[0].thermal_boundaries)
print(building.storeys[0].thermal_zone)
print('number of thermal boundaries', len(building.thermal_boundaries))
for i_tb, thermal_boundary in enumerate(building.thermal_boundaries):
print(i_tb, thermal_boundary.type)
for thermal_zone in thermal_boundary.delimits:
for thermal_zone in thermal_boundary.thermal_zones:
print(thermal_zone.id)
quit()
for thermal_zone in building.thermal_zones:
@ -95,7 +91,7 @@ if not pickle_created:
print('type', thermal_boundary.surface.type)
print('id', thermal_boundary.surface.id)
print('area tb', thermal_boundary.area)
for tz in thermal_boundary.delimits:
for tz in thermal_boundary.thermal_zones:
print('delimits', tz.id)
print('window ratio', thermal_boundary.window_ratio)
for thermal_opening in thermal_boundary.thermal_openings: