1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.orekit.control.indirect.adjoint.cost;
18
19 import org.hipparchus.geometry.euclidean.threed.Vector3D;
20 import org.hipparchus.util.FastMath;
21
22
23
24
25
26
27
28 public class LogarithmicBarrierCartesianFuel extends PenalizedCartesianFuelCost {
29
30
31
32
33
34
35
36
37
38 public LogarithmicBarrierCartesianFuel(final String name, final double massFlowRateFactor,
39 final double maximumThrustMagnitude, final double epsilon) {
40 super(name, massFlowRateFactor, maximumThrustMagnitude, epsilon);
41 }
42
43
44 @Override
45 public double evaluatePenaltyFunction(final double controlNorm) {
46 return FastMath.log(controlNorm) + FastMath.log(1. - controlNorm);
47 }
48
49
50 @Override
51 public Vector3D getThrustAccelerationVector(final double[] adjointVariables, final double mass) {
52 final double thrustForceMagnitude = getThrustForceMagnitude(adjointVariables, mass);
53 return getThrustDirection(adjointVariables).scalarMultiply(thrustForceMagnitude / mass);
54 }
55
56
57 @Override
58 public void updateAdjointDerivatives(final double[] adjointVariables, final double mass,
59 final double[] adjointDerivatives) {
60 if (getAdjointDimension() > 6) {
61 adjointDerivatives[6] += getAdjointVelocityNorm(adjointVariables) * getThrustForceMagnitude(adjointVariables,
62 mass) / (mass * mass);
63 }
64 }
65
66
67
68
69
70
71
72 private double getThrustForceMagnitude(final double[] adjointVariables, final double mass) {
73 final double twoEpsilon = getEpsilon() * 2;
74 double otherTerm = getAdjointVelocityNorm(adjointVariables) / mass - 1;
75 if (getAdjointDimension() > 6) {
76 otherTerm -= getMassFlowRateFactor() * adjointVariables[6];
77 }
78 return twoEpsilon * getMaximumThrustMagnitude() / (twoEpsilon + otherTerm + FastMath.sqrt(otherTerm * otherTerm + twoEpsilon * twoEpsilon));
79 }
80 }