PyAMS BETA

Python for Analog and Mixed Signals

Model and simulate analog and mixed-signal circuits in Python. Describe an element in a few lines, connect it to ready-made components, and run a DC, transient or AC analysis.

  • Custom models written as plain Python classes
  • About 40 ready-made components, from resistors to MOSFETs and op-amps
  • Also available as a CAD system: PyAMS software and VS Code extension

Free and open source (MIT) · Python 3.8+ · Linux, Windows, macOS

Install Documentation

What is PyAMS?

PyAMS (Python for Analog and Mixed Signals) is an open-source tool for modeling and simulating analog and mixed-signal electronic circuits. It is built around the pyams-lib library, which solves circuits by modified nodal analysis and Newton–Raphson, so you only describe what each element does.

Connect ready-made or custom elements by node names, run a DC, transient or AC analysis, sweep any parameter, and plot or post-process the results — all in plain Python.

Two ways to use PyAMS
As a Python library

Install pyams-lib with pip and write your circuits as Python scripts.

Inside the CAD system

Use the PyAMS application or the VS Code extension for schematics, symbols and a waveform viewer. The library is already included.

Note: PyAMS is currently in Beta stage. The core is stable and tested on many circuits, but some features may still change. Feedback is highly appreciated!

Features

DC, Transient and AC

Operating point, DC sweeps, time-domain simulation and small-signal frequency response.

Custom Modeling

Write a new element as a Python class: declare signals and parameters, then write the equations.

About 40 Ready Models

Passive elements, sources, diodes, thyristors, BJT, MOSFET, JFET, IGBT, op-amp, comparator and 555 timer.

Parametric Sweep

Repeat any analysis for a list of parameter values and overlay the curves.

Robust Solver

Adaptive time step, second-order integration and automatic convergence aids for switching circuits.

Plots and Results

Built-in Matplotlib plots, or NumPy arrays for your own post-processing. Interactive Plotly viewer in the CAD system.

Cross-platform

Pure Python 3 on Linux, Windows and macOS (CPython and PyPy). Only NumPy and Matplotlib are needed.

Documented

A page for every model and 40 ready-to-run circuit examples with their results.

Free and Open Source

Distributed under the MIT license.

CAD system

Besides the Python library, PyAMS is a CAD system for designing and simulating circuits graphically. Use it in one of two ways:

1. VS Code, with the PyAMS extension

The CAD tools inside Visual Studio Code, next to your Python files and models: draw schematics, design symbols and simulate without leaving the editor.

PyAMS extension
2. The PyAMS software

A dedicated application: a complete environment to draw the schematic, design symbols, run the simulation and view the results.

Download from SourceForge
What the CAD system does
Schematic capture
Draw the circuit and connect the elements.
Symbol design
Create symbols for the elements, including your own models.
Simulation
DC, transient and AC analyses with the pyams library.
Waveform viewer
Interactive Plotly viewer for the results.

The pyams library is already included in both: you only need Python with numpy and matplotlib.

Quick start

A half-wave rectifier in a dozen lines: elements, parameters, circuit, analysis, plot.

from pyams.lib import circuit
from pyams.models import Resistor, SinVoltage, Diode

V1 = SinVoltage("In", "0");  V1.setParams("Va=10V Fr=2Hz")
D1 = Diode("In", "Out")
R1 = Resistor("Out", "0");  R1.setParams("R=1KΩ")

cir = circuit()
cir.addElements({"V1": V1, "D1": D1, "R1": R1})
cir.setOutPuts("In", "Out")
cir.analysis(mode="tran", start=0, stop=2, step=0.001)
cir.run()
cir.plot()
Write your own model
from math import exp
from pyams.lib import model, signal, param, voltage, current

class MyDiode(model):
    def __init__(self, p, n):
        self.V = signal('in',  voltage, p, n)
        self.I = signal('out', current, p, n)
        self.Is = param(1e-14, 'A', 'Saturation current')
        self.Vt = param(0.02585, 'V', 'Thermal voltage')

    def analog(self):
        self.I += self.Is * (exp(self.V / self.Vt) - 1)

Choose the analysis with analysis(mode="dc"), analysis(mode="tran", ...) or analysis(mode="ac", ...), and sweep any parameter with sweep(param="R1.R", list=[...]).

Ready-made models

Basic

Resistor, Capacitor, Inductor, Conductor, VCVS, VCCS, CCVS, CCCS, Transformer, Transmission line, with initial-condition variants.

Sources

DC, sine, AC, exponential, piece-wise linear and trapezoid (pulse) sources, for both voltage and current.

Semiconductor

Diode, Zener, Tunnel diode, Diac, Thyristor, UJT, BJT, MOSFET, JFET, IGBT.

Analog ICs

Operational amplifier, Comparator and 555 timer.

Browse all models in the documentation

Examples

Every example is a complete script that builds a circuit, runs an analysis and saves the figure.

Transient response of a series RLC circuit
Series RLC

Transient ringing of an under-damped circuit.

AC response of a series RLC band-pass filter
AC analysis

Band-pass response for several resistor values.

Full-wave bridge rectifier
Bridge rectifier

Full-wave rectification fed by a transformer.

555 timer astable multivibrator
555 timer

Astable multivibrator.

JFET output characteristics
JFET curves

Output characteristics with a DC sweep.

Chua double-scroll attractor
Chua's circuit

Double-scroll chaotic oscillator with op-amps.

Installation

Choose one of the three options:

1
Install the PyAMS software

The complete CAD application.

  1. Download the installer from SourceForge.
  2. Run it and follow the instructions.
  3. Start PyAMS and open or create a project.
Download from SourceForge
2
Install VS Code with the PyAMS extension

The CAD tools inside Visual Studio Code.

  1. Install Visual Studio Code.
  2. Open the Extensions view: Ctrl + Shift + X.
  3. Search for PyAMS and click Install.
PyAMS extension
3
Install the Python library

For your own Python scripts.

$ pip install pyams-lib

NumPy and Matplotlib are installed automatically. To upgrade later:

$ pip install --upgrade pyams-lib
pyams-lib on PyPI

Options 1 and 2 already include the pyams library: do not install it with pip.

Requirements

1. PyAMS software 2. VS Code + extension 3. pip install pyams-lib
Python required required 3.8 or higher (CPython or PyPy)
NumPy and Matplotlib required required installed automatically
Visual Studio Code – required –
The pyams library included included installed by pip
System Linux, Windows or macOS

Download and links

Download the PyAMS software, or get the extension, the library, the documentation and the source code.

PyAMS software — download from SourceForge version 0.3.0
Download PyAMS software
PyAMS extension

The CAD tools inside VS Code.

VS Code Marketplace PyAMS extension
Python package

Install the library with pip (version 0.3.0).

pip install pyams-lib PyPI
Documentation

Modeling, simulation, models and examples.

readthedocs.io Read the docs
Source code

For contributors and tinkerers.

d-fathi/pyams_lib GitHub