ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
op_exx_lcao.h
Go to the documentation of this file.
1#ifndef OPEXXLCAO_H
2#define OPEXXLCAO_H
3
4#ifdef __EXX
5
6#include "operator_lcao.h"
7#include "source_cell/klist.h"
9
10#include <RI/global/Tensor.h>
11#include <RI/ri/Cell_Nearest.h>
12
13// Forward declaration of the EXX interface.
14template <typename T, typename Tdata>
16
17namespace hamilt
18{
19
20#ifndef __OPEXXTEMPLATE
21#define __OPEXXTEMPLATE
22
23template <class T>
24class OperatorEXX : public T
25{
26};
27
28#endif
29enum Add_Hexx_Type
30{
31 R,
32 k
33};
34template <typename TK, typename TR>
35class OperatorEXX<OperatorLCAO<TK, TR>> : public OperatorLCAO<TK, TR>
36{
37 using TAC = std::pair<int, std::array<int, 3>>;
38
39 public:
42 OperatorEXX<OperatorLCAO<TK, TR>>(HS_Matrix_K<TK>* hsk_in,
43 hamilt::HContainer<TR>* hR_in,
44 const UnitCell& ucell,
45 const K_Vectors& kv_in,
46 Exx_LRI_Interface<TK, double>* exd_in,
47 Exx_LRI_Interface<TK, std::complex<double>>* exc_in,
48 const Exx_Info& exx_info,
49 Add_Hexx_Type add_hexx_type_in = Add_Hexx_Type::R,
50 const int istep_in = 0,
51 const bool restart_in = false);
52
55 OperatorEXX<OperatorLCAO<TK, TR>>(
56 HS_Matrix_K<TK>* hsk_in,
57 hamilt::HContainer<TR>* hR_in,
58 const UnitCell& ucell,
59 const K_Vectors& kv_in,
60 std::vector<std::map<int, std::map<TAC, RI::Tensor<double>>>>* Hexxd_in,
61 std::vector<std::map<int, std::map<TAC, RI::Tensor<std::complex<double>>>>>* Hexxc_in,
62 const Exx_Info* exx_info,
63 Add_Hexx_Type add_hexx_type_in);
64
65 // Retained for the one-shot Add_Hexx_Type::k path used by write_Vxc/RDMFT;
66 // the main LCAO path uses contributeHR().
67 virtual void contributeHk(int ik) override;
68 virtual void contributeHR() override;
69
70 private:
71 Add_Hexx_Type add_hexx_type = Add_Hexx_Type::R;
72 int current_spin = 0;
73 bool HR_fixed_done = false;
74 bool initial_gga_done = false; // Taoni Bao add 2026-05-18, to fix RT-TDDFT EXX missing problem in the evolution
75
79 Exx_LRI_Interface<TK, double>* exd = nullptr;
80 Exx_LRI_Interface<TK, std::complex<double>>* exc = nullptr;
81
82 std::vector<std::map<int, std::map<TAC, RI::Tensor<double>>>>* Hexxd = nullptr;
83 std::vector<std::map<int, std::map<TAC, RI::Tensor<std::complex<double>>>>>* Hexxc = nullptr;
84
86 bool restart = false;
87
89 const Exx_Info* exx_info_ptr = nullptr;
90
91 const int istep = 0; // the ion step
92
93 void add_loaded_Hexx(const int ik);
94
95 const UnitCell& ucell;
96
97 const K_Vectors& kv;
98
99 // if k points has no shift, use cell_nearest to reduce the memory cost
100 RI::Cell_Nearest<int, int, 3, double, 3> cell_nearest;
101 bool use_cell_nearest = true;
102
104 std::vector<std::vector<double>> Hexxd_k_load;
105 std::vector<std::vector<std::complex<double>>> Hexxc_k_load;
106};
107
108using TAC = std::pair<int, std::array<int, 3>>;
109
110RI::Cell_Nearest<int, int, 3, double, 3> init_cell_nearest(const UnitCell& ucell, const std::array<int, 3>& Rs_period);
111
112// allocate according to the read-in HexxR, used in nscf
113template <typename Tdata, typename TR>
114void reallocate_hcontainer(const std::vector<std::map<int, std::map<TAC, RI::Tensor<Tdata>>>>& Hexxs,
115 HContainer<TR>* hR,
116 const RI::Cell_Nearest<int, int, 3, double, 3>* const cell_nearest = nullptr);
117
119template <typename TR>
120void reallocate_hcontainer(const int nat,
121 HContainer<TR>* hR,
122 const std::array<int, 3>& Rs_period,
123 const RI::Cell_Nearest<int, int, 3, double, 3>* const cell_nearest = nullptr);
124
125} // namespace hamilt
126#endif // __EXX
127#endif // OPEXXLCAO_H
Definition exx_lri_interface.h:43
Definition hcontainer.h:147
Definition operator_lcao.h:13
#define T
Definition exp.cpp:237
Exx_Info exx_info
Definition deepks_test_prep.cpp:22
Restart restart
Definition test_chg_init.cpp:27
Definition wf_op.cpp:6
std::pair< int, TC > TAC
Definition test_write_ri_cv.cpp:10