/* step barier */ /* requires libplot, compile with */ /* gcc barrier.c -L/usr/X11R6/lib -lplot -lXaw -lXmu -lXt -lSM -lICE -lXext -lX11 -lm */ /* creates a file called "packet.gif" J.R Schmidt (1999) */ #include #include #include #include #include #define N 101 double ReR[N],ImR[N],ReT[N], ImT[N],ReA[N],ImA[N],ReB[N],ImB[N]; double Amp[N], Den[N]; double dx, x,dk,k,L,V,dt,t; double Rsum, Imsum, arg1,arg2,Rright,Imright,Rleft,Imleft,Repsi,Impsi,psi2; double lambda, elamx, arg3, arg4; int n,m,l,time; int pl_handle; double firstX, firstY, secondX, secondY; void build_coefficients(double *ReRptr, double *ImRptr,double *ReTptr, double *ImTptr,double *ReAptr, double *ImAptr,double *ReBptr, double *ImBptr, double *Ampptr, double Length, double potential, double delta_k); FILE *fptr; char *name; int dec,sign, num_char; char title[30]; char *clock; main(){ float in2; double *ReRptr,*ImRptr,*ReTptr,*ImTptr,*ReAptr,*ImAptr,*ReBptr,*ImBptr,*Ampptr; L=1.0; dk=0.01; dx=0.01; dt=0.15; /* get data from user */ printf ("\t\tQUANTUM PACKET STEP POTENTIAL SIMULATION\n\n"); printf ("\tEnter a potential value V_0 between 0.0 and 10.0\n"); scanf ("%f", &in2); V = (double) in2; printf ("\tYou chose a potential height of V=%f\n", in2); printf ("\tEnter a title string, 30 characters or less, NO WHITESPACE!\n"); scanf ("%s", title); printf ("\tCreating animated GIF with 125 timesteps\n\n"); for(n=0;n<101;n++){ ReR[n]=0.0; ImR[n]=0.0; ReT[n]=0.0; ImT[n]=0.0; ReA[n]=0.0; ImA[n]=0.0; ReB[n]=0.0; ImB[n]=0.0; Amp[n]=0.0;} ReRptr=&ReR[0]; ImRptr=&ImR[0]; ReTptr=&ReT[0]; ImTptr=&ImT[0]; ReAptr=&ReA[0]; ImAptr=&ImA[0]; ReBptr=&ReB[0]; ImBptr=&ImB[0]; Ampptr=&Amp[0]; build_coefficients(ReRptr,ImRptr,ReTptr,ImTptr,ReAptr,ImAptr,ReBptr,ImBptr,Ampptr,L, V, dk); pl_parampl ("USE_DOUBLE_BUFFERING", "yes"); pl_handle = pl_newpl ("X", stdin, fptr, stderr); pl_selectpl (pl_handle); if (pl_openpl () < 0) /* open Plotter */ { fprintf (stderr, "Couldn't open Plotter\n"); return 1; } pl_fspace (-24.0, -4.0 * V, 24.0, 8.0 * V); for(time=1;time<125;time++){ pl_erase (); /* draw the barrier in red */ pl_pencolorname ("red"); pl_fline (-L, 0.0, -L, V); pl_fline (-L, V, L, V); pl_fline (L, V, L, 0.0); pl_pencolorname ("black"); /* draw in the axes */ pl_fline (-12.0, 0.0, 12.0, 0.0); pl_fline (0.0, -0.4 * V, 0.0, 3.0 * V); /* draw a label string */ pl_fmove (-9.0, -0.3*V); pl_ffontsize (1.0); pl_fontname ("HersheySerif"); pl_label (title); t=-6.0+(double)time*dt; firstX = -12.0; firstY = 0.0; /* get the time for display */ clock=fcvt((double)time,num_char,&dec,&sign); pl_fmove (9.0, -0.3*V); pl_label (clock); for(l=-1200;l<=-100;l++){ x=(double)l*dx; Rsum=0.0; Imsum=0.0; for(m=0;m