-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
clv.rs
31 lines (28 loc) · 931 Bytes
/
clv.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//! Calculate Covariant Lyapunov Vector
//!
//! This function consumes much memory since this saves matrices duraing the time evolution.
use ndarray::*;
use std::io::Write;
use eom::*;
fn main() {
let dt = 0.01;
let eom = ode::Lorenz63::default();
let teo = explicit::RK4::new(eom, dt);
let duration = 100000;
let ts = lyapunov::vectors(teo, arr1(&[1.0, 0.0, 0.0]), 1e-7, duration);
let mut l = Array::zeros(3);
println!("v0v1, v0v2, v1v2");
for (_x, v, f) in ts.into_iter().rev() {
let v0 = v.axis_iter(Axis(1)).next().unwrap();
let v1 = v.axis_iter(Axis(1)).nth(1).unwrap();
let v2 = v.axis_iter(Axis(1)).nth(2).unwrap();
println!("{}, {}, {}", v0.dot(&v1), v0.dot(&v2), v1.dot(&v2));
l += &f.map(|x| x.abs().ln());
}
writeln!(
&mut std::io::stderr(),
"exponents = {:?}",
l / (dt * duration as f64)
)
.unwrap();
}