From 0e224c562251b6db5a315c51dfd0da0e7fa82d02 Mon Sep 17 00:00:00 2001 From: "Chakrabarti, Sambuddha (Sam)" Date: Tue, 3 Dec 2024 18:26:09 -0500 Subject: [PATCH] Refined asymmetric flows; Debugging --- src/load_inputs/load_network_data.jl | 12 ++++++------ src/model/core/transmission/transmission.jl | 4 ++-- .../transmission/write_transmission_flows.jl | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/load_inputs/load_network_data.jl b/src/load_inputs/load_network_data.jl index 3c0c1b1fd..3de629e57 100644 --- a/src/load_inputs/load_network_data.jl +++ b/src/load_inputs/load_network_data.jl @@ -19,7 +19,7 @@ function load_network_data!(setup::Dict, path::AbstractString, inputs_nw::Dict) inputs_nw["L"] = L L_asym = 0 # Default number of asymmetrical lines if setup["asymmetrical_trans_flow_limit"] == 1 - L_asym = length(as_vector(network_var, :Asymmetrical, :Network_Lines)) #Number of asymmetrical lines + L_asym = length(filtered_vector(network_var, :Asymmetrical, :Network_Lines)) #Number of asymmetrical lines end println("Number of asymmetric lines: $L_asym") inputs_nw["L_asym"] = L_asym @@ -154,8 +154,8 @@ function load_network_data!(setup::Dict, path::AbstractString, inputs_nw::Dict) inputs_nw["EXPANSION_LINES"] = findall(inputs_nw["pMax_Line_Reinforcement"] .>= 0) inputs_nw["NO_EXPANSION_LINES"] = findall(inputs_nw["pMax_Line_Reinforcement"] .< 0) if setup["asymmetrical_trans_flow_limit"] == 1 - inputs_nw["EXPANSION_LINES_ASYM"] = findall((inputs_nw["pMax_Line_Reinforcement_Pos"] .> 0) || (inputs_nw["pMax_Line_Reinforcement_Neg"] .> 0)) - inputs_nw["NO_EXPANSION_LINES_ASYM"] = findall((inputs_nw["pMax_Line_Reinforcement_Pos"] .< 0) && (inputs_nw["pMax_Line_Reinforcement_Neg"] .< 0)) + inputs_nw["EXPANSION_LINES_ASYM"] = findall((inputs_nw["pMax_Line_Reinforcement_Pos"] .> 0) .| (inputs_nw["pMax_Line_Reinforcement_Neg"] .> 0)) + inputs_nw["NO_EXPANSION_LINES_ASYM"] = findall((inputs_nw["pMax_Line_Reinforcement_Pos"] .< 0) .& (inputs_nw["pMax_Line_Reinforcement_Neg"] .< 0)) end end @@ -240,7 +240,7 @@ function network_map_matrix_format_deprecation_warning() """ maxlog=1 end -function as_vector(network_var::DataFrame, asym_column::Symbol, col::Symbol) - asym_network_var = network_var[network_var[asym_col] .== 1, :] - return collect(skipmissing(asym_network_var[!, col])) +function filtered_vector(df::DataFrame, condition_col::Symbol, data_col::Symbol) + filtered_df = df[df[!,condition_col] .== 1, :] + return collect(skipmissing(filtered_df[!, data_col])) end \ No newline at end of file diff --git a/src/model/core/transmission/transmission.jl b/src/model/core/transmission/transmission.jl index d32af34ad..88809e461 100644 --- a/src/model/core/transmission/transmission.jl +++ b/src/model/core/transmission/transmission.jl @@ -192,14 +192,14 @@ function transmission!(EP::Model, inputs::Dict, setup::Dict) cMaxFlow_in[l = 1:L, t = 1:T], vFLOW[l, t] >= -EP[:eAvail_Trans_Cap][l] end) - #if setup["asymmetrical_trans_flow_limit"] ==1 + if setup["asymmetrical_trans_flow_limit"] ==1 # 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[l = 1:L_asym, t = 1:T], vTAUX_POS[l, t] <= EP[:eAvail_Trans_Cap_Pos][l] #Change these with Auxiliary cMaxFlow_in[l = 1:L_asym, t = 1:T], vTAUX_NEG[l, t] >= -EP[:eAvail_Trans_Cap_Neg][l] #Change these with Auxiliary end) - #end + end # Transmission loss related constraints - linear losses as a function of absolute value if TRANS_LOSS_SEGS == 1 diff --git a/src/write_outputs/transmission/write_transmission_flows.jl b/src/write_outputs/transmission/write_transmission_flows.jl index 6fde9f1b0..d92c410f5 100644 --- a/src/write_outputs/transmission/write_transmission_flows.jl +++ b/src/write_outputs/transmission/write_transmission_flows.jl @@ -8,7 +8,7 @@ function write_transmission_flows(path::AbstractString, L_asym = 0 #Default number of asymmetrical lines # Number of lines in the network if setup["asymmetrical_trans_flow_limit"] == 1 - L_asym = inputs_nw["L_asym"] #Number of transmission lines with different capacities in two directions + L_asym = inputs["L_asym"] #Number of transmission lines with different capacities in two directions end L = L_sym + L_asym # Power flows on transmission lines at each time step