Skip to content

Commit b850f94

Browse files
committed
Update documentation.
1 parent 5420f6b commit b850f94

File tree

8 files changed

+53
-29
lines changed

8 files changed

+53
-29
lines changed

README.md

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,23 @@ The software is described and demonstrated in the open-access [draf demo paper].
5454
cd draf
5555
```
5656

57-
1. Create and activate the `draf` conda environment (based on environment.yml including a full editable local version of `draf`):
57+
1. Create and activate the `draf` conda environment (`conda env create` will create a conda environment based on [environment.yml](environment.yml) which will install the newest versions of the required packages including the full editable local version of `draf`.):
5858

5959
```sh
6060
conda env create
6161
conda activate draf
6262
```
6363

64+
1. (optional) To use the latest electricity prices and carbon emission factors from [`elmada`], request an [ENTSO-E API key] and set it to elmada:
65+
66+
```py
67+
# You have to run this Python code only once (it writes to a permanent file):
68+
import elmada
69+
elmada.set_api_keys(entsoe="YOUR_ENTSOE_KEY")
70+
```
71+
72+
1. (optional) To use Gurobi (fast optimization), install a valid Gurobi license (its [free for academics](https://www.gurobi.com/academia/academic-program-and-licenses)).
73+
6474
1. (optional) Run tests:
6575

6676
```sh
@@ -73,20 +83,23 @@ The software is described and demonstrated in the open-access [draf demo paper].
7383
jupyter notebook
7484
```
7585

76-
1. (optional) To use Gurobi (fast optimization), install a valid Gurobi license (its [free for academics](https://www.gurobi.com/academia/academic-program-and-licenses)).
77-
78-
1. (optional) To use the latest electricity prices and carbon emission factors from [`elmada`], request an [ENTSO-E API key] and set it to elmada:
86+
1. Check if the imports work:
7987

8088
```py
81-
# Python code that you have to run only once:
89+
import draf
8290
import elmada
83-
elmada.set_api_keys(entsoe="YOUR_ENTSOE_KEY")
8491
```
8592

86-
1. Start modeling
93+
1. (optional) Installing the newest packages via `conda env create` might create issues. Alternatively, you could use a more specific conda environment with:
94+
95+
```sh
96+
conda env create --file environments\environment_py39all.yml
97+
conda activate draf39
98+
```
8799

88-
1. Have a look at the [examples](examples).
89-
Start with the [`minimal`](examples/minimal.py) example.
100+
1. Start modeling. Have a look at the [examples](examples).
101+
Start with the [`minimal`](examples/minimal.py) if you want to write your own component.
102+
Start with the [`PV`](examples/pv.py) example if you want to import existing components.
90103
For more advanced modeling look at the [draf_demo_case_studies].
91104

92105
## For users

examples/bev.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
"""This example optimizes the charging of battery electric vehicles (BEV).
2+
3+
Two time series are considered:
4+
`P_BEV_drive_TB`: The discharging power of BEV during its utilization.
5+
`y_BEV_avail_TB`: The availability (0 or 1) for charging.
6+
Here, we assume that the BEV is available for charging when it is not used.
7+
"""
8+
19
import draf
210
from draf.components import *
311

examples/der_hut.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Distributed Energy Resources (DER) and Heat Upgrading Technologies (HUT)"""
1+
"""Example model for Distributed Energy Resources (DER) and Heat Upgrading Technologies (HUT)"""
22

33

44
import draf

examples/minimal.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
"""Very simple example with only one user-defined component.
1+
"""Minimal example with only one user-defined component.
22
33
Notes:
4-
- There is nothing to optimize.
5-
- Most of the imports are type hints and can be omitted.
4+
- The model just determines the total costs `C_TOT_`. There is nothing to "optimize".
65
- param_func is DRAF syntax, the model_func is GurobiPy syntax.
76
- Most of the CaseStudy functions can be chained.
87
"""
98

109
from gurobipy import GRB, Model, quicksum
1110

1211
import draf
13-
from draf import Collectors, Dimensions, Params, Scenario, Vars
14-
from draf.abstract_component import Component
12+
from draf import Collectors, Dimensions, Params, Scenario, Vars # only used for type hinting
13+
from draf.abstract_component import Component # only used for type hinting
1514

1615

1716
class Minimal(Component):
@@ -20,10 +19,10 @@ def param_func(self, sc: Scenario):
2019

2120
# Define the optimization variable C_TOT_:
2221
sc.var("C_TOT_", doc="Total costs", unit="€/a")
23-
22+
2423
# Prepare time-dependent day-ahead market prices as parameter c_EG_RTP_T:
2524
sc.prep.c_EG_RTP_T()
26-
25+
2726
# Prepare a time-dependent G1 standard load profile (Business on weekdays 08:00 - 18:00)
2827
# with the annual energy of 5 GWh:
2928
sc.prep.P_eDem_T(profile="G1", annual_energy=5e6)

examples/prod.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
"""Flexible operation of an industrial process"""
2-
3-
1+
"""Flexible operation of an industrial process."""
42
import draf
5-
from draf.components import *
3+
from draf.components import eDem, EG, PP, PS, pDem, Main
64

75

86
def main():

examples/pv.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
"""A small script using the model pv_bes."""
1+
"""A small example with a fixed electricity demand (eDem), an electricity grid (EG), a
2+
photovoltaic system (PV), and the Main component which contains the objective function and the
3+
energy balances. There is no controllable component, so the operation is determined and cannot be
4+
optimized. That means the Solver will solve the problem in pre-solve.
5+
"""
26

37
import draf
48
from draf.components import *

examples/pv_bes.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
"""A model with a Photovoltaic and a Battery Energy Storage System. It is used in the showcase
2-
see: https://mfleschutz.github.io/draf-showcase/#/2
1+
"""Optimizing the operation of a 100 kWh Battery Energy Storage (BES) considering a Photovoltaic
2+
(PV), a fixed electricity demand (eDem), and an existing 1 MWp Photovoltaic system.
3+
4+
The example is used in the DRAF showcase see: https://mfleschutz.github.io/draf-showcase/#/2
35
"""
46

57
import draf

examples/pyomo_pv.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""This minimal example simulates the electricity purchase for a given demand and PV production.
2-
All variables are solves in the presolve. The aim of this file is to show the syntax of parameter
3-
& model definition. They are used by the main function to create a case-study with 2 scenarios:
4-
`REF` and `REF_PV`.
2+
All variables are solved in the presolve. The aim of this file is to show the syntax of parameter
3+
& model definition when using Pyomo. They are used by the main function to create a case-study with
4+
two scenarios: `REF` and `REF_PV`.
55
"""
66

77
import pyomo.environ as pyo
@@ -11,8 +11,9 @@
1111
from draf import Collectors, Dimensions, Params, Results, Scenario, Vars
1212
from draf.abstract_component import Component
1313

14+
1415
class TEST_COMP(Component):
15-
16+
1617
def param_func(_, sc: draf.Scenario):
1718

1819
# Total
@@ -34,7 +35,6 @@ def param_func(_, sc: draf.Scenario):
3435
sc.param("P_PV_CAPx_", 0, "existing capacity", "kW_peak")
3536
sc.prep.P_PV_profile_T(use_coords=True)
3637

37-
3838
def model_func(_, sc: Scenario, m: pyo.Model, d: Dimensions, p: Params, v: Vars, c: Collectors):
3939

4040
m.obj = pyo.Objective(

0 commit comments

Comments
 (0)