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.1.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.1-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: electrotechnics-1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 f4175ec2dc239b100c3f284c8cc44474e41becd07ae2089efa699210f2b695ae
MD5 36957d0e1f761459a50294afbd24ed6f
BLAKE2b-256 95ed3abb71ad11df300d73a13eb2c522ea6cc201f1ae8c6cea80e79d527becac

See more details on using hashes here.

File details

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

File metadata

  • Download URL: electrotechnics-1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2e67cbfeea36bbc711b4078ba8d833895765d203f00da6af90f0370853cdaa53
MD5 696414365cb040aa7efbdb3ecad7b4cc
BLAKE2b-256 375967980ae49e955b896c07585761138842e9d1036e3eb221813b329fc9a40a

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