# ising Makefile
-INCLUDEDIR = /usr/include
-CFLAGS = -DDEBUG -DUSE_DFB_API -DFONT=\"./decker.ttf\" -O3 -Wall -I/usr/include/directfb
+INCLUDEDIR = /usr/local/include
+CFLAGS = -DDEBUG -DUSE_DFB_API -DFONT=\"./decker.ttf\" -O3 -Wall -I/usr/local/include/directfb
LIBS = -L/usr/lib -ldirectfb
OBJS = dfbapi.o
#include <stdlib.h>
#include <string.h>
#include <math.h>
+#include <time.h>
#include "dfbapi.h"
-#define X 100
-#define Y 100
-#define MAX_T 200
+#define X 200
+#define Y 200
+#define MAX_T 100
int main(int argc, char **argv)
{
double beta;
double delta_e;
+ /* random stuff*/
+ srand(time(0));
+
/* display stuff */
d2_lattice d2_l;
for(T=1;T<MAX_T;T++)
{
- beta=1.0/T; /* k_B = 1 */
- /* do 100 itterations, we will need more */
- for(i=0;i<100;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++)
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;
- 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(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);
}