Skip to content

Commit 2e97e17

Browse files
committed
Remove Tustin discretization
1 parent 65bb4d7 commit 2e97e17

3 files changed

Lines changed: 2 additions & 66 deletions

File tree

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
- Checked model constructors with typed errors (`ModelError`)
1010
- Continuous-to-discrete conversion with explicit methods:
1111
- ZOH
12-
- Tustin
1312
- Time-domain simulation with full output equation `y = Cx + Du`
1413
- Controllability and observability analysis
1514
- Stability checks and rank diagnostics
@@ -46,7 +45,6 @@ assert!(is_ctrb);
4645
`DiscreteStateSpaceModel` has explicit conversion methods:
4746

4847
- `from_continuous_zoh`: exact ZOH (recommended default)
49-
- `from_continuous_tustin`: bilinear transform
5048

5149
Use ZOH by default for sampled-data systems with held inputs.
5250

src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ assert!(is_controllable);
3333
`DiscreteStateSpaceModel` provides explicit conversion APIs:
3434
3535
- `from_continuous_zoh`: exact ZOH using augmented matrix exponential.
36-
- `from_continuous_tustin`: bilinear transform.
3736
3837
Recommended default is ZOH for sampled-data systems driven by held inputs.
3938
*/

src/model.rs

Lines changed: 2 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
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
1314
extern 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

433388
impl 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

Comments
 (0)