A Python module for the Environmentally Constrained Optimization of Prospective Technology Transitions (ECOPT2).
ECOPT2 is a generalized and adaptable model that combines life cycle assessment (LCA), dynamic stock modelling and linear programming (LP) to assess environmentally optimal widescale deployment strategies for emerging technologies.
It is recommended that you create a virtual environment to install and run ECOPT2 in.
In the virtual environment, install the GAMS Python API.
Clone this repository to your local machine to install ECOPT2.
- gams
- pandas
- scipy
- numpy
- matplotlib
- cycler
- pyYAML
- dataclasses
Users provide input via Excel spreadsheets and a YAML file:
- sets.xlsx: Defines the members of each set in the LP model. The first line is the set names (must match names as defined in LP). Set members are listed in the column below each set name.
- GAMS_input.xlsx: Provides exogeneous data to feed the LP model. Each tab in the spreadsheet is named to match parameter names in ECOPT2. Further details are provided in the sample file in this repository.
- GAMS_input.yaml: File defining values for parameters for experiments. Multiple values can be defined for each parameter; ECOPT2 will perform experiments covering all combinations of all parameter values provided. Parameter values are provided by listing the parameter name (must match name in Python code and/or LP ), an experiment alias, and the parameter values as a scalar, list or dictionary (see e.g., here for a tutorial on YAML syntax)
Run models using main.py. In this file, you can specify the experiment type (e.g., demo, unit test or normal) and visualization options. Included in this repository is a demo experiment for a simple, stylized scenario, which is set up to run by default. Users can also specify what file format to export result figures in (.png or .pdf), whether to visualize input parameters for troubleshooting, and whether to export cross-experiment results.
Each experiment output is saved in its own folder, and includes the visualization output, a log file, the GAMS result file in .gdx format and a pickle containing the experiment's FleetModel object.
ECOPT2.gms: linear program (LP) model implemented in GAMS.main.py: user-specified experiment definition, file paths and visualization options.fleet_model_init.py: contains SetsClass and ParametersClass dataclasses (subclasses of FleetModel). Loads user input data from Excel and YAML files, performs necessary data handling and rudimentary quality checks.fleet_model.py: defines FleetModel class. With functionality for data exchange from GAMS data structures to FleetModel objectgams_runner.py: interface to GAMS. Initializes GAMS workspace and loads FleetModel object to GAMS data structures usinggmspy. Runs LP (ECOPT2.gms).visualization.py: performs result visualization and, optionally, visualization of input data for debugging
\data\: contains input files for experiment\demo\: contains demo experiment forgmspy\output\: contains results, including visualization, logfile and.gdxfiles from experiments. Figures can be exported as .png and/or .pdf.
electricity_clustering.py: calculate impact intensity of national/regional electricity mixes based on generation technologies and create clusters of regions with similarly intensive electricity mixes; projects (macro)regional trends in electricity mixes from IAMs to individual states. Has dependencies:country_converter,geopandasandjenkspyiam_parser.py: general utility for parsing data from integrated assessment models using the IAMC data format for time seriesgmspy.py: utility code for bilateral data exchange between Python and GAMS
This code is licensed under the BSD 3.0 license.