1 /* Copyright 2002-2016 CS Systèmes d'Information
2 * Licensed to CS Systèmes d'Information (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;
18
19 import java.util.List;
20
21 import org.hipparchus.analysis.differentiation.DerivativeStructure;
22 import org.hipparchus.geometry.euclidean.threed.FieldRotation;
23 import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
24 import org.orekit.errors.OrekitException;
25 import org.orekit.frames.Frame;
26 import org.orekit.propagation.SpacecraftState;
27 import org.orekit.propagation.events.EventDetector;
28 import org.orekit.propagation.numerical.TimeDerivativesEquations;
29 import org.orekit.time.AbsoluteDate;
30 import org.orekit.utils.ParameterDriver;
31
32 /** This interface represents a force modifying spacecraft motion.
33 *
34 * <p>
35 * Objects implementing this interface are intended to be added to a
36 * {@link org.orekit.propagation.numerical.NumericalPropagator numerical propagator}
37 * before the propagation is started.
38 *
39 * <p>
40 * The propagator will call at each step the {@link #addContribution(SpacecraftState,
41 * TimeDerivativesEquations)} method. The force model instance will extract all the
42 * state data it needs (date,position, velocity, frame, attitude, mass) from the first
43 * parameter. From these state data, it will compute the perturbing acceleration. It
44 * will then add this acceleration to the second parameter which will take thins
45 * contribution into account and will use the Gauss equations to evaluate its impact
46 * on the global state derivative.
47 * </p>
48 * <p>
49 * Force models which create discontinuous acceleration patterns (typically for maneuvers
50 * start/stop or solar eclipses entry/exit) must provide one or more {@link
51 * org.orekit.propagation.events.EventDetector events detectors} to the
52 * propagator thanks to their {@link #getEventsDetectors()} method. This method
53 * is called once just before propagation starts. The events states will be checked by
54 * the propagator to ensure accurate propagation and proper events handling.
55 * </p>
56 *
57 * @author Mathieu Roméro
58 * @author Luc Maisonobe
59 * @author Véronique Pommier-Maurussane
60 */
61 public interface ForceModel {
62
63 /**
64 * Initialize the force model at the start of propagation. This method will be called
65 * before any calls to {@link #addContribution(SpacecraftState,
66 * TimeDerivativesEquations)} or {@link #accelerationDerivatives(AbsoluteDate, Frame,
67 * FieldVector3D, FieldVector3D, FieldRotation, DerivativeStructure)} or {@link
68 * #accelerationDerivatives(SpacecraftState, String)}.
69 *
70 * <p> The default implementation of this method does nothing.
71 *
72 * @param initialState spacecraft state at the start of propagation.
73 * @param target date of propagation. Not equal to {@code initialState.getDate()}.
74 * @throws OrekitException if an implementing class overrides the default behavior and
75 * takes some action that throws an {@link OrekitException}.
76 */
77 default void init(SpacecraftState initialState, AbsoluteDate target)
78 throws OrekitException {
79 }
80
81 /** Compute the contribution of the force model to the perturbing
82 * acceleration.
83 * @param s current state information: date, kinematics, attitude
84 * @param adder object where the contribution should be added
85 * @exception OrekitException if some specific error occurs
86 */
87 void addContribution(SpacecraftState s, TimeDerivativesEquations adder)
88 throws OrekitException;
89
90 /** Compute acceleration derivatives with respect to state parameters.
91 * <p>
92 * The derivatives should be computed with respect to position, velocity
93 * and optionnaly mass. The input parameters already take into account the
94 * free parameters (6 or 7 depending on derivation with respect to mass
95 * being considered or not) and order (always 1). Free parameters at indices
96 * 0, 1 and 2 correspond to derivatives with respect to position. Free
97 * parameters at indices 3, 4 and 5 correspond to derivatives with respect
98 * to velocity. Free parameter at index 6 (if present) corresponds to
99 * to derivatives with respect to mass.
100 * </p>
101 * @param date current date
102 * @param frame inertial reference frame for state (both orbit and attitude)
103 * @param position position of spacecraft in reference frame
104 * @param velocity velocity of spacecraft in reference frame
105 * @param rotation orientation (attitude) of the spacecraft with respect to reference frame
106 * @param mass spacecraft mass
107 * @return acceleration with all derivatives specified by the input parameters own derivatives
108 * @exception OrekitException if derivatives cannot be computed
109 * @since 6.0
110 */
111 FieldVector3D<DerivativeStructure> accelerationDerivatives(AbsoluteDate date, Frame frame,
112 FieldVector3D<DerivativeStructure> position, FieldVector3D<DerivativeStructure> velocity,
113 FieldRotation<DerivativeStructure> rotation, DerivativeStructure mass)
114 throws OrekitException;
115
116 /** Compute acceleration derivatives with respect to additional parameters.
117 * @param s spacecraft state
118 * @param paramName name of the parameter with respect to which derivatives are required
119 * @return acceleration with all derivatives specified by the input parameters own derivatives
120 * @exception OrekitException if derivatives cannot be computed
121 * @since 6.0
122 */
123 FieldVector3D<DerivativeStructure> accelerationDerivatives(SpacecraftState s, String paramName)
124 throws OrekitException;
125
126 /** Get the discrete events related to the model.
127 * @return array of events detectors or null if the model is not
128 * related to any discrete events
129 */
130 EventDetector[] getEventsDetectors();
131
132 /** Get the drivers for force model parameters.
133 * @return drivers for force model parameters
134 * @since 8.0
135 */
136 ParameterDriver[] getParametersDrivers();
137
138 /** Get parameter value from its name.
139 * @param name parameter name
140 * @return parameter value
141 * @exception OrekitException if parameter is not supported
142 * @since 8.0
143 */
144 ParameterDriver getParameterDriver(String name) throws OrekitException;
145
146 /** Check if a parameter is supported.
147 * <p>Supported parameters are those listed by {@link #getParametersDrivers()}.</p>
148 * @param name parameter name to check
149 * @return true if the parameter is supported
150 * @see #getParametersDrivers()
151 */
152 boolean isSupported(String name);
153
154 /** Get the names of the supported parameters.
155 * @return parameters names
156 * @see #isSupported(String)
157 * @deprecated as of 8.0, replaced with {@link #getParametersDrivers()}
158 */
159 @Deprecated
160 List<String> getParametersNames();
161
162 /** Get parameter value from its name.
163 * @param name parameter name
164 * @return parameter value
165 * @exception OrekitException if parameter is not supported
166 * @deprecated as of 8.0, replaced with
167 * {@link #getParameterDriver(String)}.{@link ParameterDriver#getName()}
168 */
169 @Deprecated
170 double getParameter(String name) throws OrekitException;
171
172 /** Set the value for a given parameter.
173 * @param name parameter name
174 * @param value parameter value
175 * @exception OrekitException if parameter is not supported
176 * @deprecated as of 8.0, replaced with
177 * {@link #getParameterDriver(String)}.{@link ParameterDriver#setValue(double)}
178 */
179 @Deprecated
180 void setParameter(String name, double value) throws OrekitException;
181
182 }