From: hackbard Date: Wed, 28 May 2008 10:35:34 +0000 (+0200) Subject: added 2b bond check for tersoff X-Git-Url: https://hackdaworld.org/gitweb/?a=commitdiff_plain;h=52485a28c5f9812c0f7a2d4e0094cd8000167b24;p=physik%2Fposic.git added 2b bond check for tersoff --- diff --git a/moldyn.c b/moldyn.c index a4fef49..dd8a527 100644 --- a/moldyn.c +++ b/moldyn.c @@ -220,7 +220,7 @@ int set_potential(t_moldyn *moldyn,u8 type) { 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; diff --git a/potentials/tersoff.c b/potentials/tersoff.c index d322b69..3a0ed18 100644 --- a/potentials/tersoff.c +++ b/potentials/tersoff.c @@ -224,7 +224,8 @@ int tersoff_mult_2bp(t_moldyn *moldyn,t_atom *ai,t_atom *aj,u8 bc) { /* add forces */ v3_add(&(ai->f),&(ai->f),&force); - v3_sub(&(aj->f),&(aj->f),&force); // reason: dri rij = - drj rij + v3_scale(&force,&force,-1.0); // reason: dri rij = - drj rij + v3_add(&(aj->f),&(aj->f),&force); #ifdef DEBUG if((ai==&(moldyn->atom[0]))|(aj==&(moldyn->atom[0]))) { @@ -238,7 +239,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); /* energy 2bp contribution */ energy=f_r*f_c; @@ -500,10 +501,6 @@ int tersoff_mult_3bp_j2(t_moldyn *moldyn,t_atom *ai,t_atom *aj,u8 bc) { } #endif - /* virial */ - if(ajdist_ij)); - /* dzeta prefactor = - 0.5 f_c f_a db */ exchange->pre_dzeta=-0.5*f_a*f_c*db; @@ -611,9 +608,6 @@ int tersoff_mult_3bp_k2(t_moldyn *moldyn, } #endif - /* virial */ - //virial_calc(ai,&force,&dist_ij); - /* derivative wrt j */ v3_scale(&force,&dcosdrj,fcdg*pre_dzeta); @@ -629,9 +623,8 @@ int tersoff_mult_3bp_k2(t_moldyn *moldyn, #endif /* virial */ - //v3_scale(&force,&force,-1.0); - if(ajkcount++; @@ -661,3 +653,30 @@ int tersoff_mult_3bp_k2(t_moldyn *moldyn, return 0; } + +int tersoff_mult_check_2b_bond(t_moldyn *moldyn,t_atom *ai,t_atom *aj,u8 bc) { + + t_tersoff_mult_params *params; + t_3dvec dist; + double d; + u8 brand; + + v3_sub(&dist,&(aj->r),&(ai->r)); + if(bc) check_per_bound(moldyn,&dist); + d=v3_absolute_square(&dist); + + params=moldyn->pot_params; + brand=ai->brand; + + if(brand==aj->brand) { + if(d<=params->S2[brand]) + return TRUE; + } + else { + if(d<=params->S2mixed) + return TRUE; + } + + return FALSE; +} + diff --git a/potentials/tersoff.h b/potentials/tersoff.h index 4e12957..a23503a 100644 --- a/potentials/tersoff.h +++ b/potentials/tersoff.h @@ -83,6 +83,7 @@ int tersoff_mult_3bp_k1(t_moldyn *moldyn, int tersoff_mult_3bp_j2(t_moldyn *moldyn,t_atom *ai,t_atom *aj,u8 bc); int tersoff_mult_3bp_k2(t_moldyn *moldyn, t_atom *ai,t_atom *aj,t_atom *ak,u8 bc); +int tersoff_mult_check_2b_bond(t_moldyn *moldyn,t_atom *ai,t_atom *aj,u8 bc); /* tersoff potential paramter defines */