Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pi-model admittance parameter #202

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions examples/ieee14bus/buildexample.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ buses=OrderedDict(
"bus14"=> PQAlgebraic(P=-0.149, Q=-0.05));

branches=OrderedDict(
"branch1"=> PiModelLine(from= "bus1", to = "bus2",y=4.999131600798035-1im*15.263086523179553, y_shunt_km=0.0528/2, y_shunt_mk=0.0528/2),
"branch2"=> PiModelLine(from= "bus1", to = "bus5",y=1.025897454970189-1im*4.234983682334831, y_shunt_km=0.0492/2, y_shunt_mk=0.0492/2),
"branch3"=> PiModelLine(from= "bus2", to = "bus3",y=1.1350191923073958-1im*4.781863151757718, y_shunt_km=0.0438/2, y_shunt_mk=0.0438/2),
"branch4"=> PiModelLine(from= "bus2", to = "bus4",y=1.686033150614943-1im*5.115838325872083, y_shunt_km=0.0340/2, y_shunt_mk=0.0340/2),
"branch5"=> PiModelLine(from= "bus2", to = "bus5",y=1.7011396670944048-1im*5.193927397969713, y_shunt_km=0.0346/2, y_shunt_mk=0.0346/2),
"branch6"=> PiModelLine(from= "bus3", to = "bus4",y=1.9859757099255606-1im*5.0688169775939205, y_shunt_km=0.0128/2, y_shunt_mk=0.0128/2),
"branch1"=> PiModelLine(from= "bus1", to = "bus2",Y=4.999131600798035-1im*15.263086523179553, Y_shunt_km=0.0528/2, Y_shunt_mk=0.0528/2),
"branch2"=> PiModelLine(from= "bus1", to = "bus5",Y=1.025897454970189-1im*4.234983682334831, Y_shunt_km=0.0492/2, Y_shunt_mk=0.0492/2),
"branch3"=> PiModelLine(from= "bus2", to = "bus3",Y=1.1350191923073958-1im*4.781863151757718, Y_shunt_km=0.0438/2, Y_shunt_mk=0.0438/2),
"branch4"=> PiModelLine(from= "bus2", to = "bus4",Y=1.686033150614943-1im*5.115838325872083, Y_shunt_km=0.0340/2, Y_shunt_mk=0.0340/2),
"branch5"=> PiModelLine(from= "bus2", to = "bus5",Y=1.7011396670944048-1im*5.193927397969713, Y_shunt_km=0.0346/2, Y_shunt_mk=0.0346/2),
"branch6"=> PiModelLine(from= "bus3", to = "bus4",Y=1.9859757099255606-1im*5.0688169775939205, Y_shunt_km=0.0128/2, Y_shunt_mk=0.0128/2),
"branch7"=> StaticLine(from= "bus4", to = "bus5",Y=6.840980661495672-1im*21.578553981691588),
"branch8"=> Transformer(from= "bus4", to = "bus7", y=0.0-1im*4.781943381790359, t_ratio=0.978),
"branch9"=> Transformer(from= "bus4", to = "bus9", y=0.0-1im*1.7979790715236075, t_ratio=0.969),
"branch10"=> Transformer(from= "bus5", to = "bus6", y=0.0-1im*3.967939052456154, t_ratio=0.932),
"branch8"=> Transformer(from= "bus4", to = "bus7", Y=0.0-1im*4.781943381790359, T_ratio=0.978),
"branch9"=> Transformer(from= "bus4", to = "bus9", Y=0.0-1im*1.7979790715236075, T_ratio=0.969),
"branch10"=> Transformer(from= "bus5", to = "bus6", Y=0.0-1im*3.967939052456154, T_ratio=0.932),
"branch11"=> StaticLine(from= "bus6", to = "bus11",Y=1.9550285631772604-1im*4.0940743442404415),
"branch12"=> StaticLine(from= "bus6", to = "bus12",Y=1.525967440450974-1im*3.1759639650294003),
"branch13"=> StaticLine(from= "bus6", to = "bus13",Y=3.0989274038379877-1im*6.102755448193116),
Expand Down
72 changes: 36 additions & 36 deletions examples/ieee14bus/grid.json
Original file line number Diff line number Diff line change
Expand Up @@ -166,83 +166,83 @@
{
"name": "branch1",
"params": {
"y": {
"Y_shunt_km": 0.0264,
"Y_shunt_mk": 0.0264,
"from": "bus1",
"Y": {
"re": 4.999131600798035,
"im": -15.263086523179553
},
"from": "bus1",
"y_shunt_mk": 0.0264,
"y_shunt_km": 0.0264,
"to": "bus2"
},
"type": "PiModelLine"
},
{
"name": "branch2",
"params": {
"y": {
"Y_shunt_km": 0.0246,
"Y_shunt_mk": 0.0246,
"from": "bus1",
"Y": {
"re": 1.025897454970189,
"im": -4.234983682334831
},
"from": "bus1",
"y_shunt_mk": 0.0246,
"y_shunt_km": 0.0246,
"to": "bus5"
},
"type": "PiModelLine"
},
{
"name": "branch3",
"params": {
"y": {
"Y_shunt_km": 0.0219,
"Y_shunt_mk": 0.0219,
"from": "bus2",
"Y": {
"re": 1.1350191923073958,
"im": -4.781863151757718
},
"from": "bus2",
"y_shunt_mk": 0.0219,
"y_shunt_km": 0.0219,
"to": "bus3"
},
"type": "PiModelLine"
},
{
"name": "branch4",
"params": {
"y": {
"Y_shunt_km": 0.017,
"Y_shunt_mk": 0.017,
"from": "bus2",
"Y": {
"re": 1.686033150614943,
"im": -5.115838325872083
},
"from": "bus2",
"y_shunt_mk": 0.017,
"y_shunt_km": 0.017,
"to": "bus4"
},
"type": "PiModelLine"
},
{
"name": "branch5",
"params": {
"y": {
"Y_shunt_km": 0.0173,
"Y_shunt_mk": 0.0173,
"from": "bus2",
"Y": {
"re": 1.7011396670944048,
"im": -5.193927397969713
},
"from": "bus2",
"y_shunt_mk": 0.0173,
"y_shunt_km": 0.0173,
"to": "bus5"
},
"type": "PiModelLine"
},
{
"name": "branch6",
"params": {
"y": {
"Y_shunt_km": 0.0064,
"Y_shunt_mk": 0.0064,
"from": "bus3",
"Y": {
"re": 1.9859757099255606,
"im": -5.0688169775939205
},
"from": "bus3",
"y_shunt_mk": 0.0064,
"y_shunt_km": 0.0064,
"to": "bus4"
},
"type": "PiModelLine"
Expand All @@ -262,39 +262,39 @@
{
"name": "branch8",
"params": {
"y": {
"from": "bus4",
"Y": {
"re": 0.0,
"im": -4.781943381790359
},
"t_ratio": 0.978,
"from": "bus4",
"to": "bus7"
"to": "bus7",
"T_ratio": 0.978
},
"type": "Transformer"
},
{
"name": "branch9",
"params": {
"y": {
"from": "bus4",
"Y": {
"re": 0.0,
"im": -1.7979790715236075
},
"t_ratio": 0.969,
"from": "bus4",
"to": "bus9"
"to": "bus9",
"T_ratio": 0.969
},
"type": "Transformer"
},
{
"name": "branch10",
"params": {
"y": {
"from": "bus5",
"Y": {
"re": 0.0,
"im": -3.967939052456154
},
"t_ratio": 0.932,
"from": "bus5",
"to": "bus6"
"to": "bus6",
"T_ratio": 0.932
},
"type": "Transformer"
},
Expand Down
22 changes: 11 additions & 11 deletions src/lines/PiModel.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
```Julia
PiModel(y, y_shunt_km, y_shunt_mk, t_km, t_mk)
PiModel(Y, Y_shunt_km, Y_shunt_mk, T_km, T_mk)
```
Implementation of the unified branch model with our sign conventions.
See also the Chapter 2 in
Expand All @@ -9,17 +9,17 @@ Assumptions:
* the line admittance is symmetric

# Arguments
- `y`: line admittance
- `y_shunt_km`: shunt admittance at the end connected to node `k`
- `y_shunt_mk`: shunt admittance at the end connected to node `m`
- `t_km`: transformer ratio at the end connected to node `k`
- `t_mk`: transformer ratio at the end connected to node `m`
- `Y`: line admittance
- `Y_shunt_km`: shunt admittance at the end connected to node `k`
- `Y_shunt_mk`: shunt admittance at the end connected to node `m`
- `T_km`: transformer ratio at the end connected to node `k`
- `t_mk`: Transformer ratio at the end connected to node `m`
"""
function PiModel(y, y_shunt_km, y_shunt_mk, t_km, t_mk)
function PiModel(Y, Y_shunt_km, Y_shunt_mk, T_km, T_mk)
Π = zeros(Complex{Float64}, 2, 2)
Π[1, 1] = - abs2(t_km) * (y + y_shunt_km) # Our sign convention is opposite for the source of the edge
Π[1, 2] = conj(t_km) * t_mk * y # Our sign convention is opposite for the source of the edge
Π[2, 1] = - conj(t_mk) * t_km * y
Π[2, 2] = abs2(t_mk) * (y + y_shunt_mk)
Π[1, 1] = - abs2(T_km) * (Y + Y_shunt_km) # Our sign convention is opposite for the source of the edge
Π[1, 2] = conj(T_km) * T_mk * Y # Our sign convention is opposite for the source of the edge
Π[2, 1] = - conj(T_mk) * T_km * Y
Π[2, 2] = abs2(T_mk) * (Y + Y_shunt_mk)
Π
end
14 changes: 7 additions & 7 deletions src/lines/PiModelLine.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@doc """
```Julia
PiModelLine(from, to, y, y_shunt_km, y_shunt_mk)
PiModelLine(from, to, Y, Y_shunt_km, Y_shunt_mk)
```
A line modelled according to the PI-Model.

Expand All @@ -10,21 +10,21 @@ See also the Chapter 2 in
# Arguments
- `from` : node `k`
- `to` : node `m`
- `y`: admittance of line between `k` and `m`
- `y_shunt_km`: shunt admittance at the end connected to node `k`
- `y_shunt_mk`: shunt admittance at the end connected to node `m`
- `Y`: admittance of line between `k` and `m`
- `Y_shunt_km`: shunt admittance at the end connected to node `k`
- `Y_shunt_mk`: shunt admittance at the end connected to node `m`
- `t_km`: transformer ratio at the end connected to node `k`
- `t_mk`: transformer ratio at the end connected to node `m`

# Assumptions:
- the line admittance is symmetric
"""
@Line PiModelLine(from, to, y, y_shunt_km, y_shunt_mk) begin
Y = PiModel(y, y_shunt_km, y_shunt_mk, 1, 1)
@Line PiModelLine(from, to, Y, Y_shunt_km, Y_shunt_mk) begin
Π = PiModel(Y, Y_shunt_km, Y_shunt_mk, 1, 1)
end begin
# If current is flowing away from the source, it is negative at the source.
voltage_vector = [source_voltage,destination_voltage]
current_vector = Y * voltage_vector
current_vector = Π * voltage_vector
end

export PiModelLine
14 changes: 7 additions & 7 deletions src/lines/Transformer.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
```Julia
Transformer(from, to, y, t_ratio)
Transformer(from, to, Y, T_ratio)
```

assuming an ideal transformer in series with an admittance.
Expand All @@ -9,26 +9,26 @@ The representation uses the Π model.
# Mathematical Representation
The voltage transforms as:
```math
u_{to} = t_{ratio} u_{from}
u_{to} = T_{ratio} u_{from}
```

# Arguments

- `from` : start node
- `to` : end node
- `y`: transformer admittance
- `t_ratio`: transformation ration
- `Y`: transformer admittance
- `T_ratio`: transformation ration

# Assumptions

The admittance is here taken to be on the high-voltage side.
"""
@Line Transformer(from, to, y, t_ratio) begin
@Line Transformer(from, to, Y, T_ratio) begin

# If current is flowing away from the source, it is negative at the source.
voltage_vector = [source_voltage,destination_voltage]
Y = PiModel(y, 0, 0, t_ratio, 1)
current_vector = Y * voltage_vector
Π = PiModel(Y, 0, 0, T_ratio, 1)
current_vector = Π * voltage_vector
end

export Transformer
16 changes: 8 additions & 8 deletions src/operationpoint/power_flow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -218,18 +218,18 @@ function make_branch_ac!(data::Dict{String,Any}, dict::Dict{Any, Int}, line::Tra
branch_dict = _make_branch_ac_header(data, dict, line)
branch_dict["transformer"] = true
branch_dict["tap"] = line.t_ratio
branch_dict["br_r"] = real(1 / line.y)
branch_dict["br_x"] = imag(1 / line.y)
branch_dict["br_r"] = real(1 / line.Y)
branch_dict["br_x"] = imag(1 / line.Y)
end

function make_branch_ac!(data::Dict{String,Any}, dict::Dict{Any, Int}, line::PiModelLine)
branch_dict = _make_branch_ac_header(data, dict, line)
branch_dict["g_fr"] = real(line.y_shunt_km)
branch_dict["b_fr"] = imag(line.y_shunt_km)
branch_dict["br_r"] = real(1 / line.y)
branch_dict["br_x"] = imag(1 / line.y)
branch_dict["g_to"] = real(line.y_shunt_mk)
branch_dict["b_to"] = imag(line.y_shunt_mk)
branch_dict["g_fr"] = real(line.Y_shunt_km)
branch_dict["b_fr"] = imag(line.Y_shunt_km)
branch_dict["br_r"] = real(1 / line.Y)
branch_dict["br_x"] = imag(1 / line.Y)
branch_dict["g_to"] = real(line.Y_shunt_mk)
branch_dict["b_to"] = imag(line.Y_shunt_mk)
end


Expand Down
12 changes: 6 additions & 6 deletions test/common/PowerGrid.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ using OrderedCollections: OrderedDict

@testset "permutation tests array constructor" begin
nodes_1 = [SlackAlgebraic(U=1), SwingEqLVS(H=1, P=-1, D=1, Ω=50, Γ=20, V=1), SwingEqLVS(H=1, P=1, D=1, Ω=50, Γ=20, V=1)]
lines_1 = [StaticLine(from=1, to=2, Y=5im),PiModelLine(;from=2, to=3, y = 1/(0.1152 + im*0.0458), y_shunt_km = 0., y_shunt_mk = 0.)]
lines_1 = [StaticLine(from=1, to=2, Y=5im),PiModelLine(;from=2, to=3, Y = 1/(0.1152 + im*0.0458), Y_shunt_km = 0., Y_shunt_mk = 0.)]
power_grid_1 = PowerGrid(nodes_1,lines_1)

nodes_2 = [SlackAlgebraic(U=1), SwingEqLVS(H=1, P=-1, D=1, Ω=50, Γ=20, V=1),SwingEqLVS(H=1, P=1, D=1, Ω=50, Γ=20, V=1)]
lines_2 = [PiModelLine(;from=2, to=3, y = 1/(0.1152 + im*0.0458), y_shunt_km = 0., y_shunt_mk = 0.),StaticLine(from=1, to=2, Y=5im)]
lines_2 = [PiModelLine(;from=2, to=3, Y = 1/(0.1152 + im*0.0458), Y_shunt_km = 0., Y_shunt_mk = 0.),StaticLine(from=1, to=2, Y=5im)]
power_grid_2 = PowerGrid(nodes_2,lines_2)

@test collect(edges(power_grid_1.graph))[1]==collect(edges(power_grid_2.graph))[1]
Expand All @@ -24,7 +24,7 @@ using OrderedCollections: OrderedDict
@test sum(abs.(op1[:]-op2[:]))<=1*10-6

nodes_3 = [SwingEqLVS(H=1, P=-1, D=1, Ω=50, Γ=20, V=1),SlackAlgebraic(U=1), SwingEqLVS(H=1, P=1, D=1, Ω=50, Γ=20, V=1)]
lines_3 = [PiModelLine(;from=1, to=3, y = 1/(0.1152 + im*0.0458), y_shunt_km = 0., y_shunt_mk = 0.),StaticLine(from=1, to=2, Y=5im)]
lines_3 = [PiModelLine(;from=1, to=3, Y = 1/(0.1152 + im*0.0458), Y_shunt_km = 0., Y_shunt_mk = 0.),StaticLine(from=1, to=2, Y=5im)]
power_grid_3 = PowerGrid(nodes_3,lines_3)
op3 = find_operationpoint(power_grid_3)
@test isapprox(op2[3],op3[1],atol=1e-8)
Expand All @@ -34,11 +34,11 @@ end

@testset "permutation tests OrderedDict constructor" begin
nodes_1 = OrderedDict("bus1"=>SlackAlgebraic(U=1), "bus2"=>SwingEqLVS(H=1, P=-1, D=1, Ω=50, Γ=20, V=1),"bus3"=> SwingEqLVS(H=1, P=1, D=1, Ω=50, Γ=20, V=1))
lines_1 = OrderedDict("line1"=>StaticLine(from="bus1", to="bus2", Y=5im),"line2"=>PiModelLine(;from="bus2", to="bus3", y = 1/(0.1152 + im*0.0458), y_shunt_km = 0., y_shunt_mk = 0.))
lines_1 = OrderedDict("line1"=>StaticLine(from="bus1", to="bus2", Y=5im),"line2"=>PiModelLine(;from="bus2", to="bus3", Y = 1/(0.1152 + im*0.0458), Y_shunt_km = 0., Y_shunt_mk = 0.))
power_grid_1 = PowerGrid(nodes_1,lines_1)

nodes_2 = OrderedDict("bus1"=>SlackAlgebraic(U=1), "bus2"=>SwingEqLVS(H=1, P=-1, D=1, Ω=50, Γ=20, V=1),"bus3"=> SwingEqLVS(H=1, P=1, D=1, Ω=50, Γ=20, V=1))
lines_2 = OrderedDict("line1"=>PiModelLine(;from="bus2", to="bus3", y = 1/(0.1152 + im*0.0458), y_shunt_km = 0., y_shunt_mk = 0.),"line2"=>StaticLine(from="bus1", to="bus2", Y=5im))
lines_2 = OrderedDict("line1"=>PiModelLine(;from="bus2", to="bus3", Y = 1/(0.1152 + im*0.0458), Y_shunt_km = 0., Y_shunt_mk = 0.),"line2"=>StaticLine(from="bus1", to="bus2", Y=5im))
power_grid_2 = PowerGrid(nodes_2,lines_2)

@test collect(edges(power_grid_1.graph))[1]==collect(edges(power_grid_2.graph))[1]
Expand All @@ -49,7 +49,7 @@ end


nodes_3 = OrderedDict("bus1"=>SwingEqLVS(H=1, P=-1, D=1, Ω=50, Γ=20, V=1),"bus2"=>SlackAlgebraic(U=1), "bus3"=> SwingEqLVS(H=1, P=1, D=1, Ω=50, Γ=20, V=1))
lines_3 = OrderedDict("line1"=>PiModelLine(;from="bus1", to="bus3", y = 1/(0.1152 + im*0.0458), y_shunt_km = 0., y_shunt_mk = 0.),"line2"=>StaticLine(from="bus1", to="bus2", Y=5im))
lines_3 = OrderedDict("line1"=>PiModelLine(;from="bus1", to="bus3", Y = 1/(0.1152 + im*0.0458), Y_shunt_km = 0., Y_shunt_mk = 0.),"line2"=>StaticLine(from="bus1", to="bus2", Y=5im))

power_grid_3 = PowerGrid(nodes_3, lines_3)
op3 = find_operationpoint(power_grid_3)
Expand Down
10 changes: 5 additions & 5 deletions test/faults/NodeShortCircuit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ nodes = [
CSIMinimal(; I_r = complex(0.4988, -0.4988)),
]

y = complex(1.736, -208.326)
Y = complex(1.736, -208.326)

SL = StaticLine(; from = 1, to = 2, Y = y)
SL = StaticLine(; from = 1, to = 2, Y = Y)
PL = PiModelLine(;
from = 1,
to = 2,
y = y,
y_shunt_km = 0.0,
y_shunt_mk = 0.0,
Y = Y,
Y_shunt_km = 0.0,
Y_shunt_mk = 0.0,
)


Expand Down
Loading