hub/pv_generation.py

67 lines
2.9 KiB
Python
Raw Normal View History

from hub.imports.energy_systems_factory import EnergySystemsFactory
from hub.imports.geometry_factory import GeometryFactory
from hub.helpers.dictionaries import Dictionaries
from hub.imports.construction_factory import ConstructionFactory
from hub.imports.results_factory import ResultFactory
from hub.exports.exports_factory import ExportsFactory
from hub.imports.weather_factory import WeatherFactory
from pv_assessment.solar_calculator import SolarCalculator
from pv_assessment.pv_system_assessment_without_consumption import PvSystemProduction
from scripts import random_assignation
import subprocess
from pathlib import Path
input_file = "data/selected_buildings.geojson"
output_path = (Path(__file__).parent.parent / 'hub / out_files').resolve()
output_path.mkdir(parents=True, exist_ok=True)
sra_output_path = output_path / 'sra_outputs'
sra_output_path.mkdir(parents=True, exist_ok=True)
pv_assessment_path = output_path / 'pv_outputs'
pv_assessment_path.mkdir(parents=True, exist_ok=True)
city = GeometryFactory(
"geojson",
input_file,
height_field="height",
year_of_construction_field="contr_year",
function_field="function_c",
adjacency_field="adjacency",
lot_area_field='lot_area',
build_area_field='build_area',
function_to_hub=Dictionaries().montreal_function_to_hub_function).city
ConstructionFactory('nrcan', city).enrich()
WeatherFactory('epw', city).enrich()
ExportsFactory('sra', city, sra_output_path).export()
sra_path = (sra_output_path / f'{city.name}_sra.xml').resolve()
subprocess.run(['sra', str(sra_path)])
ResultFactory('sra', city, sra_output_path).enrich()
tilt_angle = 37
solar_parameters = SolarCalculator(city=city,
surface_azimuth_angle=180,
tilt_angle=tilt_angle,
standard_meridian=-75)
solar_angles = solar_parameters.solar_angles
solar_parameters.tilted_irradiance_calculator()
random_assignation.call_random(city.buildings, random_assignation.residential_systems_percentage)
EnergySystemsFactory('montreal_future', city).enrich()
for building in city.buildings:
PvSystemProduction(building=building,
pv_system=None,
battery=None,
tilt_angle=tilt_angle,
solar_angles=solar_angles,
pv_installation_type='rooftop',
simulation_model_type='explicit',
module_model_name=None,
inverter_efficiency=0.95,
system_catalogue_handler=None,
roof_percentage_coverage=0.75,
facade_coverage_percentage=0,
csv_output=False,
output_path=pv_assessment_path).enrich()
print("simulation done")