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 , 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 that points down, shortening the triangle's vertical side.
- Find the 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?
To 0.8 of what it was. The line current is set by the apparent power, . Correction leaves alone and shrinks from kVA to 5 kVA, a factor of 0.8. The losses in the wiring go as the current squared, so they fall to 0.64 of what they were, which is why utilities care.
Name it
Complex power in Python
With RMS phasors, , which in Python is S = V * I.conjugate(). Then:
- real power =
S.real, in watts; - reactive power =
S.imag, in vars, positive for an inductive load; - apparent power =
abs(S), in VA; - power factor = .
With amplitude phasors, use instead.
Correcting the power factor
A capacitor across the load supplies reactive power . To bring the power factor from to , it must supply , so
Three phases as a list
A balanced set of phase voltages is three phasors , and . 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:
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 A RMS. Find , , and the power factor.
Show the solution
- Complex power.
- Real and reactive power. The load takes 996 W of real power and 575 var of reactive power.
- Power factor. lagging.
Answer VA, = 996 W, = 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
- Load angle.
- Reactive power to cancel.
- Capacitor.
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
- Add the real parts. Adding , and , the real parts give
- Add the imaginary parts.
- Size of the neutral current. at .
Answer 3.46 A flows in the neutral, at .
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 , , ; 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 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?
Reactive power is energy that sloshes back and forth between the source and the load's magnetic or electric fields twice each cycle, doing no net work. But to carry it, current has to flow: the line current is set by the apparent power , and with present it's larger than the real power alone requires. That extra current heats every wire and transformer between the generator and the factory, as , and it takes up capacity that could have carried real power to someone else, so the utility must build bigger equipment to deliver the same useful energy. Correcting the power factor with capacitors near the load supplies the reactive power locally, so it no longer travels through the grid.
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.