TExcelTAD
Home › Circuit Theory & Network Analysis › AC Nodal and Mesh Analysis

AC Nodal and Mesh Analysis

A sensor interface has two sinusoidal sources at the same frequency, an excitation and a quadrature reference shifted by 90∘90^\circ, feeding a small network of resistors, a capacitor and an inductor. You need the voltage at two internal nodes, amplitude and phase. In the time domain this is a set of coupled differential equations. In sinusoidal steady state it is the same linear system you solved in Node-Voltage Analysis and Mesh-Current Analysis, with complex numbers: replace every element by its impedance (Impedance and Admittance), every source by its phasor (Sinusoids and Phasors), and solve.

Why the DC methods carry over

Kirchhoff's laws hold at every instant. If every voltage and current is a sinusoid at one frequency ω\omega, KCL at a node, ∑kik(t)=0\sum_k i_k(t) = 0, becomes Re⁡{(∑kIk)ejωt}=0\operatorname{Re}\{(\sum_k \mathbf{I}_k) e^{j\omega t}\} = 0 for all tt, which forces ∑kIk=0\sum_k \mathbf{I}_k = 0. The same argument gives KVL for phasors. Together with V=ZI\mathbf{V} = Z\mathbf{I} for every element, the phasor circuit obeys exactly the rules of a resistive circuit; only the arithmetic is complex.

So the recipe is:

  1. Check that every source has the same frequency (otherwise use superposition, AC Thevenin, Norton and Superposition).
  2. Convert sources to phasors (one convention: here RMS) and elements to impedances at that ω\omega.
  3. Write nodal equations (YV=IsY\mathbf{V} = \mathbf{I}_s) or mesh equations (ZI=VsZ\mathbf{I} = \mathbf{V}_s) by inspection, exactly as for DC.
  4. Solve with complex arithmetic, convert results to polar form, and if needed back to time functions.

The admittance matrix of a network of R, L and C (no dependent sources) is still symmetric; it is no longer positive definite, and at special frequencies it can become nearly singular, which is how resonance shows up in a matrix (Linear Systems).

+ V1 10 V, 0 deg R1 100 Ohm C1 1 uF L1 10 mH R2 50 Ohm R3 100 Ohm + V2 5 V, -90 deg a b c d I1 I2 I3 rms phasors, f = 1 kHz

Worked example: two sources, two methods

Given: the circuit above at f=1 kHzf = 1\ \text{kHz} (ω=6283 rad/s\omega = 6283\ \text{rad/s}): V1=10 V∠0∘\mathbf{V}_1 = 10\ \text{V} \angle 0^\circ, V2=5 V∠−90∘\mathbf{V}_2 = 5\ \text{V} \angle -90^\circ (RMS), R1=100 ΩR_1 = 100\ \Omega, C1=1 μFC_1 = 1\ \mu\text{F}, L1=10 mHL_1 = 10\ \text{mH}, R2=50 ΩR_2 = 50\ \Omega, R3=100 ΩR_3 = 100\ \Omega.

Find: the node voltages Vb\mathbf{V}_b and Vc\mathbf{V}_c, by nodal analysis, then check by mesh analysis.

Solve (nodal). Impedances: ZC=−j159.15 ΩZ_C = -j159.15\ \Omega, ZL=j62.83 ΩZ_L = j62.83\ \Omega. In admittances, 1/ZC=j6.283 mS1/Z_C = j6.283\ \text{mS} and 1/ZL=−j15.915 mS1/Z_L = -j15.915\ \text{mS}. KCL at b and c (leaving = positive):

Vb−V1R1+VbZC+Vb−VcZL=0Vc−VbZL+VcR2+Vc−V2R3=0\begin{aligned} \frac{\mathbf{V}_b - \mathbf{V}_1}{R_1} + \frac{\mathbf{V}_b}{Z_C} + \frac{\mathbf{V}_b - \mathbf{V}_c}{Z_L} &= 0 \\ \frac{\mathbf{V}_c - \mathbf{V}_b}{Z_L} + \frac{\mathbf{V}_c}{R_2} + \frac{\mathbf{V}_c - \mathbf{V}_2}{R_3} &= 0 \end{aligned}

In matrix form, in mS and mA:

[10−j9.632j15.915j15.91530−j15.915][VbVc]=[100−j50]\begin{bmatrix} 10 - j9.632 & j15.915 \\ j15.915 & 30 - j15.915 \end{bmatrix} \begin{bmatrix} \mathbf{V}_b \\ \mathbf{V}_c \end{bmatrix} = \begin{bmatrix} 100 \\ -j50 \end{bmatrix}

The diagonal entries are the sums of the admittances touching each node, the off-diagonal entries minus the admittance between them, as in the DC case. Solving (Cramer's rule by hand is tedious but possible; the script below does it) gives

Vb=4.526 V∠12.42∘,Vc=3.573 V∠−54.72∘\mathbf{V}_b = 4.526\ \text{V} \angle 12.42^\circ, \qquad \mathbf{V}_c = 3.573\ \text{V} \angle -54.72^\circ

Solve (mesh). With clockwise mesh currents, the mesh impedance matrix is again built by inspection: self-impedances on the diagonal, minus shared impedances off the diagonal. V1\mathbf{V}_1 drives mesh 1 forward; mesh 3 enters V2\mathbf{V}_2 at its + terminal, so V2\mathbf{V}_2 appears with a minus sign:

[R1+ZC−ZC0−ZCZC+ZL+R2−R20−R2R2+R3][I1I2I3]=[V10−V2]\begin{bmatrix} R_1 + Z_C & -Z_C & 0 \\ -Z_C & Z_C + Z_L + R_2 & -R_2 \\ 0 & -R_2 & R_2 + R_3 \end{bmatrix} \begin{bmatrix} \mathbf{I}_1 \\ \mathbf{I}_2 \\ \mathbf{I}_3 \end{bmatrix} = \begin{bmatrix} \mathbf{V}_1 \\ 0 \\ -\mathbf{V}_2 \end{bmatrix}

which gives I1=56.64 mA∠−9.89∘\mathbf{I}_1 = 56.64\ \text{mA} \angle -9.89^\circ, I2=72.39 mA∠−31.21∘\mathbf{I}_2 = 72.39\ \text{mA} \angle -31.21^\circ, I3=29.32 mA∠45.27∘\mathbf{I}_3 = 29.32\ \text{mA} \angle 45.27^\circ.

Check: Vb=ZC(I1−I2)\mathbf{V}_b = Z_C(\mathbf{I}_1 - \mathbf{I}_2) and Vc=R2(I2−I3)\mathbf{V}_c = R_2(\mathbf{I}_2 - \mathbf{I}_3) reproduce the nodal results. Note ∣I2∣>∣I1∣\lvert \mathbf{I}_2 \rvert > \lvert \mathbf{I}_1 \rvert: the middle mesh carries more current than the source mesh, because the capacitor and the inductor partly cancel each other's reactance in it. Nodal analysis needed a 2×22 \times 2 system and mesh analysis a 3×33 \times 3 one, so nodal was the better choice here.

In Python

python · try it yourself
import numpy as np

def pol(z, unit="V"):
    return f"{abs(z):7.4f} {unit} at {np.degrees(np.angle(z)):+8.3f} deg"

w = 2 * np.pi * 1e3
R1, R2, R3 = 100.0, 50.0, 100.0
ZC = 1 / (1j * w * 1e-6)                 # C1 = 1 uF
ZL = 1j * w * 10e-3                      # L1 = 10 mH
V1 = 10.0                                # rms phasor, 0 deg
V2 = 5.0 * np.exp(-1j * np.pi / 2)       # rms phasor, -90 deg

# nodal: unknowns Vb, Vc (admittances in S)
Y = np.array([[1/R1 + 1/ZC + 1/ZL, -1/ZL],
              [-1/ZL, 1/ZL + 1/R2 + 1/R3]])
i = np.array([V1 / R1, V2 / R3])
Vb, Vc = np.linalg.solve(Y, i)
print("nodal: Vb =", pol(Vb), "| Vc =", pol(Vc))

# mesh: three clockwise mesh currents (impedances in ohm)
Z = np.array([[R1 + ZC, -ZC, 0],
              [-ZC, ZC + ZL + R2, -R2],
              [0, -R2, R2 + R3]])
e = np.array([V1, 0, -V2])
I1, I2, I3 = np.linalg.solve(Z, e)
for k, I in enumerate((I1, I2, I3), 1):
    print(f"mesh:  I{k} =", pol(I * 1e3, "mA"))
print("mesh:  Vb =", pol((I1 - I2) * ZC), "| Vc =", pol((I2 - I3) * R2))
print("methods agree:", np.allclose([Vb, Vc], [(I1 - I2) * ZC, (I2 - I3) * R2]))
nodal: Vb =  4.5261 V at  +12.417 deg | Vc =  3.5731 V at  -54.720 deg
mesh:  I1 = 56.6396 mA at   -9.894 deg
mesh:  I2 = 72.3862 mA at  -31.207 deg
mesh:  I3 = 29.3233 mA at  +45.268 deg
mesh:  Vb =  4.5261 V at  +12.417 deg | Vc =  3.5731 V at  -54.720 deg
methods agree: True

np.linalg.solve works on complex matrices with no change at all: the same call as in DC nodal analysis.

Cross-check with SPICE

ngspice's .ac analysis solves exactly this phasor problem. A sweep with one point (ac lin 1 1k 1k) gives the single-frequency answer; source lines take AC magnitude phase with the phase in degrees. vm() is the magnitude and vp() the phase, which ngspice reports in radians, so the deck converts it.

bash · try it yourself
cat > acnodal.cir <<'EOF'
* AC nodal example at 1 kHz: two sources, R, C, L
V1 a 0 AC 10 0
R1 a b 100
C1 b 0 1u
L1 b c 10m
R2 c 0 50
R3 c d 100
V2 d 0 AC 5 -90
.control
ac lin 1 1k 1k
let phb = 180/pi*vp(b)
let phc = 180/pi*vp(c)
print vm(b) phb vm(c) phc
.endc
.end
EOF
ngspice -b acnodal.cir 2>&1 | grep -E '^(vm|phb|phc)'
vm(b) = 4.526139e+00
phb = 1.241662e+01
vm(c) = 3.573095e+00
phc = -5.47197e+01

Four significant figures agree with NumPy. SPICE does not know whether you mean RMS or peak: the answer has whatever convention the source values have.

Interactive: the netlist lab

02461001k10kf (Hz)|V| (V)0 A50 mA|I| (A)|V(b)||V(c)||I(L1)|phasors at f = 1.000 kHz (magnitude @ phase)V(a)10.0 V @ 0.0 degV(b)4.53 V @ 12.4 degV(c)3.57 V @ -54.7 degV(d)5.00 V @ -90.0 degI(V1)56.6 mA @ 170.1 degI(R1)56.6 mA @ -9.9 degI(C1)28.4 mA @ 102.4 degI(L1)72.4 mA @ -31.2 degI(R2)71.5 mA @ -54.7 degI(R3)29.3 mA @ 45.3 degI(V2)29.3 mA @ 45.3 deg

At 1 kHz1\ \text{kHz} the lab reads V(b)=4.526 V∠12.4∘\mathbf{V}(b) = 4.526\ \text{V} \angle 12.4^\circ and V(c)=3.573 V∠−54.7∘\mathbf{V}(c) = 3.573\ \text{V} \angle -54.7^\circ; I(L1)=I2\mathbf{I}(L_1) = \mathbf{I}_2, 72.39 mA72.39\ \text{mA}. Sweep ff: the reactances of C1C_1 and L1L_1 change in opposite directions, so both node voltages change in amplitude and phase. At every frequency the lab solves the same kind of complex 2×22 \times 2 nodal system, just with new matrix entries.

Guided lab: one source on the bench

Hand calculation. Two phase-locked generators are rare on a student bench, so build the network with V2\mathbf{V}_2 switched off: connect R3R_3's free end to ground. Drive node a from one generator at 1.00 kHz1.00\ \text{kHz}, 5.0 V5.0\ \text{V} peak. The script with V1 = 5.0 and V2 = 0 gives Vb=2.827 V∠20.3∘\mathbf{V}_b = 2.827\ \text{V} \angle 20.3^\circ and Vc=1.325 V∠−41.8∘\mathbf{V}_c = 1.325\ \text{V} \angle -41.8^\circ (peak values, since the source is given as a peak).

Simulation. In the deck set V1 a 0 AC 5 0 and V2 d 0 AC 0, and in the Python script V1 = 5.0 and V2 = 0: SPICE and Python must agree before you touch hardware.

What you would measure. Channel 1 on node a, channel 2 on b, then on c, all probe grounds on the circuit ground. Expect b at about 2.83 V2.83\ \text{V} peak, leading the source by 20∘20^\circ (56 μs56\ \mu\text{s} earlier), and c at about 1.33 V1.33\ \text{V} peak, lagging by 42∘42^\circ (116 μs116\ \mu\text{s} later). With 5 % capacitors and 10 % inductors (whose winding resistance, perhaps 1010 to 30 Ω30\ \Omega, also adds in series with L1L_1) expect deviations of several percent in amplitude and a few degrees in phase; add the measured winding resistance to the model and the agreement should improve to the resistor tolerance.

Hazards and safe setup. Function generator only, ≤10 V\le 10\ \text{V} peak. The highest current, in L1L_1, is under 40 mA40\ \text{mA} peak; resistor dissipation stays below 50 mW50\ \text{mW}. All scope grounds on the same node, because they are tied together and to earth inside the scope.

Pitfalls

  • Degrees in np.exp. Phasor angles must be converted with np.deg2rad before use.
  • ngspice phases in radians. vp() returns radians; convert, or use cph() and convert as well.
  • Mixed RMS and peak sources. Both sources in one circuit must use the same convention.
  • Different-frequency sources cannot share one phasor solve.
  • Forgetting that the matrix is complex. Building it with np.zeros((2, 2)) and then assigning complex entries silently drops the imaginary parts (NumPy warns and casts); start from np.zeros((2, 2), dtype=complex) or build it as above.

Practice

  1. Redo the nodal solution with V2=0\mathbf{V}_2 = 0 (so R3R_3 goes to ground) and V1=10 V\mathbf{V}_1 = 10\ \text{V}: what is Vb\mathbf{V}_b?
  2. In the mesh matrix, which entries change if C1C_1 is replaced by a 2 μF2\ \mu\text{F} capacitor?
  3. A circuit has 6 nodes (including ground), 8 branches and no current sources. How many equations does nodal analysis need, and how many does mesh analysis need (planar circuit)?
Answer
  1. Linearity: the bench result scaled by 2, Vb=5.654 V∠20.3∘\mathbf{V}_b = 5.654\ \text{V} \angle 20.3^\circ (RMS if V1\mathbf{V}_1 is RMS).
  2. Every entry containing ZCZ_C: Z11Z_{11}, Z12Z_{12}, Z21Z_{21} and Z22Z_{22}; ZCZ_C becomes −j79.58 Ω-j79.58\ \Omega.
  3. Nodal: N−1=5N - 1 = 5 equations (fewer if voltage sources fix some nodes). Mesh: B−N+1=8−6+1=3B - N + 1 = 8 - 6 + 1 = 3 equations.

Test yourself

In AC nodal analysis, what is the off-diagonal entry YbcY_{bc} when only an inductor LL joins nodes b and c?

  1. jωLj\omega L
  2. −1/(jωL)=j/(ωL)-1/(j\omega L) = j/(\omega L)
  3. 1/(jωL)1/(j\omega L)
  4. −jωL-j\omega L

Two sources in a circuit run at 1 kHz and 2 kHz. How do you find the steady-state response?

  1. one phasor solve with both sources
  2. solve at each frequency separately and add the time functions
  3. average the frequencies
  4. it cannot be found

ngspice prints vp(b) = 2.167e-01 after an AC analysis. What phase is that in degrees?

  1. 0.22∘0.22^\circ
  2. 12.4∘12.4^\circ
  3. 21.7∘21.7^\circ
  4. −12.4∘-12.4^\circ

Why is the admittance matrix of an R, L, C network symmetric?

  1. because all impedances are real
  2. because each two-terminal element adds the same −Y-Y to both YkmY_{km} and YmkY_{mk}
  3. because the frequency is fixed
  4. it is never symmetric