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
f9bcbc05
Commit
f9bcbc05
authored
Apr 05, 2024
by
Eric Duminil
Browse files
Trying to run with different window ratios
parent
54fc986f
Changes
1
Show whitespace changes
Inline
Side-by-side
python_scripts/run_simstadt_from_python/variable_window_ratio.py
View file @
f9bcbc05
from
pathlib
import
Path
import
shutil
from
xml.etree
import
ElementTree
as
et
import
logging
import
pandas
as
pd
import
re
from
run_simstadt_workflow
import
find_simstadt
,
SCRIPT_DIR
,
run_workflow
# logging.getLogger().setLevel(logging.WARN)
SIMSTADT2_GLOB
=
'Desktop/SimStadt2_0.*/'
REPO_PATH
=
Path
.
home
()
/
'git'
/
'simstadt2'
/
'TestRepository'
PROJECT_NAME
=
'Gruenbuehl'
...
...
@@ -15,7 +19,7 @@ PARAMS = 'params.xml'
BUILDING_PHYSICS_LIBRARY
=
'GermanBuildingTypologyLibrary_IWU.xml'
print
(
find_simstadt
(
SIMSTADT2_GLOB
))
WINDOW_RATIOS
=
[
0
,
0.5
,
1
]
TEMPLATE_NAME
=
'99_HeatDemand'
...
...
@@ -43,17 +47,36 @@ tree.write(physics_processor_params)
##########################################################
output_files
=
run_workflow
(
find_simstadt
(
SIMSTADT2_GLOB
),
workflow_path
,
CITYGMLS
)
for
window_ratio
in
WINDOW_RATIOS
:
#################### Update lib with custom values ############################
with
open
(
custom_library_path
)
as
library_file
:
content
=
library_file
.
read
()
new_content
=
re
.
sub
(
r
"<name>[\w ]+</name>"
,
f
"<name>Custom Physics Library with Window Ratio :
{
window_ratio
}
</name>"
,
content
,
1
)
new_content
=
re
.
sub
(
r
"<windowRatio>[\d\.]+</windowRatio>"
,
f
"<windowRatio>
{
window_ratio
}
</windowRatio>"
,
content
)
with
open
(
custom_library_path
,
'w'
)
as
library_file
:
library_file
.
write
(
new_content
)
#################################################################################
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
)
heat_demand_csv
=
next
(
file
for
file
in
output_files
if
'HEATING.csv'
in
file
.
name
)
################### Parse heat demand ########################
################### Parse heat demand ########################
df
=
pd
.
read_csv
(
heat_demand_csv
,
df
=
pd
.
read_csv
(
heat_demand_csv
,
skiprows
=
list
(
range
(
19
))
+
[
20
],
sep
=
';'
,
decimal
=
','
)
heat_demand_MWh
=
df
[
'Yearly Heating demand'
].
sum
()
/
1000
print
(
f
"Total heat demand :
{
heat_demand_MWh
:
.
0
f
}
MWh / a"
)
heat_demand_MWh
=
df
[
'Yearly Heating demand'
].
sum
()
/
1000
print
(
f
"Window Ratio :
{
window_ratio
*
100
}
%"
)
print
(
f
"Total heat demand :
{
heat_demand_MWh
:
.
0
f
}
MWh / a"
)
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