Implementation of a voltage controlled switch.

This module defines two classes: switch_device, switch_model

class switch_device(n1, n2, sn1, sn2, model, ic=None, part_id=u'S')[source]

This is a general switch element.

It has the following structure:


In ASCII for those who are consulting the documentation from the Python command line:

sn1 o--+         +--o n1
       |         |
      +-+      \ o
      |R|       \
      +-+        +
       |         |
sn2 o--+         +--o n2

The behavior is set by the model supplied.

The device instance calls the following methods in the model:

  • get_i(ports_v, device) - output current
  • get_go(ports_v, device) - ouput conductance
  • get_gm(ports_v, device) - output transconductance
  • get_dc_guess(self, is_on) - guesses for OP

The device instance accesses the following attributes: part_id (a string), the device label.


n1 : str
Positive output node (+)
n2 : str
Negative output node (-)
sn1 : str
Positive input node (+)
sn2 : str
Negative input node (-)
model : model obj
An instance of (v)switch_model
ic : bool, optional
The initial conditions: True stands for on, False for off.

Selected methods:

g(op_index, ports_v, port_index, time=0)[source]

Returns the differential (trans)conductance.

The transconductance is computed wrt the port specified by port_index when the element has the voltages specified in ports_v across its ports, at (simulation) time.


ports_v : list
Voltages applied to the switch. The list should be in the form: [voltage_across_port0, voltage_across_port1, ... ]
port_index : int
The index of the output port.
time : float
The simulation time at which the evaluation is performed. Set it to None during DC analysis.


g : float
The transconductance.

Get the ports that drive the output ports.


op : op solution
The OP where the drive ports are used.


pts : tuple of tuples of ports nodes, as: (port0, port1, port2 ... )

Where each port is in the form: port0 = (nplus, nminus)


Return a netlist line corresponding to the switch.


Information regarding the Operating Point (OP)


ports_v : list of lists
The parameter is to be set to [[v]], where v is the voltage applied to the switch terminals.


op_keys : list of strings
The labels corresponding to the numeric values in op_info.
op_info : list of floats
The values corresponding to op_keys.

Get the output port.

The output port is (n1, n2) for the voltage-controlled switch case.


pts : tuple of tuples of ports nodes
Such as: (port0, port1, port2 ... ). Where each port is in the form: port0 = (nplus, nminus)
i(op_index, ports_v, time=0)[source]

Returns the current flowing in the element.

The element is assumed to be biased with the voltages applied as specified in the ports_v vector.


op_index : int
The index of the output port for which the current is evaluated.
ports_v : tuple
A tuple constructed such as (voltage_across_port0, voltage_across_port1, ... )
time : float, optional
The simulation time at which the evaluation is performed. It is needed by time-variant elements, and it has no effect here. Set it to None during DC analysis.


i : int
The output current.

Updates an internal dictionary that can then be used to provide information to the user regarding the status of the element.

Normally, one would call get_op_info().



class vswitch_model(name, VT=None, VH=None, VON=None, VOFF=None, RON=None, ROFF=None)[source]

Voltage-controlled switch model.

sn1 o--+         +--o n1
       |         |
      +-+      \ o
      |R|       \
      +-+        +
       |         |
sn2 o--+         +--o n2

Note that:

  • R is infinite.
  • The voltage needed to close the switch is: \(V(s_{n1})-V(s_{n2}) > V_T+V_H\).
  • To re-open it, one needs to satisfy the relationship: \(V(s_{n1})-V(s_{n2}) < V_T-V_H\).

The switch commutes between two statuses:

  • \(R_{OUT} = R_{OFF}\)
  • \(R_{OUT} = R_{ON}\)

None of which can be set to zero or infinite.

The switching characteristics are modeled with \(tanh(x)\).


Returns a list of two floats to be used as initial guesses for the OP analysis

get_gm(xxx_todo_changeme2, dev, debug=False)[source]

Returns the source to output transconductance or d(I)/d(Vsn1-Vsn2).

get_go(xxx_todo_changeme1, dev, debug=False)[source]

Returns the output conductance d(I)/d(Vn1-Vn2).

get_i(xxx_todo_changeme, dev, debug=False)[source]

Returns the output current.


All the internal parameters of the model get printed out, for visual inspection.