Internal functions
Index
EnergyModelsBase.check_case_dataEnergyModelsBase.check_dataEnergyModelsBase.check_elementsEnergyModelsBase.check_fixed_opexEnergyModelsBase.check_linkEnergyModelsBase.check_link_dataEnergyModelsBase.check_modelEnergyModelsBase.check_nodeEnergyModelsBase.check_node_dataEnergyModelsBase.check_node_defaultEnergyModelsBase.check_profileEnergyModelsBase.check_representative_profileEnergyModelsBase.check_scenario_profileEnergyModelsBase.check_strategic_profileEnergyModelsBase.check_time_structureEnergyModelsBase.collect_typesEnergyModelsBase.compile_logsEnergyModelsBase.constraints_coupleEnergyModelsBase.constraints_elementsEnergyModelsBase.constraints_emissionsEnergyModelsBase.constraints_level_boundsEnergyModelsBase.constraints_level_iterateEnergyModelsBase.constraints_level_rpEnergyModelsBase.constraints_level_scpEnergyModelsBase.create_elementEnergyModelsBase.create_linkEnergyModelsBase.emissions_operationalEnergyModelsBase.has_charge_OPEX_fixedEnergyModelsBase.has_charge_OPEX_varEnergyModelsBase.has_charge_capEnergyModelsBase.has_discharge_OPEX_fixedEnergyModelsBase.has_discharge_OPEX_varEnergyModelsBase.has_discharge_capEnergyModelsBase.has_level_OPEX_fixedEnergyModelsBase.has_level_OPEX_varEnergyModelsBase.is_network_nodeEnergyModelsBase.is_resource_emitEnergyModelsBase.is_sinkEnergyModelsBase.is_sourceEnergyModelsBase.is_storageEnergyModelsBase.link_resEnergyModelsBase.link_subEnergyModelsBase.nodes_subEnergyModelsBase.objectiveEnergyModelsBase.objective_operationalEnergyModelsBase.res_emEnergyModelsBase.res_notEnergyModelsBase.res_subEnergyModelsBase.sort_typesEnergyModelsBase.variables_capacityEnergyModelsBase.variables_capexEnergyModelsBase.variables_elementEnergyModelsBase.variables_element_ext_dataEnergyModelsBase.variables_elementsEnergyModelsBase.variables_emissionEnergyModelsBase.variables_ext_dataEnergyModelsBase.variables_flowEnergyModelsBase.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.
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.variables_ext_data — Methodvariables_ext_data(m, _::Type{<:ExtensionData}, 𝒳::Vector{<:AbstractElement}, 𝒯, 𝒫, modeltype::EnergyModel)Default fallback method for the variables creation for a data type of a Vector{<:AbstractElement} 𝒳 if no other method is defined. The default method does not specify any variables.
The function is called for each individual subtype of AbstractElement. As a consequence, methods, and hence, variables for Nodes and Links must be specified specifically.
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_opexreturns 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_opexreturns true.𝒳 = 𝒩::Vector{<:Resource}. In the case of a vector of resources, the function returns the costs associated to the emissions using the functionemission_price.
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_emissionsreturns 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_emissionsreturns 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 AbstractElements 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{<:Cyclic}, per::TS.AbstractStrategicPeriod, modeltype::EnergyModel)When a Storage{<:Cyclic} is used in a time structure without RepresentativeProfile, the final level in an operational scenario is constrained to be the same in all operational scenarios for the cyclic constraints.
constraints_level_scp(m, n::Storage{CyclicRepresentative}, per::TS.AbstractRepresentativePeriod, 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.
This function is required in addition to enforce the CyclicRepresentative constraint.
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 nodenin operational periodt.cap_inst[n, t]is the installed capacity of nodenin 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 storagenat the end of operational periodt.stor_level_Δ_op[n, t]is the storage level change of storagenin operational periodt.stor_level_Δ_rp[n, t_rp]is the storage level change of storagenin 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 storagenin investment periodt_inv. These variables are optional and created throughSparseVariables. This implies you have to create a method for the functionvariables_nodefor your node type that should use these variables.stor_level_inst[n, t]is the installed storage capacity for storagenin 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 storagenin operational periodt.stor_charge_inst[n, t]is the installed charging capacity, e.g., power, of storagenin 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 theStoragenode has a fieldchargeand 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 storagenin operational periodt.stor_discharge_inst[n, t]is the installed discharging capacity, e.g., power, of storagenin 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 theStoragenode has a fielddischargeand 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 linklin 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 nodenin operational periodtfor resourcep. The inflow resources of nodenare extracted using the functioninputs.flow_out[n, t, p]is the flow from nodenin operational periodtfor resourcep. The outflow resources of nodenare extracted using the functionoutputs.
link_in[l, t, p]is the flow into linklin operational periodtfor resourcep. The inflow resources of linklare extracted using the functioninputs.link_out[l, t, p]is the flow from linklin operational periodtfor resourcep. The outflow resources of linklare 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 nodenin investment periodt_inv. The values can be negative to account for revenue streamsopex_fixed[n, t_inv]are the fixed operating expenses of nodenin 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 linklin investment periodt_inv. The values can be negative to account for revenue streamslink_opex_fixed[n, t_inv]are the fixed operating expenses of nodenin investment periodt_inv.
EnergyModelsBase.variables_capex — Functionvariables_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_emwith emissions in operational periodtof 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_emwith emissions in operational periodtof 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 periodtof 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 periodtof 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_limitof 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.
EnergyModelsBase.variables_element_ext_data — Functionvariables_element_ext_data(m, 𝒳::Vector{<:AbstractElement}, 𝒳ᵛᵉᶜ, 𝒯, 𝒫,modeltype::EnergyModel)Loop through all data 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.
The function subsequently calls the subroutine variables_ext_data for creating the variables for the nodes that have the corresponding data types.
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
ResourceEmits require a corresponding value in the fieldemission_limit. - The
emission_limittime profiles cannot have a finer granulation thanStrategicProfile.
Conditional checks (if check_timeprofiles=true)
- The profiles in
emission_limithave to have the same length as the number of strategic periods. - The profiles in
emission_pricehave 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_nodeto identify problematic input,check_node_dataissues in the provided additional data, andcheck_time_structureto identify time profiles at the highest level that are not equivalent to the provided timestructure.
All links are checked through the functions
check_linkto identify problematic input,check_link_datato identify issues in the provided additional data, andcheck_time_structureto 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.
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
capis required to be non-negative. - The values of the dictionary
outputare required to be non-negative. - The value of the field
fixed_opexis required to be non-negative and accessible through aStrategicPeriodas 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
capis required to be non-negative. - The values of the dictionary
inputare required to be non-negative. - The values of the dictionary
outputare required to be non-negative. - The value of the field
fixed_opexis required to be non-negative and accessible through aStrategicPeriodas 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
TimeProfileof the fieldcapacityin the type in the fieldchargeis required to be non-negative if the chosen composite type has the fieldcapacity. - The
TimeProfileof the fieldcapacityin the type in the fieldlevelis required to be non-negative`. - The
TimeProfileof the fieldcapacityin the type in the fielddischargeis required to be non-negative if the chosen composite type has the fieldcapacity. - The
TimeProfileof the fieldfixed_opexis required to be non-negative and accessible through aStrategicPeriodas outlined in the functioncheck_fixed_opex(n, 𝒯ᴵⁿᵛ, check_timeprofiles)for the chosen composite type. - The values of the dictionary
inputare required to be non-negative. - The specified storage
Resourcemust be included in the dictionaryinput. - The values of the dictionary
outputare required to be non-negative. - The specified storage
Resourcemust be included in the dictionaryoutput.
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
capis required to be non-negative. - The values of the dictionary
inputare required to be non-negative. - The dictionary
penaltyis required to have the keys:deficitand:surplus. - The sum of the values
:deficitand:surplusin the dictionarypenaltyhas to be non-negative to avoid an infeasible model.
EnergyModelsBase.check_node_data — Methodcheck_node_data(n::Node, data::ExtensionData, 𝒯, modeltype::EnergyModel, check_timeprofiles::Bool)
check_node_data(n::Node, data::EmissionsData, 𝒯, modeltype::EnergyModel, check_timeprofiles::Bool)Check that the included ExtensionData 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_captureis required to be in the range $[0, 1]$, ifCaptureDatais used.
EnergyModelsBase.check_link_data — Methodcheck_link_data(l::Link, data::ExtensionData, 𝒯, modeltype::EnergyModel, check_timeprofiles::Bool)Check that the included ExtensionData 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_fixedtime profile cannot have a finer granulation thanStrategicProfile.
Conditional checks (if check_timeprofiles=true)
- The profiles in
opex_fixedhave 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
TimeProfiles accessed inStrategicPeriods cannot includeOperationalProfile,ScenarioProfile, orRepresentativeProfileas 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
TimeProfiles accessed inRepresentativePeriods cannot includeOperationalProfileorScenarioProfileas 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
TimeProfiles accessed inRepresentativePeriods cannot includeOperationalProfileorScenarioProfileas 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 dictionaryDictwith 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 dictionaryDictwith 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.