/
facades.py
1659 lines (1301 loc) · 49.9 KB
/
facades.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# -*- coding: utf-8 -*-
""" Facade's are classes providing a simplified view on more complex classes.
More specifically, the `Facade`s in this module act as simplified, energy
specific wrappers around `oemof`'s and `oemof.solph`'s more abstract and
complex classes. The idea is to be able to instantiate a `Facade` using keyword
arguments, whose value are derived from simple, tabular data sources. Under the
hood the `Facade` then uses these arguments to construct an `oemof` or
`oemof.solph` component and sets it up to be easily used in an `EnergySystem`.
**Note** The mathematical notation is as follows:
* Optimization variables (endogenous variables) are denoted by :math:`x`
* Optimization parameters (exogenous variables) are denoted by :math:`c`
* The set of timesteps :math:`T` describes all timesteps of the optimization
problem
SPDX-License-Identifier: BSD-3-Clause
"""
from collections import deque
import warnings
from oemof.network.energy_system import EnergySystem
from oemof.network.network import Node
from oemof.solph import Bus, Flow, Investment, Sink, Source, Transformer
from oemof.solph.components import ExtractionTurbineCHP, GenericStorage
from oemof.solph.custom import ElectricalBus, ElectricalLine, Link
from oemof.solph.plumbing import sequence
from oemof.tools.debugging import SuspiciousUsageWarning
# Switch off SuspiciousUsageWarning
warnings.filterwarnings("ignore", category=SuspiciousUsageWarning)
def add_subnodes(n, **kwargs):
deque((kwargs["EnergySystem"].add(sn) for sn in n.subnodes), maxlen=0)
class Facade(Node):
"""
Parameters
----------
_facade_requires_ : list of str
A list of required attributes. The constructor checks whether these are
present as keywort arguments or whether they are already present on
self (which means they have been set by constructors of subclasses) and
raises an error if he doesn't find them.
"""
def __init__(self, *args, **kwargs):
"""
"""
self.mapped_type = type(self)
self.type = kwargs.get("type")
required = kwargs.pop("_facade_requires_", [])
super().__init__(*args, **kwargs)
self.subnodes = []
EnergySystem.signals[EnergySystem.add].connect(
add_subnodes, sender=self
)
for r in required:
if r in kwargs:
setattr(self, r, kwargs[r])
elif not hasattr(self, r):
raise AttributeError(
(
"Missing required attribute `{}` for `{}` "
"object with name/label `{!r}`."
).format(r, type(self).__name__, self.label)
)
def _nominal_value(self):
""" Returns None if self.expandable ist True otherwise it returns
the capacity
"""
if self.expandable is True:
if isinstance(self, Link):
return {
"from_to": None,
"to_from": None}
else:
return None
else:
if isinstance(self, Link):
return {
"from_to": self.from_to_capacity,
"to_from": self.to_from_capacity}
else:
return self.capacity
def _investment(self):
if not self.expandable:
self.investment = None
return self.investment
if self.capacity_cost is None:
msg = (
"If you set `expandable`to True you need to set "
"attribute `capacity_cost` of component {}!"
)
raise ValueError(msg.format(self.label))
if isinstance(self, GenericStorage):
if self.storage_capacity_cost is not None:
self.investment = Investment(
ep_costs=self.storage_capacity_cost,
maximum=self._get_maximum_additional_invest(
"storage_capacity_potential", "storage_capacity"
),
minimum=getattr(
self, "minimum_storage_capacity", 0
),
existing=getattr(self, "storage_capacity", 0),
)
else:
self.investment = Investment(
maximum=self._get_maximum_additional_invest(
"storage_capacity_potential", "storage_capacity"
),
minimum=getattr(
self, "minimum_storage_capacity", 0
),
existing=getattr(self, "storage_capacity", 0),
)
else:
self.investment = Investment(
ep_costs=self.capacity_cost,
maximum=self._get_maximum_additional_invest(
"capacity_potential", "capacity"
),
minimum=getattr(
self, "capacity_minimum", 0
),
existing=getattr(self, "capacity", 0),
)
return self.investment
def _get_maximum_additional_invest(self, attr_potential, attr_existing):
r"""
Calculates maximum additional investment by
substracting existing from potential.
Throws an error if existing is larger than potential.
"""
_potential = getattr(
self,
attr_potential,
float("+inf"),
)
_existing = getattr(
self,
attr_existing,
0,
)
if _existing is None:
_existing = 0
if _potential is None:
_potential = float("+inf")
maximum = _potential - _existing
if maximum < 0:
raise ValueError(
f"Existing {attr_existing}={_existing} is larger"
f" than {attr_potential}={_potential}.")
return maximum
def update(self):
self.build_solph_components()
class Reservoir(GenericStorage, Facade):
r""" A Reservoir storage unit, that is initially half full.
Note that the investment option is not available for this facade at
the current development state.
Parameters
----------
bus: oemof.solph.Bus
An oemof bus instance where the storage unit is connected to.
storage_capacity: numeric
The total storage capacity of the storage (e.g. in MWh)
capacity: numeric
Installed production capacity of the turbine installed at the
reservoir
efficiency: numeric
Efficiency of the turbine converting inflow to electricity
production, default: 1
profile: array-like
Absolute inflow profile of inflow into the storage
input_parameters: dict
Dictionary to specifiy parameters on the input edge. You can use
all keys that are available for the oemof.solph.network.Flow class.
output_parameters: dict
see: input_parameters
The reservoir is modelled as a storage with a constant inflow:
.. math::
x^{level}(t) =
x^{level}(t-1) \cdot (1 - c^{loss\_rate}(t))
+ x^{profile}(t) - \frac{x^{flow, out}(t)}{c^{efficiency}(t)}
\qquad \forall t \in T
.. math::
x^{level}(0) = 0.5 \cdot c^{capacity}
The inflow is bounded by the exogenous inflow profile. Thus if the inflow
exceeds the maximum capacity of the storage, spillage is possible by
setting :math:`x^{profile}(t)` to lower values.
.. math::
0 \leq x^{profile}(t) \leq c^{profile}(t) \qquad \forall t \in T
The spillage of the reservoir is therefore defined by:
:math:`c^{profile}(t) - x^{profile}(t)`.
Note
----
As the Reservoir is a sub-class of `oemof.solph.GenericStorage` you also
pass all arguments of this class.
Examples
--------
Basic usage examples of the GenericStorage with a random selection of
attributes. See the Flow class for all Flow attributes.
>>> from oemof import solph
>>> from oemof.tabular import facades
>>> my_bus = solph.Bus('my_bus')
>>> my_reservoir = Reservoir(
... label='my_reservoir',
... bus=my_bus,
... carrier='water',
... tech='reservoir',
... storage_capacity=1000,
... capacity=50,
... profile=[1, 2, 6],
... loss_rate=0.01,
... initial_storage_level=0,
... max_storage_level = 0.9,
... efficiency=0.93)
"""
def __init__(self, *args, **kwargs):
kwargs.update(
{
"_facade_requires_": [
"bus",
"carrier",
"tech",
"profile",
"efficiency",
]
}
)
super().__init__(*args, **kwargs)
self.storage_capacity = kwargs.get("storage_capacity")
self.capacity = kwargs.get("capacity")
self.efficiency = kwargs.get("efficiency", 1)
self.profile = kwargs.get("profile")
self.output_parameters = kwargs.get("output_parameters", {})
self.expandable = bool(kwargs.get("expandable", False))
self.build_solph_components()
def build_solph_components(self):
"""
"""
self.nominal_storage_capacity = self.storage_capacity
self.outflow_conversion_factor = sequence(self.efficiency)
if self.expandable:
raise NotImplementedError(
"Investment for reservoir class is not implemented."
)
inflow = Source(
label=self.label + "-inflow",
outputs={
self: Flow(nominal_value=1, max=self.profile)
},
)
self.outputs.update(
{
self.bus: Flow(
nominal_value=self.capacity, **self.output_parameters
)
}
)
self.subnodes = (inflow,)
class Dispatchable(Source, Facade):
r""" Dispatchable element with one output for example a gas-turbine
Parameters
----------
bus: oemof.solph.Bus
An oemof bus instance where the unit is connected to with its output
capacity: numeric
The installed power of the generator (e.g. in MW). If not set the
capacity will be optimized (s. also `capacity_cost` argument)
profile: array-like (optional)
Profile of the output such that profile[t] * installed capacity
yields the upper bound for timestep t
marginal_cost: numeric
Marginal cost for one unit of produced output, i.e. for a powerplant:
mc = fuel_cost + co2_cost + ... (in Euro / MWh) if timestep length is
one hour. Default: 0
capacity_cost: numeric (optional)
Investment costs per unit of capacity (e.g. Euro / MW) .
If capacity is not set, this value will be used for optimizing the
generators capacity.
expandable: boolean
True, if capacity can be expanded within optimization. Default: False.
output_paramerters: dict (optional)
Parameters to set on the output edge of the component (see. oemof.solph
Edge/Flow class for possible arguments)
capacity_potential: numeric
Max install capacity if capacity is to be expanded
capacity_minimum: numeric
Minimum install capacity if capacity is to be expanded
The mathematical representations for this components are dependent on the
user defined attributes. If the capacity is fixed before
(**dispatch mode**) the following equation holds:
.. math::
x^{flow}(t) \leq c^{capacity} \cdot c^{profile}(t) \
\qquad \forall t \in T
Where :math:`x^{flow}` denotes the production (endogenous variable)
of the dispatchable object to the bus.
If `expandable` is set to `True` (**investment mode**), the equation
changes slightly:
.. math::
x^{flow}(t) \leq (x^{capacity} +
c^{capacity}) \cdot c^{profile}(t) \qquad \forall t \in T
Where the bounded endogenous variable of the volatile component is added:
.. math::
x^{capacity} \leq c^{capacity\_potential}
**Ojective expression** for operation:
.. math::
x^{opex} = \sum_t x^{flow}(t) \cdot c^{marginal\_cost}(t)
For constraints set through `output_parameters` see oemof.solph.Flow class.
Examples
---------
>>> from oemof import solph
>>> from oemof.tabular import facades
>>> my_bus = solph.Bus('my_bus')
>>> my_dispatchable = Dispatchable(
... label='ccgt',
... bus=my_bus,
... carrier='gas',
... tech='ccgt',
... capacity=1000,
... marginal_cost=10,
... output_parameters={
... 'min': 0.2})
"""
def __init__(self, *args, **kwargs):
kwargs.update({"_facade_requires_": ["bus", "carrier", "tech"]})
super().__init__(*args, **kwargs)
self.profile = kwargs.get("profile", 1)
self.capacity = kwargs.get("capacity")
self.capacity_potential = kwargs.get(
"capacity_potential", float("+inf")
)
self.marginal_cost = kwargs.get("marginal_cost", 0)
self.capacity_cost = kwargs.get("capacity_cost")
self.capacity_minimum = kwargs.get("capacity_minimum")
self.expandable = bool(kwargs.get("expandable", False))
self.output_parameters = kwargs.get("output_parameters", {})
self.build_solph_components()
def build_solph_components(self):
"""
"""
if self.profile is None:
self.profile = 1
f = Flow(
nominal_value=self._nominal_value(),
variable_costs=self.marginal_cost,
max=self.profile,
investment=self._investment(),
**self.output_parameters
)
self.outputs.update({self.bus: f})
class Volatile(Source, Facade):
r"""Volatile element with one output. This class can be used to model
PV oder Wind power plants.
Parameters
----------
bus: oemof.solph.Bus
An oemof bus instance where the generator is connected to
capacity: numeric
The installed power of the unit (e.g. in MW).
profile: array-like
Profile of the output such that profile[t] * capacity yields output
for timestep t
marginal_cost: numeric
Marginal cost for one unit of produced output, i.e. for a powerplant:
mc = fuel_cost + co2_cost + ... (in Euro / MWh) if timestep length is
one hour.
capacity_cost: numeric (optional)
Investment costs per unit of capacity (e.g. Euro / MW) .
If capacity is not set, this value will be used for optimizing the
generators capacity.
output_paramerters: dict (optional)
Parameters to set on the output edge of the component (see. oemof.solph
Edge/Flow class for possible arguments)
capacity_potential: numeric
Max install capacity if investment
capacity_minimum: numeric
Minimum install capacity if investment
expandable: boolean
True, if capacity can be expanded within optimization. Default: False.
The mathematical representations for this components are dependent on the
user defined attributes. If the capacity is fixed before
(**dispatch mode**) the following equation holds:
.. math::
x^{flow}(t) = c^{capacity} \cdot c^{profile}(t) \qquad \forall t \in T
Where :math:`x_{volatile}^{flow}` denotes the production
(endogenous variable) of the volatile object to the bus.
If `expandable` is set to `True` (**investment mode**), the equation
changes slightly:
.. math::
x^{flow}(t) = (x^{capacity} + c^{capacity}) \
\cdot c^{profile}(t) \qquad \forall t \in T
Where the bounded endogenous variable of the volatile component is added:
.. math::
x_{volatile}^{capacity} \leq c_{volatile}^{capacity\_potential}
**Ojective expression** for operation:
.. math::
x^{opex} = \sum_t (x^{flow}(t) \cdot c^{marginal\_cost}(t))
Examples
---------
>>> from oemof import solph
>>> from oemof.tabular import facades
>>> my_bus = solph.Bus('my_bus')
>>> my_volatile = Volatile(
... label='wind',
... bus=my_bus,
... carrier='wind',
... tech='onshore',
... capacity_cost=150,
... profile=[0.25, 0.1, 0.3])
"""
def __init__(self, *args, **kwargs):
kwargs.update(
{"_facade_requires_": ["bus", "carrier", "tech", "profile"]}
)
super().__init__(*args, **kwargs)
self.profile = kwargs.get("profile")
self.capacity = kwargs.get("capacity")
self.capacity_potential = kwargs.get(
"capacity_potential",
float("+inf")
)
self.capacity_minimum = kwargs.get("capacity_minimum")
self.expandable = bool(kwargs.get("expandable", False))
self.marginal_cost = kwargs.get("marginal_cost", 0)
self.capacity_cost = kwargs.get("capacity_cost")
self.output_parameters = kwargs.get("output_parameters", {})
self.build_solph_components()
def build_solph_components(self):
"""
"""
f = Flow(
nominal_value=self._nominal_value(),
variable_costs=self.marginal_cost,
fix=self.profile,
investment=self._investment(),
**self.output_parameters
)
self.outputs.update({self.bus: f})
class ExtractionTurbine(ExtractionTurbineCHP, Facade):
r""" Combined Heat and Power (extraction) unit with one input and
two outputs.
Parameters
----------
electricity_bus: oemof.solph.Bus
An oemof bus instance where the chp unit is connected to with its
electrical output
heat_bus: oemof.solph.Bus
An oemof bus instance where the chp unit is connected to with its
thermal output
fuel_bus: oemof.solph.Bus
An oemof bus instance where the chp unit is connected to with its
input
carrier_cost: numeric
Cost per unit of used input carrier
capacity: numeric
The electrical capacity of the chp unit (e.g. in MW) in full extraction
mode.
electric_efficiency:
Electrical efficiency of the chp unit in full backpressure mode
thermal_efficiency:
Thermal efficiency of the chp unit in full backpressure mode
condensing_efficiency:
Electrical efficiency if turbine operates in full extraction mode
marginal_cost: numeric
Marginal cost for one unit of produced electrical output
E.g. for a powerplant:
marginal cost =fuel cost + operational cost + co2 cost (in Euro / MWh)
if timestep length is one hour.
capacity_cost: numeric
Investment costs per unit of electrical capacity (e.g. Euro / MW) .
If capacity is not set, this value will be used for optimizing the
chp capacity.
expandable: boolean
True, if capacity can be expanded within optimization. Default: False.
The mathematical description is derived from the oemof base class
`ExtractionTurbineCHP <https://oemof.readthedocs.io/en/
stable/oemof_solph.html#extractionturbinechp-component>`_ :
.. math::
x^{flow, carrier}(t) =
\frac{x^{flow, electricity}(t) + x^{flow, heat}(t) \
\cdot c^{beta}(t)}{c^{condensing\_efficiency}(t)}
\qquad \forall t \in T
.. math::
x^{flow, electricity}(t) \geq x^{flow, thermal}(t) \cdot
\frac{c^{electrical\_efficiency}(t)}{c^{thermal\_efficiency}(t)}
\qquad \forall t \in T
where :math:`c^{beta}` is defined as:
.. math::
c^{beta}(t) = \frac{c^{condensing\_efficiency}(t) -
c^{electrical\_efficiency(t)}}{c^{thermal\_efficiency}(t)}
\qquad \forall t \in T
**Ojective expression** for operation includes marginal cost and/or
carrier costs:
.. math::
x^{opex} = \sum_t (x^{flow, out}(t) \cdot c^{marginal\_cost}(t)
+ x^{flow, carrier}(t) \cdot c^{carrier\_cost}(t))
Examples
---------
>>> from oemof import solph
>>> from oemof.tabular import facades
>>> my_elec_bus = solph.Bus('my_elec_bus')
>>> my_fuel_bus = solph.Bus('my_fuel_bus')
>>> my_heat_bus = solph.Bus('my_heat_bus')
>>> my_extraction = ExtractionTurbine(
... label='extraction',
... carrier='gas',
... tech='ext',
... electricity_bus=my_elec_bus,
... heat_bus=my_heat_bus,
... fuel_bus=my_fuel_bus,
... capacity=1000,
... condensing_efficiency=[0.5, 0.51, 0.55],
... electric_efficiency=0.4,
... thermal_efficiency=0.35)
"""
def __init__(self, *args, **kwargs):
kwargs.update(
{
"_facade_requires_": [
"fuel_bus",
"carrier",
"tech",
"electricity_bus",
"heat_bus",
"thermal_efficiency",
"electric_efficiency",
"condensing_efficiency",
]
}
)
super().__init__(
conversion_factor_full_condensation={}, *args, **kwargs
)
self.fuel_bus = kwargs.get("fuel_bus")
self.electricity_bus = kwargs.get("electricity_bus")
self.heat_bus = kwargs.get("heat_bus")
self.carrier = kwargs.get("carrier")
self.carrier_cost = kwargs.get("carrier_cost", 0)
self.capacity = kwargs.get("capacity")
self.condensing_efficiency = sequence(self.condensing_efficiency)
self.marginal_cost = kwargs.get("marginal_cost", 0)
self.capacity_cost = kwargs.get("capacity_cost")
self.expandable = bool(kwargs.get("expandable", False))
self.input_parameters = kwargs.get("input_parameters", {})
self.build_solph_components()
def build_solph_components(self):
"""
"""
self.conversion_factors.update(
{
self.fuel_bus: sequence(1),
self.electricity_bus: sequence(self.electric_efficiency),
self.heat_bus: sequence(self.thermal_efficiency),
}
)
self.inputs.update(
{
self.fuel_bus: Flow(
variable_costs=self.carrier_cost, **self.input_parameters
)
}
)
self.outputs.update(
{
self.electricity_bus: Flow(
nominal_value=self._nominal_value(),
variable_costs=self.marginal_cost,
investment=self._investment(),
),
self.heat_bus: Flow(),
}
)
self.conversion_factor_full_condensation.update(
{self.electricity_bus: self.condensing_efficiency}
)
class BackpressureTurbine(Transformer, Facade):
r""" Combined Heat and Power (backpressure) unit with one input and
two outputs.
Parameters
----------
electricity_bus: oemof.solph.Bus
An oemof bus instance where the chp unit is connected to with its
electrical output
heat_bus: oemof.solph.Bus
An oemof bus instance where the chp unit is connected to with its
thermal output
fuel_bus: oemof.solph.Bus
An oemof bus instance where the chp unit is connected to with its
input
carrier_cost: numeric
Input carrier cost of the backpressure unit, Default: 0
capacity: numeric
The electrical capacity of the chp unit (e.g. in MW).
electric_efficiency:
Electrical efficiency of the chp unit
thermal_efficiency:
Thermal efficiency of the chp unit
marginal_cost: numeric
Marginal cost for one unit of produced electrical output
E.g. for a powerplant:
marginal cost =fuel cost + operational cost + co2 cost (in Euro / MWh)
if timestep length is one hour. Default: 0
expandable: boolean
True, if capacity can be expanded within optimization. Default: False.
capacity_cost: numeric
Investment costs per unit of electrical capacity (e.g. Euro / MW) .
If capacity is not set, this value will be used for optimizing the
chp capacity.
Backpressure turbine power plants are modelled with a constant relation
between heat and electrical output (power to heat coefficient).
.. math::
x^{flow, carrier}(t) =
\frac{x^{flow, electricity}(t) + x^{flow, heat}(t)}\
{c^{thermal\:efficiency}(t) + c^{electrical\:efficiency}(t)}
\qquad \forall t \in T
.. math::
\frac{x^{flow, electricity}(t)}{x_{flow, thermal}(t)} =
\frac{c^{electrical\:efficiency}(t)}{c^{thermal\:efficiency}(t)}
\qquad \forall t \in T
**Ojective expression** for operation includes marginal cost and/or
carrier costs:
.. math::
x^{opex} = \sum_t (x^{flow, out}(t) \cdot c^{marginal\_cost}(t)
+ x^{flow, carrier}(t) \cdot c^{carrier\_cost}(t))
Examples
---------
>>> from oemof import solph
>>> from oemof.tabular import facades
>>> my_elec_bus = solph.Bus('my_elec_bus')
>>> my_fuel_bus = solph.Bus('my_fuel_bus')
>>> my_heat_bus = solph.Bus('my_heat_bus')
>>> my_backpressure = BackpressureTurbine(
... label='backpressure',
... carrier='gas',
... tech='bp',
... fuel_bus=my_fuel_bus,
... heat_bus=my_heat_bus,
... electricity_bus=my_elec_bus,
... capacity_cost=50,
... carrier_cost=0.6,
... electric_efficiency=0.4,
... thermal_efficiency=0.35)
"""
def __init__(self, *args, **kwargs):
super().__init__(
_facade_requires_=[
"carrier",
"tech",
"electricity_bus",
"heat_bus",
"fuel_bus",
"thermal_efficiency",
"electric_efficiency",
],
*args,
**kwargs
)
self.electricity_bus = kwargs.get("electricity_bus")
self.heat_bus = kwargs.get("heat_bus")
self.fuel_bus = kwargs.get("fuel_bus")
self.capacity = kwargs.get("capacity")
self.marginal_cost = kwargs.get("marginal_cost", 0)
self.carrier_cost = kwargs.get("carrier_cost", 0)
self.capacity_cost = kwargs.get("capacity_cost")
self.expandable = bool(kwargs.get("expandable", False))
self.input_parameters = kwargs.get("input_parameters", {})
self.build_solph_components()
def build_solph_components(self):
"""
"""
self.conversion_factors.update(
{
self.fuel_bus: sequence(1),
self.electricity_bus: sequence(self.electric_efficiency),
self.heat_bus: sequence(self.thermal_efficiency),
}
)
self.inputs.update(
{
self.fuel_bus: Flow(
variable_costs=self.carrier_cost, **self.input_parameters
)
}
)
self.outputs.update(
{
self.electricity_bus: Flow(
nominal_value=self._nominal_value(),
investment=self._investment(),
),
self.heat_bus: Flow(),
}
)
class Conversion(Transformer, Facade):
r""" Conversion unit with one input and one output.
Parameters
----------
from_bus: oemof.solph.Bus
An oemof bus instance where the conversion unit is connected to with
its input.
to_bus: oemof.solph.Bus
An oemof bus instance where the conversion unit is connected to with
its output.
capacity: numeric
The conversion capacity (output side) of the unit.
efficiency: numeric
Efficiency of the conversion unit (0 <= efficiency <= 1). Default: 1
marginal_cost: numeric
Marginal cost for one unit of produced output. Default: 0
carrier_cost: numeric
Carrier cost for one unit of used input. Default: 0
capacity_cost: numeric
Investment costs per unit of output capacity.
If capacity is not set, this value will be used for optimizing the
conversion output capacity.
expandable: boolean or numeric (binary)
True, if capacity can be expanded within optimization. Default: False.
capacity_potential: numeric
Maximum invest capacity in unit of output capacity.
capacity_minimum: numeric
Minimum invest capacity in unit of output capacity.
input_parameters: dict (optional)
Set parameters on the input edge of the conversion unit
(see oemof.solph for more information on possible parameters)
ouput_parameters: dict (optional)
Set parameters on the output edge of the conversion unit
(see oemof.solph for more information on possible parameters)
.. math::
x^{flow, from}(t) \cdot c^{efficiency}(t) = x^{flow, to}(t)
\qquad \forall t \in T
**Ojective expression** for operation includes marginal cost and/or
carrier costs:
.. math::
x^{opex} = \sum_t (x^{flow, out}(t) \cdot c^{marginal\_cost}(t)
+ x^{flow, carrier}(t) \cdot c^{carrier\_cost}(t))
Examples
---------
>>> from oemof import solph
>>> from oemof.tabular import facades
>>> my_biomass_bus = solph.Bus('my_biomass_bus')
>>> my_heat_bus = solph.Bus('my_heat_bus')
>>> my_conversion = Conversion(
... label='biomass_plant',
... carrier='biomass',
... tech='st',
... from_bus=my_biomass_bus,
... to_bus=my_heat_bus,
... capacity=100,
... efficiency=0.4)
"""
def __init__(self, *args, **kwargs):
super().__init__(
_facade_requires_=["from_bus", "to_bus", "carrier", "tech"],
*args,
**kwargs
)
self.capacity = kwargs.get("capacity")
self.efficiency = kwargs.get("efficiency", 1)
self.marginal_cost = kwargs.get("marginal_cost", 0)
self.carrier_cost = kwargs.get("carrier_cost", 0)
self.capacity_cost = kwargs.get("capacity_cost")
self.expandable = bool(kwargs.get("expandable", False))
self.carrier_cost = kwargs.get("carrier_cost", 0)
self.capacity_potential = kwargs.get(
"capacity_potential",
float("+inf")
)
self.capacity_minimum = kwargs.get("capacity_minimum")
self.input_parameters = kwargs.get("input_parameters", {})
self.output_parameters = kwargs.get("output_parameters", {})
self.build_solph_components()
def build_solph_components(self):
"""
"""
self.conversion_factors.update(
{
self.from_bus: sequence(1),
self.to_bus: sequence(self.efficiency),
}
)
self.inputs.update(
{
self.from_bus: Flow(
variable_costs=self.carrier_cost, **self.input_parameters