1   /* Copyright 2002-2025 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  
18  package org.orekit.forces.maneuvers.propulsion;
19  
20  import java.util.stream.Stream;
21  
22  import org.hipparchus.CalculusFieldElement;
23  import org.hipparchus.Field;
24  import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
25  import org.hipparchus.geometry.euclidean.threed.Vector3D;
26  import org.orekit.attitudes.Attitude;
27  import org.orekit.attitudes.FieldAttitude;
28  import org.orekit.forces.maneuvers.Control3DVectorCostType;
29  import org.orekit.forces.maneuvers.Maneuver;
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.EventDetectorsProvider;
34  import org.orekit.propagation.events.FieldEventDetector;
35  import org.orekit.time.AbsoluteDate;
36  import org.orekit.time.FieldAbsoluteDate;
37  import org.orekit.utils.ParameterDriversProvider;
38  
39  /** Generic interface for a propulsion model used in a {@link Maneuver}.
40   * @author Maxime Journot
41   * @since 10.2
42   */
43  public interface PropulsionModel extends ParameterDriversProvider, EventDetectorsProvider {
44  
45      /** Initialization method.
46       *  Called in when Maneuver.init(...) is called (from ForceModel.init(...))
47       * @param initialState initial spacecraft state (at the start of propagation).
48       * @param target date of propagation. Not equal to {@code initialState.getDate()}.
49       */
50      default void init(SpacecraftState initialState, AbsoluteDate target) {
51      }
52  
53      /** Initialization method.
54       *  Called in when Maneuver.init(...) is called (from ForceModel.init(...))
55       * @param initialState initial spacecraft state (at the start of propagation).
56       * @param target date of propagation. Not equal to {@code initialState.getDate()}.
57       * @param <T> type of the elements
58       * @since 11.1
59       */
60      default <T extends CalculusFieldElement<T>> void init(FieldSpacecraftState<T> initialState, FieldAbsoluteDate<T> target) {
61          init(initialState.toSpacecraftState(), target.toAbsoluteDate());
62      }
63  
64      /** {@inheritDoc}.*/
65      @Override
66      default Stream<EventDetector> getEventDetectors() {
67          return getEventDetectors(getParametersDrivers());
68      }
69  
70      /** {@inheritDoc}.*/
71      @Override
72      default <T extends CalculusFieldElement<T>> Stream<FieldEventDetector<T>> getFieldEventDetectors(Field<T> field) {
73          return getFieldEventDetectors(field, getParametersDrivers());
74      }
75  
76      /** Get the acceleration of the spacecraft during maneuver and in maneuver frame.
77       * @param s current spacecraft state
78       * @param maneuverAttitude current attitude in maneuver
79       * @param parameters propulsion model parameters
80       * @return acceleration
81       */
82      Vector3D getAcceleration(SpacecraftState s, Attitude maneuverAttitude, double[] parameters);
83  
84      /** Get the acceleration of the spacecraft during maneuver and in maneuver frame.
85       * @param s current spacecraft state
86       * @param maneuverAttitude current attitude in maneuver
87       * @param parameters propulsion model parameters
88       * @param <T> extends CalculusFieldElement&lt;T&gt;
89       * @return acceleration
90       */
91      <T extends CalculusFieldElement<T>> FieldVector3D<T> getAcceleration(FieldSpacecraftState<T> s,
92                                                                           FieldAttitude<T> maneuverAttitude,
93                                                                           T[] parameters);
94  
95      /** Get the mass derivative (i.e. flow rate in kg/s) during maneuver.
96       * @param s current spacecraft state
97       * @param parameters propulsion model parameters
98       * @return mass derivative in kg/s
99       */
100     double getMassDerivatives(SpacecraftState s, double[] parameters);
101 
102     /** Get the mass derivative (i.e. flow rate in kg/s) during maneuver.
103      * @param s current spacecraft state
104      * @param parameters propulsion model parameters
105      * @param <T> extends CalculusFieldElement&lt;T&gt;
106      * @return mass derivative in kg/s
107      */
108     <T extends CalculusFieldElement<T>> T getMassDerivatives(FieldSpacecraftState<T> s,
109                                                              T[] parameters);
110     /** Get the maneuver name.
111      * @return the maneuver name
112      */
113     default String getName() {
114         return "";
115     }
116 
117     /** Get the control vector's cost type.
118      * @return control cost type
119      * @since 12.0
120      */
121     Control3DVectorCostType getControl3DVectorCostType();
122 
123 }