Simulation Calculator¶
The Simulation Calculator provides a powerful Python-based environment to evaluate expressions, plot waveforms, and manipulate simulation data generated by OpenS.
Overview¶
The Calculator uses an embedded Python execution environment. It automatically extracts vectors and variables from your simulation results when run (e.g., Transient, AC, DC, and Operating Point analyses). Any valid Python script can be evaluated here, and the results can be plotted to the Waveform Viewer or displayed in the Results dialog as scalars.
[!NOTE] All NumPy functions are available natively via the
npvariable, which is automatically imported into your script's scope.
Signal Fetching Functions¶
The Calculator provides built-in helper functions to easily fetch signals, arrays, and scalars from your simulation raw plots.
General Fetcher¶
v(name, plot=None): The generic voltage fetcher. It automatically tries to find the signal in your Transient, DC, AC, and Operating Point analyses consecutively.
Transient Analysis¶
vt(name, plot=None)orst(name, plot=None): Fetch a transient voltage signal array by name.it(name, plot=None): Fetch a transient current signal array by name.t: The default time array (numpy.ndarray) for the current transient analysis.
AC Analysis (Frequency Domain)¶
vf(name, plot=None)orsf(name, plot=None): Fetch an AC voltage signal array (complex numbers) by name.ifc(name, plot=None): Fetch an AC current signal array (complex numbers) by name.f: The default frequency array (numpy.ndarray) for the current AC analysis.
DC Sweep Analysis¶
vdc(name, plot=None)orsdc(name, plot=None): Fetch a DC sweep voltage signal array by name.
Operating Point Analysis¶
op(name, plot=None)orsop(name, plot=None): Fetch a scalar operating point value (voltage or current) by node name.
Math & Measurement Functions¶
You can analyze and process arrays returned by the fetcher functions.
[!TIP] If a parameter like
t_startort_stopis omitted, the measurement applies to the entire array.
mean(x, y, t_start=None, t_stop=None): Calculates the mean/average ofyover the interval[t_start, t_stop]inx.rms(x, y, t_start=None, t_stop=None): Calculates the Root Mean Square (RMS) ofyover the interval[t_start, t_stop]inx.p2p(x, y, t_start=None, t_stop=None): Calculates the Peak-to-Peak difference ofyover the interval[t_start, t_stop].value(x, y, at): Interpolates the value ofyat the precisexcoordinate specified byat.f3db(result_array, plot_name=None): Calculates the 3dB frequency (bandwidth) of a complex AC array.mag(x): Returns the absolute magnitude of a complex/real array (equivalent tonp.abs(x)).db(x)/dB(x): Converts an array to decibels (\(20 \times \log_{10}(|x|)\)).ph(x): Returns the phase angle in degrees (np.angle(x, deg=True)).
Plotting & Visualization¶
The calculator integrates seamlessly into the Waveform Viewer to plot your Python expressions.
plot(x, y=None, label=None, title=None): Renders a standard 2D plot ofyoverx. Ifyis evaluated implicitly (e.g., just evaluating an array), the calculator defaults to using thetorfarrays asx.bode(target, plot=None): Renders a Bode plot. Target can be either the name of an AC signal (e.g.,'vout') or an evaluated complex NumPy array from an AC analysis. It automatically handles plotting both magnitude (in dB) and phase (in degrees).subaxis(nrows, idx)/subfigure(nrows, idx): Tools to divide the Waveform Viewer into horizontal subplots natively from scripts.
Special Context Variables¶
np: Provides full access to thenumpylibrary (e.g.,np.sin(t),np.max(vt('out'))).plots: A dictionary containing raw Spice results covering all nodes.
Examples¶
Measuring the 3dB cutoff of vout:
Plotting a signal in Decibels:
Plotting power dissipated by a resistor: