Simulation modeling of analog, digital and mixed-signal electronic elements and circuits
Project description
pyams_lib
Python library for analog and mixed-signal simulation (PyAMS Library)
PyAMS Library
What is pyams-lib?
pyams_lib is a Python package designed to simplify the modeling of analog and digital elements and the simulation of electronic circuits. It provides:
- The ability to create custom models of electrical components.
- Simulation of circuits in different modes of operation.
- Visualization of simulation results using
matplotlib. - Compatibility with Python 3+ and PyPy, working across Linux, Windows, and macOS.
- PyAMS library (pyams_lib) documentation https://pyams-lib.readthedocs.io/.
- For circuit design using the CAD system, visit the software section at https://pyams.sf.net.
Installation
To install pyams_lib, use the following command:
pip install pyams_lib
To upgrade to the latest version:
pip install --upgrade pyams_lib
License
pyams_lib is free to use and distributed under the GPLv3 license.
Example
Example of modeling resistor and simulation in circuit
Modeling Resistor
from pyams.lib import model,signal,param
from pyams.lib import voltage,current
#Creat resistor model------------------------------------------------------------
class resistor(model):
"""
This class implements a Resistor model.
init(): initals Signals and Parameters
analog(): Defines the resistor behavior using Ohm's Law:
I = V / R
"""
def __init__(self, p, n):
#Signals declarations---------------------------------------------------
self.V = signal('in',voltage,p,n)
self.I = signal('out',current,p,n)
#Parameters declarations------------------------------------------------
self.R=param(1000.0,'Ω','Resistance')
self.Pout=param(1000.0,'Ω','Resistance')
def analog(self):
"""Defines the resistor's current-voltage relationship using Ohm's Law."""
#Resistor equation-low hom (Ir=Vr/R)------------------------------------
self.I+=self.V/self.R
Voltage Divider Circuit Simulation
This example demonstrates a simple voltage divider circuit consisting of:
- A DC voltage source (V1) supplying the input voltage.
- Two resistors (R1 and R2) connected in series.
- The output voltage measured across R2.
Circuit Diagram
Code:
from pyams.lib import circuit
from pyams.models import DCVoltage
# Elements of circuit
V1= DCVoltage('n1', '0') # Voltage source between node 'n1' and ground '0'
R1= resistor('n1', 'n2') # Resistor R1 between node 'n1' and 'n2'
R2= resistor('n2', '0') # Resistor R2 between node 'n2' and ground '0'
# Set parameters for the elements
V1.setParams("Vdc=15V") # Set input voltage to 10V
R1.setParams("R=2kΩ") # Set R1 to 2kΩ
R2.setParams("R=2kΩ") # Set R2 to 2kΩ
# Create a circuit instance
myCircuit = circuit()
# Add elements to the circuit
myCircuit.addElements({'V1': V1,'R1': R1, 'R2': R2})
# Perform DC analysis (operating point analysis)
myCircuit.analysis(mode='op')
myCircuit.run()
# print value voltage at node 'n2' and current in 'R1'
myCircuit.print('n2', R1.I)
Expected Output:
Output Voltage at node n2: 7.50 V
Output current R1.I: 3.75 mA
This example demonstrates how pyams_lib simplifies circuit simulation, making it easier to analyze electronic components and their behavior efficiently.
Support the Project 💖
If you need more support or assistance with this project, and would like to contribute to the development of the PyAMS library, consider donating through my Ko-fi page: https://ko-fi.com/pyams/
Project details
Release history Release notifications | RSS feed
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 pyams_lib-0.2.4.tar.gz.
File metadata
- Download URL: pyams_lib-0.2.4.tar.gz
- Upload date:
- Size: 213.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f3521399667618ede6b9401dbf28d62e3bb94dff0f836f1d0bee80fe50976b64
|
|
| MD5 |
ad6ce2c42631a8d4fc926991949ca027
|
|
| BLAKE2b-256 |
b8f59a461a454d156580a8d88826baa785c4568cb068e2c37f135a549ae0762e
|
File details
Details for the file pyams_lib-0.2.4-py3-none-any.whl.
File metadata
- Download URL: pyams_lib-0.2.4-py3-none-any.whl
- Upload date:
- Size: 387.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f6397aa8b186da9e9e74cec9e9f95854921c60eab99e30766753e0c744d70775
|
|
| MD5 |
795c1f21d3be7f34e7d30aecbd2bf35f
|
|
| BLAKE2b-256 |
dc5fa114cdb42701cd562a9da60278c184a12d398733f1dab55cd95bf7eb3526
|