Skip to main content

Solve electrical circuits

Project description

RTDS Circuit Analysis

RTDS Circuit Analysis is a Python software for solving electrical circuits, when given their netlist.

Installation

If you plan on using the command line interface for this software, you can use pipx for this:

pipx install rtds-circuit-analysis

If you want to use the library, however, you might prefer using pip for the installation:

pip install rtds-circuit-analysis

Netlist

Before actually using this program, you will need to write the circuit you want to analise as a netlist. This software uses a netlist style similar to SPICE programs, where each line corresponds to each component in the circuit. They will be formatted like Vin in 0 V, where:

  • The the first letter in the first word, V is the component type (V for voltage source, R for resistors, etc), and together with the rest, Vin, make up the component name.
  • The second and third words are the nodes the component is connected to. Their names are arbitrary, except for the node 0, which will always be ground. It is also always necessary.
  • The final word will be the value for the circuit. It can be a literal (such as in this case, V), a numeric value (like 10k), or a combination of both (like 10V).

For example, here is a basic RLC circuit...

rlc_circuit

... and its netlist representation:

V1 1 0 10
R1 1 2 1k
L1 2 3 100m
C1 3 0 10u

Usage

Command Line Interface

The basic usage for the CLI software is in the form:

rtds-circuit-analysis netlist.cir

netlist.cir being the path for the file containing the netlist. This will print all the solutions for the circuit (node voltages, currents, states, etc). You can use flags to filter the output. For example, to show only the currents for each component, you can run:

rtds-circuit-analysis netlist.cir -i

You can filter it even more, by giving the components/node names to the flags as parameters. So, if you want the voltage and current for the resistor R1 only, you can run:

rtds-circuit-analysis netlist.cir -v R1 -i R1

Library

To solve the circuit, you need to import the Circuit class, and pass the netlist as a parameter, creating a circuit object.

from rtds_circuit_analysis import Circuit

circuit = Circuit("netlist.cir")

This Circuit object will have all circuit solutions stored as attributes. So, for example, to find the voltage at node "2", you can use:

circuit.node_voltages["2"]

You can also use the print methods to print the solutions for the circuit in a formatted manner, similar to the CLI. For example, to print the voltages for the components R1 and R2, you can run:

circuit.print_component_voltages("R1", "R2")

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

rtds_circuit_analysis-0.1.0.tar.gz (24.6 kB view details)

Uploaded Source

Built Distribution

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

rtds_circuit_analysis-0.1.0-py3-none-any.whl (22.8 kB view details)

Uploaded Python 3

File details

Details for the file rtds_circuit_analysis-0.1.0.tar.gz.

File metadata

  • Download URL: rtds_circuit_analysis-0.1.0.tar.gz
  • Upload date:
  • Size: 24.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for rtds_circuit_analysis-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a317e0dd13a211289ba2e4948e59dbe03674012473406689623057029cc68d04
MD5 fb910d63e45ae7ae28282d1a08f9159c
BLAKE2b-256 a83b9ca2ee8d6a45e0b4be8b3620066781700097213a4f17b5803cf8b8bcf8de

See more details on using hashes here.

File details

Details for the file rtds_circuit_analysis-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for rtds_circuit_analysis-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 09a06a1fa7111a5fc1251b58c7d9811307fc1039d0bc63df8d1f4017fc910495
MD5 ede5635b3445b19d6f410da73f1e69c5
BLAKE2b-256 6eec538dcf5fa7a659f4819594879d47ccae6447ae367cc4725a55b40c58a0bb

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