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
Contents
Preparation
Shell Commands
When on windows, get access to a command executing shell. Recommended are:
Python IDEs like PyCharm
Using the Windows-Powershell7
(Usefull bash vs powershell-commands cheat sheet)
Old Repository
New Repository
Create a Github account
Clone the repo to your local machine using git:
git clone https://github.com/tZ3ma/tessif-examples.git
Navigate insdie the tessif-examples folder:
cd tessif-examples
Create a new local branch using git:
git checkout -b my-new-branch
Locate the locations at:
tessif-examples/src/tessif-examples/
Doing the port
Copy
Each of the functions in
tessif/src/tessif/examples/data/tsf/py_hard.pyrepresent one singular energy system example and should be copied to its own.py - fileintessif-examples/src/tessif-examples/. Either inside thebasicfolder or thescenariosfolder. The filename should be called like the function, withoutcreate.basicexamples 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
scenariosexamples 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
Make sure each new function starts with
create_Delete the
"store on disk"part (see the already-ported-examples for more details):From the function arguments
From the function docstring
From the function body
Change the examples section:
Only include the visualization
Change the code snippet from docctest-style (
>>>and...) to a standard code as seen in the already-ported-examplesChange the acutal code to use
dcgraphinstead ofnxgraphas seen in the already-ported-examplesStore the system graph image at:
tessif-examples/docs/source/_static/system_model_graphs/
Change the source file linking to:
.. image:: ../../_static/system_model_graphs/
Add documentation
Copy one of the existing
.rst - files, (e.g.tessif-examples/docs/source/examples/basic/mwe.rst) according to the example your porting, so forcreate_chpthis would be:tessif-examples/docs/source/examples/basic/chp.rst
Link the newly created
.rst - filesso the docs builder can include it. Linking the file is done by adding the relative path to thetessif-examples/docs/source/examples.rstfile.For the
create_chpexample this would result in adding following line:examples/basic/chp
Add tests
Add a test function for your newly ported example inside
tessif-examples/tests/examples/) according to the example your porting. So forcreate_chpthis would be an additional function calledtest_chpinside:tessif-examples/tests/examples/test_basic.py