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
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
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
TEST_REPOSITORY
=
Path
(
__file__
).
parent
/
"data"
/
"TestRepo"
...
...
@@ -21,8 +25,13 @@ def to_dict(values: list[KPI]) -> dict[str, KPI]:
@
pytest
.
mark
.
integration
@
pytest
.
mark
.
slow
def
test_pv_no_shadow
(
simstadt_folder
):
results
=
photovoltaic_simulation
(
MINI
,
METEONORM
,
with_shadows
=
False
,
min_roof_insolation
=
800
,
project_path
=
PROJECT_PATH
)
results
=
photovoltaic_simulation
(
MINI
,
METEONORM
,
with_shadows
=
False
,
min_roof_insolation
=
800
,
project_path
=
PROJECT_PATH
,
)
kpis
=
to_dict
(
results
.
kpis
)
assert
"PV potential yield"
in
kpis
assert
"Roof area for PV"
in
kpis
...
...
@@ -32,47 +41,118 @@ def test_pv_no_shadow(simstadt_folder):
@
pytest
.
mark
.
integration
@
pytest
.
mark
.
slow
def
test_pv_more_modules
(
simstadt_folder
):
base_kpis
=
to_dict
(
photovoltaic_simulation
(
MINI
,
METEONORM
,
with_shadows
=
False
,
min_roof_insolation
=
800
,
project_path
=
PROJECT_PATH
).
kpis
)
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
base_kpis
=
to_dict
(
photovoltaic_simulation
(
MINI
,
METEONORM
,
with_shadows
=
False
,
min_roof_insolation
=
800
,
project_path
=
PROJECT_PATH
,
).
kpis
)
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
.
slow
def
test_pv_shadow_reduces_yield
(
simstadt_folder
):
kpis
=
to_dict
(
photovoltaic_simulation
(
MINI
,
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
)
kpis
=
to_dict
(
photovoltaic_simulation
(
MINI
,
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
[
"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
.
slow
def
test_pv_trees_reduce_yield
(
simstadt_folder
):
shadow_kpis
=
to_dict
(
photovoltaic_simulation
(
MINI
,
METEONORM
,
with_shadows
=
True
,
min_roof_insolation
=
800
,
project_path
=
PROJECT_PATH
).
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
shadow_kpis
=
to_dict
(
photovoltaic_simulation
(
MINI
,
METEONORM
,
with_shadows
=
True
,
min_roof_insolation
=
800
,
project_path
=
PROJECT_PATH
,
).
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
.
slow
def
test_heatdemand_heating_and_cooling
(
simstadt_folder
):
kpis
=
to_dict
(
heatdemand_simulation
(
MINI
,
METEONORM
,
with_shadows
=
False
,
calculation_mode
=
"HEATING_AND_COOLING"
,
project_path
=
PROJECT_PATH
).
kpis
)
kpis
=
to_dict
(
heatdemand_simulation
(
MINI
,
METEONORM
,
with_shadows
=
False
,
calculation_mode
=
"HEATING_AND_COOLING"
,
project_path
=
PROJECT_PATH
,
).
kpis
)
assert
"Heated area"
in
kpis
assert
"Yearly Heating demand"
in
kpis
assert
"Yearly Cooling demand"
in
kpis
...
...
@@ -82,48 +162,102 @@ def test_heatdemand_heating_and_cooling(simstadt_folder):
@
pytest
.
mark
.
integration
@
pytest
.
mark
.
slow
def
test_heatdemand_shadow_increases_heating
(
simstadt_folder
):
kpis
=
to_dict
(
heatdemand_simulation
(
MINI
,
METEONORM
,
with_shadows
=
False
,
calculation_mode
=
"HEATING_AND_COOLING"
,
project_path
=
PROJECT_PATH
).
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
kpis
=
to_dict
(
heatdemand_simulation
(
MINI
,
METEONORM
,
with_shadows
=
False
,
calculation_mode
=
"HEATING_AND_COOLING"
,
project_path
=
PROJECT_PATH
,
).
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
.
slow
def
test_heatdemand_trees_increase_heating
(
simstadt_folder
):
shadow_kpis
=
to_dict
(
heatdemand_simulation
(
MINI
,
METEONORM
,
with_shadows
=
True
,
calculation_mode
=
"HEATING_AND_COOLING"
,
project_path
=
PROJECT_PATH
).
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
shadow_kpis
=
to_dict
(
heatdemand_simulation
(
MINI
,
METEONORM
,
with_shadows
=
True
,
calculation_mode
=
"HEATING_AND_COOLING"
,
project_path
=
PROJECT_PATH
,
).
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
.
slow
def
test_heatdemand_refurbishment_reduces_demand
(
simstadt_folder
):
tree_kpis
=
to_dict
(
heatdemand_simulation
(
MINI_TREES
,
METEONORM
,
with_shadows
=
True
,
calculation_mode
=
"HEATING_AND_COOLING"
,
project_path
=
PROJECT_PATH
).
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
tree_kpis
=
to_dict
(
heatdemand_simulation
(
MINI_TREES
,
METEONORM
,
with_shadows
=
True
,
calculation_mode
=
"HEATING_AND_COOLING"
,
project_path
=
PROJECT_PATH
,
).
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
@
pytest
.
mark
.
integration
@
pytest
.
mark
.
slow
def
test_greenwater
(
simstadt_folder
):
kpis
=
to_dict
(
greenwater_simulation
(
MINI_TREES
,
METEONORM
,
irrigation_ratio
=
1.0
,
project_path
=
PROJECT_PATH
).
kpis
)
kpis
=
to_dict
(
greenwater_simulation
(
MINI_TREES
,
METEONORM
,
irrigation_ratio
=
1.0
,
project_path
=
PROJECT_PATH
).
kpis
)
assert
"Rain"
in
kpis
assert
"Evaporative cooling"
in
kpis
assert
"Irrigation"
in
kpis
...
...
@@ -133,9 +267,15 @@ def test_greenwater(simstadt_folder):
@
pytest
.
mark
.
integration
@
pytest
.
mark
.
slow
def
test_greenwater_no_irrigation
(
simstadt_folder
):
kpis
=
to_dict
(
greenwater_simulation
(
MINI_TREES
,
METEONORM
,
irrigation_ratio
=
1.0
,
project_path
=
PROJECT_PATH
).
kpis
)
no_irr_kpis
=
to_dict
(
greenwater_simulation
(
MINI_TREES
,
METEONORM
,
irrigation_ratio
=
0.0
,
project_path
=
PROJECT_PATH
).
kpis
)
kpis
=
to_dict
(
greenwater_simulation
(
MINI_TREES
,
METEONORM
,
irrigation_ratio
=
1.0
,
project_path
=
PROJECT_PATH
).
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
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