diff --git a/Example_Systems/RetrofitExample/OneZone/Resources/Thermal.csv b/Example_Systems/RetrofitExample/OneZone/Resources/Thermal.csv index 46eeff511c..103043fc9d 100644 --- a/Example_Systems/RetrofitExample/OneZone/Resources/Thermal.csv +++ b/Example_Systems/RetrofitExample/OneZone/Resources/Thermal.csv @@ -5,8 +5,8 @@ coal_super_2,1,1,2,0,1,0,1,0,6000,0,0,112000,10287,0,7.43,coal,300,17,2,4,4,0.64 coal_super_3,1,1,3,0,1,0,1,0,6000,0,0,112000,10287,0,7.43,coal,300,17,2,4,4,0.64,0.64,0.55,0.25,0.25,0,0,1,Coal_super,NE,3 coal_super_4,1,1,4,0,1,0,1,0,6000,0,0,112000,10287,0,7.43,coal,300,17,2,4,4,0.64,0.64,0.55,0.25,0.25,0,0,1,Coal_super,NE,4 coal_super_5,1,1,5,0,1,0,1,0,6000,0,0,112000,10287,0,7.43,coal,300,17,2,4,4,0.64,0.64,0.55,0.25,0.25,0,0,1,Coal_super,NE,5 -20A_retrofit_1,1,1,1,1,0,0.85,0,1,0,-1,0,2342,10287,0,5,blue_ammonia,300,17,2,4,4,0.64,0.64,0.55,0.25,0.25,0,0,1,ammonia,NE,1 -20A_retrofit_2,1,1,2,1,0,0.85,0,1,0,-1,0,2342,10287,0,5,blue_ammonia,300,17,2,4,4,0.64,0.64,0.55,0.25,0.25,0,0,1,ammonia,NE,2 -20A_retrofit_3,1,1,3,1,0,0.85,0,1,0,-1,0,2342,10287,0,5,blue_ammonia,300,17,2,4,4,0.64,0.64,0.55,0.25,0.25,0,0,1,ammonia,NE,3 -20A_retrofit_4,1,1,4,1,0,0.85,0,1,0,-1,0,2342,10287,0,5,blue_ammonia,300,17,2,4,4,0.64,0.64,0.55,0.25,0.25,0,0,1,ammonia,NE,4 -20A_retrofit_5,1,1,5,1,0,0.85,0,1,0,-1,0,2342,10287,0,5,blue_ammonia,300,17,2,4,4,0.64,0.64,0.55,0.25,0.25,0,0,1,ammonia,NE,5 \ No newline at end of file +20A_retrofit_1,1,1,1,1,0,0.85,0,1,0,-1,0,2342,10287,0,5,blue_ammonia,255,17,2,4,4,0.64,0.64,0.55,0.25,0.25,0,0,1,ammonia,NE,1 +20A_retrofit_2,1,1,2,1,0,0.85,0,1,0,-1,0,2342,10287,0,5,blue_ammonia,255,17,2,4,4,0.64,0.64,0.55,0.25,0.25,0,0,1,ammonia,NE,2 +20A_retrofit_3,1,1,3,1,0,0.85,0,1,0,-1,0,2342,10287,0,5,blue_ammonia,255,17,2,4,4,0.64,0.64,0.55,0.25,0.25,0,0,1,ammonia,NE,3 +20A_retrofit_4,1,1,4,1,0,0.85,0,1,0,-1,0,2342,10287,0,5,blue_ammonia,255,17,2,4,4,0.64,0.64,0.55,0.25,0.25,0,0,1,ammonia,NE,4 +20A_retrofit_5,1,1,5,1,0,0.85,0,1,0,-1,0,2342,10287,0,5,blue_ammonia,255,17,2,4,4,0.64,0.64,0.55,0.25,0.25,0,0,1,ammonia,NE,5 diff --git a/src/load_inputs/load_resources_data.jl b/src/load_inputs/load_resources_data.jl index f96214f1f0..8ef269b095 100644 --- a/src/load_inputs/load_resources_data.jl +++ b/src/load_inputs/load_resources_data.jl @@ -1057,18 +1057,18 @@ function add_resources_to_input_data!(inputs::Dict, setup::Dict, case_path::Abst # store a unique set of retrofit_ids inputs["RETROFIT_IDS"] = Set(retrofit_id.(gen[inputs["RETROFIT_CAP"]])) - # Check if retrofit options and retrofitting units with unit commitment have the same capacity when UCommit == 1 - if setup["UCommit"] == 1 - can_retrofit_commit = intersect(inputs["RETROFIT_CAP"], inputs["COMMIT"]) - retrofit_options_commit = intersect(inputs["RETROFIT_OPTIONS"], inputs["COMMIT"]) - cap_size_can_retrofit_commit = cap_size.(gen[can_retrofit_commit]) - cap_size_retrofit_options_commit = cap_size.(gen[retrofit_options_commit]) .* retrofit_efficiency.(gen[retrofit_options_commit]) - if cap_size_can_retrofit_commit != cap_size_retrofit_options_commit - msg = "Retrofit options and retrofitting units with unit commitment should have the same capacity.\n" * - "Check \"Cap_Size\" and \"Retrofit_Efficiency\" for the retrofitting units and retrofit options in the input files." - @warn(msg) - end - end + # # Check if retrofit options and retrofitting units with unit commitment have the same capacity when UCommit == 1 + # if setup["UCommit"] == 1 + # can_retrofit_commit = intersect(inputs["RETROFIT_CAP"], inputs["COMMIT"]) + # retrofit_options_commit = intersect(inputs["RETROFIT_OPTIONS"], inputs["COMMIT"]) + # cap_size_can_retrofit_commit = cap_size.(gen[can_retrofit_commit]) + # cap_size_retrofit_options_commit = cap_size.(gen[retrofit_options_commit]) .* retrofit_efficiency.(gen[retrofit_options_commit]) + # if cap_size_can_retrofit_commit != cap_size_retrofit_options_commit + # msg = "Retrofit options and retrofitting units with unit commitment should have the same capacity.\n" * + # "Check \"Cap_Size\" and \"Retrofit_Efficiency\" for the retrofitting units and retrofit options in the input files." + # @warn(msg) + # end + # end end new_cap_energy = Set{Int64}() diff --git a/src/model/resources/retrofits/retrofits.jl b/src/model/resources/retrofits/retrofits.jl index 61ccda3b17..389cade130 100644 --- a/src/model/resources/retrofits/retrofits.jl +++ b/src/model/resources/retrofits/retrofits.jl @@ -31,11 +31,11 @@ function retrofit(EP::Model, inputs::Dict) RETROFIT_OPTIONS = inputs["RETROFIT_OPTIONS"] # Set of all resources being created RETROFIT_IDS = inputs["RETROFIT_IDS"] # Set of unique IDs for retrofit resources - @constraint(EP, cRetrofitZone[id in RETROFIT_IDS], + @constraint(EP, cRetrofitCapacity[id in RETROFIT_IDS], sum(cap_size(gen[y]) * EP[:vRETROFITCAP][y] for y in intersect(RETROFIT_CAP, COMMIT, resources_in_retrofit_pool_by_rid(gen,id)); init=0) + sum(EP[:vRETROFITCAP][y] for y in setdiff(intersect(RETROFIT_CAP, resources_in_retrofit_pool_by_rid(gen,id)), COMMIT); init=0) - == sum(cap_size(gen[y]) * EP[:vCAP][y] * retrofit_efficiency(gen[y]) for y in intersect(RETROFIT_OPTIONS, COMMIT, resources_in_retrofit_pool_by_rid(gen,id)); init=0) - + sum(EP[:vCAP][y] * retrofit_efficiency(gen[y]) for y in setdiff(intersect(RETROFIT_OPTIONS, resources_in_retrofit_pool_by_rid(gen,id)), COMMIT); init=0)) + == sum(cap_size(gen[y]) * EP[:vCAP][y] * (1/retrofit_efficiency(gen[y])) for y in intersect(RETROFIT_OPTIONS, COMMIT, resources_in_retrofit_pool_by_rid(gen,id)); init=0) + + sum(EP[:vCAP][y] * (1/retrofit_efficiency(gen[y])) for y in setdiff(intersect(RETROFIT_OPTIONS, resources_in_retrofit_pool_by_rid(gen,id)), COMMIT); init=0)) return EP end diff --git a/src/model/solve_model.jl b/src/model/solve_model.jl index 53f385c38f..2693cea662 100644 --- a/src/model/solve_model.jl +++ b/src/model/solve_model.jl @@ -70,14 +70,6 @@ function solve_model(EP::Model, setup::Dict) println("MILP solved for primal") end - if !has_duals(EP) && setup["WriteShadowPrices"] == 1 - # function to fix integers and linearize problem - fix_integers(EP) - # re-solve statement for LP solution - println("Solving LP solution for duals") - optimize!(EP) - end - ## Record solver time solver_time = time() - solver_start_time elseif setup["ComputeConflicts"]==0 diff --git a/src/write_outputs/write_outputs.jl b/src/write_outputs/write_outputs.jl index 46d5838246..de44a59424 100644 --- a/src/write_outputs/write_outputs.jl +++ b/src/write_outputs/write_outputs.jl @@ -47,6 +47,15 @@ function write_outputs(EP::Model, path::AbstractString, setup::Dict, inputs::Dic output_settings_d["WriteStatus"] && write_status(path, inputs, setup, EP) + if !has_duals(EP) && setup["WriteShadowPrices"] == 1 + # function to fix integers and linearize problem + fix_integers(EP) + # re-solve statement for LP solution + println("Solving LP solution for duals") + set_silent(EP) + optimize!(EP) + end + if output_settings_d["WriteCosts"] elapsed_time_costs = @elapsed write_costs(path, inputs, setup, EP) println("Time elapsed for writing costs is")