#include <string.h>
#include <math.h>
#include <time.h>
+
#include "dfbapi.h"
#define X 200
#define Y 200
-#define MAX_T 100
+#define MAX_T 10
int main(int argc, char **argv)
{
unsigned char *atom;
char *arg_v[4];
- char m_text[30];
- char t_text[30];
- char b_text[30];
+ char m_text[64];
+ char t_text[64];
+ char b_text[64];
int max_x,x_c,max_y,y_c;
int i;
int count_p;
for(T=1;T<MAX_T;T++)
{
- beta=20.0/T; /* k_B = 1 */
- /* do 10 itterations, we will need more */
- for(i=0;i<10;i++)
+ beta=5.0/T; /* k_B = 1 */
+ /* do 100 itterations, we will need more */
+ for(i=0;i<100;i++)
{
+ M=0;
for(x_c=0;x_c<max_x;x_c++)
{
for(y_c=0;y_c<max_y;y_c++)
{
count_p=0;
- M=0;
- if((*(atom+x_c+((2*y_c+1)%max_y)*max_x))&1) ++count_p;
- if((*(atom+x_c+((2*y_c-1)%max_y)*max_x))&1) ++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_y+1)%max_y)*max_x))&1) ++count_p;
+ if((*(atom+x_c+((y_c+max_y-1)%max_y)*max_x))&1) ++count_p;
+ if((*(atom+((max_x+x_c+1)%max_x)+y_c*max_x))&1) ++count_p;
+ if((*(atom+((max_x+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=(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;
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((*(atom+x_c+((2*y_c+1)%max_y)*max_x))&1) ++M;
+ if((*(atom+x_c+y_c*max_x))&1) ++M;
}
}
- sprintf(t_text,"T = %d",T);
+ sprintf(t_text,"temp = %d",T);
arg_v[1]=t_text;
- sprintf(b_text,"b = %f",beta);
+ sprintf(b_text,"beta = %f",beta);
arg_v[2]=b_text;
- sprintf(m_text,"M = %f",1.0-2.0*M/(max_x*max_y));
+ sprintf(m_text,"magn = %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);
}