Skip to content

Commit

Permalink
update to CommonOPF v0.4.4, clean house
Browse files Browse the repository at this point in the history
  • Loading branch information
NLaws committed Dec 23, 2024
1 parent 0deb1f9 commit 3e280af
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 28 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ MetaGraphsNext = "fa8bd995-216d-47f1-8a91-f3b68fbeb377"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"

[compat]
CommonOPF = "0.4.3"
CommonOPF = "0.4.4"
Graphs = "1.8"
JSON = "0.21"
JuMP = "1"
Expand Down
2 changes: 2 additions & 0 deletions src/model_multi_phase.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ Add variables and constraints to `m` using the values in `net`. Calls the follow
function build_bfm!(m::JuMP.AbstractModel, net::Network{MultiPhase}, ::Val{Linear})
add_linear_variables(m, net)
constrain_linear_power_balance(m, net)
# TODO finish the Linear multiphase model
# constrain_KVL_linear(m, net)
end


Expand Down
28 changes: 4 additions & 24 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,6 @@ CPF = BranchFlowModel.CommonOPF

Random.seed!(42)

# TODO alot of these methods should be in modules
function dss_voltages_pu()
d = Dict()
for b in OpenDSS.Circuit.AllBusNames()
OpenDSS.Circuit.SetActiveBus(b)
d[b] = OpenDSS.Bus.puVmagAngle()[1:2:end]
end
return d
end


function dss_voltages_mag_angle()
d = Dict()
for b in OpenDSS.Circuit.AllBusNames()
OpenDSS.Circuit.SetActiveBus(b)
d[b] = OpenDSS.Bus.VMagAngle()#[1:2:end]
end
return d
end


function build_single_phase_min_loss_model(net::CPF.Network{CPF.SinglePhase})
m = Model(Ipopt.Optimizer)
Expand Down Expand Up @@ -325,7 +305,7 @@ end
cd(work_dir)
@test(OpenDSS.Solution.Converged() == true)

dss_voltages = dss_voltages_pu()
dss_voltages = CPF.dss_voltages_pu()

net = CPF.dss_to_Network(dssfilepath)
@test net.substation_bus == "sourcebus"
Expand Down Expand Up @@ -492,7 +472,7 @@ end

@test(check_opendss_powers() == true)

dss_voltages = dss_voltages_pu()
dss_voltages = CPF.dss_voltages_pu()

net = CPF.dss_to_Network(dssfilepath)

Expand Down Expand Up @@ -596,7 +576,7 @@ end
""")
cd(work_dir)
@test(OpenDSS.Solution.Converged() == true)
dss_voltages = dss_voltages_pu()
dss_voltages = CPF.dss_voltages_pu()

for b in keys(vs)
@test abs(vs[b][1] - dss_voltages[b][1]) < 0.001
Expand Down Expand Up @@ -761,7 +741,7 @@ end
OpenDSS.dss("Solve")
@test(OpenDSS.Solution.Converged() == true)
@test(check_opendss_powers() == true)
dss_voltages = dss_voltages_pu()
dss_voltages = CPF.dss_voltages_pu()


# make the regulator work like OpenDSS
Expand Down
2 changes: 1 addition & 1 deletion test/test_linear.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ end
m = Model(HiGHS.Optimizer)

build_bfm!(m, net, Linear)

# TODO finish the linear multiphase model

end
4 changes: 2 additions & 2 deletions test/test_nlp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


m = Model(Ipopt.Optimizer)
# set_optimizer_attribute(m, "print_level", 0)
set_optimizer_attribute(m, "print_level", 0)

build_bfm!(m, net, Unrelaxed)

Expand Down Expand Up @@ -73,7 +73,7 @@
@test(OpenDSS.Solution.Converged() == true)
@test(check_opendss_powers() == true)

dss_voltages = dss_voltages_pu()
dss_voltages = CPF.dss_voltages_pu()

for b in keys(vs)
for (i, phsv) in enumerate(filter(v -> v != 0, vs[b]))
Expand Down

0 comments on commit 3e280af

Please sign in to comment.