Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Mayer
CircularGreenSimCity
Commits
a3cfa895
Commit
a3cfa895
authored
Apr 08, 2024
by
Eric Duminil
Browse files
With plot
parent
63ab5d0a
Changes
1
Show whitespace changes
Inline
Side-by-side
python_scripts/run_simstadt_from_python/variable_window_ratio.py
View file @
a3cfa895
...
@@ -2,6 +2,7 @@ from pathlib import Path
...
@@ -2,6 +2,7 @@ from pathlib import Path
import
shutil
import
shutil
from
xml.etree
import
ElementTree
as
et
from
xml.etree
import
ElementTree
as
et
import
pandas
as
pd
import
pandas
as
pd
import
matplotlib.pyplot
as
plt
from
run_simstadt_workflow
import
find_simstadt
,
SCRIPT_DIR
,
run_workflow
from
run_simstadt_workflow
import
find_simstadt
,
SCRIPT_DIR
,
run_workflow
...
@@ -13,7 +14,7 @@ logging.getLogger().setLevel(logging.WARN)
...
@@ -13,7 +14,7 @@ logging.getLogger().setLevel(logging.WARN)
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'
CITYGML
S
=
[
'Gruenbuehl_LOD2_ALKIS_1010.gml'
]
CITYGML
=
'Gruenbuehl_LOD2_ALKIS_1010.gml'
SURFACES
=
[
'outWalls'
,
'pitchedRoof'
]
SURFACES
=
[
'outWalls'
,
'pitchedRoof'
]
WINDOW_RATIOS
=
[
0
,
0.5
,
1
]
WINDOW_RATIOS
=
[
0
,
0.5
,
1
]
# Heat demand, with custom BuildingPhysics
# Heat demand, with custom BuildingPhysics
...
@@ -79,25 +80,36 @@ def parse_results(window_ratio, heat_demand_csv):
...
@@ -79,25 +80,36 @@ def parse_results(window_ratio, heat_demand_csv):
decimal
=
','
decimal
=
','
)
)
heat_demand_MWh
=
df
[
'Yearly Heating demand'
].
sum
()
/
1000
heat
ing
_demand_MWh
=
df
[
'Yearly Heating demand'
].
sum
()
/
1000
cool_demand_MWh
=
df
[
'Yearly Cooling demand'
].
sum
()
/
1000
cool
ing
_demand_MWh
=
df
[
'Yearly Cooling demand'
].
sum
()
/
1000
print
(
f
"Window Ratio :
{
window_ratio
*
100
}
%"
)
print
(
f
"Window Ratio :
{
window_ratio
*
100
}
%"
)
print
(
f
"Total heating demand :
{
heat_demand_MWh
:
.
0
f
}
MWh / a"
)
print
(
f
"Total heating demand :
{
heating_demand_MWh
:
.
0
f
}
MWh / a"
)
print
(
f
"Total cooling demand :
{
cool_demand_MWh
:
.
0
f
}
MWh / a"
)
print
(
f
"Total cooling demand :
{
cooling_demand_MWh
:
.
0
f
}
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
)
workflow_path
,
physics_processor_step
=
copy_workflow_from_template
(
TEMPLATE_NAME
,
PROJECT_PATH
)
custom_library_path
=
set_custom_library
(
physics_processor_step
)
custom_library_path
=
set_custom_library
(
physics_processor_step
)
lib_tree
=
parse_library
(
custom_library_path
)
lib_tree
=
parse_library
(
custom_library_path
)
all_results
=
[]
for
window_ratio
in
WINDOW_RATIOS
:
for
window_ratio
in
WINDOW_RATIOS
:
# TODO: Status quo too
# TODO: Status quo too
set_custom_window_ratio
(
lib_tree
,
window_ratio
,
custom_library_path
)
set_custom_window_ratio
(
lib_tree
,
window_ratio
,
custom_library_path
)
output_files
=
run_workflow
(
find_simstadt
(
SIMSTADT2_GLOB
),
workflow_path
,
CITYGML
S
)
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
)
heat_demand_csv
=
next
(
file
for
file
in
output_files
if
'HEATING_AND_COOLING.csv'
in
file
.
name
)
################### Parse heat demand ########################
################### 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
()
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment