Type Definition automatica::linear_system::continuous::Ss

source ·
pub type Ss<T> = SsGen<T, Continuous>;
Expand description

State-space representation of continuous time linear system

Implementations§

source§

impl<T> Ss<T>where T: Abs + Add<Output = T> + Clone + Div<Output = T> + Mul<Output = T> + Neg<Output = T> + PartialOrd + Sub<Output = T> + Zero,

source

pub fn equilibrium(&self, u: &[T]) -> Option<Equilibrium<T>>

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 automatica::Ss;
let a = [-1.0, 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]));
source§

impl<T> Ss<T>where T: Abs + Add<Output = T> + Clone + Copy + Div<Output = T> + EigenConst + Epsilon + Hypot + Inv<Output = T> + Max + Mul<Output = T> + Neg<Output = T> + One + PartialOrd + Pow<T> + Sign + Sqrt + Sub<Output = T> + Zero,

Implementation of the methods for the state-space

source

pub fn is_stable(&self) -> bool

System stability. Checks if all A matrix eigenvalues (poles) are negative.

Example
use automatica::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());
source§

impl<T> Ss<T>where T: Abs + Add<Output = T> + AddAssign + Clone + Div<Output = T> + Max + Mul<Output = T> + NumCast + PartialOrd + Pow<T> + RkConst + Rkf45Const + Sub<Output = T> + Zero,

source

pub fn rk2<F>(&self, u: F, x0: &[T], h: Seconds<T>, n: usize) -> Rk<'_, T, F> where F: Fn(Seconds<T>) -> Vec<T>,

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 interval
  • n - integration steps
source

pub fn rk4<F>(&self, u: F, x0: &[T], h: Seconds<T>, n: usize) -> Rk<'_, T, F> where F: Fn(Seconds<T>) -> Vec<T>,

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 interval
  • n - integration steps
source

pub fn rkf45<F>( &self, u: F, x0: &[T], h: Seconds<T>, limit: Seconds<T>, tol: T ) -> Rkf45<'_, T, F> where F: Fn(Seconds<T>) -> Vec<T>,

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 interval
  • limit - time evaluation limit
  • tol - error tolerance
source§

impl<T> Ss<T>where T: Abs + Add<Output = T> + AddAssign + Clone + Div<Output = T> + Mul<Output = T> + NumCast + One + PartialOrd + RadauConst + RelativeEq + Sub<Output = T> + Zero,

source

pub fn radau<F>( &self, u: F, x0: &[T], h: Seconds<T>, n: usize, tol: T ) -> Option<Radau<'_, T, F>>where F: Fn(Seconds<T>) -> Vec<T>,

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 interval
  • n - integration steps
  • tol - error tolerance
source§

impl<T> Ss<T>where T: Abs + Add<Output = T> + Clone + Div<Output = T> + From<f32> + Mul<Output = T> + One + PartialOrd + Sub<Output = T> + Zero,

source

pub fn discretize(&self, st: T, method: Discretization) -> Option<Ssd<T>>

Convert a linear system into a discrete system.

Arguments
  • st - sample time
  • method - discretization method
Example
use automatica::{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);