def reference_mol(mol, minao=MINAO): '''Create a molecule which uses reference minimal basis''' pmol = mol.copy() atoms = [atom for atom in gto.format_atom(pmol.atom, unit=1)] # remove ghost atoms pmol.atom = [atom for atom in atoms if not is_ghost_atom(atom[0])] if len(pmol.atom) != len(atoms): logger.info( mol, 'Ghost atoms found in system. ' 'Current IAO does not support ghost atoms. ' 'They are removed from IAO reference basis.') if getattr(pmol, 'rcut', None) is not None: pmol.rcut = None pmol.build(False, False, basis=minao) return pmol
def create_mm_mol(atoms_or_coords, charges=None, unit='Angstrom'): '''Create an MM object based on the given coordinates and charges of MM particles. ''' if isinstance(atoms_or_coords, numpy.ndarray): # atoms_or_coords == np.array([(xx, xx, xx)]) # Patch ghost atoms atoms = [(0, c) for c in atoms_or_coords] elif (isinstance(atoms_or_coords, (list, tuple)) and atoms_or_coords and isinstance(atoms_or_coords[0][1], (int, float))): # atoms_or_coords == [(xx, xx, xx)] # Patch ghost atoms atoms = [(0, c) for c in atoms_or_coords] else: atoms = atoms_or_coords atoms = gto.format_atom(atoms, unit=unit) return Mole(atoms, charges)
def guess_frag(xyz, frags, chgs, spins, gjfhead, scrfhead, gjfname, basis, wfnpath): ''' frags: e.g. [[1], [2]] for N2 chgs: e.g. [0, 0] for N2 spins: e.g. [3, -3] for N2 ''' #mol.build() print('**** generating fragments ****') atom = gto.format_atom(xyz, unit=1) #print(atom) #fraga, fragb = frags #chga, chgb = chgs #spina, spinb = spins allatom = range(1, len(atom) + 1) for k in range(len(frags)): frag = frags[k] chg = chgs[k] spin = spins[k] g_spin = spin_p2g(spin) atomk = [atom[i - 1] for i in frag] atomother = [atom[i - 1] for i in allatom if i not in frag] print('fragment %d, chg %d, spin %d' % (k, chg, spin)) #print(atomk) with open(gjfname + '%d.gjf' % k, 'w') as f: f.write(gjfhead) f.write('%d %d\n' % (chg, g_spin)) for a in atomk: f.write('%s %10.5f %10.5f %10.5f\n' % (a[0], a[1][0], a[1][1], a[1][2])) #f.write('\n') if basis is not None: f.write(basis) #f.write('\n') f.write(scrfhead) f.write('ExtraSph=%d\n\n' % len(atomother)) for b in atomother: rad = radii.uff_radii[b[0]] / 2.0 f.write(' %10.5f %10.5f %10.5f %10.5f\n' % (b[1][0], b[1][1], b[1][2], rad)) f.write('\n') if wfnpath is not None: f.write(wfnpath + '%d.wfn' % k + '\n') f.write('\n')
)], [1, ( 0., -.757, 0.587, )], [1, ( 0., 0.757, 0.587, )]] h2o.basis = { 'H': 'cc-pvdz', 'O': 'cc-pvdz', } h2o.build() gpname, origin, axes = geom.detect_symm(h2o._atom) atoms = gto.format_atom(h2o._atom, origin, axes) h2o.build(False, False, atom=atoms) print(gpname) eql_atoms = geom.symm_identical_atoms(gpname, atoms) print(symm_adapted_basis(h2o, gpname, eql_atoms)[1]) mol = gto.M(atom=[['H', (0, 0, 0)], ['H', (0, 0, -1)], ['H', (0, 0, 1)]], basis='ccpvtz', charge=1) gpname, orig, axes = geom.detect_symm(mol._atom) atoms = gto.format_atom(mol._atom, orig, axes) mol.build(False, False, atom=atoms) print(gpname) eql_atoms = geom.symm_identical_atoms(gpname, atoms) print(symm_adapted_basis(mol, gpname, eql_atoms)[1])
def rigid(internal, var, vrange, unit=1): for v in vrange: newint = internal.replace(var, '%f'%v) newcart = gto.format_atom(newint, unit=unit) newcart = atm2str(newcart) print(newcart)
return so, irrep_ids if __name__ == "__main__": from pyscf import gto h2o = gto.Mole() h2o.verbose = 0 h2o.output = None h2o.atom = [['O' , (1. , 0. , 0. ,)], [1 , (0. , -.757 , 0.587,)], [1 , (0. , 0.757 , 0.587,)] ] h2o.basis = {'H': 'cc-pvdz', 'O': 'cc-pvdz',} h2o.build() gpname, origin, axes = geom.detect_symm(h2o._atom) atoms = gto.format_atom(h2o._atom, origin, axes) h2o.build(False, False, atom=atoms) print(gpname) eql_atoms = geom.symm_identical_atoms(gpname, atoms) print(symm_adapted_basis(h2o, gpname, eql_atoms)[1]) mol = gto.M( atom = [['H', (0,0,0)], ['H', (0,0,-1)], ['H', (0,0,1)]], basis = 'ccpvtz', charge=1) gpname, orig, axes = geom.detect_symm(mol._atom) atoms = gto.format_atom(mol._atom, orig, axes) mol.build(False, False, atom=atoms) print(gpname) eql_atoms = geom.symm_identical_atoms(gpname, atoms) print(symm_adapted_basis(mol, gpname, eql_atoms)[1])