|
1
|
|
|
""" |
|
2
|
|
|
This integration test validates that the Results object properly merges |
|
3
|
|
|
status variables from NonConvexFlowBlock and InvestNonConvexFlowBlock |
|
4
|
|
|
into one DataFrame. |
|
5
|
|
|
|
|
6
|
|
|
The test scenario is using the following components: |
|
7
|
|
|
* Gas boiler with insufficient minimal part load to supply heat in time step 2. |
|
8
|
|
|
* Electrical heater without constraint but high operational costs. |
|
9
|
|
|
* Heat pump (with extremely low investment costs) but a rather low power limit. |
|
10
|
|
|
It can only supply part of the heat. As the electrical heater is always |
|
11
|
|
|
needed as a complement, it is only run if the boiler cannot. |
|
12
|
|
|
|
|
13
|
|
|
SPDX-FileCopyrightText: Patrik Schönfeldt |
|
14
|
|
|
|
|
15
|
|
|
SPDX-License-Identifier: MIT |
|
16
|
|
|
""" |
|
17
|
|
|
|
|
18
|
|
|
import pandas as pd |
|
19
|
|
|
|
|
20
|
|
|
from oemof import solph |
|
21
|
|
|
|
|
22
|
|
|
|
|
23
|
|
|
def test_non_convex_status_variables(): |
|
24
|
|
|
# Energy System |
|
25
|
|
|
energy_system = solph.EnergySystem( |
|
26
|
|
|
timeindex=pd.date_range(start="2025-01-01 12:00", freq="h", periods=3), |
|
27
|
|
|
infer_last_interval=False, |
|
28
|
|
|
) |
|
29
|
|
|
|
|
30
|
|
|
# Buses |
|
31
|
|
|
bus_heat = solph.Bus("heat") |
|
32
|
|
|
|
|
33
|
|
|
energy_system.add(bus_heat) |
|
34
|
|
|
|
|
35
|
|
|
demand_heat = solph.components.Sink( |
|
36
|
|
|
label="demand", |
|
37
|
|
|
inputs={bus_heat: solph.Flow(nominal_capacity=5, fix=[0.5, 0.3])}, |
|
38
|
|
|
) |
|
39
|
|
|
energy_system.add(demand_heat) |
|
40
|
|
|
|
|
41
|
|
|
# gas boiler with minimal load |
|
42
|
|
|
boiler = solph.components.Source( |
|
43
|
|
|
label="gb", |
|
44
|
|
|
outputs={ |
|
45
|
|
|
bus_heat: solph.Flow( |
|
46
|
|
|
nonconvex=solph.NonConvex(), |
|
47
|
|
|
nominal_capacity=5, |
|
48
|
|
|
min=0.5, |
|
49
|
|
|
variable_costs=0.15, |
|
50
|
|
|
), |
|
51
|
|
|
}, |
|
52
|
|
|
) |
|
53
|
|
|
energy_system.add(boiler) |
|
54
|
|
|
|
|
55
|
|
|
# heat pump with limited size |
|
56
|
|
|
heat_pump = solph.components.Source( |
|
57
|
|
|
label="hp", |
|
58
|
|
|
outputs={ |
|
59
|
|
|
bus_heat: solph.Flow( |
|
60
|
|
|
nominal_capacity=solph.Investment(maximum=1, ep_costs=0.1), |
|
61
|
|
|
min=0.5, |
|
62
|
|
|
nonconvex=solph.NonConvex(), |
|
63
|
|
|
variable_costs=0.1, |
|
64
|
|
|
) |
|
65
|
|
|
}, |
|
66
|
|
|
) |
|
67
|
|
|
energy_system.add(heat_pump) |
|
68
|
|
|
|
|
69
|
|
|
el_heater = solph.components.Source( |
|
70
|
|
|
label="rh", |
|
71
|
|
|
outputs={bus_heat: solph.Flow(variable_costs=0.3)}, |
|
72
|
|
|
) |
|
73
|
|
|
energy_system.add(el_heater) |
|
74
|
|
|
|
|
75
|
|
|
# Model |
|
76
|
|
|
model = solph.Model(energy_system) |
|
77
|
|
|
|
|
78
|
|
|
# Optimization |
|
79
|
|
|
model.solve(solver="cbc", solve_kwargs={"tee": False}) |
|
80
|
|
|
|
|
81
|
|
|
results = solph.Results(model) |
|
82
|
|
|
|
|
83
|
|
|
assert (results.status[(boiler, bus_heat)] == [1, 0]).all() |
|
84
|
|
|
assert (results.status[(heat_pump, bus_heat)] == [0, 1]).all() |
|
85
|
|
|
|
|
86
|
|
|
print(results.flow) |
|
87
|
|
|
|
|
88
|
|
|
|
|
89
|
|
|
if __name__ == "__main__": |
|
90
|
|
|
test_non_convex_status_variables() |
|
91
|
|
|
|