|
1
|
|
|
import os |
|
2
|
|
|
|
|
3
|
|
|
import pandas as pd |
|
4
|
|
|
|
|
5
|
|
|
from oemof.solph import EnergySystem |
|
6
|
|
|
from oemof.solph import Model |
|
7
|
|
|
from oemof.solph.buses import Bus |
|
8
|
|
|
from oemof.solph.components import Converter |
|
9
|
|
|
from oemof.solph.components import Sink |
|
10
|
|
|
from oemof.solph.components import Source |
|
11
|
|
|
from oemof.solph.flows import Flow |
|
12
|
|
|
|
|
13
|
|
|
filename = os.path.join(os.path.dirname(__file__), "input_data.csv") |
|
14
|
|
|
data = pd.read_csv(filename, sep=",") |
|
15
|
|
|
|
|
16
|
|
|
bcoal = Bus(label="coal", balanced=False) |
|
17
|
|
|
bgas = Bus(label="gas", balanced=False) |
|
18
|
|
|
boil = Bus(label="oil", balanced=False) |
|
19
|
|
|
blig = Bus(label="lignite", balanced=False) |
|
20
|
|
|
|
|
21
|
|
|
# electricity and heat |
|
22
|
|
|
bel = Bus(label="b_el") |
|
23
|
|
|
bth = Bus(label="b_th") |
|
24
|
|
|
|
|
25
|
|
|
# an excess and a shortage variable can help to avoid infeasible problems |
|
26
|
|
|
excess_el = Sink(label="excess_el", inputs={bel: Flow()}) |
|
27
|
|
|
# shortage_el = Source(label='shortage_el', |
|
28
|
|
|
# outputs={bel: Flow(variable_costs=200)}) |
|
29
|
|
|
|
|
30
|
|
|
# sources |
|
31
|
|
|
wind = Source( |
|
32
|
|
|
label="wind", |
|
33
|
|
|
outputs={ |
|
34
|
|
|
bel: Flow( |
|
35
|
|
|
fix=data["wind"], |
|
36
|
|
|
nominal_capacity=66.3, |
|
37
|
|
|
) |
|
38
|
|
|
}, |
|
39
|
|
|
) |
|
40
|
|
|
|
|
41
|
|
|
pv = Source( |
|
42
|
|
|
label="pv", |
|
43
|
|
|
outputs={ |
|
44
|
|
|
bel: Flow( |
|
45
|
|
|
fix=data["pv"], |
|
46
|
|
|
nominal_capacity=65.3, |
|
47
|
|
|
) |
|
48
|
|
|
}, |
|
49
|
|
|
) |
|
50
|
|
|
|
|
51
|
|
|
# demands (electricity/heat) |
|
52
|
|
|
demand_el = Sink( |
|
53
|
|
|
label="demand_elec", |
|
54
|
|
|
inputs={ |
|
55
|
|
|
bel: Flow( |
|
56
|
|
|
nominal_capacity=85, |
|
57
|
|
|
fix=data["demand_el"], |
|
58
|
|
|
) |
|
59
|
|
|
}, |
|
60
|
|
|
) |
|
61
|
|
|
|
|
62
|
|
|
demand_th = Sink( |
|
63
|
|
|
label="demand_therm", |
|
64
|
|
|
inputs={ |
|
65
|
|
|
bth: Flow( |
|
66
|
|
|
nominal_capacity=40, |
|
67
|
|
|
fix=data["demand_th"], |
|
68
|
|
|
) |
|
69
|
|
|
}, |
|
70
|
|
|
) |
|
71
|
|
|
|
|
72
|
|
|
# power plants |
|
73
|
|
|
pp_coal = Converter( |
|
74
|
|
|
label="pp_coal", |
|
75
|
|
|
inputs={bcoal: Flow()}, |
|
76
|
|
|
outputs={bel: Flow(nominal_capacity=20.2, variable_costs=25)}, |
|
77
|
|
|
conversion_factors={bel: 0.39}, |
|
78
|
|
|
) |
|
79
|
|
|
|
|
80
|
|
|
pp_lig = Converter( |
|
81
|
|
|
label="pp_lig", |
|
82
|
|
|
inputs={blig: Flow()}, |
|
83
|
|
|
outputs={bel: Flow(nominal_capacity=11.8, variable_costs=19)}, |
|
84
|
|
|
conversion_factors={bel: 0.41}, |
|
85
|
|
|
) |
|
86
|
|
|
|
|
87
|
|
|
pp_gas = Converter( |
|
88
|
|
|
label="pp_gas", |
|
89
|
|
|
inputs={bgas: Flow()}, |
|
90
|
|
|
outputs={bel: Flow(nominal_capacity=41, variable_costs=40)}, |
|
91
|
|
|
conversion_factors={bel: 0.50}, |
|
92
|
|
|
) |
|
93
|
|
|
|
|
94
|
|
|
pp_oil = Converter( |
|
95
|
|
|
label="pp_oil", |
|
96
|
|
|
inputs={boil: Flow()}, |
|
97
|
|
|
outputs={bel: Flow(nominal_capacity=5, variable_costs=50)}, |
|
98
|
|
|
conversion_factors={bel: 0.28}, |
|
99
|
|
|
) |
|
100
|
|
|
|
|
101
|
|
|
# combined heat and power plant (chp) |
|
102
|
|
|
pp_chp = Converter( |
|
103
|
|
|
label="pp_chp", |
|
104
|
|
|
inputs={bgas: Flow()}, |
|
105
|
|
|
outputs={ |
|
106
|
|
|
bel: Flow(nominal_capacity=30, variable_costs=42), |
|
107
|
|
|
bth: Flow(nominal_capacity=40), |
|
108
|
|
|
}, |
|
109
|
|
|
conversion_factors={bel: 0.3, bth: 0.4}, |
|
110
|
|
|
) |
|
111
|
|
|
|
|
112
|
|
|
# heatpump with a coefficient of performance (COP) of 3 |
|
113
|
|
|
b_heat_source = Bus(label="b_heat_source") |
|
114
|
|
|
|
|
115
|
|
|
heat_source = Source(label="heat_source", outputs={b_heat_source: Flow()}) |
|
116
|
|
|
|
|
117
|
|
|
cop = 3 |
|
118
|
|
|
heat_pump = Converter( |
|
119
|
|
|
label="heat_pump", |
|
120
|
|
|
inputs={bel: Flow(), b_heat_source: Flow()}, |
|
121
|
|
|
outputs={bth: Flow(nominal_capacity=10)}, |
|
122
|
|
|
conversion_factors={bel: 1 / 3, b_heat_source: (cop - 1) / cop}, |
|
123
|
|
|
) |
|
124
|
|
|
|
|
125
|
|
|
datetimeindex = pd.date_range("1/1/2012", periods=24, freq="h") |
|
126
|
|
|
energysystem = EnergySystem(timeindex=datetimeindex, infer_last_interval=True) |
|
127
|
|
|
energysystem.add( |
|
128
|
|
|
bcoal, |
|
129
|
|
|
bgas, |
|
130
|
|
|
boil, |
|
131
|
|
|
bel, |
|
132
|
|
|
bth, |
|
133
|
|
|
blig, |
|
134
|
|
|
excess_el, |
|
135
|
|
|
wind, |
|
136
|
|
|
pv, |
|
137
|
|
|
demand_el, |
|
138
|
|
|
demand_th, |
|
139
|
|
|
pp_coal, |
|
140
|
|
|
pp_lig, |
|
141
|
|
|
pp_oil, |
|
142
|
|
|
pp_gas, |
|
143
|
|
|
pp_chp, |
|
144
|
|
|
b_heat_source, |
|
145
|
|
|
heat_source, |
|
146
|
|
|
heat_pump, |
|
147
|
|
|
) |
|
148
|
|
|
|
|
149
|
|
|
# ################################ optimization ########################### |
|
150
|
|
|
|
|
151
|
|
|
# create optimization model based on energy_system |
|
152
|
|
|
optimization_model = Model(energysystem=energysystem) |
|
153
|
|
|
|
|
154
|
|
|
# solve problem |
|
155
|
|
|
optimization_model.solve() |
|
156
|
|
|
|