if(moldyn->rfd) {
dprintf(moldyn->rfd,report_end);
close(moldyn->rfd);
- snprintf(sc,255,"cd %s && pdflatex report",moldyn->vlsdir);
+ snprintf(sc,255,"cd %s && pdflatex report >/dev/null 2>&1",
+ moldyn->vlsdir);
system(sc);
- snprintf(sc,255,"cd %s && pdflatex report",moldyn->vlsdir);
+ snprintf(sc,255,"cd %s && pdflatex report >/dev/null 2>&1",
+ moldyn->vlsdir);
system(sc);
- snprintf(sc,255,"cd %s && dvipdf report",moldyn->vlsdir);
+ snprintf(sc,255,"cd %s && dvipdf report >/dev/null 2>&1",
+ moldyn->vlsdir);
system(sc);
}
if(&(moldyn->vis)) visual_tini(&(moldyn->vis));
}
/* check for hooks */
- if(sched->hook)
- sched->hook(moldyn,sched->hook_params);
+ if(sched->count+1<sched->total_sched)
+ if(sched->hook)
+ sched->hook(moldyn,sched->hook_params);
/* get a new info line */
printf("\n");
return 0;
}
+
+/*
+ * postprocessing functions
+ */
+
+int get_line(int fd,char *line,int max) {
+
+ int count,ret;
+
+ count=0;
+
+ while(1) {
+ if(count==max) return count;
+ ret=read(fd,line+count,1);
+ if(ret<=0) return ret;
+ if(line[count]=='\n') {
+ line[count]='\0';
+ return count+1;
+ }
+ count+=1;
+ }
+}
+
+int calc_fluctuations(double start,double end,t_moldyn *moldyn) {
+
+ int fd;
+ int count,ret;
+ double time,pot,kin,tot;
+ double p_sum,k_sum,t_sum;
+ char buf[64];
+ char file[128+7];
+
+ printf("[moldyn] calculating energy fluctuations [eV]:\n");
+
+ snprintf(file,128+7,"%s/energy",moldyn->vlsdir);
+ fd=open(file,O_RDONLY);
+ if(fd<0) {
+ perror("[moldyn] post proc energy open");
+ return fd;
+ }
+
+ /* first calc the averages */
+ p_sum=0.0;
+ k_sum=0.0;
+ t_sum=0.0;
+ count=0;
+ while(1) {
+ ret=get_line(fd,buf,63);
+ if(ret<=0) break;
+ if(buf[0]=='#') continue;
+ sscanf(buf,"%lf %lf %lf %lf",&time,&kin,&pot,&tot);
+ if(time<start) continue;
+ if(time>end) break;
+ p_sum+=pot;
+ k_sum+=kin;
+ t_sum+=tot;
+ count+=1;
+ }
+
+ moldyn->p_m=p_sum/count;
+ moldyn->k_m=k_sum/count;
+ moldyn->t_m=t_sum/count;
+
+ /* mean square fluctuations */
+ if(lseek(fd,SEEK_SET,0)<0) {
+ perror("[moldyn] lseek");
+ return -1;
+ }
+ count=0;
+ p_sum=0.0;
+ k_sum=0.0;
+ t_sum=0.0;
+ while(1) {
+ ret=get_line(fd,buf,63);
+ if(ret<=0) break;
+ if(buf[0]=='#') continue;
+ sscanf(buf,"%lf %lf %lf %lf",&time,&kin,&pot,&tot);
+ if(time<start) continue;
+ if(time>end) break;
+ k_sum+=((kin-moldyn->k_m)*(kin-moldyn->k_m));
+ p_sum+=((pot-moldyn->p_m)*(pot-moldyn->p_m));
+ t_sum+=((tot-moldyn->t_m)*(tot-moldyn->t_m));
+ count+=1;
+ }
+
+ moldyn->dp2_m=p_sum/count;
+ moldyn->dk2_m=k_sum/count;
+ moldyn->dt2_m=t_sum/count;
+
+ printf(" averages : %f %f %f\n",moldyn->k_m,
+ moldyn->p_m,
+ moldyn->t_m);
+ printf(" mean square: %f %f %f\n",moldyn->dk2_m,
+ moldyn->dp2_m,
+ moldyn->dt2_m);
+
+ close(fd);
+
+ return 0;
+}
+
+int get_heat_capacity(t_moldyn *moldyn) {
+
+ double temp2,mass,ighc;
+ int i;
+
+ /* (temperature average)^2 */
+ temp2=2.0*moldyn->k_m*EV/(3.0*K_BOLTZMANN);
+ printf("[moldyn] specific heat capacity for T=%f K [J/(kg K)]\n",temp2);
+ temp2*=temp2;
+
+ /* total mass */
+ mass=0.0;
+ for(i=0;i<moldyn->count;i++)
+ mass+=moldyn->atom[i].mass;
+
+ /* ideal gas contribution */
+ ighc=3.0*moldyn->count*K_BOLTZMANN/2.0;
+ printf(" ideal gas contribution: %f\n",ighc/mass*KILOGRAM/JOULE);
+
+ moldyn->c_v_nvt=moldyn->dp2_m*moldyn->count*moldyn->count*EV/(K_BOLTZMANN*temp2)+ighc;
+ moldyn->c_v_nvt/=mass;
+ moldyn->c_v_nve=ighc/(1.0-(moldyn->dp2_m*moldyn->count*moldyn->count*EV/(ighc*K_BOLTZMANN*temp2)));
+ moldyn->c_v_nve/=mass;
+
+ printf(" NVE: %f\n",moldyn->c_v_nve*KILOGRAM/JOULE);
+ printf(" NVT: %f\n",moldyn->c_v_nvt*KILOGRAM/JOULE);
+
+ return 0;
+}