circuit ¤
High-level callable circuit interface.
Classes:
| Name | Description |
|---|---|
Circuit | A compiled, callable circuit with SAX-like parameter API. |
Functions:
| Name | Description |
|---|---|
compile_circuit | Compile a netlist into a callable :class: |
Circuit ¤
A compiled, callable circuit with SAX-like parameter API.
Wraps the output of :func:compile_netlist and :func:analyze_circuit into a single callable. Global parameters (e.g. wavelength_nm) are forwarded to every component group that declares them. When array-valued parameters are passed, :meth:__call__ applies jax.vmap over the batch dimension automatically.
Attributes:
| Name | Type | Description |
|---|---|---|
solver | The configured linear solver strategy. | |
groups | Compiled component groups dict. | |
sys_size | Number of scalar unknowns in the real-valued system. | |
port_map | Maps |
Methods:
| Name | Description |
|---|---|
get_port_field | Extract the (possibly complex) field at a named port. |
with_groups | Return a new Circuit with replaced component groups. |
Source code in circulax/circuit.py
get_port_field ¤
Extract the (possibly complex) field at a named port.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
y | Array | Solution array of shape | required |
port | str | Port key as | required |
Returns:
| Type | Description |
|---|---|
Array | Real or complex scalar/array. For complex circuits, reconstructs |
Array | the field from the unrolled block format. |
Source code in circulax/circuit.py
with_groups ¤
Return a new Circuit with replaced component groups.
Use together with :func:~circulax.utils.update_params_dict for instance-specific parameter changes before solving.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
groups | dict | New groups dict. | required |
Returns:
| Type | Description |
|---|---|
Circuit | A new :class: |
Source code in circulax/circuit.py
compile_circuit ¤
compile_circuit(
net_dict: dict,
models_map: dict,
*,
backend: str = "default",
is_complex: bool = False,
g_leak: float = 1e-09
) -> Circuit
Compile a netlist into a callable :class:Circuit.
Convenience wrapper that runs :func:~circulax.compiler.compile_netlist and :func:~circulax.solvers.linear.analyze_circuit in one call.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
net_dict | dict | SAX-format netlist dict with | required |
models_map | dict | Mapping from component type name strings to :class: | required |
backend | str | Linear solver backend. One of | 'default' |
is_complex | bool | If | False |
g_leak | float | Leakage conductance for regularisation. Defaults to | 1e-09 |
Returns:
| Name | Type | Description |
|---|---|---|
A | Circuit | class: |
Example::
circuit = compile_circuit(net_dict, models_map, is_complex=True)
solutions = jax.jit(circuit)(wavelength_nm=jnp.linspace(1260, 1360, 2000))
field_out = circuit.get_port_field(solutions, "Detector,p1")