|
| 1 | +//======================= |
| 2 | +// AUTHOR : Peize Lin |
| 3 | +// DATE : 2022-08-17 |
| 4 | +//======================= |
| 5 | + |
| 6 | +#ifndef EXX_LRI_H |
| 7 | +#define EXX_LRI_H |
| 8 | + |
| 9 | +#include "LRI_CV.h" |
| 10 | +#include "source_hamilt/module_xc/exx_info.h" |
| 11 | +#include "source_basis/module_ao/ORB_atomic_lm.h" |
| 12 | +#include "source_base/matrix.h" |
| 13 | +#include <RI/physics/Exx.h> |
| 14 | + |
| 15 | +#include <vector> |
| 16 | +#include <array> |
| 17 | +#include <map> |
| 18 | +#include <deque> |
| 19 | +#include <mpi.h> |
| 20 | + |
| 21 | +#include "module_exx_symmetry/symmetry_rotation.h" |
| 22 | + |
| 23 | + class Parallel_Orbitals; |
| 24 | + |
| 25 | + template<typename T, typename Tdata> |
| 26 | + class RPA_LRI; |
| 27 | + |
| 28 | + template<typename T, typename Tdata> |
| 29 | + class Exx_LRI_Interface; |
| 30 | + |
| 31 | + namespace LR |
| 32 | + { |
| 33 | + template<typename T, typename TR> |
| 34 | + class ESolver_LR; |
| 35 | + |
| 36 | + template<typename T> |
| 37 | + class OperatorLREXX; |
| 38 | + } |
| 39 | + |
| 40 | +template<typename Tdata> |
| 41 | +class Exx_Obj |
| 42 | +{ |
| 43 | + // match with Conv_Coulomb_Pot_K::Coulomb_Method |
| 44 | + public: |
| 45 | + LRI_CV<Tdata> cv; |
| 46 | + std::map<std::string, std::vector<std::vector<Numerical_Orbital_Lm>>> abfs_ccp; |
| 47 | +}; |
| 48 | + |
| 49 | +template<typename Tdata> |
| 50 | +class Exx_LRI |
| 51 | +{ |
| 52 | +private: |
| 53 | + using TA = int; |
| 54 | + using Tcell = int; |
| 55 | + static constexpr std::size_t Ndim = 3; |
| 56 | + using TC = std::array<Tcell,Ndim>; |
| 57 | + using TAC = std::pair<TA,TC>; |
| 58 | + using TatomR = std::array<double,Ndim>; // tmp |
| 59 | + |
| 60 | +public: |
| 61 | + Exx_LRI(const Exx_Info::Exx_Info_RI& info_in) :info(info_in) {} |
| 62 | + Exx_LRI operator=(const Exx_LRI&) = delete; |
| 63 | + Exx_LRI operator=(Exx_LRI&&); |
| 64 | + |
| 65 | + std::map<std::string, std::pair<int,int>> group; |
| 66 | + |
| 67 | + void init( |
| 68 | + const MPI_Comm &mpi_comm_in, |
| 69 | + const UnitCell &ucell, |
| 70 | + const K_Vectors &kv_in, |
| 71 | + const LCAO_Orbitals& orb); |
| 72 | + void cal_exx_ions(const UnitCell& ucell, const bool write_cv = false); |
| 73 | + void cal_exx_elec( |
| 74 | + const std::vector<std::map<TA, std::map<TAC, RI::Tensor<Tdata>>>>& Ds, |
| 75 | + const UnitCell& ucell, |
| 76 | + const Parallel_Orbitals& pv, |
| 77 | + const ModuleSymmetry::Symmetry_rotation* p_symrot = nullptr); |
| 78 | + void cal_exx_force(const int& nat); |
| 79 | + void cal_exx_stress(const double& omega, const double& lat0); |
| 80 | + |
| 81 | + void reset_Cs(const std::map<TA, std::map<TAC, RI::Tensor<Tdata>>>& Cs_in) { this->exx_lri.set_Cs(Cs_in, this->info.C_threshold); } |
| 82 | + void reset_Vs(const std::map<TA, std::map<TAC, RI::Tensor<Tdata>>>& Vs_in) { this->exx_lri.set_Vs(Vs_in, this->info.V_threshold); } |
| 83 | + //std::vector<std::vector<int>> get_abfs_nchis() const; |
| 84 | + |
| 85 | + std::vector< std::map<TA, std::map<TAC, RI::Tensor<Tdata>>>> Hexxs; |
| 86 | + double Eexx; |
| 87 | + ModuleBase::matrix force_exx; |
| 88 | + ModuleBase::matrix stress_exx; |
| 89 | + |
| 90 | + |
| 91 | +private: |
| 92 | + const Exx_Info::Exx_Info_RI &info; |
| 93 | + MPI_Comm mpi_comm; |
| 94 | + const K_Vectors *p_kv = nullptr; |
| 95 | + ORB_gaunt_table MGT; |
| 96 | + std::vector<double> orb_cutoff_; |
| 97 | + |
| 98 | + std::vector<std::vector<std::vector<Numerical_Orbital_Lm>>> lcaos; |
| 99 | + std::map<std::string, std::vector<std::vector<Numerical_Orbital_Lm>>> abfs; |
| 100 | + //std::vector<std::vector<std::vector<Numerical_Orbital_Lm>>> abfs_ccp; |
| 101 | + std::map<Conv_Coulomb_Pot_K::Coulomb_Method, Exx_Obj<Tdata>> exx_objs; |
| 102 | + //LRI_CV<Tdata> cv; |
| 103 | + RI::Exx<TA,Tcell,Ndim,Tdata> exx_lri; |
| 104 | + std::map<Conv_Coulomb_Pot_K::Coulomb_Method, |
| 105 | + std::pair<bool, |
| 106 | + std::map<Conv_Coulomb_Pot_K::Coulomb_Type, |
| 107 | + std::vector<std::map<std::string,std::string>>>>> coulomb_settings; |
| 108 | + |
| 109 | + void post_process_Hexx( std::map<TA, std::map<TAC, RI::Tensor<Tdata>>> &Hexxs_io ) const; |
| 110 | + double post_process_Eexx(const double& Eexx_in) const; |
| 111 | + |
| 112 | + friend class RPA_LRI<double, Tdata>; |
| 113 | + friend class RPA_LRI<std::complex<double>, Tdata>; |
| 114 | + friend class Exx_LRI_Interface<double, Tdata>; |
| 115 | + friend class Exx_LRI_Interface<std::complex<double>, Tdata>; |
| 116 | + friend class LR::ESolver_LR<double, double>; |
| 117 | + friend class LR::ESolver_LR<std::complex<double>, double>; |
| 118 | + friend class LR::OperatorLREXX<double>; |
| 119 | + friend class LR::OperatorLREXX<std::complex<double>>; |
| 120 | +}; |
| 121 | + |
| 122 | +#include "Exx_LRI.hpp" |
| 123 | + |
| 124 | +#endif |
0 commit comments