1 | /*
|
---|
2 | * Licensed to the Apache Software Foundation (ASF) 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 | *
|
---|
19 | * <p>
|
---|
20 | * This package provides classes to handle discrete events occurring during
|
---|
21 | * Ordinary Differential Equations integration.
|
---|
22 | * </p>
|
---|
23 | *
|
---|
24 | * <p>
|
---|
25 | * Discrete events detection is based on switching functions. The user provides
|
---|
26 | * a simple {@link agents.anac.y2019.harddealer.math3.ode.events.EventHandler#g g(t, y)}
|
---|
27 | * function depending on the current time and state. The integrator will monitor
|
---|
28 | * the value of the function throughout integration range and will trigger the
|
---|
29 | * event when its sign changes. The magnitude of the value is almost irrelevant,
|
---|
30 | * it should however be continuous (but not necessarily smooth) for the sake of
|
---|
31 | * root finding. The steps are shortened as needed to ensure the events occur
|
---|
32 | * at step boundaries (even if the integrator is a fixed-step integrator).
|
---|
33 | * </p>
|
---|
34 | *
|
---|
35 | * <p>
|
---|
36 | * When an event is triggered, several different options are available:
|
---|
37 | * </p>
|
---|
38 | * <ul>
|
---|
39 | * <li>integration can be stopped (this is called a G-stop facility),</li>
|
---|
40 | * <li>the state vector or the derivatives can be changed,</li>
|
---|
41 | * <li>or integration can simply go on.</li>
|
---|
42 | * </ul>
|
---|
43 | *
|
---|
44 | * <p>
|
---|
45 | * The first case, G-stop, is the most common one. A typical use case is when an
|
---|
46 | * ODE must be solved up to some target state is reached, with a known value of
|
---|
47 | * the state but an unknown occurrence time. As an example, if we want to monitor
|
---|
48 | * a chemical reaction up to some predefined concentration for the first substance,
|
---|
49 | * we can use the following switching function setting:
|
---|
50 | * <pre>
|
---|
51 | * public double g(double t, double[] y) {
|
---|
52 | * return y[0] - targetConcentration;
|
---|
53 | * }
|
---|
54 | *
|
---|
55 | * public int eventOccurred(double t, double[] y) {
|
---|
56 | * return STOP;
|
---|
57 | * }
|
---|
58 | * </pre>
|
---|
59 | * </p>
|
---|
60 | *
|
---|
61 | * <p>
|
---|
62 | * The second case, change state vector or derivatives is encountered when dealing
|
---|
63 | * with discontinuous dynamical models. A typical case would be the motion of a
|
---|
64 | * spacecraft when thrusters are fired for orbital maneuvers. The acceleration is
|
---|
65 | * smooth as long as no maneuver are performed, depending only on gravity, drag,
|
---|
66 | * third body attraction, radiation pressure. Firing a thruster introduces a
|
---|
67 | * discontinuity that must be handled appropriately by the integrator. In such a case,
|
---|
68 | * we would use a switching function setting similar to this:
|
---|
69 | * <pre>
|
---|
70 | * public double g(double t, double[] y) {
|
---|
71 | * return (t - tManeuverStart) ∗ (t - tManeuverStop);
|
---|
72 | * }
|
---|
73 | *
|
---|
74 | * public int eventOccurred(double t, double[] y) {
|
---|
75 | * return RESET_DERIVATIVES;
|
---|
76 | * }
|
---|
77 | * </pre>
|
---|
78 | * </p>
|
---|
79 | *
|
---|
80 | * <p>
|
---|
81 | * The third case is useful mainly for monitoring purposes, a simple example is:
|
---|
82 | * <pre>
|
---|
83 | * public double g(double t, double[] y) {
|
---|
84 | * return y[0] - y[1];
|
---|
85 | * }
|
---|
86 | *
|
---|
87 | * public int eventOccurred(double t, double[] y) {
|
---|
88 | * logger.log("y0(t) and y1(t) curves cross at t = " + t);
|
---|
89 | * return CONTINUE;
|
---|
90 | * }
|
---|
91 | * </pre>
|
---|
92 | * </p>
|
---|
93 | *
|
---|
94 | *
|
---|
95 | */
|
---|
96 | package agents.anac.y2019.harddealer.math3.ode.events;
|
---|