Skip to content

Commit

Permalink
Merge pull request #3 from swang22/dev
Browse files Browse the repository at this point in the history
Dev-correct col names in rps related files
  • Loading branch information
swang22 authored Dec 20, 2023
2 parents d9e1043 + 9b7edb4 commit 911857f
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 20 deletions.
Binary file modified ModelCases/MD_Excel_case/Data_PCM2035/PCM_input_total.xlsx
Binary file not shown.
5 changes: 5 additions & 0 deletions ModelCases/MD_Excel_case/output/es_power_hourly.csv

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions ModelCases/MD_Excel_case/output/power_hourly.csv

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions ModelCases/MD_case/Data_100RPS/rpspolices.csv

This file was deleted.

3 changes: 3 additions & 0 deletions ModelCases/MD_case/Data_100RPS/rpspolicies.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
From_state,To_state,RPS
MD,NMD,1
NMD,MD,0
12 changes: 6 additions & 6 deletions src/GTEP.jl
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ function create_GTEP_model(config_set::Dict,input_data::Dict,OPTIMIZER::MOI.Opti
LR_i=[[findall(Branchdata[:,"To_zone"].==Idx_zone_dict[i]);(findall(Linedata_candidate[:,"To_zone"].==Idx_zone_dict[i]).+Num_Eline)] for i in I] #Set of receiving transmission corridors of zone i, subset of L
IL_l = Dict(zip(L,[[i,j] for i in map(x -> Zone_idx_dict[x],Branchdata[:,"From_zone"]) for j in map(x -> Zone_idx_dict[x],Branchdata[:,"To_zone"])]))
I_w=Dict(zip(W, [findall(Busdata[:,"State"].== w) for w in W])) #Set of zones in state w, subset of I
WIR_w=Dict(zip(["MD","NMD"],[["MD","NMD"],["MD","NMD"]])) #Set of states that state w can import renewable credits from (includes w itself), subset of W
WER_w=Dict(zip(["MD","NMD"],[["NMD"],["MD"]])) #Set of states that state w can export renewable credits to (excludes w itself), subset of W
WER_w=Dict(zip(unique(df[:, :From_state]),[df[findall(df[:,"From_state"].==i),"To_state"] for i in unique(df[:, :From_state])])) #Set of states that state w can import renewable credits from (includes w itself), subset of W
WIR_w=Dict(zip(unique(df[:, :From_state]), push!(df[findall(df[:,"From_state"].==i),"To_state"], i) for i in unique(df[:, :From_state]))) #Set of states that state w can export renewable credits to (excludes w itself), subset of W

G_L = Dict(zip([l for l in L], [G_i[i] for l in L for i in IL_l[l]])) #Set of generation units that linked to line l, index g, subset of G

Expand Down Expand Up @@ -172,7 +172,7 @@ function create_GTEP_model(config_set::Dict,input_data::Dict,OPTIMIZER::MOI.Opti
PT_emis=10^9 #Carbon emission volitation penalty, $/t
P_min=[Gendata[:,"Pmin (MW)"];Gendata_candidate[:,"Pmin (MW)"]]#g #Minimum power generation of unit g, MW
P_max=[Gendata[:,"Pmax (MW)"];Gendata_candidate[:,"Pmax (MW)"]]#g #Maximum power generation of unit g, MW
RPS=Dict(zip(RPSdata[:,:State],RPSdata[:,:RPS])) #w #Renewable portfolio standard in state w, unitless
RPS=Dict(zip(RPSdata[:,:From_state],RPSdata[:,:RPS])) #w #Renewable portfolio standard in state w, unitless
RM=config_set["planning_reserve_margin"]# #Planning reserve margin, unitless
SECAP=[Estoragedata[:,"Capacity (MWh)"];Estoragedata_candidate[:,"Capacity (MWh)"]]#s #Maximum energy capacity of storage unit s, MWh
SCAP=[Estoragedata[:,"Max Power (MW)"];Estoragedata_candidate[:,"Max Power (MW)"]]#s #Maximum capacity of storage unit s, MWh
Expand Down Expand Up @@ -317,7 +317,7 @@ function create_GTEP_model(config_set::Dict,input_data::Dict,OPTIMIZER::MOI.Opti
>= (1+RM)*sum(PK[i] for i in I_w["MD"]), base_name = "RA_con")

##############
##RPSPolices##
##RPSPolicies##
##############
#(23) RPS, state level total Defining
RPS_pw_con = @constraint(model, [w in W, g in intersect(union([G_i[i] for i in I_w[w]]...),G_RPS)],
Expand All @@ -337,7 +337,7 @@ function create_GTEP_model(config_set::Dict,input_data::Dict,OPTIMIZER::MOI.Opti
>= sum(N[t]*sum(sum(P_t[t][h,i]*PK[i]*RPS[w] for d in D_i[i]) for i in I_w[w] for h in H_t[t]) for t in T), base_name = "RPS_con")

###############
#CarbonPolices#
#CarbonPolicies#
###############
#(27) State carbon emission limit
#CL_con = @constraint(model, [w in W], sum(sum(N[t]*sum(EF[g]*p[g,t,h] for g in intersect(G_F,G_i[i]) for h in H[t]) for t in T) for i in I_w[w])<=ELMT[w], base_name = "CL_con")
Expand Down Expand Up @@ -397,7 +397,7 @@ function solve_model(config_set::Dict, input_data::Dict, model::Model)
##read input for print
W=unique(input_data["Busdata"][:,"State"]) #Set of states, index w/w’
RPSdata = input_data["RPSdata"]
RPS=Dict(zip(RPSdata[:,:State],RPSdata[:,:RPS]))
RPS=Dict(zip(RPSdata[:,:From_state],RPSdata[:,:RPS]))
if model_mode == "GTEP"
Estoragedata_candidate = input_data["Estoragedata_candidate"]
Linedata_candidate = input_data["Linedata_candidate"]
Expand Down
4 changes: 2 additions & 2 deletions src/PCM.jl
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ function create_PCM_model(config_set::Dict,input_data::Dict,OPTIMIZER::MOI.Optim
PT_emis=10^9 #Carbon emission volitation penalty, $/t
P_min=[Gendata[:,"Pmin (MW)"];]#g #Minimum power generation of unit g, MW
P_max=[Gendata[:,"Pmax (MW)"];]#g #Maximum power generation of unit g, MW
RPS=Dict(zip(RPSdata[:,:State],RPSdata[:,:RPS])) #w #Renewable portfolio standard in state w, unitless
RPS=Dict(zip(RPSdata[:,:From_state],RPSdata[:,:RPS])) #w #Renewable portfolio standard in state w, unitless
#RM=0.02# #Planning reserve margin, unitless
RM_SPIN_g = Dict(zip(G,Gendata[:,Symbol("RM_SPIN")]))
RU_g = Dict(zip(G,Gendata[:,Symbol("RU")]))
Expand Down Expand Up @@ -371,7 +371,7 @@ function solve_model(config_set::Dict, input_data::Dict, model::Model)# same as
##read input for print
W=unique(input_data["Busdata"][:,"State"]) #Set of states, index w/w’
RPSdata = input_data["RPSdata"]
RPS=Dict(zip(RPSdata[:,:State],RPSdata[:,:RPS]))
RPS=Dict(zip(RPSdata[:,:From_state],RPSdata[:,:RPS]))
if model_mode == "GTEP"
Estoragedata_candidate = input_data["Estoragedata_candidate"]
Linedata_candidate = input_data["Linedata_candidate"]
Expand Down
18 changes: 9 additions & 9 deletions src/Read_input_data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ function load_data(config_set::Dict,path::AbstractString)
input_data["Gendata_candidate"]=DataFrame(XLSX.readtable(joinpath(folderpath,"GTEP_input_total.xlsx"),"Gendata_candidate"))
#policies
println("Reading polices")
input_data["CBPdata"]=DataFrame(XLSX.readtable(joinpath(folderpath,"GTEP_input_total.xlsx"),"carbonpolices"))
input_data["CBPdata"]=DataFrame(XLSX.readtable(joinpath(folderpath,"GTEP_input_total.xlsx"),"carbonpolicies"))
#rpspolicydata=
input_data["RPSdata"]=DataFrame(XLSX.readtable(joinpath(folderpath,"GTEP_input_total.xlsx"),"rpspolices"))
input_data["RPSdata"]=DataFrame(XLSX.readtable(joinpath(folderpath,"GTEP_input_total.xlsx"),"rpspolicies"))
println("xlsx Files Successfully Load From $folderpath")

else
Expand Down Expand Up @@ -101,9 +101,9 @@ function load_data(config_set::Dict,path::AbstractString)
input_data["Gendata_candidate"]=CSV.read(joinpath(folderpath,"Gendata_candidate.csv"),DataFrame)
#policies
println("Reading polices")
input_data["CBPdata"]=CSV.read(joinpath(folderpath,"carbonpolices.csv"),DataFrame)
input_data["CBPdata"]=CSV.read(joinpath(folderpath,"carbonpolicies.csv"),DataFrame)
#rpspolicydata=
input_data["RPSdata"]=CSV.read(joinpath(folderpath,"rpspolices.csv"),DataFrame)
input_data["RPSdata"]=CSV.read(joinpath(folderpath,"rpspolicies.csv"),DataFrame)
println("CSV Files Successfully Load From $folderpath")
end

Expand Down Expand Up @@ -143,9 +143,9 @@ function load_data(config_set::Dict,path::AbstractString)

#policies
println("Reading polices")
input_data["CBPdata"]=DataFrame(XLSX.readtable(joinpath(folderpath,"PCM_input_total.xlsx"),"carbonpolices"))
input_data["CBPdata"]=DataFrame(XLSX.readtable(joinpath(folderpath,"PCM_input_total.xlsx"),"carbonpolicies"))
#rpspolicydata=
input_data["RPSdata"]=DataFrame(XLSX.readtable(joinpath(folderpath,"PCM_input_total.xlsx"),"rpspolices"))
input_data["RPSdata"]=DataFrame(XLSX.readtable(joinpath(folderpath,"PCM_input_total.xlsx"),"rpspolicies"))
println("xlsx Files Successfully Load From $folderpath")
else
println("No xlsx file found in the directory $folderpath, try to read data from .csv files")
Expand Down Expand Up @@ -173,10 +173,10 @@ function load_data(config_set::Dict,path::AbstractString)
input_data["NIdata"]=input_data["Loaddata"][:,"NI"]

#policies
println("Reading polices")
input_data["CBPdata"]=CSV.read(joinpath(folderpath,"carbonpolices.csv"),DataFrame)
println("Reading policies")
input_data["CBPdata"]=CSV.read(joinpath(folderpath,"carbonpolicies.csv"),DataFrame)
#rpspolicydata=
input_data["RPSdata"]=CSV.read(joinpath(folderpath,"rpspolices.csv"),DataFrame)
input_data["RPSdata"]=CSV.read(joinpath(folderpath,"rpspolicies.csv"),DataFrame)
println("CSV Files Successfully Load From $folderpath")
end
end
Expand Down

0 comments on commit 911857f

Please sign in to comment.