1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.orekit.forces.maneuvers.propulsion;
19
20 import org.hipparchus.CalculusFieldElement;
21 import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
22 import org.hipparchus.geometry.euclidean.threed.Vector3D;
23 import org.hipparchus.util.FastMath;
24 import org.hipparchus.util.MathUtils;
25 import org.orekit.forces.maneuvers.Control3DVectorCostType;
26 import org.orekit.time.AbsoluteDate;
27 import org.orekit.utils.ParameterDriver;
28
29 import java.util.Arrays;
30 import java.util.Collections;
31 import java.util.List;
32
33
34
35
36
37
38
39
40 public class SphericalConstantThrustPropulsionModel extends AbstractConstantThrustPropulsionModel {
41
42
43 public static final String THRUST_MAGNITUDE = "thrust magnitude";
44
45
46 public static final String THRUST_RIGHT_ASCENSION = "thrust alpha";
47
48
49 public static final String THRUST_DECLINATION = "thrust declination";
50
51
52
53
54
55
56
57 public static final double THRUST_SCALE = FastMath.scalb(1.0, -5);
58
59
60 private final ParameterDriver thrustMagnitude;
61
62
63 private final ParameterDriver thrustRightAscension;
64
65
66 private final ParameterDriver thrustDeclination;
67
68
69 private final double massFlowRateFactor;
70
71
72
73
74
75
76
77 public SphericalConstantThrustPropulsionModel(final double isp, final double thrustMagnitude,
78 final Vector3D thrustDirection, final String name) {
79 super(isp, thrustMagnitude, thrustDirection, Control3DVectorCostType.TWO_NORM, name);
80 this.massFlowRateFactor = -1. / ThrustPropulsionModel.getExhaustVelocity(isp);
81
82
83 this.thrustMagnitude = new ParameterDriver(name + THRUST_MAGNITUDE, thrustMagnitude, THRUST_SCALE,
84 0.0, Double.POSITIVE_INFINITY);
85 this.thrustRightAscension = new ParameterDriver(name + THRUST_RIGHT_ASCENSION, thrustDirection.getAlpha(), 1.,
86 Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);
87 this.thrustDeclination = new ParameterDriver(name + THRUST_DECLINATION, thrustDirection.getDelta(), 1.,
88 -MathUtils.SEMI_PI, MathUtils.SEMI_PI);
89 }
90
91
92
93
94
95
96 public SphericalConstantThrustPropulsionModel(final double isp, final Vector3D thrustVector, final String name) {
97 this(isp, thrustVector.getNorm(), thrustVector.normalize(), name);
98 }
99
100
101 @Override
102 public Vector3D getThrustVector() {
103
104
105
106
107 return new Vector3D(thrustRightAscension.getValue(), thrustDeclination.getValue()).scalarMultiply(thrustMagnitude.getValue());
108 }
109
110
111 @Override
112 public Vector3D getThrustVector(final AbsoluteDate date) {
113
114 return new Vector3D(thrustRightAscension.getValue(date), thrustDeclination.getValue(date)).scalarMultiply(thrustMagnitude.getValue(date));
115 }
116
117
118 @Override
119 public double getFlowRate() {
120
121
122
123
124 return getThrustVector().getNorm() * massFlowRateFactor;
125 }
126
127
128 @Override
129 public double getFlowRate(final AbsoluteDate date) {
130 return getThrustVector(date).getNorm() * massFlowRateFactor;
131 }
132
133
134 @Override
135 public List<ParameterDriver> getParametersDrivers() {
136 return Collections.unmodifiableList(Arrays.asList(thrustMagnitude, thrustRightAscension, thrustDeclination));
137 }
138
139
140 @Override
141 public Vector3D getThrustVector(final double[] parameters) {
142
143 return new Vector3D(parameters[1], parameters[2]).scalarMultiply(parameters[0]);
144 }
145
146
147 @Override
148 public double getFlowRate(final double[] parameters) {
149 return getThrustVector(parameters).getNorm() * massFlowRateFactor;
150 }
151
152
153 @Override
154 public <T extends CalculusFieldElement<T>> FieldVector3D<T> getThrustVector(final T[] parameters) {
155 return new FieldVector3D<>(parameters[1], parameters[2]).scalarMultiply(parameters[0]);
156 }
157
158
159 @Override
160 public <T extends CalculusFieldElement<T>> T getFlowRate(final T[] parameters) {
161 return getThrustVector(parameters).getNorm().multiply(massFlowRateFactor);
162 }
163 }