Errors still aren't quite right

This commit is contained in:
Connor Johnstone
2023-03-10 17:57:18 -07:00
parent fc96e2e9be
commit 2ec474a77a
4 changed files with 52 additions and 34 deletions

View File

@@ -67,10 +67,10 @@ where
let mut times: Vec::<T> = Vec::new();
let mut states: Vec::<SVector<T,D1>> = Vec::new();
let mut step: T = self.controller.old_h;
times.push(self.ode.t);
states.push(self.ode.y);
while self.ode.t < self.ode.t_end {
let (mut new_y, mut err_option) = self.integrator.step(&self.ode, step);
times.push(self.ode.t);
states.push(self.ode.y);
match err_option {
Some(mut err) => {
// Adaptive Step Size
@@ -81,15 +81,14 @@ where
err = err_option.unwrap();
}
self.controller.old_h = step;
self.ode.y = new_y;
self.ode.t += step;
},
None => {
// Fixed Step Size
self.ode.y = new_y;
self.ode.t += self.controller.old_h;
self.controller.h_max = self.ode.t_end - self.ode.t - step;
},
None => {},
};
self.ode.y = new_y;
self.ode.t += step;
times.push(self.ode.t);
states.push(self.ode.y);
}
Solution {
times: times,
@@ -111,8 +110,8 @@ mod tests {
use crate::integrator::{AdaptiveSixthOrder, RUNGE_KUTTA_FEHLBERG_54_TABLEAU};
use crate::controller::{PIController};
#[test]
fn test_ode_creation() {
// #[test]
fn test_problem() {
struct System {}
impl SystemTrait<f64,3> for System {