differential_equations/methods/apc/
mod.rs1mod apcf4;
4mod apcv4;
5
6use std::marker::PhantomData;
7
8use crate::{
9 status::Status,
10 traits::{CallBackData, Real, State},
11};
12
13pub struct AdamsPredictorCorrector<E, F, T: Real, Y: State<T>, D: CallBackData, const S: usize> {
14 pub h0: T,
16
17 h: T,
19
20 t: T,
22 y: Y,
23 dydt: Y,
24
25 tf: T,
27
28 t_prev: [T; S],
30 y_prev: [Y; S],
31
32 t_old: T,
34 y_old: Y,
35 dydt_old: Y,
36
37 k: [Y; S],
39
40 evals: usize,
42 steps: usize,
43
44 status: Status<T, Y, D>,
46
47 pub tol: T,
49 pub h_max: T,
50 pub h_min: T,
51 pub max_steps: usize,
52
53 pub stages: usize,
55
56 family: PhantomData<F>,
58
59 equation: PhantomData<E>,
61}
62
63impl<E, F, T: Real, Y: State<T>, D: CallBackData, const S: usize> Default
64 for AdamsPredictorCorrector<E, F, T, Y, D, S>
65{
66 fn default() -> Self {
67 Self {
68 h0: T::zero(),
69 h: T::zero(),
70 t: T::zero(),
71 y: Y::zeros(),
72 dydt: Y::zeros(),
73 t_prev: [T::zero(); S],
74 y_prev: [Y::zeros(); S],
75 t_old: T::zero(),
76 y_old: Y::zeros(),
77 dydt_old: Y::zeros(),
78 k: [Y::zeros(); S],
79 tf: T::zero(),
80 evals: 0,
81 steps: 0,
82 status: Status::Uninitialized,
83 tol: T::from_f64(1.0e-6).unwrap(),
84 h_max: T::infinity(),
85 h_min: T::zero(),
86 max_steps: 10_000,
87 stages: S,
88 family: PhantomData,
89 equation: PhantomData,
90 }
91 }
92}
93
94impl<E, F, T: Real, Y: State<T>, D: CallBackData, const S: usize>
95 AdamsPredictorCorrector<E, F, T, Y, D, S>
96{
97 pub fn tol(mut self, rtol: T) -> Self {
99 self.tol = rtol;
100 self
101 }
102
103 pub fn h0(mut self, h0: T) -> Self {
105 self.h0 = h0;
106 self
107 }
108
109 pub fn h_min(mut self, h_min: T) -> Self {
111 self.h_min = h_min;
112 self
113 }
114
115 pub fn h_max(mut self, h_max: T) -> Self {
117 self.h_max = h_max;
118 self
119 }
120
121 pub fn max_steps(mut self, max_steps: usize) -> Self {
123 self.max_steps = max_steps;
124 self
125 }
126
127 pub fn stages(&self) -> usize {
129 self.stages
130 }
131}