projects
/
physik
/
ising.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fixed delta e bug
[physik/ising.git]
/
ising.c
diff --git
a/ising.c
b/ising.c
index
dd538b3
..
e43b4be
100644
(file)
--- a/
ising.c
+++ b/
ising.c
@@
-11,11
+11,12
@@
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
+#include <time.h>
#include "dfbapi.h"
#include "dfbapi.h"
-#define X
1
00
-#define Y
1
00
-#define MAX_T
2
00
+#define X
2
00
+#define Y
2
00
+#define MAX_T
1
00
int main(int argc, char **argv)
{
int main(int argc, char **argv)
{
@@
-33,6
+34,9
@@
int main(int argc, char **argv)
double beta;
double delta_e;
double beta;
double delta_e;
+ /* random stuff*/
+ srand(time(0));
+
/* display stuff */
d2_lattice d2_l;
/* display stuff */
d2_lattice d2_l;
@@
-53,9
+57,9
@@
int main(int argc, char **argv)
for(T=1;T<MAX_T;T++)
{
for(T=1;T<MAX_T;T++)
{
- beta=
1
.0/T; /* k_B = 1 */
- /* do 10
0
itterations, we will need more */
- for(i=0;i<10
0
;i++)
+ beta=
20
.0/T; /* k_B = 1 */
+ /* do 10 itterations, we will need more */
+ for(i=0;i<10;i++)
{
for(x_c=0;x_c<max_x;x_c++)
{
for(x_c=0;x_c<max_x;x_c++)
@@
-69,21
+73,21
@@
int main(int argc, char **argv)
if((*(atom+((2*x_c+1)%max_x)+y_c*max_x))&1) ++count_p;
if((*(atom+((2*x_c-1)%max_x)+y_c*max_x))&1) ++count_p;
if(((*(atom+x_c+y_c*max_x))&1)==0) count_p=4-count_p;
if((*(atom+((2*x_c+1)%max_x)+y_c*max_x))&1) ++count_p;
if((*(atom+((2*x_c-1)%max_x)+y_c*max_x))&1) ++count_p;
if(((*(atom+x_c+y_c*max_x))&1)==0) count_p=4-count_p;
- delta_e=(
4-2*count_p
)*S;
+ delta_e=(
2*count_p-4
)*S;
if(delta_e<0) *(atom+x_c+y_c*max_x)=(*(atom+x_c+y_c*max_x)+1)&1;
else
{
if(1.0*rand()/RAND_MAX<exp(-1.0*delta_e*beta))
*(atom+x_c+y_c*max_x)=(*(atom+x_c+y_c*max_x)+1)&1;
if(delta_e<0) *(atom+x_c+y_c*max_x)=(*(atom+x_c+y_c*max_x)+1)&1;
else
{
if(1.0*rand()/RAND_MAX<exp(-1.0*delta_e*beta))
*(atom+x_c+y_c*max_x)=(*(atom+x_c+y_c*max_x)+1)&1;
- else M+=1;
}
}
+ if((*(atom+x_c+((2*y_c+1)%max_y)*max_x))&1) ++M;
}
}
sprintf(t_text,"T = %d",T);
arg_v[1]=t_text;
sprintf(b_text,"b = %f",beta);
arg_v[2]=b_text;
}
}
sprintf(t_text,"T = %d",T);
arg_v[1]=t_text;
sprintf(b_text,"b = %f",beta);
arg_v[2]=b_text;
- sprintf(m_text,"M = %f",1.0-2*M/(max_x*max_y));
+ sprintf(m_text,"M = %f",1.0-2
.0
*M/(max_x*max_y));
arg_v[3]=m_text;
d2_lattice_draw(&d2_l,0,0,3,arg_v);
}
arg_v[3]=m_text;
d2_lattice_draw(&d2_l,0,0,3,arg_v);
}