Computational Techniques in Theoretical Physics
 

Assignment for Lab 3: Percolation simulation using Monte Carlo algorithm.
 
 

 

Hint:
 
The following is a Fortran code for SWENDSEN-WANG ALGORITHM OF 2D ISING MODEL:
 
C     SWENDSEN-WANG ALGORITHM OF 2D ISING MODEL
C     Open boundary condition at the top and bottom, helical boundary at
C     at the site.   The following are timming of the program on
C     various computers.
C     MICROSECOND PER MC PER SPIN/MACHINE: 0.6/Dec7000, 0.8/Dec4000,
C     1.4/SGgalaxy, 1.5/HP720,
C     2.2/IBM 3090, 2.4/VP100, 3.3/indigo, 3.5/IBM 320 RISC,
C     8.8/Sparc Station, 17/Vax 3200, 21/PC486, 32/Vax750, 1300/PC AT
C
      PARAMETER (L=100, L2=L*L)
      DIMENSION LIST(L2),IS(L2)
      DATA BETA,IBM,MCHALF/ 1.0,1,100/
      IPR = (1.0 - 2.0*EXP(-2.0*0.440678/BETA)) * 2147483647.0
      MCSTEP=MCHALF*2
      MAV=0
      DO 1 I = 1, L2
 1    IS(I) = 1
      DO 2 MC = 1, MCSTEP
      LIST(1) = 1
      DO 3 I = 2, L2
      IF(IS(I-1).NE.IS(I))GOTO 4
      IBM = IBM * 16807
      IF ( IBM .GT. IPR ) GOTO 4
      LIST(I) = LIST(I-1)
      GOTO 5
 4    LIST(I) = I
 5    IF (I .LE. L)       GOTO 3
      MB = I - L
      IF(IS(MB).NE.IS(I)) GOTO 3
      IBM = IBM * 65539
      IF ( IBM .GE. IPR ) GOTO 3
 6      MB = LIST(MB)
        IF(MB.NE.LIST(MB))GOTO 6
        MA  = LIST(I)
        ISMALL = MIN0(MA,MB)
        LIST(MAX0(MA,MB)) = ISMALL
        LIST(I) = ISMALL
 3    CONTINUE
      INC = 0
      DO 7 I =1, L2
      IF ( I .EQ. LIST(I) ) THEN
        INC = INC + 1
        IS(I) = INC
      ELSE
        MA = LIST(I)
 8      MA = LIST(MA)
        IF(MA.NE.LIST(MA))GOTO 8
        IS(I) = IS(MA)
      END IF
 7    CONTINUE
      DO 9 I = 1, INC
      IBM = IBM * 16807
 9    LIST(I) = ISIGN(1,IBM)
      MAG=0
      DO 10 I = 1, L2
      IS(I) = LIST(IS(I))
 10   MAG = MAG + IS(I)
 2    IF(MC.GT.MCHALF) MAV=MAV+IABS(MAG)
      PRINT *, MAV*2.0/(L*L*MCSTEP)
      END