1   /*
2    * Licensed to the Hipparchus project under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF 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  
18  package org.orekit.propagation.events;
19  
20  import org.hipparchus.util.Binary64;
21  import org.hipparchus.util.Binary64Field;
22  import org.junit.jupiter.api.Assertions;
23  import org.junit.jupiter.api.Test;
24  import org.orekit.propagation.FieldPropagator;
25  import org.orekit.propagation.analytical.FieldKeplerianPropagator;
26  import org.orekit.propagation.analytical.KeplerianPropagator;
27  import org.orekit.propagation.events.handlers.FieldRecordAndContinue;
28  
29  
30  /**
31   * Test event handling on a {@link KeplerianPropagator}.
32   *
33   * @author Evan Ward
34   */
35  public class FieldCloseEventsAnalyticalKeplerianTest extends FieldCloseEventsAbstractTest<Binary64> {
36  
37      public FieldCloseEventsAnalyticalKeplerianTest(){
38          super(Binary64Field.getInstance());
39      }
40  
41      @Override
42      public FieldPropagator<Binary64> getPropagator(double stepSize) {
43          return new FieldKeplerianPropagator<>(initialOrbit);
44      }
45  
46      /* Extra test for analytic propagator that take big steps. */
47  
48      /** Test Analytic propagators take big steps. #830 */
49      @Test
50      public void testBigStep() {
51          // setup
52          FieldPropagator<Binary64> propagator = getPropagator(1e100);
53          propagator.setStepHandler(interpolator -> {});
54          double period = 2 * initialOrbit.getKeplerianPeriod().getReal();
55  
56          FieldRecordAndContinue<Binary64> handler = new FieldRecordAndContinue<>();
57          TimeDetector detector = new TimeDetector(1, period - 1)
58                  .withHandler(handler)
59                  .withMaxCheck(1e100)
60                  .withThreshold(v(1));
61          propagator.addEventDetector(detector);
62  
63          // action
64          propagator.propagate(epoch.shiftedBy(period));
65  
66          // verify no events
67          Assertions.assertEquals(0, handler.getEvents().size());
68      }
69  
70      /** Test Analytic propagators take big steps. #830 */
71      @Test
72      public void testBigStepReverse() {
73          // setup
74          FieldPropagator<Binary64> propagator = getPropagator(1e100);
75          propagator.setStepHandler(interpolator -> {});
76          double period = -2 * initialOrbit.getKeplerianPeriod().getReal();
77  
78          FieldRecordAndContinue<Binary64> handler = new FieldRecordAndContinue<>();
79          TimeDetector detector = new TimeDetector(-1, period + 1)
80                  .withHandler(handler)
81                  .withMaxCheck(1e100)
82                  .withThreshold(v(1));
83          propagator.addEventDetector(detector);
84  
85          // action
86          propagator.propagate(epoch.shiftedBy(period));
87  
88          // verify no events
89          Assertions.assertEquals(0, handler.getEvents().size());
90      }
91  
92  }