Modeling

The modeling of analog elements in PyAMS is based on writing their description using the Python language respecting the following structure:

  1. Declaration of the library;

  2. Creation of the name of the model;

  3. Adding parameters with an initial value;

  4. Adding type of signals (current or voltage);

  5. Adding sub-models if available.

  6. Definition of relations between signals and parameters.

The global form for modeling any analog element in PyAMS is shown in this source:

from PyAMS import model, signal        # Declaration of library

class name_of_element(model):          # Model name

     def __init__(self,ports):         # Initial function
                                       # Her signals and
                                       # parameters declarations

     def analog(self):                 # Analog function
                                       # Her equation or
                                       # analog operation

Initial and analog functions

The initial function (def __init__) is used to creating ports for connections to other units, signals, variables, and parameters with default values. The analog function (def analog) is the behavioral modeling of the analog element by giving the relation between signals and parameters.

The __init__ function and the analog function represent the principal functions of the model. However, there are two other secondary functions used to describe the model, i.e. the sub function, which is used to construct a sub-circuit in the model, and the start function, which is used to initialize values while starting a simulation.

Signals and parameters in PyAMS

Signals in PyAMS represent the voltage or current in the analog model with the direction and position of the connection. The signal declaration in PyAMS by the Python language follows this command:

signal ([Direction, Type, Port_p ,Port_n])

where Direction is the direction of the signal (in or out or inout), Type is the type of the signal (current or voltage), and Port_p and Port_n are where the positive and negative terminal are connected in the model, respectively. Any electrical or analog element contains parameters represented by constant or variable values used for operation between voltages and currents. The parameter declaration by the Python language defines its value, unit, and description as follows

param([Value,Unit,Description])

The operations allowed between signals and parameters are summarized in Table.

Operation

Description

Result

+

Addition

real

-

Subtraction

real

*

multiplication

real

/

division

real

**

exponentiation

real

==

test for equality

boolean

!=

test for inequality

boolean

<

test for less than

boolean

<=

test for less than or equal

boolean

>

test for greater than

boolean

>=

test for greater than or equal

boolean

+=

get value

real