differential_equations/methods/apc/
mod.rs1mod apcv4;
4mod apcf4;
5
6use crate::{
7 Status,
8 traits::{CallBackData, Real, State},
9};
10use std::{
11 marker::PhantomData
12};
13
14pub struct AdamsPredictorCorrector<E, F, T: Real, V: State<T>, D: CallBackData, const S: usize> {
15 pub h0: T,
17
18 h: T,
20
21 t: T,
23 y: V,
24 dydt: V,
25
26 tf: T,
28
29 t_prev: [T; S],
31 y_prev: [V; S],
32
33 t_old: T,
35 y_old: V,
36 dydt_old: V,
37
38 k: [V; S],
40
41 evals: usize,
43 steps: usize,
44
45 status: Status<T, V, D>,
47
48 pub tol: T,
50 pub h_max: T,
51 pub h_min: T,
52 pub max_steps: usize,
53
54 pub stages: usize,
56
57 family: PhantomData<F>,
59
60 equation: PhantomData<E>,
62}
63
64impl<E, F, T: Real, V: State<T>, D: CallBackData, const S: usize> Default for AdamsPredictorCorrector<E, F, T, V, D, S> {
65 fn default() -> Self {
66 Self {
67 h0: T::zero(),
68 h: T::zero(),
69 t: T::zero(),
70 y: V::zeros(),
71 dydt: V::zeros(),
72 t_prev: [T::zero(); S],
73 y_prev: [V::zeros(); S],
74 t_old: T::zero(),
75 y_old: V::zeros(),
76 dydt_old: V::zeros(),
77 k: [V::zeros(); S],
78 tf: T::zero(),
79 evals: 0,
80 steps: 0,
81 status: Status::Uninitialized,
82 tol: T::from_f64(1.0e-6).unwrap(),
83 h_max: T::infinity(),
84 h_min: T::zero(),
85 max_steps: 10_000,
86 stages: S,
87 family: PhantomData,
88 equation: PhantomData,
89 }
90 }
91}
92
93impl<E, F, T: Real, V: State<T>, D: CallBackData, const S: usize> AdamsPredictorCorrector<E, F, T, V, D, S> {
94 pub fn tol(mut self, rtol: T) -> Self {
96 self.tol = rtol;
97 self
98 }
99
100 pub fn h0(mut self, h0: T) -> Self {
102 self.h0 = h0;
103 self
104 }
105
106 pub fn h_min(mut self, h_min: T) -> Self {
108 self.h_min = h_min;
109 self
110 }
111
112 pub fn h_max(mut self, h_max: T) -> Self {
114 self.h_max = h_max;
115 self
116 }
117
118 pub fn max_steps(mut self, max_steps: usize) -> Self {
120 self.max_steps = max_steps;
121 self
122 }
123
124 pub fn stages(&self) -> usize {
126 self.stages
127 }
128}