SolidTides.java

  1. /* Copyright 2002-2019 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.forces.gravity;

  18. import java.util.stream.Stream;

  19. import org.hipparchus.Field;
  20. import org.hipparchus.RealFieldElement;
  21. import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
  22. import org.hipparchus.geometry.euclidean.threed.Vector3D;
  23. import org.orekit.bodies.CelestialBody;
  24. import org.orekit.forces.AbstractForceModel;
  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.UT1Scale;
  35. import org.orekit.utils.Constants;
  36. import org.orekit.utils.IERSConventions;
  37. import org.orekit.utils.OrekitConfiguration;
  38. import org.orekit.utils.ParameterDriver;

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

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

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

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

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

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

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

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

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

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

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

  139.     /** {@inheritDoc} */
  140.     @Override
  141.     public ParameterDriver[] getParametersDrivers() {
  142.         // delegate to underlying attraction model
  143.         return attractionModel.getParametersDrivers();
  144.     }

  145. }