SolidTides.java

  1. /* Copyright 2002-2024 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.CalculusFieldElement;
  21. import org.hipparchus.Field;
  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.ForceModel;
  26. import org.orekit.forces.gravity.potential.CachedNormalizedSphericalHarmonicsProvider;
  27. import org.orekit.forces.gravity.potential.NormalizedSphericalHarmonicsProvider;
  28. import org.orekit.forces.gravity.potential.TideSystem;
  29. import org.orekit.frames.Frame;
  30. import org.orekit.propagation.FieldSpacecraftState;
  31. import org.orekit.propagation.SpacecraftState;
  32. import org.orekit.propagation.events.EventDetector;
  33. import org.orekit.propagation.events.FieldEventDetector;
  34. import org.orekit.time.TimeScales;
  35. import org.orekit.time.UT1Scale;
  36. import org.orekit.utils.Constants;
  37. import org.orekit.utils.IERSConventions;
  38. import org.orekit.utils.OrekitConfiguration;
  39. import org.orekit.utils.ParameterDriver;

  40. /** Solid tides force model.
  41.  * @since 6.1
  42.  * @author Luc Maisonobe
  43.  */
  44. public class SolidTides implements ForceModel {

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

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

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

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

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

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

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

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

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

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

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

  147. }