ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
Classes | Functions
bessel_basis_test.cpp File Reference
#include <iostream>
#include <fstream>
#include <cmath>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cassert>
#include "../bessel_basis.h"
#include "../../source_cell/unitcell.h"
#include "../../source_estate/magnetism.h"
#include "gtest/gtest.h"
#include <mpi.h>
Include dependency graph for bessel_basis_test.cpp:

Classes

class  TestBesselBasis
 

Functions

double SimpsonIntegral (const std::vector< double > &x, const std::vector< double > &y)
 Simpson integral.
 
double SphericalBessel (int l, double x)
 recursive definition of 1st-kind Spherical Bessel function of the first kind
 
std::vector< double > CalculateSphericalBessel (int l, double q, const std::vector< double > &r)
 1st-kind Spherical Bessel function of the first kind mapped on realspace grid
 
std::vector< double > GetSphericalBesselZeros (int order, int number)
 Get the first p zeros of 1st-kind, l-ordered Spherical Bessel function from a constant table.
 
std::vector< double > GetqList (int order, int number, double rcut)
 Get mod of q vector of Spherical Bessel functions, all q satisfy when r=rcut, j_l(qr)=0.
 
std::vector< double > operator* (const std::vector< double > &x, const std::vector< double > &y)
 overload operator * for vectors, elements will be multiplied one by one
 
std::vector< std::vector< std::vector< double > > > GenerateTableOne (const bool smooth, const double sigma, const double ecutwfc, const double rcut, const int lmax, const double dr, const double dk)
 init_TableOne for unit test
 
std::unordered_map< std::string, double > ReadinC4 (const std::string &FileName, const int &NumAtomType, const int &l, const int &NumChi, const int &NumBesselFunction)
 Improved version of source_io/bessel_basis::readin_C4 and allocate_C4 functions, for generating C4 matrix but now with a higher speed on accessing elements.
 
std::vector< std::vector< std::vector< std::vector< double > > > > GenerateFaln (const std::string &FileName, const int &NumAtomType, const int &lmax, const int &NumChi, const int &NumBesselFunction, std::vector< std::vector< std::vector< double > > > vvv_d_TableOne)
 Generate F_{alpha, l, chi, k} matrix.
 
 TEST_F (TestBesselBasis, InitTest)
 
 TEST_F (TestBesselBasis, PolynomialInterpolation2Test)
 
 TEST_F (TestBesselBasis, PolynomialInterpolationTest)
 

Function Documentation

◆ CalculateSphericalBessel()

std::vector< double > CalculateSphericalBessel ( int  l,
double  q,
const std::vector< double > &  r 
)

1st-kind Spherical Bessel function of the first kind mapped on realspace grid

Attention
this function is a COMPLETE version, can replace the one in basic mathematical library
Parameters
lorder of 1st-kind spherical Bessel function
qwave vector
rrealspace grid
Returns
function value on realspace grid
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GenerateFaln()

std::vector< std::vector< std::vector< std::vector< double > > > > GenerateFaln ( const std::string &  FileName,
const int &  NumAtomType,
const int &  lmax,
const int &  NumChi,
const int &  NumBesselFunction,
std::vector< std::vector< std::vector< double > > >  vvv_d_TableOne 
)

Generate F_{alpha, l, chi, k} matrix.

Parameters
FileNamename of external file where C4-stored file information is contained
NumAtomTypenumber of atom types
lmaximal angular momentum of localized orbitals
NumChinumber of contracted spherical bessel functions to fit one atomic orbital
NumBesselFunctionnumber of spherical bessel functions in one contracted spherical bessel function
vvv_d_TableOneIntegral table, has subscripts (l, q, k), whose element is the result of integral int{dr r^2 jle(r)*jlk(r)}. l runs over angular momentum, q runs over all spherical bessel functions, k runs over k points sampled controlled by ecutwfc and dk by sqrt(ecutwfc)/dk + 1 + 4.
Returns
F_{alpha, l, chi, k} matrix, whose element is the result of sum_{q}{C4(alpha, l, chi, q)*TableOne(l, q, k)}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GenerateTableOne()

std::vector< std::vector< std::vector< double > > > GenerateTableOne ( const bool  smooth,
const double  sigma,
const double  ecutwfc,
const double  rcut,
const int  lmax,
const double  dr,
const double  dk 
)

init_TableOne for unit test

Attention
this is a COMPLETE version of init_TableOne, can replace the one in source_io/bessel_basis.cpp
Parameters
smoothwhether to smooth the function (gaussian function)
sigmastddev of gaussian function for smoothing
ecutwfccontrol the number of Spheical Bessel functions
rcutcutoff radius of Spherical Bessel functions, r>rcut, Spherical Bessel functions are zero
lmaxmaximal angular momentum of Spherical Bessel functions
drgrid spacing of r
dkgrid spacing of k
Returns
std::vector<std::vector<std::vector<double>>> TableOne[angular momentum][index of Spherical Bessel function][Arbitrary wave vector k]
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetqList()

std::vector< double > GetqList ( int  order,
int  number,
double  rcut 
)

Get mod of q vector of Spherical Bessel functions, all q satisfy when r=rcut, j_l(qr)=0.

first solve the equation j_l(x) = 0, therefore get the table (l, k) -> x, where l is the order of SBF and k is the k-th zero of j_l(x). Then let x = q*rcut, therefore q = x/rcut, return it.

Attention
this function itself is a COMPLETE version, while the function it called GetSphericalBesselZeros may be INCOMPLETE, due to limited support of numerical table.
Parameters
orderthe angular momentum of Spherical Bessel functions
numbernumber of q to be returned
rcut'cutoff radius' of Spherical Bessel functions. When r=rcut, Spherical Bessel functions are zero, and for r>rcut, they are zero as required by concept of constructing localized atomic orbital.
Returns
a vector of q, the q is from j_l(qr)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetSphericalBesselZeros()

std::vector< double > GetSphericalBesselZeros ( int  order,
int  number 
)

Get the first p zeros of 1st-kind, l-ordered Spherical Bessel function from a constant table.

Attention
this function is a INCOMPLETE version, due to limited support of numerical table.
Parameters
orderl, angular momentum
numberp, number of zeros needed
Returns
a vector of q, the q is from j_l(qr)
Here is the caller graph for this function:

◆ operator*()

std::vector< double > operator* ( const std::vector< double > &  x,
const std::vector< double > &  y 
)

overload operator * for vectors, elements will be multiplied one by one

Parameters
xone vector
yanother vector
Returns
vector after multiplication

◆ ReadinC4()

std::unordered_map< std::string, double > ReadinC4 ( const std::string &  FileName,
const int &  NumAtomType,
const int &  l,
const int &  NumChi,
const int &  NumBesselFunction 
)

Improved version of source_io/bessel_basis::readin_C4 and allocate_C4 functions, for generating C4 matrix but now with a higher speed on accessing elements.

Attention
function will read in total number of chi-s both from file and from input, and assert that they are the same. It is also just a INCOMPLETE version, for a complete version, HTML parser library will be included and the other parameter, NumAtomType, will also be used for calibrating data.
Parameters
FileNamename of external file where C4-stored file information is contained
NumAtomTypenumber of atom types
lmaximal angular momentum of localized orbitals
NumChinumber of contracted spherical bessel functions to fit one atomic orbital
NumBesselFunctionnumber of spherical bessel functions in one contracted spherical bessel function
Returns
a map whose key is a string of "atomtype l chi q", and value is the corresponding C4 value
Here is the caller graph for this function:

◆ SimpsonIntegral()

double SimpsonIntegral ( const std::vector< double > &  x,
const std::vector< double > &  y 
)

Simpson integral.

unit test for source_io/bessel_basis, not tested functions: readin_C4, allocate_C4

Attention
this function is a COMPLETE version, but there is no improvement in performance.
Parameters
xvariable stored in a vector
yfunction value stored in a vector
Returns
integral value
Here is the caller graph for this function:

◆ SphericalBessel()

double SphericalBessel ( int  l,
double  x 
)

recursive definition of 1st-kind Spherical Bessel function of the first kind

Attention
this function is a COMPLETE version, can replace the one in basic mathematical library
Parameters
lorder of 1st-kind spherical Bessel function
xvariable
Returns
value of 1st-kind spherical Bessel function
Here is the call graph for this function:
Here is the caller graph for this function:

◆ TEST_F() [1/3]

TEST_F ( TestBesselBasis  ,
InitTest   
)

◆ TEST_F() [2/3]

TEST_F ( TestBesselBasis  ,
PolynomialInterpolation2Test   
)
Here is the call graph for this function:

◆ TEST_F() [3/3]

TEST_F ( TestBesselBasis  ,
PolynomialInterpolationTest   
)
Here is the call graph for this function: