接口 EventHandler

所有超级接口:
ODEEventDetector

@Deprecated public interface EventHandler extends ODEEventDetector
已过时。
as of 1.0, replaced with ODEEventDetector
This interface represents a handler for discrete events triggered during ODE integration.

Some events can be triggered at discrete times as an ODE problem is solved. This occurs for example when the integration process should be stopped as some state is reached (G-stop facility) when the precise date is unknown a priori, or when the derivatives have discontinuities, or simply when the user wants to monitor some states boundaries crossings.

These events are defined as occurring when a g switching function sign changes.

Since events are only problem-dependent and are triggered by the independent time variable and the state vector, they can occur at virtually any time, unknown in advance. The integrators will take care to avoid sign changes inside the steps, they will reduce the step size when such an event is detected in order to put this event exactly at the end of the current step. This guarantees that step interpolation (which always has a one step scope) is relevant even in presence of discontinuities. This is independent from the stepsize control provided by integrators that monitor the local error (this event handling feature is available for all integrators, including fixed step ones).

  • 嵌套类概要

    嵌套类
    修饰符和类型
    接口
    说明
    static enum 
    已过时。
    as of 1.0, replaced with Action
  • 方法概要

    修饰符和类型
    方法
    说明
    eventOccurred(double t, double[] y, boolean increasing)
    已过时。
    处理事件并选择下一步操作。
    double
    g(double t, double[] y)
    已过时。
    计算切换函数的值。
    default double
    已过时。
    计算切换函数的值。
    default ODEEventHandler
    已过时。
    获取基础事件处理器。
    void
    init(double t0, double[] y0, double t)
    已过时。
    在ODE积分开始时初始化事件处理器。
    default void
    init(ODEStateAndDerivative initialState, double finalTime)
    已过时。
    在ODE积分开始时初始化事件处理器。
    void
    resetState(double t, double[] y)
    已过时。
    在继续积分之前重置状态。

    从接口继承的方法 org.hipparchus.ode.events.ODEEventDetector

    getMaxCheckInterval, getMaxIterationCount, getSolver
  • 方法详细资料

    • init

      default void init(ODEStateAndDerivative initialState, double finalTime)
      已过时。
      在ODE积分开始时初始化事件处理器。

      此方法在积分开始时调用一次。如果需要,事件处理器可以用它来初始化一些内部数据。

      默认实现不执行任何操作

      指定者:
      init 在接口中 ODEEventDetector
      参数:
      initialState - 初始时间、状态向量和导数
      finalTime - 积分的目标时间
    • g

      default double g(ODEStateAndDerivative state)
      已过时。
      计算切换函数的值。

      当此切换函数的符号改变时,将生成离散事件。积分器将会确保以这种方式改变步长,使这些事件恰好发生在步长边界上。切换函数在其根附近必须连续(但不一定平滑),因为积分器需要找到其根以精确定位事件。

      还要注意,为了使积分器检测到事件,切换函数的符号在事件之前和之后必须相反。如果不保持这种一致性,积分器可能无法检测到任何事件。

      这种一致性有时很难实现。一个典型的例子是使用事件来模拟球在地板上弹跳。表示这一点的第一个想法是使g(state) = h(state),其中h是时间state.getTime()时的地板上方的高度。当g(state)达到0时,球在地板上,因此应该弹起,通常的做法是反转其垂直速度。然而,这意味着在事件之前g(state)从正值减少到0,而在事件之后g(state)将再次从0增加到正值。这里破坏了一致性!这里的解决方案是使g(state) = sign * h(state),其中sign是一个变量,其初始值设置为+1。每次调用eventOccurred时,将sign重置为-sign。这允许g(state)函数保持连续(甚至平滑),即使在事件发生时,h(state)不是。基本上,事件用于在弹跳点处折叠h(state),而sign用于展开它,因此求解器看到的g(state)函数在事件发生时也是平滑的。

      此方法是幂等的,即多次使用相同状态调用此方法将产生相同的值,但有两个例外。首先,在处理程序上发生事件时,g函数的定义可能会更改,就像上面的例子一样。其次,在同一积分器中的任何其他事件处理程序的eventOccurred方法返回Action.RESET_EVENTSAction.RESET_DERIVATIVESAction.RESET_STATE时,g函数的定义可能会更改。

      指定者:
      g 在接口中 ODEEventDetector
      参数:
      state - 当前独立时间变量、状态向量和导数的值
      返回:
      切换函数的值
      另请参阅:
    • getHandler

      default ODEEventHandler getHandler()
      已过时。
      获取基础事件处理器。
      指定者:
      getHandler 在接口中 ODEEventDetector
      返回:
      基础事件处理器
    • init

      void init(double t0, double[] y0, double t)
      已过时。
      在ODE积分开始时初始化事件处理器。

      此方法在积分开始时调用一次。如果需要,事件处理器可以用它来初始化一些内部数据。

      参数:
      t0 - 独立时间变量的起始值
      y0 - 包含状态向量起始值的数组
      t - 积分的目标时间
    • g

      double g(double t, double[] y)
      已过时。
      计算切换函数的值。

      当切换函数的符号发生变化时,会生成离散事件。积分器将会确保在这些事件恰好发生在步长边界时改变步长。切换函数在其根附近必须是连续的(但不一定是光滑的),因为积分器需要找到其根以精确定位事件。

      还要注意,积分器期望一旦事件发生,切换函数在下一步开始时的符号(即事件发生后)与事件发生前的符号相反。这种步骤之间的一致性必须被保留,否则将会出现与根未被夹住相关的异常

      这种一致性的需求有时很难实现。一个典型的例子是使用事件来模拟球在地板上弹跳。表示这一点的第一个想法是让g(t) = h(t),其中h是时间t时距离地板的高度。当g(t)达到0时,球在地板上,所以它应该弹起,通常的做法是反转其垂直速度。然而,这意味着在事件发生前g(t)从正值递减到0,而在事件发生后g(t)将从0递增到正值。这里破坏了一致性!解决方法是让g(t) = sign * h(t),其中sign是一个变量,初始值设置为+1。每次调用eventOccurred时,sign被重置为-sign。这允许g(t)函数保持连续(甚至光滑),即使跨事件,尽管h(t)不是。基本上,事件用于在弹跳点处折叠h(t),而sign用于展开它,因此求解器看到的是一个g(t)函数,即使跨事件,它的行为也是平滑的。

      参数:
      t - 独立时间变量的当前值
      y - 包含状态向量当前值的数组
      返回:
      切换函数g的值
    • eventOccurred

      EventHandler.Action eventOccurred(double t, double[] y, boolean increasing)
      已过时。
      处理事件并选择下一步要执行的操作。

      当积分器接受在函数刚好发生符号变化的步骤结束时调用此方法,就在步骤处理程序本身被调用之前(有关调度,请参见下文)。它允许用户更新内部数据以承认事件已被处理(例如,在存在不连续性的情况下在微分方程中设置一个标志以切换导数计算),或者指示积分器停止或继续积分,可能是带有重置状态或导数的。

      参数:
      t - 独立时间变量的当前值
      y - 包含状态向量当前值的数组
      increasing - 如果为true,则在事件周围的时间增加时,切换函数的值也会增加(请注意,增加是相对于物理时间而不是相对于可能向后进行的积分的时间来衡量的)
      返回:
      指示积分器下一步应该做什么的指示,此值必须是EventHandler.Action.STOPEventHandler.Action.RESET_STATEEventHandler.Action.RESET_DERIVATIVESEventHandler.Action.CONTINUE之一
    • resetState

      void resetState(double t, double[] y)
      已过时。
      在继续积分之前重置状态。

      此方法在步骤处理程序返回后且下一步开始之前调用,但仅当eventOccurred(double, double[], boolean)本身返回EventHandler.Action.RESET_STATE指示器时。它允许用户重置下一步的状态向量,而不干扰完成步骤的步骤处理程序。如果eventOccurred(double, double[], boolean)从不返回EventHandler.Action.RESET_STATE指示器,则永远不会调用此函数,可以放心将其主体留空。

      参数:
      t - 独立时间变量的当前值
      y - 包含状态向量当前值的数组,新状态应该放在同一个数组中