-
Notifications
You must be signed in to change notification settings - Fork 238
Refactor source_psi, remove some unnecessary dependency #7675
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
30e0184
d9a38f9
d4c5e44
9770305
5ffbad0
759f288
4bb4c66
5bb1237
7c9342d
fe412e9
b54d8fa
c640071
44a248d
b2e9a0d
7ce9df2
5c04a11
f8c55a0
855db0f
6be82f4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,68 +1,71 @@ | ||
| #ifndef PSI_INITIALIZER_H | ||
| #define PSI_INITIALIZER_H | ||
| // data structure support | ||
| #include "source_basis/module_pw/pw_basis_k.h" // for kpoint related data structure | ||
| #include "source_pw/module_pwdft/vnl_pw.h" | ||
| #ifndef PSI_BASE_H | ||
| #define PSI_BASE_H | ||
| #include "source_basis/module_pw/pw_basis_k.h" | ||
| #include "source_pw/module_pwdft/structure_factor.h" | ||
| #include "source_psi/psi.h" // for psi data structure | ||
| // smart pointer for auto-memory management | ||
| #include "source_psi/psi.h" | ||
| #include <memory> | ||
| // numerical algorithm support | ||
| #ifdef __MPI | ||
| #include <mpi.h> | ||
| #endif | ||
| #include "source_base/macros.h" | ||
| #include "source_cell/klist.h" | ||
| #include "source_cell/unitcell.h" | ||
|
|
||
| #include <type_traits> | ||
| #include <vector> | ||
|
|
||
| using namespace std; | ||
|
|
||
| /* | ||
| Psi (planewave based wavefunction) initializer | ||
| Psi (planewave based wavefunction) base class | ||
| Auther: Kirk0830 | ||
| Institute: AI for Science Institute, BEIJING | ||
|
|
||
| This class is used to allocate memory and give initial guess for psi | ||
| therefore only double datatype is needed to be supported. | ||
| Following methods are available: | ||
| 1. file: use wavefunction file to initialize psi | ||
| implemented in psi_initializer_file.h | ||
| implemented in psi_init_file.h | ||
| 2. random: use random number to initialize psi | ||
| implemented in psi_initializer_random.h | ||
| implemented in psi_init_random.h | ||
| 3. atomic: use pseudo-wavefunction in pseudopotential file to initialize psi | ||
| implemented in psi_initializer_atomic.h | ||
| implemented in psi_init_atomic.h | ||
| 4. atomic+random: mix 'atomic' with some random numbers to initialize psi | ||
| 5. nao: use numerical orbitals to initialize psi | ||
| implemented in psi_initializer_nao.h | ||
| implemented in psi_init_nao.h | ||
| 6. nao+random: mix 'nao' with some random numbers to initialize psi | ||
|
|
||
| To use: | ||
| - WAVEFUNCTION INITIALIZATION | ||
| A practical example would be in ESolver_KS_PW, because polymorphism is achieved by | ||
| pointer, while a raw pointer is risky, therefore std::unique_ptr is a better | ||
| choice. | ||
| 1. new a std::unique_ptr<psi_initializer<T> with specific derived class | ||
| 2. initialize() to link psi_initializer with external data and methods | ||
| 1. new a std::unique_ptr<psi_base<T> with specific derived class | ||
| 2. initialize() to link psi_base with external data and methods | ||
| 3. tabulate() to calculate the interpolate table | ||
| 4. init_psig() to calculate projection of atomic radial function onto planewave basis | ||
| In summary: | ||
| new->initialize->tabulate->init_psig | ||
| */ | ||
| template <typename T> | ||
| class psi_initializer | ||
| class psi_base | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Naming:
The more concrete problem is that the file now sits next to If the goal is just to shorten the |
||
| { | ||
| private: | ||
| using Real = typename GetTypeReal<T>::type; | ||
|
|
||
| public: | ||
| psi_initializer(){}; | ||
| virtual ~psi_initializer(){}; | ||
| /// @brief initialize the psi_initializer with external data and methods | ||
| virtual void initialize(const Structure_Factor*, //< structure factor | ||
| const ModulePW::PW_Basis_K*, //< planewave basis | ||
| const UnitCell*, //< unit cell | ||
| const K_Vectors* = nullptr, //< parallel kpoints | ||
| const int& = 1, //< random seed | ||
| const pseudopot_cell_vnl* = nullptr, //< nonlocal pseudopotential | ||
| const int& = 0); //< rank | ||
| psi_base(){}; | ||
| virtual ~psi_base(){}; | ||
| /// @brief initialize the psi_base with external data and methods | ||
| virtual void initialize(const Structure_Factor* sf, //< structure factor | ||
| const ModulePW::PW_Basis_K* pw_wfc, //< planewave basis | ||
| const UnitCell* p_ucell, //< unit cell | ||
| const std::vector<int>& ik2iktot, //< ik2iktot: local->global k-point mapping | ||
| const int& nkstot, //< nkstot: total number of k-points | ||
| const int& random_seed, //< random seed | ||
| const int& lmaxkb, //< lmaxkb: max angular momentum for non-local projectors | ||
| const int& rank, //< rank | ||
| const int& npol, //< npol | ||
| const int& nbands); //< nbands | ||
|
|
||
| /// @brief CENTRAL FUNCTION: calculate the interpolate table if needed | ||
| virtual void tabulate() | ||
|
|
@@ -112,6 +115,7 @@ class psi_initializer | |
| } | ||
|
|
||
| protected: | ||
|
|
||
| #ifdef __MPI // MPI additional implementation | ||
| /// @brief mapping from (ix, iy) to is | ||
| void stick_to_pool(Real* stick, //< stick | ||
|
|
@@ -123,17 +127,35 @@ class psi_initializer | |
| const int iw_end, ///< iw_end, ending band index | ||
| const int ik, ///< ik, kpoint index | ||
| const int mode = 1); ///< mode, 0 for rr*exp(i*arg), 1 for rr/(1+gk2)*exp(i*arg) | ||
|
|
||
| const Structure_Factor* sf_ = nullptr; ///< Structure_Factor | ||
|
|
||
| const ModulePW::PW_Basis_K* pw_wfc_ = nullptr; ///< use |k+G>, |G>, getgpluskcar and so on in PW_Basis_K | ||
|
|
||
| const UnitCell* p_ucell_ = nullptr; ///< UnitCell | ||
| const K_Vectors* p_kv = nullptr; ///< Parallel_Kpoints | ||
| const pseudopot_cell_vnl* p_pspot_nl_ = nullptr; ///< pseudopot_cell_vnl | ||
|
|
||
| int lmaxkb_ = 0; ///< max angular momentum for non-local projectors | ||
|
|
||
| std::vector<int> ik2iktot_; ///< local->global k-point mapping | ||
|
|
||
| int nkstot_ = 0; ///< total number of k-points | ||
|
|
||
| int random_seed_ = 1; ///< random seed, shared by random, atomic+random, nao+random | ||
|
|
||
| std::vector<int> ixy2is_; ///< used by stick_to_pool function | ||
|
|
||
| int mem_saver_ = 0; ///< if save memory, only for nscf | ||
|
|
||
| std::string method_ = "none"; ///< method name | ||
|
|
||
| int nbands_complem_ = 0; ///< complement number of bands, which is nbands_start_ - ucell.natomwfc | ||
|
|
||
| double mixing_coef_ = 0; ///< mixing coefficient for atomic+random and nao+random | ||
|
|
||
| int nbands_start_ = 0; ///< starting nbands, which is no less than PARAM.inp.nbands | ||
|
|
||
| int npol_ = 1; ///< number of polarizations | ||
|
|
||
| int nbands_ = 1; ///< number of bands | ||
| }; | ||
| #endif | ||
| #endif | ||
Uh oh!
There was an error while loading. Please reload this page.