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
54fc986f
Commit
54fc986f
authored
Apr 05, 2024
by
Eric Duminil
Browse files
Parse heat demand
parent
ef7eb0dc
Changes
1
Hide whitespace changes
Inline
Side-by-side
python_scripts/run_simstadt_from_python/variable_window_ratio.py
View file @
54fc986f
from
pathlib
import
Path
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.*/'
REPO_PATH
=
Path
.
home
()
/
'git'
/
'simstadt2'
/
'TestRepository'
PROJECT_NAME
=
'Gruenbuehl'
CITYGMLS
=
[
'Gruenbuehl_LOD2_ALKIS_1010
_2buildings
.gml'
]
CITYGMLS
=
[
'Gruenbuehl_LOD2_ALKIS_1010.gml'
]
PROJECT_PATH
=
REPO_PATH
/
f
'
{
PROJECT_NAME
}
.proj'
PARAMS
=
'params.xml'
BUILDING_PHYSICS_LIBRARY
=
'GermanBuildingTypologyLibrary_IWU.xml'
print
(
find_simstadt
(
SIMSTADT2_GLOB
))
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
:
.
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