return 0;
}
-int set_mean_skip(t_moldyn *moldyn,int skip) {
+int set_avg_skip(t_moldyn *moldyn,int skip) {
printf("[moldyn] skip %d steps before starting average calc\n",skip);
- moldyn->mean_skip=skip;
+ moldyn->avg_skip=skip;
return 0;
}
moldyn->t=(2.0*moldyn->ekin)/(3.0*K_BOLTZMANN*moldyn->count);
- if(moldyn->total_steps<moldyn->mean_skip)
- return 0;
-
- moldyn->t_sum+=moldyn->t;
- moldyn->mean_t=moldyn->t_sum/(moldyn->total_steps+1-moldyn->mean_skip);
-
return moldyn->t;
}
/*
* PV = NkT + <W>
- * W = 1/3 sum_i f_i r_i
+ * with W = 1/3 sum_i f_i r_i (- skipped!)
* virial = sum_i f_i r_i
*
* => P = (2 Ekin + virial) / (3V)
v+=(virial->xx+virial->yy+virial->zz);
}
- /* virial sum and mean virial */
- moldyn->virial_sum+=v;
- if(moldyn->total_steps>=moldyn->mean_skip)
- moldyn->mean_v=moldyn->virial_sum/
- (moldyn->total_steps+1-moldyn->mean_skip);
-
- /* assume up to date kinetic energy */
- moldyn->p=2.0*moldyn->ekin+moldyn->mean_v;
- moldyn->p/=(3.0*moldyn->volume);
- if(moldyn->total_steps>=moldyn->mean_skip) {
+ /* virial sum and average virial */
+ if(moldyn->total_steps>=moldyn->avg_skip) {
+ moldyn->virial_sum+=v;
+ moldyn->virial_avg=moldyn->virial_sum/
+ (moldyn->total_steps+1-moldyn->avg_skip);
+ moldyn->p=2.0*moldyn->k_avg+moldyn->virial_avg;
+ moldyn->p/=(3.0*moldyn->volume);
moldyn->p_sum+=moldyn->p;
- moldyn->mean_p=moldyn->p_sum/
- (moldyn->total_steps+1-moldyn->mean_skip);
+ moldyn->p_avg=moldyn->p_sum/
+ (moldyn->total_steps+1-moldyn->avg_skip);
}
/* pressure from 'absolute coordinates' virial */
v=virial->xx+virial->yy+virial->zz;
moldyn->gp=2.0*moldyn->ekin+v;
moldyn->gp/=(3.0*moldyn->volume);
- if(moldyn->total_steps>=moldyn->mean_skip) {
+ if(moldyn->total_steps>=moldyn->avg_skip) {
moldyn->gp_sum+=moldyn->gp;
- moldyn->mean_gp=moldyn->gp_sum/
- (moldyn->total_steps+1-moldyn->mean_skip);
+ moldyn->gp_avg=moldyn->gp_sum/
+ (moldyn->total_steps+1-moldyn->avg_skip);
}
return moldyn->p;
}
-int energy_fluctuation_calc(t_moldyn *moldyn) {
+int average_and_fluctuation_calc(t_moldyn *moldyn) {
- if(moldyn->total_steps<moldyn->mean_skip)
+ if(moldyn->total_steps<moldyn->avg_skip)
return 0;
- /* assume up to date energies */
+ /* assume up to date energies, temperature, pressure etc */
/* kinetic energy */
moldyn->k_sum+=moldyn->ekin;
moldyn->k2_sum+=(moldyn->ekin*moldyn->ekin);
- moldyn->k_mean=moldyn->k_sum/(moldyn->total_steps+1-moldyn->mean_skip);
- moldyn->k2_mean=moldyn->k2_sum/
- (moldyn->total_steps+1-moldyn->mean_skip);
- moldyn->dk2_mean=moldyn->k2_mean-(moldyn->k_mean*moldyn->k_mean);
+ moldyn->k_avg=moldyn->k_sum/(moldyn->total_steps+1-moldyn->avg_skip);
+ moldyn->k2_avg=moldyn->k2_sum/(moldyn->total_steps+1-moldyn->avg_skip);
+ moldyn->dk2_avg=moldyn->k2_avg-(moldyn->k_avg*moldyn->k_avg);
/* potential energy */
moldyn->v_sum+=moldyn->energy;
moldyn->v2_sum+=(moldyn->energy*moldyn->energy);
- moldyn->v_mean=moldyn->v_sum/(moldyn->total_steps+1-moldyn->mean_skip);
- moldyn->v2_mean=moldyn->v2_sum/
- (moldyn->total_steps+1-moldyn->mean_skip);
- moldyn->dv2_mean=moldyn->v2_mean-(moldyn->v_mean*moldyn->v_mean);
+ moldyn->v_avg=moldyn->v_sum/(moldyn->total_steps+1-moldyn->avg_skip);
+ moldyn->v2_avg=moldyn->v2_sum/(moldyn->total_steps+1-moldyn->avg_skip);
+ moldyn->dv2_avg=moldyn->v2_avg-(moldyn->v_avg*moldyn->v_avg);
+
+ /* temperature */
+ moldyn->t_sum+=moldyn->t;
+ moldyn->t_avg=moldyn->t_sum/(moldyn->total_steps+1-moldyn->avg_skip);
+
+ /* virial */
+
+
+ /* pressure */
+
return 0;
}
double temp2,ighc;
/* averages needed for heat capacity calc */
- if(moldyn->total_steps<moldyn->mean_skip)
+ if(moldyn->total_steps<moldyn->avg_skip)
return 0;
/* (temperature average)^2 */
- temp2=moldyn->mean_t*moldyn->mean_t;
+ temp2=moldyn->t_avg*moldyn->t_avg;
printf("[moldyn] specific heat capacity for T=%f K [J/(kg K)]\n",
- moldyn->mean_t);
+ moldyn->t_avg);
/* ideal gas contribution */
ighc=3.0*moldyn->count*K_BOLTZMANN/2.0;
ighc/moldyn->mass*KILOGRAM/JOULE);
/* specific heat for nvt ensemble */
- moldyn->c_v_nvt=moldyn->dv2_mean/(K_BOLTZMANN*temp2)+ighc;
+ moldyn->c_v_nvt=moldyn->dv2_avg/(K_BOLTZMANN*temp2)+ighc;
moldyn->c_v_nvt/=moldyn->mass;
/* specific heat for nve ensemble */
- moldyn->c_v_nve=ighc/(1.0-(moldyn->dv2_mean/(ighc*K_BOLTZMANN*temp2)));
+ moldyn->c_v_nve=ighc/(1.0-(moldyn->dv2_avg/(ighc*K_BOLTZMANN*temp2)));
moldyn->c_v_nve/=moldyn->mass;
printf(" NVE: %f\n",moldyn->c_v_nve*KILOGRAM/JOULE);
printf(" NVT: %f\n",moldyn->c_v_nvt*KILOGRAM/JOULE);
-printf(" --> <dV2> sim: %f experimental: %f\n",moldyn->dv2_mean,1.5*moldyn->count*K_B2*moldyn->mean_t*moldyn->mean_t*(1.0-1.5*moldyn->count*K_BOLTZMANN/(700*moldyn->mass*JOULE/KILOGRAM)));
+printf(" --> <dV2> sim: %f experimental: %f\n",moldyn->dv2_avg,1.5*moldyn->count*K_B2*moldyn->t_avg*moldyn->t_avg*(1.0-1.5*moldyn->count*K_BOLTZMANN/(700*moldyn->mass*JOULE/KILOGRAM)));
return 0;
}
e_kin_calc(moldyn);
temperature_calc(moldyn);
pressure_calc(moldyn);
- energy_fluctuation_calc(moldyn);
- //tp=thermodynamic_pressure_calc(moldyn);
-//printf("thermodynamic p: %f\n",thermodynamic_pressure_calc(moldyn)/BAR);
+ average_and_fluctuation_calc(moldyn);
/* p/t scaling */
if(moldyn->pt_scale&(T_SCALE_BERENDSEN|T_SCALE_DIRECT))
if(!(i%p)) {
dprintf(moldyn->pfd,
"%f %f %f %f %f\n",moldyn->time,
- moldyn->p/BAR,moldyn->mean_p/BAR,
- moldyn->gp/BAR,moldyn->mean_gp/BAR);
+ moldyn->p/BAR,moldyn->p_avg/BAR,
+ moldyn->gp/BAR,moldyn->gp_avg/BAR);
}
}
if(t) {
if(!(i%t)) {
dprintf(moldyn->tfd,
"%f %f %f\n",
- moldyn->time,moldyn->t,moldyn->mean_t);
+ moldyn->time,moldyn->t,moldyn->t_avg);
}
}
if(s) {
if(!(i%10)) {
printf("\rsched: %d, steps: %d, T: %f, P: %f %f V: %f",
sched->count,i,
- moldyn->mean_t,
- moldyn->mean_p/BAR,
- moldyn->mean_gp/BAR,
+ moldyn->t_avg,
+ //moldyn->p_avg/BAR,
+ moldyn->p/BAR,
+ moldyn->gp_avg/BAR,
moldyn->volume);
fflush(stdout);
-printf("\n");
-get_heat_capacity(moldyn);
}
/* increase absolute time */
/* check for hooks */
if(sched->count+1<sched->total_sched)
- if(sched->hook)
+ if(sched->hook) {
+ printf("\n ## schedule hook %d/%d start ##\n",
+ sched->count+1,sched->total_sched);
sched->hook(moldyn,sched->hook_params);
-
- /* get a new info line */
- printf("\n");
+ printf(" ## schedule hook end ##\n");
+ }
}
t_linkcell lc; /* linked cell list interface */
- int mean_skip; /* amount of steps without average calc */
+ int avg_skip; /* amount of steps without average calc */
double t_ref; /* reference temperature */
double t; /* actual temperature */
double t_sum; /* sum over all t */
- double mean_t; /* mean value of t */
+ double t_avg; /* average value of t */
t_virial virial; /* global virial (absolute coordinates) */
double gp; /* pressure computed from global virial */
double gp_sum; /* sum over all gp */
- double mean_gp; /* mean value of gp */
+ double gp_avg; /* average value of gp */
- double mean_v; /* mean of virial */
+ double virial_avg; /* average of virial */
double virial_sum; /* sum over all calculated virials */
double p_ref; /* reference pressure */
double p; /* actual pressure (computed by virial) */
double p_sum; /* sum over all p */
- double mean_p; /* mean value of p */
+ double p_avg; /* average value of p */
t_3dvec tp; /* thermodynamic pressure dU/dV */
double dv; /* dV for thermodynamic pressure calc */
/* energy averages & fluctuations */
double k_sum; /* sum of kinetic energy */
double v_sum; /* sum of potential energy */
- double k_mean; /* average of kinetic energy */
- double v_mean; /* average of potential energy */
+ double k_avg; /* average of kinetic energy */
+ double v_avg; /* average of potential energy */
double k2_sum; /* sum of kinetic energy squared */
double v2_sum; /* sum of potential energy squared */
- double k2_mean; /* average of kinetic energy squared */
- double v2_mean; /* average of potential energy squared */
- double dk2_mean; /* mean square kinetic energy fluctuations */
- double dv2_mean; /* mean square potential energy fluctuations */
+ double k2_avg; /* average of kinetic energy squared */
+ double v2_avg; /* average of potential energy squared */
+ double dk2_avg; /* mean square kinetic energy fluctuations */
+ double dv2_avg; /* mean square potential energy fluctuations */
/* response functions */
double c_v_nve; /* constant volume heat capacity (nve) */
int set_potential3b_k2(t_moldyn *moldyn,pf_func3b func);
int set_potential_params(t_moldyn *moldyn,void *params);
-int set_mean_skip(t_moldyn *moldyn,int skip);
+int set_avg_skip(t_moldyn *moldyn,int skip);
int moldyn_set_log_dir(t_moldyn *moldyn,char *dir);
int moldyn_set_report(t_moldyn *moldyn,char *author,char *title);