AbstractConstantThrustPropulsionModel.java

  1. /* Copyright 2002-2022 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.maneuvers.propulsion;

  18. import org.hipparchus.CalculusFieldElement;
  19. import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
  20. import org.hipparchus.geometry.euclidean.threed.Vector3D;
  21. import org.orekit.propagation.FieldSpacecraftState;
  22. import org.orekit.propagation.SpacecraftState;
  23. import org.orekit.utils.Constants;

  24. /** This abstract class simply serve as a container for a constant thrust maneuver.
  25.  * It re-writes all spacecraft dependent methods from {@link ThrustPropulsionModel}
  26.  * and removes their dependencies to current spacecraft state.
  27.  * Indeed since the thrust is constant (i.e. not variable during the maneuver), most of the
  28.  * calculated parameters (thrust vector, flow rate etc.) do not depend on current spacecraft state.
  29.  * @author Maxime Journot
  30.  * @since 10.2
  31.  */
  32. public abstract class AbstractConstantThrustPropulsionModel implements ThrustPropulsionModel {

  33.     /** Initial thrust vector (N) in S/C frame, when building the object. */
  34.     private final Vector3D initialThrustVector;

  35.     /** Initial flow rate (kg/s), when building the object. */
  36.     private final double initialFlowRate;

  37.     /** User-defined name of the maneuver.
  38.      * This String attribute is empty by default.
  39.      * It is added as a prefix to the parameter drivers of the maneuver.
  40.      * The purpose is to differentiate between drivers in the case where several maneuvers
  41.      * were added to a propagator force model.
  42.      * Additionally, the user can retrieve the whole maneuver by looping on the force models of a propagator,
  43.      * scanning for its name.
  44.      * @since 9.2
  45.      */
  46.     private final String name;

  47.     /** Generic constructor.
  48.      * @param thrust initial thrust value (N)
  49.      * @param isp initial isp value (s)
  50.      * @param direction initial thrust direction in S/C frame
  51.      * @param name name of the maneuver
  52.      */
  53.     public AbstractConstantThrustPropulsionModel(final double thrust,
  54.                                                  final double isp,
  55.                                                  final Vector3D direction,
  56.                                                  final String name) {
  57.         this.name = name;
  58.         this.initialThrustVector = direction.normalize().scalarMultiply(thrust);
  59.         this.initialFlowRate = -thrust / (Constants.G0_STANDARD_GRAVITY * isp);
  60.     }

  61.     protected Vector3D getInitialThrustVector() {
  62.         return initialThrustVector;
  63.     }

  64.     protected double getInitialFlowrate() {
  65.         return initialFlowRate;
  66.     }

  67.     /** {@inheritDoc} */
  68.     @Override
  69.     public String getName() {
  70.         return name;
  71.     }

  72.     /** Get the specific impulse.
  73.      * @return specific impulse (s).
  74.      */
  75.     public double getIsp() {
  76.         final double thrust   = getThrust();
  77.         final double flowRate = getFlowRate();
  78.         return -thrust / (Constants.G0_STANDARD_GRAVITY * flowRate);
  79.     }

  80.     /** Get the thrust direction in S/C frame.
  81.      * @return the thrust direction in S/C frame
  82.      */
  83.     public Vector3D getDirection() {
  84.         return getThrustVector().normalize();
  85.     }

  86.     /** Get the thrust value (N).
  87.      * @return the thrust value (N)
  88.      */
  89.     public double getThrust() {
  90.         return getThrustVector().getNorm();
  91.     }

  92.     /** {@inheritDoc}
  93.      * Here the thrust vector do not depend on current S/C state.
  94.      */
  95.     @Override
  96.     public Vector3D getThrustVector(final SpacecraftState s) {
  97.         // Call the abstract function that do not depend on current S/C state
  98.         return getThrustVector();
  99.     }

  100.     /** {@inheritDoc}
  101.      * Here the flow rate do not depend on current S/C state
  102.      */
  103.     @Override
  104.     public double getFlowRate(final SpacecraftState s) {
  105.         // Call the abstract function that do not depend on current S/C state
  106.         return getFlowRate();
  107.     }

  108.     /** {@inheritDoc}
  109.      * Here the thrust vector do not depend on current S/C state.
  110.      */
  111.     @Override
  112.     public Vector3D getThrustVector(final SpacecraftState s, final double[] parameters) {
  113.         // Call the abstract function that do not depend on current S/C state
  114.         return getThrustVector(parameters);
  115.     }

  116.     /** {@inheritDoc}
  117.      * Here the flow rate do not depend on current S/C state
  118.      */
  119.     public double getFlowRate(final SpacecraftState s, final double[] parameters) {
  120.         // Call the abstract function that do not depend on current S/C state
  121.         return getFlowRate(parameters);
  122.     }

  123.     /** {@inheritDoc}
  124.      * Here the thrust vector do not depend on current S/C state.
  125.      */
  126.     public <T extends CalculusFieldElement<T>> FieldVector3D<T> getThrustVector(final FieldSpacecraftState<T> s,
  127.                                                                             final T[] parameters) {
  128.         // Call the abstract function that do not depend on current S/C state
  129.         return getThrustVector(parameters);
  130.     }

  131.     /** {@inheritDoc}
  132.      * Here the flow rate do not depend on current S/C state
  133.      */
  134.     public <T extends CalculusFieldElement<T>> T getFlowRate(final FieldSpacecraftState<T> s, final T[] parameters) {
  135.         // Call the abstract function that do not depend on current S/C state
  136.         return getFlowRate(parameters);
  137.     }

  138.     /** Get the thrust vector in spacecraft frame (N).
  139.      * Here it does not depend on current S/C state.
  140.      * @return thrust vector in spacecraft frame (N)
  141.      */
  142.     public abstract Vector3D getThrustVector();

  143.     /** Get the flow rate (kg/s).
  144.      * Here it does not depend on current S/C.
  145.      * @return flow rate (kg/s)
  146.      */
  147.     public abstract double getFlowRate();

  148.     /** Get the thrust vector in spacecraft frame (N).
  149.      * Here it does not depend on current S/C state.
  150.      * @param parameters propulsion model parameters
  151.      * @return thrust vector in spacecraft frame (N)
  152.      */
  153.     public abstract Vector3D getThrustVector(double[] parameters);

  154.     /** Get the flow rate (kg/s).
  155.      * Here it does not depend on current S/C state.
  156.      * @param parameters propulsion model parameters
  157.      * @return flow rate (kg/s)
  158.      */
  159.     public abstract double getFlowRate(double[] parameters);

  160.     /** Get the thrust vector in spacecraft frame (N).
  161.      * Here it does not depend on current S/C state.
  162.      * @param parameters propulsion model parameters
  163.      * @param <T> extends CalculusFieldElement&lt;T&gt;
  164.      * @return thrust vector in spacecraft frame (N)
  165.      */
  166.     public abstract <T extends CalculusFieldElement<T>> FieldVector3D<T> getThrustVector(T[] parameters);

  167.     /** Get the flow rate (kg/s).
  168.      * Here it does not depend on current S/C state.
  169.      * @param parameters propulsion model parameters
  170.      * @param <T> extends CalculusFieldElement&lt;T&gt;
  171.      * @return flow rate (kg/s)
  172.      */
  173.     public abstract <T extends CalculusFieldElement<T>> T getFlowRate(T[] parameters);
  174. }