DeSitterRelativity.java

  1. /* Contributed to the public domain
  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.Collections;
  19. import java.util.List;

  20. import org.hipparchus.CalculusFieldElement;
  21. import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
  22. import org.hipparchus.geometry.euclidean.threed.Vector3D;
  23. import org.hipparchus.util.FastMath;
  24. import org.orekit.annotation.DefaultDataContext;
  25. import org.orekit.bodies.CelestialBody;
  26. import org.orekit.data.DataContext;
  27. import org.orekit.forces.ForceModel;
  28. import org.orekit.propagation.FieldSpacecraftState;
  29. import org.orekit.propagation.SpacecraftState;
  30. import org.orekit.utils.Constants;
  31. import org.orekit.utils.ExtendedPositionProvider;
  32. import org.orekit.utils.FieldPVCoordinates;
  33. import org.orekit.utils.PVCoordinates;
  34. import org.orekit.utils.ParameterDriver;

  35. /**
  36.  * De Sitter post-Newtonian correction force due to general relativity.
  37.  * <p>
  38.  * De Sitter term causes a precession of the orbital plane at a rate of 19 mas per year.
  39.  * </p>
  40.  * @see "Petit, G. and Luzum, B. (eds.), IERS Conventions (2010), Chapter 10,
  41.  * General relativistic models for space-time coordinates and equations of motion (2010)"
  42.  *
  43.  * @author Bryan Cazabonne
  44.  * @since 10.3
  45.  */
  46. public class DeSitterRelativity implements ForceModel {

  47.     /** Suffix for parameter name for attraction coefficient enabling Jacobian processing. */
  48.     public static final String ATTRACTION_COEFFICIENT_SUFFIX = " attraction coefficient";

  49.     /** Central attraction scaling factor.
  50.      * <p>
  51.      * We use a power of 2 to avoid numeric noise introduction
  52.      * in the multiplications/divisions sequences.
  53.      * </p>
  54.      */
  55.     private static final double MU_SCALE = FastMath.scalb(1.0, 32);

  56.     /** The Sun. */
  57.     private final CelestialBody sun;

  58.     /** The Earth. */
  59.     private final ExtendedPositionProvider earth;

  60.     /** Driver for gravitational parameter. */
  61.     private final ParameterDriver gmParameterDriver;

  62.     /**
  63.      * Constructor.
  64.      * <p>It uses the {@link DataContext#getDefault()} to initialize the celestial bodies.</p>
  65.      */
  66.     @DefaultDataContext
  67.     public DeSitterRelativity() {
  68.         this(DataContext.getDefault().getCelestialBodies().getEarth(),
  69.              DataContext.getDefault().getCelestialBodies().getSun());
  70.     }

  71.     /**
  72.      * Simple constructor.
  73.      * @param earth the Earth
  74.      * @param sun the Sun
  75.      */
  76.     public DeSitterRelativity(final CelestialBody earth, final CelestialBody sun) {
  77.         gmParameterDriver = new ParameterDriver(sun.getName() + ATTRACTION_COEFFICIENT_SUFFIX,
  78.                                                 sun.getGM(), MU_SCALE,
  79.                                                 0.0, Double.POSITIVE_INFINITY);
  80.         this.earth = earth;
  81.         this.sun   = sun;
  82.     }

  83.     /**
  84.      * Get the sun model used to compute De Sitter effect.
  85.      * @return the sun model
  86.      */
  87.     public CelestialBody getSun() {
  88.         return sun;
  89.     }

  90.     /**
  91.      * Get the Earth model used to compute De Sitter effect.
  92.      * @return the earth model
  93.      */
  94.     public ExtendedPositionProvider getEarth() {
  95.         return earth;
  96.     }

  97.     /** {@inheritDoc} */
  98.     @Override
  99.     public boolean dependsOnPositionOnly() {
  100.         return false;
  101.     }

  102.     /** {@inheritDoc} */
  103.     @Override
  104.     public Vector3D acceleration(final SpacecraftState s, final double[] parameters) {

  105.         // Useful constant
  106.         final double c2 = Constants.SPEED_OF_LIGHT * Constants.SPEED_OF_LIGHT;

  107.         // Sun's gravitational parameter
  108.         final double gm = parameters[0];

  109.         // Satellite velocity with respect to the Earth
  110.         final PVCoordinates pvSat = s.getPVCoordinates();
  111.         final Vector3D vSat = pvSat.getVelocity();

  112.         // Coordinates of the Earth with respect to the Sun
  113.         final PVCoordinates pvEarth = earth.getPVCoordinates(s.getDate(), sun.getInertiallyOrientedFrame());
  114.         final Vector3D pEarth = pvEarth.getPosition();
  115.         final Vector3D vEarth = pvEarth.getVelocity();

  116.         // Radius
  117.         final double r  = pEarth.getNorm();
  118.         final double r3 = r * r * r;

  119.         // Eq. 10.12
  120.         return new Vector3D((-3.0 * gm) / (c2 * r3), vEarth.crossProduct(pEarth).crossProduct(vSat));
  121.     }

  122.     /** {@inheritDoc} */
  123.     @Override
  124.     public <T extends CalculusFieldElement<T>> FieldVector3D<T> acceleration(final FieldSpacecraftState<T> s,
  125.                                                                          final T[] parameters) {

  126.         // Useful constant
  127.         final double c2 = Constants.SPEED_OF_LIGHT * Constants.SPEED_OF_LIGHT;

  128.         // Sun's gravitational parameter
  129.         final T gm = parameters[0];

  130.         // Satellite velocity with respect to the Earth
  131.         final FieldPVCoordinates<T> pvSat = s.getPVCoordinates();
  132.         final FieldVector3D<T> vSat = pvSat.getVelocity();

  133.         // Coordinates of the Earth with respect to the Sun
  134.         final FieldPVCoordinates<T> pvEarth = earth.getPVCoordinates(s.getDate(), sun.getInertiallyOrientedFrame());
  135.         final FieldVector3D<T> pEarth = pvEarth.getPosition();
  136.         final FieldVector3D<T> vEarth = pvEarth .getVelocity();

  137.         // Radius
  138.         final T r  = pEarth.getNorm();
  139.         final T r3 = r.multiply(r).multiply(r);

  140.         // Eq. 10.12
  141.         return new FieldVector3D<>(gm.multiply(-3.0).divide(r3.multiply(c2)), vEarth.crossProduct(pEarth).crossProduct(vSat));
  142.     }

  143.     /** {@inheritDoc} */
  144.     @Override
  145.     public List<ParameterDriver> getParametersDrivers() {
  146.         return Collections.singletonList(gmParameterDriver);
  147.     }

  148. }