Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update DC-OPF with correct PU and additional flow limit constraints #714

Draft
wants to merge 12 commits into
base: develop
Choose a base branch
from
Draft
9 changes: 9 additions & 0 deletions docs/src/User_Guide/model_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,13 @@ The following tables summarize the model settings parameters and their default/p
|| "full" = write the model outputs with hourly resolution.|
|| "annual" = write only the annual sum of the model outputs.|


"ComputeConflicts" => 0,
"StorageVirtualDischarge" => 1,
"ResourcesFolder" => "resources",
"ResourcePoliciesFolder" => "policy_assignments",
"SystemFolder" => "system",
"PoliciesFolder" => "policies",
"ObjScale"

The next step in configuring a GenX model is to specify the solver settings parameters using a `[solver_name]_settings.yml` file inside the `settings` folder. The solver settings parameters are solver specific and are described in the following section.
22 changes: 11 additions & 11 deletions example_systems/9_IEEE_9_bus_DC_OPF/system/Network.csv
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
,Network_zones,Network_Lines,Start_Zone,End_Zone,Line_Max_Flow_MW,transmission_path_name,distance_mile,Line_Loss_Percentage,Line_Max_Reinforcement_MW,Line_Reinforcement_Cost_per_MWyr,DerateCapRes_1,CapRes_1,CapRes_Excl_1,Angle_Limit_Rad,Line_Voltage_kV,Line_Resistance_Ohms,Line_Reactance_Ohms
BUS1,z1,1,1,4,250,BUS1_to_BUS4,0.5,0.015,500,12000,0.95,0,0,0.785398,345,0,68.5584
BUS2,z2,2,4,5,250,BUS4_to_BUS5,0.5,0.015,500,12000,0.95,0,0,0.785398,345,20.23425,109.503
BUS3,z3,3,5,6,150,BUS5_to_BUS6,0.5,0.015,500,12000,0.95,0,0,0.785398,345,46.41975,202.3425
BUS4,z4,4,3,6,300,BUS3_to_BUS6,0.5,0.015,500,12000,0.95,0,0,0.785398,345,0,69.74865
BUS5,z5,5,6,7,150,BUS6_to_BUS7,0.5,0.015,500,12000,0.95,0,0,0.785398,345,14.163975,119.9772
BUS6,z6,6,7,8,250,BUS7_to_BUS8,0.5,0.015,500,12000,0.95,0,0,0.785398,345,10.117125,85.698
BUS7,z7,7,8,2,250,BUS8_to_BUS2,0.5,0.015,500,12000,0.95,0,0,0.785398,345,0,74.390625
BUS8,z8,8,8,9,250,BUS8_to_BUS9,0.5,0.015,500,12000,0.95,0,0,0.785398,345,38.088,191.63025
BUS9,z9,9,9,4,250,BUS9_to_BUS4,0.5,0.015,500,12000,0.95,0,0,0.785398,345,11.9025,101.17125
,,10,1,6,250,BUS1_to_BUS6,0.5,0.015,500,12000,0.95,0,0,0.785398,345,11.9025,101.17125
,Network_zones,Network_Lines,Start_Zone,End_Zone,Line_Max_Flow_MW,transmission_path_name,distance_mile,Line_Loss_Percentage,Line_Max_Reinforcement_MW,Line_Reinforcement_Cost_per_MWyr,DerateCapRes_1,CapRes_1,CapRes_Excl_1,Angle_Limit_Rad,Line_Voltage_kV,Line_Resistance_Ohms,Line_Reactance_Ohms,MVA_Base,Has_Transformer,Transformer_MVA_Base,Transformer_LT_Voltage_kV_Base,Transformer_HT_Voltage_kV_Base,Transformer_LT_Reactance_Ohms,Transformer_HT_Reactance_Ohms,Transformer_LT_Turns,Transformer_HT_Turns
BUS1,z1,1,1,4,250,BUS1_to_BUS4,0.5,0.015,500,12000,0.95,0,0,0.785398,345,0,68.5584,100,0,,,,,,,
BUS2,z2,2,4,5,250,BUS4_to_BUS5,0.5,0.015,500,12000,0.95,0,0,0.785398,345,20.23425,109.503,100,1,200,150,350,70.85,177.125,150000,350000
BUS3,z3,3,5,6,150,BUS5_to_BUS6,0.5,0.015,500,12000,0.95,0,0,0.785398,345,46.41975,202.3425,100,0,,,,,,,
BUS4,z4,4,3,6,300,BUS3_to_BUS6,0.5,0.015,500,12000,0.95,0,0,0.785398,345,0,69.74865,100,1,100,350,1000,81.34,203.35,350000,1000000
BUS5,z5,5,6,7,150,BUS6_to_BUS7,0.5,0.015,500,12000,0.95,0,0,0.785398,345,14.163975,119.9772,100,1,300,400,1000,65.92,164.8,400000,1000000
BUS6,z6,6,7,8,250,BUS7_to_BUS8,0.5,0.015,500,12000,0.95,0,0,0.785398,345,10.117125,85.698,100,1,450,400,1000,87.01,217.525,400000,1000000
BUS7,z7,7,8,2,250,BUS8_to_BUS2,0.5,0.015,500,12000,0.95,0,0,0.785398,345,0,74.390625,100,1,375,100,350,78.44,196.1,100000,350000
BUS8,z8,8,8,9,250,BUS8_to_BUS9,0.5,0.015,500,12000,0.95,0,0,0.785398,345,38.088,191.63025,100,0,,,,,,,
BUS9,z9,9,9,4,250,BUS9_to_BUS4,0.5,0.015,500,12000,0.95,0,0,0.785398,345,11.9025,101.17125,100,0,,,,,,,
,,10,1,6,250,BUS1_to_BUS6,0.5,0.015,500,12000,0.95,0,0,0.785398,345,11.9025,101.17125,100,1,200,200,400,78.66,196.65,200000,400000
65 changes: 65 additions & 0 deletions src/load_inputs/load_network_data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,69 @@ function load_network_data!(setup::Dict, path::AbstractString, inputs_nw::Dict)
setup["NetworkExpansion"] = 0
end
println("Reading DC-OPF values...")
#Adding the base quantities
# Base voltage (in kV)
line_voltage_kV = to_floats(:Line_Voltage_kV)
# MVA_Base (in MVA)
MVA_Base = to_floats(:MVA_Base)
# Base reactance
line_reactance_Ohms_Base = (line_voltage_kV .^ 2) ./ MVA_Base
#if (inputs_nw["Has_Transformer"] == 1)
# Base voltage (in kV)
line_voltage_kV_trans_df = network_var[network_var[!,:Has_Transformer] .== 1, :]
line_voltage_kV_trans = collect(skipmissing(line_voltage_kV_trans_df[!, :Line_Voltage_kV]))
# MVA_Base (in MVA)
MVA_Base_trans_df = network_var[network_var[!,:Has_Transformer] .== 1, :]
MVA_Base_trans = collect(skipmissing(MVA_Base_trans_df[!, :MVA_Base]))
##Adding Transformer data
line_transformer_MVA_base = to_floats(:Transformer_MVA_Base)

##Transformer LT side data
# LT Base voltage (in kV)
transformer_lt_voltage_kV_Base = to_floats(:Transformer_LT_Voltage_kV_Base)
#Transformer LT Reactance in Ohms
line_transformer_lt_reactance = to_floats(:Transformer_LT_Reactance_Ohms)
#Transformer LT Turns
line_transformer_lt_turns = to_floats(:Transformer_LT_Turns)
# LT Base reactance
lt_reactance_Base = (transformer_lt_voltage_kV_Base .^ 2) ./ line_transformer_MVA_base
#Transformer LT Reactance in pu
transformer_lt_reactance_pu = to_floats(:Transformer_LT_Reactance_Ohms) ./ lt_reactance_Base


##Transformer HT side data
# HT Base voltage (in kV)
transformer_ht_voltage_kV_Base = to_floats(:Transformer_HT_Voltage_kV_Base)
#Transformer HT Reactance in Ohms
line_transformer_ht_reactance = to_floats(:Transformer_HT_Reactance_Ohms)
#Transformer HT Turns
line_transformer_ht_turns = to_floats(:Transformer_HT_Turns)
# HT Base reactance
ht_reactance_Base = (transformer_ht_voltage_kV_Base .^ 2) ./ line_transformer_MVA_base
#Transformer LT Reactance in pu
transformer_ht_reactance_pu = to_floats(:Transformer_HT_Reactance_Ohms) ./ ht_reactance_Base


#LT Transformer Reactance referred to HT side in Ohms
lt_reactance_referred_to_ht = ((line_transformer_ht_turns ./ line_transformer_lt_turns) .^ 2) .* line_transformer_lt_reactance
#HT Transformer Reactance referred to LT side in Ohms
ht_reactance_referred_to_lt = ((line_transformer_lt_turns ./ line_transformer_ht_turns) .^ 2) .* line_transformer_ht_reactance
#Total LT Reactance in Ohms
total_lt_reactance_ohms = line_transformer_lt_reactance + ht_reactance_referred_to_lt
#Total LT Reactance in pu
total_lt_reactance_pu = total_lt_reactance_ohms ./ lt_reactance_Base
#Total HT Reactance in Ohms
total_ht_reactance_ohms = line_transformer_ht_reactance + lt_reactance_referred_to_ht
#Total HT Reactance in pu
total_ht_reactance_pu = total_ht_reactance_ohms ./ ht_reactance_Base

#Conversion of Transformer pu reactance to system pu
total_ht_reactance_system_pu = total_ht_reactance_pu .* ((transformer_ht_voltage_kV_Base ./ line_voltage_kV_trans) .^ 2) .* (MVA_Base_trans ./ line_transformer_MVA_base)
total_lt_reactance_system_pu = total_lt_reactance_pu .* ((transformer_lt_voltage_kV_Base ./ line_voltage_kV_trans) .^ 2) .* (MVA_Base_trans ./ line_transformer_MVA_base)
println("Transformer data read successfully!")
println(total_ht_reactance_system_pu)
println(total_lt_reactance_system_pu)
#end
# Transmission line voltage (in kV)
line_voltage_kV = to_floats(:Line_Voltage_kV)
# Transmission line reactance (in Ohms)
Expand All @@ -52,6 +115,8 @@ function load_network_data!(setup::Dict, path::AbstractString, inputs_nw::Dict)
# MW = (kV)^2/Ohms
inputs_nw["pDC_OPF_coeff"] = ((line_voltage_kV .^ 2) ./ line_reactance_Ohms) /
scale_factor
#Reactance in pu
inputs_nw["pu_reactance"] = line_reactance_Ohms ./ line_reactance_Ohms_Base
end

# Maximum possible flow after reinforcement for use in linear segments of piecewise approximation
Expand Down
10 changes: 9 additions & 1 deletion src/model/core/transmission/dcopf_transmission.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,16 @@ function dcopf_transmission!(EP::Model, inputs::Dict, setup::Dict)
@constraint(EP,
cPOWER_FLOW_OPF[l = 1:L, t = 1:T],
EP[:vFLOW][l,
t]==inputs["pDC_OPF_coeff"][l] *
t]==(1 / inputs["pu_reactance"][l]) *
sum(inputs["pNet_Map"][l, z] * vANGLE[z, t] for z in 1:Z))

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change


# Maximum power flows, power flow on each transmission line cannot exceed maximum capacity of the line at any hour "t"
@constraints(EP,
begin
cMaxFlow_out_dc_opf[l = 1:L, t = 1:T], EP[:vFLOW][l, t] <= EP[:eAvail_Trans_Cap][l]
cMaxFlow_in_dc_opf[l = 1:L, t = 1:T], EP[:vFLOW][l, t] >= -EP[:eAvail_Trans_Cap][l]
end)

# Bus angle limits (except slack bus)
@constraints(EP,
Expand Down