assembly
¤
Assembly functions for the transient circuit solver.
Provides functions for evaluating the residual vectors and effective Jacobian of the discretised circuit equations at each Newton iteration. Functions are provided in two variants:
-
Full assembly (:func:
assemble_system_real, :func:assemble_system_complex) — evaluates both the residual and the forward-mode Jacobian viajax.jacfwd. Used once per timestep to assemble and factor the frozen Jacobian in :class:~circulax.solver.FactorizedTransientSolver. -
Residual only (:func:
assemble_residual_only_real, :func:assemble_residual_only_complex) — evaluates only the primal residual, with no Jacobian computation. Used inside the Newton loop where the Jacobian has already been factored and only needs to be applied.
Each pair has a real and a complex variant. The complex variant operates on state vectors in unrolled block format — real parts concatenated with imaginary parts — allowing complex circuit analyses to reuse real-valued sparse linear algebra kernels.
Functions:
| Name | Description |
|---|---|
assemble_residual_only_complex |
Assemble the residual vectors for an unrolled complex system, without computing the Jacobian. |
assemble_residual_only_real |
Assemble the residual vectors for a real system, without computing the Jacobian. |
assemble_system_complex |
Assemble the residual vectors and effective Jacobian values for an unrolled complex system. |
assemble_system_real |
Assemble the residual vectors and effective Jacobian values for a real system. |
assemble_residual_only_complex
¤
assemble_residual_only_complex(
y_guess: Array, component_groups: dict, t1: float, dt: float
) -> tuple[Array, Array]
Assemble the residual vectors for an unrolled complex system, without computing the Jacobian.
The complex counterpart of :func:assemble_residual_only_real. The state
vector is expected in unrolled block format (real parts followed by imaginary
parts) matching the layout used by :func:assemble_system_complex.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
y_guess
|
Array
|
Unrolled state vector of shape |
required |
component_groups
|
dict
|
Compiled component groups returned by
:func: |
required |
t1
|
float
|
Time at which the system is being evaluated. |
required |
dt
|
float
|
Unused; present for signature symmetry with
:func: |
required |
Returns:
| Type | Description |
|---|---|
Array
|
A two-tuple |
Array
|
|
Source code in circulax/solvers/assembly.py
assemble_residual_only_real
¤
assemble_residual_only_real(
y_guess: Array, component_groups: dict, t1: float, dt: float
) -> tuple[Array, Array]
Assemble the residual vectors for a real system, without computing the Jacobian.
Cheaper than :func:assemble_system_real as it performs only primal
evaluations. Used inside the frozen-Jacobian Newton loop where the
Jacobian has already been factored and only the residual needs to be
recomputed at each iteration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
y_guess
|
Array
|
Current state vector of shape |
required |
component_groups
|
dict
|
Compiled component groups returned by
:func: |
required |
t1
|
float
|
Time at which the system is being evaluated. |
required |
dt
|
float
|
Unused; present for signature symmetry with
:func: |
required |
Returns:
| Type | Description |
|---|---|
Array
|
A two-tuple |
Array
|
|
Source code in circulax/solvers/assembly.py
assemble_system_complex
¤
assemble_system_complex(
y_guess: Array, component_groups: dict, t1: float, dt: float
) -> tuple[Array, Array, Array]
Assemble the residual vectors and effective Jacobian values for an unrolled complex system.
The complex state vector is stored in unrolled (block) format: the first
half of y_guess holds the real parts of all node voltages/states, the
second half holds the imaginary parts. This avoids JAX's limited support
for complex-valued sparse linear solvers by keeping all arithmetic real.
The Jacobian is split into four real blocks — RR, RI, IR, II — representing the partial derivatives of the real and imaginary residual components with respect to the real and imaginary state components respectively. The blocks are concatenated in RR→RI→IR→II order to match the sparsity index layout produced during compilation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
y_guess
|
Array
|
Unrolled state vector of shape |
required |
component_groups
|
dict
|
Compiled component groups returned by
:func: |
required |
t1
|
float
|
Time at which the system is being evaluated. |
required |
dt
|
float
|
Timestep duration, used to scale the reactive Jacobian blocks. |
required |
Returns:
| Type | Description |
|---|---|
Array
|
A three-tuple |
Array
|
|
Array
|
|
tuple[Array, Array, Array]
|
|
Source code in circulax/solvers/assembly.py
assemble_system_real
¤
assemble_system_real(
y_guess: Array, component_groups: dict, t1: float, dt: float
) -> tuple[Array, Array, Array]
Assemble the residual vectors and effective Jacobian values for a real system.
For each component group, evaluates the physics at t1 and computes the
forward-mode Jacobian via jax.jacfwd. The effective Jacobian combines
the resistive and reactive contributions as J_eff = df/dy + (1/dt) * dq/dy,
consistent with the implicit trapezoidal discretisation used by the solver.
Components are processed in sorted key order to ensure a deterministic non-zero layout in the sparse Jacobian, which is required for the factorisation step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
y_guess
|
Array
|
Current state vector of shape |
required |
component_groups
|
dict
|
Compiled component groups returned by
:func: |
required |
t1
|
float
|
Time at which the system is being evaluated. |
required |
dt
|
float
|
Timestep duration, used to scale the reactive Jacobian block. |
required |
Returns:
| Type | Description |
|---|---|
Array
|
A three-tuple |
Array
|
|
Array
|
|
tuple[Array, Array, Array]
|
|