Shared workflow steps

This module builds on the generic workflow utilities/Workflow class to provide steps that can be used for any workflow involving the MESSAGEix-GLOBIOM global model.

These are intended to be configured, adapted, or extended for new projects and applications, instead of duplicate, project-specific code.

Code reference

Common steps for workflows.

class message_ix_models.model.workflow.Config(demand_scenario: dict = <factory>, reserve_margin: bool = True, solve: dict[str, ~typing.Any] = <factory>)[source]

Common configuration for model workflows across projects.

Currently, the three settings are understood by solve(), which is used in ENGAGE, NAVIGATE, transport.workflow, and possibly other workflows.

demand_scenario: dict

Information on an optional, other scenario from which to copy demand data in solve() using transfer_demands(). Default: empty, do nothing.

reserve_margin: bool = True

True to call reserve_margin.res_marg.main() in solve().

solve: dict[str, Any]

Keyword arguments for message_ix.Scenario.solve() via solve().

To replicate the behaviour of the macro_params argument to engage.ScenarioRunner.run(), which in turn sets the convergence_issues argument to engage.ScenarioRunner.solve(), set max_adjustment to 0.1.

message_ix_models.model.workflow.solve(context: Context, scenario: Scenario, *, config: Config | None = None, set_as_default: bool = False)[source]

Common model solve step for ENGAGE, NAVIGATE, and other workflows.

The steps respond settings from an optional instance of Config passed as a keyword argument.

Before scenario is solved:

  1. If Config.reserve_margin is True, res_marg.main() is called.

  2. If Config.demand_scenario is non-empty and config.solve["model"] is MESSAGE-MACRO, then transfer_demands() is called to transfer data from the indicated scenario to scenario. This scenario must exist on the same Platform as scenario; the default version is loaded.

Then:

  1. scenario is solved passing Config.solve as keyword arguments to message_ix.Scenario.solve(). The keyword argument var_list has I, C, and (if config.solve["model"] is MESSAGE-MACRO) GDP appended.

After scenario is solved without exception:

  1. set_as_default() is called if the keyword argument set_as_default is True.

message_ix_models.model.workflow.step_0(context: Context, scenario: Scenario, **kwargs) Scenario[source]

Preparation step for climate policy workflows.

This is similar to (and shares the name of) project.engage.workflow.step_0(), but uses settings specific to the model structure used in SSP 2023–2025 / ScenarioMIP at (5) and (6).

  1. Remove the model solution.

  2. Call remove_emission_bounds.

  3. Update Config.regions to match scenario.

  4. Call add_FFI_CO2_accounting.

  5. Call add_AFOLU_CO2_accounting() with the default method, currently METHOD.B.

  6. Call add_alternative_TCE_accounting with the default method, currently METHOD.B.

  7. Call add_CO2_emission_constraint with constraint_value=0, type_rel="lower", effectively preventing negative emissions.

Todo

Merge project.engage.workflow.step_0() into this function and generalize with appropriate options/parameters.