""" 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 import helpers.constants as cte from unittest import TestCase from imports.geometry_factory import GeometryFactory from imports.usage_factory import UsageFactory from imports.construction_factory import ConstructionFactory from exports.energy_building_exports_factory import EnergyBuildingsExportsFactory from city_model_structure.greenery.vegetation import Vegetation from city_model_structure.greenery.soil import Soil from city_model_structure.greenery.plant import Plant class GreeneryInIdf(TestCase): """ GreeneryInIdf TestCase 1 """ @staticmethod def test_greenery_in_idf(): city_file = "../unittests/tests_data/one_building_in_kelowna.gml" output_path = Path('../unittests/tests_outputs/').resolve() city = GeometryFactory('citygml', path=city_file).city for building in city.buildings: building.year_of_construction = 2006 ConstructionFactory('nrel', city).enrich() UsageFactory('comnet', city).enrich() 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: for surface in building.surfaces: if surface.type == cte.ROOF: surface.vegetation = vegetation _idf_2 = EnergyBuildingsExportsFactory('idf', city, output_path).export_debug() _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') city = GeometryFactory('citygml', path=city_file).city for building in city.buildings: building.year_of_construction = 2006 ConstructionFactory('nrel', city).enrich() UsageFactory('comnet', city).enrich() _idf = EnergyBuildingsExportsFactory('idf', city, output_path).export() _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')