- /* 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;
+ /* rms */
+ moldyn->dk2_m=k2_sum/count-moldyn->k_m*moldyn->k_m;
+ moldyn->dp2_m=p2_sum/count-moldyn->p_m*moldyn->p_m;
+ moldyn->dt2_m=t2_sum/count-moldyn->t_m*moldyn->t_m;