1   /* Copyright 2020 Exotrail
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    * Exotrail 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.maneuvers;
18  
19  import org.hipparchus.geometry.euclidean.threed.Vector3D;
20  import org.orekit.forces.maneuvers.propulsion.AbstractConstantThrustPropulsionModel;
21  import org.orekit.forces.maneuvers.propulsion.BasicConstantThrustPropulsionModel;
22  import org.orekit.forces.maneuvers.propulsion.ThrustDirectionAndAttitudeProvider;
23  import org.orekit.forces.maneuvers.trigger.ManeuverTriggers;
24  import org.orekit.time.AbsoluteDate;
25  
26  /**
27   * This class implements a configurable low thrust maneuver.
28   * <p>
29   * The maneuver is composed of succession of a burn interval. Burn intervals are
30   * defined by two detectors. See
31   * {@link org.orekit.forces.maneuvers.trigger.StartStopEventsTrigger
32   * StartStopEventsTrigger} for more details on the detectors. The attitude
33   * and the thrust direction are provided by an instance of
34   * ThrustDirectionProvider See
35   * {@link org.orekit.forces.maneuvers.propulsion.ThrustDirectionAndAttitudeProvider
36   * ThrustDirectionProvider} for more details on thrust direction and attitude.
37   * @author Mikael Fillastre
38   * @author Andrea Fiorentino
39   * @since 10.2
40   */
41  
42  public class ConfigurableLowThrustManeuver extends Maneuver {
43  
44      /** To be used for ParameterDriver to make thrust non constant. */
45      private static String THRUST_MODEL_IDENTIFIER = "ConfigurableLowThrustManeuver";
46  
47      /** Thrust direction and spacecraft attitude provided by an external object. */
48      private final ThrustDirectionAndAttitudeProvider thrustDirectionProvider;
49  
50      /**
51       * Constructor.
52       * <p>
53       * See {@link org.orekit.forces.maneuvers.trigger.StartStopEventsTrigger
54       * StartStopEventsTrigger} for requirements on detectors
55       * </p>
56       * @param thrustDirectionProvider thrust direction and attitude provider
57       * @param trigger                 maneuver triggers
58       * @param thrust                  the thrust force (N)
59       * @param isp                     engine specific impulse (s)
60       * @since 11.1
61       */
62      public ConfigurableLowThrustManeuver(final ThrustDirectionAndAttitudeProvider thrustDirectionProvider,
63                                           final ManeuverTriggers trigger,
64                                           final double thrust, final double isp) {
65          super(thrustDirectionProvider.getManeuverAttitudeProvider(),
66                trigger,
67                buildBasicConstantThrustPropulsionModel(thrust, isp,
68                                                        thrustDirectionProvider.getThrusterAxisInSatelliteFrame()));
69          this.thrustDirectionProvider = thrustDirectionProvider;
70  
71      }
72  
73      /**
74       * Build a BasicConstantThrustPropulsionModel from thruster characteristics.
75       * @param thrust                       the thrust force (N)
76       * @param isp                          engine specific impulse (s)
77       * @param thrusterAxisInSatelliteFrame direction in spacecraft frame
78       * @return new instance of BasicConstantThrustPropulsionModel
79       */
80      private static BasicConstantThrustPropulsionModel buildBasicConstantThrustPropulsionModel(final double thrust,
81              final double isp, final Vector3D thrusterAxisInSatelliteFrame) {
82          return new BasicConstantThrustPropulsionModel(thrust, isp, thrusterAxisInSatelliteFrame,
83                  THRUST_MODEL_IDENTIFIER);
84      }
85  
86      /**
87       * Getter on Thrust direction and spacecraft attitude provided by an external
88       * object.
89       * @return internal field
90       */
91      public ThrustDirectionAndAttitudeProvider getThrustDirectionProvider() {
92          return thrustDirectionProvider;
93      }
94  
95      /**
96       * Get the thrust magnitude.
97       * @param date at which the Thrust wants to be known
98       * @return thrust force (N).
99       */
100     public double getThrustMagnitude(final AbsoluteDate date) {
101         return ((AbstractConstantThrustPropulsionModel) getPropulsionModel()).getThrustVector(date).getNorm();
102     }
103 
104     /**
105      * Get the thrust magnitude.
106      * @return thrust force (N). Will throw
107      * an exception if the Thrust driver has several
108      * values driven
109      */
110     public double getThrustMagnitude() {
111         return ((AbstractConstantThrustPropulsionModel) getPropulsionModel()).getThrustVector().getNorm();
112     }
113 
114     /**
115      * Get the specific impulse.
116      * @param date at which the ISP wants to be known
117      * @return specific impulse (s).
118      */
119     public double getIsp(final AbsoluteDate date) {
120         return ((AbstractConstantThrustPropulsionModel) getPropulsionModel()).getIsp(date);
121     }
122 
123     /**
124      * Get the specific impulse.
125      * @return specific impulse (s). Will throw
126      * an exception if the Thrust driver has several
127      * values driven
128      */
129     public double getIsp() {
130         return ((AbstractConstantThrustPropulsionModel) getPropulsionModel()).getIsp();
131     }
132 
133 }