pub struct NyquistPlotter<T, U = Hz> { /* private fields */ }Expand description
Nyquist plot over [freq_from, freq_to) with step dfreq, all given in U (Hz by default).
Implementations§
Source§impl<T, U> NyquistPlotter<T, U>
impl<T, U> NyquistPlotter<T, U>
Sourcepub fn new(freq_from: T, freq_to: T, dfreq: T) -> Self
pub fn new(freq_from: T, freq_to: T, dfreq: T) -> Self
data_len = ceil((freq_to - freq_from) / dfreq) points starting at freq_from, in U.
Examples found in repository?
examples/nyquist.rs (line 24)
9fn main() {
10
11 let omega = 300.0;
12
13 let kp = 3.0 * omega * omega;
14 let kd = 3.0 * omega;
15 let ki = omega* omega * omega;
16
17 let iter = 10;
18 for i in 0..=iter {
19 let alpha = 0.8 + 0.4 / iter as f64 * i as f64;
20
21 let mut storage_n = DataStorage::new(format!("./out/nyquist/nyquist_alpha_{:.02}.csv", alpha)).unwrap();
22 let mut storage_b = DataStorage::new(format!("./out/bode/bode_alpha_{:.02}.csv", alpha)).unwrap();
23
24 let plotter_n = NyquistPlotter::<f64>::new(10.0, 2000.0, 0.01);
25 let plotter_b = BodeDiagramPlotter::<f64>::new(0.1, 1000.0, 0.01, true);
26
27 let tf_main = TransferFunction::continuous(&[alpha * kd, alpha * kp, alpha * ki], &[1.0, 0.0]);
28 let tf_pl = TransferFunction::continuous(&[1.0], &[1.0, 0.0, 0.0]);
29 let tf = tf_main * tf_pl;
30 {
31 let responses = plotter_n.plot(&tf);
32 for res in responses {
33 storage_n.add(&res).unwrap();
34 }
35 }
36 {
37 let responses = plotter_b.frequency_response_s(&tf);
38 for res in responses {
39 storage_b.add(&res).unwrap();
40 }
41 }
42
43 storage_n.close().unwrap();
44 storage_b.close().unwrap();
45 }
46
47}Sourcepub fn plot<G: Into<FrequencyTransferFunction<T>>>(
&self,
g: G,
) -> Vec<FrequencyResponse<T>>
pub fn plot<G: Into<FrequencyTransferFunction<T>>>( &self, g: G, ) -> Vec<FrequencyResponse<T>>
Calculate the vector locus of a frequency transfer function
(or anything convertible into one, such as a continuous TransferFunction).
omega of each point is in rad/s regardless of U.
Examples found in repository?
examples/nyquist.rs (line 31)
9fn main() {
10
11 let omega = 300.0;
12
13 let kp = 3.0 * omega * omega;
14 let kd = 3.0 * omega;
15 let ki = omega* omega * omega;
16
17 let iter = 10;
18 for i in 0..=iter {
19 let alpha = 0.8 + 0.4 / iter as f64 * i as f64;
20
21 let mut storage_n = DataStorage::new(format!("./out/nyquist/nyquist_alpha_{:.02}.csv", alpha)).unwrap();
22 let mut storage_b = DataStorage::new(format!("./out/bode/bode_alpha_{:.02}.csv", alpha)).unwrap();
23
24 let plotter_n = NyquistPlotter::<f64>::new(10.0, 2000.0, 0.01);
25 let plotter_b = BodeDiagramPlotter::<f64>::new(0.1, 1000.0, 0.01, true);
26
27 let tf_main = TransferFunction::continuous(&[alpha * kd, alpha * kp, alpha * ki], &[1.0, 0.0]);
28 let tf_pl = TransferFunction::continuous(&[1.0], &[1.0, 0.0, 0.0]);
29 let tf = tf_main * tf_pl;
30 {
31 let responses = plotter_n.plot(&tf);
32 for res in responses {
33 storage_n.add(&res).unwrap();
34 }
35 }
36 {
37 let responses = plotter_b.frequency_response_s(&tf);
38 for res in responses {
39 storage_b.add(&res).unwrap();
40 }
41 }
42
43 storage_n.close().unwrap();
44 storage_b.close().unwrap();
45 }
46
47}Auto Trait Implementations§
impl<T, U> Freeze for NyquistPlotter<T, U>
impl<T, U> RefUnwindSafe for NyquistPlotter<T, U>
impl<T, U> Send for NyquistPlotter<T, U>
impl<T, U> Sync for NyquistPlotter<T, U>
impl<T, U> Unpin for NyquistPlotter<T, U>
impl<T, U> UnsafeUnpin for NyquistPlotter<T, U>
impl<T, U> UnwindSafe for NyquistPlotter<T, U>
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<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.