Laplace quadrature
ElemCo.LaplaceQuadrature — Module
LaplaceQuadrature moduleThis module provides functions to compute Laplace quadrature points and weights for MP2 calculations using the minimax (Remez) algorithm, as described by Takatsuka et al. in J. Chem. Phys. 129, 044112 (2008) or using the Häser-Almlöf simplex method.
It includes functions for both unweighted and weighted Laplace quadrature, where the latter uses a distribution function to improve accuracy.
Exported functions
ElemCo.LaplaceQuadrature.get_laplace_quadrature — Method
get_laplace_quadrature(εo::Vector{Float64}, εv::Vector{Float64}, npoints::Int; use_distribution::Bool=false, algo=:minimax)Given occupied and virtual orbital energies, compute Laplace quadrature points and weights. When use_distribution=true, uses distribution function weighting for improved accuracy. algo parameter selects the algorithm (:minimax or :simplex).
Returns:
- Tuple (weights, points): wq and tq for Laplace quadrature
ElemCo.LaplaceQuadrature.get_laplace_quadrature_simplex — Method
get_laplace_quadrature_simplex(εo::Vector{Float64}, εv::Vector{Float64}, npoints::Int)Given occupied and virtual orbital energies, compute Laplace quadrature points and weights. When use_distribution=true, uses distribution function weighting for improved accuracy. Wrapper function for simplex-based Laplace quadrature calculation.
Returns:
- Tuple (weights, points): wq and tq for Laplace quadrature
Internal functions
ElemCo.LaplaceQuadrature.build_distribution_function — Method
build_distribution_function(εo::Vector{Float64}, εv::Vector{Float64})Build the distribution function f(x) for energy denominators following Häser-Almlöf. Creates histograms of Δᵢᵃ = εₐ - εᵢ using 600 bins, then combines them into 1200 bins.
Returns:
- x_grid: Grid points for the distribution (1200 points)
- f_x: Distribution function values at grid points
- xmin, xmax: Range of energy denominators
ElemCo.LaplaceQuadrature.calc_laplace_points — Method
calc_laplace_points(emin, emax, npoints::Int)Compute Laplace quadrature points and weights for Laplace MP2 using the minimax (Remez) algorithm from Takatsuka et al., J. Chem. Phys. 129, 044112 (2008). Returns (weights, points).
ElemCo.LaplaceQuadrature.calc_laplace_points_simplex — Method
calc_laplace_points_simplex(εo::Vector{Float64}, εv::Vector{Float64}, npoints::Int;
include_zero::Bool=true, maxiter::Int=1000, tol::Scalar=1e-8)Calculate Laplace quadrature points and weights using the Häser-Almlöf simplex method.
Parameters:
- εo: Occupied orbital energies
- εv: Virtual orbital energies
- npoints: Total number of quadrature points
- include_zero: Whether to include and fix t=0 point
- maxiter: Maximum iterations for simplex optimization
- tol: Convergence tolerance
Returns:
- Tuple (weights, points): wq and tq for Laplace quadrature
ElemCo.LaplaceQuadrature.calculate_weights — Method
calculate_weights(t_points::Vector{Scalar}, x_grid::Vector{Scalar}, f_x::Vector{Scalar})Calculate optimal weights for given t_points by solving the linear least-squares system. The weights minimize ∫ f(x) * (1/x - Σq wq * exp(-x*tq))² dx.
Returns:
- w: Optimal weights
ElemCo.LaplaceQuadrature.compute_weighted_barycentric_weights — Method
compute_weighted_barycentric_weights(x_ref::Vector{Scalar}, x_grid::Vector{Scalar}, f_x::Vector{Scalar})Compute barycentric weights considering distribution function.
ElemCo.LaplaceQuadrature.find_roots — Method
find_roots(H::Function, tmin::Scalar, tmax::Scalar, nroots::Int, tol::Scalar)Find roots of function H in interval [tmin, tmax].
ElemCo.LaplaceQuadrature.find_weighted_extrema — Method
find_weighted_extrema(E::Function, dE::Function, x_grid::Vector{Scalar}, f_x::Vector{Scalar},
emin::Scalar, emax::Scalar, nroots::Int, tol::Scalar)Find extrema of the error function weighted by the distribution function.
ElemCo.LaplaceQuadrature.get_initial_laplace — Method
get_initial_laplace(npoints::Int, R::Scalar, filename::String)Obtain initial guess for Laplace quadrature points from a table file.
- npoints: number of quadrature points
- R: emax/emin
- filename: path to the table file
Returns: Vector of points (t), weights (w) and the tabulated R
ElemCo.LaplaceQuadrature.get_laplace_quadrature_minimax — Method
get_laplace_quadrature_minimax(εo::Vector{Float64}, εv::Vector{Float64}, npoints::Int; use_distribution::Bool=false)Given occupied and virtual orbital energies, compute Laplace quadrature points and weights. When use_distribution=true, uses distribution function weighting for improved accuracy. Wrapper function for minimax-based Laplace quadrature calculation.
Returns:
- Tuple (weights, points): wq and tq for Laplace quadrature
ElemCo.LaplaceQuadrature.interpolate_distribution — Method
interpolate_distribution(x::Scalar, x_grid::Vector{Scalar}, f_x::Vector{Scalar})Interpolate distribution function value at point x.
ElemCo.LaplaceQuadrature.interpolate_linear — Method
interpolate_linear(x_data::Vector{Scalar}, y_data::Vector{Scalar}, x::Scalar)Linear interpolation helper function.
ElemCo.LaplaceQuadrature.nelder_mead_simplex — Method
nelder_mead_simplex(f, x0::Vector{Scalar};
maxiter=1000, tol=1e-8, α=1.0, β=0.5, γ=2.0, δ=0.5)Simple Nelder-Mead simplex optimization.
- f: objective function
- x0: initial point
- Returns: optimized point
ElemCo.LaplaceQuadrature.objective_function — Method
objective_function(t_points::Vector{Scalar}, x_grid::Vector{Scalar}, f_x::Vector{Scalar})Compute the least-squares objective function for given t_points. Returns the value of ∫ f(x) * (1/x - Σq wq * exp(-x*tq))² dx.
ElemCo.LaplaceQuadrature.sample_from_distribution — Method
sample_from_distribution(x_grid::Vector{Scalar}, f_x::Vector{Scalar}, emin::Scalar, emax::Scalar)Sample a point from the distribution function (inverse transform sampling).
ElemCo.LaplaceQuadrature.select_weighted_reference_points — Method
select_weighted_reference_points(x_grid::Vector{Scalar}, f_x::Vector{Scalar}, nref::Int, emin::Scalar, emax::Scalar)Select initial reference points using distribution function weighting.