Skip to content

Commit

Permalink
improved precompilation, and fixed a bug related to PMU in ACSE
Browse files Browse the repository at this point in the history
  • Loading branch information
mcosovic committed Sep 3, 2024
1 parent f6be635 commit f07550c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 13 deletions.
23 changes: 11 additions & 12 deletions src/stateEstimation/acStateEstimation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,17 @@ function normalEquation!(system::PowerSystem, analysis::ACStateEstimation)
jacobian[row, col + bus.number] = voltage.magnitude[index] * (Gij * sinAngle - Bij * cosAngle) # ∂Qᵢ / ∂Vⱼ
end

elseif se.type[row] == 14 # ℜ(Vᵢ)
se.residual[row] = se.mean[row] - voltage.magnitude[index] * cos(voltage.angle[index])

jacobian[row, col] = -voltage.magnitude[index] * sin(voltage.angle[index]) # ∂ℜ(Vᵢ) / ∂θᵢ
jacobian[row, col + bus.number] = cos(voltage.angle[index]) # ∂ℜ(Vᵢ) / ∂Vᵢ

elseif se.type[row] == 15 # ℑ(Vᵢ)
se.residual[row] = se.mean[row] - voltage.magnitude[index] * sin(voltage.angle[index])

jacobian[row, col] = voltage.magnitude[index] * cos(voltage.angle[index]) # ∂ℑ(Vᵢ) / ∂θᵢ
jacobian[row, col + bus.number] = sin(voltage.angle[index]) # ∂ℑ(Vᵢ) / ∂Vᵢ
else
i, j, gij, bij, gsi, bsi, tij, Fij = branchParameter(branch, ac, index)

Expand Down Expand Up @@ -934,18 +945,6 @@ function normalEquation!(system::PowerSystem, analysis::ACStateEstimation)
jacobian[row, col + bus.number] = Iinv * (C * sinAngle - D * cosAngle) * voltage.magnitude[i] # ∂ψⱼᵢ / ∂Vⱼ
end

elseif se.type[row] == 14 # ℜ(Vᵢ)
se.residual[row] = se.mean[row] - voltage.magnitude[index] * cos(voltage.angle[index])

jacobian[row, col] = -voltage.magnitude[index] * sin(voltage.angle[index]) # ∂ℜ(Vᵢ) / ∂θᵢ
jacobian[row, col + bus.number] = cos(voltage.angle[index]) # ∂ℜ(Vᵢ) / ∂Vᵢ

elseif se.type[row] == 15 # ℑ(Vᵢ)
se.residual[row] = se.mean[row] - voltage.magnitude[index] * sin(voltage.angle[index])

jacobian[row, col] = voltage.magnitude[index] * cos(voltage.angle[index]) # ∂ℑ(Vᵢ) / ∂θᵢ
jacobian[row, col + bus.number] = sin(voltage.angle[index]) # ∂ℑ(Vᵢ) / ∂Vᵢ

elseif se.type[row] == 16 # ℜ(Iᵢⱼ)
A, B, C, D = FijCoeff(gij, gsi, bij, bsi, tij)

Expand Down
24 changes: 23 additions & 1 deletion src/utility/precompile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,39 @@ import PrecompileTools

PrecompileTools.@setup_workload begin
system = powerSystem()
device = measurement()

addBus!(system; label = 1, type = 3, active = 0.1)
addBus!(system; label = 2, type = 1, reactive = 0.05)
addBranch!(system; from = 1, to = 2, reactance = 0.05)
addGenerator!(system; bus = 1, active = 0.5, reactive = 0.1)

addPmu!(system, device; bus = 1, magnitude = 1.0, angle = 0.0)
addPmu!(system, device; bus = 2, magnitude = 1.0, angle = 0.0)

PrecompileTools.@compile_workload begin
analysis = dcPowerFlow(system)
solve!(system, analysis)

analysis = newtonRaphson(system, QR)
analysis = newtonRaphson(system)
solve!(system, analysis)

analysis = fastNewtonRaphsonBX(system)
solve!(system, analysis)

analysis = fastNewtonRaphsonXB(system)
solve!(system, analysis)

analysis = gaussSeidel(system)
solve!(system, analysis)

analysis = dcWlsStateEstimation(system, device)
solve!(system, analysis)

analysis = pmuWlsStateEstimation(system, device)
solve!(system, analysis)

analysis = gaussNewton(system, device)
solve!(system, analysis)
end
end

0 comments on commit f07550c

Please sign in to comment.