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 in SLiCAPmath (mag(), dB(), phase()) for post-processing.

Parameters:
  • raw_path (str, pathlib.Path, list) – Path(s) to NGspice .raw file(s). Pass a single str/Path for a non-stepped run. For stepped runs pass the list of per-step raw-file paths returned by _control_block(); one Analysis block 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.

static load(path) list

Parse path and return all analysis blocks in file order.

Parameters:

path (str, pathlib.Path) – Path to the NGspice .raw file.

Returns:

List of Analysis objects, one per analysis block.

Return type:

list

ac(cirFile, method, n, fstart, fstop, names=None, step=None, params=None, options=None, behavior=None, timeout=None, stimuli=None)

Run an NGspice AC sweep analysis.

Signal arrays in the result dict are dtype=complex128. Use mag(), dB(), phase(), and delay() for post-processing.

Parameters:
  • cirFile (str) – Circuit filename without the .cir extension.

  • 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}. None returns all signals.

  • step (dict, NoneType) – Parameter step dict (see op()).

  • params (list, NoneType) – Per-instruction parameter definitions — ordered list of (name, value) tuples (see op()).

  • options (dict, NoneType) – NGspice .options dict.

  • 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). Use dB() and phase() 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, names=None, step=None, params=None, options=None, behavior=None, timeout=None, stimuli=None)

Run an NGspice DC sweep analysis.

Parameters:
  • cirFile (str) – Circuit filename without the .cir extension.

  • 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}. None returns all signals.

  • step (dict, NoneType) – Parameter step dict (see op()).

  • params (list, NoneType) – Per-instruction parameter definitions — ordered list of (name, value) tuples (see op()).

  • options (dict, NoneType) – NGspice .options dict.

  • 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")
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 (.cir) from a schematic file.

Calls the SLiCAP.schematic.cli tool in a subprocess (headless Qt). When force is False the subprocess is skipped if the .cir is already newer than the schematic and its style sidecar. The file extension determines which builder is used:

  • .spice_sch → NGspice plain netlist (no .control section)

  • .slicap_sch → SLiCAP netlist

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:

Path to the generated .cir file, or None on 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 file withouit ‘.cir’ extension, 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 (Anton, 2026-07-16).

control is inserted VERBATIM as the .control .endc block, 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. with NGspiceRaw2dict() on a raw file your control writes. The schematic-derived netlist (components, models, params and stimuli overrides) is still SLiCAP’s; only the control block is yours.

Parameters:
  • cirFile (str) – Circuit filename without the .cir extension.

  • control (str) – Path to a control-section text file, or the control text itself. Text without .control is wrapped in .control .endc automatically.

  • params (list, NoneType) – Per-instruction parameter definitions — ordered list of (name, value) tuples (see op()).

  • stimuli (dict, NoneType) – Per-run source stimuli {refdes: [type, arg1, …]} (see op()).

  • behavior (str, NoneType) – NGspice compatibility mode. None = not set.

  • timeout (float, NoneType) – Simulation time limit in seconds. None = no limit.

Returns:

True on a successful NGspice run, else False.

Return type:

bool

ngspice_dict2traces(result, x_key=None, y_keys=None, trace_type='real', goal_fn=None)

Convert an NGspice result dictionary (from NGspiceRaw2dict()) into a dictionary of trace objects ready for plot().

Supported layouts (as returned by NGspiceRaw2dict()):

  • Sweep, un-stepped: {"frequency": 1-D, "v(out)": 1-D, ...} → one trace per signal key.

  • Sweep, stepped: {"frequency": 1-D, "R1": 1-D, "v(out)": 2-D, ...} → one trace per step for each 2-D signal (goal_fn=None), or one goal trace per signal with step values on the x-axis (goal_fn set).

  • OP, stepped: {"R1": 1-D, "v(out)": 1-D, ...} → one trace per signal; x-axis is the step-parameter column.

OP results without stepping are scalar dicts — not convertible to traces; pass them to print() instead.

Parameters:
  • result (dict) – Dictionary returned by NGspiceRaw2dict().

  • x_key (str or None) – Key to use as the x-axis. If None the function picks "time" or "frequency" when present, otherwise the first key whose value is a 1-D array.

  • y_keys (list[str] or None) – Keys to convert to traces. If None every key that is not the x-axis and not a step-parameter column is used.

  • trace_type (str) –

    How to handle complex-valued (AC) arrays:

    • 'real' — real part

    • 'imag' — imaginary part

    • 'mag' — absolute magnitude

    • 'dBmag' — 20·log₁₀(|value|)

    • 'phase' — phase in degrees

    • 'delay' — group delay in seconds, groupDelay() (−dφ/dω, unwrapped phase; last point duplicated)

    Ignored for real-valued arrays.

  • goal_fn (callable or None) – Optional callable f(x_sweep, y_sweep) float applied to each step row of a 2-D stepped signal. When provided, the returned trace has step values on the x-axis and the goal-function output on the y-axis — one trace per signal key. Any f(x, y) -> float works; the built-in goal functions live in SLiCAP.SLiCAPmath (goal_* — the single authoritative inventory is its _GOAL_FUNCTIONS registry, which also feeds the GUI). Ignored for 1-D (un-stepped) signals.

Returns:

{label: trace_object} ready for plot().

Return type:

dict

Example:

>>> result = NGspiceRaw2dict("design.raw")
>>> traces = ngspice_dict2traces(result, trace_type='dBmag')
>>> sl.plot("bode_gain", "Gain", "semilogx", traces,
...         xName="frequency", xUnits="Hz", yUnits="dB", show=True)
>>> # Goal function: dB magnitude at 1 MHz vs stepped parameter
>>> M1M = ngspice_dict2traces(AC1, trace_type='dBmag',
...                           goal_fn=goal_y_at_x(1e6))
>>> sl.plot("mag_vs_R", "Magnitude at 1 MHz vs R", "lin", M1M,
...         xUnits="Ω", yUnits="dB", show=True)

An NGspice result instruction (from op()/ac()/…) may also be passed directly; it is delegated to ngspice_instr2traces().

ngspice_instr2traces(instr, trace_type='real', x_key=None, y_keys=None, goal_fn=None)

Convert an NGspice result instruction (from op(), ac(), dc(), tran(), noise()) into a dict of trace objects, ready for plot().

Same trace-formatting arguments as ngspice_dict2traces() (trace_type, x_key, y_keys, goal_fn), but the sweep/step provenance is read from the instruction, so:

  • x_key is auto-derived — the sweep variable for AC/TRAN/DC/NOISE, or the step variable for a stepped OP;

  • y_keys defaults to the dependent variables (instr.circuit.dep_vars).

Un-stepped OP results are scalars and yield {} (print them instead).

Parameters:

instr (SLiCAPinstruction.instruction) – instruction returned by an NGspice analysis function.

Returns:

{label: trace_object} ready for plot().

Return type:

dict

Example:

>>> AC1 = sl.ac("VampQspice", "dec", 50, 1e3, 100e6, names={"V_out": "v(out)"})
>>> BW  = sl.ngspice_instr2traces(AC1, trace_type='dBmag')
noise(cirFile, output, input_src, method, n, fstart, fstop, names=None, step=None, params=None, options=None, behavior=None, timeout=None, stimuli=None)

Run an NGspice noise analysis. Results stored as V²/Hz PSD (set sqrnoise is always active).

Use dB(np.sqrt(result["S_u"])) or dB(result["S_u"], power=True) for a dB spectral density plot.

Parameters:
  • cirFile (str) – Circuit filename without the .cir extension.

  • 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}. None returns 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 (see op()).

  • options (dict, NoneType) – NGspice .options dict.

  • 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, names=None, step=None, params=None, options=None, behavior=None, timeout=None, stimuli=None)

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 filename without the .cir extension (file must be in ini.cir_path).

  • names (dict, NoneType) – Signal name mapping {user_key: ngspice_expr}. None returns all available signals. Example: {"V_out": "v(out)", "I_in": "i(v1)"}.

  • 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. 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 .param line 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 .options key-value pairs, e.g. {"RELTOL": 1e-5}.

  • behavior (str, NoneType) – NGspice compatibility mode (e.g. "ltpsa"). 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, names=None, step=None, params=None, options=None, behavior=None, timeout=None, fourier=None, fft=None, stimuli=None)

Run an NGspice transient analysis, optionally with Fourier/FFT post-processing (the legacy ngspice2traces postProc semantics, structured).

fourier=<fundamental> (SLiCAP notation, e.g. "100k", or {"freq": "100k", "nfreqs": 10}) runs NGspice fourier after 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 the instr.fourier dict.

fft=True (or {"window": "hanning", "order": 8} — NGspice specwindow/specwindoworder) linearizes the transient and takes its FFT: the returned instruction is FREQUENCY-domain (dataType 'fft', complex arrays + "frequency"), plotting like an ac result (dBmag/phase via ngspice_instr2traces).

Both post-processing options REQUIRE names (the analysed vectors are created with let from the names entries, so derived expressions like "v(1)-v(2)" work).

Parameters:
  • cirFile (str) – Circuit filename without the .cir extension.

  • 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.

  • names (dict, NoneType) – {user_key: ngspice_expr}. None returns all signals.

  • step (dict, NoneType) – Parameter step dict (see op()).

  • params (list, NoneType) – Per-instruction parameter definitions — ordered list of (name, value) tuples (see op()).

  • options (dict, NoneType) – NGspice .options dict.

  • 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