qmat.solvers.generic.integrators

Specialized PhiSolver classes implementing various time-integrators.

Classes

ForwardEuler

\(\phi\)-based solver doing Forward Euler update between time nodes.

BackwardEuler

\(\phi\)-based solver doing Backward Euler update between time nodes.

Module Contents

class ForwardEuler(diffOp: DiffOp, nodes, tEnd=1, nSteps=1, t0=0)[source]
Inheritance diagram of qmat.solvers.generic.integrators.ForwardEuler

\(\phi\)-based solver doing Forward Euler update between time nodes.

It uses the following definition :

\[\phi(u_0, u_1, ..., u_{m}, u_{m+1}) = \Delta\tau_{m+1} f(u_m, t_m) + ... + \Delta\tau_1 f(u_0, t_0),\]

where \(\Delta\tau_{m} = t_{m+1} - t_{m}\). In particular, since it does not depends on the node solution \(u_{m+1}\) (explicit scheme), its phiSolve method is replaced by an explicit evaluation of evalPhi.

Parameters:
  • diffOp (DiffOp) – Differential operator for the ODE.

  • nodes (1D array-like) – The time nodes \(\tau_1, ..., \tau_M\).

  • tEnd (float, optional) – Final simulation time. The default is 1.

  • nSteps (int, optional) – Number of simulation time-steps. The default is 1.

  • t0 (float, optional) – Initial simulation time. The default is 0.

evalPhi(uVals, fEvals, out, t0=0)[source]

Evaluate the \(\phi\) operator on time-node up to \(u_{m+1}\).

Considering \(u_0, u_1, \dots, u_{m+1}\), if evaluates :

\[\phi(u_0, u_1, ..., u_{m}, u_{m+1}),\]

and store its value into the output vector out. It also takes the node evaluation \(f(u_0,t_0),f(u_1,\tau_1),...,f(u_{m},\tau_{m})\) as arguments, in order to avoid any additional \(f(u,t)\) evaluations.

Parameters:
  • uVals (list[np.ndarray] of size \(m+2\)) – The \(m+1\) time-node solutions + the initial solution \(u_0\).

  • fEvals (list[np.ndarray] of size \(m+1\) or \(m+1\)) – The \(f(u,t)\) evaluations at each time nodes (+ initial solution), up to time-node \(m\). It can eventually contain a pre-computed \(f_{m+1}\) to spare one \(f(u,t)\) evaluation.

  • out (np.ndarray) – Array used to store the evaluation.

  • t0 (float, optional) – Initial step time. The default is 0.

phiSolve(uPrev, fEvals, out, rhs=0, t0=0)[source]

Solve the node update at given time-node \(\tau_{m+1}\).

Considering \(m+1\) previous known node solutions \(u_0, u_1, ..., u_{m}\), it solves the following system :

\[u -\phi(u_0, u_1, ..., u_{m}, u) = rhs,\]

where the value given in out is used as initial guess and to store the computed solution. It also takes as argument the \(f\) evaluations \(f_0, f_1, ..., f_{m}\) to avoid supplementar re-computing those.

Parameters:
  • uPrev (list[np.ndarray] of size \(m+1\)) – The previous node solutions \(u_0, u_1, ..., u_{m}\).

  • fEvals (list[np.ndarray] of size \(m+1\)) – Evaluations of previous node solutions \(f_0, f_1, ..., f_{m}\).

  • out (np.ndarray) – Array with the initial guess, used to store the final solution.

  • rhs (np.ndarray or float, optional) – Right hand side used to solve the equation above. The default is 0.

  • t0 (float, optional) – Initial step size. The default is 0.

class BackwardEuler(diffOp: DiffOp, nodes, tEnd=1, nSteps=1, t0=0)[source]
Inheritance diagram of qmat.solvers.generic.integrators.BackwardEuler

\(\phi\)-based solver doing Backward Euler update between time nodes.

It uses the following definition :

\[\phi(u_0, u_1, ..., u_{m}, u_{m+1}) = \Delta\tau_{m+1} f(u_{m+1}, t_{m+1}) + ... + \Delta\tau_1 f(u_1, t_1),\]

where \(\Delta\tau_{m} = t_{m+1} - t_{m}\). In particular, its phiSolve method is rewritten to depend directly on the fSolve method of the differential operator to avoid unecessary (re-)evaluations of \(f(u,t)\).

Parameters:
  • diffOp (DiffOp) – Differential operator for the ODE.

  • nodes (1D array-like) – The time nodes \(\tau_1, ..., \tau_M\).

  • tEnd (float, optional) – Final simulation time. The default is 1.

  • nSteps (int, optional) – Number of simulation time-steps. The default is 1.

  • t0 (float, optional) – Initial simulation time. The default is 0.

evalPhi(uVals, fEvals, out, t0=0)[source]

Evaluate the \(\phi\) operator on time-node up to \(u_{m+1}\).

Considering \(u_0, u_1, \dots, u_{m+1}\), if evaluates :

\[\phi(u_0, u_1, ..., u_{m}, u_{m+1}),\]

and store its value into the output vector out. It also takes the node evaluation \(f(u_0,t_0),f(u_1,\tau_1),...,f(u_{m},\tau_{m})\) as arguments, in order to avoid any additional \(f(u,t)\) evaluations.

Parameters:
  • uVals (list[np.ndarray] of size \(m+2\)) – The \(m+1\) time-node solutions + the initial solution \(u_0\).

  • fEvals (list[np.ndarray] of size \(m+1\) or \(m+1\)) – The \(f(u,t)\) evaluations at each time nodes (+ initial solution), up to time-node \(m\). It can eventually contain a pre-computed \(f_{m+1}\) to spare one \(f(u,t)\) evaluation.

  • out (np.ndarray) – Array used to store the evaluation.

  • t0 (float, optional) – Initial step time. The default is 0.

phiSolve(uPrev, fEvals, out, rhs=0, t0=0)[source]

Solve the node update at given time-node \(\tau_{m+1}\).

Considering \(m+1\) previous known node solutions \(u_0, u_1, ..., u_{m}\), it solves the following system :

\[u -\phi(u_0, u_1, ..., u_{m}, u) = rhs,\]

where the value given in out is used as initial guess and to store the computed solution. It also takes as argument the \(f\) evaluations \(f_0, f_1, ..., f_{m}\) to avoid supplementar re-computing those.

Parameters:
  • uPrev (list[np.ndarray] of size \(m+1\)) – The previous node solutions \(u_0, u_1, ..., u_{m}\).

  • fEvals (list[np.ndarray] of size \(m+1\)) – Evaluations of previous node solutions \(f_0, f_1, ..., f_{m}\).

  • out (np.ndarray) – Array with the initial guess, used to store the final solution.

  • rhs (np.ndarray or float, optional) – Right hand side used to solve the equation above. The default is 0.

  • t0 (float, optional) – Initial step size. The default is 0.