','..','$myPermit') ?>
SYLLABUS Previous: 2.5 Implicit Crank-Nicholson
Up: 2.5 Implicit Crank-Nicholson
Next: 2.5.2 Schrödinger equation
With Crank-Nicholson, the centered differences in space are evaluated in the same manner and with equal weights for the present and the future values of the function:
BandMatrix a = new BandMatrix(3, f.length);
BandMatrix b = new BandMatrix(3, f.length);
double[] c = new double[f.length];
for (int j=0; j<=n; j++) {
a.setL(j,-0.25*beta -0.5*alpha); //Matrix elements
a.setD(j, 1. +alpha);
a.setR(j, 0.25*beta -0.5*alpha);
b.setL(j, 0.25*beta +0.5*alpha); //Right hand side
b.setD(j, 1. -alpha);
b.setR(j,-0.25*beta +0.5*alpha);
}
c=b.dot(f); //Right hand side
c[0]=c[0]+b.getL(0)*f[n]; // with periodicity
c[n]=c[n]+b.getR(n)*f[0];
fp=a.solve3(c); //Solve linear problem
The
BandMatrix.solve3()
method solves the linear system efficiently in
The favorable stability property (2.5.1#eq.13) can nicely be
exploited in diffusion dominated problems dealing with the evolution of
large scale features
. Starting from a relatively
smooth Gaussian pulse that is subject to both advection and diffusion
,
the applet below shows
that a reasonably accurate solution (12 % for the valley to peak ratio
when the time reaches 100) can be computed using extremely large time
steps
, where
.
SYLLABUS Previous: 2.5 Implicit Crank-Nicholson Up: 2.5 Implicit Crank-Nicholson Next: 2.5.2 Schrödinger equation