Skip to content
Snippets Groups Projects
Commit 62d79faa authored by Kai Sellschopp's avatar Kai Sellschopp
Browse files

added a min_dist check for the side chains, so they don't overlap with...

added a min_dist check for the side chains, so they don't overlap with themselves or other atoms. the point in the code where this is done can be improved though...
parent c622d6df
No related branches found
No related tags found
No related merge requests found
......@@ -192,12 +192,28 @@ class CodeRed:
ad_structure = surf + Atoms(species, comb)
# calculate and add side chains, if any
min_dist_valid = True
for i in range(len(self.sideChains)):
sc = self.sideChains[i].calc_positions(len(surf)+sc_connect_indices[i], ad_structure)
ad_structure = ad_structure + sc
# check minimum distances
n_sc_atoms = len(sc)
dist_matrix = ad_structure.get_all_distances(mic=True)
# 1. check self interaction with periodic images
# (this construct gives all distances between sc_atoms in the combined unit cell)
if np.any(dist_matrix[-n_sc_atoms:,-n_sc_atoms:][np.triu_indices(n_sc_atoms,1)] < self.min_dist):
min_dist_valid = False
break
# 2. check distance to other atoms
# (this construct gives all distances of sc_atoms to other atoms in the structure)
elif np.any(dist_matrix[-n_sc_atoms:,:-n_sc_atoms] < self.min_dist):
min_dist_valid = False
break
# add to structure list
structures.append(ad_structure)
if min_dist_valid:
structures.append(ad_structure)
return structures
......
......@@ -190,6 +190,8 @@ class SideChain:
self.mode = mode
self.nn_cutoff = nn_cutoff
self.min_dist = min_dist
if self.min_dist > self.distance:
print('WARNING! The distance attribute should not be smaller than the min_dist attribute!')
def calc_positions(self, anchor_index, structure):
......@@ -227,6 +229,6 @@ class SideChain:
# calculate and set new positions
sc_atoms.set_positions(anchor + self.distance*sc_dir + np.dot(sc_atoms.get_positions(),R))
# return the side chain adapted to the given environment
return sc_atoms
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment