How to do it...

No book on scientific computing is complete without revisiting Lorenz attractors. SciPy excels both at the computation of solutions and presentation of ideas based on systems of differential equations, and we will show how and why in this recipe:

  • Consider a two-dimensional fluid cell that is heated from underneath and cooled from above, much like what occurs with the Earth's atmosphere. This creates convection which can be modeled by a single partial differential equation, for which a decent approximation has the form of the following system of ordinary differential equations:
  1. The variable x represents the rate of convective overturning. The variables y and z stand for the horizontal and vertical temperature variations, respectively. This system depends on four physical parameters, the descriptions of which are far beyond the scope of this book. The important point is that we may model the Earth's atmosphere with these equations, and in that, case a good choice for the parameters is given by sigma = 10.0, and b = 8/3.0. For certain values of the third parameter, we have systems for which the solutions behave chaotically. Let's explore this effect with the help of SciPy.
  1. In the following code snippet, we will use one of the solvers in the scipy.integratemodule, as well as the plotting utilities:
from scipy.integrate import ode

y0, t0 = [1.0j, 2.0], 0
def f(t, y, arg1): return [1j*arg1*y[0] + y[1], -arg1*y[1]**2] def jac(t, y, arg1): return [[1j*arg1, 1], [0, -arg1*2*y[1]]]
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset