Note
You can download this example as a Jupyter notebook or start it in interactive mode.
Multi-Link usage: CHP with fixed heat-power ratio#
This notebook if a demonstration of Link with multiple outputs: Combined-Heat-and-Power (CHP) with fixed heat-power ratio
For a CHP with a more complicated heat-power feasible operational area, see the power-to-gas example
This example demonstrates a Link component with more than one bus output (“bus2” in this case). In general links can have many output buses.
In this example a CHP must be heat-following because there is no other supply of heat to the bus “Frankfurt heat”.
[1]:
import pypsa
[2]:
network = pypsa.Network()
network.add("Bus", "Frankfurt", carrier="AC")
network.add("Load", "Frankfurt", bus="Frankfurt", p_set=5)
network.add("Bus", "Frankfurt heat", carrier="heat")
network.add("Load", "Frankfurt heat", bus="Frankfurt heat", p_set=3)
network.add("Bus", "Frankfurt gas", carrier="gas")
network.add("Store", "Frankfurt gas", e_initial=1e6, e_nom=1e6, bus="Frankfurt gas")
network.add(
"Link",
"OCGT",
bus0="Frankfurt gas",
bus1="Frankfurt",
p_nom_extendable=True,
capital_cost=600,
efficiency=0.4,
)
network.add(
"Link",
"CHP",
bus0="Frankfurt gas",
bus1="Frankfurt",
bus2="Frankfurt heat",
p_nom_extendable=True,
capital_cost=1400,
efficiency=0.3,
efficiency2=0.3,
)
[2]:
Index(['CHP'], dtype='object')
[3]:
network.optimize();
WARNING:pypsa.consistency:The following buses have carriers which are not defined:
Index(['Frankfurt', 'Frankfurt heat', 'Frankfurt gas'], dtype='object', name='Bus')
WARNING:pypsa.consistency:The following links have carriers which are not defined:
Index(['OCGT', 'CHP'], dtype='object', name='Link')
WARNING:pypsa.consistency:Encountered nan's in static data for columns ['efficiency2'] of component 'Link'.
WARNING:pypsa.consistency:The following stores have carriers which are not defined:
Index(['Frankfurt gas'], dtype='object', name='Store')
WARNING:pypsa.consistency:The following buses have carriers which are not defined:
Index(['Frankfurt', 'Frankfurt heat', 'Frankfurt gas'], dtype='object', name='Bus')
WARNING:pypsa.consistency:The following links have carriers which are not defined:
Index(['OCGT', 'CHP'], dtype='object', name='Link')
WARNING:pypsa.consistency:Encountered nan's in static data for columns ['efficiency2'] of component 'Link'.
WARNING:pypsa.consistency:The following stores have carriers which are not defined:
Index(['Frankfurt gas'], dtype='object', name='Store')
INFO:linopy.model: Solve problem using Highs solver
INFO:linopy.io: Writing time: 0.04s
INFO:linopy.solvers:Log file at /tmp/highs.log
INFO:linopy.constants: Optimization successful:
Status: ok
Termination condition: optimal
Solution: 6 primals, 12 duals
Objective: 1.70e+04
Solver model: available
Solver message: optimal
INFO:pypsa.optimization.optimize:The shadow-prices of the constraints Link-ext-p-lower, Link-ext-p-upper, Store-fix-e-lower, Store-fix-e-upper, Store-energy_balance were not assigned to the network.
Running HiGHS 1.7.2 (git hash: 184e327): Copyright (c) 2024 HiGHS under MIT licence terms
Coefficient ranges:
Matrix [3e-01, 1e+00]
Cost [6e+02, 1e+03]
Bound [0e+00, 0e+00]
RHS [3e+00, 1e+06]
Presolving model
0 rows, 0 cols, 0 nonzeros 0s
0 rows, 0 cols, 0 nonzeros 0s
Presolve : Reductions: rows 0(-12); columns 0(-6); elements 0(-18) - Reduced to empty
Solving the original LP from the solution after postsolve
Model status : Optimal
Objective value : 1.7000000000e+04
HiGHS run time : 0.00
Writing the solution to /tmp/linopy-solve-f6ybo1il.sol
[4]:
network.loads_t.p
[4]:
Load | Frankfurt | Frankfurt heat |
---|---|---|
snapshot | ||
now | 5.0 | 3.0 |
[5]:
network.links_t.p0
[5]:
Link | OCGT | CHP |
---|---|---|
snapshot | ||
now | 5.0 | 10.0 |
[6]:
network.links_t.p1
[6]:
Link | OCGT | CHP |
---|---|---|
snapshot | ||
now | -2.0 | -3.0 |
[7]:
network.links_t.p2
[7]:
Link | OCGT | CHP |
---|---|---|
snapshot | ||
now | 0.0 | -3.0 |