LnsCoefficients.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 java.util.TreeMap;

  19. import org.orekit.propagation.semianalytical.dsst.utilities.CoefficientsFactory.NSKey;

  20. /** Compute the L<sub>n</sub><sup>s</sup>(γ).
  21.  *  <p>
  22.  *  The fomula used is: <br>
  23.  *  L<sub>n</sub><sup>s</sup>(γ) = ( R / a )<sup>n</sup>V<sub>ns</sub>Q<sup>ns</sup>(γ)
  24.  *  </p>
  25.  *  @author Lucian Barbulescu
  26.  */
  27. public class LnsCoefficients {

  28.     /** The coefficients L<sub>n</sub><sup>s</sup>(γ). */
  29.     private final double[][] lns;

  30.     /** The coefficients dL<sub>n</sub><sup>s</sup>(γ) / dγ. */
  31.     private final double[][] dlns;

  32.     /** Create a set of L<sub>n</sub><sup>s</sup>(γ) coefficients.
  33.      *
  34.      * @param nMax maximum value for n
  35.      * @param sMax maximum value for s
  36.      * @param Qns the Q<sup>ns</sup>(γ) coefficients
  37.      * @param Vns the V<sub>ns</sub> coefficients
  38.      * @param roa (R / a)
  39.      */
  40.     public LnsCoefficients(final int nMax, final int sMax,
  41.             final double[][] Qns, final TreeMap<NSKey, Double> Vns, final double roa) {
  42.         final int rows    = nMax + 1;
  43.         final int columns = sMax + 1;
  44.         this.lns          = new double[rows][columns];
  45.         this.dlns         = new double[rows][columns];

  46.         final double[] roaPow = new double[rows];
  47.         roaPow[0] = 1.;
  48.         for (int i = 1; i <= nMax; i++) {
  49.             roaPow[i] = roa * roaPow[i - 1];
  50.         }
  51.         for (int s = 0; s <= sMax; s++) {
  52.             for (int n = s; n <= nMax; n++) {
  53.                 // if (n - s) is not even L<sub>n</sub><sup>s</sup>(γ) is 0
  54.                 if ((n - s) % 2 == 0) {
  55.                     final double coef = roaPow[n] * Vns.get(new NSKey(n, s));
  56.                     lns[n][s] = coef * Qns[n][s];
  57.                     if ( n == s) {
  58.                         // if n == s the derivative is 0 because Q[n][s+1] == Q[n][n+1] is 0
  59.                         dlns[n][s] = 0;
  60.                     } else {
  61.                         dlns[n][s] = coef * Qns[n][s + 1];
  62.                     }
  63.                 } else {
  64.                     lns[n][s] = 0.;
  65.                     dlns[n][s] = 0;
  66.                 }
  67.             }
  68.         }

  69.     }

  70.     /**Get the value of L<sub>n</sub><sup>s</sup>(γ).
  71.      *
  72.      * @param n n index
  73.      * @param s s index
  74.      * @return L<sub>n</sub><sup>s</sup>(γ)
  75.      */
  76.     public double getLns(final int n, final int s) {
  77.         return lns[n][s];
  78.     }

  79.     /**Get the value of dL<sub>n</sub><sup>s</sup> / dγ (γ).
  80.      *
  81.      * @param n n index
  82.      * @param s s index
  83.      * @return L<sub>n</sub><sup>s</sup>(γ)
  84.      */
  85.     public double getdLnsdGamma(final int n, final int s) {
  86.         return dlns[n][s];
  87.     }
  88. }