Struct rgsl::types::ordinary_differential_equations::ODEiv2Evolve
source · pub struct ODEiv2Evolve { /* private fields */ }
Implementations§
source§impl ODEiv2Evolve
impl ODEiv2Evolve
sourcepub fn new(dim: usize) -> Option<ODEiv2Evolve>
pub fn new(dim: usize) -> Option<ODEiv2Evolve>
This function returns a pointer to a newly allocated instance of an evolution function for a system of dim dimensions.
sourcepub fn apply(
&mut self,
c: &mut ODEiv2Control,
s: &mut ODEiv2Step,
sys: &mut ODEiv2System<'_>,
t: &mut f64,
t1: f64,
h: &mut f64,
y: &mut [f64]
) -> Result<(), Value>
pub fn apply( &mut self, c: &mut ODEiv2Control, s: &mut ODEiv2Step, sys: &mut ODEiv2System<'_>, t: &mut f64, t1: f64, h: &mut f64, y: &mut [f64] ) -> Result<(), Value>
This function advances the system (e, sys) from time t and position y using the stepping function step. The new time and position are stored in t and y on output.
The initial step-size is taken as h. The control function con is applied to check whether the local error estimated by the stepping function step using step-size h exceeds the required error tolerance. If the error is too high, the step is retried by calling step with a decreased step-size. This process is continued until an acceptable step-size is found. An estimate of the local error for the step can be obtained from the components of the array e->yerr[].
If the user-supplied functions defined in the system sys returns Value::BadFunc, the function returns immediately with the same return code. In this case the user must call gsl_odeiv2_step_reset and gsl_odeiv2_evolve_reset before calling this function again.
Otherwise, if the user-supplied functions defined in the system sys or the stepping function step return a status other than crate::Value::Success, the step is retried with a decreased step-size. If the step-size decreases below machine precision, a status of ::Failuer is returned if the user functions returned crate::Value::Success. Otherwise the value returned by user function is returned. If no acceptable step can be made, t and y will be restored to their pre-step values and h contains the final attempted step-size.
If the step is successful the function returns a suggested step-size for the next step in h. The maximum time t1 is guaranteed not to be exceeded by the time-step. On the final time-step the value of t will be set to t1 exactly.
sourcepub fn apply_fixed_step(
&mut self,
c: &mut ODEiv2Control,
s: &mut ODEiv2Step,
sys: &mut ODEiv2System<'_>,
t: &mut f64,
h: f64,
y: &mut [f64]
) -> Result<(), Value>
pub fn apply_fixed_step( &mut self, c: &mut ODEiv2Control, s: &mut ODEiv2Step, sys: &mut ODEiv2System<'_>, t: &mut f64, h: f64, y: &mut [f64] ) -> Result<(), Value>
This function advances the ODE-system (e, sys, con) from time t and position y using the stepping function step by a specified step size h. If the local error estimated by the stepping function exceeds the desired error level, the step is not taken and the function returns Value::Failure. Otherwise the value returned by user function is returned.
sourcepub fn reset(&mut self) -> Result<(), Value>
pub fn reset(&mut self) -> Result<(), Value>
This function resets the evolution function e. It should be used whenever the next use of e will not be a continuation of a previous step.
sourcepub fn set_driver(&mut self, d: &ODEiv2Driver<'_>) -> Result<(), Value>
pub fn set_driver(&mut self, d: &ODEiv2Driver<'_>) -> Result<(), Value>
This function sets a pointer of the driver object d for evolve object e.
If a system has discontinuous changes in the derivatives at known points, it is advisable to evolve the system between each discontinuity in sequence. For example, if a step-change in an external driving force occurs at times t_a, t_b and t_c then evolution should be carried out over the ranges (t_0,t_a), (t_a,t_b), (t_b,t_c), and (t_c,t_1) separately and not directly over the range (t_0,t_1).