compiler
¤
Compiles the group into ComponentGroups and organizes the node index.
Classes:
| Name | Description |
|---|---|
ComponentGroup |
Represents a BATCH of identical components (e.g., ALL Resistors). |
Functions:
| Name | Description |
|---|---|
compile_netlist |
Compile a netlist into batched, vectorized component groups ready for simulation. |
ensure_time_signature |
Wraps a model function to ensure it accepts a 't' keyword argument. |
get_default_params |
Return a copy so callers can’t mutate the cache. |
get_model_width |
Determines the size of the 'vars' vector expected by the model. |
merge_dicts |
Merges a list of dictionaries into a single dictionary. |
solve_connectivity |
Resolves Port-to-Port connections into a Port-to-NodeID map. |
ComponentGroup
¤
Bases: Module
Represents a BATCH of identical components (e.g., ALL Resistors). Optimized for jax.vmap in the solver.
compile_netlist
¤
Compile a netlist into batched, vectorized component groups ready for simulation.
This function bridges the gap between a human-readable netlist description and the internal representation required by the ODE solver. It resolves net connectivity, instantiates component objects, assigns state variable indices, and batches components of the same type into vectorized groups for efficient JAX execution.
The compilation proceeds in three stages:
- Connectivity resolution —
build_net_mapassigns a unique integer node index to every net, returning a flat map of"Instance,Port"keys to node indices. - Instance processing — each instance is instantiated as an Equinox
object using its settings, its port indices are looked up in the node map,
and it is placed into a bucket keyed by
(component_type, tree_structure). The tree structure is included in the key so that instances whose static fields differ (e.g. a callable parameter) are never incorrectly batched together. - Vectorization — each bucket is stacked into a single
:class:
ComponentGroupwith batched parameters and pre-computed Jacobian sparsity index arrays, ready to be passed directly to the solver.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
netlist
|
dict
|
Circuit description dict. Expected to contain an
|
required |
models_map
|
dict
|
Mapping from model name strings to
:class: |
required |
Returns:
| Type | Description |
|---|---|
dict
|
A three-tuple |
int
|
|
dict
|
|
tuple[dict, int, dict]
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If a component type listed in the netlist is not present in
|
TypeError
|
If the settings dict for an instance does not match the constructor signature of its component class. |
Source code in circulax/compiler.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 | |
ensure_time_signature
¤
Wraps a model function to ensure it accepts a 't' keyword argument.
If the original model doesn't take 't', the wrapper swallows it.
Source code in circulax/compiler.py
get_default_params
¤
get_model_width
¤
Determines the size of the 'vars' vector expected by the model.
Source code in circulax/compiler.py
merge_dicts
¤
Merges a list of dictionaries into a single dictionary.
solve_connectivity
¤
Resolves Port-to-Port connections into a Port-to-NodeID map.
Example: {"R1,p1": "V1,p1"} -> {"R1,p1": 1, "V1,p1": 1}