1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.orekit.forces;
18
19 import org.apache.commons.math3.analysis.differentiation.DerivativeStructure;
20 import org.apache.commons.math3.geometry.euclidean.threed.FieldRotation;
21 import org.apache.commons.math3.geometry.euclidean.threed.FieldVector3D;
22 import org.apache.commons.math3.geometry.euclidean.threed.Rotation;
23 import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
24 import org.orekit.errors.OrekitException;
25 import org.orekit.errors.OrekitMessages;
26 import org.orekit.forces.drag.DragSensitive;
27 import org.orekit.forces.radiation.RadiationSensitive;
28 import org.orekit.frames.Frame;
29 import org.orekit.time.AbsoluteDate;
30
31
32
33
34
35
36
37
38
39
40
41
42 public class SphericalSpacecraft implements RadiationSensitive, DragSensitive {
43
44
45 private final double crossSection;
46
47
48 private double dragCoeff;
49
50
51 private double absorptionCoeff;
52
53
54 private double specularReflectionCoeff;
55
56
57
58
59
60
61
62
63
64 public SphericalSpacecraft(final double crossSection, final double dragCoeff,
65 final double absorptionCoeff, final double reflectionCoeff) {
66 this.crossSection = crossSection;
67 this.dragCoeff = dragCoeff;
68 this.absorptionCoeff = absorptionCoeff;
69 this.specularReflectionCoeff = reflectionCoeff;
70 }
71
72
73 public Vector3D dragAcceleration(final AbsoluteDate date, final Frame frame, final Vector3D position,
74 final Rotation rotation, final double mass,
75 final double density, final Vector3D relativeVelocity) {
76 return new Vector3D(relativeVelocity.getNorm() * density * dragCoeff * crossSection / (2 * mass),
77 relativeVelocity);
78 }
79
80
81 public FieldVector3D<DerivativeStructure> dragAcceleration(final AbsoluteDate date, final Frame frame, final FieldVector3D<DerivativeStructure> position,
82 final FieldRotation<DerivativeStructure> rotation, final DerivativeStructure mass,
83 final double density, final FieldVector3D<DerivativeStructure> relativeVelocity) {
84 return new FieldVector3D<DerivativeStructure>(relativeVelocity.getNorm().multiply(density * dragCoeff * crossSection / 2).divide(mass),
85 relativeVelocity);
86 }
87
88
89 public FieldVector3D<DerivativeStructure> dragAcceleration(final AbsoluteDate date, final Frame frame, final Vector3D position,
90 final Rotation rotation, final double mass,
91 final double density, final Vector3D relativeVelocity,
92 final String paramName)
93 throws OrekitException {
94
95 if (!DRAG_COEFFICIENT.equals(paramName)) {
96 throw new OrekitException(OrekitMessages.UNSUPPORTED_PARAMETER_NAME, paramName, DRAG_COEFFICIENT);
97 }
98
99 final DerivativeStructure dragCoeffDS = new DerivativeStructure(1, 1, 0, dragCoeff);
100
101 return new FieldVector3D<DerivativeStructure>(dragCoeffDS.multiply(relativeVelocity.getNorm() * density * crossSection / (2 * mass)),
102 relativeVelocity);
103
104 }
105
106
107 public Vector3D radiationPressureAcceleration(final AbsoluteDate date, final Frame frame, final Vector3D position,
108 final Rotation rotation, final double mass, final Vector3D flux) {
109 final double kP = crossSection * (1 + 4 * (1.0 - absorptionCoeff) * (1.0 - specularReflectionCoeff) / 9.0);
110 return new Vector3D(kP / mass, flux);
111 }
112
113
114 public FieldVector3D<DerivativeStructure> radiationPressureAcceleration(final AbsoluteDate date, final Frame frame, final FieldVector3D<DerivativeStructure> position,
115 final FieldRotation<DerivativeStructure> rotation, final DerivativeStructure mass,
116 final FieldVector3D<DerivativeStructure> flux) {
117 final double kP = crossSection * (1 + 4 * (1.0 - absorptionCoeff) * (1.0 - specularReflectionCoeff) / 9.0);
118 return new FieldVector3D<DerivativeStructure>(mass.reciprocal().multiply(kP), flux);
119 }
120
121
122 public FieldVector3D<DerivativeStructure> radiationPressureAcceleration(final AbsoluteDate date, final Frame frame, final Vector3D position,
123 final Rotation rotation, final double mass,
124 final Vector3D flux, final String paramName)
125 throws OrekitException {
126
127 final DerivativeStructure absorptionCoeffDS;
128 final DerivativeStructure specularReflectionCoeffDS;
129 if (ABSORPTION_COEFFICIENT.equals(paramName)) {
130 absorptionCoeffDS = new DerivativeStructure(1, 1, 0, absorptionCoeff);
131 specularReflectionCoeffDS = new DerivativeStructure(1, 1, specularReflectionCoeff);
132 } else if (REFLECTION_COEFFICIENT.equals(paramName)) {
133 absorptionCoeffDS = new DerivativeStructure(1, 1, absorptionCoeff);
134 specularReflectionCoeffDS = new DerivativeStructure(1, 1, 0, specularReflectionCoeff);
135 } else {
136 throw new OrekitException(OrekitMessages.UNSUPPORTED_PARAMETER_NAME, paramName,
137 ABSORPTION_COEFFICIENT + ", " + REFLECTION_COEFFICIENT);
138 }
139
140 final DerivativeStructure kP =
141 absorptionCoeffDS.subtract(1).multiply(specularReflectionCoeffDS.subtract(1)).multiply(4.0 / 9.0).add(1).multiply(crossSection);
142 return new FieldVector3D<DerivativeStructure>(kP.divide(mass), flux);
143
144 }
145
146
147 public void setDragCoefficient(final double value) {
148 dragCoeff = value;
149 }
150
151
152 public double getDragCoefficient() {
153 return dragCoeff;
154 }
155
156
157 public void setAbsorptionCoefficient(final double value) {
158 absorptionCoeff = value;
159 }
160
161
162 public double getAbsorptionCoefficient() {
163 return absorptionCoeff;
164 }
165
166
167 public void setReflectionCoefficient(final double value) {
168 specularReflectionCoeff = value;
169 }
170
171
172 public double getReflectionCoefficient() {
173 return specularReflectionCoeff;
174 }
175
176 }