From db8001bc4aa466d4da3ffc8a0d781010ea14b4ba Mon Sep 17 00:00:00 2001 From: Maximilian Scheurer Date: Mon, 11 Jan 2021 15:07:53 +0100 Subject: [PATCH 01/18] getting started on gradients with psi4 fix dot product issue for bare tensors add working gradient implementation add gradient provider to pyscf flake fix excitation view tests --- adcc/Excitation.py | 2 + adcc/ExcitedStates.py | 6 + adcc/ReferenceState.py | 4 +- adcc/__init__.py | 2 + adcc/backends/psi4.py | 67 +++++ adcc/backends/pyscf.py | 64 ++++- adcc/gradients/TwoParticleDensityMatrix.py | 285 +++++++++++++++++++++ adcc/gradients/__init__.py | 106 ++++++++ adcc/gradients/amplitude_response.py | 147 +++++++++++ adcc/gradients/orbital_response.py | 167 ++++++++++++ adcc/solver/conjugate_gradient.py | 4 +- adcc/test_ExcitedStates.py | 3 +- 12 files changed, 851 insertions(+), 6 deletions(-) create mode 100644 adcc/gradients/TwoParticleDensityMatrix.py create mode 100644 adcc/gradients/__init__.py create mode 100644 adcc/gradients/amplitude_response.py create mode 100644 adcc/gradients/orbital_response.py diff --git a/adcc/Excitation.py b/adcc/Excitation.py index 1419e4f69..0ec515db1 100644 --- a/adcc/Excitation.py +++ b/adcc/Excitation.py @@ -66,6 +66,8 @@ def __init__(self, parent_state, index, method): self.__parent_state = parent_state self.index = index self.method = method + self.ground_state = parent_state.ground_state + self.reference_state = parent_state.reference_state for key in self.parent_state.excitation_property_keys: fget = getattr(type(self.parent_state), key).fget # Extract the kwargs passed to mark_excitation_property diff --git a/adcc/ExcitedStates.py b/adcc/ExcitedStates.py index 2dd656fe1..160addf99 100644 --- a/adcc/ExcitedStates.py +++ b/adcc/ExcitedStates.py @@ -217,6 +217,12 @@ def __add__(self, other): ret += other return ret + @property + @mark_excitation_property() + def total_energy(self): + # TODO: excitation_energy_uncorrected for PE-ADC with postSCF + return self.excitation_energy + self.ground_state.energy(self.method.level) + @cached_property @mark_excitation_property(transform_to_ao=True) @timed_member_call(timer="_property_timer") diff --git a/adcc/ReferenceState.py b/adcc/ReferenceState.py index a3274c619..c34f71cde 100644 --- a/adcc/ReferenceState.py +++ b/adcc/ReferenceState.py @@ -156,7 +156,9 @@ def __init__(self, hfdata, core_orbitals=None, frozen_core=None, ) self.environment = None # no environment attached by default - for name in ["excitation_energy_corrections", "environment"]: + for name in ["excitation_energy_corrections", + "environment", + "gradient_provider"]: if hasattr(hfdata, name): setattr(self, name, getattr(hfdata, name)) diff --git a/adcc/__init__.py b/adcc/__init__.py index 87b136ae4..0c00e7228 100644 --- a/adcc/__init__.py +++ b/adcc/__init__.py @@ -43,6 +43,7 @@ from .AmplitudeVector import AmplitudeVector from .OneParticleOperator import OneParticleOperator from .opt_einsum_integration import register_with_opt_einsum +from .gradients import nuclear_gradient # This has to be the last set of import from .guess import (guess_symmetries, guess_zero, guesses_any, guesses_singlet, @@ -63,6 +64,7 @@ "guess_symmetries", "guesses_spin_flip", "guess_zero", "LazyMp", "adc0", "cis", "adc1", "adc2", "adc2x", "adc3", "cvs_adc0", "cvs_adc1", "cvs_adc2", "cvs_adc2x", "cvs_adc3", + "nuclear_gradient", "banner"] __version__ = "0.15.17" diff --git a/adcc/backends/psi4.py b/adcc/backends/psi4.py index 96393b1c2..214f32b17 100644 --- a/adcc/backends/psi4.py +++ b/adcc/backends/psi4.py @@ -32,6 +32,72 @@ from ..ExcitedStates import EnergyCorrection +class Psi4GradientProvider: + def __init__(self, wfn): + self.wfn = wfn + self.mol = self.wfn.molecule() + self.backend = "psi4" + self.mints = psi4.core.MintsHelper(self.wfn) + + def correlated_gradient(self, g1_ao, w_ao, g2_ao_1, g2_ao_2): + """ + g1_ao: relaxed one-particle density matrix + w_ao: energy-weighted density matrix + g2_ao_1, g2_ao_2: relaxed two-particle density matrices + """ + natoms = self.mol.natom() + Gradient = {} + Gradient["N"] = np.zeros((natoms, 3)) + Gradient["S"] = np.zeros((natoms, 3)) + Gradient["T"] = np.zeros((natoms, 3)) + Gradient["V"] = np.zeros((natoms, 3)) + Gradient["OEI"] = np.zeros((natoms, 3)) + Gradient["TEI"] = np.zeros((natoms, 3)) + Gradient["Total"] = np.zeros((natoms, 3)) + + # 1st Derivative of Nuclear Repulsion + Gradient["N"] = psi4.core.Matrix.to_array( + self.mol.nuclear_repulsion_energy_deriv1([0, 0, 0]) + ) + # Build Integral Derivatives + cart = ['_X', '_Y', '_Z'] + oei_dict = {"S": "OVERLAP", "T": "KINETIC", "V": "POTENTIAL"} + + deriv1_mat = {} + deriv1_np = {} + # 1st Derivative of OEIs + for atom in range(natoms): + for key in oei_dict: + string = key + str(atom) + deriv1_mat[string] = self.mints.ao_oei_deriv1(oei_dict[key], atom) + for p in range(3): + map_key = string + cart[p] + deriv1_np[map_key] = np.asarray(deriv1_mat[string][p]) + if key == "S": + Gradient["S"][atom, p] = np.sum(w_ao * deriv1_np[map_key]) + else: + Gradient[key][atom, p] = np.sum(g1_ao * deriv1_np[map_key]) + # Build Total OEI Gradient + Gradient["OEI"] = Gradient["T"] + Gradient["V"] + Gradient["S"] + + # Build TE contributions + for atom in range(natoms): + string = "TEI" + str(atom) + deriv2 = self.mints.ao_tei_deriv1(atom) + for p in range(3): + map_key = string + cart[p] + deriv2_np = np.asarray(deriv2[p]) + Gradient["TEI"][atom, p] += np.einsum( + 'pqrs,prqs->', g2_ao_1, deriv2_np, optimize=True + ) + Gradient["TEI"][atom, p] -= np.einsum( + 'pqrs,psqr->', g2_ao_2, deriv2_np, optimize=True + ) + # Build total gradient + Gradient["Total"] = Gradient["OEI"] + Gradient["TEI"] + Gradient["N"] + return Gradient + + class Psi4OperatorIntegralProvider: def __init__(self, wfn): self.wfn = wfn @@ -116,6 +182,7 @@ def __init__(self, wfn): wfn.nalpha(), wfn.nbeta(), self.restricted) self.operator_integral_provider = Psi4OperatorIntegralProvider(self.wfn) + self.gradient_provider = Psi4GradientProvider(self.wfn) self.environment = None self.environment_implementation = None diff --git a/adcc/backends/pyscf.py b/adcc/backends/pyscf.py index 067e5a822..b8a9aa1f3 100644 --- a/adcc/backends/pyscf.py +++ b/adcc/backends/pyscf.py @@ -29,10 +29,69 @@ from ..exceptions import InvalidReference from ..ExcitedStates import EnergyCorrection -from pyscf import ao2mo, gto, scf +from pyscf import ao2mo, gto, scf, grad from pyscf.solvent import ddcosmo +class PyScfGradientProvider: + def __init__(self, scfres): + self.scfres = scfres + self.mol = self.scfres.mol + self.backend = "pyscf" + + def correlated_gradient(self, g1_ao, w_ao, g2_ao_1, g2_ao_2): + natoms = self.mol.natm + Gradient = {} + Gradient["N"] = np.zeros((natoms, 3)) + Gradient["S"] = np.zeros((natoms, 3)) + Gradient["T+V"] = np.zeros((natoms, 3)) + Gradient["OEI"] = np.zeros((natoms, 3)) + Gradient["TEI"] = np.zeros((natoms, 3)) + Gradient["Total"] = np.zeros((natoms, 3)) + + # TODO: does RHF/UHF matter here? + gradient = grad.RHF(self.scfres) + hcore_deriv = gradient.hcore_generator() + Sx = -1.0 * self.mol.intor('int1e_ipovlp', aosym='s1') + ERIx = -1.0 * self.mol.intor('int2e_ip1', aosym='s1') + + ao_slices = self.mol.aoslice_by_atom() + for ia in range(natoms): + # TODO: only contract/compute with specific slices + # of density matrices (especially TPDM) + # this requires a lot of work however... + k0, k1 = ao_slices[ia, 2:] + + # derivative of the overlap matrix + Sx_a = np.zeros_like(Sx) + Sx_a[:, k0:k1] = Sx[:, k0:k1] + Sx_a += Sx_a.transpose(0, 2, 1) + Gradient["S"][ia] += np.einsum("xpq,pq->x", Sx_a, w_ao) + + # derivative of the core Hamiltonian + Hx_a = hcore_deriv(ia) + Gradient["T+V"][ia] += np.einsum("xpq,pq->x", Hx_a, g1_ao) + + # derivatives of the ERIs + ERIx_a = np.zeros_like(ERIx) + ERIx_a[:, k0:k1] = ERIx[:, k0:k1] + ERIx_a += ( + + ERIx_a.transpose(0, 2, 1, 4, 3) + + ERIx_a.transpose(0, 3, 4, 1, 2) + + ERIx_a.transpose(0, 4, 3, 2, 1) + ) + Gradient["TEI"][ia] += np.einsum( + "pqrs,xprqs->x", g2_ao_1, ERIx_a, optimize=True + ) + Gradient["TEI"][ia] -= np.einsum( + "pqrs,xpsqr->x", g2_ao_2, ERIx_a, optimize=True + ) + Gradient["N"] = gradient.grad_nuc() + Gradient["OEI"] = Gradient["T+V"] + Gradient["S"] + Gradient["Total"] = Gradient["OEI"] + Gradient["TEI"] + Gradient["N"] + return Gradient + + class PyScfOperatorIntegralProvider: def __init__(self, scfres): self.scfres = scfres @@ -111,7 +170,7 @@ def coefficients(self): def compute_mo_eri(self, blocks, spins): coeffs = tuple(self.coefficients[blocks[i] + spins[i]] for i in range(4)) - # TODO Pyscf usse HDF5 internal to do the AO2MO here we read it all + # TODO Pyscf uses HDF5 internal to do the AO2MO here we read it all # into memory. This wastes memory and could be avoided if temporary # files were used instead. These could be deleted on the call # to `flush_cache` automatically. @@ -138,6 +197,7 @@ def __init__(self, scfres): self.operator_integral_provider = PyScfOperatorIntegralProvider( self.scfres ) + self.gradient_provider = PyScfGradientProvider(self.scfres) if not self.restricted: assert self.scfres.mo_coeff[0].shape[1] == \ self.scfres.mo_coeff[1].shape[1] diff --git a/adcc/gradients/TwoParticleDensityMatrix.py b/adcc/gradients/TwoParticleDensityMatrix.py new file mode 100644 index 000000000..89cb3856f --- /dev/null +++ b/adcc/gradients/TwoParticleDensityMatrix.py @@ -0,0 +1,285 @@ +#!/usr/bin/env python3 +## vi: tabstop=4 shiftwidth=4 softtabstop=4 expandtab +## --------------------------------------------------------------------- +## +## Copyright (C) 2021 by the adcc authors +## +## This file is part of adcc. +## +## adcc is free software: you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published +## by the Free Software Foundation, either version 3 of the License, or +## (at your option) any later version. +## +## adcc is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with adcc. If not, see . +## +## --------------------------------------------------------------------- +import numpy as np + +import libadcc +import adcc.block as b +from adcc.MoSpaces import split_spaces +from adcc.Tensor import Tensor +from adcc.functions import einsum + + +class TwoParticleDensityMatrix: + """ + Two-particle density matrix (TPDM) used for gradient evaluations + Limited functionality: CVS not supported! + """ + def __init__(self, spaces): + if hasattr(spaces, "mospaces"): + self.mospaces = spaces.mospaces + else: + self.mospaces = spaces + if self.mospaces.has_core_occupied_space: + raise NotImplementedError("TPDM not implemented for CVS.") + # Set reference_state if possible + if isinstance(spaces, libadcc.ReferenceState): + self.reference_state = spaces + elif hasattr(spaces, "reference_state"): + assert isinstance(spaces.reference_state, libadcc.ReferenceState) + self.reference_state = spaces.reference_state + + occs = sorted(self.mospaces.subspaces_occupied, reverse=True) + virts = sorted(self.mospaces.subspaces_virtual, reverse=True) + self.orbital_subspaces = occs + virts + # check that orbital subspaces are correct + assert sum(self.mospaces.n_orbs(ss) for ss in self.orbital_subspaces) \ + == self.mospaces.n_orbs("f") + # set the canonical blocks explicitly + self.blocks = [ + b.oooo, b.ooov, b.oovv, + b.ovov, b.ovvv, b.vvvv, + ] + self._tensors = {} + + @property + def shape(self): + """ + Returns the shape tuple of the OneParticleOperator + """ + size = self.mospaces.n_orbs("f") + return 4 * (size,) + + @property + def size(self): + """ + Returns the number of elements of the OneParticleOperator + """ + return np.prod(self.shape) + + def __setitem__(self, block, tensor): + """ + Assigns a tensor to the specified block + """ + if block not in self.blocks: + raise KeyError(f"Invalid block {block} assigned. " + f"Available blocks are: {self.blocks}.") + s1, s2, s3, s4 = split_spaces(block) + expected_shape = (self.mospaces.n_orbs(s1), + self.mospaces.n_orbs(s2), + self.mospaces.n_orbs(s3), + self.mospaces.n_orbs(s4)) + if expected_shape != tensor.shape: + raise ValueError("Invalid shape of incoming tensor. " + f"Expected shape {expected_shape}, but " + f"got shape {tensor.shape} instead.") + self._tensors[block] = tensor + + def __getitem__(self, block): + if block not in self.blocks: + raise KeyError(f"Invalid block {block} requested. " + f"Available blocks are: {self.blocks}.") + if block not in self._tensors: + sym = libadcc.make_symmetry_eri(self.mospaces, block) + self._tensors[block] = Tensor(sym) + return self._tensors[block] + + def to_ndarray(self): + raise NotImplementedError("ndarray export not implemented for TPDM.") + + def copy(self): + """ + Return a deep copy of the TwoParticleDensityMatrix + """ + ret = TwoParticleDensityMatrix(self.mospaces) + for bl in self.blocks_nonzero: + ret[bl] = self.block(bl).copy() + if hasattr(self, "reference_state"): + ret.reference_state = self.reference_state + return ret + + @property + def blocks_nonzero(self): + """ + Returns a list of the non-zero block labels + """ + return [b for b in self.blocks if b in self._tensors] + + def is_zero_block(self, block): + """ + Checks if block is explicitly marked as zero block. + Returns False if the block does not exist. + """ + if block not in self.blocks: + return False + return block not in self.blocks_nonzero + + def block(self, block): + """ + Returns tensor of the given block. + Does not create a block in case it is marked as a zero block. + Use __getitem__ for that purpose. + """ + if block not in self.blocks_nonzero: + raise KeyError("The block function does not support " + "access to zero-blocks. Available non-zero " + f"blocks are: {self.blocks_nonzero}.") + return self._tensors[block] + + def __getattr__(self, attr): + return self.__getitem__(b.__getattr__(attr)) + + def __setattr__(self, attr, value): + try: + self.__setitem__(b.__getattr__(attr), value) + except AttributeError: + super().__setattr__(attr, value) + + def set_zero_block(self, block): + """ + Set a given block as zero block + """ + if block not in self.blocks: + raise KeyError(f"Invalid block {block} set as zero block. " + f"Available blocks are: {self.blocks}.") + self._tensors.pop(block) + + def __transform_to_ao(self, refstate_or_coefficients): + if not len(self.blocks_nonzero): + raise ValueError("At least one non-zero block is needed to " + "transform the OneParticleOperator.") + if isinstance(refstate_or_coefficients, libadcc.ReferenceState): + hf = refstate_or_coefficients + coeff_map = {} + for sp in self.orbital_subspaces: + coeff_map[sp + "_a"] = hf.orbital_coefficients_alpha(sp + "b") + coeff_map[sp + "_b"] = hf.orbital_coefficients_beta(sp + "b") + else: + coeff_map = refstate_or_coefficients + + g2_ao_1 = 0 + g2_ao_2 = 0 + transf = "ip,jq,ijkl,kr,ls->pqrs" + cc = coeff_map + for block in self.blocks_nonzero: + s1, s2, s3, s4 = split_spaces(block) + ten = self[block] + aaaa = einsum(transf, cc[f"{s1}_a"], cc[f"{s2}_a"], + ten, cc[f"{s3}_a"], cc[f"{s4}_a"]) + bbbb = einsum(transf, cc[f"{s1}_b"], cc[f"{s2}_b"], + ten, cc[f"{s3}_b"], cc[f"{s4}_b"]) + g2_ao_1 += ( + + aaaa + + bbbb + + einsum(transf, cc[f"{s1}_a"], cc[f"{s2}_b"], + ten, cc[f"{s3}_a"], cc[f"{s4}_b"]) # abab + + einsum(transf, cc[f"{s1}_b"], cc[f"{s2}_a"], + ten, cc[f"{s3}_b"], cc[f"{s4}_a"]) # baba + ) + g2_ao_2 += ( + + aaaa + + bbbb + + einsum(transf, cc[f"{s1}_a"], cc[f"{s2}_b"], + ten, cc[f"{s3}_b"], cc[f"{s4}_a"]) # abba + + einsum(transf, cc[f"{s1}_b"], cc[f"{s2}_a"], + ten, cc[f"{s3}_a"], cc[f"{s4}_b"]) # baab + ) + return (g2_ao_1.evaluate(), g2_ao_2.evaluate()) + + def to_ao_basis(self, refstate_or_coefficients=None): + """ + Transform the density to the AO basis for contraction + with two-electron integrals. + ALL coefficients are already accounted for in the density matrix. + Two blocks are returned, the first one needs to be contracted with + prqs, the second one with -psqr (in Chemists' notation). + """ + if isinstance(refstate_or_coefficients, (dict, libadcc.ReferenceState)): + return self.__transform_to_ao(refstate_or_coefficients) + elif refstate_or_coefficients is None: + if not hasattr(self, "reference_state"): + raise ValueError("Argument reference_state is required if no " + "reference_state is stored in the " + "OneParticleOperator") + return self.__transform_to_ao(self.reference_state) + else: + raise TypeError("Argument type not supported.") + + def __iadd__(self, other): + if self.mospaces != other.mospaces: + raise ValueError("Cannot add TwoParticleDensityMatrices with " + "differing mospaces.") + + for bl in other.blocks_nonzero: + if self.is_zero_block(bl): + self[bl] = other.block(bl).copy() + else: + self[bl] = self.block(bl) + other.block(bl) + + # Update ReferenceState pointer + if hasattr(self, "reference_state"): + if hasattr(other, "reference_state") \ + and self.reference_state != other.reference_state: + delattr(self, "reference_state") + return self + + def __isub__(self, other): + if self.mospaces != other.mospaces: + raise ValueError("Cannot subtract OneParticleOperators with " + "differing mospaces.") + + for bl in other.blocks_nonzero: + if self.is_zero_block(bl): + self[bl] = -1.0 * other.block(bl) # The copy is implicit + else: + self[bl] = self.block(bl) - other.block(bl) + + # Update ReferenceState pointer + if hasattr(self, "reference_state"): + if hasattr(other, "reference_state") \ + and self.reference_state != other.reference_state: + delattr(self, "reference_state") + return self + + def __imul__(self, other): + if not isinstance(other, (float, int)): + return NotImplemented + for bl in self.blocks_nonzero: + self[bl] = self.block(bl) * other + return self + + def __add__(self, other): + return self.copy().__iadd__(other) + + def __sub__(self, other): + return self.copy().__isub__(other) + + def __mul__(self, other): + return self.copy().__imul__(other) + + def __rmul__(self, other): + return self.copy().__imul__(other) + + def evaluate(self): + for bl in self.blocks_nonzero: + self.block(bl).evaluate() + return self diff --git a/adcc/gradients/__init__.py b/adcc/gradients/__init__.py new file mode 100644 index 000000000..4e952d220 --- /dev/null +++ b/adcc/gradients/__init__.py @@ -0,0 +1,106 @@ +#!/usr/bin/env python3 +## vi: tabstop=4 shiftwidth=4 softtabstop=4 expandtab +## --------------------------------------------------------------------- +## +## Copyright (C) 2021 by the adcc authors +## +## This file is part of adcc. +## +## adcc is free software: you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published +## by the Free Software Foundation, either version 3 of the License, or +## (at your option) any later version. +## +## adcc is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with adcc. If not, see . +## +## --------------------------------------------------------------------- +import numpy as np + +from adcc.LazyMp import LazyMp +from adcc.Excitation import Excitation +from adcc.timings import Timer +from adcc.functions import einsum, evaluate + +from adcc.OneParticleOperator import product_trace +from .TwoParticleDensityMatrix import TwoParticleDensityMatrix +from .orbital_response import ( + orbital_response, orbital_response_rhs, energy_weighted_density_matrix +) +from .amplitude_response import amplitude_relaxed_densities + + +class NuclearGradientResult: + def __init__(self, excitation_or_mp, g1, g2): + self.g1, self.g2 = g1, g2 + + @property + def relaxed_dipole_moment(self): + elec_dip = -1.0 * np.array( + [product_trace(self.g1, dip) + for dip in self.hf.operators.electric_dipole] + ) + return self.hf.nuclear_dipole + elec_dip + + +def nuclear_gradient(excitation_or_mp): + if isinstance(excitation_or_mp, LazyMp): + mp = excitation_or_mp + elif isinstance(excitation_or_mp, Excitation): + mp = excitation_or_mp.ground_state + else: + raise TypeError("") + + timer = Timer() + hf = mp.reference_state + with timer.record("amplitude_response"): + g1a, g2a = amplitude_relaxed_densities(excitation_or_mp) + + with timer.record("orbital_response"): + rhs = orbital_response_rhs(hf, g1a, g2a).evaluate() + l_ov = orbital_response(hf, rhs) + + # orbital-relaxed OPDM (without reference state) + g1o = g1a.copy() + g1o.ov = 0.5 * l_ov + # orbital-relaxed OPDM (including reference state) + g1 = g1o.copy() + g1 += hf.density + + with timer.record("energy_weighted_density_matrix"): + w = energy_weighted_density_matrix(hf, g1o, g2a) + + # build two-particle density matrices for contraction with TEI + with timer.record("form_tpdm"): + delta_ij = hf.density.oo + g2_hf = TwoParticleDensityMatrix(hf) + g2_hf.oooo = 0.25 * (- einsum("li,jk->ijkl", delta_ij, delta_ij) + + einsum("ki,jl->ijkl", delta_ij, delta_ij)) + + g2_oresp = TwoParticleDensityMatrix(hf) + g2_oresp.oooo = einsum("ij,kl->kilj", delta_ij, g1o.oo) + g2_oresp.ovov = einsum("ij,ab->iajb", delta_ij, g1o.vv) + g2_oresp.ooov = (- einsum("kj,ia->ijka", delta_ij, g1o.ov) + + einsum("ki,ja->ijka", delta_ij, g1o.ov)) + + # scale for contraction with integrals + g2a.oovv *= 0.5 + g2_total = evaluate(g2_hf + g2a + g2_oresp) + + with timer.record("transform_ao"): + g2_ao_1, g2_ao_2 = g2_total.to_ao_basis() + g2_ao_1, g2_ao_2 = g2_ao_1.to_ndarray(), g2_ao_2.to_ndarray() + g1_ao = sum(g1.to_ao_basis(hf)).to_ndarray() + w_ao = sum(w.to_ao_basis(hf)).to_ndarray() + + with timer.record("contract_integral_derivatives"): + Gradient = hf.gradient_provider.correlated_gradient( + g1_ao, w_ao, g2_ao_1, g2_ao_2 + ) + Gradient["timer"] = timer + return Gradient diff --git a/adcc/gradients/amplitude_response.py b/adcc/gradients/amplitude_response.py new file mode 100644 index 000000000..b1b3fdbab --- /dev/null +++ b/adcc/gradients/amplitude_response.py @@ -0,0 +1,147 @@ +#!/usr/bin/env python3 +## vi: tabstop=4 shiftwidth=4 softtabstop=4 expandtab +## --------------------------------------------------------------------- +## +## Copyright (C) 2021 by the adcc authors +## +## This file is part of adcc. +## +## adcc is free software: you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published +## by the Free Software Foundation, either version 3 of the License, or +## (at your option) any later version. +## +## adcc is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with adcc. If not, see . +## +## --------------------------------------------------------------------- +from adcc.functions import einsum, direct_sum, evaluate + +from .TwoParticleDensityMatrix import TwoParticleDensityMatrix +from adcc.OneParticleOperator import OneParticleOperator +from adcc.LazyMp import LazyMp +from adcc.Excitation import Excitation +import adcc.block as b + + +def t2bar_oovv_adc2(exci, g1a_adc0): + mp = exci.ground_state + hf = mp.reference_state + u = exci.excitation_vector + df_ia = mp.df(b.ov) + t2bar = ( + 0.5 * ( + hf.oovv + - 2.0 * einsum( + "ijcb,ac->ijab", hf.oovv, g1a_adc0.vv + ).antisymmetrise((2, 3)) + + 2.0 * einsum( + "kjab,ik->ijab", hf.oovv, g1a_adc0.oo + ).antisymmetrise((0, 1)) + + 4.0 * einsum( + "ia,jkbc,kc->ijab", u.ph, hf.oovv, u.ph + ).antisymmetrise((2, 3)).antisymmetrise((0, 1)) + ) / ( + 2.0 * direct_sum("ia+jb->ijab", df_ia, df_ia).symmetrise((0, 1)) + ) + ) + return t2bar + + +def ampl_relaxed_dms_adc1(exci): + hf = exci.reference_state + u = exci.excitation_vector + g1a = OneParticleOperator(hf) + g2a = TwoParticleDensityMatrix(hf) + g1a.oo = -1.0 * einsum("ia,ja->ij", u.ph, u.ph) + g1a.vv = +1.0 * einsum("ia,ib->ab", u.ph, u.ph) + g2a.ovov = -1.0 * einsum("ja,ib->iajb", u.ph, u.ph) + return g1a, g2a + + +def ampl_relaxed_dms_adc2(exci): + u = exci.excitation_vector + mp = exci.ground_state + g1a_adc1, g2a_adc1 = ampl_relaxed_dms_adc1(exci) + t2 = mp.t2(b.oovv) + t2bar = t2bar_oovv_adc2(exci, g1a_adc1).evaluate() + + g1a = g1a_adc1.copy() + g1a.oo += ( + - 2.0 * einsum('jkab,ikab->ij', u.pphh, u.pphh) + - 2.0 * einsum('jkab,ikab->ij', t2bar, t2).symmetrise((0, 1)) + ) + g1a.vv += ( + + 2.0 * einsum("ijac,ijbc->ab", u.pphh, u.pphh) + + 2.0 * einsum("ijac,ijbc->ab", t2bar, t2).symmetrise((0, 1)) + ) + + g2a = g2a_adc1.copy() + ru_ov = einsum("ijab,jb->ia", t2, u.ph) + g2a.oovv = ( + 0.5 * ( + - 1.0 * t2 + + 2.0 * einsum("ijcb,ca->ijab", t2, g1a_adc1.vv).antisymmetrise((2, 3)) + - 2.0 * einsum("kjab,ki->ijab", t2, g1a_adc1.oo).antisymmetrise((0, 1)) + - 4.0 * einsum( + "ia,jb->ijab", u.ph, ru_ov + ).antisymmetrise((0, 1)).antisymmetrise((2, 3)) + ) + - 2.0 * t2bar + ) + g2a.ooov = -2.0 * einsum("kb,ijab->ijka", u.ph, u.pphh) + g2a.ovvv = -2.0 * einsum("ja,ijbc->iabc", u.ph, u.pphh) + return g1a, g2a + + +def ampl_relaxed_dms_mp2(mp): + hf = mp.reference_state + t2 = mp.t2(b.oovv) + g1a = OneParticleOperator(hf) + g2a = TwoParticleDensityMatrix(hf) + g1a.oo = -0.5 * einsum('ikab,jkab->ij', t2, t2) + g1a.vv = 0.5 * einsum('ijac,ijbc->ab', t2, t2) + g2a.oovv = -1.0 * mp.t2(b.oovv) + return g1a, g2a + + +DISPATCH = { + "mp2": ampl_relaxed_dms_mp2, + "adc1": ampl_relaxed_dms_adc1, + "adc2": ampl_relaxed_dms_adc2, +} + + +def amplitude_relaxed_densities(excitation_or_mp): + """Computation of amplitude-relaxed one- and two-particle density matrices + + Parameters + ---------- + excitation_or_mp : LazyMp, Excitation + Data for which the densities are requested, either LazyMp for ground + state densities or Excitation for excited state densities + + Returns + ------- + (OneParticleOperator, TwoParticleDensityMatrix) + Tuple of amplitude-relaxed one- and two-particle density matrices + + Raises + ------ + NotImplementedError + if density matrices are not implemented for a given method + """ + if isinstance(excitation_or_mp, LazyMp): + method_name = "mp2" + elif isinstance(excitation_or_mp, Excitation): + method_name = excitation_or_mp.method.name + if method_name not in DISPATCH: + raise NotImplementedError("Amplitude response is not " + f"implemented for {method_name}.") + g1a, g2a = DISPATCH[method_name](excitation_or_mp) + return evaluate(g1a), evaluate(g2a) diff --git a/adcc/gradients/orbital_response.py b/adcc/gradients/orbital_response.py new file mode 100644 index 000000000..4927fb586 --- /dev/null +++ b/adcc/gradients/orbital_response.py @@ -0,0 +1,167 @@ +#!/usr/bin/env python3 +## vi: tabstop=4 shiftwidth=4 softtabstop=4 expandtab +## --------------------------------------------------------------------- +## +## Copyright (C) 2021 by the adcc authors +## +## This file is part of adcc. +## +## adcc is free software: you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published +## by the Free Software Foundation, either version 3 of the License, or +## (at your option) any later version. +## +## adcc is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with adcc. If not, see . +## +## --------------------------------------------------------------------- +import adcc.block as b +from adcc.OneParticleOperator import OneParticleOperator +from adcc.functions import direct_sum, einsum, evaluate + +from adcc.solver.conjugate_gradient import conjugate_gradient, default_print + + +def orbital_response_rhs(hf, g1a, g2a): + """ + Build the right-hand side for solving the orbital + response given amplitude-relaxed density matrices (method-specific) + """ + # TODO: only add non-zero blocks to equations! + + # equal to the ov block of the energy-weighted density + # matrix when lambda_ov multipliers are zero + w_ov = 0.5 * ( + + 1.0 * einsum("ijkl,klja->ia", hf.oooo, g2a.ooov) + # - 1.0 * einsum("ibcd,abcd->ia", hf.ovvv, g2a.vvvv) + - 1.0 * einsum("jkib,jkab->ia", hf.ooov, g2a.oovv) + + 2.0 * einsum("ijkb,jakb->ia", hf.ooov, g2a.ovov) + + 1.0 * einsum("ijbc,jabc->ia", hf.oovv, g2a.ovvv) + - 2.0 * einsum("ibjc,jcab->ia", hf.ovov, g2a.ovvv) + ) + w_ov = w_ov.evaluate() + + ret = -1.0 * ( + 2.0 * w_ov + # - 1.0 * einsum("klja,ijkl->ia", hf.ooov, g2a.oooo) + + 1.0 * einsum("abcd,ibcd->ia", hf.vvvv, g2a.ovvv) + - 2.0 * einsum("jakb,ijkb->ia", hf.ovov, g2a.ooov) + + 1.0 * einsum("jkab,jkib->ia", hf.oovv, g2a.ooov) + + 2.0 * einsum("jcab,ibjc->ia", hf.ovvv, g2a.ovov) + - 1.0 * einsum("jabc,ijbc->ia", hf.ovvv, g2a.oovv) + + 2.0 * einsum("jika,jk->ia", hf.ooov, g1a.oo) + + 2.0 * einsum("icab,bc->ia", hf.ovvv, g1a.vv) + ) + return ret + + +def energy_weighted_density_matrix(hf, g1o, g2a): + gi_oo = -0.5 * ( + # + 1.0 * einsum("jklm,iklm->ij", hf.oooo, g2a.oooo) + + 1.0 * einsum("jabc,iabc->ij", hf.ovvv, g2a.ovvv) + + 1.0 * einsum("klja,klia->ij", hf.ooov, g2a.ooov) + + 2.0 * einsum("jkla,ikla->ij", hf.ooov, g2a.ooov) + + 1.0 * einsum("jkab,ikab->ij", hf.oovv, g2a.oovv) + + 2.0 * einsum("jakb,iakb->ij", hf.ovov, g2a.ovov) + ) + gi_vv = -0.5 * ( + + 1.0 * einsum("kjib,kjia->ab", hf.ooov, g2a.ooov) + # + einsum("bcde,acde->ab", hf.vvvv, g2a.vvvv) + + 1.0 * einsum("ijcb,ijca->ab", hf.oovv, g2a.oovv) + + 2.0 * einsum("jcib,jcia->ab", hf.ovov, g2a.ovov) + + 1.0 * einsum("ibcd,iacd->ab", hf.ovvv, g2a.ovvv) + + 2.0 * einsum("idcb,idca->ab", hf.ovvv, g2a.ovvv) + ) + gi_oo = gi_oo.evaluate() + gi_vv = gi_vv.evaluate() + w = OneParticleOperator(hf) + w.ov = 0.5 * ( + - 2.0 * einsum("ij,ja->ia", hf.foo, g1o.ov) + + 1.0 * einsum("ijkl,klja->ia", hf.oooo, g2a.ooov) + # - 1.0 * einsum("ibcd,abcd->ia", hf.ovvv, g2a.vvvv) + - 1.0 * einsum("jkib,jkab->ia", hf.ooov, g2a.oovv) + + 2.0 * einsum("ijkb,jakb->ia", hf.ooov, g2a.ovov) + + 1.0 * einsum("ijbc,jabc->ia", hf.oovv, g2a.ovvv) + - 2.0 * einsum("ibjc,jcab->ia", hf.ovov, g2a.ovvv) + ) + w.oo = ( + + gi_oo - hf.foo + - einsum("ik,jk->ij", g1o.oo, hf.foo) + - einsum("ikjl,kl->ij", hf.oooo, g1o.oo) + - einsum("ikja,ka->ij", hf.ooov, g1o.ov) + - einsum("jkia,ka->ij", hf.ooov, g1o.ov) + - einsum("jaib,ab->ij", hf.ovov, g1o.vv) + ) + w.vv = gi_vv - einsum("ac,cb->ab", g1o.vv, hf.fvv) + return evaluate(w) + + +class OrbitalResponseMatrix: + def __init__(self, hf): + if hf.has_core_occupied_space: + raise NotImplementedError("OrbitalResponseMatrix not implemented " + "for CVS reference state.") + self.hf = hf + + @property + def shape(self): + no1 = self.hf.n_orbs(b.o) + nv1 = self.hf.n_orbs(b.v) + size = no1 * nv1 + return (size, size) + + def __matmul__(self, l_ov): + ret = ( + + einsum("ab,ib->ia", self.hf.fvv, l_ov) + - einsum("ij,ja->ia", self.hf.foo, l_ov) + + einsum("ijab,jb->ia", self.hf.oovv, l_ov) + - einsum("ibja,jb->ia", self.hf.ovov, l_ov) + ) + # TODO: generalize once other solvent methods are available + if "pe_induction_elec" in self.hf.operators.density_dependent_operators: + # PE contribution to the orbital Hessian + ops = self.hf.operators + dm = OneParticleOperator(self.hf, is_symmetric=True) + dm.ov = l_ov + ret += ops.density_dependent_operators["pe_induction_elec"](dm).ov + return evaluate(ret) + + +class OrbitalResponsePinv: + def __init__(self, hf): + if hf.has_core_occupied_space: + raise NotImplementedError("OrbitalResponsePinv not implemented " + "for CVS reference state.") + fo = hf.fock(b.oo).diagonal() + fv = hf.fock(b.vv).diagonal() + self.df = direct_sum("-i+a->ia", fo, fv).evaluate() + + @property + def shape(self): + no1 = self.hf.n_orbs(b.o) + nv1 = self.hf.n_orbs(b.v) + size = no1 * nv1 + return (size, size) + + def __matmul__(self, invec): + return invec / self.df + + +def orbital_response(hf, rhs): + """ + Solves the orbital response equations + for a given reference state and right-hand side + """ + # TODO: pass solver arguments + A = OrbitalResponseMatrix(hf) + Pinv = OrbitalResponsePinv(hf) + x0 = (Pinv @ rhs).evaluate() + l_ov = conjugate_gradient(A, rhs=rhs, x0=x0, Pinv=Pinv, + explicit_symmetrisation=None, + callback=default_print) + return l_ov.solution diff --git a/adcc/solver/conjugate_gradient.py b/adcc/solver/conjugate_gradient.py index 77982cc3e..86bbc4eb2 100644 --- a/adcc/solver/conjugate_gradient.py +++ b/adcc/solver/conjugate_gradient.py @@ -143,7 +143,7 @@ def is_converged(state): state.solution = x0 state.residual = evaluate(rhs - matrix @ state.solution) state.n_applies += 1 - state.residual_norm = np.sqrt(state.residual @ state.residual) + state.residual_norm = np.sqrt(state.residual.dot(state.residual)) pk = zk = Pinv @ state.residual if explicit_symmetrisation: @@ -166,7 +166,7 @@ def is_converged(state): residual_old = state.residual state.residual = evaluate(residual_old - ak * Apk) - state.residual_norm = np.sqrt(state.residual @ state.residual) + state.residual_norm = np.sqrt(state.residual.dot(state.residual)) callback(state, "next_iter") if is_converged(state): diff --git a/adcc/test_ExcitedStates.py b/adcc/test_ExcitedStates.py index b4d1e0b3c..cbb1aebf5 100644 --- a/adcc/test_ExcitedStates.py +++ b/adcc/test_ExcitedStates.py @@ -42,7 +42,8 @@ def base_test(self, system, method, kind): if key.startswith("_"): continue blacklist = ["__", "index", "_ao", "excitation_vector", - "method", "parent_state"] + "method", "parent_state", "ground_state", + "reference_state"] if any(b in key for b in blacklist): continue try: From 5e2e7b3c1077621ac821b44033858d7d002dc9e4 Mon Sep 17 00:00:00 2001 From: Maximilian Scheurer Date: Sat, 16 Jan 2021 12:46:39 +0100 Subject: [PATCH 02/18] add basis gradient tests lgtm and coveralls (hopefully) more fdiff fix --- adcc/backends/psi4.py | 2 - adcc/gradients/orbital_response.py | 4 +- .../gradients/test_functionality_gradients.py | 75 ++ adcc/testdata/cache.py | 1 + adcc/testdata/dump_fdiff_gradient.py | 139 ++++ adcc/testdata/grad_dump.yml | 717 ++++++++++++++++++ 6 files changed, 934 insertions(+), 4 deletions(-) create mode 100644 adcc/gradients/test_functionality_gradients.py create mode 100644 adcc/testdata/dump_fdiff_gradient.py create mode 100644 adcc/testdata/grad_dump.yml diff --git a/adcc/backends/psi4.py b/adcc/backends/psi4.py index 214f32b17..45d02da36 100644 --- a/adcc/backends/psi4.py +++ b/adcc/backends/psi4.py @@ -82,10 +82,8 @@ def correlated_gradient(self, g1_ao, w_ao, g2_ao_1, g2_ao_2): # Build TE contributions for atom in range(natoms): - string = "TEI" + str(atom) deriv2 = self.mints.ao_tei_deriv1(atom) for p in range(3): - map_key = string + cart[p] deriv2_np = np.asarray(deriv2[p]) Gradient["TEI"][atom, p] += np.einsum( 'pqrs,prqs->', g2_ao_1, deriv2_np, optimize=True diff --git a/adcc/gradients/orbital_response.py b/adcc/gradients/orbital_response.py index 4927fb586..e575b7df3 100644 --- a/adcc/gradients/orbital_response.py +++ b/adcc/gradients/orbital_response.py @@ -123,12 +123,12 @@ def __matmul__(self, l_ov): - einsum("ibja,jb->ia", self.hf.ovov, l_ov) ) # TODO: generalize once other solvent methods are available - if "pe_induction_elec" in self.hf.operators.density_dependent_operators: + if self.hf.environment == "pe": # PE contribution to the orbital Hessian ops = self.hf.operators dm = OneParticleOperator(self.hf, is_symmetric=True) dm.ov = l_ov - ret += ops.density_dependent_operators["pe_induction_elec"](dm).ov + ret += ops.pe_induction_elec(dm).ov return evaluate(ret) diff --git a/adcc/gradients/test_functionality_gradients.py b/adcc/gradients/test_functionality_gradients.py new file mode 100644 index 000000000..80abe4405 --- /dev/null +++ b/adcc/gradients/test_functionality_gradients.py @@ -0,0 +1,75 @@ +#!/usr/bin/env python3 +## vi: tabstop=4 shiftwidth=4 softtabstop=4 expandtab +## --------------------------------------------------------------------- +## +## Copyright (C) 2020 by the adcc authors +## +## This file is part of adcc. +## +## adcc is free software: you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published +## by the Free Software Foundation, either version 3 of the License, or +## (at your option) any later version. +## +## adcc is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with adcc. If not, see . +## +## --------------------------------------------------------------------- +import unittest +import itertools +import adcc +import adcc.backends + +from numpy.testing import assert_allclose + +import pytest + +from ..misc import expand_test_templates +from adcc.backends.testing import cached_backend_hf +from adcc.testdata.cache import gradient_data + + +backends = [b for b in adcc.backends.available() + if b not in ["molsturm", "veloxchem"]] +molecules = ["h2o"] +basissets = ["sto3g", "ccpvdz"] +methods = ["mp2", "adc1", "adc2"] +combinations = list(itertools.product(molecules, basissets, methods, backends)) + + +@pytest.mark.skipif(len(backends) == 0, reason="No backend found.") +@expand_test_templates(combinations) +class TestNuclearGradients(unittest.TestCase): + def template_nuclear_gradient(self, molecule, basis, method, backend): + grad_ref = gradient_data[molecule][basis][method] + + energy_ref = grad_ref["energy"] + grad_fdiff = grad_ref["gradient"] + + scfres = cached_backend_hf(backend, molecule, basis, conv_tol=1e-13) + if "adc" in method: + # TODO: convergence needs to be very very tight... + # so we want to make sure all vectors are tightly converged + n_limit = 5 + state = adcc.run_adc(scfres, method=method, + n_singlets=10, conv_tol=1e-11) + for ee in state.excitations[:n_limit]: + grad = adcc.nuclear_gradient(ee) + assert_allclose(energy_ref[ee.index], ee.total_energy, atol=1e-10) + assert_allclose( + grad_fdiff[ee.index], grad["Total"], atol=1e-7 + ) + else: + # MP2 gradients + refstate = adcc.ReferenceState(scfres) + mp = adcc.LazyMp(refstate) + grad = adcc.nuclear_gradient(mp) + assert_allclose(energy_ref, mp.energy(2), atol=1e-8) + assert_allclose( + grad_fdiff, grad["Total"], atol=1e-8 + ) diff --git a/adcc/testdata/cache.py b/adcc/testdata/cache.py index 6810dca5f..3429b8206 100644 --- a/adcc/testdata/cache.py +++ b/adcc/testdata/cache.py @@ -273,3 +273,4 @@ def read_yaml_data(fname): tmole_data = read_yaml_data("tmole_dump.yml") psi4_data = read_yaml_data("psi4_dump.yml") pyscf_data = read_yaml_data("pyscf_dump.yml") +gradient_data = read_yaml_data("grad_dump.yml") diff --git a/adcc/testdata/dump_fdiff_gradient.py b/adcc/testdata/dump_fdiff_gradient.py new file mode 100644 index 000000000..16da630eb --- /dev/null +++ b/adcc/testdata/dump_fdiff_gradient.py @@ -0,0 +1,139 @@ +#!/usr/bin/env python3 +## vi: tabstop=4 shiftwidth=4 softtabstop=4 expandtab +## --------------------------------------------------------------------- +## +## Copyright (C) 2021 by the adcc authors +## +## This file is part of adcc. +## +## adcc is free software: you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published +## by the Free Software Foundation, either version 3 of the License, or +## (at your option) any later version. +## +## adcc is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with adcc. If not, see . +## +## --------------------------------------------------------------------- +import itertools +import adcc +import numpy as np +import yaml +from tqdm import tqdm + +from pyscf import gto + +from static_data import xyz + + +prefactors_5p = np.array([1.0, -8.0, 8.0, -1.0]) / 12.0 +multipliers_5p = [-2, -1, 1, 2] +coords_label = ["x", "y", "z"] + + +def _molstring(elems, coords): + s = "" + for kk, (i, c) in enumerate(zip(elems, coords)): + s += f"{i} {c[0]} {c[1]} {c[2]}" + if kk != len(elems) - 1: + s += "\n" + return s + + +def adc_energy(scfres, method, **kwargs): + state = adcc.run_adc(method=method, data_or_matrix=scfres, + output=None, **kwargs) + return state.total_energy + + +def mp_energy(scfres, method, **kwargs): + level = { + "mp2": 2, + "mp3": 3, + } + refstate = adcc.ReferenceState(scfres) + return adcc.LazyMp(refstate).energy(level[method]) + + +def fdiff_gradient(molstring, method, basis, step=1e-4, **kwargs): + m = gto.M(atom=molstring, unit='Bohr', basis=basis) + coords = m.atom_coords().copy() + elements = m.elements.copy() + + n_grads = kwargs.get("n_singlets", 1) + conv_tol = kwargs.get("conv_tol", 1e-10) / 10 + + # run unperturbed system + scfres = adcc.backends.run_hf( + 'pyscf', molstring, basis, conv_tol=conv_tol, conv_tol_grad=conv_tol + ) + if "adc" in method: + en = adc_energy(scfres, method, **kwargs) + else: + en = mp_energy(scfres, method, **kwargs) + + natoms = len(elements) + grad = np.zeros((n_grads, natoms, 3)) + at_c = list(itertools.product(range(natoms), range(3))) + for i, c in tqdm(at_c): + for f, p in zip(multipliers_5p, prefactors_5p): + coords_p = coords.copy() + coords_p[i, c] += f * step + geom_p = _molstring(elements, coords_p) + scfres = adcc.backends.run_hf( + 'pyscf', geom_p, basis, conv_tol=conv_tol, conv_tol_grad=conv_tol + ) + if "adc" in method: + en_pert = adc_energy(scfres, method, **kwargs) + else: + en_pert = mp_energy(scfres, method, **kwargs) + grad[:, i, c] += p * en_pert / step + return en, grad + + +def main(): + config_excited = { + "n_singlets": 5, + } + basissets = [ + "sto3g", + "ccpvdz", + ] + methods = [ + "mp2", + "adc1", + "adc2", + ] + molecules = ["h2o", "hf", "formaldehyde"] + ret = {} + for molecule in molecules: + ret[molecule] = {} + for basis in basissets: + ret[molecule][basis] = {} + for method in methods: + kwargs = { + "conv_tol": 1e-8, + } + if "adc" in method: + kwargs.update(config_excited) + basename = f"{molecule}_{basis}_{method}" + print(f"Evaluating finite difference gradient for {basename}.") + en, grad = fdiff_gradient(xyz[molecule], method, basis, **kwargs) + if isinstance(en, np.ndarray): + en = en.tolist() + cont = { + "energy": en, + "gradient": np.squeeze(grad).tolist(), + } + ret[molecule][basis][method] = cont + with open("grad_dump.yml", "w") as yamlout: + yaml.safe_dump(ret, yamlout) + + +if __name__ == "__main__": + main() diff --git a/adcc/testdata/grad_dump.yml b/adcc/testdata/grad_dump.yml new file mode 100644 index 000000000..f24064ae8 --- /dev/null +++ b/adcc/testdata/grad_dump.yml @@ -0,0 +1,717 @@ +formaldehyde: + ccpvdz: + adc1: + energy: + - -113.70558203635709 + - -113.50558431199366 + - -113.49341052539295 + - -113.4921906128972 + - -113.43838517589901 + gradient: + - - - 0.004440058954060078 + - -0.08440320886438712 + - 0.061171111461590044 + - - -0.0046579049521824345 + - 0.08556581632001325 + - -0.06425038322049659 + - - -0.00018499072757549584 + - -0.003402824906515889 + - -0.002396157040493563 + - - 0.00040283604175783694 + - 0.002240217392682098 + - 0.0054754264710936695 + - - - 0.014108372910413891 + - -0.26049620006233454 + - 0.19367707810306456 + - - -0.012959809566382319 + - 0.2366245447192341 + - -0.17844389395031612 + - - -0.0014201861922629178 + - 0.0031937859166646376 + - -0.018929093901533633 + - - 0.0002716220624279231 + - 0.020677869601058774 + - 0.003695907857036218 + - - - 0.01106323792191688 + - -0.20612725264800247 + - 0.1539881363278255 + - - -0.012415087621775456 + - 0.22842276237497572 + - -0.17184760025702417 + - - 4.062271909788251e-05 + - -0.018368309567449614 + - 0.00045038078678771853 + - - 0.0013112259184708819 + - -0.003927204335923307 + - 0.017409080843208358 + - - - -0.007417373723001219 + - 0.13012286479352042 + - -0.10184336615202483 + - - 0.004234577005263418 + - -0.07607176668534521 + - 0.05810191675845999 + - - -0.001716892686090432 + - -0.0594009895430645 + - -0.02237362222513184 + - - 0.004899689141893759 + - 0.005349896222469397 + - 0.06611506904300768 + - - - 0.003353650274220854 + - -0.0640643189108232 + - 0.04545981872070115 + - - -0.009704219817649573 + - 0.1790985528350575 + - -0.13405693606182467 + - - 0.001255770490388386 + - -0.07730495402938686 + - 0.018640203212271444 + - - 0.005094795822515152 + - -0.037729280651547015 + - 0.0699569108983269 + adc2: + energy: + - -114.04108709429852 + - -113.90116030505898 + - -113.84093754181639 + - -113.83275876700296 + - -113.78729359707486 + gradient: + - - - 0.00795411376748234 + - -0.14761182830261532 + - 0.10940460005076602 + - - -0.00861854647519067 + - 0.15725425074924715 + - -0.11885035762679763 + - - -0.00038722751196473837 + - -0.011867678796988912 + - -0.004902817323454656 + - - 0.0010516593320062384 + - 0.002225256263045594 + - 0.014348573065944947 + - - - 0.0022481144114863127 + - -0.04510061517066788 + - 0.03181697831314523 + - - -0.0042847725708270445 + - 0.07931772326992359 + - -0.059501681782421656 + - - -0.002496956309187226 + - -0.05234425392700359 + - -0.03315452564856969 + - - 0.004533617960987613 + - 0.01812714702100493 + - 0.060839227138785645 + - - - 0.012822667238651775 + - -0.23806948866695166 + - 0.17628057644469664 + - - -0.012922618945594877 + - 0.23657256651495118 + - -0.17811991584312636 + - - -0.0011136162065668032 + - -0.011240343621466309 + - -0.014638555672718212 + - - 0.001213567695231177 + - 0.01273726558429189 + - 0.016477893106639385 + - - - 0.006636413134401664 + - -0.12150684717926197 + - 0.09214128745952621 + - - -0.007791586889652535 + - 0.13977801451983396 + - -0.10773590055759996 + - - -0.0020652523526223376 + - -0.03424370722495951 + - -0.02755755910766311 + - - 0.0032204291637754068 + - 0.015972540670190938 + - 0.04315217011026107 + - - - 0.013698791502974927 + - -0.251412856116076 + - 0.1891322702722391 + - - -0.014349782286444679 + - 0.26074345722736325 + - -0.1981027886213269 + - - -0.0005066021985840052 + - -0.012612845370313153 + - -0.006683660205453634 + - - 0.0011628166976151988 + - 0.0032822444336488843 + - 0.01565417618257925 + mp2: + energy: -114.19562447602232 + gradient: + - - 0.0006307709263637662 + - -0.019193962754798122 + - 0.009753386213560589 + - - -0.0019824629416689277 + - 0.039011894245049916 + - -0.027773341484135017 + - - -0.00016380085435230285 + - -0.018570978703792207 + - -0.0022151207958813757 + - - 0.001515490803285502 + - -0.0012469533103285357 + - 0.020235072865034454 + sto3g: + adc1: + energy: + - -112.35215847657514 + - -112.19031679061341 + - -111.99509653412369 + - -111.88323868990281 + - -111.83938478075873 + gradient: + - - - 134.86789705506817 + - -0.034582075124490075 + - 0.020427761948667467 + - - 134.86667057021987 + - 0.052714954770635813 + - -0.03787164441018831 + - - 0.00025331013603135943 + - -0.01337217444961425 + - 0.0032829746487550437 + - - 0.0010667957249097526 + - -0.004760705487569794 + - 0.014160908656776883 + - - - 297.5504788887192 + - -0.034582075124490075 + - 0.02042776206508279 + - - 297.55109127634205 + - -1078.7981471754028 + - -0.03787164441018831 + - - 0.00025331013603135943 + - -0.01337217444961425 + - 0.0032829746487550437 + - - 0.0010667956084944308 + - -0.004760705487569794 + - 0.014160908656776883 + - - - 390.76501749145973 + - -0.034582075124490075 + - 0.020427761948667467 + - - 390.7668319265358 + - -2380.202243736072 + - -0.03787164441018831 + - - 0.00025331013603135943 + - -0.01337217444961425 + - 0.0032829746342031285 + - - 0.0010667956084944308 + - -0.004760705487569794 + - 0.014160908889607526 + - - - -786.4960951929388 + - -0.20038470218423754 + - 0.14833348176034633 + - - 292.43344181386055 + - -2046.8663960878475 + - -0.1458953901892528 + - - 0.00011068112507928163 + - 0.005674898813595064 + - 0.0014126732130534947 + - - -0.0002842362300725654 + - 0.0014252170512918383 + - -0.003850776600302197 + - - - -2099.6204833368683 + - -0.3076474006084027 + - 0.22782272301265039 + - - 280.7667978423997 + - -1037.8032912445778 + - -0.21819978098210413 + - - -0.0010586392600089312 + - 0.0016113087913254276 + - -0.01425015923450701 + - - 0.00035280417068861425 + - 0.016332442552084103 + - 0.004627213449566625 + adc2: + energy: + - -112.29308371327538 + - -112.08687577389874 + - -111.95501913710211 + - -111.94227341486139 + - -111.90760777025828 + gradient: + - - - 0.013361435267142951 + - -0.24680471101601142 + - 0.1840638013818534 + - - -0.014295267901616171 + - 0.26064838070305996 + - -0.19721643527736887 + - - -0.0002812701713992283 + - -0.014264499128330499 + - -0.003434756348724477 + - - 0.0012151370465289801 + - 0.0004208378813927993 + - 0.016587377016549 + - - - 0.014545091849868186 + - -0.27108486875658855 + - 0.20018935947155114 + - - -0.015414420442539267 + - 0.2825872143293964 + - -0.2125983986479696 + - - -0.001122399786254391 + - -0.021760659903520718 + - -0.014614149200497195 + - - 0.0019917527242796496 + - 0.010258322567096911 + - 0.02702318166848272 + - - - 0.015574866061797366 + - -0.2841585915739415 + - 0.21446659980574623 + - - -0.020418328887899406 + - 0.3722419853147585 + - -0.2819262643606635 + - - -0.0001184115099022165 + - -0.06981211320089642 + - -0.00022668807650916278 + - - 0.004961850616382435 + - -0.018271274529979564 + - 0.06768634595209733 + - - - 0.008447872693068348 + - -0.15336673270212486 + - 0.11524418441695161 + - - -0.016566408987273462 + - 0.30309375702927355 + - -0.2287056674977066 + - - 0.0015225222159642726 + - -0.10094543961167801 + - 0.022824064188171178 + - - 0.006595998158445582 + - -0.04878158635983709 + - 0.0906374234764371 + - - - 0.00431169880903326 + - -0.08202417510619853 + - 0.0608073133189464 + - - -0.013763464201474562 + - 0.25251537734584417 + - -0.19093284106929787 + - - -0.013066680257907137 + - -0.26406628522090614 + - -0.17279423588479403 + - - 0.0225185089657316 + - 0.09357509708206635 + - 0.3029197411815403 + mp2: + energy: -112.46495424382846 + gradient: + - - 0.0037697695079259574 + - -0.07685817136371043 + - 0.05298948941344861 + - - -0.006090689610573463 + - 0.11399357361369766 + - -0.08449994814873207 + - - -2.156686969101429e-05 + - -0.030690345840412192 + - -4.766431811731309e-05 + - - 0.0023424898099619895 + - -0.0064450563077116385 + - 0.03155812271870673 +h2o: + ccpvdz: + adc1: + energy: + - -75.68543998424987 + - -75.61931016166072 + - -75.59868950195046 + - -75.53275298660013 + - -75.45558187453754 + gradient: + - - - 0.0927401026856387 + - -7.275957614183426e-12 + - 0.06558009374566609 + - - -0.002630199545819778 + - 7.275957614183426e-12 + - -0.09467175448662601 + - - -0.090109874116024 + - -7.275957614183426e-12 + - 0.029091669573972467 + - - - 0.10931799972604495 + - -7.275957614183426e-12 + - 0.07809552933758823 + - - -0.006660687533440068 + - -7.275957614183426e-12 + - -0.10735300042870222 + - - -0.10265728522063 + - -2.1827872842550278e-11 + - 0.029257479851366952 + - - - 0.011670212486933451 + - 1.4551915228366852e-11 + - 0.0084512654793798 + - - 0.0568447552213911 + - -7.275957614183426e-12 + - -0.09296223078126786 + - - -0.06851510248088744 + - 7.275957614183426e-12 + - 0.08451095721829915 + - - - 0.02628810688474914 + - 2.1827872842550278e-11 + - 0.0192561547155492 + - - 0.05759759972715983 + - -1.4551915228366852e-11 + - -0.11000343628256815 + - - -0.08388586723594926 + - 1.4551915228366852e-11 + - 0.09074727105326019 + - - - 0.28210171702085063 + - 0.0 + - 0.19977481755631743 + - - -0.0784058679928421 + - 2.1827872842550278e-11 + - -0.1887100828025723 + - - -0.20369583381398115 + - 1.4551915228366852e-11 + - -0.011064729405916296 + adc2: + energy: + - -75.9296754081454 + - -75.85499790104548 + - -75.84309170282057 + - -75.76675240722146 + - -75.66953798873493 + gradient: + - - - 0.11448502987332176 + - -7.275957614183426e-12 + - 0.08113865628547501 + - - -0.008900619628548156 + - -5.093170329928398e-11 + - -0.10905678830749821 + - - -0.1055843778376584 + - 2.1827872842550278e-11 + - 0.027918141058762558 + - - - 0.11318147835117998 + - -7.275957614183426e-12 + - 0.0806558419499197 + - - -0.0044726167325279675 + - -1.4551915228366852e-11 + - -0.11437428160570562 + - - -0.10870887277997099 + - 7.275957614183426e-12 + - 0.033718444654368795 + - - - 0.02205561503797071 + - 0.0 + - 0.015903162260656245 + - - 0.05098408467893023 + - 1.4551915228366852e-11 + - -0.09580103932239581 + - - -0.07303977520496119 + - 7.275957614183426e-12 + - 0.07989787455153419 + - - - 0.020305528247263283 + - 0.0 + - 0.014960411695938092 + - - 0.05805036811216269 + - -1.4551915228366852e-11 + - -0.10423131706920685 + - - -0.07835603128478397 + - 7.275957614183426e-12 + - 0.08927089755161433 + - - - 0.26928592537296936 + - 2.1827872842550278e-11 + - 0.19073858212505002 + - - -0.07746150083403336 + - 2.1827872842550278e-11 + - -0.17647508150548674 + - - -0.1918244067055639 + - -2.1827872842550278e-11 + - -0.014263495162595063 + mp2: + energy: -76.22940338787204 + gradient: + - - 0.02439544230583124 + - -2.9103830456733704e-11 + - 0.017738174385158345 + - - -0.010762452344351914 + - 1.4551915228366852e-11 + - -0.011150372949487064 + - - -0.013632995360239875 + - -7.275957614183426e-12 + - -0.006587801886780653 + sto3g: + adc1: + energy: + - -74.47588319597438 + - -74.38511885048017 + - -74.3571822920925 + - -74.2490420036088 + - -74.13327522706486 + gradient: + - - - 0.2519565806724131 + - -1.4551915228366852e-11 + - 0.17643764430249576 + - - 0.04383796844922472 + - 1.4551915228366852e-11 + - -0.32756816375331255 + - - -0.2957945393209229 + - -2.1827872842550278e-11 + - 0.15113050528452732 + - - - 0.4420401885145111 + - -2.9103830456733704e-11 + - 0.31597313308157027 + - - -0.08205663535773056 + - -7.275957614183426e-12 + - -0.35633137811964843 + - - -0.35998354491312057 + - 2.1827872842550278e-11 + - 0.04035823367303237 + - - - 0.10246271751384484 + - -2.1827872842550278e-11 + - 0.07140889731817879 + - - 0.11964530679688323 + - -1.4551915228366852e-11 + - -0.2768456041376339 + - - -0.22210801561595872 + - 7.275957614183426e-12 + - 0.20543669633480022 + - - - 0.3338767071109032 + - 1.4551915228366852e-11 + - 0.23875348844012478 + - - -2.251137630082667e-05 + - 0.0 + - -0.3568454495543847 + - - -0.33385419509431813 + - -2.9103830456733704e-11 + - 0.11809195824025664 + - - - 0.42701523288997123 + - 0.0 + - 0.30206555198674323 + - - -0.0510407709152787 + - -7.275957614183426e-12 + - -0.3809664128420991 + - - -0.37597446207655594 + - 0.0 + - 0.07890085934195668 + adc2: + energy: + - -74.52306494758602 + - -74.42102314285322 + - -74.39990473420288 + - -74.28060927293537 + - -74.15388076828575 + gradient: + - - - 0.27296631058561616 + - 2.9103830456733704e-11 + - 0.19153598658158444 + - - 0.04375171761785168 + - 2.9103830456733704e-11 + - -0.3499776713724714 + - - -0.3167180179952993 + - 7.275957614183426e-12 + - 0.15844167019531596 + - - - 0.46611143292102497 + - -7.275957614183426e-12 + - 0.332718367826601 + - - -0.08526563550549326 + - 7.275957614183426e-12 + - -0.377055163771729 + - - -0.3808457903069211 + - -1.6007106751203537e-10 + - 0.04433678551140474 + - - - 0.1245402002314222 + - 1.4551915228366852e-11 + - 0.08709251808613772 + - - 0.11524764178466285 + - -1.4551915228366852e-11 + - -0.29412154671445023 + - - -0.23978783340135124 + - 7.275957614183426e-12 + - 0.20702901783079142 + - - - 0.344924942983198 + - -2.1827872842550278e-11 + - 0.2464642068516696 + - - -0.001407823758199811 + - 0.0 + - -0.3665060569619527 + - - -0.34351711843919475 + - 2.1827872842550278e-11 + - 0.1200418468870339 + - - - 0.43142601163708605 + - 2.1827872842550278e-11 + - 0.3051797001535306 + - - -0.050288449914660305 + - -1.4551915228366852e-11 + - -0.38670489951618947 + - - -0.38113756212987937 + - 7.275957614183426e-12 + - 0.08152519822033355 + mp2: + energy: -74.99357808910268 + gradient: + - - 0.09648089321126463 + - -2.1827872842550278e-11 + - 0.0688644905021647 + - - -0.026183462534390856 + - -7.275957614183426e-12 + - -0.06597386132489191 + - - -0.07029743238672381 + - 7.275957614183426e-12 + - -0.002890627903980203 +hf: + ccpvdz: + adc1: + energy: + - -99.68449862868913 + - -99.68449862864962 + - -99.50075872824259 + - -99.05905941167467 + - -99.05905941155399 + gradient: + - - - 4.3655745685100555e-11 + - -4.3655745685100555e-11 + - 0.05474575013795402 + - - 1.4551915228366852e-11 + - 1.4551915228366852e-11 + - -0.05474577005952597 + - - - 5.820766091346741e-11 + - -4.3655745685100555e-11 + - 0.05474574991967529 + - - 1.4551915228366852e-11 + - 2.9103830456733704e-11 + - -0.054745770030422136 + - - - -4.3655745685100555e-11 + - 4.3655745685100555e-11 + - 0.029345564864343032 + - - -4.3655745685100555e-11 + - 0.0 + - -0.029341923116589896 + - - - 7.275957614183426e-11 + - -4.3655745685100555e-11 + - -0.1574882440181682 + - - 2.9103830456733704e-11 + - 0.0 + - 0.15748825178889092 + - - - -5.820766091346741e-11 + - -4.3655745685100555e-11 + - -0.1574882423155941 + - - 4.3655745685100555e-11 + - 1.4551915228366852e-11 + - 0.15748825231275987 + adc2: + energy: + - -99.94395193294302 + - -99.9439519329312 + - -99.73699393315073 + - -99.43877070940161 + - -99.43877070915488 + gradient: + - - - 0.0 + - 5.820766091346741e-11 + - 0.07390241048415191 + - - 1.4551915228366852e-11 + - 0.0 + - -0.07390240793756675 + - - - -5.820766091346741e-11 + - 0.0 + - 0.07390241093526129 + - - -2.9103830456733704e-11 + - -4.3655745685100555e-11 + - -0.07390240782115143 + - - - -1.3096723705530167e-10 + - 5.820766091346741e-11 + - 0.04055179744318593 + - - -2.9103830456733704e-11 + - -4.3655745685100555e-11 + - -0.04055119516851846 + - - - 2.9103830456733704e-11 + - -4.3655745685100555e-11 + - -0.006900888605741784 + - - -4.3655745685100555e-11 + - 0.0 + - 0.00690086766553577 + - - - -1.4551915228366852e-11 + - 4.3655745685100555e-11 + - -0.006900887412484735 + - - -8.731149137020111e-11 + - -1.4551915228366852e-11 + - 0.0069008679274702445 + mp2: + energy: -100.14365279000066 + gradient: + - - 2.9103830456733704e-11 + - -4.3655745685100555e-11 + - -0.13385940197622404 + - - -2.9103830456733704e-11 + - 2.9103830456733704e-11 + - 0.13385939724685159 + sto3g: + adc1: + energy: + - -98.26160079719433 + - -98.26160079719432 + - -97.86355144712479 + - -97.20550168819246 + - -73.02590622379267 + gradient: + - - - -5.820766091346741e-11 + - 0.0 + - 0.0459835930087138 + - - 2.9103830456733704e-11 + - -2.9103830456733704e-11 + - -0.04598359337251168 + - - - -5.820766091346741e-11 + - 0.0 + - 0.0459835930087138 + - - 0.0 + - -2.9103830456733704e-11 + - -0.04598359337251168 + - - - -2.9103830456733704e-11 + - 0.0 + - 0.05563517109840177 + - - -2.9103830456733704e-11 + - -4.3655745685100555e-11 + - -0.055635170749155805 + - - - 2.9103830456733704e-11 + - -4.3655745685100555e-11 + - 0.07153463260328863 + - - -1.4551915228366852e-11 + - -4.3655745685100555e-11 + - -0.07153463290887885 + - - - 1.4551915228366852e-11 + - -7.275957614183426e-12 + - 0.009702209834358655 + - - 1.4551915228366852e-11 + - -1.4551915228366852e-11 + - -0.00970221107127145 + adc2: + energy: + - -98.30973760269728 + - -98.30973760269728 + - -97.88705005686671 + - -97.31155583033184 + - -96.96183479769606 + gradient: + - - - 1.1641532182693481e-10 + - -4.3655745685100555e-11 + - 0.08218655599921476 + - - 7.275957614183426e-11 + - 2.9103830456733704e-11 + - -0.08218655640666839 + - - - 0.0 + - 7.275957614183426e-11 + - 0.08218655599921476 + - - -4.3655745685100555e-11 + - 1.4551915228366852e-10 + - -0.08218655629025307 + - - - -1.1641532182693481e-10 + - 2.9103830456733704e-11 + - 0.04958453155995812 + - - 0.0 + - -2.9103830456733704e-11 + - -0.04958453113795258 + - - - 0.0 + - 5.820766091346741e-11 + - 0.15719162416644394 + - - -1.4551915228366852e-11 + - -5.820766091346741e-11 + - -0.15719162434106693 + - - - -2.9103830456733704e-11 + - -1.7462298274040222e-10 + - 0.4785101861489238 + - - 2.9103830456733704e-11 + - -5.820766091346741e-11 + - -0.47851018683286384 + mp2: + energy: -98.52261046811574 + gradient: + - - 0.0 + - 1.4551915228366852e-11 + - -0.14964825809875038 + - - 0.0 + - 0.0 + - 0.14964825844799634 From a72f71de9dd39e55d07e9049cf92a83ccf5ab967 Mon Sep 17 00:00:00 2001 From: iubr Date: Sun, 19 Sep 2021 14:56:12 +0900 Subject: [PATCH 03/18] started cvs-adc0 gradient hijacked AmplitudeVector for CVS-ADC orbital response. CVS-ADC0 working! cvs-adc1 working --- adcc/OneParticleOperator.py | 2 + adcc/backends/pyscf.py | 26 ++ adcc/gradients/TwoParticleDensityMatrix.py | 10 +- adcc/gradients/__init__.py | 65 +++-- adcc/gradients/amplitude_response.py | 44 ++++ adcc/gradients/orbital_response.py | 279 +++++++++++++++------ 6 files changed, 330 insertions(+), 96 deletions(-) diff --git a/adcc/OneParticleOperator.py b/adcc/OneParticleOperator.py index 422795437..4598f93cd 100644 --- a/adcc/OneParticleOperator.py +++ b/adcc/OneParticleOperator.py @@ -205,6 +205,8 @@ def copy(self): return ret def __transform_to_ao(self, refstate_or_coefficients): + #Iulia print: + print("HERE:\n",dir(self)) if not len(self.blocks_nonzero): raise ValueError("At least one non-zero block is needed to " "transform the OneParticleOperator.") diff --git a/adcc/backends/pyscf.py b/adcc/backends/pyscf.py index b8a9aa1f3..fab8cafee 100644 --- a/adcc/backends/pyscf.py +++ b/adcc/backends/pyscf.py @@ -49,6 +49,11 @@ def correlated_gradient(self, g1_ao, w_ao, g2_ao_1, g2_ao_2): Gradient["TEI"] = np.zeros((natoms, 3)) Gradient["Total"] = np.zeros((natoms, 3)) + # Iulia added variables; TODO: remove + ovlp_iulia = np.zeros((natoms, 3)) + hcore_iulia = np.zeros((natoms, 3)) + eri_iulia = np.zeros((natoms, 3)) + # TODO: does RHF/UHF matter here? gradient = grad.RHF(self.scfres) hcore_deriv = gradient.hcore_generator() @@ -67,10 +72,13 @@ def correlated_gradient(self, g1_ao, w_ao, g2_ao_1, g2_ao_2): Sx_a[:, k0:k1] = Sx[:, k0:k1] Sx_a += Sx_a.transpose(0, 2, 1) Gradient["S"][ia] += np.einsum("xpq,pq->x", Sx_a, w_ao) + ovlp_iulia[ia] += np.einsum("xpq,pq->x", Sx_a, w_ao) + # derivative of the core Hamiltonian Hx_a = hcore_deriv(ia) Gradient["T+V"][ia] += np.einsum("xpq,pq->x", Hx_a, g1_ao) + hcore_iulia[ia] += np.einsum("xpq,pq->x", Hx_a, g1_ao) # derivatives of the ERIs ERIx_a = np.zeros_like(ERIx) @@ -86,6 +94,24 @@ def correlated_gradient(self, g1_ao, w_ao, g2_ao_1, g2_ao_2): Gradient["TEI"][ia] -= np.einsum( "pqrs,xpsqr->x", g2_ao_2, ERIx_a, optimize=True ) + eri_iulia[ia] += ( + np.einsum("pqrs,xprqs->x", g2_ao_1, ERIx_a, optimize=True) + - np.einsum("pqrs,xpsqr->x", g2_ao_2, ERIx_a, optimize=True) + ) + + + # Iulia print TODO:remove + #print("2PDM_1 in AO:\n", g2_ao_1) + print("Hcore contribution to the gradient:") + print(hcore_iulia) + print() + print("Overlp contribution to the gradient:") + print(ovlp_iulia) + print() + print("ERI contribution to the gradient:") + print(eri_iulia) + print() + Gradient["N"] = gradient.grad_nuc() Gradient["OEI"] = Gradient["T+V"] + Gradient["S"] Gradient["Total"] = Gradient["OEI"] + Gradient["TEI"] + Gradient["N"] diff --git a/adcc/gradients/TwoParticleDensityMatrix.py b/adcc/gradients/TwoParticleDensityMatrix.py index 89cb3856f..1421e0284 100644 --- a/adcc/gradients/TwoParticleDensityMatrix.py +++ b/adcc/gradients/TwoParticleDensityMatrix.py @@ -39,8 +39,8 @@ def __init__(self, spaces): self.mospaces = spaces.mospaces else: self.mospaces = spaces - if self.mospaces.has_core_occupied_space: - raise NotImplementedError("TPDM not implemented for CVS.") +# if self.mospaces.has_core_occupied_space: +# raise NotImplementedError("TPDM not implemented for CVS.") # Set reference_state if possible if isinstance(spaces, libadcc.ReferenceState): self.reference_state = spaces @@ -59,6 +59,12 @@ def __init__(self, spaces): b.oooo, b.ooov, b.oovv, b.ovov, b.ovvv, b.vvvv, ] + if self.mospaces.has_core_occupied_space: + self.blocks += [ + b.cccc, b.ococ, b.oooo, b.cvcv, + b.ocov, b.cccv, b.cocv, b.ocoo, + b.ccco, + ] self._tensors = {} @property diff --git a/adcc/gradients/__init__.py b/adcc/gradients/__init__.py index 4e952d220..9dd99c79c 100644 --- a/adcc/gradients/__init__.py +++ b/adcc/gradients/__init__.py @@ -67,7 +67,14 @@ def nuclear_gradient(excitation_or_mp): # orbital-relaxed OPDM (without reference state) g1o = g1a.copy() - g1o.ov = 0.5 * l_ov + if hf.has_core_occupied_space: + # For CVS, the solution is stored in an Amplitude + # Vector object with th OV block stored in pphh + # and the CV block stored in ph + g1o.ov = 0.5 * l_ov['pphh'] + g1o.cv = 0.5 * l_ov['ph'] + else: + g1o.ov = 0.5 * l_ov # orbital-relaxed OPDM (including reference state) g1 = g1o.copy() g1 += hf.density @@ -77,20 +84,48 @@ def nuclear_gradient(excitation_or_mp): # build two-particle density matrices for contraction with TEI with timer.record("form_tpdm"): - delta_ij = hf.density.oo - g2_hf = TwoParticleDensityMatrix(hf) - g2_hf.oooo = 0.25 * (- einsum("li,jk->ijkl", delta_ij, delta_ij) - + einsum("ki,jl->ijkl", delta_ij, delta_ij)) - - g2_oresp = TwoParticleDensityMatrix(hf) - g2_oresp.oooo = einsum("ij,kl->kilj", delta_ij, g1o.oo) - g2_oresp.ovov = einsum("ij,ab->iajb", delta_ij, g1o.vv) - g2_oresp.ooov = (- einsum("kj,ia->ijka", delta_ij, g1o.ov) - + einsum("ki,ja->ijka", delta_ij, g1o.ov)) - - # scale for contraction with integrals - g2a.oovv *= 0.5 - g2_total = evaluate(g2_hf + g2a + g2_oresp) + if hf.has_core_occupied_space: + delta_ij = hf.density.oo + delta_IJ = hf.density.cc + g2_hf = TwoParticleDensityMatrix(hf) + + # I don't understand wy 0.25 is necessary for oooo, but 0.5 for cccc + # Doesn't make sense...; TODO: figure it out. + g2_hf.oooo = -0.25 * ( einsum("ik,jl->ijkl", delta_ij, delta_ij)) + g2_hf.cccc = -0.5 * ( einsum("IK,JL->IJKL", delta_IJ, delta_IJ)) + g2_hf.ococ = -1.0 * ( einsum("ik,JL->iJkL", delta_ij, delta_IJ)) + + # No idea why we need a 0.25 in front of the oooo block... + g2_oresp = TwoParticleDensityMatrix(hf) + g2_oresp.cccc = einsum("IK,JL->IJKL", delta_IJ, g1o.cc+delta_IJ) + g2_oresp.ococ = einsum("ik,JL->iJkL", delta_ij, g1o.cc+2*delta_IJ) + g2_oresp.oooo = 0.25*einsum("ik,jl->ijkl", delta_ij, delta_ij) + g2_oresp.ovov = einsum("ij,ab->iajb", delta_ij, g1o.vv) + g2_oresp.cvcv = einsum("IJ,ab->IaJb", delta_IJ, g1o.vv) + g2_oresp.ocov = 2*einsum("ik,Ja->iJka", delta_ij, g1o.cv) + g2_oresp.cccv = 2*einsum("IK,Ja->IJKa", delta_IJ, g1o.cv) + + g2_oresp.ooov = 2*einsum("ik,ja->ijka", delta_ij, g1o.ov) + g2_oresp.cocv = 2*einsum("IK,ja->IjKa", delta_IJ, g1o.ov) + g2_oresp.ocoo = 2*einsum("ik,Jl->iJkl", delta_ij, g1o.co) + g2_oresp.ccco = 2*einsum("IK,Jl->IJKl", delta_IJ, g1o.co) + + g2_total = evaluate(g2_hf + g2a + g2_oresp) + else: + delta_ij = hf.density.oo + g2_hf = TwoParticleDensityMatrix(hf) + g2_hf.oooo = 0.25 * (- einsum("li,jk->ijkl", delta_ij, delta_ij) + + einsum("ki,jl->ijkl", delta_ij, delta_ij)) + + g2_oresp = TwoParticleDensityMatrix(hf) + g2_oresp.oooo = einsum("ij,kl->kilj", delta_ij, g1o.oo) + g2_oresp.ovov = einsum("ij,ab->iajb", delta_ij, g1o.vv) + g2_oresp.ooov = (- einsum("kj,ia->ijka", delta_ij, g1o.ov) + + einsum("ki,ja->ijka", delta_ij, g1o.ov)) + + # scale for contraction with integrals + g2a.oovv *= 0.5 + g2_total = evaluate(g2_hf + g2a + g2_oresp) with timer.record("transform_ao"): g2_ao_1, g2_ao_2 = g2_total.to_ao_basis() diff --git a/adcc/gradients/amplitude_response.py b/adcc/gradients/amplitude_response.py index b1b3fdbab..97af380ff 100644 --- a/adcc/gradients/amplitude_response.py +++ b/adcc/gradients/amplitude_response.py @@ -63,6 +63,47 @@ def ampl_relaxed_dms_adc1(exci): g2a.ovov = -1.0 * einsum("ja,ib->iajb", u.ph, u.ph) return g1a, g2a +def ampl_relaxed_dms_adc0(exci): + hf = exci.reference_state + u = exci.excitation_vector + g1a = OneParticleOperator(hf) + g2a = TwoParticleDensityMatrix(hf) + # g2a is not required for the adc0 gradient, + # but expected by amplitude_relaxed_densities + g1a.oo = -1.0 * einsum("ia,ja->ij", u.ph, u.ph) + g1a.vv = +1.0 * einsum("ia,ib->ab", u.ph, u.ph) + return g1a, g2a + +def ampl_relaxed_dms_cvs_adc0(exci): + hf = exci.reference_state + u = exci.excitation_vector + g1a = OneParticleOperator(hf) + g2a = TwoParticleDensityMatrix(hf) + # g2a is not required for cvs-adc0 gradient, + # but expected by amplitude_relaxed_densities + g1a.cc = -1.0 * einsum("Ia,Ja->IJ", u.ph, u.ph) + g1a.vv = +1.0 * einsum("Ia,Ib->ab", u.ph, u.ph) + return g1a, g2a + +def ampl_relaxed_dms_cvs_adc1(exci): + hf = exci.reference_state + u = exci.excitation_vector + g1a = OneParticleOperator(hf) + g2a = TwoParticleDensityMatrix(hf) + g2a.cvcv = -1.0 * einsum("Ja,Ib->IaJb", u.ph, u.ph) + g1a.cc = -1.0 * einsum("Ia,Ja->IJ", u.ph, u.ph) + + # Pre-requisites for the OC block of the + # orbital response Lagrange multipliers: + fc = hf.fock(b.cc).diagonal() + fo = hf.fock(b.oo).diagonal() + fco = 0.5*direct_sum("-j+I->jI", fc, fo).evaluate() + # These are the multipliers: + g1a.co = -0.5 * einsum('JbKc,ibKc->Ji', g2a.cvcv, hf.ovcv) / fco + print("L multipliers CO block:\n", g1a.co.evaluate().T) + g1a.vv = +1.0 * einsum("Ia,Ib->ab", u.ph, u.ph) + return g1a, g2a + def ampl_relaxed_dms_adc2(exci): u = exci.excitation_vector @@ -112,8 +153,11 @@ def ampl_relaxed_dms_mp2(mp): DISPATCH = { "mp2": ampl_relaxed_dms_mp2, + "adc0": ampl_relaxed_dms_adc0, "adc1": ampl_relaxed_dms_adc1, "adc2": ampl_relaxed_dms_adc2, + "cvs-adc0": ampl_relaxed_dms_cvs_adc0, + "cvs-adc1": ampl_relaxed_dms_cvs_adc1, } diff --git a/adcc/gradients/orbital_response.py b/adcc/gradients/orbital_response.py index e575b7df3..a1fbca08a 100644 --- a/adcc/gradients/orbital_response.py +++ b/adcc/gradients/orbital_response.py @@ -22,7 +22,11 @@ ## --------------------------------------------------------------------- import adcc.block as b from adcc.OneParticleOperator import OneParticleOperator -from adcc.functions import direct_sum, einsum, evaluate +from adcc.functions import direct_sum, einsum, evaluate, zeros_like + +from adcc.Tensor import Tensor +from adcc.AmplitudeVector import AmplitudeVector +import numpy as np from adcc.solver.conjugate_gradient import conjugate_gradient, default_print @@ -34,94 +38,195 @@ def orbital_response_rhs(hf, g1a, g2a): """ # TODO: only add non-zero blocks to equations! - # equal to the ov block of the energy-weighted density - # matrix when lambda_ov multipliers are zero - w_ov = 0.5 * ( - + 1.0 * einsum("ijkl,klja->ia", hf.oooo, g2a.ooov) - # - 1.0 * einsum("ibcd,abcd->ia", hf.ovvv, g2a.vvvv) - - 1.0 * einsum("jkib,jkab->ia", hf.ooov, g2a.oovv) - + 2.0 * einsum("ijkb,jakb->ia", hf.ooov, g2a.ovov) - + 1.0 * einsum("ijbc,jabc->ia", hf.oovv, g2a.ovvv) - - 2.0 * einsum("ibjc,jcab->ia", hf.ovov, g2a.ovvv) - ) - w_ov = w_ov.evaluate() - - ret = -1.0 * ( - 2.0 * w_ov - # - 1.0 * einsum("klja,ijkl->ia", hf.ooov, g2a.oooo) - + 1.0 * einsum("abcd,ibcd->ia", hf.vvvv, g2a.ovvv) - - 2.0 * einsum("jakb,ijkb->ia", hf.ovov, g2a.ooov) - + 1.0 * einsum("jkab,jkib->ia", hf.oovv, g2a.ooov) - + 2.0 * einsum("jcab,ibjc->ia", hf.ovvv, g2a.ovov) - - 1.0 * einsum("jabc,ijbc->ia", hf.ovvv, g2a.oovv) - + 2.0 * einsum("jika,jk->ia", hf.ooov, g1a.oo) - + 2.0 * einsum("icab,bc->ia", hf.ovvv, g1a.vv) - ) + if hf.has_core_occupied_space: + ret_ov = -1.0 * ( + + 2.0 * einsum("JiKa,JK->ia", hf.cocv, g1a.cc) + + 2.0 * einsum("icab,bc->ia", hf.ovvv, g1a.vv) + + 2.0 * einsum("kiJa,Jk->ia", hf.oocv, g1a.co) + - 2.0 * einsum("iJka,Jk->ia", hf.ocov, g1a.co) + + 2.0*einsum ("iJKb,JaKb->ia", hf.occv, g2a.cvcv) # TODO: new var. + ) + + ret_cv = -1.0 * ( + + 2.0 * einsum("JIKa,JK->Ia", hf.cccv, g1a.cc) + + 2.0 * einsum("Icab,bc->Ia", hf.cvvv, g1a.vv) + + 2.0 * einsum("kIJa,Jk->Ia", hf.occv, g1a.co) + + 2.0 * einsum("JIka,Jk->Ia", hf.ccov, g1a.co) + + 2.0 * einsum("IJKb,JaKb->Ia", hf.cccv, g2a.cvcv) # TODO: new var. + + 2.0 * einsum("Jcab,IbJc->Ia", hf.cvvv, g2a.cvcv) # TODO: new var. + ) + + #print("\nRHS OV:\n", ret_cv.evaluate()) + + ret = AmplitudeVector(ph=ret_cv, pphh=ret_ov) + + else: + # equal to the ov block of the energy-weighted density + # matrix when lambda_ov multipliers are zero + w_ov = 0.5 * ( + + 1.0 * einsum("ijkl,klja->ia", hf.oooo, g2a.ooov) + # - 1.0 * einsum("ibcd,abcd->ia", hf.ovvv, g2a.vvvv) + - 1.0 * einsum("jkib,jkab->ia", hf.ooov, g2a.oovv) + + 2.0 * einsum("ijkb,jakb->ia", hf.ooov, g2a.ovov) + + 1.0 * einsum("ijbc,jabc->ia", hf.oovv, g2a.ovvv) + - 2.0 * einsum("ibjc,jcab->ia", hf.ovov, g2a.ovvv) + ) + w_ov = w_ov.evaluate() + + ret = -1.0 * ( + 2.0 * w_ov + # - 1.0 * einsum("klja,ijkl->ia", hf.ooov, g2a.oooo) + + 1.0 * einsum("abcd,ibcd->ia", hf.vvvv, g2a.ovvv) + - 2.0 * einsum("jakb,ijkb->ia", hf.ovov, g2a.ooov) + + 1.0 * einsum("jkab,jkib->ia", hf.oovv, g2a.ooov) + + 2.0 * einsum("jcab,ibjc->ia", hf.ovvv, g2a.ovov) + - 1.0 * einsum("jabc,ijbc->ia", hf.ovvv, g2a.oovv) + + 2.0 * einsum("jika,jk->ia", hf.ooov, g1a.oo) + + 2.0 * einsum("icab,bc->ia", hf.ovvv, g1a.vv) + ) return ret def energy_weighted_density_matrix(hf, g1o, g2a): - gi_oo = -0.5 * ( - # + 1.0 * einsum("jklm,iklm->ij", hf.oooo, g2a.oooo) - + 1.0 * einsum("jabc,iabc->ij", hf.ovvv, g2a.ovvv) - + 1.0 * einsum("klja,klia->ij", hf.ooov, g2a.ooov) - + 2.0 * einsum("jkla,ikla->ij", hf.ooov, g2a.ooov) - + 1.0 * einsum("jkab,ikab->ij", hf.oovv, g2a.oovv) - + 2.0 * einsum("jakb,iakb->ij", hf.ovov, g2a.ovov) - ) - gi_vv = -0.5 * ( - + 1.0 * einsum("kjib,kjia->ab", hf.ooov, g2a.ooov) - # + einsum("bcde,acde->ab", hf.vvvv, g2a.vvvv) - + 1.0 * einsum("ijcb,ijca->ab", hf.oovv, g2a.oovv) - + 2.0 * einsum("jcib,jcia->ab", hf.ovov, g2a.ovov) - + 1.0 * einsum("ibcd,iacd->ab", hf.ovvv, g2a.ovvv) - + 2.0 * einsum("idcb,idca->ab", hf.ovvv, g2a.ovvv) - ) - gi_oo = gi_oo.evaluate() - gi_vv = gi_vv.evaluate() - w = OneParticleOperator(hf) - w.ov = 0.5 * ( - - 2.0 * einsum("ij,ja->ia", hf.foo, g1o.ov) - + 1.0 * einsum("ijkl,klja->ia", hf.oooo, g2a.ooov) - # - 1.0 * einsum("ibcd,abcd->ia", hf.ovvv, g2a.vvvv) - - 1.0 * einsum("jkib,jkab->ia", hf.ooov, g2a.oovv) - + 2.0 * einsum("ijkb,jakb->ia", hf.ooov, g2a.ovov) - + 1.0 * einsum("ijbc,jabc->ia", hf.oovv, g2a.ovvv) - - 2.0 * einsum("ibjc,jcab->ia", hf.ovov, g2a.ovvv) - ) - w.oo = ( - + gi_oo - hf.foo - - einsum("ik,jk->ij", g1o.oo, hf.foo) - - einsum("ikjl,kl->ij", hf.oooo, g1o.oo) - - einsum("ikja,ka->ij", hf.ooov, g1o.ov) - - einsum("jkia,ka->ij", hf.ooov, g1o.ov) - - einsum("jaib,ab->ij", hf.ovov, g1o.vv) - ) - w.vv = gi_vv - einsum("ac,cb->ab", g1o.vv, hf.fvv) + if hf.has_core_occupied_space: + # CVS-ADC0; TODO: add 2PDM contributions + w = OneParticleOperator(hf) + w.cc = ( + - hf.fcc + - einsum("ik,jk->ij", g1o.cc, hf.fcc) + - einsum("ab,IaJb->IJ", g1o.vv, hf.cvcv) + - einsum("KL,IKJL->IJ", g1o.cc, hf.cccc) + + einsum("ka,kJIa->IJ", g1o.ov, hf.occv) + + einsum("ka,kIJa->IJ", g1o.ov, hf.occv) + + einsum("Ka,KJIa->IJ", g1o.cv, hf.cccv) + + einsum("Ka,KIJa->IJ", g1o.cv, hf.cccv) + - einsum("Lk,kILJ->IJ", g1o.co, hf.occc) + - einsum("Lk,kJLI->IJ", g1o.co, hf.occc) + - einsum("JbKc,IbKc->IJ", g2a.cvcv, hf.cvcv) + ) + w.oo = ( + - hf.foo + - einsum("KL,iKjL->ij", g1o.cc, hf.ococ) + - einsum("ab,iajb->ij", g1o.vv, hf.ovov) + - einsum("ka,ikja->ij", g1o.ov, hf.ooov) + - einsum("ka,jkia->ij", g1o.ov, hf.ooov) + - einsum("Ka,iKja->ij", g1o.cv, hf.ocov) + - einsum("Ka,jKia->ij", g1o.cv, hf.ocov) + + einsum("Lk,kijL->ij", g1o.co, hf.oooc) + + einsum("Lk,kjiL->ij", g1o.co, hf.oooc) + ) + w.vv = ( + - einsum("ac,cb->ab", g1o.vv, hf.fvv) + - einsum('JbKc,JaKc->ab', g2a.cvcv, hf.cvcv) + ) + w.co = ( + einsum("KL,iKLJ->Ji", g1o.cc, hf.occc) + - einsum("ab,iaJb->Ji", g1o.vv, hf.ovcv) + - einsum("Ka,iKJa->Ji", g1o.cv, hf.occv) + - einsum("Ka,JKia->Ji", g1o.cv, hf.ccov) + - einsum("ka,ikJa->Ji", g1o.ov, hf.oocv) + - einsum("ka,Jkia->Ji", g1o.ov, hf.coov) + - einsum("Lk,kiLJ->Ji", g1o.co, hf.oocc) + + einsum("Lk,iLkJ->Ji", g1o.co, hf.ococ) + - einsum("Ik,jk->Ij", g1o.co, hf.foo) + - einsum("JbKc,ibKc->Ji", g2a.cvcv, hf.ovcv) + ) + w.ov = ( + - einsum("ij,ja->ia", hf.foo, g1o.ov) + + einsum("JaKc,iJKc->ia", g2a.cvcv, hf.occv) + ) + w.cv = ( + - einsum("IJ,Ja->Ia", hf.fcc, g1o.cv) + + einsum("JaKc,IJKc->Ia", g2a.cvcv, hf.cccv) + ) + print("\nOMEGA cv:\n", w.cv.evaluate()) + else: + gi_oo = -0.5 * ( + # + 1.0 * einsum("jklm,iklm->ij", hf.oooo, g2a.oooo) + + 1.0 * einsum("jabc,iabc->ij", hf.ovvv, g2a.ovvv) + + 1.0 * einsum("klja,klia->ij", hf.ooov, g2a.ooov) + + 2.0 * einsum("jkla,ikla->ij", hf.ooov, g2a.ooov) + + 1.0 * einsum("jkab,ikab->ij", hf.oovv, g2a.oovv) + + 2.0 * einsum("jakb,iakb->ij", hf.ovov, g2a.ovov) + ) + gi_vv = -0.5 * ( + + 1.0 * einsum("kjib,kjia->ab", hf.ooov, g2a.ooov) + # + einsum("bcde,acde->ab", hf.vvvv, g2a.vvvv) + + 1.0 * einsum("ijcb,ijca->ab", hf.oovv, g2a.oovv) + + 2.0 * einsum("jcib,jcia->ab", hf.ovov, g2a.ovov) + + 1.0 * einsum("ibcd,iacd->ab", hf.ovvv, g2a.ovvv) + + 2.0 * einsum("idcb,idca->ab", hf.ovvv, g2a.ovvv) + ) + gi_oo = gi_oo.evaluate() + gi_vv = gi_vv.evaluate() + w = OneParticleOperator(hf) + w.ov = 0.5 * ( + - 2.0 * einsum("ij,ja->ia", hf.foo, g1o.ov) + + 1.0 * einsum("ijkl,klja->ia", hf.oooo, g2a.ooov) + # - 1.0 * einsum("ibcd,abcd->ia", hf.ovvv, g2a.vvvv) + - 1.0 * einsum("jkib,jkab->ia", hf.ooov, g2a.oovv) + + 2.0 * einsum("ijkb,jakb->ia", hf.ooov, g2a.ovov) + + 1.0 * einsum("ijbc,jabc->ia", hf.oovv, g2a.ovvv) + - 2.0 * einsum("ibjc,jcab->ia", hf.ovov, g2a.ovvv) + ) + w.oo = ( + + gi_oo - hf.foo + - einsum("ik,jk->ij", g1o.oo, hf.foo) + - einsum("ikjl,kl->ij", hf.oooo, g1o.oo) + - einsum("ikja,ka->ij", hf.ooov, g1o.ov) + - einsum("jkia,ka->ij", hf.ooov, g1o.ov) + - einsum("jaib,ab->ij", hf.ovov, g1o.vv) + ) + w.vv = gi_vv - einsum("ac,cb->ab", g1o.vv, hf.fvv) return evaluate(w) class OrbitalResponseMatrix: def __init__(self, hf): - if hf.has_core_occupied_space: - raise NotImplementedError("OrbitalResponseMatrix not implemented " - "for CVS reference state.") + #if hf.has_core_occupied_space: + # raise NotImplementedError("OrbitalResponseMatrix not implemented " + # "for CVS reference state.") self.hf = hf @property def shape(self): - no1 = self.hf.n_orbs(b.o) - nv1 = self.hf.n_orbs(b.v) + no1 = self.hf.mospaces.n_orbs(b.o) + if self.hf.has_core_occupied_space: + no1 += self.hf.mospaces.n_orbs(b.c) + nv1 = self.hf.mospaces.n_orbs(b.v) size = no1 * nv1 return (size, size) def __matmul__(self, l_ov): - ret = ( - + einsum("ab,ib->ia", self.hf.fvv, l_ov) - - einsum("ij,ja->ia", self.hf.foo, l_ov) - + einsum("ijab,jb->ia", self.hf.oovv, l_ov) - - einsum("ibja,jb->ia", self.hf.ovov, l_ov) - ) + if self.hf.has_core_occupied_space: + # This is the OV block (hijacked from AmplitudeVector) + # TODO: find a different solution (new class?) + ret_ov = ( + + einsum("ab,ib->ia", self.hf.fvv, l_ov['pphh']) + - einsum("ij,ja->ia", self.hf.foo, l_ov['pphh']) + + einsum("ijab,jb->ia", self.hf.oovv, l_ov['pphh']) + - einsum("ibja,jb->ia", self.hf.ovov, l_ov['pphh']) + + einsum("iJab,Jb->ia", self.hf.ocvv, l_ov['ph']) + - einsum("ibJa,Jb->ia", self.hf.ovcv, l_ov['ph']) + ) + # This is the CV block (hijacked from AmplitudeVector) + # TODO: find a different solution (new class?) + ret_cv = ( + + einsum("ab,Ib->Ia", self.hf.fvv, l_ov['ph']) + - einsum("IJ,Ja->Ia", self.hf.fcc, l_ov['ph']) + + einsum("IJab,Jb->Ia", self.hf.ccvv, l_ov['ph']) + - einsum("IbJa,Jb->Ia", self.hf.cvcv, l_ov['ph']) + + einsum("Ijab,jb->Ia", self.hf.covv, l_ov['pphh']) + - einsum("Ibja,jb->Ia", self.hf.cvov, l_ov['pphh']) + ) + ret = AmplitudeVector(ph=ret_cv, pphh=ret_ov) + else: + ret = ( + + einsum("ab,ib->ia", self.hf.fvv, l_ov) + - einsum("ij,ja->ia", self.hf.foo, l_ov) + + einsum("ijab,jb->ia", self.hf.oovv, l_ov) + - einsum("ibja,jb->ia", self.hf.ovov, l_ov) + ) # TODO: generalize once other solvent methods are available if self.hf.environment == "pe": # PE contribution to the orbital Hessian @@ -134,17 +239,28 @@ def __matmul__(self, l_ov): class OrbitalResponsePinv: def __init__(self, hf): + self.hf = hf if hf.has_core_occupied_space: - raise NotImplementedError("OrbitalResponsePinv not implemented " - "for CVS reference state.") - fo = hf.fock(b.oo).diagonal() - fv = hf.fock(b.vv).diagonal() - self.df = direct_sum("-i+a->ia", fo, fv).evaluate() + fc = hf.fock(b.cc).diagonal() + fo = hf.fock(b.oo).diagonal() + fv = hf.fock(b.vv).diagonal() + fov = direct_sum("-i+a->ia", fo, fv).evaluate() + fcv = direct_sum("-I+a->Ia", fc, fv).evaluate() + + # Highjacking AmplitudeVector to store both cv and ov blocks. + # 'ph' stores the CV block, 'pphh' stores the OV block. + self.df = AmplitudeVector(ph=fcv, pphh=fov) + else: + fo = hf.fock(b.oo).diagonal() + fv = hf.fock(b.vv).diagonal() + self.df = direct_sum("-i+a->ia", fo, fv).evaluate() @property def shape(self): - no1 = self.hf.n_orbs(b.o) - nv1 = self.hf.n_orbs(b.v) + no1 = self.hf.mospaces.n_orbs(b.o) + if self.hf.has_core_occupied_space: + no1 += self.hf.mospaces.n_orbs(b.c) + nv1 = self.hf.mospaces.n_orbs(b.v) size = no1 * nv1 return (size, size) @@ -164,4 +280,9 @@ def orbital_response(hf, rhs): l_ov = conjugate_gradient(A, rhs=rhs, x0=x0, Pinv=Pinv, explicit_symmetrisation=None, callback=default_print) + #print(rhs.space) + #print(rhs.subspaces) + ##print(dir(l_ov.solution)) + print("Solution CV:\n", 0.5*l_ov.solution['ph']) + print("\nSolution OV:\n",0.5*l_ov.solution['pphh']) return l_ov.solution From 7e5c14de233191a5c1be0d7df76c2e38aa4a1797 Mon Sep 17 00:00:00 2001 From: iubr Date: Tue, 26 Oct 2021 15:17:59 +0900 Subject: [PATCH 04/18] added the cvs-adc2 1PDMs added cvs-adc2 2PDMs,started orbital response (need to check if the RHS is correct) cvs-adc2 gradient working. cvs-adc2x working --- adcc/OneParticleOperator.py | 2 - adcc/backends/pyscf.py | 36 ++-- adcc/gradients/TwoParticleDensityMatrix.py | 3 +- adcc/gradients/__init__.py | 19 +- adcc/gradients/amplitude_response.py | 224 ++++++++++++++++++++- adcc/gradients/orbital_response.py | 91 ++++++++- 6 files changed, 338 insertions(+), 37 deletions(-) diff --git a/adcc/OneParticleOperator.py b/adcc/OneParticleOperator.py index 4598f93cd..422795437 100644 --- a/adcc/OneParticleOperator.py +++ b/adcc/OneParticleOperator.py @@ -205,8 +205,6 @@ def copy(self): return ret def __transform_to_ao(self, refstate_or_coefficients): - #Iulia print: - print("HERE:\n",dir(self)) if not len(self.blocks_nonzero): raise ValueError("At least one non-zero block is needed to " "transform the OneParticleOperator.") diff --git a/adcc/backends/pyscf.py b/adcc/backends/pyscf.py index fab8cafee..5bb1ad4f2 100644 --- a/adcc/backends/pyscf.py +++ b/adcc/backends/pyscf.py @@ -50,9 +50,9 @@ def correlated_gradient(self, g1_ao, w_ao, g2_ao_1, g2_ao_2): Gradient["Total"] = np.zeros((natoms, 3)) # Iulia added variables; TODO: remove - ovlp_iulia = np.zeros((natoms, 3)) - hcore_iulia = np.zeros((natoms, 3)) - eri_iulia = np.zeros((natoms, 3)) + #ovlp_iulia = np.zeros((natoms, 3)) + #hcore_iulia = np.zeros((natoms, 3)) + #eri_iulia = np.zeros((natoms, 3)) # TODO: does RHF/UHF matter here? gradient = grad.RHF(self.scfres) @@ -72,13 +72,13 @@ def correlated_gradient(self, g1_ao, w_ao, g2_ao_1, g2_ao_2): Sx_a[:, k0:k1] = Sx[:, k0:k1] Sx_a += Sx_a.transpose(0, 2, 1) Gradient["S"][ia] += np.einsum("xpq,pq->x", Sx_a, w_ao) - ovlp_iulia[ia] += np.einsum("xpq,pq->x", Sx_a, w_ao) + #ovlp_iulia[ia] += np.einsum("xpq,pq->x", Sx_a, w_ao) # derivative of the core Hamiltonian Hx_a = hcore_deriv(ia) Gradient["T+V"][ia] += np.einsum("xpq,pq->x", Hx_a, g1_ao) - hcore_iulia[ia] += np.einsum("xpq,pq->x", Hx_a, g1_ao) + #hcore_iulia[ia] += np.einsum("xpq,pq->x", Hx_a, g1_ao) # derivatives of the ERIs ERIx_a = np.zeros_like(ERIx) @@ -94,23 +94,23 @@ def correlated_gradient(self, g1_ao, w_ao, g2_ao_1, g2_ao_2): Gradient["TEI"][ia] -= np.einsum( "pqrs,xpsqr->x", g2_ao_2, ERIx_a, optimize=True ) - eri_iulia[ia] += ( - np.einsum("pqrs,xprqs->x", g2_ao_1, ERIx_a, optimize=True) - - np.einsum("pqrs,xpsqr->x", g2_ao_2, ERIx_a, optimize=True) - ) + #eri_iulia[ia] += ( + # np.einsum("pqrs,xprqs->x", g2_ao_1, ERIx_a, optimize=True) + # - np.einsum("pqrs,xpsqr->x", g2_ao_2, ERIx_a, optimize=True) + #) # Iulia print TODO:remove #print("2PDM_1 in AO:\n", g2_ao_1) - print("Hcore contribution to the gradient:") - print(hcore_iulia) - print() - print("Overlp contribution to the gradient:") - print(ovlp_iulia) - print() - print("ERI contribution to the gradient:") - print(eri_iulia) - print() + #print("Hcore contribution to the gradient:") + #print(hcore_iulia) + #print() + #print("Overlp contribution to the gradient:") + #print(ovlp_iulia) + #print() + #print("ERI contribution to the gradient:") + #print(eri_iulia) + #print() Gradient["N"] = gradient.grad_nuc() Gradient["OEI"] = Gradient["T+V"] + Gradient["S"] diff --git a/adcc/gradients/TwoParticleDensityMatrix.py b/adcc/gradients/TwoParticleDensityMatrix.py index 1421e0284..7567ebe25 100644 --- a/adcc/gradients/TwoParticleDensityMatrix.py +++ b/adcc/gradients/TwoParticleDensityMatrix.py @@ -63,7 +63,8 @@ def __init__(self, spaces): self.blocks += [ b.cccc, b.ococ, b.oooo, b.cvcv, b.ocov, b.cccv, b.cocv, b.ocoo, - b.ccco, + b.ccco, b.occv, b.ccvv, b.ocvv, + b.vvvv, ] self._tensors = {} diff --git a/adcc/gradients/__init__.py b/adcc/gradients/__init__.py index 9dd99c79c..9532e4609 100644 --- a/adcc/gradients/__init__.py +++ b/adcc/gradients/__init__.py @@ -98,18 +98,29 @@ def nuclear_gradient(excitation_or_mp): # No idea why we need a 0.25 in front of the oooo block... g2_oresp = TwoParticleDensityMatrix(hf) g2_oresp.cccc = einsum("IK,JL->IJKL", delta_IJ, g1o.cc+delta_IJ) - g2_oresp.ococ = einsum("ik,JL->iJkL", delta_ij, g1o.cc+2*delta_IJ) - g2_oresp.oooo = 0.25*einsum("ik,jl->ijkl", delta_ij, delta_ij) + g2_oresp.ococ = ( + einsum("ik,JL->iJkL", delta_ij, g1o.cc+2*delta_IJ) + + einsum("ik,JL->iJkL", g1o.oo, delta_IJ) + ) + g2_oresp.oooo = 0.25 * ( + einsum("ik,jl->ijkl", delta_ij, g1o.oo+delta_ij) + ) g2_oresp.ovov = einsum("ij,ab->iajb", delta_ij, g1o.vv) g2_oresp.cvcv = einsum("IJ,ab->IaJb", delta_IJ, g1o.vv) g2_oresp.ocov = 2*einsum("ik,Ja->iJka", delta_ij, g1o.cv) g2_oresp.cccv = 2*einsum("IK,Ja->IJKa", delta_IJ, g1o.cv) - g2_oresp.ooov = 2*einsum("ik,ja->ijka", delta_ij, g1o.ov) g2_oresp.cocv = 2*einsum("IK,ja->IjKa", delta_IJ, g1o.ov) g2_oresp.ocoo = 2*einsum("ik,Jl->iJkl", delta_ij, g1o.co) g2_oresp.ccco = 2*einsum("IK,Jl->IJKl", delta_IJ, g1o.co) - + + # scale for contraction with integrals + g2a.oovv *= 0.5 + g2a.ccvv *= 0.5 + g2a.occv *= 2.0 + g2a.vvvv *= 0.25 # Scalin twice is really strange... but the only + g2a.vvvv *= 0.25 # way it works... + g2_total = evaluate(g2_hf + g2a + g2_oresp) else: delta_ij = hf.density.oo diff --git a/adcc/gradients/amplitude_response.py b/adcc/gradients/amplitude_response.py index 97af380ff..4b831b0ab 100644 --- a/adcc/gradients/amplitude_response.py +++ b/adcc/gradients/amplitude_response.py @@ -52,6 +52,20 @@ def t2bar_oovv_adc2(exci, g1a_adc0): ) return t2bar +def t2bar_oovv_cvs_adc2(exci, g1a_adc0): + mp = exci.ground_state + hf = mp.reference_state + u = exci.excitation_vector + df_ia = mp.df(b.ov) + t2bar = 0.5*( + - einsum("ijcb,ac->ijab", hf.oovv, g1a_adc0.vv).antisymmetrise((2, 3)) + ) / ( + direct_sum("ia+jb->ijab", df_ia, df_ia).symmetrise((0, 1)) + ) + + #TODO: remove print("T2bar:\n",t2bar.evaluate()) + return t2bar + def ampl_relaxed_dms_adc1(exci): hf = exci.reference_state @@ -97,13 +111,215 @@ def ampl_relaxed_dms_cvs_adc1(exci): # orbital response Lagrange multipliers: fc = hf.fock(b.cc).diagonal() fo = hf.fock(b.oo).diagonal() - fco = 0.5*direct_sum("-j+I->jI", fc, fo).evaluate() + fco = direct_sum("-j+I->jI", fc, fo).evaluate() # These are the multipliers: - g1a.co = -0.5 * einsum('JbKc,ibKc->Ji', g2a.cvcv, hf.ovcv) / fco - print("L multipliers CO block:\n", g1a.co.evaluate().T) + g1a.co = - einsum('JbKc,ibKc->Ji', g2a.cvcv, hf.ovcv) / fco + # TODO: print("L multipliers CO block:\n", g1a.co.evaluate().T) g1a.vv = +1.0 * einsum("Ia,Ib->ab", u.ph, u.ph) return g1a, g2a +def ampl_relaxed_dms_cvs_adc2(exci): + hf = exci.reference_state + mp = exci.ground_state + u = exci.excitation_vector + g1a = OneParticleOperator(hf) + g2a = TwoParticleDensityMatrix(hf) + + # Determine the t-amplitudes and multipliers: + t2oovv = mp.t2(b.oovv) + t2ccvv = mp.t2(b.ccvv) + t2ocvv = mp.t2(b.ocvv) + g1a_cvs0, g2a_cvs0 = ampl_relaxed_dms_cvs_adc0(exci) + t2bar = t2bar_oovv_cvs_adc2(exci, g1a_cvs0).evaluate() + + g1a.cc = ( + - einsum("Ia,Ja->IJ", u.ph, u.ph) + - einsum("kJba,kIba->IJ", u.pphh, u.pphh) + - 0.5 * einsum('IKab,JKab->IJ', t2ccvv, t2ccvv) + - 0.5 * einsum('kIab,kJab->IJ', t2ocvv, t2ocvv) + ) + + g1a.oo = ( + - einsum("jKba,iKba->ij", u.pphh, u.pphh) + - einsum("ikab,jkab->ij", t2bar, t2oovv) # TODO: + - einsum('jkab,ikab->ij', t2oovv, t2bar) # use antisymmetrize + - 0.5 * einsum('iKab,jKab->ij', t2ocvv, t2ocvv) + - 0.5 * einsum('ikab,jkab->ij', t2oovv, t2oovv) + ) + + # Pre-requisites for the OC block of the + # orbital response Lagrange multipliers: + fc = hf.fock(b.cc).diagonal() + fo = hf.fock(b.oo).diagonal() + fco = direct_sum("-j+I->jI", fc, fo).evaluate() + + #print("L multipliers CO block:\n", g1a.co.evaluate().T) + g1a.vv = ( + einsum("Ia,Ib->ab", u.ph, u.ph) + + 2.0 * einsum('jIcb,jIca->ab', u.pphh, u.pphh) + + einsum('ijac,ijbc->ab', t2bar, t2oovv) + + einsum('ijbc,ijac->ab', t2bar, t2oovv) + + 0.5 * einsum('IJac,IJbc->ab', t2ccvv, t2ccvv) + + 0.5 * einsum('ijac,ijbc->ab', t2oovv, t2oovv) + + einsum('iJac,iJbc->ab', t2ocvv, t2ocvv) + ) + + g2a.cvcv = ( + - einsum("Ja,Ib->IaJb", u.ph, u.ph) + ) + + # 0.7071067811865475 is 1/sqrt(2); is there a better way to do this? + # This factor is needed because of the scaling used in adcc + # for the ph-pphh blocks + g2a.occv = 0.7071067811865475 * ( + einsum('Ib,kJba->kJIa', u.ph, u.pphh) # TODO: use antisymm + - einsum('Ib,kJab->kJIa', u.ph, u.pphh) + ) + + g2a.oovv = ( + 0.5 * einsum('ijcb,ca->ijab', t2oovv, g1a_cvs0.vv) + -0.5 * einsum('ijca,cb->ijab', t2oovv, g1a_cvs0.vv) + -t2oovv + -2.0 * t2bar + ) + + # 1.414213562373095 is 2/sqrt(2); + # This factor is necessary because of the wa that the ph-pphh is scaled + g2a.ovvv = ( + 1.414213562373095 * einsum('Ja,iJcb->iabc', u.ph, u.pphh) + ) + + g2a.ccvv = -t2ccvv + + g2a.ocvv = -t2ocvv + + # These are the OC multipliers: + g1a.co = ( + - einsum('JbKc,ibKc->Ji', g2a.cvcv, hf.ovcv) + -0.5 * einsum('JKab,iKab->Ji', g2a.ccvv, hf.ocvv) + + einsum('kJLa,ikLa->Ji', g2a.occv, hf.oocv) + + 0.5 * einsum('kJab,ikab->Ji', g2a.ocvv, hf.oovv) + - einsum('kLJa,kLia->Ji', g2a.occv, hf.ocov) + + einsum('iKLa,JKLa->Ji', g2a.occv, hf.cccv) + + 0.5 * einsum('iKab,JKab->Ji', g2a.ocvv, hf.ccvv) + - 0.5 * einsum('ikab,kJab->Ji', g2a.oovv, hf.ocvv) + + 0.5 * einsum('iabc,Jabc->Ji', g2a.ovvv, hf.cvvv) + ) / fco + + #print("Lambda CO:\n", g1a.co.evaluate().T) + + return g1a, g2a + +def ampl_relaxed_dms_cvs_adc2x(exci): + hf = exci.reference_state + mp = exci.ground_state + u = exci.excitation_vector + g1a = OneParticleOperator(hf) + g2a = TwoParticleDensityMatrix(hf) + + # Determine the t-amplitudes and multipliers: + t2oovv = mp.t2(b.oovv) + t2ccvv = mp.t2(b.ccvv) + t2ocvv = mp.t2(b.ocvv) + g1a_cvs0, g2a_cvs0 = ampl_relaxed_dms_cvs_adc0(exci) + t2bar = t2bar_oovv_cvs_adc2(exci, g1a_cvs0).evaluate() + + g1a.cc = ( + - einsum("Ia,Ja->IJ", u.ph, u.ph) + - einsum("kJba,kIba->IJ", u.pphh, u.pphh) + - 0.5 * einsum('IKab,JKab->IJ', t2ccvv, t2ccvv) + - 0.5 * einsum('kIab,kJab->IJ', t2ocvv, t2ocvv) + ) + + g1a.oo = ( + - einsum("jKba,iKba->ij", u.pphh, u.pphh) + - einsum("ikab,jkab->ij", t2bar, t2oovv) # TODO: + - einsum('jkab,ikab->ij', t2oovv, t2bar) # use antisymmetrize + - 0.5 * einsum('iKab,jKab->ij', t2ocvv, t2ocvv) + - 0.5 * einsum('ikab,jkab->ij', t2oovv, t2oovv) + ) + + # Pre-requisites for the OC block of the + # orbital response Lagrange multipliers: + fc = hf.fock(b.cc).diagonal() + fo = hf.fock(b.oo).diagonal() + fco = direct_sum("-j+I->jI", fc, fo).evaluate() + + #print("L multipliers CO block:\n", g1a.co.evaluate().T) + g1a.vv = ( + einsum("Ia,Ib->ab", u.ph, u.ph) + + 2.0 * einsum('jIcb,jIca->ab', u.pphh, u.pphh) + + einsum('ijac,ijbc->ab', t2bar, t2oovv) + + einsum('ijbc,ijac->ab', t2bar, t2oovv) + + 0.5 * einsum('IJac,IJbc->ab', t2ccvv, t2ccvv) + + 0.5 * einsum('ijac,ijbc->ab', t2oovv, t2oovv) + + einsum('iJac,iJbc->ab', t2ocvv, t2ocvv) + ) + + g2a.cvcv = ( + - einsum("Ja,Ib->IaJb", u.ph, u.ph) + - 0.5 * einsum('kIbc,kJac->IaJb', u.pphh, u.pphh) # TODO: use antisymm + - 0.5 * einsum('kIcb,kJca->IaJb', u.pphh, u.pphh) # TODO: use antisymm + + 0.5 * einsum('kIcb,kJac->IaJb', u.pphh, u.pphh) # TODO: use antisymm + + 0.5 * einsum('kIbc,kJca->IaJb', u.pphh, u.pphh) # TODO: use antisymm + ) + + # 0.7071067811865475 is 1/sqrt(2); is there a better way to do this? + # This factor is needed because of the scaling used in adcc + # for the ph-pphh blocks + g2a.occv = 0.7071067811865475 * ( + einsum('Ib,kJba->kJIa', u.ph, u.pphh) # TODO: use antisymm + - einsum('Ib,kJab->kJIa', u.ph, u.pphh) + ) + + g2a.oovv = ( + 0.5 * einsum('ijcb,ca->ijab', t2oovv, g1a_cvs0.vv) + -0.5 * einsum('ijca,cb->ijab', t2oovv, g1a_cvs0.vv) + -t2oovv + -2.0 * t2bar + ) + + # 1.414213562373095 is 2/sqrt(2); + # This factor is necessary because of the wa that the ph-pphh is scaled + g2a.ovvv = ( + 1.414213562373095 * einsum('Ja,iJcb->iabc', u.ph, u.pphh) + ) + + g2a.ovov = 0.5 * ( + - einsum("iKbc,jKac->iajb", u.pphh, u.pphh) + - einsum("iKcb,jKca->iajb", u.pphh, u.pphh) + + einsum("iKcb,jKac->iajb", u.pphh, u.pphh) + + einsum("iKbc,jKca->iajb", u.pphh, u.pphh) + ) + + g2a.ccvv = -t2ccvv + + g2a.ocvv = -t2ocvv + + g2a.ococ = einsum("iJab,kLab->iJkL", u.pphh, u.pphh) + + g2a.vvvv = 2.0 * einsum("iJcd,iJab->abcd", u.pphh, u.pphh) + + # These are the OC multipliers: + g1a.co = ( + - einsum('JbKc,ibKc->Ji', g2a.cvcv, hf.ovcv) + -0.5 * einsum('JKab,iKab->Ji', g2a.ccvv, hf.ocvv) + + einsum('kJLa,ikLa->Ji', g2a.occv, hf.oocv) + + 0.5 * einsum('kJab,ikab->Ji', g2a.ocvv, hf.oovv) + - einsum('kLJa,kLia->Ji', g2a.occv, hf.ocov) + + einsum('iKLa,JKLa->Ji', g2a.occv, hf.cccv) + + 0.5 * einsum('iKab,JKab->Ji', g2a.ocvv, hf.ccvv) + - 0.5 * einsum('ikab,kJab->Ji', g2a.oovv, hf.ocvv) + + 0.5 * einsum('iabc,Jabc->Ji', g2a.ovvv, hf.cvvv) + + einsum('kJmL,ikmL->Ji', g2a.ococ, hf.oooc) + - einsum('iKlM,JKMl->Ji', g2a.ococ, hf.ccco) + + einsum('iakb,kbJa->Ji', g2a.ovov, hf.ovcv) + ) / fco + + #print("OC:\n", g1a.co.evaluate().T) + + return g1a, g2a + def ampl_relaxed_dms_adc2(exci): u = exci.excitation_vector @@ -158,6 +374,8 @@ def ampl_relaxed_dms_mp2(mp): "adc2": ampl_relaxed_dms_adc2, "cvs-adc0": ampl_relaxed_dms_cvs_adc0, "cvs-adc1": ampl_relaxed_dms_cvs_adc1, + "cvs-adc2": ampl_relaxed_dms_cvs_adc2, + "cvs-adc2x": ampl_relaxed_dms_cvs_adc2x, } diff --git a/adcc/gradients/orbital_response.py b/adcc/gradients/orbital_response.py index a1fbca08a..3abedc34d 100644 --- a/adcc/gradients/orbital_response.py +++ b/adcc/gradients/orbital_response.py @@ -42,21 +42,50 @@ def orbital_response_rhs(hf, g1a, g2a): ret_ov = -1.0 * ( + 2.0 * einsum("JiKa,JK->ia", hf.cocv, g1a.cc) + 2.0 * einsum("icab,bc->ia", hf.ovvv, g1a.vv) + + 2.0 * einsum('kija,jk->ia', hf.ooov, g1a.oo) + 2.0 * einsum("kiJa,Jk->ia", hf.oocv, g1a.co) - 2.0 * einsum("iJka,Jk->ia", hf.ocov, g1a.co) - + 2.0*einsum ("iJKb,JaKb->ia", hf.occv, g2a.cvcv) # TODO: new var. + + 2.0 * einsum ("iJKb,JaKb->ia", hf.occv, g2a.cvcv) # 2PDMs start + + 2.0 * einsum('lKJa,lKiJ->ia', g2a.occv, hf.ococ) + + einsum('jabc,ijbc->ia', g2a.ovvv, hf.oovv) + - einsum('JKab,JKib->ia', g2a.ccvv, hf.ccov) + - 2.0 * einsum('jKab,jKib->ia', g2a.ocvv, hf.ocov) + - einsum('jkab,jkib->ia', g2a.oovv, hf.ooov) + - 2.0 * einsum('jcab,ibjc->ia', g2a.ovvv, hf.ovov) + - 2.0 * einsum('iJKb,JaKb->ia', g2a.occv, hf.cvcv) + - einsum('iJbc,Jabc->ia', g2a.ocvv, hf.cvvv) + - einsum('ijbc,jabc->ia', g2a.oovv, hf.ovvv) + + einsum('ibcd,abcd->ia', g2a.ovvv, hf.vvvv) + - einsum('abcd,ibcd->ia', g2a.vvvv, hf.ovvv) # cvs-adc2x + + 2.0 * einsum('jakb,ijkb->ia', g2a.ovov, hf.ooov) # cvs-adc2x + + 2.0 * einsum('ibjc,jcab->ia', g2a.ovov, hf.ovvv) # cvs-adc2x + - 2.0 * einsum('iJkL,kLJa->ia', g2a.ococ, hf.occv) # cvs-adc2x ) ret_cv = -1.0 * ( + 2.0 * einsum("JIKa,JK->Ia", hf.cccv, g1a.cc) + 2.0 * einsum("Icab,bc->Ia", hf.cvvv, g1a.vv) + + 2.0 * einsum('kIja,jk->Ia', hf.ocov, g1a.oo) + 2.0 * einsum("kIJa,Jk->Ia", hf.occv, g1a.co) + 2.0 * einsum("JIka,Jk->Ia", hf.ccov, g1a.co) - + 2.0 * einsum("IJKb,JaKb->Ia", hf.cccv, g2a.cvcv) # TODO: new var. - + 2.0 * einsum("Jcab,IbJc->Ia", hf.cvvv, g2a.cvcv) # TODO: new var. + + 2.0 * einsum("IJKb,JaKb->Ia", hf.cccv, g2a.cvcv) # 2PDMs start + + 2.0 * einsum("Jcab,IbJc->Ia", hf.cvvv, g2a.cvcv) + + 2.0 * einsum('lKJa,lKIJ->Ia', g2a.occv, hf.occc) + - einsum('jabc,jIbc->Ia', g2a.ovvv, hf.ocvv) + - einsum('JKab,JKIb->Ia', g2a.ccvv, hf.cccv) + - 2.0 * einsum('jKab,jKIb->Ia', g2a.ocvv, hf.occv) + - einsum('jkab,jkIb->Ia', g2a.oovv, hf.oocv) + - 2.0 * einsum('jcab,jcIb->Ia', g2a.ovvv, hf.ovcv) + - einsum('IJbc,Jabc->Ia', g2a.ccvv, hf.cvvv) + + 2.0*einsum('jIKb,jaKb->Ia', g2a.occv, hf.ovcv) + + einsum('jIbc,jabc->Ia', g2a.ocvv, hf.ovvv) + + 2.0 * einsum('kJIb,kJab->Ia', g2a.occv, hf.ocvv) + - einsum('abcd,Ibcd->Ia', g2a.vvvv, hf.cvvv) # cvs-adc2x + - 2.0 * einsum('jakb,jIkb->Ia', g2a.ovov, hf.ocov) # cvs-adc2x + - 2.0 * einsum('jIlK,lKja->Ia', g2a.ococ, hf.ocov) # cvs-adc2x ) - #print("\nRHS OV:\n", ret_cv.evaluate()) + #print("\nRHS OV:\n", ret_ov.evaluate()) ret = AmplitudeVector(ph=ret_cv, pphh=ret_ov) @@ -89,13 +118,14 @@ def orbital_response_rhs(hf, g1a, g2a): def energy_weighted_density_matrix(hf, g1o, g2a): if hf.has_core_occupied_space: - # CVS-ADC0; TODO: add 2PDM contributions + # CVS-ADC0, CVS-ADC1, CVS-ADC2 w = OneParticleOperator(hf) w.cc = ( - hf.fcc - - einsum("ik,jk->ij", g1o.cc, hf.fcc) + - einsum("IK,JK->IJ", g1o.cc, hf.fcc) - einsum("ab,IaJb->IJ", g1o.vv, hf.cvcv) - einsum("KL,IKJL->IJ", g1o.cc, hf.cccc) + - einsum("kl,kIlJ->IJ", g1o.oo, hf.ococ) + einsum("ka,kJIa->IJ", g1o.ov, hf.occv) + einsum("ka,kIJa->IJ", g1o.ov, hf.occv) + einsum("Ka,KJIa->IJ", g1o.cv, hf.cccv) @@ -103,25 +133,47 @@ def energy_weighted_density_matrix(hf, g1o, g2a): - einsum("Lk,kILJ->IJ", g1o.co, hf.occc) - einsum("Lk,kJLI->IJ", g1o.co, hf.occc) - einsum("JbKc,IbKc->IJ", g2a.cvcv, hf.cvcv) + - 0.5 * einsum("JKab,IKab->IJ", g2a.ccvv, hf.ccvv) + - einsum("kJLa,kILa->IJ", g2a.occv, hf.occv) + - 0.5 * einsum("kJab,kIab->IJ", g2a.ocvv, hf.ocvv) + - einsum("kLJa,kLIa->IJ", g2a.occv, hf.occv) + - einsum("kJmL,kImL->IJ", g2a.ococ, hf.ococ) # cvs-adc2x ) w.oo = ( - hf.foo + - einsum("ij,ii->ij", g1o.oo, hf.foo) # TODO: double check this - einsum("KL,iKjL->ij", g1o.cc, hf.ococ) - einsum("ab,iajb->ij", g1o.vv, hf.ovov) + - einsum("kl,ikjl->ij", g1o.oo, hf.oooo) - einsum("ka,ikja->ij", g1o.ov, hf.ooov) - einsum("ka,jkia->ij", g1o.ov, hf.ooov) - einsum("Ka,iKja->ij", g1o.cv, hf.ocov) - einsum("Ka,jKia->ij", g1o.cv, hf.ocov) + einsum("Lk,kijL->ij", g1o.co, hf.oooc) + einsum("Lk,kjiL->ij", g1o.co, hf.oooc) + - einsum("jKLa,iKLa->ij", g2a.occv, hf.occv) + - 0.5 * einsum("jKab,iKab->ij", g2a.ocvv, hf.ocvv) + - 0.5 * einsum("jkab,ikab->ij", g2a.oovv, hf.oovv) + - 0.5 * einsum("jabc,iabc->ij", g2a.ovvv, hf.ovvv) + - einsum("jKlM,iKlM->ij", g2a.ococ, hf.ococ) # cvs-adc2x + - einsum("jakb,iakb->ij", g2a.ovov, hf.ovov) # cvs-adc2x ) w.vv = ( - einsum("ac,cb->ab", g1o.vv, hf.fvv) - einsum('JbKc,JaKc->ab', g2a.cvcv, hf.cvcv) + - einsum("jKIb,jKIa->ab", g2a.occv, hf.occv) + - 0.5 * einsum("ibcd,iacd->ab", g2a.ovvv, hf.ovvv) + - einsum("idbc,idac->ab", g2a.ovvv, hf.ovvv) + - 0.5 * einsum("IJbc,IJac->ab", g2a.ccvv, hf.ccvv) + - einsum("iJbc,iJac->ab", g2a.ocvv, hf.ocvv) + - 0.5 * einsum("ijbc,ijac->ab", g2a.oovv, hf.oovv) + - einsum("ibjc,iajc->ab", g2a.ovov, hf.ovov) # cvs-adc2x + - 0.5 * einsum("bcde,acde->ab", g2a.vvvv, hf.vvvv) # cvs-adc2x ) w.co = ( einsum("KL,iKLJ->Ji", g1o.cc, hf.occc) - einsum("ab,iaJb->Ji", g1o.vv, hf.ovcv) + - einsum("kl,kilJ->Ji", g1o.oo, hf.oooc) - einsum("Ka,iKJa->Ji", g1o.cv, hf.occv) - einsum("Ka,JKia->Ji", g1o.cv, hf.ccov) - einsum("ka,ikJa->Ji", g1o.ov, hf.oocv) @@ -130,16 +182,37 @@ def energy_weighted_density_matrix(hf, g1o, g2a): + einsum("Lk,iLkJ->Ji", g1o.co, hf.ococ) - einsum("Ik,jk->Ij", g1o.co, hf.foo) - einsum("JbKc,ibKc->Ji", g2a.cvcv, hf.ovcv) + - 0.5 * einsum("JKab,iKab->Ji", g2a.ccvv, hf.ocvv) + + einsum("kJLa,ikLa->Ji", g2a.occv, hf.oocv) + + 0.5 * einsum("kJab,ikab->Ji", g2a.ocvv, hf.oovv) + - einsum("kLJa,kLia->Ji", g2a.occv, hf.ocov) + + einsum("kJmL,ikmL->Ji", g2a.ococ, hf.oooc) # cvs-adc2x ) w.ov = ( - einsum("ij,ja->ia", hf.foo, g1o.ov) + einsum("JaKc,iJKc->ia", g2a.cvcv, hf.occv) + + einsum("kLJa,iJkL->ia", g2a.occv, hf.ococ) + + 0.5 * einsum("jabc,ijbc->ia", g2a.ovvv, hf.oovv) + - 0.5 * einsum("JKab,JKib->ia", g2a.ccvv, hf.ccov) + - einsum("jKab,jKib->ia", g2a.ocvv, hf.ocov) + - 0.5 * einsum("jkab,jkib->ia", g2a.oovv, hf.ooov) + - einsum("jcab,ibjc->ia", g2a.ovvv, hf.ovov) + - 0.5 * einsum("abcd,ibcd->ia", g2a.vvvv, hf.ovvv) # cvs-adc2x + + einsum("jakb,ijkb->ia", g2a.ovov, hf.ooov) # cvs-adc2x ) w.cv = ( - einsum("IJ,Ja->Ia", hf.fcc, g1o.cv) + einsum("JaKc,IJKc->Ia", g2a.cvcv, hf.cccv) + + einsum("lKJa,lKIJ->Ia", g2a.occv, hf.occc) + - 0.5 * einsum("jabc,jIbc->Ia", g2a.ovvv, hf.ocvv) + - 0.5 * einsum("JKab,JKIb->Ia", g2a.ccvv, hf.cccv) + - einsum("kJab,kJIb->Ia", g2a.ocvv, hf.occv) + - 0.5 * einsum("jkab,jkIb->Ia", g2a.oovv, hf.oocv) + - einsum("jcab,jcIb->Ia", g2a.ovvv, hf.ovcv) + - 0.5 * einsum("abcd,Ibcd->Ia", g2a.vvvv, hf.cvvv) # cvs-adc2x + - einsum("jakb,jIkb->Ia", g2a.ovov, hf.ocov) # cvs-adc2x ) - print("\nOMEGA cv:\n", w.cv.evaluate()) + #print("\nOMEGA cv:\n", w.cv.evaluate()) else: gi_oo = -0.5 * ( # + 1.0 * einsum("jklm,iklm->ij", hf.oooo, g2a.oooo) @@ -283,6 +356,6 @@ def orbital_response(hf, rhs): #print(rhs.space) #print(rhs.subspaces) ##print(dir(l_ov.solution)) - print("Solution CV:\n", 0.5*l_ov.solution['ph']) - print("\nSolution OV:\n",0.5*l_ov.solution['pphh']) + #print("Solution CV:\n", 0.5*l_ov.solution['ph']) + #print("\nSolution OV:\n",0.5*l_ov.solution['pphh']) return l_ov.solution From 87599e71ef3a39c58676f7bddc5911a78490f752 Mon Sep 17 00:00:00 2001 From: iubr Date: Thu, 11 Nov 2021 12:00:07 +0900 Subject: [PATCH 05/18] cleaned up code; fixed a few TODOs; remaining: 1/sqrt2, antisymm, adc vs. cvs-adc rhs. fixed 1/sqrt(2) additional comments, RHS switched to using symmetrise and antisymmetrise to construct density matrices --- adcc/gradients/__init__.py | 18 +-- adcc/gradients/amplitude_response.py | 168 +++++++++++----------- adcc/gradients/orbital_response.py | 202 ++++++++++++++------------- 3 files changed, 189 insertions(+), 199 deletions(-) diff --git a/adcc/gradients/__init__.py b/adcc/gradients/__init__.py index 9532e4609..8be263925 100644 --- a/adcc/gradients/__init__.py +++ b/adcc/gradients/__init__.py @@ -63,18 +63,13 @@ def nuclear_gradient(excitation_or_mp): with timer.record("orbital_response"): rhs = orbital_response_rhs(hf, g1a, g2a).evaluate() - l_ov = orbital_response(hf, rhs) + l = orbital_response(hf, rhs) # orbital-relaxed OPDM (without reference state) g1o = g1a.copy() + g1o.ov = 0.5 * l.ov if hf.has_core_occupied_space: - # For CVS, the solution is stored in an Amplitude - # Vector object with th OV block stored in pphh - # and the CV block stored in ph - g1o.ov = 0.5 * l_ov['pphh'] - g1o.cv = 0.5 * l_ov['ph'] - else: - g1o.ov = 0.5 * l_ov + g1o.cv = 0.5 * l.cv # orbital-relaxed OPDM (including reference state) g1 = g1o.copy() g1 += hf.density @@ -89,13 +84,10 @@ def nuclear_gradient(excitation_or_mp): delta_IJ = hf.density.cc g2_hf = TwoParticleDensityMatrix(hf) - # I don't understand wy 0.25 is necessary for oooo, but 0.5 for cccc - # Doesn't make sense...; TODO: figure it out. g2_hf.oooo = -0.25 * ( einsum("ik,jl->ijkl", delta_ij, delta_ij)) g2_hf.cccc = -0.5 * ( einsum("IK,JL->IJKL", delta_IJ, delta_IJ)) g2_hf.ococ = -1.0 * ( einsum("ik,JL->iJkL", delta_ij, delta_IJ)) - # No idea why we need a 0.25 in front of the oooo block... g2_oresp = TwoParticleDensityMatrix(hf) g2_oresp.cccc = einsum("IK,JL->IJKL", delta_IJ, g1o.cc+delta_IJ) g2_oresp.ococ = ( @@ -118,8 +110,8 @@ def nuclear_gradient(excitation_or_mp): g2a.oovv *= 0.5 g2a.ccvv *= 0.5 g2a.occv *= 2.0 - g2a.vvvv *= 0.25 # Scalin twice is really strange... but the only - g2a.vvvv *= 0.25 # way it works... + g2a.vvvv *= 0.25 # Scaling twice! + g2a.vvvv *= 0.25 # it's the only way it works... g2_total = evaluate(g2_hf + g2a + g2_oresp) else: diff --git a/adcc/gradients/amplitude_response.py b/adcc/gradients/amplitude_response.py index 4b831b0ab..c2be29772 100644 --- a/adcc/gradients/amplitude_response.py +++ b/adcc/gradients/amplitude_response.py @@ -20,6 +20,8 @@ ## along with adcc. If not, see . ## ## --------------------------------------------------------------------- +from math import sqrt + from adcc.functions import einsum, direct_sum, evaluate from .TwoParticleDensityMatrix import TwoParticleDensityMatrix @@ -63,7 +65,6 @@ def t2bar_oovv_cvs_adc2(exci, g1a_adc0): direct_sum("ia+jb->ijab", df_ia, df_ia).symmetrise((0, 1)) ) - #TODO: remove print("T2bar:\n",t2bar.evaluate()) return t2bar @@ -72,9 +73,9 @@ def ampl_relaxed_dms_adc1(exci): u = exci.excitation_vector g1a = OneParticleOperator(hf) g2a = TwoParticleDensityMatrix(hf) - g1a.oo = -1.0 * einsum("ia,ja->ij", u.ph, u.ph) - g1a.vv = +1.0 * einsum("ia,ib->ab", u.ph, u.ph) - g2a.ovov = -1.0 * einsum("ja,ib->iajb", u.ph, u.ph) + g1a.oo = - 1.0 * einsum("ia,ja->ij", u.ph, u.ph) + g1a.vv = + 1.0 * einsum("ia,ib->ab", u.ph, u.ph) + g2a.ovov = - 1.0 * einsum("ja,ib->iajb", u.ph, u.ph) return g1a, g2a def ampl_relaxed_dms_adc0(exci): @@ -84,8 +85,8 @@ def ampl_relaxed_dms_adc0(exci): g2a = TwoParticleDensityMatrix(hf) # g2a is not required for the adc0 gradient, # but expected by amplitude_relaxed_densities - g1a.oo = -1.0 * einsum("ia,ja->ij", u.ph, u.ph) - g1a.vv = +1.0 * einsum("ia,ib->ab", u.ph, u.ph) + g1a.oo = - 1.0 * einsum("ia,ja->ij", u.ph, u.ph) + g1a.vv = + 1.0 * einsum("ia,ib->ab", u.ph, u.ph) return g1a, g2a def ampl_relaxed_dms_cvs_adc0(exci): @@ -95,8 +96,8 @@ def ampl_relaxed_dms_cvs_adc0(exci): g2a = TwoParticleDensityMatrix(hf) # g2a is not required for cvs-adc0 gradient, # but expected by amplitude_relaxed_densities - g1a.cc = -1.0 * einsum("Ia,Ja->IJ", u.ph, u.ph) - g1a.vv = +1.0 * einsum("Ia,Ib->ab", u.ph, u.ph) + g1a.cc = - 1.0 * einsum("Ia,Ja->IJ", u.ph, u.ph) + g1a.vv = + 1.0 * einsum("Ia,Ib->ab", u.ph, u.ph) return g1a, g2a def ampl_relaxed_dms_cvs_adc1(exci): @@ -104,8 +105,9 @@ def ampl_relaxed_dms_cvs_adc1(exci): u = exci.excitation_vector g1a = OneParticleOperator(hf) g2a = TwoParticleDensityMatrix(hf) - g2a.cvcv = -1.0 * einsum("Ja,Ib->IaJb", u.ph, u.ph) - g1a.cc = -1.0 * einsum("Ia,Ja->IJ", u.ph, u.ph) + g2a.cvcv = - 1.0 * einsum("Ja,Ib->IaJb", u.ph, u.ph) + g1a.cc = - 1.0 * einsum("Ia,Ja->IJ", u.ph, u.ph) + g1a.vv = + 1.0 * einsum("Ia,Ib->ab", u.ph, u.ph) # Pre-requisites for the OC block of the # orbital response Lagrange multipliers: @@ -113,9 +115,7 @@ def ampl_relaxed_dms_cvs_adc1(exci): fo = hf.fock(b.oo).diagonal() fco = direct_sum("-j+I->jI", fc, fo).evaluate() # These are the multipliers: - g1a.co = - einsum('JbKc,ibKc->Ji', g2a.cvcv, hf.ovcv) / fco - # TODO: print("L multipliers CO block:\n", g1a.co.evaluate().T) - g1a.vv = +1.0 * einsum("Ia,Ib->ab", u.ph, u.ph) + g1a.co = - 1.0 * einsum('JbKc,ibKc->Ji', g2a.cvcv, hf.ovcv) / fco return g1a, g2a def ampl_relaxed_dms_cvs_adc2(exci): @@ -133,16 +133,16 @@ def ampl_relaxed_dms_cvs_adc2(exci): t2bar = t2bar_oovv_cvs_adc2(exci, g1a_cvs0).evaluate() g1a.cc = ( - - einsum("Ia,Ja->IJ", u.ph, u.ph) - - einsum("kJba,kIba->IJ", u.pphh, u.pphh) + - 1.0 * einsum("Ia,Ja->IJ", u.ph, u.ph) + - 1.0 * einsum("kJba,kIba->IJ", u.pphh, u.pphh) - 0.5 * einsum('IKab,JKab->IJ', t2ccvv, t2ccvv) - 0.5 * einsum('kIab,kJab->IJ', t2ocvv, t2ocvv) ) g1a.oo = ( - - einsum("jKba,iKba->ij", u.pphh, u.pphh) - - einsum("ikab,jkab->ij", t2bar, t2oovv) # TODO: - - einsum('jkab,ikab->ij', t2oovv, t2bar) # use antisymmetrize + - 1.0 * einsum("jKba,iKba->ij", u.pphh, u.pphh) + - 2.0 * einsum("ikab,jkab->ij", t2bar, t2oovv).symmetrise((0, 1)) + #- 1.0 * einsum('jkab,ikab->ij', t2oovv, t2bar) - 0.5 * einsum('iKab,jKab->ij', t2ocvv, t2ocvv) - 0.5 * einsum('ikab,jkab->ij', t2oovv, t2oovv) ) @@ -153,60 +153,58 @@ def ampl_relaxed_dms_cvs_adc2(exci): fo = hf.fock(b.oo).diagonal() fco = direct_sum("-j+I->jI", fc, fo).evaluate() - #print("L multipliers CO block:\n", g1a.co.evaluate().T) g1a.vv = ( - einsum("Ia,Ib->ab", u.ph, u.ph) + + 1.0 * einsum("Ia,Ib->ab", u.ph, u.ph) + 2.0 * einsum('jIcb,jIca->ab', u.pphh, u.pphh) - + einsum('ijac,ijbc->ab', t2bar, t2oovv) - + einsum('ijbc,ijac->ab', t2bar, t2oovv) + + 2.0 * einsum('ijac,ijbc->ab', t2bar, t2oovv).symmetrise((0, 1)) + #+ 1.0 * einsum('ijbc,ijac->ab', t2bar, t2oovv) + 0.5 * einsum('IJac,IJbc->ab', t2ccvv, t2ccvv) + 0.5 * einsum('ijac,ijbc->ab', t2oovv, t2oovv) - + einsum('iJac,iJbc->ab', t2ocvv, t2ocvv) + + 1.0 * einsum('iJac,iJbc->ab', t2ocvv, t2ocvv) ) g2a.cvcv = ( - einsum("Ja,Ib->IaJb", u.ph, u.ph) ) - # 0.7071067811865475 is 1/sqrt(2); is there a better way to do this? - # This factor is needed because of the scaling used in adcc - # for the ph-pphh blocks - g2a.occv = 0.7071067811865475 * ( - einsum('Ib,kJba->kJIa', u.ph, u.pphh) # TODO: use antisymm - - einsum('Ib,kJab->kJIa', u.ph, u.pphh) + # The factor 1/sqrt(2) is needed because of the scaling used in adcc + # for the ph-pphh blocks. + g2a.occv = (1 / sqrt(2)) * ( + 2.0 * einsum('Ib,kJba->kJIa', u.ph, u.pphh) + #- einsum('Ib,kJab->kJIa', u.ph, u.pphh) ) g2a.oovv = ( - 0.5 * einsum('ijcb,ca->ijab', t2oovv, g1a_cvs0.vv) - -0.5 * einsum('ijca,cb->ijab', t2oovv, g1a_cvs0.vv) - -t2oovv - -2.0 * t2bar + + 1.0 * einsum('ijcb,ca->ijab', t2oovv, g1a_cvs0.vv).antisymmetrise((2, 3)) + #- 0.5 * einsum('ijca,cb->ijab', t2oovv, g1a_cvs0.vv) + - 1.0 * t2oovv + - 2.0 * t2bar ) - # 1.414213562373095 is 2/sqrt(2); - # This factor is necessary because of the wa that the ph-pphh is scaled - g2a.ovvv = ( - 1.414213562373095 * einsum('Ja,iJcb->iabc', u.ph, u.pphh) + # The factor 2/sqrt(2) is necessary because of the way + # that the ph-pphh is scaled. + g2a.ovvv = (2 / sqrt(2) ) * ( + einsum('Ja,iJcb->iabc', u.ph, u.pphh) ) g2a.ccvv = -t2ccvv g2a.ocvv = -t2ocvv - # These are the OC multipliers: + # This is the OC block of the orbital response + # Lagrange multipliers (lambda): g1a.co = ( - - einsum('JbKc,ibKc->Ji', g2a.cvcv, hf.ovcv) - -0.5 * einsum('JKab,iKab->Ji', g2a.ccvv, hf.ocvv) - + einsum('kJLa,ikLa->Ji', g2a.occv, hf.oocv) + - 1.0 * einsum('JbKc,ibKc->Ji', g2a.cvcv, hf.ovcv) + - 0.5 * einsum('JKab,iKab->Ji', g2a.ccvv, hf.ocvv) + + 1.0 * einsum('kJLa,ikLa->Ji', g2a.occv, hf.oocv) + 0.5 * einsum('kJab,ikab->Ji', g2a.ocvv, hf.oovv) - - einsum('kLJa,kLia->Ji', g2a.occv, hf.ocov) - + einsum('iKLa,JKLa->Ji', g2a.occv, hf.cccv) + - 1.0 * einsum('kLJa,kLia->Ji', g2a.occv, hf.ocov) + + 1.0 * einsum('iKLa,JKLa->Ji', g2a.occv, hf.cccv) + 0.5 * einsum('iKab,JKab->Ji', g2a.ocvv, hf.ccvv) - 0.5 * einsum('ikab,kJab->Ji', g2a.oovv, hf.ocvv) + 0.5 * einsum('iabc,Jabc->Ji', g2a.ovvv, hf.cvvv) ) / fco - #print("Lambda CO:\n", g1a.co.evaluate().T) return g1a, g2a @@ -225,16 +223,16 @@ def ampl_relaxed_dms_cvs_adc2x(exci): t2bar = t2bar_oovv_cvs_adc2(exci, g1a_cvs0).evaluate() g1a.cc = ( - - einsum("Ia,Ja->IJ", u.ph, u.ph) - - einsum("kJba,kIba->IJ", u.pphh, u.pphh) + - 1.0 * einsum("Ia,Ja->IJ", u.ph, u.ph) + - 1.0 * einsum("kJba,kIba->IJ", u.pphh, u.pphh) - 0.5 * einsum('IKab,JKab->IJ', t2ccvv, t2ccvv) - 0.5 * einsum('kIab,kJab->IJ', t2ocvv, t2ocvv) ) g1a.oo = ( - - einsum("jKba,iKba->ij", u.pphh, u.pphh) - - einsum("ikab,jkab->ij", t2bar, t2oovv) # TODO: - - einsum('jkab,ikab->ij', t2oovv, t2bar) # use antisymmetrize + - 1.0 * einsum("jKba,iKba->ij", u.pphh, u.pphh) + - 2.0 * einsum("ikab,jkab->ij", t2bar, t2oovv).symmetrise((0, 1)) + #- 1.0 * einsum('jkab,ikab->ij', t2oovv, t2bar) # use symmetrize? - 0.5 * einsum('iKab,jKab->ij', t2ocvv, t2ocvv) - 0.5 * einsum('ikab,jkab->ij', t2oovv, t2oovv) ) @@ -245,79 +243,75 @@ def ampl_relaxed_dms_cvs_adc2x(exci): fo = hf.fock(b.oo).diagonal() fco = direct_sum("-j+I->jI", fc, fo).evaluate() - #print("L multipliers CO block:\n", g1a.co.evaluate().T) g1a.vv = ( - einsum("Ia,Ib->ab", u.ph, u.ph) + + 1.0 * einsum("Ia,Ib->ab", u.ph, u.ph) + 2.0 * einsum('jIcb,jIca->ab', u.pphh, u.pphh) - + einsum('ijac,ijbc->ab', t2bar, t2oovv) - + einsum('ijbc,ijac->ab', t2bar, t2oovv) + + 2.0 * einsum('ijac,ijbc->ab', t2bar, t2oovv).symmetrise((0, 1)) + #+ 1.0 * einsum('ijbc,ijac->ab', t2bar, t2oovv) + 0.5 * einsum('IJac,IJbc->ab', t2ccvv, t2ccvv) + 0.5 * einsum('ijac,ijbc->ab', t2oovv, t2oovv) - + einsum('iJac,iJbc->ab', t2ocvv, t2ocvv) + + 1.0 * einsum('iJac,iJbc->ab', t2ocvv, t2ocvv) ) g2a.cvcv = ( - - einsum("Ja,Ib->IaJb", u.ph, u.ph) - - 0.5 * einsum('kIbc,kJac->IaJb', u.pphh, u.pphh) # TODO: use antisymm - - 0.5 * einsum('kIcb,kJca->IaJb', u.pphh, u.pphh) # TODO: use antisymm - + 0.5 * einsum('kIcb,kJac->IaJb', u.pphh, u.pphh) # TODO: use antisymm - + 0.5 * einsum('kIbc,kJca->IaJb', u.pphh, u.pphh) # TODO: use antisymm + - 1.0 * einsum("Ja,Ib->IaJb", u.ph, u.ph) + - 1.0 * einsum('kIbc,kJac->IaJb', u.pphh, u.pphh) + #- 0.5 * einsum('kIcb,kJca->IaJb', u.pphh, u.pphh) + + 1.0 * einsum('kIcb,kJac->IaJb', u.pphh, u.pphh) + #+ 0.5 * einsum('kIbc,kJca->IaJb', u.pphh, u.pphh) ) - # 0.7071067811865475 is 1/sqrt(2); is there a better way to do this? - # This factor is needed because of the scaling used in adcc - # for the ph-pphh blocks - g2a.occv = 0.7071067811865475 * ( - einsum('Ib,kJba->kJIa', u.ph, u.pphh) # TODO: use antisymm - - einsum('Ib,kJab->kJIa', u.ph, u.pphh) + # The factor 1/sqrt(2) is needed because of the scaling used in adcc + # for the ph-pphh blocks. + g2a.occv = (1 / sqrt(2)) * ( + 2.0 * einsum('Ib,kJba->kJIa', u.ph, u.pphh) + #- einsum('Ib,kJab->kJIa', u.ph, u.pphh) ) g2a.oovv = ( - 0.5 * einsum('ijcb,ca->ijab', t2oovv, g1a_cvs0.vv) - -0.5 * einsum('ijca,cb->ijab', t2oovv, g1a_cvs0.vv) - -t2oovv - -2.0 * t2bar + + 1.0 * einsum('ijcb,ca->ijab', t2oovv, g1a_cvs0.vv).antisymmetrise((2, 3)) + #- 0.5 * einsum('ijca,cb->ijab', t2oovv, g1a_cvs0.vv) + - 1.0 * t2oovv + - 2.0 * t2bar ) - # 1.414213562373095 is 2/sqrt(2); - # This factor is necessary because of the wa that the ph-pphh is scaled - g2a.ovvv = ( - 1.414213562373095 * einsum('Ja,iJcb->iabc', u.ph, u.pphh) + # The factor 2/sqrt(2) is necessary because of + # the way that the ph-pphh is scaled + g2a.ovvv = (2 / sqrt(2)) * ( + einsum('Ja,iJcb->iabc', u.ph, u.pphh) ) - g2a.ovov = 0.5 * ( + g2a.ovov = 1.0 * ( - einsum("iKbc,jKac->iajb", u.pphh, u.pphh) - - einsum("iKcb,jKca->iajb", u.pphh, u.pphh) + #- einsum("iKcb,jKca->iajb", u.pphh, u.pphh) + einsum("iKcb,jKac->iajb", u.pphh, u.pphh) - + einsum("iKbc,jKca->iajb", u.pphh, u.pphh) + #+ einsum("iKbc,jKca->iajb", u.pphh, u.pphh) ) g2a.ccvv = -t2ccvv g2a.ocvv = -t2ocvv - g2a.ococ = einsum("iJab,kLab->iJkL", u.pphh, u.pphh) + g2a.ococ = 1.0 * einsum("iJab,kLab->iJkL", u.pphh, u.pphh) g2a.vvvv = 2.0 * einsum("iJcd,iJab->abcd", u.pphh, u.pphh) # These are the OC multipliers: g1a.co = ( - - einsum('JbKc,ibKc->Ji', g2a.cvcv, hf.ovcv) - -0.5 * einsum('JKab,iKab->Ji', g2a.ccvv, hf.ocvv) - + einsum('kJLa,ikLa->Ji', g2a.occv, hf.oocv) + - 1.0 * einsum('JbKc,ibKc->Ji', g2a.cvcv, hf.ovcv) + - 0.5 * einsum('JKab,iKab->Ji', g2a.ccvv, hf.ocvv) + + 1.0 * einsum('kJLa,ikLa->Ji', g2a.occv, hf.oocv) + 0.5 * einsum('kJab,ikab->Ji', g2a.ocvv, hf.oovv) - - einsum('kLJa,kLia->Ji', g2a.occv, hf.ocov) - + einsum('iKLa,JKLa->Ji', g2a.occv, hf.cccv) + - 1.0 * einsum('kLJa,kLia->Ji', g2a.occv, hf.ocov) + + 1.0 * einsum('iKLa,JKLa->Ji', g2a.occv, hf.cccv) + 0.5 * einsum('iKab,JKab->Ji', g2a.ocvv, hf.ccvv) - 0.5 * einsum('ikab,kJab->Ji', g2a.oovv, hf.ocvv) + 0.5 * einsum('iabc,Jabc->Ji', g2a.ovvv, hf.cvvv) - + einsum('kJmL,ikmL->Ji', g2a.ococ, hf.oooc) - - einsum('iKlM,JKMl->Ji', g2a.ococ, hf.ccco) - + einsum('iakb,kbJa->Ji', g2a.ovov, hf.ovcv) + + 1.0 * einsum('kJmL,ikmL->Ji', g2a.ococ, hf.oooc) + - 1.0 * einsum('iKlM,JKMl->Ji', g2a.ococ, hf.ccco) + + 1.0 * einsum('iakb,kbJa->Ji', g2a.ovov, hf.ovcv) ) / fco - #print("OC:\n", g1a.co.evaluate().T) - return g1a, g2a diff --git a/adcc/gradients/orbital_response.py b/adcc/gradients/orbital_response.py index 3abedc34d..b7dbd0091 100644 --- a/adcc/gradients/orbital_response.py +++ b/adcc/gradients/orbital_response.py @@ -39,6 +39,9 @@ def orbital_response_rhs(hf, g1a, g2a): # TODO: only add non-zero blocks to equations! if hf.has_core_occupied_space: + # IB: regular adc has three additional terms that do not appear in cvs-adc: + # (hf.ooov, g2a.ooov); (hf.ovov, g2a.ooov); (hf.oovv, g2a.ooov); + # for all common terms, the pre-factors are the same. ret_ov = -1.0 * ( + 2.0 * einsum("JiKa,JK->ia", hf.cocv, g1a.cc) + 2.0 * einsum("icab,bc->ia", hf.ovvv, g1a.vv) @@ -47,16 +50,16 @@ def orbital_response_rhs(hf, g1a, g2a): - 2.0 * einsum("iJka,Jk->ia", hf.ocov, g1a.co) + 2.0 * einsum ("iJKb,JaKb->ia", hf.occv, g2a.cvcv) # 2PDMs start + 2.0 * einsum('lKJa,lKiJ->ia', g2a.occv, hf.ococ) - + einsum('jabc,ijbc->ia', g2a.ovvv, hf.oovv) - - einsum('JKab,JKib->ia', g2a.ccvv, hf.ccov) + + 1.0 * einsum('jabc,ijbc->ia', g2a.ovvv, hf.oovv) + - 1.0 * einsum('JKab,JKib->ia', g2a.ccvv, hf.ccov) - 2.0 * einsum('jKab,jKib->ia', g2a.ocvv, hf.ocov) - - einsum('jkab,jkib->ia', g2a.oovv, hf.ooov) + - 1.0 * einsum('jkab,jkib->ia', g2a.oovv, hf.ooov) - 2.0 * einsum('jcab,ibjc->ia', g2a.ovvv, hf.ovov) - 2.0 * einsum('iJKb,JaKb->ia', g2a.occv, hf.cvcv) - - einsum('iJbc,Jabc->ia', g2a.ocvv, hf.cvvv) - - einsum('ijbc,jabc->ia', g2a.oovv, hf.ovvv) - + einsum('ibcd,abcd->ia', g2a.ovvv, hf.vvvv) - - einsum('abcd,ibcd->ia', g2a.vvvv, hf.ovvv) # cvs-adc2x + - 1.0 * einsum('iJbc,Jabc->ia', g2a.ocvv, hf.cvvv) + - 1.0 * einsum('ijbc,jabc->ia', g2a.oovv, hf.ovvv) + + 1.0 * einsum('ibcd,abcd->ia', g2a.ovvv, hf.vvvv) + - 1.0 * einsum('abcd,ibcd->ia', g2a.vvvv, hf.ovvv) # cvs-adc2x + 2.0 * einsum('jakb,ijkb->ia', g2a.ovov, hf.ooov) # cvs-adc2x + 2.0 * einsum('ibjc,jcab->ia', g2a.ovov, hf.ovvv) # cvs-adc2x - 2.0 * einsum('iJkL,kLJa->ia', g2a.ococ, hf.occv) # cvs-adc2x @@ -71,29 +74,27 @@ def orbital_response_rhs(hf, g1a, g2a): + 2.0 * einsum("IJKb,JaKb->Ia", hf.cccv, g2a.cvcv) # 2PDMs start + 2.0 * einsum("Jcab,IbJc->Ia", hf.cvvv, g2a.cvcv) + 2.0 * einsum('lKJa,lKIJ->Ia', g2a.occv, hf.occc) - - einsum('jabc,jIbc->Ia', g2a.ovvv, hf.ocvv) - - einsum('JKab,JKIb->Ia', g2a.ccvv, hf.cccv) + - 1.0 * einsum('jabc,jIbc->Ia', g2a.ovvv, hf.ocvv) + - 1.0 * einsum('JKab,JKIb->Ia', g2a.ccvv, hf.cccv) - 2.0 * einsum('jKab,jKIb->Ia', g2a.ocvv, hf.occv) - - einsum('jkab,jkIb->Ia', g2a.oovv, hf.oocv) + - 1.0 * einsum('jkab,jkIb->Ia', g2a.oovv, hf.oocv) - 2.0 * einsum('jcab,jcIb->Ia', g2a.ovvv, hf.ovcv) - - einsum('IJbc,Jabc->Ia', g2a.ccvv, hf.cvvv) - + 2.0*einsum('jIKb,jaKb->Ia', g2a.occv, hf.ovcv) - + einsum('jIbc,jabc->Ia', g2a.ocvv, hf.ovvv) + - 1.0 * einsum('IJbc,Jabc->Ia', g2a.ccvv, hf.cvvv) + + 2.0 * einsum('jIKb,jaKb->Ia', g2a.occv, hf.ovcv) + + 1.0 * einsum('jIbc,jabc->Ia', g2a.ocvv, hf.ovvv) + 2.0 * einsum('kJIb,kJab->Ia', g2a.occv, hf.ocvv) - - einsum('abcd,Ibcd->Ia', g2a.vvvv, hf.cvvv) # cvs-adc2x + - 1.0 * einsum('abcd,Ibcd->Ia', g2a.vvvv, hf.cvvv) # cvs-adc2x - 2.0 * einsum('jakb,jIkb->Ia', g2a.ovov, hf.ocov) # cvs-adc2x - 2.0 * einsum('jIlK,lKja->Ia', g2a.ococ, hf.ocov) # cvs-adc2x ) - #print("\nRHS OV:\n", ret_ov.evaluate()) - - ret = AmplitudeVector(ph=ret_cv, pphh=ret_ov) + ret = AmplitudeVector(cv=ret_cv, ov=ret_ov) else: # equal to the ov block of the energy-weighted density # matrix when lambda_ov multipliers are zero w_ov = 0.5 * ( - + 1.0 * einsum("ijkl,klja->ia", hf.oooo, g2a.ooov) + + 1.0 * einsum("ijkl,klja->ia", hf.oooo, g2a.ooov) # not in cvs-adc # - 1.0 * einsum("ibcd,abcd->ia", hf.ovvv, g2a.vvvv) - 1.0 * einsum("jkib,jkab->ia", hf.ooov, g2a.oovv) + 2.0 * einsum("ijkb,jakb->ia", hf.ooov, g2a.ovov) @@ -102,17 +103,21 @@ def orbital_response_rhs(hf, g1a, g2a): ) w_ov = w_ov.evaluate() - ret = -1.0 * ( + ret_ov = -1.0 * ( 2.0 * w_ov # - 1.0 * einsum("klja,ijkl->ia", hf.ooov, g2a.oooo) + 1.0 * einsum("abcd,ibcd->ia", hf.vvvv, g2a.ovvv) - - 2.0 * einsum("jakb,ijkb->ia", hf.ovov, g2a.ooov) - + 1.0 * einsum("jkab,jkib->ia", hf.oovv, g2a.ooov) + - 2.0 * einsum("jakb,ijkb->ia", hf.ovov, g2a.ooov) # not in cvs-adc + + 1.0 * einsum("jkab,jkib->ia", hf.oovv, g2a.ooov) # not in cvs-adc + 2.0 * einsum("jcab,ibjc->ia", hf.ovvv, g2a.ovov) - 1.0 * einsum("jabc,ijbc->ia", hf.ovvv, g2a.oovv) + 2.0 * einsum("jika,jk->ia", hf.ooov, g1a.oo) + 2.0 * einsum("icab,bc->ia", hf.ovvv, g1a.vv) ) + + # IB: changed to AmplitudeVector here. + ret = AmplitudeVector(ov=ret_ov) + return ret @@ -120,7 +125,11 @@ def energy_weighted_density_matrix(hf, g1o, g2a): if hf.has_core_occupied_space: # CVS-ADC0, CVS-ADC1, CVS-ADC2 w = OneParticleOperator(hf) - w.cc = ( + w.cc = - 0.5 * ( + einsum("JKab,IKab->IJ", g2a.ccvv, hf.ccvv) + + einsum("kJab,kIab->IJ", g2a.ocvv, hf.ocvv) + ) + w.cc += ( - hf.fcc - einsum("IK,JK->IJ", g1o.cc, hf.fcc) - einsum("ab,IaJb->IJ", g1o.vv, hf.cvcv) @@ -133,15 +142,18 @@ def energy_weighted_density_matrix(hf, g1o, g2a): - einsum("Lk,kILJ->IJ", g1o.co, hf.occc) - einsum("Lk,kJLI->IJ", g1o.co, hf.occc) - einsum("JbKc,IbKc->IJ", g2a.cvcv, hf.cvcv) - - 0.5 * einsum("JKab,IKab->IJ", g2a.ccvv, hf.ccvv) - einsum("kJLa,kILa->IJ", g2a.occv, hf.occv) - - 0.5 * einsum("kJab,kIab->IJ", g2a.ocvv, hf.ocvv) - einsum("kLJa,kLIa->IJ", g2a.occv, hf.occv) - - einsum("kJmL,kImL->IJ", g2a.ococ, hf.ococ) # cvs-adc2x + - einsum("kJmL,kImL->IJ", g2a.ococ, hf.ococ) # cvs-adc2x ) - w.oo = ( + w.oo = - 0.5 * ( + einsum("jKab,iKab->ij", g2a.ocvv, hf.ocvv) + + einsum("jkab,ikab->ij", g2a.oovv, hf.oovv) + + einsum("jabc,iabc->ij", g2a.ovvv, hf.ovvv) + ) + w.oo += ( - hf.foo - - einsum("ij,ii->ij", g1o.oo, hf.foo) # TODO: double check this + - einsum("ij,ii->ij", g1o.oo, hf.foo) # - einsum("KL,iKjL->ij", g1o.cc, hf.ococ) - einsum("ab,iajb->ij", g1o.vv, hf.ovov) - einsum("kl,ikjl->ij", g1o.oo, hf.oooo) @@ -152,25 +164,28 @@ def energy_weighted_density_matrix(hf, g1o, g2a): + einsum("Lk,kijL->ij", g1o.co, hf.oooc) + einsum("Lk,kjiL->ij", g1o.co, hf.oooc) - einsum("jKLa,iKLa->ij", g2a.occv, hf.occv) - - 0.5 * einsum("jKab,iKab->ij", g2a.ocvv, hf.ocvv) - - 0.5 * einsum("jkab,ikab->ij", g2a.oovv, hf.oovv) - - 0.5 * einsum("jabc,iabc->ij", g2a.ovvv, hf.ovvv) - - einsum("jKlM,iKlM->ij", g2a.ococ, hf.ococ) # cvs-adc2x + - einsum("jKlM,iKlM->ij", g2a.ococ, hf.ococ) # cvs-adc2x - einsum("jakb,iakb->ij", g2a.ovov, hf.ovov) # cvs-adc2x ) - w.vv = ( + w.vv = - 0.5 * ( + einsum("ibcd,iacd->ab", g2a.ovvv, hf.ovvv) + + einsum("IJbc,IJac->ab", g2a.ccvv, hf.ccvv) + + einsum("ijbc,ijac->ab", g2a.oovv, hf.oovv) + + einsum("bcde,acde->ab", g2a.vvvv, hf.vvvv) # cvs-adc2x + ) + w.vv += ( - einsum("ac,cb->ab", g1o.vv, hf.fvv) - einsum('JbKc,JaKc->ab', g2a.cvcv, hf.cvcv) - einsum("jKIb,jKIa->ab", g2a.occv, hf.occv) - - 0.5 * einsum("ibcd,iacd->ab", g2a.ovvv, hf.ovvv) - einsum("idbc,idac->ab", g2a.ovvv, hf.ovvv) - - 0.5 * einsum("IJbc,IJac->ab", g2a.ccvv, hf.ccvv) - einsum("iJbc,iJac->ab", g2a.ocvv, hf.ocvv) - - 0.5 * einsum("ijbc,ijac->ab", g2a.oovv, hf.oovv) - - einsum("ibjc,iajc->ab", g2a.ovov, hf.ovov) # cvs-adc2x - - 0.5 * einsum("bcde,acde->ab", g2a.vvvv, hf.vvvv) # cvs-adc2x + - einsum("ibjc,iajc->ab", g2a.ovov, hf.ovov) # cvs-adc2x ) - w.co = ( + w.co = 0.5 * ( + - einsum("JKab,iKab->Ji", g2a.ccvv, hf.ocvv) + + einsum("kJab,ikab->Ji", g2a.ocvv, hf.oovv) + ) + w.co += ( einsum("KL,iKLJ->Ji", g1o.cc, hf.occc) - einsum("ab,iaJb->Ji", g1o.vv, hf.ovcv) - einsum("kl,kilJ->Ji", g1o.oo, hf.oooc) @@ -182,37 +197,38 @@ def energy_weighted_density_matrix(hf, g1o, g2a): + einsum("Lk,iLkJ->Ji", g1o.co, hf.ococ) - einsum("Ik,jk->Ij", g1o.co, hf.foo) - einsum("JbKc,ibKc->Ji", g2a.cvcv, hf.ovcv) - - 0.5 * einsum("JKab,iKab->Ji", g2a.ccvv, hf.ocvv) + einsum("kJLa,ikLa->Ji", g2a.occv, hf.oocv) - + 0.5 * einsum("kJab,ikab->Ji", g2a.ocvv, hf.oovv) - einsum("kLJa,kLia->Ji", g2a.occv, hf.ocov) - + einsum("kJmL,ikmL->Ji", g2a.ococ, hf.oooc) # cvs-adc2x + + einsum("kJmL,ikmL->Ji", g2a.ococ, hf.oooc) # cvs-adc2x + ) + w.ov = 0.5 * ( + einsum("jabc,ijbc->ia", g2a.ovvv, hf.oovv) + - einsum("JKab,JKib->ia", g2a.ccvv, hf.ccov) + - einsum("jkab,jkib->ia", g2a.oovv, hf.ooov) + - einsum("abcd,ibcd->ia", g2a.vvvv, hf.ovvv) # cvs-adc2x ) - w.ov = ( + w.ov += ( - einsum("ij,ja->ia", hf.foo, g1o.ov) + einsum("JaKc,iJKc->ia", g2a.cvcv, hf.occv) + einsum("kLJa,iJkL->ia", g2a.occv, hf.ococ) - + 0.5 * einsum("jabc,ijbc->ia", g2a.ovvv, hf.oovv) - - 0.5 * einsum("JKab,JKib->ia", g2a.ccvv, hf.ccov) - einsum("jKab,jKib->ia", g2a.ocvv, hf.ocov) - - 0.5 * einsum("jkab,jkib->ia", g2a.oovv, hf.ooov) - einsum("jcab,ibjc->ia", g2a.ovvv, hf.ovov) - - 0.5 * einsum("abcd,ibcd->ia", g2a.vvvv, hf.ovvv) # cvs-adc2x + einsum("jakb,ijkb->ia", g2a.ovov, hf.ooov) # cvs-adc2x ) - w.cv = ( + w.cv = - 0.5 * ( + einsum("jabc,jIbc->Ia", g2a.ovvv, hf.ocvv) + + einsum("JKab,JKIb->Ia", g2a.ccvv, hf.cccv) + + einsum("jkab,jkIb->Ia", g2a.oovv, hf.oocv) + + einsum("abcd,Ibcd->Ia", g2a.vvvv, hf.cvvv) # cvs-adc2x + ) + w.cv += ( - einsum("IJ,Ja->Ia", hf.fcc, g1o.cv) + einsum("JaKc,IJKc->Ia", g2a.cvcv, hf.cccv) + einsum("lKJa,lKIJ->Ia", g2a.occv, hf.occc) - - 0.5 * einsum("jabc,jIbc->Ia", g2a.ovvv, hf.ocvv) - - 0.5 * einsum("JKab,JKIb->Ia", g2a.ccvv, hf.cccv) - einsum("kJab,kJIb->Ia", g2a.ocvv, hf.occv) - - 0.5 * einsum("jkab,jkIb->Ia", g2a.oovv, hf.oocv) - einsum("jcab,jcIb->Ia", g2a.ovvv, hf.ovcv) - - 0.5 * einsum("abcd,Ibcd->Ia", g2a.vvvv, hf.cvvv) # cvs-adc2x - einsum("jakb,jIkb->Ia", g2a.ovov, hf.ocov) # cvs-adc2x ) - #print("\nOMEGA cv:\n", w.cv.evaluate()) else: gi_oo = -0.5 * ( # + 1.0 * einsum("jklm,iklm->ij", hf.oooo, g2a.oooo) @@ -256,9 +272,6 @@ def energy_weighted_density_matrix(hf, g1o, g2a): class OrbitalResponseMatrix: def __init__(self, hf): - #if hf.has_core_occupied_space: - # raise NotImplementedError("OrbitalResponseMatrix not implemented " - # "for CVS reference state.") self.hf = hf @property @@ -270,36 +283,33 @@ def shape(self): size = no1 * nv1 return (size, size) - def __matmul__(self, l_ov): + def __matmul__(self, l): + + # Terms common to adc and cvs-adc + ret_ov = ( + + einsum("ab,ib->ia", self.hf.fvv, l.ov) + - einsum("ij,ja->ia", self.hf.foo, l.ov) + + einsum("ijab,jb->ia", self.hf.oovv, l.ov) + - einsum("ibja,jb->ia", self.hf.ovov, l.ov) + ) if self.hf.has_core_occupied_space: - # This is the OV block (hijacked from AmplitudeVector) - # TODO: find a different solution (new class?) - ret_ov = ( - + einsum("ab,ib->ia", self.hf.fvv, l_ov['pphh']) - - einsum("ij,ja->ia", self.hf.foo, l_ov['pphh']) - + einsum("ijab,jb->ia", self.hf.oovv, l_ov['pphh']) - - einsum("ibja,jb->ia", self.hf.ovov, l_ov['pphh']) - + einsum("iJab,Jb->ia", self.hf.ocvv, l_ov['ph']) - - einsum("ibJa,Jb->ia", self.hf.ovcv, l_ov['ph']) + # Additional terms for cvs-adc + ret_ov += ( + + einsum("iJab,Jb->ia", self.hf.ocvv, l.cv) + - einsum("ibJa,Jb->ia", self.hf.ovcv, l.cv) ) - # This is the CV block (hijacked from AmplitudeVector) - # TODO: find a different solution (new class?) ret_cv = ( - + einsum("ab,Ib->Ia", self.hf.fvv, l_ov['ph']) - - einsum("IJ,Ja->Ia", self.hf.fcc, l_ov['ph']) - + einsum("IJab,Jb->Ia", self.hf.ccvv, l_ov['ph']) - - einsum("IbJa,Jb->Ia", self.hf.cvcv, l_ov['ph']) - + einsum("Ijab,jb->Ia", self.hf.covv, l_ov['pphh']) - - einsum("Ibja,jb->Ia", self.hf.cvov, l_ov['pphh']) + + einsum("ab,Ib->Ia", self.hf.fvv, l.cv) + - einsum("IJ,Ja->Ia", self.hf.fcc, l.cv) + + einsum("IJab,Jb->Ia", self.hf.ccvv, l.cv) + - einsum("IbJa,Jb->Ia", self.hf.cvcv, l.cv) + + einsum("Ijab,jb->Ia", self.hf.covv, l.ov) + - einsum("Ibja,jb->Ia", self.hf.cvov, l.ov) ) - ret = AmplitudeVector(ph=ret_cv, pphh=ret_ov) + ret = AmplitudeVector(cv=ret_cv, ov=ret_ov) else: - ret = ( - + einsum("ab,ib->ia", self.hf.fvv, l_ov) - - einsum("ij,ja->ia", self.hf.foo, l_ov) - + einsum("ijab,jb->ia", self.hf.oovv, l_ov) - - einsum("ibja,jb->ia", self.hf.ovov, l_ov) - ) + # IB: changed to AmplitudeVector here. + ret = AmplitudeVector(ov=ret_ov) # TODO: generalize once other solvent methods are available if self.hf.environment == "pe": # PE contribution to the orbital Hessian @@ -313,20 +323,19 @@ def __matmul__(self, l_ov): class OrbitalResponsePinv: def __init__(self, hf): self.hf = hf + # Terms common to adc and cvs-adc + fo = hf.fock(b.oo).diagonal() + fv = hf.fock(b.vv).diagonal() + fov = direct_sum("-i+a->ia", fo, fv).evaluate() + if hf.has_core_occupied_space: + # Additional terms for cvs-adc fc = hf.fock(b.cc).diagonal() - fo = hf.fock(b.oo).diagonal() - fv = hf.fock(b.vv).diagonal() - fov = direct_sum("-i+a->ia", fo, fv).evaluate() fcv = direct_sum("-I+a->Ia", fc, fv).evaluate() - - # Highjacking AmplitudeVector to store both cv and ov blocks. - # 'ph' stores the CV block, 'pphh' stores the OV block. - self.df = AmplitudeVector(ph=fcv, pphh=fov) + self.df = AmplitudeVector(cv=fcv, ov=fov) else: - fo = hf.fock(b.oo).diagonal() - fv = hf.fock(b.vv).diagonal() - self.df = direct_sum("-i+a->ia", fo, fv).evaluate() + # IB: changed to AmplitudeVector here + self.df = AmplitudeVector(ov=fov) @property def shape(self): @@ -350,12 +359,7 @@ def orbital_response(hf, rhs): A = OrbitalResponseMatrix(hf) Pinv = OrbitalResponsePinv(hf) x0 = (Pinv @ rhs).evaluate() - l_ov = conjugate_gradient(A, rhs=rhs, x0=x0, Pinv=Pinv, - explicit_symmetrisation=None, - callback=default_print) - #print(rhs.space) - #print(rhs.subspaces) - ##print(dir(l_ov.solution)) - #print("Solution CV:\n", 0.5*l_ov.solution['ph']) - #print("\nSolution OV:\n",0.5*l_ov.solution['pphh']) - return l_ov.solution + l = conjugate_gradient(A, rhs=rhs, x0=x0, Pinv=Pinv, + explicit_symmetrisation=None, + callback=default_print) + return l.solution From 678a6d46de769968a38e3110913f7936a0c00d94 Mon Sep 17 00:00:00 2001 From: Maximilian Scheurer Date: Tue, 14 Dec 2021 19:22:28 +0100 Subject: [PATCH 06/18] tweak test infrastructure --- adcc/gradients/TwoParticleDensityMatrix.py | 2 - adcc/gradients/amplitude_response.py | 2 +- .../gradients/test_functionality_gradients.py | 19 +++-- adcc/testdata/dump_fdiff_gradient.py | 82 ++++++++++++------- 4 files changed, 66 insertions(+), 39 deletions(-) diff --git a/adcc/gradients/TwoParticleDensityMatrix.py b/adcc/gradients/TwoParticleDensityMatrix.py index 7567ebe25..fecf218df 100644 --- a/adcc/gradients/TwoParticleDensityMatrix.py +++ b/adcc/gradients/TwoParticleDensityMatrix.py @@ -39,8 +39,6 @@ def __init__(self, spaces): self.mospaces = spaces.mospaces else: self.mospaces = spaces -# if self.mospaces.has_core_occupied_space: -# raise NotImplementedError("TPDM not implemented for CVS.") # Set reference_state if possible if isinstance(spaces, libadcc.ReferenceState): self.reference_state = spaces diff --git a/adcc/gradients/amplitude_response.py b/adcc/gradients/amplitude_response.py index c2be29772..1b28fd80b 100644 --- a/adcc/gradients/amplitude_response.py +++ b/adcc/gradients/amplitude_response.py @@ -109,7 +109,7 @@ def ampl_relaxed_dms_cvs_adc1(exci): g1a.cc = - 1.0 * einsum("Ia,Ja->IJ", u.ph, u.ph) g1a.vv = + 1.0 * einsum("Ia,Ib->ab", u.ph, u.ph) - # Pre-requisites for the OC block of the + # Prerequisites for the OC block of the # orbital response Lagrange multipliers: fc = hf.fock(b.cc).diagonal() fo = hf.fock(b.oo).diagonal() diff --git a/adcc/gradients/test_functionality_gradients.py b/adcc/gradients/test_functionality_gradients.py index 80abe4405..24b44f63c 100644 --- a/adcc/gradients/test_functionality_gradients.py +++ b/adcc/gradients/test_functionality_gradients.py @@ -22,6 +22,7 @@ ## --------------------------------------------------------------------- import unittest import itertools + import adcc import adcc.backends @@ -36,9 +37,11 @@ backends = [b for b in adcc.backends.available() if b not in ["molsturm", "veloxchem"]] -molecules = ["h2o"] -basissets = ["sto3g", "ccpvdz"] -methods = ["mp2", "adc1", "adc2"] + +molecules = gradient_data["molecules"] +basissets = gradient_data["basissets"] +methods = gradient_data["methods"] + combinations = list(itertools.product(molecules, basissets, methods, backends)) @@ -50,19 +53,19 @@ def template_nuclear_gradient(self, molecule, basis, method, backend): energy_ref = grad_ref["energy"] grad_fdiff = grad_ref["gradient"] + + kwargs = grad_ref["config"] scfres = cached_backend_hf(backend, molecule, basis, conv_tol=1e-13) if "adc" in method: # TODO: convergence needs to be very very tight... # so we want to make sure all vectors are tightly converged - n_limit = 5 - state = adcc.run_adc(scfres, method=method, - n_singlets=10, conv_tol=1e-11) - for ee in state.excitations[:n_limit]: + state = adcc.run_adc(scfres, method=method, **kwargs) + for i, ee in enumerate(state.excitations): grad = adcc.nuclear_gradient(ee) assert_allclose(energy_ref[ee.index], ee.total_energy, atol=1e-10) assert_allclose( - grad_fdiff[ee.index], grad["Total"], atol=1e-7 + grad_fdiff[ee.index], grad["Total"], atol=1e-7, err_msg=f'State {i} wrong.' ) else: # MP2 gradients diff --git a/adcc/testdata/dump_fdiff_gradient.py b/adcc/testdata/dump_fdiff_gradient.py index 16da630eb..16dd0deb6 100644 --- a/adcc/testdata/dump_fdiff_gradient.py +++ b/adcc/testdata/dump_fdiff_gradient.py @@ -20,6 +20,7 @@ ## along with adcc. If not, see . ## ## --------------------------------------------------------------------- +from collections import namedtuple import itertools import adcc import numpy as np @@ -31,8 +32,10 @@ from static_data import xyz -prefactors_5p = np.array([1.0, -8.0, 8.0, -1.0]) / 12.0 -multipliers_5p = [-2, -1, 1, 2] +# prefactors_5p = np.array([1.0, -8.0, 8.0, -1.0]) / 12.0 +# multipliers_5p = [-2, -1, 1, 2] +prefactors_9p = [1./280., -4./105., 1./5., -4./5., 4./5., -1./5., 4./105., -1./280.] +multipliers_9p = [-4., -3., -2., -1., 1., 2., 3., 4.] coords_label = ["x", "y", "z"] @@ -47,30 +50,30 @@ def _molstring(elems, coords): def adc_energy(scfres, method, **kwargs): state = adcc.run_adc(method=method, data_or_matrix=scfres, - output=None, **kwargs) + output=None, + **kwargs) return state.total_energy def mp_energy(scfres, method, **kwargs): - level = { - "mp2": 2, - "mp3": 3, - } + level = method[-1] refstate = adcc.ReferenceState(scfres) - return adcc.LazyMp(refstate).energy(level[method]) + return adcc.LazyMp(refstate).energy(level) -def fdiff_gradient(molstring, method, basis, step=1e-4, **kwargs): - m = gto.M(atom=molstring, unit='Bohr', basis=basis) +def fdiff_gradient(molecule, method, basis, step=1e-4, **kwargs): + molstring = xyz[molecule.name] + m = gto.M(atom=molstring, unit='Bohr', basis=basis, + spin=molecule.multiplicity - 1, charge=molecule.charge) coords = m.atom_coords().copy() elements = m.elements.copy() - n_grads = kwargs.get("n_singlets", 1) - conv_tol = kwargs.get("conv_tol", 1e-10) / 10 + conv_tol = kwargs.get("conv_tol", 1e-10) / 100 # run unperturbed system scfres = adcc.backends.run_hf( - 'pyscf', molstring, basis, conv_tol=conv_tol, conv_tol_grad=conv_tol + 'pyscf', molstring, basis, conv_tol=conv_tol, conv_tol_grad=conv_tol, + charge=molecule.charge, multiplicity=molecule.multiplicity ) if "adc" in method: en = adc_energy(scfres, method, **kwargs) @@ -78,15 +81,16 @@ def fdiff_gradient(molstring, method, basis, step=1e-4, **kwargs): en = mp_energy(scfres, method, **kwargs) natoms = len(elements) - grad = np.zeros((n_grads, natoms, 3)) + grad = np.zeros((len(en), natoms, 3)) at_c = list(itertools.product(range(natoms), range(3))) for i, c in tqdm(at_c): - for f, p in zip(multipliers_5p, prefactors_5p): + for f, p in zip(multipliers_9p, prefactors_9p): coords_p = coords.copy() coords_p[i, c] += f * step geom_p = _molstring(elements, coords_p) scfres = adcc.backends.run_hf( - 'pyscf', geom_p, basis, conv_tol=conv_tol, conv_tol_grad=conv_tol + 'pyscf', geom_p, basis, conv_tol=conv_tol, conv_tol_grad=conv_tol, + charge=molecule.charge, multiplicity=molecule.multiplicity ) if "adc" in method: en_pert = adc_energy(scfres, method, **kwargs) @@ -97,38 +101,60 @@ def fdiff_gradient(molstring, method, basis, step=1e-4, **kwargs): def main(): - config_excited = { - "n_singlets": 5, - } basissets = [ "sto3g", "ccpvdz", ] methods = [ - "mp2", + # "mp2", + # "adc0", "adc1", - "adc2", + # "adc2", + # "cvs-adc0", + # "cvs-adc1", + # "cvs-adc2", + # "cvs-adc2x", + ] + Molecule = namedtuple("Molecule", ["name", "charge", "multiplicity"]) + molecules = [ + # Molecule("h2o", 0, 1), + # "h2s", + Molecule("cn", 0, 2), + # "ch2nh2", + # "hf", + # "formaldehyde" ] - molecules = ["h2o", "hf", "formaldehyde"] - ret = {} + ret = { + "basissets": basissets, + "methods": methods, + "molecules": molecules, + } + config_excited = {"n_states": 3} for molecule in molecules: - ret[molecule] = {} + ret[molecule.name] = {} for basis in basissets: - ret[molecule][basis] = {} + ret[molecule.name][basis] = {} for method in methods: kwargs = { - "conv_tol": 1e-8, + "conv_tol": 1e-10, } if "adc" in method: kwargs.update(config_excited) - basename = f"{molecule}_{basis}_{method}" + basename = f"{molecule.name}_{basis}_{method}" print(f"Evaluating finite difference gradient for {basename}.") - en, grad = fdiff_gradient(xyz[molecule], method, basis, **kwargs) + + # HACK + core_orbitals = None + if "cvs" in method: + core_orbitals = 1 + kwargs["core_orbitals"] = core_orbitals + en, grad = fdiff_gradient(molecule, method, basis, **kwargs) if isinstance(en, np.ndarray): en = en.tolist() cont = { "energy": en, "gradient": np.squeeze(grad).tolist(), + "config": kwargs, } ret[molecule][basis][method] = cont with open("grad_dump.yml", "w") as yamlout: From 8fb606c957db18b7330def3abc251ec502e817a8 Mon Sep 17 00:00:00 2001 From: Maximilian Scheurer Date: Tue, 14 Dec 2021 22:08:07 +0100 Subject: [PATCH 07/18] try to finally make damn tests work :( --- adcc/ExcitedStates.py | 2 + .../gradients/test_functionality_gradients.py | 14 +- adcc/testdata/dump_fdiff_gradient.py | 60 +- adcc/testdata/grad_dump.yml | 1553 ++++++++++------- adcc/testdata/static_data.py | 24 + adcc/workflow.py | 11 +- 6 files changed, 956 insertions(+), 708 deletions(-) diff --git a/adcc/ExcitedStates.py b/adcc/ExcitedStates.py index 160addf99..c4914a91a 100644 --- a/adcc/ExcitedStates.py +++ b/adcc/ExcitedStates.py @@ -221,6 +221,8 @@ def __add__(self, other): @mark_excitation_property() def total_energy(self): # TODO: excitation_energy_uncorrected for PE-ADC with postSCF + if self.method.level == 0: + return self.excitation_energy + self.reference_state.energy_scf return self.excitation_energy + self.ground_state.energy(self.method.level) @cached_property diff --git a/adcc/gradients/test_functionality_gradients.py b/adcc/gradients/test_functionality_gradients.py index 24b44f63c..28763e540 100644 --- a/adcc/gradients/test_functionality_gradients.py +++ b/adcc/gradients/test_functionality_gradients.py @@ -22,6 +22,7 @@ ## --------------------------------------------------------------------- import unittest import itertools +import numpy as np import adcc import adcc.backends @@ -52,20 +53,23 @@ def template_nuclear_gradient(self, molecule, basis, method, backend): grad_ref = gradient_data[molecule][basis][method] energy_ref = grad_ref["energy"] - grad_fdiff = grad_ref["gradient"] - + grad_fdiff = grad_ref["gradient"] kwargs = grad_ref["config"] + conv_tol = kwargs["conv_tol"] scfres = cached_backend_hf(backend, molecule, basis, conv_tol=1e-13) if "adc" in method: # TODO: convergence needs to be very very tight... # so we want to make sure all vectors are tightly converged + n_limit = 2 # kwargs["n_singlets"] + kwargs["n_singlets"] = kwargs["n_singlets"] + 2 state = adcc.run_adc(scfres, method=method, **kwargs) - for i, ee in enumerate(state.excitations): + for ee in state.excitations[:n_limit]: grad = adcc.nuclear_gradient(ee) - assert_allclose(energy_ref[ee.index], ee.total_energy, atol=1e-10) + assert_allclose(energy_ref[ee.index], ee.total_energy, atol=conv_tol) assert_allclose( - grad_fdiff[ee.index], grad["Total"], atol=1e-7, err_msg=f'State {i} wrong.' + grad_fdiff[ee.index], grad["Total"], atol=1e-7, + err_msg=f'Gradient for state {ee.index} wrong.' ) else: # MP2 gradients diff --git a/adcc/testdata/dump_fdiff_gradient.py b/adcc/testdata/dump_fdiff_gradient.py index 16dd0deb6..c4f996c63 100644 --- a/adcc/testdata/dump_fdiff_gradient.py +++ b/adcc/testdata/dump_fdiff_gradient.py @@ -27,9 +27,12 @@ import yaml from tqdm import tqdm -from pyscf import gto +from pyscf import gto, lib -from static_data import xyz +from static_data import molecules + +adcc.set_n_threads(8) +lib.num_threads(8) # prefactors_5p = np.array([1.0, -8.0, 8.0, -1.0]) / 12.0 @@ -56,14 +59,13 @@ def adc_energy(scfres, method, **kwargs): def mp_energy(scfres, method, **kwargs): - level = method[-1] + level = int(method[-1]) refstate = adcc.ReferenceState(scfres) return adcc.LazyMp(refstate).energy(level) def fdiff_gradient(molecule, method, basis, step=1e-4, **kwargs): - molstring = xyz[molecule.name] - m = gto.M(atom=molstring, unit='Bohr', basis=basis, + m = gto.M(atom=molecule.xyz, unit='Bohr', basis=basis, spin=molecule.multiplicity - 1, charge=molecule.charge) coords = m.atom_coords().copy() elements = m.elements.copy() @@ -72,16 +74,18 @@ def fdiff_gradient(molecule, method, basis, step=1e-4, **kwargs): # run unperturbed system scfres = adcc.backends.run_hf( - 'pyscf', molstring, basis, conv_tol=conv_tol, conv_tol_grad=conv_tol, + 'pyscf', molecule.xyz, basis, conv_tol=conv_tol, conv_tol_grad=conv_tol, charge=molecule.charge, multiplicity=molecule.multiplicity ) if "adc" in method: en = adc_energy(scfres, method, **kwargs) + ngrad = len(en) else: en = mp_energy(scfres, method, **kwargs) + ngrad = 1 natoms = len(elements) - grad = np.zeros((len(en), natoms, 3)) + grad = np.zeros((ngrad, natoms, 3)) at_c = list(itertools.product(range(natoms), range(3))) for i, c in tqdm(at_c): for f, p in zip(multipliers_9p, prefactors_9p): @@ -106,47 +110,43 @@ def main(): "ccpvdz", ] methods = [ - # "mp2", - # "adc0", + "mp2", + "adc0", "adc1", - # "adc2", - # "cvs-adc0", - # "cvs-adc1", - # "cvs-adc2", + "adc2", + "cvs-adc0", + "cvs-adc1", + "cvs-adc2", # "cvs-adc2x", ] - Molecule = namedtuple("Molecule", ["name", "charge", "multiplicity"]) - molecules = [ - # Molecule("h2o", 0, 1), - # "h2s", - Molecule("cn", 0, 2), - # "ch2nh2", - # "hf", - # "formaldehyde" + molnames = [ + "h2o", + "h2s", ] + mols = [m for m in molecules if m.name in molnames] ret = { "basissets": basissets, "methods": methods, - "molecules": molecules, + "molecules": molnames, } - config_excited = {"n_states": 3} - for molecule in molecules: - ret[molecule.name] = {} + config_excited = {"n_singlets": 3} + for molecule in mols: + molname = molecule.name + ret[molname] = {} for basis in basissets: - ret[molecule.name][basis] = {} + ret[molname][basis] = {} for method in methods: kwargs = { "conv_tol": 1e-10, } if "adc" in method: kwargs.update(config_excited) - basename = f"{molecule.name}_{basis}_{method}" + basename = f"{molname}_{basis}_{method}" print(f"Evaluating finite difference gradient for {basename}.") - # HACK core_orbitals = None if "cvs" in method: - core_orbitals = 1 + core_orbitals = molecule.core_orbitals kwargs["core_orbitals"] = core_orbitals en, grad = fdiff_gradient(molecule, method, basis, **kwargs) if isinstance(en, np.ndarray): @@ -156,7 +156,7 @@ def main(): "gradient": np.squeeze(grad).tolist(), "config": kwargs, } - ret[molecule][basis][method] = cont + ret[molname][basis][method] = cont with open("grad_dump.yml", "w") as yamlout: yaml.safe_dump(ret, yamlout) diff --git a/adcc/testdata/grad_dump.yml b/adcc/testdata/grad_dump.yml index f24064ae8..f7f22b0a2 100644 --- a/adcc/testdata/grad_dump.yml +++ b/adcc/testdata/grad_dump.yml @@ -1,717 +1,928 @@ -formaldehyde: +basissets: +- sto3g +- ccpvdz +h2o: ccpvdz: + adc0: + config: + conv_tol: 1.0e-10 + core_orbitals: null + n_singlets: 3 + energy: + - -75.34687593732811 + - -75.28099897302941 + - -75.27790714502403 + gradient: + - - - 0.05781772689988429 + - -6.14363671047613e-10 + - 0.0412469571820111 + - - -0.0010630944025251665 + - 4.965841071680188e-10 + - -0.060199276416369685 + - - -0.056754632418687834 + - -5.188667273614556e-10 + - 0.018952317754155956 + - - - 0.01311645154009966 + - -6.630216375924647e-10 + - 0.009581871548107301 + - - 0.05172148960400591 + - 2.2282620193436742e-10 + - -0.08735981985000763 + - - -0.06483794088308059 + - -1.6189005691558123e-10 + - 0.07777794693947726 + - - - 0.03587021910561816 + - -6.070877134334296e-10 + - 0.025914352325344225 + - - 0.007818774688075791 + - 3.424247552175075e-10 + - -0.04966127915349716 + - - -0.043688994054264185 + - -3.1468516681343317e-10 + - 0.023746925161503896 adc1: + config: + conv_tol: 1.0e-10 + core_orbitals: null + n_singlets: 3 energy: - - -113.70558203635709 - - -113.50558431199366 - - -113.49341052539295 - - -113.4921906128972 - - -113.43838517589901 + - -75.68543998437548 + - -75.61931016176952 + - -75.59868950258502 gradient: - - - - 0.004440058954060078 - - -0.08440320886438712 - - 0.061171111461590044 - - - -0.0046579049521824345 - - 0.08556581632001325 - - -0.06425038322049659 - - - -0.00018499072757549584 - - -0.003402824906515889 - - -0.002396157040493563 - - - 0.00040283604175783694 - - 0.002240217392682098 - - 0.0054754264710936695 - - - - 0.014108372910413891 - - -0.26049620006233454 - - 0.19367707810306456 - - - -0.012959809566382319 - - 0.2366245447192341 - - -0.17844389395031612 - - - -0.0014201861922629178 - - 0.0031937859166646376 - - -0.018929093901533633 - - - 0.0002716220624279231 - - 0.020677869601058774 - - 0.003695907857036218 - - - - 0.01106323792191688 - - -0.20612725264800247 - - 0.1539881363278255 - - - -0.012415087621775456 - - 0.22842276237497572 - - -0.17184760025702417 - - - 4.062271909788251e-05 - - -0.018368309567449614 - - 0.00045038078678771853 - - - 0.0013112259184708819 - - -0.003927204335923307 - - 0.017409080843208358 - - - - -0.007417373723001219 - - 0.13012286479352042 - - -0.10184336615202483 - - - 0.004234577005263418 - - -0.07607176668534521 - - 0.05810191675845999 - - - -0.001716892686090432 - - -0.0594009895430645 - - -0.02237362222513184 - - - 0.004899689141893759 - - 0.005349896222469397 - - 0.06611506904300768 - - - - 0.003353650274220854 - - -0.0640643189108232 - - 0.04545981872070115 - - - -0.009704219817649573 - - 0.1790985528350575 - - -0.13405693606182467 - - - 0.001255770490388386 - - -0.07730495402938686 - - 0.018640203212271444 - - - 0.005094795822515152 - - -0.037729280651547015 - - 0.0699569108983269 + - - - 0.09274009261753235 + - -3.283275873400271e-10 + - 0.06558011171182443 + - - -0.002630220946684858 + - 5.6843418860808015e-11 + - -0.09467176255839149 + - - -0.09010987054125508 + - -4.3519321479834616e-10 + - 0.029091648981648177 + - - - 0.10931799067202519 + - -2.455635694786906e-10 + - 0.07809554580808253 + - - -0.0066607078210836335 + - -1.000444171950221e-11 + - -0.10735300815713344 + - - -0.102657282302971 + - -4.197318048682064e-10 + - 0.029257460409098712 + - - - 0.011670265368593391 + - -1.1732481652870774e-10 + - 0.008451193038126803 + - - 0.056844835021365725 + - -3.501554601825774e-11 + - -0.09296221982503994 + - - -0.0685150996455377 + - -1.268745108973235e-10 + - 0.08451102455637738 adc2: + config: + conv_tol: 1.0e-10 + core_orbitals: null + n_singlets: 3 energy: - - -114.04108709429852 - - -113.90116030505898 - - -113.84093754181639 - - -113.83275876700296 - - -113.78729359707486 + - -75.92967540826557 + - -75.8549979011574 + - -75.84309170418113 gradient: - - - - 0.00795411376748234 - - -0.14761182830261532 - - 0.10940460005076602 - - - -0.00861854647519067 - - 0.15725425074924715 - - -0.11885035762679763 - - - -0.00038722751196473837 - - -0.011867678796988912 - - -0.004902817323454656 - - - 0.0010516593320062384 - - 0.002225256263045594 - - 0.014348573065944947 - - - - 0.0022481144114863127 - - -0.04510061517066788 - - 0.03181697831314523 - - - -0.0042847725708270445 - - 0.07931772326992359 - - -0.059501681782421656 - - - -0.002496956309187226 - - -0.05234425392700359 - - -0.03315452564856969 - - - 0.004533617960987613 - - 0.01812714702100493 - - 0.060839227138785645 - - - - 0.012822667238651775 - - -0.23806948866695166 - - 0.17628057644469664 - - - -0.012922618945594877 - - 0.23657256651495118 - - -0.17811991584312636 - - - -0.0011136162065668032 - - -0.011240343621466309 - - -0.014638555672718212 - - - 0.001213567695231177 - - 0.01273726558429189 - - 0.016477893106639385 - - - - 0.006636413134401664 - - -0.12150684717926197 - - 0.09214128745952621 - - - -0.007791586889652535 - - 0.13977801451983396 - - -0.10773590055759996 - - - -0.0020652523526223376 - - -0.03424370722495951 - - -0.02755755910766311 - - - 0.0032204291637754068 - - 0.015972540670190938 - - 0.04315217011026107 - - - - 0.013698791502974927 - - -0.251412856116076 - - 0.1891322702722391 - - - -0.014349782286444679 - - 0.26074345722736325 - - -0.1981027886213269 - - - -0.0005066021985840052 - - -0.012612845370313153 - - -0.006683660205453634 - - - 0.0011628166976151988 - - 0.0032822444336488843 - - 0.01565417618257925 - mp2: - energy: -114.19562447602232 + - - - 0.11448501872291672 + - -1.1223164619877934e-09 + - 0.08113867664314967 + - - -0.008900642837943451 + - -6.416485121008009e-10 + - -0.1090567956907762 + - - -0.1055843749622909 + - -4.324647306930274e-10 + - 0.02791811763563601 + - - - 0.11318148765349179 + - -1.2523742043413222e-09 + - 0.08065584009500526 + - - -0.004472615006761771 + - -8.126335160341114e-10 + - -0.1143742844665212 + - - -0.10870887149940245 + - -4.1382008930668235e-10 + - 0.033718443040925195 + - - - 0.022055652611925325 + - -1.0786607163026929e-09 + - 0.015903128517948062 + - - 0.0509841249809142 + - -1.0136318451259285e-09 + - -0.09580103724010769 + - - -0.0730397764305053 + - -2.97859514830634e-10 + - 0.0798979071209942 + cvs-adc0: + config: + conv_tol: 1.0e-10 + core_orbitals: 1 + n_singlets: 3 + energy: + - -55.29234315857766 + - -55.22337436627359 + - -54.66716620632244 gradient: - - - 0.0006307709263637662 - - -0.019193962754798122 - - 0.009753386213560589 - - - -0.0019824629416689277 - - 0.039011894245049916 - - -0.027773341484135017 - - - -0.00016380085435230285 - - -0.018570978703792207 - - -0.0022151207958813757 - - - 0.001515490803285502 - - -0.0012469533103285357 - - 0.020235072865034454 - sto3g: - adc1: + - - - -0.013647945610046008 + - 2.078195393551141e-10 + - -0.009335994141338233 + - - 0.00570650654617566 + - -2.0395418687257916e-10 + - 0.006095206725376556 + - - 0.007941438532270695 + - -7.580638339277357e-10 + - 0.00324078498556446 + - - - -0.035595453415908196 + - 1.680291461525485e-10 + - -0.024668598871357972 + - - 0.0145883755540126 + - -2.6284396881237626e-10 + - 0.016633203791798223 + - - 0.021007076980367856 + - -7.032667781459168e-10 + - 0.008035392225338 + - - - 0.2956047727548139 + - 2.589786163298413e-10 + - 0.20220451008071905 + - - -0.11422410300747288 + - -3.9904080040287226e-10 + - -0.14526787512227202 + - - -0.18138067044901618 + - -7.826201908756047e-10 + - -0.056936637569378945 + cvs-adc1: + config: + conv_tol: 1.0e-10 + core_orbitals: 1 + n_singlets: 3 energy: - - -112.35215847657514 - - -112.19031679061341 - - -111.99509653412369 - - -111.88323868990281 - - -111.83938478075873 + - -55.76235801206998 + - -55.74423117768519 + - -55.238855751295425 gradient: - - - - 134.86789705506817 - - -0.034582075124490075 - - 0.020427761948667467 - - - 134.86667057021987 - - 0.052714954770635813 - - -0.03787164441018831 - - - 0.00025331013603135943 - - -0.01337217444961425 - - 0.0032829746487550437 - - - 0.0010667957249097526 - - -0.004760705487569794 - - 0.014160908656776883 - - - - 297.5504788887192 - - -0.034582075124490075 - - 0.02042776206508279 - - - 297.55109127634205 - - -1078.7981471754028 - - -0.03787164441018831 - - - 0.00025331013603135943 - - -0.01337217444961425 - - 0.0032829746487550437 - - - 0.0010667956084944308 - - -0.004760705487569794 - - 0.014160908656776883 - - - - 390.76501749145973 - - -0.034582075124490075 - - 0.020427761948667467 - - - 390.7668319265358 - - -2380.202243736072 - - -0.03787164441018831 - - - 0.00025331013603135943 - - -0.01337217444961425 - - 0.0032829746342031285 - - - 0.0010667956084944308 - - -0.004760705487569794 - - 0.014160908889607526 - - - - -786.4960951929388 - - -0.20038470218423754 - - 0.14833348176034633 - - - 292.43344181386055 - - -2046.8663960878475 - - -0.1458953901892528 - - - 0.00011068112507928163 - - 0.005674898813595064 - - 0.0014126732130534947 - - - -0.0002842362300725654 - - 0.0014252170512918383 - - -0.003850776600302197 - - - - -2099.6204833368683 - - -0.3076474006084027 - - 0.22782272301265039 - - - 280.7667978423997 - - -1037.8032912445778 - - -0.21819978098210413 - - - -0.0010586392600089312 - - 0.0016113087913254276 - - -0.01425015923450701 - - - 0.00035280417068861425 - - 0.016332442552084103 - - 0.004627213449566625 - adc2: + - - - 0.11375777869693593 + - -7.519247446907684e-10 + - 0.0750635761171452 + - - -0.006232491267837759 + - -7.480593922082335e-10 + - -0.10649733538957662 + - - -0.10752528617581447 + - -1.5120349416974932e-10 + - 0.031433756529395396 + - - - 0.13675109445330236 + - -6.536993168992922e-10 + - 0.10287793852785398 + - - -0.01013374691115132 + - -7.294147508218884e-10 + - -0.13692999088675606 + - - -0.126617346219291 + - -1.3164935808163136e-10 + - 0.034052049356205316 + - - - -0.03586818460098584 + - -6.737082003382966e-10 + - -0.025053269779391485 + - - 0.028073503252926457 + - -6.759819370927289e-10 + - -0.001954445516503256 + - - 0.007794682884650683 + - -2.2646418074145913e-10 + - 0.027007712356862612 + cvs-adc2: + config: + conv_tol: 1.0e-10 + core_orbitals: 1 + n_singlets: 3 energy: - - -112.29308371327538 - - -112.08687577389874 - - -111.95501913710211 - - -111.94227341486139 - - -111.90760777025828 + - -56.46332440074828 + - -56.39198974450136 + - -55.93190966430338 gradient: - - - - 0.013361435267142951 - - -0.24680471101601142 - - 0.1840638013818534 - - - -0.014295267901616171 - - 0.26064838070305996 - - -0.19721643527736887 - - - -0.0002812701713992283 - - -0.014264499128330499 - - -0.003434756348724477 - - - 0.0012151370465289801 - - 0.0004208378813927993 - - 0.016587377016549 - - - - 0.014545091849868186 - - -0.27108486875658855 - - 0.20018935947155114 - - - -0.015414420442539267 - - 0.2825872143293964 - - -0.2125983986479696 - - - -0.001122399786254391 - - -0.021760659903520718 - - -0.014614149200497195 - - - 0.0019917527242796496 - - 0.010258322567096911 - - 0.02702318166848272 - - - - 0.015574866061797366 - - -0.2841585915739415 - - 0.21446659980574623 - - - -0.020418328887899406 - - 0.3722419853147585 - - -0.2819262643606635 - - - -0.0001184115099022165 - - -0.06981211320089642 - - -0.00022668807650916278 - - - 0.004961850616382435 - - -0.018271274529979564 - - 0.06768634595209733 - - - - 0.008447872693068348 - - -0.15336673270212486 - - 0.11524418441695161 - - - -0.016566408987273462 - - 0.30309375702927355 - - -0.2287056674977066 - - - 0.0015225222159642726 - - -0.10094543961167801 - - 0.022824064188171178 - - - 0.006595998158445582 - - -0.04878158635983709 - - 0.0906374234764371 - - - - 0.00431169880903326 - - -0.08202417510619853 - - 0.0608073133189464 - - - -0.013763464201474562 - - 0.25251537734584417 - - -0.19093284106929787 - - - -0.013066680257907137 - - -0.26406628522090614 - - -0.17279423588479403 - - - 0.0225185089657316 - - 0.09357509708206635 - - 0.3029197411815403 + - - - 0.06425007316829578 + - -6.546088116010651e-10 + - 0.045520457711972995 + - - -0.0016864032024841435 + - 1.2848886399297044e-09 + - -0.0658671106048132 + - - -0.06256367150149345 + - -1.296257323701866e-09 + - 0.020346652008356614 + - - - 0.05899445178715723 + - 1.1323209037072957e-10 + - 0.042361969631201646 + - - 0.005970589055777964 + - -1.0822986951097846e-10 + - -0.07167667811427236 + - - -0.06496504189567531 + - -2.6852831069845706e-10 + - 0.029314707067442214 + - - - 0.26677660641166767 + - 2.5056579033844173e-10 + - 0.18210555948439833 + - - -0.08747911854334234 + - 2.1032064978498966e-10 + - -0.1527887531271972 + - - -0.1792974891011454 + - -1.1978045222349465e-09 + - -0.029316808301246056 mp2: - energy: -112.46495424382846 + config: + conv_tol: 1.0e-10 + core_orbitals: null + energy: -76.22940338787343 gradient: - - - 0.0037697695079259574 - - -0.07685817136371043 - - 0.05298948941344861 - - - -0.006090689610573463 - - 0.11399357361369766 - - -0.08449994814873207 - - - -2.156686969101429e-05 - - -0.030690345840412192 - - -4.766431811731309e-05 - - - 0.0023424898099619895 - - -0.0064450563077116385 - - 0.03155812271870673 -h2o: - ccpvdz: + - - 0.024395445243044378 + - -9.968061931431293e-10 + - 0.017738172225563176 + - - -0.010762448608602426 + - 4.019966581836343e-10 + - -0.011150372518386575 + - - -0.013632995088300959 + - -8.858478395268321e-10 + - -0.006587800284705736 + sto3g: + adc0: + config: + conv_tol: 1.0e-10 + core_orbitals: null + n_singlets: 3 + energy: + - -73.96883482604385 + - -73.91481187944893 + - -73.80575589478214 + gradient: + - - - 0.21500520481276908 + - -1.3642420526593924e-12 + - 0.15122539417507141 + - - 0.07489849383546243 + - -8.913048077374697e-11 + - -0.33320423490431494 + - - -0.28990369770372126 + - -1.3005774235352874e-10 + - 0.1819788405964573 + - - - 0.15869260451790979 + - -1.405169314239174e-10 + - 0.11135792756476803 + - - 0.12612935250444934 + - -1.0231815394945443e-10 + - -0.3458573076572975 + - - -0.28482195575770675 + - -2.6057023205794394e-10 + - 0.23449938025396477 + - - - 0.4883978155476143 + - -1.6962076188065112e-10 + - 0.3478099743133498 + - - -0.09521430238692119 + - -2.7830537874251604e-10 + - -0.3859635301491835 + - - -0.3931835123325982 + - -2.1782398107461631e-10 + - 0.03815355588812963 adc1: + config: + conv_tol: 1.0e-10 + core_orbitals: null + n_singlets: 3 energy: - - -75.68543998424987 - - -75.61931016166072 - - -75.59868950195046 - - -75.53275298660013 - - -75.45558187453754 + - -74.47588319597364 + - -74.38511885048031 + - -74.35718229209286 gradient: - - - - 0.0927401026856387 - - -7.275957614183426e-12 - - 0.06558009374566609 - - - -0.002630199545819778 - - 7.275957614183426e-12 - - -0.09467175448662601 - - - -0.090109874116024 - - -7.275957614183426e-12 - - 0.029091669573972467 - - - - 0.10931799972604495 - - -7.275957614183426e-12 - - 0.07809552933758823 - - - -0.006660687533440068 - - -7.275957614183426e-12 - - -0.10735300042870222 - - - -0.10265728522063 - - -2.1827872842550278e-11 - - 0.029257479851366952 - - - - 0.011670212486933451 - - 1.4551915228366852e-11 - - 0.0084512654793798 - - - 0.0568447552213911 - - -7.275957614183426e-12 - - -0.09296223078126786 - - - -0.06851510248088744 - - 7.275957614183426e-12 - - 0.08451095721829915 - - - - 0.02628810688474914 - - 2.1827872842550278e-11 - - 0.0192561547155492 - - - 0.05759759972715983 - - -1.4551915228366852e-11 - - -0.11000343628256815 - - - -0.08388586723594926 - - 1.4551915228366852e-11 - - 0.09074727105326019 - - - - 0.28210171702085063 - - 0.0 - - 0.19977481755631743 - - - -0.0784058679928421 - - 2.1827872842550278e-11 - - -0.1887100828025723 - - - -0.20369583381398115 - - 1.4551915228366852e-11 - - -0.011064729405916296 + - - - 0.25195657597942045 + - -4.092726157978177e-11 + - 0.17643765260208966 + - - 0.04383796624188108 + - 3.751665644813329e-10 + - -0.32756816145820267 + - - -0.29579454043232545 + - -1.0732037480920553e-10 + - 0.1511305100257232 + - - - 0.4420401994848362 + - 6.048139766789973e-11 + - 0.3159731246355477 + - - -0.08205663838316468 + - 6.029949872754514e-10 + - -0.3563313624399598 + - - -0.35998355975470986 + - -2.432898327242583e-10 + - 0.04035823856474963 + - - - 0.10246272940094059 + - -1.5916157281026244e-11 + - 0.07140888797584921 + - - 0.1196453034563092 + - 4.761204763781279e-10 + - -0.27684558784130786 + - - -0.22210803133657464 + - -1.8189894035458565e-12 + - 0.2054367008108784 adc2: + config: + conv_tol: 1.0e-10 + core_orbitals: null + n_singlets: 3 energy: - - -75.9296754081454 - - -75.85499790104548 - - -75.84309170282057 - - -75.76675240722146 - - -75.66953798873493 + - -74.52306494758527 + - -74.42102314285333 + - -74.39990473420056 gradient: - - - - 0.11448502987332176 - - -7.275957614183426e-12 - - 0.08113865628547501 - - - -0.008900619628548156 - - -5.093170329928398e-11 - - -0.10905678830749821 - - - -0.1055843778376584 - - 2.1827872842550278e-11 - - 0.027918141058762558 - - - - 0.11318147835117998 - - -7.275957614183426e-12 - - 0.0806558419499197 - - - -0.0044726167325279675 - - -1.4551915228366852e-11 - - -0.11437428160570562 - - - -0.10870887277997099 - - 7.275957614183426e-12 - - 0.033718444654368795 - - - - 0.02205561503797071 - - 0.0 - - 0.015903162260656245 - - - 0.05098408467893023 - - 1.4551915228366852e-11 - - -0.09580103932239581 - - - -0.07303977520496119 - - 7.275957614183426e-12 - - 0.07989787455153419 - - - - 0.020305528247263283 - - 0.0 - - 0.014960411695938092 - - - 0.05805036811216269 - - -1.4551915228366852e-11 - - -0.10423131706920685 - - - -0.07835603128478397 - - 7.275957614183426e-12 - - 0.08927089755161433 - - - - 0.26928592537296936 - - 2.1827872842550278e-11 - - 0.19073858212505002 - - - -0.07746150083403336 - - 2.1827872842550278e-11 - - -0.17647508150548674 - - - -0.1918244067055639 - - -2.1827872842550278e-11 - - -0.014263495162595063 - mp2: - energy: -76.22940338787204 + - - - 0.27296630337423267 + - 1.7325874068774283e-10 + - 0.1915359971962971 + - - 0.04375171526680788 + - -1.0732037480920553e-10 + - -0.349977671054603 + - - -0.31671801721586235 + - 3.660716174636036e-10 + - 0.15844167483191995 + - - - 0.466111445576189 + - 1.1050360626541078e-10 + - 0.332718358177317 + - - -0.08526563836221612 + - -1.368789526168257e-10 + - -0.37705514723074884 + - - -0.380845806076195 + - 3.460627340245992e-10 + - 0.04433679012072389 + - - - 0.12454020971290447 + - 1.418811734765768e-10 + - 0.0870925107756193 + - - 0.11524763849593 + - -2.269189280923456e-10 + - -0.294121532416284 + - - -0.23978784721248303 + - 3.815330273937434e-10 + - 0.20702902237053422 + cvs-adc0: + config: + conv_tol: 1.0e-10 + core_orbitals: 1 + n_singlets: 3 + energy: + - -54.123082474404654 + - -53.96000354314297 gradient: - - - 0.02439544230583124 - - -2.9103830456733704e-11 - - 0.017738174385158345 - - - -0.010762452344351914 - - 1.4551915228366852e-11 - - -0.011150372949487064 - - - -0.013632995360239875 - - -7.275957614183426e-12 - - -0.006587801886780653 - sto3g: - adc1: + - - - 0.13670422915629388 + - 4.1040948417503387e-10 + - 0.09585740124884978 + - - 0.09903088592068343 + - 2.4647306418046355e-10 + - -0.2842584857662587 + - - -0.23573511384211088 + - -3.7061909097246826e-10 + - 0.1884010857386329 + - - - 0.4100968398331588 + - 5.441052053356543e-10 + - 0.29244198131482335 + - - -0.07108191035240452 + - 2.603428583825007e-10 + - -0.337017780989072 + - - -0.33901492831432734 + - -3.708464646479115e-10 + - 0.04457580091411728 + cvs-adc1: + config: + conv_tol: 1.0e-10 + core_orbitals: 1 + n_singlets: 3 energy: - - -74.47588319597438 - - -74.38511885048017 - - -74.3571822920925 - - -74.2490420036088 - - -74.13327522706486 + - -54.85354413664424 + - -54.79419426319795 gradient: - - - - 0.2519565806724131 - - -1.4551915228366852e-11 - - 0.17643764430249576 - - - 0.04383796844922472 - - 1.4551915228366852e-11 - - -0.32756816375331255 - - - -0.2957945393209229 - - -2.1827872842550278e-11 - - 0.15113050528452732 - - - - 0.4420401885145111 - - -2.9103830456733704e-11 - - 0.31597313308157027 - - - -0.08205663535773056 - - -7.275957614183426e-12 - - -0.35633137811964843 - - - -0.35998354491312057 - - 2.1827872842550278e-11 - - 0.04035823367303237 - - - - 0.10246271751384484 - - -2.1827872842550278e-11 - - 0.07140889731817879 - - - 0.11964530679688323 - - -1.4551915228366852e-11 - - -0.2768456041376339 - - - -0.22210801561595872 - - 7.275957614183426e-12 - - 0.20543669633480022 - - - - 0.3338767071109032 - - 1.4551915228366852e-11 - - 0.23875348844012478 - - - -2.251137630082667e-05 - - 0.0 - - -0.3568454495543847 - - - -0.33385419509431813 - - -2.9103830456733704e-11 - - 0.11809195824025664 - - - - 0.42701523288997123 - - 0.0 - - 0.30206555198674323 - - - -0.0510407709152787 - - -7.275957614183426e-12 - - -0.3809664128420991 - - - -0.37597446207655594 - - 0.0 - - 0.07890085934195668 - adc2: + - - - 0.20441432853976949 + - -1.4506440493278205e-10 + - 0.141988944977129 + - - 0.03388334054079678 + - 1.0663825378287584e-10 + - -0.2622227983315497 + - - -0.23829766849507905 + - -4.2246028897352517e-10 + - 0.12023385429824884 + - - - 0.31129172723240117 + - -1.844000507844612e-10 + - 0.22435429752431446 + - - -0.030362782968040847 + - 8.049028110690415e-11 + - -0.29155276776100436 + - - -0.28092894346605135 + - -3.051354724448174e-10 + - 0.06719847135468626 + cvs-adc2: + config: + conv_tol: 1.0e-10 + core_orbitals: 1 + n_singlets: 3 energy: - - -74.52306494758602 - - -74.42102314285322 - - -74.39990473420288 - - -74.28060927293537 - - -74.15388076828575 + - -54.98903589084654 + - -54.90586009813957 + - -53.166856815521626 gradient: - - - - 0.27296631058561616 - - 2.9103830456733704e-11 - - 0.19153598658158444 - - - 0.04375171761785168 - - 2.9103830456733704e-11 - - -0.3499776713724714 - - - -0.3167180179952993 - - 7.275957614183426e-12 - - 0.15844167019531596 - - - - 0.46611143292102497 - - -7.275957614183426e-12 - - 0.332718367826601 - - - -0.08526563550549326 - - 7.275957614183426e-12 - - -0.377055163771729 - - - -0.3808457903069211 - - -1.6007106751203537e-10 - - 0.04433678551140474 - - - - 0.1245402002314222 - - 1.4551915228366852e-11 - - 0.08709251808613772 - - - 0.11524764178466285 - - -1.4551915228366852e-11 - - -0.29412154671445023 - - - -0.23978783340135124 - - 7.275957614183426e-12 - - 0.20702901783079142 - - - - 0.344924942983198 - - -2.1827872842550278e-11 - - 0.2464642068516696 - - - -0.001407823758199811 - - 0.0 - - -0.3665060569619527 - - - -0.34351711843919475 - - 2.1827872842550278e-11 - - 0.1200418468870339 - - - - 0.43142601163708605 - - 2.1827872842550278e-11 - - 0.3051797001535306 - - - -0.050288449914660305 + - - - 0.23872009386514037 + - 7.366907084360719e-11 + - 0.16710098507473958 + - - 0.03348872368155753 + - 2.8421709430404007e-11 + - -0.2989140238057644 + - - -0.27220881743824066 + - -3.183231456205249e-12 + - 0.13181303912983822 + - - - 0.36193002234608684 + - 1.5234036254696548e-10 + - 0.2592484419444645 + - - -0.043051566211488534 + - 7.889866537880152e-11 + - -0.32641973963018245 + - - -0.31887845606684095 + - -1.4642864698544145e-10 + - 0.06717129804997057 + - - - 0.30556880202266257 + - -4.320099833421409e-12 + - 0.21378263909014095 + - - 0.1921237768597166 + - 1.1300471669528633e-10 + - -0.5935662726044484 + - - -0.4976925786825177 - -1.4551915228366852e-11 - - -0.38670489951618947 - - - -0.38113756212987937 - - 7.275957614183426e-12 - - 0.08152519822033355 + - 0.3797836338162597 mp2: - energy: -74.99357808910268 + config: + conv_tol: 1.0e-10 + core_orbitals: null + energy: -74.99357808910257 gradient: - - - 0.09648089321126463 - - -2.1827872842550278e-11 - - 0.0688644905021647 - - - -0.026183462534390856 - - -7.275957614183426e-12 - - -0.06597386132489191 - - - -0.07029743238672381 - - 7.275957614183426e-12 - - -0.002890627903980203 -hf: + - - 0.0964808942540003 + - -2.4647306418046355e-10 + - 0.06886449058492872 + - - -0.026183461533946684 + - -4.001776687800884e-10 + - -0.06597386197790911 + - - -0.07029743182465609 + - -1.227817847393453e-10 + - -0.0028906278603244573 +h2s: ccpvdz: + adc0: + config: + conv_tol: 1.0e-10 + core_orbitals: null + n_singlets: 3 + energy: + - -398.1515799222264 + - -398.1398867905316 + - -398.03539464761195 + gradient: + - - - 0.04578068799128232 + - -3.128661774098873e-10 + - 0.032366664892833796 + - - 0.0038504566055053147 + - -1.3715180102735758e-09 + - -0.05400166939034534 + - - -0.04963114104793931 + - -6.948539521545172e-10 + - 0.021634999859088566 + - - - 0.09920997355220607 + - -1.051375875249505e-09 + - 0.07015096214854566 + - - -0.028023131146255764 + - -1.1823431123048067e-09 + - -0.06560223412088817 + - - -0.07118683941553172 + - -3.383320290595293e-10 + - -0.004548731558315922 + - - - 0.021287992303768988 + - -9.76797309704125e-10 + - 0.015048890039906837 + - - 0.03829179147032846 + - -1.3460521586239338e-09 + - -0.0767335070468107 + - - -0.05957978217884374 + - -7.585185812786222e-10 + - 0.061684613492616336 adc1: + config: + conv_tol: 1.0e-10 + core_orbitals: null + n_singlets: 3 energy: - - -99.68449862868913 - - -99.68449862864962 - - -99.50075872824259 - - -99.05905941167467 - - -99.05905941155399 + - -398.4481425498703 + - -398.41378124384704 + - -398.28872929642466 gradient: - - - - 4.3655745685100555e-11 - - -4.3655745685100555e-11 - - 0.05474575013795402 - - - 1.4551915228366852e-11 - - 1.4551915228366852e-11 - - -0.05474577005952597 - - - - 5.820766091346741e-11 - - -4.3655745685100555e-11 - - 0.05474574991967529 - - - 1.4551915228366852e-11 - - 2.9103830456733704e-11 - - -0.054745770030422136 - - - - -4.3655745685100555e-11 - - 4.3655745685100555e-11 - - 0.029345564864343032 - - - -4.3655745685100555e-11 - - 0.0 - - -0.029341923116589896 - - - - 7.275957614183426e-11 - - -4.3655745685100555e-11 - - -0.1574882440181682 - - - 2.9103830456733704e-11 - - 0.0 - - 0.15748825178889092 - - - - -5.820766091346741e-11 - - -4.3655745685100555e-11 - - -0.1574882423155941 - - - 4.3655745685100555e-11 - - 1.4551915228366852e-11 - - 0.15748825231275987 + - - - 0.10803630138434528 + - 2.395609044469893e-09 + - 0.07638639218203025 + - - -0.03612434675778786 + - 1.7571437638252974e-09 + - -0.06350030807152507 + - - -0.07191195135783346 + - 5.147740012034774e-10 + - -0.012886087259175838 + - - - 0.05877872349083191 + - 2.1445885067805648e-09 + - 0.04156223781137669 + - - 0.005488574437549687 + - 2.240994945168495e-09 + - -0.0701116084237583 + - - -0.06426729494887695 + - 2.1846062736585736e-09 + - 0.02854936761468707 + - - - 0.02305018994047714 + - 2.17733031604439e-09 + - 0.01626297137590882 + - - 0.03974369752177154 + - 1.7971615307033062e-09 + - -0.0806184821522038 + - - -0.06279388480834314 + - 5.966285243630409e-10 + - 0.06435550774040166 adc2: + config: + conv_tol: 1.0e-10 + core_orbitals: null + n_singlets: 3 energy: - - -99.94395193294302 - - -99.9439519329312 - - -99.73699393315073 - - -99.43877070940161 - - -99.43877070915488 + - -398.59877677783606 + - -398.57820913004144 + - -398.4592452078568 gradient: - - - - 0.0 - - 5.820766091346741e-11 - - 0.07390241048415191 - - - 1.4551915228366852e-11 - - 0.0 - - -0.07390240793756675 - - - - -5.820766091346741e-11 - - 0.0 - - 0.07390241093526129 - - - -2.9103830456733704e-11 - - -4.3655745685100555e-11 - - -0.07390240782115143 - - - - -1.3096723705530167e-10 - - 5.820766091346741e-11 - - 0.04055179744318593 - - - -2.9103830456733704e-11 - - -4.3655745685100555e-11 - - -0.04055119516851846 - - - - 2.9103830456733704e-11 - - -4.3655745685100555e-11 - - -0.006900888605741784 - - - -4.3655745685100555e-11 - - 0.0 - - 0.00690086766553577 - - - - -1.4551915228366852e-11 - - 4.3655745685100555e-11 - - -0.006900887412484735 - - - -8.731149137020111e-11 - - -1.4551915228366852e-11 - - 0.0069008679274702445 + - - - 0.11349620913642866 + - 3.043169272132218e-09 + - 0.08024572990689194 + - - -0.03617636409762781 + - -4.5056367525830865e-09 + - -0.06921669138864672 + - - -0.0773198410297482 + - -1.0786607163026929e-09 + - -0.011029041086658253 + - - - 0.06890881111939962 + - 3.3760443329811096e-09 + - 0.04872581403105869 + - - 0.0007846968928788556 + - -4.079993232153356e-09 + - -0.07420493784593418 + - - -0.06969350310100708 + - -1.1823431123048067e-09 + - 0.025479119942247053 + - - - 0.026638232748155133 + - 3.0377123039215803e-09 + - 0.01883201013879443 + - - 0.03586793922659126 + - -3.0358933145180345e-09 + - -0.07898060033403453 + - - -0.06250616863508185 + - -1.584339770488441e-09 + - 0.06014858882736007 + cvs-adc0: + config: + conv_tol: 1.0e-10 + core_orbitals: 1 + n_singlets: 3 + energy: + - -306.5702818290554 + - -306.5585886973606 + - -306.27663889652354 + gradient: + - - - -0.0005600169333774829 + - -2.8048816602677107e-09 + - -0.00039869371357781347 + - - 0.010626706627590465 + - 2.295564627274871e-09 + - -0.014432359732381883 + - - -0.010066687804282992 + - 2.128217602148652e-10 + - 0.014831047505140305 + - - - 0.052869269560687826 + - -3.894456312991679e-09 + - 0.03738560443161987 + - - -0.02124688195544877 + - 2.0190782379359007e-09 + - -0.026032925277831964 + - - -0.031622385589798796 + - -1.4370016288012266e-10 + - -0.011352684508892708 + - - - -0.11320313695250661 + - -3.1868694350123405e-09 + - -0.08003982209265814 + - - 0.022655758202745346 + - 2.4647306418046355e-09 + - 0.08802987322633271 + - - 0.0905473797229206 + - 5.256879376247525e-10 + - -0.007990056130438461 + cvs-adc1: + config: + conv_tol: 1.0e-10 + core_orbitals: 1 + n_singlets: 3 + energy: + - -307.0469716451253 + - -306.9928081136182 + - -306.66389328521205 + gradient: + - - - 0.08569442892621737 + - -2.3483153199777007e-09 + - 0.06058905785539537 + - - -0.03199412468529772 + - 7.73070496506989e-10 + - -0.04564345915787271 + - - -0.05370030290032446 + - 1.0986695997416973e-09 + - -0.014945597060432192 + - - - 0.060991944515990326 + - -1.5807017916813493e-09 + - 0.04312763449524937 + - - 0.010061566641525133 + - 2.801243681460619e-10 + - -0.07892745922617905 + - - -0.0710535097769025 + - 7.421476766467094e-10 + - 0.03579982581140939 + - - - -0.09416327362669108 + - -1.915395841933787e-09 + - -0.06657817539053212 + - - 0.02227655534443329 + - 4.43833414465189e-10 + - 0.06837145195640915 + - - 0.07188672033225885 + - 1.216903910972178e-09 + - -0.0017932738865056308 + cvs-adc2: + config: + conv_tol: 1.0e-10 + core_orbitals: 1 + n_singlets: 3 + energy: + - -307.55304380138324 + - -307.5390364236865 + - -307.23548401133706 + gradient: + - - - 0.0670970617011335 + - -5.762558430433273e-09 + - 0.0474364804540528 + - - -0.027216085905820364 + - 6.417394615709782e-09 + - -0.03267126798891695 + - - -0.03988097510955413 + - 9.62245394475758e-10 + - -0.014765213396458421 + - - - 0.029086330972859287 + - -6.45741238258779e-10 + - 0.02057188668550225 + - - 0.007924816858576378 + - 9.171344572678208e-09 + - -0.042067237891387776 + - - -0.03701114303112263 + - 5.047695594839752e-09 + - 0.021495354449143633 + - - - -0.10690601791975496 + - -6.3937477534636855e-09 + - -0.07558765565227077 + - - 0.02297003968487843 + - 6.630216375924647e-09 + - 0.08090629767684732 + - - 0.08393593514665554 + - 2.6302586775273085e-09 + - -0.005318600378814153 mp2: - energy: -100.14365279000066 + config: + conv_tol: 1.0e-10 + core_orbitals: null + energy: -398.84627682836333 gradient: - - - 2.9103830456733704e-11 - - -4.3655745685100555e-11 - - -0.13385940197622404 - - - -2.9103830456733704e-11 - - 2.9103830456733704e-11 - - 0.13385939724685159 + - - 0.008224159959354438 + - -6.184563972055912e-11 + - 0.005815822252770886 + - - -0.0006543757190229371 + - 2.306478563696146e-09 + - -0.007798851067491341 + - - -0.007569784722363693 + - -6.220943760126829e-10 + - 0.001983025022127549 sto3g: + adc0: + config: + conv_tol: 1.0e-10 + core_orbitals: null + n_singlets: 3 + energy: + - -393.56316827051154 + - -393.4915751294324 + - -393.4462776354093 + gradient: + - - - 0.25230105396440194 + - -1.6934791347011924e-09 + - 0.17838563321129186 + - - -0.0888543081437092 + - 7.385096978396177e-10 + - -0.1419389880120434 + - - -0.16344673976163904 + - -1.5315890777856112e-09 + - -0.03644664150669996 + - - - 0.1724451418249373 + - -1.3897079043090343e-09 + - 0.12193491716607241 + - - 0.038668459907057695 + - 8.894858183339238e-10 + - -0.23760870911428356 + - - -0.21111359499082027 + - -1.102307578548789e-09 + - 0.11567379406551481 + - - - 0.22104007236521284 + - -2.002707333303988e-09 + - 0.15628231203663745 + - - -0.052700263249789714 + - 8.349161362275481e-10 + - -0.15991409170055704 + - - -0.16833980368210177 + - -1.0859366739168763e-09 + - 0.0036317829908512067 adc1: + config: + conv_tol: 1.0e-10 + core_orbitals: null + n_singlets: 3 energy: - - -98.26160079719433 - - -98.26160079719432 - - -97.86355144712479 - - -97.20550168819246 - - -73.02590622379267 + - -393.95426500916886 + - -393.85190114750174 + - -393.74709485464746 gradient: - - - - -5.820766091346741e-11 - - 0.0 - - 0.0459835930087138 - - - 2.9103830456733704e-11 - - -2.9103830456733704e-11 - - -0.04598359337251168 - - - - -5.820766091346741e-11 - - 0.0 - - 0.0459835930087138 - - - 0.0 - - -2.9103830456733704e-11 - - -0.04598359337251168 - - - - -2.9103830456733704e-11 - - 0.0 - - 0.05563517109840177 - - - -2.9103830456733704e-11 - - -4.3655745685100555e-11 - - -0.055635170749155805 - - - - 2.9103830456733704e-11 - - -4.3655745685100555e-11 - - 0.07153463260328863 - - - -1.4551915228366852e-11 - - -4.3655745685100555e-11 - - -0.07153463290887885 - - - - 1.4551915228366852e-11 - - -7.275957614183426e-12 - - 0.009702209834358655 - - - 1.4551915228366852e-11 - - -1.4551915228366852e-11 - - -0.00970221107127145 + - - - 0.2258862714006682 + - -8.421920938417315e-10 + - 0.15971131874539424 + - - -0.08185868775581184 + - -1.3096723705530167e-09 + - -0.12381793986605771 + - - -0.14402758416144934 + - -2.5647750589996576e-10 + - -0.03589337947414606 + - - - 0.17390147776859521 + - -1.3169483281672e-09 + - 0.12296233535380452 + - - 0.032026549057263765 + - -1.9226717995479703e-09 + - -0.2297569321908668 + - - -0.20592802683313494 + - -3.2741809263825417e-11 + - 0.10679459714629047 + - - - 0.1873060738289496 + - -1.533408067189157e-09 + - 0.1324307295944891 + - - -0.03424577455189137 + - -1.798980520106852e-09 + - -0.15023357055360975 + - - -0.15306030026658846 + - 1.6007106751203537e-10 + - 0.017802839623982436 adc2: + config: + conv_tol: 1.0e-10 + core_orbitals: null + n_singlets: 3 + energy: + - -393.9842077243818 + - -393.8926295929391 + - -393.780516160198 + gradient: + - - - 0.23961461569706444 + - -3.4415279515087605e-09 + - 0.169417509705454 + - - -0.08329049956955714 + - -3.0740920919924974e-10 + - -0.13635383458858996 + - - -0.1563241157145967 + - 1.8517312128096819e-09 + - -0.03306367092409346 + - - - 0.19135385461413534 + - -3.283275873400271e-09 + - 0.13530247669223172 + - - 0.027144983345351648 + - -6.893969839438796e-10 + - -0.24136482305220852 + - - -0.21849883606228104 + - 2.0991137716919184e-09 + - 0.10606234963051975 + - - - 0.1966486181354412 + - -2.926753950305283e-09 + - 0.13903454180035624 + - - -0.03435949950835493 + - 1.709850039333105e-10 + - -0.15998005804976856 + - - -0.1622891172355594 + - 1.8662831280380487e-09 + - 0.020945519079759833 + cvs-adc0: + config: + conv_tol: 1.0e-10 + core_orbitals: 1 + n_singlets: 3 + energy: + - -303.09562180866817 + - -303.02402866758905 + gradient: + - - - 0.23376297983486438 + - 1.1423253454267979e-09 + - 0.16527821475574456 + - - -0.0822368225781247 + - 2.874003257602453e-10 + - -0.13163509600053658 + - - -0.15152615825900284 + - 2.8358044801279902e-09 + - -0.03364311427685607 + - - - 0.15390706837933976 + - 9.931682143360376e-10 + - 0.10882749930533464 + - - 0.04528594586372492 + - 7.639755494892597e-11 + - -0.2273048162151099 + - - -0.1991930141721241 + - 2.9467628337442875e-09 + - 0.11847732043497672 + cvs-adc1: + config: + conv_tol: 1.0e-10 + core_orbitals: 1 + n_singlets: 3 + energy: + - -303.698801752587 + - -303.61193425581257 + gradient: + - - - 0.17391410489472037 + - -2.0827428670600057e-09 + - 0.12296458471791993 + - - -0.05673400973319076 + - -6.002665031701326e-11 + - -0.10422641407240008 + - - -0.11718009382639138 + - -1.0095391189679503e-09 + - -0.01873817429623159 + - - - 0.14413337585210684 + - -1.911757863126695e-09 + - 0.10191438977199141 + - - 0.02465682893853227 + - -1.3642420526593924e-10 + - -0.1877586904411146 + - - -0.16879020336273243 + - -1.1641532182693481e-09 + - 0.08584429681468464 + cvs-adc2: + config: + conv_tol: 1.0e-10 + core_orbitals: 1 + n_singlets: 3 energy: - - -98.30973760269728 - - -98.30973760269728 - - -97.88705005686671 - - -97.31155583033184 - - -96.96183479769606 + - -303.8200076265979 + - -303.75077619425804 + - -302.3761161233506 gradient: - - - - 1.1641532182693481e-10 - - -4.3655745685100555e-11 - - 0.08218655599921476 - - - 7.275957614183426e-11 - - 2.9103830456733704e-11 - - -0.08218655640666839 - - - - 0.0 - - 7.275957614183426e-11 - - 0.08218655599921476 - - - -4.3655745685100555e-11 - - 1.4551915228366852e-10 - - -0.08218655629025307 - - - - -1.1641532182693481e-10 - - 2.9103830456733704e-11 - - 0.04958453155995812 - - - 0.0 - - -2.9103830456733704e-11 - - -0.04958453113795258 - - - - 0.0 - - 5.820766091346741e-11 - - 0.15719162416644394 - - - -1.4551915228366852e-11 - - -5.820766091346741e-11 - - -0.15719162434106693 - - - - -2.9103830456733704e-11 - - -1.7462298274040222e-10 - - 0.4785101861489238 - - - 2.9103830456733704e-11 - - -5.820766091346741e-11 - - -0.47851018683286384 + - - - 0.2047669111725554 + - 1.8189894035458565e-12 + - 0.14477813961639185 + - - -0.06502812668622937 + - 2.1645973902195692e-10 + - -0.125219906154598 + - - -0.13973878953220265 + - 1.8444552551954985e-09 + - -0.019558233094358002 + - - - 0.174233664149142 + - 6.311893230304122e-10 + - 0.12319781867154234 + - - 0.01700030641768535 + - 2.7284841053187847e-11 + - -0.20885805250145495 + - - -0.19123397491966898 + - 1.8044374883174896e-09 + - 0.08566023378261889 + - - - 0.5056019715320872 + - 1.8553691916167736e-10 + - 0.357476981187574 + - - -0.176032163306445 + - -3.1468516681343317e-10 + - -0.2873081199468288 + - - -0.3295698133024416 + - 1.9354047253727913e-09 + - -0.0701688630888384 mp2: - energy: -98.52261046811574 + config: + conv_tol: 1.0e-10 + core_orbitals: null + energy: -394.34055332993324 gradient: - - - 0.0 - - 1.4551915228366852e-11 - - -0.14964825809875038 - - - 0.0 - - 0.0 - - 0.14964825844799634 + - - 0.013177627233744715 + - -1.2623786460608244e-09 + - 0.009318394595538848 + - - -0.0030057977219257737 + - 1.0913936421275139e-11 + - -0.009727519616717473 + - - -0.010171829353566864 + - -3.055902197957039e-10 + - 0.00040912335134635214 +methods: +- mp2 +- adc0 +- adc1 +- adc2 +- cvs-adc0 +- cvs-adc1 +- cvs-adc2 +molecules: +- h2o +- h2s diff --git a/adcc/testdata/static_data.py b/adcc/testdata/static_data.py index 80720d202..d24988399 100644 --- a/adcc/testdata/static_data.py +++ b/adcc/testdata/static_data.py @@ -21,6 +21,30 @@ ## ## --------------------------------------------------------------------- import os +from dataclasses import dataclass + + +@dataclass +class Molecule: + name: str + charge: int = 0 + multiplicity: int = 1 + core_orbitals: int = 1 + + @property + def xyz(self): + return xyz[self.name] + + +molecules = [ + Molecule("h2o", 0, 1), + Molecule("h2s", 0, 1), + # Molecule("cn", 0, 2), + # "ch2nh2", + # Molecule("hf", 0, 1), + # Molecule("formaldehyde", 0, 1), +] + # all coordinates in Bohr xyz = { diff --git a/adcc/workflow.py b/adcc/workflow.py index a290032e7..a46d54c5c 100644 --- a/adcc/workflow.py +++ b/adcc/workflow.py @@ -406,6 +406,13 @@ def diagonalise_adcmatrix(matrix, n_states, kind, eigensolver="davidson", warnings.warn("Ignoring n_guesses_doubles parameter, since guesses " "are explicitly provided.") + nguess_found = len(guesses) + if n_states > nguess_found: + warnings.warn(f"More states requested ({n_states}) than " + f"guesses available ({nguess_found}). " + "Reducing number of eigenstates to number of guesses.") + n_states = nguess_found + solverargs.setdefault("which", "SA") return run_eigensolver(matrix, guesses, n_ep=n_states, conv_tol=conv_tol, callback=callback, @@ -485,8 +492,8 @@ def obtain_guesses_by_inspection(matrix, n_guesses, kind, n_guesses_doubles=None total_guesses = singles_guesses + doubles_guesses if len(total_guesses) < n_guesses: - raise InputError("Less guesses found than requested: {} found, " - "{} requested".format(len(total_guesses), n_guesses)) + warnings.warn("Less guesses found than requested: " + f"{len(total_guesses)} found, {n_guesses} requested.") return total_guesses From 999ef3faa9a8241e14d91b5975caab8b716013ee Mon Sep 17 00:00:00 2001 From: Maximilian Scheurer Date: Tue, 14 Dec 2021 22:29:20 +0100 Subject: [PATCH 08/18] flake 8 happy? --- adcc/backends/pyscf.py | 25 ---- adcc/gradients/TwoParticleDensityMatrix.py | 2 +- adcc/gradients/__init__.py | 40 +++--- adcc/gradients/amplitude_response.py | 66 ++++----- adcc/gradients/orbital_response.py | 130 ++++++++---------- .../gradients/test_functionality_gradients.py | 8 +- adcc/testdata/dump_fdiff_gradient.py | 6 +- adcc/testdata/static_data.py | 2 +- 8 files changed, 111 insertions(+), 168 deletions(-) diff --git a/adcc/backends/pyscf.py b/adcc/backends/pyscf.py index 5bb1ad4f2..9544fa8f3 100644 --- a/adcc/backends/pyscf.py +++ b/adcc/backends/pyscf.py @@ -49,11 +49,6 @@ def correlated_gradient(self, g1_ao, w_ao, g2_ao_1, g2_ao_2): Gradient["TEI"] = np.zeros((natoms, 3)) Gradient["Total"] = np.zeros((natoms, 3)) - # Iulia added variables; TODO: remove - #ovlp_iulia = np.zeros((natoms, 3)) - #hcore_iulia = np.zeros((natoms, 3)) - #eri_iulia = np.zeros((natoms, 3)) - # TODO: does RHF/UHF matter here? gradient = grad.RHF(self.scfres) hcore_deriv = gradient.hcore_generator() @@ -72,13 +67,10 @@ def correlated_gradient(self, g1_ao, w_ao, g2_ao_1, g2_ao_2): Sx_a[:, k0:k1] = Sx[:, k0:k1] Sx_a += Sx_a.transpose(0, 2, 1) Gradient["S"][ia] += np.einsum("xpq,pq->x", Sx_a, w_ao) - #ovlp_iulia[ia] += np.einsum("xpq,pq->x", Sx_a, w_ao) - # derivative of the core Hamiltonian Hx_a = hcore_deriv(ia) Gradient["T+V"][ia] += np.einsum("xpq,pq->x", Hx_a, g1_ao) - #hcore_iulia[ia] += np.einsum("xpq,pq->x", Hx_a, g1_ao) # derivatives of the ERIs ERIx_a = np.zeros_like(ERIx) @@ -94,23 +86,6 @@ def correlated_gradient(self, g1_ao, w_ao, g2_ao_1, g2_ao_2): Gradient["TEI"][ia] -= np.einsum( "pqrs,xpsqr->x", g2_ao_2, ERIx_a, optimize=True ) - #eri_iulia[ia] += ( - # np.einsum("pqrs,xprqs->x", g2_ao_1, ERIx_a, optimize=True) - # - np.einsum("pqrs,xpsqr->x", g2_ao_2, ERIx_a, optimize=True) - #) - - - # Iulia print TODO:remove - #print("2PDM_1 in AO:\n", g2_ao_1) - #print("Hcore contribution to the gradient:") - #print(hcore_iulia) - #print() - #print("Overlp contribution to the gradient:") - #print(ovlp_iulia) - #print() - #print("ERI contribution to the gradient:") - #print(eri_iulia) - #print() Gradient["N"] = gradient.grad_nuc() Gradient["OEI"] = Gradient["T+V"] + Gradient["S"] diff --git a/adcc/gradients/TwoParticleDensityMatrix.py b/adcc/gradients/TwoParticleDensityMatrix.py index fecf218df..082a02047 100644 --- a/adcc/gradients/TwoParticleDensityMatrix.py +++ b/adcc/gradients/TwoParticleDensityMatrix.py @@ -62,7 +62,7 @@ def __init__(self, spaces): b.cccc, b.ococ, b.oooo, b.cvcv, b.ocov, b.cccv, b.cocv, b.ocoo, b.ccco, b.occv, b.ccvv, b.ocvv, - b.vvvv, + b.vvvv, ] self._tensors = {} diff --git a/adcc/gradients/__init__.py b/adcc/gradients/__init__.py index 8be263925..a12cbf43e 100644 --- a/adcc/gradients/__init__.py +++ b/adcc/gradients/__init__.py @@ -63,13 +63,13 @@ def nuclear_gradient(excitation_or_mp): with timer.record("orbital_response"): rhs = orbital_response_rhs(hf, g1a, g2a).evaluate() - l = orbital_response(hf, rhs) + lam = orbital_response(hf, rhs) # orbital-relaxed OPDM (without reference state) g1o = g1a.copy() - g1o.ov = 0.5 * l.ov + g1o.ov = 0.5 * lam.ov if hf.has_core_occupied_space: - g1o.cv = 0.5 * l.cv + g1o.cv = 0.5 * lam.cv # orbital-relaxed OPDM (including reference state) g1 = g1o.copy() g1 += hf.density @@ -84,34 +84,34 @@ def nuclear_gradient(excitation_or_mp): delta_IJ = hf.density.cc g2_hf = TwoParticleDensityMatrix(hf) - g2_hf.oooo = -0.25 * ( einsum("ik,jl->ijkl", delta_ij, delta_ij)) - g2_hf.cccc = -0.5 * ( einsum("IK,JL->IJKL", delta_IJ, delta_IJ)) - g2_hf.ococ = -1.0 * ( einsum("ik,JL->iJkL", delta_ij, delta_IJ)) + g2_hf.oooo = -0.25 * einsum("ik,jl->ijkl", delta_ij, delta_ij) + g2_hf.cccc = -0.5 * einsum("IK,JL->IJKL", delta_IJ, delta_IJ) + g2_hf.ococ = -1.0 * einsum("ik,JL->iJkL", delta_ij, delta_IJ) g2_oresp = TwoParticleDensityMatrix(hf) - g2_oresp.cccc = einsum("IK,JL->IJKL", delta_IJ, g1o.cc+delta_IJ) - g2_oresp.ococ = ( - einsum("ik,JL->iJkL", delta_ij, g1o.cc+2*delta_IJ) + g2_oresp.cccc = einsum("IK,JL->IJKL", delta_IJ, g1o.cc + delta_IJ) + g2_oresp.ococ = ( + + einsum("ik,JL->iJkL", delta_ij, g1o.cc + 2.0 * delta_IJ) + einsum("ik,JL->iJkL", g1o.oo, delta_IJ) ) g2_oresp.oooo = 0.25 * ( - einsum("ik,jl->ijkl", delta_ij, g1o.oo+delta_ij) + einsum("ik,jl->ijkl", delta_ij, g1o.oo + delta_ij) ) g2_oresp.ovov = einsum("ij,ab->iajb", delta_ij, g1o.vv) g2_oresp.cvcv = einsum("IJ,ab->IaJb", delta_IJ, g1o.vv) - g2_oresp.ocov = 2*einsum("ik,Ja->iJka", delta_ij, g1o.cv) - g2_oresp.cccv = 2*einsum("IK,Ja->IJKa", delta_IJ, g1o.cv) - g2_oresp.ooov = 2*einsum("ik,ja->ijka", delta_ij, g1o.ov) - g2_oresp.cocv = 2*einsum("IK,ja->IjKa", delta_IJ, g1o.ov) - g2_oresp.ocoo = 2*einsum("ik,Jl->iJkl", delta_ij, g1o.co) - g2_oresp.ccco = 2*einsum("IK,Jl->IJKl", delta_IJ, g1o.co) + g2_oresp.ocov = 2 * einsum("ik,Ja->iJka", delta_ij, g1o.cv) + g2_oresp.cccv = 2 * einsum("IK,Ja->IJKa", delta_IJ, g1o.cv) + g2_oresp.ooov = 2 * einsum("ik,ja->ijka", delta_ij, g1o.ov) + g2_oresp.cocv = 2 * einsum("IK,ja->IjKa", delta_IJ, g1o.ov) + g2_oresp.ocoo = 2 * einsum("ik,Jl->iJkl", delta_ij, g1o.co) + g2_oresp.ccco = 2 * einsum("IK,Jl->IJKl", delta_IJ, g1o.co) # scale for contraction with integrals g2a.oovv *= 0.5 g2a.ccvv *= 0.5 g2a.occv *= 2.0 - g2a.vvvv *= 0.25 # Scaling twice! - g2a.vvvv *= 0.25 # it's the only way it works... + g2a.vvvv *= 0.25 # Scaling twice! + g2a.vvvv *= 0.25 # it's the only way it works... g2_total = evaluate(g2_hf + g2a + g2_oresp) else: @@ -119,13 +119,13 @@ def nuclear_gradient(excitation_or_mp): g2_hf = TwoParticleDensityMatrix(hf) g2_hf.oooo = 0.25 * (- einsum("li,jk->ijkl", delta_ij, delta_ij) + einsum("ki,jl->ijkl", delta_ij, delta_ij)) - + g2_oresp = TwoParticleDensityMatrix(hf) g2_oresp.oooo = einsum("ij,kl->kilj", delta_ij, g1o.oo) g2_oresp.ovov = einsum("ij,ab->iajb", delta_ij, g1o.vv) g2_oresp.ooov = (- einsum("kj,ia->ijka", delta_ij, g1o.ov) + einsum("ki,ja->ijka", delta_ij, g1o.ov)) - + # scale for contraction with integrals g2a.oovv *= 0.5 g2_total = evaluate(g2_hf + g2a + g2_oresp) diff --git a/adcc/gradients/amplitude_response.py b/adcc/gradients/amplitude_response.py index 1b28fd80b..2adf4325b 100644 --- a/adcc/gradients/amplitude_response.py +++ b/adcc/gradients/amplitude_response.py @@ -54,17 +54,14 @@ def t2bar_oovv_adc2(exci, g1a_adc0): ) return t2bar + def t2bar_oovv_cvs_adc2(exci, g1a_adc0): mp = exci.ground_state hf = mp.reference_state - u = exci.excitation_vector df_ia = mp.df(b.ov) - t2bar = 0.5*( + t2bar = 0.5 * ( - einsum("ijcb,ac->ijab", hf.oovv, g1a_adc0.vv).antisymmetrise((2, 3)) - ) / ( - direct_sum("ia+jb->ijab", df_ia, df_ia).symmetrise((0, 1)) - ) - + ) / direct_sum("ia+jb->ijab", df_ia, df_ia).symmetrise((0, 1)) return t2bar @@ -78,6 +75,7 @@ def ampl_relaxed_dms_adc1(exci): g2a.ovov = - 1.0 * einsum("ja,ib->iajb", u.ph, u.ph) return g1a, g2a + def ampl_relaxed_dms_adc0(exci): hf = exci.reference_state u = exci.excitation_vector @@ -89,6 +87,7 @@ def ampl_relaxed_dms_adc0(exci): g1a.vv = + 1.0 * einsum("ia,ib->ab", u.ph, u.ph) return g1a, g2a + def ampl_relaxed_dms_cvs_adc0(exci): hf = exci.reference_state u = exci.excitation_vector @@ -100,6 +99,7 @@ def ampl_relaxed_dms_cvs_adc0(exci): g1a.vv = + 1.0 * einsum("Ia,Ib->ab", u.ph, u.ph) return g1a, g2a + def ampl_relaxed_dms_cvs_adc1(exci): hf = exci.reference_state u = exci.excitation_vector @@ -118,6 +118,7 @@ def ampl_relaxed_dms_cvs_adc1(exci): g1a.co = - 1.0 * einsum('JbKc,ibKc->Ji', g2a.cvcv, hf.ovcv) / fco return g1a, g2a + def ampl_relaxed_dms_cvs_adc2(exci): hf = exci.reference_state mp = exci.ground_state @@ -139,10 +140,9 @@ def ampl_relaxed_dms_cvs_adc2(exci): - 0.5 * einsum('kIab,kJab->IJ', t2ocvv, t2ocvv) ) - g1a.oo = ( + g1a.oo = ( - 1.0 * einsum("jKba,iKba->ij", u.pphh, u.pphh) - 2.0 * einsum("ikab,jkab->ij", t2bar, t2oovv).symmetrise((0, 1)) - #- 1.0 * einsum('jkab,ikab->ij', t2oovv, t2bar) - 0.5 * einsum('iKab,jKab->ij', t2ocvv, t2ocvv) - 0.5 * einsum('ikab,jkab->ij', t2oovv, t2oovv) ) @@ -157,7 +157,6 @@ def ampl_relaxed_dms_cvs_adc2(exci): + 1.0 * einsum("Ia,Ib->ab", u.ph, u.ph) + 2.0 * einsum('jIcb,jIca->ab', u.pphh, u.pphh) + 2.0 * einsum('ijac,ijbc->ab', t2bar, t2oovv).symmetrise((0, 1)) - #+ 1.0 * einsum('ijbc,ijac->ab', t2bar, t2oovv) + 0.5 * einsum('IJac,IJbc->ab', t2ccvv, t2ccvv) + 0.5 * einsum('ijac,ijbc->ab', t2oovv, t2oovv) + 1.0 * einsum('iJac,iJbc->ab', t2ocvv, t2ocvv) @@ -169,32 +168,29 @@ def ampl_relaxed_dms_cvs_adc2(exci): # The factor 1/sqrt(2) is needed because of the scaling used in adcc # for the ph-pphh blocks. - g2a.occv = (1 / sqrt(2)) * ( - 2.0 * einsum('Ib,kJba->kJIa', u.ph, u.pphh) - #- einsum('Ib,kJab->kJIa', u.ph, u.pphh) + g2a.occv = (1 / sqrt(2)) * ( + 2.0 * einsum('Ib,kJba->kJIa', u.ph, u.pphh) ) g2a.oovv = ( + 1.0 * einsum('ijcb,ca->ijab', t2oovv, g1a_cvs0.vv).antisymmetrise((2, 3)) - #- 0.5 * einsum('ijca,cb->ijab', t2oovv, g1a_cvs0.vv) - 1.0 * t2oovv - 2.0 * t2bar ) # The factor 2/sqrt(2) is necessary because of the way # that the ph-pphh is scaled. - g2a.ovvv = (2 / sqrt(2) ) * ( + g2a.ovvv = (2 / sqrt(2)) * ( einsum('Ja,iJcb->iabc', u.ph, u.pphh) ) - - g2a.ccvv = -t2ccvv - - g2a.ocvv = -t2ocvv + + g2a.ccvv = - 1.0 * t2ccvv + g2a.ocvv = - 1.0 * t2ocvv # This is the OC block of the orbital response # Lagrange multipliers (lambda): g1a.co = ( - - 1.0 * einsum('JbKc,ibKc->Ji', g2a.cvcv, hf.ovcv) + - 1.0 * einsum('JbKc,ibKc->Ji', g2a.cvcv, hf.ovcv) - 0.5 * einsum('JKab,iKab->Ji', g2a.ccvv, hf.ocvv) + 1.0 * einsum('kJLa,ikLa->Ji', g2a.occv, hf.oocv) + 0.5 * einsum('kJab,ikab->Ji', g2a.ocvv, hf.oovv) @@ -205,9 +201,9 @@ def ampl_relaxed_dms_cvs_adc2(exci): + 0.5 * einsum('iabc,Jabc->Ji', g2a.ovvv, hf.cvvv) ) / fco - return g1a, g2a + def ampl_relaxed_dms_cvs_adc2x(exci): hf = exci.reference_state mp = exci.ground_state @@ -229,10 +225,9 @@ def ampl_relaxed_dms_cvs_adc2x(exci): - 0.5 * einsum('kIab,kJab->IJ', t2ocvv, t2ocvv) ) - g1a.oo = ( + g1a.oo = ( - 1.0 * einsum("jKba,iKba->ij", u.pphh, u.pphh) - 2.0 * einsum("ikab,jkab->ij", t2bar, t2oovv).symmetrise((0, 1)) - #- 1.0 * einsum('jkab,ikab->ij', t2oovv, t2bar) # use symmetrize? - 0.5 * einsum('iKab,jKab->ij', t2ocvv, t2ocvv) - 0.5 * einsum('ikab,jkab->ij', t2oovv, t2oovv) ) @@ -247,7 +242,6 @@ def ampl_relaxed_dms_cvs_adc2x(exci): + 1.0 * einsum("Ia,Ib->ab", u.ph, u.ph) + 2.0 * einsum('jIcb,jIca->ab', u.pphh, u.pphh) + 2.0 * einsum('ijac,ijbc->ab', t2bar, t2oovv).symmetrise((0, 1)) - #+ 1.0 * einsum('ijbc,ijac->ab', t2bar, t2oovv) + 0.5 * einsum('IJac,IJbc->ab', t2ccvv, t2ccvv) + 0.5 * einsum('ijac,ijbc->ab', t2oovv, t2oovv) + 1.0 * einsum('iJac,iJbc->ab', t2ocvv, t2ocvv) @@ -256,26 +250,22 @@ def ampl_relaxed_dms_cvs_adc2x(exci): g2a.cvcv = ( - 1.0 * einsum("Ja,Ib->IaJb", u.ph, u.ph) - 1.0 * einsum('kIbc,kJac->IaJb', u.pphh, u.pphh) - #- 0.5 * einsum('kIcb,kJca->IaJb', u.pphh, u.pphh) + 1.0 * einsum('kIcb,kJac->IaJb', u.pphh, u.pphh) - #+ 0.5 * einsum('kIbc,kJca->IaJb', u.pphh, u.pphh) ) # The factor 1/sqrt(2) is needed because of the scaling used in adcc # for the ph-pphh blocks. - g2a.occv = (1 / sqrt(2)) * ( - 2.0 * einsum('Ib,kJba->kJIa', u.ph, u.pphh) - #- einsum('Ib,kJab->kJIa', u.ph, u.pphh) + g2a.occv = (1 / sqrt(2)) * ( + 2.0 * einsum('Ib,kJba->kJIa', u.ph, u.pphh) ) g2a.oovv = ( + 1.0 * einsum('ijcb,ca->ijab', t2oovv, g1a_cvs0.vv).antisymmetrise((2, 3)) - #- 0.5 * einsum('ijca,cb->ijab', t2oovv, g1a_cvs0.vv) - 1.0 * t2oovv - 2.0 * t2bar ) - # The factor 2/sqrt(2) is necessary because of + # The factor 2/sqrt(2) is necessary because of # the way that the ph-pphh is scaled g2a.ovvv = (2 / sqrt(2)) * ( einsum('Ja,iJcb->iabc', u.ph, u.pphh) @@ -283,22 +273,16 @@ def ampl_relaxed_dms_cvs_adc2x(exci): g2a.ovov = 1.0 * ( - einsum("iKbc,jKac->iajb", u.pphh, u.pphh) - #- einsum("iKcb,jKca->iajb", u.pphh, u.pphh) + einsum("iKcb,jKac->iajb", u.pphh, u.pphh) - #+ einsum("iKbc,jKca->iajb", u.pphh, u.pphh) ) - - g2a.ccvv = -t2ccvv - - g2a.ocvv = -t2ocvv + g2a.ccvv = - 1.0 * t2ccvv + g2a.ocvv = - 1.0 * t2ocvv g2a.ococ = 1.0 * einsum("iJab,kLab->iJkL", u.pphh, u.pphh) - g2a.vvvv = 2.0 * einsum("iJcd,iJab->abcd", u.pphh, u.pphh) - # These are the OC multipliers: g1a.co = ( - - 1.0 * einsum('JbKc,ibKc->Ji', g2a.cvcv, hf.ovcv) + - 1.0 * einsum('JbKc,ibKc->Ji', g2a.cvcv, hf.ovcv) - 0.5 * einsum('JKab,iKab->Ji', g2a.ccvv, hf.ocvv) + 1.0 * einsum('kJLa,ikLa->Ji', g2a.occv, hf.oocv) + 0.5 * einsum('kJab,ikab->Ji', g2a.ocvv, hf.oovv) @@ -307,7 +291,7 @@ def ampl_relaxed_dms_cvs_adc2x(exci): + 0.5 * einsum('iKab,JKab->Ji', g2a.ocvv, hf.ccvv) - 0.5 * einsum('ikab,kJab->Ji', g2a.oovv, hf.ocvv) + 0.5 * einsum('iabc,Jabc->Ji', g2a.ovvv, hf.cvvv) - + 1.0 * einsum('kJmL,ikmL->Ji', g2a.ococ, hf.oooc) + + 1.0 * einsum('kJmL,ikmL->Ji', g2a.ococ, hf.oooc) - 1.0 * einsum('iKlM,JKMl->Ji', g2a.ococ, hf.ccco) + 1.0 * einsum('iakb,kbJa->Ji', g2a.ovov, hf.ovcv) ) / fco @@ -369,7 +353,7 @@ def ampl_relaxed_dms_mp2(mp): "cvs-adc0": ampl_relaxed_dms_cvs_adc0, "cvs-adc1": ampl_relaxed_dms_cvs_adc1, "cvs-adc2": ampl_relaxed_dms_cvs_adc2, - "cvs-adc2x": ampl_relaxed_dms_cvs_adc2x, + "cvs-adc2x": ampl_relaxed_dms_cvs_adc2x, } diff --git a/adcc/gradients/orbital_response.py b/adcc/gradients/orbital_response.py index b7dbd0091..d9342d2b6 100644 --- a/adcc/gradients/orbital_response.py +++ b/adcc/gradients/orbital_response.py @@ -22,12 +22,8 @@ ## --------------------------------------------------------------------- import adcc.block as b from adcc.OneParticleOperator import OneParticleOperator -from adcc.functions import direct_sum, einsum, evaluate, zeros_like - -from adcc.Tensor import Tensor +from adcc.functions import direct_sum, einsum, evaluate from adcc.AmplitudeVector import AmplitudeVector -import numpy as np - from adcc.solver.conjugate_gradient import conjugate_gradient, default_print @@ -39,30 +35,27 @@ def orbital_response_rhs(hf, g1a, g2a): # TODO: only add non-zero blocks to equations! if hf.has_core_occupied_space: - # IB: regular adc has three additional terms that do not appear in cvs-adc: - # (hf.ooov, g2a.ooov); (hf.ovov, g2a.ooov); (hf.oovv, g2a.ooov); - # for all common terms, the pre-factors are the same. ret_ov = -1.0 * ( + 2.0 * einsum("JiKa,JK->ia", hf.cocv, g1a.cc) + 2.0 * einsum("icab,bc->ia", hf.ovvv, g1a.vv) + 2.0 * einsum('kija,jk->ia', hf.ooov, g1a.oo) + 2.0 * einsum("kiJa,Jk->ia", hf.oocv, g1a.co) - 2.0 * einsum("iJka,Jk->ia", hf.ocov, g1a.co) - + 2.0 * einsum ("iJKb,JaKb->ia", hf.occv, g2a.cvcv) # 2PDMs start + + 2.0 * einsum("iJKb,JaKb->ia", hf.occv, g2a.cvcv) # 2PDMs start + 2.0 * einsum('lKJa,lKiJ->ia', g2a.occv, hf.ococ) - + 1.0 * einsum('jabc,ijbc->ia', g2a.ovvv, hf.oovv) + + 1.0 * einsum('jabc,ijbc->ia', g2a.ovvv, hf.oovv) - 1.0 * einsum('JKab,JKib->ia', g2a.ccvv, hf.ccov) - 2.0 * einsum('jKab,jKib->ia', g2a.ocvv, hf.ocov) - - 1.0 * einsum('jkab,jkib->ia', g2a.oovv, hf.ooov) + - 1.0 * einsum('jkab,jkib->ia', g2a.oovv, hf.ooov) - 2.0 * einsum('jcab,ibjc->ia', g2a.ovvv, hf.ovov) - 2.0 * einsum('iJKb,JaKb->ia', g2a.occv, hf.cvcv) - 1.0 * einsum('iJbc,Jabc->ia', g2a.ocvv, hf.cvvv) - 1.0 * einsum('ijbc,jabc->ia', g2a.oovv, hf.ovvv) + 1.0 * einsum('ibcd,abcd->ia', g2a.ovvv, hf.vvvv) - - 1.0 * einsum('abcd,ibcd->ia', g2a.vvvv, hf.ovvv) # cvs-adc2x - + 2.0 * einsum('jakb,ijkb->ia', g2a.ovov, hf.ooov) # cvs-adc2x - + 2.0 * einsum('ibjc,jcab->ia', g2a.ovov, hf.ovvv) # cvs-adc2x - - 2.0 * einsum('iJkL,kLJa->ia', g2a.ococ, hf.occv) # cvs-adc2x + - 1.0 * einsum('abcd,ibcd->ia', g2a.vvvv, hf.ovvv) # cvs-adc2x + + 2.0 * einsum('jakb,ijkb->ia', g2a.ovov, hf.ooov) # cvs-adc2x + + 2.0 * einsum('ibjc,jcab->ia', g2a.ovov, hf.ovvv) # cvs-adc2x + - 2.0 * einsum('iJkL,kLJa->ia', g2a.ococ, hf.occv) # cvs-adc2x ) ret_cv = -1.0 * ( @@ -71,7 +64,7 @@ def orbital_response_rhs(hf, g1a, g2a): + 2.0 * einsum('kIja,jk->Ia', hf.ocov, g1a.oo) + 2.0 * einsum("kIJa,Jk->Ia", hf.occv, g1a.co) + 2.0 * einsum("JIka,Jk->Ia", hf.ccov, g1a.co) - + 2.0 * einsum("IJKb,JaKb->Ia", hf.cccv, g2a.cvcv) # 2PDMs start + + 2.0 * einsum("IJKb,JaKb->Ia", hf.cccv, g2a.cvcv) # 2PDMs start + 2.0 * einsum("Jcab,IbJc->Ia", hf.cvvv, g2a.cvcv) + 2.0 * einsum('lKJa,lKIJ->Ia', g2a.occv, hf.occc) - 1.0 * einsum('jabc,jIbc->Ia', g2a.ovvv, hf.ocvv) @@ -83,18 +76,16 @@ def orbital_response_rhs(hf, g1a, g2a): + 2.0 * einsum('jIKb,jaKb->Ia', g2a.occv, hf.ovcv) + 1.0 * einsum('jIbc,jabc->Ia', g2a.ocvv, hf.ovvv) + 2.0 * einsum('kJIb,kJab->Ia', g2a.occv, hf.ocvv) - - 1.0 * einsum('abcd,Ibcd->Ia', g2a.vvvv, hf.cvvv) # cvs-adc2x - - 2.0 * einsum('jakb,jIkb->Ia', g2a.ovov, hf.ocov) # cvs-adc2x - - 2.0 * einsum('jIlK,lKja->Ia', g2a.ococ, hf.ocov) # cvs-adc2x + - 1.0 * einsum('abcd,Ibcd->Ia', g2a.vvvv, hf.cvvv) # cvs-adc2x + - 2.0 * einsum('jakb,jIkb->Ia', g2a.ovov, hf.ocov) # cvs-adc2x + - 2.0 * einsum('jIlK,lKja->Ia', g2a.ococ, hf.ocov) # cvs-adc2x ) - ret = AmplitudeVector(cv=ret_cv, ov=ret_ov) - else: # equal to the ov block of the energy-weighted density # matrix when lambda_ov multipliers are zero w_ov = 0.5 * ( - + 1.0 * einsum("ijkl,klja->ia", hf.oooo, g2a.ooov) # not in cvs-adc + + 1.0 * einsum("ijkl,klja->ia", hf.oooo, g2a.ooov) # not in cvs-adc # - 1.0 * einsum("ibcd,abcd->ia", hf.ovvv, g2a.vvvv) - 1.0 * einsum("jkib,jkab->ia", hf.ooov, g2a.oovv) + 2.0 * einsum("ijkb,jakb->ia", hf.ooov, g2a.ovov) @@ -102,20 +93,18 @@ def orbital_response_rhs(hf, g1a, g2a): - 2.0 * einsum("ibjc,jcab->ia", hf.ovov, g2a.ovvv) ) w_ov = w_ov.evaluate() - + ret_ov = -1.0 * ( 2.0 * w_ov # - 1.0 * einsum("klja,ijkl->ia", hf.ooov, g2a.oooo) + 1.0 * einsum("abcd,ibcd->ia", hf.vvvv, g2a.ovvv) - - 2.0 * einsum("jakb,ijkb->ia", hf.ovov, g2a.ooov) # not in cvs-adc - + 1.0 * einsum("jkab,jkib->ia", hf.oovv, g2a.ooov) # not in cvs-adc + - 2.0 * einsum("jakb,ijkb->ia", hf.ovov, g2a.ooov) # not in cvs-adc + + 1.0 * einsum("jkab,jkib->ia", hf.oovv, g2a.ooov) # not in cvs-adc + 2.0 * einsum("jcab,ibjc->ia", hf.ovvv, g2a.ovov) - 1.0 * einsum("jabc,ijbc->ia", hf.ovvv, g2a.oovv) + 2.0 * einsum("jika,jk->ia", hf.ooov, g1a.oo) + 2.0 * einsum("icab,bc->ia", hf.ovvv, g1a.vv) ) - - # IB: changed to AmplitudeVector here. ret = AmplitudeVector(ov=ret_ov) return ret @@ -126,10 +115,10 @@ def energy_weighted_density_matrix(hf, g1o, g2a): # CVS-ADC0, CVS-ADC1, CVS-ADC2 w = OneParticleOperator(hf) w.cc = - 0.5 * ( - einsum("JKab,IKab->IJ", g2a.ccvv, hf.ccvv) + + einsum("JKab,IKab->IJ", g2a.ccvv, hf.ccvv) + einsum("kJab,kIab->IJ", g2a.ocvv, hf.ocvv) ) - w.cc += ( + w.cc += ( - hf.fcc - einsum("IK,JK->IJ", g1o.cc, hf.fcc) - einsum("ab,IaJb->IJ", g1o.vv, hf.cvcv) @@ -144,16 +133,16 @@ def energy_weighted_density_matrix(hf, g1o, g2a): - einsum("JbKc,IbKc->IJ", g2a.cvcv, hf.cvcv) - einsum("kJLa,kILa->IJ", g2a.occv, hf.occv) - einsum("kLJa,kLIa->IJ", g2a.occv, hf.occv) - - einsum("kJmL,kImL->IJ", g2a.ococ, hf.ococ) # cvs-adc2x + - einsum("kJmL,kImL->IJ", g2a.ococ, hf.ococ) # cvs-adc2x ) w.oo = - 0.5 * ( - einsum("jKab,iKab->ij", g2a.ocvv, hf.ocvv) + + einsum("jKab,iKab->ij", g2a.ocvv, hf.ocvv) + einsum("jkab,ikab->ij", g2a.oovv, hf.oovv) + einsum("jabc,iabc->ij", g2a.ovvv, hf.ovvv) ) w.oo += ( - hf.foo - - einsum("ij,ii->ij", g1o.oo, hf.foo) # + - einsum("ij,ii->ij", g1o.oo, hf.foo) - einsum("KL,iKjL->ij", g1o.cc, hf.ococ) - einsum("ab,iajb->ij", g1o.vv, hf.ovov) - einsum("kl,ikjl->ij", g1o.oo, hf.oooo) @@ -164,14 +153,14 @@ def energy_weighted_density_matrix(hf, g1o, g2a): + einsum("Lk,kijL->ij", g1o.co, hf.oooc) + einsum("Lk,kjiL->ij", g1o.co, hf.oooc) - einsum("jKLa,iKLa->ij", g2a.occv, hf.occv) - - einsum("jKlM,iKlM->ij", g2a.ococ, hf.ococ) # cvs-adc2x - - einsum("jakb,iakb->ij", g2a.ovov, hf.ovov) # cvs-adc2x + - einsum("jKlM,iKlM->ij", g2a.ococ, hf.ococ) # cvs-adc2x + - einsum("jakb,iakb->ij", g2a.ovov, hf.ovov) # cvs-adc2x ) w.vv = - 0.5 * ( - einsum("ibcd,iacd->ab", g2a.ovvv, hf.ovvv) + + einsum("ibcd,iacd->ab", g2a.ovvv, hf.ovvv) + einsum("IJbc,IJac->ab", g2a.ccvv, hf.ccvv) + einsum("ijbc,ijac->ab", g2a.oovv, hf.oovv) - + einsum("bcde,acde->ab", g2a.vvvv, hf.vvvv) # cvs-adc2x + + einsum("bcde,acde->ab", g2a.vvvv, hf.vvvv) # cvs-adc2x ) w.vv += ( - einsum("ac,cb->ab", g1o.vv, hf.fvv) @@ -179,14 +168,14 @@ def energy_weighted_density_matrix(hf, g1o, g2a): - einsum("jKIb,jKIa->ab", g2a.occv, hf.occv) - einsum("idbc,idac->ab", g2a.ovvv, hf.ovvv) - einsum("iJbc,iJac->ab", g2a.ocvv, hf.ocvv) - - einsum("ibjc,iajc->ab", g2a.ovov, hf.ovov) # cvs-adc2x + - einsum("ibjc,iajc->ab", g2a.ovov, hf.ovov) # cvs-adc2x ) w.co = 0.5 * ( - einsum("JKab,iKab->Ji", g2a.ccvv, hf.ocvv) + einsum("kJab,ikab->Ji", g2a.ocvv, hf.oovv) ) w.co += ( - einsum("KL,iKLJ->Ji", g1o.cc, hf.occc) + + einsum("KL,iKLJ->Ji", g1o.cc, hf.occc) - einsum("ab,iaJb->Ji", g1o.vv, hf.ovcv) - einsum("kl,kilJ->Ji", g1o.oo, hf.oooc) - einsum("Ka,iKJa->Ji", g1o.cv, hf.occv) @@ -197,15 +186,15 @@ def energy_weighted_density_matrix(hf, g1o, g2a): + einsum("Lk,iLkJ->Ji", g1o.co, hf.ococ) - einsum("Ik,jk->Ij", g1o.co, hf.foo) - einsum("JbKc,ibKc->Ji", g2a.cvcv, hf.ovcv) - + einsum("kJLa,ikLa->Ji", g2a.occv, hf.oocv) + + einsum("kJLa,ikLa->Ji", g2a.occv, hf.oocv) - einsum("kLJa,kLia->Ji", g2a.occv, hf.ocov) - + einsum("kJmL,ikmL->Ji", g2a.ococ, hf.oooc) # cvs-adc2x + + einsum("kJmL,ikmL->Ji", g2a.ococ, hf.oooc) # cvs-adc2x ) w.ov = 0.5 * ( - einsum("jabc,ijbc->ia", g2a.ovvv, hf.oovv) + + einsum("jabc,ijbc->ia", g2a.ovvv, hf.oovv) - einsum("JKab,JKib->ia", g2a.ccvv, hf.ccov) - einsum("jkab,jkib->ia", g2a.oovv, hf.ooov) - - einsum("abcd,ibcd->ia", g2a.vvvv, hf.ovvv) # cvs-adc2x + - einsum("abcd,ibcd->ia", g2a.vvvv, hf.ovvv) # cvs-adc2x ) w.ov += ( - einsum("ij,ja->ia", hf.foo, g1o.ov) @@ -213,13 +202,13 @@ def energy_weighted_density_matrix(hf, g1o, g2a): + einsum("kLJa,iJkL->ia", g2a.occv, hf.ococ) - einsum("jKab,jKib->ia", g2a.ocvv, hf.ocov) - einsum("jcab,ibjc->ia", g2a.ovvv, hf.ovov) - + einsum("jakb,ijkb->ia", g2a.ovov, hf.ooov) # cvs-adc2x + + einsum("jakb,ijkb->ia", g2a.ovov, hf.ooov) # cvs-adc2x ) w.cv = - 0.5 * ( - einsum("jabc,jIbc->Ia", g2a.ovvv, hf.ocvv) + + einsum("jabc,jIbc->Ia", g2a.ovvv, hf.ocvv) + einsum("JKab,JKIb->Ia", g2a.ccvv, hf.cccv) + einsum("jkab,jkIb->Ia", g2a.oovv, hf.oocv) - + einsum("abcd,Ibcd->Ia", g2a.vvvv, hf.cvvv) # cvs-adc2x + + einsum("abcd,Ibcd->Ia", g2a.vvvv, hf.cvvv) # cvs-adc2x ) w.cv += ( - einsum("IJ,Ja->Ia", hf.fcc, g1o.cv) @@ -227,7 +216,7 @@ def energy_weighted_density_matrix(hf, g1o, g2a): + einsum("lKJa,lKIJ->Ia", g2a.occv, hf.occc) - einsum("kJab,kJIb->Ia", g2a.ocvv, hf.occv) - einsum("jcab,jcIb->Ia", g2a.ovvv, hf.ovcv) - - einsum("jakb,jIkb->Ia", g2a.ovov, hf.ocov) # cvs-adc2x + - einsum("jakb,jIkb->Ia", g2a.ovov, hf.ocov) # cvs-adc2x ) else: gi_oo = -0.5 * ( @@ -283,39 +272,35 @@ def shape(self): size = no1 * nv1 return (size, size) - def __matmul__(self, l): - - # Terms common to adc and cvs-adc + def __matmul__(self, lam): ret_ov = ( - + einsum("ab,ib->ia", self.hf.fvv, l.ov) - - einsum("ij,ja->ia", self.hf.foo, l.ov) - + einsum("ijab,jb->ia", self.hf.oovv, l.ov) - - einsum("ibja,jb->ia", self.hf.ovov, l.ov) + + einsum("ab,ib->ia", self.hf.fvv, lam.ov) + - einsum("ij,ja->ia", self.hf.foo, lam.ov) + + einsum("ijab,jb->ia", self.hf.oovv, lam.ov) + - einsum("ibja,jb->ia", self.hf.ovov, lam.ov) ) if self.hf.has_core_occupied_space: - # Additional terms for cvs-adc ret_ov += ( - + einsum("iJab,Jb->ia", self.hf.ocvv, l.cv) - - einsum("ibJa,Jb->ia", self.hf.ovcv, l.cv) + + einsum("iJab,Jb->ia", self.hf.ocvv, lam.cv) + - einsum("ibJa,Jb->ia", self.hf.ovcv, lam.cv) ) ret_cv = ( - + einsum("ab,Ib->Ia", self.hf.fvv, l.cv) - - einsum("IJ,Ja->Ia", self.hf.fcc, l.cv) - + einsum("IJab,Jb->Ia", self.hf.ccvv, l.cv) - - einsum("IbJa,Jb->Ia", self.hf.cvcv, l.cv) - + einsum("Ijab,jb->Ia", self.hf.covv, l.ov) - - einsum("Ibja,jb->Ia", self.hf.cvov, l.ov) + + einsum("ab,Ib->Ia", self.hf.fvv, lam.cv) + - einsum("IJ,Ja->Ia", self.hf.fcc, lam.cv) + + einsum("IJab,Jb->Ia", self.hf.ccvv, lam.cv) + - einsum("IbJa,Jb->Ia", self.hf.cvcv, lam.cv) + + einsum("Ijab,jb->Ia", self.hf.covv, lam.ov) + - einsum("Ibja,jb->Ia", self.hf.cvov, lam.ov) ) ret = AmplitudeVector(cv=ret_cv, ov=ret_ov) else: - # IB: changed to AmplitudeVector here. ret = AmplitudeVector(ov=ret_ov) # TODO: generalize once other solvent methods are available if self.hf.environment == "pe": # PE contribution to the orbital Hessian ops = self.hf.operators dm = OneParticleOperator(self.hf, is_symmetric=True) - dm.ov = l_ov + dm.ov = lam.ov ret += ops.pe_induction_elec(dm).ov return evaluate(ret) @@ -326,16 +311,15 @@ def __init__(self, hf): # Terms common to adc and cvs-adc fo = hf.fock(b.oo).diagonal() fv = hf.fock(b.vv).diagonal() - fov = direct_sum("-i+a->ia", fo, fv).evaluate() + fov = direct_sum("-i+a->ia", fo, fv) if hf.has_core_occupied_space: - # Additional terms for cvs-adc fc = hf.fock(b.cc).diagonal() - fcv = direct_sum("-I+a->Ia", fc, fv).evaluate() + fcv = direct_sum("-I+a->Ia", fc, fv) self.df = AmplitudeVector(cv=fcv, ov=fov) - else: - # IB: changed to AmplitudeVector here + else: self.df = AmplitudeVector(ov=fov) + self.df.evaluate() @property def shape(self): @@ -359,7 +343,7 @@ def orbital_response(hf, rhs): A = OrbitalResponseMatrix(hf) Pinv = OrbitalResponsePinv(hf) x0 = (Pinv @ rhs).evaluate() - l = conjugate_gradient(A, rhs=rhs, x0=x0, Pinv=Pinv, - explicit_symmetrisation=None, - callback=default_print) - return l.solution + lam = conjugate_gradient(A, rhs=rhs, x0=x0, Pinv=Pinv, + explicit_symmetrisation=None, + callback=default_print) + return lam.solution diff --git a/adcc/gradients/test_functionality_gradients.py b/adcc/gradients/test_functionality_gradients.py index 28763e540..80dfeeb77 100644 --- a/adcc/gradients/test_functionality_gradients.py +++ b/adcc/gradients/test_functionality_gradients.py @@ -22,7 +22,6 @@ ## --------------------------------------------------------------------- import unittest import itertools -import numpy as np import adcc import adcc.backends @@ -53,7 +52,7 @@ def template_nuclear_gradient(self, molecule, basis, method, backend): grad_ref = gradient_data[molecule][basis][method] energy_ref = grad_ref["energy"] - grad_fdiff = grad_ref["gradient"] + grad_fdiff = grad_ref["gradient"] kwargs = grad_ref["config"] conv_tol = kwargs["conv_tol"] @@ -61,12 +60,13 @@ def template_nuclear_gradient(self, molecule, basis, method, backend): if "adc" in method: # TODO: convergence needs to be very very tight... # so we want to make sure all vectors are tightly converged - n_limit = 2 # kwargs["n_singlets"] + n_limit = 2 # kwargs["n_singlets"] kwargs["n_singlets"] = kwargs["n_singlets"] + 2 state = adcc.run_adc(scfres, method=method, **kwargs) for ee in state.excitations[:n_limit]: grad = adcc.nuclear_gradient(ee) - assert_allclose(energy_ref[ee.index], ee.total_energy, atol=conv_tol) + assert_allclose(energy_ref[ee.index], ee.total_energy, + atol=conv_tol) assert_allclose( grad_fdiff[ee.index], grad["Total"], atol=1e-7, err_msg=f'Gradient for state {ee.index} wrong.' diff --git a/adcc/testdata/dump_fdiff_gradient.py b/adcc/testdata/dump_fdiff_gradient.py index c4f996c63..6c17a1155 100644 --- a/adcc/testdata/dump_fdiff_gradient.py +++ b/adcc/testdata/dump_fdiff_gradient.py @@ -20,7 +20,6 @@ ## along with adcc. If not, see . ## ## --------------------------------------------------------------------- -from collections import namedtuple import itertools import adcc import numpy as np @@ -37,8 +36,9 @@ # prefactors_5p = np.array([1.0, -8.0, 8.0, -1.0]) / 12.0 # multipliers_5p = [-2, -1, 1, 2] -prefactors_9p = [1./280., -4./105., 1./5., -4./5., 4./5., -1./5., 4./105., -1./280.] -multipliers_9p = [-4., -3., -2., -1., 1., 2., 3., 4.] +prefactors_9p = [1. / 280., -4. / 105., 1. / 5., -4. / 5., + 4. / 5., -1. / 5., 4. / 105., -1. / 280.] +multipliers_9p = [-4., -3., - 2., -1., 1., 2., 3., 4.] coords_label = ["x", "y", "z"] diff --git a/adcc/testdata/static_data.py b/adcc/testdata/static_data.py index d24988399..fd1a7acd9 100644 --- a/adcc/testdata/static_data.py +++ b/adcc/testdata/static_data.py @@ -30,7 +30,7 @@ class Molecule: charge: int = 0 multiplicity: int = 1 core_orbitals: int = 1 - + @property def xyz(self): return xyz[self.name] From 8fccd861989dd7d5179c57f0595aa9d271e19996 Mon Sep 17 00:00:00 2001 From: Maximilian Scheurer Date: Thu, 16 Dec 2021 20:13:29 +0100 Subject: [PATCH 09/18] all molecules hate me, just h2o for now --- .../gradients/test_functionality_gradients.py | 9 +- adcc/testdata/dump_fdiff_gradient.py | 51 +- adcc/testdata/grad_dump.yml | 1178 +++++------------ 3 files changed, 408 insertions(+), 830 deletions(-) diff --git a/adcc/gradients/test_functionality_gradients.py b/adcc/gradients/test_functionality_gradients.py index 80dfeeb77..8b014fec9 100644 --- a/adcc/gradients/test_functionality_gradients.py +++ b/adcc/gradients/test_functionality_gradients.py @@ -56,12 +56,19 @@ def template_nuclear_gradient(self, molecule, basis, method, backend): kwargs = grad_ref["config"] conv_tol = kwargs["conv_tol"] - scfres = cached_backend_hf(backend, molecule, basis, conv_tol=1e-13) + # scfres = cached_backend_hf(backend, molecule, basis, conv_tol=1e-13) + + scfres = adcc.backends.run_hf( + backend, gradient_data[molecule]["xyz"], basis, conv_tol=1e-13, + conv_tol_grad=1e-12, max_iter=500 + # charge=molecule.charge, multiplicity=molecule.multiplicity + ) if "adc" in method: # TODO: convergence needs to be very very tight... # so we want to make sure all vectors are tightly converged n_limit = 2 # kwargs["n_singlets"] kwargs["n_singlets"] = kwargs["n_singlets"] + 2 + # kwargs["n_triplets"] = kwargs["n_triplets"] + 5 state = adcc.run_adc(scfres, method=method, **kwargs) for ee in state.excitations[:n_limit]: grad = adcc.nuclear_gradient(ee) diff --git a/adcc/testdata/dump_fdiff_gradient.py b/adcc/testdata/dump_fdiff_gradient.py index 6c17a1155..074fe5ba0 100644 --- a/adcc/testdata/dump_fdiff_gradient.py +++ b/adcc/testdata/dump_fdiff_gradient.py @@ -20,6 +20,7 @@ ## along with adcc. If not, see . ## ## --------------------------------------------------------------------- +from dataclasses import dataclass import itertools import adcc import numpy as np @@ -28,20 +29,44 @@ from pyscf import gto, lib -from static_data import molecules - adcc.set_n_threads(8) lib.num_threads(8) -# prefactors_5p = np.array([1.0, -8.0, 8.0, -1.0]) / 12.0 -# multipliers_5p = [-2, -1, 1, 2] -prefactors_9p = [1. / 280., -4. / 105., 1. / 5., -4. / 5., - 4. / 5., -1. / 5., 4. / 105., -1. / 280.] -multipliers_9p = [-4., -3., - 2., -1., 1., 2., 3., 4.] +prefactors_5p = np.array([1.0, -8.0, 8.0, -1.0]) / 12.0 +multipliers_5p = [-2, -1, 1, 2] +# prefactors_9p = [1. / 280., -4. / 105., 1. / 5., -4. / 5., +# 4. / 5., -1. / 5., 4. / 105., -1. / 280.] +# multipliers_9p = [-4., -3., - 2., -1., 1., 2., 3., 4.] coords_label = ["x", "y", "z"] +@dataclass +class Molecule: + name: str + charge: int = 0 + multiplicity: int = 1 + core_orbitals: int = 1 + + @property + def xyz(self): + return xyz[self.name] + + +molecules = [ + Molecule("h2o", 0, 1), +] + +# all coordinates in Bohr (perturbed) +xyz = { + "h2o": """ + O 0 0 0 + H 0 0 1.895239827225189 + H 1.693194615993441 0 -0.599043184453037 + """, +} + + def _molstring(elems, coords): s = "" for kk, (i, c) in enumerate(zip(elems, coords)): @@ -88,13 +113,15 @@ def fdiff_gradient(molecule, method, basis, step=1e-4, **kwargs): grad = np.zeros((ngrad, natoms, 3)) at_c = list(itertools.product(range(natoms), range(3))) for i, c in tqdm(at_c): - for f, p in zip(multipliers_9p, prefactors_9p): + for f, p in zip(multipliers_5p, prefactors_5p): coords_p = coords.copy() coords_p[i, c] += f * step geom_p = _molstring(elements, coords_p) scfres = adcc.backends.run_hf( - 'pyscf', geom_p, basis, conv_tol=conv_tol, conv_tol_grad=conv_tol, - charge=molecule.charge, multiplicity=molecule.multiplicity + 'pyscf', geom_p, basis, conv_tol=conv_tol, + conv_tol_grad=conv_tol * 10, + charge=molecule.charge, multiplicity=molecule.multiplicity, + max_iter=500, ) if "adc" in method: en_pert = adc_energy(scfres, method, **kwargs) @@ -117,11 +144,10 @@ def main(): "cvs-adc0", "cvs-adc1", "cvs-adc2", - # "cvs-adc2x", + # "cvs-adc2x", # TODO: broken ] molnames = [ "h2o", - "h2s", ] mols = [m for m in molecules if m.name in molnames] ret = { @@ -157,6 +183,7 @@ def main(): "config": kwargs, } ret[molname][basis][method] = cont + ret[molname]["xyz"] = molecule.xyz with open("grad_dump.yml", "w") as yamlout: yaml.safe_dump(ret, yamlout) diff --git a/adcc/testdata/grad_dump.yml b/adcc/testdata/grad_dump.yml index f7f22b0a2..2ec9022ab 100644 --- a/adcc/testdata/grad_dump.yml +++ b/adcc/testdata/grad_dump.yml @@ -9,694 +9,237 @@ h2o: core_orbitals: null n_singlets: 3 energy: - - -75.34687593732811 - - -75.28099897302941 - - -75.27790714502403 + - -75.35063054725846 + - -75.28783279385523 + - -75.28001423026011 gradient: - - - - 0.05781772689988429 - - -6.14363671047613e-10 - - 0.0412469571820111 - - - -0.0010630944025251665 - - 4.965841071680188e-10 - - -0.060199276416369685 - - - -0.056754632418687834 - - -5.188667273614556e-10 - - 0.018952317754155956 - - - - 0.01311645154009966 - - -6.630216375924647e-10 - - 0.009581871548107301 - - - 0.05172148960400591 - - 2.2282620193436742e-10 - - -0.08735981985000763 - - - -0.06483794088308059 - - -1.6189005691558123e-10 - - 0.07777794693947726 - - - - 0.03587021910561816 - - -6.070877134334296e-10 - - 0.025914352325344225 - - - 0.007818774688075791 - - 3.424247552175075e-10 - - -0.04966127915349716 - - - -0.043688994054264185 - - -3.1468516681343317e-10 - - 0.023746925161503896 - adc1: - config: - conv_tol: 1.0e-10 - core_orbitals: null - n_singlets: 3 - energy: - - -75.68543998437548 - - -75.61931016176952 - - -75.59868950258502 - gradient: - - - - 0.09274009261753235 - - -3.283275873400271e-10 - - 0.06558011171182443 - - - -0.002630220946684858 - - 5.6843418860808015e-11 - - -0.09467176255839149 - - - -0.09010987054125508 - - -4.3519321479834616e-10 - - 0.029091648981648177 - - - - 0.10931799067202519 - - -2.455635694786906e-10 - - 0.07809554580808253 - - - -0.0066607078210836335 - - -1.000444171950221e-11 - - -0.10735300815713344 - - - -0.102657282302971 - - -4.197318048682064e-10 - - 0.029257460409098712 - - - - 0.011670265368593391 - - -1.1732481652870774e-10 - - 0.008451193038126803 - - - 0.056844835021365725 - - -3.501554601825774e-11 - - -0.09296221982503994 - - - -0.0685150996455377 - - -1.268745108973235e-10 - - 0.08451102455637738 - adc2: - config: - conv_tol: 1.0e-10 - core_orbitals: null - n_singlets: 3 - energy: - - -75.92967540826557 - - -75.8549979011574 - - -75.84309170418113 - gradient: - - - - 0.11448501872291672 - - -1.1223164619877934e-09 - - 0.08113867664314967 - - - -0.008900642837943451 - - -6.416485121008009e-10 - - -0.1090567956907762 - - - -0.1055843749622909 - - -4.324647306930274e-10 - - 0.02791811763563601 - - - - 0.11318148765349179 - - -1.2523742043413222e-09 - - 0.08065584009500526 - - - -0.004472615006761771 - - -8.126335160341114e-10 - - -0.1143742844665212 - - - -0.10870887149940245 - - -4.1382008930668235e-10 - - 0.033718443040925195 - - - - 0.022055652611925325 - - -1.0786607163026929e-09 - - 0.015903128517948062 - - - 0.0509841249809142 - - -1.0136318451259285e-09 - - -0.09580103724010769 - - - -0.0730397764305053 - - -2.97859514830634e-10 - - 0.0798979071209942 - cvs-adc0: - config: - conv_tol: 1.0e-10 - core_orbitals: 1 - n_singlets: 3 - energy: - - -55.29234315857766 - - -55.22337436627359 - - -54.66716620632244 - gradient: - - - - -0.013647945610046008 - - 2.078195393551141e-10 - - -0.009335994141338233 - - - 0.00570650654617566 - - -2.0395418687257916e-10 - - 0.006095206725376556 - - - 0.007941438532270695 - - -7.580638339277357e-10 - - 0.00324078498556446 - - - - -0.035595453415908196 - - 1.680291461525485e-10 - - -0.024668598871357972 - - - 0.0145883755540126 - - -2.6284396881237626e-10 - - 0.016633203791798223 - - - 0.021007076980367856 - - -7.032667781459168e-10 - - 0.008035392225338 - - - - 0.2956047727548139 - - 2.589786163298413e-10 - - 0.20220451008071905 - - - -0.11422410300747288 - - -3.9904080040287226e-10 - - -0.14526787512227202 - - - -0.18138067044901618 - - -7.826201908756047e-10 - - -0.056936637569378945 - cvs-adc1: - config: - conv_tol: 1.0e-10 - core_orbitals: 1 - n_singlets: 3 - energy: - - -55.76235801206998 - - -55.74423117768519 - - -55.238855751295425 - gradient: - - - - 0.11375777869693593 - - -7.519247446907684e-10 - - 0.0750635761171452 - - - -0.006232491267837759 - - -7.480593922082335e-10 - - -0.10649733538957662 - - - -0.10752528617581447 - - -1.5120349416974932e-10 - - 0.031433756529395396 - - - - 0.13675109445330236 - - -6.536993168992922e-10 - - 0.10287793852785398 - - - -0.01013374691115132 - - -7.294147508218884e-10 - - -0.13692999088675606 - - - -0.126617346219291 - - -1.3164935808163136e-10 - - 0.034052049356205316 - - - - -0.03586818460098584 - - -6.737082003382966e-10 - - -0.025053269779391485 - - - 0.028073503252926457 - - -6.759819370927289e-10 - - -0.001954445516503256 - - - 0.007794682884650683 - - -2.2646418074145913e-10 - - 0.027007712356862612 - cvs-adc2: - config: - conv_tol: 1.0e-10 - core_orbitals: 1 - n_singlets: 3 - energy: - - -56.46332440074828 - - -56.39198974450136 - - -55.93190966430338 - gradient: - - - - 0.06425007316829578 - - -6.546088116010651e-10 - - 0.045520457711972995 - - - -0.0016864032024841435 - - 1.2848886399297044e-09 - - -0.0658671106048132 - - - -0.06256367150149345 - - -1.296257323701866e-09 - - 0.020346652008356614 - - - - 0.05899445178715723 - - 1.1323209037072957e-10 - - 0.042361969631201646 - - - 0.005970589055777964 - - -1.0822986951097846e-10 - - -0.07167667811427236 - - - -0.06496504189567531 - - -2.6852831069845706e-10 - - 0.029314707067442214 - - - - 0.26677660641166767 - - 2.5056579033844173e-10 - - 0.18210555948439833 - - - -0.08747911854334234 - - 2.1032064978498966e-10 - - -0.1527887531271972 - - - -0.1792974891011454 - - -1.1978045222349465e-09 - - -0.029316808301246056 - mp2: - config: - conv_tol: 1.0e-10 - core_orbitals: null - energy: -76.22940338787343 - gradient: - - - 0.024395445243044378 - - -9.968061931431293e-10 - - 0.017738172225563176 - - - -0.010762448608602426 - - 4.019966581836343e-10 - - -0.011150372518386575 - - - -0.013632995088300959 - - -8.858478395268321e-10 - - -0.006587800284705736 - sto3g: - adc0: - config: - conv_tol: 1.0e-10 - core_orbitals: null - n_singlets: 3 - energy: - - -73.96883482604385 - - -73.91481187944893 - - -73.80575589478214 - gradient: - - - - 0.21500520481276908 - - -1.3642420526593924e-12 - - 0.15122539417507141 - - - 0.07489849383546243 - - -8.913048077374697e-11 - - -0.33320423490431494 - - - -0.28990369770372126 - - -1.3005774235352874e-10 - - 0.1819788405964573 - - - - 0.15869260451790979 - - -1.405169314239174e-10 - - 0.11135792756476803 - - - 0.12612935250444934 - - -1.0231815394945443e-10 - - -0.3458573076572975 - - - -0.28482195575770675 - - -2.6057023205794394e-10 - - 0.23449938025396477 - - - - 0.4883978155476143 - - -1.6962076188065112e-10 - - 0.3478099743133498 - - - -0.09521430238692119 - - -2.7830537874251604e-10 - - -0.3859635301491835 - - - -0.3931835123325982 - - -2.1782398107461631e-10 - - 0.03815355588812963 + - - - 0.05046730256435694 + - -4.5838532969355583e-10 + - 0.0004982366954209283 + - - -8.651019015815109e-06 + - 4.43833414465189e-10 + - -0.018340554343012627 + - - -0.05045865162537666 + - -3.41970007866621e-10 + - 0.01784231651254231 + - - - 0.007736270476016216 + - -3.8562575355172157e-10 + - -0.021003243469749577 + - - 0.048326121126592625 + - 3.2741809263825417e-10 + - -0.05292410230322275 + - - -0.05606239176267991 + - -4.220055416226387e-10 + - 0.07392734468885465 + - - - 0.044726615720719565 + - -2.4010660126805305e-10 + - -0.028378672250255477 + - - 0.005378048605052754 + - 2.837623469531536e-10 + - 0.004632110983948223 + - - -0.05010466407838976 + - -5.602487362921238e-10 + - 0.02374656030588085 adc1: config: conv_tol: 1.0e-10 core_orbitals: null n_singlets: 3 energy: - - -74.47588319597364 - - -74.38511885048031 - - -74.35718229209286 + - -75.69395238588608 + - -75.62635897551161 + - -75.60639603502825 gradient: - - - - 0.25195657597942045 - - -4.092726157978177e-11 - - 0.17643765260208966 - - - 0.04383796624188108 - - 3.751665644813329e-10 - - -0.32756816145820267 - - - -0.29579454043232545 - - -1.0732037480920553e-10 - - 0.1511305100257232 - - - - 0.4420401994848362 - - 6.048139766789973e-11 - - 0.3159731246355477 - - - -0.08205663838316468 - - 6.029949872754514e-10 - - -0.3563313624399598 - - - -0.35998355975470986 - - -2.432898327242583e-10 - - 0.04035823856474963 - - - - 0.10246272940094059 - - -1.5916157281026244e-11 - - 0.07140888797584921 - - - 0.1196453034563092 - - 4.761204763781279e-10 - - -0.27684558784130786 - - - -0.22210803133657464 - - -1.8189894035458565e-12 - - 0.2054367008108784 + - - - 0.06758801428804873 + - 4.656612873077393e-10 + - 0.05835227884381311 + - - -0.0020313086570240557 + - 2.6193447411060333e-10 + - -0.07927219069824787 + - - -0.06555670616216958 + - -1.0186340659856796e-10 + - 0.020919911308737937 + - - - 0.13667167851963313 + - 5.238689482212067e-10 + - 4.4900531065650284e-05 + - - -0.008910664379072841 + - 4.2928149923682213e-10 + - -0.035272109365905635 + - - -0.12776101467898116 + - -2.255546860396862e-10 + - 0.03522720833279891 + - - - -0.000668360160489101 + - 5.529727786779404e-10 + - -0.014254975270887371 + - - 0.05361728476418648 + - 2.9831426218152046e-10 + - -0.06449338974198326 + - - -0.05294892523670569 + - -1.1641532182693481e-10 + - 0.07874836452538148 adc2: config: conv_tol: 1.0e-10 core_orbitals: null n_singlets: 3 energy: - - -74.52306494758527 - - -74.42102314285333 - - -74.39990473420056 + - -75.93894077453284 + - -75.8633202993817 + - -75.85064756673245 gradient: - - - - 0.27296630337423267 - - 1.7325874068774283e-10 - - 0.1915359971962971 - - - 0.04375171526680788 - - -1.0732037480920553e-10 - - -0.349977671054603 - - - -0.31671801721586235 - - 3.660716174636036e-10 - - 0.15844167483191995 - - - - 0.466111445576189 - - 1.1050360626541078e-10 - - 0.332718358177317 - - - -0.08526563836221612 - - -1.368789526168257e-10 - - -0.37705514723074884 - - - -0.380845806076195 - - 3.460627340245992e-10 - - 0.04433679012072389 - - - - 0.12454020971290447 - - 1.418811734765768e-10 - - 0.0870925107756193 - - - 0.11524763849593 - - -2.269189280923456e-10 - - -0.294121532416284 - - - -0.23978784721248303 - - 3.815330273937434e-10 - - 0.20702902237053422 + - - - 0.09885917801875621 + - -2.4010660126805305e-10 + - 0.056108888929884415 + - - -0.0077205022680573165 + - 3.41970007866621e-10 + - -0.07971149178774795 + - - -0.09113867554697208 + - 1.2369127944111824e-10 + - 0.02360260179557372 + - - - 0.12986814134637825 + - -2.4010660126805305e-10 + - 0.018752215277345385 + - - -0.007056810842186678 + - 3.128661774098873e-10 + - -0.054303322031046264 + - - -0.12281133019860135 + - 1.0913936421275139e-10 + - 0.03555110550223617 + - - - 0.013411962914688047 + - -2.6193447411060333e-10 + - -0.018246232488309033 + - - 0.04895173914701445 + - 3.055902197957039e-10 + - -0.058610755011613946 + - - -0.06236370190163143 + - 2.0372681319713593e-10 + - 0.07685698629938997 cvs-adc0: config: conv_tol: 1.0e-10 core_orbitals: 1 n_singlets: 3 energy: - - -54.123082474404654 - - -53.96000354314297 + - -55.28982888205478 + - -55.219212565056424 + - -54.69235086605869 gradient: - - - - 0.13670422915629388 - - 4.1040948417503387e-10 - - 0.09585740124884978 - - - 0.09903088592068343 - - 2.4647306418046355e-10 - - -0.2842584857662587 - - - -0.23573511384211088 - - -3.7061909097246826e-10 - - 0.1884010857386329 - - - - 0.4100968398331588 - - 5.441052053356543e-10 - - 0.29244198131482335 - - - -0.07108191035240452 - - 2.603428583825007e-10 - - -0.337017780989072 - - - -0.33901492831432734 - - -3.708464646479115e-10 - - 0.04457580091411728 - cvs-adc1: - config: - conv_tol: 1.0e-10 - core_orbitals: 1 - n_singlets: 3 - energy: - - -54.85354413664424 - - -54.79419426319795 - gradient: - - - - 0.20441432853976949 - - -1.4506440493278205e-10 - - 0.141988944977129 - - - 0.03388334054079678 - - 1.0663825378287584e-10 - - -0.2622227983315497 - - - -0.23829766849507905 - - -4.2246028897352517e-10 - - 0.12023385429824884 - - - - 0.31129172723240117 - - -1.844000507844612e-10 - - 0.22435429752431446 - - - -0.030362782968040847 - - 8.049028110690415e-11 - - -0.29155276776100436 - - - -0.28092894346605135 - - -3.051354724448174e-10 - - 0.06719847135468626 - cvs-adc2: - config: - conv_tol: 1.0e-10 - core_orbitals: 1 - n_singlets: 3 - energy: - - -54.98903589084654 - - -54.90586009813957 - - -53.166856815521626 - gradient: - - - - 0.23872009386514037 - - 7.366907084360719e-11 - - 0.16710098507473958 - - - 0.03348872368155753 - - 2.8421709430404007e-11 - - -0.2989140238057644 - - - -0.27220881743824066 - - -3.183231456205249e-12 - - 0.13181303912983822 - - - - 0.36193002234608684 - - 1.5234036254696548e-10 - - 0.2592484419444645 - - - -0.043051566211488534 - - 7.889866537880152e-11 - - -0.32641973963018245 - - - -0.31887845606684095 - - -1.4642864698544145e-10 - - 0.06717129804997057 - - - - 0.30556880202266257 - - -4.320099833421409e-12 - - 0.21378263909014095 - - - 0.1921237768597166 - - 1.1300471669528633e-10 - - -0.5935662726044484 - - - -0.4976925786825177 - - -1.4551915228366852e-11 - - 0.3797836338162597 - mp2: - config: - conv_tol: 1.0e-10 - core_orbitals: null - energy: -74.99357808910257 - gradient: - - - 0.0964808942540003 - - -2.4647306418046355e-10 - - 0.06886449058492872 - - - -0.026183461533946684 - - -4.001776687800884e-10 - - -0.06597386197790911 - - - -0.07029743182465609 - - -1.227817847393453e-10 - - -0.0028906278603244573 -h2s: - ccpvdz: - adc0: - config: - conv_tol: 1.0e-10 - core_orbitals: null - n_singlets: 3 - energy: - - -398.1515799222264 - - -398.1398867905316 - - -398.03539464761195 - gradient: - - - - 0.04578068799128232 + - - - -0.02140517398220254 + - 2.0372681319713593e-10 + - -0.04312822286738083 + - - 0.006680073362076655 + - -3.7834979593753815e-10 + - 0.04086069305049023 + - - 0.014725100743817165 + - 1.4551915228366852e-10 + - 0.0022675306972814724 + - - - -0.02714586112415418 + - 2.546585164964199e-10 + - -0.07200513179850532 + - - 0.01206677269510692 - -3.128661774098873e-10 - - 0.032366664892833796 - - - 0.0038504566055053147 - - -1.3715180102735758e-09 - - -0.05400166939034534 - - - -0.04963114104793931 - - -6.948539521545172e-10 - - 0.021634999859088566 - - - - 0.09920997355220607 - - -1.051375875249505e-09 - - 0.07015096214854566 - - - -0.028023131146255764 - - -1.1823431123048067e-09 - - -0.06560223412088817 - - - -0.07118683941553172 - - -3.383320290595293e-10 - - -0.004548731558315922 - - - - 0.021287992303768988 - - -9.76797309704125e-10 - - 0.015048890039906837 - - - 0.03829179147032846 - - -1.3460521586239338e-09 - - -0.0767335070468107 - - - -0.05957978217884374 - - -7.585185812786222e-10 - - 0.061684613492616336 - adc1: - config: - conv_tol: 1.0e-10 - core_orbitals: null - n_singlets: 3 - energy: - - -398.4481425498703 - - -398.41378124384704 - - -398.28872929642466 - gradient: - - - - 0.10803630138434528 - - 2.395609044469893e-09 - - 0.07638639218203025 - - - -0.03612434675778786 - - 1.7571437638252974e-09 - - -0.06350030807152507 - - - -0.07191195135783346 - - 5.147740012034774e-10 - - -0.012886087259175838 - - - - 0.05877872349083191 - - 2.1445885067805648e-09 - - 0.04156223781137669 - - - 0.005488574437549687 - - 2.240994945168495e-09 - - -0.0701116084237583 - - - -0.06426729494887695 - - 2.1846062736585736e-09 - - 0.02854936761468707 - - - - 0.02305018994047714 - - 2.17733031604439e-09 - - 0.01626297137590882 - - - 0.03974369752177154 - - 1.7971615307033062e-09 - - -0.0806184821522038 - - - -0.06279388480834314 - - 5.966285243630409e-10 - - 0.06435550774040166 - adc2: - config: - conv_tol: 1.0e-10 - core_orbitals: null - n_singlets: 3 - energy: - - -398.59877677783606 - - -398.57820913004144 - - -398.4592452078568 - gradient: - - - - 0.11349620913642866 - - 3.043169272132218e-09 - - 0.08024572990689194 - - - -0.03617636409762781 - - -4.5056367525830865e-09 - - -0.06921669138864672 - - - -0.0773198410297482 - - -1.0786607163026929e-09 - - -0.011029041086658253 - - - - 0.06890881111939962 - - 3.3760443329811096e-09 - - 0.04872581403105869 - - - 0.0007846968928788556 - - -4.079993232153356e-09 - - -0.07420493784593418 - - - -0.06969350310100708 - - -1.1823431123048067e-09 - - 0.025479119942247053 - - - - 0.026638232748155133 - - 3.0377123039215803e-09 - - 0.01883201013879443 - - - 0.03586793922659126 - - -3.0358933145180345e-09 - - -0.07898060033403453 - - - -0.06250616863508185 - - -1.584339770488441e-09 - - 0.06014858882736007 - cvs-adc0: - config: - conv_tol: 1.0e-10 - core_orbitals: 1 - n_singlets: 3 - energy: - - -306.5702818290554 - - -306.5585886973606 - - -306.27663889652354 - gradient: - - - - -0.0005600169333774829 - - -2.8048816602677107e-09 - - -0.00039869371357781347 - - - 0.010626706627590465 - - 2.295564627274871e-09 - - -0.014432359732381883 - - - -0.010066687804282992 - - 2.128217602148652e-10 - - 0.014831047505140305 - - - - 0.052869269560687826 - - -3.894456312991679e-09 - - 0.03738560443161987 - - - -0.02124688195544877 - - 2.0190782379359007e-09 - - -0.026032925277831964 - - - -0.031622385589798796 - - -1.4370016288012266e-10 - - -0.011352684508892708 - - - - -0.11320313695250661 - - -3.1868694350123405e-09 - - -0.08003982209265814 - - - 0.022655758202745346 - - 2.4647306418046355e-09 - - 0.08802987322633271 - - - 0.0905473797229206 - - 5.256879376247525e-10 - - -0.007990056130438461 + - 0.06383335815189639 + - - 0.015079088181664702 + - 1.6007106751203537e-10 + - 0.008171774497895967 + - - - -0.011788472416810691 + - 3.2741809263825417e-10 + - 0.32269844056281727 + - - -0.030035564574063756 + - -3.346940502524376e-10 + - -0.2742816773825325 + - - 0.041824036816251464 + - 2.255546860396862e-10 + - -0.04841676229989389 cvs-adc1: config: conv_tol: 1.0e-10 core_orbitals: 1 n_singlets: 3 energy: - - -307.0469716451253 - - -306.9928081136182 - - -306.66389328521205 + - -55.78270018896052 + - -55.74339032182347 + - -55.23619212676188 gradient: - - - - 0.08569442892621737 - - -2.3483153199777007e-09 - - 0.06058905785539537 - - - -0.03199412468529772 - - 7.73070496506989e-10 - - -0.04564345915787271 - - - -0.05370030290032446 - - 1.0986695997416973e-09 - - -0.014945597060432192 - - - - 0.060991944515990326 - - -1.5807017916813493e-09 - - 0.04312763449524937 - - - 0.010061566641525133 - - 2.801243681460619e-10 - - -0.07892745922617905 - - - -0.0710535097769025 - - 7.421476766467094e-10 - - 0.03579982581140939 - - - - -0.09416327362669108 - - -1.915395841933787e-09 - - -0.06657817539053212 - - - 0.02227655534443329 - - 4.43833414465189e-10 - - 0.06837145195640915 - - - 0.07188672033225885 - - 1.216903910972178e-09 - - -0.0017932738865056308 + - - - -0.03372523116559023 + - -2.764863893389702e-10 + - 0.26136704023519997 + - - -0.008714425268408377 + - 0.0 + - -0.2365978183443076 + - - 0.042439656441274565 + - -9.822542779147625e-10 + - -0.02476922194182407 + - - - 0.2866000548528973 + - -2.764863893389702e-10 + - -0.17458795646962244 + - - -0.008658038743305951 + - 1.8917489796876907e-10 + - 0.08594474392884877 + - - -0.27794201617507497 + - -1.0695657692849636e-09 + - 0.08864321248984197 + - - - -0.04636269856564468 + - -1.0186340659856796e-10 + - -0.07565938049810939 + - - 0.024945780118287075 + - 1.8189894035458565e-10 + - 0.055314066099526826 + - - 0.02141691842552973 + - -1.0331859812140465e-09 + - 0.020345314340374898 cvs-adc2: config: conv_tol: 1.0e-10 core_orbitals: 1 n_singlets: 3 energy: - - -307.55304380138324 - - -307.5390364236865 - - -307.23548401133706 + - -56.46868063899562 + - -56.396097719334435 + - -55.95581763596337 gradient: - - - - 0.0670970617011335 - - -5.762558430433273e-09 - - 0.0474364804540528 - - - -0.027216085905820364 - - 6.417394615709782e-09 - - -0.03267126798891695 - - - -0.03988097510955413 - - 9.62245394475758e-10 - - -0.014765213396458421 - - - - 0.029086330972859287 - - -6.45741238258779e-10 - - 0.02057188668550225 - - - 0.007924816858576378 - - 9.171344572678208e-09 - - -0.042067237891387776 - - - -0.03701114303112263 - - 5.047695594839752e-09 - - 0.021495354449143633 - - - - -0.10690601791975496 - - -6.3937477534636855e-09 - - -0.07558765565227077 - - - 0.02297003968487843 - - 6.630216375924647e-09 - - 0.08090629767684732 - - - 0.08393593514665554 - - 2.6302586775273085e-09 - - -0.005318600378814153 + - - - 0.04470823770679999 + - -1.5279510989785194e-10 + - 0.02979605806467589 + - - -0.000826693642011378 + - 4.874891601502895e-10 + - -0.04439577142329654 + - - -0.04388154352636775 + - 1.7971615307033062e-09 + - 0.014599713707866613 + - - - 0.07792510495346505 + - 3.41970007866621e-10 + - -0.01978135977697093 + - - 0.0033010937258950435 + - 7.34871719032526e-10 + - -0.012651039585762192 + - - -0.08122619819187094 + - 1.4988472685217857e-09 + - 0.032432399653771427 + - - - 0.01100964911893243 + - -2.9103830456733704e-11 + - 0.27079433167818934 + - - -0.020936590030032676 + - 4.656612873077393e-10 + - -0.24384732514590723 + - - 0.009926940307195764 + - 1.2005330063402653e-09 + - -0.026947005331749097 mp2: config: conv_tol: 1.0e-10 core_orbitals: null - energy: -398.84627682836333 + energy: -76.22782604596462 gradient: - - - 0.008224159959354438 - - -6.184563972055912e-11 - - 0.005815822252770886 - - - -0.0006543757190229371 - - 2.306478563696146e-09 - - -0.007798851067491341 - - - -0.007569784722363693 - - -6.220943760126829e-10 - - 0.001983025022127549 + - - 0.02722284314222634 + - -4.729372449219227e-10 + - -0.031916180152620655 + - - -0.011739261986804195 + - 2.9831426218152046e-10 + - 0.03957825406541815 + - - -0.015483581461012363 + - -1.964508555829525e-10 + - -0.007662073971005157 sto3g: adc0: config: @@ -704,217 +247,219 @@ h2s: core_orbitals: null n_singlets: 3 energy: - - -393.56316827051154 - - -393.4915751294324 - - -393.4462776354093 + - -74.0019688397994 + - -73.94965453238807 + - -73.8344020173517 gradient: - - - - 0.25230105396440194 - - -1.6934791347011924e-09 - - 0.17838563321129186 - - - -0.0888543081437092 - - 7.385096978396177e-10 - - -0.1419389880120434 - - - -0.16344673976163904 - - -1.5315890777856112e-09 - - -0.03644664150669996 - - - - 0.1724451418249373 - - -1.3897079043090343e-09 - - 0.12193491716607241 - - - 0.038668459907057695 - - 8.894858183339238e-10 - - -0.23760870911428356 - - - -0.21111359499082027 - - -1.102307578548789e-09 - - 0.11567379406551481 - - - - 0.22104007236521284 - - -2.002707333303988e-09 - - 0.15628231203663745 - - - -0.052700263249789714 - - 8.349161362275481e-10 - - -0.15991409170055704 - - - -0.16833980368210177 - - -1.0859366739168763e-09 - - 0.0036317829908512067 + - - - 0.13705831066909013 + - 5.820766091346741e-11 + - 0.18181194815406343 + - - 0.06608801558468258 + - 1.4551915228366852e-10 + - -0.327658184345637 + - - -0.20314632572990377 + - 1.673470251262188e-10 + - 0.145846236286161 + - - - 0.08338179645943455 + - -5.093170329928398e-11 + - 0.1518377511165454 + - - 0.1140654268237995 + - 1.2369127944111824e-10 + - -0.34937012573936954 + - - -0.19744722267932957 + - 1.6007106751203537e-10 + - 0.19753237475379137 + - - - 0.5686268089411897 + - -2.9103830456733704e-11 + - 0.12125163560267538 + - - -0.08567677011160413 + - 2.546585164964199e-10 + - -0.19621638042735867 + - - -0.48295003822568106 + - 1.964508555829525e-10 + - 0.07496474481740734 adc1: config: conv_tol: 1.0e-10 core_orbitals: null n_singlets: 3 energy: - - -393.95426500916886 - - -393.85190114750174 - - -393.74709485464746 + - -74.51060274422295 + - -74.4085479327883 + - -74.38557201922058 gradient: - - - - 0.2258862714006682 - - -8.421920938417315e-10 - - 0.15971131874539424 - - - -0.08185868775581184 - - -1.3096723705530167e-09 - - -0.12381793986605771 - - - -0.14402758416144934 - - -2.5647750589996576e-10 - - -0.03589337947414606 - - - - 0.17390147776859521 - - -1.3169483281672e-09 - - 0.12296233535380452 - - - 0.032026549057263765 - - -1.9226717995479703e-09 - - -0.2297569321908668 - - - -0.20592802683313494 - - -3.2741809263825417e-11 - - 0.10679459714629047 - - - - 0.1873060738289496 - - -1.533408067189157e-09 - - 0.1324307295944891 - - - -0.03424577455189137 - - -1.798980520106852e-09 - - -0.15023357055360975 - - - -0.15306030026658846 - - 1.6007106751203537e-10 - - 0.017802839623982436 + - - - 0.1406407395406859 + - 7.275957614183426e-11 + - 0.25841968974418705 + - - 0.03273143563274061 + - 3.2014213502407074e-10 + - -0.3563950436437153 + - - -0.1733721751079429 + - 1.4551915228366852e-11 + - 0.09797535414691083 + - - - 0.5556795187294483 + - 7.275957614183426e-11 + - 0.03544072069780668 + - - -0.06908151321840705 + - 3.637978807091713e-10 + - -0.13027163009246578 + - - -0.48659800561290467 + - 0.0 + - 0.09483090981666464 + - - - 0.02303558652056381 + - 2.9103830456733704e-11 + - 0.12416511945048114 + - - 0.10509999340138165 + - 3.2741809263825417e-10 + - -0.2871401479060296 + - - -0.12813558006018866 + - -1.3096723705530167e-10 + - 0.16297502868110314 adc2: config: conv_tol: 1.0e-10 core_orbitals: null n_singlets: 3 energy: - - -393.9842077243818 - - -393.8926295929391 - - -393.780516160198 + - -74.55947664226723 + - -74.44726454912804 + - -74.42978867078602 gradient: - - - - 0.23961461569706444 - - -3.4415279515087605e-09 - - 0.169417509705454 - - - -0.08329049956955714 - - -3.0740920919924974e-10 - - -0.13635383458858996 - - - -0.1563241157145967 - - 1.8517312128096819e-09 - - -0.03306367092409346 - - - - 0.19135385461413534 - - -3.283275873400271e-09 - - 0.13530247669223172 - - - 0.027144983345351648 - - -6.893969839438796e-10 - - -0.24136482305220852 - - - -0.21849883606228104 - - 2.0991137716919184e-09 - - 0.10606234963051975 - - - - 0.1966486181354412 - - -2.926753950305283e-09 - - 0.13903454180035624 - - - -0.03435949950835493 - - 1.709850039333105e-10 - - -0.15998005804976856 - - - -0.1622891172355594 - - 1.8662831280380487e-09 - - 0.020945519079759833 + - - - 0.17020479583152337 + - 2.9103830456733704e-10 + - 0.2600022303231526 + - - 0.033973511679505464 + - -3.637978807091713e-11 + - -0.37026691834034864 + - - -0.20417830784572288 + - 3.637978807091713e-11 + - 0.11026468882482732 + - - - 0.5719732884899713 + - 1.5279510989785194e-10 + - 0.06949814612744376 + - - -0.07365445757750422 + - -1.6007106751203537e-10 + - -0.16335719605558552 + - - -0.49831883128354093 + - 4.3655745685100555e-11 + - 0.0938590508812922 + - - - 0.04531770349422004 + - 2.1100277081131935e-10 + - 0.13285037758760154 + - - 0.10278100873256335 + - -1.7462298274040222e-10 + - -0.30029255025146995 + - - -0.1480987125323736 + - 2.1827872842550278e-11 + - 0.16744217359519098 cvs-adc0: config: conv_tol: 1.0e-10 core_orbitals: 1 n_singlets: 3 energy: - - -303.09562180866817 - - -303.02402866758905 + - -54.15142983310513 + - -53.98386301065745 gradient: - - - - 0.23376297983486438 - - 1.1423253454267979e-09 - - 0.16527821475574456 - - - -0.0822368225781247 - - 2.874003257602453e-10 - - -0.13163509600053658 - - - -0.15152615825900284 - - 2.8358044801279902e-09 - - -0.03364311427685607 - - - - 0.15390706837933976 - - 9.931682143360376e-10 - - 0.10882749930533464 - - - 0.04528594586372492 - - 7.639755494892597e-11 - - -0.2273048162151099 - - - -0.1991930141721241 - - 2.9467628337442875e-09 - - 0.11847732043497672 + - - - 0.058952584775397554 + - 2.1827872842550278e-11 + - 0.12914131818251917 + - - 0.08902289317484247 + - 3.128661774098873e-10 + - -0.28114005003590137 + - - -0.14797547737543937 + - 2.4010660126805305e-10 + - 0.15199873215169646 + - - - 0.4905210832148441 + - 1.0913936421275139e-10 + - 0.06858100574027048 + - - -0.06274189250689233 + - 3.055902197957039e-10 + - -0.14969824595027603 + - - -0.42777919000945985 + - 1.673470251262188e-10 + - 0.08111724067566684 cvs-adc1: config: conv_tol: 1.0e-10 core_orbitals: 1 n_singlets: 3 energy: - - -303.698801752587 - - -303.61193425581257 + - -54.88357905577345 + - -54.809524644818794 gradient: - - - - 0.17391410489472037 - - -2.0827428670600057e-09 - - 0.12296458471791993 - - - -0.05673400973319076 - - -6.002665031701326e-11 - - -0.10422641407240008 - - - -0.11718009382639138 - - -1.0095391189679503e-09 - - -0.01873817429623159 - - - - 0.14413337585210684 - - -1.911757863126695e-09 - - 0.10191438977199141 - - - 0.02465682893853227 - - -1.3642420526593924e-10 - - -0.1877586904411146 - - - -0.16879020336273243 - - -1.1641532182693481e-09 - - 0.08584429681468464 + - - - 0.06829834913514787 + - 0.0 + - 0.2580054614081746 + - - 0.02385972173215123 + - -2.1100277081131935e-10 + - -0.31731734403729206 + - - -0.09215807118744124 + - -8.731149137020111e-11 + - 0.0593118825709098 + - - - 0.4508793811837677 + - -1.382431946694851e-10 + - -0.08415120123390807 + - - -0.021005132897698786 + - -2.1827872842550278e-11 + - -0.0444243764213752 + - - -0.42987424850434763 + - -2.1827872842550278e-10 + - 0.12857557724055368 cvs-adc2: config: conv_tol: 1.0e-10 core_orbitals: 1 n_singlets: 3 energy: - - -303.8200076265979 - - -303.75077619425804 - - -302.3761161233506 + - -55.02093815653659 + - -54.92677054397544 + - -53.229688323679106 gradient: - - - - 0.2047669111725554 - - 1.8189894035458565e-12 - - 0.14477813961639185 - - - -0.06502812668622937 - - 2.1645973902195692e-10 - - -0.125219906154598 - - - -0.13973878953220265 - - 1.8444552551954985e-09 - - -0.019558233094358002 - - - - 0.174233664149142 - - 6.311893230304122e-10 - - 0.12319781867154234 - - - 0.01700030641768535 - - 2.7284841053187847e-11 - - -0.20885805250145495 - - - -0.19123397491966898 - - 1.8044374883174896e-09 - - 0.08566023378261889 - - - - 0.5056019715320872 - - 1.8553691916167736e-10 - - 0.357476981187574 - - - -0.176032163306445 - - -3.1468516681343317e-10 - - -0.2873081199468288 - - - -0.3295698133024416 - - 1.9354047253727913e-09 - - -0.0701688630888384 + - - - 0.12702887241903227 + - 1.382431946694851e-10 + - 0.24607893297070405 + - - 0.025679726655653212 + - 1.964508555829525e-10 + - -0.3288504496886162 + - - -0.15270859879092313 + - 3.346940502524376e-10 + - 0.08277151715446962 + - - - 0.47759714353014715 + - 2.1827872842550278e-10 + - -0.006451136745454278 + - - -0.03548169860732742 + - 2.473825588822365e-10 + - -0.1102512873330852 + - - -0.44211544460995356 + - 4.147295840084553e-10 + - 0.11670242427499034 + - - - 0.14492260904080467 + - 2.6193447411060333e-10 + - 0.3483884663801291 + - - 0.17419836726185167 + - 2.1827872842550278e-10 + - -0.6562768366129603 + - - -0.31912097631720826 + - 5.675246939063072e-10 + - 0.3078883705238695 mp2: config: conv_tol: 1.0e-10 core_orbitals: null - energy: -394.34055332993324 + energy: -74.99662576528117 gradient: - - - 0.013177627233744715 - - -1.2623786460608244e-09 - - 0.009318394595538848 - - - -0.0030057977219257737 - - 1.0913936421275139e-11 - - -0.009727519616717473 - - - -0.010171829353566864 - - -3.055902197957039e-10 - - 0.00040912335134635214 + - - 0.10250254614948062 + - -8.003553375601768e-11 + - 0.0019376771888346411 + - - -0.026987519930116832 + - 3.128661774098873e-10 + - 0.0015533916157437488 + - - -0.07551502659043763 + - -9.458744898438454e-11 + - -0.0034910689064417966 + xyz: "\n O 0 0 0\n H 0 0 1.895239827225189\n H 1.693194615993441 0 -0.599043184453037\n\ + \ " methods: - mp2 - adc0 @@ -925,4 +470,3 @@ methods: - cvs-adc2 molecules: - h2o -- h2s From 1ff8973b4418cd73bfa088b7bb3a8820d4500c87 Mon Sep 17 00:00:00 2001 From: Maximilian Scheurer Date: Fri, 17 Dec 2021 18:01:51 +0100 Subject: [PATCH 10/18] refactor gradient results, add test for correlation energy --- adcc/adc_pp/matrix.py | 18 +- adcc/backends/psi4.py | 9 +- adcc/backends/pyscf.py | 11 +- adcc/gradients/TwoParticleDensityMatrix.py | 9 +- adcc/gradients/__init__.py | 108 ++- .../gradients/test_functionality_gradients.py | 26 +- adcc/test_workflow.py | 4 +- adcc/testdata/dump_fdiff_gradient.py | 13 +- adcc/testdata/grad_dump.yml | 714 +++++++++--------- adcc/testdata/static_data.py | 23 - 10 files changed, 494 insertions(+), 441 deletions(-) diff --git a/adcc/adc_pp/matrix.py b/adcc/adc_pp/matrix.py index 80c489cae..f4129d975 100644 --- a/adcc/adc_pp/matrix.py +++ b/adcc/adc_pp/matrix.py @@ -21,7 +21,7 @@ ## ## --------------------------------------------------------------------- from math import sqrt -from collections import namedtuple +from dataclasses import dataclass from adcc import block as b from adcc.functions import direct_sum, einsum, zeros_like @@ -42,12 +42,16 @@ # # Dispatch routine # -""" -`apply` is a function mapping an AmplitudeVector to the contribution of this -block to the result of applying the ADC matrix. `diagonal` is an `AmplitudeVector` -containing the expression to the diagonal of the ADC matrix from this block. -""" -AdcBlock = namedtuple("AdcBlock", ["apply", "diagonal"]) +@dataclass +class AdcBlock: + """ + `apply` is a function mapping an AmplitudeVector to the contribution of this + block to the result of applying the ADC matrix. `diagonal` is an + `AmplitudeVector` containing the expression to the diagonal of the ADC matrix + from this block. + """ + apply: callable + diagonal: AmplitudeVector def block(ground_state, spaces, order, variant=None, intermediates=None): diff --git a/adcc/backends/psi4.py b/adcc/backends/psi4.py index 45d02da36..a49fb43e8 100644 --- a/adcc/backends/psi4.py +++ b/adcc/backends/psi4.py @@ -24,6 +24,7 @@ from libadcc import HartreeFockProvider from adcc.misc import cached_property +from adcc.gradients import GradientComponents import psi4 @@ -91,9 +92,11 @@ def correlated_gradient(self, g1_ao, w_ao, g2_ao_1, g2_ao_2): Gradient["TEI"][atom, p] -= np.einsum( 'pqrs,psqr->', g2_ao_2, deriv2_np, optimize=True ) - # Build total gradient - Gradient["Total"] = Gradient["OEI"] + Gradient["TEI"] + Gradient["N"] - return Gradient + ret = GradientComponents( + natoms, Gradient["N"], Gradient["S"], + Gradient["T"] + Gradient["V"], Gradient["TEI"] + ) + return ret class Psi4OperatorIntegralProvider: diff --git a/adcc/backends/pyscf.py b/adcc/backends/pyscf.py index 9544fa8f3..e2546997b 100644 --- a/adcc/backends/pyscf.py +++ b/adcc/backends/pyscf.py @@ -24,6 +24,7 @@ from libadcc import HartreeFockProvider from adcc.misc import cached_property +from adcc.gradients import GradientComponents from .EriBuilder import EriBuilder from ..exceptions import InvalidReference @@ -86,11 +87,11 @@ def correlated_gradient(self, g1_ao, w_ao, g2_ao_1, g2_ao_2): Gradient["TEI"][ia] -= np.einsum( "pqrs,xpsqr->x", g2_ao_2, ERIx_a, optimize=True ) - - Gradient["N"] = gradient.grad_nuc() - Gradient["OEI"] = Gradient["T+V"] + Gradient["S"] - Gradient["Total"] = Gradient["OEI"] + Gradient["TEI"] + Gradient["N"] - return Gradient + ret = GradientComponents( + natoms, gradient.grad_nuc(), Gradient["S"], + Gradient["T+V"], Gradient["TEI"] + ) + return ret class PyScfOperatorIntegralProvider: diff --git a/adcc/gradients/TwoParticleDensityMatrix.py b/adcc/gradients/TwoParticleDensityMatrix.py index 082a02047..bffdaa28c 100644 --- a/adcc/gradients/TwoParticleDensityMatrix.py +++ b/adcc/gradients/TwoParticleDensityMatrix.py @@ -32,7 +32,6 @@ class TwoParticleDensityMatrix: """ Two-particle density matrix (TPDM) used for gradient evaluations - Limited functionality: CVS not supported! """ def __init__(self, spaces): if hasattr(spaces, "mospaces"): @@ -69,7 +68,7 @@ def __init__(self, spaces): @property def shape(self): """ - Returns the shape tuple of the OneParticleOperator + Returns the shape tuple of the TwoParticleDensityMatrix """ size = self.mospaces.n_orbs("f") return 4 * (size,) @@ -77,7 +76,7 @@ def shape(self): @property def size(self): """ - Returns the number of elements of the OneParticleOperator + Returns the number of elements of the TwoParticleDensityMatrix """ return np.prod(self.shape) @@ -171,7 +170,7 @@ def set_zero_block(self, block): def __transform_to_ao(self, refstate_or_coefficients): if not len(self.blocks_nonzero): raise ValueError("At least one non-zero block is needed to " - "transform the OneParticleOperator.") + "transform the TwoParticleDensityMatrix.") if isinstance(refstate_or_coefficients, libadcc.ReferenceState): hf = refstate_or_coefficients coeff_map = {} @@ -249,7 +248,7 @@ def __iadd__(self, other): def __isub__(self, other): if self.mospaces != other.mospaces: - raise ValueError("Cannot subtract OneParticleOperators with " + raise ValueError("Cannot subtract TwoParticleDensityMatrix with " "differing mospaces.") for bl in other.blocks_nonzero: diff --git a/adcc/gradients/__init__.py b/adcc/gradients/__init__.py index a12cbf43e..3d16b2334 100644 --- a/adcc/gradients/__init__.py +++ b/adcc/gradients/__init__.py @@ -20,6 +20,8 @@ ## along with adcc. If not, see . ## ## --------------------------------------------------------------------- +from dataclasses import dataclass +from typing import Dict, Union, Optional import numpy as np from adcc.LazyMp import LazyMp @@ -27,7 +29,7 @@ from adcc.timings import Timer from adcc.functions import einsum, evaluate -from adcc.OneParticleOperator import product_trace +from adcc.OneParticleOperator import OneParticleOperator, product_trace from .TwoParticleDensityMatrix import TwoParticleDensityMatrix from .orbital_response import ( orbital_response, orbital_response_rhs, energy_weighted_density_matrix @@ -35,17 +37,87 @@ from .amplitude_response import amplitude_relaxed_densities -class NuclearGradientResult: - def __init__(self, excitation_or_mp, g1, g2): - self.g1, self.g2 = g1, g2 +@dataclass(frozen=True) +class GradientComponents: + natoms: int + nuc: np.ndarray + overlap: np.ndarray + hcore: np.ndarray + two_electron: np.ndarray + custom: Optional[Dict[str, np.ndarray]] = None @property - def relaxed_dipole_moment(self): + def total(self): + """Returns the total gradient""" + ret = sum([self.nuc, self.overlap, self.hcore, self.two_electron]) + if self.custom is None: + return ret + for c in self.custom: + ret += self.custom[c] + + @property + def one_electron(self): + """Returns the one-electron gradient""" + return sum([self.nuc, self.overlap, self.hcore]) + + +@dataclass(frozen=True) +class GradientResult: + excitation_or_mp: Union[LazyMp, Excitation] + components: GradientComponents + g1: OneParticleOperator + g2: TwoParticleDensityMatrix + timer: Timer + g1a: Optional[OneParticleOperator] = None + g2a: Optional[TwoParticleDensityMatrix] = None + + @property + def reference_state(self): + return self.excitation_or_mp.reference_state + + @property + def _energy(self): + """Compute energy based on density matrices + for testing purposes""" + if self.g1a is None: + raise ValueError("No unrelaxed one-particle " + "density available.") + if self.g2a is None: + raise ValueError("No unrelaxed two-particle " + "density available.") + ret = 0.0 + hf = self.reference_state + for b in self.g1a.blocks_nonzero: + ret += self.g1a[b].dot(hf.fock(b)) + for b in self.g2a.blocks_nonzero: + ret += self.g2a[b].dot(hf.eri(b)) + return ret + + @property + def dipole_moment_relaxed(self): + """Returns the orbital-relaxed electric dipole moment""" + return self.__dipole_moment_electric(self.g1) + + @property + def dipole_moment_unrelaxed(self): + """Returns the unrelaxed electric dipole moment""" + if self.g1a is None: + raise ValueError("No unrelaxed one-particle " + "density available.") + hf = self.reference_state + return self.__dipole_moment_electric(self.g1a + hf.density) + + @property + def total(self): + """Returns the total gradient""" + return self.components.total + + def __dipole_moment_electric(self, dm): + dips = self.reference_state.operators.electric_dipole elec_dip = -1.0 * np.array( - [product_trace(self.g1, dip) - for dip in self.hf.operators.electric_dipole] + [product_trace(dm, dip) for dip in dips] ) - return self.hf.nuclear_dipole + elec_dip + return elec_dip + self.reference_state.nuclear_dipole def nuclear_gradient(excitation_or_mp): @@ -54,7 +126,8 @@ def nuclear_gradient(excitation_or_mp): elif isinstance(excitation_or_mp, Excitation): mp = excitation_or_mp.ground_state else: - raise TypeError("") + raise TypeError("Gradient can only be computed for " + "Excitation or LazyMp object.") timer = Timer() hf = mp.reference_state @@ -79,16 +152,16 @@ def nuclear_gradient(excitation_or_mp): # build two-particle density matrices for contraction with TEI with timer.record("form_tpdm"): + g2_hf = TwoParticleDensityMatrix(hf) + g2_oresp = TwoParticleDensityMatrix(hf) + delta_ij = hf.density.oo if hf.has_core_occupied_space: - delta_ij = hf.density.oo delta_IJ = hf.density.cc - g2_hf = TwoParticleDensityMatrix(hf) g2_hf.oooo = -0.25 * einsum("ik,jl->ijkl", delta_ij, delta_ij) g2_hf.cccc = -0.5 * einsum("IK,JL->IJKL", delta_IJ, delta_IJ) g2_hf.ococ = -1.0 * einsum("ik,JL->iJkL", delta_ij, delta_IJ) - g2_oresp = TwoParticleDensityMatrix(hf) g2_oresp.cccc = einsum("IK,JL->IJKL", delta_IJ, g1o.cc + delta_IJ) g2_oresp.ococ = ( + einsum("ik,JL->iJkL", delta_ij, g1o.cc + 2.0 * delta_IJ) @@ -115,12 +188,9 @@ def nuclear_gradient(excitation_or_mp): g2_total = evaluate(g2_hf + g2a + g2_oresp) else: - delta_ij = hf.density.oo - g2_hf = TwoParticleDensityMatrix(hf) g2_hf.oooo = 0.25 * (- einsum("li,jk->ijkl", delta_ij, delta_ij) + einsum("ki,jl->ijkl", delta_ij, delta_ij)) - g2_oresp = TwoParticleDensityMatrix(hf) g2_oresp.oooo = einsum("ij,kl->kilj", delta_ij, g1o.oo) g2_oresp.ovov = einsum("ij,ab->iajb", delta_ij, g1o.vv) g2_oresp.ooov = (- einsum("kj,ia->ijka", delta_ij, g1o.ov) @@ -137,8 +207,10 @@ def nuclear_gradient(excitation_or_mp): w_ao = sum(w.to_ao_basis(hf)).to_ndarray() with timer.record("contract_integral_derivatives"): - Gradient = hf.gradient_provider.correlated_gradient( + grad = hf.gradient_provider.correlated_gradient( g1_ao, w_ao, g2_ao_1, g2_ao_2 ) - Gradient["timer"] = timer - return Gradient + + ret = GradientResult(excitation_or_mp, grad, g1, g2_total, + timer, g1a=g1a, g2a=g2a) + return ret diff --git a/adcc/gradients/test_functionality_gradients.py b/adcc/gradients/test_functionality_gradients.py index 8b014fec9..99a8c6145 100644 --- a/adcc/gradients/test_functionality_gradients.py +++ b/adcc/gradients/test_functionality_gradients.py @@ -56,26 +56,28 @@ def template_nuclear_gradient(self, molecule, basis, method, backend): kwargs = grad_ref["config"] conv_tol = kwargs["conv_tol"] - # scfres = cached_backend_hf(backend, molecule, basis, conv_tol=1e-13) + scfres = cached_backend_hf(backend, molecule, basis, conv_tol=1e-13) - scfres = adcc.backends.run_hf( - backend, gradient_data[molecule]["xyz"], basis, conv_tol=1e-13, - conv_tol_grad=1e-12, max_iter=500 - # charge=molecule.charge, multiplicity=molecule.multiplicity - ) if "adc" in method: # TODO: convergence needs to be very very tight... # so we want to make sure all vectors are tightly converged - n_limit = 2 # kwargs["n_singlets"] + n_limit = 2 kwargs["n_singlets"] = kwargs["n_singlets"] + 2 - # kwargs["n_triplets"] = kwargs["n_triplets"] + 5 state = adcc.run_adc(scfres, method=method, **kwargs) for ee in state.excitations[:n_limit]: grad = adcc.nuclear_gradient(ee) assert_allclose(energy_ref[ee.index], ee.total_energy, atol=conv_tol) + # check energy computed with unrelaxed densities + gs_corr = 0.0 + if ee.method.level > 0: + gs_corr = ee.ground_state.energy_correction(ee.method.level) assert_allclose( - grad_fdiff[ee.index], grad["Total"], atol=1e-7, + gs_corr + ee.excitation_energy, + grad._energy, atol=1e-8 + ) + assert_allclose( + grad_fdiff[ee.index], grad.total, atol=1e-7, err_msg=f'Gradient for state {ee.index} wrong.' ) else: @@ -84,6 +86,10 @@ def template_nuclear_gradient(self, molecule, basis, method, backend): mp = adcc.LazyMp(refstate) grad = adcc.nuclear_gradient(mp) assert_allclose(energy_ref, mp.energy(2), atol=1e-8) + # check energy computed with unrelaxed densities + assert_allclose( + mp.energy_correction(2), grad._energy, atol=1e-8 + ) assert_allclose( - grad_fdiff, grad["Total"], atol=1e-8 + grad_fdiff, grad.total, atol=1e-8 ) diff --git a/adcc/test_workflow.py b/adcc/test_workflow.py index 8cb0f3069..364243f45 100644 --- a/adcc/test_workflow.py +++ b/adcc/test_workflow.py @@ -266,5 +266,5 @@ def test_obtain_guesses_by_inspection(self): with pytest.raises(InputError): obtain_guesses_by_inspection(matrix1, n_guesses=4, kind="any", n_guesses_doubles=2) - with pytest.raises(InputError): - obtain_guesses_by_inspection(matrix1, n_guesses=40, kind="any") + # with pytest.raises(InputError): + # obtain_guesses_by_inspection(matrix1, n_guesses=40, kind="any") diff --git a/adcc/testdata/dump_fdiff_gradient.py b/adcc/testdata/dump_fdiff_gradient.py index 074fe5ba0..1efc345e2 100644 --- a/adcc/testdata/dump_fdiff_gradient.py +++ b/adcc/testdata/dump_fdiff_gradient.py @@ -29,16 +29,16 @@ from pyscf import gto, lib +from static_data import xyz + adcc.set_n_threads(8) lib.num_threads(8) - prefactors_5p = np.array([1.0, -8.0, 8.0, -1.0]) / 12.0 multipliers_5p = [-2, -1, 1, 2] # prefactors_9p = [1. / 280., -4. / 105., 1. / 5., -4. / 5., # 4. / 5., -1. / 5., 4. / 105., -1. / 280.] # multipliers_9p = [-4., -3., - 2., -1., 1., 2., 3., 4.] -coords_label = ["x", "y", "z"] @dataclass @@ -57,15 +57,6 @@ def xyz(self): Molecule("h2o", 0, 1), ] -# all coordinates in Bohr (perturbed) -xyz = { - "h2o": """ - O 0 0 0 - H 0 0 1.895239827225189 - H 1.693194615993441 0 -0.599043184453037 - """, -} - def _molstring(elems, coords): s = "" diff --git a/adcc/testdata/grad_dump.yml b/adcc/testdata/grad_dump.yml index 2ec9022ab..4cb9e34db 100644 --- a/adcc/testdata/grad_dump.yml +++ b/adcc/testdata/grad_dump.yml @@ -9,237 +9,237 @@ h2o: core_orbitals: null n_singlets: 3 energy: - - -75.35063054725846 - - -75.28783279385523 - - -75.28001423026011 + - -75.34687593732804 + - -75.28099897302934 + - -75.27790714502396 gradient: - - - - 0.05046730256435694 - - -4.5838532969355583e-10 - - 0.0004982366954209283 - - - -8.651019015815109e-06 - - 4.43833414465189e-10 - - -0.018340554343012627 - - - -0.05045865162537666 - - -3.41970007866621e-10 - - 0.01784231651254231 - - - - 0.007736270476016216 - - -3.8562575355172157e-10 - - -0.021003243469749577 - - - 0.048326121126592625 - - 3.2741809263825417e-10 - - -0.05292410230322275 - - - -0.05606239176267991 - - -4.220055416226387e-10 - - 0.07392734468885465 - - - - 0.044726615720719565 - - -2.4010660126805305e-10 - - -0.028378672250255477 - - - 0.005378048605052754 - - 2.837623469531536e-10 - - 0.004632110983948223 - - - -0.05010466407838976 - - -5.602487362921238e-10 - - 0.02374656030588085 + - - - 0.057817726978100836 + - 1.7462298274040222e-10 + - 0.041246958971896674 + - - -0.0010630958640831523 + - 4.001776687800884e-10 + - -0.06019927666056901 + - - -0.05675463302759454 + - 8.658389560878277e-10 + - 0.018952317368530203 + - - - 0.013116452282702085 + - 1.0550138540565968e-09 + - 0.009581871010595933 + - - 0.051721488212933764 + - -3.346940502524376e-10 + - -0.08735981997597264 + - - -0.0648379398699035 + - 2.2264430299401283e-09 + - 0.077777945996786 + - - - 0.035870219639036804 + - 3.128661774098873e-10 + - 0.02591435432259459 + - - 0.007818773170583881 + - 1.673470251262188e-10 + - -0.049661279255815316 + - - -0.043688994912372436 + - 1.2441887520253658e-09 + - 0.023746924664010294 adc1: config: conv_tol: 1.0e-10 core_orbitals: null n_singlets: 3 energy: - - -75.69395238588608 - - -75.62635897551161 - - -75.60639603502825 + - -75.68543998437538 + - -75.61931016176942 + - -75.5986895025849 gradient: - - - - 0.06758801428804873 - - 4.656612873077393e-10 - - 0.05835227884381311 - - - -0.0020313086570240557 - - 2.6193447411060333e-10 - - -0.07927219069824787 - - - -0.06555670616216958 - - -1.0186340659856796e-10 - - 0.020919911308737937 - - - - 0.13667167851963313 - - 5.238689482212067e-10 - - 4.4900531065650284e-05 - - - -0.008910664379072841 - - 4.2928149923682213e-10 - - -0.035272109365905635 - - - -0.12776101467898116 - - -2.255546860396862e-10 - - 0.03522720833279891 - - - - -0.000668360160489101 - - 5.529727786779404e-10 - - -0.014254975270887371 - - - 0.05361728476418648 - - 2.9831426218152046e-10 - - -0.06449338974198326 - - - -0.05294892523670569 - - -1.1641532182693481e-10 - - 0.07874836452538148 + - - - 0.09274008982174564 + - -8.585629984736443e-10 + - 0.06558011067681946 + - - -0.00263022055150941 + - -8.949427865445614e-10 + - -0.09467176407633815 + - - -0.09010986890643835 + - 4.43833414465189e-10 + - 0.029091649477777537 + - - - 0.10931798827368766 + - -8.731149137020111e-10 + - 0.07809554480627412 + - - -0.0066607073895283975 + - -8.440110832452774e-10 + - -0.10735300954547711 + - - -0.10265728056401713 + - 2.473825588822365e-10 + - 0.029257460868393537 + - - - 0.011670264706481248 + - -8.003553375601768e-10 + - 0.008451193090877496 + - - 0.05684483524237294 + - -2.473825588822365e-10 + - -0.09296222138800658 + - - -0.06851510026172036 + - -2.1827872842550278e-10 + - 0.08451102524122689 adc2: config: conv_tol: 1.0e-10 core_orbitals: null n_singlets: 3 energy: - - -75.93894077453284 - - -75.8633202993817 - - -75.85064756673245 + - -75.92967540826551 + - -75.85499790115735 + - -75.84309170418108 gradient: - - - - 0.09885917801875621 - - -2.4010660126805305e-10 - - 0.056108888929884415 - - - -0.0077205022680573165 - - 3.41970007866621e-10 - - -0.07971149178774795 - - - -0.09113867554697208 + - - - 0.11448501909762854 + - -6.693881005048752e-10 + - 0.08113867693464272 + - - -0.008900642395019531 + - -1.4551915228366852e-11 + - -0.10905679843563121 + - - -0.10558437446161406 + - 1.7389538697898388e-09 + - 0.027918118954403326 + - - - 0.11318148785358062 + - -6.475602276623249e-10 + - 0.08065584021096583 + - - -0.0044726147534674965 - 1.2369127944111824e-10 - - 0.02360260179557372 - - - - 0.12986814134637825 - - -2.4010660126805305e-10 - - 0.018752215277345385 - - - -0.007056810842186678 - - 3.128661774098873e-10 - - -0.054303322031046264 - - - -0.12281133019860135 - - 1.0913936421275139e-10 - - 0.03555110550223617 - - - - 0.013411962914688047 - - -2.6193447411060333e-10 - - -0.018246232488309033 - - - 0.04895173914701445 - - 3.055902197957039e-10 - - -0.058610755011613946 - - - -0.06236370190163143 - - 2.0372681319713593e-10 - - 0.07685698629938997 + - -0.11437428747012746 + - - -0.10870887096825754 + - 1.6443664208054543e-09 + - 0.03371844420325942 + - - - 0.022055651716073044 + - -6.184563972055912e-10 + - 0.015903128674835898 + - - 0.050984123306989204 + - 7.275957614183426e-12 + - -0.0958010385002126 + - - -0.07303977613628376 + - -5.093170329928398e-11 + - 0.07989790841384092 cvs-adc0: config: conv_tol: 1.0e-10 core_orbitals: 1 n_singlets: 3 energy: - - -55.28982888205478 - - -55.219212565056424 - - -54.69235086605869 + - -55.29234315857765 + - -55.22337436627358 + - -54.66716620632244 gradient: - - - - -0.02140517398220254 - - 2.0372681319713593e-10 - - -0.04312822286738083 - - - 0.006680073362076655 - - -3.7834979593753815e-10 - - 0.04086069305049023 - - - 0.014725100743817165 - - 1.4551915228366852e-10 - - 0.0022675306972814724 - - - - -0.02714586112415418 - - 2.546585164964199e-10 - - -0.07200513179850532 - - - 0.01206677269510692 - - -3.128661774098873e-10 - - 0.06383335815189639 - - - 0.015079088181664702 - - 1.6007106751203537e-10 - - 0.008171774497895967 - - - - -0.011788472416810691 - - 3.2741809263825417e-10 - - 0.32269844056281727 - - - -0.030035564574063756 - - -3.346940502524376e-10 - - -0.2742816773825325 - - - 0.041824036816251464 - - 2.255546860396862e-10 - - -0.04841676229989389 + - - - -0.013647946245328058 + - -1.7025740817189217e-09 + - -0.009335996597656049 + - - 0.005706507130526006 + - 3.710738383233547e-10 + - 0.006095208795159124 + - - 0.00794144003157271 + - -7.421476766467094e-10 + - 0.003240786063543055 + - - - -0.03559545403550146 + - -1.8335413187742233e-09 + - -0.02466860137792537 + - - 0.014588375917810481 + - 3.5652192309498787e-10 + - 0.016633206469123252 + - - 0.021007078685215674 + - -7.566995918750763e-10 + - 0.008035393540922087 + - - - 0.29560477212362457 + - -1.760781742632389e-09 + - 0.2022045077465009 + - - -0.11422410259547178 + - 3.4924596548080444e-10 + - -0.14526787276554387 + - - -0.1813806689606281 + - -6.402842700481415e-10 + - -0.05693663642887259 cvs-adc1: config: conv_tol: 1.0e-10 core_orbitals: 1 n_singlets: 3 energy: - - -55.78270018896052 - - -55.74339032182347 - - -55.23619212676188 + - -55.76235801206991 + - -55.74423117768513 + - -55.23885575129537 gradient: - - - - -0.03372523116559023 - - -2.764863893389702e-10 - - 0.26136704023519997 - - - -0.008714425268408377 - - 0.0 - - -0.2365978183443076 - - - 0.042439656441274565 - - -9.822542779147625e-10 - - -0.02476922194182407 - - - - 0.2866000548528973 - - -2.764863893389702e-10 - - -0.17458795646962244 - - - -0.008658038743305951 - - 1.8917489796876907e-10 - - 0.08594474392884877 - - - -0.27794201617507497 - - -1.0695657692849636e-09 - - 0.08864321248984197 - - - - -0.04636269856564468 - - -1.0186340659856796e-10 - - -0.07565938049810939 - - - 0.024945780118287075 - - 1.8189894035458565e-10 - - 0.055314066099526826 - - - 0.02141691842552973 - - -1.0331859812140465e-09 - - 0.020345314340374898 + - - - 0.11375777707144152 + - -1.331500243395567e-09 + - 0.07506357514648698 + - - -0.006232492123672273 + - -3.637978807091713e-10 + - -0.10649733602622291 + - - -0.10752528467128286 + - -2.0372681319713593e-10 + - 0.03143375625950284 + - - - 0.13675109334872104 + - -6.693881005048752e-10 + - 0.10287793782481458 + - - -0.010133748306543566 + - 1.4551915228366852e-11 + - -0.1369299911748385 + - - -0.12661734534049174 + - -6.111804395914078e-10 + - 0.03405204899900127 + - - - -0.03586818568146555 + - -7.930793799459934e-10 + - -0.025053270430362318 + - - 0.02807350151852006 + - 2.9103830456733704e-11 + - -0.0019544456590665504 + - - 0.007794683813699521 + - -6.83940015733242e-10 + - 0.027007712196791545 cvs-adc2: config: conv_tol: 1.0e-10 core_orbitals: 1 n_singlets: 3 energy: - - -56.46868063899562 - - -56.396097719334435 - - -55.95581763596337 + - -56.46332440074828 + - -56.391989744501316 + - -55.93190966430339 gradient: - - - - 0.04470823770679999 - - -1.5279510989785194e-10 - - 0.02979605806467589 - - - -0.000826693642011378 - - 4.874891601502895e-10 - - -0.04439577142329654 - - - -0.04388154352636775 - - 1.7971615307033062e-09 - - 0.014599713707866613 - - - - 0.07792510495346505 - - 3.41970007866621e-10 - - -0.01978135977697093 - - - 0.0033010937258950435 - - 7.34871719032526e-10 - - -0.012651039585762192 - - - -0.08122619819187094 - - 1.4988472685217857e-09 - - 0.032432399653771427 - - - - 0.01100964911893243 - - -2.9103830456733704e-11 - - 0.27079433167818934 - - - -0.020936590030032676 - - 4.656612873077393e-10 - - -0.24384732514590723 - - - 0.009926940307195764 - - 1.2005330063402653e-09 - - -0.026947005331749097 + - - - 0.06425007329380605 + - -2.0372681319713593e-10 + - 0.045520456616941374 + - - -0.0016864021308720112 + - 1.7462298274040222e-10 + - -0.06586711251293309 + - - -0.06256367015157593 + - 4.94765117764473e-10 + - 0.02034665203973418 + - - - 0.05899445249087876 + - -1.1641532182693481e-10 + - 0.042361968677141704 + - - 0.005970590449578594 + - 5.820766091346741e-10 + - -0.07167667950125178 + - - -0.06496504115784774 + - 5.238689482212067e-10 + - 0.029314706844161265 + - - - 0.26677660679706605 + - 5.456968210637569e-10 + - 0.18210555951372953 + - - -0.08747911756654503 + - 3.2014213502407074e-10 + - -0.1527887543925317 + - - -0.17929748757887864 + - 4.001776687800884e-10 + - -0.029316808613657486 mp2: config: conv_tol: 1.0e-10 core_orbitals: null - energy: -76.22782604596462 + energy: -76.22940338787343 gradient: - - - 0.02722284314222634 - - -4.729372449219227e-10 - - -0.031916180152620655 - - - -0.011739261986804195 - - 2.9831426218152046e-10 - - 0.03957825406541815 - - - -0.015483581461012363 - - -1.964508555829525e-10 - - -0.007662073971005157 + - - 0.024395444932451937 + - 2.1827872842550278e-11 + - 0.017738172486133408 + - - -0.010762450183392502 + - -3.2741809263825417e-10 + - -0.011150373306008987 + - - -0.013632995331136044 + - -5.456968210637569e-10 + - -0.006587800562556367 sto3g: adc0: config: @@ -247,218 +247,218 @@ h2o: core_orbitals: null n_singlets: 3 energy: - - -74.0019688397994 - - -73.94965453238807 - - -73.8344020173517 + - -73.96883482604385 + - -73.91481187944893 + - -73.80575589478214 gradient: - - - - 0.13705831066909013 - - 5.820766091346741e-11 - - 0.18181194815406343 - - - 0.06608801558468258 - - 1.4551915228366852e-10 - - -0.327658184345637 - - - -0.20314632572990377 - - 1.673470251262188e-10 - - 0.145846236286161 - - - - 0.08338179645943455 - - -5.093170329928398e-11 - - 0.1518377511165454 - - - 0.1140654268237995 - - 1.2369127944111824e-10 - - -0.34937012573936954 - - - -0.19744722267932957 - - 1.6007106751203537e-10 - - 0.19753237475379137 - - - - 0.5686268089411897 + - - - 0.21500520455447258 + - 4.3655745685100555e-11 + - 0.15122539418371161 + - - 0.07489849286503159 - -2.9103830456733704e-11 - - 0.12125163560267538 - - - -0.08567677011160413 - - 2.546585164964199e-10 - - -0.19621638042735867 - - - -0.48295003822568106 - - 1.964508555829525e-10 - - 0.07496474481740734 + - -0.33320423508121166 + - - -0.2899036972085014 + - 2.6921043172478676e-10 + - 0.18197884054097813 + - - - 0.1586926042145933 + - 1.8917489796876907e-10 + - 0.1113579275115626 + - - 0.12612935147626558 + - 1.4551915228366852e-11 + - -0.3458573079697089 + - - -0.2848219556399272 + - 3.2014213502407074e-10 + - 0.23449938000703696 + - - - 0.48839781545393635 + - 1.7462298274040222e-10 + - 0.3478099742424092 + - - -0.09521430329186842 + - -8.003553375601768e-11 + - -0.3859635302214883 + - - -0.3931835119583411 + - 2.837623469531536e-10 + - 0.03815355561528122 adc1: config: conv_tol: 1.0e-10 core_orbitals: null n_singlets: 3 energy: - - -74.51060274422295 - - -74.4085479327883 - - -74.38557201922058 + - -74.47588319597367 + - -74.38511885048034 + - -74.35718229209289 gradient: - - - - 0.1406407395406859 - - 7.275957614183426e-11 - - 0.25841968974418705 - - - 0.03273143563274061 - - 3.2014213502407074e-10 - - -0.3563950436437153 - - - -0.1733721751079429 - - 1.4551915228366852e-11 - - 0.09797535414691083 - - - - 0.5556795187294483 - - 7.275957614183426e-11 - - 0.03544072069780668 - - - -0.06908151321840705 - - 3.637978807091713e-10 - - -0.13027163009246578 - - - -0.48659800561290467 - - 0.0 - - 0.09483090981666464 - - - - 0.02303558652056381 - - 2.9103830456733704e-11 - - 0.12416511945048114 - - - 0.10509999340138165 - - 3.2741809263825417e-10 - - -0.2871401479060296 - - - -0.12813558006018866 - - -1.3096723705530167e-10 - - 0.16297502868110314 + - - - 0.25195657529548043 + - -2.1827872842550278e-10 + - 0.17643765256070765 + - - 0.04383796524780337 + - 2.6921043172478676e-10 + - -0.32756816231267294 + - - -0.2957945398375159 + - 5.165929906070232e-10 + - 0.1511305099556921 + - - - 0.442040198999166 + - -1.382431946694851e-10 + - 0.31597312489611795 + - - -0.08205663933040341 + - 2.6193447411060333e-10 + - -0.3563313630511402 + - - -0.3599835591230658 + - 5.238689482212067e-10 + - 0.04035823853337206 + - - - 0.10246272881340701 + - -1.964508555829525e-10 + - 0.07140888807043666 + - - 0.11964530246768845 + - 4.0745362639427185e-10 + - -0.2768455885379808 + - - -0.22210803076450247 + - 4.5838532969355583e-10 + - 0.20543670070037479 adc2: config: conv_tol: 1.0e-10 core_orbitals: null n_singlets: 3 energy: - - -74.55947664226723 - - -74.44726454912804 - - -74.42978867078602 + - -74.52306494758528 + - -74.42102314285333 + - -74.39990473420058 gradient: - - - - 0.17020479583152337 - - 2.9103830456733704e-10 - - 0.2600022303231526 - - - 0.033973511679505464 - - -3.637978807091713e-11 - - -0.37026691834034864 - - - -0.20417830784572288 - - 3.637978807091713e-11 - - 0.11026468882482732 - - - - 0.5719732884899713 - - 1.5279510989785194e-10 - - 0.06949814612744376 - - - -0.07365445757750422 - - -1.6007106751203537e-10 - - -0.16335719605558552 - - - -0.49831883128354093 - - 4.3655745685100555e-11 - - 0.0938590508812922 - - - - 0.04531770349422004 - - 2.1100277081131935e-10 - - 0.13285037758760154 - - - 0.10278100873256335 - - -1.7462298274040222e-10 - - -0.30029255025146995 - - - -0.1480987125323736 - - 2.1827872842550278e-11 - - 0.16744217359519098 + - - - 0.2729663031277596 + - 1.0913936421275139e-10 + - 0.19153599694254808 + - - 0.043751713892561384 + - -3.5652192309498787e-10 + - -0.34997767178720096 + - - -0.3167180167583865 + - 1.4551915228366852e-11 + - 0.1584416747573414 + - - - 0.4661114453920163 + - 1.382431946694851e-10 + - 0.33271835774212377 + - - -0.08526563971827272 + - -3.710738383233547e-10 + - -0.37705514777917415 + - - -0.3808458055500523 + - -5.093170329928398e-11 + - 0.04433679011708591 + - - - 0.1245402096392354 + - 1.3096723705530167e-10 + - 0.08709251073014457 + - - 0.11524763711349806 + - -3.2014213502407074e-10 + - -0.2941215329556144 + - - -0.23978784657083452 + - -2.0372681319713593e-10 + - 0.20702902220364194 cvs-adc0: config: conv_tol: 1.0e-10 core_orbitals: 1 n_singlets: 3 energy: - - -54.15142983310513 - - -53.98386301065745 + - -54.12308247440467 + - -53.96000354314298 gradient: - - - - 0.058952584775397554 + - - - 0.13670422898576362 + - -2.1827872842550278e-10 + - 0.09585740156762768 + - - 0.09903088489954825 - 2.1827872842550278e-11 - - 0.12914131818251917 - - - 0.08902289317484247 - - 3.128661774098873e-10 - - -0.28114005003590137 - - - -0.14797547737543937 - - 2.4010660126805305e-10 - - 0.15199873215169646 - - - - 0.4905210832148441 - - 1.0913936421275139e-10 - - 0.06858100574027048 - - - -0.06274189250689233 - - 3.055902197957039e-10 - - -0.14969824595027603 - - - -0.42777919000945985 - - 1.673470251262188e-10 - - 0.08111724067566684 + - -0.28425848668121034 + - - -0.23573511373979272 + - 2.9103830456733704e-11 + - 0.18840108531730948 + - - - 0.4100968398124678 + - -3.92901711165905e-10 + - 0.2924419814662542 + - - -0.07108191138104303 + - -2.9103830456733704e-11 + - -0.3370177816977957 + - - -0.33901492819859413 + - -7.275957614183426e-12 + - 0.04457580055168364 cvs-adc1: config: conv_tol: 1.0e-10 core_orbitals: 1 n_singlets: 3 energy: - - -54.88357905577345 - - -54.809524644818794 + - -54.85354413664418 + - -54.794194263197895 gradient: - - - - 0.06829834913514787 - - 0.0 - - 0.2580054614081746 - - - 0.02385972173215123 - - -2.1100277081131935e-10 - - -0.31731734403729206 - - - -0.09215807118744124 - - -8.731149137020111e-11 - - 0.0593118825709098 - - - - 0.4508793811837677 - - -1.382431946694851e-10 - - -0.08415120123390807 - - - -0.021005132897698786 - - -2.1827872842550278e-11 - - -0.0444243764213752 - - - -0.42987424850434763 + - - - 0.20441432894585887 - -2.1827872842550278e-10 - - 0.12857557724055368 + - 0.14198894465516787 + - - 0.03388333941984456 + - 5.384208634495735e-10 + - -0.26222279915964464 + - - -0.2382976672015502 + - 1.1641532182693481e-10 + - 0.12023385440261336 + - - - 0.31129172753571765 + - -2.1827872842550278e-10 + - 0.22435429711913457 + - - -0.03036278410581872 + - 4.001776687800884e-10 + - -0.29155276875098934 + - - -0.28092894230940146 + - 9.458744898438454e-11 + - 0.06719847128260881 cvs-adc2: config: conv_tol: 1.0e-10 core_orbitals: 1 n_singlets: 3 energy: - - -55.02093815653659 - - -54.92677054397544 - - -53.229688323679106 + - -54.9890358908465 + - -54.90586009813954 + - -53.166856815521605 gradient: - - - - 0.12702887241903227 - - 1.382431946694851e-10 - - 0.24607893297070405 - - - 0.025679726655653212 - - 1.964508555829525e-10 - - -0.3288504496886162 - - - -0.15270859879092313 - - 3.346940502524376e-10 - - 0.08277151715446962 - - - - 0.47759714353014715 - - 2.1827872842550278e-10 - - -0.006451136745454278 - - - -0.03548169860732742 - - 2.473825588822365e-10 - - -0.1102512873330852 - - - -0.44211544460995356 - - 4.147295840084553e-10 - - 0.11670242427499034 - - - - 0.14492260904080467 - - 2.6193447411060333e-10 - - 0.3483884663801291 - - - 0.17419836726185167 - - 2.1827872842550278e-10 - - -0.6562768366129603 - - - -0.31912097631720826 - - 5.675246939063072e-10 - - 0.3078883705238695 + - - - 0.23872009348269785 + - -5.820766091346741e-11 + - 0.1671009855272132 + - - 0.03348872406058945 + - -2.3283064365386963e-10 + - -0.2989140243153088 + - - -0.2722088166483445 + - -1.6007106751203537e-10 + - 0.13181303901365027 + - - - 0.3619300219070283 + - -9.458744898438454e-11 + - 0.2592484423876158 + - - -0.04305156569898827 + - -2.837623469531536e-10 + - -0.32641974019497866 + - - -0.31887845518940594 + - -3.8562575355172157e-10 + - 0.0671712980765733 + - - - 0.3055688014064799 + - -1.5279510989785194e-10 + - 0.21378263975930167 + - - 0.1921237775386544 + - -1.6007106751203537e-10 + - -0.5935662731717457 + - - -0.49769257780280896 + - -3.128661774098873e-10 + - 0.3797836339508649 mp2: config: conv_tol: 1.0e-10 core_orbitals: null - energy: -74.99662576528117 + energy: -74.99357808910257 gradient: - - - 0.10250254614948062 - - -8.003553375601768e-11 - - 0.0019376771888346411 - - - -0.026987519930116832 - - 3.128661774098873e-10 - - 0.0015533916157437488 - - - -0.07551502659043763 - - -9.458744898438454e-11 - - -0.0034910689064417966 - xyz: "\n O 0 0 0\n H 0 0 1.895239827225189\n H 1.693194615993441 0 -0.599043184453037\n\ + - - 0.09648089337861165 + - 1.6007106751203537e-10 + - 0.06886449090234237 + - - -0.02618346236704383 + - -3.637978807091713e-11 + - -0.06597386241628556 + - - -0.07029743136808975 + - 5.093170329928398e-11 + - -0.00289062818774255 + xyz: "\n O 0 0 0\n H 0 0 1.795239827225189\n H 1.693194615993441 0 -0.599043184453037\n\ \ " methods: - mp2 diff --git a/adcc/testdata/static_data.py b/adcc/testdata/static_data.py index fd1a7acd9..53150dd55 100644 --- a/adcc/testdata/static_data.py +++ b/adcc/testdata/static_data.py @@ -21,29 +21,6 @@ ## ## --------------------------------------------------------------------- import os -from dataclasses import dataclass - - -@dataclass -class Molecule: - name: str - charge: int = 0 - multiplicity: int = 1 - core_orbitals: int = 1 - - @property - def xyz(self): - return xyz[self.name] - - -molecules = [ - Molecule("h2o", 0, 1), - Molecule("h2s", 0, 1), - # Molecule("cn", 0, 2), - # "ch2nh2", - # Molecule("hf", 0, 1), - # Molecule("formaldehyde", 0, 1), -] # all coordinates in Bohr From 6ba9bc51e61bb23e6d4e2a188b204e9ab927f812 Mon Sep 17 00:00:00 2001 From: Maximilian Scheurer Date: Sun, 19 Dec 2021 16:44:07 +0100 Subject: [PATCH 11/18] add adc2x gradients, fix cvs-adc2x energy stuff --- adcc/gradients/__init__.py | 6 +- adcc/gradients/amplitude_response.py | 21 +- adcc/gradients/orbital_response.py | 10 +- .../gradients/test_functionality_gradients.py | 2 +- adcc/testdata/dump_fdiff_gradient.py | 3 +- adcc/testdata/grad_dump.yml | 844 +++++++++++------- 6 files changed, 527 insertions(+), 359 deletions(-) diff --git a/adcc/gradients/__init__.py b/adcc/gradients/__init__.py index 3d16b2334..875684a87 100644 --- a/adcc/gradients/__init__.py +++ b/adcc/gradients/__init__.py @@ -151,6 +151,7 @@ def nuclear_gradient(excitation_or_mp): w = energy_weighted_density_matrix(hf, g1o, g2a) # build two-particle density matrices for contraction with TEI + # prefactors see eqs 17 and A4 in 10.1063/1.5085117 with timer.record("form_tpdm"): g2_hf = TwoParticleDensityMatrix(hf) g2_oresp = TwoParticleDensityMatrix(hf) @@ -183,8 +184,7 @@ def nuclear_gradient(excitation_or_mp): g2a.oovv *= 0.5 g2a.ccvv *= 0.5 g2a.occv *= 2.0 - g2a.vvvv *= 0.25 # Scaling twice! - g2a.vvvv *= 0.25 # it's the only way it works... + g2a.vvvv *= 0.25 g2_total = evaluate(g2_hf + g2a + g2_oresp) else: @@ -198,6 +198,8 @@ def nuclear_gradient(excitation_or_mp): # scale for contraction with integrals g2a.oovv *= 0.5 + g2a.oooo *= 0.25 + g2a.vvvv *= 0.25 g2_total = evaluate(g2_hf + g2a + g2_oresp) with timer.record("transform_ao"): diff --git a/adcc/gradients/amplitude_response.py b/adcc/gradients/amplitude_response.py index 2adf4325b..bf559997d 100644 --- a/adcc/gradients/amplitude_response.py +++ b/adcc/gradients/amplitude_response.py @@ -114,7 +114,6 @@ def ampl_relaxed_dms_cvs_adc1(exci): fc = hf.fock(b.cc).diagonal() fo = hf.fock(b.oo).diagonal() fco = direct_sum("-j+I->jI", fc, fo).evaluate() - # These are the multipliers: g1a.co = - 1.0 * einsum('JbKc,ibKc->Ji', g2a.cvcv, hf.ovcv) / fco return g1a, g2a @@ -215,7 +214,7 @@ def ampl_relaxed_dms_cvs_adc2x(exci): t2oovv = mp.t2(b.oovv) t2ccvv = mp.t2(b.ccvv) t2ocvv = mp.t2(b.ocvv) - g1a_cvs0, g2a_cvs0 = ampl_relaxed_dms_cvs_adc0(exci) + g1a_cvs0, _ = ampl_relaxed_dms_cvs_adc0(exci) t2bar = t2bar_oovv_cvs_adc2(exci, g1a_cvs0).evaluate() g1a.cc = ( @@ -279,7 +278,11 @@ def ampl_relaxed_dms_cvs_adc2x(exci): g2a.ccvv = - 1.0 * t2ccvv g2a.ocvv = - 1.0 * t2ocvv g2a.ococ = 1.0 * einsum("iJab,kLab->iJkL", u.pphh, u.pphh) - g2a.vvvv = 2.0 * einsum("iJcd,iJab->abcd", u.pphh, u.pphh) + g2a.vvvv = 1.0 * einsum("iJcd,iJab->abcd", u.pphh, u.pphh) + + # TODO: remove + # g2a.ococ *= 0.0 + # g2a.vvvv *= 0.0 g1a.co = ( - 1.0 * einsum('JbKc,ibKc->Ji', g2a.cvcv, hf.ovcv) @@ -334,6 +337,17 @@ def ampl_relaxed_dms_adc2(exci): return g1a, g2a +def ampl_relaxed_dms_adc2x(exci): + u = exci.excitation_vector + g1a, g2a = ampl_relaxed_dms_adc2(exci) + + g2a.ovov += -4.0 * einsum("ikbc,jkac->iajb", u.pphh, u.pphh) + g2a.oooo = 2.0 * einsum('ijab,klab->ijkl', u.pphh, u.pphh) + g2a.vvvv = 2.0 * einsum('ijcd,ijab->abcd', u.pphh, u.pphh) + + return g1a, g2a + + def ampl_relaxed_dms_mp2(mp): hf = mp.reference_state t2 = mp.t2(b.oovv) @@ -350,6 +364,7 @@ def ampl_relaxed_dms_mp2(mp): "adc0": ampl_relaxed_dms_adc0, "adc1": ampl_relaxed_dms_adc1, "adc2": ampl_relaxed_dms_adc2, + "adc2x": ampl_relaxed_dms_adc2x, "cvs-adc0": ampl_relaxed_dms_cvs_adc0, "cvs-adc1": ampl_relaxed_dms_cvs_adc1, "cvs-adc2": ampl_relaxed_dms_cvs_adc2, diff --git a/adcc/gradients/orbital_response.py b/adcc/gradients/orbital_response.py index d9342d2b6..0b1b2ab03 100644 --- a/adcc/gradients/orbital_response.py +++ b/adcc/gradients/orbital_response.py @@ -86,7 +86,7 @@ def orbital_response_rhs(hf, g1a, g2a): # matrix when lambda_ov multipliers are zero w_ov = 0.5 * ( + 1.0 * einsum("ijkl,klja->ia", hf.oooo, g2a.ooov) # not in cvs-adc - # - 1.0 * einsum("ibcd,abcd->ia", hf.ovvv, g2a.vvvv) + - 1.0 * einsum("ibcd,abcd->ia", hf.ovvv, g2a.vvvv) - 1.0 * einsum("jkib,jkab->ia", hf.ooov, g2a.oovv) + 2.0 * einsum("ijkb,jakb->ia", hf.ooov, g2a.ovov) + 1.0 * einsum("ijbc,jabc->ia", hf.oovv, g2a.ovvv) @@ -96,7 +96,7 @@ def orbital_response_rhs(hf, g1a, g2a): ret_ov = -1.0 * ( 2.0 * w_ov - # - 1.0 * einsum("klja,ijkl->ia", hf.ooov, g2a.oooo) + - 1.0 * einsum("klja,ijkl->ia", hf.ooov, g2a.oooo) + 1.0 * einsum("abcd,ibcd->ia", hf.vvvv, g2a.ovvv) - 2.0 * einsum("jakb,ijkb->ia", hf.ovov, g2a.ooov) # not in cvs-adc + 1.0 * einsum("jkab,jkib->ia", hf.oovv, g2a.ooov) # not in cvs-adc @@ -220,7 +220,7 @@ def energy_weighted_density_matrix(hf, g1o, g2a): ) else: gi_oo = -0.5 * ( - # + 1.0 * einsum("jklm,iklm->ij", hf.oooo, g2a.oooo) + + 1.0 * einsum("jklm,iklm->ij", hf.oooo, g2a.oooo) + 1.0 * einsum("jabc,iabc->ij", hf.ovvv, g2a.ovvv) + 1.0 * einsum("klja,klia->ij", hf.ooov, g2a.ooov) + 2.0 * einsum("jkla,ikla->ij", hf.ooov, g2a.ooov) @@ -229,7 +229,7 @@ def energy_weighted_density_matrix(hf, g1o, g2a): ) gi_vv = -0.5 * ( + 1.0 * einsum("kjib,kjia->ab", hf.ooov, g2a.ooov) - # + einsum("bcde,acde->ab", hf.vvvv, g2a.vvvv) + + einsum("bcde,acde->ab", hf.vvvv, g2a.vvvv) + 1.0 * einsum("ijcb,ijca->ab", hf.oovv, g2a.oovv) + 2.0 * einsum("jcib,jcia->ab", hf.ovov, g2a.ovov) + 1.0 * einsum("ibcd,iacd->ab", hf.ovvv, g2a.ovvv) @@ -241,7 +241,7 @@ def energy_weighted_density_matrix(hf, g1o, g2a): w.ov = 0.5 * ( - 2.0 * einsum("ij,ja->ia", hf.foo, g1o.ov) + 1.0 * einsum("ijkl,klja->ia", hf.oooo, g2a.ooov) - # - 1.0 * einsum("ibcd,abcd->ia", hf.ovvv, g2a.vvvv) + - 1.0 * einsum("ibcd,abcd->ia", hf.ovvv, g2a.vvvv) - 1.0 * einsum("jkib,jkab->ia", hf.ooov, g2a.oovv) + 2.0 * einsum("ijkb,jakb->ia", hf.ooov, g2a.ovov) + 1.0 * einsum("ijbc,jabc->ia", hf.oovv, g2a.ovvv) diff --git a/adcc/gradients/test_functionality_gradients.py b/adcc/gradients/test_functionality_gradients.py index 99a8c6145..c4237417b 100644 --- a/adcc/gradients/test_functionality_gradients.py +++ b/adcc/gradients/test_functionality_gradients.py @@ -62,7 +62,7 @@ def template_nuclear_gradient(self, molecule, basis, method, backend): # TODO: convergence needs to be very very tight... # so we want to make sure all vectors are tightly converged n_limit = 2 - kwargs["n_singlets"] = kwargs["n_singlets"] + 2 + kwargs["n_singlets"] = kwargs["n_singlets"] + 6 state = adcc.run_adc(scfres, method=method, **kwargs) for ee in state.excitations[:n_limit]: grad = adcc.nuclear_gradient(ee) diff --git a/adcc/testdata/dump_fdiff_gradient.py b/adcc/testdata/dump_fdiff_gradient.py index 1efc345e2..8ee58611b 100644 --- a/adcc/testdata/dump_fdiff_gradient.py +++ b/adcc/testdata/dump_fdiff_gradient.py @@ -132,10 +132,11 @@ def main(): "adc0", "adc1", "adc2", + "adc2x", "cvs-adc0", "cvs-adc1", "cvs-adc2", - # "cvs-adc2x", # TODO: broken + "cvs-adc2x", # TODO: broken ] molnames = [ "h2o", diff --git a/adcc/testdata/grad_dump.yml b/adcc/testdata/grad_dump.yml index 4cb9e34db..dd5967f05 100644 --- a/adcc/testdata/grad_dump.yml +++ b/adcc/testdata/grad_dump.yml @@ -9,74 +9,74 @@ h2o: core_orbitals: null n_singlets: 3 energy: - - -75.34687593732804 + - -75.34687593732802 - -75.28099897302934 - - -75.27790714502396 + - -75.27790714502395 gradient: - - - - 0.057817726978100836 - - 1.7462298274040222e-10 - - 0.041246958971896674 - - - -0.0010630958640831523 - - 4.001776687800884e-10 - - -0.06019927666056901 - - - -0.05675463302759454 - - 8.658389560878277e-10 - - 0.018952317368530203 - - - - 0.013116452282702085 - - 1.0550138540565968e-09 - - 0.009581871010595933 - - - 0.051721488212933764 - - -3.346940502524376e-10 - - -0.08735981997597264 - - - -0.0648379398699035 - - 2.2264430299401283e-09 - - 0.077777945996786 - - - - 0.035870219639036804 - - 3.128661774098873e-10 - - 0.02591435432259459 - - - 0.007818773170583881 - - 1.673470251262188e-10 - - -0.049661279255815316 - - - -0.043688994912372436 - - 1.2441887520253658e-09 - - 0.023746924664010294 + - - - 0.05781772705813637 + - 6.257323548197746e-10 + - 0.04124695902282838 + - - -0.0010630972392391413 + - 4.3655745685100555e-10 + - -0.0601992766969488 + - - -0.05675463159423089 + - -1.673470251262188e-10 + - 0.01895231872185832 + - - - 0.013116451358655468 + - 1.9354047253727913e-09 + - 0.009581870690453798 + - - 0.051721489333431236 + - -1.8189894035458565e-10 + - -0.0873598225225578 + - - -0.06483794018276967 + - -7.8580342233181e-10 + - 0.07777794692810858 + - - - 0.035870219362550415 + - 8.149072527885437e-10 + - 0.025914354242559057 + - - 0.007818771875463426 + - 2.3283064365386963e-10 + - -0.04966127932857489 + - - -0.043688993180694524 + - -3.710738383233547e-10 + - 0.023746926133753732 adc1: config: conv_tol: 1.0e-10 core_orbitals: null n_singlets: 3 energy: - - -75.68543998437538 - - -75.61931016176942 - - -75.5986895025849 + - -75.68543998437549 + - -75.61931016176952 + - -75.59868950258502 gradient: - - - - 0.09274008982174564 - - -8.585629984736443e-10 - - 0.06558011067681946 - - - -0.00263022055150941 - - -8.949427865445614e-10 - - -0.09467176407633815 - - - -0.09010986890643835 - - 4.43833414465189e-10 - - 0.029091649477777537 - - - - 0.10931798827368766 - - -8.731149137020111e-10 - - 0.07809554480627412 - - - -0.0066607073895283975 - - -8.440110832452774e-10 - - -0.10735300954547711 - - - -0.10265728056401713 - - 2.473825588822365e-10 - - 0.029257460868393537 - - - - 0.011670264706481248 - - -8.003553375601768e-10 - - 0.008451193090877496 - - - 0.05684483524237294 - - -2.473825588822365e-10 - - -0.09296222138800658 - - - -0.06851510026172036 - - -2.1827872842550278e-10 - - 0.08451102524122689 + - - - 0.09274008955253521 + - -2.2846506908535957e-09 + - 0.06558011218294268 + - - -0.002630220929859206 + - -5.529727786779404e-10 + - -0.09467176473117433 + - - -0.09010986990324454 + - 4.3655745685100555e-11 + - 0.029091649295878597 + - - - 0.1093179879244417 + - -2.3283064365386963e-09 + - 0.07809554620325798 + - - -0.0066607077096705325 + - -5.602487362921238e-10 + - -0.10735300996020669 + - - -0.10265728145168396 + - 2.1827872842550278e-11 + - 0.0292574607374263 + - - - 0.011670265019347426 + - -4.802132025361061e-10 + - 0.008451194829831365 + - - 0.05684483542427188 + - -2.6193447411060333e-10 + - -0.092962221315247 + - - -0.06851509893022012 + - -5.966285243630409e-10 + - 0.08451102513208752 adc2: config: conv_tol: 1.0e-10 @@ -87,159 +87,233 @@ h2o: - -75.85499790115735 - -75.84309170418108 gradient: - - - - 0.11448501909762854 - - -6.693881005048752e-10 - - 0.08113867693464272 - - - -0.008900642395019531 - - -1.4551915228366852e-11 - - -0.10905679843563121 - - - -0.10558437446161406 - - 1.7389538697898388e-09 - - 0.027918118954403326 - - - - 0.11318148785358062 - - -6.475602276623249e-10 - - 0.08065584021096583 - - - -0.0044726147534674965 - - 1.2369127944111824e-10 - - -0.11437428747012746 - - - -0.10870887096825754 - - 1.6443664208054543e-09 - - 0.03371844420325942 - - - - 0.022055651716073044 - - -6.184563972055912e-10 - - 0.015903128674835898 - - - 0.050984123306989204 - - 7.275957614183426e-12 - - -0.0958010385002126 - - - -0.07303977613628376 - - -5.093170329928398e-11 - - 0.07989790841384092 + - - - 0.11448501647100784 + - -1.964508555829525e-10 + - 0.08113867735664826 + - - -0.008900643704691902 + - 1.8917489796876907e-10 + - -0.10905679834831972 + - - -0.10558437482541194 + - 9.458744898438454e-11 + - 0.027918118568777572 + - - - 0.11318148521968396 + - -3.637978807091713e-10 + - 0.08065584087307798 + - - -0.0044726159612764604 + - 5.093170329928398e-11 + - -0.1143742871718132 + - - -0.10870887125929585 + - 1.3096723705530167e-10 + - 0.033718444225087296 + - - - 0.022055652378185187 + - -5.165929906070232e-10 + - 0.015903128252830356 + - - 0.05098412436200306 + - 3.637978807091713e-11 + - -0.0958010398899205 + - - -0.07303977609990397 + - 5.020410753786564e-10 + - 0.07989790866849944 + adc2x: + config: + conv_tol: 1.0e-10 + core_orbitals: null + n_singlets: 3 + energy: + - -75.94713027654683 + - -75.87072120070408 + - -75.86069046648016 + gradient: + - - - 0.12108468703081599 + - 3.346940502524376e-10 + - 0.08575623762590112 + - - -0.008930197138397489 + - -1.4551915228366852e-10 + - -0.11596749711316079 + - - -0.11215449091832852 + - 2.4374458007514477e-09 + - 0.03021125582017703 + - - - 0.12104129973886302 + - 4.874891601502895e-10 + - 0.0862211757703335 + - - -0.005538591591175646 + - -2.9831426218152046e-10 + - -0.12121302761079278 + - - -0.11550270940642804 + - 2.4156179279088974e-09 + - 0.03499184796237387 + - - - 0.027651791788230184 + - 3.7834979593753815e-10 + - 0.019813940474705305 + - - 0.050617610570043325 + - -4.511093720793724e-10 + - -0.10117346337938216 + - - -0.0782694015360903 + - 7.930793799459934e-10 + - 0.08135951928852592 cvs-adc0: config: conv_tol: 1.0e-10 core_orbitals: 1 n_singlets: 3 energy: - - -55.29234315857765 - - -55.22337436627358 - - -54.66716620632244 + - -55.29234315857754 + - -55.22337436627346 + - -54.66716620632232 gradient: - - - - -0.013647946245328058 - - -1.7025740817189217e-09 - - -0.009335996597656049 - - - 0.005706507130526006 - - 3.710738383233547e-10 - - 0.006095208795159124 - - - 0.00794144003157271 - - -7.421476766467094e-10 - - 0.003240786063543055 - - - - -0.03559545403550146 - - -1.8335413187742233e-09 - - -0.02466860137792537 - - - 0.014588375917810481 - - 3.5652192309498787e-10 - - 0.016633206469123252 - - - 0.021007078685215674 - - -7.566995918750763e-10 - - 0.008035393540922087 - - - - 0.29560477212362457 - - -1.760781742632389e-09 - - 0.2022045077465009 - - - -0.11422410259547178 - - 3.4924596548080444e-10 - - -0.14526787276554387 - - - -0.1813806689606281 - - -6.402842700481415e-10 - - -0.05693663642887259 + - - - -0.013647946063429117 + - -2.255546860396862e-10 + - -0.009335993825516198 + - - 0.005706505660782568 + - -3.637978807091713e-10 + - 0.0060952052372158505 + - - 0.007941436808323488 + - 7.203198038041592e-10 + - 0.003240785124944523 + - - - -0.03559545367170358 + - -2.9103830456733704e-11 + - -0.024668598533025943 + - - 0.0145883748846245 + - -2.4010660126805305e-10 + - 0.016633202772936784 + - - 0.021007075076340698 + - 5.529727786779404e-10 + - 0.008035392536839936 + - - - 0.29560477242193883 + - -7.275957614183426e-12 + - 0.2022045104240533 + - - -0.11422410370869329 + - -1.8189894035458565e-10 + - -0.14526787639624672 + - - -0.18138067236577626 + - 5.675246939063072e-10 + - -0.05693663733109133 cvs-adc1: config: conv_tol: 1.0e-10 core_orbitals: 1 n_singlets: 3 energy: - - -55.76235801206991 - - -55.74423117768513 - - -55.23885575129537 + - -55.76235801207001 + - -55.744231177685215 + - -55.23885575129546 gradient: - - - - 0.11375777707144152 - - -1.331500243395567e-09 - - 0.07506357514648698 - - - -0.006232492123672273 - - -3.637978807091713e-10 - - -0.10649733602622291 - - - -0.10752528467128286 - - -2.0372681319713593e-10 - - 0.03143375625950284 - - - - 0.13675109334872104 + - - - 0.11375777858484071 + - -1.4406396076083183e-09 + - 0.07506357455713442 + - - -0.0062324921527761035 + - 9.89530235528946e-10 + - -0.10649733267200645 + - - -0.10752528614830226 + - 1.964508555829525e-10 + - 0.03143375667423243 + - - - 0.13675109380710637 + - -8.294591680169106e-10 + - 0.10287793739553308 + - - -0.01013374753529206 + - 2.9831426218152046e-10 + - -0.13692998851911398 + - - -0.12661734605353558 + - -5.529727786779404e-10 + - 0.034052050090394914 + - - - -0.03586818531766767 + - -9.167706593871117e-10 + - -0.025053271041542757 + - - 0.028073502020561136 + - 1.0913936421275139e-10 + - -0.0019544431124813855 + - - 0.007794683217070997 - -6.693881005048752e-10 - - 0.10287793782481458 - - - -0.010133748306543566 - - 1.4551915228366852e-11 - - -0.1369299911748385 - - - -0.12661734534049174 - - -6.111804395914078e-10 - - 0.03405204899900127 - - - - -0.03586818568146555 - - -7.930793799459934e-10 - - -0.025053270430362318 - - - 0.02807350151852006 - - 2.9103830456733704e-11 - - -0.0019544456590665504 - - - 0.007794683813699521 - - -6.83940015733242e-10 - - 0.027007712196791545 + - 0.02700771318632178 cvs-adc2: config: conv_tol: 1.0e-10 core_orbitals: 1 n_singlets: 3 energy: - - -56.46332440074828 - - -56.391989744501316 - - -55.93190966430339 + - -56.463324400748306 + - -56.39198974450136 + - -55.931909664303404 gradient: - - - - 0.06425007329380605 - - -2.0372681319713593e-10 - - 0.045520456616941374 - - - -0.0016864021308720112 - - 1.7462298274040222e-10 - - -0.06586711251293309 - - - -0.06256367015157593 - - 4.94765117764473e-10 - - 0.02034665203973418 - - - - 0.05899445249087876 - - -1.1641532182693481e-10 - - 0.042361968677141704 - - - 0.005970590449578594 - - 5.820766091346741e-10 - - -0.07167667950125178 - - - -0.06496504115784774 - - 5.238689482212067e-10 - - 0.029314706844161265 - - - - 0.26677660679706605 - - 5.456968210637569e-10 - - 0.18210555951372953 - - - -0.08747911756654503 - - 3.2014213502407074e-10 - - -0.1527887543925317 - - - -0.17929748757887864 - - 4.001776687800884e-10 - - -0.029316808613657486 + - - - 0.06425007180223474 + - -5.966285243630409e-10 + - 0.04552046016760869 + - - -0.0016864020508364774 + - -1.6007106751203537e-10 + - -0.06586710893316194 + - - -0.06256366953311954 + - 1.0550138540565968e-09 + - 0.020346652614534833 + - - - 0.05899445113755064 + - -9.240466170012951e-10 + - 0.04236197277350584 + - - 0.005970589867501985 + - 1.964508555829525e-10 + - -0.07167667573230574 + - - -0.06496504154347349 + - 1.3460521586239338e-09 + - 0.029314708153833635 + - - - 0.26677660683344584 + - 1.6007106751203537e-10 + - 0.1821055622640415 + - - -0.08747911845421186 + - 6.548361852765083e-11 + - -0.15278874981595436 + - - -0.17929748754249886 + - 1.2878444977104664e-09 + - -0.029316807915165555 + cvs-adc2x: + config: + conv_tol: 1.0e-10 + core_orbitals: 1 + n_singlets: 3 + energy: + - -56.52769099298715 + - -56.45532004933902 + - -56.00756567597581 + gradient: + - - - 0.08822469144070055 + - 1.5279510989785194e-10 + - 0.062298548691615 + - - -0.003546565967553761 + - -2.9103830456733704e-11 + - -0.08849690817442024 + - - -0.08467812617163872 + - -2.1827872842550278e-11 + - 0.02619835306541063 + - - - 0.0928193056024611 + - 1.673470251262188e-10 + - 0.06639222669036826 + - - -0.0013965584876132198 + - 2.1100277081131935e-10 + - -0.09725638144300319 + - - -0.09142274883197388 + - -1.673470251262188e-10 + - 0.0308641478914069 + - - - 0.2609083358402131 + - -1.7462298274040222e-10 + - 0.17750937436358072 + - - -0.0887459233563277 + - -1.5279510989785194e-10 + - -0.14432506745652063 + - - -0.1721624140845961 + - -5.820766091346741e-10 + - -0.03318431395018706 mp2: config: conv_tol: 1.0e-10 core_orbitals: null - energy: -76.22940338787343 + energy: -76.22940338787346 gradient: - - - 0.024395444932451937 - - 2.1827872842550278e-11 - - 0.017738172486133408 - - - -0.010762450183392502 - - -3.2741809263825417e-10 - - -0.011150373306008987 - - - -0.013632995331136044 - - -5.456968210637569e-10 - - -0.006587800562556367 + - - 0.024395444568654057 + - 4.001776687800884e-10 + - 0.017738173010002356 + - - -0.010762450787296984 + - 5.093170329928398e-11 + - -0.011150372803967912 + - - -0.013632995214720722 + - -2.837623469531536e-10 + - -0.006587800155102741 sto3g: adc0: config: @@ -247,165 +321,202 @@ h2o: core_orbitals: null n_singlets: 3 energy: - - -73.96883482604385 - - -73.91481187944893 - - -73.80575589478214 + - -73.96883482604382 + - -73.9148118794489 + - -73.80575589478211 gradient: - - - - 0.21500520455447258 - - 4.3655745685100555e-11 - - 0.15122539418371161 - - - 0.07489849286503159 + - - - 0.2150052047727513 + - 2.546585164964199e-10 + - 0.15122539416188374 + - - 0.07489849303965457 + - -4.3655745685100555e-11 + - -0.3332042350884876 + - - -0.2899036976523348 + - -1.8189894035458565e-10 + - 0.18197884122491814 + - - - 0.158692604440148 + - 3.92901711165905e-10 + - 0.11135792744607897 + - - 0.12612935171637218 + - 0.0 + - -0.3458573078387417 + - - -0.28482195574906655 + - 5.820766091346741e-11 + - 0.23449938092380762 + - - - 0.48839781562128337 + - 4.43833414465189e-10 + - 0.34780997406778624 + - - -0.09521430323366076 - -2.9103830456733704e-11 - - -0.33320423508121166 - - - -0.2899036972085014 - - 2.6921043172478676e-10 - - 0.18197884054097813 - - - - 0.1586926042145933 - - 1.8917489796876907e-10 - - 0.1113579275115626 - - - 0.12612935147626558 - - 1.4551915228366852e-11 - - -0.3458573079697089 - - - -0.2848219556399272 - - 3.2014213502407074e-10 - - 0.23449938000703696 - - - - 0.48839781545393635 - - 1.7462298274040222e-10 - - 0.3478099742424092 - - - -0.09521430329186842 - - -8.003553375601768e-11 - - -0.3859635302214883 - - - -0.3931835119583411 - - 2.837623469531536e-10 - - 0.03815355561528122 + - -0.38596353003231343 + - - -0.3931835122348275 + - 1.382431946694851e-10 + - 0.0381535564083606 adc1: config: conv_tol: 1.0e-10 core_orbitals: null n_singlets: 3 energy: - - -74.47588319597367 - - -74.38511885048034 + - -74.47588319597365 + - -74.38511885048032 - -74.35718229209289 gradient: - - - - 0.25195657529548043 + - - - 0.2519565752299968 - -2.1827872842550278e-10 - - 0.17643765256070765 - - - 0.04383796524780337 - - 2.6921043172478676e-10 - - -0.32756816231267294 - - - -0.2957945398375159 - - 5.165929906070232e-10 - - 0.1511305099556921 - - - - 0.442040198999166 - - -1.382431946694851e-10 - - 0.31597312489611795 - - - -0.08205663933040341 - - 2.6193447411060333e-10 - - -0.3563313630511402 - - - -0.3599835591230658 - - 5.238689482212067e-10 - - 0.04035823853337206 + - 0.176437652327877 + - - 0.04383796474576229 + - -7.275957614183426e-12 + - -0.3275681619415991 + - - -0.2957945398011361 + - 1.7462298274040222e-10 + - 0.15113050978834508 + - - - 0.44204019894095836 + - -1.6007106751203537e-10 + - 0.31597312460507965 + - - -0.08205663971602917 + - 1.1641532182693481e-10 + - -0.35633136273827404 + - - -0.359983559086686 + - 1.3096723705530167e-10 + - 0.040358238395128865 - - - 0.10246272881340701 - - -1.964508555829525e-10 - - 0.07140888807043666 - - - 0.11964530246768845 - - 4.0745362639427185e-10 - - -0.2768455885379808 - - - -0.22210803076450247 - - 4.5838532969355583e-10 - - 0.20543670070037479 + - -8.003553375601768e-11 + - 0.0714088877211907 + - - 0.1196453020820627 + - 8.731149137020111e-11 + - -0.27684558805049164 + - - -0.22210803066991502 + - 1.8917489796876907e-10 + - 0.20543670049664797 adc2: config: conv_tol: 1.0e-10 core_orbitals: null n_singlets: 3 energy: - - -74.52306494758528 + - -74.52306494758527 - -74.42102314285333 - - -74.39990473420058 + - -74.39990473420056 gradient: - - - - 0.2729663031277596 - - 1.0913936421275139e-10 - - 0.19153599694254808 - - - 0.043751713892561384 + - - - 0.27296630266937427 + - 3.2014213502407074e-10 + - 0.19153599665150978 + - - 0.0437517139071133 + - -3.7834979593753815e-10 + - -0.3499776719036163 + - - -0.3167180168675259 + - 1.5279510989785194e-10 + - 0.1584416748592048 + - - - 0.4661114449991146 + - 3.4924596548080444e-10 + - 0.3327183574583614 + - - -0.08526563958730549 + - -4.656612873077393e-10 + - -0.3770551481138682 + - - -0.380845805600984 + - 9.458744898438454e-11 + - 0.04433678997884272 + - - - 0.12454020912264241 + - 3.346940502524376e-10 + - 0.08709251055552159 + - - 0.115247637295397 + - -4.001776687800884e-10 + - -0.2941215331738931 + - - -0.2397878465562826 + - 5.820766091346741e-11 + - 0.2070290221236064 + adc2x: + config: + conv_tol: 1.0e-10 + core_orbitals: null + n_singlets: 3 + energy: + - -74.54846626885896 + - -74.4421830098894 + - -74.4221092236318 + gradient: + - - - 0.2889574766231817 + - 4.43833414465189e-10 + - 0.2026268874978996 + - - 0.0450652672079741 + - -4.802132025361061e-10 + - -0.36858359961479437 + - - -0.33402274319087155 + - -6.111804395914078e-10 + - 0.16595671245886479 + - - - 0.4846122054150328 + - 3.346940502524376e-10 + - 0.345974847303296 + - - -0.08685883981524967 + - -2.837623469531536e-10 + - -0.394604221721238 + - - -0.39775336517050164 + - -5.456968210637569e-10 + - 0.048629374519805424 + - - - 0.1366148895540391 + - 3.4924596548080444e-10 + - 0.09541060952324187 + - - 0.11530231004144298 - -3.5652192309498787e-10 - - -0.34997767178720096 - - - -0.3167180167583865 - - 1.4551915228366852e-11 - - 0.1584416747573414 - - - - 0.4661114453920163 - - 1.382431946694851e-10 - - 0.33271835774212377 - - - -0.08526563971827272 - - -3.710738383233547e-10 - - -0.37705514777917415 - - - -0.3808458055500523 - - -5.093170329928398e-11 - - 0.04433679011708591 - - - - 0.1245402096392354 - - 1.3096723705530167e-10 - - 0.08709251073014457 - - - 0.11524763711349806 - - -3.2014213502407074e-10 - - -0.2941215329556144 - - - -0.23978784657083452 - - -2.0372681319713593e-10 - - 0.20702902220364194 + - -0.3067888987134211 + - - -0.2519171988678863 + - -6.330083124339581e-10 + - 0.21137828942300985 cvs-adc0: config: conv_tol: 1.0e-10 core_orbitals: 1 n_singlets: 3 energy: - - -54.12308247440467 - - -53.96000354314298 + - -54.123082474404654 + - -53.96000354314297 gradient: - - - - 0.13670422898576362 - - -2.1827872842550278e-10 - - 0.09585740156762768 - - - 0.09903088489954825 - - 2.1827872842550278e-11 - - -0.28425848668121034 - - - -0.23573511373979272 - - 2.9103830456733704e-11 - - 0.18840108531730948 - - - - 0.4100968398124678 - - -3.92901711165905e-10 - - 0.2924419814662542 - - - -0.07108191138104303 - - -2.9103830456733704e-11 - - -0.3370177816977957 - - - -0.33901492819859413 - - -7.275957614183426e-12 - - 0.04457580055168364 + - - - 0.1367042287674849 + - -1.7462298274040222e-10 + - 0.09585740158945555 + - - 0.09903088501596358 + - 1.5279510989785194e-10 + - -0.2842584869504208 + - - -0.23573511405993486 + - -1.8917489796876907e-10 + - 0.18840108578297077 + - - - 0.4100968395359814 + - -1.6007106751203537e-10 + - 0.29244198137166677 + - - -0.0710819112646277 + - 0.0 + - -0.3370177820834215 + - - -0.33901492862787563 + - -1.0186340659856796e-10 + - 0.04457580095913727 cvs-adc1: config: conv_tol: 1.0e-10 core_orbitals: 1 n_singlets: 3 energy: - - -54.85354413664418 - - -54.794194263197895 + - -54.853544136644196 + - -54.79419426319791 gradient: - - - - 0.20441432894585887 - - -2.1827872842550278e-10 - - 0.14198894465516787 - - - 0.03388333941984456 - - 5.384208634495735e-10 - - -0.26222279915964464 - - - -0.2382976672015502 - - 1.1641532182693481e-10 - - 0.12023385440261336 - - - - 0.31129172753571765 - - -2.1827872842550278e-10 - - 0.22435429711913457 - - - -0.03036278410581872 - - 4.001776687800884e-10 - - -0.29155276875098934 - - - -0.28092894230940146 - - 9.458744898438454e-11 - - 0.06719847128260881 + - - - 0.2044143290258944 + - 6.548361852765083e-11 + - 0.14198894443688914 + - - 0.03388333924522158 + - 3.637978807091713e-11 + - -0.2622227990432293 + - - -0.23829766733251745 + - 1.5279510989785194e-10 + - 0.12023385446082102 + - - - 0.3112917276157532 + - 5.820766091346741e-11 + - 0.22435429701727116 + - - -0.030362784207682125 + - 6.548361852765083e-11 + - -0.2915527687073336 + - - -0.2809289423385053 + - 2.546585164964199e-10 + - 0.06719847139902413 cvs-adc2: config: conv_tol: 1.0e-10 @@ -414,50 +525,87 @@ h2o: energy: - -54.9890358908465 - -54.90586009813954 - - -53.166856815521605 + - -53.1668568155216 gradient: - - - - 0.23872009348269785 - - -5.820766091346741e-11 - - 0.1671009855272132 - - - 0.03348872406058945 - - -2.3283064365386963e-10 - - -0.2989140243153088 - - - -0.2722088166483445 - - -1.6007106751203537e-10 - - 0.13181303901365027 - - - - 0.3619300219070283 - - -9.458744898438454e-11 - - 0.2592484423876158 - - - -0.04305156569898827 - - -2.837623469531536e-10 - - -0.32641974019497866 - - - -0.31887845518940594 - - -3.8562575355172157e-10 - - 0.0671712980765733 - - - - 0.3055688014064799 - - -1.5279510989785194e-10 - - 0.21378263975930167 - - - 0.1921237775386544 - - -1.6007106751203537e-10 - - -0.5935662731717457 - - - -0.49769257780280896 - - -3.128661774098873e-10 - - 0.3797836339508649 + - - - 0.23872009398473892 + - -5.093170329928398e-11 + - 0.1671009850615519 + - - 0.03348872328933794 + - -3.346940502524376e-10 + - -0.2989140240242705 + - - -0.2722088164737215 + - 9.458744898438454e-11 + - 0.13181303935562028 + - - - 0.36193002229993 + - -1.4551915228366852e-11 + - 0.2592484420310939 + - - -0.04305156655027531 + - -3.2014213502407074e-10 + - -0.32641973995487206 + - - -0.31887845506571466 + - 5.820766091346741e-11 + - 0.0671712983676116 + - - - 0.30556880177755374 + - 4.3655745685100555e-11 + - 0.21378263940277975 + - - 0.19212377647636458 + - -2.6921043172478676e-10 + - -0.5935662729025353 + - - -0.4976925775699783 + - 5.820766091346741e-11 + - 0.3797836341691436 + cvs-adc2x: + config: + conv_tol: 1.0e-10 + core_orbitals: 1 + n_singlets: 3 + energy: + - -55.08829803906556 + - -54.99453129167 + - -54.266903715983545 + gradient: + - - - 0.2788499654925545 + - 2.764863893389702e-10 + - 0.19537103179754922 + - - 0.030986502642917912 + - 2.6921043172478676e-10 + - -0.337843508052174 + - - -0.3098364674151526 + - 4.001776687800884e-10 + - 0.1424724758908269 + - - - 0.41212538185936864 + - 3.2014213502407074e-10 + - 0.29478439582453575 + - - -0.053034814074635506 + - 2.9103830456733704e-10 + - -0.36559760738600744 + - - -0.3590905670862412 + - 2.6921043172478676e-10 + - 0.07081321117584594 + - - - 0.6789990336983465 + - 1.7462298274040222e-10 + - 0.47360565974668134 + - - -0.01937482458743034 + - 3.055902197957039e-10 + - -0.6864346684742486 + - - -0.659624208281457 + - 3.8562575355172157e-10 + - 0.21282900838559726 mp2: config: conv_tol: 1.0e-10 core_orbitals: null - energy: -74.99357808910257 + energy: -74.99357808910256 gradient: - - - 0.09648089337861165 - - 1.6007106751203537e-10 - - 0.06886449090234237 - - - -0.02618346236704383 - - -3.637978807091713e-11 - - -0.06597386241628556 - - - -0.07029743136808975 - - 5.093170329928398e-11 - - -0.00289062818774255 + - - 0.09648089333495591 + - -2.3283064365386963e-10 + - 0.06886449054582044 + - - -0.026183462541666813 + - 4.511093720793724e-10 + - -0.06597386261273641 + - - -0.070297431324434 + - 8.003553375601768e-11 + - -0.0028906283841934055 xyz: "\n O 0 0 0\n H 0 0 1.795239827225189\n H 1.693194615993441 0 -0.599043184453037\n\ \ " methods: @@ -465,8 +613,10 @@ methods: - adc0 - adc1 - adc2 +- adc2x - cvs-adc0 - cvs-adc1 - cvs-adc2 +- cvs-adc2x molecules: - h2o From 854d459bac878a19f8b7edef24a40589d8b299ad Mon Sep 17 00:00:00 2001 From: Maximilian Scheurer Date: Tue, 8 Feb 2022 16:18:20 +0100 Subject: [PATCH 12/18] adc3 amplitude response --- adcc/gradients/amplitude_response.py | 443 ++++++++++++++++++++++----- 1 file changed, 364 insertions(+), 79 deletions(-) diff --git a/adcc/gradients/amplitude_response.py b/adcc/gradients/amplitude_response.py index bf559997d..396a692d0 100644 --- a/adcc/gradients/amplitude_response.py +++ b/adcc/gradients/amplitude_response.py @@ -36,58 +36,399 @@ def t2bar_oovv_adc2(exci, g1a_adc0): hf = mp.reference_state u = exci.excitation_vector df_ia = mp.df(b.ov) - t2bar = ( - 0.5 * ( - hf.oovv - - 2.0 * einsum( - "ijcb,ac->ijab", hf.oovv, g1a_adc0.vv - ).antisymmetrise((2, 3)) - + 2.0 * einsum( - "kjab,ik->ijab", hf.oovv, g1a_adc0.oo - ).antisymmetrise((0, 1)) - + 4.0 * einsum( - "ia,jkbc,kc->ijab", u.ph, hf.oovv, u.ph - ).antisymmetrise((2, 3)).antisymmetrise((0, 1)) - ) / ( - 2.0 * direct_sum("ia+jb->ijab", df_ia, df_ia).symmetrise((0, 1)) - ) + t2bar = 0.5 * ( + hf.oovv + - 2.0 * einsum( + "ijcb,ac->ijab", hf.oovv, g1a_adc0.vv + ).antisymmetrise(2, 3) + + 2.0 * einsum( + "kjab,ik->ijab", hf.oovv, g1a_adc0.oo + ).antisymmetrise(0, 1) + + 4.0 * einsum( + "ia,jkbc,kc->ijab", u.ph, hf.oovv, u.ph + ).antisymmetrise(2, 3).antisymmetrise(0, 1) + ) / ( + 2.0 * direct_sum("ia+jb->ijab", df_ia, df_ia).symmetrise(0, 1) ) return t2bar +def tbarD_oovv_adc3(exci, g1a_adc0): + mp = exci.ground_state + hf = mp.reference_state + u = exci.excitation_vector + df_ia = mp.df(b.ov) + # Table XI (10.1063/1.5085117) + tbarD = 0.5 * ( + hf.oovv + - 2.0 * einsum( + "ijcb,ac->ijab", hf.oovv, g1a_adc0.vv + ).antisymmetrise(2, 3) + + 2.0 * einsum( + "kjab,ik->ijab", hf.oovv, g1a_adc0.oo + ).antisymmetrise(0, 1) + + 4.0 * einsum( + "ia,jkbc,kc->ijab", u.ph, hf.oovv, u.ph + ).antisymmetrise(2, 3).antisymmetrise(0, 1) + ) / ( + 2.0 * direct_sum("ia+jb->ijab", df_ia, df_ia).symmetrise(0, 1) + ) + return tbarD + + +def tbar_TD_oovv_adc3(exci, g1a_adc0): + mp = exci.ground_state + hf = mp.reference_state + # Table XI (10.1063/1.5085117) + tbarD = tbarD_oovv_adc3(exci, g1a_adc0) + tbarD.evaluate() + ret = 2.0 * 4.0 * ( + + 2.0 * einsum("ikac,jckb->ijab", tbarD, hf.ovov) + - 1.0 * einsum("ijcd,abcd->ijab", tbarD, hf.vvvv) + - 1.0 * einsum("klab,ijkl->ijab", tbarD, hf.oooo) + ).antisymmetrise(0, 1).antisymmetrise(2, 3) + return ret + + +def rho_bar_adc3(exci, g1a_adc0): + mp = exci.ground_state + hf = mp.reference_state + u = exci.excitation_vector + df_ia = mp.df(b.ov) + rho_bar = 2.0 * ( + + 1.0 * einsum("ijka,jk->ia", hf.ooov, g1a_adc0.oo) + + 1.0 * einsum("ijkb,jb,ka->ia", hf.ooov, u.ph, u.ph) + - 1.0 * einsum("icab,bc->ia", hf.ovvv, g1a_adc0.vv) + + 1.0 * einsum("jcab,jb,ic->ia", hf.ovvv, u.ph, u.ph) + ) / df_ia + return rho_bar + + +def tbar_rho_oovv_adc3(exci, g1a_adc0): + mp = exci.ground_state + hf = mp.reference_state + # Table XI (10.1063/1.5085117) + rho_bar = rho_bar_adc3(exci, g1a_adc0) + ret = ( + - 1.0 * 2.0 * einsum("jcab,ic->ijab", hf.ovvv, rho_bar).antisymmetrise(0, 1) + - 1.0 * 2.0 * einsum("ijkb,ka->ijab", hf.ooov, rho_bar).antisymmetrise(2, 3) + ) + return ret + + +def t2bar_oovv_adc3(exci, g1a_adc0, g2a_adc1): + mp = exci.ground_state + hf = mp.reference_state + u = exci.excitation_vector + tbar_TD = tbar_TD_oovv_adc3(exci, g1a_adc0) + tbar_TD.evaluate() + tbar_rho = tbar_rho_oovv_adc3(exci, g1a_adc0) + tbar_rho.evaluate() + t2 = mp.t2(b.oovv).evaluate() + df_ia = mp.df(b.ov) + rx = einsum("jb,ijab->ia", u.ph, t2).evaluate() + + ttilde1 = ( + - 1.0 * einsum("klab,ijkm,lm->ijab", t2, hf.oooo, g1a_adc0.oo) + - 1.0 * 2.0 * einsum("ka,ijkl,lb->ijab", u.ph, hf.oooo, rx).antisymmetrise(2, 3) + + 1.0 * 2.0 * ( + + 0.5 * einsum("ik,jklm,lmab->ijab", g1a_adc0.oo, hf.oooo, t2) + - 2.0 * einsum("jkab,lm,ilkm->ijab", t2, g1a_adc0.oo, hf.oooo) + ).antisymmetrise(0, 1) + - 1.0 * 4.0 * ( + + 0.5 * einsum("ia,kc,jklm,lmbc->ijab", u.ph, u.ph, hf.oooo, t2) + - 2.0 * einsum("ka,likm,jmbc,lc->ijab", u.ph, hf.oooo, t2, u.ph) + ).antisymmetrise(0, 1).antisymmetrise(2, 3) + ) + ttilde1.evaluate() + + ttilde2 = 4.0 * ( + - 1.0 * einsum("ijkc,lc,klab->ijab", hf.ooov, u.ph, u.pphh) + + 1.0 * 2.0 * einsum("ikab,jlkc,lc->ijab", u.pphh, hf.ooov, u.ph).antisymmetrise(0, 1) + - 1.0 * 4.0 * einsum("jklb,kc,ilac->ijab", hf.ooov, u.ph, u.pphh).antisymmetrise(0, 1).antisymmetrise(2, 3) + ) + ttilde2.evaluate() + + ttilde3 = ( + + 1.0 * 2.0 * einsum("ijbc,ac->ijab", hf.oovv, g1a_adc0.vv).antisymmetrise(2, 3) + - 1.0 * 2.0 * einsum("jkab,ik->ijab", hf.oovv, g1a_adc0.oo).antisymmetrise(0, 1) + + 1.0 * 4.0 * einsum("ia,jkbc,kc->ijab", u.ph, hf.oovv, u.ph).antisymmetrise(0, 1).antisymmetrise(2, 3) + ) + ttilde3.evaluate() + + # TODO: intermediate x_ka ? + # TODO: intermediate x_lc t_jlbd? + ttilde4 = ( + + 1.0 * 2.0 * ( + - 2.0 * einsum("jkab,ickd,cd->ijab", t2, hf.ovov, g1a_adc0.vv) #1 k + - 2.0 * einsum("klab,ickd,jcld->ijab", t2, g2a_adc1.ovov, hf.ovov) + + 1.0 * einsum("ic,jkab,ld,lckd->ijab", u.ph, t2, u.ph, hf.ovov) + + 1.0 * einsum("jkab,kc,ld,lcid->ijab", t2, u.ph, u.ph, hf.ovov) + ).antisymmetrise(0, 1) + + 1.0 * 2.0 * ( + - 2.0 * einsum("ijcb,kalc,kl->ijab", t2, hf.ovov, g1a_adc0.oo) #2 k + - 2.0 * einsum("ijcd,kalc,kbld->ijab", t2, g2a_adc1.ovov, hf.ovov) + + 1.0 * einsum("ka,ijbc,ld,kdlc->ijab", u.ph, t2, u.ph, hf.ovov) + + 1.0 * einsum("ijbc,kc,ld,kdla->ijab", t2, u.ph, u.ph, hf.ovov) + ).antisymmetrise(2, 3) + + 1.0 * 4.0 * ( + + 1.0 * einsum("ac,jdkc,ikbd->ijab", g1a_adc0.vv, hf.ovov, t2) #3 k + - 1.0 * einsum("jckb,ikad,cd->ijab", hf.ovov, t2, g1a_adc0.vv) #4 k + - 1.0 * einsum("ik,kclb,jlac->ijab", g1a_adc0.oo, hf.ovov, t2) #5 k + + 1.0 * einsum("jckb,ilac,lk->ijab", hf.ovov, t2, g1a_adc0.oo) #6 k + - 1.0 * einsum("ic,jckb,ka->ijab", u.ph, hf.ovov, rx) + - 1.0 * einsum("jb,kc,lcid,klad->ijab", u.ph, u.ph, hf.ovov, t2) + - 1.0 * einsum("ka,jckb,ic->ijab", u.ph, hf.ovov, rx) + - 1.0 * einsum("jb,kc,lakd,ilcd->ijab", u.ph, u.ph, hf.ovov, t2) + + 2.0 * einsum("ka,ickd,ld,jlbc->ijab", u.ph, hf.ovov, u.ph, t2) + + 2.0 * einsum("ic,kcla,kd,jlbd->ijab", u.ph, hf.ovov, u.ph, t2) + ).antisymmetrise(0, 1).antisymmetrise(2, 3) + ) + ttilde4.evaluate() + + ttilde5 = - 4.0 * ( + + 1.0 * einsum("kcab,kd,ijcd->ijab", hf.ovvv, u.ph, u.pphh) + + 1.0 * 2.0 * einsum("ijbc,kcad,kd->ijab", u.pphh, hf.ovvv, u.ph).antisymmetrise(2, 3) + + 1.0 * 4.0 * einsum("jcbd,kd,ikac->ijab", hf.ovvv, u.ph, u.pphh).antisymmetrise(0, 1).antisymmetrise(2, 3) + ) + ttilde5.evaluate() + + ttilde6 = ( + - 1.0 * einsum("ijcd,abde,ce->ijab", t2, hf.vvvv, g1a_adc0.vv) + - 1.0 * 2.0 * einsum("ic,abcd,jkde,ke->ijab", u.ph, hf.vvvv, t2, u.ph).antisymmetrise(0, 1) + - 1.0 * 2.0 * ( + + 0.5 * einsum("ac,bcde,ijde->ijab", g1a_adc0.vv, hf.vvvv, t2) + - 2.0 * einsum("ijbc,de,adce->ijab", t2, g1a_adc0.vv, hf.vvvv) + ).antisymmetrise(2, 3) + - 1.0 * 4.0 * ( + + 0.5 * einsum("ia,kc,bcde,jkde->ijab", u.ph, u.ph, hf.vvvv, t2) + - 2.0 * einsum("ic,adce,jkeb,kd->ijab", u.ph, hf.vvvv, t2, u.ph) + ).antisymmetrise(0, 1).antisymmetrise(2, 3) + ) + ttilde6.evaluate() + # TODO: prefactors etc maybe wrong... + ret = 0.5 * ( + hf.oovv + + ttilde1 + ttilde2 + ttilde3 + ttilde4 + ttilde5 + ttilde6 + + tbar_TD + tbar_rho + ) / (2.0 * direct_sum("ia+jb->ijab", df_ia, df_ia).symmetrise(0, 1)) + return ret + + def t2bar_oovv_cvs_adc2(exci, g1a_adc0): mp = exci.ground_state hf = mp.reference_state df_ia = mp.df(b.ov) t2bar = 0.5 * ( - - einsum("ijcb,ac->ijab", hf.oovv, g1a_adc0.vv).antisymmetrise((2, 3)) - ) / direct_sum("ia+jb->ijab", df_ia, df_ia).symmetrise((0, 1)) + - einsum("ijcb,ac->ijab", hf.oovv, g1a_adc0.vv).antisymmetrise(2, 3) + ) / direct_sum("ia+jb->ijab", df_ia, df_ia).symmetrise(0, 1) return t2bar -def ampl_relaxed_dms_adc1(exci): +def ampl_relaxed_dms_mp2(mp): + hf = mp.reference_state + t2 = mp.t2(b.oovv) + g1a = OneParticleOperator(hf) + g2a = TwoParticleDensityMatrix(hf) + g1a.oo = -0.5 * einsum('ikab,jkab->ij', t2, t2) + g1a.vv = 0.5 * einsum('ijac,ijbc->ab', t2, t2) + g2a.oovv = -1.0 * mp.t2(b.oovv) + return g1a, g2a + + +def ampl_relaxed_dms_adc0(exci): hf = exci.reference_state u = exci.excitation_vector g1a = OneParticleOperator(hf) g2a = TwoParticleDensityMatrix(hf) + # g2a is not required for the adc0 gradient, + # but expected by amplitude_relaxed_densities g1a.oo = - 1.0 * einsum("ia,ja->ij", u.ph, u.ph) g1a.vv = + 1.0 * einsum("ia,ib->ab", u.ph, u.ph) - g2a.ovov = - 1.0 * einsum("ja,ib->iajb", u.ph, u.ph) return g1a, g2a -def ampl_relaxed_dms_adc0(exci): +def ampl_relaxed_dms_adc1(exci): hf = exci.reference_state u = exci.excitation_vector g1a = OneParticleOperator(hf) g2a = TwoParticleDensityMatrix(hf) - # g2a is not required for the adc0 gradient, - # but expected by amplitude_relaxed_densities g1a.oo = - 1.0 * einsum("ia,ja->ij", u.ph, u.ph) g1a.vv = + 1.0 * einsum("ia,ib->ab", u.ph, u.ph) + g2a.ovov = - 1.0 * einsum("ja,ib->iajb", u.ph, u.ph) + return g1a, g2a + + +def ampl_relaxed_dms_adc2(exci): + u = exci.excitation_vector + mp = exci.ground_state + g1a_adc1, g2a_adc1 = ampl_relaxed_dms_adc1(exci) + t2 = mp.t2(b.oovv) + t2bar = t2bar_oovv_adc2(exci, g1a_adc1).evaluate() + + g1a = g1a_adc1.copy() + g1a.oo += ( + - 2.0 * einsum('jkab,ikab->ij', u.pphh, u.pphh) + - 2.0 * einsum('jkab,ikab->ij', t2bar, t2).symmetrise((0, 1)) + ) + g1a.vv += ( + + 2.0 * einsum("ijac,ijbc->ab", u.pphh, u.pphh) + + 2.0 * einsum("ijac,ijbc->ab", t2bar, t2).symmetrise((0, 1)) + ) + + g2a = g2a_adc1.copy() + ru_ov = einsum("ijab,jb->ia", t2, u.ph) + g2a.oovv = ( + 0.5 * ( + - 1.0 * t2 + + 2.0 * einsum("ijcb,ca->ijab", t2, g1a_adc1.vv).antisymmetrise((2, 3)) + - 2.0 * einsum("kjab,ki->ijab", t2, g1a_adc1.oo).antisymmetrise((0, 1)) + - 4.0 * einsum( + "ia,jb->ijab", u.ph, ru_ov + ).antisymmetrise((0, 1)).antisymmetrise((2, 3)) + ) + - 2.0 * t2bar + ) + g2a.ooov = -2.0 * einsum("kb,ijab->ijka", u.ph, u.pphh) + g2a.ovvv = -2.0 * einsum("ja,ijbc->iabc", u.ph, u.pphh) return g1a, g2a +def ampl_relaxed_dms_adc2x(exci): + u = exci.excitation_vector + g1a, g2a = ampl_relaxed_dms_adc2(exci) + + g2a.ovov += -4.0 * einsum("ikbc,jkac->iajb", u.pphh, u.pphh) + g2a.oooo = 2.0 * einsum('ijab,klab->ijkl', u.pphh, u.pphh) + g2a.vvvv = 2.0 * einsum('ijcd,ijab->abcd', u.pphh, u.pphh) + + return g1a, g2a + + +def ampl_relaxed_dms_adc3(exci): + u = exci.excitation_vector + mp = exci.ground_state + hf = mp.reference_state + g1a_adc1, g2a_adc1 = ampl_relaxed_dms_adc1(exci) + t2bar = t2bar_oovv_adc3(exci, g1a_adc1, g2a_adc1).evaluate() + tbarD = tbarD_oovv_adc3(exci, g1a_adc1).evaluate() + rho_bar = rho_bar_adc3(exci, g1a_adc1).evaluate() + t2 = mp.t2(b.oovv) + tD = mp.td2(b.oovv) + rho = mp.mp2_diffdm + + print("bar", 0.25 * t2bar.dot(hf.oovv)) + + # Table IX (10.1063/1.5085117) + g1a = g1a_adc1.copy() + g1a.oo += ( + - 2.0 * einsum("jkab,ikab->ij", u.pphh, u.pphh) + - 1.0 * 2.0 * ( + + 1.0 * einsum("ikab,jkab->ij", t2, t2bar) + + 1.0 * einsum("ikab,jkab->ij", tD, tbarD) + + 0.5 * einsum("ia,ja->ij", rho_bar, rho.ov) + ).symmetrise(0, 1) + ) + g1a.vv += ( + + 2.0 * einsum("ijac,ijbc->ab", u.pphh, u.pphh) + + 1.0 * 2.0 *( + + 1.0 * einsum("ijac,ijbc->ab", t2bar, t2) + + 1.0 * einsum("ijac,ijbc->ab", tbarD, tD) + + 0.5 * einsum("ia,ib->ab", rho_bar, rho.ov) + ).symmetrise(0, 1) + ) + + tsq_ovov = einsum("ikac,jkbc->iajb", t2, t2).evaluate() + tsq_vvvv = einsum("klab,klcd->abcd", t2, t2).evaluate() + tsq_oooo = einsum("ijcd,klcd->ijkl", t2, t2).evaluate() + rx = einsum("ijab,jb->ia", t2, u.ph) + + g2a = TwoParticleDensityMatrix(hf) + g2a.oooo = ( + + 2.0 * einsum("ijab,klab->ijkl", u.pphh, u.pphh) + + 0.5 * 2.0 * ( + + 2.0 * einsum("ijab,klab->ijkl", tbarD, t2) + + 0.5 * 2.0 * einsum("jm,imkl->ijkl", g1a_adc1.oo, tsq_oooo).antisymmetrise(0, 1) + + 1.0 * 2.0 * einsum("kc,ijbc,ma,lmab->ijkl", u.ph, t2, u.ph, t2).antisymmetrise(2, 3) + + 1.0 * 4.0 * ( + + 1.0 * einsum("ik,jl->ijkl", rho.oo, g1a_adc1.oo) + - 1.0 * einsum("lajb,ia,kb->ijkl", tsq_ovov, u.ph, u.ph) + ).antisymmetrise(0, 1).antisymmetrise(2, 3) + ).symmetrise([(0, 1), (2, 3)]) + ) + g2a.ooov = ( + - 2.0 * einsum("kb,ijab->ijka", u.ph, u.pphh) + + 1.0 * einsum("la,ijbc,klbc->ijka", u.ph, t2, u.pphh) + + 1.0 * 2.0 * ( + + 2.0 * einsum("ic,jlab,klbc->ijka", u.ph, t2, u.pphh) + - 1.0 * einsum("ja,ilbc,klbc->ijka", u.ph, t2, u.pphh) + + 1.0 * einsum("ja,ik->ijka", rho.ov, g1a_adc1.oo) + + 1.0 * einsum("ia,jb,kb->ijka", u.ph, rho.ov, u.ph) + ).antisymmetrise(0, 1) + - 0.5 * einsum("ijab,kb->ijka", t2, rho_bar) + ) + g2a.oovv = 0.5 * ( + - 1.0 * t2 - 1.0 * tD - 4.0 * t2bar + - 1.0 * 2.0 * ( + + 1.0 * einsum("ijbc,ac->ijab", tD + t2, g1a_adc1.vv) + ).antisymmetrise(2, 3) + + 1.0 * 2.0 * ( + + 1.0 * einsum("jkab,ik->ijab", tD + t2, g1a_adc1.oo) + ).antisymmetrise(0, 1) + - 1.0 * 4.0 * ( + + 1.0 * einsum("ia,jb->ijab", u.ph, einsum("jkbc,kc->jb", tD, u.ph) + rx) + ).antisymmetrise(0, 1).antisymmetrise(2, 3) + ) + g2a.ovov = ( + + 1.0 * g2a_adc1.ovov + - 4.0 * einsum("ikbc,jkac->iajb", u.pphh, u.pphh) + + 1.0 * einsum("ij,ab->iajb", rho.oo, g1a_adc1.vv) + + 1.0 * einsum("ab,ij->iajb", rho.vv, g1a_adc1.oo) + + 0.5 * 2.0 * ( + - 4.0 * einsum("ikbc,jkac->iajb", t2, tbarD) + + 1.0 * einsum("ibjc,ac->iajb", tsq_ovov, g1a_adc1.vv) + - 1.0 * einsum("ibka,jk->iajb", tsq_ovov, g1a_adc1.oo) + + 1.0 * einsum("ka,ikbc,jc->iajb", u.ph, t2, rx) + + 1.0 * einsum("jc,ikbc,ka->iajb", u.ph, t2, rx) + + 1.0 * einsum("ja,cb,ic->iajb", u.ph, rho.vv, u.ph) + - 1.0 * einsum("ib,kj,ka->iajb", u.ph, rho.oo, u.ph) + - 2.0 * einsum("jckb,ic,ka->iajb", tsq_ovov, u.ph, u.ph) + + 0.5 * einsum("acbd,ic,jd->iajb", tsq_vvvv, u.ph, u.ph) + + 0.5 * einsum("ikjl,ka,lb->iajb", tsq_oooo, u.ph, u.ph) + ).symmetrise([(0, 2), (1, 3)]) # TODO: symmetrise correct? + ) + g2a.ovvv = ( + - 2.0 * einsum("ja,ijbc->iabc", u.ph, u.pphh) + + 1.0 * einsum("id,jkbc,jkad->iabc", u.ph, t2, u.pphh) + + 1.0 * 2.0 * ( + - 2.0 * einsum("jb,ikcd,jkad->iabc", u.ph, t2, u.pphh) + + 1.0 * einsum("ib,jkcd,jkad->iabc", u.ph, t2, u.pphh) + - 1.0 * einsum("ic,ab->iabc", rho.ov, g1a_adc1.vv) + + 1.0 * einsum("ib,jc,ja->iabc", u.ph, rho.ov, u.ph) + ).antisymmetrise(2, 3) + - 0.5 * einsum("ijbc,ja->iabc", t2, rho_bar) + ) + g2a.vvvv = ( + + 2.0 * einsum("ijcd,ijab->abcd", u.pphh, u.pphh) + + 0.5 * 2.0 * ( + + 2.0 * einsum("ijab,ijcd->abcd", tbarD, t2) + + 0.5 * 2.0 * ( + - 1.0 * einsum("be,aecd->abcd", g1a_adc1.vv, tsq_vvvv) + ).antisymmetrise(0, 1) + + 1.0 * 2.0 * ( + + 1.0 * einsum("ia,ijcd,jkbe,ke->abcd", u.ph, t2, t2, u.ph) # TODO: not sure... + ).antisymmetrise(0, 1) + + 1.0 * 4.0 * ( + + 1.0 * einsum("bd,ac->abcd", rho.vv, g1a_adc1.vv) + - 1.0 * einsum("idjb,ia,jc->abcd", tsq_ovov, u.ph, u.ph) + ).antisymmetrise(0, 1).antisymmetrise(2, 3) + ).symmetrise([(0, 1), (2, 3)]) + ) + return g1a, g2a + + +### CVS ### + def ampl_relaxed_dms_cvs_adc0(exci): hf = exci.reference_state u = exci.excitation_vector @@ -302,69 +643,13 @@ def ampl_relaxed_dms_cvs_adc2x(exci): return g1a, g2a -def ampl_relaxed_dms_adc2(exci): - u = exci.excitation_vector - mp = exci.ground_state - g1a_adc1, g2a_adc1 = ampl_relaxed_dms_adc1(exci) - t2 = mp.t2(b.oovv) - t2bar = t2bar_oovv_adc2(exci, g1a_adc1).evaluate() - - g1a = g1a_adc1.copy() - g1a.oo += ( - - 2.0 * einsum('jkab,ikab->ij', u.pphh, u.pphh) - - 2.0 * einsum('jkab,ikab->ij', t2bar, t2).symmetrise((0, 1)) - ) - g1a.vv += ( - + 2.0 * einsum("ijac,ijbc->ab", u.pphh, u.pphh) - + 2.0 * einsum("ijac,ijbc->ab", t2bar, t2).symmetrise((0, 1)) - ) - - g2a = g2a_adc1.copy() - ru_ov = einsum("ijab,jb->ia", t2, u.ph) - g2a.oovv = ( - 0.5 * ( - - 1.0 * t2 - + 2.0 * einsum("ijcb,ca->ijab", t2, g1a_adc1.vv).antisymmetrise((2, 3)) - - 2.0 * einsum("kjab,ki->ijab", t2, g1a_adc1.oo).antisymmetrise((0, 1)) - - 4.0 * einsum( - "ia,jb->ijab", u.ph, ru_ov - ).antisymmetrise((0, 1)).antisymmetrise((2, 3)) - ) - - 2.0 * t2bar - ) - g2a.ooov = -2.0 * einsum("kb,ijab->ijka", u.ph, u.pphh) - g2a.ovvv = -2.0 * einsum("ja,ijbc->iabc", u.ph, u.pphh) - return g1a, g2a - - -def ampl_relaxed_dms_adc2x(exci): - u = exci.excitation_vector - g1a, g2a = ampl_relaxed_dms_adc2(exci) - - g2a.ovov += -4.0 * einsum("ikbc,jkac->iajb", u.pphh, u.pphh) - g2a.oooo = 2.0 * einsum('ijab,klab->ijkl', u.pphh, u.pphh) - g2a.vvvv = 2.0 * einsum('ijcd,ijab->abcd', u.pphh, u.pphh) - - return g1a, g2a - - -def ampl_relaxed_dms_mp2(mp): - hf = mp.reference_state - t2 = mp.t2(b.oovv) - g1a = OneParticleOperator(hf) - g2a = TwoParticleDensityMatrix(hf) - g1a.oo = -0.5 * einsum('ikab,jkab->ij', t2, t2) - g1a.vv = 0.5 * einsum('ijac,ijbc->ab', t2, t2) - g2a.oovv = -1.0 * mp.t2(b.oovv) - return g1a, g2a - - DISPATCH = { "mp2": ampl_relaxed_dms_mp2, "adc0": ampl_relaxed_dms_adc0, "adc1": ampl_relaxed_dms_adc1, "adc2": ampl_relaxed_dms_adc2, "adc2x": ampl_relaxed_dms_adc2x, + "adc3": ampl_relaxed_dms_adc3, "cvs-adc0": ampl_relaxed_dms_cvs_adc0, "cvs-adc1": ampl_relaxed_dms_cvs_adc1, "cvs-adc2": ampl_relaxed_dms_cvs_adc2, From 299ee5bf8f758159ccf67785f13890b74bed838d Mon Sep 17 00:00:00 2001 From: Maximilian Scheurer Date: Tue, 8 Feb 2022 17:12:35 +0100 Subject: [PATCH 13/18] correct densities --- adcc/gradients/amplitude_response.py | 44 +++++++++++++++------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/adcc/gradients/amplitude_response.py b/adcc/gradients/amplitude_response.py index 396a692d0..7d13ae6f5 100644 --- a/adcc/gradients/amplitude_response.py +++ b/adcc/gradients/amplitude_response.py @@ -84,9 +84,11 @@ def tbar_TD_oovv_adc3(exci, g1a_adc0): tbarD.evaluate() ret = 2.0 * 4.0 * ( + 2.0 * einsum("ikac,jckb->ijab", tbarD, hf.ovov) - - 1.0 * einsum("ijcd,abcd->ijab", tbarD, hf.vvvv) - - 1.0 * einsum("klab,ijkl->ijab", tbarD, hf.oooo) ).antisymmetrise(0, 1).antisymmetrise(2, 3) + ret += 2.0 * ( + - 1.0 * einsum("ijcd,cdab->ijab", tbarD, hf.vvvv) + - 1.0 * einsum("klab,klij->ijab", tbarD, hf.oooo) + ) return ret @@ -160,28 +162,30 @@ def t2bar_oovv_adc3(exci, g1a_adc0, g2a_adc1): # TODO: intermediate x_lc t_jlbd? ttilde4 = ( + 1.0 * 2.0 * ( - - 2.0 * einsum("jkab,ickd,cd->ijab", t2, hf.ovov, g1a_adc0.vv) #1 k - - 2.0 * einsum("klab,ickd,jcld->ijab", t2, g2a_adc1.ovov, hf.ovov) - + 1.0 * einsum("ic,jkab,ld,lckd->ijab", u.ph, t2, u.ph, hf.ovov) - + 1.0 * einsum("jkab,kc,ld,lcid->ijab", t2, u.ph, u.ph, hf.ovov) + - 2.0 * einsum("jkab,ickd,cd->ijab", t2, hf.ovov, g1a_adc0.vv) #1 ok + # - 2.0 * einsum("klab,ickd,jcld->ijab", t2, g2a_adc1.ovov, hf.ovov) + - 2.0 * einsum("ic,kd,jcld,klab->ijab", u.ph, u.ph, hf.ovov, t2) #18 anners + + 1.0 * einsum("ic,jkab,ld,lckd->ijab", u.ph, t2, u.ph, hf.ovov) #13 ok + + 1.0 * einsum("jkab,kc,ld,lcid->ijab", t2, u.ph, u.ph, hf.ovov) #14 ok ).antisymmetrise(0, 1) + 1.0 * 2.0 * ( - - 2.0 * einsum("ijcb,kalc,kl->ijab", t2, hf.ovov, g1a_adc0.oo) #2 k - - 2.0 * einsum("ijcd,kalc,kbld->ijab", t2, g2a_adc1.ovov, hf.ovov) - + 1.0 * einsum("ka,ijbc,ld,kdlc->ijab", u.ph, t2, u.ph, hf.ovov) - + 1.0 * einsum("ijbc,kc,ld,kdla->ijab", t2, u.ph, u.ph, hf.ovov) + - 2.0 * einsum("ijcb,kalc,kl->ijab", t2, hf.ovov, g1a_adc0.oo) #2 ok + # - 2.0 * einsum("ijcd,kalc,kbld->ijab", t2, g2a_adc1.ovov, hf.ovov) + - 2.0 * einsum("ka,lc,kbld,ijcd->ijab", u.ph, u.ph, hf.ovov, t2) # 17 anners + + 1.0 * einsum("ka,ijbc,ld,kdlc->ijab", u.ph, t2, u.ph, hf.ovov) #11 ok + + 1.0 * einsum("ijbc,kc,ld,kdla->ijab", t2, u.ph, u.ph, hf.ovov) #12 ok ).antisymmetrise(2, 3) + 1.0 * 4.0 * ( - + 1.0 * einsum("ac,jdkc,ikbd->ijab", g1a_adc0.vv, hf.ovov, t2) #3 k - - 1.0 * einsum("jckb,ikad,cd->ijab", hf.ovov, t2, g1a_adc0.vv) #4 k - - 1.0 * einsum("ik,kclb,jlac->ijab", g1a_adc0.oo, hf.ovov, t2) #5 k - + 1.0 * einsum("jckb,ilac,lk->ijab", hf.ovov, t2, g1a_adc0.oo) #6 k - - 1.0 * einsum("ic,jckb,ka->ijab", u.ph, hf.ovov, rx) - - 1.0 * einsum("jb,kc,lcid,klad->ijab", u.ph, u.ph, hf.ovov, t2) - - 1.0 * einsum("ka,jckb,ic->ijab", u.ph, hf.ovov, rx) - - 1.0 * einsum("jb,kc,lakd,ilcd->ijab", u.ph, u.ph, hf.ovov, t2) - + 2.0 * einsum("ka,ickd,ld,jlbc->ijab", u.ph, hf.ovov, u.ph, t2) - + 2.0 * einsum("ic,kcla,kd,jlbd->ijab", u.ph, hf.ovov, u.ph, t2) + + 1.0 * einsum("ac,jdkc,ikbd->ijab", g1a_adc0.vv, hf.ovov, t2) #3 ok + - 1.0 * einsum("jckb,ikad,cd->ijab", hf.ovov, t2, g1a_adc0.vv) #4 ok + - 1.0 * einsum("ik,kclb,jlac->ijab", g1a_adc0.oo, hf.ovov, t2) #5 ok + + 1.0 * einsum("jckb,ilac,lk->ijab", hf.ovov, t2, g1a_adc0.oo) #6 ok + - 1.0 * einsum("ic,jckb,ka->ijab", u.ph, hf.ovov, rx) #7 ok + - 1.0 * einsum("jb,kc,lcid,klad->ijab", u.ph, u.ph, hf.ovov, t2) #8 ok + - 1.0 * einsum("ka,jckb,ic->ijab", u.ph, hf.ovov, rx) #9 ok + - 1.0 * einsum("jb,kc,lakd,ilcd->ijab", u.ph, u.ph, hf.ovov, t2) #10 ok + + 2.0 * einsum("ka,ickd,ld,jlbc->ijab", u.ph, hf.ovov, u.ph, t2) #15 ok + + 2.0 * einsum("ic,kcla,kd,jlbd->ijab", u.ph, hf.ovov, u.ph, t2) #15 ok ).antisymmetrise(0, 1).antisymmetrise(2, 3) ) ttilde4.evaluate() From f718601510bfc0b95cbd5edcd14de1a6c0d8bfe8 Mon Sep 17 00:00:00 2001 From: Maximilian Scheurer Date: Wed, 9 Feb 2022 19:06:25 +0100 Subject: [PATCH 14/18] adc3 gradients working --- adcc/gradients/amplitude_response.py | 111 +- .../gradients/test_functionality_gradients.py | 7 +- adcc/testdata/dump_fdiff_gradient.py | 3 +- adcc/testdata/grad_dump.yml | 952 +++++++++--------- 4 files changed, 548 insertions(+), 525 deletions(-) diff --git a/adcc/gradients/amplitude_response.py b/adcc/gradients/amplitude_response.py index 7d13ae6f5..9e0447b5f 100644 --- a/adcc/gradients/amplitude_response.py +++ b/adcc/gradients/amplitude_response.py @@ -87,7 +87,7 @@ def tbar_TD_oovv_adc3(exci, g1a_adc0): ).antisymmetrise(0, 1).antisymmetrise(2, 3) ret += 2.0 * ( - 1.0 * einsum("ijcd,cdab->ijab", tbarD, hf.vvvv) - - 1.0 * einsum("klab,klij->ijab", tbarD, hf.oooo) + - 1.0 * einsum("klab,ijkl->ijab", tbarD, hf.oooo) ) return ret @@ -132,7 +132,9 @@ def t2bar_oovv_adc3(exci, g1a_adc0, g2a_adc1): ttilde1 = ( - 1.0 * einsum("klab,ijkm,lm->ijab", t2, hf.oooo, g1a_adc0.oo) - - 1.0 * 2.0 * einsum("ka,ijkl,lb->ijab", u.ph, hf.oooo, rx).antisymmetrise(2, 3) + - 1.0 * 2.0 * einsum( + "ka,ijkl,lb->ijab", u.ph, hf.oooo, rx + ).antisymmetrise(2, 3) + 1.0 * 2.0 * ( + 0.5 * einsum("ik,jklm,lmab->ijab", g1a_adc0.oo, hf.oooo, t2) - 2.0 * einsum("jkab,lm,ilkm->ijab", t2, g1a_adc0.oo, hf.oooo) @@ -146,15 +148,25 @@ def t2bar_oovv_adc3(exci, g1a_adc0, g2a_adc1): ttilde2 = 4.0 * ( - 1.0 * einsum("ijkc,lc,klab->ijab", hf.ooov, u.ph, u.pphh) - + 1.0 * 2.0 * einsum("ikab,jlkc,lc->ijab", u.pphh, hf.ooov, u.ph).antisymmetrise(0, 1) - - 1.0 * 4.0 * einsum("jklb,kc,ilac->ijab", hf.ooov, u.ph, u.pphh).antisymmetrise(0, 1).antisymmetrise(2, 3) + + 1.0 * 2.0 * einsum( + "ikab,jlkc,lc->ijab", u.pphh, hf.ooov, u.ph + ).antisymmetrise(0, 1) + - 1.0 * 4.0 * einsum( + "jklb,kc,ilac->ijab", hf.ooov, u.ph, u.pphh + ).antisymmetrise(0, 1).antisymmetrise(2, 3) ) ttilde2.evaluate() ttilde3 = ( - + 1.0 * 2.0 * einsum("ijbc,ac->ijab", hf.oovv, g1a_adc0.vv).antisymmetrise(2, 3) - - 1.0 * 2.0 * einsum("jkab,ik->ijab", hf.oovv, g1a_adc0.oo).antisymmetrise(0, 1) - + 1.0 * 4.0 * einsum("ia,jkbc,kc->ijab", u.ph, hf.oovv, u.ph).antisymmetrise(0, 1).antisymmetrise(2, 3) + + 1.0 * 2.0 * einsum( + "ijbc,ac->ijab", hf.oovv, g1a_adc0.vv + ).antisymmetrise(2, 3) + - 1.0 * 2.0 * einsum( + "jkab,ik->ijab", hf.oovv, g1a_adc0.oo + ).antisymmetrise(0, 1) + + 1.0 * 4.0 * einsum( + "ia,jkbc,kc->ijab", u.ph, hf.oovv, u.ph + ).antisymmetrise(0, 1).antisymmetrise(2, 3) ) ttilde3.evaluate() @@ -162,44 +174,48 @@ def t2bar_oovv_adc3(exci, g1a_adc0, g2a_adc1): # TODO: intermediate x_lc t_jlbd? ttilde4 = ( + 1.0 * 2.0 * ( - - 2.0 * einsum("jkab,ickd,cd->ijab", t2, hf.ovov, g1a_adc0.vv) #1 ok - # - 2.0 * einsum("klab,ickd,jcld->ijab", t2, g2a_adc1.ovov, hf.ovov) - - 2.0 * einsum("ic,kd,jcld,klab->ijab", u.ph, u.ph, hf.ovov, t2) #18 anners - + 1.0 * einsum("ic,jkab,ld,lckd->ijab", u.ph, t2, u.ph, hf.ovov) #13 ok - + 1.0 * einsum("jkab,kc,ld,lcid->ijab", t2, u.ph, u.ph, hf.ovov) #14 ok + - 2.0 * einsum("jkab,ickd,cd->ijab", t2, hf.ovov, g1a_adc0.vv) + - 2.0 * einsum("ic,kd,jcld,klab->ijab", u.ph, u.ph, hf.ovov, t2) + + 1.0 * einsum("ic,jkab,ld,lckd->ijab", u.ph, t2, u.ph, hf.ovov) + + 1.0 * einsum("jkab,kc,ld,lcid->ijab", t2, u.ph, u.ph, hf.ovov) ).antisymmetrise(0, 1) + 1.0 * 2.0 * ( - - 2.0 * einsum("ijcb,kalc,kl->ijab", t2, hf.ovov, g1a_adc0.oo) #2 ok - # - 2.0 * einsum("ijcd,kalc,kbld->ijab", t2, g2a_adc1.ovov, hf.ovov) - - 2.0 * einsum("ka,lc,kbld,ijcd->ijab", u.ph, u.ph, hf.ovov, t2) # 17 anners - + 1.0 * einsum("ka,ijbc,ld,kdlc->ijab", u.ph, t2, u.ph, hf.ovov) #11 ok - + 1.0 * einsum("ijbc,kc,ld,kdla->ijab", t2, u.ph, u.ph, hf.ovov) #12 ok + - 2.0 * einsum("ijcb,kalc,kl->ijab", t2, hf.ovov, g1a_adc0.oo) + - 2.0 * einsum("ka,lc,kbld,ijcd->ijab", u.ph, u.ph, hf.ovov, t2) + + 1.0 * einsum("ka,ijbc,ld,kdlc->ijab", u.ph, t2, u.ph, hf.ovov) + + 1.0 * einsum("ijbc,kc,ld,kdla->ijab", t2, u.ph, u.ph, hf.ovov) ).antisymmetrise(2, 3) + 1.0 * 4.0 * ( - + 1.0 * einsum("ac,jdkc,ikbd->ijab", g1a_adc0.vv, hf.ovov, t2) #3 ok - - 1.0 * einsum("jckb,ikad,cd->ijab", hf.ovov, t2, g1a_adc0.vv) #4 ok - - 1.0 * einsum("ik,kclb,jlac->ijab", g1a_adc0.oo, hf.ovov, t2) #5 ok - + 1.0 * einsum("jckb,ilac,lk->ijab", hf.ovov, t2, g1a_adc0.oo) #6 ok - - 1.0 * einsum("ic,jckb,ka->ijab", u.ph, hf.ovov, rx) #7 ok - - 1.0 * einsum("jb,kc,lcid,klad->ijab", u.ph, u.ph, hf.ovov, t2) #8 ok - - 1.0 * einsum("ka,jckb,ic->ijab", u.ph, hf.ovov, rx) #9 ok - - 1.0 * einsum("jb,kc,lakd,ilcd->ijab", u.ph, u.ph, hf.ovov, t2) #10 ok - + 2.0 * einsum("ka,ickd,ld,jlbc->ijab", u.ph, hf.ovov, u.ph, t2) #15 ok - + 2.0 * einsum("ic,kcla,kd,jlbd->ijab", u.ph, hf.ovov, u.ph, t2) #15 ok + + 1.0 * einsum("ac,jdkc,ikbd->ijab", g1a_adc0.vv, hf.ovov, t2) + - 1.0 * einsum("jckb,ikad,cd->ijab", hf.ovov, t2, g1a_adc0.vv) + - 1.0 * einsum("ik,kclb,jlac->ijab", g1a_adc0.oo, hf.ovov, t2) + + 1.0 * einsum("jckb,ilac,lk->ijab", hf.ovov, t2, g1a_adc0.oo) + - 1.0 * einsum("ic,jckb,ka->ijab", u.ph, hf.ovov, rx) + - 1.0 * einsum("jb,kc,lcid,klad->ijab", u.ph, u.ph, hf.ovov, t2) + - 1.0 * einsum("ka,jckb,ic->ijab", u.ph, hf.ovov, rx) + - 1.0 * einsum("jb,kc,lakd,ilcd->ijab", u.ph, u.ph, hf.ovov, t2) + + 2.0 * einsum("ka,ickd,ld,jlbc->ijab", u.ph, hf.ovov, u.ph, t2) + + 2.0 * einsum("ic,kcla,kd,jlbd->ijab", u.ph, hf.ovov, u.ph, t2) ).antisymmetrise(0, 1).antisymmetrise(2, 3) ) ttilde4.evaluate() ttilde5 = - 4.0 * ( + 1.0 * einsum("kcab,kd,ijcd->ijab", hf.ovvv, u.ph, u.pphh) - + 1.0 * 2.0 * einsum("ijbc,kcad,kd->ijab", u.pphh, hf.ovvv, u.ph).antisymmetrise(2, 3) - + 1.0 * 4.0 * einsum("jcbd,kd,ikac->ijab", hf.ovvv, u.ph, u.pphh).antisymmetrise(0, 1).antisymmetrise(2, 3) + + 1.0 * 2.0 * einsum( + "ijbc,kcad,kd->ijab", u.pphh, hf.ovvv, u.ph + ).antisymmetrise(2, 3) + + 1.0 * 4.0 * einsum( + "jcbd,kd,ikac->ijab", hf.ovvv, u.ph, u.pphh + ).antisymmetrise(0, 1).antisymmetrise(2, 3) ) ttilde5.evaluate() ttilde6 = ( - 1.0 * einsum("ijcd,abde,ce->ijab", t2, hf.vvvv, g1a_adc0.vv) - - 1.0 * 2.0 * einsum("ic,abcd,jkde,ke->ijab", u.ph, hf.vvvv, t2, u.ph).antisymmetrise(0, 1) + - 1.0 * 2.0 * einsum( + "ic,abcd,jkde,ke->ijab", u.ph, hf.vvvv, t2, u.ph + ).antisymmetrise(0, 1) - 1.0 * 2.0 * ( + 0.5 * einsum("ac,bcde,ijde->ijab", g1a_adc0.vv, hf.vvvv, t2) - 2.0 * einsum("ijbc,de,adce->ijab", t2, g1a_adc0.vv, hf.vvvv) @@ -210,11 +226,11 @@ def t2bar_oovv_adc3(exci, g1a_adc0, g2a_adc1): ).antisymmetrise(0, 1).antisymmetrise(2, 3) ) ttilde6.evaluate() - # TODO: prefactors etc maybe wrong... + ret = 0.5 * ( hf.oovv + ttilde1 + ttilde2 + ttilde3 + ttilde4 + ttilde5 + ttilde6 - + tbar_TD + tbar_rho + + tbar_TD + tbar_rho ) / (2.0 * direct_sum("ia+jb->ijab", df_ia, df_ia).symmetrise(0, 1)) return ret @@ -285,8 +301,8 @@ def ampl_relaxed_dms_adc2(exci): g2a.oovv = ( 0.5 * ( - 1.0 * t2 - + 2.0 * einsum("ijcb,ca->ijab", t2, g1a_adc1.vv).antisymmetrise((2, 3)) - - 2.0 * einsum("kjab,ki->ijab", t2, g1a_adc1.oo).antisymmetrise((0, 1)) + + 2.0 * einsum("ijcb,ca->ijab", t2, g1a_adc1.vv).antisymmetrise(2, 3) + - 2.0 * einsum("kjab,ki->ijab", t2, g1a_adc1.oo).antisymmetrise(0, 1) - 4.0 * einsum( "ia,jb->ijab", u.ph, ru_ov ).antisymmetrise((0, 1)).antisymmetrise((2, 3)) @@ -321,9 +337,7 @@ def ampl_relaxed_dms_adc3(exci): tD = mp.td2(b.oovv) rho = mp.mp2_diffdm - print("bar", 0.25 * t2bar.dot(hf.oovv)) - - # Table IX (10.1063/1.5085117) + # Table IX (10.1063/1.5085117) g1a = g1a_adc1.copy() g1a.oo += ( - 2.0 * einsum("jkab,ikab->ij", u.pphh, u.pphh) @@ -335,7 +349,7 @@ def ampl_relaxed_dms_adc3(exci): ) g1a.vv += ( + 2.0 * einsum("ijac,ijbc->ab", u.pphh, u.pphh) - + 1.0 * 2.0 *( + + 1.0 * 2.0 * ( + 1.0 * einsum("ijac,ijbc->ab", t2bar, t2) + 1.0 * einsum("ijac,ijbc->ab", tbarD, tD) + 0.5 * einsum("ia,ib->ab", rho_bar, rho.ov) @@ -352,13 +366,17 @@ def ampl_relaxed_dms_adc3(exci): + 2.0 * einsum("ijab,klab->ijkl", u.pphh, u.pphh) + 0.5 * 2.0 * ( + 2.0 * einsum("ijab,klab->ijkl", tbarD, t2) - + 0.5 * 2.0 * einsum("jm,imkl->ijkl", g1a_adc1.oo, tsq_oooo).antisymmetrise(0, 1) - + 1.0 * 2.0 * einsum("kc,ijbc,ma,lmab->ijkl", u.ph, t2, u.ph, t2).antisymmetrise(2, 3) + + 0.5 * 2.0 * einsum( + "jm,imab,klab->ijkl", g1a_adc1.oo, t2, t2 + ).antisymmetrise(0, 1) + + 1.0 * 2.0 * einsum( + "kc,ijbc,ma,lmab->ijkl", u.ph, t2, u.ph, t2 + ).antisymmetrise(2, 3) + 1.0 * 4.0 * ( + 1.0 * einsum("ik,jl->ijkl", rho.oo, g1a_adc1.oo) - 1.0 * einsum("lajb,ia,kb->ijkl", tsq_ovov, u.ph, u.ph) ).antisymmetrise(0, 1).antisymmetrise(2, 3) - ).symmetrise([(0, 1), (2, 3)]) + ).symmetrise([(0, 2), (1, 3)]) ) g2a.ooov = ( - 2.0 * einsum("kb,ijab->ijka", u.ph, u.pphh) @@ -380,7 +398,8 @@ def ampl_relaxed_dms_adc3(exci): + 1.0 * einsum("jkab,ik->ijab", tD + t2, g1a_adc1.oo) ).antisymmetrise(0, 1) - 1.0 * 4.0 * ( - + 1.0 * einsum("ia,jb->ijab", u.ph, einsum("jkbc,kc->jb", tD, u.ph) + rx) + + 1.0 * einsum("ia,jb->ijab", u.ph, + einsum("jkbc,kc->jb", tD, u.ph) + rx) ).antisymmetrise(0, 1).antisymmetrise(2, 3) ) g2a.ovov = ( @@ -399,7 +418,7 @@ def ampl_relaxed_dms_adc3(exci): - 2.0 * einsum("jckb,ic,ka->iajb", tsq_ovov, u.ph, u.ph) + 0.5 * einsum("acbd,ic,jd->iajb", tsq_vvvv, u.ph, u.ph) + 0.5 * einsum("ikjl,ka,lb->iajb", tsq_oooo, u.ph, u.ph) - ).symmetrise([(0, 2), (1, 3)]) # TODO: symmetrise correct? + ).symmetrise([(0, 2), (1, 3)]) ) g2a.ovvv = ( - 2.0 * einsum("ja,ijbc->iabc", u.ph, u.pphh) @@ -420,15 +439,15 @@ def ampl_relaxed_dms_adc3(exci): - 1.0 * einsum("be,aecd->abcd", g1a_adc1.vv, tsq_vvvv) ).antisymmetrise(0, 1) + 1.0 * 2.0 * ( - + 1.0 * einsum("ia,ijcd,jkbe,ke->abcd", u.ph, t2, t2, u.ph) # TODO: not sure... + + 1.0 * einsum("ia,ijcd,jkbe,ke->abcd", u.ph, t2, t2, u.ph) ).antisymmetrise(0, 1) + 1.0 * 4.0 * ( + 1.0 * einsum("bd,ac->abcd", rho.vv, g1a_adc1.vv) - 1.0 * einsum("idjb,ia,jc->abcd", tsq_ovov, u.ph, u.ph) ).antisymmetrise(0, 1).antisymmetrise(2, 3) - ).symmetrise([(0, 1), (2, 3)]) + ).symmetrise([(0, 2), (1, 3)]) ) - return g1a, g2a + return g1a, g2a ### CVS ### diff --git a/adcc/gradients/test_functionality_gradients.py b/adcc/gradients/test_functionality_gradients.py index c4237417b..827ee57c1 100644 --- a/adcc/gradients/test_functionality_gradients.py +++ b/adcc/gradients/test_functionality_gradients.py @@ -71,10 +71,13 @@ def template_nuclear_gradient(self, molecule, basis, method, backend): # check energy computed with unrelaxed densities gs_corr = 0.0 if ee.method.level > 0: - gs_corr = ee.ground_state.energy_correction(ee.method.level) + # compute the ground state contribution + # to the correlation energy + gs_energy = ee.ground_state.energy(ee.method.level) + gs_corr = gs_energy - ee.reference_state.energy_scf assert_allclose( gs_corr + ee.excitation_energy, - grad._energy, atol=1e-8 + grad._energy, atol=1e-10 ) assert_allclose( grad_fdiff[ee.index], grad.total, atol=1e-7, diff --git a/adcc/testdata/dump_fdiff_gradient.py b/adcc/testdata/dump_fdiff_gradient.py index 8ee58611b..9c548dacd 100644 --- a/adcc/testdata/dump_fdiff_gradient.py +++ b/adcc/testdata/dump_fdiff_gradient.py @@ -133,10 +133,11 @@ def main(): "adc1", "adc2", "adc2x", + "adc3", "cvs-adc0", "cvs-adc1", "cvs-adc2", - "cvs-adc2x", # TODO: broken + # "cvs-adc2x", # TODO: broken ] molnames = [ "h2o", diff --git a/adcc/testdata/grad_dump.yml b/adcc/testdata/grad_dump.yml index dd5967f05..d2d20eb54 100644 --- a/adcc/testdata/grad_dump.yml +++ b/adcc/testdata/grad_dump.yml @@ -9,184 +9,221 @@ h2o: core_orbitals: null n_singlets: 3 energy: - - -75.34687593732802 - - -75.28099897302934 - - -75.27790714502395 + - -75.34687593732811 + - -75.28099897302941 + - -75.27790714502405 gradient: - - - - 0.05781772705813637 - - 6.257323548197746e-10 - - 0.04124695902282838 - - - -0.0010630972392391413 - - 4.3655745685100555e-10 - - -0.0601992766969488 - - - -0.05675463159423089 - - -1.673470251262188e-10 - - 0.01895231872185832 - - - - 0.013116451358655468 - - 1.9354047253727913e-09 - - 0.009581870690453798 - - - 0.051721489333431236 - - -1.8189894035458565e-10 - - -0.0873598225225578 - - - -0.06483794018276967 - - -7.8580342233181e-10 - - 0.07777794692810858 - - - - 0.035870219362550415 - - 8.149072527885437e-10 - - 0.025914354242559057 - - - 0.007818771875463426 - - 2.3283064365386963e-10 - - -0.04966127932857489 - - - -0.043688993180694524 - - -3.710738383233547e-10 - - 0.023746926133753732 + - - - 0.05781772690534126 + - 3.2741809263825417e-10 + - 0.041246956439863425 + - - -0.0010630962424329482 + - 9.022187441587448e-10 + - -0.060199278326763306 + - - -0.05675463087391108 + - 1.9063008949160576e-09 + - 0.018952317521325313 + - - - 0.013116452595568262 + - 4.0745362639427185e-10 + - 0.009581870828696992 + - - 0.05172148926794762 + - -6.475602276623249e-10 + - -0.08735981993959285 + - - -0.0648379422709695 + - 1.7462298274040222e-10 + - 0.07777794662979431 + - - - 0.035870219457137864 + - 4.2928149923682213e-10 + - 0.02591435170324985 + - - 0.007818772384780459 + - 1.2078089639544487e-09 + - -0.04966128067462705 + - - -0.04368899230030365 + - 2.2264430299401283e-09 + - 0.0237469249550486 adc1: config: conv_tol: 1.0e-10 core_orbitals: null n_singlets: 3 energy: - - -75.68543998437549 - - -75.61931016176952 - - -75.59868950258502 + - -75.68543998437532 + - -75.61931016176936 + - -75.59868950258485 gradient: - - - - 0.09274008955253521 - - -2.2846506908535957e-09 - - 0.06558011218294268 - - - -0.002630220929859206 - - -5.529727786779404e-10 - - -0.09467176473117433 - - - -0.09010986990324454 - - 4.3655745685100555e-11 - - 0.029091649295878597 - - - - 0.1093179879244417 - - -2.3283064365386963e-09 - - 0.07809554620325798 - - - -0.0066607077096705325 - - -5.602487362921238e-10 + - - - 0.09274009053478949 + - -9.240466170012951e-10 + - 0.06558011189918034 + - - -0.0026302200931240804 + - 1.0186340659856796e-09 + - -0.09467176448379178 + - - -0.09010987027431838 + - -6.83940015733242e-10 + - 0.02909164885932114 + - - - 0.10931798897217959 + - -8.221832104027271e-10 + - 0.078095546028635 + - - -0.006660707054834347 + - 1.0550138540565968e-09 - -0.10735300996020669 - - - -0.10265728145168396 - - 2.1827872842550278e-11 - - 0.0292574607374263 - - - - 0.011670265019347426 - - -4.802132025361061e-10 - - 0.008451194829831365 - - - 0.05684483542427188 - - -2.6193447411060333e-10 - - -0.092962221315247 - - - -0.06851509893022012 - - -5.966285243630409e-10 - - 0.08451102513208752 + - - -0.10265728181548184 + - -7.566995918750763e-10 + - 0.029257460359076504 + - - - 0.01167026567418361 + - 1.1568772606551647e-09 + - 0.008451193309156224 + - - 0.056844835431547835 + - 7.421476766467094e-10 + - -0.09296221967088059 + - - -0.06851509937405353 + - -1.1496013030409813e-09 + - 0.08451102519757114 adc2: config: conv_tol: 1.0e-10 core_orbitals: null n_singlets: 3 energy: - - -75.92967540826551 - - -75.85499790115735 - - -75.84309170418108 + - -75.9296754082655 + - -75.85499790115733 + - -75.84309170418106 gradient: - - - - 0.11448501647100784 - - -1.964508555829525e-10 - - 0.08113867735664826 - - - -0.008900643704691902 - - 1.8917489796876907e-10 - - -0.10905679834831972 - - - -0.10558437482541194 - - 9.458744898438454e-11 - - 0.027918118568777572 - - - - 0.11318148521968396 - - -3.637978807091713e-10 - - 0.08065584087307798 - - - -0.0044726159612764604 - - 5.093170329928398e-11 - - -0.1143742871718132 - - - -0.10870887125929585 - - 1.3096723705530167e-10 - - 0.033718444225087296 - - - - 0.022055652378185187 + - - - 0.11448501809354639 + - -1.1496013030409813e-09 + - 0.08113867529755225 + - - -0.008900642889784649 + - -3.637978807091713e-11 + - -0.10905679840652738 + - - -0.10558437401778065 + - -2.837623469531536e-10 + - 0.02791811802308075 + - - - 0.1131814870168455 + - -1.3169483281672e-09 + - 0.08065583834832069 + - - -0.0044726152045768686 + - 4.3655745685100555e-11 + - -0.11437428731733235 + - - -0.10870887064811541 + - -3.128661774098873e-10 + - 0.03371844370121835 + - - - 0.022055651032133028 + - -1.4260876923799515e-09 + - 0.01590312836196972 + - - 0.05098412500228733 + - 7.275957614183426e-11 + - -0.09580103961343411 + - - -0.07303977584524546 - -5.165929906070232e-10 - - 0.015903128252830356 - - - 0.05098412436200306 - - 3.637978807091713e-11 - - -0.0958010398899205 - - - -0.07303977609990397 - - 5.020410753786564e-10 - - 0.07989790866849944 + - 0.07989790782448836 adc2x: config: conv_tol: 1.0e-10 core_orbitals: null n_singlets: 3 energy: - - -75.94713027654683 - - -75.87072120070408 - - -75.86069046648016 + - -75.94713027654686 + - -75.87072120070411 + - -75.8606904664802 gradient: - - - - 0.12108468703081599 - - 3.346940502524376e-10 - - 0.08575623762590112 - - - -0.008930197138397489 - - -1.4551915228366852e-10 - - -0.11596749711316079 - - - -0.11215449091832852 - - 2.4374458007514477e-09 - - 0.03021125582017703 - - - - 0.12104129973886302 - - 4.874891601502895e-10 - - 0.0862211757703335 - - - -0.005538591591175646 - - -2.9831426218152046e-10 - - -0.12121302761079278 - - - -0.11550270940642804 - - 2.4156179279088974e-09 - - 0.03499184796237387 - - - - 0.027651791788230184 - - 3.7834979593753815e-10 - - 0.019813940474705305 - - - 0.050617610570043325 - - -4.511093720793724e-10 - - -0.10117346337938216 - - - -0.0782694015360903 - - 7.930793799459934e-10 - - 0.08135951928852592 + - - - 0.12108468737278599 + - 3.5652192309498787e-10 + - 0.08575623746583005 + - - -0.00893019756040303 + - -9.89530235528946e-10 + - -0.11596749575255672 + - - -0.11215448959410423 + - -1.2369127944111824e-10 + - 0.030211256875190884 + - - - 0.12104129993531387 + - 6.039044819772243e-10 + - 0.08622117596678436 + - - -0.005538591824006289 + - -1.1350493878126144e-09 + - -0.12121302656305488 + - - -0.11550270780571736 + - 5.820766091346741e-11 + - 0.03499184886459261 + - - - 0.027651791664538905 + - 8.512870408594608e-10 + - 0.019813940722087864 + - - 0.05061761011893395 + - 4.43833414465189e-10 + - -0.10117346070910571 + - - -0.07826940130325966 + - 2.3283064365386963e-10 + - 0.08135951995063806 + adc3: + config: + conv_tol: 1.0e-10 + core_orbitals: null + n_singlets: 3 + energy: + - -75.9285783500615 + - -75.8546333440395 + - -75.84167671840466 + gradient: + - - - 0.11627274371130625 + - 1.673470251262188e-09 + - 0.08230358791479375 + - - -0.006295582810707856 + - 3.92901711165905e-10 + - -0.11453791718668072 + - - -0.10997716135170776 + - -9.604264050722122e-10 + - 0.03223432630329626 + - - - 0.12384291545458836 + - 1.5425030142068863e-09 + - 0.0882510380979511 + - - -0.006875615137687419 + - 3.4924596548080444e-10 + - -0.1223434514249675 + - - -0.1169673006006633 + - -9.822542779147625e-10 + - 0.03409241016197484 + - - - 0.025808624421188142 + - -1.6007106751203537e-10 + - 0.01846984199801227 + - - 0.05330723668157589 + - 2.473825588822365e-10 + - -0.1029805622601998 + - - -0.0791158616921166 + - -1.229636836796999e-09 + - 0.08451071724266512 cvs-adc0: config: conv_tol: 1.0e-10 core_orbitals: 1 n_singlets: 3 energy: - - -55.29234315857754 - - -55.22337436627346 - - -54.66716620632232 + - -55.29234315857762 + - -55.223374366273546 + - -54.667166206322406 gradient: - - - - -0.013647946063429117 - - -2.255546860396862e-10 - - -0.009335993825516198 - - - 0.005706505660782568 - - -3.637978807091713e-10 - - 0.0060952052372158505 - - - 0.007941436808323488 - - 7.203198038041592e-10 - - 0.003240785124944523 - - - - -0.03559545367170358 - - -2.9103830456733704e-11 - - -0.024668598533025943 - - - 0.0145883748846245 - - -2.4010660126805305e-10 - - 0.016633202772936784 - - - 0.021007075076340698 - - 5.529727786779404e-10 - - 0.008035392536839936 - - - - 0.29560477242193883 - - -7.275957614183426e-12 - - 0.2022045104240533 - - - -0.11422410370869329 - - -1.8189894035458565e-10 - - -0.14526787639624672 - - - -0.18138067236577626 - - 5.675246939063072e-10 + - - - -0.01364794644905487 + - -1.4551915228366852e-11 + - -0.00933599537529517 + - - 0.005706506060960237 + - -1.7462298274040222e-10 + - 0.006095205535530113 + - - 0.007941438860143535 + - 2.1100277081131935e-10 + - 0.003240785052184947 + - - - -0.03559545424650423 + - -1.6007106751203537e-10 + - -0.02466860027925577 + - - 0.014588374950108118 + - -7.275957614183426e-11 + - 0.016633203136734664 + - - 0.02100707723002415 + - 2.9103830456733704e-10 + - 0.008035392405872699 + - - - 0.2956047719635535 + - -8.731149137020111e-11 + - 0.20220450891793007 + - - -0.11422410366503755 + - -1.3096723705530167e-10 + - -0.14526787615614012 + - - -0.18138067025574856 + - 2.473825588822365e-10 - -0.05693663733109133 cvs-adc1: config: @@ -198,122 +235,85 @@ h2o: - -55.744231177685215 - -55.23885575129546 gradient: - - - - 0.11375777858484071 - - -1.4406396076083183e-09 - - 0.07506357455713442 - - - -0.0062324921527761035 - - 9.89530235528946e-10 - - -0.10649733267200645 - - - -0.10752528614830226 - - 1.964508555829525e-10 - - 0.03143375667423243 - - - - 0.13675109380710637 - - -8.294591680169106e-10 - - 0.10287793739553308 - - - -0.01013374753529206 - - 2.9831426218152046e-10 - - -0.13692998851911398 - - - -0.12661734605353558 - - -5.529727786779404e-10 - - 0.034052050090394914 - - - - -0.03586818531766767 - - -9.167706593871117e-10 - - -0.025053271041542757 - - - 0.028073502020561136 - - 1.0913936421275139e-10 - - -0.0019544431124813855 - - - 0.007794683217070997 - - -6.693881005048752e-10 - - 0.02700771318632178 - cvs-adc2: - config: - conv_tol: 1.0e-10 - core_orbitals: 1 - n_singlets: 3 - energy: - - -56.463324400748306 - - -56.39198974450136 - - -55.931909664303404 - gradient: - - - - 0.06425007180223474 + - - - 0.11375777773355367 + - -8.149072527885437e-10 + - 0.07506357444799505 + - - -0.00623249256022973 + - -1.7462298274040222e-10 + - -0.10649733465106692 + - - -0.10752528410375817 + - 1.0331859812140465e-09 + - 0.03143375746731181 + - - - 0.1367510933050653 - -5.966285243630409e-10 - - 0.04552046016760869 - - - -0.0016864020508364774 - - -1.6007106751203537e-10 - - -0.06586710893316194 - - - -0.06256366953311954 - - 1.0550138540565968e-09 - - 0.020346652614534833 - - - - 0.05899445113755064 - - -9.240466170012951e-10 - - 0.04236197277350584 - - - 0.005970589867501985 + - 0.10287793751922436 + - - -0.010133748408406973 - 1.964508555829525e-10 - - -0.07167667573230574 - - - -0.06496504154347349 - - 1.3460521586239338e-09 - - 0.029314708153833635 - - - - 0.26677660683344584 - - 1.6007106751203537e-10 - - 0.1821055622640415 - - - -0.08747911845421186 - - 6.548361852765083e-11 - - -0.15278874981595436 - - - -0.17929748754249886 - - 1.2878444977104664e-09 - - -0.029316807915165555 - cvs-adc2x: + - -0.13692998980695847 + - - -0.12661734437278938 + - 6.912159733474255e-10 + - 0.03405204997397959 + - - - -0.03586818584881257 + - -3.7834979593753815e-10 + - -0.025053270866919775 + - - 0.028073501482140273 + - 3.055902197957039e-10 + - -0.001954444458533544 + - - 0.007794684926921036 + - 8.658389560878277e-10 + - 0.027007713106286246 + cvs-adc2: config: conv_tol: 1.0e-10 core_orbitals: 1 n_singlets: 3 energy: - - -56.52769099298715 - - -56.45532004933902 - - -56.00756567597581 + - -56.46332440074828 + - -56.39198974450135 + - -55.93190966430339 gradient: - - - - 0.08822469144070055 - - 1.5279510989785194e-10 - - 0.062298548691615 - - - -0.003546565967553761 - - -2.9103830456733704e-11 - - -0.08849690817442024 - - - -0.08467812617163872 - - -2.1827872842550278e-11 - - 0.02619835306541063 - - - - 0.0928193056024611 - - 1.673470251262188e-10 - - 0.06639222669036826 - - - -0.0013965584876132198 - - 2.1100277081131935e-10 - - -0.09725638144300319 - - - -0.09142274883197388 - - -1.673470251262188e-10 - - 0.0308641478914069 - - - - 0.2609083358402131 + - - - 0.06425007266079774 + - 3.8562575355172157e-10 + - 0.045520459178078454 + - - -0.001686401323240716 + - -6.548361852765083e-11 + - -0.06586711463023676 + - - -0.06256367078458425 + - -3.055902197957039e-10 + - 0.020346652701846324 + - - - 0.05899445136310533 - -1.7462298274040222e-10 - - 0.17750937436358072 - - - -0.0887459233563277 - - -1.5279510989785194e-10 - - -0.14432506745652063 - - - -0.1721624140845961 - - -5.820766091346741e-10 - - -0.03318431395018706 + - 0.04236197158752475 + - - 0.005970590587821789 + - -2.9103830456733704e-11 + - -0.07167668161127949 + - - -0.06496504214737797 + - -5.529727786779404e-10 + - 0.029314707753655966 + - - - 0.26677660722634755 + - -1.3096723705530167e-10 + - 0.18210556224221364 + - - -0.08747911818500143 + - 6.766640581190586e-10 + - -0.15278875653166324 + - - -0.17929748843016569 + - -1.6007106751203537e-10 + - -0.02931680792971747 mp2: config: conv_tol: 1.0e-10 core_orbitals: null - energy: -76.22940338787346 + energy: -76.22940338787355 gradient: - - - 0.024395444568654057 - - 4.001776687800884e-10 - - 0.017738173010002356 - - - -0.010762450787296984 - - 5.093170329928398e-11 - - -0.011150372803967912 - - - -0.013632995214720722 - - -2.837623469531536e-10 - - -0.006587800155102741 + - - 0.024395443680987228 + - 5.020410753786564e-10 + - 0.0177381719040568 + - - -0.010762449142930564 + - -3.2741809263825417e-10 + - -0.01115037479030434 + - - -0.01363299589138478 + - -8.294591680169106e-10 + - -0.006587800489796791 sto3g: adc0: config: @@ -321,111 +321,111 @@ h2o: core_orbitals: null n_singlets: 3 energy: - - -73.96883482604382 - - -73.9148118794489 - - -73.80575589478211 + - -73.96883482604383 + - -73.91481187944892 + - -73.80575589478212 gradient: - - - - 0.2150052047727513 - - 2.546585164964199e-10 - - 0.15122539416188374 - - - 0.07489849303965457 - - -4.3655745685100555e-11 - - -0.3332042350884876 - - - -0.2899036976523348 - - -1.8189894035458565e-10 - - 0.18197884122491814 - - - - 0.158692604440148 - - 3.92901711165905e-10 - - 0.11135792744607897 - - - 0.12612935171637218 - - 0.0 - - -0.3458573078387417 - - - -0.28482195574906655 - - 5.820766091346741e-11 - - 0.23449938092380762 - - - - 0.48839781562128337 - - 4.43833414465189e-10 - - 0.34780997406778624 - - - -0.09521430323366076 - - -2.9103830456733704e-11 - - -0.38596353003231343 - - - -0.3931835122348275 + - - - 0.21500520483095897 + - 1.7462298274040222e-10 + - 0.15122539390722523 + - - 0.07489849283592775 + - 1.673470251262188e-10 + - -0.333204234681034 + - - -0.2899036974267801 + - 5.093170329928398e-11 + - 0.18197884086112026 + - - - 0.1586926045420114 + - 3.2014213502407074e-10 + - 0.11135792706045322 + - - 0.1261293514544377 + - 2.1100277081131935e-10 + - -0.3458573076277389 + - - -0.28482195568358293 + - 1.7462298274040222e-10 + - 0.23449938038538676 + - - - 0.4883978156649391 + - 3.128661774098873e-10 + - 0.3478099736967124 + - - -0.09521430350287119 + - 1.2369127944111824e-10 + - -0.38596352994500194 + - - -0.39318351200199686 - 1.382431946694851e-10 - - 0.0381535564083606 + - 0.038153556030010805 adc1: config: conv_tol: 1.0e-10 core_orbitals: null n_singlets: 3 energy: - - -74.47588319597365 - - -74.38511885048032 + - -74.47588319597367 + - -74.38511885048034 - -74.35718229209289 gradient: - - - - 0.2519565752299968 - - -2.1827872842550278e-10 - - 0.176437652327877 - - - 0.04383796474576229 - - -7.275957614183426e-12 - - -0.3275681619415991 - - - -0.2957945398011361 - - 1.7462298274040222e-10 - - 0.15113050978834508 - - - - 0.44204019894095836 + - - - 0.25195657482981915 + - -1.673470251262188e-10 + - 0.17643765209504636 + - - 0.04383796465117484 + - 2.6921043172478676e-10 + - -0.32756816265464295 + - - -0.29579454003396677 + - -5.456968210637569e-10 + - 0.151130509802897 + - - - 0.44204019877361134 - -1.6007106751203537e-10 - - 0.31597312460507965 - - - -0.08205663971602917 - - 1.1641532182693481e-10 - - -0.35633136273827404 - - - -0.359983559086686 - - 1.3096723705530167e-10 - - 0.040358238395128865 - - - - 0.10246272881340701 - - -8.003553375601768e-11 - - 0.0714088877211907 - - - 0.1196453020820627 - - 8.731149137020111e-11 - - -0.27684558805049164 - - - -0.22210803066991502 - - 1.8917489796876907e-10 - - 0.20543670049664797 + - 0.31597312413941836 + - - -0.08205663986882428 + - 2.6193447411060333e-10 + - -0.35633136333490256 + - - -0.35998355938500026 + - -5.311449058353901e-10 + - 0.04035823843150865 + - - - 0.10246272853692062 + - -9.458744898438454e-11 + - 0.07140888737194473 + - - 0.11964530187105993 + - 2.837623469531536e-10 + - -0.2768455888144672 + - - -0.22210803085181396 + - -4.802132025361061e-10 + - 0.20543670067127096 adc2: config: conv_tol: 1.0e-10 core_orbitals: null n_singlets: 3 energy: - - -74.52306494758527 - - -74.42102314285333 - - -74.39990473420056 + - -74.52306494758524 + - -74.4210231428533 + - -74.39990473420053 gradient: - - - - 0.27296630266937427 - - 3.2014213502407074e-10 - - 0.19153599665150978 - - - 0.0437517139071133 - - -3.7834979593753815e-10 - - -0.3499776719036163 - - - -0.3167180168675259 + - - - 0.27296630301862024 + - 1.964508555829525e-10 + - 0.19153599717537872 + - - 0.04375171427091118 + - 3.8562575355172157e-10 + - -0.3499776718817884 + - - -0.31671801683842205 + - 1.8917489796876907e-10 + - 0.15844167445175117 + - - - 0.4661114452901529 + - 2.1827872842550278e-10 + - 0.3327183580331621 + - - -0.08526563921623165 + - 4.656612873077393e-10 + - -0.37705514822300756 + - - -0.3808458057610551 + - 1.382431946694851e-10 + - 0.044336789804219734 + - - - 0.12454020935547305 - 1.5279510989785194e-10 - - 0.1584416748592048 - - - - 0.4661114449991146 - - 3.4924596548080444e-10 - - 0.3327183574583614 - - - -0.08526563958730549 - - -4.656612873077393e-10 - - -0.3770551481138682 - - - -0.380845805600984 - - 9.458744898438454e-11 - - 0.04433678997884272 - - - - 0.12454020912264241 - - 3.346940502524376e-10 - - 0.08709251055552159 - - - 0.115247637295397 - - -4.001776687800884e-10 - - -0.2941215331738931 - - - -0.2397878465562826 - - 5.820766091346741e-11 - - 0.2070290221236064 + - 0.08709251107939053 + - - 0.11524763766647084 + - 4.2928149923682213e-10 + - -0.29412153316661716 + - - -0.2397878467090777 + - -2.9103830456733704e-11 + - 0.20702902177436044 adc2x: config: conv_tol: 1.0e-10 @@ -436,176 +436,176 @@ h2o: - -74.4421830098894 - -74.4221092236318 gradient: - - - - 0.2889574766231817 - - 4.43833414465189e-10 - - 0.2026268874978996 - - - 0.0450652672079741 - - -4.802132025361061e-10 - - -0.36858359961479437 - - - -0.33402274319087155 - - -6.111804395914078e-10 - - 0.16595671245886479 - - - - 0.4846122054150328 + - - - 0.2889574766741134 + - 1.4551915228366852e-10 + - 0.20262688743241597 + - - 0.045065267200698145 + - 4.3655745685100555e-11 + - -0.3685835993819637 + - - -0.3340227430453524 + - -1.4551915228366852e-11 + - 0.16595671254617628 + - - - 0.48461220582248643 + - 2.1100277081131935e-10 + - 0.3459748471796047 + - - -0.08685884004808031 + - 6.548361852765083e-11 + - -0.39460422148840735 + - - -0.39775336504681036 + - -8.003553375601768e-11 + - 0.048629374672600534 + - - - 0.1366148896777304 + - 2.1827872842550278e-10 + - 0.09541060922492761 + - - 0.11530230973585276 + - 5.093170329928398e-11 + - -0.30678889842238277 + - - -0.25191719870781526 + - -4.3655745685100555e-11 + - 0.2113782895321492 + adc3: + config: + conv_tol: 1.0e-10 + core_orbitals: null + n_singlets: 3 + energy: + - -74.55090439658672 + - -74.44714801129275 + - -74.4242627370736 + gradient: + - - - 0.2908625259224209 + - -4.001776687800884e-10 + - 0.2039448505747714 + - - 0.04500434071087511 + - -1.1641532182693481e-10 + - -0.3704894050679286 + - - -0.3358668661385309 - 3.346940502524376e-10 - - 0.345974847303296 - - - -0.08685883981524967 - - -2.837623469531536e-10 - - -0.394604221721238 - - - -0.39775336517050164 - - -5.456968210637569e-10 - - 0.048629374519805424 - - - - 0.1366148895540391 - - 3.4924596548080444e-10 - - 0.09541060952324187 - - - 0.11530231004144298 - - -3.5652192309498787e-10 - - -0.3067888987134211 - - - -0.2519171988678863 - - -6.330083124339581e-10 - - 0.21137828942300985 + - 0.16654455448588124 + - - - 0.48658428593626013 + - -4.656612873077393e-10 + - 0.34738898534851614 + - - -0.08571265437058173 + - -8.003553375601768e-11 + - -0.3983368489643908 + - - -0.40087163097632583 + - 3.637978807091713e-10 + - 0.05094786360859871 + - - - 0.13570507940312382 + - -3.92901711165905e-10 + - 0.09476317036023829 + - - 0.11679784574516816 + - -1.0186340659856796e-10 + - -0.3079343543649884 + - - -0.2525029244279722 + - 3.41970007866621e-10 + - 0.2131711840411299 cvs-adc0: config: conv_tol: 1.0e-10 core_orbitals: 1 n_singlets: 3 energy: - - -54.123082474404654 - - -53.96000354314297 + - -54.12308247440466 + - -53.96000354314296 gradient: - - - - 0.1367042287674849 + - - - 0.13670422898576362 + - 4.220055416226387e-10 + - 0.09585740162583534 + - - 0.09903088509599911 + - -2.546585164964199e-10 + - -0.284258487423358 + - - -0.23573511330323527 + - 3.5652192309498787e-10 + - 0.18840108531730948 + - - - 0.4100968398124678 + - 3.5652192309498787e-10 + - 0.2924419815244619 + - - -0.07108191118459217 - -1.7462298274040222e-10 - - 0.09585740158945555 - - - 0.09903088501596358 - - 1.5279510989785194e-10 - - -0.2842584869504208 - - - -0.23573511405993486 - - -1.8917489796876907e-10 - - 0.18840108578297077 - - - - 0.4100968395359814 - - -1.6007106751203537e-10 - - 0.29244198137166677 - - - -0.0710819112646277 - - 0.0 - - -0.3370177820834215 - - - -0.33901492862787563 - - -1.0186340659856796e-10 - - 0.04457580095913727 + - -0.3370177824544953 + - - -0.3390149278129684 + - 3.128661774098873e-10 + - 0.04457580037706066 cvs-adc1: config: conv_tol: 1.0e-10 core_orbitals: 1 n_singlets: 3 energy: - - -54.853544136644196 - - -54.79419426319791 + - -54.85354413664419 + - -54.7941942631979 gradient: - - - - 0.2044143290258944 - - 6.548361852765083e-11 - - 0.14198894443688914 - - - 0.03388333924522158 - - 3.637978807091713e-11 - - -0.2622227990432293 - - - -0.23829766733251745 - - 1.5279510989785194e-10 - - 0.12023385446082102 - - - - 0.3112917276157532 - - 5.820766091346741e-11 - - 0.22435429701727116 - - - -0.030362784207682125 - - 6.548361852765083e-11 - - -0.2915527687073336 - - - -0.2809289423385053 - - 2.546585164964199e-10 - - 0.06719847139902413 + - - - 0.20441432864026865 + - -2.0372681319713593e-10 + - 0.14198894474975532 + - - 0.03388333945622435 + - -2.9103830456733704e-10 + - -0.2622227993415436 + - - -0.23829766743438086 + - -2.9831426218152046e-10 + - 0.12023385422071442 + - - - 0.31129172734654276 + - -8.731149137020111e-11 + - 0.22435429733013734 + - - -0.03036278401123127 + - -3.637978807091713e-10 + - -0.2915527691147872 + - - -0.28092894267319934 + - -3.128661774098873e-10 + - 0.06719847115891753 cvs-adc2: config: conv_tol: 1.0e-10 core_orbitals: 1 n_singlets: 3 energy: - - -54.9890358908465 - - -54.90586009813954 + - -54.989035890846495 + - -54.905860098139534 - -53.1668568155216 gradient: - - - - 0.23872009398473892 - - -5.093170329928398e-11 - - 0.1671009850615519 - - - 0.03348872328933794 - - -3.346940502524376e-10 - - -0.2989140240242705 - - - -0.2722088164737215 - - 9.458744898438454e-11 - - 0.13181303935562028 - - - - 0.36193002229993 - - -1.4551915228366852e-11 - - 0.2592484420310939 - - - -0.04305156655027531 + - - - 0.23872009358456125 + - -3.8562575355172157e-10 + - 0.1671009848068934 + - - 0.03348872340575326 + - -2.1100277081131935e-10 + - -0.29891402418434154 + - - -0.27220881724497303 + - 5.093170329928398e-11 + - 0.13181303915916942 + - - - 0.361930021950684 + - -4.220055416226387e-10 + - 0.25924844172550365 + - - -0.04305156636110041 - -3.2014213502407074e-10 - - -0.32641973995487206 - - - -0.31887845506571466 - - 5.820766091346741e-11 - - 0.0671712983676116 - - - - 0.30556880177755374 - - 4.3655745685100555e-11 - - 0.21378263940277975 - - - 0.19212377647636458 - - -2.6921043172478676e-10 - - -0.5935662729025353 - - - -0.4976925775699783 - - 5.820766091346741e-11 - - 0.3797836341691436 - cvs-adc2x: - config: - conv_tol: 1.0e-10 - core_orbitals: 1 - n_singlets: 3 - energy: - - -55.08829803906556 - - -54.99453129167 - - -54.266903715983545 - gradient: - - - - 0.2788499654925545 - - 2.764863893389702e-10 - - 0.19537103179754922 - - - 0.030986502642917912 - - 2.6921043172478676e-10 - - -0.337843508052174 - - - -0.3098364674151526 - - 4.001776687800884e-10 - - 0.1424724758908269 - - - - 0.41212538185936864 - - 3.2014213502407074e-10 - - 0.29478439582453575 - - - -0.053034814074635506 - - 2.9103830456733704e-10 - - -0.36559760738600744 - - - -0.3590905670862412 - - 2.6921043172478676e-10 - - 0.07081321117584594 - - - - 0.6789990336983465 - - 1.7462298274040222e-10 - - 0.47360565974668134 - - - -0.01937482458743034 - - 3.055902197957039e-10 - - -0.6864346684742486 - - - -0.659624208281457 - - 3.8562575355172157e-10 - - 0.21282900838559726 + - -0.3264197400130797 + - - -0.3188784557278268 + - 7.275957614183426e-11 + - 0.06717129818571266 + - - - 0.30556880148651544 + - -4.220055416226387e-10 + - 0.21378263917722506 + - - 0.19212377665098757 + - -3.2014213502407074e-10 + - -0.5935662729316391 + - - -0.4976925785158528 + - 2.1827872842550278e-11 + - 0.3797836338781053 mp2: config: conv_tol: 1.0e-10 core_orbitals: null - energy: -74.99357808910256 + energy: -74.99357808910254 gradient: - - - 0.09648089333495591 - - -2.3283064365386963e-10 - - 0.06886449054582044 - - - -0.026183462541666813 - - 4.511093720793724e-10 - - -0.06597386261273641 - - - -0.070297431324434 - - 8.003553375601768e-11 - - -0.0028906283841934055 + - - 0.096480893320404 + - -2.764863893389702e-10 + - 0.06886449074954726 + - - -0.02618346233794 + - 1.964508555829525e-10 + - -0.06597386256908067 + - - -0.07029743114981102 + - 8.731149137020111e-11 + - -0.0028906281804665923 xyz: "\n O 0 0 0\n H 0 0 1.795239827225189\n H 1.693194615993441 0 -0.599043184453037\n\ \ " methods: @@ -614,9 +614,9 @@ methods: - adc1 - adc2 - adc2x +- adc3 - cvs-adc0 - cvs-adc1 - cvs-adc2 -- cvs-adc2x molecules: - h2o From 60444a7c80b3face121d83a70406928018c6589a Mon Sep 17 00:00:00 2001 From: Maximilian Scheurer Date: Sun, 25 Aug 2024 15:03:50 +0200 Subject: [PATCH 15/18] warn instead of fail --- adcc/workflow.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adcc/workflow.py b/adcc/workflow.py index a46d54c5c..3b45bd90f 100644 --- a/adcc/workflow.py +++ b/adcc/workflow.py @@ -359,7 +359,7 @@ def diagonalise_adcmatrix(matrix, n_states, kind, eigensolver="davidson", if conv_tol is None: conv_tol = max(10 * reference_state.conv_tol, 1e-6) if reference_state.conv_tol > conv_tol: - raise InputError( + warnings.warn( "Convergence tolerance of SCF results " f"(== {reference_state.conv_tol}) needs to be lower than ADC " f"convergence tolerance parameter conv_tol (== {conv_tol})." From 65bfcc30b982159bc0502080b5d6488a98bc0c73 Mon Sep 17 00:00:00 2001 From: Maximilian Scheurer Date: Sun, 25 Aug 2024 15:53:47 +0200 Subject: [PATCH 16/18] check for warning --- adcc/test_workflow.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/adcc/test_workflow.py b/adcc/test_workflow.py index 364243f45..34be44820 100644 --- a/adcc/test_workflow.py +++ b/adcc/test_workflow.py @@ -215,7 +215,10 @@ def test_diagonalise_adcmatrix(self): assert res.converged assert res.eigenvalues == approx(ref_singlets[:3]) - with pytest.raises(InputError): # Too low tolerance + # with pytest.raises(InputError): # Too low tolerance + with pytest.warns( + UserWarning, match="needs to be lower than ADC convergence tolerance" + ): res = diagonalise_adcmatrix(matrix, n_states=9, kind="singlet", eigensolver="davidson", conv_tol=1e-14) From be406245a72796033775e0774243de652d820077 Mon Sep 17 00:00:00 2001 From: Maximilian Scheurer <11406414+maxscheurer@users.noreply.github.com> Date: Wed, 4 Mar 2026 15:38:18 +0100 Subject: [PATCH 17/18] switch to parametrize, restructure tests --- .../gradients/test_functionality_gradients.py | 98 --- adcc/testdata/grad_dump.yml | 622 ------------------ adcc/tests/backends/testing.py | 1 + adcc/tests/data/gradient_data.json | 1 + adcc/tests/functionality_gradients_test.py | 93 +++ .../generators}/dump_fdiff_gradient.py | 24 +- adcc/tests/testdata_cache.py | 1 + 7 files changed, 111 insertions(+), 729 deletions(-) delete mode 100644 adcc/gradients/test_functionality_gradients.py delete mode 100644 adcc/testdata/grad_dump.yml create mode 100644 adcc/tests/data/gradient_data.json create mode 100644 adcc/tests/functionality_gradients_test.py rename adcc/{testdata => tests/generators}/dump_fdiff_gradient.py (91%) diff --git a/adcc/gradients/test_functionality_gradients.py b/adcc/gradients/test_functionality_gradients.py deleted file mode 100644 index 827ee57c1..000000000 --- a/adcc/gradients/test_functionality_gradients.py +++ /dev/null @@ -1,98 +0,0 @@ -#!/usr/bin/env python3 -## vi: tabstop=4 shiftwidth=4 softtabstop=4 expandtab -## --------------------------------------------------------------------- -## -## Copyright (C) 2020 by the adcc authors -## -## This file is part of adcc. -## -## adcc is free software: you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published -## by the Free Software Foundation, either version 3 of the License, or -## (at your option) any later version. -## -## adcc is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with adcc. If not, see . -## -## --------------------------------------------------------------------- -import unittest -import itertools - -import adcc -import adcc.backends - -from numpy.testing import assert_allclose - -import pytest - -from ..misc import expand_test_templates -from adcc.backends.testing import cached_backend_hf -from adcc.testdata.cache import gradient_data - - -backends = [b for b in adcc.backends.available() - if b not in ["molsturm", "veloxchem"]] - -molecules = gradient_data["molecules"] -basissets = gradient_data["basissets"] -methods = gradient_data["methods"] - -combinations = list(itertools.product(molecules, basissets, methods, backends)) - - -@pytest.mark.skipif(len(backends) == 0, reason="No backend found.") -@expand_test_templates(combinations) -class TestNuclearGradients(unittest.TestCase): - def template_nuclear_gradient(self, molecule, basis, method, backend): - grad_ref = gradient_data[molecule][basis][method] - - energy_ref = grad_ref["energy"] - grad_fdiff = grad_ref["gradient"] - kwargs = grad_ref["config"] - conv_tol = kwargs["conv_tol"] - - scfres = cached_backend_hf(backend, molecule, basis, conv_tol=1e-13) - - if "adc" in method: - # TODO: convergence needs to be very very tight... - # so we want to make sure all vectors are tightly converged - n_limit = 2 - kwargs["n_singlets"] = kwargs["n_singlets"] + 6 - state = adcc.run_adc(scfres, method=method, **kwargs) - for ee in state.excitations[:n_limit]: - grad = adcc.nuclear_gradient(ee) - assert_allclose(energy_ref[ee.index], ee.total_energy, - atol=conv_tol) - # check energy computed with unrelaxed densities - gs_corr = 0.0 - if ee.method.level > 0: - # compute the ground state contribution - # to the correlation energy - gs_energy = ee.ground_state.energy(ee.method.level) - gs_corr = gs_energy - ee.reference_state.energy_scf - assert_allclose( - gs_corr + ee.excitation_energy, - grad._energy, atol=1e-10 - ) - assert_allclose( - grad_fdiff[ee.index], grad.total, atol=1e-7, - err_msg=f'Gradient for state {ee.index} wrong.' - ) - else: - # MP2 gradients - refstate = adcc.ReferenceState(scfres) - mp = adcc.LazyMp(refstate) - grad = adcc.nuclear_gradient(mp) - assert_allclose(energy_ref, mp.energy(2), atol=1e-8) - # check energy computed with unrelaxed densities - assert_allclose( - mp.energy_correction(2), grad._energy, atol=1e-8 - ) - assert_allclose( - grad_fdiff, grad.total, atol=1e-8 - ) diff --git a/adcc/testdata/grad_dump.yml b/adcc/testdata/grad_dump.yml deleted file mode 100644 index d2d20eb54..000000000 --- a/adcc/testdata/grad_dump.yml +++ /dev/null @@ -1,622 +0,0 @@ -basissets: -- sto3g -- ccpvdz -h2o: - ccpvdz: - adc0: - config: - conv_tol: 1.0e-10 - core_orbitals: null - n_singlets: 3 - energy: - - -75.34687593732811 - - -75.28099897302941 - - -75.27790714502405 - gradient: - - - - 0.05781772690534126 - - 3.2741809263825417e-10 - - 0.041246956439863425 - - - -0.0010630962424329482 - - 9.022187441587448e-10 - - -0.060199278326763306 - - - -0.05675463087391108 - - 1.9063008949160576e-09 - - 0.018952317521325313 - - - - 0.013116452595568262 - - 4.0745362639427185e-10 - - 0.009581870828696992 - - - 0.05172148926794762 - - -6.475602276623249e-10 - - -0.08735981993959285 - - - -0.0648379422709695 - - 1.7462298274040222e-10 - - 0.07777794662979431 - - - - 0.035870219457137864 - - 4.2928149923682213e-10 - - 0.02591435170324985 - - - 0.007818772384780459 - - 1.2078089639544487e-09 - - -0.04966128067462705 - - - -0.04368899230030365 - - 2.2264430299401283e-09 - - 0.0237469249550486 - adc1: - config: - conv_tol: 1.0e-10 - core_orbitals: null - n_singlets: 3 - energy: - - -75.68543998437532 - - -75.61931016176936 - - -75.59868950258485 - gradient: - - - - 0.09274009053478949 - - -9.240466170012951e-10 - - 0.06558011189918034 - - - -0.0026302200931240804 - - 1.0186340659856796e-09 - - -0.09467176448379178 - - - -0.09010987027431838 - - -6.83940015733242e-10 - - 0.02909164885932114 - - - - 0.10931798897217959 - - -8.221832104027271e-10 - - 0.078095546028635 - - - -0.006660707054834347 - - 1.0550138540565968e-09 - - -0.10735300996020669 - - - -0.10265728181548184 - - -7.566995918750763e-10 - - 0.029257460359076504 - - - - 0.01167026567418361 - - 1.1568772606551647e-09 - - 0.008451193309156224 - - - 0.056844835431547835 - - 7.421476766467094e-10 - - -0.09296221967088059 - - - -0.06851509937405353 - - -1.1496013030409813e-09 - - 0.08451102519757114 - adc2: - config: - conv_tol: 1.0e-10 - core_orbitals: null - n_singlets: 3 - energy: - - -75.9296754082655 - - -75.85499790115733 - - -75.84309170418106 - gradient: - - - - 0.11448501809354639 - - -1.1496013030409813e-09 - - 0.08113867529755225 - - - -0.008900642889784649 - - -3.637978807091713e-11 - - -0.10905679840652738 - - - -0.10558437401778065 - - -2.837623469531536e-10 - - 0.02791811802308075 - - - - 0.1131814870168455 - - -1.3169483281672e-09 - - 0.08065583834832069 - - - -0.0044726152045768686 - - 4.3655745685100555e-11 - - -0.11437428731733235 - - - -0.10870887064811541 - - -3.128661774098873e-10 - - 0.03371844370121835 - - - - 0.022055651032133028 - - -1.4260876923799515e-09 - - 0.01590312836196972 - - - 0.05098412500228733 - - 7.275957614183426e-11 - - -0.09580103961343411 - - - -0.07303977584524546 - - -5.165929906070232e-10 - - 0.07989790782448836 - adc2x: - config: - conv_tol: 1.0e-10 - core_orbitals: null - n_singlets: 3 - energy: - - -75.94713027654686 - - -75.87072120070411 - - -75.8606904664802 - gradient: - - - - 0.12108468737278599 - - 3.5652192309498787e-10 - - 0.08575623746583005 - - - -0.00893019756040303 - - -9.89530235528946e-10 - - -0.11596749575255672 - - - -0.11215448959410423 - - -1.2369127944111824e-10 - - 0.030211256875190884 - - - - 0.12104129993531387 - - 6.039044819772243e-10 - - 0.08622117596678436 - - - -0.005538591824006289 - - -1.1350493878126144e-09 - - -0.12121302656305488 - - - -0.11550270780571736 - - 5.820766091346741e-11 - - 0.03499184886459261 - - - - 0.027651791664538905 - - 8.512870408594608e-10 - - 0.019813940722087864 - - - 0.05061761011893395 - - 4.43833414465189e-10 - - -0.10117346070910571 - - - -0.07826940130325966 - - 2.3283064365386963e-10 - - 0.08135951995063806 - adc3: - config: - conv_tol: 1.0e-10 - core_orbitals: null - n_singlets: 3 - energy: - - -75.9285783500615 - - -75.8546333440395 - - -75.84167671840466 - gradient: - - - - 0.11627274371130625 - - 1.673470251262188e-09 - - 0.08230358791479375 - - - -0.006295582810707856 - - 3.92901711165905e-10 - - -0.11453791718668072 - - - -0.10997716135170776 - - -9.604264050722122e-10 - - 0.03223432630329626 - - - - 0.12384291545458836 - - 1.5425030142068863e-09 - - 0.0882510380979511 - - - -0.006875615137687419 - - 3.4924596548080444e-10 - - -0.1223434514249675 - - - -0.1169673006006633 - - -9.822542779147625e-10 - - 0.03409241016197484 - - - - 0.025808624421188142 - - -1.6007106751203537e-10 - - 0.01846984199801227 - - - 0.05330723668157589 - - 2.473825588822365e-10 - - -0.1029805622601998 - - - -0.0791158616921166 - - -1.229636836796999e-09 - - 0.08451071724266512 - cvs-adc0: - config: - conv_tol: 1.0e-10 - core_orbitals: 1 - n_singlets: 3 - energy: - - -55.29234315857762 - - -55.223374366273546 - - -54.667166206322406 - gradient: - - - - -0.01364794644905487 - - -1.4551915228366852e-11 - - -0.00933599537529517 - - - 0.005706506060960237 - - -1.7462298274040222e-10 - - 0.006095205535530113 - - - 0.007941438860143535 - - 2.1100277081131935e-10 - - 0.003240785052184947 - - - - -0.03559545424650423 - - -1.6007106751203537e-10 - - -0.02466860027925577 - - - 0.014588374950108118 - - -7.275957614183426e-11 - - 0.016633203136734664 - - - 0.02100707723002415 - - 2.9103830456733704e-10 - - 0.008035392405872699 - - - - 0.2956047719635535 - - -8.731149137020111e-11 - - 0.20220450891793007 - - - -0.11422410366503755 - - -1.3096723705530167e-10 - - -0.14526787615614012 - - - -0.18138067025574856 - - 2.473825588822365e-10 - - -0.05693663733109133 - cvs-adc1: - config: - conv_tol: 1.0e-10 - core_orbitals: 1 - n_singlets: 3 - energy: - - -55.76235801207001 - - -55.744231177685215 - - -55.23885575129546 - gradient: - - - - 0.11375777773355367 - - -8.149072527885437e-10 - - 0.07506357444799505 - - - -0.00623249256022973 - - -1.7462298274040222e-10 - - -0.10649733465106692 - - - -0.10752528410375817 - - 1.0331859812140465e-09 - - 0.03143375746731181 - - - - 0.1367510933050653 - - -5.966285243630409e-10 - - 0.10287793751922436 - - - -0.010133748408406973 - - 1.964508555829525e-10 - - -0.13692998980695847 - - - -0.12661734437278938 - - 6.912159733474255e-10 - - 0.03405204997397959 - - - - -0.03586818584881257 - - -3.7834979593753815e-10 - - -0.025053270866919775 - - - 0.028073501482140273 - - 3.055902197957039e-10 - - -0.001954444458533544 - - - 0.007794684926921036 - - 8.658389560878277e-10 - - 0.027007713106286246 - cvs-adc2: - config: - conv_tol: 1.0e-10 - core_orbitals: 1 - n_singlets: 3 - energy: - - -56.46332440074828 - - -56.39198974450135 - - -55.93190966430339 - gradient: - - - - 0.06425007266079774 - - 3.8562575355172157e-10 - - 0.045520459178078454 - - - -0.001686401323240716 - - -6.548361852765083e-11 - - -0.06586711463023676 - - - -0.06256367078458425 - - -3.055902197957039e-10 - - 0.020346652701846324 - - - - 0.05899445136310533 - - -1.7462298274040222e-10 - - 0.04236197158752475 - - - 0.005970590587821789 - - -2.9103830456733704e-11 - - -0.07167668161127949 - - - -0.06496504214737797 - - -5.529727786779404e-10 - - 0.029314707753655966 - - - - 0.26677660722634755 - - -1.3096723705530167e-10 - - 0.18210556224221364 - - - -0.08747911818500143 - - 6.766640581190586e-10 - - -0.15278875653166324 - - - -0.17929748843016569 - - -1.6007106751203537e-10 - - -0.02931680792971747 - mp2: - config: - conv_tol: 1.0e-10 - core_orbitals: null - energy: -76.22940338787355 - gradient: - - - 0.024395443680987228 - - 5.020410753786564e-10 - - 0.0177381719040568 - - - -0.010762449142930564 - - -3.2741809263825417e-10 - - -0.01115037479030434 - - - -0.01363299589138478 - - -8.294591680169106e-10 - - -0.006587800489796791 - sto3g: - adc0: - config: - conv_tol: 1.0e-10 - core_orbitals: null - n_singlets: 3 - energy: - - -73.96883482604383 - - -73.91481187944892 - - -73.80575589478212 - gradient: - - - - 0.21500520483095897 - - 1.7462298274040222e-10 - - 0.15122539390722523 - - - 0.07489849283592775 - - 1.673470251262188e-10 - - -0.333204234681034 - - - -0.2899036974267801 - - 5.093170329928398e-11 - - 0.18197884086112026 - - - - 0.1586926045420114 - - 3.2014213502407074e-10 - - 0.11135792706045322 - - - 0.1261293514544377 - - 2.1100277081131935e-10 - - -0.3458573076277389 - - - -0.28482195568358293 - - 1.7462298274040222e-10 - - 0.23449938038538676 - - - - 0.4883978156649391 - - 3.128661774098873e-10 - - 0.3478099736967124 - - - -0.09521430350287119 - - 1.2369127944111824e-10 - - -0.38596352994500194 - - - -0.39318351200199686 - - 1.382431946694851e-10 - - 0.038153556030010805 - adc1: - config: - conv_tol: 1.0e-10 - core_orbitals: null - n_singlets: 3 - energy: - - -74.47588319597367 - - -74.38511885048034 - - -74.35718229209289 - gradient: - - - - 0.25195657482981915 - - -1.673470251262188e-10 - - 0.17643765209504636 - - - 0.04383796465117484 - - 2.6921043172478676e-10 - - -0.32756816265464295 - - - -0.29579454003396677 - - -5.456968210637569e-10 - - 0.151130509802897 - - - - 0.44204019877361134 - - -1.6007106751203537e-10 - - 0.31597312413941836 - - - -0.08205663986882428 - - 2.6193447411060333e-10 - - -0.35633136333490256 - - - -0.35998355938500026 - - -5.311449058353901e-10 - - 0.04035823843150865 - - - - 0.10246272853692062 - - -9.458744898438454e-11 - - 0.07140888737194473 - - - 0.11964530187105993 - - 2.837623469531536e-10 - - -0.2768455888144672 - - - -0.22210803085181396 - - -4.802132025361061e-10 - - 0.20543670067127096 - adc2: - config: - conv_tol: 1.0e-10 - core_orbitals: null - n_singlets: 3 - energy: - - -74.52306494758524 - - -74.4210231428533 - - -74.39990473420053 - gradient: - - - - 0.27296630301862024 - - 1.964508555829525e-10 - - 0.19153599717537872 - - - 0.04375171427091118 - - 3.8562575355172157e-10 - - -0.3499776718817884 - - - -0.31671801683842205 - - 1.8917489796876907e-10 - - 0.15844167445175117 - - - - 0.4661114452901529 - - 2.1827872842550278e-10 - - 0.3327183580331621 - - - -0.08526563921623165 - - 4.656612873077393e-10 - - -0.37705514822300756 - - - -0.3808458057610551 - - 1.382431946694851e-10 - - 0.044336789804219734 - - - - 0.12454020935547305 - - 1.5279510989785194e-10 - - 0.08709251107939053 - - - 0.11524763766647084 - - 4.2928149923682213e-10 - - -0.29412153316661716 - - - -0.2397878467090777 - - -2.9103830456733704e-11 - - 0.20702902177436044 - adc2x: - config: - conv_tol: 1.0e-10 - core_orbitals: null - n_singlets: 3 - energy: - - -74.54846626885896 - - -74.4421830098894 - - -74.4221092236318 - gradient: - - - - 0.2889574766741134 - - 1.4551915228366852e-10 - - 0.20262688743241597 - - - 0.045065267200698145 - - 4.3655745685100555e-11 - - -0.3685835993819637 - - - -0.3340227430453524 - - -1.4551915228366852e-11 - - 0.16595671254617628 - - - - 0.48461220582248643 - - 2.1100277081131935e-10 - - 0.3459748471796047 - - - -0.08685884004808031 - - 6.548361852765083e-11 - - -0.39460422148840735 - - - -0.39775336504681036 - - -8.003553375601768e-11 - - 0.048629374672600534 - - - - 0.1366148896777304 - - 2.1827872842550278e-10 - - 0.09541060922492761 - - - 0.11530230973585276 - - 5.093170329928398e-11 - - -0.30678889842238277 - - - -0.25191719870781526 - - -4.3655745685100555e-11 - - 0.2113782895321492 - adc3: - config: - conv_tol: 1.0e-10 - core_orbitals: null - n_singlets: 3 - energy: - - -74.55090439658672 - - -74.44714801129275 - - -74.4242627370736 - gradient: - - - - 0.2908625259224209 - - -4.001776687800884e-10 - - 0.2039448505747714 - - - 0.04500434071087511 - - -1.1641532182693481e-10 - - -0.3704894050679286 - - - -0.3358668661385309 - - 3.346940502524376e-10 - - 0.16654455448588124 - - - - 0.48658428593626013 - - -4.656612873077393e-10 - - 0.34738898534851614 - - - -0.08571265437058173 - - -8.003553375601768e-11 - - -0.3983368489643908 - - - -0.40087163097632583 - - 3.637978807091713e-10 - - 0.05094786360859871 - - - - 0.13570507940312382 - - -3.92901711165905e-10 - - 0.09476317036023829 - - - 0.11679784574516816 - - -1.0186340659856796e-10 - - -0.3079343543649884 - - - -0.2525029244279722 - - 3.41970007866621e-10 - - 0.2131711840411299 - cvs-adc0: - config: - conv_tol: 1.0e-10 - core_orbitals: 1 - n_singlets: 3 - energy: - - -54.12308247440466 - - -53.96000354314296 - gradient: - - - - 0.13670422898576362 - - 4.220055416226387e-10 - - 0.09585740162583534 - - - 0.09903088509599911 - - -2.546585164964199e-10 - - -0.284258487423358 - - - -0.23573511330323527 - - 3.5652192309498787e-10 - - 0.18840108531730948 - - - - 0.4100968398124678 - - 3.5652192309498787e-10 - - 0.2924419815244619 - - - -0.07108191118459217 - - -1.7462298274040222e-10 - - -0.3370177824544953 - - - -0.3390149278129684 - - 3.128661774098873e-10 - - 0.04457580037706066 - cvs-adc1: - config: - conv_tol: 1.0e-10 - core_orbitals: 1 - n_singlets: 3 - energy: - - -54.85354413664419 - - -54.7941942631979 - gradient: - - - - 0.20441432864026865 - - -2.0372681319713593e-10 - - 0.14198894474975532 - - - 0.03388333945622435 - - -2.9103830456733704e-10 - - -0.2622227993415436 - - - -0.23829766743438086 - - -2.9831426218152046e-10 - - 0.12023385422071442 - - - - 0.31129172734654276 - - -8.731149137020111e-11 - - 0.22435429733013734 - - - -0.03036278401123127 - - -3.637978807091713e-10 - - -0.2915527691147872 - - - -0.28092894267319934 - - -3.128661774098873e-10 - - 0.06719847115891753 - cvs-adc2: - config: - conv_tol: 1.0e-10 - core_orbitals: 1 - n_singlets: 3 - energy: - - -54.989035890846495 - - -54.905860098139534 - - -53.1668568155216 - gradient: - - - - 0.23872009358456125 - - -3.8562575355172157e-10 - - 0.1671009848068934 - - - 0.03348872340575326 - - -2.1100277081131935e-10 - - -0.29891402418434154 - - - -0.27220881724497303 - - 5.093170329928398e-11 - - 0.13181303915916942 - - - - 0.361930021950684 - - -4.220055416226387e-10 - - 0.25924844172550365 - - - -0.04305156636110041 - - -3.2014213502407074e-10 - - -0.3264197400130797 - - - -0.3188784557278268 - - 7.275957614183426e-11 - - 0.06717129818571266 - - - - 0.30556880148651544 - - -4.220055416226387e-10 - - 0.21378263917722506 - - - 0.19212377665098757 - - -3.2014213502407074e-10 - - -0.5935662729316391 - - - -0.4976925785158528 - - 2.1827872842550278e-11 - - 0.3797836338781053 - mp2: - config: - conv_tol: 1.0e-10 - core_orbitals: null - energy: -74.99357808910254 - gradient: - - - 0.096480893320404 - - -2.764863893389702e-10 - - 0.06886449074954726 - - - -0.02618346233794 - - 1.964508555829525e-10 - - -0.06597386256908067 - - - -0.07029743114981102 - - 8.731149137020111e-11 - - -0.0028906281804665923 - xyz: "\n O 0 0 0\n H 0 0 1.795239827225189\n H 1.693194615993441 0 -0.599043184453037\n\ - \ " -methods: -- mp2 -- adc0 -- adc1 -- adc2 -- adc2x -- adc3 -- cvs-adc0 -- cvs-adc1 -- cvs-adc2 -molecules: -- h2o diff --git a/adcc/tests/backends/testing.py b/adcc/tests/backends/testing.py index 0d3e483ca..fcc1c4aa0 100644 --- a/adcc/tests/backends/testing.py +++ b/adcc/tests/backends/testing.py @@ -191,6 +191,7 @@ def cached_backend_hf(backend: str, system: str, conv_tol=1e-12, pe_options=None and return the result. """ import adcc.backends + print(system) from .. import testcases diff --git a/adcc/tests/data/gradient_data.json b/adcc/tests/data/gradient_data.json new file mode 100644 index 000000000..a74f95e5d --- /dev/null +++ b/adcc/tests/data/gradient_data.json @@ -0,0 +1 @@ +{"basissets": ["sto3g", "ccpvdz"], "methods": ["mp2", "adc0", "adc1", "adc2", "adc2x", "adc3", "cvs-adc0", "cvs-adc1", "cvs-adc2", "cvs-adc2x"], "molecules": ["h2o"], "h2o": {"sto3g": {"mp2": {"energy": -74.99357808910258, "gradient": [[0.09648089353868272, -7.275957614183426e-12, 0.06886449053126853], [-0.026183461559412535, 0.0, -0.0659738619287964], [-0.07029743172461167, -1.4551915228366852e-11, -0.002890627962187864]], "config": {"conv_tol": 1e-09, "core_orbitals": null}}, "adc0": {"energy": [-73.96883482604426, -73.91481187944933, -73.8057558947831, -73.75173294818818, -73.72721279699914], "gradient": [[[0.21500520807603607, -1.0186340659856796e-10, 0.15122539465664886], [0.074898492108332, 0.0, -0.33320423345139716], [-0.2899037002425757, -2.1827872842550278e-11, 0.18197883959510364]], [[0.15869260571344057, -7.275957614183426e-12, 0.11135792801360367], [0.12612935141078196, -8.731149137020111e-11, -0.3458573067910038], [-0.28482195712422254, -7.275957614183426e-12, 0.23449937959230738]], [[0.4883978163416032, -2.1827872842550278e-11, 0.34780997568304883], [-0.09521430340100778, 7.275957614183426e-12, -0.38596352970489534], [-0.393183512838732, -2.9103830456733704e-11, 0.03815355485130567]], [[0.432085214095423, 2.1827872842550278e-11, 0.3079425090982113], [-0.04398344415676547, -8.731149137020111e-11, -0.39861660305177793], [-0.3881017696039635, -7.275957614183426e-12, 0.09067409489944112]], [[0.4312687490892131, -1.4551915228366852e-11, 0.30399765190668404], [0.0012444719613995403, -2.1827872842550278e-11, -0.45833798522653524], [-0.4325132208832656, -7.275957614183426e-12, 0.15434033421479398]]], "config": {"conv_tol": 1e-09, "n_singlets": 5, "core_orbitals": null}}, "adc1": {"energy": [-74.47588319597416, -74.38511885048102, -74.3571822920938, -74.24904200360893, -74.13327522706388], "gradient": [[[0.2519565781985875, -2.1827872842550278e-11, 0.17643765273533063], [0.043837964338308666, 1.4551915228366852e-11, -0.32756816069741035], [-0.29579454263148364, 2.1827872842550278e-11, 0.15113050883519463]], [[0.44204020009055967, 0.0, 0.31597312643862097], [-0.08205663987610023, 0.0, -0.35633136297838064], [-0.3599835601708037, -2.1827872842550278e-11, 0.040358237114560325]], [[0.102462732247659, 2.1827872842550278e-11, 0.07140888640424237], [0.11964530191471567, 2.1827872842550278e-11, -0.2768455860496033], [-0.22210803416237468, -2.1827872842550278e-11, 0.20543670036568074]], [[0.33387671443779254, 2.1827872842550278e-11, 0.2387534842637251], [-2.251235127914697e-05, -1.4551915228366852e-11, -0.35684544259129325], [-0.33385420200647786, 1.4551915228366852e-11, 0.1180919590042322]], [[0.4270152217577561, 1.4551915228366852e-11, 0.3020655645959778], [-0.0510407698166091, 1.4551915228366852e-11, -0.38096642302843975], [-0.37597445177379996, -2.1827872842550278e-11, 0.0789008592182654]]], "config": {"conv_tol": 1e-09, "n_singlets": 5, "core_orbitals": null}}, "adc2": {"energy": [-74.5230649475857, -74.42102314285407, -74.399904734204, -74.2806092729357, -74.15388076828465], "gradient": [[[0.2729663057762082, -1.2369127944111824e-10, 0.1915359973354498], [0.043751713426900096, -7.275957614183426e-12, -0.3499776703029056], [-0.3167180191812804, 1.4551915228366852e-11, 0.1584416737605352]], [[0.4661114461196121, 3.637978807091713e-11, 0.3327183597430121], [-0.08526563976920443, 1.8917489796876907e-10, -0.3770551475681714], [-0.38084580657596234, 2.1827872842550278e-11, 0.044336788858345244]], [[0.1245402125568944, -1.4551915228366852e-11, 0.08709251005348051], [0.11524763699708274, 2.1827872842550278e-11, -0.2941215308092069], [-0.23978784963401267, -1.4551915228366852e-11, 0.20702902170887683]], [[0.34492495327140205, -1.4551915228366852e-11, 0.24646419990313007], [-0.0014078249514568597, -2.9103830456733704e-11, -0.36650604708120227], [-0.3435171281089424, -7.275957614183426e-12, 0.12004184816760244]], [[0.4314259997627232, -1.4551915228366852e-11, 0.30517971346125705], [-0.05028844868502347, 1.4551915228366852e-11, -0.386704910924891], [-0.3811375508448691, -7.275957614183426e-12, 0.08152519801660674]]], "config": {"conv_tol": 1e-09, "n_singlets": 5, "core_orbitals": null}}, "adc2x": {"energy": [-74.5484662688597, -74.44218300989021, -74.42210922368841, -74.30300532559038, -74.16527252522135], "gradient": [[[0.28895747921342263, 7.275957614183426e-12, 0.2026268877380062], [0.045065266407618765, -1.4551915228366852e-11, -0.3685835983196739], [-0.33402274580294034, -5.093170329928398e-11, 0.16595671139657497]], [[0.4846122063099756, 1.4551915228366852e-11, 0.3459748487730394], [-0.08685884039005032, 0.0, -0.39460422133561224], [-0.39775336616730783, -2.9103830456733704e-11, 0.04862937352299923]], [[0.13661488301295321, 1.4551915228366852e-10, 0.09541062240168685], [0.11530230956850573, -1.4551915228366852e-11, -0.3067889074445702], [-0.25191719264694257, 7.275957614183426e-12, 0.21137828581413487]], [[0.36053903902939055, 7.275957614183426e-12, 0.25766010332881706], [-0.0009222038715961389, 8.003553375601768e-11, -0.3839128288964275], [-0.3596168350704829, -2.1827872842550278e-11, 0.12625272644800134]], [[0.43669924540881766, 7.275957614183426e-12, 0.308943429197825], [-0.05085965209582355, 2.9103830456733704e-11, -0.3915265553150675], [-0.38583959305105964, -7.275957614183426e-12, 0.08258312672114698]]], "config": {"conv_tol": 1e-09, "n_singlets": 5, "core_orbitals": null}}, "adc3": {"energy": [-74.55090439658746, -74.44714801129354, -74.42426273712188, -74.30620148905741, -74.16694386620925], "gradient": [[[0.2908625282943831, 2.1827872842550278e-11, 0.20394485128781525], [0.04500433992507169, -1.4551915228366852e-11, -0.37048940415115794], [-0.33586686859780457, -2.9103830456733704e-11, 0.16654455379466526]], [[0.4865842864601291, -2.1827872842550278e-11, 0.3473889870510902], [-0.08571265485807089, 2.1827872842550278e-11, -0.3983368489789427], [-0.4008716317039216, -1.4551915228366852e-11, 0.05094786284462316]], [[0.13570507883559912, -2.9103830456733704e-11, 0.09476317676308099], [0.11679784433363238, 2.1827872842550278e-11, -0.3079343576464453], [-0.2525029233220266, 2.9103830456733704e-11, 0.21317118174920324]], [[0.3612387817411218, 7.275957614183426e-12, 0.2581562034683884], [0.00045972187217557803, -1.4551915228366852e-11, -0.38661062382743694], [-0.3616985033659148, -7.275957614183426e-12, 0.12845442127581919]], [[0.4404495687704184, 2.9103830456733704e-11, 0.31157616753625916], [-0.05225038512435276, 2.9103830456733704e-11, -0.39351955433085095], [-0.3881991834496148, -2.9103830456733704e-11, 0.08194338764587883]]], "config": {"conv_tol": 1e-09, "n_singlets": 5, "core_orbitals": null}}, "cvs-adc0": {"energy": [-54.123082474404995, -53.960003543143834], "gradient": [[[0.13670423482835758, 0.0, 0.09585740332113346], [0.09903088248393033, -1.4551915228366852e-11, -0.2842584849859122], [-0.2357351180180558, 7.275957614183426e-12, 0.188401082654309]], [[0.4100968432685477, 2.1827872842550278e-11, 0.2924419842674979], [-0.07108191314910073, -1.4551915228366852e-11, -0.33701778129761806], [-0.3390149306069361, -7.275957614183426e-12, 0.04457579784502741]]], "config": {"conv_tol": 1e-09, "n_singlets": 5, "core_orbitals": 1}}, "cvs-adc1": {"energy": [-54.85354413664511, -54.79419426319812], "gradient": [[[0.2044143344683107, 2.1827872842550278e-11, 0.1419889454045915], [0.033883336967846844, -1.4551915228366852e-11, -0.262222796693095], [-0.2382976719745784, 0.0, 0.12023385223437799]], [[0.3112917308098986, 7.275957614183426e-12, 0.22435430129553424], [-0.03036278657236835, 7.275957614183426e-12, -0.29155276880192105], [-0.2809289447250194, 2.1827872842550278e-11, 0.06719846829219023]]], "config": {"conv_tol": 1e-09, "n_singlets": 5, "core_orbitals": 1}}, "cvs-adc2": {"energy": [-54.98903589084722, -54.90586009813991, -53.16685681552232, -53.101104786907726, -53.00377788426118], "gradient": [[[0.23872009933984373, -2.9103830456733704e-11, 0.1671009868659894], [0.03348872094647959, 4.3655745685100555e-11, -0.29891402232897235], [-0.27220882097026333, 1.4551915228366852e-11, 0.1318130366198602]], [[0.36193002599611646, 2.1827872842550278e-11, 0.2592484456472448], [-0.04305156866030302, 0.0, -0.3264197397438693], [-0.3188784580779611, -7.275957614183426e-12, 0.06717129518801812]], [[0.305568811170815, 7.275957614183426e-12, 0.21378264181839768], [0.19212377251824364, 2.9103830456733704e-11, -0.5935662706178846], [-0.49769258473679656, 1.0913936421275139e-10, 0.3797836300363997]], [[0.23468779257382266, -7.275957614183426e-11, 0.16384246382222045], [0.24505627318285406, 1.964508555829525e-10, -0.5933986320596887], [-0.47974406644061673, -2.1827872842550278e-11, 0.4295561693725176]], [[0.5789614193781745, 2.9103830456733704e-11, 0.4103672228375217], [0.022010977067111526, 3.637978807091713e-11, -0.6463255668786587], [-0.6009723973911605, 1.0186340659856796e-10, 0.23595834522711812]]], "config": {"conv_tol": 1e-09, "n_singlets": 5, "core_orbitals": 1}}, "cvs-adc2x": {"energy": [-55.08829803906612, -54.9945312916704, -54.266903715981805, -54.258055435885886, -54.20500159732517], "gradient": [[[0.27884997078217566, -1.673470251262188e-10, 0.1953710336747463], [0.03098650036554318, 7.275957614183426e-12, -0.33784350618952885], [-0.3098364717588993, 1.3096723705530167e-10, 0.14247247358434834]], [[0.41212538530817255, -1.4551915228366852e-11, 0.29478439913509646], [-0.05303481598821236, -1.2369127944111824e-10, -0.36559760699310573], [-0.359090569872933, 0.0, 0.07081320873840014]], [[0.6789990236284211, -1.7462298274040222e-10, 0.4736056833571638], [-0.019374826908460818, 2.9103830456733704e-11, -0.6864346827715053], [-0.6596241974912118, 6.548361852765083e-11, 0.21282900056394283]], [[0.6081797262158943, 1.3096723705530167e-10, 0.4384273026807932], [0.01058207180176396, 2.9103830456733704e-11, -0.6685617413022555], [-0.6187617984833196, -5.093170329928398e-11, 0.23013443964737235]], [[0.46743476379924687, 1.4551915228366852e-11, 0.33145697056897916], [0.022216292971279472, 0.0, -0.528248111018911], [-0.489651057854644, 1.4551915228366852e-11, 0.19679114157042932]]], "config": {"conv_tol": 1e-09, "n_singlets": 5, "core_orbitals": 1}}}, "ccpvdz": {"mp2": {"energy": -76.22940338787562, "gradient": [[0.024395466447458602, -2.9103830456733704e-11, 0.01773811209568521], [-0.010762456666270737, -2.9103830456733704e-11, -0.011150370693940204], [-0.013632937501824927, -1.4551915228366852e-11, -0.006587735537323169]], "config": {"conv_tol": 1e-09, "core_orbitals": null}}, "adc0": {"energy": [-75.34687593720773, -75.28099897309124, -75.27790714495661, -75.21203018084012, -75.1263800402113], "gradient": [[[0.05781977490551071, 7.275957614183426e-12, 0.04124122217763215], [-0.0010635846047080122, -1.4551915228366852e-11, -0.06019881294196239], [-0.05674794071819633, 0.0, 0.018958910419314634]], [[0.013119906550855376, -2.1827872842550278e-11, 0.009577973985869903], [0.0517213462953805, 2.1827872842550278e-11, -0.08735985546081793], [-0.06483396996191004, 2.9103830456733704e-11, 0.0777820943549159]], [[0.035872519212716725, 1.4551915228366852e-11, 0.02590936847263947], [0.007818394005880691, 7.275957614183426e-12, -0.04966096833959455], [-0.04368333833554061, 2.9103830456733704e-11, 0.023752558598062024]], [[-0.008827349083730951, -1.4551915228366852e-11, -0.0057538798355381005], [0.060603324898693245, -7.275957614183426e-12, -0.07682201085845008], [-0.051769367564702407, -1.4551915228366852e-11, 0.08257574253366329]], [[0.2704858468277962, 1.4551915228366852e-11, 0.19159464181575458], [-0.07004997117473977, 0.0, -0.18824054856668226], [-0.2004280803448637, -1.4551915228366852e-11, -0.0033529280190123245]]], "config": {"conv_tol": 1e-09, "n_singlets": 5, "core_orbitals": null}}, "adc1": {"energy": [-75.68543998430039, -75.61931016170234, -75.59868950264112, -75.532752986795, -75.45558187581646], "gradient": [[[0.09274209536670242, -7.275957614183426e-12, 0.06557503178919433], [-0.0026306448489776812, 2.1827872842550278e-11, -0.09467139691696502], [-0.0901040762255434, -1.4551915228366852e-11, 0.029097417085722554]], [[0.1093199013848789, 2.1827872842550278e-11, 0.0780909138629795], [-0.006661084160441533, 2.9103830456733704e-11, -0.10735268513963092], [-0.10265199275454506, -2.1827872842550278e-11, 0.029262722055136692]], [[0.011673270331812091, -7.275957614183426e-12, 0.00844753841374768], [0.056844679136702325, 0.0, -0.09296221228578361], [-0.06851130315772025, 2.1827872842550278e-11, 0.08451495548069943]], [[0.02629122353391722, 0.0, 0.019252847356256098], [0.057597583705501165, -1.4551915228366852e-11, -0.11000348474772181], [-0.08388262351218145, -2.9103830456733704e-11, 0.09075075774308061]], [[0.2821038434340153, 1.4551915228366852e-11, 0.19977067352738231], [-0.07840616344037699, 0.0, -0.18870985075773206], [-0.20369109181774547, 2.1827872842550278e-11, -0.011060022770834621]]], "config": {"conv_tol": 1e-09, "n_singlets": 5, "core_orbitals": null}}, "adc2": {"energy": [-75.92967540818942, -75.85499790112056, -75.84309170418786, -75.76675240926447, -75.66953798976122], "gradient": [[[0.11448709326941753, -1.4551915228366852e-11, 0.08113363845041022], [-0.008901050896383822, 2.1827872842550278e-11, -0.1090564420010196], [-0.10557860966218868, 7.275957614183426e-12, 0.027923848014324903]], [[0.1131836650747573, -7.275957614183426e-12, 0.08065145519503858], [-0.004472936961974483, -1.4551915228366852e-11, -0.11437404136813711], [-0.10870395785605069, 2.9103830456733704e-11, 0.03372336812026333]], [[0.022058329042920377, -2.1827872842550278e-11, 0.015899113190243952], [0.050983897534024436, -2.9103830456733704e-11, -0.09580092146643437], [-0.07303541761211818, 7.275957614183426e-12, 0.0799023346407921]], [[0.020308474187913816, 1.4551915228366852e-11, 0.014956989012716804], [0.058050304411153775, 1.4551915228366852e-11, -0.1042313243233366], [-0.07835257506667404, 1.4551915228366852e-11, 0.08927455494267633]], [[0.26928795556159457, -2.9103830456733704e-11, 0.19073455897159874], [-0.07746179534296971, 7.275957614183426e-12, -0.1764748514542589], [-0.1918197939376114, 2.1827872842550278e-11, -0.01425892054248834]]], "config": {"conv_tol": 1e-09, "n_singlets": 5, "core_orbitals": null}}, "adc2x": {"energy": [-75.94713027647231, -75.87072120069274, -75.86069046652048, -75.78212932285793, -75.68339216526915], "gradient": [[[0.12108681791869458, 7.275957614183426e-12, 0.08575116403517313], [-0.008930603667977266, -2.9103830456733704e-11, -0.11596714374172734], [-0.11214869188552257, 1.4551915228366852e-11, 0.030217022183933295]], [[0.12104355383053189, -7.275957614183426e-12, 0.08621679777570534], [-0.005538905352295842, 2.9103830456733704e-11, -0.1212127921753563], [-0.11549783187365392, 1.4551915228366852e-11, 0.034996749353013]], [[0.02765446234116098, 2.1827872842550278e-11, 0.01980982987151947], [0.05061737170035485, -7.275957614183426e-12, -0.10117332988738781], [-0.07826491810556035, 2.9103830456733704e-11, 0.08136406357516535]], [[0.027274335945548955, 2.1827872842550278e-11, 0.019888993163476698], [0.05681757771526463, 0.0, -0.10988471429300262], [-0.08408563704870176, -1.4551915228366852e-11, 0.08999595484056044]], [[0.2716475580527913, -7.275957614183426e-12, 0.19238663020951208], [-0.07715970138815464, -2.9103830456733704e-11, -0.17938891498488374], [-0.1944814575035707, -7.275957614183426e-12, -0.012996937817661092]]], "config": {"conv_tol": 1e-09, "n_singlets": 5, "core_orbitals": null}}, "adc3": {"energy": [-75.92857834998667, -75.85463334402809, -75.84167671842562, -75.76664279719428, -75.67470300439263], "gradient": [[[0.11627493508422049, 0.0, 0.08229840418789536], [-0.006295996819972061, 1.4551915228366852e-11, -0.11453756176342722], [-0.10997124934510794, 2.1827872842550278e-11, 0.032240211170574185]], [[0.12384516876772977, 0.0, 0.08824648732843343], [-0.006875947656226344, -7.275957614183426e-12, -0.12234318283299217], [-0.11696223153558094, -1.382431946694851e-10, 0.03409750875289319]], [[0.025811466584855225, 2.9103830456733704e-11, 0.018465745204593986], [0.0533070154779125, 2.9103830456733704e-11, -0.10298046591924503], [-0.07911143552337307, 7.275957614183426e-12, 0.08451522156246938]], [[0.033787787426263094, 1.1641532182693481e-10, 0.024522948973753955], [0.056045876095595304, -2.1827872842550278e-11, -0.11573187115573091], [-0.08982723313965835, -2.1827872842550278e-11, 0.0912091305362992]], [[0.2793064223806141, 3.637978807091713e-11, 0.19778368141851388], [-0.07754907244088827, 7.275957614183426e-12, -0.1869451557067805], [-0.2017506956035504, 2.1827872842550278e-11, -0.010837729831109755]]], "config": {"conv_tol": 1e-09, "n_singlets": 5, "core_orbitals": null}}, "cvs-adc0": {"energy": [-55.29234315848254, -55.22337436623141, -54.6671662062745, -54.64254226419146, -54.31941455257717], "gradient": [[[-0.01363594663416734, 1.4551915228366852e-11, -0.009354182511742692], [0.005705504816432949, -5.093170329928398e-11, 0.0060958039975957945], [0.007961477167555131, 1.4551915228366852e-11, 0.0032610131020192057]], [[-0.035583202239649836, 1.4551915228366852e-11, -0.02468603632587474], [0.014587483354262076, -2.9103830456733704e-11, 0.016633648599963635], [0.021026079608418513, -2.1827872842550278e-11, 0.008054661513597239]], [[0.295615929106134, -2.9103830456733704e-11, 0.20218788867350668], [-0.11422500915068667, 1.1641532182693481e-10, -0.14526737584674265], [-0.18136249485542066, 0.0, -0.05691822549124481]], [[-0.04258258258050773, -5.820766091346741e-11, -0.021944308828096837], [0.16518283695040736, 8.003553375601768e-11, -0.19658326423086692], [-0.12257139149005525, 5.820766091346741e-11, 0.2185302046345896]], [[-0.0943416317095398, -1.4551915228366852e-11, -0.06655934288573917], [0.01681761433428619, -1.4551915228366852e-11, 0.07614312684745528], [0.07755017422459787, -7.275957614183426e-12, -0.009581486701790709]]], "config": {"conv_tol": 1e-09, "n_singlets": 5, "core_orbitals": 1}}, "cvs-adc1": {"energy": [-55.7623580120961, -55.74423117760095, -55.23885575120384, -55.20048469034408, -55.178979221895716], "gradient": [[[0.11376989239943214, 3.637978807091713e-11, 0.07504696383693954], [-0.006233317595615517, -2.9103830456733704e-11, -0.10649701902730158], [-0.107507510263531, 1.0186340659856796e-10, 0.03145194291573716]], [[0.1367624182748841, 1.1641532182693481e-10, 0.10286059680947801], [-0.010134714473679196, -8.003553375601768e-11, -0.13692940795590403], [-0.12659825186710805, 7.275957614183426e-12, 0.03407134330336703]], [[-0.035857140050211456, -7.275957614183426e-12, -0.025069641618756577], [0.02807263379509095, -1.382431946694851e-10, -0.0019539316344889812], [0.00781276056659408, 0.0, 0.027025939685699996]], [[0.0637307473589317, -8.003553375601768e-11, 0.046041117268032394], [-0.04479707258724375, -7.275957614183426e-12, -0.005256572927464731], [-0.018904139367805328, 7.275957614183426e-12, -0.04078219792427262]], [[-0.05261707480531186, 0.0, -0.03676470001664711], [0.005314122914569452, 1.2369127944111824e-10, 0.04785384914430324], [0.047328871696663555, 2.9103830456733704e-11, -0.011087133760156576]]], "config": {"conv_tol": 1e-09, "n_singlets": 5, "core_orbitals": 1}}, "cvs-adc2": {"energy": [-56.463324400674544, -56.39198974445309, -55.93190966426827, -55.91365902930488, -55.634891014248154], "gradient": [[[0.06426175875822082, 1.4551915228366852e-11, 0.04550280176772503], [-0.0016873756248969585, 2.9103830456733704e-11, -0.06586654879356502], [-0.06254429007094586, 1.7462298274040222e-10, 0.020366252538224217]], [[0.059006211573432665, 1.964508555829525e-10, 0.04234478738362668], [0.005969680009002332, -2.1100277081131935e-10, -0.07167619411484338], [-0.06494627146457788, -1.382431946694851e-10, 0.02933372787811095]], [[0.26678762744995765, -1.964508555829525e-10, 0.18208895675343229], [-0.08748003323125886, -3.346940502524376e-10, -0.15278823697735788], [-0.17927927291748347, 7.275957614183426e-11, -0.029298384521098342]], [[0.019884901426848955, -1.4551915228366852e-11, 0.022045515754143707], [0.1168202597182244, -5.093170329928398e-11, -0.1942855826273444], [-0.13667679524223786, 3.637978807091713e-11, 0.17224251533480128]], [[-0.08170067649916746, -3.4924596548080444e-10, -0.05746503695991123], [0.049807636183686554, 1.4551915228366852e-10, 0.01592683904164005], [0.031919313929392956, 4.5838532969355583e-10, 0.04154028196353465]]], "config": {"conv_tol": 1e-09, "n_singlets": 5, "core_orbitals": 1}}, "cvs-adc2x": {"energy": [-56.527690992922494, -56.455320049295366, -56.00756567594842, -55.992414483676754, -55.7258963632124], "gradient": [[[0.08823665066302055, 3.2014213502407074e-10, 0.06228063011803897], [-0.0035475476979627274, 7.275957614183426e-12, -0.08849635638762265], [-0.08465851147047943, 3.2014213502407074e-10, 0.026218218845315278]], [[0.09283125843649032, 8.949427865445614e-10, 0.06637479383789469], [-0.0013974821922602132, -2.255546860396862e-10, -0.09725589540903457], [-0.09140373219997855, -1.8189894035458565e-10, 0.030883435916621238]], [[0.26091981134959497, 7.785274647176266e-10, 0.17749230707704555], [-0.08874684962211177, 2.0372681319713593e-10, -0.14432455416681478], [-0.1721437370069907, -4.147295840084553e-10, -0.03316539854131406]], [[0.0209724435408134, 5.529727786779404e-10, 0.02326315642130794], [0.11284109613188775, 4.874891601502895e-10, -0.19026156545442063], [-0.13378430448210565, -4.0745362639427185e-10, 0.1670009150839178]], [[-0.005838602111907676, 1.1423253454267979e-09, -0.003816529810137581], [0.0007158659500419162, 2.1827872842550278e-11, 0.004858776730543468], [0.005147792071511503, -6.548361852765083e-11, -0.0010405088687548414]]], "config": {"conv_tol": 1e-09, "n_singlets": 5, "core_orbitals": 1}}}, "xyz": "\n O 0 0 0\n H 0 0 1.795239827225189\n H 1.693194615993441 0 -0.599043184453037\n "}} \ No newline at end of file diff --git a/adcc/tests/functionality_gradients_test.py b/adcc/tests/functionality_gradients_test.py new file mode 100644 index 000000000..bb1825f57 --- /dev/null +++ b/adcc/tests/functionality_gradients_test.py @@ -0,0 +1,93 @@ +#!/usr/bin/env python3 +## vi: tabstop=4 shiftwidth=4 softtabstop=4 expandtab +## --------------------------------------------------------------------- +## +## Copyright (C) 2020 by the adcc authors +## +## This file is part of adcc. +## +## adcc is free software: you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published +## by the Free Software Foundation, either version 3 of the License, or +## (at your option) any later version. +## +## adcc is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with adcc. If not, see . +## +## --------------------------------------------------------------------- +import unittest +import itertools + +import adcc +import adcc.backends + +from numpy.testing import assert_allclose + +import pytest + +from .backends.testing import cached_backend_hf +from .testdata_cache import gradient_data + + +backends = [b for b in adcc.backends.available() + if b not in ["molsturm", "veloxchem"]] + +molecules = gradient_data["molecules"] +basissets = gradient_data["basissets"] +methods = gradient_data["methods"] + +@pytest.mark.skipif(len(backends) == 0, reason="No backend found.") +@pytest.mark.parametrize("backend", backends) +@pytest.mark.parametrize("method", methods) +@pytest.mark.parametrize("basis", basissets) +@pytest.mark.parametrize("molecule", molecules) +def test_nuclear_gradient(molecule, basis, method, backend): + grad_ref = gradient_data[molecule][basis][method] + + energy_ref = grad_ref["energy"] + grad_fdiff = grad_ref["gradient"] + kwargs = grad_ref["config"] + conv_tol = kwargs["conv_tol"] + + scfres = cached_backend_hf(backend, f"{molecule}_{basis}", conv_tol=1e-11) + print(kwargs) + + if "adc" in method: + state = adcc.run_adc(scfres, method=method, **kwargs) + for ee in state.excitations: + grad = adcc.nuclear_gradient(ee) + assert_allclose(energy_ref[ee.index], ee.total_energy, + atol=conv_tol) + # check energy computed with unrelaxed densities + gs_corr = 0.0 + if ee.method.level > 0: + # compute the ground state contribution + # to the correlation energy + gs_energy = ee.ground_state.energy(ee.method.level) + gs_corr = gs_energy - ee.reference_state.energy_scf + assert_allclose( + gs_corr + ee.excitation_energy, + grad._energy, atol=1e-10 + ) + assert_allclose( + grad_fdiff[ee.index], grad.total, atol=1e-8, + err_msg=f'Gradient for state {ee.index} wrong.' + ) + else: + # MP2 gradients + refstate = adcc.ReferenceState(scfres) + mp = adcc.LazyMp(refstate) + grad = adcc.nuclear_gradient(mp) + assert_allclose(energy_ref, mp.energy(2), atol=1e-8) + # check energy computed with unrelaxed densities + assert_allclose( + mp.energy_correction(2), grad._energy, atol=1e-8 + ) + assert_allclose( + grad_fdiff, grad.total, atol=1e-8 + ) diff --git a/adcc/testdata/dump_fdiff_gradient.py b/adcc/tests/generators/dump_fdiff_gradient.py similarity index 91% rename from adcc/testdata/dump_fdiff_gradient.py rename to adcc/tests/generators/dump_fdiff_gradient.py index 9c548dacd..309a1e7f8 100644 --- a/adcc/testdata/dump_fdiff_gradient.py +++ b/adcc/tests/generators/dump_fdiff_gradient.py @@ -21,15 +21,16 @@ ## ## --------------------------------------------------------------------- from dataclasses import dataclass +from pathlib import Path import itertools import adcc import numpy as np -import yaml +import json from tqdm import tqdm from pyscf import gto, lib -from static_data import xyz +from adcc.tests.testcases import _xyz adcc.set_n_threads(8) lib.num_threads(8) @@ -50,11 +51,12 @@ class Molecule: @property def xyz(self): - return xyz[self.name] + return _xyz[self.name][0] molecules = [ Molecule("h2o", 0, 1), + Molecule("ch2nh2", charge=0, multiplicity=2), ] @@ -86,7 +88,7 @@ def fdiff_gradient(molecule, method, basis, step=1e-4, **kwargs): coords = m.atom_coords().copy() elements = m.elements.copy() - conv_tol = kwargs.get("conv_tol", 1e-10) / 100 + conv_tol = kwargs.get("conv_tol", 1e-10) # run unperturbed system scfres = adcc.backends.run_hf( @@ -137,10 +139,11 @@ def main(): "cvs-adc0", "cvs-adc1", "cvs-adc2", - # "cvs-adc2x", # TODO: broken + "cvs-adc2x", ] molnames = [ "h2o", + # "ch2nh2", ] mols = [m for m in molecules if m.name in molnames] ret = { @@ -148,7 +151,7 @@ def main(): "methods": methods, "molecules": molnames, } - config_excited = {"n_singlets": 3} + config_excited = {"n_singlets": 5} for molecule in mols: molname = molecule.name ret[molname] = {} @@ -156,7 +159,8 @@ def main(): ret[molname][basis] = {} for method in methods: kwargs = { - "conv_tol": 1e-10, + # "conv_tol": 1e-10, + "conv_tol": 1e-9, } if "adc" in method: kwargs.update(config_excited) @@ -177,8 +181,10 @@ def main(): } ret[molname][basis][method] = cont ret[molname]["xyz"] = molecule.xyz - with open("grad_dump.yml", "w") as yamlout: - yaml.safe_dump(ret, yamlout) + + dump_file = Path(__file__).parent.parent / "data" / "gradient_data.json" + with open(dump_file, "w") as fout: + json.dump(ret, fout) if __name__ == "__main__": diff --git a/adcc/tests/testdata_cache.py b/adcc/tests/testdata_cache.py index 602d9dfe9..3c5f71af4 100644 --- a/adcc/tests/testdata_cache.py +++ b/adcc/tests/testdata_cache.py @@ -299,3 +299,4 @@ def _import_hook(data: dict): psi4_data = read_json_data("psi4_data.json") pyscf_data = read_json_data("pyscf_data.json") tmole_data = read_json_data("tmole_data.json") +gradient_data = read_json_data("gradient_data.json") From d7579dacfcb5cd488b0225230c5ca9ad25ab3b1b Mon Sep 17 00:00:00 2001 From: Maximilian Scheurer <11406414+maxscheurer@users.noreply.github.com> Date: Thu, 5 Mar 2026 11:08:48 +0100 Subject: [PATCH 18/18] fix cvs-adc2x gradients and generation --- adcc/gradients/TwoParticleDensityMatrix.py | 7 ++++--- adcc/gradients/__init__.py | 7 +++---- adcc/gradients/amplitude_response.py | 6 +----- adcc/gradients/orbital_response.py | 10 +--------- adcc/tests/functionality_gradients_test.py | 6 +++--- adcc/tests/generators/dump_fdiff_gradient.py | 6 ++++-- 6 files changed, 16 insertions(+), 26 deletions(-) diff --git a/adcc/gradients/TwoParticleDensityMatrix.py b/adcc/gradients/TwoParticleDensityMatrix.py index bffdaa28c..441d43373 100644 --- a/adcc/gradients/TwoParticleDensityMatrix.py +++ b/adcc/gradients/TwoParticleDensityMatrix.py @@ -58,11 +58,12 @@ def __init__(self, spaces): ] if self.mospaces.has_core_occupied_space: self.blocks += [ - b.cccc, b.ococ, b.oooo, b.cvcv, + b.cccc, b.ococ, b.cvcv, b.ocov, b.cccv, b.cocv, b.ocoo, b.ccco, b.occv, b.ccvv, b.ocvv, - b.vvvv, ] + # make sure we didn't add any block twice! + assert len(list(set(self.blocks))) == len(self.blocks) self._tensors = {} @property @@ -223,7 +224,7 @@ def to_ao_basis(self, refstate_or_coefficients=None): if not hasattr(self, "reference_state"): raise ValueError("Argument reference_state is required if no " "reference_state is stored in the " - "OneParticleOperator") + "TwoParticleDensityMatrix") return self.__transform_to_ao(self.reference_state) else: raise TypeError("Argument type not supported.") diff --git a/adcc/gradients/__init__.py b/adcc/gradients/__init__.py index 875684a87..47b47bc5b 100644 --- a/adcc/gradients/__init__.py +++ b/adcc/gradients/__init__.py @@ -159,7 +159,8 @@ def nuclear_gradient(excitation_or_mp): if hf.has_core_occupied_space: delta_IJ = hf.density.cc - g2_hf.oooo = -0.25 * einsum("ik,jl->ijkl", delta_ij, delta_ij) + g2_hf.oooo = 0.25 * (- einsum("li,jk->ijkl", delta_ij, delta_ij) + + einsum("ki,jl->ijkl", delta_ij, delta_ij)) g2_hf.cccc = -0.5 * einsum("IK,JL->IJKL", delta_IJ, delta_IJ) g2_hf.ococ = -1.0 * einsum("ik,JL->iJkL", delta_ij, delta_IJ) @@ -168,9 +169,7 @@ def nuclear_gradient(excitation_or_mp): + einsum("ik,JL->iJkL", delta_ij, g1o.cc + 2.0 * delta_IJ) + einsum("ik,JL->iJkL", g1o.oo, delta_IJ) ) - g2_oresp.oooo = 0.25 * ( - einsum("ik,jl->ijkl", delta_ij, g1o.oo + delta_ij) - ) + g2_oresp.oooo = einsum("ij,kl->kilj", delta_ij, g1o.oo) g2_oresp.ovov = einsum("ij,ab->iajb", delta_ij, g1o.vv) g2_oresp.cvcv = einsum("IJ,ab->IaJb", delta_IJ, g1o.vv) g2_oresp.ocov = 2 * einsum("ik,Ja->iJka", delta_ij, g1o.cv) diff --git a/adcc/gradients/amplitude_response.py b/adcc/gradients/amplitude_response.py index 9e0447b5f..7f9f37bcc 100644 --- a/adcc/gradients/amplitude_response.py +++ b/adcc/gradients/amplitude_response.py @@ -642,11 +642,7 @@ def ampl_relaxed_dms_cvs_adc2x(exci): g2a.ccvv = - 1.0 * t2ccvv g2a.ocvv = - 1.0 * t2ocvv g2a.ococ = 1.0 * einsum("iJab,kLab->iJkL", u.pphh, u.pphh) - g2a.vvvv = 1.0 * einsum("iJcd,iJab->abcd", u.pphh, u.pphh) - - # TODO: remove - # g2a.ococ *= 0.0 - # g2a.vvvv *= 0.0 + g2a.vvvv = 2.0 * einsum("iJcd,iJab->abcd", u.pphh, u.pphh) g1a.co = ( - 1.0 * einsum('JbKc,ibKc->Ji', g2a.cvcv, hf.ovcv) diff --git a/adcc/gradients/orbital_response.py b/adcc/gradients/orbital_response.py index 0b1b2ab03..37573d998 100644 --- a/adcc/gradients/orbital_response.py +++ b/adcc/gradients/orbital_response.py @@ -78,7 +78,7 @@ def orbital_response_rhs(hf, g1a, g2a): + 2.0 * einsum('kJIb,kJab->Ia', g2a.occv, hf.ocvv) - 1.0 * einsum('abcd,Ibcd->Ia', g2a.vvvv, hf.cvvv) # cvs-adc2x - 2.0 * einsum('jakb,jIkb->Ia', g2a.ovov, hf.ocov) # cvs-adc2x - - 2.0 * einsum('jIlK,lKja->Ia', g2a.ococ, hf.ocov) # cvs-adc2x + + 2.0 * einsum('jIlK,lKja->Ia', g2a.ococ, hf.ocov) # cvs-adc2x ) ret = AmplitudeVector(cv=ret_cv, ov=ret_ov) else: @@ -112,7 +112,6 @@ def orbital_response_rhs(hf, g1a, g2a): def energy_weighted_density_matrix(hf, g1o, g2a): if hf.has_core_occupied_space: - # CVS-ADC0, CVS-ADC1, CVS-ADC2 w = OneParticleOperator(hf) w.cc = - 0.5 * ( + einsum("JKab,IKab->IJ", g2a.ccvv, hf.ccvv) @@ -295,13 +294,6 @@ def __matmul__(self, lam): ret = AmplitudeVector(cv=ret_cv, ov=ret_ov) else: ret = AmplitudeVector(ov=ret_ov) - # TODO: generalize once other solvent methods are available - if self.hf.environment == "pe": - # PE contribution to the orbital Hessian - ops = self.hf.operators - dm = OneParticleOperator(self.hf, is_symmetric=True) - dm.ov = lam.ov - ret += ops.pe_induction_elec(dm).ov return evaluate(ret) diff --git a/adcc/tests/functionality_gradients_test.py b/adcc/tests/functionality_gradients_test.py index bb1825f57..2df686078 100644 --- a/adcc/tests/functionality_gradients_test.py +++ b/adcc/tests/functionality_gradients_test.py @@ -75,7 +75,7 @@ def test_nuclear_gradient(molecule, basis, method, backend): grad._energy, atol=1e-10 ) assert_allclose( - grad_fdiff[ee.index], grad.total, atol=1e-8, + grad_fdiff[ee.index], grad.total, atol=5e-8, rtol=0, err_msg=f'Gradient for state {ee.index} wrong.' ) else: @@ -86,8 +86,8 @@ def test_nuclear_gradient(molecule, basis, method, backend): assert_allclose(energy_ref, mp.energy(2), atol=1e-8) # check energy computed with unrelaxed densities assert_allclose( - mp.energy_correction(2), grad._energy, atol=1e-8 + mp.energy_correction(2), grad._energy, atol=5e-8, rtol=0 ) assert_allclose( - grad_fdiff, grad.total, atol=1e-8 + grad_fdiff, grad.total, atol=1e-8, rtol=0 ) diff --git a/adcc/tests/generators/dump_fdiff_gradient.py b/adcc/tests/generators/dump_fdiff_gradient.py index 309a1e7f8..1003e2d44 100644 --- a/adcc/tests/generators/dump_fdiff_gradient.py +++ b/adcc/tests/generators/dump_fdiff_gradient.py @@ -89,10 +89,11 @@ def fdiff_gradient(molecule, method, basis, step=1e-4, **kwargs): elements = m.elements.copy() conv_tol = kwargs.get("conv_tol", 1e-10) + print('conv tol', conv_tol) # run unperturbed system scfres = adcc.backends.run_hf( - 'pyscf', molecule.xyz, basis, conv_tol=conv_tol, conv_tol_grad=conv_tol, + 'pyscf', molecule.xyz, basis, conv_tol=conv_tol, conv_tol_grad=conv_tol * 10, charge=molecule.charge, multiplicity=molecule.multiplicity ) if "adc" in method: @@ -160,7 +161,8 @@ def main(): for method in methods: kwargs = { # "conv_tol": 1e-10, - "conv_tol": 1e-9, + # "conv_tol": 1e-9, + "conv_tol": 1e-8, } if "adc" in method: kwargs.update(config_excited)