Simulation and Netlist Parsing API¶
XyceSimulator¶
XyceSimulator executes circuit-level simulation and works with generated SPICE-compatible surrogate subcircuits.
Responsibilities:
- run Xyce backend,
- coordinate vector fitting flow,
- return simulated network data for goal checking.
One simulation is run per analysis type required by the goals. Results are returned as a SimulationResult holding an S-parameter Network for .AC runs and, for .HB runs, the frequency-domain table (.HB.FD.csv or .HB.FD.prn) as a DataFrame.
run_simulation returns None when the simulation itself failed — a non-zero
Xyce exit code or no output files. CircuitSimulationStage records no result
for that analysis type, and DesignGoalChecker gives every goal that needed it
FAILED_SIMULATION_PENALTY, so the optimizer avoids those parameters. A
simulator that cannot be started at all (Xyce missing or not executable) raises
SimulatorError instead and aborts the run.
Netlist Parsing¶
XyceNetlistParser handles netlist ingestion and controlled updates.
Capabilities include:
- parse input netlist,
- identify component instances to map,
- patch netlist variables during optimization,
- read simulation,
.optionsand.PRINTdirectives, - expose
probe_nodes, the nodes carrying bothV(node)andI(Vnode)in an HB or transient run, - expose
port_sources, the SIN/AC drive level and impedance per port, - save updated netlist for simulation stage.
When a goal requires an analysis the netlist does not declare, the stage writes a copy with the missing directive injected — .LIN for S-parameter output, or .HB / .TRAN together with a matching .PRINT <analysis> format=csv line.
Harmonic Balance Spectra¶
hb_spectrum turns an HB result table into a spectrum and is shared by the design-goal formulas and the GUI plot, so both always agree.
probe_nodes(df)lists the usable analysis points in a result.spectrum(df, node, quantity, frequency_range, pin_dbm)returns(frequencies, values)as power (dBm), gain (dB), voltage (dBV) or current (dBmA).classify_bins(freqs, fundamentals, max_order)labels each line asDC, a harmonic (H2), or a mixing product (2f1-f2).available_power_dbm(amplitude, z0)converts a port's SIN amplitude to available input power.
Transient Spectra¶
tran_spectrum turns a .PRINT tran time series into the same table layout, so everything above applies to a transient result too.
to_frequency_domain(df)resamples the waveform onto a uniform grid and returns the one-sided FFT, normalised so each bin holds amplitude/2 like an HB phasor.XyceSimulatorcalls it for every transient result and writes the table as<netlist>.TRAN.FD.csv.on_fft_grid(window, low, high)tells whether a.TRANwindow of the given length puts a bin inside a goal's frequency range.
See Advanced -> Harmonic Balance for the underlying conventions.
Component Model Strategy¶
Each parsed component maps to one source path:
- ONNX surrogate model for optimizable geometry behavior, or
- fixed Touchstone file when component response is static.
Vector Fit Integration¶
COBRA uses vector fitting so surrogate/frequency-domain responses can be represented in SPICE-compatible subcircuit form for Xyce simulation.
Note
This conversion is central for integrating surrogate S-parameter behavior into a standard circuit simulation loop.