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.handlib/fte/ivars.c). Names in comments are the C names. - linalg
- Linear solver abstraction (D-0005). Devices never see the backend;
nothing outside
linalg::backendmay callfaerorxingo-sparsedirectly. - 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 sameMeasurements back.
Structs§
- Ac
- Result of an AC analysis.
- Asrc
BXXXXXXX N+ N- V=EXPRorI=EXPR: the arbitrary source of the 3f5 (dev/asrc/).expris the parse treedune_netlist::parse_exprbuilds; itsv(node)andi(device)references resolve at build time like every other name (ani()must name a device with a branch equation: V, E, H, L or a voltage-type B). AVoltagesource drivesv(N+) − v(N−)to the expression; aCurrentone makes it flow fromN+through the source toN−.- 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.ckeyword table; defaults frombjtsetup.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 lineMXXX 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.optionsMOS defaults. - Bsim1
Model .model … nmos(level=4 …)parameters, 3f5 names (b1.ckeyword table). Everything defaults to 0 (b1set.c); the junction potentials are clamped to ≥ 0.1 at temp time.- Bsim2
Model .model … nmos(level=5 …)parameters, 3f5 names (b2.c).Bsim2Model::newcarries theb2set.cdefaults; junction potentials are clamped to ≥ 0.1 like BSIM1’s.- Bsim3
Model .model … nmos/pmos(level=8|49 …): a BSIM3v3.3.0 model card, ngspice-47’s (bsim3def.hsBSIM3model). Parameters are set by deck keyword throughBsim3Model::set; like the C, every parameter remembers whether it was given, sinceb3set.c/b3temp.cbranch 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.cmodel table) and the defaults ofCSWsetup.- 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.- Diode
Model .model … d(…)parameters, 3f5 names and defaults (spice.txt§Junction Diodes;diompar.c).- Disto
- Result of a
.distoanalysis: two plots (DISTORTION - 2nd harmonic,DISTORTION - 3rd harmonic) withoutF2OVERF1, 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 pastRD/RSare named<name>#drain/<name>#source(JFETsetup’sCKTmkVoltcalls).- Jfet
Model .model … njf(…)/pjf(…)parameters, 3f5 names and defaults (jfet.ckeyword table; defaults fromjfetset.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’sCKTmkVoltcalls).- Ltra
Model .model … ltra(…)parameters, 3f5 names (ltra.cmodel table,ltrampar.c;spice.txt§Lossy Transmission Lines). Per-unit- length quantities are multiplied byLEN.- Mes
ZXXXXXXX ND NG NS MNAME <AREA> <OFF> <IC=VDS,VGS>(MESFET) with its model inline; prime nodes as forJfet. The 3f5 MESFET has no instance temperature.- MesModel
.model … nmf(…)/pmf(…)parameters, 3f5 names and the defaults ofmessetup.c(the manual’sBETAdefault of 1e-4 is not what the code does:MESsetupuses 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/asfall back to the.options defl/defw/defad/defasvalues at build time.- Mos2
- Like
Mos1, but with the level-2 (Grove-Frohman) model. The 3f5 names its prime nodesm1#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. - Mos1
Model .model … nmos(level=1 …)/pmos(level=1 …)parameters, 3f5 names and defaults (mos1.ckeyword table; defaults frommos1set.c).Optionmarks parameters whose given-ness changes the preprocessing inMOS1temp(e.g.KPcomputed fromU0/TOX,VTO/PHI/GAMMAfromNSUB,CBDvsCJ·AD).- Mos2
Model .model … nmos(level=2 …)/pmos(level=2 …)parameters, 3f5 names and defaults (mos2.ckeyword table; defaults frommos2set.c).Optionmarks parameters whose given-ness changes the preprocessing, as incrate::Mos1Model.- Mos3
Model .model … nmos(level=3 …)/pmos(level=3 …)parameters, 3f5 names and defaults (mos3.ckeyword table; defaults frommos3set.candmos3temp.c).Optionmarks parameters whose given-ness changes the preprocessing, as incrate::Mos1Model.- Mos6
Model .model … nmos(level=6 …)/pmos(level=6 …)parameters, 3f5 names and defaults (mos6.ckeyword table; defaults frommos6set.c).- Mutual
KXXXXXXX L1 L2 K. No effect at the operating point.- Noise
- Result of a
.noiseanalysis: 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
.pssrequest (seeCircuit::pss). - Pz
- Result of a
.pzanalysis. - Resistor
RXXXXXXX N1 N2 VALUE(ohms; nonzero).- RfPort
- An ngspice RF port (
vsrc.cunderRFSPICE, ngspice-47):PORTNUM num Z0 z0. The source is a port only whennum > 0andz0 > 0(VSRCtemp); otherwise the field is inert. The ports of a circuit must be numbered1..=Nwithout gaps or duplicates. - Selection
- A resolved selection.
scaleis 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’spl_scaleis a real vector). - Sens
- Result of a
.sensanalysis: 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::VarTypeandcrate::Datare-exported at the crate root so callers need not depend ondune_raw. - Sp
- Result of an S-parameter analysis: one complex plot
SP Analysisoverfrequencyholding the node voltages and branch currents of the last port’s excitation, thenS_i_j,Y_i_j,Z_i_j(ithe responding port,jthe 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.cmodel table) and the defaults ofSWsetup.- Sweep
Output - What one run produced: the plots of every analysis card, in deck
order (as
Circuit::rungives them), and the notes of the elaboration and of each analysis. - Sweep
Run - 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 sourcectrl, 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
.tfanalysis. 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 likeTRAsetup’sCKTmkVoltcalls:<name>#i1,<name>#i2(port currents intoN1/N3) and<name>#int1,<name>#int2(the nodes between each port’sZ0and 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(…)>.- Warm
Stats - Warm-start counters of a
Session(Session::warm_stats).
Enums§
- AcSweep
.acsweep spacing.- Alter
Value - A value for
Circuit::alter: a number, or the argument list of a source function (pulse,sin,exp,pwl,sffm). - Card
Output - What one analysis card produced (
Circuit::run_card). - ColData
- Column data: real for
.op/.dc/.tran, complex for.acvectors selected without a part. - Compat
- The defaults profile (
.options compat=, D-0046). - Data
- Rawfile column data and variable kinds, as carried by
Solution::dataandSolution::variables; re-exported so the public surface does not needdune_raw(thedune_rawpaths name the same types). Plot data, one column per variable, inVariables:order. - Error
- Ltra
Interp - 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
.printcard, a Pythonresult["v(2)"]or an Rdune_run(...)$nodesselection asks for. - Output
Var - The output variable of
.tfand.sens:V(N1<,N2>)orI(VXXXXXXX)(the current through a branch-carrying element). - Part
- The derived part of a vector (
VR VI VM VP VDBinspice.txt§.PRINT;cx_*in the 3f5 front end). - PzInput
.pzinput coupling (CUR/VOL).- PzWhich
- What to find (
POL/ZER/PZ). - Spec
- Sweep
Param - One swept quantity.
- VarType
- Rawfile column data and variable kinds, as carried by
Solution::dataandSolution::variables; re-exported so the public surface does not needdune_raw(thedune_rawpaths name the same types). Vector type, as named in the rawfileVariables:table. - Wave
- A transient source function:
PULSE SIN EXP PWL SFFM, and ngspice-47’s transient-noise functionsTRNOISE TRRANDOM, raw args. The noise functions are random: a source’s realization is fixed by.options seedand the source name (seedocs/dune-core.md§Ruído transiente), and is added to the source’sDCvalue, 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_compactrefined 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 ofCKTterr(Options::lte_trtol).
Functions§
- sweep
- Run the deck once per row of
runs, each row assigningruns[r][k]toparams[k], sequentially and in order.