Giter Club home page Giter Club logo

oemoflex's Introduction

oemoflex

oemoflex is a flexible model structure for creating and analysing multi-regional sector-integrated energysystem models featuring many flexibility options.

oemoflex makes it easy to create datapackages that represent energy systems that can be optimized with oemof.solph. It also helps to postprocess the results so that you can focus on your main tasks of modeling: Finding good data and drawing assumptions to build meaningful scenarios and interpret them.

The core parts of oemoflex have been originally developed in the project FlexMex. Its main application is currently within the energy system model oemof-B3.

Getting started

Installation

You can install oemoflex in your environment for developing with pip:

pip install -e <path-to-oemoflex>

Usage

Have a look at the examples to see how to create an EnergyDataPackage by specifying the components, busses, regions and links, how to parametrize it and how to pass it to oemof.solph to solve the optimization problem.

Docs

Online documentation is hosted by readthedocs and can be found here. The docs are currently under construction.

To build the docs simply go to the docs folder

cd docs

Install the requirements

pip install -r docs_requirements.txt

and run

make html

The output will then be located in docs/_build/html and can be opened with your favorite browser

oemoflex's People

Contributors

henhuy avatar jnnr avatar juliusmeier avatar magering avatar sabinehaas avatar stefanie08 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

monika-o

oemoflex's Issues

Column order and index when stacking/unstacking

  • For stacking/unstacking to be reversible, the columns have been sorted. This is not ideal. The index order could be retained when unstacking. However, if some other step is performed with the stacked data, that information would be lost.
  • This has consequences even here!:
    # sort the columns for comparability
    component_df = pd.DataFrame(comp_data).set_index("name")
    component_df = component_df[sorted(component_df.columns)]
  • There is no guarantee that the index of the dataframes is always the same. When load from_csv_dir, DataFramePackage assumes index_col=0.
  • This is connected to
    # TODO: Check if this step is necessary only because function is used differently in some cases.
    _stacked_frame = stacked_frame.reset_index()

Bug: RTD build fails to install package

RTD fails to install package due to dependency problems. setuptools 58 stopped supporting use_2to3, which is needed by simpleeval.

As a temporary fix it has been suggested to pin setuptools < 58 as long as some packages have not dropped the dependency on use_2to3.

No capacity_potential in facade_attrs

Facades that can be expandable have an attribute capacity_potential, which means the maximal possible capacity. It is missing in facade_attrs.

How to fix that? Have a look at the files in oemoflex/model/facade_attrs/. Each file describes the attributes that the respective facade has. Have a look at oemof.tabular.facades to see which facade classes have the attribute capacity_potentialand if they do, add a line in the respective file in oemoflex/model/facade_attrs/<file_name.csv>.

Results check

There are different ways to check the results.
One opportunity is to check the results of electricity supply and demand:
(Background: I checked the oemof-B3 results data for the bus BB-electricity and demand minus supply was not always zero.)

  • Calculate the balance in every time step. (supposed to be zero)

Move functionality to oemof.tabular

The generic functionality here can move step-by-step to oemof.tabular. If most or all can be moved, this would make maintenance easier.

These can be addressed one after the other:

  • Postprocessing (after #82 is merged and tested in practice for a bit)
  • Plots

These belong together

  • DataFramepackage class
  • Define schemas for tabular data packages that describe energy systems in facade_attrs and the available components and busses in component_attrs.yml and busses.yml
  • Setup datapackages by passing the lists of regions, links, busses and components to EnergyDataPackage.setup_default. Custom-defined busses and components can be passed as dictionaries bus_attrs_update and component_attrs_update.
  • Parametrize the EnergyDataPackage with EnergyDataPackage.parametrize
  • stacking, unstacking
  • sensitivity

This could be checked, too:

  • Infer metadata (mainly done by oemof.tabular already, but maybe there are some extra features that can improve tabular).

Shrink component_attrs

Proposal:

  • Could remove all component attributes where no default is set and draw the attributes from the facade (defined by type) when creating empty dataframes.
  • Could also remove region and name, as these are there by default

Con: This would mean that component_attrs are not a comprehensive documentation of the attributes any more.

Docs missing

There is no docs. The readme should be more descriptive as well.

Capacity in postprocessed misses information about which bus it is connected to

Capacity is set to a flow in a component, internally. The postprocessed data does not tell to which bus it is connected.

Suggestion: Do not collect capacity. but rather nominal value of the flow.

capacity = filter_by_var_name(scalar_params, "capacity")
from_to_capacity = filter_by_var_name(scalar_params, "from_to_capacity")
to_from_capacity = filter_by_var_name(scalar_params, "to_from_capacity")

Postprocessed data is not documented

The variable names that appear in postprocessed data should be documented. In the course of that, we can check if the naming system is consistent.

Missing single-node model

So far, modeling with a single-node does not seem to be possible in oemoflex.

setup_default function requires positional argument 'links'

Release v0.0.3

Preparation

  • Finish issues and PRs related to the release
  • Increase version that is installed running pip install oemoflex
  • Test the examples
  • Keep an eye on open issues that are set to your release but seem to be forgotten.
  • Check that the docs look good.

Day of release

  • Optional: Open a release branch to avoid conflicts with other uses while the release progress.
  • Close "forgotten" issues with a recapitulatory comment or set them to a later release if they are still important.
  • Test if everything works
  • If you have failing test fix them or postpone the release.
  • Check the whatsnew-file
  • Check if the latest documentation looks right at readthedocs.
  • Change the version number everywhere!!! (e.g. from 0.2.1dev to 0.2.1) -> pyproject.yaml and docs/conf.py
  • If everything seems to work, merge the release branch into the main branch. (--no-ff)
  • Push your local main branch to the remote.
  • Set a release on github. Select the main branch (default: dev)! A label is set automatically.
  • Use git fetch to see the label in your local main branch.
  • Merge the release branch into the dev branch. (--no-ff)
  • Remove the obsolete release branch.
  • Prepare the dev branch for further development: Adapt the version number at (e.g. from 0.2.1 to 0.2.2dev). Also add a new whatsnew file and a link in the whatsnew.rst file. Open the file locally or use the RAW button to see the links.
  • Close the release issue with informations for the community and relax

Release v0.0.1

Preparation

  • Finish issues and PRs related to the release
  • Increase version that is installed running pip install oemoflex
  • Test the examples
  • Keep an eye on open issues that are set to your release but seem to be forgotten.
  • Check that the docs look good.

Day of release

  • Optional: Open a release branch to avoid conflicts with other uses while the release progress.
  • Close "forgotten" issues with a recapitulatory comment or set them to a later release if they are still important.
  • Test if everything works
  • If you have failing test fix them or postpone the release.
  • Check the whatsnew-file
  • Check if the latest documentation looks right at readthedocs.
  • Change the version number everywhere!!! (e.g. from 0.2.1dev to 0.2.1) -> pyproject.yaml and docs/conf.py
  • If everything seems to work, merge the release branch into the main branch. (--no-ff)
  • Push your local main branch to the remote.
  • Set a release on github. Select the main branch (default: dev)! A label is set automatically.
  • Use git fetch to see the label in your local main branch.
  • Merge the release branch into the dev branch. (--no-ff)
  • Remove the obsolete release branch.
  • Prepare the dev branch for further development: Adapt the version number at (e.g. from 0.2.1 to 0.2.2dev). Also add a new whatsnew file and a link in the whatsnew.rst file. Open the file locally or use the RAW button to see the links.
  • Close the release issue with informations for the community and relax

Refactoring of postprocessing

Hi @jnnr,

I revisited the postprocessing code, here my suggestions for refactoring the module:

  • helper functions look very good, only some minor refactoring possible but not prio 1 (i.e. get_losses and subtract_output_from_input could be improved)
  • Actual calculations in run_postprocessing could be refactored using my suggestion from https://gist.github.com/henhuy/2f94df3f80dd5c8b01c739218df9f82e
  • I would refactor code to only make use of str-based keys (instead of oemof.solph components) - this is needed i.e. in digiplan as data is sored/restored from DB in str-based format and postprocessing is done afterwards. Also we get rid of those nasty pickles!
  • change end of script in order to support multiple output formats (calculations are fine until every thing is gathered - then some oemof-B3 specific output formatting is done). Here I could think of a adapter-like interface for individual output formats

If we agree on refactoring, I would start by adding tests for postprocessing, so that we can guarantee results to be the same!

What do you think?

Bug: Installation problem

Installing with setuptools >= 58 will lead to errors because simpleeval (a dependency of frictionless) uses use_2to3.

Python3.7 checks fail

Python3.7 is outdated and must be removed from github action checks.
Instead versions 3.8 - 3.10 should be activated

Release v0.0.2

Preparation

  • Finish issues and PRs related to the release
  • Increase version that is installed running pip install oemoflex
  • Test the examples
  • Keep an eye on open issues that are set to your release but seem to be forgotten.
  • Check that the docs look good.

Day of release

  • Optional: Open a release branch to avoid conflicts with other uses while the release progress.
  • Close "forgotten" issues with a recapitulatory comment or set them to a later release if they are still important.
  • Test if everything works
  • If you have failing test fix them or postpone the release.
  • Check the whatsnew-file
  • Check if the latest documentation looks right at readthedocs.
  • Change the version number everywhere!!! (e.g. from 0.2.1dev to 0.2.1) -> pyproject.yaml and docs/conf.py
  • If everything seems to work, merge the release branch into the main branch. (--no-ff)
  • Push your local main branch to the remote.
  • Set a release on github. Select the main branch (default: dev)! A label is set automatically.
  • Use git fetch to see the label in your local main branch.
  • Merge the release branch into the dev branch. (--no-ff)
  • Remove the obsolete release branch.
  • Prepare the dev branch for further development: Adapt the version number at (e.g. from 0.2.1 to 0.2.2dev). Also add a new whatsnew file and a link in the whatsnew.rst file. Open the file locally or use the RAW button to see the links.
  • Close the release issue with informations for the community and relax

When adding new components, foreign keys have to be updated as well

When extending the components in oemoflex, one must not forget to add them to the foreign keys as well.

Problem: When passing component_attrs_update to the method EnergyDatapackage.setup_default(), one would need to update the foreign keys as well, which is not done atm. One solution would be to generate the list of foreign keys automatically from the component definitions.

Error when postprocessing flows that connect components without intermediate bus

When postprocessing scalars, the label of the variable is mapped from tuple to a single label of the form <in/out><bus_name>. The idea here is that the name of the bus defines the energy carrier of the flow. It is possibe however to connect oemof components without intermediate buses - which makes the described approach fail.

Bug: Postprocessing facades with subnodes leads to error

The error occurs because subnodes appear in the tuples of the results. However, the subnodes do not have the classifying attributes region, carrier, tech.

How to reproduce: Run a model with Bev or AssymetricStorage, run postprocessing.

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.