Skip to content

Commit 5974ba8

Browse files
authored
Merge pull request #433 from iiasa/bmt_dev
Add BMT workflows and update functions to build Buildings module
2 parents 48b8688 + 12434be commit 5974ba8

22 files changed

Lines changed: 1869 additions & 197 deletions

File tree

doc/api/model-bmt.rst

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
BMT workflow (:mod:`.model.bmt`)
2+
********************************
3+
4+
The acronym **“BMT”** refers to a configuration of MESSAGEix-GLOBIOM
5+
that combines all 3 of the
6+
:doc:`/buildings/index` (**B**),
7+
:doc:`MESSAGEix-Materials </material/index>` (**M**), and
8+
:doc:`MESSAGEix-Transport </transport/index>` (**T**)
9+
model variants.
10+
11+
The current module :mod:`.model.bmt` includes:
12+
13+
- :func:`.bmt.workflow.generate` —generates a :class:`.Workflow`
14+
that chains steps to build all 3 variants on a base scenario.
15+
See the function documentation for complete details.
16+
- :mod:`.bmt.cli` —the :program:`mix-models bmt run` CLI subcommand
17+
used to invoke the workflow.
18+
For example::
19+
20+
mix-models bmt run --from="base" "glasgow+" --dry-run
21+
22+
See :program:`mix-models bmt run --help` for options.
23+
- :mod:`.bmt.config` —handling for configuration,
24+
which is read from a file :file:`data/bmt/config.yaml`.
25+
See the module documentation for a description of the file format.
26+
27+
Code reference
28+
==============
29+
30+
.. autosummary::
31+
:toctree: _autosummary
32+
:template: autosummary-module.rst
33+
:recursive:
34+
35+
message_ix_models.model.bmt

doc/buildings/index.rst

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,18 @@ These are handled by :func:`.buildings.build_and_solve`.
4545

4646
These steps are handled by :func:`.buildings.pre_solve`.
4747

48+
When the buildings module is run as part of the :doc:`/bmt/index` workflow,
49+
it calls :func:`.buildings.build.build_B`,
50+
which loads inputs (prices, STURM outputs, static demand) specified in :attr:`context.buildings`
51+
or from :file:`data/bmt/config.yaml`,
52+
calls :func:`.buildings.build.prepare_data_B`
53+
to derive parameter data from the base scenario and those inputs,
54+
then applies the buildings spec to the scenario.
55+
:func:`.buildings.build.prepare_data_B` produces demand and technology parameters
56+
(input, output, capacity factor, etc.)
57+
for buildings commodities and the residual AFOFIO representation.
58+
It can also add materials linkage when :attr:`with_materials` is :any:`True`.
59+
4860
2. **Solve.**
4961
Because prices are endogenous in MESSAGE, solving the MESSAGE scenario produced by (1.4) can result in prices that are *different* from the ones provided to ACCESS and STURM in steps (1.2) and (1.3).
5062

@@ -56,7 +68,6 @@ These are handled by :func:`.buildings.build_and_solve`.
5668
.. note:: As of 2023-01-10, this is not in active use; the models are run in a once-through fashion with :attr:`.max_iterations` set to 1.
5769
See also the :ref:`NAVIGATE workflow <navigate-workflow>`, wherein a second iteration is run manually after a policy scenario is solved.
5870

59-
6071
Report
6172
------
6273

@@ -180,7 +191,8 @@ The following corresponds to :file:`reporting_EFC.py`:
180191
Configuration
181192
=============
182193

183-
The class :class:`.buildings.Config` defines all the options to which the code responds, as well as default values.
194+
The class :class:`.buildings.Config` defines all the options to which the code responds,
195+
as well as default values.
184196
Values given in code or on the command line will override these.
185197

186198
.. autoclass:: message_ix_models.model.buildings.Config
@@ -196,4 +208,4 @@ Code reference
196208
:template: autosummary-module.rst
197209
:recursive:
198210

199-
buildings
211+
message_ix_models.model.buildings

doc/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ Other submodules are documented on their respective pages:
9393

9494
api/model
9595
api/model-bare
96+
api/model-bmt
9697
api/model-build
9798
api/model-emissions
9899
api/model-snapshot

doc/whatsnew.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ Next release
55
============
66

77
- Add IAMC code list :class:`~.iamc.structure.CL_SCENARIO_DIAGNOSTIC` (:pull:`501`).
8+
- Add :doc:`/api/model-bmt` (:pull:`433`).
9+
10+
- Add
11+
:data:`.buildings.config.DEFAULT_DATA_PATHS`,
12+
:class:`~.buildings.config.METHOD`,
13+
:attr:`.buildings.Config.data_paths`, and
14+
:attr:`~.buildings.Config.method`.
15+
- Add :func:`.buildings.build.prepare_data_B`;
16+
rename :py:`prepare_data()` to :func:`~.buildings.build.prepare_data_A`.
817

918
v2026.4.17
1019
==========

message_ix_models/cli.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ def _log_threads(k: int, n: int):
172172
"message_ix_models.testing.cli",
173173
"message_ix_models.util.pooch",
174174
"message_ix_models.util.slurm",
175+
"message_ix_models.model.bmt.cli",
175176
]
176177

177178
try:
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# BMT workflow configuration.
2+
# Top-level keys are energy demand sectors; each is loaded into context (e.g. context.buildings).
3+
# Paths under a sector are relative to private_data_path(sector) unless redefined.
4+
5+
buildings:
6+
data_paths:
7+
# Input file names under private_data_path("buildings")
8+
prices: "input_prices_R12.csv"
9+
sturm_r: "report_MESSAGE_resid_SSP2_nopol_post.csv"
10+
sturm_c: "report_MESSAGE_comm_SSP2_nopol_post.csv"
11+
demand_static: "static_20251227.csv"
12+
# Whether to include materials (steel, cement, aluminum) in the buildings spec
13+
with_materials: true
14+
15+
# transport: {}
16+
# materials: {}
17+
# others: {}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# biomass_rc
2+
resid_cook_biomass:
3+
description: Biomass demand for residential cooking
4+
resid_heat_biomass:
5+
description: Biomass demand for residential heating
6+
resid_hotwater_biomass:
7+
description: Biomass demand for residential hotwater
8+
comm_heat_biomass:
9+
description: Biomass demand for commercial heating
10+
comm_hotwater_biomass:
11+
description: Biomass demand for commercial hotwater
12+
13+
# coal_rc
14+
resid_heat_coal:
15+
description: Coal demand for residential heating
16+
resid_hotwater_coal:
17+
description: Coal demand for residential hotwater
18+
comm_heat_coal:
19+
description: Coal demand for commercial heating
20+
comm_hotwater_coal:
21+
description: Coal demand for commercial hotwater
22+
23+
# heat_rc
24+
resid_heat_d_heat:
25+
description: District heat demand for residential heating
26+
resid_hotwater_d_heat:
27+
description: District heat demand for residential hotwater
28+
comm_heat_d_heat:
29+
description: District heat demand for commercial heating
30+
comm_hotwater_d_heat:
31+
description: District heat demand for commercial hotwater
32+
33+
# elec_rc
34+
resid_cook_electr:
35+
description: Electricity demand for residential cooking
36+
resid_heat_electr:
37+
description: Electricity demand for residential heating
38+
resid_hotwater_electr:
39+
description: Electricity demand for residential hotwater
40+
comm_heat_electr:
41+
description: Electricity demand for commercial heating
42+
comm_hotwater_electr:
43+
description: Electricity demand for commercial hotwater
44+
45+
# sp_el_RC
46+
resid_cool_electr:
47+
description: Electricity demand for residential cooling
48+
comm_cool_electr:
49+
description: Electricity demand for commercial cooling
50+
resid_apps_electr:
51+
description: Electricity demand for residential appliances
52+
resid_other_uses_electr:
53+
description: Electricity demand for residential other uses
54+
comm_other_uses_electr:
55+
description: Electricity demand for commercial other uses
56+
57+
# gas_rc
58+
resid_heat_gas:
59+
description: Gas demand for residential heating
60+
resid_hotwater_gas:
61+
description: Gas demand for residential hotwater
62+
comm_heat_gas:
63+
description: Gas demand for commercial heating
64+
comm_hotwater_gas:
65+
description: Gas demand for commercial hotwater
66+
67+
# loil_rc
68+
resid_cook_lightoil:
69+
resid_cook_lightoil:
70+
description: Light oil demand for residential cooking
71+
resid_hotwater_lightoil:
72+
description: Light oil demand for residential hotwater
73+
comm_hotwater_lightoil:
74+
description: Light oil demand for commercial hotwater
75+
resid_heat_lightoil:
76+
description: Light oil demand for residential heating
77+
comm_heat_lightoil:
78+
description: Light oil demand for commercial heating

message_ix_models/data/buildings/set.yaml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
# NB this cannot be "sector", as it collides with the MACRO set of the same name
88
buildings_sector:
99
add:
10-
afofi:
11-
name: Agriculture, forestry, and fisheries
12-
report: AFOFI
10+
afofio:
11+
name: Agriculture, forestry, fisheries, and others
12+
report: AFOFIO
1313
comm:
1414
name: Commercial buildings
1515
report: Commercial
@@ -100,25 +100,27 @@ relation:
100100
# Relations for which data should be adapted
101101
require:
102102
- BCA_Emission
103-
- CH4_Emission
103+
# - CH4_Emission
104104
- CO2_r_c
105105
- CO_Emission
106106
- HFC_Emission
107107
- HFC_foam_red
108108
- HFC_rescom_red
109-
- N2O_Emission
109+
#- N2O_Emission
110110
- NH3_Emission
111111
- NOx_Emission
112112
- OCA_Emission
113113
- SO2_Emission
114114
- VOC_Emission
115115
- oper_res
116116
- solar_th_pot
117-
117+
- gas_mix_lim
118+
# - share_low_lim_NFPE
119+
# - share_low_lim_REPE
118120

119121
technology:
120122
add:
121-
# NB some others like meth_afofi are generated in .buildings.build
123+
# NB some others like meth_afofio are generated in .buildings.build
122124
"{commodity.id}_{buildings_sector.id}_{enduse.id}":
123125
# name: "{commodity.name}-powered {enduse.name.lower()} in {buildings_sector.name.lower()}"
124126
name: "{commodity.name}-powered {enduse.name} in {buildings_sector.name}"

message_ix_models/data/technology.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2896,6 +2896,14 @@ sp_el_RC:
28962896
input: [electr, final]
28972897
output: [rc_spec, useful]
28982898

2899+
sp_el_RC_RT:
2900+
name: sp_el_RC_RT
2901+
description: Specific use of electricity in residential/commercial from rooftop PV
2902+
type: useful
2903+
sector: residential/commercial
2904+
input: [electr, final]
2905+
output: [rc_spec, useful]
2906+
28992907
h2_fc_RC:
29002908
name: h2_fc_RC
29012909
description: Specific use of hydrogen fuel cell cogeneration system in res/comm
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"""Buildings-Materials-Transport workflow."""
2+
3+
from .utils import build_PM, subtract_material_demand
4+
5+
__all__ = [
6+
"build_PM",
7+
"subtract_material_demand",
8+
]

0 commit comments

Comments
 (0)