/* Molecular Dynamics */ /* Reflective walls */ #include #include #include #define N 101 #define Tmax 20000 #define ListSize 150000 #define L 500 #define a 0.01 #define v0 0.0 #define vb 1.0 #define SEED 56723 #define BINS 1000 int num_hits=0; main() { int m,n,i,j; int t, which_pair; int *wp; float *time; float Etime; float List[ListSize]; float X[N],V[N],M[N]; int bins[BINS]; float *Xptr,*Vptr,*Mptr,*Lptr; int *binptr; void initialize(float *Xptr,float *Vptr,float *Mptr); void sort(float *Xptr,float *Vptr); void get_tagged(float *Xptr,float *Vptr,float *Mptr); void update(float *Xptr,float *Vptr,float *Mptr,int *wp); void getmintime(float *Xptr,float *Vptr,float *time,int *wp); void move(float *Xptr,float *Vptr,float *time); void check_pair(float *Lptr,float *Vptr,int *wp); void elaped_time(float time,float Etime); void data_process(float *Xptr,float *Vptr,float *Lptr,int *binptr,int num_hits); /* Body of the program */ for(n=0;n0.0) B=(*(Xptr+1)-*Xptr)/(*Vptr-*(Vptr+1)); else B=1.0E5; for(m=0;m0.0) A=(*(Xptr+m+1)-*(Xptr+m))/(*(Vptr+m)-*(Vptr+m+1)); else A=1.0E5; if(A<=B){ B=A; *wp=m;} } *time=B; return; } void move(float *Xptr,float *Vptr,float *time) { int m; for(m=1;m largest) largest = *(Lptr+j); if (*(Lptr+j) < smallest) smallest = *(Lptr+j); } /* create BINS bins */ div = (largest - smallest) / (float)BINS; /* compute the normalization constant */ normalization =div*(float)num_hits; for( j=0;jbound1 && *(Lptr+k)<=bound2) *(binptr+j)=*(binptr+j)+1; }} /* lines specific to GNU Plotutils graphing program */ printf("# The mass ratio, bath speed and tagged initial speed are \ %f\t%f\t%f\n",a,vb,v0); printf("# There were %d collisions involving tagged particle in time \ %ld\n",num_hits,Tmax); printf("# velocity limits are %f\t%f , there are %d velocty bins\n", \ smallest, largest, BINS); printf("# there are %d particles, system size is %d\n", N,L); printf("# Division size is %f The normalization constant is %f\n", \ div,normalization); vsum=0.0; v2sum=0.0; for(j=0;j