pub struct Circuit {
pub title: String,
/* private fields */
}Expand description
A circuit under construction. Analyses live in analysis/
(Phase 1: Circuit::op).
Cloning copies the element specs, .nodesets and .ics; the
clone never shares a Session’s warm-start
state.
Fields§
§title: StringImplementations§
Source§impl Circuit
impl Circuit
Source§impl Circuit
impl Circuit
Sourcepub fn disto(
&self,
opts: &Options,
sweep: AcSweep,
points: usize,
fstart: f64,
fstop: f64,
f2overf1: Option<f64>,
) -> Result<Disto, Error>
pub fn disto( &self, opts: &Options, sweep: AcSweep, points: usize, fstart: f64, fstop: f64, f2overf1: Option<f64>, ) -> Result<Disto, Error>
Run .disto DEC|OCT|LIN NP FSTART FSTOP <F2OVERF1>
(DISTOan). The sources’ DISTOF1/DISTOF2 values drive
the first-order kernels; their AC values play no part.
Source§impl Circuit
impl Circuit
Sourcepub fn noise(
&self,
opts: &Options,
output: &OutputVar,
src: &str,
sweep: AcSweep,
points: usize,
fstart: f64,
fstop: f64,
pts_per_summary: Option<usize>,
) -> Result<Noise, Error>
pub fn noise( &self, opts: &Options, output: &OutputVar, src: &str, sweep: AcSweep, points: usize, fstart: f64, fstop: f64, pts_per_summary: Option<usize>, ) -> Result<Noise, Error>
Run .noise V(OUT<,REF>) SRC DEC|OCT|LIN PTS FSTART FSTOP <PTS_PER_SUMMARY>.
output must be an OutputVar::Voltage: the 3f5’s .noise
takes only V(OUTPUT<,REF>) (spice.txt), so a current output
is an Error::Build.
Source§impl Circuit
impl Circuit
Sourcepub fn pss(&self, opts: &Options, p: &PssParams) -> Result<Pss, Error>
pub fn pss(&self, opts: &Options, p: &PssParams) -> Result<Pss, Error>
Run .pss: the periodic steady state of the circuit driven at
the fundamental p.freq (or the one its sources share), by
shooting–Newton with matrix-free GMRES on the period map (see
the module docs). Fails with Error::PssConvergence when
p.max_iter shooting iterations do not bring the period
mismatch within tolerance.
Source§impl Circuit
impl Circuit
Sourcepub fn run(
&self,
analysis: &Analysis,
opts: &Options,
) -> Result<(Vec<Solution>, Vec<String>), Error>
pub fn run( &self, analysis: &Analysis, opts: &Options, ) -> Result<(Vec<Solution>, Vec<String>), Error>
Run one analysis card (.op, .dc, .tran, .ac, .pz,
.noise, .disto, .tf, .sens, ngspice’s .sp, and .pss) as
spice3 -b (ngspice -b for .sp) would.
Returns the plots in rawfile order with their 3f5/ngspice
plotnames — one for most analyses; .noise gives the density
plot plus, when the band has more than one frequency, the
integrated totals; .disto gives 2 or 3 plots; .pss the
period and its harmonics — and the analysis’ notes (non-fatal
remarks the caller may show). This is Circuit::run_card
with the .pss result reduced to its plots
(CardOutput::into_plots).
A .tf/.sens output that is not V(..)/I(..) is an
Error::Build; engine failures pass through unchanged.
Sourcepub fn run_card(
&self,
analysis: &Analysis,
opts: &Options,
) -> Result<CardOutput, Error>
pub fn run_card( &self, analysis: &Analysis, opts: &Options, ) -> Result<CardOutput, Error>
Run one analysis card as Circuit::run does, keeping a
.pss result whole (CardOutput::Pss: period, t0 and the
shooting history besides the plots). The card’s parameters are
read here and only here — for .pss, the PssParams of the
card (ngspice’s integer truncation of the counts, the
defaults of PssParams::default for what it omits).
Source§impl Circuit
impl Circuit
Sourcepub fn alter(
&mut self,
refdes: &str,
param: &str,
value: impl Into<AlterValue>,
) -> Result<(), Error>
pub fn alter( &mut self, refdes: &str, param: &str, value: impl Into<AlterValue>, ) -> Result<(), Error>
Change one parameter of element refdes in place — the
spice3/ngspice alter command. The next analysis sees the
circuit exactly as if the deck had been written with the new
value (same spec field, same unit as the card).
refdes is the element name (case-insensitive; subcircuit
instances by their expanded name, e.g. r.x1.r1). param is
the ngspice parameter name, "" for the element’s principal
value:
| element | param ("" →) | value |
|---|---|---|
R | resistance (r) | ohms, nonzero |
C / L | capacitance (c) / inductance (l), ic | F / H; IC in V / A |
V / I | dc, acmag, acphase (degrees) | V or A |
V / I | pulse, sin, exp, pwl, sffm, trnoise, trrandom | AlterValue::List: the card’s arguments; replaces the transient function |
E F G H | gain | as on the card |
| MOS (all levels, BSIM) | w, l | meters, positive |
MOS 1/2/3/6, D, Q, J | temp | °C, like TEMP= on the card |
D, Q, J, Z | area | positive |
Altering acmag/acphase of a source without an AC
specification gives it one (the other half 0), as the card
AC 0 <phase> would. Inductor values also move the coupling of
their K elements (MUTfactor is recomputed at each run).
Topology never changes, so an altered circuit keeps its
unknowns and output vectors. The circuit-wide temperature is
an option: Session::set_temp.
Errors (Error::Build): unknown element, a parameter the
element does not have (the message lists the valid ones), a
non-finite value, a zero resistance, a nonpositive W/L/
area, a number where a list is due or vice versa.
Sourcepub fn param(
&self,
refdes: &str,
param: &str,
) -> Result<Option<AlterValue>, Error>
pub fn param( &self, refdes: &str, param: &str, ) -> Result<Option<AlterValue>, Error>
The current value of an alterable parameter (same names and
units as Circuit::alter), e.g. to seed a slider. A value
the element never got — a MOS W left to .options defw, a
source without AC — reads as None; a source without a
transient function reads None for pulse and friends, and
only the function the source has reads Some.