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
21 import org.hipparchus.analysis.differentiation.DSFactory;
22 import org.hipparchus.analysis.differentiation.DerivativeStructure;
23 import org.hipparchus.ode.EquationsMapper;
24 import org.hipparchus.ode.ExpandableODE;
25 import org.hipparchus.ode.ODEStateAndDerivative;
26 import org.hipparchus.ode.sampling.AbstractODEStateInterpolator;
27
28 public class GraggBulirschStoerStateInterpolatorTest extends ODEStateInterpolatorAbstractTest {
29
30 protected AbstractODEStateInterpolator setUpInterpolator(final ReferenceODE eqn,
31 final double t0, final double[] y0,
32 final double t1) {
33
34
35 final int derivationOrder = 7;
36 DerivativeStructure middleT = new DSFactory(1, derivationOrder).variable(0, 0.5 * (t0 + t1));
37 DerivativeStructure[] derivatives = eqn.theoreticalState(middleT);
38
39 final double[][] yMidDots = new double[derivationOrder + 1][eqn.getDimension()];
40 final double h = t1 - t0;
41 double hK = 1.0;
42 for (int k = 0; k < yMidDots.length; ++k) {
43 for (int i = 0; i < derivatives.length; ++i) {
44 yMidDots[k][i] = hK * derivatives[i].getPartialDerivative(k);
45 }
46 hK *= h;
47 }
48
49 EquationsMapper mapper = new ExpandableODE(eqn).getMapper();
50 ODEStateAndDerivative s0 = mapper.mapStateAndDerivative(t0, y0, eqn.computeDerivatives(t0, y0));
51 double[] y1 = eqn.theoreticalState(t1);
52 ODEStateAndDerivative s1 = mapper.mapStateAndDerivative(t1, y1, eqn.computeDerivatives(t1, y1));
53
54 GraggBulirschStoerStateInterpolator interpolator =
55 new GraggBulirschStoerStateInterpolator(t1 >= t0, s0, s1, s0, s1,
56 mapper, yMidDots, derivationOrder);
57 return interpolator;
58
59 }
60
61 @Override
62 public void interpolationAtBounds() {
63 doInterpolationAtBounds(1.0e-15);
64 }
65
66 @Override
67 public void interpolationInside() {
68 doInterpolationInside(3.5e-18, 1.2e-16);
69 }
70
71 @Override
72 public void restrictPrevious() {
73 doRestrictPrevious(1.0e-15, 1.0e-15);
74 }
75
76 @Override
77 public void restrictCurrent() {
78 doRestrictCurrent(1.0e-15, 1.0e-15);
79 }
80
81 @Override
82 public void restrictBothEnds() {
83 doRestrictBothEnds(1.0e-15, 1.0e-15);
84 }
85
86 @Override
87 public void degenerateInterpolation() {
88 doDegenerateInterpolation();
89 }
90
91 }