Smooth Particle Applied Mechanics: The State of the Art

4.4: Runge-Kutta Integration with Fortran and C

4.4 Runge-Kutta Integration with Fortran and C

Algorithms for integrating differential equations can be obtained as commercial packages ( such as the NAG, for "Numerical Algorithm Group", and IMSL, for `International Mathematical Subroutine Library", collections as well as the less-costly software packaged with the several books by Press et alii [6]), Such commercial packages incorporate some severe disadvantages for research work, with loss of control and loss of transparency the price of ease of operation. Understanding, speed of execution, ease of operation, and the ability to control the timestep to facilitate error analyses, are all desirable features of a useful integration algorithm.

The best general-purpose integrator is the self-starting fourth-order Runge-Kutta algorithm. In the following short equivalent programs, one in Fortran and one in C, we use the "classic" fourth-order Runge-Kutta integration algorithm to solve the one-dimensional harmonic oscillator problem. [7] For a sufficiently small Runge-Kutta timestep dt the coordinate q( t) and momentum approach the analytic sinusoidal solution of the two coupled ordinary differential equations of motion:


In this simple linear case it is also possible to express the result of the fourth-order Runge-Kutta algorithm analytically : [8]


where the parameter ? can be obtained from the equation :


In problems with time-dependent boundary conditions the righthandsides of differential equations can depend explicitly on time. Accordingly, we include the time ( time) in the list of arguments of both rk4 and rhs.

Fortran 77 Calculation of Harmonic Oscillator Dynamics

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Computational Fluid Dynamics Software (CFD)
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.