forked from MatthewPeterKelly/RungeKuttaCpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRK_4B.cpp
48 lines (41 loc) · 1.04 KB
/
RK_4B.cpp
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <iostream>
#include "RK_4B.h"
#include "integrator.h"
using namespace std;
/* 4th-Order Explicit "3/8 Rule" Runge-Kutta Method
* https://en.wikipedia.org/wiki/Runge%E2%80%93Kutta_methods
*/
/* Time-step coefficients */
static double RK4B__A[] = {
0.0,
1.0/3.0,
2.0/3.0,
1.0
};
/* Solution weighting coefficients */
static double RK4B__C[] = {
1.0 / 8.0,
3.0 / 8.0,
3.0 / 8.0,
1.0 / 8.0
};
/* Simulation weighting coefficients */
static double RK4B__B[] = {
1.0/3.0,
-1.0/3.0, 1.0,
1.0 -1.0, 1.0
};
static const int RK4B__nStage = 4;
/* Runge-Kutta "3/8 Rule"
* tLow = time at beginning of the step
* tUpp = time at the end of the step
* zLow = state at the beginning of the step
* zUpp = state at the end of the step (unknown -- Computed by this function)
* nDim = dimension of the state space*/
void rk4Bstep(DynFun dynFun,
double tLow, double tUpp, double zLow[], double zUpp[], int nDim)
{
RK_STEP( dynFun,
tLow, tUpp, zLow, zUpp, nDim,
RK4B__A, RK4B__B, RK4B__C, RK4B__nStage);
}