1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.hipparchus.ode;
19
20 import org.hipparchus.CalculusFieldElement;
21 import org.hipparchus.Field;
22 import org.hipparchus.special.elliptic.jacobi.FieldCopolarN;
23 import org.hipparchus.special.elliptic.jacobi.FieldJacobiElliptic;
24 import org.hipparchus.special.elliptic.jacobi.JacobiEllipticBuilder;
25 import org.hipparchus.util.FastMath;
26 import org.hipparchus.util.MathArrays;
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67 public class TestFieldProblem7<T extends CalculusFieldElement<T>>
68 extends TestFieldProblemAbstract<T> {
69
70
71 final T i1;
72 final T i2;
73 final T i3;
74
75
76 final T twoE;
77
78 final T m2;
79
80
81 final T tScale;
82
83
84 final T o1Scale;
85 final T o2Scale;
86 final T o3Scale;
87
88
89 final FieldJacobiElliptic<T> jacobi;
90
91
92
93
94
95 public TestFieldProblem7(Field<T> field) {
96 super(convert(field, 0.0),
97 convert(field, new double[] { 5.0, 0.0, 4.0 }),
98 convert(field, 4.0),
99 convert(field, new double[] { 1.0, 1.0, 1.0 }));
100 i1 = convert(field, 3.0 / 8.0);
101 i2 = convert(field, 1.0 / 2.0);
102 i3 = convert(field, 5.0 / 8.0);
103
104 final T[] s0 = getInitialState().getPrimaryState();
105 final T o12 = s0[0].multiply(s0[0]);
106 final T o22 = s0[1].multiply(s0[1]);
107 final T o32 = s0[2].multiply(s0[2]);
108 twoE = i1.multiply(o12).add(i2.multiply(o22)).add(i3.multiply(o32));
109 m2 = i1.multiply(i1.multiply(o12)).add(i2.multiply(i2.multiply(o22))).add(i3.multiply(i3.multiply(o32)));
110 tScale = FastMath.sqrt(i3.subtract(i2).multiply(m2.subtract(twoE.multiply(i1))).divide(i1.multiply(i2).multiply(i3)));
111 o1Scale = FastMath.sqrt(twoE.multiply(i3).subtract(m2).divide(i1.multiply(i3.subtract(i1))));
112 o2Scale = FastMath.sqrt(twoE.multiply(i3).subtract(m2).divide(i2.multiply(i3.subtract(i2))));
113 o3Scale = FastMath.sqrt(m2.subtract(twoE.multiply(i1)).divide(i3.multiply(i3.subtract(i1))));
114
115 final T k2 = i2.subtract(i1).multiply(twoE.multiply(i3).subtract(m2)).divide(i3.subtract(i2).multiply(m2.subtract(twoE.multiply(i1))));
116 jacobi = JacobiEllipticBuilder.build(k2);
117 }
118
119 @Override
120 public T[] doComputeDerivatives(T t, T[] y) {
121
122 final T[] yDot = MathArrays.buildArray(getField(), getDimension());
123
124
125 yDot[0] = y[1].multiply(y[2]).multiply(i2.subtract(i3)).divide(i1);
126 yDot[1] = y[2].multiply(y[0]).multiply(i3.subtract(i1)).divide(i2);
127 yDot[2] = y[0].multiply(y[1]).multiply(i1.subtract(i2)).divide(i3);
128
129 return yDot;
130
131 }
132
133 @Override
134 public T[] computeTheoreticalState(T t) {
135
136 final T[] y = MathArrays.buildArray(getField(), getDimension());
137
138 final FieldCopolarN<T> valuesN = jacobi.valuesN(t.multiply(tScale));
139 y[0] = o1Scale.multiply(valuesN.cn());
140 y[1] = o2Scale.multiply(valuesN.sn());
141 y[2] = o3Scale.multiply(valuesN.dn());
142
143 return y;
144
145 }
146
147 }