From c3aa705d0409ddf9457cd1ba86e43ef10fc42d6e Mon Sep 17 00:00:00 2001
From: Stan Moore <stamoor@sandia.gov>
Date: Thu, 30 Nov 2017 09:22:32 -0700
Subject: [PATCH] Improve performance of pair_reaxc, this change is safe
 because the non-bonded i-loop doesn't include ghost atoms; this optimization
 is already included in the USER-OMP version

---
 src/USER-REAXC/pair_reaxc.cpp | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/USER-REAXC/pair_reaxc.cpp b/src/USER-REAXC/pair_reaxc.cpp
index 0f4bd49cc8..7c135463ad 100644
--- a/src/USER-REAXC/pair_reaxc.cpp
+++ b/src/USER-REAXC/pair_reaxc.cpp
@@ -697,7 +697,7 @@ int PairReaxC::write_reax_lists()
   int itr_i, itr_j, i, j;
   int num_nbrs;
   int *ilist, *jlist, *numneigh, **firstneigh;
-  double d_sqr;
+  double d_sqr, cutoff_sqr;
   rvec dvec;
   double *dist, **x;
   reax_list *far_nbrs;
@@ -712,6 +712,7 @@ int PairReaxC::write_reax_lists()
   far_list = far_nbrs->select.far_nbr_list;
 
   num_nbrs = 0;
+  int inum = list->inum;
   dist = (double*) calloc( system->N, sizeof(double) );
 
   int numall = list->inum + list->gnum;
@@ -721,12 +722,17 @@ int PairReaxC::write_reax_lists()
     jlist = firstneigh[i];
     Set_Start_Index( i, num_nbrs, far_nbrs );
 
+    if (i < inum)
+      cutoff_sqr = control->nonb_cut*control->nonb_cut;
+    else
+      cutoff_sqr = control->bond_cut*control->bond_cut;
+
     for( itr_j = 0; itr_j < numneigh[i]; ++itr_j ){
       j = jlist[itr_j];
       j &= NEIGHMASK;
       get_distance( x[j], x[i], &d_sqr, &dvec );
 
-      if( d_sqr <= (control->nonb_cut*control->nonb_cut) ){
+      if( d_sqr <= (cutoff_sqr) ){
         dist[j] = sqrt( d_sqr );
         set_far_nbr( &far_list[num_nbrs], j, dist[j], dvec );
         ++num_nbrs;
-- 
GitLab