X-Git-Url: https://hackdaworld.org/gitweb/?a=blobdiff_plain;f=moldyn.c;h=2631d6a675549e183a41fa91ca863dee215bed0f;hb=746278fb5c566b621b70c78b38d8b6c0b4e2677f;hp=716a087fa90f1b89b073411af22e2d55995aba8a;hpb=01be83f52829176f95a7fa6bb38a9f3518d44aa9;p=physik%2Fposic.git diff --git a/moldyn.c b/moldyn.c index 716a087..2631d6a 100644 --- a/moldyn.c +++ b/moldyn.c @@ -873,15 +873,7 @@ int potential_force_calc(t_moldyn *moldyn) { !(jtom->attr&ATOM_ATTR_3BP)) continue; - /* - * according to mr. nordlund, we dont need to take the - * sum over all atoms now, as 'this is centered' around - * atom i ... - * i am not quite sure though! there is a not vanishing - * part even if f_c_ik is zero ... - * this analytical potentials suck! - * switching from mc to md to dft soon! - */ + /* neighbourhood of atom j is not needed! */ // link_cell_neighbour_index(moldyn, // (jtom->r.x+moldyn->dim.x/2)/lc->x, @@ -1156,6 +1148,7 @@ int tersoff_mult_2bp(t_moldyn *moldyn,t_atom *ai,t_atom *aj,u8 bc) { exchange=&(params->exchange); exchange->run3bp=0; + exchange->run2bp_post=0; /* * we need: f_c, df_c, f_r, df_r @@ -1200,7 +1193,7 @@ int tersoff_mult_2bp(t_moldyn *moldyn,t_atom *ai,t_atom *aj,u8 bc) { f_r=A*exp(-lambda*d_ij); df_r=-lambda*f_r/d_ij; - /* f_a, df_a calc + save for 3bp use */ + /* f_a, df_a calc + save for later use */ exchange->f_a=-B*exp(-mu*d_ij); exchange->df_a=-mu*exchange->f_a/d_ij; @@ -1228,8 +1221,9 @@ int tersoff_mult_2bp(t_moldyn *moldyn,t_atom *ai,t_atom *aj,u8 bc) { exchange->f_c=f_c; exchange->df_c=df_c; - /* enable the run of 3bp function */ + /* enable the run of 3bp function and 2bp post processing */ exchange->run3bp=1; + exchange->run2bp_post=1; /* reset 3bp sums */ exchange->sum1_3bp=0.0; @@ -1259,6 +1253,10 @@ int tersoff_mult_post_2bp(t_moldyn *moldyn,t_atom *ai,t_atom *aj,u8 bc) { params=moldyn->pot2b_params; exchange=&(params->exchange); + /* we do not run if f_c_ij was dtected to be 0! */ + if(!(exchange->run2bp_post)) + return 0; + db_ij=&(exchange->db_ij); f_c=exchange->f_c; df_c=exchange->df_c; @@ -1266,6 +1264,7 @@ int tersoff_mult_post_2bp(t_moldyn *moldyn,t_atom *ai,t_atom *aj,u8 bc) { df_a=exchange->df_a; betan=exchange->betan; n=*(exchange->n); + chi=exchange->chi; dist_ij=&(exchange->dist_ij); db_ij_scale1=(1+betan*exchange->sum1_3bp); @@ -1274,19 +1273,24 @@ int tersoff_mult_post_2bp(t_moldyn *moldyn,t_atom *ai,t_atom *aj,u8 bc) { b_ij=chi*db_ij_scale1*help; db_ij_scale1=-chi/(2*n)*help; + /* db_ij part */ v3_scale(db_ij,db_ij,(db_ij_scale1*db_ij_scale2)); v3_scale(db_ij,db_ij,f_a); + /* df_a part */ v3_scale(&temp,dist_ij,b_ij*df_a); + /* db_ij + df_a part */ v3_add(&force,&temp,db_ij); v3_scale(&force,&force,f_c); + /* df_c part */ v3_scale(&temp,dist_ij,f_a*b_ij*df_c); /* add energy of 3bp sum */ moldyn->energy+=(0.5*f_c*b_ij*f_a); - /* add force of 3bp calculation */ + + /* add force of 3bp calculation (all three parts) */ v3_add(&(ai->f),&temp,&force); return 0; @@ -1415,13 +1419,13 @@ int tersoff_mult_3bp(t_moldyn *moldyn,t_atom *ai,t_atom *aj,t_atom *ak,u8 bc) { bracket=0.0; bracket_n_1=0.0; bracket_n=0.0; - printf("Foo -> 0: "); + //printf("Foo -> 0: "); } else { bracket=f_c_ik*g; bracket_n_1=pow(bracket,n-1.0); bracket_n=bracket_n_1*bracket; - printf("Foo -> 1: "); + //printf("Foo -> 1: "); } //printf("%.15f %.15f %.15f\n",bracket_n_1,bracket_n,bracket);