1 /* Copyright 2002-2021 CS GROUP
2 * Licensed to CS GROUP (CS) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * CS licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17 package org.orekit.forces.drag;
18
19 import java.util.Collections;
20 import java.util.List;
21
22 import org.hipparchus.CalculusFieldElement;
23 import org.hipparchus.geometry.euclidean.threed.FieldRotation;
24 import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
25 import org.hipparchus.geometry.euclidean.threed.Rotation;
26 import org.hipparchus.geometry.euclidean.threed.Vector3D;
27 import org.hipparchus.util.FastMath;
28 import org.orekit.frames.Frame;
29 import org.orekit.time.AbsoluteDate;
30 import org.orekit.time.FieldAbsoluteDate;
31 import org.orekit.utils.ParameterDriver;
32
33 /** This class models isotropic drag effects.
34 * <p>The model of this spacecraft is a simple spherical model, this
35 * means that all coefficients are constant and do not depend of
36 * the direction.</p>
37 *
38 * @see org.orekit.forces.BoxAndSolarArraySpacecraft
39 * @see org.orekit.forces.radiation.IsotropicRadiationCNES95Convention
40 * @author Luc Maisonobe
41 * @since 7.1
42 */
43 public class IsotropicDrag implements DragSensitive {
44
45 /** Parameters scaling factor.
46 * <p>
47 * We use a power of 2 to avoid numeric noise introduction
48 * in the multiplications/divisions sequences.
49 * </p>
50 */
51 private final double SCALE = FastMath.scalb(1.0, -3);
52
53 /** Drivers for drag coefficient parameter. */
54 private final ParameterDriver dragParametersDrivers;
55
56 /** Cross section (m²). */
57 private final double crossSection;
58
59 /** Constructor with drag coefficient min/max set to ±∞.
60 * @param crossSection Surface (m²)
61 * @param dragCoeff drag coefficient
62 */
63 public IsotropicDrag(final double crossSection, final double dragCoeff) {
64 this(crossSection, dragCoeff, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);
65 }
66
67 /** Constructor with drag coefficient min/max set by user.
68 * @param crossSection Surface (m²)
69 * @param dragCoeff drag coefficient
70 * @param dragCoeffMin Minimum value of drag coefficient
71 * @param dragCoeffMax Maximum value of drag coefficient
72 */
73 public IsotropicDrag(final double crossSection, final double dragCoeff,
74 final double dragCoeffMin, final double dragCoeffMax) {
75 // in some corner cases (unknown spacecraft, fuel leaks, active piloting ...)
76 // the single coefficient may be arbitrary, and even negative
77 this.dragParametersDrivers = new ParameterDriver(DragSensitive.DRAG_COEFFICIENT,
78 dragCoeff, SCALE,
79 dragCoeffMin, dragCoeffMax);
80 this.crossSection = crossSection;
81 }
82
83 /** {@inheritDoc} */
84 @Override
85 public List<ParameterDriver> getDragParametersDrivers() {
86 return Collections.singletonList(dragParametersDrivers);
87 }
88
89 /** {@inheritDoc} */
90 @Override
91 public Vector3D dragAcceleration(final AbsoluteDate date, final Frame frame, final Vector3D position,
92 final Rotation rotation, final double mass,
93 final double density, final Vector3D relativeVelocity,
94 final double[] parameters) {
95 final double dragCoeff = parameters[0];
96 return new Vector3D(relativeVelocity.getNorm() * density * dragCoeff * crossSection / (2 * mass),
97 relativeVelocity);
98 }
99
100 /** {@inheritDoc} */
101 @Override
102 public <T extends CalculusFieldElement<T>> FieldVector3D<T>
103 dragAcceleration(final FieldAbsoluteDate<T> date, final Frame frame,
104 final FieldVector3D<T> position, final FieldRotation<T> rotation,
105 final T mass, final T density,
106 final FieldVector3D<T> relativeVelocity,
107 final T[] parameters) {
108 final T dragCoeff = parameters[0];
109 return new FieldVector3D<>(relativeVelocity.getNorm().multiply(density.multiply(dragCoeff).multiply(crossSection / 2)).divide(mass),
110 relativeVelocity);
111 }
112 }