SolidTides.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 org.apache.commons.math3.analysis.differentiation.DerivativeStructure;
  19. import org.apache.commons.math3.geometry.euclidean.threed.FieldRotation;
  20. import org.apache.commons.math3.geometry.euclidean.threed.FieldVector3D;
  21. import org.apache.commons.math3.ode.AbstractParameterizable;
  22. import org.apache.commons.math3.ode.UnknownParameterException;
  23. import org.orekit.bodies.CelestialBody;
  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.NormalizedSphericalHarmonicsProvider;
  28. import org.orekit.forces.gravity.potential.TideSystem;
  29. import org.orekit.frames.Frame;
  30. import org.orekit.propagation.SpacecraftState;
  31. import org.orekit.propagation.events.EventDetector;
  32. import org.orekit.propagation.numerical.TimeDerivativesEquations;
  33. import org.orekit.time.AbsoluteDate;
  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. /** Solid tides force model.
  39.  * @since 6.1
  40.  * @author Luc Maisonobe
  41.  */
  42. public class SolidTides extends AbstractParameterizable implements ForceModel {

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

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

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

  49.     /** Simple constructor.
  50.      * <p>
  51.      * This constructor uses pole tides, the default {@link #DEFAULT_STEP step} and default
  52.      * {@link #DEFAULT_POINTS number of points} for the tides field interpolation.
  53.      * </p>
  54.      * @param centralBodyFrame rotating body frame
  55.      * @param ae central body reference radius
  56.      * @param mu central body attraction coefficient
  57.      * @param centralTideSystem tide system used in the central attraction model
  58.      * @param conventions IERS conventions used for loading Love numbers
  59.      * @param ut1 UT1 time scale
  60.      * @param bodies tide generating bodies (typically Sun and Moon)
  61.      * @exception OrekitException if the Love numbers embedded in the
  62.      * library cannot be read
  63.      * @see #DEFAULT_STEP
  64.      * @see #DEFAULT_POINTS
  65.      * @see #SolidTides(Frame, double, double, TideSystem, boolean, double, int, IERSConventions, UT1Scale, CelestialBody...)
  66.      */
  67.     public SolidTides(final Frame centralBodyFrame, final double ae, final double mu,
  68.                       final TideSystem centralTideSystem,
  69.                       final IERSConventions conventions, final UT1Scale ut1,
  70.                       final CelestialBody ... bodies)
  71.         throws OrekitException {
  72.         this(centralBodyFrame, ae, mu, centralTideSystem, true,
  73.              DEFAULT_STEP, DEFAULT_POINTS, conventions, ut1, bodies);
  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 centralTideSystem tide system used in the central attraction model
  80.      * @param poleTide if true, pole tide is computed
  81.      * @param step time step between sample points for interpolation
  82.      * @param nbPoints number of points to use for interpolation, if less than 2
  83.      * then no interpolation is performed (thus greatly increasing computation cost)
  84.      * @param conventions IERS conventions used for loading Love numbers
  85.      * @param ut1 UT1 time scale
  86.      * @param bodies tide generating bodies (typically Sun and Moon)
  87.      * @exception OrekitException if the Love numbers embedded in the
  88.      * library cannot be read
  89.      */
  90.     public SolidTides(final Frame centralBodyFrame, final double ae, final double mu,
  91.                       final TideSystem centralTideSystem, final boolean poleTide,
  92.                       final double step, final int nbPoints,
  93.                       final IERSConventions conventions, final UT1Scale ut1,
  94.                       final CelestialBody ... bodies)
  95.         throws OrekitException {
  96.         final SolidTidesField raw =
  97.                 new SolidTidesField(conventions.getLoveNumbers(),
  98.                                conventions.getTideFrequencyDependenceFunction(ut1),
  99.                                conventions.getPermanentTide(),
  100.                                poleTide ? conventions.getSolidPoleTide(ut1.getEOPHistory()) : null,
  101.                                centralBodyFrame, ae, mu, centralTideSystem, bodies);
  102.         final NormalizedSphericalHarmonicsProvider provider;
  103.         if (nbPoints < 2) {
  104.             provider = raw;
  105.         } else {
  106.             provider =
  107.                 new CachedNormalizedSphericalHarmonicsProvider(raw, step, nbPoints,
  108.                                                                OrekitConfiguration.getCacheSlotsNumber(),
  109.                                                                7 * Constants.JULIAN_DAY,
  110.                                                                0.5 * Constants.JULIAN_DAY);
  111.         }
  112.         attractionModel = new HolmesFeatherstoneAttractionModel(centralBodyFrame, provider);
  113.     }

  114.     /** {@inheritDoc} */
  115.     @Override
  116.     public double getParameter(final String name)
  117.         throws UnknownParameterException {
  118.         // there are no tunable parameters at all in this force model
  119.         throw new UnknownParameterException(name);
  120.     }

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

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

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

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

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

  162. }