def get_basis_info(self): """ Obtain basis set info from DALTON.BAS """ molecule = mol.readin(self.dalton_bas) self.cpa = mol.contracted_per_atom(molecule) self.cpa_l = mol.contracted_per_atom_l(molecule) self.opa = mol.occupied_per_atom(molecule) self.noa = len(self.opa) # # Total number of basis functions and occpied orbitals # self.nbf = sum(self.cpa) self.noc = 0 for o in self.opa: self.noc += len(o)
def get_basis_info(self): """ Obtain basis set info from DALTON.BAS """ molecule = mol.readin(self.dalton_bas) self.cpa = mol.contracted_per_atom(molecule) self.cpa_l = mol.contracted_per_atom_l(molecule) self.opa = mol.occupied_per_atom(molecule) self.noa = len(self.opa) # # Total number of basis functions and occupied orbitals # self.nbf = sum(self.cpa) self.noc = 0 for o in self.opa: self.noc += len(o)
def set_cfunc(bf): """Return a list of contracted AO function objects """ from daltools import mol molecule = mol.readin(bf) cfunc = [] for atom in molecule: for center in atom['center']: for l, lblock in enumerate(atom['basis']): for block in lblock: #pe = np.array(block['prim']) pe = block['prim'] cc = np.array(block['cont']) for c in range(cc.shape[1]): cfunc.append( generate_contracted(l, pe, cc[:, c], center)) return cfunc
def setup(self): self.tmpdir = tmpdir(__file__) dalton_bas = self.tmpdir/"DALTON.BAS" self.bas = mol.readin(dalton_bas) self.maxDiff = None
def calculate_uhf( dalton_tmpdir, hamiltonian=None, spin=None, operator_label=None, operator=None, source_moenergies=None, source_mocoeffs=None, source_operator=None, ): if operator_label: # TODO add dipvel assert operator_label in ("dipole", "angmom", "spinorb") assert source_moenergies in ("pyscf", "dalton") assert source_mocoeffs in ("pyscf", "dalton") dalton_molecule = dalmol.readin(dalton_tmpdir / "DALTON.BAS") lines = [] for atom in dalton_molecule: label = atom["label"][0] center = atom["center"][0] center_str = " ".join(["{:f}".format(pos) for pos in center]) line = "{:3} {}".format(label, center_str) lines.append(line) lines = "\n".join(lines) # PySCF molecule setup, needed for generating the TEIs in the MO # basis. mol = pyscf.gto.Mole() verbose = 1 mol.verbose = verbose mol.atom = lines mol.unit = "Bohr" # TODO read basis from DALTON molecule mol.basis = "sto-3g" mol.symmetry = False # TODO read charge from DALTON molecule? mol.charge = 1 # TODO read spin from DALTON molecule? mol.spin = 1 mol.build() ifc = sirifc.sirifc(dalton_tmpdir / "SIRIFC") occupations = utils.occupations_from_sirifc(ifc) if source_moenergies == "pyscf" or source_mocoeffs == "pyscf": mf = pyscf.scf.UHF(mol) mf.kernel() if source_moenergies == "pyscf": E_alph = np.diag(mf.mo_energy[0]) E_beta = np.diag(mf.mo_energy[1]) E = np.stack((E_alph, E_beta), axis=0) elif source_moenergies == "dalton": job = ccopen(dalton_tmpdir / "DALTON.OUT") data = job.parse() # pylint: disable=no-member E = np.diag([ convertor(x, "eV", "hartree") for x in data.moenergies[0] ])[np.newaxis, ...] E = np.concatenate((E, E), axis=0) else: pass if source_mocoeffs == "pyscf": C = mf.mo_coeff elif source_mocoeffs == "dalton": C = ifc.cmo[0][np.newaxis, ...] C = np.concatenate((C, C), axis=0) else: pass solver = iterators.ExactInv(C, E, occupations) solver.tei_mo = ao2mo.perform_tei_ao2mo_uhf_partial(mol, C) solver.tei_mo_type = "partial" driver = cphf.CPHF(solver) if operator: driver.add_operator(operator) elif operator_label: if operator_label == "dipole": operator_dipole = operators.Operator(label="dipole", is_imaginary=False, is_spin_dependent=False, triplet=False) integrals_dipole_ao = mol.intor("cint1e_r_sph", comp=3) operator_dipole.ao_integrals = integrals_dipole_ao driver.add_operator(operator_dipole) elif operator_label == "angmom": operator_angmom = operators.Operator(label="angmom", is_imaginary=True, is_spin_dependent=False, triplet=False) integrals_angmom_ao = mol.intor("cint1e_cg_irxp_sph", comp=3) operator_angmom.ao_integrals = integrals_angmom_ao driver.add_operator(operator_angmom) elif operator_label == "spinorb": operator_spinorb = operators.Operator(label="spinorb", is_imaginary=True, is_spin_dependent=False, triplet=False) integrals_spinorb_ao = 0 for atm_id in range(mol.natm): mol.set_rinv_orig(mol.atom_coord(atm_id)) chg = mol.atom_charge(atm_id) integrals_spinorb_ao += chg * mol.intor("cint1e_prinvxp_sph", comp=3) operator_spinorb.ao_integrals = integrals_spinorb_ao driver.add_operator(operator_spinorb) else: pass else: pass driver.set_frequencies() driver.run(solver_type="exact", hamiltonian=hamiltonian, spin=spin) return driver.results[0]