ElectroSolve is a Rust project aimed at becoming a “student helper” for circuit analysis: a tool that can take a circuit description and guide you to the answer step-by-step, similar to how Photomath explains math problems.
The long-term goal is not only to compute final results, but to explain how they were obtained using standard circuit laws and reduction rules.
This repository is organized as a Rust workspace with separate crates for the core engine, a DSL (circuit description language), and a CLI interface.
ElectroSolve is designed to help students solve circuit problems by supporting:
-
Equivalent impedance calculation for AC circuits using complex impedance
-
Series/parallel circuit reduction with recorded reduction steps
-
Solving for unknown values:
- Unknown impedances (R, L, C, or general complex impedances)
- Currents and voltages (phasors for AC, scalars for DC)
- Power calculations (real, reactive, apparent)
-
Step-by-step explanations of each transformation and law used
-
A clean input format (DSL) that can later be used by:
- a CLI tool
- a future GUI app
- a web frontend
ElectroSolve is being built with correctness in mind. The core crate already includes extensive property-based testing to validate algebraic and physical invariants.
This project is under active development.
-
Circuit graph model (nodes + components)
-
Component impedance evaluation at a given angular frequency
-
Impedance arithmetic:
- series combination
- parallel combination
- Open/Short edge cases
-
Automated reduction loop:
- parallel reduction
- series reduction
-
Reduction step tracking (
ReductionStep) -
Strong test coverage using
proptestandapprox
-
DSL parser + AST + lowering to
CircuitGraph -
CLI “solve” command fully wired to DSL input
-
Delta–Wye reduction
-
Full circuit solving (not just reduction):
- nodal analysis / MNA for voltages and currents
- support for independent sources (voltage/current sources)
-
Solving unknowns (symbolic or numeric)
-
Power reporting and explanation output
The workspace is split into three crates:
The engine that represents circuits and performs reduction.
Main modules:
units: physical quantities and impedance mathcomponent: component types (R/L/C, impedance, sources)graph: circuit graph representationreduce: reduction algorithms and step tracking
A circuit description language that will allow writing circuits in a simple, readable text format.
Planned pipeline:
- Parse input into an AST
- Lower AST into a
CircuitGraph - Solve using the core engine
A command-line interface to run ElectroSolve from the terminal.
ElectroSolve models a circuit as a graph:
-
Nodes represent connection points (netlist nodes)
-
Components connect two nodes and have a type:
- resistor, inductor, capacitor
- generic impedance
- (planned) sources and dependent elements
For AC analysis, each component is converted into a complex impedance:
-
Resistor: ( Z_R = R )
-
Inductor: ( Z_L = j\omega L )
-
Capacitor: ( Z_C = \frac{1}{j\omega C} )
The reducer then repeatedly searches for simplifications:
- Parallel groups: multiple passive components across the same node pair
- Series pairs: two passive components connected through a node with degree 2
Each simplification is recorded as a ReductionStep, so the system can later produce a human-readable explanation.
You need Rust installed (stable toolchain recommended).
Build everything:
cargo buildRun tests:
cargo testThe CLI currently supports a placeholder command:
cargo run -p electro_solve_cli -- solve <file> <frequency_hz>Example:
cargo run -p electro_solve_cli -- solve examples/circuit.es 1000At the moment, the CLI reads the file and parses the frequency, but circuit parsing is not implemented yet. This will be connected once the DSL crate is completed.
The DSL is still under development, but the intended direction is a simple netlist-like syntax.
Example idea (not final):
ground gnd
R1 n1 n2 100
C1 n2 gnd 10u
L1 n1 gnd 2m
solve impedance n1 gnd @ 1kHzPlanned output (example):
- Equivalent impedance between
n1andgnd - Reduction steps (series/parallel transforms)
- Optional explanation in text form
- Finish DSL parsing and lowering
- Allow building graphs from text files
- Print reduction steps and final equivalent impedance
- Add Modified Nodal Analysis (MNA)
- Support voltage/current sources correctly
- Solve for node voltages and branch currents
- Support unknown values such as
R = x - Solve systems of equations numerically
- Add constraints (known voltages, known currents, measured impedance, etc.)
- Convert reduction/solve steps into readable explanations
- Provide intermediate results and reasoning
- Make outputs suitable for learning, not just computation
-
Correctness first: property-based tests validate invariants and physical behavior.
-
Separation of concerns:
coreis the enginedslis the input layercliis the interface
-
Step tracking: reductions and solving steps should be explainable, not “black box”.
This is a student-focused project. Contributions are welcome, especially for:
- DSL grammar design
- Reduction edge cases (especially complex impedance stability)
- MNA implementation and validation
- Explanation formatting and UX
If you plan to contribute, keep changes small and add tests where possible.
MIT License. See LICENSE.