Passed
Pull Request — dev (#1193)
by Patrik
01:53
created

facade   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 28
dl 0
loc 74
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A DSO.__init__() 0 29 1
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.network import SubNetwork
42
43
44
class DSO(SubNetwork):
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)
50
51
        internal_bus = self.subnode(Bus, local_name="internal_bus")
52
53
        self.subnode(
54
            Converter,
55
            inputs={self.el_bus: Flow(variable_costs=self.feedin_tariff * -1)},
56
            outputs={internal_bus: Flow()},
57
            local_name="feedin_converter",
58
        )
59
        self.subnode(
60
            Sink, inputs={internal_bus: Flow()}, local_name="feedin_sink"
61
        )
62
63
        self.subnode(
64
            Converter,
65
            inputs={internal_bus: Flow()},
66
            outputs={self.el_bus: Flow(variable_costs=self.energy_price)},
67
            local_name="consumption_converter",
68
        )
69
70
        self.subnode(
71
            Source,
72
            outputs={internal_bus: Flow()},
73
            local_name="consumption_source",
74
        )
75