Exemple #1
0
 def test_scf(self):
     mol = neo.Mole()
     mol.build(atom='''H 0 0 0; C 0 0 1.064; N 0 0 2.220''',
               basis='ccpvdz',
               quantum_nuc=[0])
     mf = neo.HF(mol)
     energy = mf.scf()
     self.assertAlmostEqual(energy, -92.8437063572664, 8)
Exemple #2
0
 def test_scf3(self):
     mol = neo.Mole()
     mol.build(atom='''H 0 0 0; C 0 0 1.064; N 0 0 2.220''',
               basis='ccpvdz',
               quantum_nuc=[0, 1, 2])
     mf = neo.HF(mol)
     energy = mf.scf()
     self.assertAlmostEqual(energy, -91.6090279376862, 8)
Exemple #3
0
 def test_scf2(self):
     mol = neo.Mole()
     mol.build(atom='''H 0 0 0; C 0 0 1.064; N 0 0 2.220''',
               basis='ccpvdz',
               quantum_nuc=[0, 1])
     mf = neo.HF(mol)
     energy = mf.scf()
     self.assertAlmostEqual(energy, -92.3015848917516, 8)
Exemple #4
0
 def test_grad_cdft(self):
     mol = neo.Mole()
     mol.build(atom='''H 0 0 0; F 0 0 0.94''',
               basis='ccpvdz',
               quantum_nuc=[0])
     mf = neo.CDFT(mol)
     mf.scf()
     g = neo.Gradients(mf)
     grad = g.kernel()
     self.assertAlmostEqual(grad[0, -1], 0.0051324194, 6)
Exemple #5
0
def init_guess_nuc_by_calculation(mf_nuc, mol):
    """Generate initial dm"""
    dm_nuc = [None] * mol.nuc_num
    for i in range(mol.nuc_num):
        ia = mol.nuc[i].atom_index
        mol_tmp = neo.Mole()
        mol_tmp.build(atom=mol.atom,
                      charge=mol.charge,
                      spin=mol.spin,
                      quantum_nuc=[ia])
        dm_nuc[i] = get_init_guess_nuc(mf_nuc[i], mol_tmp.nuc[0])
    return dm_nuc
Exemple #6
0
    def calculate(self,
                  atoms=None,
                  properties=['energy', 'forces', 'dipole'],
                  system_changes=[
                      'positions', 'numbers', 'cell', 'pbc', 'charges',
                      'magmoms'
                  ]):
        Calculator.calculate(self, atoms, properties, system_changes)
        mol = neo.Mole()
        atoms = self.atoms.get_chemical_symbols()
        positions = self.atoms.get_positions()
        atom_pyscf = []
        for i in range(len(atoms)):
            if atoms[i] == 'Mu':
                atom_pyscf.append(['H@0', tuple(positions[i])])
            elif atoms[i] == 'D':
                atom_pyscf.append(['H@2', tuple(positions[i])])
            else:
                atom_pyscf.append(
                    ['%s%i' % (atoms[i], i),
                     tuple(positions[i])])
        mol.build(quantum_nuc=self.parameters.quantum_nuc,
                  atom=atom_pyscf,
                  basis=self.parameters.basis,
                  charge=self.parameters.charge,
                  spin=self.parameters.spin)
        if self.parameters.spin == 0:
            mf = neo.CDFT(mol)
        else:
            mf = neo.CDFT(mol, unrestricted=True)
        mf.mf_elec.xc = self.parameters.xc
        self.results['energy'] = mf.scf() * Hartree
        g = mf.Gradients()
        self.results['forces'] = -g.grad() * Hartree / Bohr

        dip_elec = dip_moment(
            mol.elec,
            mf.mf_elec.make_rdm1())  # dipole of electrons and classical nuclei
        dip_nuc = 0
        for i in range(len(mf.mf_nuc)):
            ia = mf.mf_nuc[i].mol.atom_index
            dip_nuc += mol.atom_charge(
                ia) * mf.mf_nuc[i].nuclei_expect_position * nist.AU2DEBYE

        self.results['dipole'] = dip_elec + dip_nuc
Exemple #7
0
#!/usr/bin/env python

import unittest
from pyscf import neo

mol = neo.Mole()
mol.build(atom='''H 0 0 0; C 0 0 1.064; N 0 0 2.220''',
          basis='ccpvdz',
          quantum_nuc=[0])


class KnownValues(unittest.TestCase):
    def test_scf_noepc(self):
        mf = neo.KS(mol, epc=None)
        self.assertAlmostEqual(mf.scf(), -93.3393561862119, 8)

    def test_scf_epc17_1(self):
        mf = neo.KS(mol, epc='17-1')
        mf.max_cycle = 2000
        self.assertAlmostEqual(mf.scf(), -93.3963856345767, 5)

    def test_scf_epc17_2(self):
        mf = neo.KS(mol, epc='17-2')
        mf.max_cycle = 1000
        self.assertAlmostEqual(mf.scf(), -93.3670499235643, 5)


if __name__ == "__main__":
    print("Full Tests for neo.ks")
    unittest.main()