numerical solutions for lorentz attractor

23
2 | Page Lorenz has stumbled upon chaos, an iconoclast to the belief that approximations would only lead to subtle, negligible differences of the system’s solution. At that instant, he realized that long-term weather forecast was out the window, yet a new curiosity about the systems “orderly disorder” had arisen [2]. Despite attempts to keep the dream alive, not even the best supercomputers of the time were capable of accurately predicting meteorological conditions beyond a period of a few days. The aperiodicity, unpredictability, sensitive dependence on the initial conditions, and a system with no steady state inspired Lorenz to focus on a simplified model to explain the chaotic behavior. He modeled the hydrodynamic process of convection in heated fluid, which is coined today as the Lorenz equations. However, even this elegant system of equations displayed the certain strangeness that was witnessed in his computer printouts. Upon plotting the simulated outputs, a complex bounded swirling orbit was observed. “It traced a strange, distinctive shape, a kind of double spiral in three dimensions, like a butterfly with its two wings. The shaped signaled pure disorder, since no point or pattern of points ever reoccurred. Yet it also signaled a new kind of order” [2]. The trajectory lied on some sort of a “strange attractor.” Just as there were skeptics in the time of Aristotle and his empirical claim of the spherical shape of the Earth, Lorenz faced a similar criticism. To disprove the nonbelievers, he pulled together a chaotic waterwheel as the upmost rebuttal corroborating his claim and spreading the seed of a new branch in mathematics, chaos. The problem that led to formulation of these equations comes from fluid dynamics and meteorology. Edward Lorenz was trying to figure out a mathematical representation of chaotic behavior of weather. His 1963 publication entitled, “Deterministic Nonperiodic Flow” coined the phrase “Butterfly Effect”. The title of his 1972 talk at a meeting of the AAAS Figure 2: The Lorenz attractor displaying the strange chaotic behavior of the system governing a convective flow of a heated fluid. (American Association for the Advancement of Science) was “Predictability: Does the Flap of a Butterfly's Wings in Brazil set off a Tornado in Texas?” [3] which clearly captures the essence of what the butterfly effect is i.e. small perturbations in a chaotic system (such as the weather) can cause quite large deviations from what the short-range predictions might suggest. In other words, the sensitivity to initial conditions is called the butterfly effect. The Lorenz attractor became the symbol of chaos theory, just as Mandelbrot set became the symbol of fractal geometry. Since Mandelbrot’s work was published in 1960s as well, it was later discovered that the Lorenz attractor, is in fact, a fractal. 3. The Original Problem Everything starts with the desire to forecast weather for longer periods. It is hard to give a long-term weather forecast because the atmosphere is a chaotic system. A lot of work has been put into knowing the weather in advance, as it is of the utmost importance to military, transportation industry, and other such groups. [5] The problem that lead to the discovery of this system of equations was of thermal convection in a layer heated from above (the Bénard problem). Lorenz assumed stress-free boundaries for the system. He

Upload: mandeepsingh

Post on 16-Jan-2016

13 views

Category:

Documents


0 download

DESCRIPTION

Numerical method report to simulate a chaotic solution.

TRANSCRIPT

Page 1: Numerical Solutions for Lorentz Attractor

2 | P a g e

Lorenz has stumbled upon chaos, an iconoclast to the belief that approximations would only lead to subtle, negligible differences of the system’s solution. At that instant, he realized that long-term weather forecast was out the window, yet a new curiosity about the systems “orderly disorder” had arisen [2]. Despite attempts to keep the dream alive, not even the best supercomputers of the time were capable of accurately predicting meteorological conditions beyond a period of a few days.

The aperiodicity, unpredictability, sensitive dependence on the initial conditions, and a system with no steady state inspired Lorenz to focus on a simplified model to explain the chaotic behavior. He modeled the hydrodynamic process of convection in heated fluid, which is coined today as the Lorenz equations. However, even this elegant system of equations displayed the certain strangeness that was witnessed in his computer printouts. Upon plotting the simulated outputs, a complex bounded swirling orbit was observed. “It traced a strange, distinctive shape, a kind of double spiral in three dimensions, like a butterfly with its two wings. The shaped signaled pure disorder, since no point or pattern of points ever reoccurred. Yet it also signaled a new kind of order” [2]. The trajectory lied on some sort of a “strange attractor.”

Just as there were skeptics in the time of Aristotle and his empirical claim of the spherical shape of the Earth, Lorenz faced a similar criticism. To disprove the nonbelievers, he pulled together a chaotic waterwheel as the upmost rebuttal corroborating his claim and spreading the seed of a new branch in mathematics, chaos.

The problem that led to formulation of these equations comes from fluid dynamics and meteorology. Edward Lorenz was trying to figure out a mathematical representation of chaotic behavior of weather. His 1963 publication entitled, “Deterministic Nonperiodic Flow” coined the phrase “Butterfly Effect”. The title of his 1972 talk at a meeting of the AAAS

Figure 2: The Lorenz attractor displaying the strange chaotic behavior of the system governing a convective flow of a heated fluid.

(American Association for the Advancement of Science) was “Predictability: Does the Flap of a Butterfly's Wings in Brazil set off a Tornado in Texas?” [3] which clearly captures the essence of what the butterfly effect is i.e. small perturbations in a chaotic system (such as the weather) can cause quite large deviations from what the short-range predictions might suggest. In other words, the sensitivity to initial conditions is called the butterfly effect. The Lorenz attractor became the symbol of chaos theory, just as Mandelbrot set became the symbol of fractal geometry. Since Mandelbrot’s work was published in 1960s as well, it was later discovered that the Lorenz attractor, is in fact, a fractal.

3. The Original Problem

Everything starts with the desire to forecast weather for longer periods. It is hard to give a long-term weather forecast because the atmosphere is a chaotic system. A lot of work has been put into knowing the weather in advance, as it is of the utmost importance to military, transportation industry, and other such groups. [5] The problem that lead to the discovery of this system of equations was of thermal convection in a layer heated from above (the Bénard problem). Lorenz assumed stress-free boundaries for the system. He

Page 2: Numerical Solutions for Lorentz Attractor

3 | P a g e

defined his streamfunction by assuming nonlinear disturbances in form of rolls invariant in the y direction. For the convective hydrodynamical problem, is Prandtl number, is the ratio of Rayleigh’s number and the value at which system bifurcates, and ( )⁄ . Rayleigh’s number measures how hard we're driving the system, relative to the dissipation. More precisely, the ratio expresses a competition between g and q, (gravity and inflow). So it makes sense that steady rotation is possible only if the Rayleigh number is large enough. Lorenz obtained the system by defining streamfunction in xz-plane. ⁄ and ⁄ , with ( ) and ( ) ( ) . is the departure of temperature from the state of no convection, and k is the wavenumber of perturbation. The original Lorenz system is obtained by substituting the above equations in the equations of motion. By doing this, he was able to demonstrate that the development of chaos is associated with the attractor acquiring strange properties. [4] 4. The Strangeness

The trajectories in the phase plane in the Lorenz model of thermal convection are shown on page 2. The centers of the two loops represent the two steady convections √ ( ) . The trajectories go clockwise around the left loop and counterclockwise around the right loop; the two trajectories never intersect. This structure is an attractor because orbits starting with initial conditions outside of the attractor merge on it and then follow it. The attraction is

a result of dissipation in the system. The aperiodic attractor, however, is unlike the normal attractor in the form of a fixed point or a closed curve. This is because the two trajectories on the aperiodic attractor, with infinitesimally different initial conditions, follow each other closely only for a while, eventually diverging to very different final states. This is the basic reason for sensitivity to initial conditions. For these reasons the aperiodic attract is called a strange attractor. An ordinary attractor “forgets” slightly different initial conditions, whereas the strange attractor ultimately accentuates them. Since Lorenz’s work, attractors of other chaotic systems have been studied and they all have common property of aperiodicity, continuous spectra, and sensitivity to initial conditions.

5. References

[1] Boyce W.E. and DiPrima R.C., Elementary Differential Equations and Boundary Value Problems, Danvers: John Wiley & Sons, Inc., 2009.

[2] Gleick J., Chaos: Making a New Science, New York: Penguin Books, 2008.

[3] Hilborn, R.C. Chaos and Nonlinear Dynamics. (Oxford Uni-versity Press, 1994. Print.

[4] Pijush, Kundu. Fluid Mechanics. 4th ed. London: Academic press, 2008. 528-523. Print.

[5] Lorenz, Edward N., 1963: Deterministic Nonperiodic Flow. J. Atmos. Sci., 20, 130–141.

Page 3: Numerical Solutions for Lorentz Attractor

4 | P a g e

PART II – CRITICAL POINTS AND STABILITY ANALYSIS

The Lorenz Equations are:

For this project

There are three critical points for the above system.

( ) .√ ( ) √ ( ) / . √ ( ) √ ( ) /

Note that and only exist for .

In order to perform linear stability analysis for each of the critical points, one must linearize the system around these points.

(

)

| | ( )(( )( ) )

( ) √( ) ( )

For the values given,

Proof that above point is globally stable for :

The Liapunov function for the Lorenz equations can be constructed through trial and error. Typically, the sum of squares is the initial starting point. Let the Liapunov function V be formulated as below: ( )

( ) ( ) ( )

{(

)

[ (

) ]

} ( ) ( ) Above implies global stability.

Using the following transformation:

√ ( )

√ ( ) ( )

Produces the following equations:

√ ( )

Page 4: Numerical Solutions for Lorentz Attractor

5 | P a g e

( )

(

)

| | ( ),( )( ) -

, ( ) - ( ) ( )

Eigenvalues exist as purely real values or come in pairs of either purely imaginary or complex conjugates. A bifurcation of solutions occurs when the eigenvalues cross into the right half of complex plane. That is when * + changes sign. Thus, by looking for eigenvalues of the form , where is real, the bifurcation point can be found.

( ) ( ) ( )

, ( ) - ( ) ( ) ( ) ( )( ) ( )

At the critical point, all of the eigenvalues can be easily computed.

( )( )( ) ( )( ) ( ) ( ) ( )

( )

Now to determine the stability of the points

for this critical point, plugging in

values into the analytical cubic root formulas for and gives the following eigenvalues:

Page 5: Numerical Solutions for Lorentz Attractor

6 | P a g e

PART III – GLOBALLY STABLE

Page 6: Numerical Solutions for Lorentz Attractor

7 | P a g e

PART IV – GLOBALLY STABLE

Page 7: Numerical Solutions for Lorentz Attractor

8 | P a g e

Page 8: Numerical Solutions for Lorentz Attractor

9 | P a g e

PART V – PLOTS

Page 9: Numerical Solutions for Lorentz Attractor

10 | P a g e

Page 10: Numerical Solutions for Lorentz Attractor

11 | P a g e

PART VI – PLOTS

Poincaré map

Page 11: Numerical Solutions for Lorentz Attractor

12 | P a g e

PART VIII – PLOTS

Page 12: Numerical Solutions for Lorentz Attractor

13 | P a g e

PART VII – PLOTS

Page 13: Numerical Solutions for Lorentz Attractor

14 | P a g e

Page 14: Numerical Solutions for Lorentz Attractor

15 | P a g e

ADDITIONAL PLOT FOR PART IV

Page 15: Numerical Solutions for Lorentz Attractor

16 | P a g e

PART VIII – PROBLEM 5

Consider the Ellipsoid:

( ) ( )

a. Calculate ⁄ along trajectories of Lorenz Equations.

, ( )- ( )

( )( )

, ( )- , ( ) -

b. Determine a sufficient condition on c so that every trajectory crossing ( ) is directed inward.

From part a, we get:

, if ( ) , which holds if ( ) lies outside the ellipsoid

( )

We need to choose c, s.t. V = c lies outside the ellipsoid defined above. Writing V = c in the form of above equation, we obtain the ellipsoid:

( )

Let (√ √ ), then the ellipsoid in

the first equation is contained inside the sphere:

( )

Let another sphere, S2, be centered at ( ) with radius :

( )

( ) ( )

Then, the first sphere is contained in S2. Thus,

if we choose c, s.t. ( ) and

( ) , then as the trajectory

crosses ( ) .

c.

Page 16: Numerical Solutions for Lorentz Attractor

17 | P a g e

DISCUSSION

PART III For r<1, we see that for any set of initial conditions, the solution decays to zero for large times. The result is expected since a Liapunov function can be constructed for the governing system implying global stability.

PART IV

For 1 < r < 470/19, there are two stable critical points. Thus depending on the prescribed initial conditions, the system settles down to a steady state at one of the two points. Note that the equilibrium state at the origin is unstable, thus none of the solutions converge to this point.

PART V

r=28 corresponds to a state where all critical points are unstable. Thus, the trajectories never settle down to a steady state. Also, since there exists a trapping region as derived in part 8, the solution never goes off to infinity either. The solution lies on a strange attractor. For the critical point at the origin, the trajectories never get too close, however it seems to define the boundary where certain incoming paths become deflected from one one wing of the attractor to the other. As for the other two critical points, the solution winds about the two point in an elliptical-like fashion. As for the number of windings before it is flung onto the other wing is completely random. Also, no one point intersects another, yet come arbitrarily close to one another.

PART VI – POINCARÉ MAP

A Poincaré map is a way of taking a section out of dynamical system in order to watch the behavior of the system in one less dimension. For example, we use the Poincaré map to study the behavior of the 3D Lorenz map in a 2D plane. The most usual aspect of studying a Poincaré map is to watch what the mapped points are doing as time goes on. If the points seem to be converging to a point, there may be a fixed point. If they appear divergent, that very well may be the case for the entire

system. And if they are neither, then there is some form of cycle.

Every time the system passes through the plane z = 27 in our example, a point is plotted on a 2D surface. We can then take a look at what these points are doing and where they seem to be going. The first thing to notice is that the points do not seem to be diverging from each other, nor converging to any point, so we will take a look at the possibilities. There are sets known as a non-wandering sets of which there are four types: fixed points, limit cycles, quasiperiodic cycles, and chaotic orbits. Non-wandering simply means that all systems with different initial conditions will come arbitrarily close to one another at times, basically meaning they are not divergent systems.

Looking at our plot we can rule out all but a chaotic orbit. There is no single point it is converging to (fixed point); it is not following any one orbit (limit cycle); and there is not an orbit with a couple distinct periods or frequencies (quasiperiodic cycles). It is however, orbiting in a way and definitely stay within some form of an orbit even though that orbit is unpredictable. Therefore, the Poincaré map here shows a chaotic orbit, which we can then take and use to say that the system as a whole follows a chaotic orbit.

This process of using a Poincaré map is applicable to an n-dimensional system, and its use is then taking that system and studying in in (n-1)-dimensions, which simplifies the problem. It is extremely rare to be able to calculate a formula for the Poincaré map, but by running a numerical algorithm, such as the one used in this report, it is possible to plot a very good estimation of the map.

PART VII

“Chaos is aperiodic long-term behavior in a deterministic system that exhibits sensitive dependence on initial conditions”. (Strogatz, P.323) The motion on the attractor exhibits

Page 17: Numerical Solutions for Lorentz Attractor

18 | P a g e

sensitive dependence on initial conditions just like other chaotic systems. This means that two trajectories initially separated by a very small distance will rapidly diverge from each other with time. In order to study this behavior, we solved the Lorenz Equations for two nearby points as initial conditions. Our first initial condition is a point x(t) = (x0 , y0, z0) from the trajectory at time t = 60s and another is a nearby point x(t) + δ(t) = (x0 + δ0, y0 + δ0, z0 + δ0) separated by the distance δ0 = 10-5. δ(t) grows with time, which means the distance gets bigger as t Æ ∞. From our plots, we observed that the neighboring trajectories separate exponentially; that is, the distance grows exponentially with time. Initially, the two trajectories seem coincident, as indicated by the small difference between two points, but after certain time period the difference gets

larger and then they are no longer coincident. If we plot log(δ(t)) vs t, we find a curve that shows the exponential divergence. We observe wiggles instead of straight lines because the strength of the exponential divergence varies along the attractor. The two trajectories cannot be separated by a distance greater than the length of the attractor. Since the trajectories are bound to a finite domain of the attractor, and cannot escape to infinity, the distance between the two points can no longer grow. For larger time, as the motion continues, the distance between the trajectories varies (decreases and increases) and creates some noise because of the attractor.

Page 18: Numerical Solutions for Lorentz Attractor

19 | P a g e

APPENDIX: CODES

THIS FIRST SECTION SHOWS THE CODE FOR CALCULATIONS DONE FOR ALL THE PLOTS ON PAGES 6 TO 11 AND THE CODE USED TO

PRODUCE THOSE PLOTS.

%This code uses Runge–Kutta method of 4th order in a vector form. tic %tic-toc used for benchmarking purposes to calculate execution time. clear clc r = ; %Appropriate value for r, depending on the problem. h = ; %Declare step size. For the project, h = 0.00001 t=0:h:tf; %Create the variable vector. Value tf depending on problem. %initial conditions, chosen for each problem. x0 = ; y0 = ; z0 = ; Y = zeros(3,length(t))'; Y(1,1) = x0; Y(1,2) = y0; Y(1,3) = z0; for i=1:length(t)-1

k1 = [-10*Y(i,1)+10*Y(i,2),r*Y(i,1)-Y(i,2)-Y(i,1)*Y(i,3), Y(i,1)*Y(i,2)-(8/3)*Y(i,3)]; k2 = [-10*Y(i,1)+10*Y(i,2),r*Y(i,1)-Y(i,2)-Y(i,1)*Y(i,3), Y(i,1)*Y(i,2)-(8/3)*Y(i,3)] + 0.5*h.*k1; k3 = [-10*Y(i,1)+10*Y(i,2),r*Y(i,1)-Y(i,2)-Y(i,1)*Y(i,3), Y(i,1)*Y(i,2)-(8/3)*Y(i,3)] + 0.5*h.*k2; k4 = [-10*Y(i,1)+10*Y(i,2),r*Y(i,1)-Y(i,2)-Y(i,1)*Y(i,3), Y(i,1)*Y(i,2)-(8/3)*Y(i,3)] + 0.5*h.*k3;

Y(i+1,:) = Y(i,:)+(1/6).*h.*(k1 + 2.*k2 + 2.*k3 + k4); end toc %Produce a plot for x(t) vs. t, y(t) vs. t, z(t) vs. t figure1 = figure; axes1 = axes('Parent',figure1,'FontSize',16,'Position',[0.025 0.0868 0.956875 0.855]); box(axes1,'on'); hold(axes1,'all'); plot(t,Y(:,1),'linewidth',2) hold on plot(t,Y(:,2),'r','linewidth',2) plot(t,Y(:,3),'black','linewidth',2) xlabel('time','fontsize',16) title(['r = ',num2str(r),' Initial Conditions: x_0 = ',num2str(x0),', y_0 = ',num2str(y0),', z_0 = ',num2str(z0)],'fontsize',16) legend('x(t)','y(t)','z(t)') grid on hold off %Produce a plot for phase plane x(t) vs. y(t) figure2 = figure; axes1 = axes('Parent',figure1,'FontSize',16,'Position',[0.025 0.0868 0.956875 0.855]); box(axes1,'on'); hold(axes1,'all'); plot(Y(:,1),Y(:,2),'linewidth',2)

Page 19: Numerical Solutions for Lorentz Attractor

20 | P a g e

hold on plot(sqrt(8/3*(27)),sqrt(8/3*(27)),'b*') plot(-sqrt(8/3*(27)),-sqrt(8/3*(27)),'b*') plot(0,0,'b*') xlabel('time','fontsize',16) title(['x vs. y; r = ',num2str(r)],'fontsize',16) legend('x(t) vs. y(t)','CP') grid on hold off %Produce a plot for phase plane x(t) vs. z(t) figure3 = figure; axes1 = axes('Parent',figure1,'FontSize',16,'Position',[0.025 0.0868 0.956875 0.855]); box(axes1,'on'); hold(axes1,'all'); plot(Y(:,1),Y(:,3),'linewidth',2) hold on plot(sqrt(8/3*(27)),27,'b*') plot(-sqrt(8/3*(27)),27,'b*') plot(0,0,'b*') xlabel('time','fontsize',16) title(['x vs. z r = ',num2str(r)],'fontsize',16) legend('x(t) vs. z(t)','CP') grid on hold off %Produce a plot for phase plane y(t) vs. z(t) figure4 = figure; axes1 = axes('Parent',figure1,'FontSize',16,'Position',[0.025 0.0868 0.956875 0.855]); box(axes1,'on'); hold(axes1,'all'); plot(Y(:,2),Y(:,3),'linewidth',2) hold on plot(sqrt(8/3*(27)),27,'b*') plot(-sqrt(8/3*(27)),27,'b*') plot(0,0,'b*') xlabel('time','fontsize',16) title(['y vs. z r = ',num2str(r)],'fontsize',16) legend('y(t) vs. z(t)','CP') grid on hold off %Produce a 3D plot for the strange attractor figure5 = figure; hold on view([-297 107 228]); plot3(Y(:,1),Y(:,2),Y(:,3)); scatter3(sqrt(8/3*(27)),sqrt(8/3*(27)),27,'m*') scatter3(-sqrt(8/3*(27)),-sqrt(8/3*(27)),27,'m*') grid on xlabel('x','fontsize',16) ylabel('y','fontsize',16) zlabel('z','fontsize',16) xlim([-18 18]) ylim([-25 25]) title(['r = ',num2str(r),' Initial Conditions: x_0 = ',num2str(x0),', y_0 = ',num2str(y0),', z_0 = ',num2str(z0)],'fontsize',16) hold off

Page 20: Numerical Solutions for Lorentz Attractor

21 | P a g e

SECOND SECTION CONTAINS THE CODE FOR THE CALCULATIONS INVOLVING POINCARÉ MAP (PROBLEM 6). program lorenz integer n, i parameter (n = 100000) real x(n),y(n),z(n),t(n) real pm(n,3) real l(n,2) call AB(n,x,y,z,t) call poincareMap (x,y,z,t,n,pm) call interpolate(n,pm,l) open (77, file='xyzt.txt', status='new') do i=1, n write(77,50), x(i),y(i),z(i),t(i),pm(i,1),pm(i,2),pm(i,3),& & l(i,1),l(i,2) enddo 50 format(f10.5,8x,f10.5,8x,f10.5,8x,f10.5,8x,f10.5,8x,f10.5,8x,f10.5,& & 8x,f10.5,8x,f10.5) close(77) print *, 't = ',t(85607),' x = ', x(85607),' y = ', y(85607),' & & z = ', z(85607) stop end -------------------------------------------------------------------------- subroutine AB (n,x,y,z,t) !Adams-Bashfourth third order explicit multi-step method. real x(n),y(n),z(n),t(n) real f0(3),f1(3),f2(3),f3(3) real s,b,r parameter (s = 10, b = 8.0/3.0, r = 28) real e parameter (e = 10**(-5)) real tmax parameter (tmax = 100.0) real h integer i h = tmax/n !Initial conditions x(1) = 5.0 y(1) = 5.0 z(1) = 5.0 t(1) = 0.0 !Forward Euler O(1) for n=1 (n=0,…,99999) i=1 call rhs (s,b,r,x(i),y(i),z(i),f0) x(i+1) = x(i) + h*f0(1) y(i+1) = y(i) + h*f0(2)

Page 21: Numerical Solutions for Lorentz Attractor

22 | P a g e

z(i+1) = z(i) + h*f0(3) t(i+1) = t(i) + h !Adams-Bashfourth O(2) for n=2 i=2 call rhs (s,b,r,x(i),y(i),z(i),f1) x(i+1) = x(i) + 0.5*h*(3*f1(1) - f0(1)) y(i+1) = y(i) + 0.5*h*(3*f1(2) - f0(2)) z(i+1) = z(i) + 0.5*h*(3*f1(3) - f0(3)) t(i+1) = t(i) + h !Adams-Bashfourth O(3) for n=3,…,99999 do i=3,n-1 call rhs (s,b,r,x(i),y(i),z(i),f2) x(i+1) = x(i) + h/12*(23*f2(1) - 16*f1(1) + 5*f0(1)) y(i+1) = y(i) + h/12*(23*f2(2) - 16*f1(2) + 5*f0(2)) z(i+1) = z(i) + h/12*(23*f2(3) - 16*f1(3) + 5*f0(3)) t(i+1) = t(i) + h f0 = f1 f1 = f2 call rhs (s,b,r,x(i),y(i),z(i),f2) enddo return end -------------------------------------------------------------------------- subroutine rhs (s,b,r,x,y,z,f0) !R.H.S. of dX/dt, X=(x,y,z) real f0(3) f0(1) = s*(-x + y) f0(2) = r*x - y - x*z f0(3) = -b*z + x*y return end -------------------------------------------------------------------------- subroutine poincareMap (x,y,z,t,n,pm) !For the Poincare Map, find a point directly below the z=r-1 plane and a !point directly above the z=r-1 plane. !Computations done only for time t>30. ! plane z=r-1 at r=28 real x(n),y(n),z(n),t(n) real pm(n,3) real zp parameter (zp = 27.0) integer i,j,k,zz do j=1, n pm(j,1) = 0 pm(j,2) = 0 pm(j,3) = 0 enddo

Page 22: Numerical Solutions for Lorentz Attractor

23 | P a g e

zz = 0 i = 1 do k=1, n if ((zz .eq. 0) .and. (t(k) .ge. 30.0)) then if (z(k) .gt. zp) then pm(i,1) = x(k-1) pm(i,2) = y(k-1) pm(i,3) = z(k-1) i = i + 1 pm(i,1) = x(k) pm(i,2) = y(k) pm(i,3) = z(k) i = i + 1 zz = 1 endif endif if ((zz .eq. 1) .and. (t(k) .ge. 30.0)) then if (z(k) .lt. zp) then pm(i,1) = x(k-1) pm(i,2) = y(k-1) pm(i,3) = z(k-1) i = i + 1 pm(i,1) = x(k) pm(i,2) = y(k) pm(i,3) = z(k) i = i + 1 zz = 0 endif endif enddo return end -------------------------------------------------------------------------- subroutine interpolate(n,pm,l) !Apply linear interpolation on the two points acquired in the poincareMap !subroutine. From the line, use the point intersecting the z=r-1 plane. !This point can be analytically calculated using the geometry of the problem !involving two right triangles. This is the point used to plot the Poincare !Maps. !point(p,q) !Z=r-1 !p=(x1-x0)/(z1-z0)*(z1-Z)+x1 !q=(y1-y0)/(z1-z0)*(z1-Z)+y1 real l(n,2) real pm(n,3) real zp parameter (zp = 27.0) integer i,j do i=1, n l(i,1) = 0 l(i,2) = 0 enddo i=2

Page 23: Numerical Solutions for Lorentz Attractor

24 | P a g e

j=1 do while (pm(i,1) .ne. 0) l(j,1) = (pm(i,1) - pm(i-1,1))/(pm(i,3) - pm(i-1,3))*& & (pm(i,3) - zp) + pm(i,1) l(j,2) = (pm(i,2) - pm(i-1,2))/(pm(i,3) - pm(i-1,3))*& & (pm(i,3) - zp) + pm(i,2) i = i + 2 j = j + 1 enddo return end -------------------------------------------------------------------------- plotting code ran in MATLAB XYZT = dlmread('xyzt.txt'); x = XYZT(:,1); y = XYZT(:,2); z = XYZT(:,3); t = XYZT(:,4); X = XYZT(:,8); Y = XYZT(:,9); figure plot(X(2:186),Y(2:186),'k.') xlabel('x') ylabel('y') title('r=28, z=27, x0=5, y0=5, z0=5') --------------------------------------------------------------------------