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
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)
def test_scf_epc17_2(self): mf = neo.CDFT(mol, epc='17-2') mf.max_cycle = 1000 self.assertAlmostEqual(mf.scf(), -93.3661447224845, 6)
def test_scf_epc17_1(self): mf = neo.CDFT(mol, epc='17-1') pass
def test_scf_noepc(self): mf = neo.CDFT(mol, epc=None) self.assertAlmostEqual(mf.scf(), -93.3384022881535, 6) self.assertAlmostEqual(mf.f[0][-1], -4.03031884e-02, 5)