Skip to content

How mcltspice drives LTspice

LTspice ships as a Windows application, and there is no official Linux build — so on Linux mcltspice runs it through Wine in headless batch mode, with no GUI, no display server, and no X11 forwarding required. On macOS there is a native universal build, so mcltspice drives that binary directly with no Wine layer at all. This page explains the key pieces of both stacks and how they fit together.

Wine is a compatibility layer that runs Windows executables on Linux. mcltspice invokes LTspice through Wine with the -b (batch) flag:

Terminal window
wine XVIIx64.exe -b circuit.cir

The -b flag tells LTspice to run the simulation, write the results to a .raw file, and exit. No GUI window is created. This works in headless environments --- SSH sessions, containers, CI pipelines --- anywhere you can run a shell command.

Every Wine installation operates within a “prefix” --- a directory that acts as a virtual Windows filesystem. It contains the registry, drive letter mappings (the C:\ drive), and any DLLs the application needs.

mcltspice auto-detects the Wine prefix from the LTSPICE_DIR path. If your LTspice files are at /home/user/ltspice/extracted/ltspice, the prefix is expected at /home/user/ltspice/extracted/ltspice/.wine.

You create the prefix once during setup:

Terminal window
export WINEPREFIX=/path/to/ltspice/.wine
export WINEARCH=win64
wineboot --init

After that, mcltspice sets WINEPREFIX automatically before each simulation run. You do not need to manage it.

On macOS none of the Wine machinery applies. There is a native universal LTspice build, so mcltspice invokes the binary directly:

Terminal window
/Applications/LTspice.app/Contents/MacOS/LTspice -b circuit.net

The differences from the Linux/Wine path are worth spelling out:

  • No Wine layer. No WINEPREFIX, no WINEARCH, no wineboot. mcltspice detects sys.platform == 'darwin' and calls the binary. LTSPICE_BIN overrides the path, defaulting to the location above (mirroring LTSPICE_DIR on Linux).
  • Plain POSIX paths. The Wine path rewrites file arguments into the Z:\... drive-letter form Windows expects. The native Mac binary takes ordinary POSIX paths, so no translation happens.
  • Library root outside the app. The component library lives at ~/Library/Application Support/LTspice/ with lib/{sym,sub,cmp} underneath, unpacked from lib.zip on the first GUI launch — not glued onto the executable’s directory the way the Linux lib/ folder sits beside XVIIx64.exe.
  • .asc needs internal netlisting. The Mac command-line binary has no netlister: LTspice -b circuit.asc parses the schematic literally as a netlist and fails. So on macOS, simulate(.asc) converts the schematic to a .net internally and then runs -b on the netlist. simulate_netlist(.net/.cir) runs unchanged. On Linux, Wine’s LTspice netlists the .asc itself, so no internal step is needed. (This is the same wall that spicelib / PyLTSpice hit on macOS.)
  • Needs a GUI session; poll for output. Mac LTspice is an Aqua app that batch-runs but requires an active login/GUI session — it won’t run over bare SSH the way Wine + xvfb does. Its exit codes aren’t reliable, so mcltspice polls for the .raw/.log files to appear with a timeout, rather than trusting the process return code.

LTspice writes simulation results to binary .raw files. These are not human-readable --- they use a compact binary format specific to LTspice.

mcltspice’s raw_parser module reads these files by parsing:

  1. The header --- plain text at the top of the file containing the title, simulation type, variable names, variable types (voltage, current, frequency), and the total number of data points.
  2. The binary data block --- IEEE 754 double-precision floats packed contiguously after the header. The parser reads the correct number of bytes based on the variable count and point count from the header.

For AC analysis, each data point is a complex number (real + imaginary parts stored as two consecutive doubles). The parser converts these to magnitude and phase automatically when you call get_waveform.

For transient analysis, values are real-valued doubles. The independent variable (time) may use a compressed encoding where LTspice only stores points where the waveform changes significantly, but the parser handles this transparently.

LTspice supports several simulation types, each producing different data in the .raw file:

  • .tran (transient) --- Time-domain simulation. The independent variable is time; dependent variables are instantaneous voltages and currents. Used for oscillators, step response, switching converters.

  • .ac (AC analysis) --- Small-signal frequency response. The independent variable is frequency; dependent variables are complex-valued (magnitude and phase). Used for filter design, amplifier bandwidth, stability analysis.

  • .dc (DC sweep) --- Sweeps a source value and records the DC operating point at each step. Used for transfer characteristics and I-V curves.

  • .op (operating point) --- A single DC bias calculation with no sweep. Returns one set of node voltages and branch currents. Used to verify quiescent conditions.

  • .tf (transfer function) --- Computes small-signal gain, input impedance, and output impedance at DC. Returns scalar values, not waveforms.

  • .noise (noise analysis) --- Computes noise spectral density at each frequency point. The independent variable is frequency; dependent variables are noise voltage or current densities (V/sqrt(Hz) or A/sqrt(Hz)).

See Simulation Types for detailed coverage of each type, including directive syntax and which mcltspice tools work with each one.

Typical simulation times:

Circuit complexitySimulation typeApproximate time
Simple RC filter.ac (800 points)0.1 — 0.5 seconds
Op-amp circuit (10 components).tran (1ms)0.5 — 2 seconds
Switching converter.tran (10ms, 100k steps)2 — 5 seconds
Monte Carlo (100 runs).tran or .ac10 — 60 seconds

Wine overhead is minimal for batch mode. LTspice launches, runs the solver, writes the .raw file, and exits. The startup cost is roughly 50-100ms per invocation. For Monte Carlo or parameter sweeps, mcltspice runs LTspice once with stepped parameters rather than launching it repeatedly, which eliminates the startup overhead for multi-run analyses.

The main bottleneck is always the SPICE solver itself --- the matrix factorization and Newton-Raphson iterations that compute circuit behavior at each time step or frequency point.