Skip to content

Commit

Permalink
add test for multiphase lateral
Browse files Browse the repository at this point in the history
IEEE13 multiphase still not solving, probably need good bounds
  • Loading branch information
NLaws committed Jun 2, 2024
1 parent d1ae5b3 commit dc69355
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/model_multi_phase_network.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ function add_variables(m, net::Network{MultiPhase})
-0.5 * net.v0[2] + im*sqrt(3)/2 * net.v0[2];
-0.5 * net.v0[3] - im*sqrt(3)/2 * net.v0[3]
]
v0 = v0*cj(v0)
w0 = v0*cj(v0)
elseif typeof(net.v0) <: AbstractVector{<:Complex}
v0 = net.v0 * cj(net.v0)
w0 = net.v0 * cj(net.v0)
else # matrix provided
v0 = net.v0
w0 = net.v0 * cj(net.v0)
end

for t in 1:net.Ntimesteps
m[:w][t] = Dict(net.substation_bus => v0 * cj(v0))
m[:w][t] = Dict(net.substation_bus => v0)
# empty dicts for line values in each time step to fill
m[:l][t] = Dict()
m[:Sij][t] = Dict()
Expand Down
11 changes: 11 additions & 0 deletions test/data/two_line_multi_phase.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@ Conductor:
template: cond1-symmetric
length: 10
phases: [1, 2, 3]
- name: b2-lateral
busses:
- b2
- b4
phases: [1, 3]
r0: 0.766
x0: 1.944
r1: 0.301
x1: 0.627
length: 10


Load:
- bus: b3
Expand Down
43 changes: 40 additions & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ end
net = BranchFlowModel.CommonOPF.Network(joinpath("data", "two_line_multi_phase.yaml"))

m = Model(CSDP.Optimizer)
# set_attribute(m, "printlevel", 0)
# TODO add pieces of IEEE13 one at a time, starting with two phase lateral with load
build_model!(m, net)

@objective(m, Min,
Expand All @@ -220,14 +222,21 @@ end

optimize!(m)

# TODO do these vs match the eigen method values? (and should sqrt come last always?)
# TODO results methods in CommonOPF for multiphase models
vs = Dict(
k => abs.(sqrt(JuMP.value.(w)))
k => sqrt.(abs.(JuMP.value.(w)))
for (k,w) in m[:w][1]
)

Sijs = Dict(
k => abs.(JuMP.value.(w))
for (k,w) in m[:Sij][1]
k => abs.(JuMP.value.(sij))
for (k, sij) in m[:Sij][1]
)

Lijs = Dict(
k => abs.(JuMP.value.(lij))
for (k, lij) in m[:l][1]
)

# abs(5.6+im*1.2) # load magnitude per phase
Expand All @@ -239,6 +248,34 @@ end
@test S0[phs] Sijs[("b1", "b2")][phs, phs]
end

# bus b4 has no load so should have approximately same voltage as b2
for phs in [1, 3]
@test vs["b2"][phs, phs] vs["b4"][phs, phs]
end

# no phase 2 at b4
@test vs["b4"][2, :] == [0,0,0]
@test vs["b4"][:, 2] == [0,0,0]

# H = value.(m[:w][1]["b4"])

# # Step 3: Perform eigenvalue decomposition
# eig = eigen(H)

# # Eigenvalues and eigenvectors
# eigenvalues = eig.values
# eigenvectors = eig.vectors

# # Step 4: Select a non-zero eigenvalue and corresponding eigenvector
# non_zero_indices = findall(x -> abs(x) > 1e-8, eigenvalues)
# lambda_i = eigenvalues[non_zero_indices[1]]
# u_i = eigenvectors[:, non_zero_indices[1]]

# # Step 5: Construct the vector v
# v = sqrt(lambda_i) * u_i
# abs.(v)


end


Expand Down

0 comments on commit dc69355

Please sign in to comment.