LibrationOrbit.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.orbits;

  18. import org.hipparchus.geometry.euclidean.threed.Vector3D;
  19. import org.hipparchus.linear.EigenDecomposition;
  20. import org.hipparchus.linear.RealMatrix;
  21. import org.hipparchus.linear.RealVector;
  22. import org.orekit.attitudes.AttitudeProvider;
  23. import org.orekit.bodies.CR3BPSystem;
  24. import org.orekit.propagation.SpacecraftState;
  25. import org.orekit.propagation.numerical.cr3bp.STMEquations;
  26. import org.orekit.time.TimeScale;
  27. import org.orekit.utils.PVCoordinates;

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

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

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

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

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

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

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

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

  84.     /** Apply differential correction.
  85.      * <p>
  86.      * This will update {@link #initialPV} and
  87.      * {@link #orbitalPeriod} parameters.
  88.      * </p>
  89.      * @param attitudeProvider the attitude law for the numerocal propagator
  90.      * @param utc UTC time scale
  91.      * @deprecated as of 11.1, replaced by {@link #applyDifferentialCorrection()}
  92.      */
  93.     @Deprecated
  94.     public void applyDifferentialCorrection(final AttitudeProvider attitudeProvider, final TimeScale utc) {
  95.         applyDifferentialCorrection();
  96.     }

  97.     /** Return a manifold direction from one position on a libration Orbit.
  98.      * @param s SpacecraftState with additional equations
  99.      * @param isStable true if the manifold is stable
  100.      * @return manifold first guess Position-Velocity of a point on the libration Orbit
  101.      */
  102.     public PVCoordinates getManifolds(final SpacecraftState s,
  103.                                       final boolean isStable) {
  104.         return isStable ? getStableManifolds(s) : getUnstableManifolds(s);
  105.     }

  106.     /** Return the stable manifold direction for several positions on a libration Orbit.
  107.      * @param s SpacecraftStates (with STM equations) to compute from
  108.      * @return Stable manifold first direction from a point on the libration Orbit
  109.      */
  110.     private PVCoordinates getStableManifolds(final SpacecraftState s) {

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

  113.         // Get Normalize eigen vector linked to the stability of the manifold
  114.         final RealMatrix phi         = new STMEquations(syst).getStateTransitionMatrix(s);
  115.         final RealVector eigenVector = new EigenDecomposition(phi).getEigenvector(1).unitVector();

  116.         // New PVCoordinates following the manifold
  117.         return new PVCoordinates(s.getPVCoordinates().getPosition()
  118.                 .add(new Vector3D(eigenVector.getEntry(0), eigenVector
  119.                         .getEntry(1), eigenVector.getEntry(2))
  120.                             .scalarMultiply(epsilon)), s.getPVCoordinates()
  121.                                 .getVelocity()
  122.                                 .add(new Vector3D(eigenVector.getEntry(3),
  123.                                                   eigenVector.getEntry(4),
  124.                                                   eigenVector.getEntry(5))
  125.                                                       .scalarMultiply(epsilon)));
  126.     }

  127.     /** Get the Unstable manifold direction for several positions on a libration Orbit.
  128.      * @param s spacecraft state (with STM equations) to compute from
  129.      * @return pv coordinates representing the unstable manifold first direction
  130.      *         from a point on the libration Orbit
  131.      */
  132.     private PVCoordinates getUnstableManifolds(final SpacecraftState s) {

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

  136.         // Get Normalize eigen vector linked to the stability of the manifold
  137.         final RealMatrix phi         = new STMEquations(syst).getStateTransitionMatrix(s);
  138.         final RealVector eigenVector = new EigenDecomposition(phi).getEigenvector(0).unitVector();

  139.         // New PVCoordinates following the manifold
  140.         return new PVCoordinates(s.getPVCoordinates().getPosition()
  141.                     .add(new Vector3D(eigenVector.getEntry(0), eigenVector
  142.                         .getEntry(1), eigenVector.getEntry(2))
  143.                             .scalarMultiply(epsilon)), s.getPVCoordinates()
  144.                                 .getVelocity()
  145.                                 .add(new Vector3D(eigenVector.getEntry(3),
  146.                                                   eigenVector.getEntry(4),
  147.                                                   eigenVector.getEntry(5))
  148.                                                       .scalarMultiply(epsilon)));
  149.     }

  150.     /**
  151.      * Apply the differential correction to compute more accurate initial PV.
  152.      * @param diff cr3bp differential correction
  153.      * @return corrected PV coordinates
  154.      */
  155.     protected abstract PVCoordinates applyCorrectionOnPV(CR3BPDifferentialCorrection diff);

  156. }