OceanTides.java

  1. /* Copyright 2002-2025 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 org.orekit.annotation.DefaultDataContext;
  20. import org.orekit.data.DataContext;
  21. import org.orekit.forces.ForceModel;
  22. import org.orekit.forces.ForceModelModifier;
  23. import org.orekit.forces.gravity.potential.CachedNormalizedSphericalHarmonicsProvider;
  24. import org.orekit.forces.gravity.potential.GravityFields;
  25. import org.orekit.forces.gravity.potential.NormalizedSphericalHarmonicsProvider;
  26. import org.orekit.forces.gravity.potential.OceanTidesWave;
  27. import org.orekit.frames.Frame;
  28. import org.orekit.time.TimeScales;
  29. import org.orekit.time.UT1Scale;
  30. import org.orekit.utils.Constants;
  31. import org.orekit.utils.IERSConventions;
  32. import org.orekit.utils.OrekitConfiguration;

  33. /** Ocean tides force model.
  34.  * @since 6.1
  35.  * @author Luc Maisonobe
  36.  */
  37. public class OceanTides implements ForceModelModifier {

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

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

  42.     /** Underlying attraction model. */
  43.     private final ForceModel attractionModel;

  44.     /** Simple constructor.
  45.      * <p>
  46.      * This constructor uses pole tides, the default {@link #DEFAULT_STEP step} and default
  47.      * {@link #DEFAULT_POINTS number of points} for the tides field interpolation.
  48.      * </p>
  49.      *
  50.      * <p>This constructor uses the {@link DataContext#getDefault() default data context}.
  51.      *
  52.      * @param centralBodyFrame rotating body frame
  53.      * @param ae central body reference radius
  54.      * @param mu central body attraction coefficient
  55.      * @param degree degree of the tide model to load
  56.      * @param order order of the tide model to load
  57.      * @param conventions IERS conventions used for loading ocean pole tide
  58.      * @param ut1 UT1 time scale
  59.      * @see #DEFAULT_STEP
  60.      * @see #DEFAULT_POINTS
  61.      * @see #OceanTides(Frame, double, double, boolean, double, int, int, int, IERSConventions, UT1Scale)
  62.      * @see GravityFields#getOceanTidesWaves(int, int)
  63.      * @see #OceanTides(Frame, double, double, boolean, double, int, int, int,
  64.      * IERSConventions, UT1Scale, GravityFields)
  65.      */
  66.     @DefaultDataContext
  67.     public OceanTides(final Frame centralBodyFrame, final double ae, final double mu,
  68.                       final int degree, final int order,
  69.                       final IERSConventions conventions, final UT1Scale ut1) {
  70.         this(centralBodyFrame, ae, mu, true,
  71.              DEFAULT_STEP, DEFAULT_POINTS, degree, order,
  72.              conventions, ut1);
  73.     }

  74.     /** Simple constructor.
  75.      *
  76.      * <p>This constructor uses the {@link DataContext#getDefault() default data context}.
  77.      *
  78.      * @param centralBodyFrame rotating body frame
  79.      * @param ae central body reference radius
  80.      * @param mu central body attraction coefficient
  81.      * @param poleTide if true, pole tide is computed
  82.      * @param step time step between sample points for interpolation
  83.      * @param nbPoints number of points to use for interpolation, if less than 2
  84.      * then no interpolation is performed (thus greatly increasing computation cost)
  85.      * @param degree degree of the tide model to load
  86.      * @param order order of the tide model to load
  87.      * @param conventions IERS conventions used for loading ocean pole tide
  88.      * @param ut1 UT1 time scale
  89.      * @see GravityFields#getOceanTidesWaves(int, int)
  90.      * @see #OceanTides(Frame, double, double, boolean, double, int, int, int,
  91.      * IERSConventions, UT1Scale, GravityFields)
  92.      */
  93.     @DefaultDataContext
  94.     public OceanTides(final Frame centralBodyFrame, final double ae, final double mu,
  95.                       final boolean poleTide, final double step, final int nbPoints,
  96.                       final int degree, final int order,
  97.                       final IERSConventions conventions, final UT1Scale ut1) {
  98.         this(centralBodyFrame, ae, mu, poleTide, step, nbPoints, degree, order,
  99.                 conventions, ut1, DataContext.getDefault().getGravityFields());
  100.     }

  101.     /** Simple constructor.
  102.      * @param centralBodyFrame rotating body frame
  103.      * @param ae central body reference radius
  104.      * @param mu central body attraction coefficient
  105.      * @param poleTide if true, pole tide is computed
  106.      * @param step time step between sample points for interpolation
  107.      * @param nbPoints number of points to use for interpolation, if less than 2
  108.      * then no interpolation is performed (thus greatly increasing computation cost)
  109.      * @param degree degree of the tide model to load
  110.      * @param order order of the tide model to load
  111.      * @param conventions IERS conventions used for loading ocean pole tide
  112.      * @param ut1 UT1 time scale
  113.      * @param gravityFields used to compute ocean tides.
  114.      * @see GravityFields#getOceanTidesWaves(int, int)
  115.      * @since 10.1
  116.      */
  117.     public OceanTides(final Frame centralBodyFrame, final double ae, final double mu,
  118.                       final boolean poleTide, final double step, final int nbPoints,
  119.                       final int degree, final int order,
  120.                       final IERSConventions conventions, final UT1Scale ut1,
  121.                       final GravityFields gravityFields) {

  122.         // load the ocean tides model
  123.         final List<OceanTidesWave> waves = gravityFields.getOceanTidesWaves(degree, order);

  124.         final TimeScales timeScales = ut1.getEOPHistory().getTimeScales();
  125.         final OceanTidesField raw =
  126.                 new OceanTidesField(ae, mu, waves,
  127.                                     conventions.getNutationArguments(ut1, timeScales),
  128.                                     poleTide ? conventions.getOceanPoleTide(ut1.getEOPHistory()) : null);

  129.         final NormalizedSphericalHarmonicsProvider provider;
  130.         if (nbPoints < 2) {
  131.             provider = raw;
  132.         } else {
  133.             provider =
  134.                 new CachedNormalizedSphericalHarmonicsProvider(raw, step, nbPoints,
  135.                                                                OrekitConfiguration.getCacheSlotsNumber(),
  136.                                                                7 * Constants.JULIAN_DAY,
  137.                                                                0.5 * Constants.JULIAN_DAY);
  138.         }

  139.         attractionModel = new HolmesFeatherstoneAttractionModel(centralBodyFrame, provider);

  140.     }

  141.     @Override
  142.     public ForceModel getUnderlyingModel() {
  143.         return attractionModel;
  144.     }

  145. }