-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathnode.jl
More file actions
773 lines (618 loc) · 23.5 KB
/
Copy pathnode.jl
File metadata and controls
773 lines (618 loc) · 23.5 KB
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
"""
abstract type Node <: AbstractElement
A supertype for all technologies that convert a stream to another.
"""
abstract type Node <: AbstractElement end
Base.show(io::IO, n::Node) = print(io, "n_$(n.id)")
"""
abstract type StorageBehavior
`StorageBehavior` as supertype for individual storage behaviours.
Storage behaviour is used to identify how a storage node should behave within the individual
`TimeStructure`s of a strategic period.
"""
abstract type StorageBehavior end
"""
abstract type Accumulating <: StorageBehavior
`Accumulating` as supertype for an accumulating storage level.
Accumulating storage behaviour implies that the change in the overall storage level in a
strategic period can be both positive or negative.
Examples for potential usage of `Accumulating` are CO₂ storages in which the CO₂ is
permanently stored or multi year hydropower magazines.
"""
abstract type Accumulating <: StorageBehavior end
"""
abstract type Cyclic <: StorageBehavior
`Cyclic` as supertype for a cyclic storage level.
Cyclic storage behaviour implies that the change in the overall storage level in a strategic
period behaves cyclic.
"""
abstract type Cyclic <: StorageBehavior end
"""
struct AccumulatingEmissions <: Accumulating
`StorageBehavior` which accumulates all inflow witin a strategic period.
`AccumulatingEmissions` allows as well to serve as a [`ResourceEmit`](@ref) emission point to
represent a soft constraint on storing the captured emissions.
"""
struct AccumulatingEmissions <: Accumulating end
"""
struct CyclicRepresentative <: Cyclic
`StorageBehavior` in which cyclic behaviour is achieved within the lowest time structure
excluding operational times.
In the case of `TwoLevel{SimpleTimes}`, this approach is similar to `CyclicStrategic`.
In the case of `TwoLevel{RepresentativePeriods{SimpleTimes}}`, this approach differs from
`CyclicStrategic` as the cyclic constraint is enforeced within each representative period.
"""
struct CyclicRepresentative <: Cyclic end
"""
struct CyclicStrategic <: Cyclic
`StorageBehavior` in which the the cyclic behaviour is achieved within a strategic period.
This implies that the initial level in individual representative periods can be different
when using `RepresentativePeriods`.
"""
struct CyclicStrategic <: Cyclic end
"""
`AbstractStorageParameters` as supertype for individual parameters for [`Storage`](@ref) nodes.
Storage parameters are used to provide the user the flexibility to include or not include
capacities and variable and fixed OPEX parameters for charging, the storage level, and
discharging.
"""
abstract type AbstractStorageParameters end
"""
struct StorCapOpex <: AbstractStorageParameters
A storage parameter type for including a capacity as well as variable and fixed operational
expenditures.
# Fields
- **`capacity::TimeProfile`** is the installed capacity.
- **`opex_var::TimeProfile`** is the variable operating expense per capacity usage
through the variable `:cap_use`.
- **`opex_fixed::TimeProfile`** is the fixed operating expense per installed capacity
through the variable `:cap_inst`.
"""
struct StorCapOpex <: AbstractStorageParameters
capacity::TimeProfile
opex_var::TimeProfile
opex_fixed::TimeProfile
end
"""
struct StorCap <: AbstractStorageParameters
A storage parameter type for including only a capacity. This implies that neither the usage
of the [`Storage`](@ref), nor the installed capacity have a direct impact on the objective
function.
# Fields
- **`capacity::TimeProfile`** is the installed capacity.
"""
struct StorCap <: AbstractStorageParameters
capacity::TimeProfile
end
"""
struct StorCapOpexVar <: AbstractStorageParameters
A storage parameter type for including a capacity and variable operational expenditures.
This implies that the installed capacity has no direct impact on the objective function.
# Fields
- **`capacity::TimeProfile`** is the installed capacity.
- **`opex_var::TimeProfile`** is the variable operating expense per capacity usage
through the variable `:cap_use`.
"""
struct StorCapOpexVar <: AbstractStorageParameters
capacity::TimeProfile
opex_var::TimeProfile
end
"""
struct StorCapOpexFixed <: AbstractStorageParameters
A storage parameter type for including a capacity and fixed operational expenditures.
This implies that the installed capacity has no direct impact on the objective function.
# Fields
- **`capacity::TimeProfile`** is the installed capacity.
- **`opex_fixed::TimeProfile`** is the fixed operating expense per installed capacity
through the variable `:cap_inst`.
"""
struct StorCapOpexFixed <: AbstractStorageParameters
capacity::TimeProfile
opex_fixed::TimeProfile
end
"""
struct StorOpexVar <: AbstractStorageParameters
A storage parameter type for including variable operational expenditures.
This implies that the charge or discharge rate do not have a capacity and the [`Storage`](@ref)
level can be used within a single `TimePeriod`.
This type can only be used for the fields `charge` and `discharge`.
# Fields
- **`opex_var::TimeProfile`** is the variable operating expense per capacity usage
through the variable `:cap_use`.
"""
struct StorOpexVar <: AbstractStorageParameters
opex_var::TimeProfile
end
"""
UnionOpexFixed
Union for simpler dispatching for storage parameters that include fixed OPEX.
"""
UnionOpexFixed = Union{StorCapOpex,StorCapOpexFixed}
"""
UnionOpexVar
Union for simpler dispatching for storage parameters that include variable OPEX.
"""
UnionOpexVar = Union{StorCapOpex,StorCapOpexVar,StorOpexVar}
"""
UnionCapacity
Union for simpler dispatching for storage parameters that include a capacity.
"""
UnionCapacity = Union{StorCapOpex,StorCap,StorCapOpexVar,StorCapOpexFixed}
"""
abstract type Source <: Node
A `Node` with only output.
"""
abstract type Source <: Node end
"""
abstract type NetworkNode <: Node
A `Node` with both input and output.
"""
abstract type NetworkNode <: Node end
"""
abstract type Sink <: Node
A `Node` with only input.
"""
abstract type Sink <: Node end
"""
abstract type Storage{T<:StorageBehavior} <: NetworkNode
A `NetworkNode` with a storage level.
"""
abstract type Storage{T<:StorageBehavior} <: NetworkNode end
"""
abstract type Availability <: NetworkNode
A `NetworkNode` as routing node.
"""
abstract type Availability <: NetworkNode end
"""
struct RefSource <: Source
A reference [`Source`](@ref) node.
The reference [`Source`](@ref) node allows for a time varying capacity which is normalized to a
conversion value of 1 in the field `input`.
Note, that if you include investments, you can only use as `TimeProfile` a `FixedProfile`
or `StrategicProfile`.
# Fields
- **`id`** is the name/identifier of the node.
- **`cap::TimeProfile`** is the installed capacity.
- **`opex_var::TimeProfile`** is the variable operating expense per per capacity usage
through the variable `:cap_use`.
- **`opex_fixed::TimeProfile`** is the fixed operating expense per installed capacity
through the variable `:cap_inst`.
- **`output::Dict{<:Resource,<:Real}`** are the generated [`Resource`](@ref)s with
conversion value `Real`.
- **`data::Vector{<:ExtensionData}`** is the additional data (*e.g.*, for investments).
The field `data` is conditional through usage of a constructor.
"""
struct RefSource <: Source
id::Any
cap::TimeProfile
opex_var::TimeProfile
opex_fixed::TimeProfile
output::Dict{<:Resource,<:Real}
data::Vector{<:ExtensionData}
end
function RefSource(
id,
cap::TimeProfile,
opex_var::TimeProfile,
opex_fixed::TimeProfile,
output::Dict{<:Resource,<:Real},
)
return RefSource(id, cap, opex_var, opex_fixed, output, ExtensionData[])
end
"""
struct RefNetworkNode <: NetworkNode
A reference [`NetworkNode`](@ref) node.
The `RefNetworkNode` utilizes a linear, time independent conversion rate of the `input`
[`Resource`](@ref)s to the output [`Resource`](@ref)s, subject to the available capacity.
The capacity is hereby normalized to a conversion value of 1 in the fields `input` and
`output`.
# Fields
- **`id`** is the name/identifier of the node.
- **`cap::TimeProfile`** is the installed capacity.
- **`opex_var::TimeProfile`** is the variable operating expense per per capacity usage
through the variable `:cap_use`.
- **`opex_fixed::TimeProfile`** is the fixed operating expense per installed capacity
through the variable `:cap_inst`.
- **`input::Dict{<:Resource,<:Real}`** are the input [`Resource`](@ref)s with conversion
value `Real`.
- **`output::Dict{<:Resource,<:Real}`** are the generated [`Resource`](@ref)s with
conversion value `Real`.
- **`data::Vector{ExtensionData}`** is the additional data (*e.g.*, for investments).
The field `data` is conditional through usage of a constructor.
"""
struct RefNetworkNode <: NetworkNode
id::Any
cap::TimeProfile
opex_var::TimeProfile
opex_fixed::TimeProfile
input::Dict{<:Resource,<:Real}
output::Dict{<:Resource,<:Real}
data::Vector{<:ExtensionData}
end
function RefNetworkNode(
id,
cap::TimeProfile,
opex_var::TimeProfile,
opex_fixed::TimeProfile,
input::Dict{<:Resource,<:Real},
output::Dict{<:Resource,<:Real},
)
return RefNetworkNode(id, cap, opex_var, opex_fixed, input, output, ExtensionData[])
end
"""
struct GenAvailability <: Availability
A reference `Availability` node.
The reference `Availability` node solves the energy balance for all connected flows.
# Fields
- **`id`** is the name/identifier of the node.
- **`input::Vector{<:Resource}`** are the input [`Resource`](@ref)s.
- **`output::Vector{<:Resource}`** are the output [`Resource`](@ref)s.
A constructor is provided so that only a single array can be provided with the fields:
- **`id`** is the name/identifier of the node.
- **`𝒫::Vector{<:Resource}`** are the `[`Resource`](@ref)s.
"""
struct GenAvailability <: Availability
id::Any
input::Vector{<:Resource}
output::Vector{<:Resource}
end
GenAvailability(id, 𝒫::Vector{<:Resource}) = GenAvailability(id, 𝒫, 𝒫)
"""
struct RefStorage{T} <: Storage{T}
A reference [`Storage`](@ref) node.
This node is designed to store either a [`ResourceCarrier`](@ref) or a [`ResourceEmit`](@ref).
It is designed as a parametric type through the type parameter `T` to differentiate between
different cyclic behaviours. Note that the parameter `T` is only used for dispatching, but
does not carry any other information. Hence, it is simple to fast switch between different
[`StorageBehavior`](@ref)s.
The current implemented cyclic behaviours are [`CyclicRepresentative`](@ref),
[`CyclicStrategic`](@ref), and [`AccumulatingEmissions`](@ref).
# Fields
- **`id`** is the name/identifier of the node.
- **`charge::AbstractStorageParameters`** are the charging parameters of the [`Storage`](@ref) node.
Depending on the chosen type, the charge parameters can include variable OPEX, fixed OPEX,
and/or a capacity.
- **`level::AbstractStorageParameters`** are the level parameters of the [`Storage`](@ref) node.
Depending on the chosen type, the level parameters can include variable OPEX and/or fixed OPEX.
They must include a capacity.
- **`stor_res::Resource`** is the stored [`Resource`](@ref).
- **`input::Dict{<:Resource,<:Real}`** are the input [`Resource`](@ref)s with conversion
value `Real`.
- **`output::Dict{<:Resource,<:Real}`** are the generated [`Resource`](@ref)s with conversion
value `Real`. Only relevant for linking and the stored [`Resource`](@ref) as the output
value is not utilized in the calculations.
- **`data::Vector{<:ExtensionData}`** is the additional data (*e.g.*, for investments).
The field `data` is conditional through usage of a constructor.
"""
struct RefStorage{T} <: Storage{T}
id::Any
charge::AbstractStorageParameters
level::UnionCapacity
stor_res::Resource
input::Dict{<:Resource,<:Real}
output::Dict{<:Resource,<:Real}
data::Vector{<:ExtensionData}
end
function RefStorage{T}(
id,
charge::AbstractStorageParameters,
level::UnionCapacity,
stor_res::Resource,
input::Dict{<:Resource,<:Real},
output::Dict{<:Resource,<:Real},
) where {T<:StorageBehavior}
return RefStorage{T}(id, charge, level, stor_res, input, output, ExtensionData[])
end
"""
struct RefSink <: Sink
A reference [`Sink`](@ref) node. This node corresponds to a demand given by the field `cap`.
The penalties introduced in the field `penalty` affect the variable OPEX for both a surplus
and deficit.
# Fields
- **`id`** is the name/identifier of the node.
- **`cap::TimeProfile`** is the demand.
- **`penalty::Dict{Symbol,<:TimeProfile}`** are penalties for surplus or deficits. The
dictionary requires the fields `:surplus` and `:deficit`.
- **`input::Dict{<:Resource,<:Real}`** are the input [`Resource`](@ref)s with conversion
value `Real`.
- **`data::Vector{<:ExtensionData}`** is the additional data (*e.g.*, for investments).
The field `data` is conditional through usage of a constructor.
"""
struct RefSink <: Sink
id::Any
cap::TimeProfile
penalty::Dict{Symbol,<:TimeProfile}
input::Dict{<:Resource,<:Real}
data::Vector{<:ExtensionData}
end
function RefSink(
id,
cap::TimeProfile,
penalty::Dict{<:Any,<:TimeProfile},
input::Dict{<:Resource,<:Real},
)
return RefSink(id, cap, penalty, input, ExtensionData[])
end
"""
is_source(n::Node)
Checks whether node `n` is a [`Source`](@ref) node.
"""
is_source(n::Node) = false
is_source(n::Source) = true
"""
is_network_node(n::Node)
Checks whether node `n` is a [`NetworkNode`](@ref) node.
"""
is_network_node(n::Node) = false
is_network_node(n::NetworkNode) = true
"""
is_storage(n::Node)
Checks whether node `n` is a [`Storage`](@ref) node.
"""
is_storage(n::Node) = false
is_storage(n::Storage) = true
"""
is_sink(n::Node)
Checks whether node `n` is a [`Sink`](@ref) node.
"""
is_sink(n::Node) = false
is_sink(n::Sink) = true
"""
has_capacity(n::Node)
Checks whether node `n` has a standard capacity.
By default, [`Storage`](@ref) and [`Availability`](@ref) nodes are excluded as they either
have multiple capacities (`Storage`) or non (`Availability`).
"""
has_capacity(n::Node) = true
has_capacity(n::Storage) = false
has_capacity(n::Availability) = false
"""
has_opex(n::Node)
Checks whether node `n` has operating expenses.
By default, all nodes except for [`Availability`](@ref) nodes do have operating expenses.
"""
has_opex(n::Node) = true
has_opex(n::Availability) = false
"""
has_emissions(n::Node)
Checks whether node `n` has emissions.
"""
has_emissions(n::Node) = any(typeof(data) <: EmissionsData for data ∈ n.data)
has_emissions(n::Availability) = false
has_emissions(n::RefStorage{AccumulatingEmissions}) = true
"""
has_emissions(𝒩::Array{<:Node})
Returns nodes that have emission data for a given Array `::Array{<:Node}`.
"""
nodes_emissions(𝒩::Array{<:Node}) = filter(has_emissions, 𝒩)
"""
nodes_sub(𝒩::Array{<:Node}, sub)
Returns nodes that are of type `sub` for a given Array `𝒩::Array{<:Node}`.
"""
nodes_sub(𝒩::Array{<:Node}, sub = NetworkNode) = filter(x -> isa(x, sub), 𝒩)
"""
nodes_input(𝒩::Array{<:Node}, sub)
Returns nodes that have an input, *i.e.*, [`Sink`](@ref) and [`NetworkNode`](@ref) nodes.
"""
nodes_input(𝒩::Array{<:Node}) = filter(has_input, 𝒩)
"""
has_input(n::Node)
Returns logic whether the node is an input node, *i.e.*, [`Sink`](@ref) and
[`NetworkNode`](@ref) nodes.
"""
has_input(n::Node) = true
has_input(n::Source) = false
"""
nodes_output(𝒩::Array{<:Node})
Returns nodes that have an output, *i.e.*, [`Source`](@ref) and [`NetworkNode`](@ref) nodes.
"""
nodes_output(𝒩::Array{<:Node}) = filter(has_output, 𝒩)
"""
has_output(n::Node)
Returns logic whether the node is an output node, *i.e.*, [`Source`](@ref) and
[`NetworkNode`](@ref) nodes.
"""
has_output(n::Node) = true
has_output(n::Sink) = false
"""
is_unidirectional(n::Node)
Returns logic whether the node `n` can be used bidirectional or only unidirectional.
!!! note "Bidirectional flow in nodes"
In the current stage, `EnergyModelsBase` does not include any nodes which can be used
bidirectional, that is with flow reversal.
If you plan to use bidirectional flow, you have to declare your own nodes and links that
support this. You can then dispatch on this function for the incorporation.
"""
is_unidirectional(n::Node) = true
"""
has_charge(n::Storage)
Returns logic whether the node has a `charge` field allowing for restrictions and/or costs
on the (installed) charging rate.
"""
has_charge(n::Storage) = hasfield(typeof(n), :charge)
"""
charge(n::Storage)
Returns the parameter type of the `charge` field of the node. If the node has no field
`charge`, it returns `nothing`.
"""
charge(n::Storage) = has_charge(n) ? n.charge : nothing
"""
has_charge_cap(n::Storage)
Returns logic whether the node has a `charge` capacity.
"""
has_charge_cap(n::Storage) = has_charge(n) && isa(charge(n), UnionCapacity)
"""
has_charge_OPEX_fixed(n::Storage)
Returns logic whether the node has a `charge` fixed OPEX contribution.
"""
has_charge_OPEX_fixed(n::Storage) =
has_charge(n) && isa(charge(n), UnionOpexFixed)
"""
has_charge_OPEX_var(n::Storage)
Returns logic whether the node has a `charge` variable OPEX contribution.
"""
has_charge_OPEX_var(n::Storage) =
has_charge(n) && isa(charge(n), UnionOpexVar)
"""
has_discharge(n::Storage)
Returns logic whether the node has a `discharge` field allowing for restrictions and/or
costs on the (installed) discharging rate.
"""
has_discharge(n::Storage) = hasfield(typeof(n), :discharge)
"""
discharge(n::Storage)
Returns the parameter type of the `discharge` field of the node. If the node has no field
`discharge`, it returns `nothing`.
"""
discharge(n::Storage) = has_discharge(n) ? n.discharge : nothing
"""
has_discharge_cap(n::Storage)
Returns logic whether the node has a `discharge` capacity.
"""
has_discharge_cap(n::Storage) =
has_discharge(n) && isa(discharge(n), UnionCapacity)
"""
has_discharge_OPEX_fixed(n::Storage)
Returns logic whether the node has a `discharge` fixed OPEX contribution.
"""
has_discharge_OPEX_fixed(n::Storage) =
has_discharge(n) && isa(discharge(n), UnionOpexFixed)
"""
has_discharge_OPEX_var(n::Storage)
Returns logic whether the node has a `discharge` variable OPEX contribution.
"""
has_discharge_OPEX_var(n::Storage) =
has_discharge(n) && isa(discharge(n), UnionOpexVar)
"""
level(n::Storage)
Returns the parameter type of the `level` field of the node.
"""
level(n::Storage) = n.level
"""
has_level_OPEX_fixed(n::Storage)
Returns logic whether the node has a `level` fixed OPEX contribution.
"""
has_level_OPEX_fixed(n::Storage) = isa(level(n), UnionOpexFixed)
"""
has_level_OPEX_var(n::Storage)
Returns logic whether the node has a `level` variable OPEX contribution.
"""
has_level_OPEX_var(n::Storage) = isa(level(n), UnionOpexVar)
"""
capacity(n::Node)
capacity(n::Node, t)
Returns the capacity of a node `n` as `TimeProfile` or in operational period `t`.
!!! warning "Storage nodes"
The capacity is not directly defined for [`Storage`](@ref) nodes. Instead, it is necessary
to call the function on the respective field, see
[`capacity(stor_par::AbstractStorageParameters)`](@ref).
"""
capacity(n::Node) = n.cap
capacity(n::Node, t) = n.cap[t]
"""
capacity(stor_par::AbstractStorageParameters)
capacity(stor_par::AbstractStorageParameters, t)
Returns the capacity of storage parameter `stor_par` as `TimeProfile` or in operational
period `t`.
!!! note "Accessing storage parameters"
The individual storage parameters of a [`Storage`](@ref) node can be accessed through the
functions [`charge(n)`](@ref), [`level(n)`](@ref), and [`discharge(n)`](@ref).
"""
capacity(stor_par::AbstractStorageParameters) = stor_par.capacity
capacity(stor_par::AbstractStorageParameters, t) = stor_par.capacity[t]
"""
inputs(n::Node)
inputs(n::Node, p::Resource)
Returns the input resources of a node `n`, specified *via* the field `input`.
If the resource `p` is specified, it returns the value (1 in the case of
[`Availability`](@ref), nothing in the case of a [`Source`](@ref))
"""
inputs(n::Node) = collect(keys(n.input))
inputs(n::Availability) = n.input
inputs(n::Source) = Resource[]
inputs(n::Node, p::Resource) = n.input[p]
inputs(n::Availability, p::Resource) = 1
inputs(n::Source, p::Resource) = nothing
"""
outputs(n::Node)
outputs(n::Node, p::Resource)
Returns the output resources of a node `n`, specified *via* the field `output`.
If the resource `p` is specified, it returns the value (1 in the case of
[`Availability`](@ref), nothing in the case of a [`Sink`](@ref))
"""
outputs(n::Node) = collect(keys(n.output))
outputs(n::Availability) = n.output
outputs(n::Sink) = Resource[]
outputs(n::Node, p::Resource) = n.output[p]
outputs(n::Availability, p::Resource) = 1
outputs(n::Sink, p::Resource) = nothing
"""
node_data(n::Node)
Returns the [`ExtensionData`](@ref) array of node `n`.
"""
node_data(n::Node) = n.data
node_data(n::Availability) = ExtensionData[]
element_data(n::Node) = node_data(n)
"""
storage_resource(n::Storage)
Returns the storage resource of [`Storage`](@ref) node `n`.
"""
storage_resource(n::Storage) = n.stor_res
"""
opex_var(n::Node)
opex_var(n::Node, t)
Returns the variable OPEX of a node `n` as `TimeProfile` or in operational period `t`.
!!! warning "Storage nodes"
The variable OPEX is not directly defined for [`Storage`](@ref) nodes. Instead, it is
necessary to call the function on the respective field, see
[`opex_var(stor_par::AbstractStorageParameters)`](@ref).
"""
opex_var(n::Node) = n.opex_var
opex_var(n::Node, t) = n.opex_var[t]
"""
opex_var(stor_par::UnionOpexVar)
opex_var(stor_par::UnionOpexVar, t)
Returns the variable OPEX of storage parameter `stor_par` as `TimeProfile` or in operational
period `t`.
!!! note "Accessing storage parameters"
The individual storage parameters of a [`Storage`](@ref) node can be accessed through the
functions [`charge(n)`](@ref), [`level(n)`](@ref), and [`discharge(n)`](@ref).
"""
opex_var(stor_par::UnionOpexVar) = stor_par.opex_var
opex_var(stor_par::UnionOpexVar, t) = stor_par.opex_var[t]
"""
opex_fixed(n::Node)
opex_fixed(n::Node, t_inv)
Returns the fixed OPEX of a node `n` as `TimeProfile` or in strategic period `t_inv`.
!!! warning "Storage nodes"
The fixed OPEX is not directly defined for [`Storage`](@ref) nodes. Instead, it is necessary
to call the function on the respective field, see
[`opex_fixed(stor_par::AbstractStorageParameters)`](@ref).
"""
opex_fixed(n::Node) = n.opex_fixed
opex_fixed(n::Node, t_inv) = n.opex_fixed[t_inv]
"""
opex_fixed(stor_par::UnionOpexFixed)
opex_fixed(stor_par::UnionOpexFixed, t_inv)
Returns the fixed OPEX of storage parameter `stor_par` as `TimeProfile` or in strategic
period `t_inv`.
!!! note "Accessing storage parameters"
The individual storage parameters of a [`Storage`](@ref) node can be accessed through the
functions [`charge(n)`](@ref), [`level(n)`](@ref), and [`discharge(n)`](@ref).
"""
opex_fixed(stor_par::UnionOpexFixed) = stor_par.opex_fixed
opex_fixed(stor_par::UnionOpexFixed, t_inv) = stor_par.opex_fixed[t_inv]
"""
surplus_penalty(n::Sink)
surplus_penalty(n::Sink, t)
Returns the surplus penalty of sink `n` as `TimeProfile` or in operational period `t`.
"""
surplus_penalty(n::Sink) = n.penalty[:surplus]
surplus_penalty(n::Sink, t) = n.penalty[:surplus][t]
"""
deficit_penalty(n::Sink)
deficit_penalty(n::Sink, t)
Returns the deficit penalty of sink `n` as `TimeProfile` or in operational period `t`.
"""
deficit_penalty(n::Sink) = n.penalty[:deficit]
deficit_penalty(n::Sink, t) = n.penalty[:deficit][t]