/** * The engine behind the transient analyses (W2e): one small interface the * sweep, Monte Carlo, AC sweep and SPICE `.tran` runners step through, over * either classic's checked step (SimEngine) or one reused CoreEngine. * * WHY one engine choice per RUN (D14), made after compiling every point: * A sweep or Monte Carlo result is one curve or one distribution. If point * 37 ran on the core and point 38 on classic, any step in the curve could be * an engine difference rather than a circuit fact, and the result could not * say which engine produced it. So the choice is made once, after every * point's circuit has been compiled (a point that only fails to compile at * the end of the run would otherwise discard the work before it), and the * result reports `engine` plus the `fallbackReasons` that made it classic. * The one case compiling cannot see is the Rust load declining a topology; * the planner loads the first point once to catch the common case, and * `runOnPlan` handles a later point's decline by rerunning the WHOLE run on * classic, telling the caller first (`onRestart`). * * WHY the core is advanced to each grid point (D15): * The analyses sample on a fixed grid (ANALYSIS_STEP_S). The core's own * stepping is free to be coarser between events, but a tail average over a * sine or a switching waveform needs the value AT each grid point, so the * core is advanced to every one: solved values, never interpolated, and the * grid is never coarser than classic's step. Each advance is a clamp on the * core's trajectory (the same D6 clamp the headless fixed grid takes). * * WHY classic's checked step is kept as the classic implementation: * `stepAnalysisEngine` snapshots, steps and rolls back a failed iterate. It * is the analyses' safety contract, and the classic path through this * abstraction must stay bit-identical to what the runners did before it * existed, so it is wrapped, not re-derived. The core reports a failed * advance as `lastConverged = false` with its readouts at the last trusted * instant, which is the same state a rollback restores, so it maps to the * same AnalysisConvergenceError (as its subclass AnalysisCoreStalledError, * which `runOnPlan` replays on classic under `auto`: the core giving up on a * circuit part-way is not proof that classic would, ruling R116). * * WHAT `auto` routes: * `auto` routes to the core only for kinds in CORE_SUPPORTED_KINDS, the * kinds that have cleared the three accuracy gates (kinds.ts). A run with * any other kind is classic and says why. `coreSupportedKinds` replaces the * list for the dual-engine tests (the HeadlessRunner option of the same * name); a normal host never passes it. The core must also be ready * (`initCore()` awaited): a host that never initialises it stays on classic * with `core-not-initialized`. */ import type { SimCircuit } from "../sim/engine/sim-engine.js"; import { type AnalysisEnginePlan, type PlanOptions } from "./engine-base.js"; export * from "./engine-base.js"; /** * Decide the engine for a whole run. `circuits` is every circuit the run will * load (one per sweep point, per Monte Carlo run, per frequency); each is * compiled here, so a malformed point anywhere sends the whole run to classic * before any work is done. * * `core` never falls back: a circuit the core cannot take is an Error naming * the reasons. `auto` falls back and records them. `classic` records nothing. */ export declare function planAnalysisEngine(circuits: Iterable, options?: PlanOptions): AnalysisEnginePlan; /** * The planner options a runner takes from its spec and its caller's hooks: * the caller's `engine` wins over the spec's, so a host can pin an engine * without rewriting a saved spec. */