return moldyn->p;
}
+int average_reset(t_moldyn *moldyn) {
+
+ /* update skip value */
+ moldyn->avg_skip=moldyn->total_steps;
+
+ /* kinetic energy */
+ moldyn->k_sum=0.0;
+ moldyn->k2_sum=0.0;
+
+ /* potential energy */
+ moldyn->v_sum=0.0;
+ moldyn->v2_sum=0.0;
+
+ /* temperature */
+ moldyn->t_sum=0.0;
+
+ /* virial */
+ moldyn->virial_sum=0.0;
+ moldyn->gv_sum=0.0;
+
+ /* pressure */
+ moldyn->p_sum=0.0;
+ moldyn->gp_sum=0.0;
+
+ return 0;
+}
+
int average_and_fluctuation_calc(t_moldyn *moldyn) {
int denom;
v3_add(&(atom[i].v),&(atom[i].v),&delta);
}
+ /* criticial check */
+ moldyn_bc_check(moldyn);
+
/* neighbour list update */
link_cell_update(moldyn);
/* should never happen but it does 8) -
* related to -ffloat-store problem! */
- if(s>=slots) s=slots-1;
+ if(s>=slots) {
+ printf("[moldyn] WARNING pcc (%d/%d)\n",
+ s,slots);
+ s=slots-1;
+ }
if(ibrand!=jtom->brand) {
/* mixed */
int scale_velocity(t_moldyn *moldyn,u8 equi_init);
double virial_sum(t_moldyn *moldyn);
double pressure_calc(t_moldyn *moldyn);
-int energy_fluctuation_calc(t_moldyn *moldyn);
+int average_reset(t_moldyn *moldyn);
+int average_and_fluctuation_calc(t_moldyn *moldyn);
int get_heat_capacity(t_moldyn *moldyn);
double thermodynamic_pressure_calc(t_moldyn *moldyn);
double get_pressure(t_moldyn *moldyn);
int i,j;
u8 run;
t_3dvec r,v,dist;
- double d;
+ double d,dmin;
t_atom *atom;
r.z+=INS_OFFSET;
/* assume valid coordinates */
run=0;
+ dmin=10000000000.0; // for sure too high!
for(i=0;i<moldyn->count;i++) {
atom=&(moldyn->atom[i]);
v3_sub(&dist,&(atom->r),&r);
run=1;
break;
}
+ if(d<dmin)
+ dmin=d;
}
}
add_atom(moldyn,INS_TYPE,INS_MASS,INS_BRAND,
//ATOM_ATTR_HB|ATOM_ATTR_VB,
ATOM_ATTR_HB,
&r,&v);
+ printf(" %02d: atom %d | %f %f %f | %f\n",
+ j,moldyn->count-1,r.x,r.y,r.z,dmin);
}
return 0;
t_moldyn *md;
int steps;
double tau;
+ double dt;
hp=hook_params;
md=moldyn;
/* act according to state */
switch(hp->state) {
case STATE_INSERT:
+ /* assigne values */
+ steps=INS_RELAX;
+ tau=INS_TAU;
/* check temperature */
- if(md->t_avg-md->t_ref>INS_DELTA_TC) {
- steps=INS_RELAX;
- tau=INS_TAU;
+ dt=md->t_avg-md->t_ref;
+ if(dt<0)
+ dt=-dt;
+ if(dt>INS_DELTA_TC)
break;
- }
/* insert atoms */
hp->insert_count+=1;
printf(" ### insert atoms (%d/%d) ###\n",
hp->state=STATE_POSTRUN;
break;
case STATE_POSTRUN:
- /* settings */
- if(md->t-md->t_ref>POST_DELTA_TC) {
- steps=POST_RELAX;
- tau=POST_TAU;
- }
+ /* assigne values */
+ steps=POST_RELAX;
+ tau=POST_TAU;
+ /* check temperature */
+ dt=md->t_avg-md->t_ref;
+ if(dt<0)
+ dt=-dt;
+ if(dt>INS_DELTA_TC)
+ break;
/* decrease temperature */
hp->postrun_count+=1;
printf(" ### postrun (%d/%d) ###\n",
break;
}
+ /* reset the average counters */
+ average_reset(md);
+
/* add schedule */
moldyn_add_schedule(md,steps,tau);