completed schedules and constructions in trnsys
This commit is contained in:
parent
39951a76a9
commit
a6f9425068
@ -111,7 +111,6 @@ class Trnsys:
|
||||
if layer.density is not None:
|
||||
density = layer.density
|
||||
|
||||
|
||||
layers[layer.material_name] = {
|
||||
'conductivity': conductivity,
|
||||
'capacity': capacity, # todo: transform units
|
||||
@ -120,8 +119,8 @@ class Trnsys:
|
||||
'penrt': '0'
|
||||
}
|
||||
f.write('PROPERTIES\n')
|
||||
for layer_name, values in layers.items():
|
||||
f.write(f'LAYER {layer_name.replace(" ", "_").upper()}\n')
|
||||
for name, values in layers.items():
|
||||
f.write(f'LAYER {name.replace(" ", "_").upper()}\n')
|
||||
for attribute, value in values.items():
|
||||
f.write(f'{attribute.upper()}=\t{value}\t')
|
||||
f.write('\n')
|
||||
@ -140,6 +139,22 @@ class Trnsys:
|
||||
f.write('MAX_ISHADE : any : max shading factor of internal shading\n')
|
||||
f.write('MAX_ESHADE : any : max shading factor of external shading\n')
|
||||
|
||||
@staticmethod
|
||||
def _add_schedule(f, schedule, name):
|
||||
if schedule.time_step is cte.HOUR:
|
||||
for day_type in schedule.day_types:
|
||||
f.write(f'{name} {day_type.upper()}\n')
|
||||
hours = 'HOURS= '
|
||||
values = 'VALUES= '
|
||||
previous = math.inf
|
||||
for hour, value in enumerate(schedule.values):
|
||||
if previous != value:
|
||||
hours = f'{hours} {hour}.000'
|
||||
values = f'{values} {value}'
|
||||
previous = value
|
||||
f.write(f'{hours} 24.0\n')
|
||||
f.write(f'{values} {schedule.values[0]}\n')
|
||||
|
||||
@staticmethod
|
||||
def _schedules(f, building):
|
||||
f.write('***************************************\n')
|
||||
@ -148,19 +163,39 @@ class Trnsys:
|
||||
for thermal_zone in building.thermal_zones_from_internal_zones:
|
||||
for usage in thermal_zone.usages:
|
||||
for schedule in usage.occupancy.occupancy_schedules:
|
||||
if schedule.time_step is cte.HOUR:
|
||||
for day_type in schedule.day_types:
|
||||
f.write(f'SCHEDULE {day_type.upper()}\n')
|
||||
hours = 'HOURS= '
|
||||
values = 'VALUES= '
|
||||
previous = math.inf
|
||||
for hour, value in enumerate(schedule.values):
|
||||
if previous != value:
|
||||
hours = f'{hours} {hour}.000'
|
||||
values = f'{values} {value}'
|
||||
previous = value
|
||||
f.write(f'{hours} 24.0\n')
|
||||
f.write(f'{values} {schedule.values[0]}\n')
|
||||
Trnsys._add_schedule(f, schedule, 'SCHEDULE OCCUPANCY')
|
||||
for schedule in usage.lighting.schedules:
|
||||
Trnsys._add_schedule(f, schedule, 'SCHEDULE LIGHTING ')
|
||||
|
||||
@staticmethod
|
||||
def _construction(f, building):
|
||||
f.write('***************************************\n')
|
||||
f.write(f'* Construction\n')
|
||||
f.write('***************************************\n')
|
||||
constructions = {}
|
||||
for thermal_zone in building.thermal_zones_from_internal_zones:
|
||||
for thermal_boundary in thermal_zone.thermal_boundaries:
|
||||
constructions[thermal_boundary.construction_name] = {
|
||||
'layers': '',
|
||||
'thickness': '',
|
||||
'absortance-front': thermal_boundary.layers[0].solar_absorptance,
|
||||
'absortance-back': thermal_boundary.layers[-1].solar_absorptance,
|
||||
'resistance-front': 1 - thermal_boundary.layers[0].thermal_absorptance,
|
||||
'resistance-back': 1 - thermal_boundary.layers[-1].thermal_absorptance,
|
||||
'he': thermal_boundary.he,
|
||||
'hi': thermal_boundary.hi
|
||||
}
|
||||
for layer in thermal_boundary.layers:
|
||||
constructions[thermal_boundary.construction_name]['layers'] = f'{constructions[thermal_boundary.construction_name]["layers"]} {layer.material_name.replace(" ", "_").upper()} '
|
||||
constructions[thermal_boundary.construction_name]['thickness'] = f'{constructions[thermal_boundary.construction_name]["thickness"]} {layer.thickness} '
|
||||
for name, values in constructions.items():
|
||||
f.write(f'CONSTRUCTION {name.replace(" ", "_").upper()}\n')
|
||||
f.write(f'LAYERS = {constructions[thermal_boundary.construction_name]["layers"]}\n')
|
||||
f.write(f'THICKNESS = {constructions[thermal_boundary.construction_name]["thickness"]}\n')
|
||||
f.write(f'ABS-FRONT = {constructions[thermal_boundary.construction_name]["absortance-front"]} : ABS-BACK = {constructions[thermal_boundary.construction_name]["absortance-back"]}\n')
|
||||
f.write(f'EPS-FRONT = {constructions[thermal_boundary.construction_name]["resistance-front"]} : EPS-BACK = {constructions[thermal_boundary.construction_name]["resistance-back"]}\n')
|
||||
f.write(f'HFRONT = {constructions[thermal_boundary.construction_name]["he"]} : HBACK = {constructions[thermal_boundary.construction_name]["hi"]}\n')
|
||||
f.write('\n')
|
||||
|
||||
def export(self):
|
||||
print("export")
|
||||
@ -173,5 +208,6 @@ class Trnsys:
|
||||
Trnsys._types(f, building)
|
||||
Trnsys._inputs(f)
|
||||
Trnsys._schedules(f, building)
|
||||
Trnsys._construction(f, building)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user