Skip to main content

A python package for symbolic electronic circuit analysis

Project description

SymCirc

pypi version Downloads Powered by SymPy Tests codecov

A lightweight python package for symbolic circuit analysis.

Documentation

Documentation is available on GitHub Pages.

What can it do?

SymCirc currently offers symbolic and semisymbolic DC, AC and transient small signal circuit analysis. It supports the following ideal circuit elements: resistors, inductors, capacitors, independent sources, controlled sources, ideal operational amplifiers and coupled inductors. BJT, MOS and diode have models implemented only for AC and TF analysis. Transient simulation allows for initial conditions of capacitors and standard/coupled inductors.

Install

Use this command to install via pip

pip install symcirc

Hard dependencies

SymPy

SymCirc is a light-weight package. It needs only the SymPy package, which is used for computations. It should get automatically installed with SymCirc when installed using pip.

Optional dependencies

gmpy2

To achieve better performance install the gmpy2 package. If gmpy2 is installed, SymPy automatically uses it for integer operations. It significantly impacts semi-symbolic analysis performance.

symengine

SymEngine is an optional symbolic core for SymPy. To use the SymEngine core, run your script with the environment variable USE_SYMENGINE=1, or run AnalyseCircuit with an optional argument use_symengine=True Example: symcirc.AnalyseCircuit(netlist, use_symengine=True)

numpy and matplotlib

For bode plots and other graphing utilities.

Build

Or you can build with this command:

python setup.py sdist bdist_wheel

Examples

See examples for more insight into circuit analysis with SymCirc.

Basic simulation example

from symcirc import *

# Insert your netlist
netlist = """CIRCUIT NAME - First line is always the circuit name
* This is a comment
R1 1 0 2k
R2 3 0 (1/G)
V1 2 1 dc 1 ac 1
R3 3 4 6k
C1 3 4 1n
R4 4 0 10k
V2 4 0 dc 5
I1 3 2 dc 1m ac 0
"""

# Execute netlist simulation
analysis_type = "DC"  # or "AC", "TF", "tran"
method = "tableau"  # Default is "two_graph_node", which is faster, but currently lacks coupled inductors.
symbolic = True  # If set to False, only elements which have no numeric value are left as symbolic. In this case only R2 stays symbolic.

circuit = AnalyseCircuit(netlist, analysis_type, symbolic=True, method=method)

all_values = circuit.component_values("all")
latex_formatted_values = to_latex(all_values)

print(all_values)

Netlist syntax

There are many example netlists available in the netlists folder. This folder contains a database of netlists which are used to automatically test every new version of SymCirc.

Elements

  • Resistor: RXXX N+ N- RESISTANCE
  • Capacitor: CXXX N+ N- CAPACITY IC=<INIT_VOLTAGE>
  • Inductor: LXXX N+ N- INDUCTANCE IC=<INIT_CURRENT>
  • Coupling: KXXX LYYY LZZZ K
  • Voltage source: VXXX N+ N- dc VOLTAGE ac AMPLITUDE
  • Current source: IXXX N+ N- dc CURRENT ac AMPLITUDE
  • IOAMP: AXXX Nout1 Nout2 Nin+ Nin-
  • VCVS: EXXX N1 N2 Ncontrol+ Ncontrol- GAIN
  • CCCS: FXXX N1 N2 VSENSE GAIN
  • VCCS: GXXX N1 N2 Ncontrol+ Ncontrol- GAIN
  • CCVS: HXXX N1 N2 VSENSE GAIN

Units

  • terra: T
  • giga: G
  • mega: meg
  • kilo: k
  • mili: m
  • micro: u
  • nano: n
  • pico: p
  • femto: f

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

symcirc-0.2.0.tar.gz (27.6 kB view details)

Uploaded Source

Built Distribution

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

symcirc-0.2.0-py3-none-any.whl (25.6 kB view details)

Uploaded Python 3

File details

Details for the file symcirc-0.2.0.tar.gz.

File metadata

  • Download URL: symcirc-0.2.0.tar.gz
  • Upload date:
  • Size: 27.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.0

File hashes

Hashes for symcirc-0.2.0.tar.gz
Algorithm Hash digest
SHA256 effc14385b96eefdf9500d1914b5e3634f75e1d8cc4bcfbc39abd5574265b7cf
MD5 25da2c1821943f727a8ffc2b267ee18d
BLAKE2b-256 2099d11541724a620e6c581d94ae4f1e20a608c48cbcdc7682a6531c13e960ff

See more details on using hashes here.

File details

Details for the file symcirc-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: symcirc-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 25.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.0

File hashes

Hashes for symcirc-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 00b8b45c1de99743d5d2c25d115ad114168b72bccab1846b7d4d775f863b430f
MD5 bdcc9cea6d735ce6092e3bd9989490ae
BLAKE2b-256 21ad781d91b63c5f30073f79dd32557bc532f50fc0037db745a74f607bf69555

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