','..','$myPermit') ?>
SYLLABUS Previous: 2.3 Lax-Wendroff
Up: 2 FINITE DIFFERENCES
Next: 2.5 Implicit Crank-Nicholson
The leap-frog algorithm is often used for the propagation of waves, where
a low numerical damping is required with a relatively high accuracy.
Relying on two functions
to approximate the scalar
wave equation (1.3.1#eq.2) in flux-conservative form,
staggered grids (where the mesh points are shifted with respect
to each other by half an interval, as in fig.2.4#fig.4) are
used to evaluate centered differences with an accuracy in
:
for (int j=1; j<=n; j++) { //1st equation
fp[j]=f[j] -beta*(g[j]-g[j-1]); }
fp[0]=f[0] -beta*(g[0]-g[n]);
for (int j=0; j<=n-1; j++) { //2nd equation
gp[j]=g[j] -beta*(fp[j+1]-fp[j]); }
gp[n]=g[n] -beta*(fp[0]-fp[n]);
Special care is required when
starting
the integration, since the initial condition
By substitution, note that the leap-frog scheme is equivalent to the implicit 3 levels scheme
SYLLABUS Previous: 2.3 Lax-Wendroff Up: 2 FINITE DIFFERENCES Next: 2.5 Implicit Crank-Nicholson