Documente Academic
Documente Profesional
Documente Cultură
/*
* Slightly adapted from a code (c) Kari Rummukainen.
* Simple 2d Ising model simulation program in c.
* Uses heat bath update.
* Prints out measurements of energy and magnetization.
*
* Needs files: ising_sim.c mersenne.h mersenne_inline.c
*/
#include
#include
#include
#include
<stdio.h>
<stdlib.h>
<math.h>
<sys/time.h>
46
#define USE_ARRAY
#ifdef USE_ARRAY
static int x_up[NX],y_up[NY],x_dn[NX],y_dn[NY];
#define xup(i) x_up[i]
#define xdn(i) x_dn[i]
#define yup(i) y_up[i]
#define ydn(i) y_dn[i]
#else
#define
#define
#define
#define
#endif
xup(i)
xdn(i)
yup(i)
ydn(i)
((i+1) % NX)
((i-1+NX) % NX)
((i+1) % NY)
((i-1+NY) % NY)
47
n_loops = atoi(argv[1]);
beta = atof(argv[2]);
/* number of loops */
/* value of beta */
48
void update()
{
int sum,x,y;
double p_plus,p_minus;
Recall:
0
p(z )
... z
+ + +
z+
1
z+2
z1
z2
h
i
exp Sz (z0 )
.
exp [Sz (+1)] + exp [Sz (1)]
... + Sz (z ) ,
49
50
1
32_20_hot.dat using 1:3
= 0.20
0.5
0.5
-0.5
-0.5
-1
-1
0
500
1000
1500
2000
2500
3000
500
1000
1500
= 0.30
0.5
0.5
-0.5
-0.5
-1
500
1000
1500
2000
2500
3000
500
1000
1500
2000
2500
3000
1
32_40_cold.dat using 1:3
0.5
0.5
-0.5
-0.5
-1
-1
0
500
1000
1500
2000
2500
3000
500
1000
1500
2000
2500
3000
1
32_50_hot.dat using 1:3
0.5
0.5
-0.5
-0.5
-1
-1
0
500
1000
1500
2000
2500
3000
500
1000
1500
2000
2500
3000
1
32_60_hot.dat using 1:3
= 0.60
3000
-1
0
= 0.50
2500
= 0.40
2000
0.5
0.5
-0.5
-0.5
-1
-1
0
500
1000
1500
2000
2500
3000
500
1000
1500
2000
2500
3000
51
1
64_30_hot.dat using 1:3
= 0.30
0.5
0.5
-0.5
-0.5
-1
-1
0
500
1000
1500
2000
2500
3000
500
1000
1500
3000
0.5
0.5
-0.5
-0.5
-1
-1
0
500
1000
1500
2000
2500
3000
500
1000
1500
2000
2500
3000
1
64_50_hot.dat using 1:3
= 0.50
2500
1
64_40_hot.dat using 1:3
= 0.40
2000
0.5
0.5
-0.5
-0.5
-1
-1
0
500
1000
1500
2000
2500
3000
500
1000
1500
2000
2500
3000
52
1
64_44_hot_every.dat using 1:3
= 0.44
0.5
0.5
-0.5
-0.5
-1
-1
0
50
100
150
200
250
300
50
100
150
200
250
300
1
64_44_hot_100.dat using 1:3
= 0.44
0.5
0.5
-0.5
-0.5
-1
-1
0
5000
10000
15000
20000
25000
30000
5000
10000
15000
20000
25000
30000
53
0.5
-0.5
= 0.435
-1
0
10000
20000
30000
40000
50000
60000
1
64_438_cold_big.dat using 1:3
0.5
-0.5
= 0.438
-1
0
10000
20000
30000
40000
50000
60000
1
64_439_cold_big.dat using 1:3
0.5
-0.5
= 0.439
-1
0
10000
20000
30000
40000
50000
60000
1
64_4400_cold_big.dat using 1:3
0.5
-0.5
= 0.440
-1
0
10000
20000
30000
40000
50000
60000
1
64_4410_cold_big.dat using 1:3
0.5
-0.5
= 0.441
-1
0
10000
20000
30000
40000
50000
60000
54
0.1
0.08
0.06
0.04
0.02
= 0.435
0
-1
-0.5
0.5
0.16
64_438_cold_big.histo using 1:2
0.14
0.12
0.1
0.08
0.06
0.04
0.02
= 0.438
0
-1
-0.5
0.5
0.3
64_439_cold_big.histo using 1:2
0.25
0.2
0.15
0.1
0.05
= 0.439
0
-1
-0.5
0.5
0.2
64_440_cold_big.histo using 1:2
0.18
0.16
0.14
0.12
0.1
0.08
0.06
0.04
0.02
= 0.440
0
-1
-0.5
0.5
0.25
64_441_cold_big.histo using 1:2
0.2
0.15
0.1
0.05
= 0.441
0
-1
-0.5
0.5
55