ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
exx_lri.h
Go to the documentation of this file.
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 "ewald_vq.h"
13#include "source_base/matrix.h"
14#include <RI/physics/Exx.h>
15
16#include <vector>
17#include <array>
18#include <map>
19#include <deque>
20#include <mpi.h>
21
23
25
26 template<typename T, typename Tdata>
27 class RPA_LRI;
28
29 template<typename T, typename Tdata>
31
32 namespace LR
33 {
34 template<typename T>
36 }
37
38template<typename Tdata>
40{
41 // match with Conv_Coulomb_Pot_K::Coulomb_Method
42 public:
45 std::vector<std::vector<std::vector<Numerical_Orbital_Lm>>> abfs_ccp;
46};
47
48template<typename Tdata>
50{
51private:
52 using TA = int;
53 using Tcell = int;
54 static constexpr std::size_t Ndim = 3;
55 using TC = std::array<Tcell,Ndim>;
56 using TAC = std::pair<TA,TC>;
57 using TatomR = std::array<double,Ndim>; // tmp
58
59public:
61 std::pair<bool,
63 std::vector<std::map<std::string, std::string>>>>>;
64
65 Exx_LRI(const Exx_Info_RI& info_in) :info(info_in) {}
66 Exx_LRI operator=(const Exx_LRI&) = delete;
68
69 // accessors used by the LR-TDDFT analytical-gradient module
71 {
72 return this->exx_lri;
73 }
74 const Exx_Info_RI& get_info() const
75 {
76 return this->info;
77 }
78 const MPI_Comm& get_mpi_comm() const
79 {
80 return this->mpi_comm;
81 }
82
83 // Share read-only geometry tensors, but keep all electronic work buffers independent.
84 std::shared_ptr<Exx_LRI<Tdata>> make_lr_workspace(const UnitCell& ucell,
85 const K_Vectors& kv) const;
86
87 void init(
88 const MPI_Comm &mpi_comm_in,
89 const UnitCell &ucell,
90 const K_Vectors &kv_in,
91 const LCAO_Orbitals& orb,
92 const std::vector<std::vector<std::vector<Numerical_Orbital_Lm>>>& abfs_in = {});
93 void init(
94 const MPI_Comm &mpi_comm_in,
95 const UnitCell &ucell,
96 const K_Vectors &kv_in,
97 const LCAO_Orbitals &orb,
98 const std::vector<std::vector<std::vector<Numerical_Orbital_Lm>>> &abfs_in,
99 const bool use_gpu);
101 void refresh_coulomb(
102 const UnitCell &ucell,
103 const LCAO_Orbitals &orb,
104 const CoulombSettings &settings,
105 const bool use_gpu);
106 void init_spencer(const MPI_Comm& mpi_comm_in,
107 const UnitCell& ucell,
108 const K_Vectors& kv_in,
109 const LCAO_Orbitals& orb,
110 const std::vector<std::vector<std::vector<Numerical_Orbital_Lm>>>& abfs_in = {});
111 void cal_exx_ions(const UnitCell& ucell, const bool write_cv = false);
113 std::map<TA, std::map<TAC, RI::Tensor<Tdata>>>& Vs_cut_IJR,
114 std::map<TA, std::map<TAC, RI::Tensor<Tdata>>>& Cs,
115 const UnitCell& ucell,
116 const bool write_cv = false);
118 std::map<TA, std::map<TAC, RI::Tensor<Tdata>>>& Vs_full_IJR,
119 std::map<TA, std::map<TAC, RI::Tensor<Tdata>>>& Cs,
120 const UnitCell& ucell,
121 const bool write_cv = false);
122 void cal_exx_elec(
123 const std::vector<std::map<TA, std::map<TAC, RI::Tensor<Tdata>>>>& Ds,
124 const UnitCell& ucell,
125 const Parallel_Orbitals& pv,
126 const ModuleSymmetry::Symmetry_rotation* p_symrot = nullptr);
127 // (nspin=4) real-space symmetry EXX: the spinor H(R) rotation couples the 4 spin channels via
128 // the SU(2) part U(isym), so the 4 channels must be rotated together (not one-per-outer-loop).
129 // Gathers the irreducible Hs of all 4 channels, calls Symmetry_rotation::restore_HR_nspin4, then
130 // finishes energy/gather per channel. Called from cal_exx_elec when p_symrot && nspin==4.
131 void cal_exx_elec_soc(
132 const std::vector<std::map<TA, std::map<TAC, RI::Tensor<Tdata>>>>& Ds,
133 const UnitCell& ucell,
134 const std::vector<std::tuple<std::set<TA>, std::set<TA>>>& judge,
135 const ModuleSymmetry::Symmetry_rotation* p_symrot);
136 void cal_exx_force(const int& nat);
137 void cal_exx_stress(const double& omega, const double& lat0);
138
139 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); }
140 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); }
141 //std::vector<std::vector<int>> get_abfs_nchis() const;
142
143 std::vector< std::map<TA, std::map<TAC, RI::Tensor<Tdata>>>> Hexxs;
144 double Eexx = 0.0; // initialize: in the HexxR-restart branch (init_chg=file) Eexx is
145 // never computed, and OperatorEXX still reads get_Eexx() for the NSCF
146 // energy report; leaving it uninitialized leaked an indeterminate value.
149
150 void post_process_Hexx(std::map<TA, std::map<TAC, RI::Tensor<Tdata>>>& Hexxs_io) const;
151 double post_process_Eexx(const double& Eexx_in) const;
152
153 int abfs_Lmax() const { return abfs_Lmax_; }
154 const Exx_Info_RI& get_info_ri() const { return info; }
155 const std::array<int, 3>& hybrid_images_period() const { return hybrid_images_period_; }
156
157private:
159 std::array<int, 3> hybrid_images_period_{{1, 1, 1}};
160 int abfs_Lmax_ = 0;
161 MPI_Comm mpi_comm;
162 const K_Vectors *p_kv = nullptr;
163 std::shared_ptr<ORB_gaunt_table> MGT;
164 std::vector<double> orb_cutoff_;
165
166 std::vector<std::vector<std::vector<Numerical_Orbital_Lm>>> lcaos;
167 std::vector<std::vector<std::vector<Numerical_Orbital_Lm>>> abfs;
168 //std::vector<std::vector<std::vector<Numerical_Orbital_Lm>>> abfs_ccp;
169 std::map<Conv_Coulomb_Pot_K::Coulomb_Method, Exx_Obj<Tdata>> exx_objs;
170 //LRI_CV<Tdata> cv;
173
174 friend class RPA_LRI<double, Tdata>;
175 friend class RPA_LRI<std::complex<double>, Tdata>;
176 friend class Exx_LRI_Interface<double, Tdata>;
177 friend class Exx_LRI_Interface<std::complex<double>, Tdata>;
178 friend class LR::OperatorLREXX<double>;
179 friend class LR::OperatorLREXX<std::complex<double>>;
180};
181
182#include "exx_lri.hpp"
183
184#endif
Definition ewald_vq.h:23
Definition exx_lri_interface.h:43
std::shared_ptr< Exx_LRI< Tdata > > make_lr_workspace(const UnitCell &ucell, const K_Vectors &kv) const
Definition exx_workspace.cpp:66
ModuleBase::matrix stress_exx
Definition exx_lri.h:148
RI::Exx< TA, Tcell, Ndim, Tdata > & get()
Definition exx_lri.h:70
void post_process_Hexx(std::map< TA, std::map< TAC, RI::Tensor< Tdata > > > &Hexxs_io) const
Definition exx_lri.hpp:1007
std::vector< std::vector< std::vector< Numerical_Orbital_Lm > > > lcaos
Definition exx_lri.h:166
int abfs_Lmax_
Definition exx_lri.h:160
const std::array< int, 3 > & hybrid_images_period() const
Definition exx_lri.h:155
CoulombSettings coulomb_settings
Definition exx_lri.h:172
std::vector< std::vector< std::vector< Numerical_Orbital_Lm > > > abfs
Definition exx_lri.h:167
void reset_Vs(const std::map< TA, std::map< TAC, RI::Tensor< Tdata > > > &Vs_in)
Definition exx_lri.h:140
void init(const MPI_Comm &mpi_comm_in, const UnitCell &ucell, const K_Vectors &kv_in, const LCAO_Orbitals &orb, const std::vector< std::vector< std::vector< Numerical_Orbital_Lm > > > &abfs_in={})
Definition exx_lri.hpp:39
void cal_cut_coulomb_cs(std::map< TA, std::map< TAC, RI::Tensor< Tdata > > > &Vs_cut_IJR, std::map< TA, std::map< TAC, RI::Tensor< Tdata > > > &Cs, const UnitCell &ucell, const bool write_cv=false)
Definition exx_lri.hpp:741
static constexpr std::size_t Ndim
Definition exx_lri.h:54
int abfs_Lmax() const
Definition exx_lri.h:153
std::vector< std::map< TA, std::map< TAC, RI::Tensor< Tdata > > > > Hexxs
Definition exx_lri.h:143
Exx_Info_RI info
Definition exx_lri.h:158
ModuleBase::matrix force_exx
Definition exx_lri.h:147
Exx_LRI(const Exx_Info_RI &info_in)
Definition exx_lri.h:65
void cal_exx_elec(const std::vector< std::map< TA, std::map< TAC, RI::Tensor< Tdata > > > > &Ds, const UnitCell &ucell, const Parallel_Orbitals &pv, const ModuleSymmetry::Symmetry_rotation *p_symrot=nullptr)
Definition exx_lri.hpp:898
void cal_exx_elec_soc(const std::vector< std::map< TA, std::map< TAC, RI::Tensor< Tdata > > > > &Ds, const UnitCell &ucell, const std::vector< std::tuple< std::set< TA >, std::set< TA > > > &judge, const ModuleSymmetry::Symmetry_rotation *p_symrot)
Definition exx_lri.hpp:966
std::shared_ptr< ORB_gaunt_table > MGT
Definition exx_lri.h:163
double post_process_Eexx(const double &Eexx_in) const
Definition exx_lri.hpp:1018
const Exx_Info_RI & get_info_ri() const
Definition exx_lri.h:154
const Exx_Info_RI & get_info() const
Definition exx_lri.h:74
std::pair< TA, TC > TAC
Definition exx_lri.h:56
std::map< Conv_Coulomb_Pot_K::Coulomb_Method, std::pair< bool, std::map< Conv_Coulomb_Pot_K::Coulomb_Type, std::vector< std::map< std::string, std::string > > > > > CoulombSettings
Definition exx_lri.h:60
void reset_Cs(const std::map< TA, std::map< TAC, RI::Tensor< Tdata > > > &Cs_in)
Definition exx_lri.h:139
int TA
Definition exx_lri.h:52
std::array< int, 3 > hybrid_images_period_
Definition exx_lri.h:159
void refresh_coulomb(const UnitCell &ucell, const LCAO_Orbitals &orb, const CoulombSettings &settings, const bool use_gpu)
Refresh changed Coulomb kernels while retaining the initialized basis and Gaunt table.
Definition exx_lri.hpp:116
double Eexx
Definition exx_lri.h:144
const MPI_Comm & get_mpi_comm() const
Definition exx_lri.h:78
std::map< Conv_Coulomb_Pot_K::Coulomb_Method, Exx_Obj< Tdata > > exx_objs
Definition exx_lri.h:169
void cal_exx_ions(const UnitCell &ucell, const bool write_cv=false)
Definition exx_lri.hpp:247
MPI_Comm mpi_comm
Definition exx_lri.h:161
void cal_exx_force(const int &nat)
Definition exx_lri.hpp:1044
void init_spencer(const MPI_Comm &mpi_comm_in, const UnitCell &ucell, const K_Vectors &kv_in, const LCAO_Orbitals &orb, const std::vector< std::vector< std::vector< Numerical_Orbital_Lm > > > &abfs_in={})
Definition exx_lri.hpp:177
std::array< Tcell, Ndim > TC
Definition exx_lri.h:55
std::array< double, Ndim > TatomR
Definition exx_lri.h:57
RI::Exx< TA, Tcell, Ndim, Tdata > exx_lri
Definition exx_lri.h:171
void cal_ewald_coulomb(std::map< TA, std::map< TAC, RI::Tensor< Tdata > > > &Vs_full_IJR, std::map< TA, std::map< TAC, RI::Tensor< Tdata > > > &Cs, const UnitCell &ucell, const bool write_cv=false)
Definition exx_lri.hpp:818
Exx_LRI operator=(const Exx_LRI &)=delete
int Tcell
Definition exx_lri.h:53
void cal_exx_stress(const double &omega, const double &lat0)
Definition exx_lri.hpp:1070
const K_Vectors * p_kv
Definition exx_lri.h:162
Exx_LRI operator=(Exx_LRI &&)
std::vector< double > orb_cutoff_
Definition exx_lri.h:164
Definition exx_lri.h:40
LRI_CV< Tdata > cv
Definition exx_lri.h:43
std::vector< std::vector< std::vector< Numerical_Orbital_Lm > > > abfs_ccp
Definition exx_lri.h:45
Ewald_Vq< Tdata > evq
Definition exx_lri.h:44
Class for k-points management.
Definition klist.h:20
Definition orb_read.h:18
Definition lri_cv.h:26
Definition exx_lri.h:35
Definition matrix.h:15
Definition parallel_orbitals.h:16
Definition exx_workspace.h:9
Definition rpa_lri_coeff_v1.h:11
Definition rpa_lri.h:63
Provide the basic information about unitcell.
Definition unitcell.h:16
#define complex
Definition elpa_new.h:28
Coulomb_Type
Definition coulomb_config.h:11
Coulomb_Method
Definition coulomb_config.h:23
Definition esolver_lr_lcao_tddft.h:28
Definition exx_info_ri.h:11