SolidTides.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.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.errors.OrekitException;
  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.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 extends AbstractForceModel {

  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.      * @exception OrekitException if the Love numbers embedded in the
  64.      * library cannot be read
  65.      * @see #DEFAULT_STEP
  66.      * @see #DEFAULT_POINTS
  67.      * @see #SolidTides(Frame, double, double, TideSystem, boolean, double, int, IERSConventions, UT1Scale, CelestialBody...)
  68.      */
  69.     public SolidTides(final Frame centralBodyFrame, final double ae, final double mu,
  70.                       final TideSystem centralTideSystem,
  71.                       final IERSConventions conventions, final UT1Scale ut1,
  72.                       final CelestialBody... bodies)
  73.         throws OrekitException {
  74.         this(centralBodyFrame, ae, mu, centralTideSystem, true,
  75.              DEFAULT_STEP, DEFAULT_POINTS, conventions, ut1, bodies);
  76.     }

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

  116.     /** {@inheritDoc} */
  117.     @Override
  118.     public boolean dependsOnPositionOnly() {
  119.         return attractionModel.dependsOnPositionOnly();
  120.     }

  121.     /** {@inheritDoc} */
  122.     @Override
  123.     public Vector3D acceleration(final SpacecraftState s, final double[] parameters)
  124.         throws OrekitException {
  125.         // delegate to underlying attraction model
  126.         return attractionModel.acceleration(s, parameters);
  127.     }

  128.     /** {@inheritDoc} */
  129.     @Override
  130.     public <T extends RealFieldElement<T>> FieldVector3D<T> acceleration(final FieldSpacecraftState<T> s,
  131.                                                                          final T[] parameters)
  132.         throws OrekitException {
  133.         // delegate to underlying attraction model
  134.         return attractionModel.acceleration(s, parameters);
  135.     }

  136.     /** {@inheritDoc} */
  137.     @Override
  138.     public Stream<EventDetector> getEventsDetectors() {
  139.         // delegate to underlying attraction model
  140.         return attractionModel.getEventsDetectors();
  141.     }

  142.     /** {@inheritDoc} */
  143.     @Override
  144.     public <T extends RealFieldElement<T>> Stream<FieldEventDetector<T>> getFieldEventsDetectors(final Field<T> field) {
  145.         // delegate to underlying attraction model
  146.         return attractionModel.getFieldEventsDetectors(field);
  147.     }

  148.     /** {@inheritDoc} */
  149.     @Override
  150.     public ParameterDriver[] getParametersDrivers() {
  151.         // delegate to underlying attraction model
  152.         return attractionModel.getParametersDrivers();
  153.     }

  154. }