AbstractBodyAttraction.java

  1. /* Copyright 2022-2024 Romain Serra
  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 org.hipparchus.util.FastMath;
  19. import org.orekit.bodies.CelestialBody;
  20. import org.orekit.forces.ForceModel;
  21. import org.orekit.utils.ParameterDriver;

  22. import java.util.Collections;
  23. import java.util.List;

  24. /** Abstract class for body attraction force model.
  25.  *
  26.  * @author Romain Serra
  27.  */
  28. public abstract class AbstractBodyAttraction implements ForceModel {

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

  31.     /** Central attraction scaling factor.
  32.      * <p>
  33.      * We use a power of 2 to avoid numeric noise introduction
  34.      * in the multiplications/divisions sequences.
  35.      * </p>
  36.      */
  37.     private static final double MU_SCALE = FastMath.scalb(1.0, 32);

  38.     /** The body to consider. */
  39.     private final CelestialBody body;

  40.     /** Drivers for body attraction coefficient. */
  41.     private final ParameterDriver gmParameterDriver;

  42.     /** Simple constructor.
  43.      * @param body the third body to consider
  44.      */
  45.     protected AbstractBodyAttraction(final CelestialBody body) {
  46.         this.body = body;
  47.         this.gmParameterDriver = new ParameterDriver(body.getName() + ATTRACTION_COEFFICIENT_SUFFIX,
  48.                 body.getGM(), MU_SCALE, 0.0, Double.POSITIVE_INFINITY);
  49.     }

  50.     /** Getter for the body's name.
  51.      * @return the body's name
  52.      */
  53.     public String getBodyName() {
  54.         return body.getName();
  55.     }

  56.     /** Protected getter for the body.
  57.      * @return the third body considered
  58.      */
  59.     protected CelestialBody getBody() {
  60.         return body;
  61.     }

  62.     /** {@inheritDoc} */
  63.     @Override
  64.     public boolean dependsOnPositionOnly() {
  65.         return true;
  66.     }

  67.     /** {@inheritDoc} */
  68.     @Override
  69.     public List<ParameterDriver> getParametersDrivers() {
  70.         return Collections.singletonList(gmParameterDriver);
  71.     }
  72. }