Skip to content

Commit 260ec5e

Browse files
committed
Modeling magnituzation admittance
1 parent c099ac0 commit 260ec5e

7 files changed

Lines changed: 94 additions & 41 deletions

File tree

GridKit/Model/PhasorDynamics/Branch/Branch.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,8 @@ namespace GridKit
203203
RealT X_{0.0};
204204
RealT G_{0.0};
205205
RealT B_{0.0};
206+
RealT Gmag_{0.0};
207+
RealT Bmag_{0.0};
206208
RealT tap_{1.0};
207209
RealT phase_{0.0};
208210
IdxT bus1_id_{0};

GridKit/Model/PhasorDynamics/Branch/BranchData.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ namespace GridKit
1717
{
1818
R, ///< Line series resistance
1919
X, ///< Line series reactance
20-
G, ///< Total shunt conductance
21-
B, ///< Total shunt susceptance
20+
G, ///< Total line shunt conductance
21+
B, ///< Total line shunt susceptance
22+
Gmag, ///< Total magnetizing shunt conductance
23+
Bmag, ///< Total magnetizing shunt susceptance
2224
tap, ///< Off-nominal tap magnitude on bus1 side
2325
phase, ///< Phase shift angle in radians
2426
};

GridKit/Model/PhasorDynamics/Branch/BranchImpl.hpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ namespace GridKit
5252
* @param bus2 - pointer to bus-2
5353
* @param R - line series resistance
5454
* @param X - line series reactance
55-
* @param G - total shunt conductance
56-
* @param B - total shunt susceptance
55+
* @param G - total line shunt conductance
56+
* @param B - total line shunt susceptance
5757
* @param tap - off-nominal tap magnitude on bus1 side
5858
* @param phase - phase shift angle in radians
5959
*/
@@ -165,6 +165,8 @@ namespace GridKit
165165
check(std::isfinite(X_), "X must be finite");
166166
check(std::isfinite(G_), "G must be finite");
167167
check(std::isfinite(B_), "B must be finite");
168+
check(std::isfinite(Gmag_), "Gmag must be finite");
169+
check(std::isfinite(Bmag_), "Bmag must be finite");
168170
check(std::isfinite(tap_), "tap must be finite");
169171
check(std::isfinite(phase_), "phase must be finite");
170172
check(R_ * R_ + X_ * X_ > RealT{0.0}, "R and X cannot both be zero");
@@ -335,6 +337,8 @@ namespace GridKit
335337
readRealParameter(data, Parameter::X, X_);
336338
readRealParameter(data, Parameter::G, G_);
337339
readRealParameter(data, Parameter::B, B_);
340+
readRealParameter(data, Parameter::Gmag, Gmag_);
341+
readRealParameter(data, Parameter::Bmag, Bmag_);
338342
readRealParameter(data, Parameter::tap, tap_);
339343
readRealParameter(data, Parameter::phase, phase_);
340344

@@ -478,20 +482,20 @@ namespace GridKit
478482
const RealT cos_ph = std::cos(phase_);
479483
const RealT sin_ph = std::sin(phase_);
480484

481-
const RealT g_diag = -(g_br + RealT{0.5} * G_);
482-
const RealT b_diag = -(b_br + RealT{0.5} * B_);
485+
const RealT g_diag = -(g_br + RealT{0.5} * Gmag_);
486+
const RealT b_diag = -(b_br + RealT{0.5} * Bmag_);
483487

484-
g11_ = g_diag * inv_tap * inv_tap;
485-
b11_ = b_diag * inv_tap * inv_tap;
488+
g11_ = g_diag * inv_tap * inv_tap - RealT{0.5} * G_;
489+
b11_ = b_diag * inv_tap * inv_tap - RealT{0.5} * B_;
486490

487491
g12_ = (g_br * cos_ph - b_br * sin_ph) * inv_tap;
488492
b12_ = (b_br * cos_ph + g_br * sin_ph) * inv_tap;
489493

490494
g21_ = (g_br * cos_ph + b_br * sin_ph) * inv_tap;
491495
b21_ = (b_br * cos_ph - g_br * sin_ph) * inv_tap;
492496

493-
g22_ = g_diag;
494-
b22_ = b_diag;
497+
g22_ = g_diag - RealT{0.5} * G_;
498+
b22_ = b_diag - RealT{0.5} * B_;
495499
}
496500

497501
} // namespace PhasorDynamics

GridKit/Model/PhasorDynamics/Branch/README.md

Lines changed: 46 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ contributions are oriented entering the adjacent buses.
77
Notes:
88
- Setting $\tau = 1$ and $\theta = 0$ gives the ordinary symmetric
99
transmission-line $\pi$ model.
10-
- $G$ and $B$ are total branch shunt values split equally between terminals.
10+
- The total line shunt $G + jB$ is added outside the $\mathbf{M}$ transformation,
11+
while the total magnetizing shunt $G_\text{mag} + jB_\text{mag}$ is transformed
12+
by $\mathbf{M}$; both total shunts are split equally between terminals.
1113
- The branch has no solver-owned variables; it contributes current residuals
1214
directly to the connected buses.
1315

@@ -23,40 +25,43 @@ Figure 1: Branch equivalent circuit
2325

2426
## Model Parameters
2527

26-
Symbol | Units | Description | Typical Value | Note
27-
------------|---------|--------------------------------------------------|---------------|------
28-
$R$ | [p.u.] | Branch series resistance | |
29-
$X$ | [p.u.] | Branch series reactance | |
30-
$G$ | [p.u.] | Total branch shunt conductance | 0 |
31-
$B$ | [p.u.] | Total branch shunt susceptance | 0 |
32-
$\tau$ | [p.u.] | Off-nominal tap magnitude on bus-1 side | 1 | Parameter name: `tap`
33-
$\theta$ | [rad] | Phase-shift angle | 0 | Parameter name: `phase`
28+
Symbol | Units | JSON | Description | Typical Value | Note
29+
---------------------|--------|---------|-----------------------------------------|---------------|------
30+
$R$ | [p.u.] | `R` | Branch series resistance | |
31+
$X$ | [p.u.] | `X` | Branch series reactance | |
32+
$G$ | [p.u.] | `G` | Total line shunt conductance | 0.0 |
33+
$B$ | [p.u.] | `B` | Total line shunt susceptance | 0.0 |
34+
$G_\text{mag}$ | [p.u.] | `Gmag` | Total magnetizing shunt conductance | 0.0 |
35+
$B_\text{mag}$ | [p.u.] | `Bmag` | Total magnetizing shunt susceptance | 0.0 |
36+
$\tau$ | [p.u.] | `tap` | Off-nominal tap magnitude on bus-1 side | 1.0 |
37+
$\theta$ | [rad] | `phase` | Phase-shift angle | 0.0 |
3438

3539
### Parameter Validation
3640

3741
Invalid Branch parameter sets are rejected by the following checks:
3842

3943
```math
4044
\begin{aligned}
41-
&R, X, G, B, \tau, \theta \in \mathbb{R}\ \text{and finite} \\
45+
&R, X, G, B, G_\text{mag}, B_\text{mag}, \tau, \theta
46+
\in \mathbb{R}\ \text{and finite} \\
4247
&R^2 + X^2 > 0 \\
4348
&\tau > 0
4449
\end{aligned}
4550
```
4651

4752
### Model Derived Parameters
4853

49-
The series and shunt admittances are:
54+
The series, magnetizing shunt, and line shunt admittances are:
5055

5156
```math
5257
\begin{aligned}
53-
Y_{\mathrm{br}} &= \dfrac{1}{R + jX} \\
54-
Y_{\mathrm{sh}} &= G + jB
58+
Y_{\mathrm{br}} &= \dfrac{1}{R + jX} \\
59+
Y_{\mathrm{mag}} &= G_\text{mag} + jB_\text{mag} \\
60+
Y_{\mathrm{sh}} &= G + jB
5561
\end{aligned}
5662
```
5763

58-
The nominal $\pi$-branch admittance matrix is the sum of the series and shunt
59-
admittance contributions:
64+
The series, magnetizing shunt, and line shunt admittance matrices are:
6065

6166
```math
6267
\begin{aligned}
@@ -67,7 +72,17 @@ admittance contributions:
6772
Y_{\mathrm{br}}
6873
& -Y_{\mathrm{br}}
6974
\end{bmatrix}
70-
+
75+
\\
76+
\mathbf{Y}_\text{mag}
77+
&=
78+
\dfrac{1}{2}
79+
\begin{bmatrix}
80+
-Y_{\mathrm{mag}} & 0 \\
81+
0 & -Y_{\mathrm{mag}}
82+
\end{bmatrix}
83+
\\
84+
\mathbf{Y}_\text{sh}
85+
&=
7186
\dfrac{1}{2}
7287
\begin{bmatrix}
7388
-Y_{\mathrm{sh}} & 0 \\
@@ -85,8 +100,21 @@ The off-nominal transformer transformation uses bus 1 as the tap side:
85100
\begin{bmatrix}
86101
\tau^{-1} & 0 \\
87102
0 & e^{j\theta}
88-
\end{bmatrix} \\
89-
\mathbf{Y} &= \mathbf{M}^{\dagger}\mathbf{Y}_0\mathbf{M}
103+
\end{bmatrix}
104+
\end{aligned}
105+
```
106+
107+
The line shunt is added outside the transformation:
108+
109+
```math
110+
\begin{aligned}
111+
\mathbf{Y}
112+
&=
113+
\mathbf{M}^{\dagger}
114+
\left(\mathbf{Y}_0 + \mathbf{Y}_\text{mag}\right)
115+
\mathbf{M}
116+
+
117+
\mathbf{Y}_\text{sh}
90118
\end{aligned}
91119
```
92120

GridKit/Model/PhasorDynamics/INPUT_FORMAT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ are specified:
139139

140140
Device class | Description | Ports | Initialization parameters | Variables available to monitor
141141
---------------------|------------------------------------------------------|----------------------------------|---------------------------- | -------------------------
142-
`Branch` | algebraic pi model for a line or off-nominal transformer branch | `bus1`, `bus2` | `R`, `X`, `G`, `B`, `tap`, `phase` | `ir1`, `ii1`, `im1`, `p1`, `q1`, `ir2`, `ii2`, `im2`, `p2`, `q2`
142+
`Branch` | algebraic pi model for a line or off-nominal transformer branch | `bus1`, `bus2` | `R`, `X`, `G`, `B`, `Gmag`, `Bmag`, `tap`, `phase` | `ir1`, `ii1`, `im1`, `p1`, `q1`, `ir2`, `ii2`, `im2`, `p2`, `q2`
143143
`Load` | a basic static impedence load model | `bus` | `R`, `X` | `p`, `q`
144144
`Genrou` | 6th order machine model | `bus`, `pmech`\*, `speed`\*, `efd`\* | `p0`, `q0`, `H`, `D`, `Ra`, `Tdop`, `Tdopp`, `Tqop`, `Tqopp`, `Xd`, `Xdp`, `Xdpp`, `Xq`, `Xqp`, `Xqpp`, `Xl`, `S10`, `S12`, `mva` | `ir`, `ii`, `p`, `q`, `delta`, `omega`, `speed`
145145
`Gensal` | 5th order salient-pole machine model | `bus`, `pmech`\*, `speed`\*, `efd`\* | `p0`, `q0`, `H`, `D`, `Ra`, `Tdop`, `Tdopp`, `Tqopp`, `Xd`, `Xdp`, `Xdpp`, `Xq`, `Xl`, `S10`, `S12`, `mva` | `ir`, `ii`, `p`, `q`, `delta`, `omega`, `speed`, `Eqp`, `psidp`, `psiqpp`, `psidpp`, `vd`, `vq`, `te`, `id`, `iq`

tests/UnitTests/PhasorDynamics/BranchTests.hpp

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,15 @@ namespace GridKit
9292

9393
TestOutcome offNominalResidual()
9494
{
95-
// Verifies tap and phase-shift current residual contributions.
95+
// Verifies tap, phase-shift, line-shunt, and magnetizing-shunt contributions.
9696
TestStatus success = true;
9797

9898
RealT R{2.0};
9999
RealT X{4.0};
100-
RealT G{0.2};
101-
RealT B{1.2};
100+
RealT G{0.4};
101+
RealT B{0.8};
102+
RealT Gmag{0.2};
103+
RealT Bmag{1.2};
102104
RealT tap{1.25};
103105
RealT phase{0.3};
104106

@@ -107,10 +109,10 @@ namespace GridKit
107109
ScalarT Vr2{30.0};
108110
ScalarT Vi2{40.0};
109111

110-
const ScalarT Ir1{12.719793434963478};
111-
const ScalarT Ii1{-4.047960563981182};
112-
const ScalarT Ir2{13.821345956502421};
113-
const ScalarT Ii2{-21.182080826645354};
112+
const ScalarT Ir1{18.719793434963478};
113+
const ScalarT Ii1{-12.047960563981182};
114+
const ScalarT Ir2{23.821345956502421};
115+
const ScalarT Ii2{-41.182080826645354};
114116

115117
PhasorDynamics::Bus<ScalarT, IdxT> bus1(Vr1, Vi1);
116118
PhasorDynamics::Bus<ScalarT, IdxT> bus2(Vr2, Vi2);
@@ -121,7 +123,20 @@ namespace GridKit
121123
bus2.initialize();
122124
bus2.evaluateResidual();
123125

124-
PhasorDynamics::Branch<ScalarT, IdxT> branch(&bus1, &bus2, R, X, G, B, tap, phase);
126+
using Data = typename PhasorDynamics::Branch<ScalarT, IdxT>::ModelDataT;
127+
using Parameter = typename Data::Parameters;
128+
129+
Data data;
130+
data.parameters[Parameter::R] = R;
131+
data.parameters[Parameter::X] = X;
132+
data.parameters[Parameter::G] = G;
133+
data.parameters[Parameter::B] = B;
134+
data.parameters[Parameter::Gmag] = Gmag;
135+
data.parameters[Parameter::Bmag] = Bmag;
136+
data.parameters[Parameter::tap] = tap;
137+
data.parameters[Parameter::phase] = phase;
138+
139+
PhasorDynamics::Branch<ScalarT, IdxT> branch(&bus1, &bus2, data);
125140
branch.allocate();
126141
branch.evaluateResidual();
127142

@@ -385,12 +400,12 @@ namespace GridKit
385400
const std::complex<RealT> ybr{g, b};
386401
const std::complex<RealT> ysh{G, B};
387402
const std::complex<RealT> rotation{std::cos(phase), std::sin(phase)};
388-
const std::complex<RealT> ydiag = -(ybr + RealT{0.5} * ysh);
403+
const std::complex<RealT> ydiag = -ybr;
389404

390-
const std::complex<RealT> y11 = ydiag * inv_tap * inv_tap;
405+
const std::complex<RealT> y11 = ydiag * inv_tap * inv_tap - RealT{0.5} * ysh;
391406
const std::complex<RealT> y12 = ybr * rotation * inv_tap;
392407
const std::complex<RealT> y21 = ybr * std::conj(rotation) * inv_tap;
393-
const std::complex<RealT> y22 = ydiag;
408+
const std::complex<RealT> y22 = ydiag - RealT{0.5} * ysh;
394409

395410
std::vector<DependencyTracking::Variable::DependencyMap> dependencies(4);
396411
dependencies[0] = {{0, y11.real()}, {1, -y11.imag()}, {2, y12.real()}, {3, -y12.imag()}};

tests/UnitTests/Utilities/CaseFormatTests.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ namespace GridKit
6161
{ "number": 2, "class": "infinite_bus", "name": "Bus 2", "init": {"Vr":1.0, "Vi":0.0}, "params": {"kv": 115.0} }
6262
],
6363
"devices": [
64-
{ "class": "Branch", "ports": {"bus1":1, "bus2":2}, "id": "1", "params": {"R":0.0, "X":0.1, "G":0.0, "B":0.0, "tap":1.05, "phase":0.1} },
64+
{ "class": "Branch", "ports": {"bus1":1, "bus2":2}, "id": "1", "params": {"R":0.0, "X":0.1, "G":0.0, "B":0.0, "Gmag":0.01, "Bmag":0.02, "tap":1.05, "phase":0.1} },
6565
{ "class": "Genrou", "ports": {"bus":1}, "id": "1", "params": {"p0":1.0, "q0":0.05013, "H":3.0, "D":0.0, "Ra":0.0, "Tdop":7.0, "Tdopp":0.04, "Tqopp":0.05,
6666
"Tqop":0.75, "Xd":2.1, "Xdp":0.2, "Xdpp":0.18, "Xq":0.5, "Xqp": 0.0, "Xqpp":0.18, "Xl":0.15, "S10":0.0, "S12":0.0}, "mon": ["delta", "omega"] },
6767
{ "class": "Gensal", "ports": {"bus":1}, "id": "2", "params": {"p0":1.0, "q0":0.05013, "H":3.0, "D":0.0, "Ra":0.0, "Tdop":7.0, "Tdopp":0.04, "Tqopp":0.05,
@@ -114,6 +114,8 @@ namespace GridKit
114114
success *= std::get<RealT>(result.branch[0].parameters[BranchParameters::X]) == 0.1;
115115
success *= std::get<RealT>(result.branch[0].parameters[BranchParameters::G]) == 0.0;
116116
success *= std::get<RealT>(result.branch[0].parameters[BranchParameters::B]) == 0.0;
117+
success *= std::get<RealT>(result.branch[0].parameters[BranchParameters::Gmag]) == 0.01;
118+
success *= std::get<RealT>(result.branch[0].parameters[BranchParameters::Bmag]) == 0.02;
117119
success *= std::get<RealT>(result.branch[0].parameters[BranchParameters::tap]) == 1.05;
118120
success *= std::get<RealT>(result.branch[0].parameters[BranchParameters::phase]) == 0.1;
119121
success *= result.branch[0].buses[BranchBuses::bus1] == 1;

0 commit comments

Comments
 (0)