SLiCAPngspice.py
SLiCAP module for interfacing with NGspice.
- class Analysis(name: str, x_name: str, x_data: ndarray, signals: dict, var_names: list = <factory>)
One analysis block from an NGspice Nutmeg raw file.
- Parameters:
name – Plot name as written by NGspice (e.g.
"Transient Analysis").x_name – Name of the independent variable (
"time","frequency").x_data – Independent variable array, shape (M,), always real.
signals –
{signal_name: array}; complex for AC / noise blocks.var_names – All variable names in file order (x first, then signals).
- is_complex() bool
True when signal arrays are complex (AC / noise spectral density).
- name: str
- signals: dict
- var_names: list
- x_data: ndarray
- x_name: str
- class MOS(refDes, lib, dev, W, L, M)
MOS Transistor.
- Parameters:
refDes (str) – Reference designator used in SLiCAP circuit file
lib (str) – path to library file, absolute or relative to python script.
dev (str) – Device name (as in library)
MOS attributes:
self.refDes = refDes
self.lib = lib
self.dev = dev
self.modelDef = Text string with SLiCAP model definition for this device
self.parDefs = Dictionary with SLiCAP parameter definitions for this device
self.params = Dictionary with names and values of parameters provided by ngspice
self.errors = Relative difference between forward and reverse parameter measurement
self.step = Step data for VG or ID, defaults to False
- getOPid(ID, VD, VS, VB, f, step=None)
Returns operating point information of the device with the drain current as (swept) independent variable.
- Parameters:
W (float) – Width of the device in [m]
L (float) – Length of the device in [m]
M (int) – Number of devices in parallel
ID (float) – Drain current [A]
VD (float) – Drain voltage with respect to ground in [V]
VS (float) – Source voltage with respect to ground in [V]
VB (float) – Bulk voltage with respect to ground in [V]
step – Step data for ID; list with start value, number of values and stop value. Defaults to None
- getOPvg(VG, VD, VS, VB, f, step=None)
Returns operating point information of the device with the gate voltage as (swept) independent variable.
- Parameters:
W (float) – Width of the device in [m]
L (float) – Length of the device in [m]
M (int) – Number of devices in parallel
VG (float) – Gate voltage with respect to ground in [V]
VD (float) – Drain voltage with respect to ground in [V]
VS (float) – Source voltage with respect to ground in [V]
VB (float) – Bulk voltage with respect to ground in [V]
step – Step data for VG; list with start value, number of values and stop value. Defaults to None
- getSv_inoise(ID, VD, VS, VB, fmin, fmax, numDec)
- NGspiceRaw2dict(raw_path, step_param=None, step_values=None)
Parse an NGspice Nutmeg raw file and return a unified result dictionary.
The dictionary layout depends on the analysis type and whether stepping was used:
OP (no stepping) — all values are Python floats:
{"v(out)": 1.23, "i(v1)": -4.56e-3, ...}
Sweep (no stepping) — 1-D numpy arrays:
{"time": array, "v(out)": array, ...} # transient {"frequency": array, "v(out)": array, ...} # AC (complex arrays)
OP (stepped) — 1-D arrays, one value per step:
{"R1": array, "v(out)": array, ...}
Sweep (stepped) — sweep variable 1-D, signals 2-D (n_steps × n_sweep):
{"frequency": array, "R1": array, "v(out)": 2-D array, ...}
For AC analysis the signal arrays are
dtype=complex128. Use the helpers inSLiCAPmath(mag(),dB(),phase()) for post-processing.- Parameters:
raw_path (str, pathlib.Path, list) – Path(s) to NGspice
.rawfile(s). Pass a singlestr/Pathfor a non-stepped run. For stepped runs pass the list of per-step raw-file paths returned by the deck’s control block; oneAnalysisblock is read from each file and the step files are deleted afterwards.step_param (str, NoneType) – Name of the stepped parameter (e.g.
"R1").step_values (list, numpy.ndarray, NoneType) – 1-D sequence of step parameter values.
- Returns:
Result dictionary — structure depends on analysis type (see above).
- Return type:
dict
- class RawFile
Static-method parser for NGspice Nutmeg raw files.
Usage:
analyses = RawFile.load("output.raw") # list[Analysis]
Supports binary and ASCII blocks; multiple analysis blocks per file. No Qt dependency — safe for CLI and notebook use.
- ac(cirFile, method, n, fstart, fstop, save=None, step=None, params=None, options=None, behavior=None, timeout=None, stimuli=None, savecurrents=False)
Run an NGspice AC sweep analysis.
Signal arrays in the result dict are
dtype=complex128. Usemag(),dB(),phase(), anddelay()for post-processing.- Parameters:
cirFile (str) – Circuit name: the stem of
cir/<name>.spice_cirorcir/<name>.cir.method (str) – Frequency sweep type:
"dec"(per decade),"oct"(per octave), or"lin"(linear).n (int) – Points per decade / octave, or total points for
"lin".fstart (float, int) – Start frequency [Hz].
fstop (float, int) – Stop frequency [Hz].
names (dict, NoneType) –
{user_key: ngspice_expr}.Nonereturns all signals.step (dict, NoneType) – Parameter step dict (see
op()).params (list, NoneType) – Per-instruction parameter definitions — ordered list of
(name, value)tuples (seeop()).options (dict, NoneType) – NGspice simulator options for this run, written as
option name = valuecommands before the analysis, e.g.{"rshunt": "1e12", "reltol": "1e-5"}. A value ofNonewrites a flag without a value ({"noopiter": None}). Convergence aids for vendor macro-models with floating internal nodes:rshunt(1e12) orgmin(1e-10); see the NGspice manual, chapter “Simulation options”.behavior (str, NoneType) – NGspice compatibility mode.
timeout (float, NoneType) – Simulation time limit in seconds.
- Returns:
Result dictionary;
"frequency"key holds the 1-D frequency array.- Return type:
dict
- bode(title, freq, mag_dB, phase_deg, labels=None, filename=None)
Create a two-subplot Bode plot: magnitude [dB] on top, phase [°] below, both on a shared logarithmic frequency axis.
mag_dB and phase_deg may be 1-D (single trace) or 2-D (shape
(n_traces, n_freq)for stepped results). UsedB()andphase()to compute these from a complex AC result.- Parameters:
title (str) – Figure title.
freq (numpy.ndarray) – Frequency array [Hz], 1-D.
mag_dB (numpy.ndarray) – Magnitude in dB — 1-D or 2-D.
phase_deg (numpy.ndarray) – Phase in degrees — same shape as mag_dB.
labels (list, NoneType) – Legend strings, one per trace.
None→ no legend.filename (str, NoneType) – Save the figure to this path (SVG / PDF / PNG …) and close it.
None→ figure returned open for interactive display or further customisation.
- Returns:
The matplotlib Figure object.
- Return type:
matplotlib.figure.Figure
Example:
gain_dB = dB(AC1["V_out"] / AC1["V_in"]) phase_deg = phase(AC1["V_out"] / AC1["V_in"]) labels = [f"R1 = {v:.0f} Ω" for v in AC1["step_R1"]] sim.bode("Gain and phase", AC1["frequency"], gain_dB, phase_deg, labels=labels, filename="bode.svg")
- dc(cirFile, source, start, stop, incr, save=None, step=None, params=None, options=None, behavior=None, timeout=None, stimuli=None, savecurrents=False)
Run an NGspice DC sweep analysis.
- Parameters:
cirFile (str) – Circuit name: the stem of
cir/<name>.spice_cirorcir/<name>.cir.source (str) – Source name to sweep (e.g.
"V1"), or"TEMP"for a temperature sweep.start (float, int) – Sweep start value.
stop (float, int) – Sweep stop value.
incr (float, int) – Sweep increment.
names (dict, NoneType) –
{user_key: ngspice_expr}.Nonereturns all signals.step (dict, NoneType) – Parameter step dict (see
op()).params (list, NoneType) – Per-instruction parameter definitions — ordered list of
(name, value)tuples (seeop()).options (dict, NoneType) – NGspice simulator options for this run, written as
option name = valuecommands before the analysis, e.g.{"rshunt": "1e12", "reltol": "1e-5"}. A value ofNonewrites a flag without a value ({"noopiter": None}). Convergence aids for vendor macro-models with floating internal nodes:rshunt(1e12) orgmin(1e-10); see the NGspice manual, chapter “Simulation options”.behavior (str, NoneType) – NGspice compatibility mode.
timeout (float, NoneType) – Simulation time limit in seconds.
- Returns:
Result dictionary with sweep variable and signal arrays.
- Return type:
dict
- delete(filepath, key)
Remove one result group from an HDF5 file.
- Parameters:
filepath (str, pathlib.Path) – Path to the HDF5 file.
key (str) – Group name to remove.
- Raises:
KeyError – If key is not present in the file.
ImportError – If h5py is not installed.
Example:
sim.delete("results.h5", "AC1")
- instr2dataset(instr, x_key=None, y_keys=None)
Convert an NGspice result instruction into a
dataset.This is the NGspice PRODUCER ADAPTER: it states the provenance of the numbers - which key is the sweep variable, which columns are step parameters - and hands them to the backend-neutral post-processing layer It is registered with
register_dataset_adapter(), somake_traces()also accepts the result object itself.- Parameters:
instr (SLiCAPinstruction.instruction) – instruction returned by an NGspice analysis function.
x_key (str, NoneType) – sweep variable; None auto-derives it (the sweep variable for AC/TRAN/DC/NOISE, the step variable for a stepped OP).
y_keys (list, NoneType) – signals to keep; None keeps the dependent variables.
- Returns:
dataset, or None when the result holds no traceable data (an un-stepped operating point is a set of scalars).
- Return type:
SLiCAPtraces.dataset, NoneType
- Example:
>>> TR = sl.tran("amp", "1n", "1u", names={"V_out": "v(out)"}) >>> D = sl.instr2dataset(TR) >>> T = sl.make_traces(D, [{"y": "V_out * 2", "label": "twice"}])
- load(filepath, key)
Load one result dict from an HDF5 file.
- Parameters:
filepath (str, pathlib.Path) – Path to the HDF5 file.
key (str) – Group name to load (the kwarg name used in
save()).
- Returns:
Result dictionary — numpy arrays for signals and sweep variables, Python floats for OP scalars (0-D datasets).
- Return type:
dict
- Raises:
KeyError – If key is not present in the file.
ImportError – If h5py is not installed.
Example:
AC1 = sim.load("results.h5", "AC1")
- make_netlist(filename, title=None, force=False)
Generate a program netlist from a schematic file.
Calls the
SLiCAP.schematic.clitool in a subprocess (headless Qt). When force is False the subprocess is skipped if the netlist is already newer than the schematic and its style sidecar. The file extension determines which builder is used and the extension of the netlist (Anton, 2026-11-07):.spice_sch→ NGspice plain netlistcir/<stem>.spice_cir(no.controlsection).slicap_sch→ SLiCAP netlistcir/<stem>.slicap_cir
- Parameters:
filename (str) – Schematic filename with extension, relative to
ini.schematic_path(e.g."VampQspice.spice_sch").title (str, NoneType) – Circuit title override. Defaults to the title stored in the schematic or, if empty, to the file stem.
- Returns:
Pathto the generated netlist file, orNoneon failure.- Return type:
pathlib.Path, NoneType
- ngspice2traces(cirFile, simCmd, namesDict, stepCmd=None, parList=None, traceType='magPhase', squaredNoise=False, postProc=None, saveLog=True, optDict=None, mode=None, timeout=None)
Creates a dictionary with values or traces from an ngspice run.
- Parameters:
cirFile (str) – Name of the circuit (netlist cir/<name>.spice_cir or cir/<name>.cir), located in the cir folder.
simCmd (str) –
ngspice instruction,
ac dec 20 1 10meg
tran 1n 10u
dc Source Vstart Vstop Vincr [ Source2 Vstart2 Vstop2 Vincr2 ]
noise V(out) Vs dec 10 1 10meg 1
op
stepCmd (str, nonetype) –
Step instruction or None if no parameter stepping is performed:
Syntax: <parname> <stepmethod> <firstvalue> (<lastvalue> <numberofvalues | listwithvalues>)
parname (str): name of the parameter (not a RefDes)
stepmethod (str): lin, log or list
namesDict (dict) –
Dictionary with key-value pairs:
key: plot label (str)
value: nodal voltage, branch current or device parameter in ngspice notation
traceType (str) –
Type of traces for AC, noise, and FFT analysis:
realImag: real and imaginary parts
magPhase: magnitude and phse
dBmagPhase: dB(magnitude) and phase
onoise: output referred noise
inoise: input referred noise
parList (list) –
List with parameter definitions, each item in the list must be a tuple with the name and the value of a parameter. The name must be a string, and the value a string, an integer, a float, or a SPICE expression (between curly brackets). The order of parameter definitions should be such that SPICE can evaluate a numeric value for each parameter in a non-recursive way.
- Example:
>>> params = [('R', '1k'), ('C', '1n'), ('tau', '{1/(R*C)}')]
squaredNoise (Bool) –
True: output in V^2/Hz, A^2/Hz, V^2 or A^2
False: output in V/rt(Hz), A/rt(Hz), V or A
Defaults to True
postProc (str, NoneType) –
Post processing fuction for transient analysis:
None
No post processing is performed
FFT <vector> (<vector> …)
Returns the Fast Fourier Transform of one or more vectors obtained from a transient analysis. Curently only Hanning windowing has been implemented.
FOURIER <vector> (<vector> …)
Lists the values of the first ten harmonics of one or more vectors obtained from a transient analysis in the simulation log file.
saveLog (Bool) – True | False, defaults to True. The log file is saved in the txt folder in the project directory. The name is the circuit file name with ‘.log’ file extension.
optDict (NoneType, dict) – None (default) or a dictionary with NGspice options, The keys are the NGspice option names and the values are ‘None’ if the option requires no value, or the option value.
mode – NGspice simulation mode, defaults to ‘ltpsa’
- Returns:
In case of an “OP” instruction without parameter stepping:
A dictionary with key-value pairs:
key: str Name of the variable
value: float Value of the parameter, voltage or current
In all other cases: a tuple (dict, str1, str2)
dict
key: str Name of the variable
value: SLiCAP.SLiCAPplots.trace object or single value
str1: name of the x-variable
str2: units if the x-variable
- Return type:
tuple: dict, (dict, str, str)
- ngspice_control(cirFile, control, params=None, stimuli=None, behavior=None, timeout=None)
Run NGspice with a USER-SUPPLIED control section — full-control / raw mode.
control is inserted VERBATIM as the
.control … .endcblock, replacing SLiCAP’s auto-generated control. You are driving NGspice directly: SLiCAP does not parse a result object and shows nothing in the design-data panel. Read any output yourself, e.g. withNGspiceRaw2dict()on a raw file your control writes. The schematic-derived netlist (components, models,paramsandstimulioverrides) is still SLiCAP’s; only the control block is yours.- Parameters:
cirFile (str) – Circuit name: the stem of
cir/<name>.spice_cirorcir/<name>.cir.control (str) – Path to a control-section text file, or the control text itself. Text without
.controlis wrapped in.control … .endcautomatically.params (list, NoneType) – Per-instruction parameter definitions — ordered list of
(name, value)tuples (seeop()).stimuli (dict, NoneType) – Per-run source stimuli
{refdes: [type, arg1, …]}(seeop()).behavior (str, NoneType) – NGspice compatibility mode.
None= not set.timeout (float, NoneType) – Simulation time limit in seconds.
None= no limit.
- Returns:
Trueon a successful NGspice run, elseFalse.- Return type:
bool
- noise(cirFile, output, input_src, method, n, fstart, fstop, save=None, step=None, params=None, options=None, behavior=None, timeout=None, stimuli=None, contributions=False, savecurrents=False)
Run an NGspice noise analysis. Results stored as V²/Hz PSD (
set sqrnoiseis always active).Use
dB(np.sqrt(result["S_u"]))ordB(result["S_u"], power=True)for a dB spectral density plot.- Parameters:
cirFile (str) – Circuit name: the stem of
cir/<name>.spice_cirorcir/<name>.cir.output (str) – Output node expression, e.g.
"V(out)".input_src (str) – Input noise source name, e.g.
"V1".method (str) – Frequency sweep type:
"dec","oct", or"lin".n (int) – Points per decade / octave, or total points for
"lin".fstart (float, int) – Start frequency [Hz].
fstop (float, int) – Stop frequency [Hz].
names (dict, NoneType) –
{user_key: ngspice_expr}.Nonereturns all signals. Typical:{"S_u": "onoise_spectrum"}.step (dict, NoneType) – Parameter step dict (see
op()).params (list, NoneType) – Per-instruction parameter definitions — ordered list of
(name, value)tuples (seeop()).options (dict, NoneType) – NGspice simulator options for this run, written as
option name = valuecommands before the analysis, e.g.{"rshunt": "1e12", "reltol": "1e-5"}. A value ofNonewrites a flag without a value ({"noopiter": None}). Convergence aids for vendor macro-models with floating internal nodes:rshunt(1e12) orgmin(1e-10); see the NGspice manual, chapter “Simulation options”.behavior (str, NoneType) – NGspice compatibility mode.
timeout (float, NoneType) – Simulation time limit in seconds.
- Returns:
Result dictionary;
"frequency"key holds the 1-D frequency array. Noise signal arrays are real (V²/Hz).- Return type:
dict
- op(cirFile, save=None, step=None, params=None, options=None, behavior=None, timeout=None, stimuli=None, savecurrents=False)
Run an NGspice operating-point (
.op) analysis.Without stepping returns
{signal_name: float, ...}— all scalars.With stepping returns
{"<param>": 1-D array, signal_name: 1-D array, ...}.- Parameters:
cirFile (str) – Circuit name: the stem of
cir/<name>.spice_cirorcir/<name>.cir(file must be inini.cir_path).save (list, NoneType) – NGspice vectors to write, as NGspice writes them:
["v(out)", "i(v1)"].Noneor an empty list saves the default set - node voltages (including subcircuit nodes such asv(x1.mid)) and voltage-source branch currents. A non-empty list saves ONLY what it lists (manual 15.6.1: “If .SAVE lines are given, only those vectors specified are saved”), so to add an internal device parameter to everything else, listallwith it:save=["all", "@q1[gm]"]. Python names for these vectors are chosen afterwards, insl.make_traces(..., names={...})- the analysis call speaks NGspice only.savecurrents (bool) – True adds
.options savecurrentsto the deck, so the terminal currents of M, J, Q, D, R, C, L, B, F, G, W, S and I devices are written as well, inside subcircuits too (i(@r3[i]),i(@r.x1.r1[i])- NGspice writes them with thati(...)wrapper). Manual 15.7.3: op, dc and tran only, NOT ac; and for MOS devices only a subset of the current parameters unless the model-specific options are used.step (dict, NoneType) –
Parameter step dict:
{"param": "R1", "method": "lin", "start": 100, "stop": 1000, "num": 11}
"method"may be"lin","log", or"list"(use"values": [...]instead of start/stop/num for list).params (list, NoneType) – Per-instruction parameter definitions: ordered list of
(name, value)tuples, or a dict such asSLiCAP.SLiCAPdesignData.selectPars()returns (its insertion order is the list order). A name already defined in the netlist gets its value replaced in place (overriding the schematic value for this run only); a new name is appended as a.paramline in list order. Order the entries so that every parameter is numerically evaluable in a non-recursive way, e.g.[("R", "1k"), ("C", "1n"), ("tau", "{1/(R*C)}")].options (dict, NoneType) – NGspice simulator options for this run, written as
option name = valuecommands before the analysis, e.g.{"rshunt": "1e12", "reltol": "1e-5"}. A value ofNonewrites a flag without a value ({"noopiter": None}). Convergence aids for vendor macro-models with floating internal nodes:rshunt(1e12) orgmin(1e-10); see the NGspice manual, chapter “Simulation options”.behavior (str, NoneType) – NGspice compatibility flags as ONE word, e.g.
"ltpsa"(lt + ps + a): ps, lt, hs, spe, s3, ki, eg, and a for the whole netlist (without a, the syntax flags apply to .include’d libraries only).None= not set.timeout (float, NoneType) – Simulation time limit in seconds.
None= no limit.
- Returns:
Result dictionary.
- Return type:
dict
- plot(title, x, y, xlabel='', ylabel='', labels=None, logx=False, logy=False, filename=None)
Generic x-y plot with optional log scales on either axis.
y may be 1-D (single trace) or 2-D (shape
(n_traces, n_points)for stepped results).- Parameters:
title (str) – Figure title.
x (numpy.ndarray) – X-axis data, 1-D.
y (numpy.ndarray) – Y-axis data — 1-D or 2-D.
xlabel (str) – X-axis label string.
ylabel (str) – Y-axis label string.
labels (list, NoneType) – Legend strings, one per trace.
None→ no legend.logx (bool) – Use a logarithmic x-axis (default
False).logy (bool) – Use a logarithmic y-axis (default
False).filename (str, NoneType) – Save path.
None→ figure returned open.
- Returns:
The matplotlib Figure object.
- Return type:
matplotlib.figure.Figure
Example:
# DC sweep — V(out) vs. V1 for several R1 values labels = [f"R1 = {v:.0f} Ω" for v in DC1["step_R1"]] sim.plot("DC transfer", DC1["v-sweep"], DC1["V_out"], xlabel="V1 (V)", ylabel="V(out) (V)", labels=labels)
- plot_noise(title, freq, S_u, S_w=None, rms_u=None, rms_w=None, labels=None, filename=None)
Plot noise amplitude spectral density (V/√Hz) on a log-log scale.
S_u and S_w are power spectral densities [V²/Hz] — the function converts them to amplitude spectral density [V/√Hz] by taking the square root. Weighted curves are drawn as dashed lines.
- Parameters:
title (str) – Figure title.
freq (numpy.ndarray) – Frequency array [Hz], 1-D.
S_u (numpy.ndarray) – Unweighted noise PSD [V²/Hz] — 1-D or 2-D.
S_w (numpy.ndarray, NoneType) – Weighted noise PSD [V²/Hz], same shape as S_u.
None→ not plotted.rms_u (float, NoneType) – Unweighted RMS noise [V] — shown as a text annotation.
rms_w (float, NoneType) – Weighted RMS noise [V] — shown as a text annotation.
labels (list, NoneType) – Legend strings, one per trace.
None→ auto-labels ("unweighted"/"weighted"when S_w is given).filename (str, NoneType) – Save path.
None→ figure returned open.
- Returns:
The matplotlib Figure object.
- Return type:
matplotlib.figure.Figure
Example:
wf = noiseWeighting({"din_a": {}}) rms_u, rms_w, S_w = weightedRMS(NOISE1["S_u"], NOISE1["frequency"], wf) sim.plot_noise("Output noise", NOISE1["frequency"], NOISE1["S_u"], S_w=S_w, rms_u=rms_u, rms_w=rms_w)
- save(filepath, **kwargs)
Save one or more result dicts to an HDF5 file.
Each keyword argument becomes a top-level group named after the argument. If the group already exists it is silently overwritten. The file is created if it does not exist; other existing groups are left untouched.
Supported value types inside a result dict:
numpy.ndarray(any shape, real or complex) → HDF5 dataset.float/int(OP scalar) → 0-D HDF5 dataset.
- Parameters:
filepath (str, pathlib.Path) – Path to the HDF5 file (
*.h5).kwargs (dict) – Result dicts to store, e.g.
save("r.h5", AC1=ac_result, TRAN1=tran_result).
- Raises:
TypeError – If a value in kwargs is not a dict.
ImportError – If h5py is not installed.
Example:
sim.save("results.h5", AC1=AC1, NOISE1=NOISE1)
- selectTraces(traceDict, namesList)
This function returns a dictionary selected traces from a dictionary with traces.
- Parameters:
traceDict – A dictionary with key-value pairs: - key: name of the trace - value: a SLiCAP.SLiCAPplots.trace object holding trace (x, y) data and a trace label
namesList – A list with names of traces (== keys in traceDict) that needs to be returned
- Returns:
a dictionary with selected traces (sub of traceDict)
- Return type:
dict
- show()
Display all open matplotlib figures.
Calls
matplotlib.pyplot.show(). In a script this blocks until all figure windows are closed; in a Jupyter notebook it renders inline.
- tran(cirFile, tstep, tstop, tstart=0, save=None, step=None, params=None, options=None, behavior=None, timeout=None, fourier=None, fft=None, stimuli=None, savecurrents=False, tmax=None)
Run an NGspice transient analysis, optionally with Fourier/FFT post-processing (the legacy
ngspice2tracespostProcsemantics, structured).fourier=<fundamental>(SLiCAP notation, e.g."100k", or{"freq": "100k", "nfreqs": 10}) runs NGspicefourierafter the transient: the returned instruction still holds the TIME traces (dataType 'tran'), and the harmonics table (magnitude/phase/ normalized per harmonic + THD per signal) is attached as theinstr.fourierdict.fft=True(or{"window": "hanning", "order": 8}— NGspicespecwindow/specwindoworder) linearizes the transient and takes its FFT: the returned instruction is FREQUENCY-domain (dataType 'fft', complex arrays +"frequency"), plotting like anacresult.Both post-processing options REQUIRE
savenaming the vectors to transform. An entry"name = expression"creates a derived vector with NGspiceletafter the transient, e.g.save=["v_ac = v(out) - 4.3"]for the output with its operating point removed; the transform then works onname.- Parameters:
cirFile (str) – Circuit name: the stem of
cir/<name>.spice_cirorcir/<name>.cir.tstep (float, int) – Suggested internal time step.
tstop (float, int) – End time.
tstart (float, int) – Start time (default 0); data before this time is discarded.
tmax (float, int, str, NoneType) – Maximum internal time step of the integration (the fourth argument of the NGspice
trancommand). Defaults to None: NGspice chooses it, at mosttstep. A smalltmaxlowers the numerical noise floor of an FFT (2026-09-21).names (dict, NoneType) –
{user_key: ngspice_expr}.Nonereturns all signals.step (dict, NoneType) – Parameter step dict (see
op()).params (list, NoneType) – Per-instruction parameter definitions — ordered list of
(name, value)tuples (seeop()).options (dict, NoneType) – NGspice simulator options for this run, written as
option name = valuecommands before the analysis, e.g.{"rshunt": "1e12", "reltol": "1e-5"}. A value ofNonewrites a flag without a value ({"noopiter": None}). Convergence aids for vendor macro-models with floating internal nodes:rshunt(1e12) orgmin(1e-10); see the NGspice manual, chapter “Simulation options”.behavior (str, NoneType) – NGspice compatibility mode.
timeout (float, NoneType) – Simulation time limit in seconds.
- Returns:
Result dictionary;
"time"key holds the 1-D time array.- Return type:
dict