Life With and Without Phasors: Example Circuit Analysis
import matplotlib.pyplot as plt
import numpy as np
import schemdraw
import schemdraw.elements as elm
from sympy import (
Derivative,
Eq,
Function,
atan,
cos,
exp,
lambdify,
sin,
solve,
sqrt,
symbols,
)
from sympy import I as j
from src.drawing_utils import clear_axes
from src.figure_utils import process_figure
from src.plotting_utils import configure_matplotlib, rm, set_discrete_colors
from src.schemdraw_utils import configure_schemdraw
configure_matplotlib()
configure_schemdraw()
One of the main reasons for many people being confused about phasors is that phasors are abstract, but they don’t understand why the abstraction exists. In other words, they may know what phasors represent, but they don’t know what they replace—they don’t know of any alternative approach for analyzing AC circuits that can be used to put phasors in perspective. This is understandable as many electrical engineering textbooks poorly explain why we use phasors.
With the aid of an example AC circuit (Figure 1), this chapter goes over what’s hidden behind the phasor abstraction. By first trying to solve the circuit without phasors, we will better understand how AC circuit analysis works at its core. And by then solving the circuit with phasors, we will see that it is not only a more concise notation, but also a simpler mathematical representation and a faster method for analyzing AC circuits.
Figure 1:Example circuit with multiple AC sources and a bridge-type topology that does not allow us to consolidate impedances using formulae for impedances in series or in parallel.
Say that we want to solve for voltages va(t) and vb(t). Doing so would allow us to solve for the voltage across—and therefore the current through—any one component. Just as for a purely resistive DC network, Kirchhoff’s Current Law (KCL) applies and we can do nodal analysis to determine the voltages at nodes a and b. In particular we must use the supernode technique with a single node ab because the current through voltage source vs2 cannot be put in terms of va(t) or vb(t). This loses us an equation, but we gain one in its place with the following relationship:
Paired with Equation (1), this represents a system of two integro-differential equations. By differentiating, we put this in the more familiar form of a system of differential equations (in which the highest-order derivative is two):
We put this into a canonical form of a system of first-order differential equations by introducing an auxiliary variable vb′(t) and by using Equation (1) to replace the need for variable va(t) with vb′(t):
Our system is now in terms of two unknowns—vb(t) and vb′(t)—two functions to solve for. We start to solve our system of differential equations by assuming a solution of the form:
This equation is in terms of two unknowns—Vb and θb. While having only one equation may appear to be insufficient to solve for two unknowns, the equation is parameterized by t and must be satisfied for all values of t. So, in this sense, we actually have an infinite number of equations at our disposal. We can pick two ‘easy’ values of t that result in two relatively simple equations:
This nonlinear system is inconvenient to solve. We can plot these two equations as shown in Figure 2 and solve the system numerically. However, numerical methods are less efficient than being able to directly calculate the solution. We should be able to solve AC circuits very quickly.
Furthermore, as we have seen, the process to derive the system of equations is long and notation-heavy despite being consistent between different AC circuits.
Before we see how the circuit can be solved with phasors, let’s see how we can solve its system of integro-differential equations with the aid of the Laplace transform.
The Laplace transform L converts a function f(t) (in the time domain) into a function F(s) (in the complex frequency domain) through the following integration:
The Laplace transform is closely related to the Fourier transform. Both transforms convert to the frequency domain. However, the Laplace transform converts to a frequency domain whose variable s is a complex number, which can simplify calculations. This domain is known as the s-domain or Laplace domain.
The Laplace transform has a number of favorable properties. One such property is that differentiating with respect to t in the time domain becomes multiplication by s in the Laplace domain. Similarly, integrating with respect to t in the time domain becomes division by s in the Laplace domain. Because of this, the Laplace transform is often used to convert a system of differential equations into a regular system of equations which can be solved more easily.
Furthermore, many useful functions in the time domain become simple, rational functions in the Laplace domain, for example those in Table 1.
Listings of the Laplace transforms of common functions, such as those above, are called Laplace tables.
u(t) is the Heaviside step function, which is 1 for t≥0 and 0 otherwise. The time-domain functions are multiplied by u(t)—that is, only nonzero for t≥0, for the same reason that the lower bound of integration in Equation (13) is 0. The Laplace transform only looks at t≥0, and is thus useful for solving differential equations involving functions that are only nonzero for t≥0. This aspect allows us to answer questions about a system—particularly an electric circuit—that is modeled by differential equations, such as: “what happens when the system is turned on?”, “what happens when the value of this component suddenly changes?”, and “what happens when the circuit’s topology changes in this way?” To consider functions that are nonzero for t<0, and thus model no sudden change at t=0, the two-sided or bilateral Laplace transform can be used.
We want to solve the system of two integro-differential equations (1) and (5) that we derived in the previous section. That system was in terms of va(t) and vb(t), in the time domain. First, we will apply the Laplace transform to convert it to a regular system of equations in terms of Va(s) and Vb(s), in the Laplace domain. Then, we will be able to solve for Va(s) and Vb(s) very easily. Finally, we will convert our solution back to the time domain using the inverse Laplace transform.
Applying the Laplace transform to equations (1) and (5) gives us:
Here, ∣Vs1∣(s) and ∣Vs2∣(s) are the Laplace transforms of vs1(t) and vs2(t)—not to be confused with the amplitudes ∣Vs1∣ and ∣Vs2∣ of vs1(t) and vs2(t).
Solving for Va(s) in the second equation and substituting it into the first equation yields:
Substituting in Vsi(s)=L{Vsisin(ωt)u(t)}=Vsiω/(s2+ω2) yields the following. Note that, because the voltage sources are multiplied by u(t), we are essentially answering the question of how the circuit responds when turned on at t=0.
At this point, the algebra will be significantly easier if we substitute in known values for our parameters. Let’s introduce numerical values (2), after which we will omit units for brevity. However, Vb(s) is still in units of volts and s is still, like ω, in units of radians per second.
We need to convert this solution for Vb(s) back to the time domain. Converting a function from the Laplace domain to the time domain can be done by looking it up in a Laplace table. However, Vb(s) is too complicated in its current form to find a matching function in a Laplace table—in particular, because the order of the polynomial in the denominator is four. This is higher than the highest-order denominator of two that can be found in typical Laplace tables. We can handle this by rewriting our solution as a linear combination of simpler functions that we will be able to find in the Laplace table. To determine such simpler functions, we factor the denominator then apply partial fraction decomposition. The denominator needs to be split into factors whose order is at most two. This is already the case. Next, we assume the following modified format of our Vb solution and find the values A1 through A4 that make it true:
The ω1 here is (not coincidentally) the same as our natural frequency ω=3rad/s. Now, we need to solve for θ1 and B1, which we can do by setting up the following system of equations:
And finally, substituting in the inverse Laplace transforms of the first and second terms yields the following full solution for vb(t) in the time domain:
a = B_1 * cos(theta_1)
b = B_1 * sin(theta_1) + 2
v_a_amplitude = sqrt(a**2 + b**2)
v_a_phase = atan(-b / a)
print(f"{v_a_amplitude = :.5f} V")
print(f"v_a_phase = {np.rad2deg(float(v_a_phase)):.4f} deg")
The solution for vb(t) (and va(t)), plotted in Figure 3, has two distinct terms. It is a linear combination of cosine waves, each with their own natural frequency and phase, but one of the cosine waves is exponentially decaying. The exponentially decaying cosine models how the circuit responds when turned on at t=0—its transient response. The non-decaying cosine is how the circuit responds in the longer term—its steady-state response as t tends to infinity (but practically much sooner as the transient quickly dies out).
Paired with Equation (1), Va−Vb=Vs2, this represents a system of two linear equations in two unknowns Va and Vb. Substituting Equation (1) into the above yields:
Getting here required some algebra involving complex numbers. However, when solving a real circuit whose parameters have known values, this process would have been aided significantly by being able to evaluate/simplify expressions at each step. Let’s introduce numerical values (2) to see how Vb and Va can be evaluated.
# Checking the result.
v_a_sol = v_a.subs(v_b, v_b_sol)
print(subs(v_b_sol).evalf(6))
print(subs(v_a_sol).evalf(6))
By calculating the amplitude A and phase θ, we can convert from complex number phasor notation a+jb to either polar phasor notation A∠θ or back into the time domain as Acos(ωt+θ). The amplitude and phase are calculated using:
# Converting from the phasor domain to the time domain.
v_b_sol = v_b_amplitude * cos(subs(w) * t + v_b_phase)
v_a_sol = v_b_sol + subs(v_s2 := V_s2 * sin(w * t))
With the amplitude and phase calculated, it becomes very easy to plot the solution for va(t) and vb(t), as in Figure 4.
At this point, we have derived the equations representing the circuit with and without phasors, and we have solved the circuit with phasors. To check our work, we can plug the solution obtained using phasors into the differential equation (8) obtained without using phasors, and verify that the equation holds true (that the left-hand side equals the right-hand side). This can be done conveniently by plotting both the left- and right-hand sides, as in Figure 5. As can be seen, the left- and right-hand sides are equal.