X-Git-Url: https://hackdaworld.org/gitweb/?a=blobdiff_plain;f=moldyn.c;h=f92ce557cecfaa398ff31ace4ef77513d1cf719e;hb=0d71b08d4382b23b8217342caf138cfce36226cc;hp=ad0f9a383ea7ae3e01a5a7c3ebc67de518756dc6;hpb=e763f6e3072fbbbc5ecf7345b989d7d29929a38f;p=physik%2Fposic.git diff --git a/moldyn.c b/moldyn.c index ad0f9a3..f92ce55 100644 --- a/moldyn.c +++ b/moldyn.c @@ -481,7 +481,7 @@ int link_cell_update(t_moldyn *moldyn) { for(i=0;icells;i++) list_destroy(&(moldyn->lc.subcell[i])); - for(count=0;countcount;count++) { + for(count=0;countcount;count++) { i=(atom[count].r.x+(moldyn->dim.x/2))/lc->x; j=(atom[count].r.y+(moldyn->dim.y/2))/lc->y; k=(atom[count].r.z+(moldyn->dim.z/2))/lc->z; @@ -995,12 +995,16 @@ int tersoff(t_moldyn *moldyn) { /* 2 body stuff */ + /* we need: f_c, df_c, f_r, df_r */ + v3_sub(&dist_ij,btom,&(atom[i])); d_ij=v3_norm(&dist_ij); if(d_ij<=S) { - S=; - R=; + /* determine the tersoff parameters */ + if(atom[i].element!=btom->element) { + S=sqrt(TERSOFF_S[e1]*TERSOFF_S[e2]); + R=R_m; A=; lambda=; B=; @@ -1010,8 +1014,10 @@ int tersoff(t_moldyn *moldyn) { betaN=; if(d_ij<=R) { - f_c=1.0; - df_c=0.0; + df_r=-lambda*A*exp(-lambda*d_ij)/d_ij; + v3_scale(&force,&dist_ij,df_r); + v3_add(&(atom[i].f),&(atom[i].f), + &force); } else { s_r=S-R; @@ -1019,7 +1025,11 @@ int tersoff(t_moldyn *moldyn) { f_c=0.5+0.5*cos(arg1); df_c=-0.5*sin(arg1)*(PI/(s_r*d_ij)); f_r=A*exp(-lambda*d_ij); - f_a=-B*exp(-mu*d_ij); + df_r=-lambda*f_r/d_ij; + scale=df_c*f_r+df_r*f_c; + v3_scale(&force,&dist_ij,scale); + v3_add(&(atom[i].f),&(atom[i].f), + &force); } } else @@ -1084,6 +1094,8 @@ int tersoff(t_moldyn *moldyn) { v3_sub(&distance_jk,ktom,btom); cos_theta=(d_ij2+d_ik*d_ik-d_jk*d_jk)/\ (2*d_ij*d_ik); + sin_theta=sqrt(1.0/\ + (cos_theta*cos_theta)); theta=arccos(cos_theta);