1   /* Copyright 2022-2025 Thales Alenia Space
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.models.earth.displacement;
18  
19  import org.hipparchus.geometry.euclidean.threed.Vector3D;
20  import org.hipparchus.util.FastMath;
21  import org.orekit.bodies.GeodeticPoint;
22  import org.orekit.time.AbsoluteDate;
23  
24  /** Model for post-seismic deformation corrections.
25   * @since 12.1
26   * @author Luc Maisonobe
27   */
28  public class PsdCorrection {
29  
30      /** Correction axis. */
31      private final Axis axis;
32  
33      /** Time evolution. */
34      private final TimeEvolution evolution;
35  
36      /** Earthquake date. */
37      private final AbsoluteDate earthquakeDate;
38  
39      /** Amplitude. */
40      private final double amplitude;
41  
42      /** Relaxation time. */
43      private final double relaxationTime;
44  
45      /** Simple constructor.
46       * @param axis correction axis
47       * @param evolution time evolution
48       * @param earthquakeDate earthquake date
49       * @param amplitude amplitude
50       * @param relaxationTime relaxation time
51       */
52      public PsdCorrection(final Axis axis,
53                           final TimeEvolution evolution,
54                           final AbsoluteDate earthquakeDate,
55                           final double amplitude,
56                           final double relaxationTime) {
57          this.axis           = axis;
58          this.evolution      = evolution;
59          this.earthquakeDate = earthquakeDate;
60          this.amplitude      = amplitude;
61          this.relaxationTime = relaxationTime;
62      }
63  
64      /** Get correction axis.
65       * @return correction axis
66       */
67      public Axis getAxis() {
68          return axis;
69      }
70  
71      /** Get time evolution.
72       * @return time evolution
73       */
74      public TimeEvolution getEvolution() {
75          return evolution;
76      }
77  
78      /** Get earthquake date.
79       * @return earthquake date
80       */
81      public AbsoluteDate getEarthquakeDate() {
82          return earthquakeDate;
83      }
84  
85      /** Get amplitude.
86       * @return amplitude
87       */
88      public double getAmplitude() {
89          return amplitude;
90      }
91  
92      /** Get relaxation time.
93       * @return relaxation time
94       */
95      public double getRelaxationTime() {
96          return relaxationTime;
97      }
98  
99      /** Compute displacement.
100      * @param date date
101      * @param base base point
102      * @return displacement vector in Earth frame
103      */
104     public Vector3D displacement(final AbsoluteDate date, final GeodeticPoint base) {
105         final double scaledTime = date.durationFrom(earthquakeDate) / relaxationTime;
106         final double timeFactor = evolution.timeFactor(scaledTime);
107         return new Vector3D(amplitude * timeFactor, axis.vector(base));
108     }
109 
110     /** Enumerate for correction axis. */
111     public enum Axis {
112         /** East axis. */
113         EAST {
114             public Vector3D vector(final GeodeticPoint base) {
115                 return base.getEast();
116             }
117         },
118 
119         /** North axis. */
120         NORTH {
121             public Vector3D vector(final GeodeticPoint base) {
122                 return base.getNorth();
123             }
124         },
125 
126         /** Up axis. */
127         UP {
128             public Vector3D vector(final GeodeticPoint base) {
129                 return base.getZenith();
130             }
131         };
132 
133         /** Get axis unit vector.
134          * @param base base point
135          * @return direction in Earth frame
136          */
137         public abstract Vector3D vector(GeodeticPoint base);
138     }
139 
140     /** Enumerate for correction time evolution. */
141     public enum TimeEvolution {
142 
143         /** Exponential evolution. */
144         EXP {
145             public double timeFactor(final double scaledTime) {
146                 return 1 - FastMath.exp(-scaledTime);
147             }
148         },
149 
150         /** Logarithmic evolution. */
151         LOG {
152             public double timeFactor(final double scaledTime) {
153                 return FastMath.log(1 + scaledTime);
154             }
155         };
156 
157         /** Evaluate correction time factor.
158          * @param scaledTime scaled time since earthquake
159          * @return correction time factor
160          */
161         public abstract double timeFactor(double scaledTime);
162 
163     }
164 
165 }