Skip to main content

Library for analysing and calculating electric networks.

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

circuitcalculator-0.4.23.tar.gz (57.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

circuitcalculator-0.4.23-py3-none-any.whl (78.9 kB view details)

Uploaded Python 3

File details

Details for the file circuitcalculator-0.4.23.tar.gz.

File metadata

  • Download URL: circuitcalculator-0.4.23.tar.gz
  • Upload date:
  • Size: 57.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for circuitcalculator-0.4.23.tar.gz
Algorithm Hash digest
SHA256 8c77ff6e19495c0e149b88a1795a9ebdd3163e1cfae89a000756251013d4d339
MD5 4b183c99d8485939f600aef0c7f36db5
BLAKE2b-256 a7285de74c5ebe09674d7e5787183e30db7e040f423227a0b681d9f61778ba3d

See more details on using hashes here.

File details

Details for the file circuitcalculator-0.4.23-py3-none-any.whl.

File metadata

File hashes

Hashes for circuitcalculator-0.4.23-py3-none-any.whl
Algorithm Hash digest
SHA256 382014f20377b494f9112d05cbe5651010e22f11f0f85f6436855fce0388cf39
MD5 576de38ac97bf578acfcef2e301336b0
BLAKE2b-256 f77a9fbeab14d47c485733d3e36ab3431af9075fc0a32bddab8c1e5df55d2c91

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page