Révision 16 ase/embed.py

embed.py (revision 16)
16 16

  
17 17
class Embed(Atoms):
18 18
    #--- constructor of the Embed class ---
19
    def __init__(self, system, cluster, cell_cluster = "Auto", cluster_pos = True):
19
    def __init__(self, system, cluster, cell_cluster = "Auto", cluster_pos = True, linkType = 'H'):
20 20
        super(Embed, self).__init__()
21 21
        # define the atom map
22 22
        self.atom_map_sys_cl = []
......
39 39
        # set the cell of the system
40 40
        self.set_cell(system.get_cell())
41 41
        self.cell_cluster = cell_cluster
42
        
43
        self.embed(linkType)
42 44
        return
43 45

  
44 46
    #--- set the cluster ---
......
98 100
        return self.atoms_system
99 101

  
100 102
    #--- Embedding ---
101
    def embed(self):
103
    def embed(self, linkType):
102 104
        # is the cluster and the host system definied ?
103 105
        if self.atoms_cluster is None or self.atoms_system is None:
104 106
            return
105 107
        self.find_cluster()
106
        self.set_linkatoms()
108
        self.set_linkatoms(linkType)
107 109
        print "link atoms found: ", len(self.linkatoms)
108 110
        if self.cell_cluster == "System":
109 111
            self.atoms_cluster.set_cell(self.atoms_system.get_cell())
......
165 167
            if bSysOnly:
166 168
                self.atom_map_sys_cl[iat_sys] = -1
167 169

  
168
    def set_linkatoms(self, tol=15., linkAtom=None, debug=False):
170
    def set_linkatoms(self, linkType, tol=15.):
169 171
        # local copies of xyz coordinates to avoid massive copying of xyz objects
170 172
        xyzs_cl=[]
171 173
        for atom_cl in self.atoms_cluster:
......
173 175
        xyzs_sys=[]
174 176
        for atom_sys in self.atoms_system:
175 177
            xyzs_sys.append(atom_sys.get_position())
176
        # set the standard link atom
177
        if linkAtom is None:
178
            linkAtom ='H'
179 178
        # number of atoms in the cluster and the system
180 179
        nat_cl=len(self.atoms_cluster)
181 180
        nat_sys=len(self.atoms_system)
......
235 234
                    r = np.sqrt(np.dot(xyz_diff, xyz_diff))
236 235
                    # ratio of the distance to the sum of covalent radius
237 236
                    f = r / (r_cl + r_sys)
238
                    if debug:
239
                        print "Covalent radii = ",r_cl, r_sys
240
                        print "Distance ", f
241
                        print "tol = ",(1+tol/100.),(1-tol/100.),(1-2*tol/100.)
242 237
                    if f <= (1+tol/100.) and f >= (1-2*tol/100.):
243 238
                        s = cell_L, self.atom_map_cl_sys[iat_cl], iat_sys, r_cl
244 239
                        bonds.append(s)
......
246 241
                    if f <= (1-2*tol/100.):
247 242
                        raise RuntimeError("QMX: The cluster atom", iat_cl, " and the system atom", iat_sys, "came too close")
248 243

  
249
        r_h = covalent_radii[atomic_numbers[linkAtom]]
244
        r_h = covalent_radii[atomic_numbers[linkType]]
250 245
        for bond in bonds:
251 246
            cell_L, iat_cl_sys, iat_sys, r_cl = bond
252 247
            # assign the tags for the border atoms
......
259 254
            # determine position of the link atom
260 255
            xyz_diff += xyzs_sys[iat_cl_sys]
261 256
            # create link atom
262
            atom = Atom(symbol=linkAtom, position=xyz_diff, tag=50)
257
            atom = Atom(symbol=linkType, position=xyz_diff, tag=50)
263 258
            # add atom to cluster
264 259
            self.atoms_cluster.append(atom)
265 260
            # add atom to the linkatoms

Formats disponibles : Unified diff