ahkab.switch¶
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 currentget_go(ports_v, device)
- ouput conductanceget_gm(ports_v, device)
- output transconductanceget_dc_guess(self, is_on)
- guesses for OP
The device instance accesses the following attributes:
part_id
(a string), the device label.Parameters:
- 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:
get_output_ports()
-> (n1, n2)get_drive_ports()
-> (n1, n2), (ns1, ns2)
-
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 inports_v
across its ports, at (simulation)time
.Parameters:
- 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.
Returns:
- g : float
- The transconductance.
-
get_drive_ports
(op)[source]¶ Get the ports that drive the output ports.
Parameters:
- op : op solution
- The OP where the drive ports are used.
Returns:
pts : tuple of tuples of ports nodes, as:
(port0, port1, port2 ... )
Where each port is in the form:
port0 = (nplus, nminus)
-
get_op_info
(ports_v)[source]¶ Information regarding the Operating Point (OP)
Parameters:
- ports_v : list of lists
- The parameter is to be set to
[[v]]
, wherev
is the voltage applied to the switch terminals.
Returns:
- 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_output_ports
()[source]¶ Get the output port.
The output port is
(n1, n2)
for the voltage-controlled switch case.Returns:
- 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.Parameters:
- 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.
Returns:
- i : int
- The output current.
-
update_status_dictionary
(ports_v)[source]¶ 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()
.Returns:
None
.
-
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)\).
-
get_dc_guess
(is_on)[source]¶ 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).