Struct au::transfer_function::TfGen[][src]

pub struct TfGen<T, U: Time> { /* fields omitted */ }

Transfer function representation of a linear system

Implementations

impl<T: Float> TfGen<T, Continuous>[src]

pub fn delay(tau: Seconds<T>) -> impl Fn(Complex<T>) -> Complex<T>[src]

Time delay for continuous time transfer function. y(t) = u(t - tau) `G(s) = e^(-tau * s)

Arguments

  • tau - Time delay

Example

use au::{num_complex::Complex, Seconds, Tf};
let d = Tf::delay(Seconds(2.));
assert_eq!(1., d(Complex::new(0., 10.)).norm());

#[must_use]pub fn init_value(&self) -> T[src]

System inital value response to step input. y(0) = G(s->infinity)

Example

use au::{poly, Tf};
let tf = Tf::new(poly!(4.), poly!(1., 5.));
assert_eq!(0., tf.init_value());

#[must_use]pub fn init_value_der(&self) -> T[src]

System derivative inital value response to step input. y'(0) = s * G(s->infinity)

Example

use au::{poly, Tf};
let tf = Tf::new(poly!(1., -3.), poly!(1., 3., 2.));
assert_eq!(-1.5, tf.init_value_der());

#[must_use]pub fn sensitivity(&self, r: &Self) -> Self[src]

Sensitivity function for the given controller r.

             1
S(s) = -------------
       1 + G(s)*R(s)

Arguments

  • r - Controller

Example

use au::{poly, Tf};
let g = Tf::new(poly!(1.), poly!(0., 1.));
let r = Tf::new(poly!(4.), poly!(1., 1.));
let s = g.sensitivity(&r);
assert_eq!(Tf::new(poly!(0., 1., 1.), poly!(4., 1., 1.)), s);

#[must_use]pub fn compl_sensitivity(&self, r: &Self) -> Self[src]

Complementary sensitivity function for the given controller r.

         G(s)*R(s)
F(s) = -------------
       1 + G(s)*R(s)

Arguments

  • r - Controller

Example

use au::{poly, Tf};
let g = Tf::new(poly!(1.), poly!(0., 1.));
let r = Tf::new(poly!(4.), poly!(1., 1.));
let f = g.compl_sensitivity(&r);
assert_eq!(Tf::new(poly!(4.), poly!(4., 1., 1.)), f);

#[must_use]pub fn control_sensitivity(&self, r: &Self) -> Self[src]

Sensitivity to control function for the given controller r.

           R(s)
Q(s) = -------------
       1 + G(s)*R(s)

Arguments

  • r - Controller

Example

use au::{poly, Tf};
let g = Tf::new(poly!(1.), poly!(0., 1.));
let r = Tf::new(poly!(4.), poly!(1., 1.));
let q = g.control_sensitivity(&r);
assert_eq!(Tf::new(poly!(0., 4.), poly!(4., 1., 1.)), q);

impl<T: Float + RealField> TfGen<T, Continuous>[src]

#[must_use]pub fn is_stable(&self) -> bool[src]

System stability. Checks if all poles are negative.

Example

use au::{Poly, Tf};
let tf = Tf::new(Poly::new_from_coeffs(&[1.]), Poly::new_from_roots(&[-1., -2.]));
assert!(tf.is_stable());

pub fn root_locus(&self, k: T) -> Vec<Complex<T>>[src]

Root locus for the given coefficient k

Arguments

  • k - Transfer function constant

Example

use au::{num_complex::Complex, poly, Poly, Tf};
let l = Tf::new(poly!(1.), Poly::new_from_roots(&[-1., -2.]));
let locus = l.root_locus(0.25);
assert_eq!(Complex::new(-1.5, 0.), locus[0]);

pub fn root_locus_plot(self, min_k: T, max_k: T, step: T) -> RootLocus<T>[src]

Create a RootLocus plot

Arguments

  • min_k - Minimum transfer constant of the plot
  • max_k - Maximum transfer constant of the plot
  • step - Step between each transfer constant

step is linear.

Panics

Panics if the step is not strictly positive of the minimum transfer constant is not lower than the maximum transfer constant.

Example

use au::{num_complex::Complex, poly, Poly, Tf};
let l = Tf::new(poly!(1.), Poly::new_from_roots(&[-1., -2.]));
let locus = l.root_locus_plot(0.1, 1.0, 0.05).into_iter();
assert_eq!(19, locus.count());

impl<T> TfGen<T, Continuous>[src]

#[must_use]pub fn static_gain<'a>(&'a self) -> T where
    &'a T: 'a + Div<&'a T, Output = T>, 
[src]

Static gain G(0). Ratio between constant output and constant input. Static gain is defined only for transfer functions of 0 type.

Example

use au::{poly, Tf};
let tf = Tf::new(poly!(4., -3.),poly!(2., 5., -0.5));
assert_eq!(2., tf.static_gain());

impl<T: Float> TfGen<T, Discrete>[src]

pub fn delay(k: i32) -> impl Fn(Complex<T>) -> Complex<T>[src]

Time delay for discrete time transfer function. y(k) = u(k - h) `G(z) = z^(-h)

Arguments

  • h - Time delay

Example

use au::{num_complex::Complex, units::Seconds, Tfz};
let d = Tfz::delay(2);
assert_eq!(0.010000001, d(Complex::new(0., 10.0_f32)).norm());

#[must_use]pub fn init_value(&self) -> T[src]

System inital value response to step input. y(0) = G(z->infinity)

Example

use au::{poly, Tfz};
let tf = Tfz::new(poly!(4.), poly!(1., 5.));
assert_eq!(0., tf.init_value());

impl<'a, T: 'a + Add<&'a T, Output = T> + Div<Output = T> + Zero> TfGen<T, Discrete>[src]

#[must_use]pub fn static_gain(&'a self) -> T[src]

Static gain G(1). Ratio between constant output and constant input. Static gain is defined only for transfer functions of 0 type.

Example

use au::{poly, Tfz};
let tf = Tfz::new(poly!(5., -3.),poly!(2., 5., -6.));
assert_eq!(2., tf.static_gain());

impl<T: Float + RealField> TfGen<T, Discrete>[src]

#[must_use]pub fn is_stable(&self) -> bool[src]

System stability. Checks if all poles are inside the unit circle.

Example

use au::{Poly, Tfz};
let tfz = Tfz::new(Poly::new_from_coeffs(&[1.]), Poly::new_from_roots(&[0.5, 1.5]));
assert!(!tfz.is_stable());

impl<T: Float + Mul<Output = T> + Sum> TfGen<T, Discrete>[src]

pub fn arma_fn<F>(&self, input: F) -> ArmaFn<F, T>

Notable traits for ArmaFn<F, T>

impl<F, T> Iterator for ArmaFn<F, T> where
    F: Fn(usize) -> T,
    T: Float + Mul<Output = T> + Sum
type Item = T;
where
    F: Fn(usize) -> T, 
[src]

Autoregressive moving average representation of a discrete transfer function It transforms the transfer function into time domain input-output difference equation.

                  b_n*z^n + b_(n-1)*z^(n-1) + ... + b_1*z + b_0
Y(z) = G(z)U(z) = --------------------------------------------- U(z)
                    z^n + a_(n-1)*z^(n-1) + ... + a_1*z + a_0

y(k) = - a_(n-1)*y(k-1) - ... - a_1*y(k-n+1) - a_0*y(k-n) +
       + b_n*u(k) + b_(n-1)*u(k-1) + ... + b_1*u(k-n+1) + b_0*u(k-n)

Arguments

  • input - Input function

Example

use au::{poly, signals::discrete, Tfz};
let tfz = Tfz::new(poly!(1., 2., 3.), poly!(0., 0., 0., 1.));
let mut iter = tfz.arma_fn(discrete::step(1., 0));
assert_eq!(Some(0.), iter.next());
assert_eq!(Some(3.), iter.next());
assert_eq!(Some(5.), iter.next());
assert_eq!(Some(6.), iter.next());

pub fn arma_iter<I, II>(&self, iter: II) -> ArmaIter<I, T>

Notable traits for ArmaIter<I, T>

impl<I, T> Iterator for ArmaIter<I, T> where
    I: Iterator<Item = T>,
    T: Float + Mul<Output = T> + Sum
type Item = T;
where
    II: IntoIterator<Item = T, IntoIter = I>,
    I: Iterator<Item = T>, 
[src]

Autoregressive moving average representation of a discrete transfer function It transforms the transfer function into time domain input-output difference equation.

                  b_n*z^n + b_(n-1)*z^(n-1) + ... + b_1*z + b_0
Y(z) = G(z)U(z) = --------------------------------------------- U(z)
                    z^n + a_(n-1)*z^(n-1) + ... + a_1*z + a_0

y(k) = - a_(n-1)*y(k-1) - ... - a_1*y(k-n+1) - a_0*y(k-n) +
       + b_n*u(k) + b_(n-1)*u(k-1) + ... + b_1*u(k-n+1) + b_0*u(k-n)

Arguments

  • iter - Iterator supplying the input data to the model

Example

use au::{poly, signals::discrete, Tfz};
let tfz = Tfz::new(poly!(1., 2., 3.), poly!(0., 0., 0., 1.));
let mut iter = tfz.arma_iter(std::iter::repeat(1.));
assert_eq!(Some(0.), iter.next());
assert_eq!(Some(3.), iter.next());
assert_eq!(Some(5.), iter.next());
assert_eq!(Some(6.), iter.next());

impl<T: Float> TfGen<T, Continuous>[src]

pub fn discretize(&self, ts: Seconds<T>, method: Discretization) -> Tfz<T>[src]

Convert a continuous time transfer function into a discrete time transfer function using the given method.

  • ts - Sampling period in seconds
  • method - Discretization method

Example

use au::{polynomial::Poly, Discretization, Seconds, Tf, Tfz};
use au::num_complex::Complex64;
let tf = Tf::new(
    Poly::new_from_coeffs(&[2., 20.]),
    Poly::new_from_coeffs(&[1., 0.1]),
);
let tfz = tf.discretize(Seconds(1.), Discretization::BackwardEuler);
assert_eq!(0.1 / 1.1, tfz.real_poles().unwrap()[0]);

pub fn discretize_with_warp(
    &self,
    ts: Seconds<T>,
    warp_freq: RadiansPerSecond<T>
) -> Tfz<T>
[src]

Convert a continuous time transfer function into a discrete time transfer function using Tustin method with frequency pre-warping.

  • ts - Sampling period in seconds
  • warp_freq - Pre-warping frequency in radians per second

Example

use au::{polynomial::Poly, Discretization, RadiansPerSecond, Seconds, Tf, Tfz};
use au::num_complex::Complex64;
let tf = Tf::new(
    Poly::new_from_coeffs(&[2.0_f32, 20.]),
    Poly::new_from_coeffs(&[1., 0.1]),
);
let tfz = tf.discretize_with_warp(Seconds(1.), RadiansPerSecond(0.1));
assert_eq!(-0.6668982, tfz.real_poles().unwrap()[0]);

impl<T: Float, U: Time> TfGen<T, U>[src]

#[must_use]pub fn new(num: Poly<T>, den: Poly<T>) -> Self[src]

Create a new transfer function given its numerator and denominator

Arguments

  • num - Transfer function numerator
  • den - Transfer function denominator

Example

use au::{poly, Tfz};
let tfz = Tfz::new(poly!(1., 2.), poly!(-4., 6., -2.));

#[must_use]pub fn relative_degree(&self) -> i32[src]

Calculate the relative degree between denominator and numerator.

Example

use au::{num_traits::Inv, poly, Tfz};
let tfz = Tfz::new(poly!(1., 2.), poly!(-4., 6., -2.));
let expected = tfz.relative_degree();
assert_eq!(expected, 1);
assert_eq!(tfz.inv().relative_degree(), -1);

impl<T, U: Time> TfGen<T, U>[src]

#[must_use]pub fn num(&self) -> &Poly<T>[src]

Extract transfer function numerator

Example

use au::{poly, Tfz};
let num = poly!(1., 2.);
let tfz = Tfz::new(num.clone(), poly!(-4., 6., -2.));
assert_eq!(&num, tfz.num());

#[must_use]pub fn den(&self) -> &Poly<T>[src]

Extract transfer function denominator

Example

use au::{poly, Tfz};
let den = poly!(-4., 6., -2.);
let tfz = Tfz::new(poly!(1., 2.), den.clone());
assert_eq!(&den, tfz.den());

impl<T, U: Time> TfGen<T, U>[src]

pub fn inv_mut(&mut self)[src]

Compute the reciprocal of a transfer function in place.

impl<T: Float + RealField, U: Time> TfGen<T, U>[src]

#[must_use]pub fn real_poles(&self) -> Option<Vec<T>>[src]

Calculate the poles of the transfer function

#[must_use]pub fn complex_poles(&self) -> Vec<Complex<T>>[src]

Calculate the poles of the transfer function

#[must_use]pub fn real_zeros(&self) -> Option<Vec<T>>[src]

Calculate the zeros of the transfer function

#[must_use]pub fn complex_zeros(&self) -> Vec<Complex<T>>[src]

Calculate the zeros of the transfer function

impl<T: Float, U: Time> TfGen<T, U>[src]

#[must_use]pub fn feedback_n(&self) -> Self[src]

Negative feedback.

          L(s)
G(s) = ----------
        1 + L(s)

where self = L(s)

#[must_use]pub fn feedback_p(&self) -> Self[src]

Positive feedback

          L(s)
G(s) = ----------
        1 - L(s)

where self = L(s)

#[must_use]pub fn normalize(&self) -> Self[src]

Normalization of transfer function. If the denominator is zero the same transfer function is returned.

from:

       b_n*z^n + b_(n-1)*z^(n-1) + ... + b_1*z + b_0
G(z) = ---------------------------------------------
       a_n*z^n + a_(n-1)*z^(n-1) + ... + a_1*z + a_0

to:

       b'_n*z^n + b'_(n-1)*z^(n-1) + ... + b'_1*z + b'_0
G(z) = -------------------------------------------------
         z^n + a'_(n-1)*z^(n-1) + ... + a'_1*z + a'_0

Example

use au::{poly, Tfz};
let tfz = Tfz::new(poly!(1., 2.), poly!(-4., 6., -2.));
let expected = Tfz::new(poly!(-0.5, -1.), poly!(2., -3., 1.));
assert_eq!(expected, tfz.normalize());

pub fn normalize_mut(&mut self)[src]

In place normalization of transfer function. If the denominator is zero no operation is done.

from:

       b_n*z^n + b_(n-1)*z^(n-1) + ... + b_1*z + b_0
G(z) = ---------------------------------------------
       a_n*z^n + a_(n-1)*z^(n-1) + ... + a_1*z + a_0

to:

       b'_n*z^n + b'_(n-1)*z^(n-1) + ... + b'_1*z + b'_0
G(z) = -------------------------------------------------
         z^n + a'_(n-1)*z^(n-1) + ... + a'_1*z + a'_0

Example

use au::{poly, Tfz};
let mut tfz = Tfz::new(poly!(1., 2.), poly!(-4., 6., -2.));
tfz.normalize_mut();
let expected = Tfz::new(poly!(-0.5, -1.), poly!(2., -3., 1.));
assert_eq!(expected, tfz);

impl<U: Time> TfGen<f64, U>[src]

pub fn new_from_siso(ss: &SsGen<f64, U>) -> Result<Self, Error>[src]

Convert a state-space representation into transfer functions. Conversion is available for Single Input Single Output system. If fails if the system is not SISO

Arguments

ss - state space linear system

Errors

It returns an error if the linear system is not single input single output.

impl<U: Time> TfGen<f32, U>[src]

pub fn new_from_siso(ss: &SsGen<f32, U>) -> Result<Self, Error>[src]

Convert a state-space representation into transfer functions. Conversion is available for Single Input Single Output system. If fails if the system is not SISO

Arguments

ss - state space linear system

Errors

It returns an error if the linear system is not single input single output.

impl<T: Clone, U: Time> TfGen<T, U>[src]

pub fn eval_by_val<N>(&self, s: N) -> N where
    N: Add<T, Output = N> + Clone + Div<Output = N> + Mul<Output = N> + Zero
[src]

Evaluate the transfer function.

Arguments

  • s - Value at which the transfer function is evaluated.

Example

use au::{poly, Tf};
use au::num_complex::Complex as C;
let tf = Tf::new(poly!(1., 2., 3.), poly!(-4., -3., 1.));
assert_eq!(-8.5, tf.eval_by_val(3.));
assert_eq!(C::new(0.64, -0.98), tf.eval_by_val(C::new(0., 2.0_f32)));

impl<T, U: Time> TfGen<T, U>[src]

pub fn eval<'a, N>(&'a self, s: &'a N) -> N where
    T: 'a,
    N: 'a + Add<&'a T, Output = N> + Div<Output = N> + Mul<&'a N, Output = N> + Zero
[src]

Evaluate the transfer function.

Arguments

  • s - Value at which the transfer function is evaluated.

Example

use au::{poly, Tf};
use au::num_complex::Complex as C;
let tf = Tf::new(poly!(1., 2., 3.), poly!(-4., -3., 1.));
assert_eq!(-8.5, tf.eval(&3.));
assert_eq!(C::new(0.64, -0.98), tf.eval(&C::new(0., 2.0_f32)));

Trait Implementations

impl<T: Float, U: Time> Add<&'_ T> for TfGen<T, U>[src]

Implementation of transfer function addition

type Output = Self

The resulting type after applying the + operator.

impl<T: Float, U: Time> Add<&'_ TfGen<T, U>> for &TfGen<T, U>[src]

Implementation of transfer function addition

type Output = TfGen<T, U>

The resulting type after applying the + operator.

impl<T: Float, U: Time> Add<T> for TfGen<T, U>[src]

Implementation of transfer function addition

type Output = Self

The resulting type after applying the + operator.

impl<T: Float, U: Time> Add<TfGen<T, U>> for TfGen<T, U>[src]

Implementation of transfer function addition

type Output = Self

The resulting type after applying the + operator.

impl<T: Clone, U: Clone + Time> Clone for TfGen<T, U>[src]

impl<T: Debug, U: Debug + Time> Debug for TfGen<T, U>[src]

impl<T, U> Display for TfGen<T, U> where
    T: Display + One + PartialEq + PartialOrd + Signed + Zero,
    U: Time
[src]

Implementation of transfer function printing

impl<T: Float, U: Time> Div<&'_ TfGen<T, U>> for &TfGen<T, U>[src]

Implementation of transfer function division

type Output = TfGen<T, U>

The resulting type after applying the / operator.

impl<T: Float, U: Time> Div<TfGen<T, U>> for TfGen<T, U>[src]

Implementation of transfer function division

type Output = Self

The resulting type after applying the / operator.

impl<T: Clone, U: Time> Inv for &TfGen<T, U>[src]

type Output = TfGen<T, U>

The result after applying the operator.

fn inv(self) -> Self::Output[src]

Compute the reciprocal of a transfer function.

impl<T: Clone, U: Time> Inv for TfGen<T, U>[src]

type Output = Self

The result after applying the operator.

fn inv(self) -> Self::Output[src]

Compute the reciprocal of a transfer function.

impl<T: Float, U: Time> Mul<&'_ TfGen<T, U>> for &TfGen<T, U>[src]

Implementation of transfer function multiplication

type Output = TfGen<T, U>

The resulting type after applying the * operator.

impl<T: Float, U: Time> Mul<&'_ TfGen<T, U>> for TfGen<T, U>[src]

Implementation of transfer function multiplication

type Output = Self

The resulting type after applying the * operator.

impl<T: Float, U: Time> Mul<TfGen<T, U>> for TfGen<T, U>[src]

Implementation of transfer function multiplication

type Output = Self

The resulting type after applying the * operator.

impl<T: Float, U: Time> Neg for &TfGen<T, U>[src]

Implementation of transfer function negation. Negative sign is transferred to the numerator.

type Output = TfGen<T, U>

The resulting type after applying the - operator.

impl<T: Float, U: Time> Neg for TfGen<T, U>[src]

Implementation of transfer function negation. Negative sign is transferred to the numerator.

type Output = Self

The resulting type after applying the - operator.

impl<T: PartialEq, U: PartialEq + Time> PartialEq<TfGen<T, U>> for TfGen<T, U>[src]

impl<T, U: Time> StructuralPartialEq for TfGen<T, U>[src]

impl<T: Float, U: Time> Sub<&'_ TfGen<T, U>> for &TfGen<T, U>[src]

Implementation of transfer function subtraction

type Output = TfGen<T, U>

The resulting type after applying the - operator.

impl<T: Float, U: Time> Sub<TfGen<T, U>> for TfGen<T, U>[src]

Implementation of transfer function subtraction

type Output = Self

The resulting type after applying the - operator.

impl<T: Float, U: Time> Zero for TfGen<T, U>[src]

Auto Trait Implementations

impl<T, U> RefUnwindSafe for TfGen<T, U> where
    T: RefUnwindSafe,
    U: RefUnwindSafe

impl<T, U> Send for TfGen<T, U> where
    T: Send,
    U: Send

impl<T, U> Sync for TfGen<T, U> where
    T: Sync,
    U: Sync

impl<T, U> Unpin for TfGen<T, U> where
    T: Unpin,
    U: Unpin

impl<T, U> UnwindSafe for TfGen<T, U> where
    T: UnwindSafe,
    U: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> ClosedNeg for T where
    T: Neg<Output = T>, 

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<SS, SP> SupersetOf<SS> for SP where
    SS: SubsetOf<SP>, 

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,