qmat.solvers.generic.integrators ================================ .. py:module:: qmat.solvers.generic.integrators .. autoapi-nested-parse:: Specialized :class:`PhiSolver` classes implementing various time-integrators. Classes ------- .. autoapisummary:: qmat.solvers.generic.integrators.ForwardEuler qmat.solvers.generic.integrators.BackwardEuler Module Contents --------------- .. py:class:: ForwardEuler(diffOp: DiffOp, nodes, tEnd=1, nSteps=1, t0=0) .. autoapi-inheritance-diagram:: qmat.solvers.generic.integrators.ForwardEuler :parts: 1 :math:`\phi`-based solver doing Forward Euler update between time nodes. It uses the following definition : .. math:: \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 :math:`\Delta\tau_{m} = t_{m+1} - t_{m}`. In particular, since it does not depends on the node solution :math:`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 :math:`\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. .. py:method:: evalPhi(uVals, fEvals, out, t0=0) Evaluate the :math:`\phi` operator on time-node up to :math:`u_{m+1}`. Considering :math:`u_0, u_1, \dots, u_{m+1}`, if evaluates : .. math:: \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 :math:`f(u_0,t_0),f(u_1,\tau_1),...,f(u_{m},\tau_{m})` as arguments, in order to avoid any additional :math:`f(u,t)` evaluations. :Parameters: * **uVals** (list[np.ndarray] of size :math:`m+2`) -- The :math:`m+1` time-node solutions + the initial solution :math:`u_0`. * **fEvals** (list[np.ndarray] of size :math:`m+1` or :math:`m+1`) -- The :math:`f(u,t)` evaluations at each time nodes (+ initial solution), up to time-node :math:`m`. It can eventually contain a pre-computed :math:`f_{m+1}` to spare one :math:`f(u,t)` evaluation. * **out** (*np.ndarray*) -- Array used to store the evaluation. * **t0** (*float, optional*) -- Initial step time. The default is 0. .. py:method:: phiSolve(uPrev, fEvals, out, rhs=0, t0=0) Solve the node update at given time-node :math:`\tau_{m+1}`. Considering :math:`m+1` previous known node solutions :math:`u_0, u_1, ..., u_{m}`, it solves the following system : .. math:: 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 :math:`f` evaluations :math:`f_0, f_1, ..., f_{m}` to avoid supplementar re-computing those. :Parameters: * **uPrev** (list[np.ndarray] of size :math:`m+1`) -- The previous node solutions :math:`u_0, u_1, ..., u_{m}`. * **fEvals** (list[np.ndarray] of size :math:`m+1`) -- Evaluations of previous node solutions :math:`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. .. py:class:: BackwardEuler(diffOp: DiffOp, nodes, tEnd=1, nSteps=1, t0=0) .. autoapi-inheritance-diagram:: qmat.solvers.generic.integrators.BackwardEuler :parts: 1 :math:`\phi`-based solver doing Backward Euler update between time nodes. It uses the following definition : .. math:: \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 :math:`\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 :math:`f(u,t)`. :Parameters: * **diffOp** (*DiffOp*) -- Differential operator for the ODE. * **nodes** (*1D array-like*) -- The time nodes :math:`\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. .. py:method:: evalPhi(uVals, fEvals, out, t0=0) Evaluate the :math:`\phi` operator on time-node up to :math:`u_{m+1}`. Considering :math:`u_0, u_1, \dots, u_{m+1}`, if evaluates : .. math:: \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 :math:`f(u_0,t_0),f(u_1,\tau_1),...,f(u_{m},\tau_{m})` as arguments, in order to avoid any additional :math:`f(u,t)` evaluations. :Parameters: * **uVals** (list[np.ndarray] of size :math:`m+2`) -- The :math:`m+1` time-node solutions + the initial solution :math:`u_0`. * **fEvals** (list[np.ndarray] of size :math:`m+1` or :math:`m+1`) -- The :math:`f(u,t)` evaluations at each time nodes (+ initial solution), up to time-node :math:`m`. It can eventually contain a pre-computed :math:`f_{m+1}` to spare one :math:`f(u,t)` evaluation. * **out** (*np.ndarray*) -- Array used to store the evaluation. * **t0** (*float, optional*) -- Initial step time. The default is 0. .. py:method:: phiSolve(uPrev, fEvals, out, rhs=0, t0=0) Solve the node update at given time-node :math:`\tau_{m+1}`. Considering :math:`m+1` previous known node solutions :math:`u_0, u_1, ..., u_{m}`, it solves the following system : .. math:: 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 :math:`f` evaluations :math:`f_0, f_1, ..., f_{m}` to avoid supplementar re-computing those. :Parameters: * **uPrev** (list[np.ndarray] of size :math:`m+1`) -- The previous node solutions :math:`u_0, u_1, ..., u_{m}`. * **fEvals** (list[np.ndarray] of size :math:`m+1`) -- Evaluations of previous node solutions :math:`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.