OceanTides.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.List;
  19. import java.util.stream.Stream;

  20. import org.hipparchus.Field;
  21. import org.hipparchus.RealFieldElement;
  22. import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
  23. import org.hipparchus.geometry.euclidean.threed.Vector3D;
  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.GravityFieldFactory;
  28. import org.orekit.forces.gravity.potential.NormalizedSphericalHarmonicsProvider;
  29. import org.orekit.forces.gravity.potential.OceanTidesWave;
  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. /** Ocean tides force model.
  41.  * @since 6.1
  42.  * @author Luc Maisonobe
  43.  */
  44. public class OceanTides 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 degree degree of the tide model to load
  60.      * @param order order of the tide model to load
  61.      * @param conventions IERS conventions used for loading ocean pole tide
  62.      * @param ut1 UT1 time scale
  63.      * @see #DEFAULT_STEP
  64.      * @see #DEFAULT_POINTS
  65.      * @see #OceanTides(Frame, double, double, boolean, double, int, int, int, IERSConventions, UT1Scale)
  66.      * @see GravityFieldFactory#getOceanTidesWaves(int, int)
  67.      */
  68.     public OceanTides(final Frame centralBodyFrame, final double ae, final double mu,
  69.                       final int degree, final int order,
  70.                       final IERSConventions conventions, final UT1Scale ut1) {
  71.         this(centralBodyFrame, ae, mu, true,
  72.              DEFAULT_STEP, DEFAULT_POINTS, degree, order,
  73.              conventions, ut1);
  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 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 degree degree of the tide model to load
  84.      * @param order order of the tide model to load
  85.      * @param conventions IERS conventions used for loading ocean pole tide
  86.      * @param ut1 UT1 time scale
  87.      * @see GravityFieldFactory#getOceanTidesWaves(int, int)
  88.      */
  89.     public OceanTides(final Frame centralBodyFrame, final double ae, final double mu,
  90.                       final boolean poleTide, final double step, final int nbPoints,
  91.                       final int degree, final int order,
  92.                       final IERSConventions conventions, final UT1Scale ut1) {

  93.         // load the ocean tides model
  94.         final List<OceanTidesWave> waves = GravityFieldFactory.getOceanTidesWaves(degree, order);

  95.         final OceanTidesField raw =
  96.                 new OceanTidesField(ae, mu, waves,
  97.                                     conventions.getNutationArguments(ut1),
  98.                                     poleTide ? conventions.getOceanPoleTide(ut1.getEOPHistory()) : null);

  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 model
  120.         return attractionModel.acceleration(s, parameters);
  121.     }

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


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

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

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

  147. }