Révision 0d7be691
b/modules/add_adsorbate_euler+dissociation.py | ||
---|---|---|
9 | 9 |
from ase.io import read |
10 | 10 |
from ase.io import write |
11 | 11 |
from ase import Atom |
12 |
from ase import Atoms |
|
12 | 13 |
from ase import build |
13 | 14 |
from ase.build import add_adsorbate |
14 | 15 |
from ase import constraints |
... | ... | |
43 | 44 |
angle = np.arccos(np.sign(norm_dot) if np.abs(norm_dot) >= 1 else norm_dot) |
44 | 45 |
return(angle*180/np.pi if degrees else angle) |
45 | 46 |
|
47 |
|
|
48 |
#################################################### |
|
49 |
# Re-definition of the add-adsorbate function of ase |
|
50 |
#################################################### |
|
51 |
|
|
52 |
def new_add_adsorbate(slab, adsorbate, height, position=(0, 0, 0), offset=None, mol_index=0): |
|
53 |
# works as the add_adsorbate fonction of ase but takes into account not only |
|
54 |
# the x and y coordinates of the adsorption site but also the z in order to |
|
55 |
# put the adsorbate at a given distance above the adsorption site (and not at |
|
56 |
# a given height above the highest point of the surface) |
|
57 |
# |
|
58 |
# Sarah Blanck 22/01/2020 |
|
59 |
|
|
60 |
info = slab.info.get('adsorbate_info', {}) |
|
61 |
pos = np.array([0.0, 0.0]) # (x, y) part |
|
62 |
pos2 = np.array([0.0, 0.0, 0.0]) # (x, y, z) part |
|
63 |
spos = np.array([0.0, 0.0]) # part relative to unit cell |
|
64 |
if offset is not None: |
|
65 |
spos += np.asarray(offset, float) |
|
66 |
if isinstance(position, basestring): |
|
67 |
# A site-name: |
|
68 |
if 'sites' not in info: |
|
69 |
raise TypeError('If the atoms are not made by an ' + 'ase.build function, ' + 'position cannot be a name.') |
|
70 |
if position not in info['sites']: |
|
71 |
raise TypeError('Adsorption site %s not supported.' % position) |
|
72 |
spos += info['sites'][position] |
|
73 |
else: |
|
74 |
pos2 += position |
|
75 |
pos += [pos2[0], pos2[1]] |
|
76 |
if 'cell' in info: |
|
77 |
cell = info['cell'] |
|
78 |
else: |
|
79 |
cell = slab.get_cell()[:2, :2] |
|
80 |
pos += np.dot(spos, cell) |
|
81 |
# Convert the adsorbate to an Atoms object |
|
82 |
if isinstance(adsorbate, Atoms): |
|
83 |
ads = adsorbate |
|
84 |
elif isinstance(adsorbate, Atom): |
|
85 |
ads = Atoms([adsorbate]) |
|
86 |
else: |
|
87 |
# Assume it is a string representing a single Atom |
|
88 |
ads = Atoms([Atom(adsorbate)]) |
|
89 |
# Get the z-coordinate: |
|
90 |
z = pos2[2] + height |
|
91 |
# Move adsorbate into position |
|
92 |
ads.translate([pos[0], pos[1], z] - ads.positions[mol_index]) |
|
93 |
# Attach the adsorbate |
|
94 |
slab.extend(ads) |
|
95 |
|
|
96 |
|
|
97 |
########################################################### |
|
98 |
# Definition of PBC conditions for molecules on the surface |
|
99 |
########################################################### |
|
100 |
|
|
46 | 101 |
def point_in_cell(p,h_matrix): |
47 | 102 |
# This function checks wether a given point defined by [x,y,z] is inside a |
48 | 103 |
# given cell defined by h_matrix=[a,b,c] where a=[xa,ya,za], b=[xb,yb,zb], |
... | ... | |
112 | 167 |
|
113 | 168 |
return collision |
114 | 169 |
|
170 |
|
|
115 | 171 |
########################################## |
116 | 172 |
# Lecture des différents arguments de base |
117 | 173 |
########################################## |
... | ... | |
309 | 365 |
|
310 | 366 |
distance = distance - z_max_ads_1 + surf_atom_z |
311 | 367 |
|
312 |
add_adsorbate(surface, molecule, distance, (x_atom_surf_1,y_atom_surf_1), mol_index=atom_molecule)
|
|
368 |
new_add_adsorbate(surface, molecule, distance, (x_atom_surf_1,y_atom_surf_1,z_atom_surf_1), mol_index=atom_molecule)
|
|
313 | 369 |
|
314 | 370 |
out=output+".xyz" |
315 | 371 |
write(out, surface) |
... | ... | |
364 | 420 |
else: |
365 | 421 |
translation_matrix_dissociation.append(vector_H_diss) |
366 | 422 |
molecule.translate(translation_matrix_dissociation) |
367 |
add_adsorbate(surface, molecule, distance, (x_atom_surf_1,y_atom_surf_1), mol_index=atom_molecule)
|
|
423 |
new_add_adsorbate(surface, molecule, distance, (x_atom_surf_1,y_atom_surf_1,z_atom_surf_1), mol_index=atom_molecule)
|
|
368 | 424 |
output_diss = output + "_diss_" + str(i) + ".xyz" |
369 | 425 |
write(output_diss, surface) |
370 | 426 |
|
Formats disponibles : Unified diff