vayesta.rpa.rirpa

Submodules

vayesta.rpa.rirpa.NI_eval

exception vayesta.rpa.rirpa.NI_eval.NIException[source]

Bases: BaseException

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

class vayesta.rpa.rirpa.NI_eval.NumericalIntegratorBase(out_shape, diag_shape, npoints, log)[source]

Bases: object

Abstract base class for numerical integration over semi-infinite and infinite limits. Subclasses implementing a specific quadrature need to define

Subclasses implementing specific evaluations need to define:

.eval_contrib .eval_diag_contrib .eval_diag_deriv_contrib .eval_diag_deriv2_contrib .eval_diag_exact

A new .__init__ assigning any required attributes and a .fix_params may also be required, depending upon the particular form of the integral to be approximated. Might be able to write this as a factory class, but this’ll do for now.

property npoints
get_quad(a)[source]

Generate the appropriate Clenshaw-Curtis quadrature points and weights.

eval_contrib(freq)[source]

Evaluate contribution to numerical integral of result at given frequency point.

eval_diag_contrib(freq)[source]

Evaluate contribution to integral of diagonal approximation at given frequency point.

eval_diag_deriv_contrib(freq)[source]

Evaluate gradient of contribution to integral of diagonal approximation at given frequency point, w.r.t that frequency point.

eval_diag_deriv2_contrib(freq)[source]

Evaluate second derivative of contribution to integral of diagonal approximation at given frequency point, w.r.t that frequency point.

eval_diag_exact()[source]

Provides an exact evaluation of the integral for the diagonal approximation.

eval_NI_approx(a)[source]

Evaluate the NI approximation of the integral with a provided quadrature.

eval_diag_NI_approx(a)[source]

Evaluate the NI approximation to the diagonal approximation of the integral.

eval_diag_NI_approx_grad(a)[source]

Evaluate the gradient w.r.t a of NI diagonal expression. Note that for all quadratures the weights and quadrature point positions are proportional to the arbitrary parameter `a’, so we can use the same expressions for the derivatives.

eval_diag_NI_approx_deriv2(a)[source]

Evaluate the second derivative w.r.t a of NI diagonal expression. Note that for all quadratures the weights and quadrature point positions are proportional to the arbitrary parameter `a’, so we can use the same expressions for the derivatives.

test_diag_derivs(a, delta=1e-06)[source]
opt_quadrature_diag(ainit=None)[source]

Optimise the quadrature to exactly integrate a diagonal approximation to the integral

fix_params()[source]

If required set parameters within ansatz; defined to ensure hook for functionality in future, will not always be needed.

get_offset()[source]
kernel(a=None, opt_quad=True)[source]

Perform numerical integration. Put simply, fix any arbitrary parameters in the integral to be evaluated, optimise the quadrature grid to ensure a diagonal approximation is exactly integrated then evaluate full expression.

kernel_adaptive()[source]
l2_scan(freqs)[source]
max_scan(freqs)[source]
get_quad_vals(a, l2norm=True)[source]
class vayesta.rpa.rirpa.NI_eval.NumericalIntegratorClenCur(out_shape, diag_shape, npoints, log)[source]

Bases: NumericalIntegratorBase

property npoints
calculate_error(a, b)[source]

Calculate error by solving cubic equation to model convergence as lpha e^{-eta n_p}. This relies upon the Cauchy-Schwartz inequality, and assumes all errors are at their maximum values, so generally overestimates the resulting error, which suits us well. This also overestimates the error since it doesn’t account for the effect of quadrature grid optimisation, which leads to our actual estimates converging more rapidly than they would with a static grid spacing parameter.

This approach is detailed in Appendix B of https://arxiv.org/abs/2301.09107, Eqs. 100-104.

To understand the general behaviour of this approach, we can instead consider the simpler approximation that the magnitude of a given difference is dominated by the least accurate estimate. This leads to the estimate of the error resulting from our most accurate estimate as

error = b ** 3 / a ** 2

with the error in this approximation given by

error_error = b ** 2 / a ** 2.

eval_NI_approx(a)[source]

Evaluate the NI approximation of the integral with a provided quadrature.

eval_contrib(freq)

Evaluate contribution to numerical integral of result at given frequency point.

eval_diag_NI_approx(a)

Evaluate the NI approximation to the diagonal approximation of the integral.

eval_diag_NI_approx_deriv2(a)

Evaluate the second derivative w.r.t a of NI diagonal expression. Note that for all quadratures the weights and quadrature point positions are proportional to the arbitrary parameter `a’, so we can use the same expressions for the derivatives.

eval_diag_NI_approx_grad(a)

Evaluate the gradient w.r.t a of NI diagonal expression. Note that for all quadratures the weights and quadrature point positions are proportional to the arbitrary parameter `a’, so we can use the same expressions for the derivatives.

eval_diag_contrib(freq)

Evaluate contribution to integral of diagonal approximation at given frequency point.

eval_diag_deriv2_contrib(freq)

Evaluate second derivative of contribution to integral of diagonal approximation at given frequency point, w.r.t that frequency point.

eval_diag_deriv_contrib(freq)

Evaluate gradient of contribution to integral of diagonal approximation at given frequency point, w.r.t that frequency point.

eval_diag_exact()

Provides an exact evaluation of the integral for the diagonal approximation.

fix_params()

If required set parameters within ansatz; defined to ensure hook for functionality in future, will not always be needed.

get_offset()
get_quad(a)

Generate the appropriate Clenshaw-Curtis quadrature points and weights.

get_quad_vals(a, l2norm=True)
kernel(a=None, opt_quad=True)

Perform numerical integration. Put simply, fix any arbitrary parameters in the integral to be evaluated, optimise the quadrature grid to ensure a diagonal approximation is exactly integrated then evaluate full expression.

kernel_adaptive()
l2_scan(freqs)
max_scan(freqs)
opt_quadrature_diag(ainit=None)

Optimise the quadrature to exactly integrate a diagonal approximation to the integral

test_diag_derivs(a, delta=1e-06)
class vayesta.rpa.rirpa.NI_eval.NumericalIntegratorClenCurInfinite(out_shape, diag_shape, npoints, log, even)[source]

Bases: NumericalIntegratorClenCur

get_quad(a)[source]

Generate the appropriate Clenshaw-Curtis quadrature points and weights.

calculate_error(a, b)

Calculate error by solving cubic equation to model convergence as lpha e^{-eta n_p}. This relies upon the Cauchy-Schwartz inequality, and assumes all errors are at their maximum values, so generally overestimates the resulting error, which suits us well. This also overestimates the error since it doesn’t account for the effect of quadrature grid optimisation, which leads to our actual estimates converging more rapidly than they would with a static grid spacing parameter.

This approach is detailed in Appendix B of https://arxiv.org/abs/2301.09107, Eqs. 100-104.

To understand the general behaviour of this approach, we can instead consider the simpler approximation that the magnitude of a given difference is dominated by the least accurate estimate. This leads to the estimate of the error resulting from our most accurate estimate as

error = b ** 3 / a ** 2

with the error in this approximation given by

error_error = b ** 2 / a ** 2.

eval_NI_approx(a)

Evaluate the NI approximation of the integral with a provided quadrature.

eval_contrib(freq)

Evaluate contribution to numerical integral of result at given frequency point.

eval_diag_NI_approx(a)

Evaluate the NI approximation to the diagonal approximation of the integral.

eval_diag_NI_approx_deriv2(a)

Evaluate the second derivative w.r.t a of NI diagonal expression. Note that for all quadratures the weights and quadrature point positions are proportional to the arbitrary parameter `a’, so we can use the same expressions for the derivatives.

eval_diag_NI_approx_grad(a)

Evaluate the gradient w.r.t a of NI diagonal expression. Note that for all quadratures the weights and quadrature point positions are proportional to the arbitrary parameter `a’, so we can use the same expressions for the derivatives.

eval_diag_contrib(freq)

Evaluate contribution to integral of diagonal approximation at given frequency point.

eval_diag_deriv2_contrib(freq)

Evaluate second derivative of contribution to integral of diagonal approximation at given frequency point, w.r.t that frequency point.

eval_diag_deriv_contrib(freq)

Evaluate gradient of contribution to integral of diagonal approximation at given frequency point, w.r.t that frequency point.

eval_diag_exact()

Provides an exact evaluation of the integral for the diagonal approximation.

fix_params()

If required set parameters within ansatz; defined to ensure hook for functionality in future, will not always be needed.

get_offset()
get_quad_vals(a, l2norm=True)
kernel(a=None, opt_quad=True)

Perform numerical integration. Put simply, fix any arbitrary parameters in the integral to be evaluated, optimise the quadrature grid to ensure a diagonal approximation is exactly integrated then evaluate full expression.

kernel_adaptive()
l2_scan(freqs)
max_scan(freqs)
property npoints
opt_quadrature_diag(ainit=None)

Optimise the quadrature to exactly integrate a diagonal approximation to the integral

test_diag_derivs(a, delta=1e-06)
class vayesta.rpa.rirpa.NI_eval.NumericalIntegratorClenCurSemiInfinite(out_shape, diag_shape, npoints, log)[source]

Bases: NumericalIntegratorClenCur

get_quad(a)[source]

Generate the appropriate Clenshaw-Curtis quadrature points and weights.

calculate_error(a, b)

Calculate error by solving cubic equation to model convergence as lpha e^{-eta n_p}. This relies upon the Cauchy-Schwartz inequality, and assumes all errors are at their maximum values, so generally overestimates the resulting error, which suits us well. This also overestimates the error since it doesn’t account for the effect of quadrature grid optimisation, which leads to our actual estimates converging more rapidly than they would with a static grid spacing parameter.

This approach is detailed in Appendix B of https://arxiv.org/abs/2301.09107, Eqs. 100-104.

To understand the general behaviour of this approach, we can instead consider the simpler approximation that the magnitude of a given difference is dominated by the least accurate estimate. This leads to the estimate of the error resulting from our most accurate estimate as

error = b ** 3 / a ** 2

with the error in this approximation given by

error_error = b ** 2 / a ** 2.

eval_NI_approx(a)

Evaluate the NI approximation of the integral with a provided quadrature.

eval_contrib(freq)

Evaluate contribution to numerical integral of result at given frequency point.

eval_diag_NI_approx(a)

Evaluate the NI approximation to the diagonal approximation of the integral.

eval_diag_NI_approx_deriv2(a)

Evaluate the second derivative w.r.t a of NI diagonal expression. Note that for all quadratures the weights and quadrature point positions are proportional to the arbitrary parameter `a’, so we can use the same expressions for the derivatives.

eval_diag_NI_approx_grad(a)

Evaluate the gradient w.r.t a of NI diagonal expression. Note that for all quadratures the weights and quadrature point positions are proportional to the arbitrary parameter `a’, so we can use the same expressions for the derivatives.

eval_diag_contrib(freq)

Evaluate contribution to integral of diagonal approximation at given frequency point.

eval_diag_deriv2_contrib(freq)

Evaluate second derivative of contribution to integral of diagonal approximation at given frequency point, w.r.t that frequency point.

eval_diag_deriv_contrib(freq)

Evaluate gradient of contribution to integral of diagonal approximation at given frequency point, w.r.t that frequency point.

eval_diag_exact()

Provides an exact evaluation of the integral for the diagonal approximation.

fix_params()

If required set parameters within ansatz; defined to ensure hook for functionality in future, will not always be needed.

get_offset()
get_quad_vals(a, l2norm=True)
kernel(a=None, opt_quad=True)

Perform numerical integration. Put simply, fix any arbitrary parameters in the integral to be evaluated, optimise the quadrature grid to ensure a diagonal approximation is exactly integrated then evaluate full expression.

kernel_adaptive()
l2_scan(freqs)
max_scan(freqs)
property npoints
opt_quadrature_diag(ainit=None)

Optimise the quadrature to exactly integrate a diagonal approximation to the integral

test_diag_derivs(a, delta=1e-06)
class vayesta.rpa.rirpa.NI_eval.NumericalIntegratorGaussianSemiInfinite(out_shape, diag_shape, npoints, log)[source]

Bases: NumericalIntegratorBase

property npoints
get_quad(a)[source]

Generate the appropriate Clenshaw-Curtis quadrature points and weights.

eval_NI_approx(a)

Evaluate the NI approximation of the integral with a provided quadrature.

eval_contrib(freq)

Evaluate contribution to numerical integral of result at given frequency point.

eval_diag_NI_approx(a)

Evaluate the NI approximation to the diagonal approximation of the integral.

eval_diag_NI_approx_deriv2(a)

Evaluate the second derivative w.r.t a of NI diagonal expression. Note that for all quadratures the weights and quadrature point positions are proportional to the arbitrary parameter `a’, so we can use the same expressions for the derivatives.

eval_diag_NI_approx_grad(a)

Evaluate the gradient w.r.t a of NI diagonal expression. Note that for all quadratures the weights and quadrature point positions are proportional to the arbitrary parameter `a’, so we can use the same expressions for the derivatives.

eval_diag_contrib(freq)

Evaluate contribution to integral of diagonal approximation at given frequency point.

eval_diag_deriv2_contrib(freq)

Evaluate second derivative of contribution to integral of diagonal approximation at given frequency point, w.r.t that frequency point.

eval_diag_deriv_contrib(freq)

Evaluate gradient of contribution to integral of diagonal approximation at given frequency point, w.r.t that frequency point.

eval_diag_exact()

Provides an exact evaluation of the integral for the diagonal approximation.

fix_params()

If required set parameters within ansatz; defined to ensure hook for functionality in future, will not always be needed.

get_offset()
get_quad_vals(a, l2norm=True)
kernel(a=None, opt_quad=True)

Perform numerical integration. Put simply, fix any arbitrary parameters in the integral to be evaluated, optimise the quadrature grid to ensure a diagonal approximation is exactly integrated then evaluate full expression.

kernel_adaptive()
l2_scan(freqs)
max_scan(freqs)
opt_quadrature_diag(ainit=None)

Optimise the quadrature to exactly integrate a diagonal approximation to the integral

test_diag_derivs(a, delta=1e-06)
vayesta.rpa.rirpa.NI_eval.gen_ClenCur_quad_inf(a, npoints, even=False)[source]

Generate quadrature points and weights for Clenshaw-Curtis quadrature over infinite range (-inf to +inf)

vayesta.rpa.rirpa.NI_eval.gen_ClenCur_quad_semiinf(a, npoints)[source]

Generate quadrature points and weights for Clenshaw-Curtis quadrature over semiinfinite range (0 to +inf)

class vayesta.rpa.rirpa.NI_eval.NICheckInf(exponent, npoints)[source]

Bases: NumericalIntegratorClenCurInfinite

calculate_error(a, b)

Calculate error by solving cubic equation to model convergence as lpha e^{-eta n_p}. This relies upon the Cauchy-Schwartz inequality, and assumes all errors are at their maximum values, so generally overestimates the resulting error, which suits us well. This also overestimates the error since it doesn’t account for the effect of quadrature grid optimisation, which leads to our actual estimates converging more rapidly than they would with a static grid spacing parameter.

This approach is detailed in Appendix B of https://arxiv.org/abs/2301.09107, Eqs. 100-104.

To understand the general behaviour of this approach, we can instead consider the simpler approximation that the magnitude of a given difference is dominated by the least accurate estimate. This leads to the estimate of the error resulting from our most accurate estimate as

error = b ** 3 / a ** 2

with the error in this approximation given by

error_error = b ** 2 / a ** 2.

eval_NI_approx(a)

Evaluate the NI approximation of the integral with a provided quadrature.

eval_diag_NI_approx(a)

Evaluate the NI approximation to the diagonal approximation of the integral.

eval_diag_NI_approx_deriv2(a)

Evaluate the second derivative w.r.t a of NI diagonal expression. Note that for all quadratures the weights and quadrature point positions are proportional to the arbitrary parameter `a’, so we can use the same expressions for the derivatives.

eval_diag_NI_approx_grad(a)

Evaluate the gradient w.r.t a of NI diagonal expression. Note that for all quadratures the weights and quadrature point positions are proportional to the arbitrary parameter `a’, so we can use the same expressions for the derivatives.

eval_diag_contrib(freq)

Evaluate contribution to integral of diagonal approximation at given frequency point.

eval_diag_deriv2_contrib(freq)

Evaluate second derivative of contribution to integral of diagonal approximation at given frequency point, w.r.t that frequency point.

eval_diag_deriv_contrib(freq)

Evaluate gradient of contribution to integral of diagonal approximation at given frequency point, w.r.t that frequency point.

eval_diag_exact()

Provides an exact evaluation of the integral for the diagonal approximation.

fix_params()

If required set parameters within ansatz; defined to ensure hook for functionality in future, will not always be needed.

get_offset()
get_quad(a)

Generate the appropriate Clenshaw-Curtis quadrature points and weights.

get_quad_vals(a, l2norm=True)
kernel(a=None, opt_quad=True)

Perform numerical integration. Put simply, fix any arbitrary parameters in the integral to be evaluated, optimise the quadrature grid to ensure a diagonal approximation is exactly integrated then evaluate full expression.

kernel_adaptive()
l2_scan(freqs)
max_scan(freqs)
property npoints
opt_quadrature_diag(ainit=None)

Optimise the quadrature to exactly integrate a diagonal approximation to the integral

test_diag_derivs(a, delta=1e-06)
eval_contrib(freq)[source]

Evaluate contribution to numerical integral of result at given frequency point.

vayesta.rpa.rirpa.RIRPA

vayesta.rpa.rirpa.RIRPA.memory_string()
class vayesta.rpa.rirpa.RIRPA.ssRIRRPA(dfmf, rixc=None, log=None, err_tol=1e-06, svd_tol=1e-12, lov=None, compress=0)[source]

Bases: object

Approach based on equations expressed succinctly in the appendix of Furche, F. (2001). PRB, 64(19), 195120. https://doi.org/10.1103/PhysRevB.64.195120 WARNING: Should only be used with canonical mean-field orbital coefficients in mf.mo_coeff and RHF.

Parameters:
  • dfmf (pyscf.scf.SCF) – PySCF density-fitted mean-field object.

  • rixc (tuple of tuples or arrays, optional) – low-rank decomposition of exchange-correlation kernel. First tuple separates two different spin channels, and the second the left- and right-sides of an asymmetric decomposition. Default value is None.

  • log (logging object, optional) – Default value is None.

  • err_tol (float, optional) – Threshold defining estimated error at which to print various accuracy warnings. Default value is 1e-6.

  • svd_tol (float, optional) – Threshold defining negligible singular values when compressing various decompositions. Default value is 1e-12.

  • lov (np.ndarray or tuple of np.ndarray, optional) – occupied-virtual CDERIs in mo basis of provided mean field. If None recalculated from AOs. Default value is None.

  • compress (int, optional) – How thoroughly to attempt compression of the low-rank representations of various matrices. Thresholds are: - above 0: Compress representation of (A+B)(A-B) once constructed, prior to main calculation. - above 3: Compress representations of A+B and A-B separately prior to constructing (A+B)(A-B) or (A+B)^{-1} - above 5: Compress representation of (A+B)^{-1} prior to contracting. This is basically never worthwhile. Note that in all cases these compressions will have computational cost O(N_{aux}^2 ov), the same as our later computations, and so a tradeoff must be made between reducing the N_{aux} in later calculations vs the cost of compression. Default value is 0.

property mol
property df
property kdf
property nocc
property nvir
property naux_eri
property ov
property ov_tot
property mo_coeff

Occupied MO coefficients.

property mo_coeff_occ

Occupied MO coefficients.

property mo_coeff_vir

Virtual MO coefficients.

property mo_energy
property mo_energy_occ
property mo_energy_vir
property e_corr
property e_tot
property eps
property D
kernel_moms(max_moment, target_rot=None, **kwargs)[source]

Calculates all density-density moments up to and including `max_moment’ with one index projected into `target_rot’ space. For details of numerical integration approach see https://arxiv.org/abs/2301.09107.

Runtime: O(n_{points} ((n_{target} + n_{aux}) n_{aux} ov + n_{aux}^3)

Parameters:
  • max_moment (int) – Maximum moment of the dd response to return.

  • target_rot (array_like, of size (n_{target}, o_a v_a + o_b v_b)) – Projector for one index of the moment.

  • npoints (int, optional.) – Integer number of points to use in numerical integrations; will be increased to next highest multiple of 4 for error estimation purposes. Default: 48 (excessive).

  • integral_deduct (str, optional.) – What terms to deduct from numerical integration. Options are “HO” (default), “D”, and None, corresponding to deducting both the mean-field contribution and additional higher-order terms, just the mean-field contribution, or nothing. For discussion of the specific approaches see Appendix A of https://arxiv.org/abs/2301.09107.

  • ainit (float, optional.) – Value of grid scaling to initialise optimisation from. If `opt_quad’ is False, this value of a is used. Default: 10.0

  • opt_quad (bool, optional.) – Whether to optimise the grid spacing `a’. Default: True

  • adaptive_quad (bool, optional.) – Whether to use scipy adaptive quadrature for calculation. Requires prohibitively more evaluations but can provide validation of usual approach. Default: False

  • alpha (float, optional.) – Value or electron interaction scaling in adiabatic connection. Default: 1.0

  • ri_decomps (iterable of three tuples of array_like or None, optional.) – Low-rank RI expressions (S_L,S_R) for (A-B)(A+B), A+B and A-B, such that the non-diagonal contribution to each is given by S_L S_R^T. If `None’ these will be contructed at O(N^4) cost. Default: None

  • analytic_lower_bound (bool, optional.) – Whether to compute analytic lower bound on the error of the computed zeroth dd moment. Computation requires O(N^4) operation, and given limited utility of lower bound this is optional. Default: False.

Returns:

  • moments (array_like, shape (max_moment + 1, n_{tar}, o_a v_a + o_b v_b)) – Array storing the i^th dd moment in the space defined by `target_rot’ in moments[i].

  • err0 (tuple.) – Bounds on the error, in form (upper_bound, lower_bound). If `analytic_lower_bound’=False lower bound will be None.

mult_apbinv(integral, ri_apb_inv)[source]
test_eta0_error(mom0, target_rot, ri_apb, ri_amb)[source]
Test how well our obtained zeroth moment obeys relation used to derive it, namely

A-B = eta0 (A+B) eta0

From this we can estimate the error in eta0 using Cauchy-Schwartz. For details see Appendix B of https://arxiv.org/abs/2301.09107, Eq. 96-99.

kernel_trMPrt(npoints=48, ainit=10)[source]

Evaluate Tr((MP)^(1/2)).

kernel_energy(npoints=48, ainit=10, correction='linear')[source]
direct_AC_integration(local_rot=None, fragment_projectors=None, deg=5, npoints=48, cluster_constrain=False)[source]

Perform direct integration of the adiabatic connection for RPA correlation energy. This will be preferable when the xc kernel is comparable or larger in magnitude to the coulomb kernel, as it only requires evaluation of the moment and not its inverse. local_rot describes the rotation of the ov-excitations to the space of local excitations within a cluster, while fragment_projectors gives the projector within this local excitation space to the actual fragment.

get_gap(calc_xy=False, tol_eig=0.01, max_space=12, nroots=1, **kwargs)[source]

Calculate the RPA gap using a Davidson solver. First checks that A+B and A-B are PSD by calculating their lowest eigenvalues. For a fixed number of eigenvalues in each case this scales as O(N^3), so shouldn’t be prohibitively expensive.

get_compressed_MP(alpha=1.0)[source]
check_errors(error, nelements)[source]
construct_RI_AB()[source]

Construct the RI expressions for the deviation of A+B and A-B from D.

compress_low_rank(ri_l, ri_r, name=None)[source]
get_apb_eri_ri()[source]
get_ab_xc_ri()[source]
get_cderi(blksize=None)[source]
test_spectral_rep(freqs)[source]
record_memory()[source]
vayesta.rpa.rirpa.RIRPA.construct_product_RI(D, ri_1, ri_2)[source]

Given two matrices expressed as low-rank modifications, cderi_1 and cderi_2, of some full-rank matrix D, construct the RI expression for the deviation of their product from D**2. The rank of the resulting deviation is at most the sum of the ranks of the original modifications.

vayesta.rpa.rirpa.RIRPA.construct_inverse_RI(D, ri)[source]
vayesta.rpa.rirpa.RIRPA.compress_low_rank(ri_l, ri_r, tol=1e-12, log=None, name=None)[source]

vayesta.rpa.rirpa.RIURPA

class vayesta.rpa.rirpa.RIURPA.ssRIURPA(dfmf, rixc=None, log=None, err_tol=1e-06, svd_tol=1e-12, lov=None, compress=0)[source]

Bases: ssRIRRPA

property mo_occ
property nmo

Total number of molecular orbitals (MOs).

property nocc

Number of occupied MOs.

property nvir

Number of virtual MOs.

property naux_eri
property mo_coeff

Occupied MO coefficients.

property mo_coeff_occ

Occupied MO coefficients.

property mo_coeff_vir

Virtual MO coefficients.

property mo_energy
property mo_energy_occ
property mo_energy_vir
property ov
property ov_tot
property D
get_apb_eri_ri()[source]
check_errors(error, nelements)
compress_low_rank(ri_l, ri_r, name=None)
construct_RI_AB()

Construct the RI expressions for the deviation of A+B and A-B from D.

property df
direct_AC_integration(local_rot=None, fragment_projectors=None, deg=5, npoints=48, cluster_constrain=False)

Perform direct integration of the adiabatic connection for RPA correlation energy. This will be preferable when the xc kernel is comparable or larger in magnitude to the coulomb kernel, as it only requires evaluation of the moment and not its inverse. local_rot describes the rotation of the ov-excitations to the space of local excitations within a cluster, while fragment_projectors gives the projector within this local excitation space to the actual fragment.

property e_corr
property e_tot
property eps
get_ab_xc_ri()[source]
get_compressed_MP(alpha=1.0)
get_gap(calc_xy=False, tol_eig=0.01, max_space=12, nroots=1, **kwargs)

Calculate the RPA gap using a Davidson solver. First checks that A+B and A-B are PSD by calculating their lowest eigenvalues. For a fixed number of eigenvalues in each case this scales as O(N^3), so shouldn’t be prohibitively expensive.

property kdf
kernel_energy(npoints=48, ainit=10, correction='linear')
kernel_moms(max_moment, target_rot=None, **kwargs)

Calculates all density-density moments up to and including `max_moment’ with one index projected into `target_rot’ space. For details of numerical integration approach see https://arxiv.org/abs/2301.09107.

Runtime: O(n_{points} ((n_{target} + n_{aux}) n_{aux} ov + n_{aux}^3)

Parameters:
  • max_moment (int) – Maximum moment of the dd response to return.

  • target_rot (array_like, of size (n_{target}, o_a v_a + o_b v_b)) – Projector for one index of the moment.

  • npoints (int, optional.) – Integer number of points to use in numerical integrations; will be increased to next highest multiple of 4 for error estimation purposes. Default: 48 (excessive).

  • integral_deduct (str, optional.) – What terms to deduct from numerical integration. Options are “HO” (default), “D”, and None, corresponding to deducting both the mean-field contribution and additional higher-order terms, just the mean-field contribution, or nothing. For discussion of the specific approaches see Appendix A of https://arxiv.org/abs/2301.09107.

  • ainit (float, optional.) – Value of grid scaling to initialise optimisation from. If `opt_quad’ is False, this value of a is used. Default: 10.0

  • opt_quad (bool, optional.) – Whether to optimise the grid spacing `a’. Default: True

  • adaptive_quad (bool, optional.) – Whether to use scipy adaptive quadrature for calculation. Requires prohibitively more evaluations but can provide validation of usual approach. Default: False

  • alpha (float, optional.) – Value or electron interaction scaling in adiabatic connection. Default: 1.0

  • ri_decomps (iterable of three tuples of array_like or None, optional.) – Low-rank RI expressions (S_L,S_R) for (A-B)(A+B), A+B and A-B, such that the non-diagonal contribution to each is given by S_L S_R^T. If `None’ these will be contructed at O(N^4) cost. Default: None

  • analytic_lower_bound (bool, optional.) – Whether to compute analytic lower bound on the error of the computed zeroth dd moment. Computation requires O(N^4) operation, and given limited utility of lower bound this is optional. Default: False.

Returns:

  • moments (array_like, shape (max_moment + 1, n_{tar}, o_a v_a + o_b v_b)) – Array storing the i^th dd moment in the space defined by `target_rot’ in moments[i].

  • err0 (tuple.) – Bounds on the error, in form (upper_bound, lower_bound). If `analytic_lower_bound’=False lower bound will be None.

kernel_trMPrt(npoints=48, ainit=10)

Evaluate Tr((MP)^(1/2)).

property mol
mult_apbinv(integral, ri_apb_inv)
record_memory()
test_eta0_error(mom0, target_rot, ri_apb, ri_amb)
Test how well our obtained zeroth moment obeys relation used to derive it, namely

A-B = eta0 (A+B) eta0

From this we can estimate the error in eta0 using Cauchy-Schwartz. For details see Appendix B of https://arxiv.org/abs/2301.09107, Eq. 96-99.

test_spectral_rep(freqs)
get_cderi(blksize=None)[source]

vayesta.rpa.rirpa.RIdRRPA

class vayesta.rpa.rirpa.RIdRRPA.ssRIdRRPA(dfmf, rixc=None, log=None, err_tol=1e-06, svd_tol=1e-12, lov=None, compress=0)[source]

Bases: ssRIRRPA

Class for computing direct RPA correlated quantites with a restricted reference state.

kernel_moms(max_moment, target_rot=None, return_spatial=False, **kwargs)[source]

Calculates all density-density moments up to and including `max_moment’ with one index projected into `target_rot’ space. For details of numerical integration approach see https://arxiv.org/abs/2301.09107.

Runtime: O(n_{points} ((n_{target} + n_{aux}) n_{aux} ov + n_{aux}^3)

Parameters:
  • max_moment (int) – Maximum moment of the dd response to return.

  • target_rot (array_like, of size (n_{target}, o_a v_a + o_b v_b)) – Projector for one index of the moment.

  • npoints (int, optional.) – Integer number of points to use in numerical integrations; will be increased to next highest multiple of 4 for error estimation purposes. Default: 48 (excessive).

  • integral_deduct (str, optional.) – What terms to deduct from numerical integration. Options are “HO” (default), “D”, and None, corresponding to deducting both the mean-field contribution and additional higher-order terms, just the mean-field contribution, or nothing. For discussion of the specific approaches see Appendix A of https://arxiv.org/abs/2301.09107.

  • ainit (float, optional.) – Value of grid scaling to initialise optimisation from. If `opt_quad’ is False, this value of a is used. Default: 10.0

  • opt_quad (bool, optional.) – Whether to optimise the grid spacing `a’. Default: True

  • adaptive_quad (bool, optional.) – Whether to use scipy adaptive quadrature for calculation. Requires prohibitively more evaluations but can provide validation of usual approach. Default: False

  • alpha (float, optional.) – Value or electron interaction scaling in adiabatic connection. Default: 1.0

  • ri_decomps (iterable of three tuples of array_like or None, optional.) – Low-rank RI expressions (S_L,S_R) for (A-B)(A+B), A+B and A-B, such that the non-diagonal contribution to each is given by S_L S_R^T. If `None’ these will be contructed at O(N^4) cost. Default: None

  • analytic_lower_bound (bool, optional.) – Whether to compute analytic lower bound on the error of the computed zeroth dd moment. Computation requires O(N^4) operation, and given limited utility of lower bound this is optional. Default: False.

Returns:

  • moments (array_like, shape (max_moment + 1, n_{tar}, o_a v_a + o_b v_b)) – Array storing the i^th dd moment in the space defined by `target_rot’ in moments[i].

  • err0 (tuple.) – Bounds on the error, in form (upper_bound, lower_bound). If `analytic_lower_bound’=False lower bound will be None.

kernel_trMPrt(npoints=48, ainit=10)[source]

Evaluate Tr((MP)^(1/2)).

kernel_energy(npoints=48, ainit=10, correction='linear')[source]
get_compressed_MP(alpha=1.0)[source]
check_target_rot(target_rot)[source]
compress_target_rot(target_rot, tol=1e-10)[source]
property D
check_errors(error, nelements)
compress_low_rank(ri_l, ri_r, name=None)
construct_RI_AB()

Construct the RI expressions for the deviation of A+B and A-B from D.

property df
direct_AC_integration(local_rot=None, fragment_projectors=None, deg=5, npoints=48, cluster_constrain=False)

Perform direct integration of the adiabatic connection for RPA correlation energy. This will be preferable when the xc kernel is comparable or larger in magnitude to the coulomb kernel, as it only requires evaluation of the moment and not its inverse. local_rot describes the rotation of the ov-excitations to the space of local excitations within a cluster, while fragment_projectors gives the projector within this local excitation space to the actual fragment.

property e_corr
property e_tot
property eps
get_ab_xc_ri()
get_apb_eri_ri()
get_cderi(blksize=None)
get_gap(calc_xy=False, tol_eig=0.01, max_space=12, nroots=1, **kwargs)

Calculate the RPA gap using a Davidson solver. First checks that A+B and A-B are PSD by calculating their lowest eigenvalues. For a fixed number of eigenvalues in each case this scales as O(N^3), so shouldn’t be prohibitively expensive.

property kdf
property mo_coeff

Occupied MO coefficients.

property mo_coeff_occ

Occupied MO coefficients.

property mo_coeff_vir

Virtual MO coefficients.

property mo_energy
property mo_energy_occ
property mo_energy_vir
property mol
mult_apbinv(integral, ri_apb_inv)
property naux_eri
property nocc
property nvir
property ov
property ov_tot
record_memory()
test_eta0_error(mom0, target_rot, ri_apb, ri_amb)
Test how well our obtained zeroth moment obeys relation used to derive it, namely

A-B = eta0 (A+B) eta0

From this we can estimate the error in eta0 using Cauchy-Schwartz. For details see Appendix B of https://arxiv.org/abs/2301.09107, Eq. 96-99.

test_spectral_rep(freqs)

vayesta.rpa.rirpa.energy_NI

Functionality to calculate zeroth moment via numerical integration

exception vayesta.rpa.rirpa.energy_NI.NIError[source]

Bases: Exception

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

class vayesta.rpa.rirpa.energy_NI.NITrRootMP(D, S_L, S_R, npoints, log)[source]

Bases: NumericalIntegratorClenCurInfinite

property n_aux
get_F(freq)[source]
get_Q(freq)[source]

Efficiently construct Q = S_R (D^{-1} G) S_L^T This is generally the limiting

property diagmat1
property diagmat2
eval_diag_contrib(freq)[source]

Evaluate contribution to integral of diagonal approximation at given frequency point.

eval_diag_deriv_contrib(freq)[source]

Evaluate gradient of contribution to integral of diagonal approximation at given frequency point, w.r.t that frequency point.

eval_diag_deriv2_contrib(freq)[source]

Evaluate second derivative of contribution to integral of diagonal approximation at given frequency point, w.r.t that frequency point.

eval_diag_exact()[source]

Provides an exact evaluation of the integral for the diagonal approximation.

calculate_error(a, b)

Calculate error by solving cubic equation to model convergence as lpha e^{-eta n_p}. This relies upon the Cauchy-Schwartz inequality, and assumes all errors are at their maximum values, so generally overestimates the resulting error, which suits us well. This also overestimates the error since it doesn’t account for the effect of quadrature grid optimisation, which leads to our actual estimates converging more rapidly than they would with a static grid spacing parameter.

This approach is detailed in Appendix B of https://arxiv.org/abs/2301.09107, Eqs. 100-104.

To understand the general behaviour of this approach, we can instead consider the simpler approximation that the magnitude of a given difference is dominated by the least accurate estimate. This leads to the estimate of the error resulting from our most accurate estimate as

error = b ** 3 / a ** 2

with the error in this approximation given by

error_error = b ** 2 / a ** 2.

eval_NI_approx(a)

Evaluate the NI approximation of the integral with a provided quadrature.

eval_contrib(freq)[source]

Evaluate contribution to numerical integral of result at given frequency point.

eval_diag_NI_approx(a)

Evaluate the NI approximation to the diagonal approximation of the integral.

eval_diag_NI_approx_deriv2(a)

Evaluate the second derivative w.r.t a of NI diagonal expression. Note that for all quadratures the weights and quadrature point positions are proportional to the arbitrary parameter `a’, so we can use the same expressions for the derivatives.

eval_diag_NI_approx_grad(a)

Evaluate the gradient w.r.t a of NI diagonal expression. Note that for all quadratures the weights and quadrature point positions are proportional to the arbitrary parameter `a’, so we can use the same expressions for the derivatives.

fix_params()

If required set parameters within ansatz; defined to ensure hook for functionality in future, will not always be needed.

get_offset()
get_quad(a)

Generate the appropriate Clenshaw-Curtis quadrature points and weights.

get_quad_vals(a, l2norm=True)
kernel(a=None, opt_quad=True)

Perform numerical integration. Put simply, fix any arbitrary parameters in the integral to be evaluated, optimise the quadrature grid to ensure a diagonal approximation is exactly integrated then evaluate full expression.

kernel_adaptive()
l2_scan(freqs)
max_scan(freqs)
property npoints
opt_quadrature_diag(ainit=None)

Optimise the quadrature to exactly integrate a diagonal approximation to the integral

test_diag_derivs(a, delta=1e-06)
class vayesta.rpa.rirpa.energy_NI.NITrRootMP_dRHF(D, S_L, S_R, npoints, log)[source]

Bases: NITrRootMP

All provided quantities are now in spatial orbitals. This actually only requires an additional factor in the get_Q method.

calculate_error(a, b)

Calculate error by solving cubic equation to model convergence as lpha e^{-eta n_p}. This relies upon the Cauchy-Schwartz inequality, and assumes all errors are at their maximum values, so generally overestimates the resulting error, which suits us well. This also overestimates the error since it doesn’t account for the effect of quadrature grid optimisation, which leads to our actual estimates converging more rapidly than they would with a static grid spacing parameter.

This approach is detailed in Appendix B of https://arxiv.org/abs/2301.09107, Eqs. 100-104.

To understand the general behaviour of this approach, we can instead consider the simpler approximation that the magnitude of a given difference is dominated by the least accurate estimate. This leads to the estimate of the error resulting from our most accurate estimate as

error = b ** 3 / a ** 2

with the error in this approximation given by

error_error = b ** 2 / a ** 2.

property diagmat1
property diagmat2
eval_NI_approx(a)

Evaluate the NI approximation of the integral with a provided quadrature.

eval_diag_NI_approx(a)

Evaluate the NI approximation to the diagonal approximation of the integral.

eval_diag_NI_approx_deriv2(a)

Evaluate the second derivative w.r.t a of NI diagonal expression. Note that for all quadratures the weights and quadrature point positions are proportional to the arbitrary parameter `a’, so we can use the same expressions for the derivatives.

eval_diag_NI_approx_grad(a)

Evaluate the gradient w.r.t a of NI diagonal expression. Note that for all quadratures the weights and quadrature point positions are proportional to the arbitrary parameter `a’, so we can use the same expressions for the derivatives.

eval_diag_contrib(freq)

Evaluate contribution to integral of diagonal approximation at given frequency point.

eval_diag_deriv2_contrib(freq)

Evaluate second derivative of contribution to integral of diagonal approximation at given frequency point, w.r.t that frequency point.

eval_diag_deriv_contrib(freq)

Evaluate gradient of contribution to integral of diagonal approximation at given frequency point, w.r.t that frequency point.

eval_diag_exact()

Provides an exact evaluation of the integral for the diagonal approximation.

fix_params()

If required set parameters within ansatz; defined to ensure hook for functionality in future, will not always be needed.

get_F(freq)
get_offset()
get_quad(a)

Generate the appropriate Clenshaw-Curtis quadrature points and weights.

get_quad_vals(a, l2norm=True)
kernel(a=None, opt_quad=True)

Perform numerical integration. Put simply, fix any arbitrary parameters in the integral to be evaluated, optimise the quadrature grid to ensure a diagonal approximation is exactly integrated then evaluate full expression.

kernel_adaptive()
l2_scan(freqs)
max_scan(freqs)
property n_aux
property npoints
opt_quadrature_diag(ainit=None)

Optimise the quadrature to exactly integrate a diagonal approximation to the integral

test_diag_derivs(a, delta=1e-06)
get_Q(freq)[source]

Efficiently construct Q = S_R (D^{-1} G) S_L^T This is generally the limiting

eval_contrib(freq)[source]

Evaluate contribution to numerical integral of result at given frequency point.

vayesta.rpa.rirpa.momzero_NI

Functionality to calculate zeroth moment via numerical integration

class vayesta.rpa.rirpa.momzero_NI.NIMomZero(D, S_L, S_R, target_rot, npoints, log)[source]

Bases: NumericalIntegratorClenCurInfinite

property n_aux
get_F(freq)[source]
get_Q(freq)[source]

Efficiently construct Q = S_R F S_L^T This is generally the limiting step.

property diagmat1
property diagmat2
calculate_error(a, b)

Calculate error by solving cubic equation to model convergence as lpha e^{-eta n_p}. This relies upon the Cauchy-Schwartz inequality, and assumes all errors are at their maximum values, so generally overestimates the resulting error, which suits us well. This also overestimates the error since it doesn’t account for the effect of quadrature grid optimisation, which leads to our actual estimates converging more rapidly than they would with a static grid spacing parameter.

This approach is detailed in Appendix B of https://arxiv.org/abs/2301.09107, Eqs. 100-104.

To understand the general behaviour of this approach, we can instead consider the simpler approximation that the magnitude of a given difference is dominated by the least accurate estimate. This leads to the estimate of the error resulting from our most accurate estimate as

error = b ** 3 / a ** 2

with the error in this approximation given by

error_error = b ** 2 / a ** 2.

eval_NI_approx(a)

Evaluate the NI approximation of the integral with a provided quadrature.

eval_contrib(freq)

Evaluate contribution to numerical integral of result at given frequency point.

eval_diag_NI_approx(a)

Evaluate the NI approximation to the diagonal approximation of the integral.

eval_diag_NI_approx_deriv2(a)

Evaluate the second derivative w.r.t a of NI diagonal expression. Note that for all quadratures the weights and quadrature point positions are proportional to the arbitrary parameter `a’, so we can use the same expressions for the derivatives.

eval_diag_NI_approx_grad(a)

Evaluate the gradient w.r.t a of NI diagonal expression. Note that for all quadratures the weights and quadrature point positions are proportional to the arbitrary parameter `a’, so we can use the same expressions for the derivatives.

eval_diag_contrib(freq)

Evaluate contribution to integral of diagonal approximation at given frequency point.

eval_diag_deriv2_contrib(freq)

Evaluate second derivative of contribution to integral of diagonal approximation at given frequency point, w.r.t that frequency point.

eval_diag_deriv_contrib(freq)

Evaluate gradient of contribution to integral of diagonal approximation at given frequency point, w.r.t that frequency point.

eval_diag_exact()

Provides an exact evaluation of the integral for the diagonal approximation.

fix_params()

If required set parameters within ansatz; defined to ensure hook for functionality in future, will not always be needed.

get_offset()
get_quad(a)

Generate the appropriate Clenshaw-Curtis quadrature points and weights.

get_quad_vals(a, l2norm=True)
kernel(a=None, opt_quad=True)

Perform numerical integration. Put simply, fix any arbitrary parameters in the integral to be evaluated, optimise the quadrature grid to ensure a diagonal approximation is exactly integrated then evaluate full expression.

kernel_adaptive()
l2_scan(freqs)
max_scan(freqs)
property npoints
opt_quadrature_diag(ainit=None)

Optimise the quadrature to exactly integrate a diagonal approximation to the integral

test_diag_derivs(a, delta=1e-06)
class vayesta.rpa.rirpa.momzero_NI.MomzeroDeductNone(*args, **kwargs)[source]

Bases: NIMomZero

property diagmat1
eval_diag_contrib(freq)[source]

Evaluate contribution to integral of diagonal approximation at given frequency point.

eval_diag_deriv_contrib(freq)[source]

Evaluate gradient of contribution to integral of diagonal approximation at given frequency point, w.r.t that frequency point.

eval_diag_deriv2_contrib(freq)[source]

Evaluate second derivative of contribution to integral of diagonal approximation at given frequency point, w.r.t that frequency point.

eval_diag_exact()[source]

Provides an exact evaluation of the integral for the diagonal approximation.

eval_contrib(freq)[source]

Evaluate contribution to numerical integral of result at given frequency point.

calculate_error(a, b)

Calculate error by solving cubic equation to model convergence as lpha e^{-eta n_p}. This relies upon the Cauchy-Schwartz inequality, and assumes all errors are at their maximum values, so generally overestimates the resulting error, which suits us well. This also overestimates the error since it doesn’t account for the effect of quadrature grid optimisation, which leads to our actual estimates converging more rapidly than they would with a static grid spacing parameter.

This approach is detailed in Appendix B of https://arxiv.org/abs/2301.09107, Eqs. 100-104.

To understand the general behaviour of this approach, we can instead consider the simpler approximation that the magnitude of a given difference is dominated by the least accurate estimate. This leads to the estimate of the error resulting from our most accurate estimate as

error = b ** 3 / a ** 2

with the error in this approximation given by

error_error = b ** 2 / a ** 2.

property diagmat2
eval_NI_approx(a)

Evaluate the NI approximation of the integral with a provided quadrature.

eval_diag_NI_approx(a)

Evaluate the NI approximation to the diagonal approximation of the integral.

eval_diag_NI_approx_deriv2(a)

Evaluate the second derivative w.r.t a of NI diagonal expression. Note that for all quadratures the weights and quadrature point positions are proportional to the arbitrary parameter `a’, so we can use the same expressions for the derivatives.

eval_diag_NI_approx_grad(a)

Evaluate the gradient w.r.t a of NI diagonal expression. Note that for all quadratures the weights and quadrature point positions are proportional to the arbitrary parameter `a’, so we can use the same expressions for the derivatives.

fix_params()

If required set parameters within ansatz; defined to ensure hook for functionality in future, will not always be needed.

get_F(freq)
get_Q(freq)

Efficiently construct Q = S_R F S_L^T This is generally the limiting step.

get_offset()
get_quad(a)

Generate the appropriate Clenshaw-Curtis quadrature points and weights.

get_quad_vals(a, l2norm=True)
kernel(a=None, opt_quad=True)

Perform numerical integration. Put simply, fix any arbitrary parameters in the integral to be evaluated, optimise the quadrature grid to ensure a diagonal approximation is exactly integrated then evaluate full expression.

kernel_adaptive()
l2_scan(freqs)
max_scan(freqs)
property n_aux
property npoints
opt_quadrature_diag(ainit=None)

Optimise the quadrature to exactly integrate a diagonal approximation to the integral

test_diag_derivs(a, delta=1e-06)
class vayesta.rpa.rirpa.momzero_NI.MomzeroDeductD(*args, **kwargs)[source]

Bases: MomzeroDeductNone

property diagmat2
eval_contrib(freq)[source]

Evaluate contribution to numerical integral of result at given frequency point.

calculate_error(a, b)

Calculate error by solving cubic equation to model convergence as lpha e^{-eta n_p}. This relies upon the Cauchy-Schwartz inequality, and assumes all errors are at their maximum values, so generally overestimates the resulting error, which suits us well. This also overestimates the error since it doesn’t account for the effect of quadrature grid optimisation, which leads to our actual estimates converging more rapidly than they would with a static grid spacing parameter.

This approach is detailed in Appendix B of https://arxiv.org/abs/2301.09107, Eqs. 100-104.

To understand the general behaviour of this approach, we can instead consider the simpler approximation that the magnitude of a given difference is dominated by the least accurate estimate. This leads to the estimate of the error resulting from our most accurate estimate as

error = b ** 3 / a ** 2

with the error in this approximation given by

error_error = b ** 2 / a ** 2.

property diagmat1
eval_NI_approx(a)

Evaluate the NI approximation of the integral with a provided quadrature.

eval_diag_NI_approx(a)

Evaluate the NI approximation to the diagonal approximation of the integral.

eval_diag_NI_approx_deriv2(a)

Evaluate the second derivative w.r.t a of NI diagonal expression. Note that for all quadratures the weights and quadrature point positions are proportional to the arbitrary parameter `a’, so we can use the same expressions for the derivatives.

eval_diag_NI_approx_grad(a)

Evaluate the gradient w.r.t a of NI diagonal expression. Note that for all quadratures the weights and quadrature point positions are proportional to the arbitrary parameter `a’, so we can use the same expressions for the derivatives.

eval_diag_contrib(freq)

Evaluate contribution to integral of diagonal approximation at given frequency point.

eval_diag_deriv2_contrib(freq)

Evaluate second derivative of contribution to integral of diagonal approximation at given frequency point, w.r.t that frequency point.

eval_diag_deriv_contrib(freq)

Evaluate gradient of contribution to integral of diagonal approximation at given frequency point, w.r.t that frequency point.

eval_diag_exact()

Provides an exact evaluation of the integral for the diagonal approximation.

fix_params()

If required set parameters within ansatz; defined to ensure hook for functionality in future, will not always be needed.

get_F(freq)
get_Q(freq)

Efficiently construct Q = S_R F S_L^T This is generally the limiting step.

get_offset()
get_quad(a)

Generate the appropriate Clenshaw-Curtis quadrature points and weights.

get_quad_vals(a, l2norm=True)
kernel(a=None, opt_quad=True)

Perform numerical integration. Put simply, fix any arbitrary parameters in the integral to be evaluated, optimise the quadrature grid to ensure a diagonal approximation is exactly integrated then evaluate full expression.

kernel_adaptive()
l2_scan(freqs)
max_scan(freqs)
property n_aux
property npoints
opt_quadrature_diag(ainit=None)

Optimise the quadrature to exactly integrate a diagonal approximation to the integral

test_diag_derivs(a, delta=1e-06)
class vayesta.rpa.rirpa.momzero_NI.MomzeroDeductHigherOrder(*args, **kwargs)[source]

Bases: MomzeroDeductD

eval_diag_contrib(freq)[source]

Evaluate contribution to integral of diagonal approximation at given frequency point.

eval_diag_deriv_contrib(freq)[source]

Evaluate gradient of contribution to integral of diagonal approximation at given frequency point, w.r.t that frequency point.

eval_diag_deriv2_contrib(freq)[source]

Evaluate second derivative of contribution to integral of diagonal approximation at given frequency point, w.r.t that frequency point.

eval_diag_exact()[source]

Provides an exact evaluation of the integral for the diagonal approximation.

eval_contrib(freq)[source]

Evaluate contribution to numerical integral of result at given frequency point.

calculate_error(a, b)

Calculate error by solving cubic equation to model convergence as lpha e^{-eta n_p}. This relies upon the Cauchy-Schwartz inequality, and assumes all errors are at their maximum values, so generally overestimates the resulting error, which suits us well. This also overestimates the error since it doesn’t account for the effect of quadrature grid optimisation, which leads to our actual estimates converging more rapidly than they would with a static grid spacing parameter.

This approach is detailed in Appendix B of https://arxiv.org/abs/2301.09107, Eqs. 100-104.

To understand the general behaviour of this approach, we can instead consider the simpler approximation that the magnitude of a given difference is dominated by the least accurate estimate. This leads to the estimate of the error resulting from our most accurate estimate as

error = b ** 3 / a ** 2

with the error in this approximation given by

error_error = b ** 2 / a ** 2.

property diagmat1
property diagmat2
eval_NI_approx(a)

Evaluate the NI approximation of the integral with a provided quadrature.

eval_diag_NI_approx(a)

Evaluate the NI approximation to the diagonal approximation of the integral.

eval_diag_NI_approx_deriv2(a)

Evaluate the second derivative w.r.t a of NI diagonal expression. Note that for all quadratures the weights and quadrature point positions are proportional to the arbitrary parameter `a’, so we can use the same expressions for the derivatives.

eval_diag_NI_approx_grad(a)

Evaluate the gradient w.r.t a of NI diagonal expression. Note that for all quadratures the weights and quadrature point positions are proportional to the arbitrary parameter `a’, so we can use the same expressions for the derivatives.

fix_params()

If required set parameters within ansatz; defined to ensure hook for functionality in future, will not always be needed.

get_F(freq)
get_Q(freq)

Efficiently construct Q = S_R F S_L^T This is generally the limiting step.

get_offset()
get_quad(a)

Generate the appropriate Clenshaw-Curtis quadrature points and weights.

get_quad_vals(a, l2norm=True)
kernel(a=None, opt_quad=True)

Perform numerical integration. Put simply, fix any arbitrary parameters in the integral to be evaluated, optimise the quadrature grid to ensure a diagonal approximation is exactly integrated then evaluate full expression.

kernel_adaptive()
l2_scan(freqs)
max_scan(freqs)
property n_aux
property npoints
opt_quadrature_diag(ainit=None)

Optimise the quadrature to exactly integrate a diagonal approximation to the integral

test_diag_derivs(a, delta=1e-06)
class vayesta.rpa.rirpa.momzero_NI.BaseMomzeroOffset(D, S_L, S_R, target_rot, npoints, log)[source]

Bases: NumericalIntegratorBase

NB this is an abstract class!

get_offset()[source]
eval_contrib(freq)[source]

Evaluate contribution to numerical integral of result at given frequency point.

eval_diag_contrib(freq)[source]

Evaluate contribution to integral of diagonal approximation at given frequency point.

eval_diag_deriv_contrib(freq)[source]

Evaluate gradient of contribution to integral of diagonal approximation at given frequency point, w.r.t that frequency point.

eval_diag_deriv2_contrib(freq)[source]

Evaluate second derivative of contribution to integral of diagonal approximation at given frequency point, w.r.t that frequency point.

eval_diag_exact()[source]

Provides an exact evaluation of the integral for the diagonal approximation.

eval_NI_approx(a)

Evaluate the NI approximation of the integral with a provided quadrature.

eval_diag_NI_approx(a)

Evaluate the NI approximation to the diagonal approximation of the integral.

eval_diag_NI_approx_deriv2(a)

Evaluate the second derivative w.r.t a of NI diagonal expression. Note that for all quadratures the weights and quadrature point positions are proportional to the arbitrary parameter `a’, so we can use the same expressions for the derivatives.

eval_diag_NI_approx_grad(a)

Evaluate the gradient w.r.t a of NI diagonal expression. Note that for all quadratures the weights and quadrature point positions are proportional to the arbitrary parameter `a’, so we can use the same expressions for the derivatives.

fix_params()

If required set parameters within ansatz; defined to ensure hook for functionality in future, will not always be needed.

get_quad(a)

Generate the appropriate Clenshaw-Curtis quadrature points and weights.

get_quad_vals(a, l2norm=True)
kernel(a=None, opt_quad=True)

Perform numerical integration. Put simply, fix any arbitrary parameters in the integral to be evaluated, optimise the quadrature grid to ensure a diagonal approximation is exactly integrated then evaluate full expression.

kernel_adaptive()
l2_scan(freqs)
max_scan(freqs)
property npoints
opt_quadrature_diag(ainit=None)

Optimise the quadrature to exactly integrate a diagonal approximation to the integral

test_diag_derivs(a, delta=1e-06)
class vayesta.rpa.rirpa.momzero_NI.MomzeroOffsetCalcGaussLag(D, S_L, S_R, target_rot, npoints, log)[source]

Bases: BaseMomzeroOffset, NumericalIntegratorGaussianSemiInfinite

eval_NI_approx(a)

Evaluate the NI approximation of the integral with a provided quadrature.

eval_contrib(freq)

Evaluate contribution to numerical integral of result at given frequency point.

eval_diag_NI_approx(a)

Evaluate the NI approximation to the diagonal approximation of the integral.

eval_diag_NI_approx_deriv2(a)

Evaluate the second derivative w.r.t a of NI diagonal expression. Note that for all quadratures the weights and quadrature point positions are proportional to the arbitrary parameter `a’, so we can use the same expressions for the derivatives.

eval_diag_NI_approx_grad(a)

Evaluate the gradient w.r.t a of NI diagonal expression. Note that for all quadratures the weights and quadrature point positions are proportional to the arbitrary parameter `a’, so we can use the same expressions for the derivatives.

eval_diag_contrib(freq)

Evaluate contribution to integral of diagonal approximation at given frequency point.

eval_diag_deriv2_contrib(freq)

Evaluate second derivative of contribution to integral of diagonal approximation at given frequency point, w.r.t that frequency point.

eval_diag_deriv_contrib(freq)

Evaluate gradient of contribution to integral of diagonal approximation at given frequency point, w.r.t that frequency point.

eval_diag_exact()

Provides an exact evaluation of the integral for the diagonal approximation.

fix_params()

If required set parameters within ansatz; defined to ensure hook for functionality in future, will not always be needed.

get_offset()
get_quad(a)

Generate the appropriate Clenshaw-Curtis quadrature points and weights.

get_quad_vals(a, l2norm=True)
kernel(a=None, opt_quad=True)

Perform numerical integration. Put simply, fix any arbitrary parameters in the integral to be evaluated, optimise the quadrature grid to ensure a diagonal approximation is exactly integrated then evaluate full expression.

kernel_adaptive()
l2_scan(freqs)
max_scan(freqs)
property npoints
opt_quadrature_diag(ainit=None)

Optimise the quadrature to exactly integrate a diagonal approximation to the integral

test_diag_derivs(a, delta=1e-06)
class vayesta.rpa.rirpa.momzero_NI.MomzeroOffsetCalcCC(D, S_L, S_R, target_rot, npoints, log)[source]

Bases: BaseMomzeroOffset, NumericalIntegratorClenCurSemiInfinite

calculate_error(a, b)

Calculate error by solving cubic equation to model convergence as lpha e^{-eta n_p}. This relies upon the Cauchy-Schwartz inequality, and assumes all errors are at their maximum values, so generally overestimates the resulting error, which suits us well. This also overestimates the error since it doesn’t account for the effect of quadrature grid optimisation, which leads to our actual estimates converging more rapidly than they would with a static grid spacing parameter.

This approach is detailed in Appendix B of https://arxiv.org/abs/2301.09107, Eqs. 100-104.

To understand the general behaviour of this approach, we can instead consider the simpler approximation that the magnitude of a given difference is dominated by the least accurate estimate. This leads to the estimate of the error resulting from our most accurate estimate as

error = b ** 3 / a ** 2

with the error in this approximation given by

error_error = b ** 2 / a ** 2.

eval_NI_approx(a)

Evaluate the NI approximation of the integral with a provided quadrature.

eval_contrib(freq)

Evaluate contribution to numerical integral of result at given frequency point.

eval_diag_NI_approx(a)

Evaluate the NI approximation to the diagonal approximation of the integral.

eval_diag_NI_approx_deriv2(a)

Evaluate the second derivative w.r.t a of NI diagonal expression. Note that for all quadratures the weights and quadrature point positions are proportional to the arbitrary parameter `a’, so we can use the same expressions for the derivatives.

eval_diag_NI_approx_grad(a)

Evaluate the gradient w.r.t a of NI diagonal expression. Note that for all quadratures the weights and quadrature point positions are proportional to the arbitrary parameter `a’, so we can use the same expressions for the derivatives.

eval_diag_contrib(freq)

Evaluate contribution to integral of diagonal approximation at given frequency point.

eval_diag_deriv2_contrib(freq)

Evaluate second derivative of contribution to integral of diagonal approximation at given frequency point, w.r.t that frequency point.

eval_diag_deriv_contrib(freq)

Evaluate gradient of contribution to integral of diagonal approximation at given frequency point, w.r.t that frequency point.

eval_diag_exact()

Provides an exact evaluation of the integral for the diagonal approximation.

fix_params()

If required set parameters within ansatz; defined to ensure hook for functionality in future, will not always be needed.

get_offset()
get_quad(a)

Generate the appropriate Clenshaw-Curtis quadrature points and weights.

get_quad_vals(a, l2norm=True)
kernel(a=None, opt_quad=True)

Perform numerical integration. Put simply, fix any arbitrary parameters in the integral to be evaluated, optimise the quadrature grid to ensure a diagonal approximation is exactly integrated then evaluate full expression.

kernel_adaptive()
l2_scan(freqs)
max_scan(freqs)
property npoints
opt_quadrature_diag(ainit=None)

Optimise the quadrature to exactly integrate a diagonal approximation to the integral

test_diag_derivs(a, delta=1e-06)
vayesta.rpa.rirpa.momzero_NI.diag_sqrt_contrib(D, freq)[source]
vayesta.rpa.rirpa.momzero_NI.diag_sqrt_grad(D, freq)[source]
vayesta.rpa.rirpa.momzero_NI.diag_sqrt_deriv2(D, freq)[source]
class vayesta.rpa.rirpa.momzero_NI.MomzeroDeductHigherOrder_dRHF(*args, **kwargs)[source]

Bases: MomzeroDeductHigherOrder

All provided quantities are now in spatial orbitals. This actually only requires an additional factor in the get_Q method.

calculate_error(a, b)

Calculate error by solving cubic equation to model convergence as lpha e^{-eta n_p}. This relies upon the Cauchy-Schwartz inequality, and assumes all errors are at their maximum values, so generally overestimates the resulting error, which suits us well. This also overestimates the error since it doesn’t account for the effect of quadrature grid optimisation, which leads to our actual estimates converging more rapidly than they would with a static grid spacing parameter.

This approach is detailed in Appendix B of https://arxiv.org/abs/2301.09107, Eqs. 100-104.

To understand the general behaviour of this approach, we can instead consider the simpler approximation that the magnitude of a given difference is dominated by the least accurate estimate. This leads to the estimate of the error resulting from our most accurate estimate as

error = b ** 3 / a ** 2

with the error in this approximation given by

error_error = b ** 2 / a ** 2.

property diagmat1
property diagmat2
eval_NI_approx(a)

Evaluate the NI approximation of the integral with a provided quadrature.

eval_contrib(freq)

Evaluate contribution to numerical integral of result at given frequency point.

eval_diag_NI_approx(a)

Evaluate the NI approximation to the diagonal approximation of the integral.

eval_diag_NI_approx_deriv2(a)

Evaluate the second derivative w.r.t a of NI diagonal expression. Note that for all quadratures the weights and quadrature point positions are proportional to the arbitrary parameter `a’, so we can use the same expressions for the derivatives.

eval_diag_NI_approx_grad(a)

Evaluate the gradient w.r.t a of NI diagonal expression. Note that for all quadratures the weights and quadrature point positions are proportional to the arbitrary parameter `a’, so we can use the same expressions for the derivatives.

eval_diag_contrib(freq)

Evaluate contribution to integral of diagonal approximation at given frequency point.

eval_diag_deriv2_contrib(freq)

Evaluate second derivative of contribution to integral of diagonal approximation at given frequency point, w.r.t that frequency point.

eval_diag_deriv_contrib(freq)

Evaluate gradient of contribution to integral of diagonal approximation at given frequency point, w.r.t that frequency point.

eval_diag_exact()

Provides an exact evaluation of the integral for the diagonal approximation.

fix_params()

If required set parameters within ansatz; defined to ensure hook for functionality in future, will not always be needed.

get_F(freq)
get_offset()
get_quad(a)

Generate the appropriate Clenshaw-Curtis quadrature points and weights.

get_quad_vals(a, l2norm=True)
kernel(a=None, opt_quad=True)

Perform numerical integration. Put simply, fix any arbitrary parameters in the integral to be evaluated, optimise the quadrature grid to ensure a diagonal approximation is exactly integrated then evaluate full expression.

kernel_adaptive()
l2_scan(freqs)
max_scan(freqs)
property n_aux
property npoints
opt_quadrature_diag(ainit=None)

Optimise the quadrature to exactly integrate a diagonal approximation to the integral

test_diag_derivs(a, delta=1e-06)
get_Q(freq)[source]

Efficiently construct Q = S_R F S_L^T This is generally the limiting step.

Module contents

vayesta.rpa.rirpa.ssRIRPA(mf, *args, **kwargs)[source]