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.2.tar.gz (4.1 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.2-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for electrotechnics-1.2.tar.gz
Algorithm Hash digest
SHA256 d52359eb8c101de691413b8b527d2623f743e2355e8aa174513ce155c6d2b584
MD5 5ae882f44924654cd8ec8ec1ab10697e
BLAKE2b-256 2452527b3351ca2a50a67c7da23d110697b90e2eaf3c747e6e60486d59632b54

See more details on using hashes here.

File details

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

File metadata

  • Download URL: electrotechnics-1.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 aedd908289c0430753c1740e87814b76271767238cc758a5762b4c236900d13a
MD5 713e25f2bb5224a40e5b106a989c75ee
BLAKE2b-256 48e1beca78f276bf0300020111589d10a9b4a50e3867720644a4fe89d445df61

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