implementations.problem_classes.Lorenz module¶
- class LorenzAttractor(sigma=10.0, rho=28.0, beta=2.6666666666666665, u0=(1, 1, 1), newton_tol=1e-09, newton_maxiter=99, stop_at_nan=True)[source]¶
Bases:
ptype
Simple script to run a Lorenz attractor problem.
The Lorenz attractor is a system of three ordinary differential equations (ODEs) that exhibits some chaotic behaviour. It is well known for the “Butterfly Effect”, because the solution looks like a butterfly (solve to \(T_{end} = 100\) or so to see this with these initial conditions) and because of the chaotic nature.
Lorenz developed this system from equations modelling convection in a layer of fluid with the top and bottom surfaces kept at different temperatures. In the notation used here, the first component of u is proportional to the convective motion, the second component is proportional to the temperature difference between the surfaces and the third component is proportional to the distortion of the vertical temperature profile from linearity.
See doi.org/10.1175/1520-0469(1963)020<0130:DNF>2.0.CO;2 for the original publication.
Since the problem is non-linear, we need to use a Newton solver.
The system of ODEs is given by
\[\frac{d y_1(t)}{dt} = \sigma (y_2 (t) - y_1 (t)),\]\[\frac{d y_2(t)}{dt} = \rho y_1 (t) - y_2 (t) - y_1 (t) y_3 (t),\]\[\frac{d y_3(t)}{dt} = y_1 (t) y_2 (t) - \beta y_3 (t)\]with initial condition \((y_1(0), y_2(0), y_3(0))^T = (1, 1, 1)^T\) (default) for \(t \in [0, 1]\). The problem parameters for this problem are \(\sigma = 10\), \(\rho = 28\) and \(\beta = 8/3\). Lorenz chose these parameters such that the Reynolds number \(\rho\) is slightly supercritical as to provoke instability of steady convection.
- Parameters:
sigma (float, optional) – Parameter \(\sigma\) of the problem.
rho (float, optional) – Parameter \(\rho\) of the problem.
beta (float, optional) – Parameter \(\beta\) of the problem.
u0 (tuple, optional) – Initial solution \(u_0\) of the problem.
newton_tol (float, optional) – Tolerance for Newton for termination.
newton_maxiter (int, optional) – Maximum number of iterations for Newton’s method.
- work_counter¶
Counts the iterations/nfev (here for Newton’s method and the nfev for the right-hand side).
- Type:
dict
- 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.
- Returns:
f – The right-hand side of the problem.
- Return type:
dtype_f
- solve_system(rhs, dt, u0, t)[source]¶
Simple Newton solver for the nonlinear system.
- Parameters:
rhs (dtype_f) – Right-hand side for the nonlinear system.
factor (float) – Abbrev. for the local 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:
me – 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