commit 5fb01677db72c44c8994eb8124c68044c8cf0052
Author: Carles Marti <carles.marti-aliod@ens-lyon.fr>
Date:   Thu Jun 25 14:07:26 2020 +0200

    Allow 'surf_norm_vect' to accept the shortcut values '-x' '-y' '-z' equivalent to [-1, 0, 0] [0, -1, 0] [0, 0, -1] respectively. Changed When min_coll_height is not False collision is checked only by checking the height of the atoms.

diff --git a/modules/screening.py b/modules/screening.py
index 0f3399c..e9a2328 100644
--- a/modules/screening.py
+++ b/modules/screening.py
@@ -148,22 +148,25 @@ def check_collision(slab_molec, slab_num_atoms, min_height, vect, nn_slab,
     @return: bool, whether the surface and the molecule collide.
     """
     from ase.neighborlist import natural_cutoffs, neighbor_list
-    if (vect == np.array([1.0, 0.0, 0.0])).all \
-            or (vect == np.array([0.0, 1.0, 0.0])).all \
-            or (vect == np.array([0.0, 0.0, 1.0])).all:
-        for atom in slab_molec[slab_num_atoms:]:
-            if np.linalg.norm(atom.position * vect) < min_height:
-                return True
-    slab_molec_cutoffs = natural_cutoffs(slab_molec, mult=coll_coeff)
-    slab_molec_nghbs = len(neighbor_list("i", slab_molec, slab_molec_cutoffs))
-    if slab_molec_nghbs > nn_slab + nn_molec:
-        return True
+    if min_height is not False:
+        cart_coords = [[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]
+        if list(map(abs, vect.tolist())) in cart_coords:
+            for atom in slab_molec[slab_num_atoms:]:
+                if np.linalg.norm(atom.position * vect) < min_height:
+                    #  TODO Check norm when there are negative values
+                    return True
     else:
-        return False
+        slab_molec_cutoffs = natural_cutoffs(slab_molec, mult=coll_coeff)
+        slab_molec_nghbs = len(neighbor_list("i", slab_molec, slab_molec_cutoffs))
+        if slab_molec_nghbs > nn_slab + nn_molec:
+            return True
+        else:
+            return False
 
 
 def correct_coll(molec, slab, ctr_coord, site_coord, num_pts,
-                 coll_bttm, norm_vect, slab_nghbs, molec_nghbs, coll_coeff):
+                 min_coll_height, norm_vect, slab_nghbs, molec_nghbs,
+                 coll_coeff):
     # TODO Rethink this function
     """Tries to adsorb a molecule on a slab trying to avoid collisions by doing
     small rotations.
@@ -176,7 +179,7 @@ def correct_coll(molec, slab, ctr_coord, site_coord, num_pts,
     @param site_coord: The coordinates of the surface on which to adsorb the
         molecule
     @param num_pts: Number on which to sample Euler angles.
-    @param coll_bttm: The lowermost height for which to detect a collision
+    @param min_coll_height: The lowermost height for which to detect a collision
     @param norm_vect: The vector perpendicular to the surface.
     @param slab_nghbs: Number of neigbors in the surface.
     @param molec_nghbs: Number of neighbors in the molecule.
@@ -199,7 +202,7 @@ def correct_coll(molec, slab, ctr_coord, site_coord, num_pts,
                            center=ctr_coord)
         add_adsorbate(slab_molec, molec, site_coord, ctr_coord, 2.5,
                       norm_vect=norm_vect)
-        collision = check_collision(slab_molec, slab_num_atoms, coll_bttm,
+        collision = check_collision(slab_molec, slab_num_atoms, min_coll_height,
                                     norm_vect, slab_nghbs, molec_nghbs,
                                     coll_coeff)
         num_corr += 1
@@ -207,7 +210,7 @@ def correct_coll(molec, slab, ctr_coord, site_coord, num_pts,
 
 
 def ads_euler(orig_molec, slab, ctr_coord, site_coord, num_pts,
-              coll_bttm, coll_coeff, norm_vect, slab_nghbs, molec_nghbs):
+              min_coll_height, coll_coeff, norm_vect, slab_nghbs, molec_nghbs):
     """Generates adsorbate-surface structures by sampling over Euler angles.
 
     This function generates a number of adsorbate-surface structures at
@@ -220,7 +223,7 @@ def ads_euler(orig_molec, slab, ctr_coord, site_coord, num_pts,
     @param site_coord: The coordinates of the surface on which to adsorb the
         molecule
     @param num_pts: Number on which to sample Euler angles.
-    @param coll_bttm: The lowermost height for which to detect a collision
+    @param min_coll_height: The lowermost height for which to detect a collision
     @param coll_coeff: The coefficient that multiplies the covalent radius of
         atoms resulting in a distance that two atoms being closer to that is
         considered as atomic collision.
@@ -241,8 +244,11 @@ def ads_euler(orig_molec, slab, ctr_coord, site_coord, num_pts,
                 molec = deepcopy(orig_molec)
                 molec.euler_rotate(alpha, beta, gamma, center=ctr_coord)
                 slab_molec, collision = correct_coll(molec, slab,
-                    ctr_coord, site_coord, num_pts, coll_bttm, norm_vect,
-                    slab_nghbs, molec_nghbs, coll_coeff)
+                                                     ctr_coord, site_coord,
+                                                     num_pts, min_coll_height,
+                                                     norm_vect,
+                                                     slab_nghbs, molec_nghbs,
+                                                     coll_coeff)
                 if not collision:
                     slab_ads_list.append(slab_molec)
 
@@ -254,7 +260,7 @@ def ads_chemcat(site, ctr, pts_angle):
 
 
 def adsorb_confs(conf_list, surf, molec_ctrs, sites, algo, num_pts, neigh_ctrs,
-                 norm_vect, coll_bttm, coll_coeff):
+                 norm_vect, min_coll_height, coll_coeff):
     """Generates a number of adsorbate-surface structure coordinates.
 
     Given a list of conformers, a surface, a list of atom indices (or list of
@@ -270,7 +276,7 @@ def adsorb_confs(conf_list, surf, molec_ctrs, sites, algo, num_pts, neigh_ctrs,
     @param neigh_ctrs: the indices of the neighboring atoms to the adsorption
         atoms.
     @param norm_vect: The vector perpendicular to the surface.
-    @param coll_bttm: The lowermost height for which to detect a collision
+    @param min_coll_height: The lowermost height for which to detect a collision
     @param coll_coeff: The coefficient that multiplies the covalent radius of
         atoms resulting in a distance that two atoms being closer to that is
         considered as atomic collision.
@@ -279,18 +285,24 @@ def adsorb_confs(conf_list, surf, molec_ctrs, sites, algo, num_pts, neigh_ctrs,
     from ase.neighborlist import natural_cutoffs, neighbor_list
     surf_ads_list = []
     sites_coords = get_atom_coords(surf, sites)
-    surf_cutoffs = natural_cutoffs(surf, mult=coll_coeff)
-    surf_nghbs = len(neighbor_list("i", surf, surf_cutoffs))
+    if min_coll_height is not False:
+        surf_cutoffs = natural_cutoffs(surf, mult=coll_coeff)
+        surf_nghbs = len(neighbor_list("i", surf, surf_cutoffs))
+    else:
+        surf_nghbs = 0
     for conf in conf_list:
         molec_ctr_coords = get_atom_coords(conf, molec_ctrs)
         molec_neigh_coords = get_atom_coords(conf, neigh_ctrs)
-        conf_cutoffs = natural_cutoffs(conf, mult=coll_coeff)
-        molec_nghbs = len(neighbor_list("i", conf, conf_cutoffs))
+        if min_coll_height is not False:
+            conf_cutoffs = natural_cutoffs(conf, mult=coll_coeff)
+            molec_nghbs = len(neighbor_list("i", conf, conf_cutoffs))
+        else:
+            molec_nghbs = 0
         for site in sites_coords:
             for ctr in molec_ctr_coords:
                 if algo == 'euler':
                     surf_ads_list.extend(ads_euler(conf, surf, ctr, site,
-                                                   num_pts, coll_bttm,
+                                                   num_pts, min_coll_height,
                                                    coll_coeff, norm_vect,
                                                    surf_nghbs, molec_nghbs))
                 elif algo == 'chemcat':
@@ -332,6 +344,6 @@ def run_screening(inp_vars):
                                  inp_vars['sample_points_per_angle'],
                                  inp_vars['molec_neigh_ctrs'],
                                  inp_vars['surf_norm_vect'],
-                                 inp_vars['collision_bottom'],
+                                 inp_vars['min_coll_height'],
                                  inp_vars['collision_threshold'])
     run_calc('screening', inp_vars, surf_ads_list)
