/*********************************************************/ /* One-dimensional time dependent Schrodinger Equation. */ /* The scattering of a wavepack on a square barrier. */ /* Use Crank-Nicholson/Cayley algorithm... */ /* Stable, Norm Conserving. Li Ju. March.28,1995 */ /*********************************************************/ #include #include #include #include #include "complex.h" /* The complex operation packet */ #define MESH 1000 /* # of space intevals from 0-1 */ #define TAU 2E-6 /* Time inteval */ #define PI 3.1415925 Complex w[MESH+1]; /* w[] is where the wave function is kept. */ float Width,Height,K; /* Width is the width of the barrier */ /* Height is the height */ /* K is the wave vector */ Complex HEAD,TAIL; /* Dirichlet boundary condition -- might be time dependent */ /* ** Potential function */ float V(int i) { if (abs(i-500)=1;i--) { A0 = A00+A0V*V(i); bi = (2-A0)*w[i]-AP*(w[i-1]+w[i+1]); gamma[i] = -1/(A0+AP*alpha[i]); alpha[i-1] = gamma[i]*AP; beta[i-1] = gamma[i]*(AP*beta[i]-bi); } w[0] = HEAD; for (i=0;i<=N-1;i++) w[i+1] = alpha[i]*w[i]+beta[i]; } int main() { FILE * OUTPUT; long Steps,Shot,i,j; /* Total time step,Barrier width,height */ scanf ("%ld %ld %f %f %f",&Steps,&Shot,&Width,&Height,&K); OUTPUT = fopen("a.out","w"); InitWave(); for (i=0;i<=Steps;i++) { Cayley(); if (i%Shot == 0) { for (j=0;j<=MESH-1;j++) fprintf (OUTPUT,"%lf\n",w[j].Abs()); printf ("Running to Step %ld\n",i); } } return(1); }