An interactive desktop simulator for linear electric circuits based on the Laplace transform.
Circuit Analyzer is a Python desktop application that bridges the gap between circuit theory and hands-on analysis. It lets you draw an electrical schematic using a drag-and-drop interface, then automatically derives symbolic equations in the operator (Laplace) domain, computes numerical values, and plots transient responses β all without manual algebraic manipulation.
Why does it exist? Analyzing RLC circuits with inductors, capacitors, and resistors by hand requires solving systems of integro-differential equations, which is tedious and error-prone. Circuit Analyzer automates exactly that pipeline:
- Build a schematic visually.
- Get symbolic equations in the Laplace domain instantly.
- Evaluate any variable numerically at a chosen moment in time.
- Plot the full transient waveform.
How it works under the hood:
The solver uses Modified Nodal Analysis (MNA) in operator form β the same method used by industrial SPICE simulators. Passive elements are replaced by their operator impedances (R, Lp, 1/Cp), and the resulting matrix equation A(p)Β·X(p) = Z(p) is solved symbolically via SymPy. The inverse Laplace transform is then applied analytically (where possible) or numerically via FFT-based methods to recover the time-domain signal.
Place a Voltage Source, Resistor, Inductor, and Capacitor in series. Hit Analyse to get the symbolic expression for current I(p) and plot the transient response showing whether the circuit is over-, under-, or critically damped.
Connect a capacitor and resistor in parallel, driven by a constant EMF through an inductor. The tool computes node voltages and branch currents symbolically, verifies Kirchhoff's laws automatically, and outputs expressions ready for further analysis.
Use an AC voltage source with configurable amplitude A, angular frequency Ο, and phase Ο. Toggle a switch (modelled as a near-zero / near-infinite resistance) to simulate circuit make/break events and observe the resulting transient current waveform.
Build a two-loop circuit with shared reactive elements (as in classical textbook problems). The MNA engine handles the coupled equations automatically and returns individual loop currents as rational functions of p.
- Python 3.9+
- pip
git clone https://github.com/Ulaykss/Circuit-Analyzer.git
cd Circuit-Analyzerpip install -r requirements.txtKey packages: PyQt5, sympy, numpy, matplotlib.
cd src
python main.pyOr, on Windows, run the pre-built executable:
dist/main.exe
- Drag components from the left panel onto the canvas.
- Right-click a component to rotate, flip, or edit its properties.
- Draw wires by dragging from one terminal (green dot) to another.
- Open Settings β Voltage Source Type to choose DC or AC.
- Click Analyse in the toolbar.
- Switch between the Symbolic Analysis, Numerical Analysis, and Graphs tabs on the right panel.
demo.mp4
| Technology | Role |
|---|---|
| Python 3.9+ | Core language |
| PyQt5 | GUI framework (canvas, dialogs, event loop) |
| SymPy | Symbolic algebra, LU solve, inverse Laplace transform |
| NumPy | Numerical arrays, FFT-based inverse Laplace |
| Matplotlib | Transient waveform plots embedded in Qt |
| JSON | .circuit file format for saving/loading schematics |
| Union-Find (DSU) | Netlist topology construction |
| MNA (Modified Nodal Analysis) | Core circuit equation assembly |
The symbolic results produced by Circuit Analyzer have been verified against analytical solutions from classical electrical engineering problems:
- Example 1 (RLC series, DC source): The operator expression for source current
I_E1matches the hand-derived result exactly (up to a common factor ofCβbefore simplification). - Task β70 (RL circuit, sinusoidal source with switch): The program outputs a generalized expression valid for arbitrary switch resistance
Kβ. Taking the limitKβ β β(open switch) reproduces the textbook formula identically:
Both cases confirm that the MNA engine, symbolic solver, and operator-form source models work correctly.
The project is functional but has room for improvement. Here are concrete areas where your contribution would be welcome:
- Python's interpreted nature makes analysis of complex multi-loop circuits noticeably slow.
- Idea: Implement the MNA matrix assembly and LU solver as a native shared library (
dll/.so) in C or C++, called from Python viactypesorcffi. This could yield a 10β100Γ speedup for large netlists.
- The current FFT-based method (TallonβStieltjes) can be inaccurate for stiff systems or very long time windows.
- Idea: Integrate the Weeks method or de Hoog algorithm for more robust numerical inversion.
- Currently supports R, L, C, voltage source, and switch only.
- Idea: Add current sources, dependent sources (VCVS, CCCS), transformers, and transmission lines.
- Simulation results cannot be saved.
- Idea: Add export to CSV / PDF report, and SPICE netlist export for cross-validation with LTspice.
- The codebase lacks automated tests.
- Idea: Add a
tests/directory withpytestcases covering netlist construction, MNA stamping, and known analytical solutions.
This project is licensed under the MIT License β see the LICENSE file for details.
Yaroslav Obukhov β developer, author of the bachelor's thesis underlying this project.
Made with β€οΈ and lots of Laplace transforms Β Β·Β Irkutsk State University, 2026