|
1 | 1 | //! Explicit Runge-Kutta method with Dormand-Prince coefficients of order 8(5,3) and dense output of order 7. |
2 | 2 |
|
3 | 3 | use crate::butcher_tableau::dopri853; |
| 4 | +use crate::constants::{dense_output, initial_step, stiffness}; |
4 | 5 | use crate::controller::Controller; |
5 | 6 | use crate::dop_shared::*; |
6 | 7 |
|
@@ -210,11 +211,11 @@ where |
210 | 211 | } |
211 | 212 |
|
212 | 213 | // Compute h0 |
213 | | - let tol = T::from(1.0E-10).unwrap(); |
214 | | - let mut h0 = if d0 < tol || d1 < tol { |
215 | | - T::from(1.0E-6).unwrap() |
| 214 | + let tol = initial_step::min_tolerance(); |
| 215 | + let mut h0: T = if d0 < tol || d1 < tol { |
| 216 | + initial_step::default_initial_step() |
216 | 217 | } else { |
217 | | - T::from(0.01).unwrap() * (d0 / d1).sqrt() |
| 218 | + initial_step::safety_factor::<T>() * (d0 / d1).sqrt() |
218 | 219 | }; |
219 | 220 |
|
220 | 221 | h0 = h0.min(self.controller.h_max()); |
@@ -377,18 +378,18 @@ where |
377 | 378 | T::zero() |
378 | 379 | }; |
379 | 380 |
|
380 | | - if h_lamb > T::from(6.1).unwrap() { |
| 381 | + if h_lamb > stiffness::dop853_threshold() { |
381 | 382 | non_stiff = 0; |
382 | 383 | iasti += 1; |
383 | | - if iasti == 15 { |
| 384 | + if iasti == stiffness::MAX_STIFF_ITERATIONS { |
384 | 385 | self.h_old = self.h; |
385 | 386 | return Err(IntegrationError::StiffnessDetected { |
386 | 387 | x: f64::from(self.x), |
387 | 388 | }); |
388 | 389 | } |
389 | 390 | } else { |
390 | 391 | non_stiff += 1; |
391 | | - if non_stiff == 6 { |
| 392 | + if non_stiff == stiffness::NON_STIFF_RESET_COUNT { |
392 | 393 | iasti = 0; |
393 | 394 | } |
394 | 395 | } |
@@ -528,7 +529,7 @@ where |
528 | 529 | } |
529 | 530 |
|
530 | 531 | // Ensure the last point is added if it's within floating point error of x_end. |
531 | | - if (self.xd - self.x_end).abs() < T::from(1e-9).unwrap() { |
| 532 | + if (self.xd - self.x_end).abs() < dense_output::endpoint_tolerance() { |
532 | 533 | let theta = (self.x_end - self.x_old) / self.h_old; |
533 | 534 | let theta1 = T::one() - theta; |
534 | 535 | let y_out = self.compute_y_out(theta, theta1); |
|
0 commit comments