11. Mapping: SPICE raw files

How an LTspice / ngspice `.raw` file maps onto this model. This is the check that §5's axis generalisation and §6.5's runs actually earn their keep.

SPICE rawLogb
`Title:`, `Date:`, `Command:`file META keys
`Plotname: Transient Analysis`stream META `sim.analysis` = `transient` \`ac` \`dc` \`noise` \`op` \`tf`
`Flags: real``float` fields
`Flags: complex``complex` fields (§6.3)
`Flags: double`field `bit_width` 64 vs 32 — per field, so the mixed case is free
`Flags: fastaccess``filter=transpose` on the DATA frame (§8)
`Flags: log``axis_mode=2`, implicit log (§5.3) — `ratio = 10^(1/points_per_decade)`, zero bytes per record. An importer may also write the axis explicitly, which is what LTspice hands it
`Flags: stepped`one RUN frame per step (§6.5)
`No. Variables:``field_count`
`No. Points:`not needed — frames are self-delimiting
`Offset:`folded into `axis_base`
simulator timestep resolution`axis_exp` — ngspice's internal time is `double` seconds; an importer picks the exponent that holds the run exactly (§5.1)
`Variables:` block, first variablethe axis: `time`→`axis_kind=time`, `frequency`→`axis_kind=frequency`, a swept source→`axis_kind=other` with `axis_unit`
`Variables:` block, restfields; the type column (`voltage`, `device_current`) → `unit` plus field META
the netlistATTACH frame
the run boundariesexplicit (§6.5), not inferred

Notes on the quirks, which are the importer's problem and not the format's:

  • The axis variable is always `f64` even when `Flags: double` is absent and every

other variable is `f32`. Per-field `bit_width` expresses this directly, so it stops being a special case.

  • LTspice stores the sign bit of the time axis as a marker, requiring `abs()` on

read. An importer normalises this away; nothing about it survives into Logb.

  • `Flags: compressed` is LTspice's own scheme, which `rveen/ltspice` rejects

outright. It maps to `codec=zstd` on write and is a decode problem on import.

Streaming is the bonus. ngspice currently writes the raw file at the end of a run, because the header states `No. Points:` up front and so cannot be written until the count is known. Under Logb a simulator emits DATA frames as it solves, and a long transient analysis becomes watchable while it runs. That falls out of rule 1 without being designed for.


MD5 signature: 27b7318122e583b83b672b217a13f078