![Open Energy Transition Logo](https://private-user-images.githubusercontent.com/53824825/257832183-ca7893de-26e2-47ad-a3e4-d91cd6716652.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjM4MDg0NjksIm5iZiI6MTcyMzgwODE2OSwicGF0aCI6Ii81MzgyNDgyNS8yNTc4MzIxODMtY2E3ODkzZGUtMjZlMi00N2FkLWEzZTQtZDkxY2Q2NzE2NjUyLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MTYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODE2VDExMzYwOVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTZkMGNlNTZmZDhiMDg0NGZlNTQ5MzVkM2FiZjhhYTM4MTlmNjc2ZjhjOTg5Y2VjMjU1ZmRjZTY5MjgwYjUxYWEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.oR_6wEb2UB-b4xYeu0NrZWlOBGqsHQQhjmmpXze8og8)
![Agora Energiewende Logo](https://private-user-images.githubusercontent.com/53824825/257833590-63bd0250-c54a-4ce1-8df3-eb116baac01b.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjM4MDg0NjksIm5iZiI6MTcyMzgwODE2OSwicGF0aCI6Ii81MzgyNDgyNS8yNTc4MzM1OTAtNjNiZDAyNTAtYzU0YS00Y2UxLThkZjMtZWIxMTZiYWFjMDFiLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MTYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODE2VDExMzYwOVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTc3MGM2OWM4MjZkZWQzNTEwMDAyMzJlOWRiMzU3MDFlMWQ1NTA5ZDkzY2NjZjM1YzIzN2QyMzA0M2YwNTBlZTgmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.pSt4N7_ePen3Nj627aCbOqBwwoLcj4ebE6P2qcHjWhQ)
Agora Energiewende aims to model the Kazakh power system, incorporating a substantial increase in variable generation, such as solar and wind, surpassing the current official mid-term policy goal of 15% of all renewable energy sources (RES) in generation by 2030. This endeavor has received support from Open Energy Transition on the modeling side.
Extra data for the Kazakhstan model that will be used as input for PyPSA-Earth. Repo design oriented on: https://github.com/pypsa-meets-earth/pypsa-zm-data
Contains openly available data for Kazakhstan
Monthly electricity demand data with monthly aggregation provided by Kazakhstan operator of the electric energy and power market
kz_demand_validation.csv
(demand_valid_clean.R
contains for details on how data were extracted and a simple vizualization; needs to work any R terminal + installation of two libraries)
The provided workflow builds on PyPSA-Earth. Therefore, first, the PyPSA-Earth repository must be forked and the fork should then be cloned. A fork can be created by navigating to the PyPSA-Earth website. By clicking on the fork-symbol in the upper right corner, a fork is created and linked to the specific user.
Next, we also need to fork the pypsa-kz-data repository. A fork can be created by navigating to the pypsa-kz-data website and clicking the fork symbol in the upper right corner.
In order to clone both forks to the correct locations on a local machine, the following commands can be used using the local machines shell:
git clone https://github.com/<user-name>/pypsa-earth
<user-name>
must be replaced with the personal github-username.
After that, one must change to the freshly created pypsa-earth repository.
cd pypsa-earth/
and repeat the cloning, this time for the pypsa-kz-data repository.
git clone https://github.com/<user-name>/pypsa-kz-data
Again, <user-name>
must be replaced with the personal github-username.
In order to install the pypsa-earth environment, instructions are provided in the pypsa-earth documentation, see Install dependencies
and Python dependencies
.
After installing the environment, activate it using
conda activate pypsa-earth
Before the whole workflow can be executed, the databundle must be retrieved. This can be done via:
snakemake -j 1 retrieve_databundle_light
This step can optionally be skipped if the data/
folder with all relevant subfolders already exists.
To adapt the overall workflow for kz, only three further changes are necessary:
- replace the
pypsa-earth/data/custom_powerplants.csv
with the providedpypsa-kz-data/data/custom_powerplants.csv
. This can be done using the command:
cp pypsa-kz-data/data/custom_powerplants.csv data/custom_powerplants.csv
- Open the Snakefile (in
pypsa-earth/
) and navigate to line 25, which should readconfigfile: "config.yaml"
. Replace this line withconfigfile: "pypsa-kz-data/config_kz_default.yaml"
. To run the default scenario for different weather years (2011, 2013, 2018), add a new line below (line 26) withconfigfile: "pypsa-kz-data/config_kz_<year>.yaml"
, where<year>
represents an existing weather year (2011, 2013, 2018).
The whole workflow can be reproduced by executing
snakemake -j 1 solve_everything
- Only for scenarios: To run a certain scenario, make sure to update the 2nd config file, i.e. navigate to line 26 in the Snakefile, which now should read:
configfile: "pypsa-kz-data/config_kz_<year>.yaml"
and replace this with the scenario you want to execute:configfile: "pypsa-kz-data/config_kz_<year>_discount<p>.yaml"
.<year>
and<p>
must be replaced with existing years (2011, 2013, 2018) and discount rates (10 for optimistic scenario, 15 for BAU and 20 for pessimistic scenario). To run the coal exit scenario, the corresponding config file also must be referred in line 26 of theSnakemake
. For this setting, the line must readconfigfile: "pypsa-kz-data/config_kz_<year>_discount<p>_coalexit.yaml"
, where<year>
and<p>
are the weather year (2011, 2013, 2018) and discount rates (10, 15, and 20).
Again, the whole workflow can be reproduced by executing the same command as above:
snakemake -j 1 solve_everything
Results are generated and locally saved in pypsa-earth/results/<scenario_folder>/networks/
.
-
A rule is killed. In this case, open the
Snakefile
inpypsa-earth
or openkz.smk
inpypsa-kz-data
(depending on the rule which is killed), navigate to the rule that is being killed in the workflow and increase the memory assignment (for example, add a 0 at the end). -
The workflow runs into an error during the
build_powerplants
rule. In this case, try to repeat step 1. of the workflow using the command
cp pypsa-kz-data/data/custom_powerplants.csv data/custom_powerplants.csv
- Unusual error arising from either Snakemake or the
Snakefile
and proving to be challenging to comprehend: Inspect all indentation. Ensure there is no tab spacing; employ only spaces, i.e.,configfile: 'pypsa-kz-data/config_kz_<...>.yaml'
are tabs instead of four spaces.
After all cutouts were generated (i.e. the three files asia-<year>-era5.nc
exist in the folder pypsa-earth/cutouts/
, where <year>
is 2011, 2013, and 2018, navigate to pypsa-earth/pypsa-kz-data
, open the default config file, navigate to line 36, which should read build_cutout: True
, and set it to build_cutout: false
. This will save you a lot of time when (re-)runnig scenarios. But remember to set it back to true
in case one of the cutouts was deleted!
Code development and testing: Open Energy Transition
Model assumptions: Agora Energiewende