The Museum of HP Calculators

Two-bus AC Power Transfer for the HP-32SII

This program is by Karl Schneider and is used here by permission.

This program is supplied without representation or warranty of any kind. Karl Schneider and The Museum of HP Calculators therefore assume no responsibility and shall have no liability, consequential or otherwise, of any kind arising from the use of this program material or any part thereof.


PROGRAM FUNCTION: Calculates transfer of complex power between two AC buses





This program calculates the total active (real) power "P" and reactive power "Q" injected into either end of an AC line or pair of paralleled AC lines joined by two buses. The AC line(s) may be three-phase or single-phase.

Each AC line is modeled with one set of "balanced-pi" parameters of series resistance, series reactance, and shunt susceptance. The AC bus voltages are defined in terms of rms magnitudes and a phase-angle difference.

The program includes a routine "Z" that will calculate the equivalent parameters of a parallel line-pair, if needed. The user may also run "Z" separately as a stand-alone program.


Total storage:        246.5 bytes

Program labels:    4 (166.5 bytes)

Stored variables: 10 ( 80.0 bytes)

Flags:             1 (flag 2)


Label  Bytes  Checksum  Description

  S    19.5     D02C    Starts program; prompts for input variables

  C    42.0     671D    Drives calculation of the output variables

  P    51.0     843E    Calculates all injections of real and reactive power

  Z    54.0     A2F4    Calculates equivalent parameters of line-pair

INPUT VARIABLES (in order of entry):

Variable  Description                              Unit of measure    Notes

   V      Voltage magnitude at first bus           [per unit]         (1)

   W      Voltage magnitude at second bus          [per unit]         (1)

   D      Voltage-angle difference between buses   [degrees]          (2)

   R      Series resistance of line                [per unit]         (3)

   X      Series reactance of line                 [per unit]         (3)

   B      Total shunt susceptance of line          [per unit]         (4)

   R      Series resistance of second line         [per unit]         (3,5)

   X      Series reactance of second line          [per unit]         (3,5)

   B      Total shunt susceptance of second line   [per unit]         (4,5)

(1)  1-phase lines: Base voltage is rms nominal line-ground (LG) voltage
     3-phase lines: Base voltage is rms nominal line-line (LL) voltage = sqrt(3)*LG

(2)  Positive-valued angle difference is inputted for voltage at the first bus
     leading that of the second bus; negative-valued angle difference is entered
     for a lagging first-bus voltage.

(3)  Base impedance for R and X is the squared base voltage divided by power base
     (100 MVA in line P27).

(4)  Base admittance for B is the reciprocal of base impedance.

(5)  R, X, and B for the second line are to be input only if two lines are modeled.

OUTPUT VARIABLES (in order of display):

Variable   Description                                    Unit of measure   Notes

   P, S    Real power injected by first bus               [MW]              (6,7)

   Q, T    Reactive power injected by first bus           [MVAr]            (6,8)

   P       Real power injected by second bus              [MW]              (6)

   Q       Reactive power injected by second bus          [MVAr]            (6)

stack y    Real-power consumption (losses) on the line    [MW]              (6)

stack x    Reactive-power consumption on the line         [MVAr]            (6)

(6)  These units (MW or MVAr) assume a base voltage in kV and base power of 100 MVA.

(7)  P is re-stored to variable S when second-bus power is calculated.

(8)  Q is re-stored to variable T when second-bus power is calculated.


  1. Set Flag 2 if two parallel transmission lines are to be entered

  2. Start program using "XEQ S"

  3. Enter input variables V, W, D, R, X, and B

  4. Enter additional input variables R, X, and B for second line if necessary

  5. Read total first-bus real power P; press "R/S"

  6. Read total first-bus reactive power Q; press "R/S"

  7. Read total second-bus real power P; press "R/S"

  8. Read total second-bus reactive power Q; press "R/S"

  9. Read total real-power line losses, then reactive power line losses after pause



S01  LBL S       Enter main program
S02  DEG
S03  INPUT V     First-bus voltage magnitude (V1)
S04  INPUT W     Second-bus voltage magnitude (V2)
S05  INPUT D     Voltage-angle difference (d)
S06  FS? 2       2-line network?
S07  XEQ Z       -- If yes, run parallel-line program
S08  FS? 2
S09  GTO C
S08  INPUT R     -- Else, enter line parameters here
S12  GTO C

C01  LBL C
C02  CF 2
C03  XEQ P       Calculate power from first bus
C04  RCL P
C05  STO S       Store P from first bus
C06  RCL Q
C07  STO T       Store Q from first bus
C08  RCL V       Set variables to calculate power from second bus:
C09  x<> W       -- Swap V and W
C10  STO V
C11  RCL D       -- Change sign of D
C12  +/-
C13  STO D
C14  XEQ P       Calculate power from second bus
C15  RCL V       Restore original values of V, W, and D
C16  x<> W
C17  STO V
C18  RCL D
C19  +/-
C20  STO D
C21  RCL T
C22  RCL S
C23  RCL Q
C24  RCL P
C25  CMPLX+      Add complex power at first bus and second bus
C26  PSE         Display P losses
C27  x<>y        Display Q losses
C28  RTN

P01  LBL P       Begin calculation of power injections
P02  RCL D       Voltage-angle difference (d)
P03  RCL V       First-bus voltage magnitude (V1)
P04  RCL W       Second-bus voltage magnitude (V2)
P05  *
P06  Th,r->y,x
P07  0
P08  RCL V
P09  x2
P10  Rdown
P11  Rdown
P12  CMPLX-      V_dif = V1^2 - V1*V2*(cos d + j*sin d)
P13  RCL X
P14  +/-
P15  RCL R
P16  CMPLX/      S through line [in pu] = V_dif / (R - j*X)
P17  RCL B
P18  2
P19  /
P20  RCL V
P21  x2
P22  *
P23  0
P24  CMPLX-     Subtract line-charging Q (= j*B/2 * V1^2)
P25  0
P27  100        Power base = 100 MVA
P28  CMPLX*     Multiply P and net Q by power base
P29  STO P
P30  VIEW P     Show P injected into line(s)
P31  x<>y
P32  STO Q
P33  VIEW Q     Show Q injected into line(s)
P34  RTN

Z01  LBL Z
Z02  INPUT R    Enter resistance of first line (R1)
Z03  INPUT X    Enter reactance of first line  (X1)
Z04  INPUT B    Enter susceptance of first line (B1)
Z05  RCL X
Z06  RCL R
Z07  CMPLX1/x
Z08  STO S      Real part in temporary storage
Z09  x<>y
Z10  STO T      Imaginary part in temporary storage
Z11  INPUT R    Enter resistance of second line (R2)
Z12  INPUT X    Enter reactance of second line  (X2)
Z13  RCL X
Z14  RCL R
Z15  CMPLX1/x
Z16  RCL T
Z17  RCL S
Z19  CMPLX1/x   (Req + j*Xeq) = (R1+ j*X1) || (R2 + j*X2)
Z20  STO R
Z21  x<>y
Z22  STO X
Z23  RCL B
Z24  STO S
Z25  INPUT B    Enter susceptance of second line (B2)
Z26  RCL+ S
Z27  STO B      Beq = B1 + B2
Z28  CLx
Z29  STO S      Deallocate S and T registers
Z30  STO T
Z31  FS? 2      Is "Z" being run from AC transfer program?
Z32  RTN        -- If yes, return without displaying results
Z33  VIEW R     -- Else, display Req, Xeq, Beq in sequence
Z36  RTN

Go back to the software library
Go back to the main exhibit hall