Skip to content

Commit 8e71cd2

Browse files
committed
Debugging code
1 parent 41b8743 commit 8e71cd2

4 files changed

Lines changed: 19 additions & 12 deletions

File tree

src/constraints/electric_utility_constraints.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# REopt®, Copyright (c) Alliance for Sustainable Energy, LLC. See also https://github.com/NREL/REopt.jl/blob/master/LICENSE.
22
function add_export_constraints(m, p; _n="")
3-
3+
print("\n #1: p.techs.all is: $(p.techs.all)")
44
##Constraint (8e): Production export and curtailment no greater than production
55
@constraint(m, [t in p.techs.elec, ts in p.time_steps_with_grid],
66
p.production_factor[t,ts] * p.levelization_factor[t] * m[Symbol("dvRatedProduction"*_n)][t,ts]
@@ -384,8 +384,8 @@ end
384384

385385

386386
function add_elec_utility_expressions(m, p; _n="")
387-
388-
if !isempty(p.s.electric_tariff.export_bins) && !isempty(p.techs.all)
387+
# TODO: if prefered, change the if statement below so that the hydropower does not need to be called out separately (note: hydro is removed from p.techs.all in reopt.jl in this line of code: NonHydroTechs = filter!(x->x != hydropower_tech, p.techs.all))
388+
if (!isempty(p.s.electric_tariff.export_bins) && !isempty(p.techs.all)) || (!isempty(p.techs.existing_hydropower))
389389
# NOTE: levelization_factor is baked into dvProductionToGrid
390390
m[Symbol("TotalExportBenefit"*_n)] = m[Symbol("NEM_benefit"*_n)] + m[Symbol("WHL_benefit"*_n)] +
391391
m[Symbol("EXC_benefit"*_n)]

src/constraints/existing_hydropower_constraints.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ function add_existing_hydropower_constraints(m,p)
7070

7171
elseif p.s.existing_hydropower.computation_type == "fixed_efficiency_linearized_reservoir_head"
7272
@info "Adding hydropower power output constraint using a fixed efficiency and linearized reservoir head"
73+
# TODO: make an option that is like this, but linearized using discretization
7374

7475
@variable(m, reservoir_head[ts in p.time_steps] >= 0)
7576

@@ -111,6 +112,8 @@ function add_existing_hydropower_constraints(m,p)
111112
throw(@error("Invalid input for the computation_type field"))
112113
end
113114

115+
print("*********The p.techs.elec are: $(p.techs.elec)")
116+
114117
# Total water volume is between the max and min levels
115118
@constraint(m, [ts in p.time_steps],
116119
m[:dvWaterVolume][ts] <= p.s.existing_hydropower.cubic_meter_maximum
@@ -288,8 +291,9 @@ function add_existing_hydropower_constraints(m,p)
288291
@constraint(m, !m[:indicator_turbine_turn_off][t, ts] => { m[:binTurbineActive][t,ts+1] - m[:binTurbineActive][t,ts] >= 0 } )
289292
end
290293
end
294+
291295
# TODO: remove this constraint, which prevents a spike in the spillway use during the first time step
292-
#@constraint(m, [ts in p.time_steps], m[:dvSpillwayWaterFlow][1] == 0)
296+
@constraint(m, [ts in p.time_steps], m[:dvSpillwayWaterFlow][1] == 0)
293297

294298
end
295299

src/core/reopt.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,8 @@ function build_reopt!(m::JuMP.AbstractModel, p::REoptInputs)
274274
m[:ResidualGHXCapCost] = 0.0
275275
m[:ObjectivePenalties] = 0.0
276276

277+
print("\n ****************** The no curtail techs are: $(p.techs.no_curtail)")
278+
277279
if !isempty(p.techs.all)
278280
add_tech_size_constraints(m, p)
279281

@@ -384,7 +386,6 @@ function build_reopt!(m::JuMP.AbstractModel, p::REoptInputs)
384386
add_coincident_peak_charge_constraints(m, p)
385387
end
386388

387-
388389
# Remove hydropower from the calculation:
389390
NonHydroTechs=[]
390391
for hydropower_tech in p.techs.existing_hydropower
@@ -396,7 +397,6 @@ function build_reopt!(m::JuMP.AbstractModel, p::REoptInputs)
396397
m[:TotalTechCapCosts] += p.third_party_factor *
397398
sum( p.cap_cost_slope[t] * m[:dvPurchaseSize][t] for t in setdiff(NonHydroTechs, p.techs.segmented))
398399
end
399-
400400
if !isempty(p.techs.segmented)
401401
@warn "Adding binary variable(s) to model cost curves"
402402
add_cost_curve_vars_and_constraints(m, p)
@@ -407,7 +407,6 @@ function build_reopt!(m::JuMP.AbstractModel, p::REoptInputs)
407407
)
408408
end
409409
end
410-
411410
@expression(m, TotalStorageCapCosts, p.third_party_factor * (
412411
sum( p.s.storage.attr[b].net_present_cost_per_kw * m[:dvStoragePower][b] for b in p.s.storage.types.elec) +
413412
sum( p.s.storage.attr[b].net_present_cost_per_kwh * m[:dvStorageEnergy][b] for b in p.s.storage.types.all )
@@ -518,7 +517,7 @@ function build_reopt!(m::JuMP.AbstractModel, p::REoptInputs)
518517
add_to_expression!(Costs, m[:Lifecycle_Emissions_Cost_Health])
519518
end
520519
if "ExistingHydropower_Turbine1" in p.techs.elec
521-
print("\n Adding hydro to the objective function")
520+
print("\n Adding spillway water flow to the objective function to minimize the spillway water flow")
522521
add_to_expression!(Costs, sum(m[:dvSpillwayWaterFlow][ts] for ts in p.time_steps)) # minimize the water that is released in the spillway
523522
end
524523
## Modify objective with incentives that are not part of the LCC

src/core/reopt_inputs.jl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -431,10 +431,10 @@ function setup_tech_inputs(s::AbstractScenario)
431431
else
432432
heating_cop["ElectricHeater"] = 1.0
433433
end
434-
435-
if "ExistingHydropower_Turbine1" in techs.all
434+
435+
if "ExistingHydropower_Turbine1" in techs.all # Note: the setup_existing_hydropower_inputs function adds inputs for the other turbine numbers
436436
print("\n Setting up Existing Hydropower in the reopt inputs file")
437-
setup_existing_hydropower_inputs(s, existing_hydropower_inputs, techs_by_exportbin, production_factor)
437+
setup_existing_hydropower_inputs(s, existing_hydropower_inputs, techs_by_exportbin, production_factor, techs)
438438
else
439439
print("\n Existing Hydropower is not in the techs")
440440
#existing_hydropower["existing_kw_per_turbine"] = 0
@@ -645,13 +645,17 @@ function setup_wind_inputs(s::AbstractScenario, max_sizes, min_sizes, existing_s
645645
return nothing
646646
end
647647

648-
function setup_existing_hydropower_inputs(s::AbstractScenario, existing_hydropower_inputs, techs_by_exportbin, production_factor)
648+
function setup_existing_hydropower_inputs(s::AbstractScenario, existing_hydropower_inputs, techs_by_exportbin, production_factor, techs)
649649
existing_hydropower_inputs["existing_kw_per_turbine"] = s.existing_hydropower.existing_kw_per_turbine
650650
for i in 1:s.existing_hydropower.number_of_turbines
651651
# TODO: update so that hydropower works with 15 min and 30 min interval data too
652652
production_factor["ExistingHydropower_Turbine"*string(i),:] = ones(8760 * s.settings.time_steps_per_hour) # get_production_factor(s.existing_hydropower; s.settings.time_steps_per_hour)
653653
fillin_techs_by_exportbin(techs_by_exportbin, s.existing_hydropower, "ExistingHydropower_Turbine"*string(i))
654654

655+
if !(s.existing_hydropower.can_curtail)
656+
push!(techs.no_curtail, "ExistingHydropower_Turbine"*string(i))
657+
end
658+
655659
end
656660
return nothing
657661
end

0 commit comments

Comments
 (0)