示例#1
0
 def test_input_ecp(self):
     mol1 = gto.Mole()
     mol1.atom = mol0.atom
     mol1.ecp = 'lanl2dz'
     mol1.build(False, False)
     gto.basis.load_ecp('lanl08', 'O')
     gto.format_ecp({'O': 'lanl08', 1: 'lanl2dz'})
     self.assertRaises(KeyError, gto.format_ecp, {'H': 'lan2ldz'})
示例#2
0
 def test_input_ecp(self):
     mol1 = gto.Mole()
     mol1.atom = mol0.atom
     mol1.ecp = 'lanl2dz'
     mol1.build(False, False)
     gto.basis.load_ecp('lanl08', 'O')
     gto.format_ecp({'O':'lanl08', 1:'lanl2dz'})
     self.assertRaises(KeyError, gto.format_ecp, {'H':'lan2ldz'})
示例#3
0
def concat_mols(mol_list):
    """Concatenates Mole objects into one Mole.

    Parameters
    ----------
    mol_list : list
        List of Mole objects to concatenate into single Mole.
    """

    assert (len(mol_list) > 1), "Must have more than 1 mol object"

    total_spin = 0
    for i, mol_obj in enumerate(mol_list):
        mol1 = gto.mole.copy(mol_obj)
        total_spin += mol1.spin
        mol1.unit = 'bohr'
        atom_coords = mol1.atom_coords()
        mol1.atom = []
        uniq_atoms = set()
        for j, coord in enumerate(atom_coords):
            a_symb = mol1.atom_symbol(j) + '-' + str(i)
            uniq_atoms.add(a_symb)
            mol1.atom.append([a_symb, tuple(coord)])

        if isinstance(mol1.basis, (str, tuple, list)):
            new_basis = dict(((a, mol1.basis) for a in uniq_atoms))
        elif isinstance(mol1.basis, dict):
            old_basis = copy.copy(mol1.basis)
            new_basis = {}
            if 'default' in old_basis:
                default_basis = old_basis['default']
                new_basis = dict(((a, default_basis) for a in uniq_atoms))
                del old_basis['default']
            for atom_symb in old_basis:
                new_symb = atom_symb + '-' + str(i)
                new_basis[new_symb] = old_basis[atom_symb]
        else:
            new_basis = mol1.basis
        mol1.basis = gto.format_basis(new_basis)

        if mol1.ecp:
            if isinstance(mol1.ecp, str):
                new_ecp = dict(((a, str(mol1.ecp)) for a in uniq_atoms))
            elif isinstance(mol1.ecp, dict):
                old_ecp = copy.copy(mol1.ecp)
                if 'default' in old_ecp:
                    default_ecp = old_ecp['default']
                    new_ecp = dict(((a, default_ecp) for a in uniq_atoms))
                    del old_ecp['default']
                for atom_symb in old_ecp:
                    new_symb = atom_symb + '-' + str(i)
                    new_ecp[new_symb] = old_ecp[atom_symb]
            else:
                new_ecp = mol1.ecp
            mol1.ecp = gto.format_ecp(new_ecp)

        mol1.build()
        if i == 0:
            mol2 = gto.mole.copy(mol1)
        else:
            new_mol = gto.mole.conc_mol(mol2, mol1)
            new_mol.build()
            mol2 = new_mol

    conc_mol = mol2
    conc_mol.spin = total_spin  #check that this works properly.
    #Remove overlapping ghost atoms.
    final_mol = __remove_overlap_ghost(conc_mol)
    final_mol = conc_mol
    return final_mol