sycan.components.basic.vswitch

Voltage-controlled switch (SPICE S).

A smooth resistive switch:

R(V_c) = R_off + (R_on - R_off) · ½ · (1 + tanh((V_c - V_t) / V_h))

with V_c = V(nc_plus) - V(nc_minus). V_t is the threshold voltage and V_h is the half-width of the transition (smaller → sharper switch, but harder for Newton’s method to close on).

  • DC: the conductance G(V_c) = 1/R(V_c) is stamped through stamp_nonlinear so V_c can come from the operating point.

  • AC: linearised around an operating point V_c_op. Two terms drop out — a small-signal conductance between n_plus/n_minus and a transconductance into nc_plus/nc_minus from the voltage drop across the switch. When the switch is hard on or hard off, the cross term is negligible and the switch behaves like a static resistor.

Classes

VSwitch(name, n_plus, n_minus, nc_plus, nc_minus)

Voltage-controlled smooth switch.

class sycan.components.basic.vswitch.VSwitch(name, n_plus, n_minus, nc_plus, nc_minus, R_on=1, R_off=<factory>, V_t=0, V_h=<factory>, *, V_c_op=None, include_noise=None)[source]

Bases: Component

Voltage-controlled smooth switch.

Parameters:
  • name (str) – Switched terminals.

  • n_plus (str) – Switched terminals.

  • n_minus (str) – Switched terminals.

  • nc_plus (str) – Control terminals.

  • nc_minus (str) – Control terminals.

  • R_on (Expr) – Resistances in the closed and open states.

  • R_off (Expr) – Resistances in the closed and open states.

  • V_t (sympy.core.expr.Expr) – Control-voltage threshold (midpoint of the transition).

  • V_h (sympy.core.expr.Expr) – Transition half-width.

  • V_c_op (sympy.core.expr.Expr | None) – Operating-point control voltage used for AC linearisation. Defaults to a per-instance symbol V_c_op_<name> when None.

  • include_noise (None | str | list[str] | tuple[str, ...] | frozenset[str])

name: str
n_plus: str
n_minus: str
nc_plus: str
nc_minus: str
R_on: Expr = 1
R_off: Expr
V_t: Expr = 0
V_h: Expr
V_c_op: Expr | None = None
include_noise: None | str | list[str] | tuple[str, ...] | frozenset[str] = None
ports: ClassVar[tuple[str, ...]] = ('n_plus', 'n_minus', 'nc_plus', 'nc_minus')
has_nonlinear: ClassVar[bool] = True
SUPPORTED_NOISE: ClassVar[frozenset[str]] = frozenset({})
stamp(ctx)[source]
Parameters:

ctx (StampContext)

Return type:

None

stamp_nonlinear(ctx)[source]

Add transcendental terms to ctx.residuals at solve time.

Only invoked for DC analysis when the circuit contains at least one component with has_nonlinear = True. Default is no-op.

Parameters:

ctx (StampContext)

Return type:

None