def make_molecule(self): mol = Mole() mol.atom = """ O 0 0 0 H 1 0 0 H 0 1 0 """ mol.basis = "sto-3g" mol.build() return mol
def setUpModule(): global mol, mf mol = Mole() mol.atom = ''' C 0.681068338 0.605116159 0.307300799 C -0.733665805 0.654940451 -0.299036438 C -1.523996730 -0.592207689 0.138683275 H 0.609941801 0.564304456 1.384183068 H 1.228991034 1.489024155 0.015946420 H -1.242251083 1.542928348 0.046243898 H -0.662968178 0.676527364 -1.376503770 H -0.838473936 -1.344174292 0.500629028 H -2.075136399 -0.983173387 -0.703807608 H -2.212637905 -0.323898759 0.926200671 O 1.368219958 -0.565620846 -0.173113101 H 2.250134219 -0.596689848 0.204857736 ''' mol.basis = 'STO-3G' mol.verbose = 0 mol.output = None mol.build() mf = RHF(mol) mf.conv_tol = 1.0e-12 mf.kernel()
mol = Mole() mol.atom = ''' C 0.681068338 0.605116159 0.307300799 C -0.733665805 0.654940451 -0.299036438 C -1.523996730 -0.592207689 0.138683275 H 0.609941801 0.564304456 1.384183068 H 1.228991034 1.489024155 0.015946420 H -1.242251083 1.542928348 0.046243898 H -0.662968178 0.676527364 -1.376503770 H -0.838473936 -1.344174292 0.500629028 H -2.075136399 -0.983173387 -0.703807608 H -2.212637905 -0.323898759 0.926200671 O 1.368219958 -0.565620846 -0.173113101 H 2.250134219 -0.596689848 0.204857736 ''' mol.basis = 'STO-3G' mol.verbose = 0 mol.output = None mol.build() mf = RHF(mol) mf.conv_tol = 1.0e-12 mf.kernel() class KnownValues(unittest.TestCase): def setUp(self): self.mol = mol.copy() self.mo_coeff = mf.mo_coeff.copy() self.nocc = numpy.count_nonzero(mf.mo_occ > 0) self.rdm1_rhf = mf.make_rdm1()
# ''' DF-MP2 natural orbitals for the allyl radical ''' from pyscf.gto import Mole from pyscf.scf import UHF from pyscf.tools import molden from pyscf.mp.dfump2_native import DFMP2 mol = Mole() mol.atom = ''' C -1.1528 -0.1151 -0.4645 C 0.2300 -0.1171 -0.3508 C 0.9378 0.2246 0.7924 H 0.4206 0.5272 1.7055 H 2.0270 0.2021 0.8159 H -1.6484 -0.3950 -1.3937 H -1.7866 0.1687 0.3784 H 0.8086 -0.4120 -1.2337 ''' mol.basis = 'def2-TZVP' mol.spin = 1 mol.build() mf = UHF(mol).run() # MP2 natural occupation numbers and natural orbitals natocc, natorb = DFMP2(mf).make_natorbs() # store the natural orbitals in a molden file molden.from_mo(mol, 'allyl_mp2nat.molden', natorb, occ=natocc)
''' from numpy.linalg import norm from pyscf.gto import Mole from pyscf.scf import RHF from pyscf.mp.dfmp2_native import DFMP2 mol = Mole() mol.atom = ''' C 0.000000 0.000000 0.000000 Cl 0.000000 0.000000 1.785000 H 1.019297 0.000000 -0.386177 H -0.509649 0.882737 -0.386177 H -0.509649 -0.882737 -0.386177 ''' mol.basis = 'aug-cc-pVTZ' mol.build() mf = RHF(mol).run() pt = DFMP2(mf).run() # The unrelaxed density always has got natural occupation numbers between 2 and 0. # However, it is inaccurate for properties. dm_ur = pt.make_rdm1_unrelaxed(ao_repr=True) # The relaxed density is more accurate for properties when MP2 is well-behaved, # whereas the natural occupation numbers can be above 2 or below 0 for ill-behaved systems. dm_re = pt.make_rdm1_relaxed(ao_repr=True) print('') print('HF dipole moment:')
mol = Mole() mol.atom = ''' C 0.681068338 0.605116159 0.307300799 C -0.733665805 0.654940451 -0.299036438 C -1.523996730 -0.592207689 0.138683275 H 0.609941801 0.564304456 1.384183068 H 1.228991034 1.489024155 0.015946420 H -1.242251083 1.542928348 0.046243898 H -0.662968178 0.676527364 -1.376503770 H -0.838473936 -1.344174292 0.500629028 H -2.075136399 -0.983173387 -0.703807608 H -2.212637905 -0.323898759 0.926200671 O 1.368219958 -0.565620846 -0.173113101 H 2.250134219 -0.596689848 0.204857736 ''' mol.basis = 'def2-SVP' mol.build() # Perform a Hartree-Fock calculation mf = RHF(mol) mf.kernel() # determine the number of occupied orbitals nocc = numpy.count_nonzero(mf.mo_occ > 0) # localize the occupied orbitals separately lmo_occ = cholesky_mos(mf.mo_coeff[:, :nocc]) # localize the virtual orbitals separately lmo_virt = cholesky_mos(mf.mo_coeff[:, nocc:]) # merge the MO coefficients in one matrix lmo_merged = numpy.hstack((lmo_occ, lmo_virt)) # dump the merged MO coefficients in a molden file