LibrationOrbit.java

  1. /* Copyright 2002-2024 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.orbits;

  18. import org.hipparchus.complex.Complex;
  19. import org.hipparchus.geometry.euclidean.threed.Vector3D;
  20. import org.hipparchus.linear.EigenDecompositionNonSymmetric;
  21. import org.hipparchus.linear.FieldVector;
  22. import org.hipparchus.linear.MatrixUtils;
  23. import org.hipparchus.linear.RealMatrix;
  24. import org.hipparchus.linear.RealVector;
  25. import org.orekit.bodies.CR3BPSystem;
  26. import org.orekit.propagation.SpacecraftState;
  27. import org.orekit.propagation.numerical.cr3bp.STMEquations;
  28. import org.orekit.utils.PVCoordinates;

  29. /**
  30.  * Base class for libration orbits.
  31.  * @see HaloOrbit
  32.  * @see LyapunovOrbit
  33.  * @author Vincent Mouraux
  34.  * @author Bryan Cazabonne
  35.  * @since 10.2
  36.  */
  37. public abstract class LibrationOrbit {

  38.     /** CR3BP System of the libration Orbit. */
  39.     private final CR3BPSystem syst;

  40.     /** Position-Velocity initial position on a libration Orbit. */
  41.     private PVCoordinates initialPV;

  42.     /** Orbital Period of the libration Orbit. */
  43.     private double orbitalPeriod;

  44.     /**
  45.      * Constructor.
  46.      * @param system CR3BP System considered
  47.      * @param initialPV initial position on a libration Orbit
  48.      * @param orbitalPeriod initial orbital period of the libration Orbit
  49.      */
  50.     protected LibrationOrbit(final CR3BPSystem system,
  51.                              final PVCoordinates initialPV,
  52.                              final double orbitalPeriod) {
  53.         this.syst = system;
  54.         this.initialPV = initialPV;
  55.         this.orbitalPeriod = orbitalPeriod;
  56.     }

  57.     /** Return the orbital period of the libration orbit.
  58.      * @return orbitalPeriod  orbital period of the libration orbit
  59.      */
  60.     public double getOrbitalPeriod() {
  61.         return orbitalPeriod;
  62.     }

  63.     /** Return the initialPV on the libration orbit.
  64.      * <p>
  65.      * This will return the exact initialPV only if you applied a prior
  66.      * differential correction. If you did not, you can use the method
  67.      * {@link #applyCorrectionOnPV(CR3BPDifferentialCorrection)}
  68.      * </p>
  69.      * @return initialPV initialPV on the libration orbit
  70.      */
  71.     public PVCoordinates getInitialPV() {
  72.         return initialPV;
  73.     }

  74.     /** Apply differential correction.
  75.      * <p>
  76.      * This will update {@link #initialPV} and
  77.      * {@link #orbitalPeriod} parameters.
  78.      * </p>
  79.      */
  80.     public void applyDifferentialCorrection() {
  81.         final CR3BPDifferentialCorrection diff = new CR3BPDifferentialCorrection(initialPV, syst, orbitalPeriod);
  82.         initialPV = applyCorrectionOnPV(diff);
  83.         orbitalPeriod = diff.getOrbitalPeriod();
  84.     }

  85.     /** Return a manifold direction from one position on a libration Orbit.
  86.      * @param s SpacecraftState with additional equations
  87.      * @param isStable true if the manifold is stable
  88.      * @return manifold first guess Position-Velocity of a point on the libration Orbit
  89.      */
  90.     public PVCoordinates getManifolds(final SpacecraftState s, final boolean isStable) {

  91.         // Get the index of the eigen vector of the state transition matrix,
  92.         // depending on the stability or unstability of the manifold
  93.         final int eigenVectorIndex = isStable ? 1 : 0;

  94.         // Small delta, linked to the characteristic velocity of the CR3BP system
  95.         final double epsilon = syst.getVdim() * 1E2 / syst.getDdim();

  96.         // Get monodromy (i.e. state transition) matrix and its eigen decomposition
  97.         final RealMatrix phi = new STMEquations(syst).getStateTransitionMatrix(s);
  98.         final EigenDecompositionNonSymmetric eigen = new EigenDecompositionNonSymmetric(phi);

  99.         // Get normalized eigen vector linked to the stability of the manifold
  100.         final FieldVector<Complex> cv = eigen.getEigenvector(eigenVectorIndex);

  101.         // Get real vector value and normalize
  102.         final RealVector           rv = MatrixUtils.createRealVector(cv.getDimension());
  103.         for (int i = 0; i < cv.getDimension(); ++i) {
  104.             rv.setEntry(i, cv.getEntry(i).getRealPart());
  105.         }
  106.         final RealVector eigenVector = rv.unitVector();

  107.         // New PVCoordinates following the manifold
  108.         return new PVCoordinates(s.getPosition().add(new Vector3D(eigenVector.getEntry(0),
  109.                                                                   eigenVector.getEntry(1),
  110.                                                                   eigenVector.getEntry(2)).scalarMultiply(epsilon)),
  111.                                  s.getPVCoordinates().getVelocity().add(new Vector3D(eigenVector.getEntry(3),
  112.                                                                                      eigenVector.getEntry(4),
  113.                                                                                      eigenVector.getEntry(5)).scalarMultiply(epsilon)));
  114.     }

  115.     /**
  116.      * Apply the differential correction to compute more accurate initial PV.
  117.      * @param diff cr3bp differential correction
  118.      * @return corrected PV coordinates
  119.      */
  120.     protected abstract PVCoordinates applyCorrectionOnPV(CR3BPDifferentialCorrection diff);

  121. }