diff --git a/test/measurement/buildUpdate.jl b/test/measurement/buildUpdate.jl index 7794f75ef..06f25a45a 100644 --- a/test/measurement/buildUpdate.jl +++ b/test/measurement/buildUpdate.jl @@ -1,8 +1,8 @@ -@testset "Build and Update Measurement Data in Per-Units" begin +@testset "Build and Update Measurements in Per-Units" begin @default(template) @default(unit) - system = powerSystem(string(path, "case14test.m")) + system = powerSystem(path * "case14test.m") device = measurement() deviceAll = measurement() @@ -27,14 +27,14 @@ varianceMagnitudeTo = 1e-2, varianceAngleTo = 1e-3, statusMagnitudeBus = 0 ) - ########## Generate Measurement Data from AC Power Flow ########## + ########## Generate Measurements from AC Power Flow ########## addVoltmeter!(system, deviceAll, analysis; noise = true) addAmmeter!(system, deviceAll, analysis) addWattmeter!(system, deviceAll, analysis) addVarmeter!(system, deviceAll, analysis) addPmu!(system, deviceAll, analysis) - ##### Test Bus Measurements ##### + # Bus Measurements volt = device.voltmeter for (key, value) in system.bus.label addVoltmeter!(system, device; bus = key, magnitude = analysis.voltage.magnitude[value]) @@ -64,7 +64,7 @@ @test device.pmu.angle.status[end] == 1 end - ##### Test Branch Measurements ##### + # Branch Measurements cnt = 1 amp = device.ammeter watt = device.wattmeter @@ -142,7 +142,7 @@ end end - ##### Test Update Voltmeter ##### + # Update Voltmeters updateVoltmeter!( system, device; label = "Voltmeter 3", magnitude = 0.2, variance = 1e-6, status = 0 @@ -160,7 +160,7 @@ @test device.voltmeter.magnitude.variance[5] == 1e-10 @test device.voltmeter.magnitude.status[5] == 1 - ##### Test Update Ammeter ##### + # Update Ammeters updateAmmeter!( system, device; label = "Ammeter 3", magnitude = 0.4, variance = 1e-8, status = 0 ) @@ -177,7 +177,7 @@ @test device.ammeter.magnitude.variance[8] == 1e-10 @test device.ammeter.magnitude.status[8] == 1 - ##### Test Update Wattmeter ##### + # Update Wattmeters updateWattmeter!(system, device; label = "4", active = 0.5, variance = 1e-2, status = 0) @test device.wattmeter.active.mean[4] == 0.5 @test device.wattmeter.active.variance[4] == 1e-2 @@ -192,7 +192,7 @@ @test device.wattmeter.active.variance[14] == 1e-10 @test device.wattmeter.active.status[14] == 1 - ##### Test Update Varmeter ##### + # Update Varmeters updateVarmeter!(system, device; label = "5", reactive = 1.5, variance = 1e-1, status = 0) @test device.varmeter.reactive.mean[5] == 1.5 @test device.varmeter.reactive.variance[5] == 1e-1 @@ -207,7 +207,7 @@ @test device.varmeter.reactive.variance[16] == 1e-10 @test device.varmeter.reactive.status[16] == 1 - ##### Test Update PMU ##### + # Update PMUs updatePmu!( system, device; label = "4 PMU", magnitude = 0.1, angle = 0.2, varianceMagnitude = 1e-6, varianceAngle = 1e-7, statusMagnitude = 0, statusAngle = 1 @@ -234,7 +234,7 @@ @test device.pmu.angle.status[5] == 0 end -@testset "Build and Update Measurement Data in SI Units" begin +@testset "Build and Update Measurements in SI Units" begin @default(template) @default(unit) @@ -255,14 +255,14 @@ end addGenerator!(system; bus = 1) baseCurrent = system.base.power.value * system.base.power.prefix / (fn * 0.23 * 10^6) - ##### Test Voltmeter Data ##### + # Voltmeter Data addVoltmeter!(system, device; bus = 1, magnitude = 126.5 / fn, variance = 126.5 / fn) addVoltmeter!(system, device; bus = 1, magnitude = 126.5 / fn, variance = 1e-60 / fn, noise = true) @test device.voltmeter.magnitude.mean[1] == system.bus.voltage.magnitude[1] @test device.voltmeter.magnitude.variance[1] == system.bus.voltage.magnitude[1] @test device.voltmeter.magnitude.mean[2] == system.bus.voltage.magnitude[1] - ##### Test Ammeter Data ##### + # Ammeter Data addAmmeter!(system, device; from = 1, magnitude = 102.5, variance = 102.5) addAmmeter!(system, device; from = 1, magnitude = 102.5, variance = 1e-60, noise = true) @test device.ammeter.magnitude.mean[1] ≈ (102.5 / baseCurrent) atol = 1e-15 @@ -275,7 +275,7 @@ end @test device.ammeter.magnitude.variance[3] ≈ (20 / baseCurrent) atol = 1e-15 @test device.ammeter.magnitude.mean[4] ≈ (20 / baseCurrent) atol = 1e-15 - ##### Test Wattmeter Data ##### + # Wattmeter Data addWattmeter!(system, device; bus = 1, active = 20.5, variance = 20.5) addWattmeter!(system, device; bus = 1, active = 20.5, variance = 1e-60, noise = true) @test device.wattmeter.active.mean[1] == system.bus.demand.active[1] @@ -294,7 +294,7 @@ end @test device.wattmeter.active.variance[5] == system.bus.demand.active[1] @test device.wattmeter.active.mean[6] == system.bus.demand.active[1] - ##### Test Varmeter Data ##### + # Varmeter Data addVarmeter!(system, device; bus = 1, reactive = 11.2, variance = 11.2, noise = false) addVarmeter!(system, device; bus = 1, reactive = 11.2, variance = 1e-60, noise = true) @test device.varmeter.reactive.mean[1] == system.bus.demand.reactive[1] @@ -313,7 +313,7 @@ end @test device.varmeter.reactive.variance[5] == system.bus.demand.reactive[1] @test device.varmeter.reactive.mean[6] == system.bus.demand.reactive[1] - ##### Test PMU Data ##### + # PMU Data addPmu!( system, device; bus = 2, magnitude = 95 / fn, angle = 2.4, varianceMagnitude = 95 / fn, varianceAngle = 2.4, noise = false @@ -359,7 +359,7 @@ end @test device.pmu.angle.variance[5] == 3 @test device.pmu.angle.mean[6] == 3 - ##### Test Multiple Labels ##### + # Multiple Labels device = measurement() @voltmeter(label = "!") @@ -377,8 +377,8 @@ end @default(template) @labels(Integer) - ########## Generate Measurement Data from AC Power Flow ########## - system = powerSystem(string(path, "case14test.m")) + ########## Generate Measurements from AC Power Flow ########## + system = powerSystem(path * "case14test.m") device = measurement() analysis = newtonRaphson(system) @@ -394,7 +394,7 @@ end stateVariable = 2 * system.bus.number - 1 - ##### Test Set of Voltmeters ##### + # Set of Voltmeters addVoltmeter!(system, device, analysis) statusVoltmeter!(system, device; inservice = 10) @@ -406,7 +406,7 @@ end statusVoltmeter!(system, device; redundancy = 0.5) @test sum(device.voltmeter.magnitude.status) == round(0.5 * stateVariable) - ##### Test Set of Ammeters ##### + # Set of Ammeters addAmmeter!(system, device, analysis; noise = true) statusAmmeter!(system, device; inservice = 18) @@ -431,7 +431,7 @@ end @test sum(device.ammeter.magnitude.status[layout.from]) == round(0.5 * stateVariable) @test sum(device.ammeter.magnitude.status[layout.to]) == round(0.2 * stateVariable) - ##### Test Set of Wattmeters ##### + # Set of Wattmeters addWattmeter!(system, device, analysis; noise = true) statusWattmeter!(system, device; inservice = 14) @@ -465,7 +465,7 @@ end @test sum(device.wattmeter.active.status[layout.from]) == round(0.3 * stateVariable) @test sum(device.wattmeter.active.status[layout.to]) == round(0.4 * stateVariable) - ##### Test Set of Varmeters ##### + # Set of Varmeters addVarmeter!(system, device, analysis; noise = true) statusVarmeter!(system, device; inservice = 1) @@ -497,7 +497,7 @@ end @test sum(device.varmeter.reactive.status[layout.from]) == round(0.1 * stateVariable) @test sum(device.varmeter.reactive.status[layout.to]) == round(0.3 * stateVariable) - ##### Test Set of PMUs ##### + # Set of PMUs addPmu!(system, device, analysis; noise = true) statusPmu!(system, device; inservice = 10) @@ -533,7 +533,7 @@ end @test sum(device.pmu.magnitude.status[layout.from]) == round(0.2 * stateVariable) @test sum(device.pmu.magnitude.status[layout.to]) == round(0.4 * stateVariable) - ##### Test Measurement ##### + # Measurements status!(system, device; inservice = 40) @test device.pmu.magnitude.status == device.pmu.angle.status @test sum(device.voltmeter.magnitude.status) + sum(device.ammeter.magnitude.status) + @@ -553,7 +553,7 @@ end sum(device.pmu.magnitude.status) == round(3.1 * stateVariable) end -@testset "Build Measurement Data in Per-Units Using Macros" begin +@testset "Build Measurements in Per-Units Using Macros" begin @default(template) @default(unit) @@ -567,7 +567,7 @@ end ########## Voltmeter Macro ########## @voltmeter(label = "Voltmeter ?", variance = 1e-2, status = 0, noise = true) - #### Test Voltmeter Data #### + # Voltmeter Data addVoltmeter!(system, device; bus = "Bus 1", magnitude = 1.0) @test device.voltmeter.label["Voltmeter 1"] == 1 @test device.voltmeter.magnitude.mean[1] != 1.0 @@ -589,7 +589,7 @@ end statusFrom = 1, statusTo = 0, noise = true ) - ####### Test From-bus Ammeter Data ####### + # From-bus Ammeter Data addAmmeter!(system, device; from = "Branch 1", magnitude = 1.0) @test device.ammeter.label["Ammeter 1"] == 1 @test device.ammeter.magnitude.mean[1] != 1.0 @@ -605,7 +605,7 @@ end @test device.ammeter.magnitude.variance[2] == 1e-4 @test device.ammeter.magnitude.status[2] == 0 - ##### Test To-bus Ammeter Data ##### + # To-bus Ammeter Data addAmmeter!(system, device; to = "Branch 1", magnitude = 2.0) @test device.ammeter.label["Ammeter 3"] == 3 @test device.ammeter.magnitude.mean[3] != 2.0 @@ -627,7 +627,7 @@ end varianceTo = 1e-3, statusBus = 0, statusFrom = 1, statusTo = 0, noise = true ) - ##### Test Bus Wattmeter Data ##### + # Bus Wattmeter Data addWattmeter!(system, device; bus = "Bus 1", active = 1.0) @test device.wattmeter.label["Wattmeter 1"] == 1 @test device.wattmeter.active.mean[1] != 1.0 @@ -643,7 +643,7 @@ end @test device.wattmeter.active.variance[2] == 1 @test device.wattmeter.active.status[2] == 1 - ##### Test From-bus Wattmeter Data ##### + # From-bus Wattmeter Data addWattmeter!(system, device; from = "Branch 1", active = 5.0) @test device.wattmeter.label["Wattmeter 3"] == 3 @test device.wattmeter.active.mean[3] != 5.0 @@ -659,7 +659,7 @@ end @test device.wattmeter.active.variance[4] == 2 @test device.wattmeter.active.status[4] == 0 - ##### Test To-bus Wattmeter Data ##### + # To-bus Wattmeter Data addWattmeter!(system, device; to = "Branch 1", active = 6.0) @test device.wattmeter.label["Wattmeter 5"] == 5 @test device.wattmeter.active.mean[5] != 6.0 @@ -681,7 +681,7 @@ end varianceTo = 3, statusBus = 1, statusFrom = 0, statusTo = 1, noise = true ) - ##### Test Bus Varmeter Data ##### + # Bus Varmeter Data addVarmeter!(system, device; bus = "Bus 1", reactive = 1.1) @test device.varmeter.label["Varmeter 1"] == 1 @test device.varmeter.reactive.mean[1] != 1.1 @@ -697,7 +697,7 @@ end @test device.varmeter.reactive.variance[2] == 10 @test device.varmeter.reactive.status[2] == 0 - ##### Test From-bus Varmeter Data ##### + # From-bus Varmeter Data addVarmeter!(system, device; from = "Branch 1", reactive = 5.1) @test device.varmeter.label["Varmeter 3"] == 3 @test device.varmeter.reactive.mean[3] != 5.1 @@ -713,7 +713,7 @@ end @test device.varmeter.reactive.variance[4] == 20 @test device.varmeter.reactive.status[4] == 1 - ##### Test To-bus Varmeter Data ##### + # To-bus Varmeter Data addVarmeter!(system, device; to = "Branch 1", reactive = 6.1) @test device.varmeter.label["Varmeter 5"] == 5 @test device.varmeter.reactive.mean[5] != 6.1 @@ -738,7 +738,7 @@ end varianceMagnitudeTo = 50, varianceAngleTo = 60, statusMagnitudeTo = 0, statusAngleTo = 0) - ##### Test Bus PMU Data ##### + # Bus PMU Data addPmu!(system, device; bus = "Bus 1", magnitude = 2, angle = 1) @test device.pmu.label["PMU 1"] == 1 @test device.pmu.magnitude.mean[1] != 2 @@ -766,7 +766,7 @@ end @test device.pmu.layout.polar[2] == false @test device.pmu.layout.correlated[2] == false - ##### Test From-bus PMU Data ##### + # From-bus PMU Data addPmu!(system, device; from = "Branch 1", magnitude = 5, angle = 6) @test device.pmu.label["PMU 3"] == 3 @test device.pmu.magnitude.mean[3] != 5 @@ -793,7 +793,7 @@ end @test device.pmu.layout.polar[4] == false @test device.pmu.layout.correlated[4] == false - ##### Test To-bus PMU Data ##### + # To-bus PMU Data addPmu!(system, device; to = "Branch 1", magnitude = 500, angle = 600) @test device.pmu.label["PMU 5"] == 5 @test device.pmu.magnitude.mean[5] != 500 @@ -821,7 +821,7 @@ end @test device.pmu.layout.correlated[6] == false end -@testset "Build Measurement Data in SI Units Using Macros" begin +@testset "Build Measurements in SI Units Using Macros" begin @default(unit) @default(template) @@ -838,14 +838,14 @@ end addBus!(system; label = "Bus 2", base = 100) addBranch!(system; label = "Branch 1", from = "Bus 1", to = "Bus 2", reactance = 0.12) - ##### Test Voltmeter Macro ##### + # Voltmeter Macro @voltmeter(label = "Voltmeter ?", variance = 1 / sqrt(3)) addVoltmeter!(system, device; bus = "Bus 1", magnitude = 100 / sqrt(3)) @test device.voltmeter.magnitude.mean[1] ≈ 1.0 @test device.voltmeter.magnitude.variance[1] ≈ 1e-2 - ##### Test Ammeter Macro ##### + # Ammeter Macro @ammeter( label = "Ammeter ?", varianceFrom = 1e-2 * ((100 * 10^6) / (sqrt(3) * 100 * 10^3)) @@ -858,21 +858,21 @@ end @test device.ammeter.magnitude.mean[1] ≈ 1.0 @test device.ammeter.magnitude.variance[1] ≈ 1e-2 - ##### Test Wattmeter Macro ##### + # Wattmeter Macro @wattmeter(label = "Wattmeter ?", varianceBus = 10) addWattmeter!(system, device; bus = "Bus 1", active = 100) @test device.wattmeter.active.mean[1] == 1.0 @test device.wattmeter.active.variance[1] == 1e-1 - ##### Test Varmeter Macro ##### + # Varmeter Macro @varmeter(label = "Varmeter ?", varianceBus = 100) addVarmeter!(system, device; bus = "Bus 1", reactive = 110) @test device.varmeter.reactive.mean[1] == 1.1 @test device.varmeter.reactive.variance[1] == 1 - ##### Test PMU Macro ##### + # PMU Macro @pmu( label = "PMU ?", varianceMagnitudeBus = 1e3 / sqrt(3), varianceAngleBus = 20 * 180 / pi, varianceMagnitudeFrom = 30 * ((100 * 10^6) / (sqrt(3) * 100 * 10^3)), @@ -895,7 +895,7 @@ end @test device.pmu.angle.variance[2] ≈ 40 end -@testset "Test Errors and Messages" begin +@testset "Errors and Messages" begin @default(unit) @default(template) system = powerSystem() @@ -918,7 +918,7 @@ end addVarmeter!(system, device; label = "Var 1", from = "Branch 1", reactive = 1) addPmu!(system, device; label = "PMU 1", bus = "Bus 1", magnitude = 1, angle = 1) - ##### Test Voltmeter Errors ##### + # Voltmeter Errors err = ErrorException( "The status 2 is not allowed; it should be in-service (1) or out-of-service (0)." ) @@ -929,7 +929,7 @@ end @test_throws LoadError @eval @voltmeter(label = "Voltmeter ?", means = 1) - ##### Test Ammeter Errors ##### + # Ammeter Errors err = ErrorException("The label Amm 1 is not unique.") @test_throws err addAmmeter!(system, device; label = "Amm 1", from = "Branch 1", magnitude = 1) @@ -944,7 +944,7 @@ end @test_throws LoadError @eval @ammeter(label = "Ammeter ?", means = 1) - ##### Test Wattmeter Errors ##### + # Wattmeter Errors err = ErrorException("The label Watt 1 is not unique.") @test_throws err addWattmeter!(system, device; label = "Watt 1", from = "Branch 1", active = 1) @@ -959,7 +959,7 @@ end @test_throws LoadError @eval @wattmeter(label = "Wattmeter ?", means = 1) - ##### Test Varmeter Errors ##### + # Varmeter Errors err = ErrorException("The label Var 1 is not unique.") @test_throws err addVarmeter!(system, device; label = "Var 1", from = "Branch 1", reactive = 1) @@ -971,7 +971,7 @@ end @test_throws LoadError @eval @varmeter(label = "Varmeter ?", means = 1) - ##### Test PMU Errors ##### + # PMU Errors err = ErrorException("The label PMU 1 is not unique.") @test_throws err addPmu!(system, device; label = "PMU 1", bus = "Bus 1", magnitude = 1, angle = 1) @@ -980,7 +980,7 @@ end @test_throws LoadError @eval @pmu(label = "PMU ?", means = 1) - ##### Test Configuration Errors ##### + # Configuration Errors err = ErrorException( "The total number of available devices is less than the " * "requested number for a status change." @@ -991,7 +991,7 @@ end @test_throws err statusAmmeter!(system, device; inserviceFrom = 12) @test_throws err statusPmu!(system, device; inserviceBus = 12) - ##### Test Load Errors ##### + # Load Errors err = DomainError(".m", "The extension .m is not supported.") @test_throws err measurement("case14.m") end \ No newline at end of file diff --git a/test/measurement/loadSave.jl b/test/measurement/loadSave.jl index 4f39fb113..468567bc8 100644 --- a/test/measurement/loadSave.jl +++ b/test/measurement/loadSave.jl @@ -1,6 +1,6 @@ -@testset "Load and Save Measurement Data with String Labels" begin +@testset "Load and Save Measurements with String Labels" begin ########## Build Measurement Data ########## - system = powerSystem(string(path, "case14test.m")) + system = powerSystem(path * "case14test.m") device = measurement() @voltmeter(label = "Voltmeter ?") @@ -35,10 +35,10 @@ ) ########## Save Measurement Data ########## - saveMeasurement(device; path = string(path, "measurement14.h5")) + saveMeasurement(device; path = path * "measurement14.h5") ########## Load Measurement Data ########## - hdf5 = measurement(string(path, "measurement14.h5")) + hdf5 = measurement(path * "measurement14.h5") ##### Test Measurement Data ##### compstruct(device.voltmeter, hdf5.voltmeter) @@ -48,11 +48,11 @@ compstruct(device.pmu, hdf5.pmu) end -@testset "Load and Save Measurement Data with Integer Labels" begin +@testset "Load and Save Measurements with Integer Labels" begin @labels(Integer) ########## Build Measurement Data ########## - system = powerSystem(string(path, "case14test.m")) + system = powerSystem(path * "case14test.m") device = measurement() addVoltmeter!(system, device; bus = 1, magnitude = 1.1, noise = true, status = 0) @@ -86,10 +86,10 @@ end ) ########## Save Measurement Data ########## - saveMeasurement(device; path = string(path, "measurement14Int.h5")) + saveMeasurement(device; path = path * "measurement14Int.h5") ########## Load Measurement Data ########## - hdf5 = measurement(string(path, "measurement14Int.h5")) + hdf5 = measurement(path * "measurement14Int.h5") ##### Test Measurement Data ##### compstruct(device.voltmeter, hdf5.voltmeter) diff --git a/test/optimalPowerFlow/analysis.jl b/test/optimalPowerFlow/analysis.jl index 641aef9d0..b32ac0d21 100644 --- a/test/optimalPowerFlow/analysis.jl +++ b/test/optimalPowerFlow/analysis.jl @@ -1,6 +1,6 @@ -system14 = powerSystem(string(path, "case14optimal.m")) +system14 = powerSystem(path * "case14optimal.m") @testset "AC Optimal Power Flow" begin - matpwr14 = h5read(string(path, "results.h5"), "case14optimal/acOptimalPowerFlow") + matpwr14 = h5read(path * "results.h5", "case14optimal/acOptimalPowerFlow") ########## IEEE 14-bus Test Case ########## analysis = acOptimalPowerFlow(system14, Ipopt.Optimizer) @@ -13,11 +13,11 @@ system14 = powerSystem(string(path, "case14optimal.m")) voltage = analysis.voltage current = analysis.current - ##### Test Voltages ##### + # Test Voltages @test voltage.magnitude ≈ matpwr14["voltageMagnitude"] atol = 1e-6 @test voltage.angle ≈ matpwr14["voltageAngle"] atol = 1e-6 - ##### Test Powers ##### + # Test Powers @test power.injection.active ≈ matpwr14["injectionActive"] atol = 1e-6 @test power.injection.reactive ≈ matpwr14["injectionReactive"] atol = 1e-6 @test power.supply.active ≈ matpwr14["supplyActive"] atol = 1e-6 @@ -34,28 +34,28 @@ system14 = powerSystem(string(path, "case14optimal.m")) @test power.generator.active ≈ matpwr14["generatorActive"] atol = 1e-6 @test power.generator.reactive ≈ matpwr14["generatorReactive"] atol = 1e-6 - ##### Test Currents ##### + # Test Currents branch = system14.branch to = branch.layout.to from = branch.layout.from - Si = (complex.(power.injection.active, power.injection.reactive)) + Si = complex.(power.injection.active, power.injection.reactive) Vi = voltage.magnitude .* cis.(voltage.angle) @test current.injection.magnitude .* cis.(-current.injection.angle) ≈ Si ./ Vi - Sij = (complex.(power.from.active, power.from.reactive)) + Sij = complex.(power.from.active, power.from.reactive) Vi = voltage.magnitude[from] .* cis.(voltage.angle[from]) @test current.from.magnitude .* cis.(-current.from.angle) ≈ Sij ./ Vi - Sji = (complex.(power.to.active, power.to.reactive)) - Vj = (voltage.magnitude[to] .* cis.(voltage.angle[to])) + Sji = complex.(power.to.active, power.to.reactive) + Vj = voltage.magnitude[to] .* cis.(voltage.angle[to]) @test current.to.magnitude .* cis.(-current.to.angle) ≈ Sji ./ Vj ratio = (1 ./ branch.parameter.turnsRatio) .* cis.(-branch.parameter.shiftAngle) Sijb = complex.(power.series.active, power.series.reactive) @test current.series.magnitude .* cis.(-current.series.angle) ≈ Sijb ./ (ratio .* Vi - Vj) - ##### Test Specific Bus Powers and Currents ##### + # Test Specific Bus Powers and Currents for (key, value) in system14.bus.label active, reactive = injectionPower(system14, analysis; label = key) @test active ≈ power.injection.active[value] @@ -74,7 +74,7 @@ system14 = powerSystem(string(path, "case14optimal.m")) @test angle ≈ current.injection.angle[value] end - ##### Test Specific Branch Powers and Currents ##### + # Test Specific Branch Powers and Currents for (key, value) in system14.branch.label active, reactive = fromPower(system14, analysis; label = key) @test active ≈ power.from.active[value] @@ -105,31 +105,46 @@ system14 = powerSystem(string(path, "case14optimal.m")) @test angle ≈ current.series.angle[value] end - ##### Test Specific Generator Powers ##### + # Test Specific Generator Powers for (key, value) in system14.generator.label active, reactive = generatorPower(system14, analysis; label = key) @test active ≈ power.generator.active[value] @test reactive ≈ power.generator.reactive[value] end - ##### Active Power Flow Constraints ##### - matpwr14 = h5read(string(path, "results.h5"), "case14optimal/acOptimalPowerFlowActive") + # Apparent Power Native Flow Constraints + system14.branch.flow.type .= 2 + + analysis = acOptimalPowerFlow(system14, Ipopt.Optimizer) + set_silent(analysis.method.jump) + solve!(system14, analysis) + + # Test Voltages + @test analysis.voltage.magnitude ≈ matpwr14["voltageMagnitude"] atol = 1e-6 + @test analysis.voltage.angle ≈ matpwr14["voltageAngle"] atol = 1e-6 + + # Test Powers + @test analysis.power.generator.active ≈ matpwr14["generatorActive"] atol = 1e-6 + @test analysis.power.generator.reactive ≈ matpwr14["generatorReactive"] atol = 1e-6 + + # Active Power Flow Constraints + matpwr14 = h5read(path * "results.h5", "case14optimal/acOptimalPowerFlowActive") system14.branch.flow.type .= 1 analysis = acOptimalPowerFlow(system14, Ipopt.Optimizer) set_silent(analysis.method.jump) solve!(system14, analysis) - ##### Test Voltages ##### + # Test Voltages @test analysis.voltage.magnitude ≈ matpwr14["voltageMagnitude"] atol = 1e-6 @test analysis.voltage.angle ≈ matpwr14["voltageAngle"] atol = 1e-6 - ##### Test Powers ##### + # Test Powers @test analysis.power.generator.active ≈ matpwr14["generatorActive"] atol = 1e-6 @test analysis.power.generator.reactive ≈ matpwr14["generatorReactive"] atol = 1e-6 - ##### Current Magnitude Flow Constraints ##### - matpwr14 = h5read(string(path, "results.h5"), "case14optimal/acOptimalPowerFlowCurrent") + # Current Magnitude Native Flow Constraints + matpwr14 = h5read(path * "results.h5", "case14optimal/acOptimalPowerFlowCurrent") system14.branch.flow.type .= 4 analysis = acOptimalPowerFlow(system14, Ipopt.Optimizer) @@ -137,20 +152,36 @@ system14 = powerSystem(string(path, "case14optimal.m")) solve!(system14, analysis) solve!(system14, analysis) - ##### Test Voltages ##### + # Test Voltages + @test analysis.voltage.magnitude ≈ matpwr14["voltageMagnitude"] atol = 1e-6 + @test analysis.voltage.angle ≈ matpwr14["voltageAngle"] atol = 1e-6 + + # Test Powers + @test analysis.power.generator.active ≈ matpwr14["generatorActive"] atol = 1e-6 + @test analysis.power.generator.reactive ≈ matpwr14["generatorReactive"] atol = 1e-6 + + # Current Magnitude Squared Flow Constraints + system14.branch.flow.type .= 5 + + analysis = acOptimalPowerFlow(system14, Ipopt.Optimizer) + set_silent(analysis.method.jump) + solve!(system14, analysis) + solve!(system14, analysis) + + # Test Voltages @test analysis.voltage.magnitude ≈ matpwr14["voltageMagnitude"] atol = 1e-6 @test analysis.voltage.angle ≈ matpwr14["voltageAngle"] atol = 1e-6 - ##### Test Powers ##### + # Test Powers @test analysis.power.generator.active ≈ matpwr14["generatorActive"] atol = 1e-6 @test analysis.power.generator.reactive ≈ matpwr14["generatorReactive"] atol = 1e-6 end -system14 = powerSystem(string(path, "case14test.m")) -system30 = powerSystem(string(path, "case30test.m")) +system14 = powerSystem(path * "case14test.m") +system30 = powerSystem(path * "case30test.m") @testset "DC Optimal Power Flow" begin - matpwr14 = h5read(string(path, "results.h5"), "case14test/dcOptimalPowerFlow") - matpwr30 = h5read(string(path, "results.h5"), "case30test/dcOptimalPowerFlow") + matpwr14 = h5read(path * "results.h5", "case14test/dcOptimalPowerFlow") + matpwr30 = h5read(path * "results.h5", "case30test/dcOptimalPowerFlow") ########## IEEE 14-bus Test Case ########## dcModel!(system14) @@ -159,17 +190,17 @@ system30 = powerSystem(string(path, "case30test.m")) solve!(system14, analysis) power!(system14, analysis) - ##### Test Voltage Angles ##### + # Test Voltage Angles @test analysis.voltage.angle ≈ matpwr14["voltage"] atol = 1e-6 - ##### Test Active Powers ##### + # Test Active Powers @test analysis.power.injection.active ≈ matpwr14["injection"] atol = 1e-6 @test analysis.power.supply.active ≈ matpwr14["supply"] atol = 1e-6 @test analysis.power.from.active ≈ matpwr14["from"] atol = 1e-6 @test analysis.power.to.active ≈ -matpwr14["from"] atol = 1e-6 @test analysis.power.generator.active ≈ matpwr14["generator"] atol = 1e-6 - ##### Test Specific Bus Active Powers ##### + # Test Specific Bus Active Powers for (key, value) in system14.bus.label injection = injectionPower(system14, analysis; label = key) supply = supplyPower(system14, analysis; label = key) @@ -178,7 +209,7 @@ system30 = powerSystem(string(path, "case30test.m")) @test supply ≈ analysis.power.supply.active[value] end - ##### Test Specific Branch Active Powers ##### + # Test Specific Branch Active Powers for (key, value) in system14.branch.label from = fromPower(system14, analysis; label = key) to = toPower(system14, analysis; label = key) @@ -187,7 +218,7 @@ system30 = powerSystem(string(path, "case30test.m")) @test to ≈ analysis.power.to.active[value] end - ##### Test Specific Generator Active Powers ##### + # Test Specific Generator Active Powers for (key, value) in system14.generator.label generator = generatorPower(system14, analysis; label = key) @test generator ≈ analysis.power.generator.active[value] @@ -200,17 +231,17 @@ system30 = powerSystem(string(path, "case30test.m")) solve!(system30, analysis) power!(system30, analysis) - ##### Test Voltage Angles ##### + # Test Voltage Angles @test analysis.voltage.angle ≈ matpwr30["voltage"] atol = 1e-10 - ##### Test Active Powers ##### + # Test Active Powers @test analysis.power.injection.active ≈ matpwr30["injection"] atol = 1e-6 @test analysis.power.supply.active ≈ matpwr30["supply"] atol = 1e-10 @test analysis.power.from.active ≈ matpwr30["from"] atol = 1e-10 @test analysis.power.to.active ≈ -matpwr30["from"] atol = 1e-10 @test analysis.power.generator.active ≈ matpwr30["generator"] atol = 1e-10 - ##### Test Specific Bus Active Powers ##### + # Test Specific Bus Active Powers for (key, value) in system30.bus.label injection = injectionPower(system30, analysis; label = key) supply = supplyPower(system30, analysis; label = key) @@ -219,7 +250,7 @@ system30 = powerSystem(string(path, "case30test.m")) @test supply ≈ analysis.power.supply.active[value] end - ##### Test Specific Branch Active Powers ##### + # Test Specific Branch Active Powers for (key, value) in system30.branch.label from = fromPower(system30, analysis; label = key) to = toPower(system30, analysis; label = key) @@ -228,14 +259,14 @@ system30 = powerSystem(string(path, "case30test.m")) @test to ≈ analysis.power.to.active[value] end - ##### Test Specific Generator Active Powers ##### + # Test Specific Generator Active Powers for (key, value) in system30.generator.label generator = generatorPower(system30, analysis; label = key) @test generator ≈ analysis.power.generator.active[value] end end -@testset "Test Errors and Messages" begin +@testset "Errors and Messages" begin @default(unit) @default(template) system = powerSystem() @@ -279,19 +310,19 @@ end set_silent(analysis.method.jump) solve!(system14, analysis) - ##### Print Bus Constraint Data ##### + # Print Bus Constraint Data @capture_out printBusConstraint(system14, analysis; delimiter = "") @capture_out printBusConstraint(system14, analysis; style = false) @capture_out printBusConstraint(system14, analysis; label = 1, header = true) @capture_out printBusConstraint(system14, analysis; label = 2, footer = true) - ##### Print Branch Constraint Data ##### + # Print Branch Constraint Data @capture_out printBranchConstraint(system14, analysis; delimiter = "") @capture_out printBranchConstraint(system14, analysis; label = 5, header = true) @capture_out printBranchConstraint(system14, analysis; label = 6, footer = true) @capture_out printBranchConstraint(system14, analysis; style = false) - ##### Print Generator Constraint Data ##### + # Print Generator Constraint Data @capture_out printGeneratorConstraint(system14, analysis; delimiter = "") @capture_out printGeneratorConstraint(system14, analysis; label = 5, header = true) @capture_out printGeneratorConstraint(system14, analysis; label = 6, footer = true) @@ -307,13 +338,13 @@ end @capture_out printBusConstraint(system14, analysis; label = 1, header = true) @capture_out printBusConstraint(system14, analysis; label = 2, footer = true) - ##### Print Branch Constraint Data ##### + # Print Branch Constraint Data @capture_out printBranchConstraint(system14, analysis; delimiter = "") @capture_out printBranchConstraint(system14, analysis; label = 5, header = true) @capture_out printBranchConstraint(system14, analysis; label = 6, footer = true) @capture_out printBranchConstraint(system14, analysis; style = false) - ##### Print Generator Constraint Data ##### + # Print Generator Constraint Data @capture_out printGeneratorConstraint(system14, analysis; delimiter = "") @capture_out printGeneratorConstraint(system14, analysis; label = 5, header = true) @capture_out printGeneratorConstraint(system14, analysis; label = 6, footer = true) @@ -330,19 +361,19 @@ end set_silent(analysis.method.jump) solve!(system14, analysis) - ##### Print Bus Constraint Data ##### + # Print Bus Constraint Data @capture_out printBusConstraint(system14, analysis; delimiter = "") @capture_out printBusConstraint(system14, analysis; style = false) @capture_out printBusConstraint(system14, analysis; label = 1, header = true) @capture_out printBusConstraint(system14, analysis; label = 2, footer = true) - ##### Print Branch Constraint Data ##### + # Print Branch Constraint Data @capture_out printBranchConstraint(system14, analysis; delimiter = "") @capture_out printBranchConstraint(system14, analysis; label = 5, header = true) @capture_out printBranchConstraint(system14, analysis; label = 6, footer = true) @capture_out printBranchConstraint(system14, analysis; style = false) - ##### Print Generator Constraint Data ##### + # Print Generator Constraint Data @capture_out printGeneratorConstraint(system14, analysis; delimiter = "") @capture_out printGeneratorConstraint(system14, analysis; label = 5, header = true) @capture_out printGeneratorConstraint(system14, analysis; label = 6, footer = true) @@ -358,13 +389,13 @@ end @capture_out printBusConstraint(system14, analysis; label = 1, header = true) @capture_out printBusConstraint(system14, analysis; label = 2, footer = true) - ##### Print Branch Constraint Data ##### + # Print Branch Constraint Data @capture_out printBranchConstraint(system14, analysis; delimiter = "") @capture_out printBranchConstraint(system14, analysis; label = 5, header = true) @capture_out printBranchConstraint(system14, analysis; label = 6, footer = true) @capture_out printBranchConstraint(system14, analysis; style = false) - ##### Print Generator Constraint Data ##### + # Print Generator Constraint Data @capture_out printGeneratorConstraint(system14, analysis; delimiter = "") @capture_out printGeneratorConstraint(system14, analysis; label = 5, header = true) @capture_out printGeneratorConstraint(system14, analysis; label = 6, footer = true) diff --git a/test/optimalPowerFlow/reusing.jl b/test/optimalPowerFlow/reusing.jl index 3e52f98f7..34e8f7cfd 100644 --- a/test/optimalPowerFlow/reusing.jl +++ b/test/optimalPowerFlow/reusing.jl @@ -4,7 +4,7 @@ @labels(Integer) ########## First Pass ########## - system = powerSystem(string(path, "case14optimal.m")) + system = powerSystem(path * "case14optimal.m") updateBus!( system; @@ -53,8 +53,8 @@ solve!(system, analysis) power!(system, analysis) - ##### Reuse AC Optimal Power Flow Model ##### - resystem = powerSystem(string(path, "case14optimal.m")) + # Reuse AC Optimal Power Flow Model + resystem = powerSystem(path * "case14optimal.m") acModel!(resystem) reusing = acOptimalPowerFlow(resystem, Ipopt.Optimizer) @@ -117,12 +117,12 @@ solve!(resystem, reusing) power!(resystem, reusing) - ##### Test Results ##### + # Test Results compstruct(analysis.voltage, reusing.voltage; atol = 1e-10) compstruct(analysis.power, reusing.power; atol = 1e-10) @test objective_value(analysis.method.jump) ≈ objective_value(reusing.method.jump) - ##### Test Number of Constraints ##### + # Test Number of Constraints for list in list_of_constraint_types(analysis.method.jump) @test num_constraints(analysis.method.jump, list[1], list[2]) == num_constraints(reusing.method.jump, list[1], list[2]) @@ -158,7 +158,7 @@ solve!(system, analysis) power!(system, analysis) - ##### Reuse AC Optimal Power Flow Model ##### + # Reuse AC Optimal Power Flow Model updateBus!( resystem, reusing; label = 1, type = 1, conductance = 0.06, susceptance = 0.8, angle = -0.01 @@ -190,12 +190,12 @@ solve!(resystem, reusing) power!(resystem, reusing) - ##### Test Results ##### + # Test Results compstruct(analysis.voltage, reusing.voltage; atol = 1e-10) compstruct(analysis.power, reusing.power; atol = 1e-10) @test objective_value(analysis.method.jump) ≈ objective_value(reusing.method.jump) - ##### Test Number of Constraints ##### + # Test Number of Constraints for list in list_of_constraint_types(analysis.method.jump) @test num_constraints(analysis.method.jump, list[1], list[2]) == num_constraints(reusing.method.jump, list[1], list[2]) @@ -207,7 +207,7 @@ end @default(template) ########## First Pass ########## - system = powerSystem(string(path, "case14test.m")) + system = powerSystem(path * "case14test.m") updateBus!( system; label = 1, type = 1, active = 0.15, conductance = 0.16, angle = -0.1 @@ -245,8 +245,8 @@ end solve!(system, analysis) power!(system, analysis) - ##### Reuse DC Optimal Power Flow Model ##### - resystem = powerSystem(string(path, "case14test.m")) + # Reuse DC Optimal Power Flow Model + resystem = powerSystem(path * "case14test.m") dcModel!(resystem) reusing = dcOptimalPowerFlow(resystem, Ipopt.Optimizer) @@ -288,12 +288,12 @@ end solve!(resystem, reusing) power!(resystem, reusing) - ##### Test Results ##### + # Test Results compstruct(analysis.voltage, reusing.voltage; atol = 1e-10) compstruct(analysis.power, reusing.power; atol = 1e-10) @test objective_value(analysis.method.jump) ≈ objective_value(reusing.method.jump) - ##### Test Number of Constraints ##### + # Test Number of Constraints for list in list_of_constraint_types(analysis.method.jump) @test num_constraints(analysis.method.jump, list[1], list[2]) == num_constraints(reusing.method.jump, list[1], list[2]) @@ -323,7 +323,7 @@ end solve!(system, analysis) power!(system, analysis) - ##### Reuse DC Optimal Power Flow Model ##### + # Reuse DC Optimal Power Flow Model updateBus!(resystem, reusing; label = 1, type = 1, conductance = 0.06, angle = -0.01) updateBranch!( @@ -345,12 +345,12 @@ end solve!(resystem, reusing) power!(resystem, reusing) - ##### Test Results ##### + # Test Results compstruct(analysis.voltage, reusing.voltage; atol = 1e-10) compstruct(analysis.power, reusing.power; atol = 1e-10) @test objective_value(analysis.method.jump) ≈ objective_value(reusing.method.jump) - ##### Test Number of Constraints ##### + # Test Number of Constraints for list in list_of_constraint_types(analysis.method.jump) @test num_constraints(analysis.method.jump, list[1], list[2]) == num_constraints(reusing.method.jump, list[1], list[2]) diff --git a/test/powerFlow/analysis.jl b/test/powerFlow/analysis.jl index 7a6bec7cd..e8298f7c3 100644 --- a/test/powerFlow/analysis.jl +++ b/test/powerFlow/analysis.jl @@ -3,8 +3,8 @@ @default(template) ########## IEEE 14-bus Test Case ########## - system14 = powerSystem(string(path, "case14test.m")) - matpwr14 = h5read(string(path, "results.h5"), "case14test/newtonRaphson") + system14 = powerSystem(path * "case14test.m") + matpwr14 = h5read(path * "results.h5", "case14test/newtonRaphson") acModel!(system14) analysis = newtonRaphson(system14, QR) @@ -24,14 +24,14 @@ voltage = analysis.voltage current = analysis.current - ##### Test Iteration Number ##### + # Test Iteration Number @test iteration == matpwr14["iteration"][1] - ##### Test Voltages ##### + # Test Voltages @test voltage.magnitude ≈ matpwr14["voltageMagnitude"] @test voltage.angle ≈ matpwr14["voltageAngle"] - ##### Test Powers ##### + # Test Powers @test power.injection.active ≈ matpwr14["injectionActive"] @test power.injection.reactive ≈ matpwr14["injectionReactive"] @test power.supply.active ≈ matpwr14["supplyActive"] @@ -48,28 +48,28 @@ @test power.generator.active ≈ matpwr14["generatorActive"] @test power.generator.reactive ≈ matpwr14["generatorReactive"] - ##### Test Currents ##### + # Test Currents branch = system14.branch to = branch.layout.to from = branch.layout.from - Si = (complex.(power.injection.active, power.injection.reactive)) + Si = complex.(power.injection.active, power.injection.reactive) Vi = voltage.magnitude .* cis.(voltage.angle) @test current.injection.magnitude .* cis.(-current.injection.angle) ≈ Si ./ Vi - Sij = (complex.(power.from.active, power.from.reactive)) + Sij = complex.(power.from.active, power.from.reactive) Vi = voltage.magnitude[from] .* cis.(voltage.angle[from]) @test current.from.magnitude .* cis.(-current.from.angle) ≈ Sij ./ Vi - Sji = (complex.(power.to.active, power.to.reactive)) - Vj = (voltage.magnitude[to] .* cis.(voltage.angle[to])) + Sji = complex.(power.to.active, power.to.reactive) + Vj = voltage.magnitude[to] .* cis.(voltage.angle[to]) @test current.to.magnitude .* cis.(-current.to.angle) ≈ Sji ./ Vj ratio = (1 ./ branch.parameter.turnsRatio) .* cis.(-branch.parameter.shiftAngle) Sijb = complex.(power.series.active, power.series.reactive) @test current.series.magnitude .* cis.(-current.series.angle) ≈ Sijb ./ (ratio .* Vi - Vj) - ##### Test Specific Bus Powers and Currents ##### + # Test Specific Bus Powers and Currents for (key, value) in system14.bus.label active, reactive = injectionPower(system14, analysis; label = key) @test active ≈ power.injection.active[value] atol = 1e-14 @@ -88,7 +88,7 @@ @test angle ≈ current.injection.angle[value] end - ##### Test Specific Branch Powers and Currents ##### + # Test Specific Branch Powers and Currents for (key, value) in system14.branch.label active, reactive = fromPower(system14, analysis; label = key) @test active ≈ power.from.active[value] @@ -119,7 +119,7 @@ @test angle ≈ current.series.angle[value] end - ##### Test Specific Generator Powers ##### + # Test Specific Generator Powers for (key, value) in system14.generator.label active, reactive = generatorPower(system14, analysis; label = key) @test active ≈ power.generator.active[value] @@ -127,8 +127,8 @@ end ########## IEEE 30-bus Test Case ########## - system30 = powerSystem(string(path, "case30test.m")) - matpwr30 = h5read(string(path, "results.h5"), "case30test/newtonRaphson") + system30 = powerSystem(path * "case30test.m") + matpwr30 = h5read(path * "results.h5", "case30test/newtonRaphson") analysis = newtonRaphson(system30) startMagnitude = copy(analysis.voltage.magnitude) @@ -149,14 +149,14 @@ voltage = analysis.voltage current = analysis.current - ##### Test Iteration Number ##### + # Test Iteration Number @test iteration == matpwr30["iteration"][1] - ##### Test Voltages ##### + # Test Voltages @test voltage.magnitude ≈ matpwr30["voltageMagnitude"] @test voltage.angle ≈ matpwr30["voltageAngle"] - ##### Test Powers ##### + # Test Powers @test power.injection.active ≈ matpwr30["injectionActive"] @test power.injection.reactive ≈ matpwr30["injectionReactive"] @test power.supply.active ≈ matpwr30["supplyActive"] @@ -173,28 +173,28 @@ @test power.generator.active ≈ matpwr30["generatorActive"] @test power.generator.reactive ≈ matpwr30["generatorReactive"] - ##### Test Currents ##### + # Test Currents branch = system30.branch to = branch.layout.to from = branch.layout.from - Si = (complex.(power.injection.active, power.injection.reactive)) + Si = complex.(power.injection.active, power.injection.reactive) Vi = voltage.magnitude .* cis.(voltage.angle) @test current.injection.magnitude .* cis.(-current.injection.angle) ≈ Si ./ Vi - Sij = (complex.(power.from.active, power.from.reactive)) + Sij = complex.(power.from.active, power.from.reactive) Vi = voltage.magnitude[from] .* cis.(voltage.angle[from]) @test current.from.magnitude .* cis.(-current.from.angle) ≈ Sij ./ Vi - Sji = (complex.(power.to.active, power.to.reactive)) - Vj = (voltage.magnitude[to] .* cis.(voltage.angle[to])) + Sji = complex.(power.to.active, power.to.reactive) + Vj = voltage.magnitude[to] .* cis.(voltage.angle[to]) @test current.to.magnitude .* cis.(-current.to.angle) ≈ Sji ./ Vj ratio = (1 ./ branch.parameter.turnsRatio) .* cis.(-branch.parameter.shiftAngle) Sijb = complex.(power.series.active, power.series.reactive) @test current.series.magnitude .* cis.(-current.series.angle) ≈ Sijb ./ (ratio .* Vi - Vj) - ##### Test Specific Bus Powers and Currents ##### + # Test Specific Bus Powers and Currents for (key, value) in system30.bus.label active, reactive = injectionPower(system30, analysis; label = key) @test active ≈ power.injection.active[value] @@ -213,7 +213,7 @@ @test angle ≈ current.injection.angle[value] end - ##### Test Specific Branch Powers and Currents ##### + # Test Specific Branch Powers and Currents for (key, value) in system30.branch.label active, reactive = fromPower(system30, analysis; label = key) @test active ≈ power.from.active[value] @@ -244,14 +244,14 @@ @test angle ≈ current.series.angle[value] end - ##### Test Specific Generator Powers ##### + # Test Specific Generator Powers for (key, value) in system30.generator.label active, reactive = generatorPower(system30, analysis; label = key) @test active ≈ power.generator.active[value] @test reactive ≈ power.generator.reactive[value] end - ##### Test Starting Voltages ##### + # Test Starting Voltages startingVoltage!(system30, analysis) @test analysis.voltage.magnitude == startMagnitude @test analysis.voltage.angle == startAngle @@ -267,7 +267,7 @@ end @test iteration == matpwr30["iteration"][1] - ##### Test Slack Bus Changes ##### + # Test Slack Bus Changes updateBus!(system30; label = 1, type = 2) updateBus!(system30; label = 3, type = 3) @@ -289,8 +289,8 @@ end @testset "Fast Newton-Raphson BX Method" begin ########## IEEE 14-bus Test Case ########## - system14 = powerSystem(string(path, "case14test.m")) - matpwr14 = h5read(string(path, "results.h5"), "case14test/fastNewtonRaphsonBX") + system14 = powerSystem(path * "case14test.m") + matpwr14 = h5read(path * "results.h5", "case14test/fastNewtonRaphsonBX") acModel!(system14) analysis = fastNewtonRaphsonBX(system14) @@ -304,16 +304,16 @@ end iteration += 1 end - ##### Test Iteration Number ##### + # Test Iteration Number @test iteration == matpwr14["iteration"][1] - ##### Test Voltages ##### + # Test Voltages @test analysis.voltage.magnitude ≈ matpwr14["voltageMagnitude"] @test analysis.voltage.angle ≈ matpwr14["voltageAngle"] ########## IEEE 30-bus Test Case ########## - system30 = powerSystem(string(path, "case30test.m")) - matpwr30 = h5read(string(path, "results.h5"), "case30test/fastNewtonRaphsonBX") + system30 = powerSystem(path * "case30test.m") + matpwr30 = h5read(path * "results.h5", "case30test/fastNewtonRaphsonBX") analysis = fastNewtonRaphsonBX(system30, QR) iteration = 0 @@ -326,14 +326,14 @@ end iteration += 1 end - ##### Test Iteration Number ##### + # Test Iteration Number @test iteration == matpwr30["iteration"][1] - ##### Test Voltages ##### + # Test Voltages @test analysis.voltage.magnitude ≈ matpwr30["voltageMagnitude"] @test analysis.voltage.angle ≈ matpwr30["voltageAngle"] - ##### Test Pattern Changes ##### + # Test Pattern Changes updateBranch!(system30, analysis; label = 5, status = 0) dropZeros!(system30.model.ac) updateBranch!(system30, analysis; label = 5, status = 1) @@ -358,8 +358,8 @@ end @labels(Integer) ########## IEEE 14-bus Test Case ########## - system14 = powerSystem(string(path, "case14test.m")) - matpwr14 = h5read(string(path, "results.h5"), "case14test/fastNewtonRaphsonXB") + system14 = powerSystem(path * "case14test.m") + matpwr14 = h5read(path * "results.h5", "case14test/fastNewtonRaphsonXB") acModel!(system14) analysis = fastNewtonRaphsonXB(system14) @@ -373,16 +373,16 @@ end iteration += 1 end - ##### Test Iteration Number ##### + # Test Iteration Number @test iteration == matpwr14["iteration"][1] - ##### Test Voltages ##### + # Test Voltages @test analysis.voltage.magnitude ≈ matpwr14["voltageMagnitude"] @test analysis.voltage.angle ≈ matpwr14["voltageAngle"] ########## IEEE 30-bus Test Case ########## - system30 = powerSystem(string(path, "case30test.m")) - matpwr30 = h5read(string(path, "results.h5"), "case30test/fastNewtonRaphsonXB") + system30 = powerSystem(path * "case30test.m") + matpwr30 = h5read(path * "results.h5", "case30test/fastNewtonRaphsonXB") analysis = fastNewtonRaphsonXB(system30, QR) iteration = 0 @@ -395,10 +395,10 @@ end iteration += 1 end - ##### Test Iteration Number ##### + # Test Iteration Number @test iteration == matpwr30["iteration"][1] - ##### Test Voltages ##### + # Test Voltages @test analysis.voltage.magnitude ≈ matpwr30["voltageMagnitude"] @test analysis.voltage.angle ≈ matpwr30["voltageAngle"] end @@ -407,8 +407,8 @@ end @default(template) ########## IEEE 14-bus Test Case ########## - system14 = powerSystem(string(path, "case14test.m")) - matpwr14 = h5read(string(path, "results.h5"), "case14test/gaussSeidel") + system14 = powerSystem(path * "case14test.m") + matpwr14 = h5read(path * "results.h5", "case14test/gaussSeidel") acModel!(system14) analysis = gaussSeidel(system14) @@ -422,16 +422,16 @@ end iteration += 1 end - ##### Test Iteration Number ##### + # Test Iteration Number @test iteration == matpwr14["iteration"][1] - ##### Test Voltages ##### + # Test Voltages @test analysis.voltage.magnitude ≈ matpwr14["voltageMagnitude"] @test analysis.voltage.angle ≈ matpwr14["voltageAngle"] ########## IEEE 30-bus Test Case ########## - system30 = powerSystem(string(path, "case30test.m")) - matpwr30 = h5read(string(path, "results.h5"), "case30test/gaussSeidel") + system30 = powerSystem(path * "case30test.m") + matpwr30 = h5read(path * "results.h5", "case30test/gaussSeidel") analysis = gaussSeidel(system30) iteration = 0 @@ -444,10 +444,10 @@ end iteration += 1 end - ##### Test Iteration Number ##### + # Test Iteration Number @test iteration == matpwr30["iteration"][1] - ##### Test Voltages ##### + # Test Voltages @test analysis.voltage.magnitude ≈ matpwr30["voltageMagnitude"] @test analysis.voltage.angle ≈ matpwr30["voltageAngle"] end @@ -457,7 +457,7 @@ end @default(template) ########## IEEE 14-bus Test Case ########## - system14 = powerSystem(string(path, "case14test.m")) + system14 = powerSystem(path * "case14test.m") updateBranch!(system14; label = 1, conductance = 0.58) updateBranch!(system14; label = 7, conductance = 0.083) @@ -500,7 +500,7 @@ end solve!(system14, gs) end - ##### Test Voltages ##### + # Test Voltages @test nr.voltage.magnitude ≈ fnrBX.voltage.magnitude @test nr.voltage.angle ≈ fnrBX.voltage.angle @test nr.voltage.magnitude ≈ fnrXB.voltage.magnitude @@ -509,7 +509,7 @@ end @test nr.voltage.angle ≈ gs.voltage.angle ########## IEEE 30-bus Test Case ########## - system30 = powerSystem(string(path, "case30test.m")) + system30 = powerSystem(path * "case30test.m") updateBranch!(system30; label = 2, conductance = 0.01) updateBranch!(system30; label = 5, conductance = 1e-4) @@ -552,7 +552,7 @@ end solve!(system30, gs) end - ##### Test Voltages ##### + # Test Voltages @test nr.voltage.magnitude ≈ fnrBX.voltage.magnitude @test nr.voltage.angle ≈ fnrBX.voltage.angle @test nr.voltage.magnitude ≈ fnrXB.voltage.magnitude @@ -563,25 +563,25 @@ end @testset "DC Power Flow" begin ########## IEEE 14-bus Test Case ########## - system14 = powerSystem(string(path, "case14test.m")) - matpwr14 = h5read(string(path, "results.h5"), "case14test/dcPowerFlow") + system14 = powerSystem(path * "case14test.m") + matpwr14 = h5read(path * "results.h5", "case14test/dcPowerFlow") dcModel!(system14) analysis = dcPowerFlow(system14) solve!(system14, analysis) power!(system14, analysis) - ##### Test Voltage Angles ##### + # Test Voltage Angles @test analysis.voltage.angle ≈ matpwr14["voltage"] - ##### Test Active Powers ##### + # Test Active Powers @test analysis.power.injection.active ≈ matpwr14["injection"] @test analysis.power.supply.active ≈ matpwr14["supply"] @test analysis.power.from.active ≈ matpwr14["from"] @test analysis.power.to.active ≈ -matpwr14["from"] @test analysis.power.generator.active ≈ matpwr14["generator"] - ##### Test Specific Bus Active Powers ##### + # Test Specific Bus Active Powers for (key, value) in system14.bus.label injection = injectionPower(system14, analysis; label = key) supply = supplyPower(system14, analysis; label = key) @@ -590,7 +590,7 @@ end @test supply ≈ matpwr14["supply"][value] atol = 1e-14 end - ##### Test Specific Branch Active Powers ##### + # Test Specific Branch Active Powers for (key, value) in system14.branch.label from = fromPower(system14, analysis; label = key) to = toPower(system14, analysis; label = key) @@ -599,31 +599,31 @@ end @test to ≈ -matpwr14["from"][value] atol = 1e-14 end - ##### Test Specific Generator Active Powers ##### + # Test Specific Generator Active Powers for (key, value) in system14.generator.label generator = generatorPower(system14, analysis; label = key) @test generator ≈ matpwr14["generator"][value] atol = 1e-14 end ########## IEEE 30-bus Test Case ########## - system30 = powerSystem(string(path, "case30test.m")) - matpwr30 = h5read(string(path, "results.h5"), "case30test/dcPowerFlow") + system30 = powerSystem(path * "case30test.m") + matpwr30 = h5read(path * "results.h5", "case30test/dcPowerFlow") analysis = dcPowerFlow(system30, LDLt) solve!(system30, analysis) power!(system30, analysis) - ##### Test Voltage Angles ##### + # Test Voltage Angles @test analysis.voltage.angle ≈ matpwr30["voltage"] - ##### Test Active Powers ##### + # Test Active Powers @test analysis.power.injection.active ≈ matpwr30["injection"] @test analysis.power.supply.active ≈ matpwr30["supply"] @test analysis.power.from.active ≈ matpwr30["from"] @test analysis.power.to.active ≈ -matpwr30["from"] @test analysis.power.generator.active ≈ matpwr30["generator"] - ##### Test Specific Bus Active Powers ##### + # Test Specific Bus Active Powers for (key, value) in system30.bus.label injection = injectionPower(system30, analysis; label = key) supply = supplyPower(system30, analysis; label = key) @@ -632,7 +632,7 @@ end @test supply ≈ matpwr30["supply"][value] atol = 1e-14 end - ##### Test Specific Branch Active Powers ##### + # Test Specific Branch Active Powers for (key, value) in system30.branch.label from = fromPower(system30, analysis; label = key) to = toPower(system30, analysis; label = key) @@ -641,7 +641,7 @@ end @test to ≈ -matpwr30["from"][value] atol = 1e-14 end - ##### Test Specific Generator Active Powers ##### + # Test Specific Generator Active Powers for (key, value) in system30.generator.label generator = generatorPower(system30, analysis; label = key) @test generator ≈ matpwr30["generator"][value] atol = 1e-14 @@ -649,7 +649,7 @@ end end @testset "Print Data in Per-Units" begin - system14 = powerSystem(string(path, "case14test.m")) + system14 = powerSystem(path * "case14test.m") ########## Print AC Data ########## analysis = newtonRaphson(system14) @@ -658,14 +658,14 @@ end power!(system14, analysis) current!(system14, analysis) - ##### Print Bus Data ##### + # Print Bus Data width = Dict("Voltage" => 10, "Power Demand Active" => 9) show = Dict("Current Injection" => false, "Power Demand Reactive" => false) fmt = Dict("Shunt Power" => "%.6f", "Voltage" => "%.2f") @capture_out printBusData(system14, analysis; width, show, fmt, repeat = 10) @capture_out printBusData(system14, analysis; width, show, fmt, repeat = 10, style = false) - ##### Print Specific Bus Data ##### + # Print Specific Bus Data width = Dict("Voltage Angle" => 10, "Power Injection Active" => 9) delimiter = "" @capture_out printBusData(system14, analysis; label = 1, width, delimiter, header = true) @@ -673,21 +673,21 @@ end @capture_out printBusData(system14, analysis; label = 4, width, delimiter, footer = true) @capture_out printBusData(system14, analysis; label = 1, width, delimiter, style = false) - ##### Print Bus Summary ##### + # Print Bus Summary width = Dict("In-Use" => 10) show = Dict("Minimum" => false) fmt = Dict("Maximum Value" => "%.6f") @capture_out printBusSummary(system14, analysis; width, show, fmt) @capture_out printBusSummary(system14, analysis; width, show, fmt, style = false) - ##### Print Branch Data ##### + # Print Branch Data width = Dict("To-Bus Power" => 10) show = Dict("Label" => false, "Series Current Angle" => false) fmt = Dict("From-Bus Power" => "%.2f", "To-Bus Power Reactive" => "%.2e") @capture_out printBranchData(system14, analysis; width, show, fmt, repeat = 10) @capture_out printBranchData(system14, analysis; width, show, fmt, style = false) - ##### Print Specific Branch Data ##### + # Print Specific Branch Data width = Dict("To-Bus Power" => 10) delimiter = "" @capture_out printBranchData(system14, analysis; label = 1, width, delimiter, header = true) @@ -695,24 +695,24 @@ end @capture_out printBranchData(system14, analysis; label = 4, width, delimiter, footer = true) @capture_out printBranchData(system14, analysis; label = 4, width, style = false) - ##### Print Branch Summary ##### + # Print Branch Summary width = Dict("In-Use" => 10) show = Dict("Minimum" => false) fmt = Dict("Maximum Value" => "%.2f") @capture_out printBranchSummary(system14, analysis; width, show, fmt, title = false) @capture_out printBranchSummary(system14, analysis; width, show, fmt, style = false) - ##### Print Generator Data ##### + # Print Generator Data width = Dict("Power Output" => 10) show = Dict("Label Bus" => false, "Status" => true) @capture_out printGeneratorData(system14, analysis; width, show) @capture_out printGeneratorData(system14, analysis; width, show, style = false) - ##### Print Specific Generator Data ##### + # Print Specific Generator Data @capture_out printGeneratorData(system14, analysis; label = 1, header = true, footer = true) @capture_out printGeneratorData(system14, analysis; label = 1, style = false) - ##### Print Generator Summary ##### + # Print Generator Summary @capture_out printGeneratorSummary(system14, analysis; title = false) @capture_out printGeneratorSummary(system14, analysis; style = false) @@ -721,24 +721,24 @@ end solve!(system14, analysis) power!(system14, analysis) - ##### Print Bus Data and Summary ##### + # Print Bus Data and Summary @capture_out printBusData(system14, analysis, repeat = 10) @capture_out printBusData(system14, analysis, repeat = 10; label = 1) @capture_out printBusSummary(system14, analysis) - ##### Print Branch Data and Summary ##### + # Print Branch Data and Summary @capture_out printBranchData(system14, analysis) @capture_out printBranchData(system14, analysis; label = 1) @capture_out printBranchSummary(system14, analysis) - ##### Print Generator Data and Summary ##### + # Print Generator Data and Summary @capture_out printGeneratorData(system14, analysis) @capture_out printGeneratorData(system14, analysis; label = 1) @capture_out printGeneratorSummary(system14, analysis) end @testset "Print Data in SI Units" begin - system14 = powerSystem(string(path, "case14test.m")) + system14 = powerSystem(path * "case14test.m") @power(GW, MVAr, MVA) @voltage(kV, deg, V) @@ -752,17 +752,17 @@ end power!(system14, analysis) current!(system14, analysis) - ##### Print Bus Data and Summary ##### + # Print Bus Data and Summary @capture_out printBusData(system14, analysis) @capture_out printBusData(system14, analysis; label = 1, header = true) @capture_out printBusSummary(system14, analysis) - ##### Print Branch Data and Summary ##### + # Print Branch Data and Summary @capture_out printBranchData(system14, analysis) @capture_out printBranchData(system14, analysis; label = 1, header = true) @capture_out printBranchSummary(system14, analysis) - ##### Print Generator Data and Summary ##### + # Print Generator Data and Summary @capture_out printGeneratorData(system14, analysis) @capture_out printGeneratorData(system14, analysis; label = 1, header = true) @capture_out printGeneratorSummary(system14, analysis) @@ -772,19 +772,18 @@ end solve!(system14, analysis) power!(system14, analysis) - ##### Print Bus Data and Summary ##### + # Print Bus Data and Summary @capture_out printBusData(system14, analysis, repeat = 10) @capture_out printBusData(system14, analysis, repeat = 10; label = 1) @capture_out printBusSummary(system14, analysis) - ##### Print Branch Data and Summary ##### + # Print Branch Data and Summary @capture_out printBranchData(system14, analysis) @capture_out printBranchData(system14, analysis; label = 1) @capture_out printBranchSummary(system14, analysis) - ##### Print Generator Data and Summary ##### + # Print Generator Data and Summary @capture_out printGeneratorData(system14, analysis) @capture_out printGeneratorData(system14, analysis; label = 1) @capture_out printGeneratorSummary(system14, analysis) - end \ No newline at end of file diff --git a/test/powerFlow/limits.jl b/test/powerFlow/limits.jl index 5ccaf6e0e..4675a8396 100644 --- a/test/powerFlow/limits.jl +++ b/test/powerFlow/limits.jl @@ -1,9 +1,9 @@ -system14 = powerSystem(string(path, "case14test.m")) -system30 = powerSystem(string(path, "case30test.m")) +system14 = powerSystem(path * "case14test.m") +system30 = powerSystem(path * "case30test.m") @testset "Newton-Raphson Method with Reactive Power Limits" begin - matpower14 = h5read(string(path, "results.h5"), "case14test/reactiveLimit/newtonRaphson") - matpower30 = h5read(string(path, "results.h5"), "case30test/reactiveLimit/newtonRaphson") + matpower14 = h5read(path * "results.h5", "case14test/reactiveLimit/newtonRaphson") + matpower30 = h5read(path * "results.h5", "case30test/reactiveLimit/newtonRaphson") ########## IEEE 14-bus Test Case ########## acModel!(system14) @@ -32,10 +32,10 @@ system30 = powerSystem(string(path, "case30test.m")) adjustAngle!(system14, analysis; slack = 1) - ##### Test Iteration Number ##### + # Test Iteration Number @test iteration == matpower14["iteration"][1] - ##### Test Voltages ##### + # Test Voltages @test analysis.voltage.magnitude ≈ matpower14["voltageMagnitude"] @test analysis.voltage.angle ≈ matpower14["voltageAngle"] @@ -66,10 +66,10 @@ system30 = powerSystem(string(path, "case30test.m")) adjustAngle!(system30, analysis; slack = 1) - ##### Test Iteration Number ##### + # Test Iteration Number @test iteration == matpower30["iteration"][1] - ##### Test Voltages ##### + # Test Voltages @test analysis.voltage.magnitude ≈ matpower30["voltageMagnitude"] @test analysis.voltage.angle ≈ matpower30["voltageAngle"] end \ No newline at end of file diff --git a/test/powerFlow/reusing.jl b/test/powerFlow/reusing.jl index fd525c365..8f07da744 100644 --- a/test/powerFlow/reusing.jl +++ b/test/powerFlow/reusing.jl @@ -4,7 +4,7 @@ @labels(integer) ########## First Pass ########## - system = powerSystem(string(path, "case14test.m")) + system = powerSystem(path * "case14test.m") updateBus!( system; label = 14, active = 0.12, reactive = 0.13, conductance = 0.1, @@ -39,8 +39,8 @@ power!(system, analysis) current!(system, analysis) - ##### Reuse Newton-Raphson Model ##### - resystem = powerSystem(string(path, "case14test.m")) + # Reuse Newton-Raphson Model + resystem = powerSystem(path * "case14test.m") acModel!(resystem) reusing = newtonRaphson(resystem) @@ -75,7 +75,7 @@ power!(resystem, reusing) current!(resystem, reusing) - ##### Test Results ##### + # Test Results compstruct(analysis.voltage, reusing.voltage; atol = 1e-10) compstruct(analysis.power, reusing.power; atol = 1e-10) compstruct(analysis.current, reusing.current; atol = 1e-8) @@ -112,7 +112,7 @@ power!(system, analysis) current!(system, analysis) - ##### Reuse Newton-Raphson Model ##### + # Reuse Newton-Raphson Model updateBus!( resystem, reusing; label = 10, active = 0.12, susceptance = 0.005, magnitude = 1.02, angle = -0.21 @@ -142,7 +142,7 @@ power!(resystem, reusing) current!(resystem, reusing) - ##### Test Results ##### + # Test Results compstruct(analysis.voltage, reusing.voltage; atol = 1e-10) compstruct(analysis.power, reusing.power; atol = 1e-10) compstruct(analysis.current, reusing.current; atol = 1e-8) @@ -152,7 +152,7 @@ end @default(template) ########## First Pass ########## - system = powerSystem(string(path, "case14test.m")) + system = powerSystem(path * "case14test.m") updateBus!( system; label = 14, active = 0.12, reactive = 0.13, conductance = 0.1, @@ -187,8 +187,8 @@ end power!(system, analysis) current!(system, analysis) - ##### Reuse Gauss-Seidel Model ##### - resystem = powerSystem(string(path, "case14test.m")) + # Reuse Gauss-Seidel Model + resystem = powerSystem(path * "case14test.m") acModel!(resystem) reusing = gaussSeidel(resystem) @@ -223,7 +223,7 @@ end power!(resystem, reusing) current!(resystem, reusing) - ##### Test Results ##### + # Test Results compstruct(analysis.voltage, reusing.voltage; atol = 1e-10) compstruct(analysis.power, reusing.power; atol = 1e-10) compstruct(analysis.current, reusing.current; atol = 1e-8) @@ -260,7 +260,7 @@ end power!(system, analysis) current!(system, analysis) - ##### Reuse Gauss-Seidel Model ##### + # Reuse Gauss-Seidel Model updateBus!( resystem, reusing; label = 10, active = 0.12, susceptance = 0.005, magnitude = 1.02, angle = -0.21 @@ -291,7 +291,7 @@ end power!(resystem, reusing) current!(resystem, reusing) - ##### Test Results ##### + # Test Results compstruct(analysis.voltage, reusing.voltage; atol = 1e-10) compstruct(analysis.power, reusing.power; atol = 1e-10) compstruct(analysis.current, reusing.current; atol = 1e-8) @@ -299,7 +299,7 @@ end @testset "Reusing Fast Newton-Raphson Method" begin ########## First Pass ########## - system = powerSystem(string(path, "case14test.m")) + system = powerSystem(path * "case14test.m") updateBus!( system; label = 14, active = 0.12, reactive = 0.13, magnitude = 1.2, angle = -0.17 @@ -335,8 +335,8 @@ end power!(system, analysis) current!(system, analysis) - ##### Reuse Fast Newton-Raphson Model ##### - resystem = powerSystem(string(path, "case14test.m")) + # Reuse Fast Newton-Raphson Model + resystem = powerSystem(path * "case14test.m") acModel!(resystem) reusing = fastNewtonRaphsonBX(resystem) @@ -375,7 +375,7 @@ end power!(resystem, reusing) current!(resystem, reusing) - ##### Test Results ##### + # Test Results compstruct(analysis.voltage, reusing.voltage; atol = 1e-10) compstruct(analysis.power, reusing.power; atol = 1e-10) compstruct(analysis.current, reusing.current; atol = 1e-8) @@ -399,7 +399,7 @@ end power!(system, analysis) current!(system, analysis) - ##### Reuse Fast Newton-Raphson Model ##### + # Reuse Fast Newton-Raphson Model updateBus!(resystem, reusing; label = 10, active = 0.12, magnitude = 1.02, angle = -0.21) addGenerator!(resystem, reusing; bus = 2, active = 0.2, magnitude = 0.92) addGenerator!(resystem, reusing; bus = 16, active = 0.3, reactive = 0.2) @@ -416,7 +416,7 @@ end power!(resystem, reusing) current!(resystem, reusing) - ##### Test Results ##### + # Test Results compstruct(analysis.voltage, reusing.voltage; atol = 1e-10) compstruct(analysis.power, reusing.power; atol = 1e-10) compstruct(analysis.current, reusing.current; atol = 1e-8) @@ -427,7 +427,7 @@ end @default(template) ########## First Pass ########## - system = powerSystem(string(path, "case14test.m")) + system = powerSystem(path * "case14test.m") updateBus!(system; label = 1, active = 0.15, conductance = 0.16) addGenerator!(system; bus = 2, active = 0.8) @@ -440,8 +440,8 @@ end solve!(system, analysis) power!(system, analysis) - ##### Reuse DC Power Flow Model ##### - resystem = powerSystem(string(path, "case14test.m")) + # Reuse DC Power Flow Model + resystem = powerSystem(path * "case14test.m") dcModel!(resystem) reusing = dcPowerFlow(resystem) @@ -458,7 +458,7 @@ end releaseSystem = copy(resystem.model.dc.model) releaseReusing = copy(reusing.method.dcmodel) - ##### Test Results ##### + # Test Results compstruct(analysis.voltage, reusing.voltage; atol = 1e-10) compstruct(analysis.power, reusing.power; atol = 1e-10) @@ -473,7 +473,7 @@ end solve!(system, analysis) power!(system, analysis) - ##### Reuse DC Power Flow Model ##### + # Reuse DC Power Flow Model updateBus!(resystem, reusing; label = 3, active = 0.25, susceptance = 0.21) updateBus!(resystem, reusing; label = 4, conductance = 0.21) updateBranch!(resystem, reusing; label = 4, shiftAngle = -1.2) @@ -482,11 +482,11 @@ end solve!(resystem, reusing) power!(resystem, reusing) - ##### Test Results ##### + # Test Results compstruct(analysis.voltage, reusing.voltage; atol = 1e-10) compstruct(analysis.power, reusing.power; atol = 1e-10) - ##### Test Release ##### + # Test Release @test releaseSystem == resystem.model.dc.model @test releaseReusing == reusing.method.dcmodel @@ -506,7 +506,7 @@ end solve!(system, analysis) power!(system, analysis) - ##### Reuse DC Power Flow Model ##### + # Reuse DC Power Flow Model updateBus!(resystem, reusing; label = 2, active = 0.15, susceptance = 0.16, type = 2) addBranch!(resystem, reusing; from = 16, to = 7, reactance = 0.03) updateBranch!(resystem, reusing; label = 14, status = 1, reactance = 0.03) @@ -520,15 +520,15 @@ end solve!(resystem, reusing) power!(resystem, reusing) - ##### Test Results ##### + # Test Results compstruct(analysis.voltage, reusing.voltage; atol = 1e-10) compstruct(analysis.power, reusing.power; atol = 1e-10) - ##### Test Release ##### + # Test Release @test releaseSystem != resystem.model.dc.model @test releaseReusing != reusing.method.dcmodel - ##### Test Pattern Changes ##### + # Test Pattern Changes dropZeros!(resystem.model.dc) solve!(resystem, reusing) @test analysis.voltage.angle ≈ reusing.voltage.angle diff --git a/test/powerSystem/buildUpdate.jl b/test/powerSystem/buildUpdate.jl index 70b126d11..ab7afb97b 100644 --- a/test/powerSystem/buildUpdate.jl +++ b/test/powerSystem/buildUpdate.jl @@ -1,13 +1,13 @@ -@testset "Build and Update Power System Data in Per-Units" begin +@testset "Build and Update Power System in Per-Units" begin @default(template) - load = powerSystem(string(path, "build.m")) + load = powerSystem(path * "build.m") rad = pi / 180 ########## Build Power System ########## build = powerSystem() - ##### Buses ##### + # Add Buses @bus(area = 1, lossZone = 1, base = 230e3) addBus!(build; label = "1", type = 3, active = 0.17, conductance = 0.09) addBus!(build; label = 2, type = 2, magnitude = 1.1, minMagnitude = 0.9, base = 115e3) @@ -18,7 +18,7 @@ addBus!(build; susceptance = -0.1, magnitude = 0.98, angle = 7.1 * rad) addBus!(build; label = 9, active = 0.4, reactive = 0.04, base = 115e3) - ##### Branches ##### + # Add Branches @branch( minDiffAngle = 0, maxDiffAngle = 360 * pi / 180, susceptance = 0.14, resistance = 0.09, reactance = 0.02 @@ -40,35 +40,35 @@ ) addBranch!(build; from = 4, to = 9, resistance = 0.08, reactance = 0.30) - ##### Generators ##### + # Add Generators @generator(label = "?", minReactive = -0.5, maxReactive = 0.9) addGenerator!(build; bus = "1", active = 3.7, maxReactive = 1.75, maxActive = 4.72) addGenerator!(build; bus = 2, active = 2.1, magnitude = 1.1, maxActive = 3.16, status = 0) addGenerator!(build; bus = 2, active = 2.6, reactive = 0.3, maxActive = 3.16) addGenerator!(build; bus = 1, active = 0.8, reactive = 0.3, status = 0) - ##### Costs ##### + # Add Costs cost!(build; label = 1, active = 2, polynomial = [0.01 * 100^2; 40 * 100; 4]) cost!(build; label = 2, active = 2, polynomial = [0.0266666667 * 100^2; 20 * 100; 3]) cost!(build; label = 3, active = 2, polynomial = [0.0266666667 * 100^2; 20 * 100; 2]) cost!(build; label = 4, active = 2, polynomial = [30.0 * 100; 5]) - ##### Test Power System Data ##### + # Test Power System Data compstruct(load.bus, build.bus; atol = 1e-14) compstruct(load.branch, build.branch) compstruct(load.generator, build.generator) compstruct(load.base, build.base) ########## Update Power System ########## - load = powerSystem(string(path, "update.m")) + load = powerSystem(path * "update.m") - ##### Buses ##### + # Update Buses updateBus!(build; label = 1, conductance = 0.1, susceptance = -0.2, active = 0.3) updateBus!(build; label = 2, type = 1, reactive = 0.2, magnitude = 1.2, base = 120e3) updateBus!(build; label = 5, angle = -0.8 * rad, area = 2, lossZone = 3) updateBus!(build; label = 8, minMagnitude = 0.8, maxMagnitude = 1.2) - ##### Branches ##### + # Update Branches updateBranch!( build; label = 1, status = 0, resistance = 0.05, turnsRatio = 0.89, shiftAngle = 1.2 * rad @@ -82,7 +82,7 @@ updateBranch!(build; label = 2, status = 0) updateBranch!(build; label = 8, minDiffAngle = -2 * rad, maxDiffAngle = rad) - ##### Generators ##### + # Update Generators updateGenerator!(build; label = 2, status = 1, magnitude = 1.2) updateGenerator!(build; label = 4, status = 1, active = 0.1, reactive = 0.2) updateGenerator!(build; label = 1, status = 0, minActive = 0.1, maxActive = 1) @@ -92,19 +92,19 @@ updateGenerator!(build; label = 1, upActive = 5, minUpReactive = 3, maxUpReactive = 4) updateGenerator!(build; label = 1, loadFollowing = 5, reserve10min = 3, reactiveRamp = 4) - ##### Costs ##### + # Update Costs cost!(build; label = 4, active = 2, polynomial = [0.3 * 100^2; 15 * 100; 5]) - ##### Test Power System Data ##### + # Test Power System Data compstruct(load.bus, build.bus; atol = 1e-14) compstruct(load.branch, build.branch; atol = 1e-14) compstruct(load.generator, build.generator) compstruct(load.base, build.base) end -@testset "Build and Update Power System Data in SI Units" begin +@testset "Build and Update Power System in SI Units" begin @labels(Integer) - load = powerSystem(string(path, "build.m")) + load = powerSystem(path * "build.m") @base(load, MVA, kV) ########## Build Power System ########## @@ -117,7 +117,7 @@ end @base(build, MVA, kV) fn = sqrt(3) - ##### Buses ##### + # Add Buses @bus(area = 1, lossZone = 1, base = 0.23) addBus!(build; label = 1, type = 3, active = 17e3, conductance = 9e3) addBus!(build; type = 2, magnitude = 1.1 * 115 / fn, minMagnitude = 0.9 * 115 / fn, base = 0.115) @@ -131,7 +131,7 @@ end addBus!(build; susceptance = -10, magnitude = 0.98 * 230 / fn, angle = 7.1) addBus!(build; label = 9, active = 40e3, reactive = 4, base = 0.115) - ##### Branches ##### + # Add Branches Zb1 = (230e3 * 0.956)^2 / (100e6) Zb2 = (230e3 * 1.05)^2 / (100e6) Zb3 = 230^2 / 100 @@ -176,7 +176,7 @@ end susceptance = 0.14 / Zb3 ) - ##### Generators ##### + # Add Generators @generator(minReactive = -50, maxReactive = 90) addGenerator!(build; bus = 1, active = 370e3, maxReactive = 175, maxActive = 472e3) addGenerator!( @@ -186,29 +186,29 @@ end addGenerator!(build; bus = 2, active = 260e3, reactive = 30, maxActive = 316e3) addGenerator!(build; bus = 1, active = 80e3, reactive = 30, status = 0) - ##### Costs ##### + # Add Costs cost!(build; label = 1, active = 2, polynomial = [0.01e-6; 40e-3; 4]) cost!(build; label = 2, active = 2, polynomial = [0.0266666667e-6; 20e-3; 3]) cost!(build; label = 3, active = 2, polynomial = [0.0266666667e-6; 20e-3; 2]) cost!(build; label = 4, active = 2, polynomial = [30.0e-3; 5]) - ##### Test Power System Data ##### + # Test Power System Data compstruct(load.bus, build.bus; atol = 1e-12) compstruct(load.branch, build.branch; atol = 1e-12) compstruct(load.generator, build.generator; atol = 1e-12) compstruct(load.base, build.base) ########## Update Power System ########## - load = powerSystem(string(path, "update.m")) + load = powerSystem(path * "update.m") @base(load, MVA, kV) - ##### Buses ##### + # Update Buses updateBus!(build; label = 1, conductance = 10e3, susceptance = -20, active = 30e3) updateBus!(build; label = 2, type = 1, reactive = 20, magnitude = 1.2 * 120 / fn, base = 0.12) updateBus!(build; label = 5, angle = -0.8, area = 2, lossZone = 3) updateBus!(build; label = 8, minMagnitude = 0.8 * 230 / fn, maxMagnitude = 1.2 * 230 / fn) - ##### Branches ##### + # Update Branches Zb1 = 230^2 / 100 Zb2 = 120^2 / 100 Zb3 = (230e3 * 0.89)^2 / (100e6) @@ -228,7 +228,7 @@ end updateBranch!(build; label = 2, status = 0) updateBranch!(build; label = 8, minDiffAngle = -2, maxDiffAngle = 1) - ##### Generators ##### + # Update Generators updateGenerator!( build; label = 1, lowActive = 100e3, minLowReactive = 200, maxLowReactive = 300 ) @@ -244,17 +244,17 @@ end updateGenerator!(build; label = 3, status = 0, active = 30e3, reactive = 10) updateGenerator!(build; label = 1, minReactive = -10, maxReactive = 90) - ##### Costs ##### + # Update Costs cost!(build; label = 4, active = 2, polynomial = [0.3e-6; 15e-3; 5]) - ##### Test Power System Data ##### + # Test Power System Data compstruct(load.bus, build.bus; atol = 1e-12) compstruct(load.branch, build.branch; atol = 1e-12) compstruct(load.generator, build.generator; atol = 1e-12) compstruct(load.base, build.base) end -@testset "Build Power System Data in Per-Units with Macros" begin +@testset "Build Power System in Per-Units with Macros" begin @default(unit) @default(template) system = powerSystem() @@ -266,7 +266,7 @@ end maxMagnitude = 0.9, base = 100e3, area = 2, lossZone = 3 ) - ##### Test Bus Data ##### + # Test Bus Data addBus!(system) @test system.bus.label["Bus 1"] == 1 @test system.bus.layout.type[1] == 2 @@ -309,7 +309,7 @@ end minToBus = -0.3, maxToBus = 0.3, type = 2 ) - ##### Test Branch Data ##### + # Test Branch Data addBranch!(system; from = "Bus 1", to = "Bus 2") @test system.branch.label["Branch 1"] == 1 @test system.branch.layout.status[1] == 0 @@ -358,7 +358,7 @@ end loadFollowing = 1.1, reserve10min = 1.2, reserve30min = 1.3, reactiveRamp = 1.4 ) - ##### Test Generator Data ##### + # Test Generator Data addGenerator!(system; bus = "Bus 1") @test system.generator.label["Generator 1"] == 1 @test system.generator.layout.status[1] == 0 @@ -408,7 +408,7 @@ end @test system.generator.ramping.reactiveRamp[2] == 2.4 end -@testset "Build Power System Data in SI Units with Macros" begin +@testset "Build Power System in SI Units with Macros" begin @default(unit) @default(template) @@ -427,7 +427,7 @@ end lossZone = 3 ) - ##### Test Bus Data ##### + # Test Bus Data addBus!(system) @test system.bus.label["Bus 1"] == 1 @test system.bus.layout.type[1] == 2 @@ -455,7 +455,7 @@ end minToBus = 0.3e5, maxToBus = 0.4e5, type = 1 ) - ##### Test Branch Data ##### + # Test Branch Data addBranch!(system; from = "Bus 1", to = "Bus 2") @test system.branch.label["Branch 1"] == 1 @test system.branch.layout.status[1] == 0 @@ -483,7 +483,7 @@ end reserve10min = 1.2e5, reserve30min = 1.3e5, reactiveRamp = 1.4e2 ) - ##### Test Generator Data ##### + # Test Generator Data addGenerator!(system; bus = "Bus 1") @test system.generator.label["Generator 1"] == 1 @test system.generator.layout.status[1] == 0 @@ -506,7 +506,7 @@ end @test system.generator.ramping.reactiveRamp[1] ≈ 1.4 end -@testset "Test Errors and Messages" begin +@testset "Errors and Messages" begin @default(unit) @default(template) system = powerSystem() @@ -528,7 +528,7 @@ end addBus!(system, label = "Bus 3") addBus!(system, label = 4) - #### Test Deleting Models #### + ########## Test Deleting Models ########## @test isempty(system.model.ac.nodalMatrix) == true @test isempty(system.model.ac.nodalMatrixTranspose) == true @test isempty(system.model.ac.nodalFromFrom) == true @@ -545,7 +545,7 @@ end @test system.model.dc.model == 1 @test system.model.dc.pattern == 1 - ##### Test Print ##### + ########## Test Prints ########## voltg = system.bus.voltage print1 = @capture_out print(system.bus.label, voltg.magnitude) @@ -557,7 +557,7 @@ end print3 = @capture_out print(system.bus.label, system.bus.layout.type) @test print3 == "Bus 1: 3\nBus 2: 1\nBus 3: 1\n4: 1\n" - ##### Test Add Bus Errors ##### + ########## Test Add and Update Bus Errors ########## err = ErrorException("The label Bus 1 is not unique.") @test_throws err addBus!(system; label = "Bus 1") @@ -577,7 +577,6 @@ end @test_throws err addBus!(system, fnrbx; label = "Bus 4", active = 0.1) @test_throws err addBus!(system, gs; label = "Bus 4", active = 0.1) - ##### Test Update Bus Errors ##### err = ErrorException( "To set bus with label Bus 3 as the slack bus, reassign the current slack " * "bus to either a generator or demand bus." @@ -607,7 +606,7 @@ end @test_throws LoadError @eval @bus(label = "Bus ?", typee = 1) - ##### Test Add Branch Errors ##### + ########## Test Add and Update Branch Errors ########## err = ErrorException("The label Branch 1 is not unique.") @test_throws err addBranch!(system; label = "Branch 1", from = "Bus 1", to = "Bus 2") @@ -624,7 +623,6 @@ end @test_throws LoadError @eval @branch(label = "Branch ?", resistances = 1) - ##### Test Add Generator Errors ##### err = ErrorException("The label Generator 1 is not unique.") @test_throws err addGenerator!(system; label = "Generator 1", bus = "Bus 1") @@ -633,7 +631,6 @@ end ) @test_throws err addGenerator!(system; label = "Generator 2", bus = "Bus 1", status = 2) - ##### Test Update Generator Errors ##### err = ErrorException( "The power flow model cannot be reused due to required bus type conversion." ) @@ -641,7 +638,7 @@ end @test_throws err updateGenerator!(system, nr; label = "Generator 1", status = 0) @test_throws err updateGenerator!(system, gs; label = "Generator 1", status = 0) - ##### Test Cost Errors ##### + ########## Test Add and Update Cost Errors ########## err = ErrorException( "The concurrent definition of the keywords active and reactive is not allowed." ) @@ -669,15 +666,15 @@ end @test_throws LoadError @eval @generator(label = "Generator ?", actives = 1) - ##### Test Unit Errors ##### + ########## Test Unit Errors ########## @test_throws LoadError @eval @current(sA, deg) @test_throws LoadError @eval @current(kV, deg) - ##### Test Voltage Errors######### + ########## Test Voltage Errors ########## err = ErrorException("The voltage values are missing.") @test_throws err power!(system, dc) - ##### Test Load Errors ##### + ########## Test Load Errors ########## err = DomainError(".h6", "The extension .h6 is not supported.") @test_throws err powerSystem("case14.h6") diff --git a/test/powerSystem/loadSave.jl b/test/powerSystem/loadSave.jl index 3896d7d36..17bfc4586 100644 --- a/test/powerSystem/loadSave.jl +++ b/test/powerSystem/loadSave.jl @@ -1,25 +1,24 @@ -@testset "Load and Save Power System Data with String Labels" begin +@testset "Load and Save Power System with String Labels" begin ########## Load Power System ########## - matlab = powerSystem(string(path, "case14test.m")) + matlab = powerSystem(path * "case14test.m") @base(matlab, MVA, kV) ########## Save Power System ########## savePowerSystem( - matlab; - path = string(path, "case14test.h5"), reference = "IEEE 14", note = "Test Data" + matlab; path = path * "case14test.h5", reference = "IEEE 14", note = "Test Data" ) ########## Load Power System ########## - hdf5 = powerSystem(string(path, "case14test.h5")) + hdf5 = powerSystem(path * "case14test.h5") @base(hdf5, MVA, kV) - ##### Test Power System Data ##### + # Test Power System Data compstruct(matlab.bus, hdf5.bus) compstruct(matlab.branch, hdf5.branch) compstruct(matlab.generator, hdf5.generator) compstruct(matlab.base, hdf5.base) - ##### Test Base Data ##### + # Test Base Data @test matlab.base.power.value == 100.0 @test matlab.base.power.unit == "MVA" @test matlab.base.power.prefix == 1e6 @@ -28,24 +27,23 @@ @test matlab.base.voltage.prefix == 1e3 end -@testset "Load and Save Power System Data with Integer Labels" begin +@testset "Load and Save Power System with Integer Labels" begin @labels(Integer) ########## Load Power System ########## - matlab = powerSystem(string(path, "case14test.m")) + matlab = powerSystem(path * "case14test.m") @base(matlab, MVA, kV) ########## Save Power System ########## savePowerSystem( - matlab; - path = string(path, "case14Int.h5"), reference = "IEEE 14", note = "Test Data" + matlab; path = path * "case14Int.h5", reference = "IEEE 14", note = "Test Data" ) ########## Load Power System ########## hdf5 = powerSystem(string(path, "case14Int.h5")) @base(hdf5, MVA, kV) - ##### Test Power System Data ##### + # Test Power System Data compstruct(matlab.bus, hdf5.bus) compstruct(matlab.branch, hdf5.branch) compstruct(matlab.generator, hdf5.generator) diff --git a/test/stateEstimation/analysis.jl b/test/stateEstimation/analysis.jl index 08a3ea3bc..680a54c7a 100644 --- a/test/stateEstimation/analysis.jl +++ b/test/stateEstimation/analysis.jl @@ -1,5 +1,5 @@ -system14 = powerSystem(string(path, "case14test.m")) -system30 = powerSystem(string(path, "case30test.m")) +system14 = powerSystem(path * "case14test.m") +system30 = powerSystem(path * "case30test.m") @testset "AC State Estimation" begin @default(template) @default(unit) @@ -47,7 +47,7 @@ system30 = powerSystem(string(path, "case30test.m")) power!(system14, analysis) current!(system14, analysis) - ##### Test Voltmeter Measurements ##### + # Voltmeter Measurements device = measurement() for (key, idx) in system14.bus.label addPmu!( @@ -66,7 +66,7 @@ system30 = powerSystem(string(path, "case30test.m")) @capture_out printVoltmeterData(system14, device, analysisSE; label = 6) @capture_out printVoltmeterData(system14, device, analysisSE; label = 8, footer = true) - ##### Test Ammeter Measurements ##### + # Ammeter Measurements device = measurement() for (key, idx) in system14.bus.label addPmu!( @@ -91,7 +91,7 @@ system30 = powerSystem(string(path, "case30test.m")) @capture_out printAmmeterData(system14, device, analysisSE; label = 6) @capture_out printAmmeterData(system14, device, analysisSE; label = 8, footer = true) - ##### Test Bus Wattmeter Measurements ##### + # Bus Wattmeter Measurements device = measurement() for (key, idx) in system14.bus.label addPmu!( @@ -110,7 +110,7 @@ system30 = powerSystem(string(path, "case30test.m")) @capture_out printWattmeterData(system14, device, analysisSE; label = 6) @capture_out printWattmeterData(system14, device, analysisSE; label = 8, footer = true) - ##### Test Branch Wattmeter Measurements ##### + # Branch Wattmeter Measurements device = measurement() for (key, idx) in system14.bus.label addPmu!( @@ -130,7 +130,7 @@ system30 = powerSystem(string(path, "case30test.m")) end analysisSE = acStateEstimationTest(system14, device, analysisSE) - ##### Test Bus Varmeter Measurements ##### + # Bus Varmeter Measurements device = measurement() for (key, idx) in system14.bus.label addPmu!( @@ -144,7 +144,7 @@ system30 = powerSystem(string(path, "case30test.m")) end analysisSE = acStateEstimationTest(system14, device, analysis) - ##### Test Branch Varmeter Measurements ##### + # Branch Varmeter Measurements device = measurement() for (key, idx) in system14.bus.label addPmu!( @@ -164,7 +164,7 @@ system30 = powerSystem(string(path, "case30test.m")) end analysisSE = acStateEstimationTest(system14, device, analysis) - ##### Test Bus Rectangular PMU Measurements ##### + # Bus Rectangular PMU Measurements device = measurement() for (key, idx) in system14.bus.label addPmu!( @@ -178,7 +178,7 @@ system30 = powerSystem(string(path, "case30test.m")) end analysisSE = acStateEstimationTest(system14, device, analysis) - ##### Test Branch Rectangular PMU Measurements ##### + # Branch Rectangular PMU Measurements device = measurement() for (key, idx) in system14.bus.label addPmu!( @@ -199,7 +199,7 @@ system30 = powerSystem(string(path, "case30test.m")) end acStateEstimationTest(system14, device, analysis) - ##### Test Branch Rectangular Correlated PMU Measurements ##### + # Branch Rectangular Correlated PMU Measurements device = measurement() for (key, idx) in system14.bus.label addPmu!( @@ -220,7 +220,7 @@ system30 = powerSystem(string(path, "case30test.m")) end acStateEstimationTest(system14, device, analysis) - ##### Test From-Branch Polar PMU Measurements ##### + # From-Branch Polar PMU Measurements device = measurement() for (key, idx) in system14.bus.label addPmu!( @@ -238,7 +238,7 @@ system30 = powerSystem(string(path, "case30test.m")) end acStateEstimationTest(system14, device, analysis) - ##### Test To-Branch Polar PMU Measurements ##### + # To-Branch Polar PMU Measurements device = measurement() for (key, idx) in system14.bus.label addPmu!( @@ -256,7 +256,7 @@ system30 = powerSystem(string(path, "case30test.m")) end acStateEstimationTest(system14, device, analysis) - ##### Test All Measurements ##### + # All Measurements device = measurement() for (key, idx) in system14.bus.label addVoltmeter!( @@ -324,7 +324,7 @@ system30 = powerSystem(string(path, "case30test.m")) end acStateEstimationTest(system14, device, analysis) - ##### Test QR Factorization ##### + # QR Factorization analysisQR = gaussNewton(system14, device, QR) for iteration = 1:100 stopping = solve!(system14, analysisQR) @@ -335,7 +335,7 @@ system30 = powerSystem(string(path, "case30test.m")) @test analysisQR.voltage.magnitude ≈ analysis.voltage.magnitude @test analysisQR.voltage.angle ≈ analysis.voltage.angle - ##### Test Orthogonal Method ##### + # Orthogonal Method device = measurement() for (key, idx) in system14.bus.label addVoltmeter!( @@ -406,7 +406,7 @@ system30 = powerSystem(string(path, "case30test.m")) compstruct(analysisOrt.voltage, analysis.voltage; atol = 1e-10) compstruct(analysisOrt.power, analysis.power; atol = 1e-10) - ##### Test Specific Bus Powers ##### + # Specific Bus Powers for (key, idx) in system14.bus.label active, reactive = injectionPower(system14, analysisOrt; label = key) @test active ≈ analysis.power.injection.active[idx] atol = 1e-6 @@ -421,7 +421,7 @@ system30 = powerSystem(string(path, "case30test.m")) @test reactive ≈ analysis.power.shunt.reactive[idx] atol = 1e-6 end - ##### Test Specific Branch Powers ##### + # Specific Branch Powers for (key, idx) in system14.branch.label active, reactive = fromPower(system14, analysisOrt; label = key) @test active ≈ analysis.power.from.active[idx] atol = 1e-6 @@ -453,7 +453,7 @@ system30 = powerSystem(string(path, "case30test.m")) power!(system30, analysis) current!(system30, analysis) - ##### Test Voltmeter Measurements ##### + # Voltmeter Measurements device = measurement() for (key, idx) in system30.bus.label addPmu!( @@ -467,7 +467,7 @@ system30 = powerSystem(string(path, "case30test.m")) end acStateEstimationTest(system30, device, analysis) - ##### Test Wattmeter Measurements ##### + # Wattmeter Measurements device = measurement() for (key, idx) in system30.bus.label addPmu!( @@ -491,7 +491,7 @@ system30 = powerSystem(string(path, "case30test.m")) end acStateEstimationTest(system30, device, analysis) - ##### Test Varmeter Measurements ##### + # Varmeter Measurements device = measurement() for (key, idx) in system30.bus.label addPmu!( @@ -515,7 +515,7 @@ system30 = powerSystem(string(path, "case30test.m")) end acStateEstimationTest(system30, device, analysis) - ##### Test Rectangular PMU Measurements ##### + # Rectangular PMU Measurements device = measurement() for (key, idx) in system30.bus.label addPmu!( @@ -547,7 +547,7 @@ system30 = powerSystem(string(path, "case30test.m")) end acStateEstimationTest(system30, device, analysis) - ##### Test Polar PMU Measurements ##### + # Polar PMU Measurements device = measurement() for (key, idx) in system30.bus.label addPmu!( @@ -566,7 +566,7 @@ system30 = powerSystem(string(path, "case30test.m")) acStateEstimationTest(system30, device, analysis) - ##### Test All Measurements ##### + # All Measurements device = measurement() for (key, idx) in system30.bus.label addVoltmeter!( @@ -611,7 +611,7 @@ system30 = powerSystem(string(path, "case30test.m")) end acStateEstimationTest(system30, device, analysis) - ##### Test Orthogonal Method ##### + # Orthogonal Method analysisOrt = gaussNewton(system30, device, Orthogonal) for iteration = 1:100 stopping = solve!(system30, analysisOrt) @@ -621,7 +621,7 @@ system30 = powerSystem(string(path, "case30test.m")) end compstruct(analysisOrt.voltage, analysis.voltage; atol = 1e-10) - ##### Test Covariance Matrix ##### + # Covariance Matrix system = powerSystem() device = measurement() covariance = zeros(6, 6) @@ -669,8 +669,8 @@ system30 = powerSystem(string(path, "case30test.m")) @test inv(covariance) ≈ Matrix(analysis.method.precision) end -system14 = powerSystem(string(path, "case14test.m")) -system30 = powerSystem(string(path, "case30test.m")) +system14 = powerSystem(path * "case14test.m") +system30 = powerSystem(path * "case30test.m") @testset "PMU State Estimation" begin @default(template) @default(unit) @@ -705,7 +705,7 @@ system30 = powerSystem(string(path, "case30test.m")) power!(system14, analysis) current!(system14, analysis) - ##### Test Uncorrelated PMU Measurements ##### + # Uncorrelated PMU Measurements device = measurement() for (key, idx) in system14.bus.label addPmu!( @@ -725,7 +725,7 @@ system30 = powerSystem(string(path, "case30test.m")) end pmuStateEstimationTest(system14, device, analysis) - ##### Test QR Factorization ##### + # QR Factorization analysisQR = pmuStateEstimation(system14, device, QR) solve!(system14, analysisQR) power!(system14, analysisQR) @@ -733,13 +733,12 @@ system30 = powerSystem(string(path, "case30test.m")) compstruct(analysisQR.voltage, analysis.voltage; atol = 1e-10) compstruct(analysisQR.power, analysis.power; atol = 1e-10) - - ##### Test Orthogonal Method ##### + # Orthogonal Method analysisOrt = pmuStateEstimation(system14, device, Orthogonal) solve!(system14, analysisOrt) compstruct(analysisOrt.voltage, analysis.voltage; atol = 1e-10) - ##### Test Specific Bus Powers ##### + # Specific Bus Powers for (key, idx) in system14.bus.label active, reactive = injectionPower(system14, analysisQR; label = key) @test active ≈ analysis.power.injection.active[idx] atol = 1e-6 @@ -754,7 +753,7 @@ system30 = powerSystem(string(path, "case30test.m")) @test reactive ≈ analysis.power.shunt.reactive[idx] atol = 1e-6 end - ##### Test Specific Branch Powers ##### + # Specific Branch Powers for (key, idx) in system14.branch.label active, reactive = fromPower(system14, analysisQR; label = key) @test active ≈ analysis.power.from.active[idx] atol = 1e-6 @@ -773,7 +772,7 @@ system30 = powerSystem(string(path, "case30test.m")) @test reactive ≈ analysis.power.charging.reactive[idx] atol = 1e-6 end - ##### Test Correlated PMU Measurements ##### + # Correlated PMU Measurements device = measurement() for (key, idx) in system14.bus.label addPmu!( @@ -805,7 +804,7 @@ system30 = powerSystem(string(path, "case30test.m")) end current!(system30, analysis) - ##### Test PMU Measurements ##### + # PMU Measurements device = measurement() for (key, idx) in system30.bus.label addPmu!( @@ -834,8 +833,8 @@ system30 = powerSystem(string(path, "case30test.m")) pmuStateEstimationTest(system30, device, analysis) end -system14 = powerSystem(string(path, "case14test.m")) -system30 = powerSystem(string(path, "case30test.m")) +system14 = powerSystem(path * "case14test.m") +system30 = powerSystem(path * "case30test.m") @testset "DC State Estimation" begin @default(template) @default(unit) @@ -864,7 +863,7 @@ system30 = powerSystem(string(path, "case30test.m")) power!(system14, analysis) device = measurement() - ##### Test Bus Wattmeter Measurements ##### + # Bus Wattmeter Measurements device = measurement() for (key, idx) in system14.bus.label addPmu!( @@ -878,7 +877,7 @@ system30 = powerSystem(string(path, "case30test.m")) end dcStateEstimationTest(system14, device, analysis) - ##### Test Branch Wattmeter Measurements ##### + # Branch Wattmeter Measurements device = measurement() for (key, idx) in system14.bus.label addPmu!( @@ -897,7 +896,7 @@ system30 = powerSystem(string(path, "case30test.m")) @capture_out printPmuData(system14, device, analysisSE; label = 6) @capture_out printPmuData(system14, device, analysisSE; label = 8, footer = true) - ##### Test Wattmeters ##### + # Wattmeters for (key, idx) in system14.bus.label addWattmeter!(system14, device; bus = key, active = analysis.power.injection.active[idx]) end @@ -912,12 +911,12 @@ system30 = powerSystem(string(path, "case30test.m")) @capture_out printWattmeterData(system14, device, analysisSE; label = 6) @capture_out printWattmeterData(system14, device, analysisSE; label = 8, footer = true) - ##### Test QR Factorization ##### + # QR Factorization analysisQR = dcStateEstimation(system14, device, QR) solve!(system14, analysisQR) @test analysisQR.voltage.angle ≈ analysis.voltage.angle - ##### Test Orthogonal Method ##### + # Orthogonal Method analysisOrt = dcStateEstimation(system14, device, Orthogonal) solve!(system14, analysisOrt) power!(system14, analysisOrt) @@ -925,13 +924,13 @@ system30 = powerSystem(string(path, "case30test.m")) @test analysisOrt.voltage.angle ≈ analysis.voltage.angle compstruct(analysisOrt.power, analysis.power; atol = 1e-10) - ##### Test Specific Bus Powers ##### + # Specific Bus Powers for (key, idx) in system14.bus.label @test injectionPower(system14, analysisOrt; label = key) ≈ analysis.power.injection.active[idx] atol = 1e-6 @test supplyPower(system14, analysisOrt; label = key) ≈ analysis.power.supply.active[idx] atol = 1e-6 end - ##### Test Specific Branch Powers ##### + # Specific Branch Powers for (key, idx) in system14.branch.label @test fromPower(system14, analysisOrt; label = key) ≈ analysis.power.from.active[idx] atol = 1e-6 @test toPower(system14, analysisOrt; label = key) ≈ analysis.power.to.active[idx] atol = 1e-6 @@ -943,7 +942,7 @@ system30 = powerSystem(string(path, "case30test.m")) solve!(system30, analysis) power!(system30, analysis) - ##### Test Wattmeters ##### + # Wattmeters device = measurement() for (key, idx) in system30.bus.label addWattmeter!(system30, device; bus = key, active = analysis.power.injection.active[idx], variance = 1e-6) @@ -954,14 +953,14 @@ system30 = powerSystem(string(path, "case30test.m")) end dcStateEstimationTest(system30, device, analysis) - ##### Test Orthogonal Method ##### + # Orthogonal Method analysisOrt = dcStateEstimation(system30, device, Orthogonal) solve!(system30, analysisOrt) @test analysisOrt.voltage.angle ≈ analysis.voltage.angle end @testset "Print Data in Per-Units" begin - system = powerSystem(string(path, "case14test.m")) + system = powerSystem(path * "case14test.m") device = measurement("measurement14.h5") addPmu!(system, device; bus = 1, magnitude = 1.0, angle = 0.0) addPmu!(system, device; bus = 3, magnitude = 1.1, angle = -0.3) @@ -972,7 +971,7 @@ end power!(system, analysis) current!(system, analysis) - ##### Print Voltmeter Data ##### + # Print Voltmeter Data width = Dict("Voltage Magnitude Residual" => 10) show = Dict("Voltage Magnitude Estimate" => false) fmt = Dict("Voltage Magnitude" => "%.2f") @@ -981,26 +980,26 @@ end @capture_out printVoltmeterData(system, device, analysis; label = 2, footer = true) @capture_out printVoltmeterData(system, device, analysis; style = false) - ##### Print Ammeter Data ##### + # Print Ammeter Data show = Dict("Current Magnitude Status" => false) @capture_out printAmmeterData(system, device, analysis; show, repeat = 10) @capture_out printAmmeterData(system, device, analysis; label = "From 1", header = true) @capture_out printAmmeterData(system, device, analysis; label = "From 2", footer = true) @capture_out printAmmeterData(system, device, analysis; style = false) - ##### Print Wattmeter Data ##### + ##### Print Wattmeter Data @capture_out printWattmeterData(system, device, analysis; repeat = 10) @capture_out printWattmeterData(system, device, analysis; label = 1, header = true) @capture_out printWattmeterData(system, device, analysis; label = 4, footer = true) @capture_out printWattmeterData(system, device, analysis; style = false) - ##### Print Varmeter Data ##### + # Print Varmeter Data @capture_out printVarmeterData(system, device, analysis; repeat = 10) @capture_out printVarmeterData(system, device, analysis; label = 1, header = true) @capture_out printVarmeterData(system, device, analysis; label = 4, footer = true) @capture_out printVarmeterData(system, device, analysis; style = false) - ##### Print PMU Data ##### + # Print PMU Data @capture_out printPmuData(system, device, analysis; repeat = 10) @capture_out printPmuData(system, device, analysis; label = "From 1", header = true) @capture_out printPmuData(system, device, analysis; label = "From 4", footer = true) @@ -1013,13 +1012,13 @@ end solve!(system, analysis) power!(system, analysis) - ##### Print Wattmeter Data ##### + # Print Wattmeter Data @capture_out printWattmeterData(system, device, analysis; repeat = 10) @capture_out printWattmeterData(system, device, analysis; label = 1, header = true) @capture_out printWattmeterData(system, device, analysis; label = 4, footer = true) @capture_out printWattmeterData(system, device, analysis; style = false) - ##### Print PMU Data ##### + # Print PMU Data @capture_out printPmuData(system, device, analysis; repeat = 10) @capture_out printPmuData(system, device, analysis; label = 41, header = true) @capture_out printPmuData(system, device, analysis; label = 42, footer = true) @@ -1027,7 +1026,7 @@ end end @testset "Print Data in SI Units" begin - system = powerSystem(string(path, "case14test.m")) + system = powerSystem(path * "case14test.m") device = measurement("measurement14.h5") addPmu!(system, device; bus = 1, magnitude = 1.0, angle = 0.0) addPmu!(system, device; bus = 3, magnitude = 1.1, angle = -0.3) @@ -1042,23 +1041,23 @@ end power!(system, analysis) current!(system, analysis) - ##### Print Voltmeter Data ##### + # Print Voltmeter Data @capture_out printVoltmeterData(system, device, analysis) @capture_out printVoltmeterData(system, device, analysis; label = 1) - ##### Print Ammeter Data ##### + # Print Ammeter Data @capture_out printAmmeterData(system, device, analysis) @capture_out printAmmeterData(system, device, analysis; label = "From 1") - ##### Print Wattmeter Data ##### + # Print Wattmeter Data @capture_out printWattmeterData(system, device, analysis) @capture_out printWattmeterData(system, device, analysis; label = 1) - ##### Print Varmeter Data ##### + # Print Varmeter Data @capture_out printVarmeterData(system, device, analysis) @capture_out printVarmeterData(system, device, analysis; label = 1) - ##### Print PMU Data ##### + # Print PMU Data @capture_out printPmuData(system, device, analysis) @capture_out printPmuData(system, device, analysis; label = "From 1") @capture_out printPmuData(system, device, analysis; label = 41) @@ -1068,11 +1067,11 @@ end solve!(system, analysis) power!(system, analysis) - ##### Print Wattmeter Data ##### + # Print Wattmeter Data @capture_out printWattmeterData(system, device, analysis) @capture_out printWattmeterData(system, device, analysis; label = 1) - ##### Print PMU Data ##### + # Print PMU Data @capture_out printPmuData(system, device, analysis) @capture_out printPmuData(system, device, analysis; label = 41) end diff --git a/test/stateEstimation/badData.jl b/test/stateEstimation/badData.jl index c8321e6d6..a1968547a 100644 --- a/test/stateEstimation/badData.jl +++ b/test/stateEstimation/badData.jl @@ -1,5 +1,5 @@ -system14 = powerSystem(string(path, "case14test.m")) -system30 = powerSystem(string(path, "case30test.m")) +system14 = powerSystem(path * "case14test.m") +system30 = powerSystem(path * "case30test.m") @testset "AC State Estimation: Bad Data" begin @default(template) @default(unit) @@ -41,7 +41,7 @@ system30 = powerSystem(string(path, "case30test.m")) addVarmeter!(system14, device; to = key, reactive = analysis.power.to.reactive[idx]) end - ##### Test One Outlier ##### + # One Outlier updateVarmeter!(system14, device; label = "Varmeter 4", reactive = 10.25) analysisSE = gaussNewton(system14, device) @@ -64,7 +64,7 @@ system30 = powerSystem(string(path, "case30test.m")) end compstruct(analysisSE.voltage, analysis.voltage; atol = 1e-10) - ##### Test Two Outliers ##### + # Two Outliers @pmu(label = "PMU ?") for (key, idx) in system14.bus.label addPmu!( @@ -108,7 +108,7 @@ system30 = powerSystem(string(path, "case30test.m")) @test analysis.voltage.magnitude ≈ analysisSE.voltage.magnitude @test analysis.voltage.angle ≈ analysisSE.voltage.angle - ##### Test Orthogonal Method with Two Outliers ##### + # Orthogonal Method with Two Outliers updateVarmeter!(system14, device; label = "Varmeter 4", status = 1) updatePmu!(system14, device; label = "PMU 10", statusMagnitude = 1) @@ -143,7 +143,7 @@ system30 = powerSystem(string(path, "case30test.m")) end compstruct(analysisSE.voltage, analysis.voltage; atol = 1e-10) - ##### Test PMU Rectangular with One Outlier ##### + # PMU Rectangular with One Outlier for (key, idx) in system14.branch.label addPmu!( system14, device; from = key, magnitude = analysis.current.from.magnitude[idx], @@ -212,7 +212,7 @@ end ) end - ##### Test One Outlier ##### + # One Outlier updatePmu!(system14, device; label = "PMU 2", magnitude = 15) analysisSE = pmuStateEstimation(system14, device) solve!(system14, analysisSE) @@ -224,7 +224,7 @@ end solve!(system14, analysisSE) compstruct(analysisSE.voltage, analysis.voltage; atol = 1e-10) - ##### Test Two Outliers ##### + # Two Outliers updatePmu!(system14, device; label = "PMU 2", statusAngle = 1, statusMagnitude = 1) updatePmu!(system14, device; label = "PMU 20", angle = 10pi, magnitude = 30) analysisSE = pmuStateEstimation(system14, device) @@ -242,7 +242,7 @@ end solve!(system14, analysisSE) compstruct(analysisSE.voltage, analysis.voltage; atol = 1e-10) - ##### Test Orthogonal Method with One Outlier ##### + # Orthogonal Method with One Outlier updatePmu!(system14, device; label = "PMU 2", statusAngle = 1, statusMagnitude = 1) updatePmu!( system14, device; label = "PMU 20", magnitude = analysis.current.to.magnitude[4], @@ -259,7 +259,7 @@ end @test analysis.voltage.magnitude ≈ analysisSE.voltage.magnitude @test analysis.voltage.angle ≈ analysisSE.voltage.angle - ##### Test Orthogonal Method with Two Outliers ##### + # Orthogonal Method with Two Outliers updatePmu!(system14, device; label = "PMU 2", statusAngle = 1, statusMagnitude = 1) updatePmu!(system14, device; label = "PMU 20", angle = 10pi, magnitude = 30) analysisSE = pmuStateEstimation(system14, device, Orthogonal) @@ -314,7 +314,7 @@ end ) end - ##### Test One Outlier ##### + # One Outlier updateWattmeter!(system14, device; label = "Wattmeter 2", active = 100) analysisSE = dcStateEstimation(system14, device) solve!(system14, analysisSE) @@ -326,7 +326,7 @@ end solve!(system14, analysisSE) @test analysis.voltage.angle ≈ analysisSE.voltage.angle - ##### Test Two Outliers ##### + # Two Outliers updateWattmeter!(system14, device; label = "Wattmeter 2", status = 1) updatePmu!(system14, device; label = "PMU 10", angle = 10pi) analysisSE = dcStateEstimation(system14, device) @@ -344,7 +344,7 @@ end solve!(system14, analysisSE) @test analysis.voltage.angle ≈ analysisSE.voltage.angle - ##### Test Orthogonal Method with One Outlier ##### + # Orthogonal Method with One Outlier updateWattmeter!(system14, device; label = "Wattmeter 2", status = 1) updatePmu!( system14, device; @@ -360,7 +360,7 @@ end solve!(system14, analysisSE) @test analysis.voltage.angle ≈ analysisSE.voltage.angle - ##### Test Orthogonal Method with Two Outliers ##### + # Test Orthogonal Method with Two Outliers updateWattmeter!(system14, device; label = "Wattmeter 2", status = 1) updatePmu!(system14, device; label = "PMU 10", angle = 10pi) analysisSE = dcStateEstimation(system14, device, Orthogonal) diff --git a/test/stateEstimation/observability.jl b/test/stateEstimation/observability.jl index f380a2e37..65d863511 100644 --- a/test/stateEstimation/observability.jl +++ b/test/stateEstimation/observability.jl @@ -45,7 +45,7 @@ dcModel!(system) - ##### Test Case 1 ##### + ########## Case 1 ########## device = measurement() addWattmeter!(system, device; from = "Branch 3", active = 0.04, variance = 1e-4) @@ -121,7 +121,7 @@ end @test isempty(pseudoSet) - ##### Test Case 2 ##### + ########## Test Case 2 ########## device = measurement() addWattmeter!(system, device; from = "Branch 3", active = 0.04, variance = 1e-4) @@ -162,8 +162,8 @@ analysis = dcStateEstimation(system, device) @test device.wattmeter.label["P3"] == 17 - ##### Test Case 3 ##### - system14 = powerSystem(string(path, "case14test.m")) + ########## Case 3 ########## + system14 = powerSystem(path * "case14test.m") updateBranch!(system14, label = 3, status = 1) updateBranch!(system14, label = 18, status = 1) dcModel!(system14) @@ -198,7 +198,7 @@ solve!(system14, analysisSE) @test analysisSE.voltage.angle ≈ analysis.voltage.angle - ##### Test Case 4 ##### + ########## Case 4 ########## device = measurement() for (key, idx) in system14.bus.label addWattmeter!( @@ -229,7 +229,7 @@ solve!(system14, analysisSE) @test analysisSE.voltage.angle ≈ analysis.voltage.angle - ##### Test Case 5 ##### + ########## Case 5 ########## device = measurement() for (key, idx) in system14.bus.label addWattmeter!( diff --git a/test/stateEstimation/pmuPlacement.jl b/test/stateEstimation/pmuPlacement.jl index 3fee4df9f..bc784a02b 100644 --- a/test/stateEstimation/pmuPlacement.jl +++ b/test/stateEstimation/pmuPlacement.jl @@ -1,5 +1,5 @@ -system14 = powerSystem(string(path, "case14test.m")) -system30 = powerSystem(string(path, "case30test.m")) +system14 = powerSystem(path * "case14test.m") +system30 = powerSystem(path * "case30test.m") @testset "Optimal PMU Placement" begin @default(template) @@ -50,7 +50,7 @@ system30 = powerSystem(string(path, "case30test.m")) ) end - ##### LU Factorization ##### + # LU Factorization analysisLU = pmuStateEstimation(system14, device, LU) solve!(system14, analysisLU) compstruct(analysisLU.voltage, analysis.voltage; atol = 1e-10) @@ -88,7 +88,7 @@ system30 = powerSystem(string(path, "case30test.m")) ) end - ##### LU Factorization ##### + # LU Factorization analysisLU = pmuStateEstimation(system30, device, LU) solve!(system30, analysisLU) compstruct(analysisLU.voltage, analysis.voltage; atol = 1e-10) diff --git a/test/stateEstimation/reusing.jl b/test/stateEstimation/reusing.jl index fbf3af3f9..9625d15cf 100644 --- a/test/stateEstimation/reusing.jl +++ b/test/stateEstimation/reusing.jl @@ -1,4 +1,4 @@ -system14 = powerSystem(string(path, "case14test.m")) +system14 = powerSystem(path * "case14test.m") @testset "Reusing Meters AC State Estimation" begin @default(template) @default(unit) @@ -16,7 +16,7 @@ system14 = powerSystem(string(path, "case14test.m")) power!(system14, analysis) current!(system14, analysis) - #### Measurements #### + # Add Measurements device = measurement() @wattmeter(label = "!") @@ -227,11 +227,11 @@ system14 = powerSystem(string(path, "case14test.m")) end end - #### Original WLS and LAV Models #### + # Original WLS and LAV Models analysisWLS = gaussNewton(system14, device) analysisLAV = acLavStateEstimation(system14, device, Ipopt.Optimizer) - #### Update Only Devices #### + # Update Devices updateVoltmeter!(system14, device; label = 1, status = 0) updateVoltmeter!(system14, device; label = 3, status = 1) updateVoltmeter!( @@ -330,7 +330,7 @@ system14 = powerSystem(string(path, "case14test.m")) label = "PMU 17 To", magnitude = analysis.current.to.magnitude[17], polar = true ) - #### Solve Updated WLS and LAV Models #### + # Solve Updated WLS and LAV Models analysisWLSUpdate = gaussNewton(system14, device) for iteration = 1:40 stopping = solve!(system14, analysisWLSUpdate) @@ -345,7 +345,7 @@ system14 = powerSystem(string(path, "case14test.m")) solve!(system14, analysisLAVUpdate) compstruct(analysisLAVUpdate.voltage, analysis.voltage; atol = 1e-10) - #### Update Devices and Original WLS Model #### + # Update Devices and Original WLS Model updateVoltmeter!(system14, device, analysisWLS; label = 1, status = 0) updateVoltmeter!(system14, device, analysisWLS; label = 3, status = 1) updateVoltmeter!( @@ -472,7 +472,7 @@ system14 = powerSystem(string(path, "case14test.m")) end compstruct(analysisWLS.voltage, analysis.voltage; atol = 1e-10) - #### Update Devices and Original LAV Model #### + # Update Devices and Original LAV Model updateVoltmeter!(system14, device, analysisLAV; label = 1, status = 0) updateVoltmeter!(system14, device, analysisLAV; label = 3, status = 1) updateVoltmeter!( @@ -593,7 +593,7 @@ system14 = powerSystem(string(path, "case14test.m")) compstruct(analysisLAV.voltage, analysis.voltage; atol = 1e-10) end -system14 = powerSystem(string(path, "case14test.m")) +system14 = powerSystem(path * "case14test.m") @testset "Reusing Meters PMU State Estimation" begin @default(template) @default(unit) @@ -611,7 +611,7 @@ system14 = powerSystem(string(path, "case14test.m")) end current!(system14, analysis) - #### Measurements #### + # Add Measurements device = measurement() placement = pmuPlacement(system14, GLPK.Optimizer) @@ -687,13 +687,13 @@ system14 = powerSystem(string(path, "case14test.m")) end end - #### Original Device, WLS and LAV Models #### + # Original Device, WLS and LAV Models deviceWLS = deepcopy(device) deviceLAV = deepcopy(device) analysisWLS = pmuStateEstimation(system14, device) analysisLAV = pmuLavStateEstimation(system14, device, Ipopt.Optimizer) - #### Update Just PMUs #### + # Update Just PMUs updatePmu!(system14, device; label = 1, magnitude = analysis.voltage.magnitude[1]) updatePmu!(system14, device; label = 4, angle = analysis.voltage.angle[4], statusMagnitude = 1) updatePmu!( @@ -712,7 +712,7 @@ system14 = powerSystem(string(path, "case14test.m")) updatePmu!(system14, device; label = "To 10", angle = analysis.current.to.angle[10]) updatePmu!(system14, device; label = "To 15", statusAngle = 1) - #### Solve Updated WLS and LAV Models #### + # Solve Updated WLS and LAV Models analysisWLSUpdate = pmuStateEstimation(system14, device) solve!(system14, analysisWLSUpdate) compstruct(analysisWLSUpdate.voltage, analysis.voltage; atol = 1e-10) @@ -722,7 +722,7 @@ system14 = powerSystem(string(path, "case14test.m")) solve!(system14, analysisLAVUpdate) compstruct(analysisLAVUpdate.voltage, analysis.voltage; atol = 1e-8) - #### Update Devices and Original WLS Model #### + # Update Devices and Original WLS Model updatePmu!( system14, deviceWLS, analysisWLS; label = 1, magnitude = analysis.voltage.magnitude[1] @@ -767,7 +767,7 @@ system14 = powerSystem(string(path, "case14test.m")) solve!(system14, analysisWLS) compstruct(analysisWLS.voltage, analysis.voltage; atol = 1e-10) - #### Update Devices and Original LAV Model #### + # Update Devices and Original LAV Model updatePmu!( system14, deviceLAV, analysisLAV; label = 1, magnitude = analysis.voltage.magnitude[1] @@ -814,7 +814,7 @@ system14 = powerSystem(string(path, "case14test.m")) solve!(system14, analysisLAV) compstruct(analysisLAV.voltage, analysis.voltage; atol = 1e-8) - #### Check Precision Matrix #### + # Check Precision Matrix precision = copy(analysisWLS.method.precision) updatePmu!(system14, deviceWLS, analysisWLS; label = 4, correlated = false) @@ -851,7 +851,7 @@ system14 = powerSystem(string(path, "case14test.m")) @test analysisWLS.method.precision[22, 21] == 0.0 end -system14 = powerSystem(string(path, "case14test.m")) +system14 = powerSystem(path * "case14test.m") @testset "Reusing Meters DC State Estimation" begin @default(template) @default(unit) @@ -867,7 +867,7 @@ system14 = powerSystem(string(path, "case14test.m")) solve!(system14, analysis) power!(system14, analysis) - #### Measurements #### + # Add Measurements device = measurement() @wattmeter(label = "!") @@ -961,11 +961,11 @@ system14 = powerSystem(string(path, "case14test.m")) end end - #### Original WLS and LAV Models #### + # Original WLS and LAV Models analysisWLS = dcStateEstimation(system14, device) analysisLAV = dcLavStateEstimation(system14, device, Ipopt.Optimizer) - #### Update Only Devices #### + # Update Devices updateWattmeter!(system14, device; label = 1, status = 0) updateWattmeter!(system14, device; label = 3, status = 1) updateWattmeter!( @@ -1002,7 +1002,7 @@ system14 = powerSystem(string(path, "case14test.m")) ) updatePmu!(system14, device; label = 13, angle = analysis.voltage.angle[13]) - #### Solve Updated WLS and LAV Models #### + # Solve Updated WLS and LAV Models analysisWLSUpdate = dcStateEstimation(system14, device) solve!(system14, analysisWLSUpdate) @test analysisWLSUpdate.voltage.angle ≈ analysis.voltage.angle @@ -1012,7 +1012,7 @@ system14 = powerSystem(string(path, "case14test.m")) solve!(system14, analysisLAVUpdate) @test analysisLAVUpdate.voltage.angle ≈ analysis.voltage.angle - #### Update Devices and Original WLS Model #### + # Update Devices and Original WLS Model updateWattmeter!(system14, device, analysisWLS; label = 1, status = 0) updateWattmeter!(system14, device, analysisWLS; label = 3, status = 1) updateWattmeter!( @@ -1068,7 +1068,7 @@ system14 = powerSystem(string(path, "case14test.m")) solve!(system14, analysisWLS) @test analysisWLS.voltage.angle ≈ analysis.voltage.angle - #### Update Devices and Original LAV Model #### + # Update Devices and Original LAV Model updateWattmeter!(system14, device, analysisLAV; label = 1, status = 0) updateWattmeter!(system14, device, analysisLAV; label = 3, status = 1) updateWattmeter!(