BasicConstantThrustPropulsionModel.java

  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. package org.orekit.forces.maneuvers.propulsion;

  18. import java.util.Arrays;
  19. import java.util.Collections;
  20. import java.util.List;

  21. import org.hipparchus.CalculusFieldElement;
  22. import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
  23. import org.hipparchus.geometry.euclidean.threed.Vector3D;
  24. import org.hipparchus.util.FastMath;
  25. import org.orekit.forces.maneuvers.Control3DVectorCostType;
  26. import org.orekit.time.AbsoluteDate;
  27. import org.orekit.utils.ParameterDriver;

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

  36.     /** Parameter name for thrust. */
  37.     public static final String THRUST = "thrust";

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

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

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

  54.     /** Driver for thrust parameter. */
  55.     private final ParameterDriver thrustDriver;

  56.     /** Driver for flow rate parameter. */
  57.     private final ParameterDriver flowRateDriver;

  58.     /** Thrust direction in spacecraft frame. */
  59.     private final Vector3D direction;

  60.     /** Generic constructor.
  61.      * @param thrust thrust (N)
  62.      * @param isp isp (s)
  63.      * @param direction direction in spacecraft frame
  64.      * @param control3DVectorCostType control cost type
  65.      * @param name name of the maneuver
  66.      * @since 12.0
  67.      */
  68.     public BasicConstantThrustPropulsionModel(final double thrust,
  69.                                               final double isp,
  70.                                               final Vector3D direction,
  71.                                               final Control3DVectorCostType control3DVectorCostType,
  72.                                               final String name) {
  73.         super(thrust, isp, direction, control3DVectorCostType, name);
  74.         this.direction = direction.normalize();

  75.         final double initialFlowRate = super.getInitialFlowRate();

  76.         // Build the parameter drivers, using maneuver name as prefix
  77.         this.thrustDriver   = new ParameterDriver(name + THRUST, thrust, THRUST_SCALE,
  78.                                                   0.0, Double.POSITIVE_INFINITY);
  79.         this.flowRateDriver = new ParameterDriver(name + FLOW_RATE, initialFlowRate, FLOW_RATE_SCALE,
  80.                                                   Double.NEGATIVE_INFINITY, 0.0 );
  81.     }

  82.     /** Simple constructor.
  83.      * @param thrust thrust (N)
  84.      * @param isp isp (s)
  85.      * @param direction direction in spacecraft frame
  86.      * @param name name of the maneuver
  87.      */
  88.     public BasicConstantThrustPropulsionModel(final double thrust,
  89.                                               final double isp,
  90.                                               final Vector3D direction,
  91.                                               final String name) {
  92.         this(thrust, isp, direction, DEFAULT_CONTROL_3D_VECTOR_COST_TYPE, name);
  93.     }

  94.     /** {@inheritDoc} */
  95.     @Override
  96.     public Vector3D getThrustVector() {
  97.         // Thrust vector does not depend on spacecraft state for a constant maneuver.
  98.         // thrustDriver as only 1 value estimated over the whole time period
  99.         // by construction thrustDriver has only 1 value estimated over the all period
  100.         // that is why no argument is acceptable
  101.         return direction.scalarMultiply(thrustDriver.getValue());
  102.     }

  103.     /** {@inheritDoc} */
  104.     @Override
  105.     public Vector3D getThrustVector(final AbsoluteDate date) {
  106.         // Thrust vector does not depend on spacecraft state for a constant maneuver.
  107.         return direction.scalarMultiply(thrustDriver.getValue(date));
  108.     }

  109.     /** {@inheritDoc} */
  110.     @Override
  111.     public double getFlowRate() {
  112.         // Thrust vector does not depend on spacecraft state for a constant maneuver.
  113.         // thrustDriver has only 1 value estimated over the whole time period
  114.         // by construction thrustDriver has only 1 value estimated over the all period
  115.         // that is why no argument is acceptable
  116.         return flowRateDriver.getValue();
  117.     }

  118.     /** {@inheritDoc} */
  119.     @Override
  120.     public double getFlowRate(final AbsoluteDate date) {
  121.         return flowRateDriver.getValue(date);
  122.     }

  123.     /** {@inheritDoc} */
  124.     @Override
  125.     public List<ParameterDriver> getParametersDrivers() {
  126.         return Collections.unmodifiableList(Arrays.asList(thrustDriver, flowRateDriver));
  127.     }

  128.     /** {@inheritDoc} */
  129.     @Override
  130.     public Vector3D getThrustVector(final double[] parameters) {
  131.         // Thrust vector does not depend on spacecraft state for a constant maneuver.
  132.         return direction.scalarMultiply(parameters[0]);
  133.     }

  134.     /** {@inheritDoc} */
  135.     @Override
  136.     public double getFlowRate(final double[] parameters) {
  137.         return parameters[1];
  138.     }

  139.     /** {@inheritDoc} */
  140.     @Override
  141.     public <T extends CalculusFieldElement<T>> FieldVector3D<T> getThrustVector(final T[] parameters) {
  142.         return new FieldVector3D<>(parameters[0], direction);
  143.     }

  144.     /** {@inheritDoc} */
  145.     @Override
  146.     public <T extends CalculusFieldElement<T>> T getFlowRate(final T[] parameters) {
  147.         return parameters[1];
  148.     }
  149. }