pub struct Session { /* private fields */ }Expand description
A live circuit for interactive re-solves: the elaborated circuit, its options and its analysis cards, kept between runs (issue #12).
use dune_core::Session;
let deck = "divider\nv1 1 0 dc 10\nr1 1 2 1k\nr2 2 0 1k\n.op\n.end\n";
let parsed = dune_netlist::parse_str("deck.cir", deck);
let (mut s, _notes) = Session::from_netlist(&parsed.netlist).unwrap();
let (plots, _) = s.run().unwrap();
s.alter("r2", "", 3e3).unwrap();
let (again, _) = s.run().unwrap();
let v2 = |p: &dune_core::Solution| p.column("v(2)").unwrap()[0];
assert_eq!(v2(&plots[0]), 5.0);
assert_eq!(v2(&again[0]), 7.5);See the module notes for the bit-for-bit contract and the warm-start opt-in.
Implementations§
Source§impl Session
impl Session
Sourcepub fn new(circuit: Circuit, options: Options, analyses: Vec<Analysis>) -> Self
pub fn new(circuit: Circuit, options: Options, analyses: Vec<Analysis>) -> Self
A session over an already built circuit; analyses are what
Session::run runs, in order.
Sourcepub fn from_netlist(nl: &Netlist) -> Result<(Self, Vec<String>), Error>
pub fn from_netlist(nl: &Netlist) -> Result<(Self, Vec<String>), Error>
Elaborate a parsed deck into a session: the circuit
(Circuit::from_netlist), the deck’s .options (warnings
about them are dropped — apply them yourself with
Options::apply and use Session::new to keep them) and
its analysis cards. Returns the elaboration notes.
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>
Circuit::alter on the session’s circuit.
Sourcepub fn param(
&self,
refdes: &str,
param: &str,
) -> Result<Option<AlterValue>, Error>
pub fn param( &self, refdes: &str, param: &str, ) -> Result<Option<AlterValue>, Error>
Circuit::param on the session’s circuit.
Sourcepub fn set_temp(&mut self, celsius: f64) -> Result<(), Error>
pub fn set_temp(&mut self, celsius: f64) -> Result<(), Error>
The circuit temperature, °C (.options temp=, the card’s
unit). Instance TEMP= overrides still win, as in the 3f5.
Sourcepub fn set_warm_start(&mut self, on: bool)
pub fn set_warm_start(&mut self, on: bool)
Turn the operating-point warm start on or off (off by default; turning it off forgets the stored point). See the module notes: on, results agree with a fresh run to the Newton tolerances instead of bit for bit.
pub fn warm_start(&self) -> bool
Sourcepub fn warm_stats(&self) -> WarmStats
pub fn warm_stats(&self) -> WarmStats
Warm-start hits and misses so far.
pub fn circuit(&self) -> &Circuit
pub fn options(&self) -> &Options
Sourcepub fn options_mut(&mut self) -> &mut Options
pub fn options_mut(&mut self) -> &mut Options
The options, for changes beyond Session::set_temp. They
apply from the next run on.
Sourcepub fn analyses(&self) -> &[Analysis]
pub fn analyses(&self) -> &[Analysis]
The analysis cards Session::run runs.
Sourcepub fn run(&mut self) -> Result<(Vec<Solution>, Vec<String>), Error>
pub fn run(&mut self) -> Result<(Vec<Solution>, Vec<String>), Error>
Run every analysis card in order, as Circuit::run does for
each: the plots in rawfile order and the analyses’ notes (the
elaboration notes came with Session::from_netlist). The
first error stops the run.
Sourcepub fn run_analysis(
&mut self,
analysis: &Analysis,
) -> Result<(Vec<Solution>, Vec<String>), Error>
pub fn run_analysis( &mut self, analysis: &Analysis, ) -> Result<(Vec<Solution>, Vec<String>), Error>
Run one analysis card (any card, not only the deck’s) on the session’s circuit.
Sourcepub fn run_card(&mut self, analysis: &Analysis) -> Result<CardOutput, Error>
pub fn run_card(&mut self, analysis: &Analysis) -> Result<CardOutput, Error>
Session::run_analysis keeping a .pss result whole, as
Circuit::run_card does (same warm start, same cold re-run
after a miss).