Skip to main content

StateSpace

Struct StateSpace 

Source
pub struct StateSpace {
    pub a: Vec<Vec<f64>>,
    pub b: Vec<Vec<f64>>,
    pub c: Vec<Vec<f64>>,
    pub d: Vec<Vec<f64>>,
    pub e: Option<Vec<Vec<f64>>>,
}

Fields§

§a: Vec<Vec<f64>>

n x n dynamics matrix.

§b: Vec<Vec<f64>>

n x m input matrix (m = number of inputs).

§c: Vec<Vec<f64>>

p x n output matrix (p = number of outputs).

§d: Vec<Vec<f64>>

p x m feedthrough matrix.

§e: Option<Vec<Vec<f64>>>

n x n descriptor matrix. None means the identity (ordinary state-space); an explicit non-identity e is the “Descriptor State-Space” case.

Implementations§

Source§

impl StateSpace

Source

pub fn new( a: Vec<Vec<f64>>, b: Vec<Vec<f64>>, c: Vec<Vec<f64>>, d: Vec<Vec<f64>>, e: Option<Vec<Vec<f64>>>, ) -> Result<Self, StateSpaceError>

Validates e (if given) is invertible, then returns the assembled system. Every StateSpace::derivative call downstream relies on this having already been checked — see StateSpaceError::NonInvertibleDescriptorMatrix’s own doc comment.

Source

pub fn states(&self) -> usize

Source

pub fn inputs(&self) -> usize

Source

pub fn outputs(&self) -> usize

Source

pub fn output(&self, x: &[f64], u: &[f64]) -> Vec<f64>

y = C*x + D*u.

Source

pub fn derivative(&self, x: &[f64], u: &[f64]) -> Vec<f64>

dx/dt at the given (x, u), solving E * dx/dt = A*x + B*u for dx/dt when a non-identity descriptor matrix e is present (via the same dense Gauss-Jordan solve dae-runtime uses — small, hand-checkable, faer deferred until it’s actually needed; see that crate’s linsolve module doc for the same reasoning applied here).

Source

pub fn rk4_step(&self, x: &[f64], u: &[f64], dt: f64) -> Vec<f64>

Advances one RK4 step of size dt, holding u constant over the step (zero-order hold — matches how a discrete-timestep circuit/controller simulation would drive this block in dae-runtime’s eventual timestep loop). Returns the new state; call StateSpace::output separately for y at the new state.

Source

pub fn discrete_step(&self, x: &[f64], u: &[f64]) -> Vec<f64>

One step of a genuinely discrete-time system: x[i+1] = A*x[i] + B*u[i], plain linear recursion, no RK4, no dt, no numerical integration at all — the discrete-domain counterpart to Self::rk4_step. A/B here are already discrete-domain matrices, given directly by the caller (this method does no continuous-to-discrete conversion of its own) — see book/dev-guide/src/discrete-time-blocks.md. dae-runtime calls this once per declared sample period instead of once per circuit step, the same zero-order- hold accumulator cscript/pyblock already use. Ignores self.e entirely — a descriptor matrix has no meaning for a plain discrete recursion (there is no dx/dt to solve E against here).

Trait Implementations§

Source§

impl Clone for StateSpace

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for StateSpace

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for StateSpace

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for StateSpace

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