Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up Materials migration branch #189

Merged
merged 60 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
efd1bec
Addition of data files and sets
GamzeUnlu95 Sep 15, 2020
9e460ad
Resolve conflict 2
macflo8 Apr 22, 2024
a859eef
Resolve rebase conflict
macflo8 Apr 22, 2024
636916b
Test run with china model
Jihoon Oct 12, 2020
572c64c
Updated data with cement
Jihoon Oct 19, 2020
508b09f
Data updated
GamzeUnlu95 Oct 22, 2020
2b5d219
Data update
GamzeUnlu95 Oct 23, 2020
948f5cb
Add sets for petrochemical sector
GamzeUnlu95 Oct 29, 2020
806c01b
Changes to integrate petro_chemicals
GamzeUnlu95 Nov 11, 2020
2eb478e
Updated buildings data
Jihoon Jan 25, 2021
46577e5
Add initial scripts and data for buildings work
Jihoon Jan 21, 2021
8a312c5
Resolve rebasing conflict with buildings file
macflo8 May 23, 2024
402d8e4
Resolve rebase conflict 3
macflo8 Apr 22, 2024
874fb4f
Small correction of description
volker-krey Mar 22, 2021
440d227
Update data
GamzeUnlu95 May 21, 2021
c570322
Fix data files
GamzeUnlu95 May 27, 2021
09bd802
Update region names in the data files for r12
GamzeUnlu95 Jun 8, 2021
87998bc
Update the region names to r12
GamzeUnlu95 Jun 9, 2021
f057b73
Remove unnecessary vintage years
GamzeUnlu95 Mar 1, 2022
f641b5c
Update n-fertilizer_techno-economic_new.xlsx
GamzeUnlu95 Mar 3, 2022
5c71658
Fix ccs units
GamzeUnlu95 Mar 30, 2022
47389ad
Update data to match base year statistics
GamzeUnlu95 Apr 25, 2022
a6577c6
Resolve conflict with input filea
macflo8 May 10, 2024
7ddb914
Remove deprecated input files and modules
macflo8 Apr 23, 2024
fcf7a6b
Modify imports and adjust data handling
macflo8 Apr 23, 2024
68910ca
Register material-ix as subcommand in CLI
macflo8 Apr 23, 2024
94f4e43
Fix typo in parameter string
macflo8 Apr 23, 2024
49ba610
Remove duplicated function definition
macflo8 Apr 24, 2024
cc9be29
Remove unused technology from set.yaml
macflo8 Apr 24, 2024
a5001c9
Remove deprecated files from rebase
macflo8 May 10, 2024
9cb260c
Delete duplicated codes in set.yaml
macflo8 May 10, 2024
ec87103
Apply ruff reformatting
macflo8 May 10, 2024
86a29ca
Add docstrings and type hints for materials util functions
macflo8 May 10, 2024
47db910
Change data input directory to message-ix-models
macflo8 May 10, 2024
3cd63f5
Resolve code quality warnings
macflo8 May 13, 2024
4580fb6
Apply black to materials modules
macflo8 May 13, 2024
a480bc2
Resolve remaining code quality issues
macflo8 May 13, 2024
b4886bd
Resolve code quality issues in materials reporting
macflo8 May 13, 2024
b1352f6
Resolve code quality issues in material demand module
macflo8 May 13, 2024
0654db4
Remove ntfy in materials commands
macflo8 May 13, 2024
02b905e
Comment unused variable in reporting
macflo8 May 13, 2024
ddfa1f3
Delete unused materials submodule
macflo8 May 13, 2024
6c48963
Refactor materials data module functions
macflo8 May 15, 2024
6a2ab7b
Add missing import for materials build
macflo8 May 16, 2024
7d0845a
Fix wrong data paths
macflo8 May 16, 2024
3b2e3cd
Apply formatting to data_util
macflo8 May 16, 2024
277c2f5
Add missing parameter in docstring in bare.py
macflo8 May 16, 2024
d12642b
Add comment to FIXME mnemonic
macflo8 May 16, 2024
e88d836
Migrate functions required by materials reporting from m_data
glatterf42 May 17, 2024
d39c074
Mark forgotten personal reference as FIXME
glatterf42 May 17, 2024
5f8e890
Format and tidy up reporting notebook
glatterf42 May 17, 2024
0b49e53
Adapt final imports from message_data
glatterf42 May 17, 2024
4150176
Migrate more required functions from m_data
glatterf42 May 17, 2024
ef842df
Reduce complexity of methanol module
macflo8 May 21, 2024
19d04fb
Apply ruff format to data_util
macflo8 May 21, 2024
cb3031f
Apply ruff formatting with ruff 0.4.4
macflo8 May 21, 2024
2e26923
Move doc file and update
macflo8 May 21, 2024
39d494f
Reformat materials demand module after rebase
macflo8 May 23, 2024
63ec181
Delete unused data files from data/material
macflo8 May 23, 2024
cc2e59f
Add #188, #189 to doc/whatsnew
macflo8 May 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
191 changes: 191 additions & 0 deletions doc/material/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
MESSAGEix-Materials
********************

Description
===========

This module adds material stock and flow accounting in MESSAGEix-GLOBIOM. The implementation currently includes four key energy/emission-intensive
material industries: Iron&Steel, Aluminum, Cement, and Chemicals.

.. contents::
:local:

Code reference
==============

.. automodule:: message_ix_models.model.material
:members:

.. automodule:: message_ix_models.data.material
:members:

Data preparation
----------------

These scripts are used to prepare and read the data into the model. They can be turned on and off individually under `DATA_FUNCTIONS` in `__init__.py`.
For example, the buildings script (`data_buildings.py`) is only used when the buildings model outputs are given explicitly without linking the
CHILLED/STURM model through a soft link.

.. automodule:: message_ix_models.model.material.data_aluminum
:members:

.. automodule:: message_ix_models.model.material.data_steel
:members:

.. automodule:: message_ix_models.model.material.data_cement
:members:

.. automodule:: message_ix_models.model.material.data_petro
:members:

.. automodule:: message_ix_models.model.material.data_power_sector
:members:

.. automodule:: message_ix_models.model.material.data_buildings
:members:

.. automodule:: message_ix_models.model.material.data_generic
:members:

.. automodule:: message_ix_models.model.material.data_ammonia_new
:members:

.. automodule:: message_ix_models.model.material.data_methanol_new
:members:

Build and Solve the model from CLI
==================================

Note: To include material stocks from power sector message_ix should be the following version from source:
https://github.com/iiasa/message_ix/tree/material_stock

Use ``mix-models materials-ix build`` to add the material implementation on top of existing standard global (R12) scenarios, also giving the base scenario and indicating the relevant data location, e.g.::

$ mix-models \
--url="ixmp://ixmp_dev/MESSAGEix-GLOBIOM 1.1-R12/baseline_DEFAULT#21" \
--local-data "./data" material-ix build --tag test

The output scenario name will be baseline_DEFAULT_test. An additional tag `--tag` can be used to add an additional suffix to the new scenario name.
The mode option `--mode` has two different inputs 'by_url' (by default) or 'by_copy'. The first one uses the provided url to add the materials implementation on top of the scenario from the url.
This is the default option. The latter is used to create a 2 degree mitigation scenario with materials by copying carbon prices to the scenario that is specified by `--scenario_name`.

$ mix-models material-ix build --tag test --mode by_copy --scenario_name baseline_DEFAULT_test.

This command line only builds the scenario but does not solve it. To solve the scenario, use ``mix-models materials-ix solve``, giving the scenario name, e.g.::

$ mix-models material-ix solve --scenario_name baseline_DEFAULT_test --add_calibration False --add_macro False

The solve command has the `--add_calibration` option to add MACRO calibration to a baseline scenario. `--add_macro` option solves the scenario with MACRO.
Both options are False by defualt. To first calibrate the scenario and then solve that scenario with MACRO both options should be set to True.

Reporting
=========

The reporting generates specific variables related to materials, mainly Production and Final Energy.
The resulting reporting file is generated under message_ix_models\\data\\material\\reporting_output
with the name “New_Reporting_MESSAGEix-Materials_scenario_name.xlsx”. More detailed
variables related to the whole energy system and emissions are not inlcuded in
this reporting.

Reporting is executed by the following command:

$ mix-models --url="ixmp://ixmp_dev/MESSAGEix-Materials/scenario_name" --local-data "./data" material-ix report

To remove any existing timeseries in the scenario the following command can be used:
$ mix-models --url="ixmp://ixmp_dev/MESSAGEix-Materials/scenario_name" material-ix report --remove_ts True

Data, metadata, and configuration
=================================

Binary/raw data files
---------------------

The code relies on the following input files, stored in :file:`data/material/`:

:file:`CEMENT.BvR2010.xlsx`
Historical cement demand data

:file:`STEEL_database_2012.xlsx`
Historical steel demand data

:file:`Global_steel_cement_MESSAGE.xlsx`
Techno-economic parametrization data for steel and cement sector combined (R12)

:file:`demand_aluminum.xlsx`
Historical aluminum demand data

:file:`demand_aluminum.xlsx`
Historical aluminum demand data

:file:`aluminum_techno_economic.xlsx`
Techno-economic parametrization data for aluminum sector

:file:`generic_furnace_boiler_techno_economic.xlsx`
Techno-economic parametrization data for generic furnace technologies

:file:`iamc_db ENGAGE baseline GDP PPP.xlsx`
SSP GDP projection used for material demand projections

:file:`MESSAGEix-Materials_final_energy_industry.xlsx`
Final energy values to calibrate base year values for industries

:file:`residual_industry_2019.xlsx`
Final energy values to calculate the residual industry demand.

:file:`nh3_fertilizer_demand.xlsx`
Nitrogen fertilizer demand

:file:`fert_techno_economic.xlsx`
Techno-economic parameters for NH3 production technologies

:file:`cost_conv_nh3.xlsx`
Cost convergance parameters for NH3 produciton technologies

:file:`methanol demand.xlsx`
Methanol demand

:file:`methanol_sensitivity_pars.xlsx`
Methanol sensitivity parameters

:file:`methanol_techno_economic.xlsx`
Techno-economic parameters for methanol production technologies

:file:`petrochemicals_techno_economic.xls`
Techno-economic parameters for refinery and high value chemicals production technologies

:file:`steam_cracking_hist_act.csv`
Steam cracker historical activities

:file:`steam_cracking_hist_new_cap.csv`
Steam cracker historical capacities

:file:`NTNU_LCA_coefficients.xlsx`
Material intensity (and other) coefficients for power plants based on lifecycle assessment (LCA) data from the THEMIS database, compiled in the `ADVANCE project <http://www.fp7-advance.eu/?q=content/environmental-impacts-module>`_.

:file:`MESSAGE_global_model_technologies.xlsx`
Technology list of global MESSAGEix-GLOBIOM model with mapping to LCA technology dataset.

:file:`LCA_region_mapping.xlsx`
Region mapping of global 11-regional MESSAGEix-GLOBIOM model to regions of THEMIS LCA dataset.

:file:`LCA_commodity_mapping.xlsx`
Commodity mapping (for materials) of global 11-regional MESSAGEix-GLOBIOM model to commodities of THEMIS LCA dataset.

:file:`SSP_UE_dyn_input.xlsx`
Calibration of end-use energy demands

:file:`material/set.yaml`
----------------------------

.. literalinclude:: ../../../data/material/set.yaml
:language: yaml

R code and dependencies
=======================

:file:`init_modularized.R`
This code performs regression analysis to generate the steel, cement and aluminum material demands based on historical GDP per capita data.
The regression function is later used in python data code of the relevant material to predict the future demand based on GDP and population
projections. This code is linked to Python workflow via the Python package `rpy2`. Depending on the local R installation(s), the environment
variables `R_HOME` and `R_USER` may need to be set for the installation to work (see `stackoverflow <https://stackoverflow.com/questions/12698877/how-to-setup-environment-variable-r-user-to-use-rpy2-in-python>`_).
Additional dependencies include the R packages `dplyr`, `tidyr`, `readxl` and `imputeTS` that need to be installed in the R environment.
1 change: 1 addition & 0 deletions doc/whatsnew.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ What's new
Next release
============

- Add :doc:`/material/index` (:pull:`188`, :pull:`189`).
Changes to :doc:`/api/tools-costs`
----------------------------------
- Fix jumps in cost projections for technologies with first technology year that's after than the first model year (:pull:`186`).
Expand Down
1 change: 1 addition & 0 deletions message_ix_models/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ def _log_threads(k: int, n: int):
"message_ix_models.model.water.cli",
"message_ix_models.project.ssp",
"message_ix_models.report.cli",
"message_ix_models.model.material",
"message_ix_models.testing.cli",
"message_ix_models.util.pooch",
]
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

3 changes: 0 additions & 3 deletions message_ix_models/data/material/deprecated/demand_petro.xlsx

This file was deleted.

This file was deleted.

This file was deleted.

3 changes: 0 additions & 3 deletions message_ix_models/data/material/deprecated/trade.FAO.R12.csv

This file was deleted.

3 changes: 0 additions & 3 deletions message_ix_models/data/material/high_demand_output.xlsx

This file was deleted.

Git LFS file not shown
Git LFS file not shown
2 changes: 1 addition & 1 deletion message_ix_models/data/material/set.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# accounting. Different sets can be created once there are 2+ different
# categories of materials.


common:
commodity:
require:
Expand Down Expand Up @@ -317,7 +318,6 @@ steel:
- pellet_steel
- bf_steel
- dri_steel
- sr_steel
- bof_steel
- eaf_steel
- prep_secondary_steel_1
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Loading