Energy Gap Code

Taylor L. Hughes

/************************** Code by Taylor L. Hughes June 2,2008. to compile simply use gcc -lm prog.c -o pp and run pp.exe **************************/ #include <stdio.h> #include <math.h> #define PI 3.1415926536 int main() { FILE *f; double grid=1800.0; double t=1.0; double div =1.0/grid; float DD; f = fopen ("uplot.dat", "w");// Clear out file fclose(f); /////////////////////////////DO Integral/////////// int inx=0; int iny=0; double sum=0.0; for(DD=0.01;DD<10.0;DD+=0.05) { for(inx=0;inx< (int)grid;inx++) { for(iny=0;iny< (int)grid; iny++) { sum+=(2.0*PI*div)*(2.0*PI*div)/(sqrt(4.0*t*t*(cos(2.0*PI*((float)inx)*div)+cos(2.0*PI*((float)iny)*div))*(cos(2.0*PI*((float)inx)*div)+cos(2.0*PI*((float)iny)*div))+DD*DD)); } } sum/=((2.0*PI)*(2.0*PI)); sum/=2.0; float out=1.0/sum;//calculate U from the integral f = fopen ("uplot.dat", "a+"); fprintf(f,"\n%g\t %g",DD,out); } return 0; }