FieldLnsCoefficients.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.propagation.semianalytical.dsst.utilities;

  18. import java.util.TreeMap;

  19. import org.hipparchus.Field;
  20. import org.hipparchus.CalculusFieldElement;
  21. import org.hipparchus.util.MathArrays;
  22. import org.orekit.propagation.semianalytical.dsst.utilities.CoefficientsFactory.NSKey;

  23. /** Compute the L<sub>n</sub><sup>s</sup>(γ).
  24.  *  <p>
  25.  *  The fomula used is: <br>
  26.  *  L<sub>n</sub><sup>s</sup>(γ) = ( R / a )<sup>n</sup>V<sub>ns</sub>Q<sup>ns</sup>(γ)
  27.  *  </p>
  28.  *  @author Lucian Barbulescu
  29.  */
  30. public class FieldLnsCoefficients <T extends CalculusFieldElement<T>> {

  31.     /** The coefficients L<sub>n</sub><sup>s</sup>(γ). */
  32.     private final T[][] lns;

  33.     /** The coefficients dL<sub>n</sub><sup>s</sup>(γ) / dγ. */
  34.     private final T[][] dlns;

  35.     /** Create a set of L<sub>n</sub><sup>s</sup>(γ) coefficients.
  36.     *
  37.     * @param nMax maximum value for n
  38.     * @param sMax maximum value for s
  39.     * @param Qns the Q<sup>ns</sup>(γ) coefficients
  40.     * @param Vns the V<sub>ns</sub> coefficients
  41.     * @param roa (R / a)
  42.     * @param field field used by default
  43.     */
  44.     public FieldLnsCoefficients(final int nMax, final int sMax,
  45.                                 final T[][] Qns, final TreeMap<NSKey, Double> Vns, final T roa,
  46.                                 final Field<T> field) {
  47.         final T zero      = field.getZero();
  48.         final int rows    = nMax + 1;
  49.         final int columns = sMax + 1;
  50.         this.lns          = MathArrays.buildArray(field, rows, columns);
  51.         this.dlns         = MathArrays.buildArray(field, rows, columns);

  52.         final T[] roaPow = MathArrays.buildArray(field, rows);
  53.         roaPow[0] = zero.add(1.);
  54.         for (int i = 1; i <= nMax; i++) {
  55.             roaPow[i] = roa.multiply(roaPow[i - 1]);
  56.         }
  57.         for (int s = 0; s <= sMax; s++) {
  58.             for (int n = s; n <= nMax; n++) {
  59.                 // if (n - s) is not even L<sub>n</sub><sup>s</sup>(γ) is 0
  60.                 if ((n - s) % 2 == 0) {
  61.                     final T coef = roaPow[n].multiply(Vns.get(new NSKey(n, s)));
  62.                     lns[n][s] = coef.multiply(Qns[n][s]);
  63.                     if ( n == s) {
  64.                         // if n == s the derivative is 0 because Q[n][s+1] == Q[n][n+1] is 0
  65.                         dlns[n][s] = zero;
  66.                     } else {
  67.                         dlns[n][s] = coef.multiply(Qns[n][s + 1]);
  68.                     }
  69.                 } else {
  70.                     lns[n][s]  = zero;
  71.                     dlns[n][s] = zero;
  72.                 }
  73.             }
  74.         }

  75.     }

  76.    /**Get the value of L<sub>n</sub><sup>s</sup>(γ).
  77.     *
  78.     * @param n n index
  79.     * @param s s index
  80.     * @return L<sub>n</sub><sup>s</sup>(γ)
  81.     */
  82.     public T getLns(final int n, final int s) {
  83.         return lns[n][s];
  84.     }

  85.    /**Get the value of dL<sub>n</sub><sup>s</sup> / dγ (γ).
  86.     *
  87.     * @param n n index
  88.     * @param s s index
  89.     * @return L<sub>n</sub><sup>s</sup>(γ)
  90.     */
  91.     public T getdLnsdGamma(final int n, final int s) {
  92.         return dlns[n][s];
  93.     }
  94. }