Porting Old Examples

Following sections provide information on how to port the old private repo examples to this new library. It uses shell-commands which are denoted the indented box as in:

shell-command example

Preparation

Shell Commands

When on windows, get access to a command executing shell. Recommended are:

Old Repository

  1. Get access to to the Old-Repo

  2. Clone the repo to your local machine using git:

    git clone https://collaborating.tuhh.de/ietma/tessif.git
    
  3. Locate the old files at:

    tessif/src/tessif/examples/data/tsf/py_hard.py
    

New Repository

  1. Create a Github account

  2. Clone the repo to your local machine using git:

    git clone https://github.com/tZ3ma/tessif-examples.git
    
  3. Navigate insdie the tessif-examples folder:

    cd tessif-examples
    
  4. Create a new local branch using git:

    git checkout -b my-new-branch
    
  5. Locate the locations at:

    tessif-examples/src/tessif-examples/
    

Doing the port

Copy

  1. Each of the functions in tessif/src/tessif/examples/data/tsf/py_hard.py represent one singular energy system example and should be copied to its own .py - file in tessif-examples/src/tessif-examples/. Either inside the basic folder or the scenarios folder. The filename should be called like the function, without create.

  2. basic examples are:

    • create_mwe

    • create_fpwe

    • emission_objective

    • create_connected_es

    • create_chp

    • create_variable_chp

    • create_storage_example

    • create_expansion_plan_example

    • create_simple_transformer_grid_es

    • create_time_varying_efficiency_transformer

  3. scenarios examples are:

    • create_hhes

    • create_grid_es

    • create_component_es

    • create_grid_kp_es

    • create_grid_cs_es

    • create_grid_cp_es

    • create_grid_ts_es

    • create_grid_tp_es

Modify

  1. Make sure each new function starts with create_

  2. Delete the "store on disk" part (see the already-ported-examples for more details):

    1. From the function arguments

    2. From the function docstring

    3. From the function body

  3. Change the examples section:

    1. Only include the visualization

    2. Change the code snippet from docctest-style (>>> and ...) to a standard code as seen in the already-ported-examples

    3. Change the acutal code to use dcgraph instead of nxgraph as seen in the already-ported-examples

    4. Store the system graph image at:

      tessif-examples/docs/source/_static/system_model_graphs/
      
    5. Change the source file linking to:

      .. image:: ../../_static/system_model_graphs/

Add documentation

  1. Copy one of the existing .rst - files, (e.g. tessif-examples/docs/source/examples/basic/mwe.rst) according to the example your porting, so for create_chp this would be:

    tessif-examples/docs/source/examples/basic/chp.rst
    
  2. Link the newly created .rst - files so the docs builder can include it. Linking the file is done by adding the relative path to the tessif-examples/docs/source/examples.rst file.

    For the create_chp example this would result in adding following line:

    examples/basic/chp
    

Add tests

  1. Add a test function for your newly ported example inside tessif-examples/tests/examples/) according to the example your porting. So for create_chp this would be an additional function called test_chp inside:

    tessif-examples/tests/examples/test_basic.py