Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug dc couple #436

Draft
wants to merge 8 commits into
base: dc-couple
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/constraints/outage_constraints.jl
Original file line number Diff line number Diff line change
Expand Up @@ -391,15 +391,15 @@ function add_cannot_have_MG_with_only_PVwind_constraints(m, p)
end

function add_MG_dc_coupled_tech_elec_storage_constraints(m, p)
# # Lower bound on DC coupled PV and battery inverter power capacity
# @constraint(m, [s in p.s.electric_utility.scenarios, tz in p.s.electric_utility.outage_start_time_steps, ts in p.s.electric_utility.outage_time_steps],
# m[:dvDCCoupledTechStorageInverterSize]["ElectricStorage"] >=
# m[:dvMGDischargeFromStorage][s, tz, ts] +
# sum(m[:dvMGRatedProduction][t, s, tz, ts] * p.production_factor[t, tz+ts-1] * p.levelization_factor[t]
# - m[:dvMGProductionToStorage][t, s, tz, ts] - m[:dvMGCurtail][t, s, tz, ts]
# for t in p.techs.dc_couple_with_stor
# )
# )
# Lower bound on DC coupled PV and battery inverter power capacity
@constraint(m, [s in p.s.electric_utility.scenarios, tz in p.s.electric_utility.outage_start_time_steps, ts in p.s.electric_utility.outage_time_steps],
m[:dvDCCoupledTechStorageInverterSize]["ElectricStorage"] >=
m[:dvMGDischargeFromStorage][s, tz, ts] +
sum(m[:dvMGRatedProduction][t, s, tz, ts] * p.production_factor[t, tz+ts-1] * p.levelization_factor[t]
- m[:dvMGProductionToStorage][t, s, tz, ts] - m[:dvMGCurtail][t, s, tz, ts]
for t in p.techs.dc_couple_with_stor
)
)

# Don't let AC coupled elec techs charge battery.
# Future development could make this an option by adding a bool input and creating the set p.techs.elec_cannot_charge_stor that is different than p.techs.ac_couple_with_stor
Expand Down
38 changes: 19 additions & 19 deletions src/constraints/storage_constraints.jl
Original file line number Diff line number Diff line change
Expand Up @@ -104,25 +104,25 @@ function add_elec_storage_dispatch_constraints(m, p, b; _n="")
end

function add_dc_coupled_tech_elec_storage_constraints(m, p, b; _n="")
# # Constraint (4d)-1: Lower bound on DC coupled PV and battery inverter power capacity (inverter direction)
# @constraint(m, [ts in p.time_steps],
# m[Symbol("dvDCCoupledTechStorageInverterSize"*_n)][b] >=
# m[Symbol("dvDischargeFromStorage"*_n)][b,ts]
# - sum(m[Symbol("dvProductionToStorage"*_n)][b, t, ts] for t in p.techs.ac_couple_with_stor)
# + sum(p.production_factor[t, ts] * p.levelization_factor[t] * m[Symbol("dvRatedProduction"*_n)][t,ts]
# - m[Symbol("dvProductionToStorage"*_n)][b, t, ts]
# - m[Symbol("dvCurtail"*_n)][t, ts] for t in p.techs.dc_couple_with_stor)
# )

# # Constraint (4d)-2: Lower bound on DC coupled PV and battery inverter power capacity (rectifier direction)
# @constraint(m, [ts in p.time_steps],
# m[Symbol("dvDCCoupledTechStorageInverterSize"*_n)][b] >=
# - m[Symbol("dvDischargeFromStorage"*_n)][b,ts]
# + sum(m[Symbol("dvProductionToStorage"*_n)][b, t, ts] for t in p.techs.ac_couple_with_stor)
# - sum(p.production_factor[t, ts] * p.levelization_factor[t] * m[Symbol("dvRatedProduction"*_n)][t,ts]
# - m[Symbol("dvProductionToStorage"*_n)][b, t, ts]
# - m[Symbol("dvCurtail"*_n)][t, ts] for t in p.techs.dc_couple_with_stor)
# )
# Constraint (4d)-1: Lower bound on DC coupled PV and battery inverter power capacity (inverter direction)
@constraint(m, [ts in p.time_steps],
m[Symbol("dvDCCoupledTechStorageInverterSize"*_n)][b] >=
m[Symbol("dvDischargeFromStorage"*_n)][b,ts]
- sum(m[Symbol("dvProductionToStorage"*_n)][b, t, ts] for t in p.techs.ac_couple_with_stor)
+ sum(p.production_factor[t, ts] * p.levelization_factor[t] * m[Symbol("dvRatedProduction"*_n)][t,ts]
- m[Symbol("dvProductionToStorage"*_n)][b, t, ts]
- m[Symbol("dvCurtail"*_n)][t, ts] for t in p.techs.dc_couple_with_stor)
)

# Constraint (4d)-2: Lower bound on DC coupled PV and battery inverter power capacity (rectifier direction)
@constraint(m, [ts in p.time_steps],
m[Symbol("dvDCCoupledTechStorageInverterSize"*_n)][b] >=
- m[Symbol("dvDischargeFromStorage"*_n)][b,ts]
+ sum(m[Symbol("dvProductionToStorage"*_n)][b, t, ts] for t in p.techs.ac_couple_with_stor)
- sum(p.production_factor[t, ts] * p.levelization_factor[t] * m[Symbol("dvRatedProduction"*_n)][t,ts]
- m[Symbol("dvProductionToStorage"*_n)][b, t, ts]
- m[Symbol("dvCurtail"*_n)][t, ts] for t in p.techs.dc_couple_with_stor)
)

# Constraint (4d)-3: Don't let AC coupled elec techs charge battery.
# Future development could make this an option by adding a bool input and creating the set p.techs.elec_cannot_charge_stor that is different than p.techs.ac_couple_with_stor
Expand Down
6 changes: 3 additions & 3 deletions src/core/reopt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -610,9 +610,9 @@ function add_variables!(m::JuMP.AbstractModel, p::REoptInputs)
binGHP[p.ghp_options], Bin # Can be <= 1 if require_ghp_purchase=0, and is ==1 if require_ghp_purchase=1
end

# if !isempty(p.techs.dc_couple_with_stor)
# @variable(m, dvDCCoupledTechStorageInverterSize[p.s.storage.types.elec] >= 0) # Power capacity of the DC coupled PV and electric storage system b [kW]
# end
if !isempty(p.techs.dc_couple_with_stor)
@variable(m, dvDCCoupledTechStorageInverterSize[p.s.storage.types.elec] >= 0) # Power capacity of the DC coupled PV and electric storage system b [kW]
end

if !isempty(p.techs.gen) # Problem becomes a MILP
@warn "Adding binary variable to model gas generator. Some solvers are very slow with integer variables."
Expand Down
6 changes: 3 additions & 3 deletions src/results/electric_storage.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ function add_electric_storage_results(m::JuMP.AbstractModel, p::REoptInputs, d::
r = Dict{String, Any}()
r["size_kwh"] = round(value(m[Symbol("dvStorageEnergy"*_n)][b]), digits=2)
r["size_kw"] = round(value(m[Symbol("dvStoragePower"*_n)][b]), digits=2)
# if !isempty(p.techs.dc_couple_with_stor)
# r["dc_couple_inverter_size_kw"] = round(value(m[:dvDCCoupledTechStorageInverterSize][b]), digits=2)
# end
if !isempty(p.techs.dc_couple_with_stor)
r["dc_couple_inverter_size_kw"] = round(value(m[:dvDCCoupledTechStorageInverterSize][b]), digits=2)
end

if r["size_kwh"] != 0
soc = (m[Symbol("dvStoredEnergy"*_n)][b, ts] for ts in p.time_steps)
Expand Down
Loading
Loading