Saturday, May 7, 2022

Source free series circuit

In this post, the Python modules SymPy and SciPy are used to solve for currents and voltages in a series connected circuit with a resistor, inductor and capacitor. The characteristic differential equation for the circuit is derived and solutions are obtained with SymPy and SciPy. 

A source free series RLC circuit consists of a resistor, capacitor and inductor connected in series with some initial energy stored either in the inductor, capacitor or both. Since the circuit is a single loop, the current flowing around the loop is the same current in each component. Both parallel and series connected circuits are usually presented in electrical circuit analysis classes. The two textbooks I used while in college presented the parallel connected circuit in some detail then kind of glossed over the series connect circuit since it is the dual of the other. 

The schematic for the series connected circuit is shown below.

A Jupyter notebook with the python code was used to document the analysis. To view the notebook, click here to open the notebook nbviewer (nbviewer does not execute notebooks, it only renders the inputs and outputs).

The notebook source is located on github, click here to follow the link to the repository.





Saturday, March 5, 2022

Coupled inductor circuits

 Last update: 4 July 2022

This blog post summarizes the results from my Jupyter notebook, which can be viewed here. The notebook is hosted on Github.  

The Jupyter notebook examines coupled inductor circuits. Numeric and symbolic solutions are obtained for the voltages and currents in the circuits. The first circuit specifies the inductor values and the coupling in terms of mutual inductance. The second circuit is of a traditional transformer circuit where the turns ratio is given and the coupling constant is assumed to be 1.  

A coupled inductor has two or more windings that are connected by a magnetic circuit. Coupled inductors transfer energy from one winding to a different winding usually through a common core. The efficiency of the magnetic coupling between both the windings is defined by the coupling factor k or by mutual inductance. The coupling constant and the mutual inductance are related by the equation:

Where k is the coupling coefficient and in spice the value of k can be from -1 to +1 to account negative phase relation. Phase dots are drawn on the schematic to indicate the relative direction of the windings.  In LTspice the phase dots are associated with the negative terminal of the winding.

Coupled inductor circuit 1 is shown below. The circuit was drawn in LTspice and both the schematic and net list were exported. The inductors L1 and L2 are coupled with a mutual inductance of 0.5j. 


Coupled inductor circuit 2 is shown below. This circuit has two independent voltage sources and a transformer. The turn ratio of the transformer is specified as 1:2 and the coupling constant is assumed to be 1.


For both circuits, the solutions obtained with Python were verified with results obtained from LTspice.

Reference: https://en.wikipedia.org/wiki/Inductance#Mutual_inductance





Tuesday, February 22, 2022

Nodal analysis of a RLC circuit with controlled sources

Consider the circuit below, which contains independent and dependent current and voltage sources. The circuit is from [1], Figure 4.8. Circuit analysis is a fundamental part of electrical engineering and this post describes using Python to analyze electrical circuits. The schematic of the circuit was redrawn in LTspice [2].


The zero volt source, V2, was added to the schematic so that the current through R4 could be measured since this current controls H1. The voltages and currents in the circuit were solved for in a Jupyter notebook running Python and using the SymPy and SciPy libraries. The netlist is used to generate modified nodal equations with the python program described here. To view the notebook click here, to open the notebook viewer. The Jupyter notebook is located on github, click here, to follow the link to the repository.

References  

1. Basic Electric Circuit Analysis, D. E. Johnson, J. L. Hilburn, and J. R. Johnson, Prentice-Hall, 1978

2. https://www.analog.com/en/design-center/design-tools-and-calculators/ltspice-simulator.html

Wednesday, February 16, 2022

Thevenin equivalent circuit

The Thevenin equivalent circuit is the reduction of a linear one port circuit to a single source and impedance and is based on Thevenin’s Theorem. This notebook describes solving problem 11.25, given in chapter 11 of [1]. The Python libraries of SimPy and Numpy are used to perform the math in the proposed solution. The problem asks the student to replace the circuit to the left of terminals a-b by its Thevenin equivalent and find V. The schematic was drawn using LTspice [2] and the nodes were numbered. Terminals a-b are across the resistor R3. The circuit given in the textbook does not include a reference node, however the node at the bottom of the schematic was chosen as the reference node, ground.


Having drawn the circuit in LTspice, the netlist was exported as a text file. The solution is worked out in the jupyter notebook which can be viewed here. 

The Jupyter notebook is located on github, click here to follow the link to the repository.


Reference

1. Basic Electric Circuit Analysis, D. E. Johnson, J. L. Hilburn, and J. R. Johnson, Prentice-Hall, 1978

2. LTspice, last accessed on 2/24/2022.