1   /* Copyright 2022-2025 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.radiation;
18  
19  import org.hipparchus.CalculusFieldElement;
20  import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
21  import org.hipparchus.geometry.euclidean.threed.Vector3D;
22  import org.hipparchus.util.FastMath;
23  import org.orekit.propagation.events.EventDetectionSettings;
24  import org.orekit.utils.ExtendedPositionProvider;
25  
26  /**
27   * Abstract class for the definition of the solar flux model with a single occulting body of spherical shape.
28   *
29   * @author Romain Serra
30   * @see LightFluxModel
31   * @since 12.2
32   */
33  public abstract class AbstractSolarLightFluxModel extends AbstractLightFluxModel {
34  
35      /** Radius of central, occulting body (approximated as spherical).
36       * Its center is assumed to be at the origin of the frame linked to the state. */
37      private final double occultingBodyRadius;
38  
39      /** Reference flux normalized for a 1m distance (N). */
40      private final double kRef;
41  
42      /** Eclipse detection settings. */
43      private final EventDetectionSettings eventDetectionSettings;
44  
45      /**
46       * Constructor.
47       * @param kRef reference flux
48       * @param occultedBody position provider for light source
49       * @param occultingBodyRadius radius of central, occulting body
50       * @param eventDetectionSettings user-defined detection settings for eclipses (if ill-tuned, events might be missed or performance might drop)
51       */
52      protected AbstractSolarLightFluxModel(final double kRef, final ExtendedPositionProvider occultedBody,
53                                            final double occultingBodyRadius, final EventDetectionSettings eventDetectionSettings) {
54          super(occultedBody);
55          this.kRef = kRef;
56          this.occultingBodyRadius = occultingBodyRadius;
57          this.eventDetectionSettings = eventDetectionSettings;
58      }
59  
60      /**
61       * Constructor with default value for reference flux.
62       * @param occultedBody position provider for light source
63       * @param occultingBodyRadius radius of central, occulting body
64       * @param eventDetectionSettings user-defined detection settings for eclipses (if ill-tuned, events might be missed or performance might drop)
65       */
66      protected AbstractSolarLightFluxModel(final ExtendedPositionProvider occultedBody, final double occultingBodyRadius,
67                                            final EventDetectionSettings eventDetectionSettings) {
68          this(4.56e-6 * FastMath.pow(149597870000.0, 2), occultedBody, occultingBodyRadius,
69                  eventDetectionSettings);
70      }
71  
72      /**
73       * Getter for occulting body radius.
74       * @return radius
75       */
76      public double getOccultingBodyRadius() {
77          return occultingBodyRadius;
78      }
79  
80      /**
81       * Getter for eclipse event detection settings used for eclipses.
82       * @return event detection settings
83       */
84      public EventDetectionSettings getEventDetectionSettings() {
85          return eventDetectionSettings;
86      }
87  
88      /** {@inheritDoc} */
89      @Override
90      protected Vector3D getUnoccultedFluxVector(final Vector3D relativePosition) {
91          final double squaredRadius = relativePosition.getNormSq();
92          final double factor = kRef / (squaredRadius * FastMath.sqrt(squaredRadius));
93          return relativePosition.scalarMultiply(factor);
94      }
95  
96      /** {@inheritDoc} */
97      @Override
98      protected <T extends CalculusFieldElement<T>> FieldVector3D<T> getUnoccultedFluxVector(final FieldVector3D<T> relativePosition) {
99          final T squaredRadius = relativePosition.getNormSq();
100         final T factor = (squaredRadius.multiply(squaredRadius.sqrt())).reciprocal().multiply(kRef);
101         return relativePosition.scalarMultiply(factor);
102     }
103 
104 }