Analyzing Electric Circuits with Computer Algebra

Abstract

This report shows how starting from classic electric circuits embodying commonly electric components we have reached semi-complicated circuits embodying the same components that analyzing the signal characteristics requires a Computer Algebra System. Our approach distinguishes itself from the electrical engineers’ (EE) approach that relies on utilizing commercially available software. Our approach step-by-step shows how Kirchhoff’s rules are applied conducive to the needed circuit information. It is shown for the case at hand the characteristic information is a set of coupled differential equations and that with the help of Mathematica numeric solutions are sought. Our report paves the research road for unlimited creative similar circuits with any degree of complications. Occasionally, by tweaking the circuits we have addressed the “what if” scenarios widening the scope of the investigation. Justification of the accuracy of our analysis for the generalized circuits is cross-checked by arranging the components symmetrizing the circuit leading to an intuitively predictable reasonable result. Mathematica codes are embedded assisting the interested reader in producing and extending our results.

Share and Cite:

Sarafian, H. (2023) Analyzing Electric Circuits with Computer Algebra. American Journal of Computational Mathematics, 13, 91-98. doi: 10.4236/ajcm.2023.131003.

1. Introduction

Analyzing the characters of signals in classic electric circuits embodying components such as resistors, capacitors, and self-inductors or ultimately various combinations of these elements connected in series or parallel driven by DC or AC sources is a routine practice for electric engineers. In practice, they utilize commercial software such as [1] [2] . This approach mostly passes the analytic aspect of the circuit analysis generating the needed information. This approach although efficient in obtaining the needed information lacks analytic rigor. From a physicist’s point of view, we would rather start from the fundamental principles generating the needed information leading to controllable output conducive to the same knowledge.

With this objective, we craft this report that consists of three sections. In Sect 2, we depict a designed circuit that is more sophisticated than the routinely used above-mentioned elements. It consists of a multi-mesh, to be precise a double-loop circuit. In the first scenario, it is driven by DC power supplies. In a later scenario an AC, and two DC sources. This section includes the mathematical analysis including solutions to the coupled ODEs. At first, the circuit is designed symmetrically meaning certain adjustable parameters are used making the output intuitively predictable. This helps check the accuracy of the calculation, it bypasses the need to solve the coupled differential equations. In the follow-up scenario for a rigor analysis, the coupled ODEs have to be solved. This approves that our proposed circuit is a suitable example justifying why there is a need to learn how to solve the equations. As such, although the coupled ODEs are not analytically solvable, we apply a Computer Algebra System, such as Mathematica conducive to its numeric solution. We show the results graphically and we test their integrity by proposing “what if” scenarios. We supply the Mathematica codes, so that interested readers can practice the concept. Our approach to analyzing the designed circuit is universal, meaning, it paves the research road in analyzing limitless, similar circuits. Noticing, more complicated multi-loops circuits would generate a few more coupled ODEs underlying the need to apply a CAS. We complete the report in Sect 3, the Conclusions and Comments.

2. Multi-Mesh Circuit Each Containing RCL-Series Elements

The left panel of Figure 1 depicts a classic circuit containing an RCL-series circuit driven by a DC source. Applying Kirchhoff’s Loop law leads to a single linear differential equation. Its solution and implications have been discussed in texts such as [3] [4] . It has a straightforward solution that requires two initial conditions. There is no need to apply a CAS to solve the ODE, it can be solved without it. Although, one might decide to do so for the sake of practice getting prepared for upcoming challenging cases. The right panel of Figure 1 is the “reflection” of the left circuit. It comes about by copying over the circuit of the left trice. The purpose of doing so is to create a multi-loot circuit. The loops are joined at the top and the bottom nodes. The solution of the quantities of interest is not as trivial as the aforementioned case. This circuit is the upgrade of the circuit that classic textbooks [3] [4] avoid analyzing them. Analysis of this circuit may be considered a mathematical exercise justifying the need to learn why the solution of a couple of differential equations is a must.

Figure 1. The left circuit is a single loop containing three elements, a resistor R, a capacitor C, and a self-inductor L, driven with a DC power supply ϵ. The right panel is a “reflection” of the left forming a double-loop circuit.

The values of the components in the circuit shown in Figure 1 are irrelevant. Meaning, any reasonable values may be assigned to these elements. The analysis of the circuit is generic, it is independent of these values. However, for the reasons explained in the forthcoming sections, two different special sets of values are used. See for instance the bold entries values 2b, and values 2c under the subsections 2b and 2c, respectively.

2.1. Analysis

To analyze the circuit depicted on the right panel of Figure 1, we apply Kirchhoff’s loop law. According to the well-known Kirchhoff’s laws 1) the algebraic sum of the emfs in a single loop circuit equals the sum of the ohmic voltage drops across the resistors. And 2) In a multi-mesh circuit at any node, the algebraic sum of the currents adds to a zero. There are three such loops, two are selected. The two squares are the referenced shown by clockwise directions 1 and 2. Knowing the voltages across the capacitor with the capacitance C, the self-inductor with the inductance of L, and the obvious voltage loss across the

resistor R are subject to ( Δ V ) C = q C and ( Δ V ) L = L d d t i , and ( Δ V ) R = R i , respectively we advance to the next step. The loops contain additional emf’s, ϵ 1 , ϵ 2 , and ϵ 3 . Kirchhoff’s loop law applied to loop 1 yield,

ϵ 1 ϵ 2 1 C 1 q 1 L 1 d d t i 1 + L 2 d d t i 2 + 1 C 2 q 2 = R 1 i 1 R 2 i 2 , (1)

Repeating the same principle to loop 2, we have

ϵ 2 ϵ 3 1 C 2 q 2 L 2 d d t i 2 + L 3 d d t i 3 + 1 C 3 q 3 = R 2 i 2 R 3 i 3 , (2)

and applying Kirchhoff’s node law at node A, we have

i 1 + i 2 + i 3 = 0 , (3)

In these equations, we replace the currents with their derivatives concerning time, namely, i 1 = d q 1 d t , i 2 = d q 2 d t , and i 3 = d q 3 d t . Substituting these in (1), (2) and (3) yield,

ϵ 1 ϵ 2 1 C 1 q 1 L 1 q ¨ 1 + L 2 q ¨ 2 + 1 C 2 q 2 = R 1 q ˙ 1 R 2 q ˙ 2 , (4)

ϵ 2 ϵ 3 1 C 2 q 2 L 2 q ¨ 2 + L 3 q ¨ 3 + 1 C 3 q 3 = R 2 q ˙ 2 R 3 q ˙ 3 , (5)

q ˙ 1 + q ˙ 2 + q ˙ 3 = 0 , (6)

where the over dots stand for the derivative concerning time. The set of Equations, (4), (5), and (6) are three coupled linear second-order inhomogeneous differential equations with constant coefficients. With the initial conditions, q 1 ( 0 ) = q 2 ( 0 ) = q 3 ( 0 ) = 0 and q ˙ 1 ( 0 ) = q ˙ 2 ( 0 ) = q ˙ 3 ( 0 ) = 0 we seek solutions. We fail to solve them analytically, claiming this is a suitable example to utilize with a CAS. By selecting a reasonable set of parameters using NDSolve command of Mathematic [5] we solve them numerically. Before doing so we adopt a strategy. 1) we set the parameters such that the double-looped circuit becomes symmetric, i.e. the parameters associated with loop 1 are the same as the parameters of loop; 2) Then by assigning small values to the embodied components, R, C, L, and ϵ and stronger ϵ for the mid common branch we anticipate a symmetric signal characteristics output. Upon justifying our intuitive point by breaking the symmetry we consider nonsymmetric elements leading the general features of the circuit. The Mathematica [5] codes running these scenarios are as follows.

2.2. Symmetric Loops, Signal Characteristics Generated with Three DC Power Supplies

For the symmetric case, we store the values of the components in values2b, units are SI. As mentioned, we assign small values to ϵ1 and ϵ2 and a stronger emf to the mid branch ϵ2.

values2b={ϵ1->5.,ϵ2->50.,ϵ3->5.,R1->2.,R2->5.,R3->2.,L1->3.,L2->5.,L3->3., C1->4.,C2->10.,C3->4.}

We write,

eq1=ϵ1-ϵ2-1/C1q1[t]-L1q1’’[t]+1/C2q2[t]+L2q2’’[t]==R1q1’[t]-R2q2’[t]/.values

eq2=ϵ2-ϵ3-1/C2q2[t]-L2q2’’[t]+1/C3q3[t]+L3q3’’[t]==R2q2’[t]-R3q3’[t]/.values

eq3=q1’[t]+q2’[t]+q3’[t]==0/.values

initialCond=q1[0]==q2[0]==q3[0]==q1’[0]==q2’[0]==q3’[0]==0

with these codes, we solve the equations numerically displaying the solutions. I.e. charge on the capacitors q(t), voltages across the capacitors, currents through the loops, and the voltages across the self-inductors vs. time, respectively. These are depicted in Figure 2

solq=NDSolve [{eq1,eq2,eq3,initialCond}/.values,{q1[t],q2[t],q3[t]},{t,0,300}]

Figure 2. The graphs on the first row are the charge, q in Coulombs, q(C), and the voltagesacross the capacitors ε(V) vs time, respectively. The blue and the magenta curvescompletely overlapped and appeared to be one curve. These are associated with capacitors of the far left and the far right of the loops. The red curves correspond to the capacitor of the mid-branch. The graphs on the second row are the currents and the voltage across the self-inductors’ vs time, respectively. The blue and the magenta curves overlapped. These are associated with the self-inductors of the far left and the far right of the circuit. The red curves are those for the mid-branch.

As mentioned in the figure caption, although each graph appears to contain only two signals in reality there are three. The thickened blue signals completely overlapped on the magenta acting as one signal as expected.

The interpretation of shown grouped signals of each plate is straightforward. The upper left graph is the charging characteristics of the capacitors. It follows the routine charging trends as pointed out initially they begin with no charge q ( t = 0 ) = 0 and gradually grow to their plateau saturation. The second plot on the first row is the scaled version of the first, this is because q ( t ) = ( Δ V ) C . It depicts the exponential growth of the voltage across the capacitors. The first and the second graphs of the second row are the classic current jumps and their exponential decay of the voltages across the current and the self-conductors, respectively.

With confidence in the accuracy of the crafted formulations and codes next we assign asymmetric values to the elements. These are stored in values2c, units are SI as well.

2.3. Asymmetric Double Loops, Signal Characteristics Generated with Three DC Power Supplies

values2c={ϵ1→5.,ϵ2→50.,ϵ3→10.0,R1→2.,R2→5.,R3→5.0,L1->3.,L2->5.0,L3->5.0,C1->4.,C2->4.,C3->5.0};

We run the same mentioned code with the values2c. The description of the graphs depicted in Figure 3 is the same as in Figure 2. The impact of the asymmetric parameters is evident. The blue of the magenta signals is separated as expected. For the signals displayed on the first row, we used the same period as we used in Figure 2. However, for the signals on the second row because of the values of the chosen elements, we used a shorter period enabling displaying the signal characters.

By comparing the signals displayed in Figure 2 and Figure 3 we realize the impact of the symmetric vs asymmetric parameters. Here again, the general behavior of the signals is what one expected. These are the mimics of the classic singles with no surprises.

2.4. An Asymmetric Double Loop, Characteristics Signal Characteristics Generated with an AC and Double DC Power Supplies

Here we show how easily one may modify the circuit dramatically by replacing one of the DC power supplies with an AC driver. Although there are three DC sources as shown in Figure 1, here for the sake of demonstrating the procedure we replace only one driver, ϵ2. The interested reader may wish to try replacing ϵ1 and/or ϵ3 or ultimately all three. As mentioned, we have complete control over setting the parameters. Just for the sack of demonstration, we set the parameters as,

values2d={ϵ1->5.0,ϵ2->50.0 Sin[π t],ϵ3->5.0,R1->2.0,R2->5.0,R3->2.0,L1->3.0,L2->3.0,L3->3.0,C1->4.0,C2->4.0,C3->4.0}

The second driver is a sinusoidal source, ϵ2(t) = 50 sin[πt]. Its voltage amplitude is 50.0 V and its low frequency is f = 1/2 Hz. Replacing the ϵ2 in (1) and (2) with the sinusoidal driver easily is accomplished via the driver’s character given in value2d. The circuit is shown in Figure 4.

Here the voltages of the left and the right loops as well as the values of the resistances, capacitances, and the self-inductors are set the same. The character of

Figure 3. The description of the displayed signals is the same as in Figure 2.

Figure 4. The shown double-loop circuit is the same as Figure 1, the difference is the DC emf of the middle branch is being replaced with an AC driver.

Figure 5. The description of the displayed signals is the same as in Figure 3. As noted, each graph contains three different colored curves. The waviness of each signal comes about from the character of the AC source embedded in the mid branch of the circuit shown in Figure 4. The character of the AC source is given by values3d.

the emf of the central branch is replaced with an AC source. The values of the other elements of the circuit are set differently as well. This procedure shows how easy it is to switch from DC to an AC source. As expected, the effective value of the power supply and its oscillating character dominates the time dependency behavior of the signals of interest. Eyeballed view of the characters of Figure 2 and Figure 3 reveals the impact of the DC vs AC sources, as shown in Figure 5. Utilizing the codes makes it easy to either place the source in the left and or right loop. Or even better design a fresh circuit either based on one’s curiosity and need.

3. Conclusion

One of the objectives of crafting this report was to demonstrate how by utilizing a Computer Algebra System (CAS) electric circuits are analyzed. This approach bypasses utilizing commercially available software that their application merely gets the character of the signals in a chosen circuit without showing the fundamental physics principle. Our approach is designed such that the user by applying the fundamentals principles constructs the essential equations. And irrespective of their challenging nature their solution leads to the desired output. To justify the made points three different circuits are analyzed, two using a DC and one using an AC source. CAS codes, specifically Mathematica codes are embedded so that the interested reader may duplicate and/or by tweaking adjust to the need. The interested reader may find [6] [7] resourceful.

Acknowledgements

The author acknowledges the John T. and Page S. Smith Professorship funds for completing and publishing this work.

Conflicts of Interest

The authors declare no conflicts of interest regarding the publication of this paper.

References

[1] STSpice.
https://www.analog.com/
[2] NI Multisim.
https://www.ni.com/en-us/support/downloads/software-products/download.multisim.html#452133
[3] Halliday, D., Resnick, R., and Walker, J. (2021) Fundamentals of Physics. 11th Edition, John Wiley & Sons, Inc., New Jersey.
[4] Bauer W. and Westfall, G. (2011) University Physics with Modern Physics. McGraw Hill, New York.
[5] Mathematica V12.3.
https://www.Wolfram.com
[6] Wolfram, S. (1996) Mathematica Book. 3rd Edition, Cambridge University Press, Cambridge.
[7] Sarafian, H. (2019) Mathematica Graphics Examples. 2nd Edition, Scientific Research Publishing, Wuhan.

Copyright © 2024 by authors and Scientific Research Publishing Inc.

Creative Commons License

This work and the related PDF file are licensed under a Creative Commons Attribution 4.0 International License.