def test_adc2_shift_invert_singlets(self): refdata = cache.reference_data["h2o_sto3g"] matrix = adcc.AdcMatrix("adc2", LazyMp(cache.refstate["h2o_sto3g"])) conv_tol = 1e-5 shift = -0.5 # Construct shift and inverted matrix: shinv = IterativeInverse(AdcMatrixShifted(matrix, shift), conv_tol=conv_tol / 10, Pinv=JacobiPreconditioner, callback=cg_print) # Solve for singlets guesses = adcc.guesses_singlet(matrix, n_guesses=5, block="ph") symm = IndexSpinSymmetrisation(matrix, enforce_spin_kind="singlet") res = lanczos(shinv, guesses, n_ep=5, callback=la_print, explicit_symmetrisation=symm) assert res.converged # Undo spectral transformation and compare eigenvalues = sorted(1 / res.eigenvalues - shift) ref_singlets = refdata["adc2"]["singlet"]["eigenvalues"][:5] assert eigenvalues == approx(ref_singlets)
def test_adc2_singlets(self): refdata = cache.reference_data["h2o_sto3g"] matrix = adcc.AdcMatrix("adc2", LazyMp(cache.refstate["h2o_sto3g"])) # Solve for singlets guesses = adcc.guesses_singlet(matrix, n_guesses=9, block="s") res = jacobi_davidson(matrix, guesses, n_ep=9) ref_singlets = refdata["adc2"]["singlet"]["eigenvalues"] assert res.converged assert res.eigenvalues == approx(ref_singlets)
def test_adc2_singlets(self): refdata = cache.reference_data["h2o_sto3g"] matrix = adcc.AdcMatrix("adc2", LazyMp(cache.refstate["h2o_sto3g"])) # Solve for singlets guesses = adcc.guesses_singlet(matrix, n_guesses=5, block="ph") res = lanczos(matrix, guesses, n_ep=5, which="SM") ref_singlets = refdata["adc2"]["singlet"]["eigenvalues"][:5] assert res.converged assert res.eigenvalues == approx(ref_singlets)
def test_diagonalise_adcmatrix(self): from adcc.workflow import diagonalise_adcmatrix refdata = cache.reference_data["h2o_sto3g"] matrix = adcc.AdcMatrix("adc2", adcc.LazyMp(cache.refstate["h2o_sto3g"])) res = diagonalise_adcmatrix(matrix, n_states=3, kind="singlet", eigensolver="davidson") ref_singlets = refdata["adc2"]["singlet"]["eigenvalues"] assert res.converged assert res.eigenvalues == approx(ref_singlets[:3]) guesses = adcc.guesses_singlet(matrix, n_guesses=6, block="ph") res = diagonalise_adcmatrix(matrix, n_states=3, kind="singlet", guesses=guesses) ref_singlets = refdata["adc2"]["singlet"]["eigenvalues"] assert res.converged assert res.eigenvalues == approx(ref_singlets[:3]) with pytest.raises(InputError): # Too low tolerance res = diagonalise_adcmatrix(matrix, n_states=9, kind="singlet", eigensolver="davidson", conv_tol=1e-14) with pytest.raises(InputError): # Wrong solver method res = diagonalise_adcmatrix(matrix, n_states=9, kind="singlet", eigensolver="blubber") with pytest.raises(InputError): # Too few guesses res = diagonalise_adcmatrix(matrix, n_states=9, kind="singlet", eigensolver="davidson", guesses=guesses)