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
0473e661
You need to sign in or sign up before continuing.
Commit
0473e661
authored
Mar 13, 2026
by
Eric Duminil
Browse files
Formatting
parent
eb959ebe
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/test_workflows.py
View file @
0473e661
...
@@ -4,7 +4,11 @@ from pathlib import Path
...
@@ -4,7 +4,11 @@ from pathlib import Path
import
pytest
import
pytest
from
simstadt
import
greenwater_simulation
,
heatdemand_simulation
,
photovoltaic_simulation
from
simstadt
import
(
greenwater_simulation
,
heatdemand_simulation
,
photovoltaic_simulation
,
)
from
simstadt.results
import
KPI
from
simstadt.results
import
KPI
TEST_REPOSITORY
=
Path
(
__file__
).
parent
/
"data"
/
"TestRepo"
TEST_REPOSITORY
=
Path
(
__file__
).
parent
/
"data"
/
"TestRepo"
...
@@ -21,8 +25,13 @@ def to_dict(values: list[KPI]) -> dict[str, KPI]:
...
@@ -21,8 +25,13 @@ def to_dict(values: list[KPI]) -> dict[str, KPI]:
@
pytest
.
mark
.
integration
@
pytest
.
mark
.
integration
@
pytest
.
mark
.
slow
@
pytest
.
mark
.
slow
def
test_pv_no_shadow
(
simstadt_folder
):
def
test_pv_no_shadow
(
simstadt_folder
):
results
=
photovoltaic_simulation
(
MINI
,
METEONORM
,
with_shadows
=
False
,
min_roof_insolation
=
800
,
results
=
photovoltaic_simulation
(
project_path
=
PROJECT_PATH
)
MINI
,
METEONORM
,
with_shadows
=
False
,
min_roof_insolation
=
800
,
project_path
=
PROJECT_PATH
,
)
kpis
=
to_dict
(
results
.
kpis
)
kpis
=
to_dict
(
results
.
kpis
)
assert
"PV potential yield"
in
kpis
assert
"PV potential yield"
in
kpis
assert
"Roof area for PV"
in
kpis
assert
"Roof area for PV"
in
kpis
...
@@ -32,47 +41,118 @@ def test_pv_no_shadow(simstadt_folder):
...
@@ -32,47 +41,118 @@ def test_pv_no_shadow(simstadt_folder):
@
pytest
.
mark
.
integration
@
pytest
.
mark
.
integration
@
pytest
.
mark
.
slow
@
pytest
.
mark
.
slow
def
test_pv_more_modules
(
simstadt_folder
):
def
test_pv_more_modules
(
simstadt_folder
):
base_kpis
=
to_dict
(
photovoltaic_simulation
(
MINI
,
METEONORM
,
with_shadows
=
False
,
min_roof_insolation
=
800
,
base_kpis
=
to_dict
(
project_path
=
PROJECT_PATH
).
kpis
)
photovoltaic_simulation
(
more_kpis
=
to_dict
(
photovoltaic_simulation
(
MINI
,
METEONORM
,
with_shadows
=
False
,
min_roof_insolation
=
800
,
MINI
,
pv_share_flat
=
80
,
pv_share_tilted
=
80
,
METEONORM
,
project_path
=
PROJECT_PATH
).
kpis
)
with_shadows
=
False
,
assert
more_kpis
[
"PV potential nominal power"
].
value
>
base_kpis
[
"PV potential nominal power"
].
value
*
1.5
min_roof_insolation
=
800
,
assert
more_kpis
[
"PV potential yield"
].
value
>
base_kpis
[
"PV potential yield"
].
value
*
1.5
project_path
=
PROJECT_PATH
,
assert
abs
(
more_kpis
[
"Irradiance in module plane"
].
value
-
base_kpis
[
"Irradiance in module plane"
].
value
)
<
1
).
kpis
assert
abs
(
more_kpis
[
"Roof area for PV"
].
value
-
base_kpis
[
"Roof area for PV"
].
value
)
<
100
)
more_kpis
=
to_dict
(
photovoltaic_simulation
(
MINI
,
METEONORM
,
with_shadows
=
False
,
min_roof_insolation
=
800
,
pv_share_flat
=
80
,
pv_share_tilted
=
80
,
project_path
=
PROJECT_PATH
,
).
kpis
)
assert
(
more_kpis
[
"PV potential nominal power"
].
value
>
base_kpis
[
"PV potential nominal power"
].
value
*
1.5
)
assert
(
more_kpis
[
"PV potential yield"
].
value
>
base_kpis
[
"PV potential yield"
].
value
*
1.5
)
assert
(
abs
(
more_kpis
[
"Irradiance in module plane"
].
value
-
base_kpis
[
"Irradiance in module plane"
].
value
)
<
1
)
assert
(
abs
(
more_kpis
[
"Roof area for PV"
].
value
-
base_kpis
[
"Roof area for PV"
].
value
)
<
100
)
@
pytest
.
mark
.
integration
@
pytest
.
mark
.
integration
@
pytest
.
mark
.
slow
@
pytest
.
mark
.
slow
def
test_pv_shadow_reduces_yield
(
simstadt_folder
):
def
test_pv_shadow_reduces_yield
(
simstadt_folder
):
kpis
=
to_dict
(
photovoltaic_simulation
(
MINI
,
METEONORM
,
with_shadows
=
False
,
min_roof_insolation
=
800
,
kpis
=
to_dict
(
project_path
=
PROJECT_PATH
).
kpis
)
photovoltaic_simulation
(
shadow_kpis
=
to_dict
(
photovoltaic_simulation
(
MINI
,
METEONORM
,
with_shadows
=
True
,
min_roof_insolation
=
800
,
MINI
,
project_path
=
PROJECT_PATH
).
kpis
)
METEONORM
,
with_shadows
=
False
,
min_roof_insolation
=
800
,
project_path
=
PROJECT_PATH
,
).
kpis
)
shadow_kpis
=
to_dict
(
photovoltaic_simulation
(
MINI
,
METEONORM
,
with_shadows
=
True
,
min_roof_insolation
=
800
,
project_path
=
PROJECT_PATH
,
).
kpis
)
assert
shadow_kpis
[
"PV potential yield"
].
value
<
kpis
[
"PV potential yield"
].
value
assert
shadow_kpis
[
"PV potential yield"
].
value
<
kpis
[
"PV potential yield"
].
value
assert
shadow_kpis
[
"Irradiance in module plane"
].
value
<
kpis
[
"Irradiance in module plane"
].
value
assert
(
shadow_kpis
[
"Irradiance in module plane"
].
value
<
kpis
[
"Irradiance in module plane"
].
value
)
@
pytest
.
mark
.
integration
@
pytest
.
mark
.
integration
@
pytest
.
mark
.
slow
@
pytest
.
mark
.
slow
def
test_pv_trees_reduce_yield
(
simstadt_folder
):
def
test_pv_trees_reduce_yield
(
simstadt_folder
):
shadow_kpis
=
to_dict
(
photovoltaic_simulation
(
MINI
,
METEONORM
,
with_shadows
=
True
,
min_roof_insolation
=
800
,
shadow_kpis
=
to_dict
(
project_path
=
PROJECT_PATH
).
kpis
)
photovoltaic_simulation
(
tree_kpis
=
to_dict
(
photovoltaic_simulation
(
MINI
,
TEST_REPOSITORY
/
"Grombühl_mini_with_comically_large_trees.gml"
,
METEONORM
,
METEONORM
,
with_shadows
=
True
,
min_roof_insolation
=
800
,
project_path
=
PROJECT_PATH
,
with_shadows
=
True
,
).
kpis
)
min_roof_insolation
=
800
,
assert
tree_kpis
[
"PV potential nominal power"
].
value
<
shadow_kpis
[
"PV potential nominal power"
].
value
*
0.8
project_path
=
PROJECT_PATH
,
assert
tree_kpis
[
"PV potential yield"
].
value
<
shadow_kpis
[
"PV potential yield"
].
value
*
0.8
).
kpis
)
tree_kpis
=
to_dict
(
photovoltaic_simulation
(
TEST_REPOSITORY
/
"Grombühl_mini_with_comically_large_trees.gml"
,
METEONORM
,
with_shadows
=
True
,
min_roof_insolation
=
800
,
project_path
=
PROJECT_PATH
,
).
kpis
)
assert
(
tree_kpis
[
"PV potential nominal power"
].
value
<
shadow_kpis
[
"PV potential nominal power"
].
value
*
0.8
)
assert
(
tree_kpis
[
"PV potential yield"
].
value
<
shadow_kpis
[
"PV potential yield"
].
value
*
0.8
)
@
pytest
.
mark
.
integration
@
pytest
.
mark
.
integration
@
pytest
.
mark
.
slow
@
pytest
.
mark
.
slow
def
test_heatdemand_heating_and_cooling
(
simstadt_folder
):
def
test_heatdemand_heating_and_cooling
(
simstadt_folder
):
kpis
=
to_dict
(
heatdemand_simulation
(
MINI
,
METEONORM
,
with_shadows
=
False
,
kpis
=
to_dict
(
calculation_mode
=
"HEATING_AND_COOLING"
,
heatdemand_simulation
(
project_path
=
PROJECT_PATH
).
kpis
)
MINI
,
METEONORM
,
with_shadows
=
False
,
calculation_mode
=
"HEATING_AND_COOLING"
,
project_path
=
PROJECT_PATH
,
).
kpis
)
assert
"Heated area"
in
kpis
assert
"Heated area"
in
kpis
assert
"Yearly Heating demand"
in
kpis
assert
"Yearly Heating demand"
in
kpis
assert
"Yearly Cooling demand"
in
kpis
assert
"Yearly Cooling demand"
in
kpis
...
@@ -82,48 +162,102 @@ def test_heatdemand_heating_and_cooling(simstadt_folder):
...
@@ -82,48 +162,102 @@ def test_heatdemand_heating_and_cooling(simstadt_folder):
@
pytest
.
mark
.
integration
@
pytest
.
mark
.
integration
@
pytest
.
mark
.
slow
@
pytest
.
mark
.
slow
def
test_heatdemand_shadow_increases_heating
(
simstadt_folder
):
def
test_heatdemand_shadow_increases_heating
(
simstadt_folder
):
kpis
=
to_dict
(
heatdemand_simulation
(
MINI
,
METEONORM
,
with_shadows
=
False
,
kpis
=
to_dict
(
calculation_mode
=
"HEATING_AND_COOLING"
,
heatdemand_simulation
(
project_path
=
PROJECT_PATH
).
kpis
)
MINI
,
shadow_kpis
=
to_dict
(
heatdemand_simulation
(
MINI
,
METEONORM
,
with_shadows
=
True
,
METEONORM
,
calculation_mode
=
"HEATING_AND_COOLING"
,
with_shadows
=
False
,
project_path
=
PROJECT_PATH
).
kpis
)
calculation_mode
=
"HEATING_AND_COOLING"
,
assert
shadow_kpis
[
"Yearly Heating demand"
].
value
>
kpis
[
"Yearly Heating demand"
].
value
*
1.02
project_path
=
PROJECT_PATH
,
assert
shadow_kpis
[
"Yearly Cooling demand"
].
value
<
kpis
[
"Yearly Cooling demand"
].
value
*
0.95
).
kpis
)
shadow_kpis
=
to_dict
(
heatdemand_simulation
(
MINI
,
METEONORM
,
with_shadows
=
True
,
calculation_mode
=
"HEATING_AND_COOLING"
,
project_path
=
PROJECT_PATH
,
).
kpis
)
assert
(
shadow_kpis
[
"Yearly Heating demand"
].
value
>
kpis
[
"Yearly Heating demand"
].
value
*
1.02
)
assert
(
shadow_kpis
[
"Yearly Cooling demand"
].
value
<
kpis
[
"Yearly Cooling demand"
].
value
*
0.95
)
@
pytest
.
mark
.
integration
@
pytest
.
mark
.
integration
@
pytest
.
mark
.
slow
@
pytest
.
mark
.
slow
def
test_heatdemand_trees_increase_heating
(
simstadt_folder
):
def
test_heatdemand_trees_increase_heating
(
simstadt_folder
):
shadow_kpis
=
to_dict
(
heatdemand_simulation
(
MINI
,
METEONORM
,
with_shadows
=
True
,
shadow_kpis
=
to_dict
(
calculation_mode
=
"HEATING_AND_COOLING"
,
heatdemand_simulation
(
project_path
=
PROJECT_PATH
).
kpis
)
MINI
,
tree_kpis
=
to_dict
(
heatdemand_simulation
(
MINI_TREES
,
METEONORM
,
with_shadows
=
True
,
METEONORM
,
calculation_mode
=
"HEATING_AND_COOLING"
,
with_shadows
=
True
,
project_path
=
PROJECT_PATH
).
kpis
)
calculation_mode
=
"HEATING_AND_COOLING"
,
assert
tree_kpis
[
"Yearly Heating demand"
].
value
>
shadow_kpis
[
"Yearly Heating demand"
].
value
*
1.01
project_path
=
PROJECT_PATH
,
assert
tree_kpis
[
"Yearly Cooling demand"
].
value
<
shadow_kpis
[
"Yearly Cooling demand"
].
value
*
0.95
).
kpis
)
tree_kpis
=
to_dict
(
heatdemand_simulation
(
MINI_TREES
,
METEONORM
,
with_shadows
=
True
,
calculation_mode
=
"HEATING_AND_COOLING"
,
project_path
=
PROJECT_PATH
,
).
kpis
)
assert
(
tree_kpis
[
"Yearly Heating demand"
].
value
>
shadow_kpis
[
"Yearly Heating demand"
].
value
*
1.01
)
assert
(
tree_kpis
[
"Yearly Cooling demand"
].
value
<
shadow_kpis
[
"Yearly Cooling demand"
].
value
*
0.95
)
@
pytest
.
mark
.
integration
@
pytest
.
mark
.
integration
@
pytest
.
mark
.
slow
@
pytest
.
mark
.
slow
def
test_heatdemand_refurbishment_reduces_demand
(
simstadt_folder
):
def
test_heatdemand_refurbishment_reduces_demand
(
simstadt_folder
):
tree_kpis
=
to_dict
(
heatdemand_simulation
(
MINI_TREES
,
METEONORM
,
with_shadows
=
True
,
tree_kpis
=
to_dict
(
calculation_mode
=
"HEATING_AND_COOLING"
,
heatdemand_simulation
(
project_path
=
PROJECT_PATH
).
kpis
)
MINI_TREES
,
refurb_kpis
=
to_dict
(
heatdemand_simulation
(
MINI_TREES
,
METEONORM
,
with_shadows
=
True
,
METEONORM
,
calculation_mode
=
"HEATING_AND_COOLING"
,
with_shadows
=
True
,
refurbishment_ratio
=
1.0
,
calculation_mode
=
"HEATING_AND_COOLING"
,
project_path
=
PROJECT_PATH
).
kpis
)
project_path
=
PROJECT_PATH
,
assert
refurb_kpis
[
"Yearly Heating demand"
].
value
<
tree_kpis
[
"Yearly Heating demand"
].
value
*
0.50
).
kpis
)
refurb_kpis
=
to_dict
(
heatdemand_simulation
(
MINI_TREES
,
METEONORM
,
with_shadows
=
True
,
calculation_mode
=
"HEATING_AND_COOLING"
,
refurbishment_ratio
=
1.0
,
project_path
=
PROJECT_PATH
,
).
kpis
)
assert
(
refurb_kpis
[
"Yearly Heating demand"
].
value
<
tree_kpis
[
"Yearly Heating demand"
].
value
*
0.50
)
assert
refurb_kpis
[
"Mean Uvalue"
].
value
<
tree_kpis
[
"Mean Uvalue"
].
value
*
0.50
assert
refurb_kpis
[
"Mean Uvalue"
].
value
<
tree_kpis
[
"Mean Uvalue"
].
value
*
0.50
@
pytest
.
mark
.
integration
@
pytest
.
mark
.
integration
@
pytest
.
mark
.
slow
@
pytest
.
mark
.
slow
def
test_greenwater
(
simstadt_folder
):
def
test_greenwater
(
simstadt_folder
):
kpis
=
to_dict
(
greenwater_simulation
(
MINI_TREES
,
METEONORM
,
irrigation_ratio
=
1.0
,
kpis
=
to_dict
(
project_path
=
PROJECT_PATH
).
kpis
)
greenwater_simulation
(
MINI_TREES
,
METEONORM
,
irrigation_ratio
=
1.0
,
project_path
=
PROJECT_PATH
).
kpis
)
assert
"Rain"
in
kpis
assert
"Rain"
in
kpis
assert
"Evaporative cooling"
in
kpis
assert
"Evaporative cooling"
in
kpis
assert
"Irrigation"
in
kpis
assert
"Irrigation"
in
kpis
...
@@ -133,9 +267,15 @@ def test_greenwater(simstadt_folder):
...
@@ -133,9 +267,15 @@ def test_greenwater(simstadt_folder):
@
pytest
.
mark
.
integration
@
pytest
.
mark
.
integration
@
pytest
.
mark
.
slow
@
pytest
.
mark
.
slow
def
test_greenwater_no_irrigation
(
simstadt_folder
):
def
test_greenwater_no_irrigation
(
simstadt_folder
):
kpis
=
to_dict
(
greenwater_simulation
(
MINI_TREES
,
METEONORM
,
irrigation_ratio
=
1.0
,
kpis
=
to_dict
(
project_path
=
PROJECT_PATH
).
kpis
)
greenwater_simulation
(
no_irr_kpis
=
to_dict
(
greenwater_simulation
(
MINI_TREES
,
METEONORM
,
irrigation_ratio
=
0.0
,
MINI_TREES
,
METEONORM
,
irrigation_ratio
=
1.0
,
project_path
=
PROJECT_PATH
project_path
=
PROJECT_PATH
).
kpis
)
).
kpis
)
no_irr_kpis
=
to_dict
(
greenwater_simulation
(
MINI_TREES
,
METEONORM
,
irrigation_ratio
=
0.0
,
project_path
=
PROJECT_PATH
).
kpis
)
assert
kpis
[
"Irrigation"
].
value
>
500
assert
kpis
[
"Irrigation"
].
value
>
500
assert
no_irr_kpis
[
"Irrigation"
].
rounded_value
==
0
assert
no_irr_kpis
[
"Irrigation"
].
rounded_value
==
0
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