BasicConstantThrustPropulsionModel.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 java.util.Arrays;
  19. import java.util.List;

  20. import org.hipparchus.CalculusFieldElement;
  21. import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
  22. import org.hipparchus.geometry.euclidean.threed.Vector3D;
  23. import org.hipparchus.util.FastMath;
  24. import org.orekit.utils.Constants;
  25. import org.orekit.utils.ParameterDriver;

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

  34.     /** Parameter name for thrust. */
  35.     public static final String THRUST = "thrust";

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

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

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

  52.     /** Driver for thrust parameter. */
  53.     private final ParameterDriver thrustDriver;

  54.     /** Driver for flow rate parameter. */
  55.     private final ParameterDriver flowRateDriver;

  56.     /** Thrust direction in spacecraft frame. */
  57.     private final Vector3D direction;

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

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

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

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

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

  89.     /** {@inheritDoc} */
  90.     @Override
  91.     public List<ParameterDriver> getParametersDrivers() {
  92.         return Arrays.asList(thrustDriver, flowRateDriver);
  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 CalculusFieldElement<T>> FieldVector3D<T> getThrustVector(final T[] parameters) {
  108.         return new FieldVector3D<T>(parameters[0], direction);
  109.     }

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