Methods - EnergyModelsBase
Index
EnergyModelsBase.capacityEnergyModelsBase.check_elementsEnergyModelsBase.check_time_structureEnergyModelsBase.constraints_coupleEnergyModelsBase.constraints_couple_resourceEnergyModelsBase.constraints_elementsEnergyModelsBase.constraints_ext_dataEnergyModelsBase.constraints_resourceEnergyModelsBase.create_nodeEnergyModelsBase.emissions_operationalEnergyModelsBase.has_emissionsEnergyModelsBase.has_opexEnergyModelsBase.inputsEnergyModelsBase.objective_operationalEnergyModelsBase.opex_fixedEnergyModelsBase.opex_varEnergyModelsBase.outputsEnergyModelsBase.variables_capacityEnergyModelsBase.variables_capexEnergyModelsBase.variables_elementEnergyModelsBase.variables_element_ext_dataEnergyModelsBase.variables_elementsEnergyModelsBase.variables_emissionEnergyModelsBase.variables_ext_dataEnergyModelsBase.variables_flowEnergyModelsBase.variables_flow_resourceEnergyModelsBase.variables_opex
Extension methods
EnergyModelsBase.create_node — Function
EMB.create_node(m, n::GeoAvailability, 𝒯, 𝒫, modeltype::EnergyModel)Set all constraints for a GeoAvailability. The energy balance is handled in the function constraints_couple.
EnergyModelsBase.objective_operational — Function
EMB.objective_operational(m, ℒᵗʳᵃⁿˢ::Vector{Transmission}, 𝒯ᴵⁿᵛ::TS.AbstractStratPers, modeltype::EnergyModel)
EMB.objective_operational(m, 𝒜::Vector{<:Area}, 𝒯ᴵⁿᵛ::TS.AbstractStratPers, modeltype::EnergyModel)Create JuMP expressions indexed over the investment periods 𝒯ᴵⁿᵛ for different elements. The expressions correspond to the operating 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{Transmission}. In the case of a vector of transmission corridors, the method returns the sum of the variable and fixed OPEX for all modes whose method of the functionhas_opexreturns true.𝒳 = 𝒜::Vector{<:Area}. In the case of a vector of areas, the method returns a value of 0 for all investment periods.
EnergyModelsBase.emissions_operational — Function
EMB.emissions_operational(m, ℒᵗʳᵃⁿˢ::Vector{Transmission}, 𝒫ᵉᵐ, 𝒯, modeltype::EnergyModel)
EMB.emissions_operational(m, 𝒜::Vector{<:Area}, 𝒫ᵉᵐ, 𝒯, modeltype::EnergyModel)Create JuMP expressions indexed over the operational periods 𝒯 for different elements. The expressions correspond to the total emissions of a given type.
By default, emissions expressions are included for:
𝒳 = ℒᵗʳᵃⁿˢ::Vector{Transmission}. In the case of a vector of transmission corridors, the function returns the sum of the emissions of all modes whose method of the functionhas_emissionsreturns true.𝒳 = 𝒜::Vector{<:Area}. In the case of a vector of areas, the method returns a value of 0 for all operational periods and emission resources.
EnergyModelsBase.constraints_elements — Function
EMB.constraints_elements(m, 𝒜::Vector{<:Area}, 𝒳ᵛᵉᶜ, 𝒫, 𝒯, modeltype::EnergyModel)
EMB.constraints_elements(m, ℒᵗʳᵃⁿˢ::Vector{Transmission}, 𝒳ᵛᵉᶜ, 𝒫, 𝒯, modeltype::EnergyModel)Loop through all entries of the elements vector and call a subfunction for creating the internal constraints of the entries of the elements vector.
EnergyModelsGeography provides the user with two element types, Area and Transmission:
Area- the subfunction iscreate_area.Transmission- the subfunction iscreate_transmission_modeand called for allTransmissionModes withinℒᵗʳᵃⁿˢ.
EnergyModelsBase.constraints_resource — Function
EMB.constraints_resource(m, a::Area, 𝒯, 𝒫::Vector{<:Resource}, modeltype::EnergyModel)
EMB.constraints_resource(m, tm::TransmissionMode, 𝒯, 𝒫::Vector{<:Resource}, modeltype::EnergyModel)Create constraints for the flow of resources through an AbstractElement for specific resource types. In EnergyModelsGeography, this method is provided for Area and TransmissionMode.
The function is empty by default and can be implemented in extension packages.
While we allow the method to be also used for Areas, we strongly advise against introducing new constraints for an Area as it would require more steps to introduce new variables. It is instead easier to access the relevant Availability node in the function EMB.constraints_couple.
This approach allows you to couple the local energy system with the transmission modes.
EnergyModelsBase.constraints_couple — Function
EMB.constraints_couple(m, 𝒜::Vector{<:Area}, ℒᵗʳᵃⁿˢ::Vector{Transmission}, 𝒫, 𝒯, modeltype::EnergyModel)
EMB.constraints_couple(m, ℒᵗʳᵃⁿˢ::Vector{Transmission}, 𝒜::Vector{<:Area}, 𝒫, 𝒯, modeltype::EnergyModel)Create the new couple constraints in EnergyModelsGeography.
The couple constraints are utilizing the variables :flow_in and :flow_out in combination with :area_exchange for solving the energy balance on an Area level for the respective GeoAvailability node.
The coupling is achieved through the variable :area_exchange which is calculated through the functions compute_trans_in and compute_trans_out.
As a consequence, each Area can be coupled with multiple Transmission corridors but each Transmission corridor can only be coupled to two Areas.
EnergyModelsBase.constraints_couple_resource — Function
EMB.constraints_couple_resource(m, 𝒜::Vector{<:Area}, ℒᵗʳᵃⁿˢ::Vector{<:Transmission}, 𝒫::Vector{<:Resource}, 𝒯, modeltype::EnergyModel)Create resource-specific coupling constraints.
The method is called from EMB.constraints_couple for each resource-type segment generated by EMB.res_types_vec(𝒫).
The default method is empty and intended to be implemented in extension packages.
EnergyModelsBase.constraints_ext_data — Method
EMB.constraints_ext_data(m, tm::TransmissionMode, 𝒯, modeltype::EnergyModel, data::ExtensionData)Fallback option when data is specified for a TransmissionMode, but it is not desired to add constraints through this function. This is, e.g., the case for EnergyModelsInvestments as the capacity constraint has to be replaced.
Variable methods
EnergyModelsBase.variables_capacity — Function
EMB.variables_capacity(m, ℒᵗʳᵃⁿˢ::Vector{Transmission}, 𝒳ᵛᵉᶜ, 𝒯, modeltype::EnergyModel)
EMB.variables_capacity(m, 𝒜::Vector{<:Area}, 𝒳ᵛᵉᶜ, 𝒯, modeltype::EnergyModel)Declaration of different capacity variables for the element types introduced in EnergyModelsGeography. Due to the design of the package, the individual TransmissionModes must be extracted in each function.
The capacity variables are only created for TransmissionModes and not Transmission corridors. The created variable is
trans_cap[tm, t]is the installed capacity of transmission modetmin operational periodt.
EnergyModelsBase.variables_flow — Function
EMB.variables_flow(m, ℒᵗʳᵃⁿˢ::Vector{Transmission}, 𝒳ᵛᵉᶜ, 𝒫, 𝒯, modeltype::EnergyModel)
EMB.variables_flow(m, 𝒜::Vector{<:Area}, 𝒳ᵛᵉᶜ, 𝒫, 𝒯, modeltype::EnergyModel)Declaration of flow variables for the element types introduced in EnergyModelsGeography. EnergyModelsGeography introduces two elements for an energy system, and hence, provides the user with two individual methods:
The flow variables are only created for TransmissionModes and not Transmission corridors. The created variables are
trans_in[tm, t]is the flow into modetmin operational periodt. The inflow resources of transmission modetmare extracted using the functioninputs.trans_out[tm, t]is the flow from modetmin operational periodt. The outflow resources of transmission modetmare extracted using the functionoutputs.- call of the function
EMB.variables_flow_resourcefor introducing resource specific flow variables.
area_exchange[a, t, p]is the exchange of resourcepby areaain operational periodt. The exchange resources are extracted using the functionexchange_resources.- call of the function
EMB.variables_flow_resourcefor introducing resource specific flow variables.
EnergyModelsBase.variables_flow_resource — Function
EMB.variables_flow_resource(m, ℳ::Vector{<:TransmissionMode}, 𝒫::Vector{<:Resource}, 𝒯, modeltype::EnergyModel)
EMB.variables_flow_resource(m, 𝒜::Vector{<:Area}, 𝒫::Vector{<:Resource}, 𝒯, modeltype::EnergyModel)Declaration of flow variables for the different resource-type segments.
The methods are called from EMB.variables_flow after segmenting 𝒫 through EMB.res_types_vec(𝒫).
The default methods are empty and intended to be implemented in extension packages that add resource-specific variables.
EnergyModelsBase.variables_opex — Function
EMB.variables_opex(m, ℒᵗʳᵃⁿˢ::Vector{Transmission}, 𝒳ᵛᵉᶜ, 𝒯, modeltype::EnergyModel)
EMB.variables_opex(m, 𝒜::Vector{<:Area}, 𝒳ᵛᵉᶜ, 𝒯, modeltype::EnergyModel)Declaration of different OPEX variables for the element types introduced in EnergyModelsGeography. Although EnergyModelsGeography introduces two elements, only ℒᵗʳᵃⁿˢ::Vector{Transmission} requires operational expense variables.
The operating expenses variables are only created for TransmissionModes and not Transmission corridors. The OPEX variables are furthermore only created for transmission modes, if the function has_opex(tm::TransmissionMode) has received an additional method for a given mode tm returning the value true. By default, this corresponds to all modes.
trans_opex_var[tm, t_inv]are the variable operating expenses of transmission modetmin investment periodt_inv. The values can be negative to account for revenue streams.trans_opex_fixed[tm, t_inv]are the fixed operating expenses of transmission modetmin investment periodt_inv.
EnergyModelsBase.variables_capex — Method
EMB.variables_capex(m, ℒᵗʳᵃⁿˢ::Vector{Transmission}, 𝒳ᵛᵉᶜ, 𝒯, modeltype::EnergyModel)
EMB.variables_capex(m, 𝒜::Vector{<:Area}, 𝒳ᵛᵉᶜ, 𝒯, modeltype::EnergyModel)Declaration of different capital expenditures variables for the element types introduced in EnergyModelsGeography. EnergyModelsGeography introduces two elements for an energy system, and hence, provides the user with two individual methods.
EnergyModelsBase.variables_elements — Function
EMB.variables_elements(m, ℒᵗʳᵃⁿˢ::Vector{Transmission}, 𝒳ᵛᵉᶜ, 𝒯, modeltype::EnergyModel)Loop through all TransmissionMode types present in ℒᵗʳᵃⁿˢ::Vector{Transmission} and create variables specific to each type. This is done by calling the method variables_trans_mode on all modes of each type.
The TransmissionMode type representing the widest category will be called first. That is, variables_trans_mode will be called on a TransmissionMode before it is called on PipeMode.
EnergyModelsBase.variables_element — Function
EMB.variables_element(m, 𝒜ˢᵘᵇ::Vector{<:Area}, 𝒯, modeltype::EnergyModel)Default fallback method for a vector of elements if no other method is defined for a given vector type.
EnergyModelsBase.variables_element_ext_data — Function
EMB.variables_element_ext_data(m, ℒᵗʳᵃⁿˢ::Vector{Transmission}, 𝒳ᵛᵉᶜ, 𝒯, 𝒫, modeltype::EnergyModel)Loop through all data subtypes and create variables specific to each subtype. It starts at the top level and subsequently moves through the branches until it reaches a leaf.
The function subsequently calls the subroutine variables_ext_data for creating the variables for the transmission modes that have the corresponding data types.
EnergyModelsBase.variables_ext_data — Method
EMB.variables_ext_data(m, _::Type{<:ExtensionData}, ℳ::Vector{<:TransmissionMode}, 𝒯, 𝒫, modeltype::EnergyModel)Default fallback method for the variables creation for a data type of a Vector{<:TransmissionMode} ℳ if no other method is defined. The default method does not specify any variables.
EnergyModelsBase.variables_emission — Function
EMB.variables_emission(m, ℒᵗʳᵃⁿˢ::Vector{Transmission}, 𝒳ᵛᵉᶜ, 𝒫, 𝒯, modeltype::EnergyModel)
EMB.variables_emission(m, 𝒜::Vector{<:Area}, 𝒳ᵛᵉᶜ, 𝒫, 𝒯, modeltype::EnergyModel)Declaration of emission variables for the element types introduced in EnergyModelsGeography. Although EnergyModelsGeography introduces two elements, only ℒᵗʳᵃⁿˢ::Vector{Transmission} requires an emission variable.
Declaration of variables for the modeling of transmission emissions. These variables are only created for transmission modes where emissions are included. All emission resources that are not included for a type are fixed to a value of 0.
emissions_trans[tm, t, p_em]emissions ofResourceEmitof transmission modetmin operational periodt. The variable is fixed to 0 forResourceEmitthat are not within the vector returned by the functionemit_resources.
Field extraction methods
EnergyModelsBase.capacity — Function
EMB.capacity(tm::TransmissionMode)
EMB.capacity(tm::TransmissionMode, t)Returns the capacity of transmission mode tm as TimeProfile or in operational period t.
EnergyModelsBase.inputs — Function
EMB.inputs(tm::TransmissionMode)
EMB.inputs(tm::PipeMode)Returns the input resources of transmission mode tm.
EnergyModelsBase.outputs — Function
EMB.outputs(tm::TransmissionMode)
EMB.outputs(tm::PipeMode)Returns the output resources of transmission mode tm.
EnergyModelsBase.opex_fixed — Function
EMB.opex_fixed(tm::TransmissionMode)
EMB.opex_fixed(tm::TransmissionMode, t_inv)Returns the fixed OPEX of transmission mode tm as TimeProfile or in strategic period t_inv.
EnergyModelsBase.opex_var — Function
EMB.opex_var(tm::TransmissionMode)
EMB.opex_var(tm::TransmissionMode, t)Returns the variable OPEX of transmission mode tm as TimeProfile or in operational period t.
Identification methods
EnergyModelsBase.has_opex — Function
EMB.has_opex(tm::TransmissionMode)Checks whether transmission mode tm has operating expenses.
By default, all transmission modes have operating expenses.
EnergyModelsBase.has_emissions — Function
EMB.has_emissions(tm::TransmissionMode)Returns whether there are emissions associated with transmission mode tm. The default behaviour is no emissions.
Check methods
EnergyModelsBase.check_elements — Function
EMB.check_elements(log_by_element, 𝒜::Vector{<:Area}, 𝒳ᵛᵉᶜ, 𝒯, modeltype::EnergyModel, check_timeprofiles::Bool)
EMB.check_elements(log_by_element, ℒᵗʳᵃⁿˢ::Vector{<:Transmission}, 𝒳ᵛᵉᶜ, 𝒯, modeltype::EnergyModel, check_timeprofiles::Bool)All areas are checked through the functions
check_areato identify problematic input,check_time_structureto identify time profiles at the highest level that are not equivalent to the provided timestructure.
In addition, all areas are directly checked
- that the node returned by the function
availability_nodeis within the Node vector, - that the availability node is a
GeoAvailabilitynode, and - that the exchange resources are within the resources of the
GeoAvailabilitynode.
All transmission corridors are checked through the functions
check_transmissionto identify problematic input,check_time_structureto identify time profiles at the highest level that are not equivalent to the provided timestructure.
The individual transmission modes of a corridor are checked through the functions
check_modeto identify problematic input andcheck_time_structureto identify time profiles at the highest level that are not equivalent to the provided timestructure.
In addition, all transmission corridors are directly checked that the areas in the fields :from and :to are present in the Area vector as extracted through the function get_areas.
EnergyModelsBase.check_time_structure — Function
EMB.check_time_structure(tm::TransmissionMode, 𝒯)Check that all fields of a TransmissionMode that are of type TimeProfile correspond to the time structure 𝒯.