EGR 2201 Unit 3 Nodal Analysis Read Alexander & Sadiku, Appendix A and Sections 3.1 to 3.3. Homework #3 and Lab #3 due next week. Quiz next week. A Systematic Approach With the laws from Chapter 2 (Ohm’s law, KCL, and KVL), we can analyze a wide variety of circuits containing resistors and sources. However, those laws do not constitute a systematic method for analyzing circuits. Different people may apply the laws in different orders. We want a systematic, step-by-step method. Nodal analysis is one such method. Mesh analysis, which we’ll study next week, is another one. Simultaneous Linear Equations Nodal analysis and mesh analysis both involve writing down a set of equations, based on an inspection of the circuit you’re analyzing, and then solving those equations simultaneously. In your math classes you have studied how to solve simultaneous equations, so let’s start with a review of the math. Math Review: Solving Simultaneous Linear Equations Recall that a linear equation in one variable has a unique solution. Example: The linear equation 2x = 8 has a unique solution, namely x = 4. In contrast, a linear equation in two variables does not have a unique solution. Example: The linear equation 3x 4y = 7 does not have a unique solution. Simultaneous Linear Equations Although a single linear equation in two variables doesn’t have a unique solution, a pair of independent linear equations in two variables does have a unique solution. Example: The pair of equations 3x 4y = 7 and 2x + 8y = 26 has a unique solution, namely x = 5 and y = 2. Generalizing More generally, for any positive integer n, a set of n independent linear equations in n variables does have a unique solution. Example of a set of three equations in three variables: 3x y 2z = 1 x + 6y 3z = 0 2x 3y + 6z = 6 How do we find the solution? Many Methods for Solving Simultaneous Equations Mathematicians have found many ways of attacking this problem: 1. 2. 3. 4. 5. Substitution Gaussian elimination Cramer’s rule Matrix inversion … How Many Equations Do You Have? In theory, there’s no limit to the size of the problems that you can attack with the methods listed on the previous slide. Example: Eight equations in eight variables. But from a practical standpoint, all of these methods are cumbersome if you have more than three equations in three variables. In such cases, you can use a powerful calculator (such as a TI-89) or software (such as MATLAB). Matrices We’ll focus on the methods that use Cramer’s rule and matrix inversion. Both of these methods rely on matrices and determinants, so let’s do a quick review of those topics. The textbook’s Appendix A also gives a nice review. Subscripted Variables When working with matrices, we generally prefer to use variable names like x1, x2, x3,… rather than x, y, z,…. Rewriting our earlier set of two equations in two variables: 3x1 4x2 = 7 2x1 + 8x2 = 26 A 2-by-2 Matrix Equation Suppose we have two equations in two variables: a11x1 + a12x2 = b1 a21x1 + a22x2 = b2 We can write this in matrix form as a11 a12 x1 b1 a 21 a22 x2 b2 or AX=B Example of a 2-by-2 Matrix Equation Using our two equations in two variables from earlier: 3x1 4x2 = 7 2x1 + 8x2 = 26 We can write this in matrix form as 3 4 x1 7 2 8 x 26 2 or AX=B Solution Using Cramer’s Rule Cramer’s rule says that the solution of the matrix equation A X = B is given by: n 1 2 x1 , x2 , ... , xn where is the determinant of A, and i is the determinant of the matrix formed by replacing the ith column of A by B. Determinant of a 2-by-2 Matrix Suppose we have a 2-by-2 matrix A: a11 a12 A a21 a22 This matrix’s determinant is given by: = a11a22 a12a21 Example of the Determinant of a 2by-2 Matrix In the earlier example, our 2-by-2 matrix A was: 3 4 A 2 8 This matrix’s determinant is equal to 32, since : = 3×8 (4×2) = 24 (8) = 32 Example of Solution Using Cramer’s Rule Continuing with our 2-by-2 example: 3 4 x1 7 2 8 x 26 2 We’ve just seen that = 32 for the matrix above. 7 4 Also, 1 is the determinant of 26 8 So 1 = 160. 3 7 And 2 is the determinant of 2 26 So 2 = 64. Example of Solution Using Cramer’s Rule (Continued) We’ve found that, for our example, = 32, 1 = 160, and 2 = 64. Therefore, Cramer’s rule tells us that 1 168 x1 5 32 2 64 x2 2 32 This agrees with our earlier solution. A 3-by-3 Matrix Equation Suppose we have three equations in three variables: a11x1 + a12x2 + a13x3 = b1 a21x1 + a22x2 + a23x3 = b2 a31x1 + a32x2 + a33x3 = b3 We can write this in matrix form as a11 a 21 a31 a12 a22 a32 a13 x1 b1 a23 x2 b2 a33 x3 b3 or AX=B Example of a 3-by-3 Matrix Equation Consider the following three equations in three variables: 3x1 x2 2x3 = 1 x1 + 6x2 3x3 = 0 2x1 3x2 + 6x3 = 6 We can write this in matrix form as 3 1 2 x1 1 1 6 3 x 0 2 2 3 6 x3 6 or AX=B Determinant of a 3-by-3 Matrix Suppose we have a 3-by-3 matrix A: a11 A a21 a31 a12 a22 a32 a13 a23 a33 This matrix’s determinant is given by: a11a22a33 + a21a32a13 + a31a12a23 a13a22a31 a23a32a11 a33a12a21 See page A-2 for a way to remember this. How Much of This Do You Need to Know? On exams, I’ll expect you to be able to use Cramer’s rule or matrix inversion to solve a problem involving two equations in two variables—in other words, involving a 2-by-2 matrix. You’ll need to show every step in the solution. But for more complicated exam problems, you can use a calculator or MATLAB to solve the equations. Solution Using Matrix Inversion Suppose again that we have the matrix equation AX=B We can solve for X by rewriting this equation as X = A-1 B where A-1 is a matrix called the inverse of A. The question now is: How do we find this inverse matrix A-1? Inverse of a 2-by-2 Matrix Suppose we have a matrix A given by a11 a12 A a21 a22 This matrix’s inverse is given by 1 A A 1 a22 a12 a 21 a11 where |A| is the determinant of A. Example of the Inverse of a 2-by-2 Matrix In the earlier example, our 2-by-2 matrix A was: 3 4 A 2 8 And we found that this matrix’s determinant |A| is equal to 32. Therefore this matrix’s inverse is 0.125 1 8 4 0.25 A 32 2 3 0.0625 0.09375 -1 Example of Solution Using Matrix Inversion Now that we’ve found A-1, we write X = A-1 B, or 0.125 7 5 0.25 X 0.0625 0.09375 26 2 (That’s because 0.25 × 7 + 0.125 × 26 = 5 0.0625 × 7 + 0.09375 × 26 = 2) So x1 = 5 and x2 = 2, in agreement with our earlier solutions. Inverse of a 3-by-3 Matrix? If you have three equations in three variables, you’ll need to find the inverse of at 3-by-3 matrix. This gets a little ugly. See page A-6 in the textbook. If you have four (or more) equations in four (or more) variables, don’t try it by hand. Use a calculator or MATLAB. A Quick Introduction to MATLAB The main window is the Command Window, in which you type commands at the >> prompt. Examples: >> >> >> >> >> >> >> 3*5 3+5^2 (3+5)^2 a=10 b=2 c=a/b sqrt(36) A Few MATLAB Tips You can’t move up to a previous line to re-execute a command, but you can use the up-arrow and down-arrow keys to retrieve old commands. The clc command clears the command window. MATLAB has many built-in math functions, Function Description including: sqrt(x) Square root exp(x) Exponential (ex) abs(x) Absolute value log(x) Natural logarithm log10(x) Base-10 logarithm cos(x) Cosine (x in radians) cosd(x) Cosine (x in degrees) Solving Our 2-by-2 Example with MATLAB First, define the coefficient matrix A and the vector of constants B: >> A = [3 -4; 2 8] >> B = [7; 26] Second, multiply A’s inverse times B: >> X = inv(A)*B Solving Our 3-by-3 Example with MATLAB First, define the coefficient matrix A and the vector of constants B: >> A = [3 -1 -2; -1 6 -3; -2 -3 6] >> B = [1; 0; 6] Second, multiply A’s inverse times B: >> X = inv(A)*B Simplifying Before You Can Use MATLAB Often you’ll have a set of equations that you must simplify using basic algebra to put it into a form that you can enter in MATLAB. 𝑥1 𝑥1 − 𝑥2 Example: 𝑥1 − 10 + 5 + 2 =0 𝑥2 − 𝑥1 𝑥2 + −2=0 2 10 This simplifies to: 17𝑥1 − 5𝑥2 = 100 −5𝑥1 + 6𝑥2 = 20 Nodal Analysis We’ve finished our review of the math. Now let’s see how to use the math to analyze circuits. Nodal analysis, which is based on Kirchhoff’s current law (KCL), is a process for finding the voltages at the nodes in a circuit. Once we’ve found these node voltages, we can use KVL to find any other voltages in the circuit and use Ohm’s law to find any currents in the circuit. Reference Node To perform nodal analysis on a circuit, we must first select one of the circuit’s nodes to be the reference node. This means that we’ll only talk about voltages that are relative to this node. Thinking in terms of a multimeter, this means that we’ll keep the meter’s black lead at the reference node when making any voltage measurements. See the next two slides for a picture…. Voltage Measurements without a Reference Node In Lab #1 you built this three-node circuit and then measured several voltages: vab, vac, vbc, vba, vcb, and vca. Recall that to measure any of these voltages, you touched the meter’s red lead to the node named first and the black lead to the node named second. Example: To measure vac, you touched the meter’s red lead to node a and the black lead to node c. Voltage Measurements with a Reference Node When doing nodal analysis, we’ll single out one node as the reference node and then measure all voltages relative to that node. Example: Suppose that in this circuit, we select node c as the reference node. Then we’ll keep the meter’s black lead on node c for all voltage measurements. We can therefore drop the letter c from the names of the voltages. Instead of writing vac, we’ll just write va. And instead of vbc, we’ll write vb. Schematic Symbol for the Reference Node In schematic diagrams, the symbol identifies the reference node. So if we’ve selected node c in the previous circuit as the reference node, we can redraw the circuit as shown here. (And we no longer label the reference node with a letter.) “Datum Node” and “Ground” Two other names for the reference node are datum node and ground. “Ground” is a confusing term that is used in several different ways, including “chassis ground” and “earth ground.” Also, there are several different ground symbols, which different authors use in different ways. We’ll always use this one. How to Select the Reference Node? In many of the textbook’s problems, the authors have already selected a reference node and identified it with the symbol. If not, you should select the node connected to the most branches as your reference node. This is often the lowest node in the diagram, as in the two cases below. Steps in Performing Nodal Analysis on a Circuit with No Voltage Sources Given a circuit with n nodes, with no voltage sources, follow these steps: 1. 2. 3. Select a node as the reference node. Assign voltages v1, v2, …, vn-1 to the remaining n-1 nodes. These voltages are relative to the reference node. Apply KCL to each of the n-1 nonreference nodes. Use Ohm’s law to express the branch currents in terms of node voltages. Then simplify the equations. Solve the resulting n-1 simultaneous equations to obtain the unknown node voltages. Example: Step 1 (Identify the Nodes) Consider this circuit from the book’s Example 3.1. Step 1 has already been performed for us, since the reference node is identified and the other two nodes are labeled 1 and 2. We’ll call the voltages at these nodes v1 and v2. Example: Step 2 (Apply KCL & Ohm’s Law) Part 1 of 4 Voltages and currents (with assumed directions) are labeled here. If one or more of our assumed current directions are wrong, that’s no problem. The math will still work out just fine. Example: Step 2 (Apply KCL & Ohm’s Law) Part 2 of 4 Apply KCL at node 1: i1 = i2 + i 3 Apply KCL at node 2: i2 + i4 = i 1 + i5 Note that we already know the values of some currents (i1 and i4), but not of the others. Example: Step 2 (Apply KCL & Ohm’s Law) Part 3 of 4 Trickiest part! Rewrite the KCL equations using Ohm’s law and the known currents. At node 1: i1=i2+i3 becomes 5= 𝑣1 −𝑣2 4 + 𝑣1 −0 2 At node 2: i2+i4=i1+i5 becomes 𝑣1 −𝑣2 4 + 10 = 5 + 𝑣2 −0 6 Example: Step 2 (Apply KCL & Ohm’s Law) Part 4 of 4 Second-trickiest part! Next we use algebra to simplify our equations. At node 1: 5= + 𝑣1 −0 2 becomes 3𝑣1 − 𝑣2 = 20 At node 2: 𝑣1 −𝑣2 4 𝑣1 −𝑣2 4 + 10 = 5 + 𝑣2 −0 becomes 6 −3𝑣1 + 5𝑣2 = 60 We now have our two equations in two variables. Example: Step 3 (Solve) Next we use any of our methods— substitution, Cramer’s rule, matrix inversion, MATLAB—to solve our two equations in two variables. Using MATLAB, the solution to 3𝑣1 − 𝑣2 = 20 −3𝑣1 + 5𝑣2 = 60 is v1 = 13.33 V and v2 = 20 V Example: Extending the Analysis Nodal analysis has given us the values of the node voltages v1 and v2. We can find all other voltages and currents in the circuit once we know these node voltages. Example: Knowing that v1 = 13.33 V and v2 = 20 V, how would we find i2? Review: Steps in Performing Nodal Analysis on a Circuit with No Voltage Sources Given a circuit with n nodes, with no voltage sources, follow these steps: 1. 2. 3. Select a node as the reference node. Assign voltages v1, v2, …, vn-1 to the remaining n-1 nodes. These voltages are relative to the reference node. Apply KCL to each of the n-1 nonreference nodes. Use Ohm’s law to express the branch currents in terms of node voltages. Then simplify the equations. Solve the resulting n-1 simultaneous equations to obtain the unknown node voltages. Online Alternative to MATLAB WolframAlpha (wolframalpha.com) is a powerful free online math tool. An earlier example using MATLAB: >> A = [3 -4; 2 8] >> B = [7; 26] >> X = inv(A)*B Same example using WolframAlpha: inv({{3, -4},{2, 8}})*{{7},{26}} What About Circuits with Voltage Sources? As described above, our procedure applies only to circuits without voltage sources. But it’s not hard to extend the procedure to circuits with voltage sources. The way you handle a voltage source depends on whether the source is connected to the reference node…. Is the Voltage Source Connected to the Reference Node? Case 1. Voltage sources connected to the reference node, like this one, are handled one way. Case 2. Voltage sources not connected to the reference node, like this one, are handled another way. Case 1: A Voltage Source That Is Connected to the Reference Node A voltage source connected to the reference node is easy to handle, because it immediately reveals the voltage at one of the non-reference nodes. Example: In the circuit shown, we can immediately see that v1 = 10 V. Case 2: A Voltage Source That Is Not Connected to the Reference Node A voltage source not connected to the reference node is trickier. To handle it, we treat the voltage source and its two nodes (along with any elements in parallel with the voltage source), as a supernode. How to Handle a Supernode We apply KCL and KVL to the supernode to get two equations. Example: In the circuit shown, KCL gives i1 + i4 = i2 + i3 And KVL gives v2 = 5 + v3 We Still Get Enough Equations If this circuit did not have a supernode, we would get one equation by applying KCL to node 2 and another by applying KCL to node 3. With the supernode, we get one equation by applying KCL to the supernode and another by applying KVL to the supernode.