UpperBounds.java

  1. /* Copyright 2002-2018 CS Systèmes d'Information
  2.  * Licensed to CS Systèmes d'Information (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.propagation.semianalytical.dsst.utilities;

  18. import org.hipparchus.util.FastMath;


  19. /** Utility class to compute upper bounds for truncation algorithms.
  20.  *
  21.  *  @author Pascal Parraud
  22.  */
  23. public class UpperBounds {

  24.     /** Private constructor as the class is a utility class. */
  25.     private UpperBounds() {
  26.     }

  27.     /** Get the upper bound value D<sub>n</sub><sup>l</sup>(&Chi;).
  28.      *
  29.      * @param xx value of &Chi;²
  30.      * @param xpl value of &Chi; * (&Chi;² / 2)<sup>l</sup>
  31.      * @param n index n (power of a/R)
  32.      * @param l index l (power of eccentricity)
  33.      * @return the upper bound D<sub>n</sub><sup>l</sup>(&Chi;)
  34.      */
  35.     public static double getDnl(final double xx, final double xpl, final int n, final int l) {
  36.         final int lp2 = l + 2;
  37.         if (n > lp2) {
  38.             final int ll = l * l;
  39.             double dM = xpl;
  40.             double dL = dM;
  41.             double dB = (l + 1) * xx * xpl;
  42.             for (int j = l + 3; j <= n; j++) {
  43.                 final int jm1 = j - 1;
  44.                 dL = dM;
  45.                 dM = dB;
  46.                 dB = jm1 * xx * ((2 * j - 3) * dM - (j - 2) * dL) / (jm1 * jm1 - ll);
  47.             }
  48.             return dB;
  49.         } else if (n == lp2) {
  50.             return  (l + 1) * xx * xpl;
  51.         } else {
  52.             return xpl;
  53.         }
  54.     }

  55.     /** Get the upper bound value R<sup>ε</sup><sub>n,m,l</sub>(γ).
  56.      *
  57.      * @param gamma value of γ
  58.      * @param n index n
  59.      * @param l index l
  60.      * @param m index m
  61.      * @param eps ε value (+1/-1)
  62.      * @param irf retrograde factor I (+1/-1)
  63.      * @return the upper bound R<sup>ε</sup><sub>n,m,l</sub>(γ)
  64.      */
  65.     public static double getRnml(final double gamma,
  66.                                  final int n, final int l, final int m,
  67.                                  final int eps, final int irf) {
  68.         // Initialization
  69.         final int mei = m * eps * irf;
  70.         final double sinisq = 1. - gamma * gamma;
  71.         // Set a lower bound for inclination
  72.         final double sininc = FastMath.max(0.03, FastMath.sqrt(sinisq));
  73.         final double onepig = 1. + gamma * irf;
  74.         final double sinincPowLmMEI = FastMath.pow(sininc, l - mei);
  75.         final double onepigPowLmMEI = FastMath.pow(onepig, mei);

  76.         // Bound for index 0
  77.         double rBound = sinincPowLmMEI * onepigPowLmMEI;

  78.         // If index > 0
  79.         if (n > l) {
  80.             final int lp1 = l + 1;

  81.             double dpnml  = lp1 * eps;
  82.             double pnml   = dpnml * gamma - m;

  83.             // If index > 1
  84.             if (n > l + 1) {
  85.                 final int ll  = l * l;
  86.                 final int ml  = m * l;
  87.                 final int mm  = m * m;

  88.                 double pn1ml  = 1.;
  89.                 double dpn1ml = 0.;
  90.                 double pn2ml  = 1.;
  91.                 double dpn2ml = 0.;
  92.                 for (int in = l + 2; in <= n; in++) {
  93.                     final int nm1   = in - 1;
  94.                     final int tnm1  = in + nm1;
  95.                     final int nnlnl = nm1 * (in * in - ll);
  96.                     final int nnmnm = in * (nm1 * nm1 - mm);
  97.                     final int c2nne = tnm1 * in * nm1 * eps;
  98.                     final int c2nml = tnm1 * ml;
  99.                     final double coef = c2nne * gamma - c2nml;

  100.                     pn2ml  = pn1ml;
  101.                     dpn2ml = dpn1ml;
  102.                     pn1ml  = pnml;
  103.                     dpn1ml = dpnml;
  104.                     pnml   = (coef * pn1ml  - nnmnm * pn2ml) / nnlnl;
  105.                     dpnml  = (coef * dpn1ml - nnmnm * dpn2ml + c2nne * pn1ml) / nnlnl;
  106.                 }
  107.             }
  108.             // Bound for index > 0
  109.             rBound *= FastMath.sqrt(pnml * pnml + dpnml * dpnml * sinisq / ((n - l) * (n + lp1)));
  110.         }

  111.         return rBound;
  112.     }

  113. }