Methods - Internal

Index

Constraint methods

EnergyModelsHydrogen.constraints_usageFunction
constraints_usage(m, n::AbstractElectrolyzer, 𝒯ᴵⁿᵛ, modeltype::EnergyModel)

Function for creating the usage constraints for an AbstractElectrolyzer. These constraints calculate the usage of the electrolyzer up to each time step for both the lifetime and the degradation calculations.

source
EnergyModelsHydrogen.constraints_usage_spFunction
constraints_usage_sp(
    m,
    n::AbstractElectrolyzer,
    prev_pers::PreviousPeriods,
    t_inv::TS.AbstractStrategicPeriod,
    modeltype::EnergyModel,
)

Function for creating the constraints on the previous usage of an AbstractElectrolyzer before the beginning of a strategic period.

In the case of the first strategic period, it fixes the variable elect_prev_use_sp to 0. In all subsequent strategic periods, the previous usage is calculated.

source
EnergyModelsHydrogen.constraints_usage_iterateFunction
constraints_usage_iterate(
    m,
    n::AbstractElectrolyzer,
    prev_pers::PreviousPeriods,
    elec_pers::ElecPeriods,
    per,
    ts::RepresentativePeriods,
    modeltype::EnergyModel,
)

Iterate through the individual time structures of a AbstractElectrolyzer node.

In the case of RepresentativePeriods, additional constraints are calculated for the usage of the electrolyzer in representative periods through introducing the variable elect_use_rp[𝒩ᴱᴸ, 𝒯ʳᵖ].

source

In the case of OperationalScenarios, we purely iterate through the individual time structures.

source

In the case of SimpleTimes, the iterator function is at its lowest level. In this situation,the previous level is calculated using the function constraints_previous_usage. The approach for calculating the constraints is depending on the types in the parameteric type PreviousPeriods.

source
EnergyModelsHydrogen.constraints_previous_usageFunction
constraints_previous_usage(
    m,
    n::AbstractElectrolyzer,
    prev_pers::PreviousPeriods,
    elec_pers::ElecPeriods,
    t::OperationalPeriod,
    modeltype::EnergyModel,
)

Returns the previous usage of an AbstractElectrolyzer node depending on the type of PreviousPeriods.

The basic functionality is used in the case when the previous operational period is a TimePeriod, in which case it just returns the previous operational period.

source

When the previous operational, representative, and strategic periods are Nothing, the

variable elect_prev_use is fixed to a value of 0.

source

When the previous operational and representative periods are Nothing while the previous strategic period is given, then previous usage is given through the sum of the usage in all previous strategic periods after the stack replacement through the variable prev_usage.

source

When the previous operational period is Nothing and the previous representative period an AbstractRepresentativePeriod then the time structure does include RepresentativePeriods.

The constraint then sums up the values from the previous representative period.

source
EnergyModelsHydrogen.constraints_rate_of_change_iterateFunction
constraints_rate_of_change_iterate(
    m,
    n::Reformer,
    per,
    t_last,
    ts,
    modeltype::EnergyModel,
)

Function for iterating through the time structure for calculating the correct rate of change constraints of the Reformer n.

When the time structure includes RepresentativePeriods, period t_last is updated with last operational period within each representative period.

source

When the time structure includes OperationalScenarios, period t_last is updated with last operational period within each operational scenario.

source
EnergyModelsHydrogen.constraints_rate_of_changeFunction
constraints_rate_of_change(
    m,
    n::Reformer,
    ramp_lim::UnionRampUp,
    ref_pers::RefPeriods,
    prod_on,
    modeltype::EnergyModel,
)

Function for creating the constraints on the maximum postivite rate of change. This constraint is only active if the Reformer is online in both the current and the previous operational periods, that is:

m[:ref_on_b][n, t_prev] = m[:ref_on_b][n, t] = 1

The function prev_op is used to incorporate the cyclic constraints while the function ramp_disjunct is used to extract the disjuntion contribution to the constraint depending on the modeltype.

source
EnergyModelsHydrogen.constraints_state_seq_iterFunction
constraints_state_seq_iter(
    m,
    n::Reformer,
    per,
    t_last,
    ts,
    modeltype::EnergyModel
)

Function for iterating through the time structure for calculating the correct cyclic constraints for the sequencing of the states of the Reformer n.

The function automatically deduces the provided time structure and calls the calls the corresponding functions iteratively. It eventually calls the function constraints_state_seq for imposing the sequencing constraints on the different states.

When the time structure includes RepresentativePeriods, period t_last is updated with last operational period within each representative period.

source

When the time structure includes OperationalScenarios, period t_last is updated with last operational period within each operational scenario.

source
EnergyModelsHydrogen.constraints_state_seqFunction
constraints_state_seq(
    m,
    n::Reformer,
    ref_pers::RefPeriods,
    state_a::Symbol,
    state_b::Symbol,
    modeltype::EnergyModel,
)

Function for creating the constraints on the sequencing of the individual states when state_b has to occur after state_a. Both state_a and state_b refer in this case to binary variables included in the JuMP model.

The function prev_op is used to incorporate the cyclic constraints.

source
EnergyModelsHydrogen.constraints_state_time_iterFunction
constraints_state_time_iter(
    m,
    n::Reformer,
    per,
    t_last,
    ts,
    modeltype::EnergyModel
)

Function for iterating through the time structure for calculating the correct requirement for the length of the individual states.

When the time structure includes RepresentativePeriods, period t_last is updated with last operational period within each representative period.

source

When the time structure includes OperationalScenarios, period t_last is updated with last operational period within each operational scenario.

source

Check methods

EnergyModelsHydrogen.check_load_limFunction
check_load_lim(n, 𝒯)

Checks the limits for the capacity load.

Checks

  • The field min_load is required to be non-negative.
  • The field max_load is required to be larger than the field min_load.
source
EnergyModelsHydrogen.check_commitment_profileFunction
check_commitment_profile(
    time_profile::TimeProfile,
    𝒯::TwoLevel,
    field_name::String,
    check_timeprofiles::Bool
)

Checks that the unit commitment time_profile for the field field_name follows the given TimeStructure 𝒯.

Checks

Conditional checks (if check_timeprofiles=true)

  • The time_profiles have to have the same length as the number of strategic or representative periods.
source

Utility methods

EnergyModelsHydrogen.capacity_maxFunction
capacity_max(n::AbstractElectrolyzer, t_inv, modeltype::EnergyModel)

Function for calculating the maximum capacity.

modeltype::EnergyModel

When the modeltype is an EnergyModel, it returns the capacity of the AbstractElectrolyzer.

modeltype::AbstractInvestmentModel

When the modeltype is an AbstractInvestmentModel, it returns the maximum installed capacity.

Note

If the AbstractElectrolyzer node does not have investments, it reuses the default function.

source
EnergyModelsHydrogen.linear_reformulationFunction
linear_reformulation(
    m,
    𝒯,
    var_binary,
    var_continuous,
    lb::TimeProfile,
    ub::TimeProfile,
)

Linear reformulation of the element-wise multiplication of the binary variable var_binary[𝒯] and the continuous variable var_continuous[𝒯] ∈ [ub, lb].

It returns the product var_aux[𝒯] with

$var\_aux[t] = var\_binary[t] \times var\_continuous[t]$.

Note

The bounds lb and ub must have the ability to access their fields using the iterator of 𝒯, that is if 𝒯 corresponds to the strategic periods, it is not possible to provide an OperationalProfile or RepresentativeProfile.

source
linear_reformulation(
    m,
    𝒯ᵃ::T,
    𝒯ᵇ::T,
    var_binary,
    var_continuous,
    lb::TimeProfile,
    ub::TimeProfile,
) where {T}

Linear reformulation of the multiplication of the binary variable var_binary[𝒯ᵃ, 𝒯ᵇ] and the continuous variable var_continuous[𝒯ᵇ] ∈ [ub, lb].

It returns the product var_aux[𝒯ᵃ, 𝒯ᵇ] with

$var\_aux[t_a, t_b] = var\_binary[t_a, t_b] \times var\_continuous[t_b]$.

Note

𝒯ᵃ and 𝒯ᵇ must be of the same type, that is either, e.g. a TwoLevel, AbstractStratPers, StratReprPeriods, or comparable. This is enforced through the parametric type T.

The bounds lb and ub must have the ability to access their fields using the iterator of 𝒯ᵃ, that is if 𝒯ᵃ corresponds to the strategic periods, it is not possible to provide an OperationalProfile or RepresentativeProfile.

source
EnergyModelsHydrogen.multiplication_variablesFunction
multiplication_variables(
    m,
    n::AbstractHydrogenNetworkNode,
    𝒯,
    var_b,
    modeltype::EnergyModel
)

Function for calculating the muliplication of the capacity of an AbstractHydrogenNetworkNode and a binary variable.

modeltype::EnergyModel

Multiplication of the installed capacity (expressed through capacity(n, t)) and a binary variable var_b in a period t (e.g., elect_on_b[n, t]).

Note

The time structure 𝒯 can be either a TwoLevel or StrategicPeriods. It is however necessary, that the variable var_b is indexed over the iterators of 𝒯.

Returns

  • prod[t]: Multiplication of capacity(n, t) and var_b[n, t].
modeltype::AbstractInvestmentModel

When the modeltype is an AbstractInvestmentModel, then the function applies a linear reformulation of the binary-continuous multiplication based on the McCormick relaxation and the function linear_reformulation.

Note

If the AbstractHydrogenNetworkNode node does not have investments, it reuses the default function to avoid increasing the number of variables in the model.

Returns

  • prod[t]: Multiplication of cap_inst[n, t] and var_b[t] or alternatively cap_current[n, t] and var_b[t], if the TimeStructure is a StrategicPeriods and the node n has investments.
source
EnergyModelsHydrogen.fix_elect_on_bFunction
fix_elect_on_b(m, n::AbstractElectrolyzer, 𝒯, 𝒫, modeltype::EnergyModel)

Fixes the variable :elect_on_b in operational periods without capacity and the variable :elect_stack_replace_b in strategic periods without capacity to 0 to simplify the optimziation problem.

Provides start values to the variables in all other periods as well as start values for the variable :elect_usage_mult_sp_b

modeltype::EnergyModel

The function utilizes the the value of the field cap of the node.

modeltype::AbstractInvestmentModel

When the node has investment data, the function utilizes the the value of the field EMI.max_add of the AbstractInvData. Otherwise, it uses as well the field cap of the node.

source
EnergyModelsHydrogen.ramp_disjunctFunction
ramp_disjunct(m, n::Reformer, ref_pers::RefPeriods, modeltype::EnergyModel)

Function for calculating the disjunction contribution for the ramping constraints of a reformer.

modeltype::EnergyModel

The function utilizes the the value of the field cap of the node for achieving tight bounds for the disjunction.

modeltype::AbstractInvestmentModel

When the node has investment data, the function utilizes the the value of the field EMI.max_installed of the AbstractInvData for achieving tight bounds for the disjunction. Otherwise, it uses as well the field cap of the node.

source
EnergyModelsHydrogen.compression_energyFunction
compression_energy(p₁, p₂; T₁=298.15, κ=1.41, η=0.75)

Returns the required compression energy for a compression from pressure p₁ to p₂. The compression energy is in principle based on isentropic compression. The unit of the compression energy is J/mol.

Arguments

  • p₁ is the inlet pressure to the compressor. The unit for pressure is not relevant.
  • p₂ is the outlet pressure from the compressor. The unit for pressure is not relevant, but it must be the same unit as p₁.

Keyword arguments

  • T₁ is the inlet temperature to the compressor.
  • κ is the ratio of specific heats. Using a value of [1, κ] would correspond hence to polytropic compression.
  • η is the efficiency of the compressor.
source
EnergyModelsHydrogen.energy_curveFunction
energy_curve(
    p::Float64,
    pᵢₙ::Float64,
    PR::Float64,
    n_comp::Int,
    M::Float64,
    LHV::Float64
)

Returns the relative compression energy requirement for a multi-stage compression train.

Arguments

  • p::Float64 is the delivery pressure.
  • pᵢₙ::Float64 is the inlet pressure.
  • PR::Float64 is the compression rate of each compressor in the train.
  • n_comp::Int is the number of compressors in the train.
  • M::Float64 is molecular mass of the compressed gas.
  • LHV::Float64 is the mass lower heating value of the compressed gas.

Keyword arguments

  • T₁ is the inlet temperature to the compressor.
  • κ is the ratio of specific heats. Using a value of [1, κ] would correspond hence to polytropic compression.
  • η is the efficiency of the compressor.
Units

The units have to be consistent. This implies that both p and pᵢₙ require to have the same unit. The molecular mass should be provided in g/mol while the lower heating value should be given in MJ/kg.

source