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.Decimal64;
21  import org.hipparchus.util.Decimal64Field;
22  import org.junit.Assert;
23  import org.junit.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<Decimal64> {
36  
37      public FieldCloseEventsAnalyticalKeplerianTest(){
38          super(Decimal64Field.getInstance());
39      }
40  
41      @Override
42      public FieldPropagator<Decimal64> 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<Decimal64> propagator = getPropagator(1e100);
53          propagator.setStepHandler(interpolator -> {});
54          double period = 2 * initialOrbit.getKeplerianPeriod().getReal();
55  
56          FieldRecordAndContinue<TimeDetector, Decimal64> handler =
57                  new FieldRecordAndContinue<>();
58          TimeDetector detector = new TimeDetector(1, period - 1)
59                  .withHandler(handler)
60                  .withMaxCheck(v(1e100))
61                  .withThreshold(v(1));
62          propagator.addEventDetector(detector);
63  
64          // action
65          propagator.propagate(epoch.shiftedBy(period));
66  
67          // verify no events
68          Assert.assertEquals(0, handler.getEvents().size());
69      }
70  
71      /** Test Analytic propagators take big steps. #830 */
72      @Test
73      public void testBigStepReverse() {
74          // setup
75          FieldPropagator<Decimal64> propagator = getPropagator(1e100);
76          propagator.setStepHandler(interpolator -> {});
77          double period = -2 * initialOrbit.getKeplerianPeriod().getReal();
78  
79          FieldRecordAndContinue<TimeDetector, Decimal64> handler =
80                  new FieldRecordAndContinue<>();
81          TimeDetector detector = new TimeDetector(-1, period + 1)
82                  .withHandler(handler)
83                  .withMaxCheck(v(1e100))
84                  .withThreshold(v(1));
85          propagator.addEventDetector(detector);
86  
87          // action
88          propagator.propagate(epoch.shiftedBy(period));
89  
90          // verify no events
91          Assert.assertEquals(0, handler.getEvents().size());
92      }
93  
94  }