|
1
|
|
|
# -*- coding: utf-8 -*- |
|
2
|
|
|
|
|
3
|
|
|
""" |
|
4
|
|
|
This file is part of project oemof (github.com/oemof/oemof). It's copyrighted |
|
5
|
|
|
by the contributors recorded in the version control history of the file, |
|
6
|
|
|
available from its original location oemof/tests/test_scripts/test_solph/ |
|
7
|
|
|
test_storage_investment/test_storage_investment.py |
|
8
|
|
|
|
|
9
|
|
|
SPDX-License-Identifier: MIT |
|
10
|
|
|
""" |
|
11
|
|
|
|
|
12
|
|
|
import logging |
|
13
|
|
|
|
|
14
|
|
|
import pandas as pd |
|
15
|
|
|
|
|
16
|
|
|
from oemof import solph |
|
17
|
|
|
from oemof.solph import views |
|
18
|
|
|
|
|
19
|
|
|
|
|
20
|
|
|
def test_regression_investment_storage(solver="cbc"): |
|
21
|
|
|
"""The problem was infeasible if the existing capacity and the maximum was |
|
22
|
|
|
defined in the Flow. |
|
23
|
|
|
""" |
|
24
|
|
|
|
|
25
|
|
|
logging.info("Initialize the energy system") |
|
26
|
|
|
date_time_index = pd.date_range("1/1/2012", periods=4, freq="h") |
|
27
|
|
|
|
|
28
|
|
|
energysystem = solph.EnergySystem( |
|
29
|
|
|
timeindex=date_time_index, infer_last_interval=True |
|
30
|
|
|
) |
|
31
|
|
|
|
|
32
|
|
|
# Buses |
|
33
|
|
|
bgas = solph.buses.Bus(label=("natural", "gas")) |
|
34
|
|
|
bel = solph.buses.Bus(label="electricity") |
|
35
|
|
|
energysystem.add(bgas, bel) |
|
36
|
|
|
|
|
37
|
|
|
energysystem.add( |
|
38
|
|
|
solph.components.Sink( |
|
39
|
|
|
label="demand", |
|
40
|
|
|
inputs={ |
|
41
|
|
|
bel: solph.flows.Flow( |
|
42
|
|
|
fix=[209643, 207497, 200108, 191892], nominal_capacity=1 |
|
43
|
|
|
) |
|
44
|
|
|
}, |
|
45
|
|
|
) |
|
46
|
|
|
) |
|
47
|
|
|
|
|
48
|
|
|
# Sources |
|
49
|
|
|
energysystem.add( |
|
50
|
|
|
solph.components.Source( |
|
51
|
|
|
label="rgas", outputs={bgas: solph.flows.Flow()} |
|
52
|
|
|
) |
|
53
|
|
|
) |
|
54
|
|
|
|
|
55
|
|
|
# Converter |
|
56
|
|
|
energysystem.add( |
|
57
|
|
|
solph.components.Converter( |
|
58
|
|
|
label="pp_gas", |
|
59
|
|
|
inputs={bgas: solph.flows.Flow()}, |
|
60
|
|
|
outputs={bel: solph.flows.Flow(nominal_capacity=300000)}, |
|
61
|
|
|
conversion_factors={bel: 0.58}, |
|
62
|
|
|
) |
|
63
|
|
|
) |
|
64
|
|
|
|
|
65
|
|
|
# Investment storage |
|
66
|
|
|
energysystem.add( |
|
67
|
|
|
solph.components.GenericStorage( |
|
68
|
|
|
label="storage", |
|
69
|
|
|
inputs={ |
|
70
|
|
|
bel: solph.flows.Flow( |
|
71
|
|
|
nominal_capacity=solph.Investment( |
|
72
|
|
|
existing=625046 / 6, maximum=0 |
|
73
|
|
|
) |
|
74
|
|
|
) |
|
75
|
|
|
}, |
|
76
|
|
|
outputs={ |
|
77
|
|
|
bel: solph.flows.Flow( |
|
78
|
|
|
nominal_capacity=solph.Investment( |
|
79
|
|
|
existing=104174.33, maximum=1 |
|
80
|
|
|
) |
|
81
|
|
|
) |
|
82
|
|
|
}, |
|
83
|
|
|
loss_rate=0.00, |
|
84
|
|
|
initial_storage_level=0, |
|
85
|
|
|
invest_relation_input_capacity=1 / 6, |
|
86
|
|
|
invest_relation_output_capacity=1 / 6, |
|
87
|
|
|
inflow_conversion_factor=1, |
|
88
|
|
|
outflow_conversion_factor=0.8, |
|
89
|
|
|
nominal_capacity=solph.Investment( |
|
90
|
|
|
ep_costs=50, |
|
91
|
|
|
existing=625046, |
|
92
|
|
|
), |
|
93
|
|
|
) |
|
94
|
|
|
) |
|
95
|
|
|
|
|
96
|
|
|
# Solve model |
|
97
|
|
|
om = solph.Model(energysystem) |
|
98
|
|
|
om.solve(solver=solver) |
|
99
|
|
|
|
|
100
|
|
|
# Results |
|
101
|
|
|
results = solph.processing.results(om) |
|
102
|
|
|
|
|
103
|
|
|
electricity_bus = views.node(results, "electricity") |
|
104
|
|
|
my_results = electricity_bus["sequences"].sum(axis=0).to_dict() |
|
105
|
|
|
storage = energysystem.groups["storage"] |
|
106
|
|
|
my_results["storage_invest"] = results[(storage, None)]["scalars"][ |
|
107
|
|
|
"invest" |
|
108
|
|
|
] |
|
109
|
|
|
|