#include <time.h>
#include <math.h>
+#include <fpu_control.h>
+
+#ifdef PARALLEL
+#include <omp.h>
+#endif
+
#include "moldyn.h"
#include "report/report.h"
#include "potentials/tersoff.h"
#endif
+/* pse */
+#define PSE_NAME
+#define PSE_COL
+#include "pse.h"
+#undef PSE_NAME
+#undef PSE_COL
+
/*
* the moldyn functions
*/
printf("[moldyn] init\n");
+ /* only needed if compiled without -msse2 (float-store prob!) */
+ //fpu_set_rtd();
+
memset(moldyn,0,sizeof(t_moldyn));
moldyn->argc=argc;
moldyn->func3b_k1=tersoff_mult_3bp_k1;
moldyn->func3b_j2=tersoff_mult_3bp_j2;
moldyn->func3b_k2=tersoff_mult_3bp_k2;
- // missing: check 2b bond func
+ moldyn->check_2b_bond=tersoff_mult_check_2b_bond;
break;
case MOLDYN_POTENTIAL_AM:
moldyn->func3b_j1=albe_mult_3bp_j1;
count=moldyn->count;
/* how many atoms do we expect */
+ if(type==NONE) {
+ new*=1;
+ printf("[moldyn] WARNING: create 'none' lattice called");
+ }
if(type==CUBIC) new*=1;
if(type==FCC) new*=4;
if(type==DIAMOND) new*=8;
scale*=2.0;
else
if(moldyn->pt_scale&T_SCALE_BERENDSEN)
- scale=1.0+(scale-1.0)/moldyn->t_tc;
+ scale=1.0+(scale-1.0)*moldyn->tau/moldyn->t_tc;
scale=sqrt(scale);
/* velocity scaling */
/* scaling factor */
if(moldyn->pt_scale&P_SCALE_BERENDSEN) {
- scale=1.0-(moldyn->p_ref-moldyn->p)*moldyn->p_tc;
+ scale=1.0-(moldyn->p_ref-moldyn->p)*moldyn->p_tc*moldyn->tau;
scale=pow(scale,ONE_THIRD);
}
else {
}
if(lc->cells<27)
- printf("[moldyn] FATAL: less then 27 subcells!\n");
+ printf("[moldyn] FATAL: less then 27 subcells! (%d)\n",
+ lc->cells);
if(vol) {
#ifdef STATIC_LISTS
printf("[moldyn] WARNING: cutoff > 0.5 x dim.y\n");
if(moldyn->cutoff>0.5*moldyn->dim.z)
printf("[moldyn] WARNING: cutoff > 0.5 x dim.z\n");
- ds=0.5*atom[0].f.x*moldyn->tau_square/atom[0].mass;
- if(ds>0.05*moldyn->nnd)
+ if(moldyn->count) {
+ ds=0.5*atom[0].f.x*moldyn->tau_square/atom[0].mass;
+ if(ds>0.05*moldyn->nnd)
printf("[moldyn] WARNING: forces too high / tau too small!\n");
+ }
/* zero absolute time */
// should have right values!
sched->count,i,moldyn->total_steps,
moldyn->t,moldyn->t_avg,
moldyn->p/BAR,moldyn->p_avg/BAR,
+ //moldyn->p/BAR,(moldyn->p-2.0*moldyn->ekin/(3.0*moldyn->volume))/BAR,
moldyn->volume,
(int)(t2.tv_sec-t1.tv_sec));
link_cell_update(moldyn);
/* forces depending on chosen potential */
+#ifndef ALBE_FAST
potential_force_calc(moldyn);
+#else
+ albe_potential_force_calc(moldyn);
+#endif
for(i=0;i<count;i++) {
/* check whether fixed atom */
memset(&(moldyn->gvir),0,sizeof(t_virial));
/* reset force, site energy and virial of every atom */
+#ifdef PARALLEL
+ #pragma omp parallel for private(virial)
+#endif
for(i=0;i<count;i++) {
/* reset force */
jtom=&(atom[neighbour_i[j][p]]);
p++;
-
- if(jtom==&(itom[i]))
- continue;
-
- if((jtom->attr&ATOM_ATTR_2BP)&
- (itom[i].attr&ATOM_ATTR_2BP)) {
- moldyn->func2b(moldyn,
- &(itom[i]),
- jtom,
- bc_ij);
- }
- }
#else
this=&(neighbour_i[j]);
list_reset_f(this);
do {
jtom=this->current->data;
+#endif
if(jtom==&(itom[i]))
continue;
jtom,
bc_ij);
}
+#ifdef STATIC_LISTS
+ }
+#else
} while(list_next_f(this)!=L_NO_NEXT_ELEMENT);
#endif
#endif
/* some postprocessing */
+#ifdef PARALLEL
+ #pragma omp parallel for
+#endif
for(i=0;i<count;i++) {
/* calculate global virial */
moldyn->gvir.xx+=itom[i].r.x*itom[i].f.x;
/* check forces regarding the given timestep */
if(v3_norm(&(itom[i].f))>\
- 0.1*moldyn->nnd*itom[i].mass/moldyn->tau_square)
+ 0.1*moldyn->nnd*itom[i].mass/moldyn->tau_square)
printf("[moldyn] WARNING: pfc (high force: atom %d)\n",
i);
}
int p;
#else
t_list neighbour[27];
+ t_list *this;
#endif
u8 bc;
t_atom *itom,*jtom;
int i,j;
- t_list *this;
lc=&(moldyn->lc);
itom=moldyn->atom;
return 0;
}
+/*
+ * fpu cntrol functions
+ */
+
+// set rounding to double (eliminates -ffloat-store!)
+int fpu_set_rtd(void) {
+
+ fpu_control_t ctrl;
+
+ _FPU_GETCW(ctrl);
+
+ ctrl&=~_FPU_EXTENDED;
+ ctrl|=_FPU_DOUBLE;
+
+ _FPU_SETCW(ctrl);
+
+ return 0;
+}
+