NGSpice: Interactive Quick Reference

NGSpice executes in either interactive mode or batch mode, where interactive is the default. This is actually a very useful mode that allows to rapidly change the type and parameters of an analysis, enabling more rapid convergence to a working simulation.

Change Directory

Syntax: cd [directory]
Example: cd c:\spice     \\ changes to c:\spice directory
Example: cd                    \\ displays current directory


Syntax: edit [file]
Example: edit test.cir       \\ loads file as current circuit and opens in editor
Example: edit                     \\ opens current circuit in editor
Notes: The editor is an external editor, which on windows is notepad.exe. In order to change this to something else edit the config file (eg C:\<ngspice dir>\share\ngspice\scripts\spinit) and add a line that looks something like ‘set editor=C:\Vim\vim74\gvim.exe’, if you have the gvim editor installed. The directories will vary depending on your installation.


Syntax: listing [logical][physical][deck][expand][param]      \\ default=logical
Example: listing


Syntax: quit
Note: Exits the NGSpice simulator application.

Remove Current Circuit File

Syntax: remcirc
Note: Removes the current circuit in memory. Verify with ‘setcirc’.

Reset Simulation

Syntax: reset
Note: Clears any simulation data on the current in memory circuit.

Set Current Circuit

Syntax: setcirc [circname]
Example: setcirc
Note: NGSpice caches the circuit files in memory, and this allows you to scroll back and select a prior in memory circuit.

Load Spice File

Syntax: source circfile
Example: source rf-switch.cir
Note: Reads the file from the current directory.

Write Data to Simple File

Syntax: wrdata [file] [vectors]
Example: wrdata rc-test v(out)
Note: This generates an ASCII format data file.

Write Data to File (Spice 3f5 format)

Syntax: write [file] [exprs]
Example: write rc-test v(out)
Note: The default file format is binary, and is defined by the filetype variable. To generate ASCII output, enter: “set filetype=ascii”. To reset enter: “set filetype=binary”

Status Commands

Resource Status

Syntax: rusage [resource]
Example: rusage
Example: rusage all

System Info

Syntax: sysinfo

NGSpice Version

Syntax: version

Analysis Modes

Execute Circuit Simulation

Syntax: run
Note: Runs the simulation specified by the current in memory circuit.

Operating Point Analysis

Syntax: op
Example: op
Note: Generates the DC operating point analysis.

AC Analysis

Syntax: ac (DEC|OCT|LIN) N FStart FStop
Example: ac DEC 20 1k 1meg
Note: Sweeps any source with an AC component over the range specified.

DC Sweep

Syntax: dc Source VStart VStop VInc

Transfer Function Analysis

Syntax: tf output-node input-source

Transient Analysis

Syntax: tran TStep TStop [TStart [TMax]] [UIC]
Example: tran 10ns 10us
Note: Transient analysis of the circuit for any source that specifies a transient element.

Plotting and Printing


Syntax: gnuplot output-file plotargs
Example: gnuplot rctest v(out)
Note: This requires that gnuplot be installed and configured. As part of this process several output files will created.

Plot Data

Syntax: plot expr
Example: plot v(out)
Note: Some of the plot display parameters can be modified. For complete set refer to the NGSpice Predefined Variables list in the manual. For a few of the more useful ones, refer the section below on Plot Configuration.

Print Data

Syntax: print expr
Example: print v(out)
Example: print <all | allv | alli | ally>

Plot Configuration

Example: set color0=white         \\ background
Example: set color1=black           \\ foreground
Example: set xbrushwidth           \\ line width
Example: set gridstyle [lingrid|loglog|xlog|ylog|smith|smithgrid|polar|nogrid]
Example: set curplottitle=”RC Transfer Curve”

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s