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 currentI = f(V(...), …)fromn_pluston_minus. Equivalent to SPICEB1 N+ N- I=...and ngspice’sVxxx ... value={...}form.BehavioralVoltage— enforces the voltageV(n_plus) - V(n_minus) = f(V(...), …). Equivalent to SPICEB1 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. IfV_op_subsisNone, the operating point is left symbolic — fine for symbolic transfer-function work.
Classes
|
Current source whose value is an arbitrary symbolic expression. |
|
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:
ComponentCurrent source whose value is an arbitrary symbolic expression.
DC: residual contribution adds
+exprton_plusand-expratn_minus(current flowing from + to - internally).AC:
expris linearised aroundV_op_subs; each partial derivative∂expr/∂V(k)is stamped as a VCCS term from nodekto 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.residualsat 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:
ComponentVoltage 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
-exprfrom 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.residualsat 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