sycan.components.basic.behavioral

Behavioral sources (SPICE B elements).

Two flavours, both letting the user pin an arbitrary symbolic expression to a pair of nodes:

  • BehavioralCurrent — drives the current I = f(V(...), …) from n_plus to n_minus. Equivalent to SPICE B1 N+ N- I=... and ngspice’s Vxxx ... value={...} form.

  • BehavioralVoltage — enforces the voltage V(n_plus) - V(n_minus) = f(V(...), …). Equivalent to SPICE B1 N+ N- V=....

The expression may reference any sympy Symbol. Node voltages are addressed using the same naming convention as the MNA solution vector: Symbol("V(<node>)"). A behavioural element therefore captures nonlinear control laws — squarers, multipliers, sign extractors, saturating amplifiers — without having to wire them up from primitives.

  • DC — the expression is used directly via stamp_nonlinear(), so even non-polynomial control laws (tanh, Min, Max, exponentials, etc.) flow through the existing damped-Newton path.

  • AC — the expression is linearised around an operating point V_op_subs (a mapping {Symbol: value}). Partial derivatives with respect to every referenced node voltage are stamped as VCCS / VCVS contributions. If V_op_subs is None, the operating point is left symbolic — fine for symbolic transfer-function work.

Classes

BehavioralCurrent(name, n_plus, n_minus, expr, *)

Current source whose value is an arbitrary symbolic expression.

BehavioralVoltage(name, n_plus, n_minus, expr, *)

Voltage source whose value is an arbitrary symbolic expression.

class sycan.components.basic.behavioral.BehavioralCurrent(name, n_plus, n_minus, expr, *, V_op_subs=None, include_noise=None)[source]

Bases: Component

Current source whose value is an arbitrary symbolic expression.

DC: residual contribution adds +expr to n_plus and -expr at n_minus (current flowing from + to - internally).

AC: expr is linearised around V_op_subs; each partial derivative ∂expr/∂V(k) is stamped as a VCCS term from node k to the (n+, n-) pair. Constant terms in the linearisation are dropped — they belong to the DC operating point, not the small signal.

Parameters:
  • name (str)

  • n_plus (str)

  • n_minus (str)

  • expr (Expr)

  • V_op_subs (dict | None)

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

name: str
n_plus: str
n_minus: str
expr: Expr
V_op_subs: dict | None = None
include_noise: None | str | list[str] | tuple[str, ...] | frozenset[str] = None
ports: ClassVar[tuple[str, ...]] = ('n_plus', 'n_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

class sycan.components.basic.behavioral.BehavioralVoltage(name, n_plus, n_minus, expr, *, V_op_subs=None, include_noise=None)[source]

Bases: Component

Voltage source whose value is an arbitrary symbolic expression.

Enforces V(n_plus) - V(n_minus) = expr. Behaves like a normal voltage source for stamping (introduces an aux branch current), but with a non-constant right-hand side.

DC: the constraint row directly gets -expr from the node unknowns. Linear references resolve in the linear path; nonlinear expressions go through the nonlinear residual.

AC: linearised around V_op_subs — only first-order terms remain.

Parameters:
  • name (str)

  • n_plus (str)

  • n_minus (str)

  • expr (Expr)

  • V_op_subs (dict | None)

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

name: str
n_plus: str
n_minus: str
expr: Expr
V_op_subs: dict | None = None
include_noise: None | str | list[str] | tuple[str, ...] | frozenset[str] = None
ports: ClassVar[tuple[str, ...]] = ('n_plus', 'n_minus')
has_aux: ClassVar[bool] = True
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