]> hackdaworld.org Git - physik/posic.git/commitdiff
added 2b bond check for tersoff
authorhackbard <hackbard@sage.physik.uni-augsburg.de>
Wed, 28 May 2008 10:35:34 +0000 (12:35 +0200)
committerhackbard <hackbard@sage.physik.uni-augsburg.de>
Wed, 28 May 2008 10:35:34 +0000 (12:35 +0200)
moldyn.c
potentials/tersoff.c
potentials/tersoff.h

index a4fef49f1f6f7d1a431e584d56a8d7c3c815038d..dd8a527ff77f91bc1ce214ddb4370526222b357f 100644 (file)
--- 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;
index d322b69af72f083af2b6a891b4e92091f73bf208..3a0ed1846967e159430cde751d250e2c5347a901 100644 (file)
@@ -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(aj<ai)
-               virial_calc(ai,&force,&(exchange->dist_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(aj<ai)
-               virial_calc(ai,&force,&dist_ij);
+       v3_scale(&force,&force,-1.0);
+       virial_calc(ai,&force,&dist_ij);
 
        /* derivative wrt k */
        v3_scale(&force,&dist_ik,-1.0*dfcg); // dri rik = - drk rik
@@ -651,9 +644,8 @@ int tersoff_mult_3bp_k2(t_moldyn *moldyn,
 #endif
 
        /* virial */
-       //v3_scale(&force,&force,-1.0);
-       if(aj<ai)
-               virial_calc(ai,&force,&dist_ik);
+       v3_scale(&force,&force,-1.0);
+       virial_calc(ai,&force,&dist_ik);
        
        /* increase k counter */
        exchange->kcount++;     
@@ -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;
+}
+
index 4e129570f90f0f2f9aaa506c03551acfb013d185..a23503a0ed9693859a10631ba4ba3b6077a829be 100644 (file)
@@ -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 */