Révision 5fb01677 modules/screening.py
b/modules/screening.py | ||
---|---|---|
148 | 148 |
@return: bool, whether the surface and the molecule collide. |
149 | 149 |
""" |
150 | 150 |
from ase.neighborlist import natural_cutoffs, neighbor_list |
151 |
if (vect == np.array([1.0, 0.0, 0.0])).all \ |
|
152 |
or (vect == np.array([0.0, 1.0, 0.0])).all \ |
|
153 |
or (vect == np.array([0.0, 0.0, 1.0])).all: |
|
154 |
for atom in slab_molec[slab_num_atoms:]: |
|
155 |
if np.linalg.norm(atom.position * vect) < min_height: |
|
156 |
return True |
|
157 |
slab_molec_cutoffs = natural_cutoffs(slab_molec, mult=coll_coeff) |
|
158 |
slab_molec_nghbs = len(neighbor_list("i", slab_molec, slab_molec_cutoffs)) |
|
159 |
if slab_molec_nghbs > nn_slab + nn_molec: |
|
160 |
return True |
|
151 |
if min_height is not False: |
|
152 |
cart_coords = [[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]] |
|
153 |
if list(map(abs, vect.tolist())) in cart_coords: |
|
154 |
for atom in slab_molec[slab_num_atoms:]: |
|
155 |
if np.linalg.norm(atom.position * vect) < min_height: |
|
156 |
# TODO Check norm when there are negative values |
|
157 |
return True |
|
161 | 158 |
else: |
162 |
return False |
|
159 |
slab_molec_cutoffs = natural_cutoffs(slab_molec, mult=coll_coeff) |
|
160 |
slab_molec_nghbs = len(neighbor_list("i", slab_molec, slab_molec_cutoffs)) |
|
161 |
if slab_molec_nghbs > nn_slab + nn_molec: |
|
162 |
return True |
|
163 |
else: |
|
164 |
return False |
|
163 | 165 |
|
164 | 166 |
|
165 | 167 |
def correct_coll(molec, slab, ctr_coord, site_coord, num_pts, |
166 |
coll_bttm, norm_vect, slab_nghbs, molec_nghbs, coll_coeff): |
|
168 |
min_coll_height, norm_vect, slab_nghbs, molec_nghbs, |
|
169 |
coll_coeff): |
|
167 | 170 |
# TODO Rethink this function |
168 | 171 |
"""Tries to adsorb a molecule on a slab trying to avoid collisions by doing |
169 | 172 |
small rotations. |
... | ... | |
176 | 179 |
@param site_coord: The coordinates of the surface on which to adsorb the |
177 | 180 |
molecule |
178 | 181 |
@param num_pts: Number on which to sample Euler angles. |
179 |
@param coll_bttm: The lowermost height for which to detect a collision
|
|
182 |
@param min_coll_height: The lowermost height for which to detect a collision
|
|
180 | 183 |
@param norm_vect: The vector perpendicular to the surface. |
181 | 184 |
@param slab_nghbs: Number of neigbors in the surface. |
182 | 185 |
@param molec_nghbs: Number of neighbors in the molecule. |
... | ... | |
199 | 202 |
center=ctr_coord) |
200 | 203 |
add_adsorbate(slab_molec, molec, site_coord, ctr_coord, 2.5, |
201 | 204 |
norm_vect=norm_vect) |
202 |
collision = check_collision(slab_molec, slab_num_atoms, coll_bttm,
|
|
205 |
collision = check_collision(slab_molec, slab_num_atoms, min_coll_height,
|
|
203 | 206 |
norm_vect, slab_nghbs, molec_nghbs, |
204 | 207 |
coll_coeff) |
205 | 208 |
num_corr += 1 |
... | ... | |
207 | 210 |
|
208 | 211 |
|
209 | 212 |
def ads_euler(orig_molec, slab, ctr_coord, site_coord, num_pts, |
210 |
coll_bttm, coll_coeff, norm_vect, slab_nghbs, molec_nghbs):
|
|
213 |
min_coll_height, coll_coeff, norm_vect, slab_nghbs, molec_nghbs):
|
|
211 | 214 |
"""Generates adsorbate-surface structures by sampling over Euler angles. |
212 | 215 |
|
213 | 216 |
This function generates a number of adsorbate-surface structures at |
... | ... | |
220 | 223 |
@param site_coord: The coordinates of the surface on which to adsorb the |
221 | 224 |
molecule |
222 | 225 |
@param num_pts: Number on which to sample Euler angles. |
223 |
@param coll_bttm: The lowermost height for which to detect a collision
|
|
226 |
@param min_coll_height: The lowermost height for which to detect a collision
|
|
224 | 227 |
@param coll_coeff: The coefficient that multiplies the covalent radius of |
225 | 228 |
atoms resulting in a distance that two atoms being closer to that is |
226 | 229 |
considered as atomic collision. |
... | ... | |
241 | 244 |
molec = deepcopy(orig_molec) |
242 | 245 |
molec.euler_rotate(alpha, beta, gamma, center=ctr_coord) |
243 | 246 |
slab_molec, collision = correct_coll(molec, slab, |
244 |
ctr_coord, site_coord, num_pts, coll_bttm, norm_vect, |
|
245 |
slab_nghbs, molec_nghbs, coll_coeff) |
|
247 |
ctr_coord, site_coord, |
|
248 |
num_pts, min_coll_height, |
|
249 |
norm_vect, |
|
250 |
slab_nghbs, molec_nghbs, |
|
251 |
coll_coeff) |
|
246 | 252 |
if not collision: |
247 | 253 |
slab_ads_list.append(slab_molec) |
248 | 254 |
|
... | ... | |
254 | 260 |
|
255 | 261 |
|
256 | 262 |
def adsorb_confs(conf_list, surf, molec_ctrs, sites, algo, num_pts, neigh_ctrs, |
257 |
norm_vect, coll_bttm, coll_coeff):
|
|
263 |
norm_vect, min_coll_height, coll_coeff):
|
|
258 | 264 |
"""Generates a number of adsorbate-surface structure coordinates. |
259 | 265 |
|
260 | 266 |
Given a list of conformers, a surface, a list of atom indices (or list of |
... | ... | |
270 | 276 |
@param neigh_ctrs: the indices of the neighboring atoms to the adsorption |
271 | 277 |
atoms. |
272 | 278 |
@param norm_vect: The vector perpendicular to the surface. |
273 |
@param coll_bttm: The lowermost height for which to detect a collision
|
|
279 |
@param min_coll_height: The lowermost height for which to detect a collision
|
|
274 | 280 |
@param coll_coeff: The coefficient that multiplies the covalent radius of |
275 | 281 |
atoms resulting in a distance that two atoms being closer to that is |
276 | 282 |
considered as atomic collision. |
... | ... | |
279 | 285 |
from ase.neighborlist import natural_cutoffs, neighbor_list |
280 | 286 |
surf_ads_list = [] |
281 | 287 |
sites_coords = get_atom_coords(surf, sites) |
282 |
surf_cutoffs = natural_cutoffs(surf, mult=coll_coeff) |
|
283 |
surf_nghbs = len(neighbor_list("i", surf, surf_cutoffs)) |
|
288 |
if min_coll_height is not False: |
|
289 |
surf_cutoffs = natural_cutoffs(surf, mult=coll_coeff) |
|
290 |
surf_nghbs = len(neighbor_list("i", surf, surf_cutoffs)) |
|
291 |
else: |
|
292 |
surf_nghbs = 0 |
|
284 | 293 |
for conf in conf_list: |
285 | 294 |
molec_ctr_coords = get_atom_coords(conf, molec_ctrs) |
286 | 295 |
molec_neigh_coords = get_atom_coords(conf, neigh_ctrs) |
287 |
conf_cutoffs = natural_cutoffs(conf, mult=coll_coeff) |
|
288 |
molec_nghbs = len(neighbor_list("i", conf, conf_cutoffs)) |
|
296 |
if min_coll_height is not False: |
|
297 |
conf_cutoffs = natural_cutoffs(conf, mult=coll_coeff) |
|
298 |
molec_nghbs = len(neighbor_list("i", conf, conf_cutoffs)) |
|
299 |
else: |
|
300 |
molec_nghbs = 0 |
|
289 | 301 |
for site in sites_coords: |
290 | 302 |
for ctr in molec_ctr_coords: |
291 | 303 |
if algo == 'euler': |
292 | 304 |
surf_ads_list.extend(ads_euler(conf, surf, ctr, site, |
293 |
num_pts, coll_bttm,
|
|
305 |
num_pts, min_coll_height,
|
|
294 | 306 |
coll_coeff, norm_vect, |
295 | 307 |
surf_nghbs, molec_nghbs)) |
296 | 308 |
elif algo == 'chemcat': |
... | ... | |
332 | 344 |
inp_vars['sample_points_per_angle'], |
333 | 345 |
inp_vars['molec_neigh_ctrs'], |
334 | 346 |
inp_vars['surf_norm_vect'], |
335 |
inp_vars['collision_bottom'],
|
|
347 |
inp_vars['min_coll_height'],
|
|
336 | 348 |
inp_vars['collision_threshold']) |
337 | 349 |
run_calc('screening', inp_vars, surf_ads_list) |
Formats disponibles : Unified diff