implementations.problem_classes.nonlinear_ODE_1 module¶
- class nonlinear_ODE_1(u0=0.0, newton_maxiter=200, newton_tol=5e-11, stop_at_nan=True)[source]¶
Bases:
ptype
This class implements a simple nonlinear ODE with a singularity in the derivative, taken from https://www.osti.gov/servlets/purl/6111421 (Problem E-4). For \(0 \leq t \leq 5\), the problem is given by
\[\frac{du(t)}{dt} = \sqrt{1 - u(t)}\]with initial condition \(u(0) = 0\). The exact solution is
\[u(t) = t - \frac{t^2}{4}.\]- Parameters:
u0 (float, optional) – Initial condition.
newton_maxiter (float, optional) – Maximum number of iterations for Newton’s method.
newton_tol (float, optional) – Tolerance for Newton’s method to terminate.
stop_at_nan (bool, optional) – Indicates that Newton solver has to stop if
nan
values arise.
- newton_itercount¶
Counts the Newton iterations.
- Type:
int
- newton_ncalls¶
Counts calls of Newton method.
- Type:
int
- 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