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