Skip to main content

Crate dune_core

Crate dune_core 

Source
Expand description

Circuit simulation engine derived from SPICE3f5: MNA, devices, Newton-Raphson, analyses. The netlist IR (dune-netlist) is the bridge from decks; results mirror the rawfile (D-0008).

Porting notes live in docs/dune-core.md; the C sources cited in each module are under corpus/spice3f5/src/lib.

Re-exports§

pub use measure::MeasClause;
pub use measure::MeasDetail;
pub use measure::MeasureError;
pub use measure::MeasureOutcome;
pub use measure::Measurement;
pub use measure::measure_all;

Modules§

consts
Physical constants and reference values, byte for byte the 3f5’s (corpus/spice3f5/src/include/const.h and lib/fte/ivars.c). Names in comments are the C names.
linalg
Linear solver abstraction (D-0005). Devices never see the backend; nothing outside linalg::backend may call faer or xingo-sparse directly.
measure
.measure: scalar measurements over a computed plot — a pure post-processing layer (data in, scalars out) that never touches the simulation. The CLI prints it in ngspice’s format; the Python, R and JS bindings hand the same Measurements back.

Structs§

Ac
Result of an AC analysis.
Asrc
BXXXXXXX N+ N- V=EXPR or I=EXPR: the arbitrary source of the 3f5 (dev/asrc/). expr is the parse tree dune_netlist::parse_expr builds; its v(node) and i(device) references resolve at build time like every other name (an i() must name a device with a branch equation: V, E, H, L or a voltage-type B). A Voltage source drives v(N+) − v(N−) to the expression; a Current one makes it flow from N+ through the source to N−.
Bjt
QXXXXXXX NC NB NE <NS> MNAME <AREA> <OFF> <IC=VBE,VCE> <TEMP=T> with its model inline. nodes[3] is ground when no substrate was given.
BjtModel
.model … npn(…)/pnp(…) parameters, 3f5 names and defaults (bjt.c keyword table; defaults from bjtsetup.c).
Bsim1
Like Mos1, but with the BSIM1 (level-4) model.
Bsim2
Like Mos1, but with the BSIM2 (level-5) model.
Bsim3
A BSIM3v3.3.0 MOSFET (LEVEL=8/49, ngspice-47’s instance line MXXX D G S B MNAME <L=> <W=> <AD=> <AS=> <PD=> <PS=> <NRD=> <NRS=> <M=> <DELVTO=> <MULU0=> <OFF> <IC=VDS,VGS,VBS>, b3.c). L and W default to 5 µm (b3set.c), not the .options MOS defaults.
Bsim1Model
.model … nmos(level=4 …) parameters, 3f5 names (b1.c keyword table). Everything defaults to 0 (b1set.c); the junction potentials are clamped to ≥ 0.1 at temp time.
Bsim2Model
.model … nmos(level=5 …) parameters, 3f5 names (b2.c). Bsim2Model::new carries the b2set.c defaults; junction potentials are clamped to ≥ 0.1 like BSIM1’s.
Bsim3Model
.model … nmos/pmos(level=8|49 …): a BSIM3v3.3.0 model card, ngspice-47’s (bsim3def.h sBSIM3model). Parameters are set by deck keyword through Bsim3Model::set; like the C, every parameter remembers whether it was given, since b3set.c/b3temp.c branch on that.
Capacitor
CXXXXXXX N+ N- VALUE <IC=INCOND> (farads).
Cccs
FXXXXXXX N+ N- VNAM VALUE (CCCS).
Ccvs
HXXXXXXX N+ N- VNAM VALUE (CCVS, ohms).
Circuit
A circuit under construction. Analyses live in analysis/ (Phase 1: Circuit::op).
CswModel
.model … csw(…) parameters, 3f5 names (csw.c model table) and the defaults of CSWsetup.
Dc
Result of a DC transfer-curve analysis.
DcSweep
One sweep level: .dc SRC START STOP STEP.
Diode
DXXXXXXX N+ N- MNAME <AREA> <OFF> with its model inline.
DiodeModel
.model … d(…) parameters, 3f5 names and defaults (spice.txt §Junction Diodes; diompar.c).
Disto
Result of a .disto analysis: two plots (DISTORTION - 2nd harmonic, DISTORTION - 3rd harmonic) without F2OVERF1, three (DISTORTION - IM: f1+f2, … f1-f2, … 2f1-f2) with it.
Inductor
LYYYYYYY N+ N- VALUE <IC=INCOND> (henries).
Isource
IYYYYYYY N+ N- <DC VALUE> <tranfn(…)> (flows through the source from + to -).
Jfet
JXXXXXXX ND NG NS MNAME <AREA> <OFF> <IC=VDS,VGS> <TEMP=T> with its model inline. Prime nodes past RD/RS are named <name>#drain/<name>#source (JFETsetup’s CKTmkVolt calls).
JfetModel
.model … njf(…)/pjf(…) parameters, 3f5 names and defaults (jfet.c keyword table; defaults from jfetset.c).
Ltra
OXXXXXXX N1 N2 N3 N4 MNAME: a lossy transmission line (LTRA) between port 1 (N1, N2) and port 2 (N3, N4), with its model inline. The two port currents are extra unknowns named <name>#i1/<name>#i2 (LTRAsetup’s CKTmkVolt calls).
LtraModel
.model … ltra(…) parameters, 3f5 names (ltra.c model table, ltrampar.c; spice.txt §Lossy Transmission Lines). Per-unit- length quantities are multiplied by LEN.
Mes
ZXXXXXXX ND NG NS MNAME <AREA> <OFF> <IC=VDS,VGS> (MESFET) with its model inline; prime nodes as for Jfet. The 3f5 MESFET has no instance temperature.
MesModel
.model … nmf(…)/pmf(…) parameters, 3f5 names and the defaults of messetup.c (the manual’s BETA default of 1e-4 is not what the code does: MESsetup uses 2.5e-3).
Mos1
MXXXXXXX ND NG NS NB MNAME <L=> <W=> <AD=> <AS=> <PD=> <PS=> <NRD=> <NRS=> <OFF> <IC=VDS,VGS,VBS> <TEMP=T> with its level-1 model inline. l/w/ad/as fall back to the .options defl/defw/defad/defas values at build time.
Mos2
Like Mos1, but with the level-2 (Grove-Frohman) model. The 3f5 names its prime nodes m1#internal#drain/#internal#source (mos2set.c).
Mos3
Like Mos1, but with the level-3 (semi-empirical short-channel) model. Prime nodes are named like MOS2’s, m1#internal#drain/#internal#source (mos3set.c).
Mos6
Like Mos1, but with the level-6 (Sakurai-Newton) model.
Mos1Model
.model … nmos(level=1 …)/pmos(level=1 …) parameters, 3f5 names and defaults (mos1.c keyword table; defaults from mos1set.c). Option marks parameters whose given-ness changes the preprocessing in MOS1temp (e.g. KP computed from U0/TOX, VTO/PHI/GAMMA from NSUB, CBD vs CJ·AD).
Mos2Model
.model … nmos(level=2 …)/pmos(level=2 …) parameters, 3f5 names and defaults (mos2.c keyword table; defaults from mos2set.c). Option marks parameters whose given-ness changes the preprocessing, as in crate::Mos1Model.
Mos3Model
.model … nmos(level=3 …)/pmos(level=3 …) parameters, 3f5 names and defaults (mos3.c keyword table; defaults from mos3set.c and mos3temp.c). Option marks parameters whose given-ness changes the preprocessing, as in crate::Mos1Model.
Mos6Model
.model … nmos(level=6 …)/pmos(level=6 …) parameters, 3f5 names and defaults (mos6.c keyword table; defaults from mos6set.c).
Mutual
KXXXXXXX L1 L2 K. No effect at the operating point.
Noise
Result of a .noise analysis: the density sweep and, when the band has more than one frequency, the integrated totals.
Op
Result of an operating-point analysis.
Options
OutColumn
One selected column: pure data, ready for a numpy array, an R vector, a JSON column or the CLI formatter.
Pss
Result of a periodic steady-state analysis.
PssParams
The .pss request (see Circuit::pss).
Pz
Result of a .pz analysis.
Resistor
RXXXXXXX N1 N2 VALUE (ohms; nonzero).
RfPort
An ngspice RF port (vsrc.c under RFSPICE, ngspice-47): PORTNUM num Z0 z0. The source is a port only when num > 0 and z0 > 0 (VSRCtemp); otherwise the field is inert. The ports of a circuit must be numbered 1..=N without gaps or duplicates.
Selection
A resolved selection. scale is the plot’s abscissa (time, frequency, v(v-sweep)) when the analysis has one, whether or not it was asked for — consumers building tables want it alongside. The scale is real by construction, also in complex plots (the 3f5’s pl_scale is a real vector).
Sens
Result of a .sens analysis: one real point (DC) or one complex point per frequency (AC), one vector per perturbed parameter.
SensAc
The AC form of .sens: AC DEC|OCT|LIN N FSTART FSTOP.
Session
A live circuit for interactive re-solves: the elaborated circuit, its options and its analysis cards, kept between runs (issue #12).
Solution
One analysis plot: what a rawfile plot holds, with crate::VarType and crate::Data re-exported at the crate root so callers need not depend on dune_raw.
Sp
Result of an S-parameter analysis: one complex plot SP Analysis over frequency holding the node voltages and branch currents of the last port’s excitation, then S_i_j, Y_i_j, Z_i_j (i the responding port, j the driven one) and, with noise, i(Cy_i_j) plus, for two ports, NF, SOpt, NFmin, Rn — named and typed as ngspice-47’s rawfile writes them.
SwModel
.model … sw(…) parameters, 3f5 names (sw.c model table) and the defaults of SWsetup.
SweepOutput
What one run produced: the plots of every analysis card, in deck order (as Circuit::run gives them), and the notes of the elaboration and of each analysis.
SweepRun
One run of a sweep: the values it assigned (in the order of the sweep’s parameters) and its outcome. A failing run (no convergence, say — routine in a Monte Carlo tail) does not stop the others.
SwitchI
WXXXXXXX N+ N- VNAM MODEL <ON|OFF>: current-controlled switch keyed by the branch current of voltage source ctrl, with its model inline (dev/csw/).
SwitchV
SXXXXXXX N+ N- NC+ NC- MODEL <ON|OFF>: voltage-controlled switch with its model inline (dev/sw/).
Tf
Result of a .tf analysis. The plot holds the same three values under the ngspice vector names (Transfer_function, <src>#Input_impedance, output_impedance_at_V(…) or <src>#Output_impedance).
Tra
TXXXXXXX N1 N2 N3 N4 Z0=VALUE <TD=VALUE | F=FREQ <NL=NRMLEN>> <IC=V1,I1,V2,I2>: an ideal (lossless) transmission line between port 1 (N1, N2) and port 2 (N3, N4) (dev/tra/). Four extra unknowns, named like TRAsetup’s CKTmkVolt calls: <name>#i1, <name>#i2 (port currents into N1/N3) and <name>#int1, <name>#int2 (the nodes between each port’s Z0 and its delayed source).
Tran
Result of a transient analysis: one row per accepted timepoint.
Vccs
GXXXXXXX N+ N- NC+ NC- VALUE (VCCS, mhos).
Vcvs
EXXXXXXX N+ N- NC+ NC- VALUE (VCVS).
Vsource
VXXXXXXX N+ N- <DC VALUE> <tranfn(…)>.
WarmStats
Warm-start counters of a Session (Session::warm_stats).

Enums§

AcSweep
.ac sweep spacing.
AlterValue
A value for Circuit::alter: a number, or the argument list of a source function (pulse, sin, exp, pwl, sffm).
CardOutput
What one analysis card produced (Circuit::run_card).
ColData
Column data: real for .op/.dc/.tran, complex for .ac vectors selected without a part.
Compat
The defaults profile (.options compat=, D-0046).
Data
Rawfile column data and variable kinds, as carried by Solution::data and Solution::variables; re-exported so the public surface does not need dune_raw (the dune_raw paths name the same types). Plot data, one column per variable, in Variables: order.
Error
LtraInterp
How the delayed port values v(t−T), i(t−T) are interpolated from the accepted timepoints (LININTERP/QUADINTERP/ MIXEDINTERP).
Method
The .options method= integration method.
OutExpr
One output expression: what a .print card, a Python result["v(2)"] or an R dune_run(...)$nodes selection asks for.
OutputVar
The output variable of .tf and .sens: V(N1<,N2>) or I(VXXXXXXX) (the current through a branch-carrying element).
Part
The derived part of a vector (VR VI VM VP VDB in spice.txt §.PRINT; cx_* in the 3f5 front end).
PzInput
.pz input coupling (CUR/VOL).
PzWhich
What to find (POL/ZER/PZ).
Spec
SweepParam
One swept quantity.
VarType
Rawfile column data and variable kinds, as carried by Solution::data and Solution::variables; re-exported so the public surface does not need dune_raw (the dune_raw paths name the same types). Vector type, as named in the rawfile Variables: table.
Wave
A transient source function: PULSE SIN EXP PWL SFFM, and ngspice-47’s transient-noise functions TRNOISE TRRANDOM, raw args. The noise functions are random: a source’s realization is fixed by .options seed and the source name (see docs/dune-core.md §Ruído transiente), and is added to the source’s DC value, as in ngspice.

Constants§

LTRA_BREAK_RATE
The LTRA breakpoint hygiene of the Dune profile (Options::ltra_break_rate = None): about this many slope breakpoints per TMAX span (D-0047). Without an echo cascade it changes nothing — every LTRA deck of the corpus is bit-identical with it on and off at the deck’s step — and with one it decides whether the run ends: regress/ltra_compact refined 20 and 40 times exceeds the step budget without it. A lower rate already changes that deck at its own step.
PSS_FREQ_PLOT
Plot name of the harmonics (ngspice-47’s).
PSS_TIME_PLOT
Plot name of the period in the time domain (ngspice-47’s).
SPICE_TRTOL
SPICE’s default TRTOL, the overestimation its step control assumes of CKTterr (Options::lte_trtol).

Functions§

sweep
Run the deck once per row of runs, each row assigning runs[r][k] to params[k], sequentially and in order.