implementations.problem_classes.odeSystem module¶
Implementation of systems test problem ODEs.
Reference :
Van der Houwen, P. J., & Sommeijer, B. P. (1991). Iterated Runge–Kutta methods on parallel computers. SIAM journal on scientific and statistical computing, 12(5), 1000-1028.
- class ChemicalReaction3Var(newton_maxiter=200, newton_tol=5e-11, stop_at_nan=True)[source]¶
Bases:
ptype
Chemical reaction with three components, modeled by the non-linear system:
\[\begin{split}\frac{d{\bf u}}{dt} = \begin{pmatrix} 0.013+1000u_3 & 0 & 0 \\ 0 & 2500u_3 0 \\ 0.013 & 0 & 1000u_1 + 2500u_2 \end{pmatrix} {\bf u},\end{split}\]with initial solution \(u(0)=(0.990731920827, 1.009264413846, -0.366532612659e-5)\).
- Parameters:
newton_maxiter (int, optional) – Maximum number of Newton iteration in solve_system. The default is 200.
newton_tol (float, optional) – Residuum tolerance for Newton iteration in solve_system. The default is 5e-11.
stop_at_nan (bool, optional) – Wheter to stop or not solve_system when getting NAN. The default is True.
Reference
---------
Houwen (Van der)
J. (P.)
Sommeijer (&)
methods (B. P. (1991). Iterated Runge–Kutta)
computing (on parallel computers. SIAM journal on scientific and statistical)
:param : :param 12(5): :param 1000-1028.:
- dtype_f¶
alias of
mesh
- dtype_u¶
alias of
mesh
- eval_f(u, t)[source]¶
Routine to evaluate the right-hand side of the problem.
- Parameters:
u (dtype_u) – Current values of the numerical solution.
t (float) – Current time of the numerical solution is computed (not used here).
- Returns:
f – The right-hand side of the problem (one component).
- Return type:
dtype_f
- solve_system(rhs, dt, u0, t)[source]¶
Simple Newton solver for the nonlinear equation
- Parameters:
rhs (dtype_f) – Right-hand side for the nonlinear system.
dt (float) – Abbrev. for the node-to-node stepsize (or any other factor required).
u0 (dtype_u) – Initial guess for the iterative solver.
t (float) – Current time (e.g. for time-dependent BCs).
- Returns:
u – The solution as mesh.
- Return type:
dtype_u
- u_exact(t, u_init=None, t_init=None)[source]¶
Routine to return initial conditions or to approximate exact solution using
SciPy
.- Parameters:
t (float) – Time at which the approximated exact solution is computed.
u_init (pySDC.implementations.problem_classes.Lorenz.dtype_u) – Initial conditions for getting the exact solution.
t_init (float) – The starting time.
- Returns:
me – The approximated exact solution.
- Return type:
dtype_u
- class JacobiElliptic(newton_maxiter=200, newton_tol=5e-11, stop_at_nan=True)[source]¶
Bases:
ptype
Implement the Jacobi Elliptic non-linear problem:
\[\begin{split}\begin{eqnarray*} \frac{du}{dt} &=& vw, &\quad u(0) = 0, \\ \frac{dv}{dt} &=& -uw, &\quad v(0) = 1, \\ \frac{dw}{dt} &=& -0.51uv, &\quad w(0) = 1. \end{eqnarray*}\end{split}\]- Parameters:
newton_maxiter (int, optional) – Maximum number of Newton iteration in solve_system. The default is 200.
newton_tol (float, optional) – Residuum tolerance for Newton iteration in solve_system. The default is 5e-11.
stop_at_nan (bool, optional) – Wheter to stop or not solve_system when getting NAN. The default is True.
Reference
---------
Houwen (Van Der)
J. (P.)
Sommeijer
P. (B.)
Veen (& Van Der)
(1995). (W. A.)
for (Parallel iteration across the steps of high-order Runge-Kutta methods)
applied (nonstiff initial value problems. Journal of computational and)
mathematics
60(3)
309-329.
- dtype_f¶
alias of
mesh
- dtype_u¶
alias of
mesh
- eval_f(u, t)[source]¶
Routine to evaluate the right-hand side of the problem.
- Parameters:
u (dtype_u) – Current values of the numerical solution.
t (float) – Current time of the numerical solution is computed (not used here).
- Returns:
f – The right-hand side of the problem (one component).
- Return type:
dtype_f
- solve_system(rhs, dt, u0, t)[source]¶
Simple Newton solver for the nonlinear equation
- Parameters:
rhs (dtype_f) – Right-hand side for the nonlinear system.
dt (float) – Abbrev. for the node-to-node stepsize (or any other factor required).
u0 (dtype_u) – Initial guess for the iterative solver.
t (float) – Current time (e.g. for time-dependent BCs).
- Returns:
u – The solution as mesh.
- Return type:
dtype_u
- u_exact(t, u_init=None, t_init=None)[source]¶
Routine to return initial conditions or to approximate exact solution using
SciPy
.- Parameters:
t (float) – Time at which the approximated exact solution is computed.
u_init (pySDC.implementations.problem_classes.Lorenz.dtype_u) – Initial conditions for getting the exact solution.
t_init (float) – The starting time.
- Returns:
me – The approximated exact solution.
- Return type:
dtype_u
- class Kaps(epsilon=0.001, newton_maxiter=200, newton_tol=5e-11, stop_at_nan=True)[source]¶
Bases:
ptype
Implement the Kaps problem:
\[\begin{split}\begin{eqnarray*} \frac{du}{dt} &=& -(2+\epsilon^{-1})u + \frac{v^2}{\epsilon}, &\quad u(0) = 1,\\ \frac{dv}{dt} &=& u - v(1+v), &\quad v(0) = 1, \end{eqnarray*}\end{split}\]with \(\epsilon\) a stiffness parameter, that makes the problem more stiff the smaller it is (usual taken value is \(\epsilon=1e^{-3}\)). Exact solution is given by \(u(t)=e^{-2t},\;v(t)=e^{-t}\).
- Parameters:
epsilon (float, optional) – Stiffness parameter. The default is 1e-3.
newton_maxiter (int, optional) – Maximum number of Newton iteration in solve_system. The default is 200.
newton_tol (float, optional) – Residuum tolerance for Newton iteration in solve_system. The default is 5e-11.
stop_at_nan (bool, optional) – Wheter to stop or not solve_system when getting NAN. The default is True.
Reference
---------
Houwen (Van der)
J. (P.)
Sommeijer (&)
methods (B. P. (1991). Iterated Runge–Kutta)
computing (on parallel computers. SIAM journal on scientific and statistical)
:param : :param 12(5): :param 1000-1028.:
- dtype_f¶
alias of
mesh
- dtype_u¶
alias of
mesh
- eval_f(u, t)[source]¶
Routine to evaluate the right-hand side of the problem.
- Parameters:
u (dtype_u) – Current values of the numerical solution.
t (float) – Current time of the numerical solution is computed (not used here).
- Returns:
f – The right-hand side of the problem (one component).
- Return type:
dtype_f
- solve_system(rhs, dt, u0, t)[source]¶
Simple Newton solver for the nonlinear equation
- Parameters:
rhs (dtype_f) – Right-hand side for the nonlinear system.
dt (float) – Abbrev. for the node-to-node stepsize (or any other factor required).
u0 (dtype_u) – Initial guess for the iterative solver.
t (float) – Current time (e.g. for time-dependent BCs).
- Returns:
u – The solution as mesh.
- Return type:
dtype_u
- u_exact(t, u_init=None, t_init=None)[source]¶
Routine to return initial conditions or exact solutions.
- Parameters:
t (float) – Time at which the exact solution is computed.
u_init (dtype_u) – Initial conditions for getting the exact solution.
t_init (float) – The starting time.
- Returns:
u – The exact solution.
- Return type:
dtype_u
- class ProtheroRobinsonAutonomous(epsilon=0.001, nonLinear=False, newton_maxiter=200, newton_tol=5e-11, stop_at_nan=True)[source]¶
Bases:
ptype
Implement the Prothero-Robinson problem into autonomous form:
\[\begin{split}\begin{eqnarray*} \frac{du}{dt} &=& -\frac{u^3-g(v)^3}{\epsilon} + \frac{dg}{dv}, &\quad u(0) = g(0),\\ \frac{dv}{dt} &=& 1, &\quad v(0) = 0, \end{eqnarray*}\end{split}\]with \(\epsilon\) a stiffness parameter, that makes the problem more stiff the smaller it is (usual taken value is \(\epsilon=1e^{-3}\)). Exact solution is given by \(u(t)=g(t),\;v(t)=t\), and this implementation uses \(g(t)=\cos(t)\).
Implement also the non-linear form of this problem:
\[\frac{du}{dt} = -\frac{u^3-g(v)^3}{\epsilon} + \frac{dg}{dv}, \quad u(0) = g(0).\]To use an other exact solution, one just have to derivate this class and overload the g, dg and dg2 methods. For instance, to use \(g(t)=e^{-0.2t}\), define and use the following class:
>>> class MyProtheroRobinson(ProtheroRobinsonAutonomous): >>> >>> def g(self, t): >>> return np.exp(-0.2 * t) >>> >>> def dg(self, t): >>> return (-0.2) * np.exp(-0.2 * t) >>> >>> def dg2(self, t): >>> return (-0.2) ** 2 * np.exp(-0.2 * t)
- Parameters:
epsilon (float, optional) – Stiffness parameter. The default is 1e-3.
nonLinear (bool, optional) – Wether or not to use the non-linear form of the problem. The default is False.
newton_maxiter (int, optional) – Maximum number of Newton iteration in solve_system. The default is 200.
newton_tol (float, optional) – Residuum tolerance for Newton iteration in solve_system. The default is 5e-11.
stop_at_nan (bool, optional) – Wheter to stop or not solve_system when getting NAN. The default is True.
Reference
---------
Robinson (A. Prothero and A.)
solving (On the stability and accuracy of one-step methods for)
equations (stiff systems of ordinary differential)
Computation (Mathematics of)
(1974) (28)
:param : :param pp. 145–162.:
- dtype_f¶
alias of
mesh
- dtype_u¶
alias of
mesh
- eval_f(u, t)[source]¶
Routine to evaluate the right-hand side of the problem.
- Parameters:
u (dtype_u) – Current values of the numerical solution.
t (float) – Current time of the numerical solution is computed (not used here).
- Returns:
f – The right-hand side of the problem (one component).
- Return type:
dtype_f
- solve_system(rhs, dt, u0, t)[source]¶
Simple Newton solver for the nonlinear equation
- Parameters:
rhs (dtype_f) – Right-hand side for the nonlinear system.
dt (float) – Abbrev. for the node-to-node stepsize (or any other factor required).
u0 (dtype_u) – Initial guess for the iterative solver.
t (float) – Time of the updated solution (e.g. for time-dependent BCs).
- Returns:
u – The solution as mesh.
- Return type:
dtype_u
- u_exact(t, u_init=None, t_init=None)[source]¶
Routine to return initial conditions or exact solutions.
- Parameters:
t (float) – Time at which the exact solution is computed.
u_init (dtype_u) – Initial conditions for getting the exact solution.
t_init (float) – The starting time.
- Returns:
u – The exact solution.
- Return type:
dtype_u