1 /* Copyright 2022-2025 Romain Serra
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.control.indirect.adjoint.cost;
18
19
20 import org.hipparchus.geometry.euclidean.threed.Vector3D;
21
22 /**
23 * Class for minimizing the flight duration (a.k.a. time of flight) with Cartesian coordinates.
24 * It is the integral over time of the constant one. The control is assumed to be bounded.
25 * It also assumes that no external acceleration depends on mass.
26 * If the mass flow rate factor is zero, then there is no adjoint for the mass.
27 *
28 * @author Romain Serra
29 * @see CartesianCost
30 * @since 13.0
31 */
32 public class CartesianFlightDurationCost extends AbstractCartesianCost {
33
34 /**
35 * Maximum value of thrust force Euclidean norm.
36 */
37 private final double maximumThrustMagnitude;
38
39 /**
40 * Constructor.
41 *
42 * @param name name
43 * @param massFlowRateFactor mass flow rate factor
44 * @param maximumThrustMagnitude maximum thrust magnitude
45 */
46 public CartesianFlightDurationCost(final String name, final double massFlowRateFactor,
47 final double maximumThrustMagnitude) {
48 super(name, massFlowRateFactor);
49 this.maximumThrustMagnitude = maximumThrustMagnitude;
50 }
51
52 /**
53 * Getter for maximum thrust magnitude.
54 *
55 * @return maximum thrust
56 */
57 public double getMaximumThrustMagnitude() {
58 return maximumThrustMagnitude;
59 }
60
61 /**
62 * {@inheritDoc}
63 */
64 @Override
65 public Vector3D getThrustAccelerationVector(final double[] adjointVariables, final double mass) {
66 return new Vector3D(adjointVariables[3], adjointVariables[4], adjointVariables[5]).normalize()
67 .scalarMultiply(maximumThrustMagnitude);
68 }
69
70 /**
71 * {@inheritDoc}
72 */
73 @Override
74 public void updateAdjointDerivatives(final double[] adjointVariables, final double mass,
75 final double[] adjointDerivatives) {
76 if (getAdjointDimension() > 6) {
77 adjointDerivatives[6] += getAdjointVelocityNorm(adjointVariables) * maximumThrustMagnitude / (mass * mass);
78 }
79 }
80
81 /**
82 * {@inheritDoc}
83 */
84 @Override
85 public double getHamiltonianContribution(final double[] adjointVariables, final double mass) {
86 return -1.;
87 }
88 }