1
|
|
|
# -*- coding: utf-8 -*- |
2
|
|
|
|
3
|
|
|
""" |
4
|
|
|
General description |
5
|
|
|
------------------- |
6
|
|
|
|
7
|
|
|
A basic example to show how to get the dual variables from the system. Try |
8
|
|
|
to understand the plot. |
9
|
|
|
|
10
|
|
|
Code |
11
|
|
|
---- |
12
|
|
|
Download source code: :download:`dual_variable_example.py |
13
|
|
|
</../examples/dual_variable_example/dual_variable_example.py>` |
14
|
|
|
|
15
|
|
|
.. dropdown:: Click to display code |
16
|
|
|
|
17
|
|
|
.. literalinclude:: /../examples/dual_variable_example/dual_variable_example.py |
18
|
|
|
:language: python |
19
|
|
|
:lines: 34-297 |
20
|
|
|
|
21
|
|
|
|
22
|
|
|
Installation requirements |
23
|
|
|
------------------------- |
24
|
|
|
|
25
|
|
|
This example requires the version v0.6.x of oemof.solph: |
26
|
|
|
|
27
|
|
|
.. code:: bash |
28
|
|
|
|
29
|
|
|
pip install 'oemof.solph[examples]>=0.6,<0.7' |
30
|
|
|
|
31
|
|
|
SPDX-FileCopyrightText: Uwe Krien <[email protected]> |
32
|
|
|
SPDX-FileCopyrightText: Pierre-François Duc |
33
|
|
|
|
34
|
|
|
SPDX-License-Identifier: MIT |
35
|
|
|
""" |
36
|
|
|
|
37
|
|
|
from oemof.solph.components import Converter, Source, Sink |
38
|
|
|
from oemof.solph.flows import Flow |
39
|
|
|
from oemof.solph.buses import Bus |
40
|
|
|
|
41
|
|
|
from oemof.solph import Facade |
42
|
|
|
|
43
|
|
|
|
44
|
|
|
class DSO(Facade): |
45
|
|
|
def __init__(self, label, el_bus, *args, energy_price, feedin_tariff): |
46
|
|
|
self.energy_price = energy_price |
47
|
|
|
self.feedin_tariff = feedin_tariff |
48
|
|
|
self.el_bus = el_bus |
49
|
|
|
super().__init__(*args, label=label, facade_type=type(self)) |
50
|
|
|
|
51
|
|
|
def define_subnetwork(self): |
52
|
|
|
internal_bus = self.subnode(Bus, label="internal_bus") |
53
|
|
|
|
54
|
|
|
self.subnode( |
55
|
|
|
Converter, |
56
|
|
|
inputs={self.el_bus: Flow(variable_costs=self.feedin_tariff * -1)}, |
57
|
|
|
outputs={internal_bus: Flow()}, |
58
|
|
|
label="feedin_converter", |
59
|
|
|
) |
60
|
|
|
self.subnode( |
61
|
|
|
Sink, inputs={internal_bus: Flow()}, label="feedin_sink" |
62
|
|
|
) |
63
|
|
|
|
64
|
|
|
self.subnode( |
65
|
|
|
Converter, |
66
|
|
|
inputs={internal_bus: Flow()}, |
67
|
|
|
outputs={self.el_bus: Flow(variable_costs=self.energy_price)}, |
68
|
|
|
label="consumption_converter", |
69
|
|
|
) |
70
|
|
|
|
71
|
|
|
self.subnode( |
72
|
|
|
Source, outputs={internal_bus: Flow()}, label="consumption_source" |
73
|
|
|
) |
74
|
|
|
|