37 virtual adoreMatrix<T>
solve(
AOdeModel<T>* model,
const adoreMatrix<double, 1, 0>& time,
const adoreMatrix<double, 0, 1>&
x0)
override
41 adoreMatrix<T> result(n, m);
42 adoreMatrix<T, 0, 1> k1(n, 1);
43 adoreMatrix<T, 0, 1> k2(n, 1);
44 adoreMatrix<T, 0, 1> k3(n, 1);
45 adoreMatrix<T, 0, 1> k4(n, 1);
46 result.set_size(n, m);
47 set_colm(result, 0) =
x0;
48 for (
int i = 1; i < m; i++)
50 T dt = time(i) - time(i - 1);
51 model->
f(time(i - 1), colm(result, i - 1), k1);
52 model->
f(time(i - 1) + dt / (T)2, colm(result, i - 1) + (dt / (T)2)*k1, k2);
53 model->
f(time(i - 1) + dt / (T)2, colm(result, i - 1) + (dt / (T)2)*k2, k3);
54 model->
f(time(i - 1) + dt, colm(result, i - 1) + dt*k3, k4);
55 set_colm(result, i) = colm(result, i - 1) + dt / (T)6 * (k1 + k2*(T)2 + k3*(T)2 + k4);
63 adoreMatrix<T> result(n, m);
64 adoreMatrix<T, 0, 1> k1(n, 1);
65 adoreMatrix<T, 0, 1> k2(n, 1);
66 adoreMatrix<T, 0, 1> k3(n, 1);
67 adoreMatrix<T, 0, 1> k4(n, 1);
68 adoreMatrix<T, 0, 1>
y(Y_out.nr(),1);
69 result.set_size(n, m);
70 set_colm(result, 0) =
x0;
71 for (
int i = 1; i < m; i++)
73 T dt = time(i) - time(i - 1);
74 model->
fh(time(i - 1), colm(result, i - 1), k1,
y);
75 set_colm(Y_out, i - 1) =
y;
76 model->
fh(time(i - 1) + dt / (T)2, colm(result, i - 1) + (dt / (T)2)*k1, k2,
y);
77 model->
fh(time(i - 1) + dt / (T)2, colm(result, i - 1) + (dt / (T)2)*k2, k3,
y);
78 model->
fh(time(i - 1) + dt, colm(result, i - 1) + (dt / (T)2)*k1, k4,
y);
79 set_colm(result, i) = colm(result, i - 1) + dt / (T)6 * (k1 + k2*(T)2 + k3*(T)2 + k4);
82 model->
fh(time(m - 1), colm(result, m - 1), k1,
y);
83 set_colm(Y_out, m - 1) =
y;
Definition: aodemodel.h:53
virtual void fh(T t, const adoreMatrix< T, 0, 1 > &x_in, adoreMatrix< T, 0, 1 > &dx_out, adoreMatrix< T, 0, 1 > &y_out)=0
Definition: aodemodel.h:30
virtual void f(T t, const adoreMatrix< T, 0, 1 > &x_in, adoreMatrix< T, 0, 1 > &dx_out)=0
Definition: aodesolver.h:28
virtual adoreMatrix< T > solve(AOdeModel< T > *model, const adoreMatrix< double, 1, 0 > &time, const adoreMatrix< double, 0, 1 > &x0) override
Definition: oderk4.h:37
OdeRK4()
Definition: oderk4.h:31
virtual ~OdeRK4()
Definition: oderk4.h:34
virtual adoreMatrix< T > solve_with_output(AOdeModelWithOutput< T > *model, const adoreMatrix< double, 1, 0 > &time, const adoreMatrix< double, 0, 1 > &x0, adoreMatrix< double > &Y_out) override
Definition: oderk4.h:59
x0
Definition: adore_set_goal.py:25
y
Definition: adore_set_goal.py:31
Definition: areaofeffectconverter.h:20