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.propagation.events;
18
19 import org.orekit.propagation.events.intervals.AdaptableInterval;
20
21 /**
22 * Class containing parameters for event detection.
23 *
24 * @author Romain Serra.
25 * @since 12.2
26 * @see EventDetector
27 */
28 public class EventDetectionSettings {
29
30 /** Default maximum checking interval (s). */
31 public static final double DEFAULT_MAX_CHECK = 600;
32
33 /** Default convergence threshold (s). */
34 public static final double DEFAULT_THRESHOLD = 1.e-6;
35
36 /** Default maximum number of iterations in the event time search. */
37 public static final int DEFAULT_MAX_ITER = 100;
38
39 /** Adaptable interval for maximum time without event evaluation. */
40 private final AdaptableInterval maxCheckInterval;
41
42 /** Detection threshold. */
43 private final double threshold;
44
45 /** Maximum iteration number when detecting event. */
46 private final int maxIterationCount;
47
48 /**
49 * Constructor.
50 *
51 * @param maxCheckInterval adaptable interval
52 * @param threshold detection threshold on time
53 * @param maxIterationCount maximum iteration number
54 */
55 public EventDetectionSettings(final AdaptableInterval maxCheckInterval, final double threshold,
56 final int maxIterationCount) {
57 this.maxCheckInterval = maxCheckInterval;
58 this.maxIterationCount = maxIterationCount;
59 this.threshold = threshold;
60 }
61
62 /**
63 * Constructor with maximum check as double.
64 *
65 * @param maxCheck constant maximum check for adaptable interval
66 * @param threshold detection threshold on time
67 * @param maxIterationCount maximum iteration number
68 */
69 public EventDetectionSettings(final double maxCheck, final double threshold, final int maxIterationCount) {
70 this(AdaptableInterval.of(maxCheck), threshold, maxIterationCount);
71 }
72
73 /**
74 * Getter for adaptable interval.
75 * @return adaptable interval
76 */
77 public AdaptableInterval getMaxCheckInterval() {
78 return maxCheckInterval;
79 }
80
81 /**
82 * Getter for threshold.
83 * @return threshold
84 */
85 public double getThreshold() {
86 return threshold;
87 }
88
89 /**
90 * Getter for max iter.
91 * @return max iter
92 */
93 public int getMaxIterationCount() {
94 return maxIterationCount;
95 }
96
97 /**
98 * Builds a new instance with a new max. check interval.
99 * @param newMaxCheckInterval new max. check.
100 * @return new object
101 * @since 13.0
102 */
103 public EventDetectionSettings withMaxCheckInterval(final AdaptableInterval newMaxCheckInterval) {
104 return new EventDetectionSettings(newMaxCheckInterval, threshold, maxIterationCount);
105 }
106
107 /**
108 * Builds a new instance with a new threshold value.
109 * @param newThreshold detection threshold in seconds
110 * @return new object
111 * @since 13.0
112 */
113 public EventDetectionSettings withThreshold(final double newThreshold) {
114 return new EventDetectionSettings(maxCheckInterval, newThreshold, maxIterationCount);
115 }
116
117 /**
118 * Builds a new instance with a new max. iteration count.
119 * @param newMaxIterationCount new max iteration count.
120 * @return new object
121 * @since 13.0
122 */
123 public EventDetectionSettings withMaxIter(final int newMaxIterationCount) {
124 return new EventDetectionSettings(maxCheckInterval, threshold, newMaxIterationCount);
125 }
126
127 /**
128 * Returns default settings for event detections.
129 * @return default settings
130 */
131 public static EventDetectionSettings getDefaultEventDetectionSettings() {
132 return new EventDetectionSettings(DEFAULT_MAX_CHECK, DEFAULT_THRESHOLD, DEFAULT_MAX_ITER);
133 }
134 }