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 and batch mode
Section titled “Wine and batch mode”Wine is a compatibility layer that runs Windows executables on Linux. mcltspice invokes LTspice through Wine with the -b (batch) flag:
wine XVIIx64.exe -b circuit.cirThe -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.
The WINEPREFIX
Section titled “The WINEPREFIX”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:
export WINEPREFIX=/path/to/ltspice/.wineexport WINEARCH=win64wineboot --initAfter that, mcltspice sets WINEPREFIX automatically before each simulation run. You do not need to manage it.
macOS: the native binary
Section titled “macOS: the native binary”On macOS none of the Wine machinery applies. There is a native universal LTspice build, so mcltspice invokes the binary directly:
/Applications/LTspice.app/Contents/MacOS/LTspice -b circuit.netThe differences from the Linux/Wine path are worth spelling out:
- No Wine layer. No
WINEPREFIX, noWINEARCH, nowineboot. mcltspice detectssys.platform == 'darwin'and calls the binary.LTSPICE_BINoverrides the path, defaulting to the location above (mirroringLTSPICE_DIRon 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/withlib/{sym,sub,cmp}underneath, unpacked fromlib.zipon the first GUI launch — not glued onto the executable’s directory the way the Linuxlib/folder sits besideXVIIx64.exe. .ascneeds internal netlisting. The Mac command-line binary has no netlister:LTspice -b circuit.ascparses the schematic literally as a netlist and fails. So on macOS,simulate(.asc)converts the schematic to a.netinternally and then runs-bon the netlist.simulate_netlist(.net/.cir)runs unchanged. On Linux, Wine’s LTspice netlists the.ascitself, 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/.logfiles to appear with a timeout, rather than trusting the process return code.
Binary .raw files
Section titled “Binary .raw files”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:
- 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.
- 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.
Simulation types
Section titled “Simulation types”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.
Performance
Section titled “Performance”Typical simulation times:
| Circuit complexity | Simulation type | Approximate 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 .ac | 10 — 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.