Hello all,
I have posted an earlier question on coding renewable generation constraints with availability factors. I am still stuck with the problem. I have reverted back to bare basics, but i still receive keyErrors. A sample of the dispatch code is below and data is available on the link.
using JuMP, Clp
using DataFrames, CSV
#Load data
generators = DataFrame(CSV.File(joinpath(inputs_path, "plants_aggregation.csv")))
generators = select(generators, :R_ID, :plant_type, :node, :node_id, :g_max, :cost, :Conventional,:ROR, :WIND, :SOLAR)
demand_inputs = DataFrame(CSV.File(joinpath(inputs_path, "demand_2018.csv")))
demand = select(demand_inputs, :Load_z1, :Load_z2, :Load_z3, :Load_z4, :Load_z5, :Load_z6, :Load_z7, :Load_z8, :Load_z9, :Load_z10, :Load_z11)
variability = DataFrame(CSV.File(joinpath(inputs_path, "Generators_variability.csv")))
variability = variability[:,2:ncol(variability)]
network = DataFrame(CSV.File(joinpath(inputs_path, "Network.csv")))
zones = collect(skipmissing(network.Network_zones))
lines = select(network[1:9,:],
:Network_lines, :z1, :z2, :z3, :z4, :z5, :z6, :z7, :z8, :z9, :z10, :z11,
:f_max, :Line_Min_Flow_MW)
# Sets
G = generators.R_ID #all generators
T = convert(Array{Int64}, demand_inputs.time_index) #time
Z = convert(Array{Int64}, 1:11) #zones
L = convert(Array{Int64}, lines.Network_lines) #lines
#SUBSETS
C = generators.R_ID[generators.Conventional.==1] #conventional generators
WND = intersect(generators.R_ID[generators.WIND.==1], G) #wind resources
SOL = intersect(generators.R_ID[generators.SOLAR.==1], G) #solar resources
ROR = intersect(generators.R_ID[generators.ROR.==1], G) #Run-Of-River
#Define model
Dispatch_Model = Model(Clp.Optimizer)
#Decission variables
@variable(Dispatch_Model, vGEN[c in C, T] >=0) #Conventional plant generation
@variable(Dispatch_Model, vFLOW[T, L] ) #Line power flow
@variable(Dispatch_Model, vRUNOFRIVER[r in ROR, T] >=0) #run-of-river
@variable(Dispatch_Model, vSOLAR[s in SOL, T] >=0) #solar
@variable(Dispatch_Model, vWIND[w in WND, T] >=0) #wind
#Constraints
@constraint(Dispatch_Model, cMaxPower[c in C, t in T],
vGEN[c,t] <= generators[generators.R_ID .== c,:g_max][1])
#Renewable injection constraints
@constraint(Dispatch_Model, cSolarInjection[t in T, s in SOL], vSOLAR[t,s] <= generators[s,:g_max] * variability[t,s])
....
#Same constraints for wind and ROR
My main problem still lies with coding renewable generation constraints (solar, wind, and ROR). For now in the variability csv files, each renewable resource has a time series of capacity factors instead of the zonal capacity factor (my previous attempt).What I am still trying to obtain is output for my renewables (solar, wind etc,), over time and across the zones.
Thanks!
Data file: Sample_Data - Google Drive