def test_uhf_energy_same_as_rhf(atomzs, dist, energy_true, variational): # test to see if uhf energy gets the same energy as rhf for non-polarized systems poss = torch.tensor([[-0.5, 0.0, 0.0], [0.5, 0.0, 0.0]], dtype=dtype) * dist mol = Mol((atomzs, poss), basis=basis, dtype=dtype) qc = HF(mol, restricted=False, variational=variational).run() ene = qc.energy() assert torch.allclose(ene, ene * 0 + energy_true, rtol=1e-8)
def test_uhf_energy_atoms(atomz, spin, energy_true, variational): # check the energy of atoms with non-0 spins torch.manual_seed(123) poss = torch.tensor([[0.0, 0.0, 0.0]], dtype=dtype) mol = Mol(([atomz], poss), basis=basis, dtype=dtype, spin=spin) qc = HF(mol, restricted=False, variational=variational).run() ene = qc.energy() assert torch.allclose(ene, ene * 0 + energy_true, atol=0.0, rtol=1e-7)
def get_energy(atomz, with_ii=True): atomzs = [atomz, atomz] poss = torch.tensor([[-0.5, 0.0, 0.0], [0.5, 0.0, 0.0]], dtype=dtype) mol = Mol((atomzs, poss), basis=basis, spin=0, dtype=dtype) qc = HF(mol, restricted=True).run() ene = qc.energy() if with_ii: ene = ene - mol.get_nuclei_energy() return ene
def test_uhf_energy_mols(atomzs, dist, spin, energy_true, variational): # check the energy of molecules with non-0 spins # NOTE: O2 iteration gets into excited state (probably) torch.manual_seed(123) poss = torch.tensor([[-0.5, 0.0, 0.0], [0.5, 0.0, 0.0]], dtype=dtype) * dist mol = Mol((atomzs, poss), basis=basis, dtype=dtype, spin=spin) qc = HF(mol, restricted=False, variational=variational).run() ene = qc.energy() assert torch.allclose(ene, ene * 0 + energy_true, rtol=1e-8, atol=0.0)
def _test_hf_mols(): poss = torch.tensor([[-0.5, 0.0, 0.0], [0.5, 0.0, 0.0]], dtype=dtype) * dist poss = poss.requires_grad_() mol = Mol((atomzs, poss), basis="6-311++G**", dtype=dtype, spin=spin) qc = HF(mol).run() ene = qc.energy() # see if grad and backward create memleak grads = torch.autograd.grad(ene, (poss, ), create_graph=True) ene.backward() # no create_graph here because of known pytorch's leak
def test_rhf_energy_overcomplete(atomzs, dist, energy_true, variational): # test to see if the energy calculated by DQC agrees with PySCF with # overcomplete basis torch.manual_seed(123) # double the basis to make it overcomplete basis0 = loadbasis(f"{atomzs[0]}:{basis}") * 2 basis1 = loadbasis(f"{atomzs[1]}:{basis}") * 2 poss = torch.tensor([[-0.5, 0.0, 0.0], [0.5, 0.0, 0.0]], dtype=dtype) * dist # orthogonalize_basis = True to handle overcomplete mol = Mol((atomzs, poss), basis=[basis0, basis1], dtype=dtype, orthogonalize_basis=True) qc = HF(mol, restricted=True, variational=variational).run() ene = qc.energy() assert torch.allclose(ene, ene * 0 + energy_true, rtol=1e-7)
def test_rhf_energy(atomzs, dist, energy_true, variational): # test to see if the energy calculated by DQC agrees with PySCF torch.manual_seed(123) # only set debugging mode only in one case to save time if atomzs == [1, 1]: xt.set_debug_mode(True) poss = torch.tensor([[-0.5, 0.0, 0.0], [0.5, 0.0, 0.0]], dtype=dtype) * dist mol = Mol((atomzs, poss), basis=basis, dtype=dtype) qc = HF(mol, restricted=True, variational=variational).run() ene = qc.energy() assert torch.allclose(ene, ene * 0 + energy_true, rtol=1e-7) if atomzs == [1, 1]: xt.set_debug_mode(False)
def get_energy(dist_tensor): poss_tensor = torch.tensor([[-0.5, 0.0, 0.0], [0.5, 0.0, 0.0]], dtype=dtype) * dist_tensor mol = Mol((atomzs, poss_tensor), basis=basis, dtype=dtype) qc = HF(mol, restricted=True, variational=variational).run( fwd_options=fwd_options, bck_options=bck_options) return qc.energy()
def get_energy(atomzs): poss = torch.tensor([[-0.5, 0.0, 0.0], [0.5, 0.0, 0.0]], dtype=dtype) mol = Mol((atomzs, poss), basis=basis, spin=0, dtype=dtype) qc = HF(mol, restricted=True).run() ene = qc.energy() - mol.get_nuclei_energy() return ene
def test_instability_check(): # check if is_orb_min returns False for a known excited state atomzs = [8, 8] # O2 atomposs = torch.tensor([[-1.0, 0., 0.], [1.0, 0., 0.]], dtype=dtype) mol = Mol(moldesc=(atomzs, atomposs), basis="3-21G", dtype=dtype, spin=2) # known excited state of O2 dm0 = SpinParam(u=torch.tensor([[ 1.4374e-02, -6.5933e-17, -1.3556e-17, 1.1258e-17, -1.8834e-03, 2.1021e-16, -2.3638e-13, -2.6444e-12, 2.2637e-02, -4.9366e-17, -5.9629e-02, 1.8549e-17, 5.0367e-17, -1.5571e-16, -5.6398e-12, -6.9681e-12, -1.0048e-01, 1.2257e-15], [-6.5933e-17, 2.3236e-02, -2.1167e-12, -5.2740e-13, -7.3181e-17, -1.0873e-02, -8.3590e-17, 1.2056e-17, -9.3082e-17, 8.0595e-02, 3.6757e-16, 9.1094e-12, -3.9485e-13, 1.2539e-01, -9.1129e-18, -2.8306e-17, -7.9300e-17, -1.8937e-02], [-1.3556e-17, -2.1167e-12, 4.2572e-02, 8.2444e-04, -1.2280e-16, 1.5572e-12, -1.5306e-17, 1.7276e-16, 2.7191e-18, 6.4115e-13, 1.1101e-16, -1.9820e-01, -3.8413e-02, -1.7302e-12, -7.2395e-16, -5.6557e-16, 1.6237e-17, 2.3304e-13], [ 1.1258e-17, -5.2740e-13, 8.2444e-04, 3.9468e-02, 6.1344e-17, 3.8795e-13, 1.2361e-16, -6.1389e-18, 8.2929e-17, 1.5994e-13, -1.2242e-16, -4.0719e-02, 1.9040e-01, -4.3109e-13, 2.8388e-17, -3.7710e-16, 9.6793e-17, 5.8088e-14], [-1.8834e-03, -7.3181e-17, -1.2280e-16, 6.1344e-17, 2.6433e-04, -1.9302e-19, -1.0905e-13, -1.2203e-12, -1.8316e-03, -1.1234e-16, 4.4601e-03, 5.1546e-16, 4.1761e-16, -5.2628e-16, -7.2761e-12, -8.9879e-12, 1.5410e-02, -1.5680e-16], [ 2.1021e-16, -1.0873e-02, 1.5572e-12, 3.8795e-13, -1.9302e-19, 1.9720e-02, -4.5050e-18, 4.1017e-17, 5.5749e-17, -4.4163e-02, -3.6973e-16, -6.9926e-12, 3.0281e-13, -3.5499e-02, 5.1310e-16, -3.6489e-17, -2.1794e-16, 1.2650e-01], [-2.3638e-13, -8.3590e-17, -1.5306e-17, 1.2361e-16, -1.0905e-13, -4.5050e-18, 1.7231e-02, -1.7505e-04, -9.2770e-14, -3.9129e-16, 3.4332e-13, -4.4355e-18, 8.8915e-16, -4.0986e-16, -9.3919e-02, 9.0076e-02, 1.0851e-12, 1.3598e-16], [-2.6444e-12, 1.2056e-17, 1.7276e-16, -6.1389e-18, -1.2203e-12, 4.1017e-17, -1.7505e-04, 1.5289e-02, -1.0377e-12, 1.2434e-17, 3.8408e-12, -1.3267e-15, -1.7575e-16, 1.1638e-16, 8.5865e-02, 8.7648e-02, 1.2149e-11, 4.9825e-17], [ 2.2637e-02, -9.3082e-17, 2.7191e-18, 8.2929e-17, -1.8316e-03, 5.5749e-17, -9.2770e-14, -1.0377e-12, 1.0891e-01, 5.4901e-16, -3.1041e-01, -2.1589e-16, 9.7090e-17, -2.0236e-16, 2.5871e-12, 3.1957e-12, -1.3275e-02, -3.7240e-16], [-4.9366e-17, 8.0595e-02, 6.4115e-13, 1.5994e-13, -1.1234e-16, -4.4163e-02, -3.9129e-16, 1.2434e-17, 5.4901e-16, 9.9128e-01, 6.4760e-16, -9.9216e-13, 4.2760e-14, -1.2043e-02, 1.5942e-16, -1.0898e-16, 1.7759e-16, 7.3878e-03], [-5.9629e-02, 3.6757e-16, 1.1101e-16, -1.2242e-16, 4.4601e-03, -3.6973e-16, 3.4332e-13, 3.8408e-12, -3.1041e-01, 6.4760e-16, 8.8722e-01, -4.5809e-17, 1.7987e-16, -2.7821e-16, 2.1268e-13, 2.6265e-13, -1.1616e-02, -1.0344e-16], [ 1.8549e-17, 9.1094e-12, -1.9820e-01, -4.0719e-02, 5.1546e-16, -6.9926e-12, -4.4355e-18, -1.3267e-15, -2.1589e-16, -9.9216e-13, -4.5809e-17, 9.5723e-01, 1.5197e-04, -1.8852e-12, 1.6341e-16, 1.0968e-16, -7.3105e-17, 1.1978e-12], [ 5.0367e-17, -3.9485e-13, -3.8413e-02, 1.9040e-01, 4.1761e-16, 3.0281e-13, 8.8915e-16, -1.7575e-16, 9.7090e-17, 4.2760e-14, 1.7987e-16, 1.5197e-04, 9.6073e-01, 8.1569e-14, -4.7992e-16, 3.4136e-16, 3.3857e-17, -5.1807e-14], [-1.5571e-16, 1.2539e-01, -1.7302e-12, -4.3109e-13, -5.2628e-16, -3.5499e-02, -4.0986e-16, 1.1638e-16, -2.0236e-16, -1.2043e-02, -2.7821e-16, -1.8852e-12, 8.1569e-14, 9.8251e-01, 1.5091e-16, -1.8316e-16, -1.7641e-16, 7.2007e-03], [-5.6398e-12, -9.1129e-18, -7.2395e-16, 2.8388e-17, -7.2761e-12, 5.1310e-16, -9.3919e-02, 8.5865e-02, 2.5871e-12, 1.5942e-16, 2.1268e-13, 1.6341e-16, -4.7992e-16, 1.5091e-16, 9.8353e-01, 9.6527e-04, -1.3954e-12, 5.5578e-17], [-6.9681e-12, -2.8306e-17, -5.6557e-16, -3.7710e-16, -8.9879e-12, -3.6489e-17, 9.0076e-02, 8.7648e-02, 3.1957e-12, -1.0898e-16, 2.6265e-13, 1.0968e-16, 3.4136e-16, -1.8316e-16, 9.6527e-04, 9.8395e-01, -1.7236e-12, 1.2375e-16], [-1.0048e-01, -7.9300e-17, 1.6237e-17, 9.6793e-17, 1.5410e-02, -2.1794e-16, 1.0851e-12, 1.2149e-11, -1.3275e-02, 1.7759e-16, -1.1616e-02, -7.3105e-17, 3.3857e-17, -1.7641e-16, -1.3954e-12, -1.7236e-12, 9.8924e-01, -1.2411e-16], [ 1.2257e-15, -1.8937e-02, 2.3304e-13, 5.8088e-14, -1.5680e-16, 1.2650e-01, 1.3598e-16, 4.9825e-17, -3.7240e-16, 7.3878e-03, -1.0344e-16, 1.1978e-12, -5.1807e-14, 7.2007e-03, 5.5578e-17, 1.2375e-16, -1.2411e-16, 9.8325e-01]], dtype=torch.float64), d=torch.tensor([[ 2.2958e-02, 5.9133e-17, -4.3465e-17, -3.5203e-17, -5.2141e-03, 1.9909e-16, 1.6717e-14, 1.8684e-13, 3.9446e-02, 2.7848e-16, -6.6246e-02, 1.2336e-17, -2.6465e-16, 8.6160e-16, -2.8860e-11, -3.5653e-11, -1.2829e-01, 1.5006e-15], [ 5.9133e-17, 4.6415e-03, -1.3965e-10, -3.4794e-11, -2.6531e-17, -7.5184e-03, 6.8007e-17, -1.8251e-17, 1.2508e-16, 4.6059e-02, -5.7129e-18, 6.4528e-10, -2.7957e-11, -7.4002e-03, -7.1789e-16, 5.1820e-16, -9.0260e-16, -4.8860e-02], [-4.3465e-17, -1.3965e-10, 4.3859e-02, 1.0928e-02, -6.8315e-17, 6.4583e-11, 1.4620e-17, 1.7630e-16, -1.1049e-16, -2.1608e-10, 2.5101e-16, -2.0430e-01, 8.8512e-03, -7.6096e-10, -7.9051e-16, -5.0478e-16, 1.2440e-16, -8.9813e-11], [-3.5203e-17, -3.4794e-11, 1.0928e-02, 2.7228e-03, -1.0420e-17, 1.6091e-11, 3.7273e-17, 1.7772e-17, -2.7800e-17, -5.3837e-11, 5.6712e-18, -5.0902e-02, 2.2053e-03, -1.8960e-10, -7.8317e-16, 8.0795e-17, 2.4562e-16, -2.2377e-11], [-5.2141e-03, -2.6531e-17, -6.8315e-17, -1.0420e-17, 1.2314e-03, -5.6992e-18, -1.4157e-13, -1.5837e-12, -7.1148e-03, 7.0004e-17, 9.4083e-03, 3.5543e-16, 4.2740e-17, -2.7677e-16, -2.1264e-12, -2.6263e-12, 3.2613e-02, 1.1833e-18], [ 1.9909e-16, -7.5184e-03, 6.4583e-11, 1.6091e-11, -5.6992e-18, 1.6029e-02, -2.4000e-17, 2.0307e-17, 1.2229e-16, -3.2365e-02, -2.4677e-16, -2.8977e-10, 1.2554e-11, -5.3257e-03, 2.8397e-16, -1.7180e-16, -8.3203e-17, 1.2099e-01], [ 1.6717e-14, 6.8007e-17, 1.4620e-17, 3.7273e-17, -1.4157e-13, -2.4000e-17, 3.7952e-03, 7.4301e-04, -4.3281e-13, 4.4101e-16, -1.6173e-12, -4.2060e-17, 2.1463e-16, 2.1636e-16, -4.1059e-02, 4.5765e-02, -2.8999e-12, 1.0801e-16], [ 1.8684e-13, -1.8251e-17, 1.7630e-16, 1.7772e-17, -1.5837e-12, 2.0307e-17, 7.4301e-04, 1.2040e-02, -4.8418e-12, -1.2562e-16, -1.8091e-11, -1.2667e-15, -4.7435e-17, -1.7249e-16, 7.2754e-02, 8.1250e-02, -3.2434e-11, 8.1554e-17], [ 3.9446e-02, 1.2508e-16, -1.1049e-16, -2.7800e-17, -7.1148e-03, 1.2229e-16, -4.3281e-13, -4.8418e-12, 1.3971e-01, 1.1579e-15, -3.3375e-01, -4.4814e-17, -5.2377e-16, 1.4905e-15, -7.4596e-11, -9.2152e-11, -8.4825e-02, 5.5948e-16], [ 2.7848e-16, 4.6059e-02, -2.1608e-10, -5.3837e-11, 7.0004e-17, -3.2365e-02, 4.4101e-16, -1.2562e-16, 1.1579e-15, 9.2048e-01, -1.0153e-16, 9.8356e-10, -4.2613e-11, -2.6337e-01, -1.3755e-15, 6.0548e-16, -1.5088e-15, -2.5713e-02], [-6.6246e-02, -5.7129e-18, 2.5101e-16, 5.6712e-18, 9.4083e-03, -2.4677e-16, -1.6173e-12, -1.8091e-11, -3.3375e-01, -1.0153e-16, 8.6354e-01, 9.1119e-17, 9.7805e-16, -3.0709e-15, -3.0487e-11, -3.7662e-11, -4.4392e-02, -2.2345e-16], [ 1.2336e-17, 6.4528e-10, -2.0430e-01, -5.0902e-02, 3.5543e-16, -2.8977e-10, -4.2060e-17, -1.2667e-15, -4.4814e-17, 9.8356e-10, 9.1119e-17, 9.5163e-01, -4.1229e-02, 3.5411e-09, 3.4000e-16, -7.3179e-17, 4.4148e-17, 5.0171e-10], [-2.6465e-16, -2.7957e-11, 8.8512e-03, 2.2053e-03, 4.2740e-17, 1.2554e-11, 2.1463e-16, -4.7435e-17, -5.2377e-16, -4.2613e-11, 9.7805e-16, -4.1229e-02, 1.7862e-03, -1.5342e-10, -3.2950e-15, 1.6944e-15, 1.3384e-15, -2.1736e-11], [ 8.6160e-16, -7.4002e-03, -7.6096e-10, -1.8960e-10, -2.7677e-16, -5.3257e-03, 2.1636e-16, -1.7249e-16, 1.4905e-15, -2.6337e-01, -3.0709e-15, 3.5411e-09, -1.5342e-10, 8.9643e-02, -5.2073e-15, 2.4346e-15, -5.8143e-15, -1.1027e-01], [-2.8860e-11, -7.1789e-16, -7.9051e-16, -7.8317e-16, -2.1264e-12, 2.8397e-16, -4.1059e-02, 7.2754e-02, -7.4596e-11, -1.3755e-15, -3.0487e-11, 3.4000e-16, -3.2950e-15, -5.2073e-15, 9.9295e-01, -4.0971e-03, -9.4472e-12, -6.9572e-16], [-3.5653e-11, 5.1820e-16, -5.0478e-16, 8.0795e-17, -2.6263e-12, -1.7180e-16, 4.5765e-02, 8.1250e-02, -9.2152e-11, 6.0548e-16, -3.7662e-11, -7.3179e-17, 1.6944e-15, 2.4346e-15, -4.0971e-03, 9.9121e-01, -1.1671e-11, 5.1711e-16], [-1.2829e-01, -9.0260e-16, 1.2440e-16, 2.4562e-16, 3.2613e-02, -8.3203e-17, -2.8999e-12, -3.2434e-11, -8.4825e-02, -1.5088e-15, -4.4392e-02, 4.4148e-17, 1.3384e-15, -5.8143e-15, -9.4472e-12, -1.1671e-11, 9.7256e-01, -8.6388e-16], [ 1.5006e-15, -4.8860e-02, -8.9813e-11, -2.2377e-11, 1.1833e-18, 1.2099e-01, 1.0801e-16, 8.1554e-17, 5.5948e-16, -2.5713e-02, -2.2345e-16, 5.0171e-10, -2.1736e-11, -1.1027e-01, -6.9572e-16, 5.1711e-16, -8.6388e-16, 9.6920e-01]], dtype=torch.float64)) qc = HF(mol).run(dm0=dm0) ene = qc.energy() assert not is_orb_min(qc) # known ground state of O2 dm1 = SpinParam(u=torch.tensor([[ 2.0683e-02, -1.4420e-16, 1.8209e-17, -8.9218e-18, -1.1292e-03, 2.4994e-16, 1.3424e-17, -1.3778e-17, 3.1936e-02, -2.0260e-16, -6.6341e-02, 5.2691e-17, -3.3777e-17, -6.2702e-16, -1.9655e-17, -1.3381e-15, -1.2179e-01, 1.1911e-15], [-1.4420e-16, 2.5205e-02, 1.5440e-18, -1.5470e-18, -1.2490e-16, -1.1032e-02, -4.4534e-17, -4.0071e-17, -1.5877e-16, 8.2001e-02, 3.1857e-16, 3.3331e-16, -2.5398e-16, 1.3203e-01, -1.0306e-16, 1.1040e-17, -7.2944e-17, -1.7112e-02], [ 1.8209e-17, 1.5440e-18, 3.6441e-02, 1.0879e-13, -1.1019e-16, -6.7960e-17, 2.3446e-17, 1.4381e-16, -1.3948e-17, 6.9656e-17, 6.2990e-17, -1.8362e-01, -3.7391e-02, 4.0401e-16, -7.8922e-16, -5.2022e-16, -2.4977e-16, -2.3482e-17], [-8.9218e-18, -1.5470e-18, 1.0879e-13, 3.6441e-02, 5.4484e-17, -1.0500e-16, 8.8368e-17, -3.8825e-17, 3.4381e-17, 2.4618e-16, -1.2742e-16, -3.7391e-02, 1.8362e-01, 2.4770e-16, -2.9739e-16, -2.9106e-16, 9.1167e-17, 5.5659e-17], [-1.1292e-03, -1.2490e-16, -1.1019e-16, 5.4484e-17, 7.1554e-05, 1.1112e-17, 2.0896e-17, -8.7962e-18, -8.9524e-04, -1.6020e-16, 1.0596e-03, 4.8917e-16, 3.8244e-16, -8.4877e-16, -1.6487e-16, 1.5251e-16, 8.2674e-03, -2.0908e-16], [ 2.4994e-16, -1.1032e-02, -6.7960e-17, -1.0500e-16, 1.1112e-17, 1.9013e-02, -3.8712e-18, -2.4730e-18, 1.3092e-16, -4.3091e-02, -3.6917e-16, 3.2346e-16, -3.8502e-16, -3.7068e-02, 2.5626e-17, -2.1922e-16, -3.1125e-16, 1.2369e-01], [ 1.3424e-17, -4.4534e-17, 2.3446e-17, 8.8368e-17, 2.0896e-17, -3.8712e-18, 1.7462e-02, -1.4887e-11, 4.7461e-18, -8.8927e-17, -4.0357e-17, -1.1873e-17, 5.0543e-16, -3.6232e-16, -9.4065e-02, 9.1151e-02, -1.0645e-15, 1.8543e-17], [-1.3778e-17, -4.0071e-17, 1.4381e-16, -3.8825e-17, -8.7962e-18, -2.4730e-18, -1.4887e-11, 1.7462e-02, -1.2512e-17, -1.1642e-16, 5.8123e-17, -1.3728e-15, -2.0690e-16, -1.4420e-16, 9.1151e-02, 9.4065e-02, -9.7118e-16, 4.9315e-17], [ 3.1936e-02, -1.5877e-16, -1.3948e-17, 3.4381e-17, -8.9524e-04, 1.3092e-16, 4.7461e-18, -1.2512e-17, 1.2198e-01, 5.5052e-16, -3.2192e-01, 7.7566e-18, -6.8423e-17, -6.6652e-16, 1.3687e-16, -5.6171e-16, -4.9446e-02, -1.5290e-16], [-2.0260e-16, 8.2001e-02, 6.9656e-17, 2.4618e-16, -1.6020e-16, -4.3091e-02, -8.8927e-17, -1.1642e-16, 5.5052e-16, 9.9113e-01, 6.4477e-16, -1.2044e-16, -2.2427e-16, -1.2837e-02, 1.0462e-16, -6.5168e-17, 8.9549e-17, 6.9992e-03], [-6.6341e-02, 3.1857e-16, 6.2990e-17, -1.2742e-16, 1.0596e-03, -3.6917e-16, -4.0357e-17, 5.8123e-17, -3.2192e-01, 6.4477e-16, 8.7574e-01, 9.2656e-17, 1.0997e-16, -4.7293e-16, 1.4328e-17, -2.7222e-16, -2.8003e-02, -4.2238e-17], [ 5.2691e-17, 3.3331e-16, -1.8362e-01, -3.7391e-02, 4.8917e-16, 3.2346e-16, -1.1873e-17, -1.3728e-15, 7.7566e-18, -1.2044e-16, 9.2656e-17, 9.6356e-01, 1.9387e-14, -1.1383e-16, -3.7055e-16, 2.4158e-16, -8.2073e-17, -9.3030e-17], [-3.3777e-17, -2.5398e-16, -3.7391e-02, 1.8362e-01, 3.8244e-16, -3.8502e-16, 5.0543e-16, -2.0690e-16, -6.8423e-17, -2.2427e-16, 1.0997e-16, 1.9387e-14, 9.6356e-01, -1.2755e-16, -4.3096e-16, 2.4102e-16, -3.6390e-17, 9.8892e-17], [-6.2702e-16, 1.3203e-01, 4.0401e-16, 2.4770e-16, -8.4877e-16, -3.7068e-02, -3.6232e-16, -1.4420e-16, -6.6652e-16, -1.2837e-02, -4.7293e-16, -1.1383e-16, -1.2755e-16, 9.8060e-01, 5.0343e-17, 3.6493e-17, -2.1165e-16, 7.1881e-03], [-1.9655e-17, -1.0306e-16, -7.8922e-16, -2.9739e-16, -1.6487e-16, 2.5626e-17, -9.4065e-02, 9.1151e-02, 1.3687e-16, 1.0462e-16, 1.4328e-17, -3.7055e-16, -4.3096e-16, 5.0343e-17, 9.8254e-01, 8.2092e-11, -1.4172e-18, 2.2854e-17], [-1.3381e-15, 1.1040e-17, -5.2022e-16, -2.9106e-16, 1.5251e-16, -2.1922e-16, 9.1151e-02, 9.4065e-02, -5.6171e-16, -6.5168e-17, -2.7222e-16, 2.4158e-16, 2.4102e-16, 3.6493e-17, 8.2092e-11, 9.8254e-01, 4.9448e-18, 9.8734e-17], [-1.2179e-01, -7.2944e-17, -2.4977e-16, 9.1167e-17, 8.2674e-03, -3.1125e-16, -1.0645e-15, -9.7118e-16, -4.9446e-02, 8.9549e-17, -2.8003e-02, -8.2073e-17, -3.6390e-17, -2.1165e-16, -1.4172e-18, 4.9448e-18, 9.8153e-01, -1.4542e-16], [ 1.1911e-15, -1.7112e-02, -2.3482e-17, 5.5659e-17, -2.0908e-16, 1.2369e-01, 1.8543e-17, 4.9315e-17, -1.5290e-16, 6.9992e-03, -4.2238e-17, -9.3030e-17, 9.8892e-17, 7.1881e-03, 2.2854e-17, 9.8734e-17, -1.4542e-16, 9.8405e-01]], dtype=torch.float64), d=torch.tensor([[ 1.2641e-02, -1.5358e-16, 4.7752e-17, -8.9111e-18, -4.4876e-03, 2.2773e-16, 6.1698e-18, -7.4570e-18, 2.0856e-02, -6.6447e-17, -5.7084e-02, -4.3042e-17, -5.2418e-17, -4.8881e-16, -1.3178e-17, -1.0353e-15, -9.3633e-02, 1.2411e-15], [-1.5358e-16, 3.0229e-02, 6.8437e-17, 3.5949e-17, -1.0507e-16, -1.5192e-02, -1.7095e-17, -2.0281e-17, -2.3740e-16, 8.8960e-02, 5.2239e-16, 2.5002e-17, -8.2051e-17, 1.4194e-01, 1.1475e-16, 1.5330e-17, -3.2950e-17, -3.1999e-02], [ 4.7752e-17, 6.8437e-17, 7.0466e-31, 2.7196e-31, -2.0268e-17, -3.0557e-17, 6.9564e-18, -2.8971e-17, -1.2805e-17, 1.5775e-16, 5.3677e-17, 8.9575e-31, 3.5820e-31, 3.5525e-16, -4.2190e-16, -2.6774e-16, -5.3815e-16, -4.5207e-17], [-8.9111e-18, 3.5949e-17, 2.7196e-31, 3.5707e-31, 4.3021e-18, -1.4450e-17, 8.7953e-18, -3.0556e-17, 1.6753e-17, 1.8210e-16, -5.2250e-17, 9.0062e-31, 5.3400e-31, 1.3106e-16, -4.6254e-16, -2.6536e-16, 1.2935e-16, 4.9788e-18], [-4.4876e-03, -1.0507e-16, -2.0268e-17, 4.3021e-18, 1.6888e-03, -6.6376e-18, 1.3986e-18, 3.8055e-18, -4.7627e-03, -4.8232e-16, 1.2498e-02, 1.2663e-17, 1.4987e-17, -5.3503e-16, -2.2757e-17, 4.8352e-16, 3.8560e-02, -3.3090e-16], [ 2.2773e-16, -1.5192e-02, -3.0557e-17, -1.4450e-17, -6.6376e-18, 1.9762e-02, 1.6945e-17, 2.4527e-17, 1.1483e-16, -4.5236e-02, -3.5267e-16, -2.8982e-18, 4.2041e-17, -4.5713e-02, -8.0265e-17, 1.0546e-18, -2.5558e-16, 1.2249e-01], [ 6.1698e-18, -1.7095e-17, 6.9564e-18, 8.7953e-18, 1.3986e-18, 1.6945e-17, 3.5428e-03, 4.3824e-11, 1.0206e-17, -2.4135e-17, -2.5997e-17, -9.4414e-18, 9.8201e-17, -6.4590e-17, -4.2669e-02, 4.1347e-02, -4.9636e-16, 7.9868e-17], [-7.4570e-18, -2.0281e-17, -2.8971e-17, -3.0556e-17, 3.8055e-18, 2.4527e-17, 4.3824e-11, 3.5428e-03, -1.7468e-17, -1.2992e-16, 4.3756e-17, -1.0961e-16, -4.9473e-17, -4.8268e-17, 4.1347e-02, 4.2669e-02, -4.2779e-16, 1.5287e-16], [ 2.0856e-02, -2.3740e-16, -1.2805e-17, 1.6753e-17, -4.7627e-03, 1.1483e-16, 1.0206e-17, -1.7468e-17, 1.0739e-01, 3.0990e-16, -3.0878e-01, -1.4332e-16, -1.8655e-16, -6.0195e-16, -1.9554e-17, -1.0795e-16, -7.5289e-03, -1.6864e-16], [-6.6447e-17, 8.8960e-02, 1.5775e-16, 1.8210e-16, -4.8232e-16, -4.5236e-02, -2.4135e-17, -1.2992e-16, 3.0990e-16, 9.8962e-01, 6.2003e-16, -4.3189e-16, -5.5535e-16, -1.5301e-02, 1.3215e-16, -6.0640e-17, 9.2815e-17, 8.7875e-03], [-5.7084e-02, 5.2239e-16, 5.3677e-17, -5.2250e-17, 1.2498e-02, -3.5267e-16, -2.5997e-17, 4.3756e-17, -3.0878e-01, 6.2003e-16, 8.8879e-01, 4.0697e-16, 5.3094e-16, -4.3659e-16, -2.9932e-17, -6.8804e-17, -9.2814e-03, -2.3331e-17], [-4.3042e-17, 2.5002e-17, 8.9575e-31, 9.0062e-31, 1.2663e-17, -2.8982e-18, -9.4414e-18, -1.0961e-16, -1.4332e-16, -4.3189e-16, 4.0697e-16, 4.0132e-30, 1.6971e-30, 4.3752e-16, -1.1655e-15, -1.4303e-15, 1.7323e-16, -1.6309e-17], [-5.2418e-17, -8.2051e-17, 3.5820e-31, 5.3400e-31, 1.4987e-17, 4.2041e-17, 9.8201e-17, -4.9473e-17, -1.8655e-16, -5.5535e-16, 5.3094e-16, 1.6971e-30, 4.1255e-30, -1.9731e-16, -1.7601e-15, 5.5023e-16, 1.8679e-16, 4.7534e-17], [-4.8881e-16, 1.4194e-01, 3.5525e-16, 1.3106e-16, -5.3503e-16, -4.5713e-02, -6.4590e-17, -4.8268e-17, -6.0195e-16, -1.5301e-02, -4.3659e-16, 4.3752e-16, -1.9731e-16, 9.7688e-01, 1.6012e-16, 1.7160e-17, -1.5571e-16, 1.0700e-02], [-1.3178e-17, 1.1475e-16, -4.2190e-16, -4.6254e-16, -2.2757e-17, -8.0265e-17, -4.2669e-02, 4.1347e-02, -1.9554e-17, 1.3215e-16, -2.9932e-17, -1.1655e-15, -1.7601e-15, 1.6012e-16, 9.9646e-01, -2.4166e-10, 1.4456e-17, 2.1470e-17], [-1.0353e-15, 1.5330e-17, -2.6774e-16, -2.6536e-16, 4.8352e-16, 1.0546e-18, 4.1347e-02, 4.2669e-02, -1.0795e-16, -6.0640e-17, -6.8804e-17, -1.4303e-15, 5.5023e-16, 1.7160e-17, -2.4166e-10, 9.9646e-01, -6.1813e-17, 5.6203e-17], [-9.3633e-02, -3.2950e-17, -5.3815e-16, 1.2935e-16, 3.8560e-02, -2.5558e-16, -4.9636e-16, -4.2779e-16, -7.5289e-03, 9.2815e-17, -9.2814e-03, 1.7323e-16, 1.8679e-16, -1.5571e-16, 1.4456e-17, -6.1813e-17, 9.8949e-01, -1.6997e-16], [ 1.2411e-15, -3.1999e-02, -4.5207e-17, 4.9788e-18, -3.3090e-16, 1.2249e-01, 7.9868e-17, 1.5287e-16, -1.6864e-16, 8.7875e-03, -2.3331e-17, -1.6309e-17, 4.7534e-17, 1.0700e-02, 2.1470e-17, 5.6203e-17, -1.6997e-16, 9.8351e-01]], dtype=torch.float64)) qc = HF(mol).run(dm0=dm1) ene = qc.energy() assert is_orb_min(qc)
def get_energy(atomposs, efield, grad_efield): efields = (efield, grad_efield) mol = Mol(moldesc=(atomzs, atomposs), basis="3-21G", dtype=dtype, efield=efields) qc = HF(mol).run() ene = qc.energy() return ene