2 * calcultae fluctuations and related values
4 * author: frank.zirkelbach@physik.uni-augsburg.de
12 #include <sys/types.h>
16 #define AMU 1.6605388628e-27
19 #define KILOGRAM (1.0/AMU)
20 #define NEWTON (METER*KILOGRAM/(SECOND*SECOND))
21 #define JOULE (NEWTON*METER)
22 #define K_BOLTZMANN (1.380650524e-23*METER*NEWTON)
23 #define K_B2 (K_BOLTZMANN*K_BOLTZMANN)
24 #define EV (1.6021765314e-19*METER*NEWTON)
26 int get_line(int fd,char *line,int max) {
33 if(count==max) return count;
34 ret=read(fd,line+count,1);
35 if(ret<=0) return ret;
36 if(line[count]=='\n') {
44 int main(int argc,char **argv) {
50 double e,e2,de2,val,time;
57 printf("%s <file> <from> <to> <linenumber>\n",argv[0]);
59 printf("optional add: <nr particles> <mass> <temperature>");
64 strncpy(file,argv[1],255);
74 m=atof(argv[6])*AMU*np;
75 t=atof(argv[7])+273.0;
78 fd=open(file,O_RDONLY);
89 if(get_line(fd,buf,255)<=0)
93 if((time>=from)&(time<=to)) {
103 de2=e2/count-e*e/(count*count);
104 printf("--> fluctuation [eV/atom]: %.20f\n",de2);
106 de2*=((np*np*EV*EV));
107 printf(" specific heat capacity (T=%f K) [J/(kg K)]:\n",
110 (1.5*np*K_BOLTZMANN/(1.0-de2/(1.5*np*K_B2*t*t))/
113 (de2/(K_BOLTZMANN*t*t)+1.5*np*K_BOLTZMANN)/