Skip to main content

Session

Struct Session 

Source
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

Source

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.

Source

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.

Source

pub fn alter( &mut self, refdes: &str, param: &str, value: impl Into<AlterValue>, ) -> Result<(), Error>

Circuit::alter on the session’s circuit.

Source

pub fn param( &self, refdes: &str, param: &str, ) -> Result<Option<AlterValue>, Error>

Circuit::param on the session’s circuit.

Source

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.

Source

pub fn temp(&self) -> f64

The circuit temperature, °C.

Source

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.

Source

pub fn warm_start(&self) -> bool

Source

pub fn warm_stats(&self) -> WarmStats

Warm-start hits and misses so far.

Source

pub fn circuit(&self) -> &Circuit

Source

pub fn options(&self) -> &Options

Source

pub fn options_mut(&mut self) -> &mut Options

The options, for changes beyond Session::set_temp. They apply from the next run on.

Source

pub fn analyses(&self) -> &[Analysis]

The analysis cards Session::run runs.

Source

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.

Source

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.

Source

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).

Trait Implementations§

Source§

impl Clone for Session

Source§

fn clone(&self) -> Self

An independent session with the same circuit, options, cards and warm-start setting, and no warm-start history.

1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ByRef<T> for T

Source§

fn by_ref(&self) -> &T

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.