Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
SimStadt
simstadtpy
Commits
14952505
Commit
14952505
authored
Mar 13, 2026
by
Eric Duminil
Browse files
Adding bundled templates
parent
e07fb2e3
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/simstadt/workflows.py
View file @
14952505
...
...
@@ -12,6 +12,8 @@ from .results import SimStadtResults
from
.runner
import
run_workflow_with_citygml
from
.utils
import
remove_random_id
,
set_random_seed
BUNDLED_TEMPLATES
=
Path
(
__file__
).
parent
/
"templates"
def
_set_weather_file
(
meteonorm_filename
:
str
)
->
dict
[
str
,
str
]:
"""Build the params.xml replacement for the weather file."""
...
...
@@ -39,6 +41,7 @@ def photovoltaic_simulation(
hourly_pv
:
bool
=
False
,
with_shadows
:
bool
=
True
,
description
:
str
=
"Photovoltaic"
,
project_path
:
Path
|
None
=
None
,
)
->
SimStadtResults
:
"""Run a PhotovoltaicPotential workflow.
...
...
@@ -60,8 +63,8 @@ def photovoltaic_simulation(
"<int>MIN_ROOF_INSOLATION</int>"
:
f
"<int>
{
min_roof_insolation
}
</int>"
,
"<boolean>HOURLY_PV</boolean>"
:
f
"<boolean>
{
str
(
hourly_pv
).
lower
()
}
</boolean>"
,
}
template
=
"105_PVWithShadow"
if
with_shadows
else
"103_PV"
pv_results
=
run_workflow_with_citygml
(
template
,
citygml_path
,
replaces
=
replaces
,
description
=
description
)
template
=
BUNDLED_TEMPLATES
/
(
"105_PVWithShadow"
if
with_shadows
else
"103_PV"
)
pv_results
=
run_workflow_with_citygml
(
template
,
citygml_path
,
replaces
=
replaces
,
description
=
description
,
project_path
=
project_path
)
set_random_seed
(
remove_random_id
(
citygml_path
.
name
))
pv_results
.
_df
=
pv_results
.
dataframe
.
sample
(
frac
=
roof_percentage
/
100.0
)
...
...
@@ -75,6 +78,7 @@ def heatdemand_simulation(
calculation_mode
:
str
=
"HEATING"
,
refurbishment_ratio
:
float
=
0.0
,
description
:
str
=
"Heat demand"
,
project_path
:
Path
|
None
=
None
,
)
->
SimStadtResults
:
"""Run a HeatDemand workflow.
...
...
@@ -87,13 +91,13 @@ def heatdemand_simulation(
description: Label stored on the result object.
"""
citygml_path
=
Path
(
citygml_path
)
template
=
"104_HeatDemandWithShadow"
if
with_shadows
else
"101_HeatDemand"
template
=
BUNDLED_TEMPLATES
/
(
"104_HeatDemandWithShadow"
if
with_shadows
else
"101_HeatDemand"
)
replaces
=
(
_set_weather_file
(
meteonorm_filename
)
|
_set_calculation_mode
(
calculation_mode
)
|
_set_refurbishment
(
refurbishment_ratio
)
)
return
run_workflow_with_citygml
(
template
,
citygml_path
,
replaces
=
replaces
,
description
=
description
)
return
run_workflow_with_citygml
(
template
,
citygml_path
,
replaces
=
replaces
,
description
=
description
,
project_path
=
project_path
)
def
greenwater_simulation
(
...
...
@@ -101,6 +105,7 @@ def greenwater_simulation(
meteonorm_filename
:
str
,
irrigation_ratio
:
float
,
description
:
str
=
"Green water"
,
project_path
:
Path
|
None
=
None
,
)
->
SimStadtResults
:
"""Run a GreenWater workflow.
...
...
@@ -114,4 +119,4 @@ def greenwater_simulation(
replaces
=
_set_weather_file
(
meteonorm_filename
)
|
{
"<double>MAX_WATER_STRESS</double>"
:
f
"<double>
{
1
-
irrigation_ratio
}
</double>"
,
}
return
run_workflow_with_citygml
(
"102_GreenWater"
,
citygml_path
,
replaces
=
replaces
,
description
=
description
)
return
run_workflow_with_citygml
(
BUNDLED_TEMPLATES
/
"102_GreenWater"
,
citygml_path
,
replaces
=
replaces
,
description
=
description
,
project_path
=
project_path
)
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