Skip to content

Commit

Permalink
1. check the compatibility between multi-fuels and piesewise heat rat…
Browse files Browse the repository at this point in the history
…es when reading generators_data.csv;

2. change i into f in load_generators_data.jl in "for i in 1:max_fuels"
  • Loading branch information
qluo0320github committed Jan 4, 2024
1 parent 8f48fa4 commit 5b983be
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 22 deletions.
22 changes: 14 additions & 8 deletions src/load_inputs/load_generators_data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -262,12 +262,12 @@ function load_multi_fuels_data!(inputs_gen::Dict, setup::Dict, path::AbstractStr

inputs_gen["NUM_FUELS"] = gen_in[!,:Num_Fuels] # Number of fuels that this resource can use
max_fuels = maximum(inputs_gen["NUM_FUELS"])
fuel_cols = [ Symbol(string("Fuel",i)) for i in 1:max_fuels ]
heat_rate_cols = [ Symbol(string("Heat_Rate",i, "_MMBTU_per_MWh")) for i in 1:max_fuels ]
max_cofire_cols = [ Symbol(string("Fuel",i, "_Max_Cofire_Level")) for i in 1:max_fuels ]
min_cofire_cols = [ Symbol(string("Fuel",i, "_Min_Cofire_Level")) for i in 1:max_fuels ]
max_cofire_start_cols = [ Symbol(string("Fuel",i, "_Max_Cofire_Level_Start")) for i in 1:max_fuels ]
min_cofire_start_cols = [ Symbol(string("Fuel",i, "_Min_Cofire_Level_Start")) for i in 1:max_fuels ]
fuel_cols = [ Symbol(string("Fuel",f)) for f in 1:max_fuels ]
heat_rate_cols = [ Symbol(string("Heat_Rate",f, "_MMBTU_per_MWh")) for f in 1:max_fuels ]
max_cofire_cols = [ Symbol(string("Fuel",f, "_Max_Cofire_Level")) for f in 1:max_fuels ]
min_cofire_cols = [ Symbol(string("Fuel",f, "_Min_Cofire_Level")) for f in 1:max_fuels ]
max_cofire_start_cols = [ Symbol(string("Fuel",f, "_Max_Cofire_Level_Start")) for f in 1:max_fuels ]
min_cofire_start_cols = [ Symbol(string("Fuel",f, "_Min_Cofire_Level_Start")) for f in 1:max_fuels ]
fuel_types = [ gen_in[!,f] for f in fuel_cols ]
heat_rates = [ gen_in[!,f] for f in heat_rate_cols ]
max_cofire = [ gen_in[!,f] for f in max_cofire_cols ]
Expand All @@ -284,13 +284,19 @@ function load_multi_fuels_data!(inputs_gen::Dict, setup::Dict, path::AbstractStr
inputs_gen["MAX_NUM_FUELS"] = max_fuels

# check whether non-zero heat rates are used for resources that only use a single fuel
for i in 1:max_fuels
for hr in heat_rates[i][inputs_gen["SINGLE_FUEL"]]
for f in 1:max_fuels
for hr in heat_rates[f][inputs_gen["SINGLE_FUEL"]]
if hr > 0
error("Heat rates for multi fuels must be zero when only one fuel is used")
end
end
end
# do not allow the multi-fuel option when piece-wise heat rates are used
THERM_COMMIT_PWFU = inputs_gen["THERM_COMMIT_PWFU"]
# segemnt for piecewise fuel usage
if !isempty(THERM_COMMIT_PWFU)
error("Multi-fuel option is not available when piece-wise heat rates are used. Please remove multi fuels to avoid this error.")
end
end

@doc raw"""
Expand Down
24 changes: 10 additions & 14 deletions src/model/core/fuel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -258,20 +258,16 @@ function fuel!(EP::Model, inputs::Dict, setup::Dict)
THERM_COMMIT_PWFU = inputs["THERM_COMMIT_PWFU"]
# segemnt for piecewise fuel usage
if !isempty(THERM_COMMIT_PWFU)
if isempty(MULTI_FUELS)
segs = 1:inputs["PWFU_Num_Segments"]
PWFU_data = inputs["PWFU_data"]
slope_cols = inputs["slope_cols"]
intercept_cols = inputs["intercept_cols"]
segment_intercept(y, seg) = PWFU_data[y, intercept_cols[seg]]
segment_slope(y, seg) = PWFU_data[y, slope_cols[seg]]
# constraint for piecewise fuel consumption
@constraint(EP, PiecewiseFuelUsage[y in THERM_COMMIT_PWFU, t = 1:T, seg in segs],
EP[:vFuel][y, t] >= (EP[:vP][y, t] * segment_slope(y, seg) +
EP[:vCOMMIT][y, t] * segment_intercept(y, seg)))
else
error("Multi-fuel option is not available when piece-wise heat rates are used. Please remove multi fuels to avoid this error.")
end
segs = 1:inputs["PWFU_Num_Segments"]
PWFU_data = inputs["PWFU_data"]
slope_cols = inputs["slope_cols"]
intercept_cols = inputs["intercept_cols"]
segment_intercept(y, seg) = PWFU_data[y, intercept_cols[seg]]
segment_slope(y, seg) = PWFU_data[y, slope_cols[seg]]
# constraint for piecewise fuel consumption
@constraint(EP, PiecewiseFuelUsage[y in THERM_COMMIT_PWFU, t = 1:T, seg in segs],
EP[:vFuel][y, t] >= (EP[:vP][y, t] * segment_slope(y, seg) +
EP[:vCOMMIT][y, t] * segment_intercept(y, seg)))
end

# constraint for fuel consumption at a constant heat rate
Expand Down

0 comments on commit 5b983be

Please sign in to comment.