SolidTides.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.forces.gravity;

  18. import java.util.List;
  19. import java.util.stream.Stream;

  20. import org.hipparchus.Field;
  21. import org.hipparchus.CalculusFieldElement;
  22. import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
  23. import org.hipparchus.geometry.euclidean.threed.Vector3D;
  24. import org.orekit.bodies.CelestialBody;
  25. import org.orekit.forces.AbstractForceModel;
  26. import org.orekit.forces.ForceModel;
  27. import org.orekit.forces.gravity.potential.CachedNormalizedSphericalHarmonicsProvider;
  28. import org.orekit.forces.gravity.potential.NormalizedSphericalHarmonicsProvider;
  29. import org.orekit.forces.gravity.potential.TideSystem;
  30. import org.orekit.frames.Frame;
  31. import org.orekit.propagation.FieldSpacecraftState;
  32. import org.orekit.propagation.SpacecraftState;
  33. import org.orekit.propagation.events.EventDetector;
  34. import org.orekit.propagation.events.FieldEventDetector;
  35. import org.orekit.time.TimeScales;
  36. import org.orekit.time.UT1Scale;
  37. import org.orekit.utils.Constants;
  38. import org.orekit.utils.IERSConventions;
  39. import org.orekit.utils.OrekitConfiguration;
  40. import org.orekit.utils.ParameterDriver;

  41. /** Solid tides force model.
  42.  * @since 6.1
  43.  * @author Luc Maisonobe
  44.  */
  45. public class SolidTides extends AbstractForceModel {

  46.     /** Default step for tides field sampling (seconds). */
  47.     public static final double DEFAULT_STEP = 600.0;

  48.     /** Default number of points tides field sampling. */
  49.     public static final int DEFAULT_POINTS = 12;

  50.     /** Underlying attraction model. */
  51.     private final ForceModel attractionModel;

  52.     /** Simple constructor.
  53.      * <p>
  54.      * This constructor uses pole tides, the default {@link #DEFAULT_STEP step} and default
  55.      * {@link #DEFAULT_POINTS number of points} for the tides field interpolation.
  56.      * </p>
  57.      * @param centralBodyFrame rotating body frame
  58.      * @param ae central body reference radius
  59.      * @param mu central body attraction coefficient
  60.      * @param centralTideSystem tide system used in the central attraction model
  61.      * @param conventions IERS conventions used for loading Love numbers
  62.      * @param ut1 UT1 time scale
  63.      * @param bodies tide generating bodies (typically Sun and Moon)
  64.      * @see #DEFAULT_STEP
  65.      * @see #DEFAULT_POINTS
  66.      * @see #SolidTides(Frame, double, double, TideSystem, boolean, double, int, IERSConventions, UT1Scale, CelestialBody...)
  67.      */
  68.     public SolidTides(final Frame centralBodyFrame, final double ae, final double mu,
  69.                       final TideSystem centralTideSystem,
  70.                       final IERSConventions conventions, final UT1Scale ut1,
  71.                       final CelestialBody... bodies) {
  72.         this(centralBodyFrame, ae, mu, centralTideSystem, true,
  73.              DEFAULT_STEP, DEFAULT_POINTS, conventions, ut1, bodies);
  74.     }

  75.     /** Simple constructor.
  76.      * @param centralBodyFrame rotating body frame
  77.      * @param ae central body reference radius
  78.      * @param mu central body attraction coefficient
  79.      * @param centralTideSystem tide system used in the central attraction model
  80.      * @param poleTide if true, pole tide is computed
  81.      * @param step time step between sample points for interpolation
  82.      * @param nbPoints number of points to use for interpolation, if less than 2
  83.      * then no interpolation is performed (thus greatly increasing computation cost)
  84.      * @param conventions IERS conventions used for loading Love numbers
  85.      * @param ut1 UT1 time scale
  86.      * @param bodies tide generating bodies (typically Sun and Moon)
  87.      */
  88.     public SolidTides(final Frame centralBodyFrame, final double ae, final double mu,
  89.                       final TideSystem centralTideSystem, final boolean poleTide,
  90.                       final double step, final int nbPoints,
  91.                       final IERSConventions conventions, final UT1Scale ut1,
  92.                       final CelestialBody... bodies) {
  93.         final TimeScales timeScales = ut1.getEOPHistory().getTimeScales();
  94.         final SolidTidesField raw =
  95.                 new SolidTidesField(conventions.getLoveNumbers(),
  96.                                     conventions.getTideFrequencyDependenceFunction(ut1, timeScales),
  97.                                     conventions.getPermanentTide(),
  98.                                     poleTide ? conventions.getSolidPoleTide(ut1.getEOPHistory()) : null,
  99.                                              centralBodyFrame, ae, mu, centralTideSystem, bodies);
  100.         final NormalizedSphericalHarmonicsProvider provider;
  101.         if (nbPoints < 2) {
  102.             provider = raw;
  103.         } else {
  104.             provider =
  105.                 new CachedNormalizedSphericalHarmonicsProvider(raw, step, nbPoints,
  106.                                                                OrekitConfiguration.getCacheSlotsNumber(),
  107.                                                                7 * Constants.JULIAN_DAY,
  108.                                                                0.5 * Constants.JULIAN_DAY);
  109.         }
  110.         attractionModel = new HolmesFeatherstoneAttractionModel(centralBodyFrame, provider);
  111.     }

  112.     /** {@inheritDoc} */
  113.     @Override
  114.     public boolean dependsOnPositionOnly() {
  115.         return attractionModel.dependsOnPositionOnly();
  116.     }

  117.     /** {@inheritDoc} */
  118.     @Override
  119.     public Vector3D acceleration(final SpacecraftState s, final double[] parameters) {
  120.         // delegate to underlying attraction model
  121.         return attractionModel.acceleration(s, parameters);
  122.     }

  123.     /** {@inheritDoc} */
  124.     @Override
  125.     public <T extends CalculusFieldElement<T>> FieldVector3D<T> acceleration(final FieldSpacecraftState<T> s,
  126.                                                                          final T[] parameters) {
  127.         // delegate to underlying attraction model
  128.         return attractionModel.acceleration(s, parameters);
  129.     }

  130.     /** {@inheritDoc} */
  131.     @Override
  132.     public Stream<EventDetector> getEventsDetectors() {
  133.         // delegate to underlying attraction model
  134.         return attractionModel.getEventsDetectors();
  135.     }

  136.     /** {@inheritDoc} */
  137.     @Override
  138.     public <T extends CalculusFieldElement<T>> Stream<FieldEventDetector<T>> getFieldEventsDetectors(final Field<T> field) {
  139.         // delegate to underlying attraction model
  140.         return attractionModel.getFieldEventsDetectors(field);
  141.     }

  142.     /** {@inheritDoc} */
  143.     @Override
  144.     public List<ParameterDriver> getParametersDrivers() {
  145.         // delegate to underlying attraction model
  146.         return attractionModel.getParametersDrivers();
  147.     }

  148. }