2022-05-16 09:35:19 -04:00
|
|
|
"""
|
|
|
|
Greenery in idf test
|
|
|
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
|
|
|
Copyright © 2022 Concordia CERC group
|
|
|
|
Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
|
|
|
"""
|
|
|
|
from pathlib import Path
|
|
|
|
import csv
|
2023-01-24 10:51:50 -05:00
|
|
|
import hub.helpers.constants as cte
|
2022-05-16 09:35:19 -04:00
|
|
|
from unittest import TestCase
|
2023-01-24 10:51:50 -05:00
|
|
|
from hub.imports.geometry_factory import GeometryFactory
|
|
|
|
from hub.imports.usage_factory import UsageFactory
|
|
|
|
from hub.imports.construction_factory import ConstructionFactory
|
2023-05-03 14:14:13 -04:00
|
|
|
from hub.imports.weather_factory import WeatherFactory
|
2023-01-24 10:51:50 -05:00
|
|
|
from hub.exports.energy_building_exports_factory import EnergyBuildingsExportsFactory
|
|
|
|
from hub.city_model_structure.greenery.vegetation import Vegetation
|
|
|
|
from hub.city_model_structure.greenery.soil import Soil
|
|
|
|
from hub.city_model_structure.greenery.plant import Plant
|
2022-05-16 09:35:19 -04:00
|
|
|
|
|
|
|
|
|
|
|
class GreeneryInIdf(TestCase):
|
|
|
|
"""
|
|
|
|
GreeneryInIdf TestCase 1
|
|
|
|
"""
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def test_greenery_in_idf():
|
2023-01-24 10:51:50 -05:00
|
|
|
city_file = "tests_data/one_building_in_kelowna.gml"
|
|
|
|
output_path = Path('tests_outputs/').resolve()
|
2022-05-16 09:35:19 -04:00
|
|
|
|
2022-11-21 13:53:58 -05:00
|
|
|
city = GeometryFactory('citygml', path=city_file).city
|
2022-05-16 09:35:19 -04:00
|
|
|
for building in city.buildings:
|
|
|
|
building.year_of_construction = 2006
|
|
|
|
ConstructionFactory('nrel', city).enrich()
|
|
|
|
UsageFactory('comnet', city).enrich()
|
2023-05-03 14:14:13 -04:00
|
|
|
WeatherFactory('epw', city, file_name='CAN_PQ_Montreal.Intl.AP.716270_CWEC.epw').enrich()
|
2022-05-16 09:35:19 -04:00
|
|
|
vegetation_name = 'BaseEco'
|
|
|
|
soil_thickness = 0.18
|
|
|
|
soil_name = 'EcoRoofSoil'
|
|
|
|
roughness = 'MediumSmooth'
|
|
|
|
dry_conductivity = 0.4
|
|
|
|
dry_density = 641
|
|
|
|
dry_specific_heat = 1100
|
|
|
|
thermal_absorptance = 0.95
|
|
|
|
solar_absorptance = 0.8
|
|
|
|
visible_absorptance = 0.7
|
|
|
|
saturation_volumetric_moisture_content = 0.4
|
|
|
|
residual_volumetric_moisture_content = 0.01
|
|
|
|
soil = Soil(soil_name, roughness, dry_conductivity, dry_density, dry_specific_heat, thermal_absorptance,
|
|
|
|
solar_absorptance, visible_absorptance, saturation_volumetric_moisture_content,
|
|
|
|
residual_volumetric_moisture_content)
|
|
|
|
soil.initial_volumetric_moisture_content = 0.2
|
|
|
|
plant_name = 'plant'
|
|
|
|
height = 0.5
|
|
|
|
leaf_area_index = 5
|
|
|
|
leaf_reflectivity = 0.2
|
|
|
|
leaf_emissivity = 0.95
|
|
|
|
minimal_stomatal_resistance = 180
|
|
|
|
co2_sequestration = 0
|
|
|
|
grows_on_soils = [soil]
|
|
|
|
plant = Plant(plant_name, height, leaf_area_index, leaf_reflectivity, leaf_emissivity, minimal_stomatal_resistance,
|
|
|
|
co2_sequestration, grows_on_soils)
|
|
|
|
plant.percentage = 1
|
|
|
|
plants = [plant]
|
|
|
|
vegetation = Vegetation(vegetation_name, soil, soil_thickness, plants)
|
|
|
|
for building in city.buildings:
|
2022-11-08 15:57:50 -05:00
|
|
|
for surface in building.surfaces:
|
|
|
|
if surface.type == cte.ROOF:
|
|
|
|
surface.vegetation = vegetation
|
2022-05-16 09:35:19 -04:00
|
|
|
|
2022-11-25 12:34:11 -05:00
|
|
|
_idf_2 = EnergyBuildingsExportsFactory('idf', city, output_path).export_debug()
|
2022-05-16 09:35:19 -04:00
|
|
|
_idf_2.run()
|
|
|
|
with open((output_path / f'{city.name}_out.csv').resolve()) as f:
|
|
|
|
reader = csv.reader(f, delimiter=',')
|
|
|
|
heating = 0
|
|
|
|
cooling = 0
|
|
|
|
for row in reader:
|
|
|
|
if '00:00' in row[0]:
|
|
|
|
heating += float(row[8]) / 3600000
|
|
|
|
cooling += float(row[9]) / 3600000
|
|
|
|
|
|
|
|
print('With greenery')
|
|
|
|
print(f'heating: {heating} MWh/yr, cooling: {cooling} MWh/yr')
|
|
|
|
|
2022-11-21 13:53:58 -05:00
|
|
|
city = GeometryFactory('citygml', path=city_file).city
|
2022-05-16 09:35:19 -04:00
|
|
|
for building in city.buildings:
|
|
|
|
building.year_of_construction = 2006
|
|
|
|
ConstructionFactory('nrel', city).enrich()
|
|
|
|
UsageFactory('comnet', city).enrich()
|
2023-05-03 14:14:13 -04:00
|
|
|
WeatherFactory('epw', city, file_name='CAN_PQ_Montreal.Intl.AP.716270_CWEC.epw').enrich()
|
2022-11-25 12:34:11 -05:00
|
|
|
_idf = EnergyBuildingsExportsFactory('idf', city, output_path).export()
|
2022-05-16 09:35:19 -04:00
|
|
|
_idf.run()
|
|
|
|
with open((output_path / f'{city.name}_out.csv').resolve()) as f:
|
|
|
|
reader = csv.reader(f, delimiter=',')
|
|
|
|
heating = 0
|
|
|
|
cooling = 0
|
|
|
|
for row in reader:
|
|
|
|
if '00:00' in row[0]:
|
|
|
|
heating += float(row[8]) / 3600000
|
|
|
|
cooling += float(row[9]) / 3600000
|
|
|
|
|
|
|
|
print('Without greenery')
|
|
|
|
print(f'heating: {heating} MWh/yr, cooling: {cooling} MWh/yr')
|