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.propagation.events;
18  
19  /**
20   * Class containing parameters for event detection.
21   *
22   * @author Romain Serra.
23   * @since 12.2
24   * @see EventDetector
25   */
26  public class EventDetectionSettings {
27  
28      /** Default maximum checking interval (s). */
29      public static final double DEFAULT_MAXCHECK = 600;
30  
31      /** Default convergence threshold (s). */
32      public static final double DEFAULT_THRESHOLD = 1.e-6;
33  
34      /** Default maximum number of iterations in the event time search. */
35      public static final int DEFAULT_MAX_ITER = 100;
36  
37      /** Adaptable interval for maximum time without event evaluation. */
38      private final AdaptableInterval maxCheckInterval;
39  
40      /** Detection threshold. */
41      private final double threshold;
42  
43      /** Maximum iteration number when detecting event. */
44      private final int maxIterationCount;
45  
46      /**
47       * Constructor.
48       *
49       * @param maxCheckInterval  adaptable interval
50       * @param threshold         detection threshold on time
51       * @param maxIterationCount maximum iteration number
52       */
53      public EventDetectionSettings(final AdaptableInterval maxCheckInterval, final double threshold,
54                                    final int maxIterationCount) {
55          this.maxCheckInterval = maxCheckInterval;
56          this.maxIterationCount = maxIterationCount;
57          this.threshold = threshold;
58      }
59  
60      /**
61       * Constructor with maximum check as double.
62       *
63       * @param maxCheck          constant maximum check for adaptable interval
64       * @param threshold         detection threshold on time
65       * @param maxIterationCount maximum iteration number
66       */
67      public EventDetectionSettings(final double maxCheck, final double threshold, final int maxIterationCount) {
68          this(AdaptableInterval.of(maxCheck), threshold, maxIterationCount);
69      }
70  
71      /**
72       * Getter for adaptable interval.
73       * @return adaptable interval
74       */
75      public AdaptableInterval getMaxCheckInterval() {
76          return maxCheckInterval;
77      }
78  
79      /**
80       * Getter for threshold.
81       * @return threshold
82       */
83      public double getThreshold() {
84          return threshold;
85      }
86  
87      /**
88       * Getter for max iter.
89       * @return max iter
90       */
91      public int getMaxIterationCount() {
92          return maxIterationCount;
93      }
94  
95      /**
96       * Returns default settings for event detections.
97       * @return default settings
98       */
99      public static EventDetectionSettings getDefaultEventDetectionSettings() {
100         return new EventDetectionSettings(DEFAULT_MAXCHECK, DEFAULT_THRESHOLD, DEFAULT_MAX_ITER);
101     }
102 }