Struct au::linear_system::SsGen [−][src]
State-space representation of a linear system
xdot(t) = A * x(t) + B * u(t)
y(t) = C * x(t) + D * u(t)
Implementations
impl<T: ComplexField> SsGen<T, Continuous>
[src]
Implementation of the methods for the state-space
pub fn equilibrium(&self, u: &[T]) -> Option<Equilibrium<T>>
[src]
Calculate the equilibrium point for continuous time systems, given the input condition
x = - A^-1 * B * u
y = - (C * A^-1 * B + D) * u
Arguments
u
- Input vector
Example
use au::Ss; let a = [-1., 1., -1., 0.25]; let b = [1., 0.25]; let c = [0., 1., -1., 1.]; let d = [0., 1.]; let sys = Ss::new_from_slice(2, 1, 2, &a, &b, &c, &d); let u = 0.0; let eq = sys.equilibrium(&[u]).unwrap(); assert_eq!((0., 0.), (eq.x()[0], eq.y()[0]));
impl<T: ComplexField + Float + RealField> SsGen<T, Continuous>
[src]
Implementation of the methods for the state-space
#[must_use]pub fn is_stable(&self) -> bool
[src]
System stability. Checks if all A matrix eigenvalues (poles) are negative.
Example
use au::Ss; let sys = Ss::new_from_slice(2, 1, 1, &[-2., 0., 3., -7.], &[1., 3.], &[-1., 0.5], &[0.1]); assert!(sys.is_stable());
impl SsGen<T, Continuous>
[src]
Implementation of the methods for the state-space
pub fn rk2<F>(
&self,
u: F,
x0: &[f64],
h: Seconds<f64>,
n: usize
) -> Rk<'_, F, f64>ⓘ where
F: Fn(Seconds<f64>) -> Vec<f64>,
[src]
&self,
u: F,
x0: &[f64],
h: Seconds<f64>,
n: usize
) -> Rk<'_, F, f64>ⓘ where
F: Fn(Seconds<f64>) -> Vec<f64>,
Time evolution for the given input, using Runge-Kutta second order method
Arguments
u
- input function returning a vector (column mayor)x0
- initial state (column mayor)h
- integration time intervaln
- integration steps
pub fn rk4<F>(
&self,
u: F,
x0: &[f64],
h: Seconds<f64>,
n: usize
) -> Rk<'_, F, f64>ⓘ where
F: Fn(Seconds<f64>) -> Vec<f64>,
[src]
&self,
u: F,
x0: &[f64],
h: Seconds<f64>,
n: usize
) -> Rk<'_, F, f64>ⓘ where
F: Fn(Seconds<f64>) -> Vec<f64>,
Time evolution for the given input, using Runge-Kutta fourth order method
Arguments
u
- input function returning a vector (column mayor)x0
- initial state (column mayor)h
- integration time intervaln
- integration steps
pub fn rkf45<F>(
&self,
u: F,
x0: &[f64],
h: Seconds<f64>,
limit: Seconds<f64>,
tol: f64
) -> Rkf45<'_, F, f64>ⓘ where
F: Fn(Seconds<f64>) -> Vec<f64>,
[src]
&self,
u: F,
x0: &[f64],
h: Seconds<f64>,
limit: Seconds<f64>,
tol: f64
) -> Rkf45<'_, F, f64>ⓘ where
F: Fn(Seconds<f64>) -> Vec<f64>,
Runge-Kutta-Fehlberg 45 with adaptive step for time evolution.
Arguments
u
- input function returning a vector (column vector)x0
- initial state (column vector)h
- integration time intervallimit
- time evaluation limittol
- error tolerance
pub fn radau<F>(
&self,
u: F,
x0: &[f64],
h: Seconds<f64>,
n: usize,
tol: f64
) -> Radau<'_, F, f64>ⓘ where
F: Fn(Seconds<f64>) -> Vec<f64>,
[src]
&self,
u: F,
x0: &[f64],
h: Seconds<f64>,
n: usize,
tol: f64
) -> Radau<'_, F, f64>ⓘ where
F: Fn(Seconds<f64>) -> Vec<f64>,
Radau of order 3 with 2 steps method for time evolution.
Arguments
u
- input function returning a vector (column vector)x0
- initial state (column vector)h
- integration time intervaln
- integration stepstol
- error tolerance
impl<T: ComplexField> SsGen<T, Discrete>
[src]
Implementation of the methods for the state-space
pub fn equilibrium(&self, u: &[T]) -> Option<Equilibrium<T>>
[src]
Calculate the equilibrium point for discrete time systems, given the input condition. Input vector must have the same number of inputs of the system.
x = (I-A)^-1 * B * u
y = (C * (I-A)^-1 * B + D) * u
Arguments
u
- Input vector
Example
use au::Ssd; let a = [-1., 1., -1., 0.25]; let b = [1., 0.25]; let c = [0., 1., -1., 1.]; let d = [0., 1.]; let sys = Ssd::new_from_slice(2, 1, 2, &a, &b, &c, &d); let u = 0.0; let eq = sys.equilibrium(&[u]).unwrap(); assert_eq!((0., 0.), (eq.x()[0], eq.y()[0]));
impl<T: Scalar> SsGen<T, Discrete>
[src]
Trait for the set of methods on discrete linear systems.
pub fn evolution_fn<F>(
&self,
steps: usize,
input: F,
x0: &[T]
) -> EvolutionFn<'_, F, T>ⓘNotable traits for EvolutionFn<'a, F, T>
impl<'a, F, T> Iterator for EvolutionFn<'a, F, T> where
F: Fn(usize) -> Vec<T>,
T: AddAssign + Float + MulAssign + Scalar, type Item = TimeEvolution<T>;
where
F: Fn(usize) -> Vec<T>,
[src]
&self,
steps: usize,
input: F,
x0: &[T]
) -> EvolutionFn<'_, F, T>ⓘ
Notable traits for EvolutionFn<'a, F, T>
impl<'a, F, T> Iterator for EvolutionFn<'a, F, T> where
F: Fn(usize) -> Vec<T>,
T: AddAssign + Float + MulAssign + Scalar, type Item = TimeEvolution<T>;
F: Fn(usize) -> Vec<T>,
Time evolution for a discrete linear system.
Arguments
step
- simulation lengthinput
- input functionx0
- initial state
Example
use au::{Discretization, Ssd}; let disc_sys = Ssd::new_from_slice(2, 1, 1, &[0.6, 0., 0., 0.4], &[1., 5.], &[1., 3.], &[0.]); let impulse = |t| if t == 0 { vec![1.] } else { vec![0.] }; let evo = disc_sys.evolution_fn(20, impulse, &[0., 0.]); let last = evo.last().unwrap(); assert_abs_diff_eq!(0., last.state()[1], epsilon = 0.001);
pub fn evolution_iter<I, II>(
&self,
iter: II,
x0: &[T]
) -> EvolutionIter<'_, I, T>ⓘ where
II: IntoIterator<Item = Vec<T>, IntoIter = I>,
I: Iterator<Item = Vec<T>>,
[src]
&self,
iter: II,
x0: &[T]
) -> EvolutionIter<'_, I, T>ⓘ where
II: IntoIterator<Item = Vec<T>, IntoIter = I>,
I: Iterator<Item = Vec<T>>,
Time evolution for a discrete linear system.
Arguments
iter
- input datax0
- initial state
Example
use std::iter; use au::{Discretization, Ssd}; let disc_sys = Ssd::new_from_slice(2, 1, 1, &[0.6, 0., 0., 0.4], &[1., 5.], &[1., 3.], &[0.]); let impulse = iter::once(vec![1.]).chain(iter::repeat(vec![0.])).take(20); let evo = disc_sys.evolution_iter(impulse, &[0., 0.]); let last = evo.last().unwrap(); assert!(last[0] < 0.001);
impl<T: ComplexField + Float + RealField> SsGen<T, Discrete>
[src]
#[must_use]pub fn is_stable(&self) -> bool
[src]
System stability. Checks if all A matrix eigenvalues (poles) are inside the unit circle.
Example
use au::Ssd; let sys = Ssd::new_from_slice(2, 1, 1, &[-0.2, 0., 3., 0.1], &[1., 3.], &[-1., 0.5], &[0.1]); assert!(sys.is_stable());
impl<T: ComplexField + Float> SsGen<T, Continuous>
[src]
pub fn discretize(&self, st: T, method: Discretization) -> Option<Ssd<T>>
[src]
Convert a linear system into a discrete system.
Arguments
st
- sample timemethod
- discretization method
Example
use au::{Discretization, Ss}; let sys = Ss::new_from_slice(2, 1, 1, &[-3., 0., -4., -4.], &[0., 1.], &[1., 1.], &[0.]); let disc_sys = sys.discretize(0.1, Discretization::Tustin).unwrap(); let evo = disc_sys.evolution_fn(20, |t| vec![1.], &[0., 0.]); let last = evo.last().unwrap(); assert_relative_eq!(0.25, last.state()[1], max_relative = 0.01);
impl<T: Scalar, U: Time> SsGen<T, U>
[src]
Implementation of the methods for the state-space
pub fn new_from_slice(
states: usize,
inputs: usize,
outputs: usize,
a: &[T],
b: &[T],
c: &[T],
d: &[T]
) -> Self
[src]
states: usize,
inputs: usize,
outputs: usize,
a: &[T],
b: &[T],
c: &[T],
d: &[T]
) -> Self
Create a new state-space representation
Arguments
states
- number of states (n)inputs
- number of inputs (m)outputs
- number of outputs (p)a
- A matrix (nxn), row major matrix supplied as sliceb
- B matrix (nxm), row major matrix supplied as slicec
- C matrix (pxn), row major matrix supplied as sliced
- D matrix (pxm), row major matrix supplied as slice
Panics
Panics if matrix dimensions do not match
Example
use au::Ss; let sys = Ss::new_from_slice(2, 1, 1, &[-2., 0., 3., -7.], &[1., 3.], &[-1., 0.5], &[0.1]);
#[must_use]pub fn dim(&self) -> Dim
[src]
Get the dimensions of the system (states, inputs, outputs).
Example
use au::Ssd; let sys = Ssd::new_from_slice(2, 1, 1, &[-2., 0., 3., -7.], &[1., 3.], &[-1., 0.5], &[0.1]); let dimensions = sys.dim();
impl<T: ComplexField + Float + RealField, U: Time> SsGen<T, U>
[src]
Implementation of the methods for the state-space
#[must_use]pub fn poles(&self) -> Vec<Complex<T>>
[src]
Calculate the poles of the system
Example
use au::Ss; let sys = Ss::new_from_slice(2, 1, 1, &[-2., 0., 3., -7.], &[1., 3.], &[-1., 0.5], &[0.1]); let poles = sys.poles(); assert_eq!(-2., poles[0].re); assert_eq!(-7., poles[1].re);
impl<T: RealField + Scalar, U: Time> SsGen<T, U>
[src]
#[must_use]pub fn controllability(&self) -> (usize, usize, Vec<T>)
[src]
Controllability matrix
Mr = [B AB A^2B ... A^(n-1)B]
-> (n, mn) matrix.
The return value is: (rows, cols, vector with data in column major mode)
Example
use au::{linear_system::SsGen, Discrete}; let a = [-1., 3., 0., 2.]; let b = [1., 2.]; let c = [1., 1.]; let d = [0.]; let sys = SsGen::<_, Discrete>::new_from_slice(2, 1, 1, &a, &b, &c, &d); let mr = sys.controllability(); assert_eq!((2, 2, vec![1., 2., 5., 4.]), mr);
#[must_use]pub fn osservability(&self) -> (usize, usize, Vec<T>)
[src]
Osservability matrix
Mo = [C' A'C' A'^2B ... A'^(n-1)C']
-> (n, pn) matrix.
The return value is: (rows, cols, vector with data in column major mode)
Example
use au::{linear_system::SsGen, Continuous}; let a = [-1., 3., 0., 2.]; let b = [1., 2.]; let c = [1., 1.]; let d = [0.]; let sys = SsGen::<_, Continuous>::new_from_slice(2, 1, 1, &a, &b, &c, &d); let mr = sys.osservability(); assert_eq!((2, 2, vec![1., 1., -1., 5.]), mr);
impl<T: ComplexField + Float + RealField, U: Time> SsGen<T, U>
[src]
pub fn new_observability_realization(tf: &TfGen<T, U>) -> Result<Self, Error>
[src]
Convert a transfer function representation into state space representation. Conversion is done using the observability canonical form.
b_n*s^n + b_(n-1)*s^(n-1) + ... + b_1*s + b_0
G(s) = ---------------------------------------------
s^n + a_(n-1)*s^(n-1) + ... + a_1*s + a_0
┌ ┐ ┌ ┐
│ 0 0 0 . 0 -a_0 │ │ b'_0 │
│ 1 0 0 . 0 -a_1 │ │ b'_1 │
A = │ 0 1 0 . 0 -a_2 │, B = │ b'_2 │
│ . . . . . . │ │ . │
│ 0 0 0 . 1 -a_(n-1)│ │ b'_(n-1)│
└ ┘ └ ┘
┌ ┐ ┌ ┐
C = │0 0 0 . 0 1│, D = │b'_n│
└ ┘ └ ┘
b'_n = b_n, b'_i = b_i - a_i*b'_n, i = 0, ..., n-1
Arguments
tf
- transfer function
Errors
It returns an error if the transfer function has no poles.
pub fn new_controllability_realization(tf: &TfGen<T, U>) -> Result<Self, Error>
[src]
Convert a transfer function representation into state space representation. Conversion is done using the controllability canonical form.
b_n*s^n + b_(n-1)*s^(n-1) + ... + b_1*s + b_0
G(s) = ---------------------------------------------
s^n + a_(n-1)*s^(n-1) + ... + a_1*s + a_0
┌ ┐ ┌ ┐
│ 0 1 0 . 0 │ │ 0 │
│ 0 0 1 . 0 │ │ 0 │
A = │ 0 0 0 . 0 │, B = │ 0 │
│ . . . . . │ │ . │
│ 0 0 0 . 1 │ │ 0 │
│ -a_0 -a_1 -a_2 . -a_(n-1)│ │ 1 │
└ ┘ └ ┘
┌ ┐ ┌ ┐
C = │b'_0 b'_1 b'_2 . b'_(n-1)│, D = │b'_n│
└ ┘ └ ┘
b'_n = b_n, b'_i = b_i - a_i*b'_n, i = 0, ..., n-1
Arguments
tf
- transfer function
Errors
It returns an error if the transfer function has no poles.
Trait Implementations
impl<T: Clone + Scalar, U: Clone + Time> Clone for SsGen<T, U>
[src]
impl<T: Debug + Scalar, U: Debug + Time> Debug for SsGen<T, U>
[src]
impl<T: Scalar + Display, U: Time> Display for SsGen<T, U>
[src]
Implementation of state-space representation
impl<T: Time> From<SsGen<f32, T>> for TfMatrix<f32>
[src]
fn from(ss: SsGen<f32, T>) -> Self
[src]
Convert a state-space representation into a matrix of transfer functions
Arguments
ss
- state space linear system
impl<T: Time> From<SsGen<f64, T>> for TfMatrix<f64>
[src]
fn from(ss: SsGen<f64, T>) -> Self
[src]
Convert a state-space representation into a matrix of transfer functions
Arguments
ss
- state space linear system
impl<T: PartialEq + Scalar, U: PartialEq + Time> PartialEq<SsGen<T, U>> for SsGen<T, U>
[src]
impl<T: Scalar, U: Time> StructuralPartialEq for SsGen<T, U>
[src]
Auto Trait Implementations
impl<T, U> RefUnwindSafe for SsGen<T, U> where
T: RefUnwindSafe,
U: RefUnwindSafe,
T: RefUnwindSafe,
U: RefUnwindSafe,
impl<T, U> Send for SsGen<T, U> where
T: Send,
U: Send,
T: Send,
U: Send,
impl<T, U> Sync for SsGen<T, U> where
T: Sync,
U: Sync,
T: Sync,
U: Sync,
impl<T, U> Unpin for SsGen<T, U> where
T: Unpin,
U: Unpin,
T: Unpin,
U: Unpin,
impl<T, U> UnwindSafe for SsGen<T, U> where
T: UnwindSafe,
U: UnwindSafe,
T: UnwindSafe,
U: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
SS: SubsetOf<SP>,
pub fn to_subset(&self) -> Option<SS>
pub fn is_in_subset(&self) -> bool
pub fn to_subset_unchecked(&self) -> SS
pub fn from_subset(element: &SS) -> SP
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,