16
PH36010: Numerical Methods - Evaluating the Lorenz Attractor using Runge-Kutta methods Mr. Benjamen P. Reed (110108461) [email protected] IMPACS, Aberystwyth University January 31, 2014 Abstract A set of three coupled ordinary differential equations known as the Lorenz equations were evaluated using the Fourth-Order Runge-Kutta method to produce a solution known as the Lorenz Attractor. The parameters of the Lorenz attractor were systematically altered using a FORTRAN program to ascertain their effect on the behaviour of the chaotic system and the possible physical consequences of these changes was discussed. The functionality of the Runge- Kutta method is also considered.

Numerical Methods: Lorenz Attractor - · PDF filePH36010: Numerical Methods - Evaluating the Lorenz Attractor using Runge-Kutta methods Mr. Benjamen P. Reed (110108461) [email protected]

Embed Size (px)

Citation preview

Page 1: Numerical Methods: Lorenz Attractor - · PDF filePH36010: Numerical Methods - Evaluating the Lorenz Attractor using Runge-Kutta methods Mr. Benjamen P. Reed (110108461) bpr@aber.ac.uk

PH36010: Numerical Methods -

Evaluating the Lorenz Attractor using Runge-Kutta methods

Mr. Benjamen P. Reed (110108461)

[email protected]

IMPACS, Aberystwyth University

January 31, 2014

Abstract

A set of three coupled ordinary differential equations known as the Lorenz equations were evaluated using the Fourth-Order Runge-Kutta method to produce a solution known as the Lorenz Attractor. The parameters of the Lorenz attractor were systematically altered using a FORTRAN program to ascertain their effect on the behaviour of the chaotic system and the possible physical consequences of these changes was discussed. The functionality of the Runge-Kutta method is also considered.

Page 2: Numerical Methods: Lorenz Attractor - · PDF filePH36010: Numerical Methods - Evaluating the Lorenz Attractor using Runge-Kutta methods Mr. Benjamen P. Reed (110108461) bpr@aber.ac.uk

Benjamen Reed (110108461) [email protected]

2

Table of Contents

1. Introduction 3

2. Background Theory and Procedure 4

2.1 Lorenz Equations………………………………………………………… 4 2.2 Fourth-Order Runge-Kutta………………………………………………. 4 2.3 Evaluating the Lorenz Equations………………………………………… 5

3. Results 6

3.1 Typical Lorenz Attractor………………………………………………… 6 3.2 Dependence on sigma σ…………………………………………………. 7 3.3 Dependence on beta β…………………………………………………… 9 3.4 Dependence on rho ρ……………………………………………………. 11

4. Discussion 13

5. Conclusion 14

Acknowledgements 14

References 14

Appendixes 15

A. Runge-Kutta Code to Evaluate Lorenz Equations……………………… 15

Page 3: Numerical Methods: Lorenz Attractor - · PDF filePH36010: Numerical Methods - Evaluating the Lorenz Attractor using Runge-Kutta methods Mr. Benjamen P. Reed (110108461) bpr@aber.ac.uk

Benjamen Reed (110108461) [email protected]

3

1. Introduction

Of all the dynamic systems that physics, and the physical sciences describe and model, none are more subtle yet potent than chaotic systems; these are systems whose behaviour is highly sensitive to the initial conditions of that system. One example of a chaotic system is the double rod pendulum, which has a full rotation hinge in the middle of the system, allowing the bottom half of the pendulum to swing quasi-independently of the main pendulum. The high initial condition dependence in these systems has been poetically named the Butterfly effect, after Edward Norton Lorenz’s (an American mathematician and meteorologist) work on the Lorenz attractor and his 1972 talk, ‘Predictability: Does the Flap of a Butterfly's Wings in Brazil set off a Tornado in Texas?’

As a meteorologist, Lorenz investigated the functionality and possibility of performing accurate long-term weather forecasts, and his research demonstrated that even the smallest change in a weather system could have significant effects on the system as it evolved in time. He concluded that any model of any weather system would have to take into account the smallest variations in the weather conditions in order to have a high accuracy; today’s weather modelling computers are designed to compute thousands of variables in order to predict the short-term forecast. However, despite all the known variables, there are still just as many unknown variables that have non-periodic or chaotic behaviour, and as such they are intrinsically unpredictable in the long-term. Even smaller systems with considerably less variables, still exhibit this long-term unpredictability (Palmer, 1993).

One simple system to exhibit chaotic behaviour is the Lorentz equations, a system of three coupled ordinary differential equations that are a simple and idealistic set of twelve hydrodynamical equations that describe turbulent flow in the atmosphere. When the 3-dimensional coordinates of this system are plotted with time as the independent variable, an interesting graph is observed. For a single point moving around in phase space (i.e. x(t), y(t) and z(t) where t is time), it traces out a curve , or an orbit which always converges and then remains on a surface comprised of two ‘wings’. For any initial conditions, the point always and eventually links up with this two-winged surface, and hence it is known generally as an attractor. The attractor created with the Lorenz equations, shown in figure 1, is appropriately named the Butterfly attractor for its appearance and also because it visualises solutions that exhibit the butterfly effect (Taylor, 2011).

As previously mentioned, the Lorenz attractor can be constructed using three coupled ordinary differential equations, and as such can be modelled with a relatively simple program and a robust graphing client. In this report, the Lorenz attractor for an arbitrary chaotic system is evaluated using a program written in the script-based programming language FORTRAN. The program employs the use of the Fourth-Order Runge-Kutta method in order to solve the Lorenz equation and thus produce useable data. The parameters and variables of the system were changed systematically in order to ascertain their effect on the shape and profile of the butterfly attractor in phase space. This report will also discuss the effectiveness of using the Fourth-Order Runge-Kutta method with coupled ordinary differential equations.

Figure 1 - A visualisation of the Lorenz attractor in phase space; solution to the Lorenz equations as an orbit in phase space. (Source: http://www.mizuno.org/c/la/img/lorenz_web.jpg)

Page 4: Numerical Methods: Lorenz Attractor - · PDF filePH36010: Numerical Methods - Evaluating the Lorenz Attractor using Runge-Kutta methods Mr. Benjamen P. Reed (110108461) bpr@aber.ac.uk

Benjamen Reed (110108461) [email protected]

4

2. Background Theory and Procedure

2.1 The Lorenz Equations

The Lorenz equations, as written by Edward Lorenz himself are…

dxdt=σ (y− x) (1)

dydt= x(ρ − z)− y (2)

dzdt= xy−βz (3)

…where x, y, and z are variables in phase space and σ , ρ . And β are the constant parameters of the system. It is easy to see in this system, that as one variable of phase space changes, the other two variables in phase space change in response. The parameters in these equations each have physical meanings are not just some mathematical quirk. Sigma σ is called the Prandtl number and is a description of the systems physical characteristics such as viscosity and thermal conductivity in the case of convection flow. Rho ρ represents a control parameter, which is the difference between the extrema driving forces in the system. For the example where the Lorenz attractor is characterising convection in a fluid filled tank, ρ would represent the temperature difference between the top and bottom of the tank. Finally beta β is a value that describes the shape of the ‘box’ that the Lorenz attractor is contained within. For the convection example, β would be the width-to-height ratio of the convection layer (Stockie & Wong, 2009).

2.2 The Fourth Order Runge-Kutta

The Runge-Kutta method is an iterative numerical method for solving systems of coupled ordinary differential equations (CODEs), and is highly considered to be the most accurate numerical method for this purpose for the amount of effort required to code it. It is similar to Euler’s method of solving ODEs however whereas Euler’s method only evaluates each iterative step at one point, Runge-Kutta evaluates each step at four separate locations as shown by equations 4 to 7. Two evaluations are made at the end points of each interval, and two are made in the middle.

F1 = δtf (yi, ti ) (4)

F2 = δtf yi +12F1, ti +

12δt

!

"#

$

%& (5)

F3 = δtf yi +12F2, ti +

12δt

!

"#

$

%& (6)

F4 = dtf yi +F3, ti +δt( ) (7)

It then combines these solutions into one highly accurate approximation of the function at that point. In essence, this means that any number of time-dependant CODEs can be evaluated by one

Page 5: Numerical Methods: Lorenz Attractor - · PDF filePH36010: Numerical Methods - Evaluating the Lorenz Attractor using Runge-Kutta methods Mr. Benjamen P. Reed (110108461) bpr@aber.ac.uk

Benjamen Reed (110108461) [email protected]

5

program and hence data can be formulated for data analysis. The final recombination step is characterised by equation 8, which gives the phase space coordinate at that time step (Süli, 2013).

yi+1 = yi +16F1 + 2F2 + 2F3 +F4( ) (8)

(N.B. y in equations 4 – 8 can represent any value in any axis, i.e. y can be x or z. Cartesian coordinates are evaluated separately for each axis, so Runge-Kutta is executed three times for each point in phase space).

2.3 Evaluating the Lorenz Equations

To solve the Lorenz equations and thus produce the Lorenz attractor plot, a program was written in FORTRAN, which used the aforementioned Fourth-Order Runge-Kutta method to evaluate the CODEs hence produce useable data in the form of a comma separating variable file. This data was then sent to gnuplot to produce 3-dimensional phase space plots and 2-dimension time dependent graphs of the variables (Press et al., 2007). The full FORTRAN can be viewed in the appendix.

To ascertain the effect of parameters on the Lorenz attractor, a default attractor was plotted and then each parameter was adjusted systematically. The attractor was then re-plotted and compared with the original to ascertain what had changed.

Page 6: Numerical Methods: Lorenz Attractor - · PDF filePH36010: Numerical Methods - Evaluating the Lorenz Attractor using Runge-Kutta methods Mr. Benjamen P. Reed (110108461) bpr@aber.ac.uk

Benjamen Reed (110108461) [email protected]

6

3. Results

3.1 Typical Lorenz Attractor

Figure 2 - A 3D plot of a typical Lorenz attractor in phase space, where σ = 10, β = 8/3, ρ = 28.

Figure 3 - A 2D plot of Lorenz attractor phase space coordinates against time, where σ = 10, β = 8/3, ρ = 28.

Page 7: Numerical Methods: Lorenz Attractor - · PDF filePH36010: Numerical Methods - Evaluating the Lorenz Attractor using Runge-Kutta methods Mr. Benjamen P. Reed (110108461) bpr@aber.ac.uk

Benjamen Reed (110108461) [email protected]

7

3.2 Dependence on sigma σ

Figure 4 - A 3D plot of a typical Lorenz attractor in phase space, where σ = 5, β = 8/3, ρ = 28.

Figure 5 - A 2D plot of Lorenz attractor phase space coordinates against time, where σ = 5, β = 8/3, ρ = 28.

Page 8: Numerical Methods: Lorenz Attractor - · PDF filePH36010: Numerical Methods - Evaluating the Lorenz Attractor using Runge-Kutta methods Mr. Benjamen P. Reed (110108461) bpr@aber.ac.uk

Benjamen Reed (110108461) [email protected]

8

Figure 6 - A 3D plot of a typical Lorenz attractor in phase space, where σ = 20, β = 8/3, ρ = 28.

Figure 7 - A 2D plot of Lorenz attractor phase space coordinates against time, where σ = 20, β = 8/3, ρ = 28.

Page 9: Numerical Methods: Lorenz Attractor - · PDF filePH36010: Numerical Methods - Evaluating the Lorenz Attractor using Runge-Kutta methods Mr. Benjamen P. Reed (110108461) bpr@aber.ac.uk

Benjamen Reed (110108461) [email protected]

9

3.3 Dependence on beta β

Figure 8 - A 3D plot of a typical Lorenz attractor in phase space, where σ = 10, β =4/3, ρ = 28.

Figure 9 - A 2D plot of Lorenz attractor phase space coordinates against time, where σ = 10, β =4/3, ρ = 28.

Page 10: Numerical Methods: Lorenz Attractor - · PDF filePH36010: Numerical Methods - Evaluating the Lorenz Attractor using Runge-Kutta methods Mr. Benjamen P. Reed (110108461) bpr@aber.ac.uk

Benjamen Reed (110108461) [email protected]

10

Figure 10 - A 3D plot of a typical Lorenz attractor in phase space, where σ = 10, β =16/3, ρ = 28.

Figure 11 - A 2D plot of Lorenz attractor phase space coordinates against time, where σ = 10, β =16/3, ρ = 28.

Page 11: Numerical Methods: Lorenz Attractor - · PDF filePH36010: Numerical Methods - Evaluating the Lorenz Attractor using Runge-Kutta methods Mr. Benjamen P. Reed (110108461) bpr@aber.ac.uk

Benjamen Reed (110108461) [email protected]

11

3.4 Dependence on rho ρ

Figure 12 - A 3D plot of a typical Lorenz attractor in phase space, where σ = 10, β =8/3, ρ = 14.

Figure 13 - A 2D plot of Lorenz attractor phase space coordinates against time, where σ = 10, β =8/3, ρ = 14.

Page 12: Numerical Methods: Lorenz Attractor - · PDF filePH36010: Numerical Methods - Evaluating the Lorenz Attractor using Runge-Kutta methods Mr. Benjamen P. Reed (110108461) bpr@aber.ac.uk

Benjamen Reed (110108461) [email protected]

12

Figure 14 - A 3D plot of a typical Lorenz attractor in phase space, where σ = 10, β =8/3, ρ = 56.

Figure 15 - A 2D plot of Lorenz attractor phase space coordinates against time, where σ = 10, β =8/3, ρ = 56.

Page 13: Numerical Methods: Lorenz Attractor - · PDF filePH36010: Numerical Methods - Evaluating the Lorenz Attractor using Runge-Kutta methods Mr. Benjamen P. Reed (110108461) bpr@aber.ac.uk

Benjamen Reed (110108461) [email protected]

13

4. Discussion

Figure 2 shows a typical Lorenz attractor with the parameters σ = 10, β = 8/3, ρ = 28. This 3-dimensional plot, along with its 2-dimensional temporal dependence graph in figure 3 was treated as the ‘control’, a reference that could be used to determine the changes in the Lorenz attractor shape as the parameters were altered. The 3d representation in figure 2 was typical of the butterfly wings found in the literature and resource material. Hence, it was assumed that these figures were correct and an accurate demonstration of chaotic flow in atmospheric systems. To infer some physical meaning to the results detailed in section 3, it has been assumed that the Lorenz equations in this situation are characterising the convectional flow of a viscous fluid in a heated tank.

The first parameter that was altered was sigma σ , which as mentioned in section 2.1, is the Prandtl number and is a description of the systems physical characteristics of flow. It tells information about the fluid’s viscosity and thermal conductivity. Figures 4 and 5 show the situation where the parameter sigma has been halved from it original value. Physically, this means that the viscosity of the fluid is higher, so the fluid takes longer to converge on the attractor surface. Furthermore, once on the surface the flow begins to spiral inwards on only one wing. Figure 5 shows that the movement of one unit of fluid decreases over time, which implies that the flow is so viscous that it actually dampens any movement within it. Conversely, in figures 6 and 7 the viscosity is lower and hence the flow quickly converges on the attractor surface, and onto two wings. Once there, it is able to sweep out large arcs of movement in the decreased viscosity hence why there appears to be no inner orbits within the wings.

The second parameter to be altered was beta β, which characterises the width-to-height ratio of the convection layer. Intuition infers that a smaller width in the convection zone means that flow will frequently switch between one wing of the attractor surface and the other. Whereas a larger width in the convection zone will mean that flow will switch attractor wings frequently, if at all. The figures in section 3.3 seem to agree with this intuition, with the 2D temporal dependence graphs demonstrating this much more clearly. Figure 9 shows the temporal dependence of the flow when the width-to-height ratio is low; the x(t) and y(t) frequently change phase which implies that the flow is moving through the convection zone frequently and changing which wing it orbits. On the other hand, figure 10 where β is double the control parameter, shows that once the flow is orbiting one wing, it never switches over to other wing, implying that the width of the convection zone is so large, that flow cannot or rarely passes into it.

Finally, the last parameter rho ρ details the temperature difference between the top and the bottom of the tank. It is expected that a large difference in temperature between the top and the bottom of the tank will give rise to a large flow rate with frequent changes in attractor orbit. The system would also take an extended period of time to reach equilibrium and so the flow rate would continue to be rapid for a long time. With a small temperature difference, the thermal driving forces would be reduced and the system would reach equilibrium relatively faster. This is certainly what seems to be happening in figures 12 and 13. The low thermodynamic driving force means that the flow hardly changes orbit, or in this case, doesn’t at all. Furthermore, once equilibrium is reached, all macroscopic movement stops as shown by figure 13 and the system tends toward equilibrium, a dampening effect is observed much like in figure 5.

From this discussion, it is apparent that small changes in the Lorentz attractor system give rise to large macroscopic effects. The Runge-Kutta method has illustrated these changes well and is a very suitable method to use in the modelling of chaotic systems. It does not appear to show signs of divergence, a common issue in the simpler Euler’s method, and so confidence is high that there is minimal error in the Lorentz modelling.

Page 14: Numerical Methods: Lorenz Attractor - · PDF filePH36010: Numerical Methods - Evaluating the Lorenz Attractor using Runge-Kutta methods Mr. Benjamen P. Reed (110108461) bpr@aber.ac.uk

Benjamen Reed (110108461) [email protected]

14

5. Conclusion

A model of the Lorenz attractor has been constructed using the Runge-Kutta method to solve the Lorenz equations, a set of three coupled ordinary differential equations that describe chaotic flow in atmospheric or hydrodynamic systems. The modelling proved to be successful and the Lorenz equation parameters were varied to ascertain their effect on the behaviour of the system. It was found that small changes to these parameters could have huge effects on the dynamics of the system, either making it more chaotic, or taming it such that the flow rate of the system tends to zero. In the cases where the flow rate tended to zero, the parameters gave rise to an unstable system where the dynamics could not be maintain for an extended period of time. Conversely, in the situations where the flow became more chaotic, the system remained stable and the orbits of the attractor surface were more pronounced.

In respect to the numerical method employed, the Runge-Kutta method performed well and produced an accurate, stable model in which to observe the Lorenz attractor.

Acknowledgements

The author would like to extend their gratitude to Dr. Martin Wilding for the tuition he provided during the course, and for taking time out of his own schedule to give students on the course the time necessary to provide work of their best effort. The author would also like to thank Mr. Patrick Dixon, Mr. Andrew Leonard and Mr. Tom Knight for helping to run the module and provide lessons in effective coding. Finally, the author would like to thank Miss. Carley Martin, Miss. Fffion Whitehouse and Miss. Rose Cooper for providing much needed discussion and support during the module.

References

Palmer, T., 1993. Exploring Chaos: A Guide to the New Science of Disorder. London: W. W. Norton & Co.

Press, W.H., Teukolsky, S.A., Vetterling, W.T. & Flannery, B.P. 2007. Numerical Recipes: The Art of Scientific Computing. 3rd ed. Cambridge: Cambridge Press.

Stockie, J. & Wong, K., 2009. A Simple Model of the Unpredictability of Weather: The Lorenz Equations. Clouds, Aerosols and Climate Feedback Publications. Available at: <http://clouds.eos.ubc.ca/~phil/numeric/labs/lab6/lab6.pdf> [Accessed 30 January 2014]

Süli, E. 2013. Numerical Solution of Ordinary Differential Equations. [pdf] Mathematical Institute, University of Oxford. Available at: <http://people.maths.ox.ac.uk/suli/nsodes.pdf> [Accessed 30 January 2014]

Taylor, R.L.V., 2011. Attractors: Nonstrange to Chaotic. SIAM Undergraduate Research Online, 4.

Page 15: Numerical Methods: Lorenz Attractor - · PDF filePH36010: Numerical Methods - Evaluating the Lorenz Attractor using Runge-Kutta methods Mr. Benjamen P. Reed (110108461) bpr@aber.ac.uk

Benjamen Reed (110108461) [email protected]

15

A Runge-Kutta Code to Evaluate Lorenz Equations

PROGRAM  lorentz  IMPLICIT  NONE  INTEGER  ::  i  INTEGER,PARAMETER  ::  npars=3,nvars=3,nits=50000  REAL,DIMENSION(npars)  ::  pars  REAL,DIMENSION(nvars)  ::  yO  REAL,DIMENSION(nits+1)  ::  tout  REAL,DIMENSION(nvars,nits+1)  ::  yout  REAL  ::  tO,tf,dt  !define  parameters  !    PRINT*,  "Please  input  the  parameter  sigma  (default:  10)"  !    READ*,  pars(1)  !    PRINT*,  "Please  input  the  parameter  beta  (default:  8/3)"  !    READ*,  pars(2)  !    PRINT*,  "Please  input  the  parameter  rho  (default:  28)"  !    READ*,  pars(3)      pars(1)  =  10.0      pars(2)  =  8.0/3.0      pars(3)  =  56.0  !define  yO      yO(1)  =  -­‐10.0      yO(2)  =  -­‐10.0      yO(3)  =  -­‐5.0  !define  tO      tO  =  0.0      tf  =  30.0  !Working  out  dt      dt  =  (tf-­‐tO)/nits  !calling  subroutine  rungeit      CALL  rungeit(nvars,yO,tO,dt,npars,pars,nits,yout,tout)      OPEN(UNIT=10,FILE='lorentz.csv',FORM='FORMATTED',ACTION='WRITE')          DO  i  =  1,nits+1                WRITE(UNIT=10,FMT='(F13.5,A3,F13.5,A3,F13.5,A3,F13.5)')  tout(i),  "  ",  yout(1,i),  "  ",  yout(2,i),  "  ",  yout(3,i)          END  DO      CLOSE(10)  END  PROGRAM  Lorentz  !===============================================================  !Subroutine  of  the  function  we  wish  to  solve  for  !narvs  -­‐  number  of  eqns  we're  solving  for.  !yin  -­‐  narvs  element  array  of  solution  at  current  time.  !t  -­‐  the  current  time  !npars  -­‐  number  of  parameters/constants  in  the  equations  !pars  -­‐  npars  element  array  containing  the  constants  !yout  -­‐  nvars  element  array  of  the  solution  at  new  time  SUBROUTINE  fy(nvars,yin,t,npars,pars,yout)  IMPLICIT  NONE  INTEGER,  INTENT(IN)  ::  nvars,  npars  REAL,  INTENT(IN),  DIMENSION(nvars)  ::  yin  REAL,  INTENT(IN),  DIMENSION(npars)  ::  pars  REAL,  INTENT(IN)  ::  t  REAL,  INTENT(INOUT),  DIMENSION(nvars)  ::  yout      yout(1)  =  pars(1)*(yin(2)-­‐yin(1))      yout(2)  =  yin(1)*(pars(3)-­‐yin(3))-­‐yin(2)      yout(3)  =  (yin(1)*yin(2))-­‐(pars(2)*yin(3))  END  SUBROUTINE  fy  !==============================================================  !Subroutine  to  perform  the  Runge-­‐Kutta  steps  SUBROUTINE  rungestep(nvars,yin,tO,dt,npars,pars,yout)  IMPLICIT  NONE  

Page 16: Numerical Methods: Lorenz Attractor - · PDF filePH36010: Numerical Methods - Evaluating the Lorenz Attractor using Runge-Kutta methods Mr. Benjamen P. Reed (110108461) bpr@aber.ac.uk

Benjamen Reed (110108461) [email protected]

16

INTEGER,  INTENT(IN)  ::  nvars,  npars  REAL,  INTENT(IN),  DIMENSION(nvars)  ::  yin  REAL,  INTENT(IN),  DIMENSION(npars)  ::  pars  REAL,  INTENT(IN)  ::  dt,  tO  REAL,  INTENT(INOUT),  DIMENSION(nvars)  ::  yout  REAL,  DIMENSION(nvars)  ::  f1,  f2,  f3,  f4,  ytemp  !First  step      CALL  fy(nvars,yin,tO,npars,pars,ytemp)      f1  =  dt*ytemp  !Second  step      CALL  fy(nvars,yin+f1/2.0,tO+dt/2.0,npars,pars,ytemp)      f2  =  dt*ytemp  !Third  step      CALL  fy(nvars,yin+f2/2.0,tO+dt/2.0,npars,pars,ytemp)      f3  =  dt*ytemp  !Forth  step      CALL  fy(nvars,yin+f3,tO+dt,npars,pars,ytemp)      f4  =  dt*ytemp  !Collecting  steps  together      yout  =  yin+((f1+2.0*f2+2.0*f3+f4)/6.0)  END  SUBROUTINE  rungestep  !============================================================  SUBROUTINE  rungeit(nvars,yO,tO,dt,npars,pars,nits,yout,tout)  IMPLICIT  NONE  INTEGER,  INTENT(IN)  ::  nits,nvars,npars  REAL,  INTENT(IN),  DIMENSION(nvars)  ::  yO  REAL,  INTENT(IN),  DIMENSION(npars)  ::  pars  REAL,  INTENT(IN)  ::  dt,  tO  REAL,  INTENT(INOUT),  DIMENSION(nvars,nits+1)  ::  yout  REAL,  INTENT(INOUT),  DIMENSION(nits+1)  ::  tout  INTEGER  ::  i  !put  the  initial  conditions  into  the  output  array      tout(1)  =  tO      yout(:,1)  =  yO  !iterate  thro  all  timesteps,  taking  a  new  step  from  the  previous  !result.  Note  the  suroutine  call  to  eulermodstep  is  different  to  the  !function  call  in  the  1D  case      DO  i  =  2,  nits+1          tout(i)  =  tout(i-­‐1)  +  dt          CALL  rungestep(nvars,yout(:,i-­‐1),tout(i-­‐1),dt,npars,pars,  &          &  yout(:,i))      END  DO  END  SUBROUTINE  rungeit  !======================================================================