pub struct FrequencyTransferFunction<T> { /* private fields */ }Expand description
Frequency transfer function ω [rad/s] -> G(jω).
Built from a TransferFunction (s = jω / z = e^{jωTs}) or from any closure,
so that elements without a rational form (e.g. dead time e^{-jωL}) can also be handled.
use dsmc::{tf, BodeDiagramPlotter, NyquistPlotter};
// Second-order low-pass filter, 10 Hz
let wn = 2.0 * std::f64::consts::PI * 10.0;
let g = tf!("{} / (s^2 + {} s + {})", wn * wn, 1.4 * wn, wn * wn);
let g_jw = g.frequency_transfer_function();
// Bode diagram from 1 Hz to 100 Hz (gain in dB) and Nyquist plot
let bode = BodeDiagramPlotter::<f64>::new(1.0, 100.0, 1.0, true).plot(&g_jw);
let nyquist = NyquistPlotter::<f64>::new(1.0, 100.0, 1.0).plot(&g_jw);
assert_eq!(bode.len(), nyquist.len());Implementations§
Source§impl<T: Float + FloatConst + 'static> FrequencyTransferFunction<T>
impl<T: Float + FloatConst + 'static> FrequencyTransferFunction<T>
Sourcepub fn new(response: impl Fn(T) -> Complex<T> + 'static) -> Self
pub fn new(response: impl Fn(T) -> Complex<T> + 'static) -> Self
From any omega [rad/s] -> G(jω) closure, e.g. a dead time |w| Complex::new(0.0, -w * l).exp().
Sourcepub fn inverse(&self) -> Self
pub fn inverse(&self) -> Self
Inverse 1 / G(jω), e.g. the input shape that flattens the output of G.
Sourcepub fn characteristics<U: FrequencyUnit>(
&self,
frequency: T,
log_scale: bool,
) -> FrequencyCharacteristics<T, U>
pub fn characteristics<U: FrequencyUnit>( &self, frequency: T, log_scale: bool, ) -> FrequencyCharacteristics<T, U>
Gain (in dB if log_scale, otherwise the magnitude) and phase [rad] at frequency given in U.
Sourcepub fn characteristics_fn<U: FrequencyUnit>(
&self,
log_scale: bool,
) -> impl Fn(T) -> FrequencyCharacteristics<T, U> + '_
pub fn characteristics_fn<U: FrequencyUnit>( &self, log_scale: bool, ) -> impl Fn(T) -> FrequencyCharacteristics<T, U> + '_
|frequency| -> FrequencyCharacteristics closure (see characteristics).
Trait Implementations§
Source§impl<T> Clone for FrequencyTransferFunction<T>
impl<T> Clone for FrequencyTransferFunction<T>
Source§impl<T> From<&FrequencyTransferFunction<T>> for FrequencyTransferFunction<T>
impl<T> From<&FrequencyTransferFunction<T>> for FrequencyTransferFunction<T>
Source§fn from(g: &FrequencyTransferFunction<T>) -> Self
fn from(g: &FrequencyTransferFunction<T>) -> Self
Converts to this type from the input type.
Source§impl<T: Float + FloatConst + 'static> From<&TransferFunction<T>> for FrequencyTransferFunction<T>
impl<T: Float + FloatConst + 'static> From<&TransferFunction<T>> for FrequencyTransferFunction<T>
Source§fn from(tf: &TransferFunction<T, Continuous>) -> Self
fn from(tf: &TransferFunction<T, Continuous>) -> Self
Converts to this type from the input type.
Source§impl<T: Float + FloatConst + 'static> From<&TransferFunctionWithDelay<T>> for FrequencyTransferFunction<T>
impl<T: Float + FloatConst + 'static> From<&TransferFunctionWithDelay<T>> for FrequencyTransferFunction<T>
Source§fn from(g: &TransferFunctionWithDelay<T>) -> Self
fn from(g: &TransferFunctionWithDelay<T>) -> Self
Converts to this type from the input type.
Source§impl<T: Float + FloatConst + 'static> From<TransferFunction<T>> for FrequencyTransferFunction<T>
impl<T: Float + FloatConst + 'static> From<TransferFunction<T>> for FrequencyTransferFunction<T>
Source§fn from(tf: TransferFunction<T, Continuous>) -> Self
fn from(tf: TransferFunction<T, Continuous>) -> Self
Converts to this type from the input type.
Source§impl<T: Float + FloatConst + 'static> From<TransferFunctionWithDelay<T>> for FrequencyTransferFunction<T>
impl<T: Float + FloatConst + 'static> From<TransferFunctionWithDelay<T>> for FrequencyTransferFunction<T>
Source§fn from(g: TransferFunctionWithDelay<T>) -> Self
fn from(g: TransferFunctionWithDelay<T>) -> Self
Converts to this type from the input type.
Source§impl<T: Float + FloatConst + 'static> Mul for FrequencyTransferFunction<T>
Series connection G1(jω) G2(jω), e.g. a continuous plant with a discrete controller.
impl<T: Float + FloatConst + 'static> Mul for FrequencyTransferFunction<T>
Series connection G1(jω) G2(jω), e.g. a continuous plant with a discrete controller.
Source§impl<T: Float + FloatConst + 'static> Mul for &FrequencyTransferFunction<T>
impl<T: Float + FloatConst + 'static> Mul for &FrequencyTransferFunction<T>
Source§type Output = FrequencyTransferFunction<T>
type Output = FrequencyTransferFunction<T>
The resulting type after applying the
* operator.Source§fn mul(self, rhs: Self) -> FrequencyTransferFunction<T>
fn mul(self, rhs: Self) -> FrequencyTransferFunction<T>
Performs the
* operation. Read moreAuto Trait Implementations§
impl<T> !RefUnwindSafe for FrequencyTransferFunction<T>
impl<T> !Send for FrequencyTransferFunction<T>
impl<T> !Sync for FrequencyTransferFunction<T>
impl<T> !UnwindSafe for FrequencyTransferFunction<T>
impl<T> Freeze for FrequencyTransferFunction<T>
impl<T> Unpin for FrequencyTransferFunction<T>
impl<T> UnsafeUnpin for FrequencyTransferFunction<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.