/* compile line ; gcc -o ensemble ensemble.c -lm */ #include #include #include #define SIZE 30000 /* ensemble size */ /* create a macro for generating a sign from two rands */ #define sgn(a,b) (((a)>= (b)) ? (1.0) : (-1.0)) /* parameters for computations */ int BINS =200; float DIV ,distribution; int Tmax=210; /* create a timestep */ float dt=0.02; /* define a few useful variables */ int n,m,k,l; long I,J,b_value; float bin_x; main() { /* create some arrays to store x, v */ float bins[BINS+1], *binptr; float x[SIZE],v[SIZE]; float *xptr, *vptr, kx1,kx2,kv1,kv2; /* Set up a data file */ FILE *fpt; fpt=fopen("data", "w+"); DIV=2.0/BINS; /* initialize the random number generator */ srand((unsigned long)getpid()); /* initialize the positions and speeds */ for(n=0;n