Part B: extending MIMOSA
For the second part of the assigment, you will extend MIMOSA. Choose a topic you find interesting, and that is missing in MIMOSA, or that you want to change/improve in the current version of MIMOSA. Here are some ideas to get you started. You can also come up with your own idea.
Ideas for your own extension
The ideas below are grouped in four categories: mitigation and fairness, impacts and adaptation, climate and sea-level rise, and economy and development pathways. Each category contains a few example questions you could explore. You can also propose your own idea, as long as it is not already included in MIMOSA.
-
Mitigation and fairness
- Who pays? Compare fairness rules or propose a different way to share mitigation costs between regions.
- Lifestyle changes? Explore ways to include lifestyle changes in the model, such as changes in diet.
- Reduce demand? Represent lower energy or material demand and its effect on emissions and mitigation costs.
- More recycled steel? Estimate how using more scrap to make the same amount of steel changes baseline CO₂ emissions.
- Enough materials for clean power? Add a cost penalty when the material needed for new wind or solar capacity exceeds an assumed supply.
- How much mitigation at home? Require regions to make a minimum share of their credited emissions cuts domestically and compare how much they trade.
How it works now: Mitigation costs and learning, effort-sharing, emission trading and emissions and temperature limits.
-
Impacts and adaptation
- A new impact sector? Add a simple damage relationship for a sector such as infrastructure or ecosystem services, or explore biodiversity loss.
- Who is affected? Explore how the same warming causes different damages within regions, or how impacts are distributed across different groups.
- Thresholds and protection? Explore damages that rise sharply beyond a warming threshold, or add/change assumptions on adaptation measures.
- Where does water become scarce? Compare regional water withdrawals with available freshwater under different warming pathways.
- Who gets loss and damage funding? Compare how a fixed fund is split if regions are paid by total damages or by damages as a share of GDP.
How it works now: ACCREU sectors and adaptation and welfare and inequality.
-
Climate and sea-level rise
- Different warming responses? The current climate modules is simply a linear reponse of temperature to cumulative emissions. Explore different alternative approaches, for example by adding methane emissions besides CO2.
- Climate tipping points? Add a simplified feedback that starts above a temperature threshold, such as extra emissions or faster ice loss.
- Can coastal wetlands move inland? Estimate how much wetland remains as seas rise under different assumptions about available land.
How it works now: Emissions and temperature and sea-level-rise contributions.
-
Economy and development pathways
- A different future? Compare Shared Socioeconomic Pathways (SSPs), or supply your own population, GDP or baseline emissions assumptions.
- Lower growth or degrowth? Explore alternative economic trajectories and their consequences for emissions, consumption and welfare.
- A different economy? Change how investment, productivity or production affects GDP, and investigate changes to the production function.
- Whose consumption drives emissions? For one traded product, compare assigning its production emissions to the regions that make it or use it.
- Who can meet basic needs? Split regional consumption between two income groups and compare their shortfalls against a basic-needs threshold.
How it works now: GDP, investment and consumption and welfare.
Steps for this assignment
- Choose a topic from the topics above
- In the MIMOSA causal loop diagram you made last week, identify where your new component fits in the model. Which variables will you add, how do they depend on existing variables, and which existing variables will depend on your new variable?
- Using a small literature review, define a simple relationship for your new variable. Make an overview of which data you need, where to get it, and how to include it in MIMOSA.
-
Implement your new component in MIMOSA, following the steps in the guided exercise. You should at least add one or several variables and define their relationship to existing variables.
-
Easier:
Including a new variable that has no effect on other variables is easier to implement, but serves as an output-only variable.
-
More interesting, but harder:
If the new variable also has an effect on existing variables, the feedbacks in MIMOSA are also affected. This is more interesting, but can also be more difficult to implement.
-
-
Report your findings in a short report, including your causal loop diagram, the literature review, and the results of your new component.
Guided practice exercise: adding a new impact sector
For this exercise, you will add a new impact sector to MIMOSA. Specifically, you will model the economic benefits of increased ice-cream sales in a warming climate. The exercise will guide you through the steps to add a new variable, define its relationship to existing variables, and include it in the total damages deducted from GDP. You will also make the benefit coefficient configurable, so you can explore different assumptions.
Where to work
Your course branch already contains mimosa/components/new_component.py, with the
empty get_constraints(m, inputs) function. It is already connected in
model_builder.py, so MIMOSA will include your additions automatically.
You will use these files:
mimosa/
├── components/
│ ├── new_component.py # Add the new sector here
│ └── damages/
│ └── accreu/
└── all_damages.py # Include it in total damages
└── inputdata/
└── config/
└── config_default.yaml # Define the new parameter here
run_extension.py # Create this script to run the exercise
All paths start from MIMOSA's main directory: the folder containing the mimosa
folder and pyproject.toml.
This exercise uses the ACCREU damage module and assumes your editable copy of MIMOSA
is ready to run.
Inside get_constraints, m is the model. A variable holds a model result, a
parameter supplies an assumption, and an equation describes how to calculate
one variable from other model quantities.
Our fictional benefit function
We assume that each additional degree of warming brings extra ice-cream sales revenue equal to 0.2% of gross GDP:
Here \(T_t\) is the temperature at timestep \(t\), and \(T_0\) is the temperature at the model start. Subtracting \(T_0\) makes the extra benefits zero in the initial year. Under this simple linear relation, cooling below the initial temperature would reduce sales, represented by a negative benefit value.
We store benefits as a fraction of GDP, so 0.002 means 0.2%. For example,
one degree of additional warming gives 0.002, and two degrees give 0.004, or
0.4% of GDP. We use the same benefit fraction in every region for this exercise.
1. Add a variable
Open mimosa/components/new_component.py. The names used below, including Var,
Param and RegionalEquation, are already imported in your starter file.
Inside get_constraints, add the following code to define a new variable:
# Add your variables and parameters here
m.icecream_sales_benefit = Var(
m.t,
m.regions,
doc="Fictional economic benefits from increased ice-cream sales, as a fraction of gross GDP, relative to the model start.",
)
| Part | Meaning |
|---|---|
m.icecream_sales_benefit |
The name of the new variable on the model |
Var(m.t, m.regions, ...) |
Store a value for every timestep and region |
doc=... |
A short description of the variable |
See Variables for more ways to define variables.
2. Add the benefit equation
In the same file, replace the empty constraints = [...] block with:
constraints = [
RegionalEquation(
m.icecream_sales_benefit,
lambda m, t, r: 0.002 * (m.temperature[t] - m.T0),
),
]
Keep the existing return constraints line below it. This returns your equation to
MIMOSA so it can be used when running the model.
Read lambda m, t, r: ... as: “For this timestep and region, calculate the expression
after the colon.” MIMOSA applies it to every timestep and region for you.
tidentifies a timestep andridentifies a region.m.temperature[t]is the global temperature at that timestep; it has no region index.m.T0is the initial temperature, which is the same for all timesteps and regions.- The first argument,
m.icecream_sales_benefit, names the result being calculated and is written without[t, r].
See Equations for more detail on
RegionalEquation and the lambda notation.
Save new_component.py before continuing.
3. Run the model and check your calculation
Create run_extension.py in MIMOSA's main directory and paste in:
from mimosa import MIMOSA, load_params
params = load_params()
model = MIMOSA(params)
simulation = model.run_simulation()
model.save_simulation(simulation, "guided_exercise")
This is a no-policy simulation using all default parameters, regions and timesteps.
Calling run_simulation() without control values sets mitigation to zero. This
exercise uses simulation and does not need IPOPT.
Run the script from MIMOSA's main directory:
The results are saved to output/guided_exercise.csv. You can open this file in
Excel, or open the MIMOSA Dashboard
and drag and drop the CSV file onto it to explore the results.
In the CSV, the Variable and Region columns identify each row, and the year
columns contain the results. Your new variable is included automatically. Look for:
| Variable | Region | What to check |
|---|---|---|
icecream_sales_benefit |
WEU |
Extra benefits are zero in 2025 and positive in 2050. Values are fractions of GDP, so 0.002 means 0.2%. |
temperature |
Global |
The temperature values in 2025 and 2050 show how much additional warming has occurred. |
GDP_net |
WEU |
Write down the value in the 2050 column to compare after the next step. |
To check your equation using the CSV, subtract the 2025 temperature from the 2050
temperature and multiply by 0.002. This should match the ice-cream benefit
fraction in the 2050 column, allowing for rounding in the saved values.
At this stage, the new benefit variable is calculated and saved. The next step makes it part of the damages deducted from GDP.
4. Include the new sector in total damages
Open mimosa/components/damages/accreu/all_damages.py. Inside get_constraints, find the
RegionalEquation for m.damage_costs. It currently adds m.labourprod_damage_costs_net,
m.riverine_damage_costs and m.slr_damage_costs.
Replace only that equation with the version below, which subtracts your new sector's benefit from the total damages. Keep the other equations and the surrounding list in place:
RegionalEquation(
m.damage_costs,
lambda m, t, r: (
m.labourprod_damage_costs_net[t, r]
+ m.riverine_damage_costs[t, r]
+ m.slr_damage_costs[t, r]
- m.icecream_sales_benefit[t, r]
),
),
The total damage fraction now subtracts the new ice-cream benefit, so warming lowers the total damages through this sector. The economic module deducts the total damage costs from GDP, which affects consumption and welfare as well.
Save all_damages.py and run run_extension.py again. Reopen the CSV in Excel or load
the new file into the dashboard. Check the ice-cream benefit value and compare
GDP_net for the USA in 2050 with the value you wrote down. It should be higher
when the ice-cream benefit is included. Each run replaces the previous
output/guided_exercise.csv file.
For this exercise, we treat the fictional ice-cream sector as an additional impact that is not already included in the ACCREU damage functions.
5. Make the benefit coefficient configurable
The value 0.002 is currently written directly in the equation. We will turn it
into a parameter so you can choose a different value from your run script.
Open mimosa/inputdata/config/config_default.yaml. Find economics:, then the
existing damages: section beneath it. Add icecream_benefit_coefficient at the
same indentation level as scale factor:
economics:
damages:
icecream_benefit_coefficient:
descr: Fictional ice-cream sales benefit fraction per degree of additional warming
type: float
min: 0
default: 0.002
Keep the existing economics: and damages: headings and all their other entries.
Only add the new parameter entry.
type: float means the value is a decimal number, and min: 0 prevents a negative
coefficient. We interpret the number as the benefit fraction per additional degree
of warming. The default remains 0.002.
See Adding parameters from configuration for more detail on defining a new configuration entry.
In new_component.py, add this declaration above constraints = [...], alongside
your variable declaration:
m.icecream_benefit_coefficient = Param(
initialize=inputs.config("economics.damages.icecream_benefit_coefficient"),
doc="Fictional ice-cream sales benefit fraction per degree of warming above the model's initial temperature.",
)
inputs.config(...) reads the value from the configuration. Its name on the model
is m.icecream_benefit_coefficient, and it has the same value for every timestep
and region.
Finally, replace the constraints = [...] block in new_component.py with:
constraints = [
RegionalEquation(
m.icecream_sales_benefit,
lambda m, t, r: m.icecream_benefit_coefficient * (m.temperature[t] - m.T0),
),
]
Save both files and run the script again. The results should match your previous
run when you open the new CSV in Excel or the dashboard: you have changed where
the coefficient comes from, while keeping its value at 0.002 per degree.
6. Try a stronger benefit assumption
Replace the contents of run_extension.py with the complete script below. The
highlighted lines change the coefficient and save this run with a different filename:
from mimosa import MIMOSA, load_params
params = load_params()
params["economics"]["damages"]["icecream_benefit_coefficient"] = 0.004
model = MIMOSA(params)
simulation = model.run_simulation()
model.save_simulation(simulation, "guided_exercise_stronger_benefits")
This doubles the benefit fraction assigned to a given amount of additional warming:
from 0.2% to 0.4% of GDP per degree. Save and rerun the script. The new results
are saved to output/guided_exercise_stronger_benefits.csv, keeping the original
output/guided_exercise.csv available for comparison.
Open both files in Excel, or drag and drop both into the
MIMOSA Dashboard. Compare
icecream_sales_benefit and GDP_net for the same region and year. You can now
change this assumption without editing the component or its configuration defaults.
As a second check, set the coefficient to 0 in the parameter line and rerun. In
the new CSV, icecream_sales_benefit should be zero in every year.
For more ways to supply parameter values, including regional data, see Adding parameters and data.
Check your completed component
Your completed mimosa/components/new_component.py should look like this:
from mimosa.common import (
ConcreteModel,
RegionalEquation,
GlobalEquation,
Var,
Param,
)
from mimosa.core.model_inputs import ModelInputs
def get_constraints(m: ConcreteModel, inputs: ModelInputs):
"""Fictional ice-cream sales benefits for the guided exercise."""
m.icecream_sales_benefit = Var(
m.t,
m.regions,
doc="Fictional economic benefits from increased ice-cream sales, as a fraction of gross GDP, relative to the model start.",
)
m.icecream_benefit_coefficient = Param(
initialize=inputs.config("economics.damages.icecream_benefit_coefficient"),
doc="Fictional ice-cream sales benefit fraction per degree of warming above the model's initial temperature.",
)
constraints = [
RegionalEquation(
m.icecream_sales_benefit,
lambda m, t, r: m.icecream_benefit_coefficient * (m.temperature[t] - m.T0),
),
]
return constraints