OceanTides.java

  1. /* Copyright 2002-2013 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 org.apache.commons.math3.analysis.differentiation.DerivativeStructure;
  20. import org.apache.commons.math3.geometry.euclidean.threed.FieldRotation;
  21. import org.apache.commons.math3.geometry.euclidean.threed.FieldVector3D;
  22. import org.apache.commons.math3.ode.AbstractParameterizable;
  23. import org.apache.commons.math3.ode.UnknownParameterException;
  24. import org.orekit.errors.OrekitException;
  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.SpacecraftState;
  32. import org.orekit.propagation.events.EventDetector;
  33. import org.orekit.propagation.numerical.TimeDerivativesEquations;
  34. import org.orekit.time.AbsoluteDate;
  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. /** Ocean tides force model.
  40.  * @since 6.1
  41.  * @author Luc Maisonobe
  42.  */
  43. public class OceanTides extends AbstractParameterizable implements ForceModel {

  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 degree degree of the tide model to load
  59.      * @param order order of the tide model to load
  60.      * @param conventions IERS conventions used for loading ocean pole tide
  61.      * @param ut1 UT1 time scale
  62.      * @exception OrekitException if the ocean tides model cannot be read or the
  63.      * model does not support requested degree or order
  64.      * @see #DEFAULT_STEP
  65.      * @see #DEFAULT_POINTS
  66.      * @see #OceanTides(Frame, double, double, boolean, double, int, int, int, IERSConventions, UT1Scale)
  67.      * @see GravityFieldFactory#getOceanTidesWaves(int, int)
  68.      */
  69.     public OceanTides(final Frame centralBodyFrame, final double ae, final double mu,
  70.                       final int degree, final int order,
  71.                       final IERSConventions conventions, final UT1Scale ut1)
  72.         throws OrekitException {
  73.         this(centralBodyFrame, ae, mu, true,
  74.              DEFAULT_STEP, DEFAULT_POINTS, degree, order,
  75.              conventions, ut1);
  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 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.      * @exception OrekitException if the ocean tides model cannot be read or the
  90.      * model does not support requested degree or order
  91.      * @see GravityFieldFactory#getOceanTidesWaves(int, int)
  92.      */
  93.     public OceanTides(final Frame centralBodyFrame, final double ae, final double mu,
  94.                       final boolean poleTide, final double step, final int nbPoints,
  95.                       final int degree, final int order,
  96.                       final IERSConventions conventions, final UT1Scale ut1)
  97.         throws OrekitException {

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

  100.         final OceanTidesField raw =
  101.                 new OceanTidesField(ae, mu, waves,
  102.                                     conventions.getNutationArguments(ut1),
  103.                                     poleTide ? conventions.getOceanPoleTide(ut1.getEOPHistory()) : null);

  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 double getParameter(final String name)
  119.         throws UnknownParameterException {
  120.         // there are no tunable parameters at all in this force model
  121.         throw new UnknownParameterException(name);
  122.     }

  123.     /** {@inheritDoc} */
  124.     @Override
  125.     public void setParameter(final String name, final double value)
  126.         throws UnknownParameterException {
  127.         // there are no tunable parameters at all in this force model
  128.         throw new UnknownParameterException(name);
  129.     }

  130.     /** {@inheritDoc} */
  131.     @Override
  132.     public void addContribution(final SpacecraftState s,
  133.                                 final TimeDerivativesEquations adder)
  134.         throws OrekitException {
  135.         // delegate to underlying attraction model
  136.         attractionModel.addContribution(s, adder);
  137.     }

  138.     /** {@inheritDoc} */
  139.     @Override
  140.     public FieldVector3D<DerivativeStructure> accelerationDerivatives(final AbsoluteDate date,
  141.                                                                       final Frame frame,
  142.                                                                       final FieldVector3D<DerivativeStructure> position,
  143.                                                                       final FieldVector3D<DerivativeStructure> velocity,
  144.                                                                       final FieldRotation<DerivativeStructure> rotation,
  145.                                                                       final DerivativeStructure mass)
  146.         throws OrekitException {
  147.         // delegate to underlying attraction model
  148.         return attractionModel.accelerationDerivatives(date, frame, position, velocity, rotation, mass);
  149.     }

  150.     /** {@inheritDoc} */
  151.     @Override
  152.     public FieldVector3D<DerivativeStructure> accelerationDerivatives(final SpacecraftState s,
  153.                                                                       final String paramName)
  154.         throws OrekitException {
  155.         // this should never be called as there are no tunable parameters
  156.         return attractionModel.accelerationDerivatives(s, paramName);
  157.     }

  158.     /** {@inheritDoc} */
  159.     @Override
  160.     public EventDetector[] getEventsDetectors() {
  161.         // delegate to underlying attraction model
  162.         return attractionModel.getEventsDetectors();
  163.     }

  164. }