YoungFaithful / CapacityExpansion.jl

Capacity Expansion Problem Formulation for Julia

Home Page:https://youngfaithful.github.io/CapacityExpansion.jl/stable

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Setting initial battery storage level to 50%

holgerteichgraeber opened this issue · comments

@YoungFaithful
I'm trying to fix every day at an initial storage level of 50%. This is for the case of simple storage.

I am looking at the function below in opt.jl.

  • Limit the storage of the energy part of the battery to its installed power : Is this limiting the energy part of the battery to its installed power, or to its installed energy capacity (I would hope the latter)?
  • Is this the battery energy capacity: sum(cep.model[:CAP][tech, infrastruct, node] for infrastruct=set["infrastruct"]["all"])*scale[:CAP]/scale[:INTRASTOR] ? Why the sum over infrastruct, what are examples where it is summed over multiple infrastructs?
  • I'm thinking of replacing the right hand side of the third constraint by sum(cep.model[:CAP][tech, infrastruct, node] for infrastruct=set["infrastruct"]["all"])*scale[:CAP]/scale[:INTRASTOR] / 0.5. Anything I should be aware of with scaling?
function setup_opt_simplestorage!(cep::OptModelCEP,
                            ts_data::ClustData,
                            opt_data::OptDataCEP,
                            scale::Dict{Symbol,Int})
    ## DATA ##
    set=cep.set
    #`techs::OptVariable`: techs[tech][tech_group] - OptDataCEPTech
    techs = opt_data.techs

    ## INTRASTORAGE ##
    # Limit the storage of the energy part of the battery to its installed power
    push!(cep.info,"INTRASTOR[carrier,tech, t, k, node] ≤ Σ_{infrastruct} CAP[tech,infrastruct,node] ∀ node, tech_storage, t, k")
    @constraint(cep.model, [node=set["nodes"]["all"], tech=set["tech"]["storage"], t=set["time_T_period"]["all"], k=set["time_K"]["all"]], cep.model[:INTRASTOR][tech, techs[tech].input["carrier"], t,k,node]<=sum(cep.model[:CAP][tech, infrastruct, node] for infrastruct=set["infrastruct"]["all"])*scale[:CAP]/scale[:INTRASTOR])
    # Set storage level at beginning and end of day equal
    push!(cep.info,"INTRASTOR[carrier,tech, '0', k, node] = INTRASTOR[carrier,tech, 't[end]', k, node] ∀ node, tech_storage, k")
    @constraint(cep.model, [node=set["nodes"]["all"], tech=set["tech"]["storage"], k=set["time_K"]["all"]], cep.model[:INTRASTOR][tech, techs[tech].input["carrier"], 0, k, node]== cep.model[:INTRASTOR][tech,techs[tech].input["carrier"],set["time_T_point"]["all"][end],k,node])
    # Set the storage level at the beginning of each representative day to the same
    push!(cep.info,"INTRASTOR[carrier,tech, '0', k, node] = INTRASTOR[carrier,tech, '0', k, node] ∀ node, tech_storage, k")
    @constraint(cep.model, [node=set["nodes"]["all"], tech=set["tech"]["storage"], k=set["time_K"]["all"]], cep.model[:INTRASTOR][tech, techs[tech].input["carrier"], 0, k, node]== cep.model[:INTRASTOR][tech, techs[tech].input["carrier"], 0, 1, node])
    return cep
end

The last question should be with *0.5:

I'm thinking of replacing the right hand side of the third constraint by sum(cep.model[:CAP][tech, infrastruct, node] for infrastruct=set["infrastruct"]["all"])*scale[:CAP]/scale[:INTRASTOR] * 0.5. Anything I should be aware of with scaling?

  • The comment Limit the storage of the energy part of the battery to its installed power should say: Limit the stored energy of the battery to its energy capacity to meet what's mathematically happening
  • sum(cep.model[:CAP][tech, infrastruct, node] for infrastruct=set["infrastruct"]["all"])*scale[:CAP]/scale[:INTRASTOR] (for each tech=set["tech"]["storage"] and node=set["nodes"]["all"]) is used to sum over the installed energy capacity. infrastruct is used to determine between existing and new installation. If you have existing capacities, the summation would be over both new and existing capacities.
  • the proposed change would work. Alternatively you could also add an additional function like:
                            ts_data::ClustData,
                            opt_data::OptDataCEP,
                            scale::Dict{Symbol,Int})
    ## DATA ##
    set=cep.set
    #`techs::OptVariable`: techs[tech][tech_group] - OptDataCEPTech
    techs = opt_data.techs

    ## INTRASTORAGE ##
    # Set the storage level at the beginning of the first 
    push!(cep.info,"INTRASTOR[carrier,tech, '0', 1, node] = Σ_{infrastruct} CAP[tech,infrastruct,node] * 0.5 ∀ node, tech_storage, k")
    @constraint(cep.model, [node=set["nodes"]["all"], tech=set["tech"]["storage"]], cep.model[:INTRASTOR][tech, techs[tech].input["carrier"], 0, 1, node]== sum(cep.model[:CAP][tech, infrastruct, node] for infrastruct=set["infrastruct"]["all"])*scale[:CAP]/scale[:INTRASTOR] * 0.5
    return cep
end

theoretically the factor could also be part of the input.