ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
Classes | Public Member Functions | Private Attributes | List of all members
ModuleBase::SphericalBesselTransformer Class Reference

A class that provides spherical Bessel transforms. More...

#include <spherical_bessel_transformer.h>

Collaboration diagram for ModuleBase::SphericalBesselTransformer:

Classes

class  Impl
 

Public Member Functions

 SphericalBesselTransformer (const bool cache_enabled=false)
 
 ~SphericalBesselTransformer ()=default
 
 SphericalBesselTransformer (SphericalBesselTransformer const &)=default
 
 SphericalBesselTransformer (SphericalBesselTransformer &&)=default
 
SphericalBesselTransformeroperator= (const SphericalBesselTransformer &)=default
 
SphericalBesselTransformeroperator= (SphericalBesselTransformer &&)=default
 
void radrfft (const int l, const int ngrid, const double cutoff, const double *const in, double *const out, const int p=0) const
 Spherical Bessel transform via fast Fourier transforms.
 
void direct (const int l, const int ngrid_in, const double *const grid_in, const double *const in, const int ngrid_out, const double *const grid_out, double *const out, const int p=0) const
 Spherical Bessel transform via numerical integration with Simpson's rule.
 
size_t heap_usage () const
 total heap usage (in bytes) from the FFTW buffer and tabulated jl
 
void clear ()
 clear the FFTW plan & buffer as well as the tabulated jl
 
bool operator== (const SphericalBesselTransformer &rhs) const
 check if two objects share the same underlying implementation object
 

Private Attributes

std::shared_ptr< Implimpl_
 

Detailed Description

A class that provides spherical Bessel transforms.

Note
This class is implemented as an opaque shared pointer. The underlying object of the implementation class, which may cache some tabulated function values, is shared via copy-construction and copy-assignment.

The spherical Bessel transform of a function F(x) is defined as

                          / +inf     2
     G(y) = sqrt(2/pi) *  |      dx x  F(x) j (y*x)
                          /  0               l

where

     j
      l

is the l-th order spherical Bessel function of the first kind.

This class interprets the input array as

              p
     in[i] = x [i] F(x[i])   (p being an input argument)

and, on finish, fills the output array with

         out[j] = G(y[j])

Usage:

 // cache is disabled by default
 SphericalBesselTransformer sbt;

 // cache enabled mode
 // faster for multiple transforms with the same size & order
 SphericalBesselTransformer sbt2(true);

 //---------------------------------------------------------------------
 //                      FFT-based algorithm
 //---------------------------------------------------------------------
 // basic usage
 sbt.radrfft(l, ngrid, cutoff, in, out);

 // perform SBT on F(r) with input values r*F(r)
 sbt.radrfft(l, ngrid, cutoff, in, out, 1);

 //---------------------------------------------------------------------
 //              numerical integration (Simpson's rule)
 //---------------------------------------------------------------------
 // basic usage
 sbt.direct(l, ngrid_in, grid_in, value_in, ngrid_out, grid_out, value_out);

 // perform SBT on F(r) with input values r^2*F(r)
 sbt.direct(l, ngrid_in, grid_in, value_in, ngrid_out, grid_out, value_out, 2);

Constructor & Destructor Documentation

◆ SphericalBesselTransformer() [1/3]

ModuleBase::SphericalBesselTransformer::SphericalBesselTransformer ( const bool  cache_enabled = false)

◆ ~SphericalBesselTransformer()

ModuleBase::SphericalBesselTransformer::~SphericalBesselTransformer ( )
default

◆ SphericalBesselTransformer() [2/3]

ModuleBase::SphericalBesselTransformer::SphericalBesselTransformer ( SphericalBesselTransformer const &  )
default

◆ SphericalBesselTransformer() [3/3]

ModuleBase::SphericalBesselTransformer::SphericalBesselTransformer ( SphericalBesselTransformer &&  )
default

Member Function Documentation

◆ clear()

void ModuleBase::SphericalBesselTransformer::clear ( )

clear the FFTW plan & buffer as well as the tabulated jl

Here is the caller graph for this function:

◆ direct()

void ModuleBase::SphericalBesselTransformer::direct ( const int  l,
const int  ngrid_in,
const double *const  grid_in,
const double *const  in,
const int  ngrid_out,
const double *const  grid_out,
double *const  out,
const int  p = 0 
) const

Spherical Bessel transform via numerical integration with Simpson's rule.

This function computes the spherical Bessel transform F(x) -> G(y) with input

              p
     in[i] = x [i] F(x[i])

where p <= 2 is an integer. On finish, out[j] = G(y[j]).

Parameters
[in]lorder of the transform
[in]ngrid_innumber of the input grid points
[in]grid_ininput grid
[in]ininput values
[in]ngrid_outnumber of the output grid points
[in]grid_outoutput grid
[out]outtransformed values on the output grid
[in]pexponent of the extra power term in input values (must not exceed 2)
Note
Even if the input grid forms a good sampling of F(x), results would still be inaccurate for very large y values (y*dx ~ pi) because the oscillation of j_l(y*x) in this case is poorly sampled, in which case Simpson's 1/3 rule could be a bad approximation.
p is restricted to p <= 2 in order to avoid the situation that one has to determine x^2*F(x) at x = 0 from x[i]^p*F(x[i]).
Here is the caller graph for this function:

◆ heap_usage()

size_t ModuleBase::SphericalBesselTransformer::heap_usage ( ) const

total heap usage (in bytes) from the FFTW buffer and tabulated jl

Here is the caller graph for this function:

◆ operator=() [1/2]

SphericalBesselTransformer & ModuleBase::SphericalBesselTransformer::operator= ( const SphericalBesselTransformer )
default

◆ operator=() [2/2]

SphericalBesselTransformer & ModuleBase::SphericalBesselTransformer::operator= ( SphericalBesselTransformer &&  )
default

◆ operator==()

bool ModuleBase::SphericalBesselTransformer::operator== ( const SphericalBesselTransformer rhs) const
inline

check if two objects share the same underlying implementation object

◆ radrfft()

void ModuleBase::SphericalBesselTransformer::radrfft ( const int  l,
const int  ngrid,
const double  cutoff,
const double *const  in,
double *const  out,
const int  p = 0 
) const

Spherical Bessel transform via fast Fourier transforms.

This function computes the spherical Bessel transform F(x) -> G(y) with input

              p
     in[i] = x [i] F(x[i])

where p <= 2 is an integer, and

                cutoff
     x[i] = i * -------          i = 0, 1, 2,..., ngrid-1.
                ngrid-1

On finish, out[j] = G(y[j]) where

                 pi
     y[j] = j * ------           j = 0, 1, 2,..., ngrid-1.
                cutoff
Parameters
[in]lorder of the transform
[in]ngridnumber of grid points (same for input and output)
[in]cutoffcutoff distance of input grid
[in]ininput values
[out]outtransformed values
[in]pexponent of the extra power term in input values (must not exceed 2)
Note
F(x) is supposed to be exactly zero at and after cutoff. Results would make no sense if the input is truncated at a place where F(x) is still significantly non-zero.
FFT-based algorithm is not accurate for high l at small y. Numerical integration via Simpson's rule is implicitly invoked to handle this case.
p is restricted to p <= 2 in order to avoid the situation that one has to determine x^2*F(x) at x = 0 from x[i]^p*F(x[i]).
Here is the caller graph for this function:

Member Data Documentation

◆ impl_

std::shared_ptr<Impl> ModuleBase::SphericalBesselTransformer::impl_
private

The documentation for this class was generated from the following files: