Compare commits

...

2 Commits
main ... sra

Author SHA1 Message Date
04e029d4a0 feat: SRA finalized
The "beam" attribute in "CityObject" class is renamed to "direct_normal" and new attribute named "beam" is created. SRA inputs are fixed
2024-05-15 09:20:10 -04:00
b865708629 feat: code is prepared to store the roof radiation and its components in a csv file 2024-05-14 12:17:35 -04:00
7 changed files with 54 additions and 42 deletions

View File

@ -41,9 +41,11 @@ class CityObject:
self._ground_temperature = {}
self._global_horizontal = {}
self._diffuse = {}
self._beam = {}
self._direct_normal = {}
self._sensors = []
self._neighbours = None
self._beam = {}
@property
def level_of_detail(self) -> LevelOfDetail:
@ -238,20 +240,20 @@ class CityObject:
self._diffuse = value
@property
def beam(self) -> dict:
def direct_normal(self) -> dict:
"""
Get beam radiation surrounding the city object in J/m2
Get direct normal radiation surrounding the city object in J/m2
:return: dict{dict{[float]}}
"""
return self._beam
return self._direct_normal
@beam.setter
def beam(self, value):
@direct_normal.setter
def direct_normal(self, value):
"""
Set beam radiation surrounding the city object in J/m2
Set direct normal radiation surrounding the city object in J/m2
:param value: dict{dict{[float]}}
"""
self._beam = value
self._direct_normal = value
@property
def lower_corner(self):
@ -302,3 +304,19 @@ class CityObject:
Set the list of neighbour_objects and their properties associated to the current city_object
"""
self._neighbours = value
@property
def beam(self) -> dict:
"""
Get beam radiation surrounding the city object in J/m2
:return: dict{dict{[float]}}
"""
return self._beam
@beam.setter
def beam(self, value):
"""
Set beam radiation surrounding the city object in J/m2
:param value: dict{dict{[float]}}
"""
self._beam = value

View File

@ -67,7 +67,7 @@ class SimplifiedRadiosityAlgorithm:
i = (total_days + day - 1) * 24 + hour - 1
representative_building = self._city.buildings[0]
_global = representative_building.diffuse[cte.HOUR][i] / cte.WATTS_HOUR_TO_JULES
_beam = representative_building.beam[cte.HOUR][i] / cte.WATTS_HOUR_TO_JULES
_beam = representative_building.direct_normal[cte.HOUR][i] / cte.WATTS_HOUR_TO_JULES
content += f'{day} {month} {hour} {_global} {_beam}\n'
with open(file, 'w', encoding='utf-8') as file:
file.write(content)

View File

@ -114,8 +114,10 @@ class EpwWeatherParameters:
for x in self._weather_values['global_horizontal_radiation_wh_m2']]
building.diffuse[cte.HOUR] = [x * cte.WATTS_HOUR_TO_JULES
for x in self._weather_values['diffuse_horizontal_radiation_wh_m2']]
building.beam[cte.HOUR] = [x * cte.WATTS_HOUR_TO_JULES
for x in self._weather_values['direct_normal_radiation_wh_m2']]
building.direct_normal[cte.HOUR] = [x * cte.WATTS_HOUR_TO_JULES
for x in self._weather_values['direct_normal_radiation_wh_m2']]
building.beam[cte.HOUR] = [building.global_horizontal[cte.HOUR][i] - building.diffuse[cte.HOUR][i]
for i in range(len(building.global_horizontal[cte.HOUR]))]
building.cold_water_temperature[cte.HOUR] = wh().cold_water_temperature(building.external_temperature[cte.HOUR])
# create the monthly and yearly values out of the hourly

48
main.py
View File

@ -1,24 +1,18 @@
import csv
from scripts.geojson_creator import process_geojson
from pathlib import Path
import subprocess
from scripts.ep_run_enrich import energy_plus_workflow
from hub.imports.geometry_factory import GeometryFactory
from hub.helpers.dictionaries import Dictionaries
from hub.imports.construction_factory import ConstructionFactory
from hub.imports.usage_factory import UsageFactory
from hub.imports.weather_factory import WeatherFactory
from hub.imports.results_factory import ResultFactory
from scripts.energy_system_analysis_report import EnergySystemAnalysisReport
from scripts import random_assignation
from hub.imports.energy_systems_factory import EnergySystemsFactory
from scripts.energy_system_sizing import SystemSizing
from scripts.energy_system_retrofit_results import system_results, new_system_results
from scripts.energy_system_sizing_and_simulation_factory import EnergySystemsSimulationFactory
from scripts.costs.cost import Cost
from scripts.costs.constants import SKIN_RETROFIT_AND_SYSTEM_RETROFIT_AND_PV
from hub.exports.exports_factory import ExportsFactory
import hub.helpers.constants as cte
# Specify the GeoJSON file path
geojson_file = process_geojson(x=-73.5681295982132, y=45.49218262677643, diff=0.0001)
geojson_file = process_geojson(x=-73.58006429386116, y=45.49642202402885, diff=0.0001)
file_path = (Path(__file__).parent.parent / 'input_files' / f'{geojson_file}')
# Specify the output path for the PDF file
output_path = (Path(__file__).parent / 'out_files').resolve()
@ -34,29 +28,27 @@ ConstructionFactory('nrcan', city).enrich()
UsageFactory('nrcan', city).enrich()
WeatherFactory('epw', city).enrich()
print('test')
ExportsFactory('sra', city, output_path).export()
sra_path = (output_path / f'{city.name}_sra.xml').resolve()
subprocess.run(['sra', str(sra_path)])
ResultFactory('sra', city, output_path).enrich()
energy_plus_workflow(city)
ExportsFactory('obj', city, output_path).export()
random_assignation.call_random(city.buildings, random_assignation.residential_systems_percentage)
EnergySystemsFactory('montreal_custom', city).enrich()
SystemSizing(city.buildings).montreal_custom()
current_system = new_system_results(city.buildings)
random_assignation.call_random(city.buildings, random_assignation.residential_new_systems_percentage)
EnergySystemsFactory('montreal_future', city).enrich()
print('test')
for building in city.buildings:
EnergySystemsSimulationFactory('archetype1', building=building, output_path=output_path).enrich()
new_system = system_results(city.buildings)
EnergySystemAnalysisReport(city, output_path).create_report(current_system, new_system)
for building in city.buildings:
costs = Cost(building=building, retrofit_scenario=SKIN_RETROFIT_AND_SYSTEM_RETROFIT_AND_PV).life_cycle
costs.to_csv(output_path / f'{building.name}_lcc.csv')
(costs.loc['global_operational_costs', f'Scenario {SKIN_RETROFIT_AND_SYSTEM_RETROFIT_AND_PV}'].
to_csv(output_path / f'{building.name}_op.csv'))
costs.loc['global_capital_costs', f'Scenario {SKIN_RETROFIT_AND_SYSTEM_RETROFIT_AND_PV}'].to_csv(
output_path / f'{building.name}_cc.csv')
direct_normal = [x / 3600 for x in building.direct_normal[cte.HOUR]]
beam = [x / 3600 for x in building.beam[cte.HOUR]]
diffuse = [x / 3600 for x in building.diffuse[cte.HOUR]]
global_radiation = [x / 3600 for x in building.global_horizontal[cte.HOUR]]
roof = building.roofs[0].global_irradiance[cte.HOUR]
data = list(zip(direct_normal, beam, diffuse, global_radiation, roof))
file_name = f'solar_radiation_{building.name}.csv'
with open(output_path / file_name, 'w', newline='') as csvfile:
output_file = csv.writer(csvfile)
# Write header
output_file.writerow(['direct_normal', 'beam_component', 'diffuse_component', 'global', 'roof_global_irradiance'])
# Write data
output_file.writerows(data)

View File

@ -81,7 +81,7 @@ class TestConstructionFactory(TestCase):
self.assertEqual(len(building.external_temperature), 0, 'building external temperature is calculated')
self.assertEqual(len(building.global_horizontal), 0, 'building global horizontal is calculated')
self.assertEqual(len(building.diffuse), 0, 'building diffuse is calculated')
self.assertEqual(len(building.beam), 0, 'building beam is calculated')
self.assertEqual(len(building.direct_normal), 0, 'building beam is calculated')
self.assertIsNotNone(building.lower_corner, 'building lower corner is none')
self.assertEqual(len(building.sensors), 0, 'building sensors are assigned')
self.assertIsNotNone(building.internal_zones, 'no internal zones created')

View File

@ -52,7 +52,7 @@ class TestGeometryFactory(TestCase):
self.assertEqual(len(building.external_temperature), 0, 'building external temperature is calculated')
self.assertEqual(len(building.global_horizontal), 0, 'building global horizontal is calculated')
self.assertEqual(len(building.diffuse), 0, 'building diffuse is calculated')
self.assertEqual(len(building.beam), 0, 'building beam is calculated')
self.assertEqual(len(building.direct_normal), 0, 'building beam is calculated')
self.assertIsNotNone(building.lower_corner, 'building lower corner is none')
self.assertEqual(len(building.sensors), 0, 'building sensors are assigned')
self.assertIsNotNone(building.internal_zones, 'no internal zones created')

View File

@ -44,7 +44,7 @@ class TestUsageFactory(TestCase):
self.assertEqual(len(building.external_temperature), 0, 'building external temperature is calculated')
self.assertEqual(len(building.global_horizontal), 0, 'building global horizontal is calculated')
self.assertEqual(len(building.diffuse), 0, 'building diffuse is calculated')
self.assertEqual(len(building.beam), 0, 'building beam is calculated')
self.assertEqual(len(building.direct_normal), 0, 'building beam is calculated')
self.assertIsNotNone(building.lower_corner, 'building lower corner is none')
self.assertEqual(len(building.sensors), 0, 'building sensors are assigned')
self.assertIsNotNone(building.internal_zones, 'no internal zones created')