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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
02637d50da0a41b44f06ecac60688892e02f267f54a0a1acf5c30c3d5bbfe5b3
|
|
| MD5 |
7246c48dcf18075b457d85fb725ca9b4
|
|
| BLAKE2b-256 |
fe984acc071caed613ad32af3577f1347a003ee5ccef984d1bc2d53bfa1a2516
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
df8cbccd3945947d9f76c101e8b8d7959376a9c19437ad2c15565d2a647e8473
|
|
| MD5 |
3c545f45379cee0a8536f51f14e1d590
|
|
| BLAKE2b-256 |
cbb09cd9c61387bf8408ae0ebe626602f86a84dbeb10ec7a8dedaccabbb34db1
|