forked from deepmodeling/abacus-develop
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: Quasiatomic Orbital (QO) implement - immediate (deepmodeling…
…#3236) * building two center overlap * 20231120 * 20231121 * 20231124 * serial implementation done * because rcut_max is not set in previous, after addition, the corresponding unit test is forgotten to update. * full implementation of QO analysis, next is to improve accuracy of associated Laguerre Polynomial * Accurancy improved. C++-side in principle no problem for use anymore * provide python-end qo analysis into tools folder. In readme.md the usage is introduced. * recover changed INPUT files * support strategy full, use filter in postprocessing to select basis to reconstruct hamiltonian * - add new derived class pswfc_radials - extend strategy of derived class hydrogen_radials (but tested to perform ill) * implement qo_basis = pswfc * update python-end * Oops! update Makefile.Objects * add ceil() when computing supercell * update documentation * change kvec_c to kvec_d when folding * add integrated test and support output of HqoR matrix * correct CMakeLists.txt * correct CMakeLists.txt * correct CMakeLists.txt * reduce number of hydrogen-like orbitals generated with "energy" strategy * update reference value of hydrogen_radials unittest * update example and debugging the unfolding_Hk function, not completed yet * correct the method to find supercells * recover example/scf/lcao_Cu * recover examples/scf/lcao_Cu * complete necessary annotations * support the use of qo_thr for qo_basis = pswfc, flexibly controls the rcut of pswfc * add more unittest to test the symmetrical-kpoints cancellation on imaginary parts * update unittest on toqo class * complement zero_out before every so-called folding_Hk * update debugged python-end analysis package and correct CMakeLists.txt * update README.md of QO in tools/qo * Update INPUT in tools/qo/examples/abacus_input * delete redundant example files * update docs according to the newest implementation * remove commented out codes accordint to code review * provide example and update more detailed README.md * change default strategy to `minimal` for memory save concern --------- Co-authored-by: wqzhou <[email protected]>
- Loading branch information
1 parent
8cf8f4b
commit cbaccdf
Showing
68 changed files
with
5,478 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,4 +18,6 @@ build | |
dist | ||
.idea | ||
toolchain.tar.gz | ||
time.json | ||
time.json | ||
*.pyc | ||
__pycache__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
#include "module_base/assoc_laguerre.h" | ||
#include "module_base/global_function.h" | ||
//#include <tr1/cmath> // use cmath the factorial function | ||
#include <cmath> | ||
Assoc_Laguerre::Assoc_Laguerre() | ||
{ | ||
} | ||
|
||
Assoc_Laguerre::~Assoc_Laguerre() | ||
{ | ||
} | ||
|
||
void Assoc_Laguerre::generate(const int &n, const int &l, const double ns, double* const &s, double* L) | ||
{ | ||
for(int i = 0; i < ns; i++) | ||
{ | ||
L[i] = this->value(n, l, s[i]); | ||
} | ||
} | ||
|
||
void Assoc_Laguerre::generate(const int &n, const int &l, std::vector<double> &x, std::vector<double> &y) | ||
{ | ||
for(int i = 0; i < x.size(); i++) | ||
{ | ||
y[i] = this->value(n, l, x[i]); | ||
} | ||
} | ||
|
||
double Assoc_Laguerre::laguerre(const int &n, const double x) | ||
{ | ||
if(n == 0) | ||
{ | ||
return 1; | ||
} | ||
else if(n == 1) | ||
{ | ||
return -x + 1; | ||
} | ||
else if(n == 2) | ||
{ | ||
return 0.5 * x * x - 2 * x + 1; | ||
} | ||
else if(n == 3) | ||
{ | ||
return -x * x * x / 6.0 + 3.0 * x * x / 2.0 - 3.0 * x + 1; | ||
} | ||
else if(n >= 4) | ||
{ | ||
double n_ = static_cast<double>(n); | ||
double first = (2*n_ - 1 - x)/n_ * Assoc_Laguerre::laguerre(n-1, x); | ||
double second = (n_ - 1)/n_ * Assoc_Laguerre::laguerre(n-2, x); | ||
return first - second; | ||
} | ||
else | ||
{ | ||
ModuleBase::WARNING_QUIT("Assoc_Laguerre::laguerre", "n is out of range"); | ||
return 0; | ||
} | ||
} | ||
|
||
double Assoc_Laguerre::associate_laguerre(const int &n, const double x, const int &a) | ||
{ | ||
// formula from https://en.wikipedia.org/wiki/Laguerre_polynomials | ||
double n_ = static_cast<double>(n); | ||
double a_ = static_cast<double>(a); | ||
if(n == 0) | ||
{ | ||
return 1; | ||
} | ||
else if(n == 1) | ||
{ | ||
return -x + 1 + a_; | ||
} | ||
else if(n == 2) | ||
{ | ||
return 0.5 * (x*x - 2*(a_+2)*x + (a_+1)*(a_+2)); | ||
} | ||
else if(n == 3) | ||
{ | ||
return -x*x*x/6.0 + (a_+3)*x*x/2.0 - (a_+2)*(a_+3)*x/2.0 + (a_+1)*(a_+2)*(a_+3)/6.0; | ||
} | ||
else if(n >= 4) | ||
{ | ||
double first = (2*n_ - 1 + a_ - x)/n_ * this->associate_laguerre(n-1, x, a); | ||
double second = (n_ + a_ - 1)/n_ * this->associate_laguerre(n-2, x, a); | ||
return first - second; | ||
} | ||
else | ||
{ | ||
ModuleBase::WARNING_QUIT("Assoc_Laguerre::associate_laguerre", "n is out of range"); | ||
return 0; | ||
} | ||
} | ||
|
||
int Assoc_Laguerre::factorial(const int &n) | ||
{ | ||
if(n == 0) | ||
{ | ||
return 1; | ||
} | ||
else if(n > 0) | ||
{ | ||
return n * this->factorial(n-1); | ||
} | ||
else | ||
{ | ||
ModuleBase::WARNING_QUIT("Assoc_Laguerre::factorial", "n is out of range"); | ||
return 0; | ||
} | ||
} | ||
|
||
double Assoc_Laguerre::value(const int &n, const int &l, const double &s) | ||
{ | ||
int k_ = 2*l + 1; | ||
int n_ = n - l - 1; | ||
if(k_ < 0) | ||
{ | ||
ModuleBase::WARNING_QUIT("Assoc_Laguerre::value", "k is out of range"); | ||
return 0; | ||
} | ||
if(n_ < 0) | ||
{ | ||
ModuleBase::WARNING_QUIT("Assoc_Laguerre::value", "n is out of range"); | ||
return 0; | ||
} | ||
double L = 0; | ||
for(int iq = 0; iq <= n_; iq++) | ||
{ | ||
L += std::pow(-s, iq) * | ||
static_cast<double>(this->factorial(n_ + k_)) / | ||
static_cast<double>(this->factorial(n_ - iq)) / | ||
static_cast<double>(this->factorial(k_ + iq)) / | ||
static_cast<double>(this->factorial(iq)); | ||
} | ||
//L = std::tr1::assoc_laguerre(n_, k_, s); // use standard library | ||
return L; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#ifndef ASSOC_LAGUEERRE_H | ||
#define ASSOC_LAGUEERRE_H | ||
|
||
#include <vector> | ||
#include <string> | ||
|
||
class Assoc_Laguerre | ||
{ | ||
public: | ||
Assoc_Laguerre(); | ||
~Assoc_Laguerre(); | ||
/// @brief generate the associated Laguerre polynomial (overloaded for double*) | ||
/// @param n principal quantum number | ||
/// @param l orbital quantum number | ||
/// @param ns number of x-coordinates | ||
/// @param s x-coordinates | ||
/// @param L y-coordinates | ||
void generate(const int &n, const int &l, const double ns, double* const &s, double* L); | ||
/// @brief generate the associated Laguerre polynomial (overloaded for std::vector) | ||
/// @param n principal quantum number | ||
/// @param l orbital quantum number | ||
/// @param x x-coordinates in std::vector | ||
/// @param y y-coordinates in std::vector | ||
void generate(const int &n, const int &l, std::vector<double> &x, std::vector<double> &y); | ||
/// @brief Laguerre polynomial | ||
/// @param n degree of the polynomial | ||
/// @param x radial coordinate | ||
/// @return L_n(x) | ||
double laguerre(const int &n, const double x); | ||
/// @brief recursive relationship to find the associated Laguerre polynomial | ||
/// @param n degree of the polynomial | ||
/// @param x radial coordinate | ||
/// @param a order of the polynomial | ||
/// @return L^(a)_n(x) | ||
double associate_laguerre(const int &n, const double x, const int &a); | ||
/// @brief wrapper for associate_laguerre | ||
/// @param n principal quantum number | ||
/// @param l orbital quantum number | ||
/// @param s radial coordinate | ||
/// @return L^(2l+1)_(n-l-1)(s) | ||
double value(const int &n, const int &l, const double &s); | ||
/// @brief factorial function | ||
/// @param n | ||
/// @return n! | ||
int factorial(const int &n); | ||
}; | ||
#endif // ASSOC_LAGUEERRE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.