Next: Listing for concrete.c Up: Computer programs for hard Previous: Listing for burnt.c

Listing for volume.c

/*********************************************************************/
/*                                                                   */
/*   Program: volume.c                                               */
/*   Purpose: To calculate the volumes occupied by the hard cores    */
/*             and soft shells in the HCSS 3-D model                 */
/*   Programmer: Kenneth A. Snyder and Dale P. Bentz                 */
/*               NIST                                                */
/*               Building 226 Room B-350                             */
/*               Gaithersburg, MD  20899-8621                        */
/*               Phone: (301) 975-5865  Fax: (301) 990-6891          */
/*               E-mail: jackal@nist.gov  dale.bentz@nist.gov        */
/*               WWW page: http://ciks.cbt.nist.gov/~bentz           */
/*                                                                   */
/*********************************************************************/
/* 
     A grid is superposed onto the volume and the number of points lying
       within hard/soft spheres are counted.

        resolution : number of points subdividing a single bin 

     Note: This routine can be easily modified to output a digitized 
          representation of the microstructure if needed for further 
          analysis
 */
/* resolution is requested resolution for point counting */
/* in points per bin length */
void volume(resolution)
     float resolution;
{
   int ix,iy,iz,     /* bin indices */
       shellcount,  /* loop counter for shell thicknesses */
       point,        /* descriptor of point: 0-neither 2-soft 3-both */
       burnt_point;  /* descriptor of burnt point: 0-not 20-yes */

   long hard_count,  /* number of points within hard cores */
        soft_count,  /* number of points within soft shells */
        total_count, /* total number of points in system */
        burnt_hard_count, /* number of points within burnt hard cores */
        burnt_soft_count, /* number of points within burnt soft shells */
        acc_soft_count;   /* number of points within accessible soft shells */

   float x,y,z,      /* location of the points for volume calculation */
         stepsize,   /* distance between points */
         binwidth,   /* width of bin */ 
         shell[2],     /* shell thicknesses (0.0,shellthick) */
         x_lo,x_hi,
         y_lo,y_hi,
         z_lo,z_hi,  /* limits of bin */
         radius,     /* temp. variable for radius^2 */
         dist;       /* square of distance from point to sphere */

   struct partlist *new_bin;  /* linked list of bin information */

   /* INITIALIZE VARIABLES */
   shell[0] = 0.0;
   shell[1] = shellthick;
   hard_count = 0;
   soft_count = 0;
   total_count = 0;
   burnt_hard_count=0;
   burnt_soft_count=0;
   acc_soft_count=0;
   binwidth = SYSIZE/(float)NBIN;
   stepsize = binwidth/resolution; 

      /***  loop through all bins ***/
      /***  and all points in bins ***/
      /***  Interdisperse these two loops ***/
      /***  to allow for easy output of digitized ***/
      /***  microstructure if user would like ***/
   for(iz=0;iz<NBIN;iz++) {
        z_lo = binwidth*(float)iz;
        z_hi = z_lo + binwidth-stepsize/2.;
    for(z=z_lo;z<z_hi;z+=stepsize) {
   for(iy=0;iy<NBIN;iy++) {
        y_lo = binwidth*(float)iy;
        y_hi = y_lo + binwidth-stepsize/2.;
    for(y=y_lo;y<y_hi;y+=stepsize) {
   for(ix=0;ix<NBIN;ix++) {
        x_lo = binwidth*(float)ix;
        x_hi = x_lo + binwidth-stepsize/2.;
    for(x=x_lo;x<x_hi;x+=stepsize) {

    point = 0;
    burnt_point=0;
    total_count ++;    /*** count total number of points ***/
    new_bin = bin[ix][iy][iz];
       /*** loop through all spheres in bin ***/
    while(new_bin->partnum != -1) {
       /* Check for both hard core only and for hard core with soft shell */
       for(shellcount=0;shellcount<2;shellcount++) {
         radius = SQR( new_bin->size+shell[shellcount] );
         dist = SQR(x-new_bin->xloc)+SQR(y-new_bin->yloc)+SQR(z-new_bin->zloc);
         if(dist<=radius) {
           point |= (shellcount+1);
           burnt_point|=particle[new_bin->partnum]->burnt;
         }
       }
      new_bin = new_bin->nextpart;
    } /* while() */

    if(point>0) {
       if(point>2){
          hard_count ++;   /*** inside both ***/
          if(burnt_point>=BACKBONEID) burnt_hard_count++;
          }
       else     {
          soft_count ++;   /*** only inside soft sphere ***/
          if(burnt_point>=BACKBONEID) burnt_soft_count++;
          if(burnt_point>0) acc_soft_count++;
          }
    }

    /* If user desired to output digitized microstructure */
    /* could simply print value of point to a file here */
    /* 0 - bulk matrix */
    /* 2 - soft shell */
    /* 3 - hard core */

    }}} /* for(points in bin) */
   }}}  /* and(NBINS,NBINS,NBINS) */

  /* Output results of systematic point sampling */
  printf("\n Volume assessment results \n");
  printf("Total points(calculated): %10.0f\n",CUB(resolution)*CUB((float)NBIN));
printf("Total points(actual)    : %10ld \n",total_count);
printf("Hard count: %ld\n",hard_count);
printf("Soft count: %ld\n",soft_count);
printf("Burnt Hard Count: %ld \n",burnt_hard_count);
printf("Burnt Soft Count: %ld \n",burnt_soft_count);
printf("Accessible Soft Count: %ld \n",acc_soft_count);
}