mirror of
https://rs-loy-gitlab.concordia.ca/PMAU/DynamicBuildingSimulation.git
synced 2024-11-14 15:00:29 -05:00
added id to thermal_boundary.py and thermal_opening.py
erased \r from files generators added generator of auxiliary files for dynamic model
This commit is contained in:
parent
07afa0eed1
commit
573678a6c5
|
@ -22,3 +22,6 @@ class SimulationParameters:
|
|||
cooling_power = '100000000'
|
||||
heating_power = '100000000'
|
||||
|
||||
inside_emissivity = '0.9'
|
||||
alpha_coefficient = '0.3'
|
||||
radiative_coefficient = '2.25'
|
||||
|
|
|
@ -22,7 +22,8 @@ class Insel:
|
|||
@property
|
||||
def full_path(self):
|
||||
if self._full_path is None:
|
||||
self._full_path = (Path(self._path) / 'third_party_files/insel' / self._name).resolve()
|
||||
self._full_path = (Path(self._path) / 'tests/tmp' / self._name).resolve()
|
||||
print(self._full_path)
|
||||
return self._full_path
|
||||
|
||||
@property
|
||||
|
@ -37,19 +38,19 @@ class Insel:
|
|||
|
||||
@staticmethod
|
||||
def add_block(file, block_number, block_type, inputs='', parameters=''):
|
||||
file += "S " + str(block_number) + " " + block_type + "\r\n"
|
||||
file += "S " + str(block_number) + " " + block_type + "\n"
|
||||
for block_input in inputs:
|
||||
file += block_input + "\r\n"
|
||||
file += block_input + "\n"
|
||||
if len(parameters) > 0:
|
||||
file += "P " + str(block_number) + "\r\n"
|
||||
file += "P " + str(block_number) + "\n"
|
||||
for block_parameter in parameters:
|
||||
file += block_parameter + "\r\n"
|
||||
file += block_parameter + "\n"
|
||||
return file
|
||||
|
||||
def add_content(self, new_content, mode):
|
||||
# mode = 1: keep old content
|
||||
if mode == 1:
|
||||
self._content = self.content + '\r\n' + new_content
|
||||
self._content = self.content + '\n' + new_content
|
||||
# mode = 2: over-write
|
||||
elif mode == 2:
|
||||
self._content = new_content
|
||||
|
|
|
@ -1,24 +1,70 @@
|
|||
"""
|
||||
Thermal demand dynamic simulation template generator
|
||||
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||||
Copyright © 2021 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
||||
"""
|
||||
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
from insel.insel import Insel
|
||||
import helpers.constants as cte
|
||||
|
||||
|
||||
class ThermalDemandDynamicSimulation:
|
||||
@staticmethod
|
||||
def generate_thermal_dynamic_template(building, outputs_paths, weather_path, ig_path, fij_paths,
|
||||
simulation_parameters):
|
||||
number_usage_zones = len(building.usage_zones)
|
||||
"""
|
||||
ThermalDemandDynamicSimulation class
|
||||
"""
|
||||
def __init__(self, building, outputs_paths, weather_path, ig_path, fij_paths, simulation_parameters):
|
||||
self._building = building
|
||||
self._outputs_paths = outputs_paths
|
||||
self._weather_path = weather_path
|
||||
self._ig_path = ig_path
|
||||
self._fij_paths = fij_paths
|
||||
self._simulation_parameters = simulation_parameters
|
||||
|
||||
def generate_thermal_dynamic_template(self):
|
||||
"""
|
||||
Generates the thermal dynamic simulation template for Insel.
|
||||
:return: str
|
||||
"""
|
||||
|
||||
file = ""
|
||||
file += "%Thermal Demand Dynamic Calculation\r\n"
|
||||
file += "%by Pilar Monsalvete Alvarez de Uribarri\r\n"
|
||||
file += "%email: pilar.monsalvete@concordia.ca\r\n"
|
||||
file += "%Thermal Demand Dynamic Calculation\n"
|
||||
file += "%by Pilar Monsalvete Alvarez de Uribarri\n"
|
||||
file += "%email: pilar.monsalvete@concordia.ca\n"
|
||||
|
||||
for thermal_zone in self._building.thermal_zones:
|
||||
for thermal_boundary in thermal_zone.thermal_boundaries:
|
||||
thermal_boundary.inside_emissivity = self._simulation_parameters.inside_emissivity
|
||||
thermal_boundary.alpha_coefficient = self._simulation_parameters.alpha_coefficient
|
||||
thermal_boundary.radiative_coefficient = self._simulation_parameters.radiative_coefficient
|
||||
for thermal_opening in thermal_boundary.thermal_openings:
|
||||
thermal_opening.inside_emissivity = self._simulation_parameters.inside_emissivity
|
||||
thermal_opening.alpha_coefficient = self._simulation_parameters.alpha_coefficient
|
||||
thermal_opening.radiative_coefficient = self._simulation_parameters.radiative_coefficient
|
||||
|
||||
# insel template
|
||||
i_block = 0
|
||||
new_file, pointers = self._general_blocks(i_block, self._building, self._outputs_paths, self._weather_path,
|
||||
self._ig_path, self._simulation_parameters)
|
||||
file += new_file
|
||||
|
||||
new_file, pointers = self._zones_blocks(pointers, self._building, self._fij_paths, self._simulation_parameters)
|
||||
file += new_file
|
||||
|
||||
new_file = self._surfaces_blocks(pointers, self._building)
|
||||
file += new_file
|
||||
|
||||
return file
|
||||
|
||||
@staticmethod
|
||||
def _general_blocks(i_block, building, outputs_paths, weather_path, ig_path, simulation_parameters):
|
||||
# time blocks
|
||||
i_block += 1
|
||||
n_clock = i_block
|
||||
|
||||
number_usage_zones = len(building.usage_zones)
|
||||
|
||||
parameters = [f"{simulation_parameters.year_start} %[YearIni]",
|
||||
f"{simulation_parameters.month_start} %[MonthIni]",
|
||||
f"{simulation_parameters.day_start} %[DayIni]",
|
||||
|
@ -33,7 +79,7 @@ class ThermalDemandDynamicSimulation:
|
|||
f"{simulation_parameters.second_end} %[SecEnd]",
|
||||
f"{simulation_parameters.delta_time} %[Incr]",
|
||||
f"{simulation_parameters.delta_time_unit} %[Unit]"]
|
||||
file = Insel.add_block(file, i_block, 'CLOCK', parameters=parameters)
|
||||
file = Insel.add_block('', i_block, 'CLOCK', parameters=parameters)
|
||||
|
||||
i_block += 1
|
||||
n_moy = i_block
|
||||
|
@ -61,7 +107,13 @@ class ThermalDemandDynamicSimulation:
|
|||
# weather blocks
|
||||
i_block += 1
|
||||
n_weather = i_block
|
||||
n_records = 3 + len(building.surfaces) * 5
|
||||
n_records = 3
|
||||
for thermal_boundary in building.thermal_boundaries:
|
||||
if thermal_boundary.surface.type != cte.GROUND:
|
||||
if len(thermal_boundary.thermal_openings) > 0:
|
||||
n_records += 5
|
||||
else:
|
||||
n_records += 2
|
||||
inputs = [f"{n_hoy}.1"]
|
||||
parameters = [f"{n_records} %[Nrec]",
|
||||
f"{n_records * 12} %[RecLen]",
|
||||
|
@ -88,8 +140,8 @@ class ThermalDemandDynamicSimulation:
|
|||
f"{n_clock}.4"]
|
||||
headline = ''
|
||||
for i in range(0, number_usage_zones):
|
||||
inputs.append(f"{i_block + 2}." + str(i*2+2))
|
||||
inputs.append(f"{i_block + 2}." + str(i*2+3))
|
||||
inputs.append(f"{i_block + 2}." + str(i * 2 + 2))
|
||||
inputs.append(f"{i_block + 2}." + str(i * 2 + 3))
|
||||
headline += f"CoolingTZ_{i + 1} (Wh); HeatingTZ_{i + 1} (Wh); "
|
||||
parameters = ["1 %[Mode]",
|
||||
f"'{outputs_paths}_demand.out' %[FileName]",
|
||||
|
@ -105,7 +157,7 @@ class ThermalDemandDynamicSimulation:
|
|||
f"{n_clock}.4"]
|
||||
headline = ''
|
||||
for i in range(0, number_usage_zones):
|
||||
inputs.append(str(i_block+2) + "." + str(i+2))
|
||||
inputs.append(str(i_block + 2) + "." + str(i + 2))
|
||||
headline += f"TempTZ_{i + 1} (C); "
|
||||
parameters = ["1 %[Mode]",
|
||||
f"'{outputs_paths}_temp.out' %[FileName]",
|
||||
|
@ -161,6 +213,16 @@ class ThermalDemandDynamicSimulation:
|
|||
n_zero = i_block
|
||||
parameters = ["0 %[ZeroConst]"]
|
||||
file = Insel.add_block(file, i_block, 'CONST', parameters=parameters)
|
||||
pointers = [i_block, n_gain_moy, n_weather, n_ig, n_zero]
|
||||
return file, pointers
|
||||
|
||||
@staticmethod
|
||||
def _zones_blocks(pointers, building, fij_paths, simulation_parameters):
|
||||
i_block = pointers[0]
|
||||
n_gain_moy = pointers[1]
|
||||
n_weather = pointers[2]
|
||||
n_ig = pointers[3]
|
||||
n_zero = pointers[4]
|
||||
|
||||
# Zones:
|
||||
n_start_zones = i_block + 1
|
||||
|
@ -218,7 +280,7 @@ class ThermalDemandDynamicSimulation:
|
|||
for thermal_boundary in thermal_zone.thermal_boundaries:
|
||||
for thermal_opening in thermal_boundary.thermal_openings:
|
||||
parameters.append(f"{thermal_opening.area} {thermal_opening.hi} %[Area] + [ConvCoefi]")
|
||||
file = Insel.add_block(file, i_block, 'UBROOMV2', inputs, parameters)
|
||||
file = Insel.add_block('', i_block, 'UBROOMV2', inputs, parameters)
|
||||
|
||||
i_block += 1
|
||||
inputs = [f"{i_block - 1}.1"]
|
||||
|
@ -341,10 +403,25 @@ class ThermalDemandDynamicSimulation:
|
|||
inputs = inputs_next
|
||||
file = Insel.add_block(file, i_block, 'SUM', inputs)
|
||||
|
||||
pointers = [i_block, n_gain_moy, n_weather, n_ig, n_zero, n_zone]
|
||||
return file, pointers
|
||||
|
||||
@staticmethod
|
||||
def _surfaces_blocks(pointers, building):
|
||||
i_block = pointers[0]
|
||||
n_gain_moy = pointers[1]
|
||||
n_weather = pointers[2]
|
||||
n_ig = pointers[3]
|
||||
n_zero = pointers[4]
|
||||
n_zone = pointers[5]
|
||||
|
||||
file = ''
|
||||
|
||||
# Surfaces
|
||||
i_weather = 3
|
||||
i_weather_window = 3
|
||||
for i_tz, thermal_zone in enumerate(building.thermal_zones):
|
||||
# opaque surfaces
|
||||
i_surface = 0
|
||||
for thermal_boundary in thermal_zone.thermal_boundaries:
|
||||
i_block += 1
|
||||
|
@ -409,18 +486,21 @@ class ThermalDemandDynamicSimulation:
|
|||
parameters = [f"{thermal_boundary.area} % [AreaW]"]
|
||||
file = Insel.add_block(file, i_block, 'GAIN', inputs=inputs, parameters=parameters)
|
||||
elif thermal_boundary.surface.type == cte.INTERIOR_SLAB:
|
||||
parameters = []
|
||||
file = Insel.add_block(file, i_block, 'UBWALLV2', inputs=inputs, parameters=parameters)
|
||||
i_block += 1
|
||||
file = Insel.add_block(file, i_block, 'GAIN', inputs=inputs, parameters=parameters)
|
||||
i_block += 1
|
||||
file = Insel.add_block(file, i_block, 'GAIN', inputs=inputs, parameters=parameters)
|
||||
elif thermal_boundary.surface.type == cte.INTERIOR_WALL:
|
||||
parameters = []
|
||||
file = Insel.add_block(file, i_block, 'UBWALLV2', inputs=inputs, parameters=parameters)
|
||||
i_block += 1
|
||||
file = Insel.add_block(file, i_block, 'GAIN', inputs=inputs, parameters=parameters)
|
||||
i_block += 1
|
||||
file = Insel.add_block(file, i_block, 'GAIN', inputs=inputs, parameters=parameters)
|
||||
elif thermal_boundary.surface.type == cte.ATTIC_FLOOR:
|
||||
parameters = []
|
||||
file = Insel.add_block(file, i_block, 'UBWALLV2', inputs=inputs, parameters=parameters)
|
||||
i_block += 1
|
||||
file = Insel.add_block(file, i_block, 'GAIN', inputs=inputs, parameters=parameters)
|
||||
|
@ -471,100 +551,94 @@ class ThermalDemandDynamicSimulation:
|
|||
|
||||
return file
|
||||
|
||||
"""
|
||||
# Surfaces
|
||||
def generate_weather_file(self):
|
||||
"""
|
||||
Generates the weather file needed by the thermal dynamic simulation template for Insel.
|
||||
"""
|
||||
building = self._building
|
||||
weather_path = self._weather_path
|
||||
zeros = np.zeros(8760)
|
||||
content = pd.DataFrame(building.external_temperature[cte.HOUR])
|
||||
content.rename(columns={content.columns[0]: 'ambient_temperature'})
|
||||
# content['sky_temperature'] = building.sky_temperature
|
||||
content['sky_temperature'] = zeros
|
||||
# content['ground_temperature'] = building.ground_temperature
|
||||
content['ground_temperature'] = zeros
|
||||
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)
|
||||
if thermal_boundary.surface.type == cte.WALL or thermal_boundary.surface.type == cte.ROOF:
|
||||
content[f'global_irradiance_{i_tb}'] = thermal_boundary.surface.global_irradiance[cte.HOUR].astype(float)
|
||||
if len(thermal_boundary.thermal_openings) > 0:
|
||||
content[f'diffuse_irradiance_{i_tb}'] = zeros
|
||||
g_values = np.full((8760, 1), thermal_boundary.thermal_openings[0].g_value).astype(float)
|
||||
content[f'g_value_{i_tb}'] = g_values
|
||||
content[f'darkness_value_{i_tb}'] = zeros
|
||||
content[f'wind_velocity_{i_tb}'] = zeros
|
||||
content.to_csv(weather_path, header=False, index=False, float_format='%12.3f')
|
||||
text = open(weather_path, 'r')
|
||||
text = ''.join([i for i in text]).replace(',', '')
|
||||
replaced_text = open(weather_path, 'w')
|
||||
replaced_text.writelines(text)
|
||||
replaced_text.close()
|
||||
|
||||
# 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)
|
||||
"""
|
||||
def generate_ig_file(self):
|
||||
"""
|
||||
Generates the internal gains file needed by the thermal dynamic simulation template for Insel.
|
||||
"""
|
||||
building = self._building
|
||||
ig_path = self._ig_path
|
||||
content = pd.DataFrame()
|
||||
zeros = np.zeros(8760)
|
||||
for i_uz, usage_zone in enumerate(building.usage_zones):
|
||||
content[f'convective_part_{i_uz}'] = zeros
|
||||
content[f'radiative_part_{i_uz}'] = zeros
|
||||
content[f'ventilation_rate_{i_uz}'] = zeros
|
||||
content[f'set_point_cooling_{i_uz}'] = zeros
|
||||
content[f'set_point_heating_{i_uz}'] = zeros
|
||||
content.to_csv(ig_path, header=False, index=False, float_format='%12.3f')
|
||||
text = open(ig_path, 'r')
|
||||
text = ''.join([i for i in text]).replace(',', '')
|
||||
replaced_text = open(ig_path, 'w')
|
||||
replaced_text.writelines(text)
|
||||
replaced_text.close()
|
||||
|
||||
def generate_fij_files(self):
|
||||
"""
|
||||
Generates the view factors files of each zone needed by the thermal dynamic simulation template for Insel.
|
||||
"""
|
||||
building = self._building
|
||||
fij_paths = self._fij_paths
|
||||
for i_tz, thermal_zone in enumerate(building.thermal_zones):
|
||||
total_area = 0
|
||||
content = ''
|
||||
for thermal_boundary in thermal_zone.thermal_boundaries:
|
||||
total_area += thermal_boundary.area
|
||||
for thermal_opening in thermal_boundary.thermal_openings:
|
||||
total_area += thermal_opening.area
|
||||
for thermal_boundary_1 in thermal_zone.thermal_boundaries:
|
||||
line = ''
|
||||
for thermal_boundary_2 in thermal_zone.thermal_boundaries:
|
||||
value = 0
|
||||
if thermal_boundary_1.id != thermal_boundary_2.id:
|
||||
value = thermal_boundary_2.area / (total_area - thermal_boundary_1.area)
|
||||
line += f'{value}, '
|
||||
for thermal_boundary in thermal_zone.thermal_boundaries:
|
||||
for thermal_opening in thermal_boundary.thermal_openings:
|
||||
value = thermal_opening.area / (total_area - thermal_boundary_1.area)
|
||||
line += f'{value}, '
|
||||
content += f'{line}\n'
|
||||
for thermal_boundary_1 in thermal_zone.thermal_boundaries:
|
||||
line = ''
|
||||
for thermal_opening_1 in thermal_boundary_1.thermal_openings:
|
||||
for thermal_boundary_2 in thermal_zone.thermal_boundaries:
|
||||
value = thermal_boundary_2.area / (total_area - thermal_opening_1.area)
|
||||
line += f'{value}, '
|
||||
for thermal_boundary in thermal_zone.thermal_boundaries:
|
||||
for thermal_opening_2 in thermal_boundary.thermal_openings:
|
||||
value = 0
|
||||
if thermal_opening_1.id != thermal_opening_2.id:
|
||||
value = thermal_opening_2.area / (total_area - thermal_opening_1.area)
|
||||
line += f'{value}, '
|
||||
content += f'{line}\n'
|
||||
text = open(fij_paths[i_tz], 'w')
|
||||
text.writelines(content)
|
||||
text.close()
|
||||
|
|
20
main.py
20
main.py
|
@ -24,7 +24,7 @@ full_path_gml = (example_path / 'tests' / 'tests_data' / name_gml).resolve()
|
|||
outputs_path = (example_path / 'tests' / 'tests_outputs').resolve()
|
||||
tmp_path = (example_path / 'tests' / 'tmp').resolve()
|
||||
weather_path = (Path(__file__).parent.parent / 'libs' / 'data' / 'weather').resolve()
|
||||
keep_files = False
|
||||
keep_files = True
|
||||
pickle_created = True
|
||||
pickle_file = 'tests/tests_data/one_building_in_kelowna.pickle'
|
||||
|
||||
|
@ -101,7 +101,7 @@ if not pickle_created:
|
|||
|
||||
for building in city.buildings:
|
||||
building.heated = True
|
||||
building.cooled = False
|
||||
building.cooled = True
|
||||
building.attic_heated = 2
|
||||
building.basement_heated = 0
|
||||
|
||||
|
@ -110,15 +110,21 @@ for building in city.buildings:
|
|||
full_path_out = (outputs_path / building.name).resolve()
|
||||
full_path_wea = (tmp_path / (building.name + '.weather')).resolve()
|
||||
full_path_ig = (tmp_path / (building.name + '.ig')).resolve()
|
||||
full_paths_fij = ['D:\Concordia\DynamicModel\DEBW522AA0000ce5f\FijFile_one_zoneRoom1.txt']
|
||||
full_paths_fij = []
|
||||
for i_tz in range(0, len(building.thermal_zones)):
|
||||
full_paths_fij.append((tmp_path / (building.name + '_' + str(i_tz) + '.fij')).resolve())
|
||||
|
||||
insel_file_name = building.name + '.insel'
|
||||
try:
|
||||
content = Templates.generate_thermal_dynamic_template(building, full_path_out, full_path_wea, full_path_ig,
|
||||
full_paths_fij, Sp)
|
||||
print(content)
|
||||
quit()
|
||||
template = Templates(building, full_path_out, full_path_wea, full_path_ig,
|
||||
full_paths_fij, Sp)
|
||||
content = template.generate_thermal_dynamic_template()
|
||||
template.generate_weather_file()
|
||||
template.generate_ig_file()
|
||||
template.generate_fij_files()
|
||||
print(insel_file_name)
|
||||
insel = Insel(example_path, insel_file_name, content, mode=2, keep_files=keep_files).results
|
||||
|
||||
except:
|
||||
print(sys.exc_info()[1])
|
||||
print('Building ' + building.name + ' could not be processed')
|
||||
|
|
4
tests/tmp/.gitignore
vendored
Normal file
4
tests/tmp/.gitignore
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
# Ignore everything in this directory
|
||||
*
|
||||
# Except this file
|
||||
!.gitignore
|
Loading…
Reference in New Issue
Block a user