From a3cfa895b9afc080611f4fd8b9a13f75aef95015 Mon Sep 17 00:00:00 2001 From: Eric Duminil <eric.duminil@gmail.com> Date: Mon, 8 Apr 2024 11:51:25 +0200 Subject: [PATCH] With plot --- .../variable_window_ratio.py | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/python_scripts/run_simstadt_from_python/variable_window_ratio.py b/python_scripts/run_simstadt_from_python/variable_window_ratio.py index 718b47a..e14d34e 100644 --- a/python_scripts/run_simstadt_from_python/variable_window_ratio.py +++ b/python_scripts/run_simstadt_from_python/variable_window_ratio.py @@ -2,6 +2,7 @@ from pathlib import Path import shutil from xml.etree import ElementTree as et import pandas as pd +import matplotlib.pyplot as plt from run_simstadt_workflow import find_simstadt, SCRIPT_DIR, run_workflow @@ -13,7 +14,7 @@ logging.getLogger().setLevel(logging.WARN) SIMSTADT2_GLOB = 'Desktop/SimStadt2_0.*/' REPO_PATH = Path.home() / 'git' / 'simstadt2' / 'TestRepository' PROJECT_NAME = 'Gruenbuehl' -CITYGMLS = ['Gruenbuehl_LOD2_ALKIS_1010.gml'] +CITYGML = 'Gruenbuehl_LOD2_ALKIS_1010.gml' SURFACES = ['outWalls', 'pitchedRoof'] WINDOW_RATIOS = [0, 0.5, 1] # Heat demand, with custom BuildingPhysics @@ -79,25 +80,36 @@ def parse_results(window_ratio, heat_demand_csv): decimal=',' ) - heat_demand_MWh = df['Yearly Heating demand'].sum() / 1000 - cool_demand_MWh = df['Yearly Cooling demand'].sum() / 1000 + heating_demand_MWh = df['Yearly Heating demand'].sum() / 1000 + cooling_demand_MWh = df['Yearly Cooling demand'].sum() / 1000 print(f"Window Ratio : {window_ratio * 100} %") - print(f"Total heating demand : {heat_demand_MWh:.0f} MWh / a") - print(f"Total cooling demand : {cool_demand_MWh:.0f} MWh / a") + print(f"Total heating demand : {heating_demand_MWh:.0f} MWh / a") + print(f"Total cooling demand : {cooling_demand_MWh:.0f} MWh / a") + return {'WindowRatio': window_ratio, + 'HeatingDemand': heating_demand_MWh, + 'CoolingDemand': cooling_demand_MWh} workflow_path, physics_processor_step = copy_workflow_from_template(TEMPLATE_NAME, PROJECT_PATH) custom_library_path = set_custom_library(physics_processor_step) lib_tree = parse_library(custom_library_path) +all_results = [] for window_ratio in WINDOW_RATIOS: # TODO: Status quo too set_custom_window_ratio(lib_tree, window_ratio, custom_library_path) - output_files = run_workflow(find_simstadt(SIMSTADT2_GLOB), workflow_path, CITYGMLS) + output_files = run_workflow(find_simstadt(SIMSTADT2_GLOB), workflow_path, [CITYGML]) heat_demand_csv = next(file for file in output_files if 'HEATING_AND_COOLING.csv' in file.name) ################### Parse heat demand ######################## - parse_results(window_ratio, heat_demand_csv) + all_results.append(parse_results(window_ratio, heat_demand_csv)) + +df = pd.DataFrame(all_results).set_index('WindowRatio') +print(df) +df.plot() +plt.ylabel('MWh') +plt.title("Demands depending on Window Ratio") +plt.show() -- GitLab