1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.hipparchus.ode.nonstiff;
19
20 import org.hipparchus.ode.EquationsMapper;
21 import org.hipparchus.ode.ODEStateAndDerivative;
22
23
24
25
26
27
28
29
30
31 class HighamHall54StateInterpolator
32 extends RungeKuttaStateInterpolator {
33
34
35 private static final long serialVersionUID = 20111120L;
36
37
38
39
40
41
42
43
44
45
46 HighamHall54StateInterpolator(final boolean forward,
47 final double[][] yDotK,
48 final ODEStateAndDerivative globalPreviousState,
49 final ODEStateAndDerivative globalCurrentState,
50 final ODEStateAndDerivative softPreviousState,
51 final ODEStateAndDerivative softCurrentState,
52 final EquationsMapper mapper) {
53 super(forward, yDotK,
54 globalPreviousState, globalCurrentState, softPreviousState, softCurrentState,
55 mapper);
56 }
57
58
59 @Override
60 protected HighamHall54StateInterpolator create(final boolean newForward, final double[][] newYDotK,
61 final ODEStateAndDerivative newGlobalPreviousState,
62 final ODEStateAndDerivative newGlobalCurrentState,
63 final ODEStateAndDerivative newSoftPreviousState,
64 final ODEStateAndDerivative newSoftCurrentState,
65 final EquationsMapper newMapper) {
66 return new HighamHall54StateInterpolator(newForward, newYDotK,
67 newGlobalPreviousState, newGlobalCurrentState,
68 newSoftPreviousState, newSoftCurrentState,
69 newMapper);
70 }
71
72
73 @Override
74 protected ODEStateAndDerivative computeInterpolatedStateAndDerivatives(final EquationsMapper mapper,
75 final double time, final double theta,
76 final double thetaH, final double oneMinusThetaH) {
77
78 final double bDot0 = 1 + theta * (-15.0/2.0 + theta * (16.0 - 10.0 * theta));
79 final double bDot1 = 0;
80 final double bDot2 = theta * (459.0/16.0 + theta * (-729.0/8.0 + 135.0/2.0 * theta));
81 final double bDot3 = theta * (-44.0 + theta * (152.0 - 120.0 * theta));
82 final double bDot4 = theta * (375.0/16.0 + theta * (-625.0/8.0 + 125.0/2.0 * theta));
83 final double bDot5 = theta * 5.0/8.0 * (2 * theta - 1);
84
85 final double[] interpolatedState;
86 final double[] interpolatedDerivatives;
87 if (getGlobalPreviousState() != null && theta <= 0.5) {
88 final double b0 = thetaH * (1.0 + theta * (-15.0/4.0 + theta * (16.0/3.0 - 5.0/2.0 * theta)));
89 final double b1 = 0;
90 final double b2 = thetaH * ( theta * (459.0/32.0 + theta * (-243.0/8.0 + theta * 135.0/8.0)));
91 final double b3 = thetaH * ( theta * (-22.0 + theta * (152.0/3.0 + theta * -30.0)));
92 final double b4 = thetaH * ( theta * (375.0/32.0 + theta * (-625.0/24.0 + theta * 125.0/8.0)));
93 final double b5 = thetaH * ( theta * (-5.0/16.0 + theta * 5.0/12.0));
94 interpolatedState = previousStateLinearCombination(b0 , b1, b2, b3, b4, b5);
95 interpolatedDerivatives = derivativeLinearCombination(bDot0 , bDot1, bDot2, bDot3, bDot4, bDot5);
96 } else {
97 final double theta2 = theta * theta;
98 final double h = thetaH / theta;
99 final double b0 = h * (-1.0/12.0 + theta * (1.0 + theta * (-15.0/4.0 + theta * (16.0/3.0 + theta * -5.0/2.0))));
100 final double b1 = 0;
101 final double b2 = h * (-27.0/32.0 + theta2 * (459.0/32.0 + theta * (-243.0/8.0 + theta * 135.0/8.0)));
102 final double b3 = h * (4.0/3.0 + theta2 * (-22.0 + theta * (152.0/3.0 + theta * -30.0)));
103 final double b4 = h * (-125.0/96.0 + theta2 * (375.0/32.0 + theta * (-625.0/24.0 + theta * 125.0/8.0)));
104 final double b5 = h * (-5.0/48.0 + theta2 * (-5.0/16.0 + theta * 5.0/12.0));
105 interpolatedState = currentStateLinearCombination(b0 , b1, b2, b3, b4, b5);
106 interpolatedDerivatives = derivativeLinearCombination(bDot0 , bDot1, bDot2, bDot3, bDot4, bDot5);
107 }
108
109 return mapper.mapStateAndDerivative(time, interpolatedState, interpolatedDerivatives);
110
111 }
112
113 }