88//! It also provides multiple continuous-to-discrete conversion methods:
99//!
1010//! - Exact ZOH (augmented matrix exponential)
11- //! - Tustin (bilinear transform)
11+ //! The library intentionally exposes a small discretization surface for now:
12+ //! exact ZOH.
1213
1314extern crate nalgebra as na;
1415
@@ -366,36 +367,6 @@ impl DiscreteStateSpaceModel {
366367 Self :: try_from_matrices ( & mat_a, & mat_b, mat_cc, mat_dc, sampling_dt)
367368 }
368369
369- /// Discretizes a continuous model using the bilinear/Tustin transform.
370- ///
371- /// This corresponds to:
372- ///
373- /// - `A_d = (I - A*dt/2)^-1 * (I + A*dt/2)`
374- /// - `B_d = (I - A*dt/2)^-1 * B*dt`
375- ///
376- /// It requires inversion of `I - A*dt/2`.
377- pub fn from_continuous_matrix_tustin (
378- mat_ac : & na:: DMatrix < f64 > ,
379- mat_bc : & na:: DMatrix < f64 > ,
380- mat_cc : & na:: DMatrix < f64 > ,
381- mat_dc : & na:: DMatrix < f64 > ,
382- sampling_dt : f64 ,
383- ) -> Result < DiscreteStateSpaceModel , ModelError > {
384- validate_state_space_dimensions ( mat_ac, mat_bc, mat_cc, mat_dc) ?;
385- validate_sampling_dt ( sampling_dt) ?;
386-
387- let mat_i = na:: DMatrix :: < f64 > :: identity ( mat_ac. nrows ( ) , mat_ac. nrows ( ) ) ;
388- let left = mat_i. clone ( ) - mat_ac. scale ( 0.5 * sampling_dt) ;
389- let inv_left = left
390- . try_inverse ( )
391- . ok_or ( ModelError :: SingularMatrix ( "I - A*dt/2 for Tustin" ) ) ?;
392-
393- let mat_a = & inv_left * ( mat_i + mat_ac. scale ( 0.5 * sampling_dt) ) ;
394- let mat_b = inv_left * mat_bc. scale ( sampling_dt) ;
395-
396- Self :: try_from_matrices ( & mat_a, & mat_b, mat_cc, mat_dc, sampling_dt)
397- }
398-
399370 /// Discretizes a continuous model using exact ZOH.
400371 ///
401372 /// See [`DiscreteStateSpaceModel::from_continuous_matrix_zoh`] for equations.
@@ -412,22 +383,6 @@ impl DiscreteStateSpaceModel {
412383 )
413384 }
414385
415- /// Discretizes a continuous model using Tustin.
416- ///
417- /// See [`DiscreteStateSpaceModel::from_continuous_matrix_tustin`] for equations.
418- pub fn from_continuous_tustin (
419- model : & ContinuousStateSpaceModel ,
420- sampling_dt : f64 ,
421- ) -> Result < DiscreteStateSpaceModel , ModelError > {
422- Self :: from_continuous_matrix_tustin (
423- model. mat_a ( ) ,
424- model. mat_b ( ) ,
425- model. mat_c ( ) ,
426- model. mat_d ( ) ,
427- sampling_dt,
428- )
429- }
430-
431386}
432387
433388impl Pole for DiscreteStateSpaceModel {
@@ -619,22 +574,6 @@ mod tests {
619574 assert_eq ! ( ss_model. mat_d( ) [ ( 0 , 0 ) ] , 8.0f64 ) ;
620575 }
621576
622- // Verifies Tustin discretization against first-order analytic values.
623- #[ test]
624- fn test_discretization_tustin_first_order ( ) {
625- let a = na:: dmatrix![ -2.0 ] ;
626- let b = na:: dmatrix![ 1.0 ] ;
627- let c = na:: dmatrix![ 1.0 ] ;
628- let d = na:: dmatrix![ 0.0 ] ;
629- let dt = 0.1 ;
630-
631- let model =
632- DiscreteStateSpaceModel :: from_continuous_matrix_tustin ( & a, & b, & c, & d, dt) . unwrap ( ) ;
633-
634- approx_eq_matrix ( model. mat_a ( ) , & na:: dmatrix![ 0.8181818181818182 ] , 1e-12 ) ;
635- approx_eq_matrix ( model. mat_b ( ) , & na:: dmatrix![ 0.09090909090909091 ] , 1e-12 ) ;
636- }
637-
638577 // Verifies ZOH discretization against first-order exact discretization values.
639578 #[ test]
640579 fn test_discretization_zoh_first_order ( ) {
0 commit comments