Can we use Monte Carlo to compute Z? (even for a very simple, minimum-size, discrete case) Consider a model of spins on a 2D lattice (idealized magnetic.

Slides:



Advertisements
Similar presentations
Dr Roger Bennett Rm. 23 Xtn Lecture 19.
Advertisements

Introduction Landau Theory Many phase transitions exhibit similar behaviors: critical temperature, order parameter… Can one find a rather simple unifying.
ALGORITHMS - PART 2 CONDITIONAL BRANCH CONTROL STRUCTURE
Prepared 7/28/2011 by T. O’Neil for 3460:677, Fall 2011, The University of Akron.
Lecture 13: Conformational Sampling: MC and MD Dr. Ronald M. Levy Contributions from Mike Andrec and Daniel Weinstock Statistical Thermodynamics.
Ising Model Dr. Ernst Ising May 10, 1900 – May 11, 1998.
The Potts and Ising Models of Statistical Mechanics.
The Markov property Discrete time: A time symmetric version: A more general version: Let A be a set of indices >k, B a set of indices
Monte Carlo Simulation of Ising Model and Phase Transition Studies
C Lecture Notes Functions (Cont...). C Lecture Notes 5.8Calling Functions: Call by Value and Call by Reference Used when invoking functions Call by value.
The Ising Model of Ferromagnetism by Lukasz Koscielski Chem 444 Fall 2006.
Monte Carlo Methods H. Rieger, Saarland University, Saarbrücken, Germany Summerschool on Computational Statistical Physics, NCCU Taipei, Taiwan.
Presentation in course Advanced Solid State Physics By Michael Heß
Monte Carlo Simulation of Ising Model and Phase Transition Studies By Gelman Evgenii.
Advanced methods of molecular dynamics Monte Carlo methods
Classical and Quantum Monte Carlo Methods Or: Why we know as little as we do about interacting fermions Erez Berg Student/Postdoc Journal Club, Oct
Excerpts of Some Statistical Mechanics Lectures Found on the Web.
Physics Fluctuomatics (Tohoku University) 1 Physical Fluctuomatics 7th~10th Belief propagation Appendix Kazuyuki Tanaka Graduate School of Information.
Free energies and phase transitions. Condition for phase coexistence in a one-component system:
TUTORIAL no. 2 Monte Carlo simulations: Lennard Jones gas G. Lattanzi Università degli studi di Bari “Aldo Moro” Trieste, July 10 th, 2012 CECAM school.
F.F. Assaad. MPI-Stuttgart. Universität-Stuttgart Numerical approaches to the correlated electron problem: Quantum Monte Carlo.  The Monte.
Monte Carlo Simulation: Simulate an Isothermal-Isobaric Ensemble Timothy Tie Dong Bing School of Physics, Computer Lab 25 th Jan 2013.
The H 2 O molecule: converging the size of the simulation box Objectives - study the convergence of the properties with the size of the unit cell.
1 Worm Algorithms Jian-Sheng Wang National University of Singapore.
Basic Monte Carlo (chapter 3) Algorithm Detailed Balance Other points.
Hit-and-Miss (or Rejection) Monte Carlo Method:
Monte Carlo Methods and Simulation
Introduction to Lattice Simulations. Cellular Automata What are Cellular Automata or CA? A cellular automata is a discrete model used to study a range.
The Ising Model Mathematical Biology Lecture 5 James A. Glazier (Partially Based on Koonin and Meredith, Computational Physics, Chapter 8)
Two Temperature Non-equilibrium Ising Model in 1D Nick Borchers.
8. Selected Applications. Applications of Monte Carlo Method Structural and thermodynamic properties of matter [gas, liquid, solid, polymers, (bio)-macro-
Hit-and-Miss (or Rejection) Monte Carlo Method: a “brute-force” method based on completely random sampling Then, how do we throw the stones and count them.
Importance sampling for MC simulation
Animating Tessellations of the Plane with Statistic Models Ben McCabe Advisor: Rolfe Petschek Department of Physics, Case Western Reserve University Artists,
Path Integral Quantum Monte Carlo Consider a harmonic oscillator potential a classical particle moves back and forth periodically in such a potential x(t)=
Javier Junquera Introduction to atomistic simulation methods in condensed matter Alberto García Pablo Ordejón.
13. Extended Ensemble Methods. Slow Dynamics at First- Order Phase Transition At first-order phase transition, the longest time scale is controlled by.
An Introduction to Monte Carlo Methods in Statistical Physics Kristen A. Fichthorn The Pennsylvania State University University Park, PA
Monte Carlo in different ensembles Chapter 5
Graduate School of Information Sciences, Tohoku University
Javier Junquera Importance sampling Monte Carlo. Cambridge University Press, Cambridge, 2002 ISBN Bibliography.
Byeong-Joo Lee Atomistic Simulations Byeong-Joo Lee Dept. of MSE Pohang University of Science and Technology
Some physical properties of disorder Blume-Emery-Griffiths model S.L. Yan, H.P Dong Department of Physics Suzhou University CCAST
MC Simulation Lab 7: 2-Dimensional Lennard-Jones Simple Liquid (Off-Lattice) and Its Phase Transition.
Ginzburg-Landau theory of second-order phase transitions Vitaly L. Ginzburg Lev Landau Second order= no latent heat (ferromagnetism, superfluidity, superconductivity).
Basic Monte Carlo (chapter 3) Algorithm Detailed Balance Other points non-Boltzmann sampling.
Landau free energy density For large N we expect thermodynamic limit t=(T-T c )/T c (t=0 corresponds to the critical temperature Can think of this as averaging.
Monte Carlo Simulation of Canonical Distribution The idea is to generate states i,j,… by a stochastic process such that the probability  (i) of state.
Lecture 14: Advanced Conformational Sampling Dr. Ronald M. Levy Statistical Thermodynamics.
Computational Physics (Lecture 4) PHY4370. Random Variable, density function and distribution function.
Introduction to Computer Simulation of Physical Systems (Lecture 10) Numerical and Monte Carlo Methods (CONTINUED) PHYS 3061.
Computational Physics (Lecture 10) PHY4370. Simulation Details To simulate Ising models First step is to choose a lattice. For example, we can us SC,
Computational Physics (Lecture 8) PHY4061. Inverse of a matrix The inverse of a matrix A using linear equating approach: A −1 i j = x i j, – for i, j.
Monte Carlo Simulation of the Ising Model Consider a system of N classical spins which can be either up or down. The total.
Systematic errors of MC simulations Equilibrium error averages taken before the system has reached equilibrium  Monitor the variables you are interested.
Applications of the Canonical Ensemble: Simple Models of Paramagnetism
Computational Physics (Lecture 10)
Statistical-Mechanical Approach to Probabilistic Image Processing -- Loopy Belief Propagation and Advanced Mean-Field Method -- Kazuyuki Tanaka and Noriko.
Phase diagram of a mixed spin-1 and spin-3/2 Ising ferrimagnet
Applications of the Canonical Ensemble:
14. TMMC, Flat-Histogram and Wang-Landau Method
Model systems with interaction
In “Adaptive Cooperative Systems” Summarized by Ho-Sik Seok
Presented by Rhee, Je-Keun
Using compiler-directed approach to create MPI code automatically
Mean Field Approximation
Lattice gas with interactions
Common Types of Simulations
Thermodynamics and Statistical Physics
Presentation transcript:

Can we use Monte Carlo to compute Z? (even for a very simple, minimum-size, discrete case) Consider a model of spins on a 2D lattice (idealized magnetic model). ⇒ a discrete system Each of N spins can take 2 states: up ( ↑ ) and down ( ↓ ). ⇒ 2 N microstates Each spin interacts only with its nearest neighbors (nn). ⇒ 4 neighbors for a 2D square lattice Suppose that it takes (or ) s to compute the interaction of a spin with its neighbors. ⇒ Time to calculate the energy E i of a microstate i = N x (or N x ) s For N = 100 spins: ~ microstates (or ) s to calculate the energy of a microstate ⇒ (or ) s to estimate Z! (~ age of the universe ~ 13.8 billion years ~ 4 x s) The situation gets worse with a real (continuous, larger, with beyond-nn interaction) system! a microstate ⇒ We cannot compute Z (and the absolute free energy  kT ln Z) for real systems! (However, we can compute a relative free energy between two states.)

MC simulation (beyond-1-dimension-1-body): 2-Dimensional square-lattice “Ising model” for ferromagnetic phase transition  One of the simplest and best studied of statistical mechanical models  A simple model of a magnet  Proposed to interpret ferromagnetism in materials by Wilhelm Lenz (1920) and analytically solved by Ernst Ising (1925; 1D) and Lars Onsager (1944; 2D)  Magnetic dipoles or atomic spins σ ( ↑ or ↓, +1 or -1) are placed on a lattice.  For N sites on the lattice (N-atom model), the system can e in 2 N microstates.  The total energy of a microstate is given by the Ising Hamiltonian: J = interaction energy between nearest-neighbor spin H or B = external magnetic field (= 0 at the moment)  = magnetic moment  Let’s estimate quantities like magnetization m and specific heat c at a given temperature. a microstate

Specific heat = variance of energy Magnetic susceptibility = variance of magnetization

#include "test.h" #include "build_ferro.h" #include "build_para.h" #include "init_glx_2d.h" #include "visu_glx_2d.h" #include "compute_pot.h" #include "mc_cycle.h" GLfloat xAngle = 90.0, yAngle = 0.0, zAngle =.0, xTrans = 0.95, yTrans = 0.0, zTrans = -24, xAngle_init, yAngle_init, zAngle_init, xPlane = 100; /*! main() for driver_test. */ int main(int argc, char *argv[]) { int i, j, n_dim, n_atoms, init, n_x, n_y, i_step, n_steps, n_blocks, n_data_block; double sigma, sigma2, a; double *h, **r, *s, **sl; int **nl; double temp; int *nn; long seed; double pot_energy, m, cv, pot_energy_block, pot_energy2_block, m_block, cv_block; int n_trial, n_accept; FILE *fp, *fpb; ising_2d.c

Display *dpy; Window win; GLboolean doubleBuffer = GL_TRUE; GLUquadricObj *qobj; int graph_switch, resph; int antialias_switch = 1; double radius; KeySym ks; char buff[31]; XEvent event; int keep_going; /* Get command-line input */ if (argc != 9) { fprintf(stderr, "Usage: %s init n_x n_y temp n_steps n_blocks seed graph_switch\n", argv[0]); exit(1); } init = atoi(argv[1]); n_x = atoi(argv[2]); n_y = atoi(argv[3]); temp = atof(argv[4]); n_steps = atoi(argv[5]); n_blocks = atoi(argv[6]); seed = atoi(argv[7]); graph_switch = atoi(argv[8]); n_dim = 2; sigma = 1.0; ising_2d.c

/* Build initial condition. */ if (init == 0) { /* build paramagnetic */ build_para(nn, a, r, s, nl, sl, &seed); } else { /* build ferromagnetic */ build_ferro(nn, a, r, s, nl, sl); } /* Initialize graphics. */ antialias_switch = 1; radius = sigma / 2.0; resph = 8; if (graph_switch > 0) { initialize_2d(&dpy, &win, doubleBuffer, &qobj, graph_switch, antialias_switch, h); keep_going = 1; while (keep_going) { XNextEvent(dpy, &event); switch (event.type) { case KeyPress: (void) XLookupString(&event.xkey, buff, sizeof(buff), &ks, NULL); switch (ks) { case XK_Escape: keep_going = 0; break; default: break; } redraw_2d(dpy, win, doubleBuffer, qobj, n_atoms, r, s, h, radius, resph); } ising_2d.c

/* Compute total energy. */ pot_energy = compute_pot(n_atoms, nn, nl, sl); /* Print energy. */ fprintf(stderr, "\n\n Initial\n"); fprintf(stderr, "\n\nPotential energy = %12.8f\n", pot_energy); /* Initialize block variables. */ m_block = 0.0; pot_energy_block = 0.0; pot_energy2_block = 0.0; /* Open files. */ fp = fopen("inst.dat", "w"); fpb = fopen("block.dat", "w"); /* MC loop. */ for (i_step = 1; i_step <= n_steps; ++i_step) { /* Perform a MC cycle. */ mc_cycle(nn, n_atoms, nl, sl, s, temp, &seed, &pot_energy, &n_trial, &n_accept); /* Calculate and write thermodynamic quantities in file every cycle. */ m = 0; for (i = 0; i < n_atoms; ++i) { m += s[i]; } m /= (double) n_atoms; m = fabs(m); fprintf(fp, "%d %12.8f %12.8f\n", i_step, pot_energy / n_atoms, m); ising_2d.c

/* Accumulate blocks. */ m_block += m; pot_energy_block += pot_energy; pot_energy2_block += pot_energy * pot_energy; if (i_step % n_blocks == 0) { m_block /= (double) n_blocks; pot_energy_block /= (double) n_blocks; pot_energy2_block /= (double) n_blocks; cv_block = (pot_energy2_block - pot_energy_block * pot_energy_block) / (temp * temp * n_atoms); fprintf(fpb, "%d %12.8f %12.8f %12.8f\n", i_step, pot_energy_block / n_atoms, m_block, cv_block); m_block = 0.0; pot_energy_block = 0.0; pot_energy2_block = 0.0; } /* Draw system. */ if (graph_switch > 0 && i_step % 1000 == 0) redraw_2d(dpy, win, doubleBuffer, qobj, n_atoms, r, s, h, radius, resph); } /* Print energy. */ fprintf(stderr, "\n\n Final\n"); fprintf(stderr, "\n\nPotential energy = %12.8f\n", pot_energy); fprintf(stderr, "\n\nAccepted moves = %12.8f\n", (double)n_accept / (double)n_trial); /* Close files. */ fclose(fp); fclose(fpb); /* Exit */ return(0); } ising_2d.c

#include "build_ferro.h" void build_ferro(int *nn, double a, double **r, double *s, int **nl, double **sl) { int i, j, ii, n_atoms; n_atoms = nn[0] * nn[1]; /* Loop over atoms. */ ii = 0; for (j = 0; j < nn[1]; ++j) { for (i = 0; i < nn[0]; ++i) { /* Generate lattice and spin */ r[ii][0] = -nn[0] * 0.5 * a + i * a; r[ii][1] = -nn[1] * 0.5 * a + j * a; nl[ii][0] = i; nl[ii][1] = j; s[ii] = 1.0; sl[i][j] = s[ii]; ++ii; } if (ii != n_atoms) { printf("problem in ferro building\n"); exit(1); } printf("\nConfiguration building completed\n"); fflush(NULL); /* Return zero if the initial condition is successfully constructed. */ return; } Build_ferro.c

Periodic boundary condition: Implementation (2d case) 1. Real coordinates /* (xi, yi) particle i coordinates */ if (xi > Lx/2) xi = xi – Lx; else if (xi < -Lx/2) xi = xi + Lx; if (yi > Ly/2) yi = yi – Ly; else if (yi < -Ly/2) yi = yi + Ly; y 0 L x /2 -L x /2 L y /2 -L y /2 i xixi yiyi x x i -L x 2. Scaled (between [-0.5,0.5]) coordinates (better to handle any cell shape): orthorombic cell case #define NINT(x) ((x) < 0.0 ? (int) ((x) - 0.5) : (int) ((x) + 0.5)) sxi = xi / Lx; /* (sxi, syi) particle i scaled coordinates */ syi = yi / Ly; sxi = NINT(sxi); /* Apply PBC */ syi = NINT(syi); xi = sxi * Lx; /* (xi, yi) particle i folded real coordinates */ yi = syi * Ly;

#include "test.h" #include "build_para.h" #include "ran3.h" void build_para(int *nn, double a, double **r, double *s, int **nl, double **sl, long *seed) { int i, j, ii, s_up, s_down, spin_up, spin_down, n_atoms, assign; double rr; n_atoms = nn[0] * nn[1]; spin_up = n_atoms / 2; spin_down = spin_up; /* Loop over atoms. */ ii = 0; s_up = 0; s_down = 0; for (j = 0; j < nn[1]; ++j) { for (i = 0; i < nn[0]; ++i) { /* Generate lattice and spin */ r[ii][0] = -nn[0] * 0.5 * a + i * a; r[ii][1] = -nn[1] * 0.5 * a + j * a; nl[ii][0] = i; nl[ii][1] = j; build_para.c

/* Assign spins */ do { assign = 0; rr = ran3(seed); if (rr < 0.5 && s_up < spin_up) { s[ii] = 1.0; s_up += 1; assign = 1; } else if (rr >= 0.5 && s_down < spin_down) { s[ii] = -1.0; s_down += 1; assign = 1; } } while (!assign); sl[i][j] = s[ii]; ++ii; } if (ii != (spin_up + spin_down)) { printf("problem in para building\n"); exit(1); } printf("\nConfiguration building completed\n"); fflush(NULL); /* Return zero if the initial condition is successfully constructed. */ return; } build_para.c

#include "test.h" #include "compute_pot.h" #include "pbc.h" double compute_pot(int n_atoms, int *nn, int **nl, double **sl) { int i, j, ip1, jp1, i_atom, n_x, n_y; double u, spin; n_x = nn[0]; n_y = nn[1]; /* Zero potential energy. */ u = 0.0; /* Loop over first atom. */ for (i_atom = 0; i_atom < n_atoms; ++i_atom) { i = nl[i_atom][0]; j = nl[i_atom][1]; spin = sl[i][j]; /* Compute 1/2 interaction on the square lattice. */ ip1 = pbc(i + 1, n_x); jp1 = pbc(j + 1, n_y); u -= spin * (sl[ip1][j] + sl[i][jp1]); } /* Return potential energy. */ return u; } #include #include "pbc.h" int pbc(int i, int n) { if (i >= n) i -= n; else if (i < 0) i += n; return i; } comput_pot.cpbc.c

/* This routine carries out a single Monte Carlo cycle, comprising only of Monte Carlo atom move. Output: particle positions and potential energy are modified on output */ #include "test.h" #include "mc_cycle.h" #include "spin_flip.h" void mc_cycle(int *nn, int n_atoms, int **nl, double **sl, double *s, double temp, long *seed, double *u_pot, int *n_trial, int *n_accept) { int i_move; /* Loop over trial Monte Carlo moves (we only flip spins here). */ for (i_move = 0; i_move < n_atoms; ++i_move) { /* Make trial move. */ ++(*n_trial); *n_accept += spin_flip(nn, n_atoms, nl, sl, s, temp, seed, u_pot); } return; } mc_cycle.c

/* This routine generates a trial displacement of an interaction atom and accepts it based on the Metropolis criterion. Output: the return value is 1 if the move was accepted and 0 otherwise. */ #include "test.h" #include "pbc.h" #include "ran3.h" #include "spin_flip.h" int spin_flip(int *nn, int n_atoms, int **nl, double **sl, double *s, double temp, long *seed, double *u_pot) { int i, j, i_atom, accept; double spin, delta_u; int n_x, n_y, ip1, im1, jp1, jm1; /* Select an atom at random. */ i_atom = (int) (ran3(seed) * n_atoms); if (i_atom == n_atoms) --i_atom; n_x = nn[0]; n_y = nn[1]; i = nl[i_atom][0]; j = nl[i_atom][1]; spin = sl[i][j]; ip1 = pbc(i+1, n_x); im1 = pbc(i-1, n_x); jp1 = pbc(j+1, n_y); jm1 = pbc(j-1, n_y); Spin_flip.c

/* Compute change in potential energy and accept move using Metropolis criterion. */ delta_u = 2.0 * spin * (sl[im1][j] + sl[ip1][j] + sl[i][jm1] + sl[i][jp1]); if (delta_u <= 0.0) accept = 1; else accept = ran3(seed) < exp(- delta_u / temp); /* Update system potential energy if trial move is accepted. */ if (accept) { *u_pot += delta_u; sl[i][j] = -spin; s[i_atom] = -spin; } /* Return 1 if trial move is accepted, 0 otherwise. */ return accept; } Spin_flip.c