X-Git-Url: https://www.hackdaworld.org/gitweb/?a=blobdiff_plain;f=potentials%2Ftersoff.c;h=6bfcf30e0239ce2d0fa964607ff2ef9098ce403d;hb=92ef07d77a4c879527180224acea73a3f6564497;hp=531d292131121ad5acb7b1ce2a4a0c551199b34a;hpb=0b96eb313c9bfec6272b1f8de0d99c4ce26d1686;p=physik%2Fposic.git diff --git a/potentials/tersoff.c b/potentials/tersoff.c index 531d292..6bfcf30 100644 --- a/potentials/tersoff.c +++ b/potentials/tersoff.c @@ -94,6 +94,9 @@ int tersoff_mult_2bp(t_moldyn *moldyn,t_atom *ai,t_atom *aj,u8 bc) { double s_r; double arg; + printf("WARNING! - tersoff_mult_2bp is obsolete.\n"); + printf("WARNING! - repulsive part handled in 3bp/j2 routine.\n"); + /* use newtons third law */ if(aif),&(ai->f),&force); - v3_sub(&(aj->f),&(aj->f),&force); + v3_sub(&(aj->f),&(aj->f),&force); // reason: dri rij = - drj rij #ifdef DEBUG if((ai==&(moldyn->atom[0]))|(aj==&(moldyn->atom[0]))) { @@ -167,14 +170,7 @@ int tersoff_mult_2bp(t_moldyn *moldyn,t_atom *ai,t_atom *aj,u8 bc) { #endif /* virial */ - //virial_calc(ai,&force,&dist_ij); - //virial_calc(aj,&force,&dist_ij); - //ai->virial.xx-=force.x*dist_ij.x; - //ai->virial.yy-=force.y*dist_ij.y; - //ai->virial.zz-=force.z*dist_ij.z; - //ai->virial.xy-=force.x*dist_ij.y; - //ai->virial.xz-=force.x*dist_ij.z; - //ai->virial.yz-=force.y*dist_ij.z; + virial_calc(ai,&force,&dist_ij); /* energy 2bp contribution */ moldyn->energy+=f_r*f_c; @@ -316,6 +312,14 @@ int tersoff_mult_3bp_k1(t_moldyn *moldyn, exchange->zeta_ij+=f_c_ik*g; } +#ifdef DEBUG + if((ai==&(moldyn->atom[0]))| + (aj==&(moldyn->atom[864]))| + (ak==&(moldyn->atom[1003]))) { + printf(" -> %f %f %f\n",exchange->ci2di2,frac,h_cos); + } +#endif + /* store even more data for second k loop */ exchange->g[kcount]=g; exchange->dg[kcount]=dg; @@ -336,7 +340,10 @@ int tersoff_mult_3bp_j2(t_moldyn *moldyn,t_atom *ai,t_atom *aj,u8 bc) { t_tersoff_exchange *exchange; t_3dvec force; double f_a,df_a,b,db,f_c,df_c; + double f_r,df_r; + double scale; double mu,B,chi; + double lambda,A; double d_ij; unsigned char brand; double ni,tmp; @@ -350,14 +357,18 @@ int tersoff_mult_3bp_j2(t_moldyn *moldyn,t_atom *ai,t_atom *aj,u8 bc) { S=params->S[brand]; R=params->R[brand]; B=params->B[brand]; + A=params->A[brand]; mu=params->mu[brand]; + lambda=params->lambda[brand]; chi=1.0; } else { S=params->Smixed; R=params->Rmixed; B=params->Bmixed; + A=params->Amixed; mu=params->mu_m; + lambda=params->lambda_m; chi=params->chi; } @@ -379,6 +390,10 @@ int tersoff_mult_3bp_j2(t_moldyn *moldyn,t_atom *ai,t_atom *aj,u8 bc) { f_a=-B*exp(-mu*d_ij); df_a=mu*f_a/d_ij; + /* f_r, df_r */ + f_r=A*exp(-lambda*d_ij); + df_r=lambda*f_r/d_ij; + /* b, db */ if(exchange->zeta_ij==0.0) { b=chi; @@ -388,16 +403,16 @@ int tersoff_mult_3bp_j2(t_moldyn *moldyn,t_atom *ai,t_atom *aj,u8 bc) { ni=*(exchange->n_i); tmp=exchange->betaini*pow(exchange->zeta_ij,ni-1.0); b=(1.0+exchange->zeta_ij*tmp); - db=chi*pow(b,-1.0/(2*ni)-1.0); + db=chi*pow(b,-1.0/(2.0*ni)-1.0); b=db*b; db*=-0.5*tmp; } /* force contribution */ - v3_scale(&force,&(exchange->dist_ij),df_a*f_c+f_a*df_c); - v3_scale(&force,&force,-0.5*b); + scale=-0.5*(f_c*(df_r+b*df_a)+df_c*(f_r+b*df_a)); + v3_scale(&force,&(exchange->dist_ij),scale); v3_add(&(ai->f),&(ai->f),&force); - v3_sub(&(aj->f),&(aj->f),&force); + v3_sub(&(aj->f),&(aj->f),&force); // dri rij = - drj rij #ifdef DEBUG if((ai==&(moldyn->atom[0]))|(aj==&(moldyn->atom[0]))) { @@ -407,18 +422,21 @@ int tersoff_mult_3bp_j2(t_moldyn *moldyn,t_atom *ai,t_atom *aj,u8 bc) { printf("total i: %f %f %f\n",ai->f.x,ai->f.y,ai->f.z); if(aj==&(moldyn->atom[0])) printf("total j: %f %f %f\n",aj->f.x,aj->f.y,aj->f.z); + printf("energy: %f = %f %f %f %f\n",0.5*f_c*(b*f_a+f_r), + f_c,b,f_a,f_r); + printf(" %f %f %f\n",exchange->zeta_ij,.0,.0); } #endif /* virial */ - //virial_calc(ai,&force,&(exchange->dist_ij)); - //virial_calc(aj,&force,&(exchange->dist_ij)); + if(ajdist_ij)); /* dzeta prefactor = - 0.5 f_c f_a db */ exchange->pre_dzeta=-0.5*f_a*f_c*db; /* energy contribution */ - moldyn->energy+=0.5*f_c*b*f_a; + moldyn->energy+=0.5*f_c*(b*f_a+f_r); /* reset k counter for second k loop */ exchange->kcount=0; @@ -522,7 +540,7 @@ int tersoff_mult_3bp_k2(t_moldyn *moldyn, /* virial */ //virial_calc(ai,&force,&dist_ij); - /* derivatice wrt j */ + /* derivative wrt j */ v3_scale(&force,&dcosdrj,fcdg*pre_dzeta); /* force contribution */ @@ -537,10 +555,12 @@ int tersoff_mult_3bp_k2(t_moldyn *moldyn, #endif /* virial */ - //virial_calc(aj,&force,&dist_ij); + //v3_scale(&force,&force,-1.0); + if(ajkcount++;