implementations.problem_classes.LogisticEquation module¶
- class logistics_equation(u0=0.5, newton_maxiter=100, newton_tol=1e-12, direct=True, lam=1, stop_at_nan=True)[source]¶
Bases:
ptype
Problem implementing a specific form of the Logistic Differential Equation
\[\frac{du}{dt} = \lambda u(t)(1-u(t))\]with \(\lambda\) a given real coefficient. Its analytical solution is given by
\[u(t) = u(0) \frac{e^{\lambda t}}{1-u(0)+u(0)e^{\lambda t}}\]- Parameters:
u0 (float, optional) – Initial condition.
newton_maxiter (int, optional) – Maximum number of iterations for Newton’s method.
newton_tol (float, optional) – Tolerance for Newton’s method to terminate.
direct (bool, optional) – Indicates if the problem should be solved directly or not. If False, it will be approximated by Newton.
lam (float, optional) – Problem parameter \(\lambda\).
stop_at_nan (bool, optional) – Indicates if the Newton solver stops when nan values arise.
- dtype_f¶
alias of
mesh
- dtype_u¶
alias of
mesh
- eval_f(u, t)[source]¶
Routine to compute 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.
- Returns:
f – The right-hand side of the problem (contains 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