solve_idae

deer.solve_idae(func: Callable[[Array, Array, Any, Any], Array], y0: Array, xinp: Any, params: Any, tpts: Array, method: SolveIDAEMethod | None = None) Result[source]

Solve the implicit differential algebraic equations (IDAE) systems.

\[f(\dot{y}, y, x; \theta) = 0\]

where \(\dot{y}\) is the time-derivative of the output signal \(y\), \(x\) is the input signal at given sampling time \(t\), and \(\theta\) are the parameters of the function. The tentative initial condition is given by \(y(0) = y_0\).

Parameters:
  • func (Callable[[jnp.ndarray, jnp.ndarray, Any, Any], jnp.ndarray]) – Function to evaluate the residual of the IDAE system. The arguments are: (1) time-derivative of the output signal \(\dot{y}\) (ny,), (2) output signal \(y\) (ny,), (3) input signal \(x\) (*nx,) in a pytree, and (4) parameters \(\theta\) in a pytree. The return value is the residual of the IDAE system (ny,).

  • y0 (jnp.ndarray) – Tentative initial condition on \(y\) (ny,). If the IDAE system has algebraic variables, then the initial values of the algebraic variables might be different to what is supplied.

  • xinp (Any) – The external input signal of shape (nsamples, *nx) in a pytree.

  • params (Any) – The parameters of the function func.

  • tpts (jnp.ndarray) – The time points to evaluate the solution (nsamples,).

  • method (Optional[SolveIDAEMethod]) – The method to solve the implicit DAE. If None, then use the BwdEulerDEER() method.

Returns:

res – The Result object where .value is the solution of the IDAE system at the given time with shape (nsamples, ny) and .success is the boolean array indicating the convergence of the solver.

Return type:

Result

Examples

>>> import jax.numpy as jnp
>>> def idae_func(dy, y, x, params):
...     return dy + y - x - params
>>> y0 = jnp.array([1.0])
>>> xinp = jnp.array([[0.0], [1.0], [2.0], [3.0]])
>>> params = jnp.array([0.5])
>>> tpts = jnp.array([0.0, 1.0, 2.0, 3.0])
>>> solve_idae(idae_func, y0, xinp, params, tpts).value
Array([[1.    ],
       [1.25  ],
       [1.875 ],
       [2.6875]], dtype=float64)
method=solve_idae.BwdEuler()
solve_idae.BwdEuler(solver: Optional[deer.froot.RootMethod] = None)

Solve the implicit DAE method using backward Euler’s method.

Parameters:

solver (Optional[RootMethod]) – The root finder solver. If None, then use the Newton’s method.

method=solve_idae.BwdEulerDEER()
solve_idae.BwdEulerDEER(yinit_guess: Optional[jax.Array] = None, max_iter: int = 200, atol: Optional[float] = None, rtol: Optional[float] = None)

Solve the implicit DAE method using DEER method for backward Euler’s method.

Parameters:
  • yinit_guess (Optional[jnp.ndarray]) – The initial guess of the output signal (nsamples, ny). If None, it will be initialized as all y0.

  • max_iter (int) – The maximum number of DEER iterations to perform.

  • atol (Optional[float]) – The absolute tolerance of the DEER iteration convergence.

  • rtol (Optional[float]) – The relative tolerance of the DEER iteration convergence.