Exemple #1
0
//////////////////////////////////////////////////////////////////////////////
///
///	Read data
///
//////////////////////////////////////////////////////////////////////////////
void controller::readData(long* operand1, long* operand2,
  Operation* operation) {
 unsigned char raw[20];

 readInputStream(raw);
 *operand1 = getFirstOperand(raw);
 *operand2 = getSecondOperand(raw);
 *operation = getOperation(raw);
}
Exemple #2
0
int main(int argc, char* argv[])
{
  double tx, ty, tz;
  double volume;
  int successes=0, attempts=0;

  setCommandLineParameters(argc, argv);
  if (getFlagParam("-usage"))
  {
    printf("usage:  cv [ -randomize ]\n\n");
    printf("        will return MC volume of list of spheres entered, box size determined automatically.\n");
    printf("\n");
    printf("// Reads a centered cluster and determines the volume of it.\n");
    printf("// Will deliver an erroneous result if cluster is not centered or percolates.\n");
    printf("\n");
    printf("// More generally, it will give the volume of all the cavities, whether clustered or not.\n");
    printf("\n");
    printf("// In:  one cluster; 1 or more records in .cav format \n");
    printf("// Out: .dst (reports one value of volume) \n");
    exit(1);
  }
  if (getFlagParam("-randomize")) initializeRandomNumberGenerator2(-1);
  else initializeRandomNumberGenerator2(0);

  instream = stdin;
  readInputStream();

  findMinimumBoxSize();

  successes=0;

  for (attempts=0; successes<N_SUCCESSES; attempts++)
  {
    // pick a point and check inclusion

    tx = rnd2() * box_x;
    ty = rnd2() * box_y;
    tz = rnd2() * box_z;

    successes += checkInclusion(tx, ty, tz);
    if (attempts > 100000000)
    {
      printf("too many attempts.");
      exit(1);
    }
  }

  volume = (box_x * box_y * box_z * successes)/attempts;

  printf("%lf\n", volume);
  return 0;
}
int main(int argc, char* argv[])
{
    setCommandLineParameters(argc, argv);
    if (getFlagParam("-usage"))
    {
        printf("cav2cluster\t-box [ 10 10 10 ]\n");
        printf("           \t-sfactor [ 1 ]\n");
        printf("\n");
        exit(0);
    }
    getVectorParam("-box", &box_x, &box_y, &box_z);
    getDoubleParam("-sfactor", &sfactor);

    readInputStream();
    findAllPairs();
    buildClusters();
    deleteEmptyClusters();
    sortClusters();
    printClusters();
}
Exemple #4
0
int main(int argc, char* argv[])
{
  double surface_area;
  int successes=0, attempts=0;
  int particle_number;

  instream=stdin;
  setCommandLineParameters(argc, argv);
  getVectorParam("-box", &box_x, &box_y, &box_z);
  if (getFlagParam("-randomize")) initializeRandomNumberGenerator2(-1);
  else initializeRandomNumberGenerator2(0);

  readInputStream();

  // figure out total surface area for sampling
  for (particle_number=0; particle_number<number_of_cavities; particle_number++)
  { 
    sorface_area[particle_number] = PI * d[particle_number] * d[particle_number];
    total_surface_area += sorface_area[particle_number];
  }

  for (attempts=0; attempts<N_SAMPLES; attempts++)
  {
    // pick a particle, then pick a point on its surface
    while(1)
    {
      particle_number = rnd2() * number_of_cavities;
      if (rnd2() < (sorface_area[particle_number]/total_surface_area)) break;
    }

    generateSamplePoint(particle_number);

    successes += checkExclusion();
  }

  //  volume = (box_x * box_y * box_z * successes)/attempts;
  surface_area = (total_surface_area * successes)/attempts;

  printf("%lf\n", surface_area);
  return 0;
}
int main(int argc, char* argv[])
{
  double tx, ty, tz;
  double volume;
  int successes=0, attempts=0;

  setCommandLineParameters(argc, argv);
  getVectorParam("-box", &box_x, &box_y, &box_z);
  if (getFlagParam("-randomize")) initializeRandomNumberGenerator2(-1);
  else initializeRandomNumberGenerator2(0);

  readInputStream();

  successes=0;

  for (attempts=0; successes<N_SUCCESSES; attempts++)
  {
    // pick a point and check inclusion

    tx = rnd2() * box_x;
    ty = rnd2() * box_y;
    tz = rnd2() * box_z;

    successes += checkInclusion(tx, ty, tz);
    if (attempts > 100000000)
    {
      printf("too many attempts.");
      exit(1);
    }
  }

  volume = (box_x * box_y * box_z * successes)/attempts;

  printf("%lf\n", volume);
  return 0;
}
Exemple #6
0
int main(int argc, char *argv[])
{
  int x_minus_ok, x_plus_ok;
  int y_minus_ok, y_plus_ok;
  int z_minus_ok, z_plus_ok;

  int i, j, k, ri, rj, rk;

  setCommandLineParameters(argc, argv);
  getVectorParam("-box", &box_x, &box_y, &box_z);
  getDoubleParam("-resolution", &resolution);
  getDoubleParam("-test_diameter", &test_diameter);
  if (getFlagParam("-usage"))
  {
    printf("\n");
    printf("usage:\t-box [ 10 10 10 ]\n");
    printf("      \t-resolution [ .10 ]\n");
    printf("      \t-test_diameter [ 1.0 ]\n");
    printf("\n");
    exit(0);
  }

  n_value = test_diameter/(resolution*sqrt(3));
  max_x_value = floor(.000001 + box_x/resolution) - n_value;
  max_y_value = floor(.000001 + box_y/resolution) - n_value;
  max_z_value = floor(.000001 + box_z/resolution) - n_value;
 
  readInputStream(); 

  // now cull the useful vals...

 
  for (i=n_value; i<max_x_value; i++)
  for (j=n_value; j<max_y_value; j++)
  for (k=n_value; k<max_z_value; k++)
  {
    if (use_point[i][j][k]) 
    {
      x_minus_ok=0;
      z_minus_ok=0;
      y_minus_ok=0;
      x_plus_ok=0;
      y_plus_ok=0;
      z_plus_ok=0;

      for (ri=i-n_value; ri < i; ri++)
      if (use_point[ri][j][k])
      {
        x_minus_ok = 1;
        break;
      }
      for (ri=i+1; ri <= i + n_value; ri++)
      if (use_point[ri][j][k])
      {
        x_plus_ok = 1;
        break;
      }

      for (rj=j-n_value; rj < j; rj++)
      if (use_point[i][rj][k]) 
      {
        y_minus_ok = 1;
        break;
      }
      for (rj=j+1; rj <= j + n_value; rj++)
      if (use_point[i][rj][k])
      {
        y_plus_ok = 1;
        break;
      }

      for (rk=k-n_value; rk < k; rk++)
      if (use_point[i][j][rk]) 
      {
        z_minus_ok = 1;
        break;
      }
      for (rk=k+1; rk <= k + n_value; rk++)
      if (use_point[i][j][rk])
      {
        z_plus_ok = 1;
        break;
      }

    if (x_minus_ok && x_plus_ok && y_minus_ok && y_plus_ok && z_minus_ok && z_plus_ok) 
      use_point[i][j][k] = 0;
    }
  }

  for (i=0; i<floor(.000001 + box_x/resolution); i++)
  for (j=0; j<floor(.000001 + box_y/resolution); j++)
  for (k=0; k<floor(.000001 + box_z/resolution); k++)
  if (use_point[i][j][k]) 
    printf("%lf\t%lf\t%lf\t%lf\n", i*resolution, j*resolution, k*resolution, test_diameter);
}
Exemple #7
0
int main(int argc, char* argv[])
{
  double tx, ty, tz;
  double volume;
  int successes=0, attempts=0;
  int centers;
  int i;
  double dx, dy, dz, dd;
  double zero_x, zero_y, zero_z;

  setCommandLineParameters(argc, argv);
  getVectorParam("-box", &box_x, &box_y, &box_z);
  getIntParam("-n_centers", &n_centers);
  getIntParam("-n_attempts", &n_attempts);

  if (getFlagParam("-usage")) 
  {
    printf("usage:\t-box [ 10 10 10 ]\n");
    printf("      \t-n_centers [ 1000 ]\n");
    printf("      \t-n_attempts [ 1000 ]\n");
    exit(0);
  }

  rnd_step_x=box_x*rnd_step;
  rnd_step_y=box_y*rnd_step;
  rnd_step_z=box_z*rnd_step;

srand(15);

  instream = stdin;
  readInputStream();

  successes=0;

  for (centers=0; centers<n_centers; centers++)
  {
    center_x=rand()*rnd_step_x;
    center_y=rand()*rnd_step_y;
    center_z=rand()*rnd_step_z;
  
    /* build Verlet list */
    number_of_close=0;
    for (i=0; i<number_of_cavities; i++)
    {
      dx=center_x-x[i];
      dy=center_y-y[i];
      dz=center_z-z[i];
  
      dd = dx*dx + dy*dy + dz*dz;
      if (4*dd < (d_max + d[i])*(d_max + d[i]))
      {
        close_x[number_of_close] = x[i];
        close_y[number_of_close] = y[i];
        close_z[number_of_close] = z[i];
        close_d[number_of_close] = d[i];
        number_of_close++;
      }
    }

    zero_x=center_x-(d_max*0.69336127435063470484335227478596*.5);
    zero_y=center_y-(d_max*0.69336127435063470484335227478596*.5);
    zero_z=center_z-(d_max*0.69336127435063470484335227478596*.5);
    
    if (number_of_close>0) for (attempts=0; attempts<n_attempts; attempts++)
    {
      // pick a point and check inclusion

      tx = zero_x + rand() * rnd_step_center;
      ty = zero_y + rand() * rnd_step_center;
      tz = zero_z + rand() * rnd_step_center;

      successes += checkInclusion(tx, ty, tz);
    }
  }

  volume = (box_x * box_y * box_z * successes)/(n_centers*n_attempts);

  printf("%lf\n", volume);
  return 0;
}