Internal functions
Index
EnergyModelsBase.check_case_data
EnergyModelsBase.check_data
EnergyModelsBase.check_elements
EnergyModelsBase.check_fixed_opex
EnergyModelsBase.check_link
EnergyModelsBase.check_link_data
EnergyModelsBase.check_model
EnergyModelsBase.check_node
EnergyModelsBase.check_node_data
EnergyModelsBase.check_node_default
EnergyModelsBase.check_profile
EnergyModelsBase.check_representative_profile
EnergyModelsBase.check_scenario_profile
EnergyModelsBase.check_strategic_profile
EnergyModelsBase.check_time_structure
EnergyModelsBase.collect_types
EnergyModelsBase.compile_logs
EnergyModelsBase.constraints_couple
EnergyModelsBase.constraints_elements
EnergyModelsBase.constraints_emissions
EnergyModelsBase.constraints_level_bounds
EnergyModelsBase.constraints_level_iterate
EnergyModelsBase.constraints_level_rp
EnergyModelsBase.constraints_level_scp
EnergyModelsBase.create_element
EnergyModelsBase.create_link
EnergyModelsBase.emissions_operational
EnergyModelsBase.has_charge_OPEX_fixed
EnergyModelsBase.has_charge_OPEX_var
EnergyModelsBase.has_charge_cap
EnergyModelsBase.has_discharge_OPEX_fixed
EnergyModelsBase.has_discharge_OPEX_var
EnergyModelsBase.has_discharge_cap
EnergyModelsBase.has_level_OPEX_fixed
EnergyModelsBase.has_level_OPEX_var
EnergyModelsBase.is_network_node
EnergyModelsBase.is_resource_emit
EnergyModelsBase.is_sink
EnergyModelsBase.is_source
EnergyModelsBase.is_storage
EnergyModelsBase.link_res
EnergyModelsBase.link_sub
EnergyModelsBase.nodes_sub
EnergyModelsBase.objective
EnergyModelsBase.objective_operational
EnergyModelsBase.res_em
EnergyModelsBase.res_not
EnergyModelsBase.res_sub
EnergyModelsBase.sort_types
EnergyModelsBase.variables_capacity
EnergyModelsBase.variables_capex
EnergyModelsBase.variables_element
EnergyModelsBase.variables_elements
EnergyModelsBase.variables_emission
EnergyModelsBase.variables_flow
EnergyModelsBase.variables_opex
Extension functions
EnergyModelsBase.create_element
— Functioncreate_element(m, n::Node, 𝒯, 𝒫, modeltype::EnergyModel)
create_element(m, l::Link, 𝒯, 𝒫, modeltype::EnergyModel)
Default fallback method for an element type if no other method is defined for a given type. This function calls subfunctions to maintain backwards compatibility and simplify the differentiation in extension packages.
EnergyModelsBase
provides the user with two element types, Link
and Node
:
Node
- the subfunction iscreate_node
.Link
- the subfunction iscreate_link
.
EnergyModelsBase.create_link
— Functioncreate_link(m, l::Link, 𝒯, 𝒫, modeltype::EnergyModel)
create_link(m, l::Direct, 𝒯, 𝒫, modeltype::EnergyModel)
create_link(m, 𝒯, 𝒫, l::Link, modeltype::EnergyModel, formulation::Formulation)
Set the constraints for a Link
.
The argument order (m, 𝒯, 𝒫, l::Link, modeltype::EnergyModel, formulation::Formulation)
is deprecated. It will be removed in the near future. It remains to provide the user with the potential for a simple adjustment of the links
EnergyModelsBase.variables_element
— Functionvariables_element(m, 𝒩ˢᵘᵇ::Vector{<:Node}, 𝒯, modeltype::EnergyModel)
variables_element(m, ℒˢᵘᵇ::Vector{<:Link}, 𝒯, modeltype::EnergyModel)
Default fallback method for a vector of elements if no other method is defined for a given vector of element subtypes. This function calls subfunctions to maintain backwards compatibility and simplify the differentiation in extension packages.
EnergyModelsBase
provides the user with two element types, Link
and Node
:
Node
- the subfunction isvariables_node
.Link
- the subfunction isvariables_link
.
EnergyModelsBase.objective
— Methodobjective(m, 𝒳ᵛᵉᶜ, 𝒫, 𝒯, modeltype::EnergyModel)
Create the objective for the optimization problem for a given modeltype.
The default option includes to the objective function:
- the variable and fixed operating expenses for the individual nodes,
- the variable and fixed operating expenses for the individual links, and
- the cost for the emissions.
The values are not discounted.
This function serve as fallback option if no other method is specified for a specific modeltype
.
EnergyModelsBase.objective_operational
— Functionobjective_operational(m, 𝒳, 𝒯ᴵⁿᵛ::TS.AbstractStratPers, modeltype::EnergyModel)
Create JuMP expressions indexed over the investment periods 𝒯ᴵⁿᵛ
for different elements 𝒳. The expressions correspond to the operational expenses of the different elements. The expressions are not discounted and do not take the duration of the investment periods into account.
By default, objective expressions are included for:
𝒳 = 𝒩::Vector{<:Node}
. In the case of a vector of nodes, the function returns the sum of the variable and fixed OPEX for all nodes whose method of the functionhas_opex
returns true.𝒳 = 𝒩::Vector{<:Link}
. In the case of a vector of links, the function returns the sum of the variable and fixed OPEX for all links whose method of the functionhas_opex
returns true.𝒳 = 𝒩::Vector{<:Resource}
. In the case of a vector of resources, the function returns the costs associated to the emissions using the functionemission_price
.
It is also possible to provide a tuple 𝒳ᵛᵉᶜ
for only operational or only investment objective contributions. In this situation, the expression returns a value of 0 for all investment periods.
EnergyModelsBase.emissions_operational
— Functionemissions_operational(m, 𝒳, 𝒫ᵉᵐ, 𝒯, modeltype::EnergyModel)
Create JuMP expressions indexed over the operational periods 𝒯
for different elements 𝒳. The expressions correspond to the total emissions of a given element type.
By default, emissions expressions are included for:
𝒳 = 𝒩::Vector{<:Node}
. In the case of a vector of nodes, the function returns the sum of the emissions of all nodes whose method of the functionhas_emissions
returns true. These nodes should be automatically identified without user intervention.𝒳 = 𝒩::Vector{<:Link}
. In the case of a vector of links, the function returns the sum of the emissions of all links whose method of the functionhas_emissions
returns true.
Constraint functions
EnergyModelsBase.constraints_emissions
— Functionconstraints_emissions(m, 𝒳ᵛᵉᶜ, 𝒫, 𝒯, modeltype::EnergyModel)
Create constraints for the emissions accounting for both operational and strategic periods.
EnergyModelsBase.constraints_elements
— Functionconstraints_elements(m, 𝒳::Vector{<:AbstractElement}, 𝒳ᵛᵉᶜ, 𝒫, 𝒯, modeltype::EnergyModel)
Loop through all entries of the elements vector and call the subfunction create_element
for creating the internal constraints of the entries of the elements vector.
EnergyModelsBase.constraints_couple
— Functionconstraints_couple(m, 𝒩::Vector{<:Node}, ℒ::Vector{<:Link}, 𝒫, 𝒯, modeltype::EnergyModel)
constraints_couple(m, ℒ::Vector{<:Link}, 𝒩::Vector{<:Node}, 𝒫, 𝒯, modeltype::EnergyModel)
Create the couple constraints in EnergyModelsBase
.
Only couplings between two types are introducded in energy models base. A fallback solution is available for the coupling between AbstractElement
s while a method is implemented for the coupling between a Link
and a Node
.
EnergyModelsBase.constraints_level_iterate
— Functionconstraints_level_iterate(
m,
n::Storage,
prev_pers::PreviousPeriods,
cyclic_pers::CyclicPeriods,
per,
ts::RepresentativePeriods,
modeltype::EnergyModel,
)
Iterate through the individual time structures of a Storage
node. This iteration function should in general allow for all necessary functionality for incorporating modifications.
In the case of RepresentativePeriods
, this is achieved through calling the function constraints_level_rp
to introduce, e.g., cyclic constraints as it is in the default case.
constraints_level_iterate(
m,
n::Storage,
prev_pers::PreviousPeriods,
per,
ts::OperationalScenarios,
modeltype::EnergyModel,
)
In the case of OperationalScenarios
, this is achieved through calling the function constraints_level_scp
. In the default case, no constraints are added.
constraints_level_iterate(
m,
n::Storage,
prev_pers::PreviousPeriods,
per,
ts::SimpleTimes,
modeltype::EnergyModel,
)
In the case of SimpleTimes
, the iterator function is at its lowest level. In this situation,the previous level is calculated using the function previous_level
and used for the storage balance. The the approach for calculating the previous_level
is depending on the types in the parameteric type PreviousPeriods
.
In addition, additional bounds can be included on the initial level within an operational period.
EnergyModelsBase.constraints_level_rp
— Functionconstraints_level_rp(m, n::Storage, per, modeltype::EnergyModel)
Provides additional contraints for representative periods.
The default approach is to set the total change in all representative periods within a strategic period to 0. This implies that the Storage
node cannot accumulate energy between individual strategic periods.
constraints_level_rp(m, n::Storage{<:Accumulating}, per, modeltype::EnergyModel)
When a Storage{<:Accumulating}
is used, the cyclic constraint for restricting the level change within a strategic period to 0 (through setting the sum of :stor_level_Δ_rp
within a strategic period to 0) is not implemented as accumulation within a strategic period is desirable.
This implies that Accumulating
behaviours require the developer to introduce the function previous_level
in the case of prev_pers = PreviousPeriods{<:NothingPeriod, Nothing, Nothing}
.
constraints_level_rp(m, n::Storage{CyclicRepresentative}, per, modeltype::EnergyModel)
When a Storage{CyclicRepresentative}
is used, the change in the representative period is constrained to 0.
EnergyModelsBase.constraints_level_scp
— Functionconstraints_level_scp(m, n::Storage, per, modeltype::EnergyModel)
Provides additional constraints for scenario periods.
The default approach is to not provide any constraints.
constraints_level_scp(m, n::Storage{CyclicRepresentative}, per, modeltype::EnergyModel)
When a Storage{CyclicRepresentative} is used, the final level in an operational scenario is constrained to be the same in all operational scenarios.
EnergyModelsBase.constraints_level_bounds
— Functionconstraints_level_bounds(
m,
n::Storage,
t::TS.TimePeriod,
prev_pers::TS.TimePeriod,
modeltype::EnergyModel,
)
Provides bounds on the initial storage level in an operational period to account for the level being modelled at the end of the operational periods.
The default approach is to not provide bounds.
constraints_level_bounds(
m,
n::Storage,
t::TS.TimePeriod,
cyclic_pers::CyclicPeriods{<:TS.AbstractRepresentativePeriod},
modeltype::EnergyModel,
)
When representative periods are used and the previous operational period is nothing
, then bounds are incorporated to avoid that the initial level storage level is violating the maximum and minimum level.
Variable creation functions
EnergyModelsBase.variables_capacity
— Functionvariables_capacity(m, 𝒩::Vector{<:Node}, 𝒳ᵛᵉᶜ, 𝒯, modeltype::EnergyModel)
variables_capacity(m, ℒ::Vector{<:Link}, 𝒳ᵛᵉᶜ, 𝒯, modeltype::EnergyModel)
Declaration of different capacity variables for the element types introduced in EnergyModelsBase
. EnergyModelsBase
introduces two elements for an energy system, and hence, provides the user with two individual methods:
All nodes, excluding Storage
and Availability
nodes have the following capacity variables:
cap_use[n, t]
is the capacity utilization of noden
in operational periodt
.cap_inst[n, t]
is the installed capacity of noden
in operational periodt
.
Storage
nodes have multiple capacities. The storage level (the amount of mass/energy) stored is described through the followign variables
stor_level[n, t]
is the storage level of storagen
at the end of operational periodt
.stor_level_Δ_op[n, t]
is the storage level change of storagen
in operational periodt
.stor_level_Δ_rp[n, t_rp]
is the storage level change of storagen
in representative periodt_rp
. These variables are only created if the time structure includes representative periods.stor_level_Δ_sp[n, t_inv]
is storage level change of storagen
in investment periodt_inv
. These variables are optional and created throughSparseVariables
. This implies you have to create a method for the functionvariables_node
for your node type that should use these variables.stor_level_inst[n, t]
is the installed storage capacity for storagen
in operational periodt
, constrained in the operational case to the provided capacity in the storage parameters used in the field:level
.
The charge capacity variables are describing the charging of a Storage
:
stor_charge_use[n, t]
is the charging rate of storagen
in operational periodt
.stor_charge_inst[n, t]
is the installed charging capacity, e.g., power, of storagen
in operational periodt
, constrained in the operational case to the provided capacity in the storage parameters used in the field:charge
. This variable is only declared if theStorage
node has a fieldcharge
and the storage parameters include a capacity.
The discharge capacity variables are describing the discharging of a Storage
:
stor_discharge_use[n, t]
is the discharging rate of storagen
in operational periodt
.stor_discharge_inst[n, t]
is the installed discharging capacity, e.g., power, of storagen
in operational periodt
, constrained in the operational case to the provided capacity in the storage parameters used in the field:discharge
. This variable is only declared if theStorage
node has a fielddischarge
and the storage parameters include a capacity.
The capacity variables are only created for links, if the function has_capacity
has received an additional method for a given link l
returning the value true
.
link_cap_inst[l, t]
is the installed capacity of linkl
in operational periodt
.
EnergyModelsBase.variables_flow
— Functionvariables_flow(m, 𝒩::Vector{<:Node}, 𝒳ᵛᵉᶜ, 𝒯, modeltype::EnergyModel)
variables_flow(m, ℒ::Vector{<:Link}, 𝒳ᵛᵉᶜ, 𝒯, modeltype::EnergyModel)
Declaration of flow OPEX variables for the element types introduced in EnergyModelsBase
. EnergyModelsBase
introduces two elements for an energy system, and hence, provides the user with two individual methods:
flow_in[n, t, p]
is the flow into noden
in operational periodt
for resourcep
. The inflow resources of noden
are extracted using the functioninputs
.flow_out[n, t, p]
is the flow from noden
in operational periodt
for resourcep
. The outflow resources of noden
are extracted using the functionoutputs
.
link_in[l, t, p]
is the flow into linkl
in operational periodt
for resourcep
. The inflow resources of linkl
are extracted using the functioninputs
.link_out[l, t, p]
is the flow from linkl
in operational periodt
for resourcep
. The outflow resources of linkl
are extracted using the functionoutputs
.
By default, all nodes 𝒩
and links ℒ
only allow for unidirectional flow. You can specify bidirectional flow through providing a method to the function is_unidirectional
for new link/node types.
EnergyModelsBase.variables_opex
— Functionvariables_opex(m, 𝒩::Vector{<:Node}, 𝒳ᵛᵉᶜ, 𝒯, modeltype::EnergyModel)
variables_opex(m, ℒ::Vector{<:Link}, 𝒳ᵛᵉᶜ, 𝒯, modeltype::EnergyModel)
Declaration of different OPEX variables for the element types introduced in EnergyModelsBase
. EnergyModelsBase
introduces two elements for an energy system, and hence, provides the user with two individual methods:
The OPEX variables are only created for nodes, if the function has_opex(n::Node)
has received an additional method for a given nodes n
returning the value true
. By default, this corresponds to all nodes except for Availability
nodes.
opex_var[n, t_inv]
are the variable operating expenses of noden
in investment periodt_inv
. The values can be negative to account for revenue streamsopex_fixed[n, t_inv]
are the fixed operating expenses of noden
in investment periodt_inv
.
The OPEX variables are only created for links, if the function has_opex(l::Link)
has received an additional method for a given link l
returning the value true
.
link_opex_var[n, t_inv]
are the variable operating expenses of linkl
in investment periodt_inv
. The values can be negative to account for revenue streamslink_opex_fixed[n, t_inv]
are the fixed operating expenses of noden
in investment periodt_inv
.
EnergyModelsBase.variables_capex
— Methodvariables_capex(m, 𝒩::Vector{<:Node}, 𝒳ᵛᵉᶜ, 𝒯, modeltype::EnergyModel)
variables_capex(m, ℒ::Vector{<:Link}, 𝒳ᵛᵉᶜ, 𝒯, modeltype::EnergyModel)
Declaration of different capital expenditures variables for the element types introduced in EnergyModelsBase
. EnergyModelsBase
introduces two elements for an energy system, and hence, provides the user with two individual methods:
The default method is empty but it is required for multiple dispatch in investment models.
EnergyModelsBase.variables_emission
— Functionvariables_emission(m, ℒ::Vector{<:Node}, 𝒫, 𝒯, modeltype::EnergyModel)
variables_emission(m, ℒ::Vector{<:Link}, 𝒫, 𝒯, modeltype::EnergyModel)
variables_emission(m, 𝒯, 𝒫, modeltype::EnergyModel)
Declaration of emissions variables for the element types introduced in EnergyModelsBase
as well as global emission variables. EnergyModelsBase
introduces two elements for an energy system, and hence, provides the user with in total three individual methods, including the global variables:
emissions_node[n_em, t, p_em]
are the emissions of noden_em
with emissions in operational periodt
of emission resourcep_em
. The values can be negative to account for removal of emissions resources from the environment, through, e.g., direct air capture.
emissions_node[n_em, t, p_em]
are the emissions of linkl_em
with emissions in operational periodt
of emission resourcep_em
. The values can only be positive as links should not allow for removal.
emissions_total[t, p_em]
are the total emissions of in operational periodt
of emission resourcep_em
. The values can be negative to account for removal of emissions resources from the environment, through, e.g., direct air capture.emissions_strategic[t_inv, p_em]
are the total emissions of in operational periodt
of emission resourcep_em
. The values can be negative to account for removal of emissions resources from the environment, through, e.g., direct air capture. The variable has an upper bound introduced through the functionemission_limit
of theEnergyModel
.
The inclusion of node and link emissions require that the function has_emissions
returns true
for the given node or link. This is by default achieved for nodes through inclusion of EmissionData
in nodes while links require you to explicitly provide a method for your link type.
EnergyModelsBase.variables_elements
— Functionvariables_elements(m, 𝒳::Vector{<:AbstractElement}, 𝒳ᵛᵉᶜ, 𝒯, modeltype::EnergyModel)
Loop through all element subtypes and create variables specific to each subtype. It starts at the top level and subsequently move through the branches until it reaches a leave.
That is, for nodes, variables_element
will be called on a Node
before it is called on NetworkNode
-nodes.
The function subsequently calls the subroutine variables_element
for creating the variables only for a subset of the elements.
Check functions
EnergyModelsBase.check_data
— Functioncheck_data(case, modeltype::EnergyModel, check_timeprofiles::Bool)
Check if the case data is consistent. Use the @assert_or_log
macro when testing. Currently only checking node data.
EnergyModelsBase.check_case_data
— Functioncheck_case_data(case)
Checks the case
dictionary is in the correct format.
Checks
- The individual elements vector must be unique, that it is not possible to have two vector of nodes within the elements vector.
- Check that the coupling functions do return elements and not only an empty vector
EnergyModelsBase.check_model
— Functioncheck_model(case, modeltype::EnergyModel, check_timeprofiles::Bool)
Checks the modeltype
.
Checks
- All
ResourceEmit
s require a corresponding value in the fieldemission_limit
. - The
emission_limit
time profiles cannot have a finer granulation thanStrategicProfile
.
Conditional checks (if check_timeprofiles=true
)
- The profiles in
emission_limit
have to have the same length as the number of strategic periods. - The profiles in
emission_price
have to follow the time structure as outlined incheck_profile
.
EnergyModelsBase.check_elements
— Functioncheck_elements(log_by_element, _::Vector{<:AbstractElement}, 𝒳ᵛᵉᶜ, 𝒯, modeltype::EnergyModel, check_timeprofiles::Bool)
check_elements(log_by_element, 𝒩::Vector{<:Node}, 𝒳ᵛᵉᶜ, 𝒯, modeltype::EnergyModel, check_timeprofiles::Bool)
check_elements(log_by_element, ℒ::Vector{<:Link}}, 𝒳ᵛᵉᶜ, 𝒯, modeltype::EnergyModel, check_timeprofiles::Bool)
Checks the individual elements vector. It has implemented methods for both Vector{<:Node}
and Vector{<:Link}.
All nodes are checked through the functions
check_node
to identify problematic input,check_node_data
issues in the provided additional data, andcheck_time_structure
to identify time profiles at the highest level that are not equivalent to the provided timestructure.
All links are checked through the functions
check_link
to identify problematic input,check_link_data
to identify issues in the provided additional data, andcheck_time_structure
to identify time profiles at the highest level that are not equivalent to the provided timestructure.
In addition, all links are directly checked to have in the fields :from
and :to
nodes that are present in the Node vector as extracted through the function get_nodes
and that these nodes have input (:to
) or output (:from
).
EnergyModelsBase.check_node
— Functioncheck_node(n::Node, 𝒯, modeltype::EnergyModel, check_timeprofiles::Bool)
Check that the fields of a Node
corresponds to required structure.
The default approach calls the subroutine check_node_default
which provides the user with default checks for Source
, NetworkNode
, Availability
, Storage
, and Sink
nodes.
When developing a new node with new checks, it is important to create a new method for check_node
. You can then call within this function the default tests for the corresponding supertype through calling the function check_node_default
.
EnergyModelsBase.check_link
— Functioncheck_link(n::Link, 𝒯, modeltype::EnergyModel, check_timeprofiles::Bool)
Check that the fields of a Link
corresponds to required structure. The default functionality does not check anthing, aside from the checks performed in check_elements
.
When developing a new link with new checks, it is important to create a new method for check_link
.
EnergyModelsBase.check_node_default
— Functioncheck_node_default(n::Node, 𝒯, modeltype::EnergyModel, check_timeprofiles::Bool)
This method checks that a Node
node is valid. By default, that does not include any checks.
check_node_default(n::Availability, 𝒯, modeltype::EnergyModel, check_timeprofiles::Bool)
This method checks that an Availability
node is valid. By default, that does not include any checks.
check_node_default(n::Source, 𝒯, modeltype::EnergyModel, check_timeprofiles::Bool)
Subroutine that can be utilized in other packages for incorporating the standard tests for a Source
node.
Checks
- The field
cap
is required to be non-negative. - The values of the dictionary
output
are required to be non-negative. - The value of the field
fixed_opex
is required to be non-negative and accessible through aStrategicPeriod
as outlined in the functioncheck_fixed_opex(n, 𝒯ᴵⁿᵛ, check_timeprofiles)
.
check_node_default(n::NetworkNode, 𝒯, modeltype::EnergyModel, check_timeprofiles::Bool)
Subroutine that can be utilized in other packages for incorporating the standard tests for a NetworkNode
node.
Checks
- The field
cap
is required to be non-negative. - The values of the dictionary
input
are required to be non-negative. - The values of the dictionary
output
are required to be non-negative. - The value of the field
fixed_opex
is required to be non-negative and accessible through aStrategicPeriod
as outlined in the functioncheck_fixed_opex(n, 𝒯ᴵⁿᵛ, check_timeprofiles)
.
check_node_default(n::Storage, 𝒯, modeltype::EnergyModel, check_timeprofiles::Bool)
Subroutine that can be utilized in other packages for incorporating the standard tests for a Storage
node.
Checks
- The
TimeProfile
of the fieldcapacity
in the type in the fieldcharge
is required to be non-negative if the chosen composite type has the fieldcapacity
. - The
TimeProfile
of the fieldcapacity
in the type in the fieldlevel
is required to be non-negative`. - The
TimeProfile
of the fieldcapacity
in the type in the fielddischarge
is required to be non-negative if the chosen composite type has the fieldcapacity
. - The
TimeProfile
of the fieldfixed_opex
is required to be non-negative and accessible through aStrategicPeriod
as outlined in the functioncheck_fixed_opex(n, 𝒯ᴵⁿᵛ, check_timeprofiles)
for the chosen composite type. - The values of the dictionary
input
are required to be non-negative. - The values of the dictionary
output
are required to be non-negative.
check_node_default(n::Sink, 𝒯, modeltype::EnergyModel, check_timeprofiles::Bool)
Subroutine that can be utilized in other packages for incorporating the standard tests for a Sink
node.
Checks
- The field
cap
is required to be non-negative. - The values of the dictionary
input
are required to be non-negative. - The dictionary
penalty
is required to have the keys:deficit
and:surplus
. - The sum of the values
:deficit
and:surplus
in the dictionarypenalty
has to be non-negative to avoid an infeasible model.
EnergyModelsBase.check_node_data
— Methodcheck_node_data(n::Node, data::Data, 𝒯, modeltype::EnergyModel, check_timeprofiles::Bool)
check_node_data(n::Node, data::EmissionsData, 𝒯, modeltype::EnergyModel, check_timeprofiles::Bool)
Check that the included Data
types of a Node
correspond to required structure.
Checks EmissionsData
- Each node can only have a single
EmissionsData
. - Time profiles for process emissions, if present.
- The value of the field
co2_capture
is required to be in the range $[0, 1]$, ifCaptureData
is used.
EnergyModelsBase.check_link_data
— Methodcheck_link_data(l::Link, data::Data, 𝒯, modeltype::EnergyModel, check_timeprofiles::Bool)
Check that the included Data
types of a Link
correspond to required structure.
EnergyModelsBase.check_fixed_opex
— Functioncheck_fixed_opex(n, 𝒯ᴵⁿᵛ, check_timeprofiles::Bool)
Checks that the fixed opex value follows the given TimeStructure
. This check requires that a function opex_fixed(n)
is defined for the input n
which returns a TimeProfile
.
Checks
- The
opex_fixed
time profile cannot have a finer granulation thanStrategicProfile
.
Conditional checks (if check_timeprofiles=true
)
- The profiles in
opex_fixed
have to have the same length as the number of strategic periods.
EnergyModelsBase.check_time_structure
— Functioncheck_time_structure(x::AbstractElement, 𝒯)
Check that all fields of a AbstractElement
that are of type TimeProfile
correspond to the time structure 𝒯
.
EnergyModelsBase.check_profile
— Functioncheck_profile(fieldname, value::TimeProfile, 𝒯)
Check that an individual TimeProfile
corresponds to the time structure 𝒯
. It currently does not include support for identifying OperationalScenarios
.
check_profile(fieldname, value::TimeProfile, ts::TimeStructure, p_msg)
Check that an individual TimeProfile
corresponds to the time structure ts
in strategic period sp
. The function flow is designed to provide errors in all situations in which the the TimeProfile
does not correspond to the chosen TimeStructure
through the application of the @assert_or_log
macro.
Examples for inconsistent combinations:
ts = SimpleTimes(3, 1)
# A too long OperationalProfile resulting in omitting the last 2 values
value = OperationalProfile([1, 2, 3, 4, 5])
# A too short OperationalProfile resulting in repetition of the last value once
value = OperationalProfile([1, 2])
If you use a more detailed TimeProfile
than the TimeStructure
, it will provide you with a warning, e.g., using RepresentativeProfile
without RepresentativePeriods
.
EnergyModelsBase.check_strategic_profile
— Functioncheck_strategic_profile(time_profile::TimeProfile, message::String)
Function for checking that an individual TimeProfile
does not include the wrong type for strategic indexing.
Checks
TimeProfile
s accessed inStrategicPeriod
s cannot includeOperationalProfile
,ScenarioProfile
, orRepresentativeProfile
as this is not allowed through indexing on theTimeProfile
.
EnergyModelsBase.check_representative_profile
— Functioncheck_representative_profile(time_profile::TimeProfile, message::String)
Function for checking that an individual TimeProfile
does not include the wrong type for representative periods indexing.
Input
time_profile
- The time profile that should be checked.message
- A message that should be printed after the type of profile.
Checks
TimeProfile
s accessed inRepresentativePeriod
s cannot includeOperationalProfile
orScenarioProfile
as this is not allowed through indexing on theTimeProfile
.
EnergyModelsBase.check_scenario_profile
— Functioncheck_scenario_profile(time_profile::TimeProfile, message::String)
Function for checking that an individual TimeProfile
does not include the wrong type for scenario indexing.
Checks
TimeProfile
s accessed inRepresentativePeriod
s cannot includeOperationalProfile
orScenarioProfile
as this is not allowed through indexing on theTimeProfile
.
EnergyModelsBase.compile_logs
— Functioncompile_logs(case, log_by_element)
Simple method for showing all log messages.
Identification functions
EnergyModelsBase.is_network_node
— Functionis_network_node(n::Node)
Checks whether node n
is a NetworkNode
node.
EnergyModelsBase.is_sink
— Functionis_sink(n::Node)
Checks whether node n
is a Sink
node.
EnergyModelsBase.is_source
— Functionis_source(n::Node)
Checks whether node n
is a Source
node.
EnergyModelsBase.is_storage
— Functionis_storage(n::Node)
Checks whether node n
is a Storage
node.
EnergyModelsBase.is_resource_emit
— Functionis_resource_emit(p::Resource)
Checks whether the Resource p
is of type ResourceEmit
.
EnergyModelsBase.has_charge_OPEX_fixed
— Functionhas_charge_OPEX_fixed(n::Storage)
Returns logic whether the node has a charge
fixed OPEX contribution.
EnergyModelsBase.has_charge_OPEX_var
— Functionhas_charge_OPEX_var(n::Storage)
Returns logic whether the node has a charge
variable OPEX contribution.
EnergyModelsBase.has_charge_cap
— Functionhas_charge_cap(n::Storage)
Returns logic whether the node has a charge
capacity.
EnergyModelsBase.has_discharge_OPEX_fixed
— Functionhas_discharge_OPEX_fixed(n::Storage)
Returns logic whether the node has a discharge
fixed OPEX contribution.
EnergyModelsBase.has_discharge_OPEX_var
— Functionhas_discharge_OPEX_var(n::Storage)
Returns logic whether the node has a discharge
variable OPEX contribution.
EnergyModelsBase.has_discharge_cap
— Functionhas_discharge_cap(n::Storage)
Returns logic whether the node has a discharge
capacity.
EnergyModelsBase.has_level_OPEX_fixed
— Functionhas_level_OPEX_fixed(n::Storage)
Returns logic whether the node has a level
fixed OPEX contribution.
EnergyModelsBase.has_level_OPEX_var
— Functionhas_level_OPEX_var(n::Storage)
Returns logic whether the node has a level
variable OPEX contribution.
EnergyModelsBase.nodes_sub
— Functionnodes_sub(𝒩::Array{<:Node}, sub)
Returns nodes that are of type sub
for a given Array 𝒩::Array{<:Node}
.
EnergyModelsBase.link_res
— Functionlink_res(l::Link)
Return the resources transported for a given link l
.
The default approach is to use the intersection of the inputs of the to
node and the outputs of the from
node.
EnergyModelsBase.link_sub
— Functionlink_sub(ℒ::Vector{<:Link}, n::Node)
Return connected links from the vector ℒ
for a given node n
as array. The first subarray corresponds to the from
field, while the second to the to
field.
EnergyModelsBase.res_em
— Functionres_em(𝒫::Array{<:Resource})
res_em(𝒫::Dict)
Returns all emission resources for a
- a given array
::Array{<:Resource}
. The output is in this case anArray{<:Resource}
- a given dictionary
::Dict
. The output is in this case a dictionaryDict
with the correct fields
EnergyModelsBase.res_not
— Functionres_not(𝒩::Array{<:Resource}, res_inst)
res_not(𝒫::Dict, res_inst::Resource)
Return all resources that are not res_inst
for
- a given array
::Array{<:Resource}
. The output is in this case anArray{<:Resource}
- a given dictionary
::Dict
. The output is in this case a dictionaryDict
with the correct fields
EnergyModelsBase.res_sub
— Functionres_sub(𝒫::Array{<:Resource}, sub = ResourceEmit)
Return resources that are of type sub
for a given Array ::Array{Resource}
.
Miscellaneous functions
EnergyModelsBase.collect_types
— Functioncollect_types(types_list)
Return a Dict of all the give types_list and their supertypes. The keys in the dictionary are the types, and their corresponding value is the number in the type hierarchy.
As an example, Node
is at the top and will thus have the value 1. Types just below Node
will have value 2, and so on.
EnergyModelsBase.sort_types
— Functionsort_types(types_list::Dict)
Sort the result of collect_types
and return a vector where a supertype comes before all its subtypes.