Skip to main content

A library for basic electrotechnical calculations

Project description

Electrotechnics

A small Python library for basic circuit analysis using nodal Laplacian (admittance) matrices.

This repository provides utilities to build complex nodal Laplacian matrices from edge lists and compute Thevenin equivalent impedances between nodes. It includes a small example that computes and plots the Thevenin impedance of a sample circuit as a function of frequency.

Features

  • Build nodal Laplacian (admittance) matrices from edge lists (impedance or admittance input).
  • Compute equivalent Thevenin impedance between two nodes using the Moore–Penrose pseudoinverse or test-current method.
  • Example script that sweeps frequency and plots magnitude and phase using matplotlib.

Installation

Install the lastest stable version from the PyPI repository.

pip install electrotechnics -U

On MS Windows you may prefer:

python -m pip install electrotechnics -U

Once installed, run the example in a Python script or console:

from electrotechnics.examples import example1

Requirements

  • Python 3.8+
  • numpy
  • matplotlib (only required for the example plotting)

Install the required packages (recommended in a virtual environment):

python -m pip install numpy matplotlib

Usage

Run the provided example (from the repository root). The example script is inside the src package, so run it on Linux with PYTHONPATH set to src.

env PYTHONPATH=src python -m electrotechnics.examples.example1

This will print the Thevenin impedance at a reference frequency and open two plots (magnitude and phase vs frequency).

You can also import the core function in your code:

from electrotechnics.circuit import z_th_circuit

# edges: list of (n1, n2, z) where z is complex impedance
edges = [(1, 0, 100.0), (1, 2, 1j*2*np.pi*1000*10e-3)]
Z = z_th_circuit(edges, a=1, b=0)

License

This project is licensed under the MIT License — see the LICENSE file for details.

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

electrotechnics-1.0.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

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

electrotechnics-1.0-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file electrotechnics-1.0.tar.gz.

File metadata

  • Download URL: electrotechnics-1.0.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.2

File hashes

Hashes for electrotechnics-1.0.tar.gz
Algorithm Hash digest
SHA256 02637d50da0a41b44f06ecac60688892e02f267f54a0a1acf5c30c3d5bbfe5b3
MD5 7246c48dcf18075b457d85fb725ca9b4
BLAKE2b-256 fe984acc071caed613ad32af3577f1347a003ee5ccef984d1bc2d53bfa1a2516

See more details on using hashes here.

File details

Details for the file electrotechnics-1.0-py3-none-any.whl.

File metadata

  • Download URL: electrotechnics-1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.2

File hashes

Hashes for electrotechnics-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 df8cbccd3945947d9f76c101e8b8d7959376a9c19437ad2c15565d2a647e8473
MD5 3c545f45379cee0a8536f51f14e1d590
BLAKE2b-256 cbb09cd9c61387bf8408ae0ebe626602f86a84dbeb10ec7a8dedaccabbb34db1

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