152 lines
6.2 KiB
Python
152 lines
6.2 KiB
Python
from pathlib import Path
|
|
from building_modelling.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 enrich_demand import enrich
|
|
import pandas as pd
|
|
|
|
# Directory management
|
|
input_files_path = (Path(__file__).parent / 'input_files')
|
|
input_files_path.mkdir(parents=True, exist_ok=True)
|
|
geojson_file_path = input_files_path / 'Lachine_Geojson_Mixed_Use.geojson'
|
|
output_path = (Path(__file__).parent / 'out_files').resolve()
|
|
output_path.mkdir(parents=True, exist_ok=True)
|
|
energy_plus_output_path = output_path / 'energy_plus_outputs'
|
|
energy_plus_output_path.mkdir(parents=True, exist_ok=True)
|
|
simulation_results_path = (Path(__file__).parent / 'out_files' / 'simulation_results').resolve()
|
|
simulation_results_path.mkdir(parents=True, exist_ok=True)
|
|
sra_output_path = output_path / 'sra_outputs'
|
|
sra_output_path.mkdir(parents=True, exist_ok=True)
|
|
cost_analysis_output_path = output_path / 'cost_analysis'
|
|
cost_analysis_output_path.mkdir(parents=True, exist_ok=True)
|
|
lachine_output_path = output_path / 'lachine_outputs'
|
|
|
|
# Create City from HUB to run EP_Workflow
|
|
city_ep_workflow = GeometryFactory(
|
|
file_type='geojson',
|
|
path=geojson_file_path,
|
|
height_field='maximum_roof_height',
|
|
year_of_construction_field='year_built',
|
|
function_field='building_type',
|
|
function_to_hub=Dictionaries().montreal_function_to_hub_function
|
|
).city
|
|
|
|
ConstructionFactory('nrcan', city_ep_workflow).enrich()
|
|
UsageFactory('nrcan', city_ep_workflow).enrich()
|
|
WeatherFactory('epw', city_ep_workflow).enrich()
|
|
energy_plus_workflow(city_ep_workflow, energy_plus_output_path)
|
|
|
|
# Create City from HUB to use Grasshopper results
|
|
city_grasshopper = GeometryFactory(
|
|
file_type='geojson',
|
|
path=geojson_file_path,
|
|
height_field='maximum_roof_height',
|
|
year_of_construction_field='year_built',
|
|
function_field='building_type',
|
|
function_to_hub=Dictionaries().montreal_function_to_hub_function
|
|
).city
|
|
|
|
ConstructionFactory('nrcan', city_grasshopper).enrich()
|
|
UsageFactory('nrcan', city_grasshopper).enrich()
|
|
WeatherFactory('epw', city_grasshopper).enrich()
|
|
|
|
enrich(city_grasshopper)
|
|
|
|
# Collect data from city_ep_workflow
|
|
ep_building_data = []
|
|
|
|
for building in city_ep_workflow.buildings:
|
|
building_name = building.name
|
|
|
|
# Get total floor area
|
|
total_floor_area = 0
|
|
for zone in building.thermal_zones_from_internal_zones:
|
|
total_floor_area += zone.total_floor_area # Assuming area is in m^2
|
|
|
|
# Get yearly heating demand in Joules
|
|
yearly_heating_demand_J = building.heating_demand['year'][0] # Should be a single value
|
|
# Convert to kWh
|
|
yearly_heating_demand_kWh = yearly_heating_demand_J / 3.6e6
|
|
# Compute heating demand intensity (kWh/m²)
|
|
heating_demand_intensity = yearly_heating_demand_kWh / total_floor_area if total_floor_area > 0 else 0
|
|
|
|
# Get yearly cooling demand in Joules
|
|
yearly_cooling_demand_J = building.cooling_demand['year'][0] # Should be a single value
|
|
# Convert to kWh
|
|
yearly_cooling_demand_kWh = yearly_cooling_demand_J / 3.6e6
|
|
# Compute cooling demand intensity (kWh/m²)
|
|
cooling_demand_intensity = yearly_cooling_demand_kWh / total_floor_area if total_floor_area > 0 else 0
|
|
|
|
# Append data to list
|
|
ep_building_data.append({
|
|
'Building Name': building_name,
|
|
'Yearly Heating Demand EP (kWh)': yearly_heating_demand_kWh,
|
|
'Demand Intensity Heating EP (kWh/m²)': heating_demand_intensity,
|
|
'Yearly Cooling Demand EP (kWh)': yearly_cooling_demand_kWh,
|
|
'Demand Intensity Cooling EP (kWh/m²)': cooling_demand_intensity,
|
|
'Total Floor Area (m²)': total_floor_area
|
|
})
|
|
|
|
# Collect data from city_grasshopper
|
|
grasshopper_building_data = []
|
|
|
|
for building in city_grasshopper.buildings:
|
|
building_name = building.name
|
|
|
|
# Get total floor area
|
|
total_floor_area = 0
|
|
for zone in building.thermal_zones_from_internal_zones:
|
|
total_floor_area += zone.total_floor_area # Assuming area is in m^2
|
|
|
|
# Get yearly heating demand in Joules
|
|
yearly_heating_demand_J = building.heating_demand['year'][0] # Should be a single value
|
|
# Convert to kWh
|
|
yearly_heating_demand_kWh = yearly_heating_demand_J / 3.6e6
|
|
# Compute heating demand intensity (kWh/m²)
|
|
heating_demand_intensity = yearly_heating_demand_kWh / total_floor_area if total_floor_area > 0 else 0
|
|
|
|
# Get yearly cooling demand in Joules
|
|
yearly_cooling_demand_J = building.cooling_demand['year'][0] # Should be a single value
|
|
# Convert to kWh
|
|
yearly_cooling_demand_kWh = yearly_cooling_demand_J / 3.6e6
|
|
# Compute cooling demand intensity (kWh/m²)
|
|
cooling_demand_intensity = yearly_cooling_demand_kWh / total_floor_area if total_floor_area > 0 else 0
|
|
|
|
# Append data to list
|
|
grasshopper_building_data.append({
|
|
'Building Name': building_name,
|
|
'Yearly Heating Demand Grasshopper (kWh)': yearly_heating_demand_kWh,
|
|
'Demand Intensity Heating Grasshopper (kWh/m²)': heating_demand_intensity,
|
|
'Yearly Cooling Demand Grasshopper (kWh)': yearly_cooling_demand_kWh,
|
|
'Demand Intensity Cooling Grasshopper (kWh/m²)': cooling_demand_intensity
|
|
})
|
|
|
|
# Create DataFrames
|
|
ep_df = pd.DataFrame(ep_building_data)
|
|
grasshopper_df = pd.DataFrame(grasshopper_building_data)
|
|
|
|
# Merge DataFrames on 'Building Name' and 'Total Floor Area (m²)'
|
|
# Since Total Floor Area should be the same for both, we can use it from ep_df
|
|
merged_df = pd.merge(ep_df, grasshopper_df, on='Building Name')
|
|
|
|
# Rearrange columns if needed
|
|
merged_df = merged_df[[
|
|
'Building Name',
|
|
'Yearly Heating Demand EP (kWh)',
|
|
'Demand Intensity Heating EP (kWh/m²)',
|
|
'Yearly Cooling Demand EP (kWh)',
|
|
'Demand Intensity Cooling EP (kWh/m²)',
|
|
'Yearly Heating Demand Grasshopper (kWh)',
|
|
'Demand Intensity Heating Grasshopper (kWh/m²)',
|
|
'Yearly Cooling Demand Grasshopper (kWh)',
|
|
'Demand Intensity Cooling Grasshopper (kWh/m²)',
|
|
'Total Floor Area (m²)'
|
|
]]
|
|
|
|
# Write to Excel
|
|
output_excel_path = lachine_output_path / 'building_heating_cooling_demands.xlsx'
|
|
merged_df.to_excel(output_excel_path, index=False)
|