Next: Measurements
Up: Computer Simulation
Previous: Programming the Metropolis
/* Metropolis Monte Carlo update of 2-d Ising ferromagnet */
#include
extern int size;
void
metropolis(sweeps)
int sweeps;
{
int imet,i,j,ipos,jpos,ineg,jneg;
int old_spin,new_spin,spin_sum;
int old_energy,new_energy;
double energy_diff;
double ranf(); /* random number generator */
/* Loop over sweeps */
for (imet=0;imet ranf() ) ) {
/* Accept the change */
spin[i][j] = new_spin;
}
}} /* end of loop over sites */
} /* end of loop over sweeps */
}
Note: some browsers may not display this code listing correctly.
If not, you can view or save the source to see the program.
Paul Coddington, Northeast Parallel Architectures Center at Syracuse University, paulc@npac.syr.edu