1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.orekit.forces.drag;
18
19 import java.util.List;
20 import java.util.stream.Stream;
21
22 import org.hipparchus.Field;
23 import org.hipparchus.CalculusFieldElement;
24 import org.hipparchus.analysis.differentiation.DerivativeStructure;
25 import org.hipparchus.analysis.differentiation.Gradient;
26 import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
27 import org.hipparchus.geometry.euclidean.threed.Vector3D;
28 import org.orekit.frames.Frame;
29 import org.orekit.models.earth.atmosphere.Atmosphere;
30 import org.orekit.propagation.FieldSpacecraftState;
31 import org.orekit.propagation.SpacecraftState;
32 import org.orekit.propagation.events.EventDetector;
33 import org.orekit.propagation.events.FieldEventDetector;
34 import org.orekit.time.AbsoluteDate;
35 import org.orekit.time.FieldAbsoluteDate;
36 import org.orekit.utils.ParameterDriver;
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54 public class DragForce extends AbstractDragForceModel {
55
56
57 private final Atmosphere atmosphere;
58
59
60 private final DragSensitive spacecraft;
61
62
63
64
65
66 public DragForce(final Atmosphere atmosphere, final DragSensitive spacecraft) {
67 super(atmosphere);
68 this.atmosphere = atmosphere;
69 this.spacecraft = spacecraft;
70 }
71
72
73 @Override
74 public Vector3D acceleration(final SpacecraftState s, final double[] parameters) {
75
76 final AbsoluteDate date = s.getDate();
77 final Frame frame = s.getFrame();
78 final Vector3D position = s.getPVCoordinates().getPosition();
79
80 final double rho = atmosphere.getDensity(date, position, frame);
81 final Vector3D vAtm = atmosphere.getVelocity(date, position, frame);
82 final Vector3D relativeVelocity = vAtm.subtract(s.getPVCoordinates().getVelocity());
83
84 return spacecraft.dragAcceleration(date, frame, position, s.getAttitude().getRotation(),
85 s.getMass(), rho, relativeVelocity, parameters);
86
87 }
88
89
90 @SuppressWarnings("unchecked")
91 @Override
92 public <T extends CalculusFieldElement<T>> FieldVector3D<T> acceleration(final FieldSpacecraftState<T> s,
93 final T[] parameters) {
94
95 final FieldAbsoluteDate<T> date = s.getDate();
96 final Frame frame = s.getFrame();
97 final FieldVector3D<T> position = s.getPVCoordinates().getPosition();
98
99
100 final T rho;
101
102
103
104
105 if (isGradientStateDerivative(s)) {
106 rho = (T) this.getGradientDensityWrtStateUsingFiniteDifferences(date.toAbsoluteDate(), frame, (FieldVector3D<Gradient>) position);
107 } else if (isDSStateDerivative(s)) {
108 rho = (T) this.getDSDensityWrtStateUsingFiniteDifferences(date.toAbsoluteDate(), frame, (FieldVector3D<DerivativeStructure>) position);
109 } else {
110 rho = atmosphere.getDensity(date, position, frame);
111 }
112
113
114 final FieldVector3D<T> vAtm = atmosphere.getVelocity(date, position, frame);
115 final FieldVector3D<T> relativeVelocity = vAtm.subtract(s.getPVCoordinates().getVelocity());
116
117
118 return spacecraft.dragAcceleration(date, frame, position, s.getAttitude().getRotation(),
119 s.getMass(), rho, relativeVelocity, parameters);
120
121 }
122
123
124 @Override
125 public List<ParameterDriver> getParametersDrivers() {
126 return spacecraft.getDragParametersDrivers();
127 }
128
129
130 @Override
131 public Stream<EventDetector> getEventsDetectors() {
132 return Stream.empty();
133 }
134
135
136 @Override
137 public <T extends CalculusFieldElement<T>> Stream<FieldEventDetector<T>> getFieldEventsDetectors(final Field<T> field) {
138 return Stream.empty();
139 }
140
141
142
143
144 public Atmosphere getAtmosphere() {
145 return atmosphere;
146 }
147
148
149
150
151 public DragSensitive getSpacecraft() {
152 return spacecraft;
153 }
154 }