A326 of 29
0 XP
  1. Hook
  2. Play
  3. Predict
  4. Name it
  5. Check
  6. Explain

A3 · Lesson 26 · Lab: AC power in Python

Complex power, power-factor correction and three phases, computed

Utilities bill industrial customers for poor power factor, three-phase systems need their neutral currents checked, and every power supply's harmonics have to be counted. All of it is arithmetic with phasors, which makes it a natural job for Python. In this lab you'll compute complex power from voltage and current, size a correction capacitor, build a three-phase system as a list of phasors, and check the formula for the RMS of a signal with several frequencies against a direct calculation. If you haven't started A4 yet, its lessons on functions, loops and lists (lessons 1 to 8) cover the Python used here.

  • A load takes real power P, in kW, at a power factor that you set. The arrows are the power triangle: real power along the axis, reactive power up, and the apparent power as the long side.
  • Add correction: a capacitor supplies reactive power QC that points down, shortening the triangle's vertical side.
  • Find the QC that makes the power factor 1. How much shorter is the apparent power arrow?

Predict

A 5 kW load at power factor 0.8 is corrected to 1. By what factor does the current it draws from the line fall?

Name it

Complex power in Python

With RMS phasors, S=VI*, which in Python is S = V * I.conjugate(). Then:

  • real power P = S.real, in watts;
  • reactive power Q = S.imag, in vars, positive for an inductive load;
  • apparent power |S| = abs(S), in VA;
  • power factor = P/|S|.

With amplitude phasors, use S=12VI* instead.

Correcting the power factor

A capacitor across the load supplies reactive power QC=V2ωC. To bring the power factor from cos⁡φ1 to cos⁡φ2, it must supply QC=P(tan⁡φ1−tan⁡φ2), so

C=P(tan⁡φ1−tan⁡φ2)2πfV2

Three phases as a list

A balanced set of phase voltages is three phasors Vp∠0°, Vp∠−120° and Vp∠120°. The line voltages are the differences between pairs, and the neutral current is the sum of the three phase currents. A list and a loop handle any number of phases or any imbalance.

RMS of several frequencies

For a signal made of a DC part and sinusoids at different frequencies, the mean squares add:

Vrms2=V02+A122+A222+⋯

A direct check samples one full period of the slowest component, squares, averages and takes the root.

Worked example

A load on 230 V RMS draws 5∠−30° A RMS. Find S, P, Q and the power factor.

Show the solution
  1. Complex power. S=VI*=230×5∠30°=1150∠30°VA=996+j575VA
  2. Real and reactive power. The load takes 996 W of real power and 575 var of reactive power.
  3. Power factor. cos⁡30°=0.866 lagging.

Answer S=1150∠30° VA, P = 996 W, Q = 575 var, and the power factor is 0.866 lagging.

Worked example

A 5 kW load at power factor 0.8 is on 230 V, 50 Hz. What capacitor brings it to unity?

Show the solution
  1. Load angle. tan⁡φ1=tan⁡(arccos⁡0.8)=0.75
  2. Reactive power to cancel. QC=5000×0.75=3750var
  3. Capacitor. C=37502π×50×2302F=225.6μF

Answer a 225.6 µF capacitor brings it to unity.

Worked example

A 120 V phase system has phase currents of 10 A, 8 A and 6 A, each in phase with its own voltage. What flows in the neutral?

Show the solution
  1. Add the real parts. Adding 10∠0°, 8∠−120° and 6∠120°, the real parts give 10−4−3=3
  2. Add the imaginary parts. −6.928+5.196=−1.732
  3. Size of the neutral current. |In|=32+1.7322=3.46A at −30°.

Answer 3.46 A flows in the neutral, at −30°.

Check

A 5 kW load at power factor 0.7 is on 230 V RMS, 60 Hz. What capacitance corrects it to unity?

Write units the way you normally would: 1.5 F, 1500 mF and 0.0015 kF are the same answer.

Check

A signal is 5 V DC plus 1 V amplitude at 1 kHz plus 3 V amplitude at 3 kHz. What is its RMS value?

Write units the way you normally would: 1.5 V, 1500 mV and 0.0015 kV are the same answer.

Check

Write complex_power(V, I), taking RMS phasors and returning (P, Q, pf).

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Check

Write correction_C(P, pf_now, pf_target, V, f), returning the capacitance that raises a lagging load's power factor from pf_now to pf_target.

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Check

Write phases(Vp), returning the list of three phasors Vp∠0°, Vp∠−120°, Vp∠120°; line_voltage(a, b), returning abs(a - b); and neutral(currents), returning the size of the sum of a list of phasors.

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Check

Write rms_by_samples(V0, parts, f1, N). parts is a list of (A, f) pairs, sinusoids Acos⁡2πft added to the DC level V0, all with frequencies that are whole multiples of f1. Sample one period of f1 at N evenly spaced times, square, average and take the root. The test compares it with the formula.

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Explain why

A factory is billed for reactive power even though reactive power does no work. Why does it cost the utility anything?

Practice

Keep practicing

4 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.