Commit 54fc986f authored by Eric Duminil's avatar Eric Duminil
Browse files

Parse heat demand

parent ef7eb0dc
from pathlib import Path from pathlib import Path
import shutil import shutil
from run_simstadt_workflow import find_simstadt, check_paths, SCRIPT_DIR, prepare_workflow, run_workflow from xml.etree import ElementTree as et
import pandas as pd
from run_simstadt_workflow import find_simstadt, SCRIPT_DIR, run_workflow
SIMSTADT2_GLOB = 'Desktop/SimStadt2_0.*/' SIMSTADT2_GLOB = 'Desktop/SimStadt2_0.*/'
REPO_PATH = Path.home() / 'git' / 'simstadt2' / 'TestRepository' REPO_PATH = Path.home() / 'git' / 'simstadt2' / 'TestRepository'
PROJECT_NAME = 'Gruenbuehl' PROJECT_NAME = 'Gruenbuehl'
CITYGMLS = ['Gruenbuehl_LOD2_ALKIS_1010_2buildings.gml'] CITYGMLS = ['Gruenbuehl_LOD2_ALKIS_1010.gml']
PROJECT_PATH = REPO_PATH / f'{PROJECT_NAME}.proj' PROJECT_PATH = REPO_PATH / f'{PROJECT_NAME}.proj'
PARAMS = 'params.xml' PARAMS = 'params.xml'
BUILDING_PHYSICS_LIBRARY = 'GermanBuildingTypologyLibrary_IWU.xml'
print(find_simstadt(SIMSTADT2_GLOB)) print(find_simstadt(SIMSTADT2_GLOB))
TEMPLATE_NAME = '99_HeatDemand' TEMPLATE_NAME = '99_HeatDemand'
TEMPLATE = SCRIPT_DIR / 'Template' / f'{TEMPLATE_NAME}.flow' # Heat demand, with custom BuildingPhysics template = SCRIPT_DIR / 'Template' / f'{TEMPLATE_NAME}.flow' # Heat demand, with custom BuildingPhysics
workflow_path = PROJECT_PATH / f'{TEMPLATE_NAME}.flow'
shutil.copytree(template, workflow_path, dirs_exist_ok=True)
print(workflow_path)
physics_processor_step = workflow_path / '01_Preprocessing.step/02_PhysicsPreprocessor.step'
############# Specify custom lib #########################
custom_library_path = physics_processor_step / BUILDING_PHYSICS_LIBRARY
physics_processor_params = physics_processor_step / PARAMS
WORKFLOW_PATH = PROJECT_PATH / f'{TEMPLATE_NAME}.flow' tree = et.parse(physics_processor_params)
root = tree.getroot()
shutil.copytree(TEMPLATE, WORKFLOW_PATH, dirs_exist_ok=True) lib_node = root.find(".//object[@class='de.hft.stuttgart.simstadt2.assessment.PhysicsXmlLib']/void[@property='path']/string")
lib_node.text = str(custom_library_path)
tree.write(physics_processor_params)
##########################################################
output_files = run_workflow(find_simstadt(SIMSTADT2_GLOB), workflow_path, CITYGMLS)
heat_demand_csv = next(file for file in output_files if 'HEATING.csv' in file.name)
################### Parse heat demand ########################
output_files = run_workflow(find_simstadt(SIMSTADT2_GLOB), WORKFLOW_PATH, CITYGMLS) df = pd.read_csv(heat_demand_csv,
skiprows=list(range(19)) + [20],
sep=';',
decimal=','
)
print(next(file for file in output_files if 'HEATING.csv' in file.name)) heat_demand_MWh = df['Yearly Heating demand'].sum() / 1000
print(f"Total heat demand : {heat_demand_MWh:.0f} MWh / a")
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment