OhmSpice docs

Python Scripting

Python scripting

Scripts can run sheet simulations, derive traces, and open temporary plot outputs without changing the saved schematic.

Module functions

get_sheet(sheet_name=None)

Returns a schematic handle for run-local component overrides and simulations.

dc_source(value=0)

Creates a typed DC source override.

ac_source(magnitude=1, *, phase=0, dc=0)

Creates a typed small-signal AC source override.

sine_source(amplitude, frequency, *, offset=0, delay=0, phase=0)

Creates a typed sinusoidal source override.

pulse_source(low, high, frequency, *, duty=50, delay=0, rise=0, fall=0)

Creates a typed periodic pulse source override.

solver(*, method=None, preset=None, **options)

Builds a validated solver configuration without raw `.options` text.

subplots(rows=1, cols=1, *, title=None, sharex=False)

Creates a figure and one axis or a tuple of axes.

export_csv(filename, *signals)

Downloads derived Signals that share an x axis as CSV.

plot(signal_or_x, y=None, *, label=None, color=None)

Adds a Signal or x/y sequence to the default figure.

show(*, title=None, xlabel=None, ylabel=None, xscale=None)

Opens the default figure as a script output tab.

Result, sheet, axis, and figure methods

sheet.component(refdes)

Returns a run-local component override handle.

sheet.override(**components)

Returns an independent sheet handle with scalar or typed-source overrides.

sheet.sweep(*, mode="product", **components)

Creates a Cartesian component sweep that executes as one batch host operation.

sheet.run(*, save="all", solver=None, parameters=None, directives=None, timeout=15)

Runs the sheet's configured analysis.

sheet.op(*, save="all", solver=None, parameters=None, directives=None, timeout=15)

Runs an operating-point analysis.

sheet.tran(stop, *, step="10u", start=None, max_step=None, uic=False, save="all", solver=None, timeout=15)

Runs a transient analysis.

sheet.ac(start, stop, *, points=100, sweep="dec", save="all", solver=None, timeout=15)

Runs a linear, octave, or decade AC sweep.

sheet.dc(source, start, stop, step, *, save="all", solver=None, timeout=15)

Runs a DC source sweep.

result.component(refdes)

Returns the semantic signal groups saved for one component.

result.signal(expression)

Returns an explicitly saved node voltage, default current, or semantic component signal.

component.signal(path)

Returns one saved semantic signal using a component-relative group path.

result.to_csv(*expressions)

Returns CSV text for selected signals, or every returned vector when no expressions are given.

result.export_csv(filename, *expressions)

Downloads selected result signals as CSV, preserving real and imaginary AC columns.

result.v(net)

Returns a node-voltage Signal.

result.i(refdes)

Returns the component Model's declared default-current Signal.

signal.window(start=None, stop=None)

Returns the samples inside an x-axis window.

signal.at(x, *, method="linear")

Samples a Signal by linear interpolation or nearest point.

signal.mean(*, start=None, stop=None)

Mean measurement; transient mean/RMS/integral use time weighting.

signal.rms(*, start=None, stop=None)

Rms measurement; transient mean/RMS/integral use time weighting.

signal.min(*, start=None, stop=None)

Min measurement; transient mean/RMS/integral use time weighting.

signal.max(*, start=None, stop=None)

Max measurement; transient mean/RMS/integral use time weighting.

signal.pkpk(*, start=None, stop=None)

Peak-to-peak measurement; transient mean/RMS/integral use time weighting.

signal.integral(*, start=None, stop=None)

Integral measurement; transient mean/RMS/integral use time weighting.

signal.crossings(level=0, *, edge="both")

Returns interpolated rising, falling, or all threshold-crossing x coordinates.

signal.fft(*, window="hann", detrend=True)

Resamples adaptive transient data uniformly and returns a complex frequency-domain Signal.

signal.thd(fundamental, *, harmonics=10, start=None, stop=None)

Computes total harmonic distortion from a transient window.

axis.plot(signal_or_x, y=None, *, label=None, color=None)

Adds a Signal or x/y sequence to an axis and returns the axis.

axis.set(*, title=None, xlabel=None, ylabel=None, xscale=None)

Sets pane labels and scale, then returns the axis.

figure.show(title=None)

Opens the figure as a script output tab.

figure.savefig(filename, *, title=None)

Opens the figure output and downloads all of its panes as one PNG.