Ejemplo n.º 1
0
 /**
  * Checks to see if there are two neighbors not in same cluster
  *
  * @param x_i,y_i
  */
 public void checkNeighbors(int x_i, int y_i) {
   for (int j = 0; j < 4; j++) {
     int px = PBC.position(x_i + nnx[j], L);
     int py = PBC.position(y_i + nny[j], L);
     if ((site[px][py] != -1) && (site[px][py] != site[x_i][y_i])) {
       merge(site[px][py], site[x_i][y_i]);
     }
   }
 }
Ejemplo n.º 2
0
 /** Moves a cluster chosen at random in a random direction */
 public void step() {
   int cluster = (int) (Math.random() * numberOfClusters);
   int direction = (int) (Math.random() * 4);
   int dx = nnx[direction];
   int dy = nny[direction];
   int particle = firstParticle[cluster];
   do {
     site[x[particle]][y[particle]] = -1;
     x[particle] = PBC.position(x[particle] + dx, L);
     y[particle] = PBC.position(y[particle] + dy, L);
     particle = nextParticle[particle];
   } while (particle != -1);
   particle = firstParticle[cluster];
   do {
     site[x[particle]][y[particle]] = cluster; // labels new sites occupied by cluster
     particle = nextParticle[particle];
   } while (particle != -1);
   particle = firstParticle[cluster];
   do {
     checkNeighbors(x[particle], y[particle]); // checks for merger
     particle = nextParticle[particle];
   } while (particle != -1);
 }