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 test_adc2_triplets(self): refdata = cache.reference_data["h2o_sto3g"] matrix = adcc.AdcMatrix("adc2", LazyMp(cache.refstate["h2o_sto3g"])) # Solve for triplets guesses = adcc.guesses_triplet(matrix, n_guesses=10, block="s") res = jacobi_davidson(matrix, guesses, n_ep=10) ref_triplets = refdata["adc2"]["triplet"]["eigenvalues"] assert res.converged assert res.eigenvalues == approx(ref_triplets)
def test_adc2_triplets(self): refdata = cache.reference_data["h2o_sto3g"] matrix = adcc.AdcMatrix("adc2", LazyMp(cache.refstate["h2o_sto3g"])) # Solve for triplets guesses = adcc.guesses_triplet(matrix, n_guesses=6, block="ph") res = lanczos(matrix, guesses, n_ep=6, which="SM") ref_triplets = refdata["adc2"]["triplet"]["eigenvalues"][:6] assert res.converged assert res.eigenvalues == approx(ref_triplets)
def make_mock_adc_state(refstate, matmethod, kind, reference): ground_state = LazyMp(refstate, CacheAllPolicy()) matrix = AdcMatrix(matmethod, ground_state) # Number of full state results n_full = len(reference[kind]["eigenvectors_singles"]) state = AdcMockState(matrix) state.method = matrix.method state.ground_state = ground_state state.reference_state = refstate state.kind = kind state.eigenvalues = reference[kind]["eigenvalues"][:n_full] spin_change = 0 if refstate.restricted and kind == "singlet": symm = "symmetric" elif refstate.restricted and kind == "triplet": symm = "antisymmetric" elif kind in ["state", "spin_flip"]: symm = "none" else: raise ValueError("Unknown kind: {}".format(kind)) state.eigenvectors = [ guess_zero(matrix, irrep="A", spin_change=spin_change, spin_block_symmetrisation=symm) for i in range(n_full) ] has_doubles = "eigenvectors_doubles" in reference[kind] vec_singles = reference[kind]["eigenvectors_singles"] vec_doubles = reference[kind].get("eigenvectors_doubles", None) for i, evec in enumerate(state.eigenvectors): evec["s"].set_from_ndarray(vec_singles[i]) if has_doubles: evec["d"].set_from_ndarray(vec_doubles[i], 1e-14) return ExcitedStates(state)