def test_adc2_shift_invert_triplets(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 triplets guesses = adcc.guesses_triplet(matrix, n_guesses=5, block="ph") symm = IndexSpinSymmetrisation(matrix, enforce_spin_kind="triplet") 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_triplets = refdata["adc2"]["triplet"]["eigenvalues"][:5] assert eigenvalues == approx(ref_triplets)
def base_adc2(self, kind, guess_function, max_iter=100): refdata = cache.reference_data["h2o_sto3g"] matrix = adcc.AdcMatrix("adc2", cache.refstate["h2o_sto3g"]) conv_tol = 1e-6 guesses = guess_function(matrix, n_guesses=1) symm = IndexSpinSymmetrisation(matrix, enforce_spin_kind=kind) inverse = IterativeInverse(matrix, Pinv=JacobiPreconditioner, conv_tol=conv_tol / 10, construct_guess=guess_from_previous) res = power_method(inverse, guesses[0], conv_tol=conv_tol, explicit_symmetrisation=symm, callback=powprint, max_iter=max_iter) ref_singlets = refdata["adc2"][kind]["eigenvalues"] assert res.converged assert 1 / res.eigenvalues[0] == approx(ref_singlets[0])