Skip to main content

CircuitCalculator

CircuitCalculator is a Python library for symbolic and numeric analysis of electrical circuits. It supports DC and AC analysis, nodal analysis, state-space modeling, and works with both numeric and symbolic component values. The library is designed for engineers, students, and researchers who want to analyze, simulate, or teach circuit theory using Python.

Features

  • Symbolic and numeric circuit analysis
  • Support for resistors, capacitors, inductors, voltage sources, and current sources
  • Nodal analysis and state-space modeling
  • Easy-to-use API for building and solving circuits
  • Integration with Jupyter/IPython notebooks for interactive exploration

Installation

You can install CircuitCalculator and its dependencies using pip (e.g. in a virtual environment):

python -m venv ./venv
source ./venv/bin activate
pip install CircuitCalculator

Usage

The most convenient interface is the Circuit class, which allows you to define a circuit as a list of components and then solve it. Below is a minimal example for DC analysis:

Example

from CircuitCalculator.Circuit.circuit import Circuit
import CircuitCalculator.Circuit.Components.components as ccp
from CircuitCalculator.Circuit.solution import dc_solution

# Define the circuit
circuit = Circuit([
    ccp.dc_voltage_source(V=1, id='Vs', nodes=('1', '0')),
    ccp.resistor(R=1, id='R', nodes=('1', '0'))
])

# Solve the circuit
solution = dc_solution(circuit)
print(f'I(R)={solution.get_current("R"):2.2f}A')
print(f'V(R)={solution.get_voltage("R"):2.2f}V')

Output:

I(R)=1.00A
V(R)=1.00V

Examples

Several Jupyter/IPython notebook examples can be found in the examples directory.

Three-Phase API

The three-phase API is available in CircuitCalculator.ThreePhaseCircuit and uses explicit factory functions per topology.

from CircuitCalculator.ThreePhaseCircuit import (
    ThreePhaseCircuit,
    three_phase_voltage_source_star,
    three_phase_voltage_source_delta,
    three_phase_current_source_star,
    three_phase_current_source_delta,
    three_phase_impedance_load_star,
    three_phase_impedance_load_delta,
    three_phase_custom_component_line,
    three_phase_custom_component_star,
    three_phase_custom_component_delta,
    three_phase_complex_solution,
)

Main functions:

  • three_phase_voltage_source_star(id, nodes=(phase_bus, neutral_bus), V, Z=0j)
  • three_phase_voltage_source_delta(id, nodes=(phase_bus,), V, Z=0j)
  • three_phase_current_source_star(id, nodes=(phase_bus, neutral_bus), I, Y=0j)
  • three_phase_current_source_delta(id, nodes=(phase_bus,), I, Y=0j)
  • three_phase_impedance_load_star(id, nodes=(phase_bus, neutral_bus), Z)
  • three_phase_impedance_load_delta(id, nodes=(phase_bus,), Z)
  • three_phase_custom_component_line(id, nodes=(from_bus, to_bus), phase_a, phase_b, phase_c)
  • three_phase_custom_component_star(id, nodes=(phase_bus, neutral_bus), phase_a, phase_b, phase_c)
  • three_phase_custom_component_delta(id, nodes=(phase_bus,), phase_a, phase_b, phase_c)

Solver note:

  • three_phase_current_source_delta may lead to a solver contradiction in pure-current-source setups without a stabilizing voltage-defined branch. See examples/python/three_phase/example_three_phase_delta_current_source_conflict.ipynb.

Contribution

This project is open-source and contributions are welcome. If you would like to contribute, please fork the repository and make a pull request.

License

This project is licensed under the MIT License.

Contact

If you have any questions or issues, please open an issue on the GitHub repository.

Release files for CircuitCalculator 0.4.25

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for CircuitCalculator 0.4.25
File Size Uploaded
circuitcalculator-0.4.25.tar.gz 57.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for CircuitCalculator 0.4.25
File Interpreter ABI Platform
circuitcalculator-0.4.25-py3-none-any.whl Python 3 none any Details

Total release size: 136.9 kB

Release files / circuitcalculator-0.4.25.tar.gz

Download URL circuitcalculator-0.4.25.tar.gz
Size 57.8 kB
Tags Source
SHA-256 checksum
How to use checksums
b3be3619a8d81ba87d97b8473b4c7d4e3237965e80d3ca2795fec15906096f1d
BLAKE2b-256 checksum
How to use checksums
4d18b944b2420e0df6174b5c16b40f6c398ce6248709262aae9cc31eccd0958a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / circuitcalculator-0.4.25-py3-none-any.whl

Download URL circuitcalculator-0.4.25-py3-none-any.whl
Size 79.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8ebe589973340146966ac0dbdea47712b16a40424c7519cb23d5a906556125d4
BLAKE2b-256 checksum
How to use checksums
54745a58dd8b2aa377abef77967837e02867c9214768d85dc3756aa227a199cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release history Release notifications | RSS feed

This release

0.4.25 This release

2 release files

0.4.24

2 release files

0.4.23

2 release files

0.4.22

2 release files

0.4.21

2 release files

0.4.20

2 release files

0.4.19

2 release files

0.4.18

2 release files

0.4.17

2 release files

0.4.16

2 release files

0.4.15

2 release files

0.4.14

2 release files

0.4.13

2 release files

0.4.12

2 release files

0.4.11

2 release files

0.4.10

2 release files

0.4.9

2 release files

0.4.8

2 release files

0.4.7

2 release files

0.4.6

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

0.0.16

2 release files

0.0.15

2 release files

0.0.14

2 release files

0.0.13

2 release files

0.0.12

2 release files

0.0.11

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page