BasicConstantThrustPropulsionModel.java

  1. /* Copyright 2002-2020 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.RealFieldElement;
  19. import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
  20. import org.hipparchus.geometry.euclidean.threed.Vector3D;
  21. import org.hipparchus.util.FastMath;
  22. import org.orekit.utils.Constants;
  23. import org.orekit.utils.ParameterDriver;

  24. /** Constant thrust propulsion model with:
  25.  *  - Constant thrust direction in spacecraft frame
  26.  *  - Parameter drivers (for estimation) for the thrust norm or the flow rate.
  27.  * Note that both parameters CANNOT be selected at the same time since they depend on one another.
  28.  * @author Maxime Journot
  29.  * @since 10.2
  30.  */
  31. public class BasicConstantThrustPropulsionModel extends AbstractConstantThrustPropulsionModel {

  32.     /** Parameter name for thrust. */
  33.     public static final String THRUST = "thrust";

  34.     /** Parameter name for flow rate. */
  35.     public static final String FLOW_RATE = "flow rate";

  36.     /** Thrust scaling factor.
  37.      * <p>
  38.      * We use a power of 2 to avoid numeric noise introduction
  39.      * in the multiplications/divisions sequences.
  40.      * </p>
  41.      */
  42.     public static final double THRUST_SCALE = FastMath.scalb(1.0, -5);

  43.     /** Flow rate scaling factor.
  44.      * <p>
  45.      * We use a power of 2 to avoid numeric noise introduction
  46.      * in the multiplications/divisions sequences.
  47.      * </p>
  48.      */
  49.     public static final double FLOW_RATE_SCALE = FastMath.scalb(1.0, -12);

  50.     /** Driver for thrust parameter. */
  51.     private final ParameterDriver thrustDriver;

  52.     /** Driver for flow rate parameter. */
  53.     private final ParameterDriver flowRateDriver;

  54.     /** Thrust direction in spacecraft frame. */
  55.     private final Vector3D direction;

  56.     /** Simple constructor.
  57.      * @param thrust thrust (N)
  58.      * @param isp isp (s)
  59.      * @param direction direction in spacecraft frame
  60.      * @param name name of the maneuver
  61.      */
  62.     public BasicConstantThrustPropulsionModel(final double thrust,
  63.                                               final double isp,
  64.                                               final Vector3D direction,
  65.                                               final String name) {
  66.         super(thrust, isp, direction, name);
  67.         this.direction = direction.normalize();

  68.         final double initialFlowRate = -thrust / (Constants.G0_STANDARD_GRAVITY * isp);

  69.         // Build the parameter drivers, using maneuver name as prefix
  70.         this.thrustDriver   = new ParameterDriver(name + THRUST, thrust, THRUST_SCALE,
  71.                                                   0.0, Double.POSITIVE_INFINITY);
  72.         this.flowRateDriver = new ParameterDriver(name + FLOW_RATE, initialFlowRate, FLOW_RATE_SCALE,
  73.                                                   Double.NEGATIVE_INFINITY, 0.0 );
  74.     }

  75.     /** {@inheritDoc} */
  76.     @Override
  77.     public Vector3D getThrustVector() {
  78.         // Thrust vector does not depend on spacecraft state for a constant maneuver.
  79.         return direction.scalarMultiply(thrustDriver.getValue());
  80.     }

  81.     /** {@inheritDoc} */
  82.     @Override
  83.     public double getFlowRate() {
  84.         // Flow rate does not depend on spacecraft state for a constant maneuver.
  85.         return flowRateDriver.getValue();
  86.     }

  87.     /** {@inheritDoc} */
  88.     @Override
  89.     public ParameterDriver[] getParametersDrivers() {
  90.         return new ParameterDriver[] {
  91.             thrustDriver, flowRateDriver
  92.         };
  93.     }

  94.     /** {@inheritDoc} */
  95.     @Override
  96.     public Vector3D getThrustVector(final double[] parameters) {
  97.         // Thrust vector does not depend on spacecraft state for a constant maneuver.
  98.         return direction.scalarMultiply(parameters[0]);
  99.     }

  100.     /** {@inheritDoc} */
  101.     @Override
  102.     public double getFlowRate(final double[] parameters) {
  103.         return parameters[1];
  104.     }

  105.     /** {@inheritDoc} */
  106.     @Override
  107.     public <T extends RealFieldElement<T>> FieldVector3D<T> getThrustVector(final T[] parameters) {
  108.         return new FieldVector3D<T>(parameters[0], direction);
  109.     }

  110.     /** {@inheritDoc} */
  111.     @Override
  112.     public <T extends RealFieldElement<T>> T getFlowRate(final T[] parameters) {
  113.         return parameters[1];
  114.     }
  115. }