' Given phase impedance, compute phase currents, then line currents
' reverse the process to recover the phase currents
' line X is connected to phases B and C, opposite phase A
' line Y is connected to phases C and A, opposite phase B
' line Z is connected to phases A and B, opposite phase C
' topology: currents flow counter-clockwise in the delta, A to B to C
' currents flow towards the supply generator in X, Y and Z
' declare state variables
Complex Xv, Yv, Zv ' line voltages
Complex Xi, Yi, Zi ' line currents
Complex Av, Bv, Cv ' phase voltages
Complex Az, Bz, Cz ' phase impedances
Complex Ai, Bi, Ci ' phase currents
' initial line voltages
Double Vrms, Vpk, phase
Vrms = 230 ' neutral to any phase
Vpk = Vrms * Sqr( 2 )
' phasors
phase = 0
Xv = Type( Vpk * Cos( phase ), Vpk * Sin( phase ) )
phase = + TwoPi / 3
Yv = Type( Vpk * Cos( phase ), Vpk * Sin( phase ) )
phase = - TwoPi / 3
Zv = Type( Vpk * Cos( phase ), Vpk * Sin( phase ) )
' phases voltages are line differences
Av = Yv - Zv
Bv = Zv - Xv
Cv = Xv - Yv
' generate random phase impedances
Randomize
Az = Type(200 * Rnd, 100 * ( Rnd - 0.5) )
Bz = Type(200 * Rnd, 100 * ( Rnd - 0.5) )
Cz = Type(200 * Rnd, 100 * ( Rnd - 0.5) )
' phase currents
Ai = Av / Az
Bi = Bv / Bz
Ci = Cv / Cz
' line currents
Xi = Ci - Bi
Yi = Ai - Ci
Zi = Bi - Ai
' now we are ready to go backwards
' we know
' Xi = Ci - Bi
' Yi = Ai - Ci
' Zi = Bi - Ai
Ai = Type( 2, -1 ) ' assume something new for Ai
Bi = Type( 0, 0 ) ' blind trial, hide original
Ci = Type( 0, 0 ) ' blind trial, hide original
' then compute Ai, in a circular argument
Ci = Ai + Yi
Bi = Ci + Xi
Ai = Bi + Zi
' now, Ai is whatever was assumed a few lines back
' there are an infinity of solutions.