This repo contains code developed by the Analysis team at TransitionZero (TZA) to build and solve with PyPSA models. TZA-PyPSA allows us to modularly construct and work with PyPSA network models.
TZA-PyPSA can be used to build a PyPSA model from scratch, but there are a set of pre-built models that a user can call as a starting point for their analysis. Please see all pre-built models are available in tza-pypsa here. See instructions below on how to use a pre-built model or how you can build your own.
Model construction and validation:
Data:
Firstly, clone or download this repository (or an older version) and then navigate into the directory.
cd tza-pypsa
Next, install tza-pypsa into your local environment by running:
pip install -e .
That's it! You are now ready to use tza-pypsa as shown below. However, you will need to install additional packages before doing so, which are:
You can either build your model or use a pre-built model. With a pre-built model, you can construct and run a PyPSA model with only a few lines of code. For instance, you can run the ASEAN at an hourly resolution between 2023 and 2050 at 10-year timesteps as shown below:
from tz_pypsa.model import Model
from tz_pypsa.constraints import constr_bus_self_sufficiency
# load a pre-defined stock model (returns PyPSA network)
network = (
Model
.load_model(
'ASEAN',
years=[2023, 2030, 2040, 2050],
frequency='1h'
)
)
# add stock constraints ((optional))
constr_bus_self_sufficiency(network)
# solve the model
network.optimize(
solver_name='highs',
solver_options={"solver": "pdlp"},
)
# export results to csv
network.export_to_csv_folder('some-output-folder-name')Please see one of the pre-built models to understand how the files should be written and structured.
We strongly welcome anyone interested in contributing to this project. If you have any ideas, suggestions or encounter problems, feel invited to file issues or make pull requests on GitHub.
To discuss ideas for the project, please contact @amanmajid
- Do not contribute to master directly without a pull request, wherever possible.
- Create issues and allocate an individual.
- One pull request per issue.