EventDetectionSettings.java

  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. import org.orekit.propagation.events.intervals.AdaptableInterval;

  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.     /** Default maximum checking interval (s). */
  28.     public static final double DEFAULT_MAX_CHECK = 600;

  29.     /** Default convergence threshold (s). */
  30.     public static final double DEFAULT_THRESHOLD = 1.e-6;

  31.     /** Default maximum number of iterations in the event time search. */
  32.     public static final int DEFAULT_MAX_ITER = 100;

  33.     /** Adaptable interval for maximum time without event evaluation. */
  34.     private final AdaptableInterval maxCheckInterval;

  35.     /** Detection threshold. */
  36.     private final double threshold;

  37.     /** Maximum iteration number when detecting event. */
  38.     private final int maxIterationCount;

  39.     /**
  40.      * Constructor.
  41.      *
  42.      * @param maxCheckInterval  adaptable interval
  43.      * @param threshold         detection threshold on time
  44.      * @param maxIterationCount maximum iteration number
  45.      */
  46.     public EventDetectionSettings(final AdaptableInterval maxCheckInterval, final double threshold,
  47.                                   final int maxIterationCount) {
  48.         this.maxCheckInterval = maxCheckInterval;
  49.         this.maxIterationCount = maxIterationCount;
  50.         this.threshold = threshold;
  51.     }

  52.     /**
  53.      * Constructor with maximum check as double.
  54.      *
  55.      * @param maxCheck          constant maximum check for adaptable interval
  56.      * @param threshold         detection threshold on time
  57.      * @param maxIterationCount maximum iteration number
  58.      */
  59.     public EventDetectionSettings(final double maxCheck, final double threshold, final int maxIterationCount) {
  60.         this(AdaptableInterval.of(maxCheck), threshold, maxIterationCount);
  61.     }

  62.     /**
  63.      * Getter for adaptable interval.
  64.      * @return adaptable interval
  65.      */
  66.     public AdaptableInterval getMaxCheckInterval() {
  67.         return maxCheckInterval;
  68.     }

  69.     /**
  70.      * Getter for threshold.
  71.      * @return threshold
  72.      */
  73.     public double getThreshold() {
  74.         return threshold;
  75.     }

  76.     /**
  77.      * Getter for max iter.
  78.      * @return max iter
  79.      */
  80.     public int getMaxIterationCount() {
  81.         return maxIterationCount;
  82.     }

  83.     /**
  84.      * Builds a new instance with a new max. check interval.
  85.      * @param newMaxCheckInterval new max. check.
  86.      * @return new object
  87.      * @since 13.0
  88.      */
  89.     public EventDetectionSettings withMaxCheckInterval(final AdaptableInterval newMaxCheckInterval) {
  90.         return new EventDetectionSettings(newMaxCheckInterval, threshold, maxIterationCount);
  91.     }

  92.     /**
  93.      * Builds a new instance with a new threshold value.
  94.      * @param newThreshold detection threshold in seconds
  95.      * @return new object
  96.      * @since 13.0
  97.      */
  98.     public EventDetectionSettings withThreshold(final double newThreshold) {
  99.         return new EventDetectionSettings(maxCheckInterval, newThreshold, maxIterationCount);
  100.     }

  101.     /**
  102.      * Builds a new instance with a new max. iteration count.
  103.      * @param newMaxIterationCount new max iteration count.
  104.      * @return new object
  105.      * @since 13.0
  106.      */
  107.     public EventDetectionSettings withMaxIter(final int newMaxIterationCount) {
  108.         return new EventDetectionSettings(maxCheckInterval, threshold, newMaxIterationCount);
  109.     }

  110.     /**
  111.      * Returns default settings for event detections.
  112.      * @return default settings
  113.      */
  114.     public static EventDetectionSettings getDefaultEventDetectionSettings() {
  115.         return new EventDetectionSettings(DEFAULT_MAX_CHECK, DEFAULT_THRESHOLD, DEFAULT_MAX_ITER);
  116.     }
  117. }