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
0aba942b
Commit
0aba942b
authored
May 11, 2026
by
Eric Duminil
Browse files
Adding households and people
parent
d8b6c65f
Changes
2
Show whitespace changes
Inline
Side-by-side
src/simstadt/results/energy_grid.py
View file @
0aba942b
...
@@ -31,6 +31,8 @@ class EnergyGridResults(SimStadtResults):
...
@@ -31,6 +31,8 @@ class EnergyGridResults(SimStadtResults):
"pv_production"
:
np
.
sum
([
b
[
"pv_production"
]
for
b
in
buildings
],
axis
=
0
),
"pv_production"
:
np
.
sum
([
b
[
"pv_production"
]
for
b
in
buildings
],
axis
=
0
),
})
})
df
.
attrs
[
"number_of_buildings"
]
=
len
(
buildings
)
df
.
attrs
[
"number_of_buildings"
]
=
len
(
buildings
)
df
.
attrs
[
"number_of_households"
]
=
sum
(
b
[
"number_of_households"
]
for
b
in
buildings
)
df
.
attrs
[
"number_of_people"
]
=
sum
(
sum
(
b
[
"people_in_units"
])
for
b
in
buildings
)
df
.
attrs
[
"total_heated_area"
]
=
sum
(
b
[
"heated_area"
]
for
b
in
buildings
)
df
.
attrs
[
"total_heated_area"
]
=
sum
(
b
[
"heated_area"
]
for
b
in
buildings
)
return
df
return
df
...
@@ -42,6 +44,8 @@ class EnergyGridResults(SimStadtResults):
...
@@ -42,6 +44,8 @@ class EnergyGridResults(SimStadtResults):
total_elec_kwh
=
df
[
"electricity_demand"
].
sum
()
total_elec_kwh
=
df
[
"electricity_demand"
].
sum
()
return
[
return
[
KPI
(
"Number of buildings"
,
df
.
attrs
[
"number_of_buildings"
],
precision
=
0
),
KPI
(
"Number of buildings"
,
df
.
attrs
[
"number_of_buildings"
],
precision
=
0
),
KPI
(
"Number of households"
,
df
.
attrs
[
"number_of_households"
],
precision
=
0
),
KPI
(
"Number of people"
,
df
.
attrs
[
"number_of_people"
],
precision
=
0
),
KPI
(
"Total heated area"
,
total_heated_area
,
"m²"
,
precision
=
0
),
KPI
(
"Total heated area"
,
total_heated_area
,
"m²"
,
precision
=
0
),
KPI
(
"Total electricity demand"
,
total_elec_kwh
/
1000
,
"MWh / a"
,
precision
=
1
),
KPI
(
"Total electricity demand"
,
total_elec_kwh
/
1000
,
"MWh / a"
,
precision
=
1
),
KPI
(
"Specific electricity demand"
,
total_elec_kwh
/
total_heated_area
,
"kWh / (m² · a)"
,
precision
=
1
),
KPI
(
"Specific electricity demand"
,
total_elec_kwh
/
total_heated_area
,
"kWh / (m² · a)"
,
precision
=
1
),
...
...
tests/test_results.py
View file @
0aba942b
...
@@ -653,6 +653,10 @@ def test_energy_grid_kpis(energy_grid_results):
...
@@ -653,6 +653,10 @@ def test_energy_grid_kpis(energy_grid_results):
kpis
=
kpis_by_name
(
energy_grid_results
)
kpis
=
kpis_by_name
(
energy_grid_results
)
assert
kpis
[
"Number of buildings"
].
value
==
3
assert
kpis
[
"Number of buildings"
].
value
==
3
assert
kpis
[
"Number of buildings"
].
unit
is
None
assert
kpis
[
"Number of buildings"
].
unit
is
None
assert
kpis
[
"Number of households"
].
value
==
8
assert
kpis
[
"Number of households"
].
unit
is
None
assert
kpis
[
"Number of people"
].
value
==
13
assert
kpis
[
"Number of people"
].
unit
is
None
assert
kpis
[
"Total heated area"
].
value
==
pytest
.
approx
(
1198.1
,
abs
=
0.1
)
assert
kpis
[
"Total heated area"
].
value
==
pytest
.
approx
(
1198.1
,
abs
=
0.1
)
assert
kpis
[
"Total heated area"
].
unit
==
"m²"
assert
kpis
[
"Total heated area"
].
unit
==
"m²"
assert
kpis
[
"Total electricity demand"
].
value
==
pytest
.
approx
(
17.0
,
abs
=
0.1
)
assert
kpis
[
"Total electricity demand"
].
value
==
pytest
.
approx
(
17.0
,
abs
=
0.1
)
...
@@ -667,7 +671,7 @@ def test_energy_grid_kpis(energy_grid_results):
...
@@ -667,7 +671,7 @@ def test_energy_grid_kpis(energy_grid_results):
assert
kpis
[
"Total PV production"
].
unit
==
"MWh / a"
assert
kpis
[
"Total PV production"
].
unit
==
"MWh / a"
assert
kpis
[
"Average temperature"
].
value
==
pytest
.
approx
(
9.95
,
abs
=
0.05
)
assert
kpis
[
"Average temperature"
].
value
==
pytest
.
approx
(
9.95
,
abs
=
0.05
)
assert
kpis
[
"Average temperature"
].
unit
==
"°C"
assert
kpis
[
"Average temperature"
].
unit
==
"°C"
assert
len
(
kpis
)
==
8
assert
len
(
kpis
)
==
10
# ---------------------------------------------------------------------------
# ---------------------------------------------------------------------------
...
...
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