GithubHelp home page GithubHelp logo

kth-desa / osemosys_step Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 2.0 288 KB

Scripts to conduct myopic runs with OSeMOSYS models

License: MIT License

Python 100.00%
osemosys energy-system-modelling energy energy-system open-source

osemosys_step's Introduction

OSeMOSYS step

This repository contains a set of scripts to conduct model runs with limited foresight with OSeMOSYS models.

osemosys_step's People

Contributors

hauhe avatar

Watchers

 avatar  avatar  avatar

Forkers

trevorb1 hauhe

osemosys_step's Issues

Limits clashing with solver tolerance

When passing the installed capacity from one step to the next OSeMOSYS might crash if the installed capacity passed is slightly higher than implemented limits due to the tolerance of solvers.

sol-files taking storage space

The sol files created when solving with gurobi or cplex take significant storage space. They could be deleted after the conversion of the results to csv.

Package OSeMOSYS_step

To ease the use of the scripts and facilitate easy integration in workflows it would be good to create a package of the scripts.

Function to create folder structure locally

To package the tool so that it can be installed locally, write a function which creates the desired folder structure in a user-defined location. For example, the command:

step create ./my_folder/my_myopic_model

would create the desired folder structure containing data scenarios, model, results and steps. A second command:

step run ./my_folder/my_myopic_model

would then run the workflow on the folder structure.

No final results generated if no step has options

If no step has options the results of the steps are not merged in the results folder.
Issue is that main.py in line 431 searches for subdirectories in ../results but if no step has option no subdirectories exist.

Snakemake bug

The current snakefile doesn't produce any output and gives the below bug.
(osemosys_step) KTH-dESA/OSeMOSYS_step - (snakemake) > snakemake --cores 1 Academic license - for non-commercial use only - expires 2021-10-07 Using license file /Users/cotti/gurobi.lic No parameters matching '_test' found SyntaxError in line 16 of /Users/cotti/GitHub/KTH-dESA/OSeMOSYS_step/Snakefile: invalid syntax (Snakefile, line 16)

Add check if snakemake is installed

The error one get's if snakemake is not installed doesn't indicate that it is related to the missing installation. A upfront check for the installation might be useful

Integrate lp generation into snakemake workflow

The generation of lp file can take quite some time for larger models. Hence it would be good to parallelize this part as well.
Do you think this would be very complicated @trevorb1?
I think in the original scripts I had it within the script called by snakemake.

Solver integration

In the current step function the models are run with GLPK.
Especially for large models other solvers like gurobi, cbc, or cplex are commonly used.
It would be good to write an integration for those. The desired solver could be provided as an argument.
To consider is that glpk is needed to generate the lp file.

User determined foresight

Allow the user to determine the foresight the step models should have.
Currently the foresight in each step is the same length as the step, i.e. with a step length of 5 years, the foresight is five, which means the model covers 10 years.
However, it would be interesting to be able to investigate the effect of different foresight horizons. Considering that many power plants have a life time of approximately 25 years a model horizon of 25 years would be interesting. The step length could be 5 years and the foresight 20.
My suggestion would be to leave the current behaviour of doubling the step length to determine the model length as default, but allow to provide the desired foresight as an additional input.
What do you think @trevorb1?

ERROR:utils:Step must be of type int or List[int]

When running main.py with python main.py --step_length 5 I get an error saying that the there is no sol file produced from step 0. In the log file I see the below message:
ERROR:utils:Step must be of type int or List[int]. Recieved type <class 'tuple'> WARNING:otoole.read_strategies:Parameter ResultsPath could not be found in the configuration.

Stranded assets

In a myopic setting the likelihood for stranded assets is higher than under perfect-foresight.
It would be interesting to add the required calculations in this package or in otoole.

Add option for cbc

In the solv.py script option could be created to run the models with cbc.

Merge of ResidualCapacity and NewCapacity

When running a model that with a TotalAnnualMaxCapacity of 6GW on a certain technolgy the model installs in step 4 in 2035 3 GW and in 2039 again 3 GW. So far no step had options, but the next step, step 5 has one decision with two options. However, here the run crashes at the osemosys check of ResidualCapacity and TotalAnnualMaxCapacity. The two models for step 5 both show a ResidualCapacity of 9GW, even though it should be 6, not just because of the limit but also because in step 4 there were twice 3 GW installed.

I know you are currently very time constrained, but if you have 20 minutes to spare today could you have a look @trevorb1?
Otherwise, I will give it a go tomorrow. But it seems odd to me. Had we not already looked into the logic of adding ResidualCap. and NewCap.?

the change of input parameter over time depends on the decisions of previous steps

the current set-up of the step scripts works well for decisions that can be described as ON/OFF.
However, decisions like for example the pace of emission reductions can't be done. The issue is that previous decisions affect the starting point of the next step.
To represent such decions it would be good to be able to indicate the different paces of reduction e.g. 5% or 10% and then calculate the time series for the upcoming step using the last year of the previous modelling period as a starting point.

Use gurobipy

For running models with gurobi one could use gurobipy instead of calling gurobi via subprocess

Option to run with perfect foresight and scenarios

A option to run the model under perfect foresight while providing scenario options like in the myopic set up with limited foresight would facilitate to have one base case/reference scenario of a model and then run scenarios without creating each time by hand a modified new model file/set of csv files.

Residual Capacity + NewCapacity

Hi @trevorb1, I have gone through the results. I can't explain all differences, but I see that it seems like the NewCapacity of RHO, I don't know if others as well, from step 0 is not passed on to step1, this makes the model at the beginning of step1 install the amount that is missing. Not sure why this capacities are not passed on.

Rounding of solver tolerated values leaves too many values

In the merge of ResidualCapacity and NewCapacity the New capacity is currently rounded to 4 digits behind the dot. However this still creates errors with TotalAnnualMaxCapacity limits. Since these limits are often having one digit behind the point I suggest to reduce the rounding to one digit behind the point.
The alternative would be to use np.floor but that could potentially cause a significant loss of capacity between steps.

Passing of NewCapacity doesn't work as expected

Hi @trevorb1,
When digging into the input data and results, I noticed, that the calculation of the ResidualCapacity doesn't work as expected.
I notice that NewCapacity is also passed from years that are not in the step but in the foresight horizon, e.g. with a five year step length and model starting in 1990, NewCapacity from 1996 and onwards should not be added to the next step anymore.
Haven't looked into the scripts yet. Might not manage to do so today, so if you have time ;)

Use provided model file independent of it's name

Currently the scripts are using a model file called osemosys.txt. If one wants to use a modified or specific version of osemosys it might be nice to indicate that in the file name. this could be done by letting the script check the files in the model folder and throw a bug if there are more files than expected.

ilp logs are written into step directory, which then deleted

When a model is infeasible gurobi produces a ilp file which can be useful to understanding why a model is infeasible. The file is written into the corresponding step directory. However, if the model is infeasible, this directory is deleted, which makes it difficult to understand why a model is infeasible...

Subprocess on Windows

It seems like on Windows the calling of snakemake from the python script via subprocess doesn't work.
A solution that works on Unix and Windows would be desirable.

check of feasibility for gurobi missing

This kills the process when scenarios are infeasible.
It seems like when infeasible gurobi writes an ilp-file AND an empty .sol-file

@trevorb1, since you wrote the other tests and in case you have 15 minutes could you give it a go?
Otherwise, don't worry, I can do it tomorrow.

[Packaging] Error: Snakefile not found

When calling the package outside the cloned repo, the snakefile is not found.

Problem is that the path is relative.

Error: Snakefile "src/osemosys_step/snakefile" not found.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.