d2_l->p_surface->GetSize(d2_l->p_surface,&(d2_l->s_width),&(d2_l->s_height));
font_dsc.flags=DFDESC_HEIGHT;
- font_dsc.height=d2_l->max_y*((d2_l->s_height)/(d2_l->max_y))/20; /* 20 ? */
+ font_dsc.height=d2_l->max_y*((d2_l->s_height)/(d2_l->max_y))/40; /* 40 ? */
+ d2_l->font_h=font_dsc.height;
d2_l->dfb->CreateFont(d2_l->dfb,FONT,&font_dsc,&(d2_l->font));
d2_l->p_surface->SetFont(d2_l->p_surface,d2_l->font);
d2_l->p_surface->SetColor(d2_l->p_surface,0x80,0x80,0xff,0xff);
for(i=1;i<=arg_c;i++)
{
- d2_l->p_surface->DrawString(d2_l->p_surface,arg_v[1],-1,
+ d2_l->p_surface->DrawString(d2_l->p_surface,arg_v[i],-1,
d2_l->info_x+d2_l->fakt_x,
- d2_l->info_y+d2_l->fakt_x+(i-1)*d2_l->fakt_x,
+ d2_l->info_y+d2_l->fakt_y+d2_l->font_h+(i-1)*2*d2_l->font_h,
DSTF_LEFT);
}
/* now we flip all to surface */
#include <math.h>
#include "dfbapi.h"
-#define X 50
-#define Y 50
+#define X 100
+#define Y 100
#define MAX_T 200
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];
int max_x,x_c,max_y,y_c;
- int i,j;
+ int i;
+ int count_p;
unsigned int T;
- double M;
+ double S;
+ int M;
double beta;
double delta_e;
/* begin at T=0 M=1 situation */
memset(atom,0,max_x*max_y*sizeof(unsigned char));
+ S=1; /* i have no idea! */
+
for(T=1;T<MAX_T;T++)
{
beta=1.0/T; /* k_B = 1 */
- /* do N*N itterations, we will need more */
- for(i=0;i<max_x*max_y;i++)
+ /* do 100 itterations, we will need more */
+ for(i=0;i<100;i++)
{
- for(x_c=0;x_c<max_x-1;x_c++)
+ for(x_c=0;x_c<max_x;x_c++)
{
- for(y_c=0;y_c<max_y-1;y_c++)
+ for(y_c=0;y_c<max_y;y_c++)
{
- delta_e=0;
- // delta_e+=(-1*(int)(atom
+ 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_x))&1)==0) count_p=4-count_p;
+ delta_e=(4-2*count_p)*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;
+ }
}
-
}
-
+ 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));
+ arg_v[3]=m_text;
+ d2_lattice_draw(&d2_l,0,0,3,arg_v);
}
- d2_lattice_draw(&d2_l,0,0,0,NULL);
}
getchar();