ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
RPA_LRI.hpp
Go to the documentation of this file.
1//=======================
2// AUTHOR : Rong Shi
3// DATE : 2022-12-09
4//=======================
5
6#ifndef RPA_LRI_HPP
7#define RPA_LRI_HPP
8#include <cstring>
9#include <fstream>
10#include <iomanip>
11#include <iostream>
12#include <set>
13#include <stdexcept>
14#include <vector>
16
17#include "RPA_LRI.h"
21
22#if defined(__GLIBC__)
23#include <malloc.h>
24#endif
25
26namespace RpaLriDetail
27{
28inline void trim_malloc_cache()
29{
30#if defined(__GLIBC__)
31 malloc_trim(0);
32#endif
33}
34}
35
36template <typename T, typename Tdata>
38 const MPI_Comm& mpi_comm_in,
40 const elecstate::ElecState* pelec,
41 const K_Vectors& kv,
42 const LCAO_Orbitals& orb,
43 const Parallel_Orbitals& parav,
44 const psi::Psi<T>& psi)
45{
46 ModuleBase::TITLE("RPA_LRI", "postSCF");
47 ModuleBase::timer::start("RPA_LRI", "postSCF");
48
49 this->cal_postSCF_exx(dm, mpi_comm_in, ucell, kv, orb);
50 this->init(mpi_comm_in, kv, orb.cutoffs());
51 this->out_bands(pelec);
52 this->out_eigen_vector(parav, psi);
53 this->out_struc(ucell);
54
55 std::cout << "rpa_pca_threshold: " << this->info.pca_threshold << std::endl;
56 std::cout << "rpa_ccp_rmesh_times: " << this->info.ccp_rmesh_times << std::endl;
57 std::cout << "rpa_lcao_exx(Ha): " << std::fixed << std::setprecision(15) << exx_cut_coulomb->Eexx / 2.0 << std::endl;
58
59 std::cout << "etxc(Ha): " << std::fixed << std::setprecision(15) << pelec->f_en.etxc / 2.0 << std::endl;
60 std::cout << "etot(Ha): " << std::fixed << std::setprecision(15) << pelec->f_en.etot / 2.0 << std::endl;
61 std::cout << "Etot_without_rpa(Ha): " << std::fixed << std::setprecision(15)
62 << (pelec->f_en.etot - pelec->f_en.etxc + exx_cut_coulomb->Eexx) / 2.0 << std::endl;
63 delete exx_cut_coulomb;
64 exx_cut_coulomb = nullptr;
66
67 if (GlobalC::exx_info.info_ri.shrink_abfs_pca_thr >= 0.0)
68 {
69 cal_large_Cs(ucell, orb, kv);
70 cal_abfs_overlap(ucell, orb, kv);
72 }
73 this->output_ewald_coulomb(ucell, kv, orb);
74
75 ModuleBase::timer::end("RPA_LRI", "postSCF");
76}
77
78template <typename T, typename Tdata>
79void RPA_LRI<T, Tdata>::init(const MPI_Comm& mpi_comm_in, const K_Vectors& kv_in, const std::vector<double>& orb_cutoff)
80{
81 ModuleBase::TITLE("RPA_LRI", "init");
82 ModuleBase::timer::start("RPA_LRI", "init");
83 this->mpi_comm = mpi_comm_in;
84 this->orb_cutoff_ = orb_cutoff;
85 this->lcaos = exx_cut_coulomb->lcaos;
86 this->p_kv = &kv_in;
87 this->MGT = exx_cut_coulomb->MGT;
88
89 if (GlobalC::exx_info.info_ri.shrink_abfs_pca_thr >= 0.0)
90 {
91 this->abfs_shrink = exx_cut_coulomb->abfs;
92 }
93 else
94 {
95 this->abfs = exx_cut_coulomb->abfs;
96 }
97 // this->cv = std::move(exx_lri_rpa.cv);
98 // exx_lri_rpa.cv = exx_lri_rpa.cv;
99 ModuleBase::timer::end("RPA_LRI", "init");
100}
101
102template <typename T, typename Tdata>
104 const MPI_Comm& mpi_comm_in,
105 const UnitCell& ucell,
106 const K_Vectors& kv,
107 const LCAO_Orbitals& orb)
108{
109 ModuleBase::TITLE("RPA_LRI", "cal_postSCF_exx");
110 ModuleBase::timer::start("RPA_LRI", "cal_postSCF_exx");
111
112 this->mpi_comm = mpi_comm_in;
113 this->p_kv = &kv;
114 this->orb_cutoff_ = orb.cutoffs();
115
116 Mix_DMk_2D mix_DMk_2D;
117 bool exx_spacegroup_symmetry = (PARAM.inp.nspin < 4 && ModuleSymmetry::Symmetry::symm_flag == 1);
118 if (exx_spacegroup_symmetry)
119 {mix_DMk_2D.set_nks(kv.get_nkstot_full() * (PARAM.inp.nspin == 2 ? 2 : 1), PARAM.globalv.gamma_only_local);}
120 else
121 {mix_DMk_2D.set_nks(kv.get_nks(), PARAM.globalv.gamma_only_local);}
122
123 mix_DMk_2D.set_mixing(nullptr);
125 if (exx_spacegroup_symmetry)
126 {
127 const std::array<Tcell, Ndim> period = RI_Util::get_Born_vonKarmen_period(kv);
128 const auto& Rs = RI_Util::get_Born_von_Karmen_cells(period);
129 symrot.find_irreducible_sector(ucell.symm, ucell.atoms, ucell.st, Rs, period, ucell.lat);
130 // set Lmax of the rotation matrices to max(l_ao, l_abf), to support rotation under ABF
131 symrot.set_abfs_Lmax(GlobalC::exx_info.info_ri.abfs_Lmax);
132 symrot.cal_Ms(kv, ucell, *dm.get_paraV_pointer());
133 // output Ts (symrot_R.txt) and Ms (symrot_k.txt)
134 ModuleSymmetry::print_symrot_info_R(symrot, ucell.symm, ucell.lmax, Rs);
135 ModuleSymmetry::print_symrot_info_k(symrot, kv, ucell);
136 mix_DMk_2D.mix(symrot.restore_dm(kv, dm.get_DMK_vector(), *dm.get_paraV_pointer()), true);
137 }
138 else { mix_DMk_2D.mix(dm.get_DMK_vector(), true); }
139
140 const std::vector<std::map<TA, std::map<TAC, RI::Tensor<Tdata>>>>
142 ? RI_2D_Comm::split_m2D_ktoR<Tdata>(ucell,kv, mix_DMk_2D.get_DMk_gamma_out(), *dm.get_paraV_pointer(), PARAM.inp.nspin)
143 : RI_2D_Comm::split_m2D_ktoR<Tdata>(ucell,kv, mix_DMk_2D.get_DMk_k_out(), *dm.get_paraV_pointer(), PARAM.inp.nspin, exx_spacegroup_symmetry);
144
145 // set parameters for bare Coulomb potential
146 GlobalC::exx_info.info_global.ccp_type = Conv_Coulomb_Pot_K::Ccp_Type::Hf; // not used now, Hf/Ccp -> singularity_correction, see conv_coulomb_pot_k.cpp
148 // reserve exx_ccp_rmesh_times to calculate full Coulomb
149 this->ccp_rmesh_times_ewald = GlobalC::exx_info.info_ri.ccp_rmesh_times;
150 // rpa=1 set
151 // GlobalC::exx_info.info_ri.ccp_rmesh_times=rpa_ccp_rmesh_times
152 // Using this->info.ccp_rmesh_times to calculate cut Coulomb this->Vs_period
154 if (!exx_cut_coulomb)
155 exx_cut_coulomb = new Exx_LRI<double>(GlobalC::exx_info.info_ri);
156
157 if (GlobalC::exx_info.info_ri.shrink_abfs_pca_thr >= 0.0)
158 {
159 this->lcaos = Exx_Abfs::Construct_Orbs::change_orbs(orb, this->info.kmesh_times);
160 const std::vector<std::vector<std::vector<Numerical_Orbital_Lm>>> abfs_same_atom
162 orb,
163 this->lcaos,
164 this->info.kmesh_times,
165 this->info.shrink_abfs_pca_thr);
166 if (this->info.files_shrink_abfs.empty())
167 {
168 this->abfs_shrink = abfs_same_atom;
169 }
170 else
171 {
172 this->abfs_shrink = Exx_Abfs::IO::construct_abfs(abfs_same_atom,
173 orb,
174 this->info.files_shrink_abfs,
175 this->info.kmesh_times);
176 }
178 exx_cut_coulomb->init_spencer(mpi_comm_in, ucell, kv, orb, abfs_shrink);
179 }
180 else
181 exx_cut_coulomb->init_spencer(mpi_comm_in, ucell, kv, orb);
182 // cal C and V for exx
183 this->output_cut_coulomb_cs(ucell, exx_cut_coulomb);
184 // cal CVCD
185 if (exx_spacegroup_symmetry && PARAM.inp.exx_symmetry_realspace)
186 {
187 exx_cut_coulomb->cal_exx_elec(Ds, ucell, *dm.get_paraV_pointer(), &symrot);
188 }
189 else
190 {
191 exx_cut_coulomb->cal_exx_elec(Ds, ucell, *dm.get_paraV_pointer());
192 }
193 // cout<<"postSCF_Eexx: "<<exx_lri_rpa.Eexx<<endl;
194 ModuleBase::timer::end("RPA_LRI", "cal_postSCF_exx");
195}
196
197// if use shrink, output Coulomb and Cs_data in small abfs
198// otherwise, output in normal abfs
199template <typename T, typename Tdata>
201{
202 ModuleBase::TITLE("RPA_LRI", "output_cut_coulomb_cs");
203 ModuleBase::timer::start("RPA_LRI", "output_cut_coulomb_cs");
204
205 std::map<TA, std::map<TAC, RI::Tensor<Tdata>>> Vs_cut_IJR;
206 std::map<TA, std::map<TAC, RI::Tensor<Tdata>>> Cs;
207 std::map<TA, std::map<TAC, RI::Tensor<Tdata>>> tmp;
208 std::cout << "Use rpa_ccp_rmesh_times=" << this->info.ccp_rmesh_times << " to calculate cut Coulomb" << std::endl;
209 // Shrink_ABFS_ORBITAL cannot exceed this angular momentum of MGT
210 exx_lri_rpa->cal_cut_coulomb_cs(Vs_cut_IJR, Cs, ucell, PARAM.inp.out_ri_cv);
211 // MPI: {ia0, {ia1, R}} to {ia0, ia1}
212 std::vector<TA> atoms(ucell.nat);
213 for (int iat = 0; iat < ucell.nat; ++iat)
214 atoms[iat] = iat;
215 const std::array<Tcell, Ndim> period_Vs
216 = LRI_CV_Tools::cal_latvec_range<Tcell>(1 + this->info.ccp_rmesh_times, ucell, this->orb_cutoff_);
217 const std::pair<std::vector<TA>, std::vector<std::vector<std::pair<TA, TC>>>> list_As_Vs_atoms
218 = RI::Distribute_Equally::distribute_atoms(this->mpi_comm, atoms, period_Vs, 2, false);
219 const auto list_A0_pair_R = list_As_Vs_atoms.first;
220 const auto list_A1_pair_R = list_As_Vs_atoms.second[0];
221 std::set<TA> atoms00;
222 std::set<TA> atoms01;
223 for (const auto& I: list_A0_pair_R)
224 {
225 atoms00.insert(I);
226 }
227 for (const auto& JR: list_A1_pair_R)
228 {
229 atoms01.insert(JR.first);
230 }
231 std::map<TA, std::map<TAC, RI::Tensor<Tdata>>> Vs_cut_IJ
232 = RI_2D_Comm::comm_map2_first(this->mpi_comm, Vs_cut_IJR, atoms00, atoms01);
233 Vs_cut_IJR.clear();
234 const std::array<Tcell, Ndim> period = {p_kv->nmp[0], p_kv->nmp[1], p_kv->nmp[2]};
235 this->Vs_period = RI::RI_Tools::cal_period(Vs_cut_IJ, period);
236 this->out_coulomb_k(ucell, this->Vs_period, "coulomb_cut_", exx_lri_rpa);
237 Vs_period.clear();
238 Vs_period.swap(tmp);
239
240 this->Cs_period = RI::RI_Tools::cal_period(Cs, period);
241 this->Cs_period = exx_lri_rpa->exx_lri.post_2D.set_tensors_map2(this->Cs_period);
242
243 if (GlobalC::exx_info.info_ri.shrink_abfs_pca_thr >= 0.0)
244 this->out_Cs(ucell, this->Cs_period, "Cs_shrinked_data_");
245 else
246 this->out_Cs(ucell, this->Cs_period, "Cs_data_");
247 Cs_period.clear();
248 Cs_period.swap(tmp);
249
250 ModuleBase::timer::end("RPA_LRI", "output_cut_coulomb_cs");
251}
252
253template <typename T, typename Tdata>
255{
256 ModuleBase::TITLE("RPA_LRI", "output_ewald_coulomb");
257 ModuleBase::timer::start("RPA_LRI", "output_ewald_coulomb");
258
259 GlobalC::exx_info.info_ri.ccp_rmesh_times = this->ccp_rmesh_times_ewald;
260 if (!exx_full_coulomb)
261 exx_full_coulomb = new Exx_LRI<double>(GlobalC::exx_info.info_ri);
262
263 if (GlobalC::exx_info.info_ri.shrink_abfs_pca_thr >= 0.0)
264 exx_full_coulomb->init(mpi_comm, ucell, kv, orb, this->abfs_shrink);
265 else
266 exx_full_coulomb->init(mpi_comm, ucell, kv, orb, this->abfs);
267 std::map<TA, std::map<TAC, RI::Tensor<Tdata>>> Vs_full_IJR;
268 std::map<TA, std::map<TAC, RI::Tensor<Tdata>>> Cs;
269 std::map<TA, std::map<TAC, RI::Tensor<Tdata>>> tmp;
270 exx_full_coulomb->cal_ewald_coulomb(Vs_full_IJR, Cs, ucell, PARAM.inp.out_ri_cv);
271 // MPI: {ia0, {ia1, R}} to {ia0, ia1}
272 std::vector<TA> atoms(ucell.nat);
273 for (int iat = 0; iat < ucell.nat; ++iat)
274 atoms[iat] = iat;
275 const std::array<Tcell, Ndim> period_Vs
276 = LRI_CV_Tools::cal_latvec_range<Tcell>(1 + this->ccp_rmesh_times_ewald, ucell, this->orb_cutoff_);
277 const std::pair<std::vector<TA>, std::vector<std::vector<std::pair<TA, TC>>>> list_As_Vs_atoms
278 = RI::Distribute_Equally::distribute_atoms(mpi_comm, atoms, period_Vs, 2, false);
279 const auto list_A0_pair_R = list_As_Vs_atoms.first;
280 const auto list_A1_pair_R = list_As_Vs_atoms.second[0];
281 std::set<TA> atoms00;
282 std::set<TA> atoms01;
283 for (const auto& I: list_A0_pair_R)
284 {
285 atoms00.insert(I);
286 }
287 for (const auto& JR: list_A1_pair_R)
288 {
289 atoms01.insert(JR.first);
290 }
291 std::map<TA, std::map<TAC, RI::Tensor<Tdata>>> Vs_full_IJ
292 = RI_2D_Comm::comm_map2_first(mpi_comm, Vs_full_IJR, atoms00, atoms01);
293 Vs_full_IJR.clear();
294
295 const std::array<Tcell, Ndim> period = {p_kv->nmp[0], p_kv->nmp[1], p_kv->nmp[2]};
296 this->Vs_period = RI::RI_Tools::cal_period(Vs_full_IJ, period);
297 this->out_coulomb_k(ucell, this->Vs_period, "coulomb_mat_", exx_full_coulomb);
298 Vs_period.clear();
299 Vs_period.swap(tmp);
300 Cs.clear();
301 Cs.swap(tmp);
302
303 delete exx_full_coulomb;
304 exx_full_coulomb = nullptr;
306
307 ModuleBase::timer::end("RPA_LRI", "output_ewald_coulomb");
308}
309
310template <typename T, typename Tdata>
311void RPA_LRI<T, Tdata>::cal_large_Cs(const UnitCell& ucell, const LCAO_Orbitals& orb, const K_Vectors& kv)
312{
313 ModuleBase::TITLE("RPA_LRI", "cal_large_Cs");
314 ModuleBase::timer::start("RPA_LRI", "cal_large_Cs");
315 if (!exx_cut_coulomb)
316 exx_cut_coulomb = new Exx_LRI<double>(GlobalC::exx_info.info_ri);
317 exx_cut_coulomb->init_spencer(this->mpi_comm, ucell, kv, orb);
318 ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "exx_cut_coulomb->init");
319 this->abfs = exx_cut_coulomb->abfs;
320 this->MGT = exx_cut_coulomb->MGT;
321 std::vector<TA> atoms(ucell.nat);
322 for (int iat = 0; iat < ucell.nat; ++iat)
323 {
324 atoms[iat] = iat;
325 }
326 std::map<TA, TatomR> atoms_pos;
327 for (int iat = 0; iat < ucell.nat; ++iat)
328 atoms_pos[iat] = RI_Util::Vector3_to_array3(ucell.atoms[ucell.iat2it[iat]].tau[ucell.iat2ia[iat]]);
329 const std::array<TatomR, Ndim> latvec = {RI_Util::Vector3_to_array3(ucell.a1),
332 const std::array<Tcell, Ndim> period = {p_kv->nmp[0], p_kv->nmp[1], p_kv->nmp[2]};
333 this->exx_cut_coulomb->exx_lri.set_parallel(this->mpi_comm, atoms_pos, latvec, period);
334 auto center2_obj_it = this->exx_cut_coulomb->exx_objs.find(Conv_Coulomb_Pot_K::Coulomb_Method::Center2);
335 if (center2_obj_it == this->exx_cut_coulomb->exx_objs.end())
336 {
337 throw std::invalid_argument("RPA_LRI::cal_large_Cs expected a Center2 cut-Coulomb object after init_spencer.");
338 }
339 center2_obj_it->second.cv.set_orbitals(ucell,
340 orb,
341 this->lcaos,
342 exx_cut_coulomb->abfs,
343 center2_obj_it->second.abfs_ccp,
344 this->info.kmesh_times,
345 this->MGT, // get MGT from exx_cut_coulomb and used in `cal_abfs_overlap`
346 true);
347
348 const std::array<Tcell, Ndim> period_Vs
349 = LRI_CV_Tools::cal_latvec_range<Tcell>(1 + this->info.ccp_rmesh_times, ucell, orb_cutoff_);
350 std::pair<std::vector<TA>, std::vector<std::vector<std::pair<TA, std::array<Tcell, Ndim>>>>> list_As_Vs
351 = RI::Distribute_Equally::distribute_atoms_periods(this->mpi_comm, atoms, period_Vs, 2, false);
353 std::map<TA, std::map<TAC, RI::Tensor<Tdata>>> Vs_cut_IJR
354 = center2_obj_it->second.cv.cal_Vs(ucell, list_As_Vs.first, list_As_Vs.second[0], {{"writable_Vws", true}});
356
357 const std::array<Tcell, Ndim> period_Cs = LRI_CV_Tools::cal_latvec_range<Tcell>(2, ucell, orb_cutoff_);
358 const std::pair<std::vector<TA>, std::vector<std::vector<std::pair<TA, std::array<Tcell, Ndim>>>>> list_As_Cs
359 = RI::Distribute_Equally::distribute_atoms_periods(this->mpi_comm, atoms, period_Cs, 2, false);
360 std::pair<std::map<TA, std::map<TAC, RI::Tensor<Tdata>>>,
361 std::map<TA, std::map<TAC, std::array<RI::Tensor<Tdata>, 3>>>>
362 Cs_dCs = center2_obj_it->second.cv.cal_Cs_dCs(ucell,
363 list_As_Cs.first,
364 list_As_Cs.second[0],
365 {{"cal_dC", false},
366 {"writable_Cws", true},
367 {"writable_dCws", true},
368 {"writable_Vws", false},
369 {"writable_dVws", false}});
371
372 std::map<TA, std::map<TAC, RI::Tensor<Tdata>>> tmp;
374 {
375 this->Vs_period = RI::RI_Tools::cal_period(Vs_cut_IJR, period);
376 Vs_cut_IJR.clear();
378 // MPI: {ia0, {ia1, R}} to {ia0, ia1}
379 const std::pair<std::vector<TA>, std::vector<std::vector<std::pair<TA, TC>>>> list_As_Vs_atoms
380 = RI::Distribute_Equally::distribute_atoms(this->mpi_comm, atoms, period_Vs, 2, false);
381 const auto list_A0_pair_R = list_As_Vs_atoms.first;
382 const auto list_A1_pair_R = list_As_Vs_atoms.second[0];
383 std::set<TA> atoms00;
384 std::set<TA> atoms01;
385 for (const auto& I: list_A0_pair_R)
386 {
387 atoms00.insert(I);
388 }
389 for (const auto& JR: list_A1_pair_R)
390 {
391 atoms01.insert(JR.first);
392 }
393
394 this->Vs_period = RI_2D_Comm::comm_map2_first(this->mpi_comm, this->Vs_period, atoms00, atoms01);
396
397 this->out_coulomb_k(ucell, this->Vs_period, "coulomb_unshrinked_cut_", exx_cut_coulomb);
399 this->Vs_period.clear();
400 this->Vs_period.swap(tmp);
401 }
402
403 std::map<TA, std::map<TAC, RI::Tensor<Tdata>>>& Cs = std::get<0>(Cs_dCs);
404 this->Cs_period = RI::RI_Tools::cal_period(Cs, period);
405 this->Cs_period = exx_cut_coulomb->exx_lri.post_2D.set_tensors_map2(this->Cs_period);
406 this->out_Cs(ucell, this->Cs_period, "Cs_data_");
408 this->Cs_period.clear();
409 this->Cs_period.swap(tmp);
410 delete exx_cut_coulomb;
411 exx_cut_coulomb = nullptr;
413
414 ModuleBase::timer::end("RPA_LRI", "cal_large_Cs");
415}
416
417template <typename T, typename Tdata>
419{
420 ModuleBase::TITLE("DFT_RPA_interface", "cal_abfs_overlap");
421 const auto& abfs_s = this->abfs_shrink;
422
423 // <smaller abfs|smaller abfs>
424 Matrix_Orbs11 m_abfs_abfs;
425 // <smaller abfs|larger abfs>
426 Matrix_Orbs11 m_abfs_abf;
427
428 m_abfs_abf.MGT = this->MGT;
429 m_abfs_abf.init(abfs_s, this->abfs, ucell, orb, this->info.kmesh_times);
430 m_abfs_abf.init_radial_table();
431
432 m_abfs_abfs.MGT = this->MGT;
433 m_abfs_abfs.init(abfs_s, abfs_s, ucell, orb, this->info.kmesh_times);
434 m_abfs_abfs.init_radial_table();
435 // get Rlist
436 const std::array<Tcell, Ndim> period = RI_Util::get_Born_vonKarmen_period(kv);
437 const auto R_period = RI_Util::get_Born_von_Karmen_cells(period);
438 std::map<TA, std::map<TAC, RI::Tensor<Tdata>>> overlap_abfs_abfs;
439 std::map<TA, std::map<TAC, RI::Tensor<Tdata>>> overlap_abfs_abf;
440
441 // index of smaller abfs
445 // index of larger abfs
449
450 auto orb_cutoff_ = orb.cutoffs();
451 const std::array<Tcell, Ndim> period_Vs = LRI_CV_Tools::cal_latvec_range<Tcell>(2, ucell, orb_cutoff_);
452 std::vector<TA> atoms(ucell.nat);
453 for (int iat = 0; iat < ucell.nat; ++iat)
454 atoms[iat] = iat;
455 const std::pair<std::vector<TA>, std::vector<std::vector<std::pair<TA, std::array<Tcell, Ndim>>>>> list_As_Vs
456 = RI::Distribute_Equally::distribute_atoms_periods(this->mpi_comm, atoms, period_Vs, 2, false);
457
458// Huanjing Gong debug
459// std::stringstream ss;
460// ss << "IJR_" << GlobalV::MY_RANK << ".txt";
461// std::ofstream ofs;
462// ofs.open(ss.str().c_str(), std::ios::out);
463// for (size_t iA = 0; iA < list_As_Vs.first.size(); ++iA)
464// {
465// const auto& A = list_As_Vs.first[iA];
466// for (const auto& BR: list_As_Vs.second[0])
467// {
468// const auto& B = BR.first;
469// const auto& R = BR.second;
470// ofs << "ABR: " << A << B << "," << R.at(0) << R.at(1) << R.at(2) << std::endl;
471// }
472// }
473// ofs.close();
474#pragma omp parallel
475 {
476 using LocalMapType = std::map<std::pair<int, std::array<int, 3>>, RI::Tensor<double>>;
477 std::map<int, LocalMapType> overlap_abfs_abfs_local;
478 std::map<int, LocalMapType> overlap_abfs_abf_local;
479
480#pragma omp for schedule(dynamic) nowait
481 for (size_t iA = 0; iA < list_As_Vs.first.size(); ++iA)
482 {
483 const auto& A = list_As_Vs.first[iA];
484 for (const auto& BR: list_As_Vs.second[0])
485 {
486 const auto& B = BR.first;
487 const auto& R = BR.second;
488
489 const size_t TA = ucell.iat2it[A];
490 const size_t IA = ucell.iat2ia[A];
491 const auto& tauA = ucell.atoms[TA].tau[IA];
492 const size_t TB = ucell.iat2it[B];
493 const size_t IB = ucell.iat2ia[B];
494 const auto& tauB = ucell.atoms[TB].tau[IB];
495
496 const ModuleBase::Vector3<double> tauB_shift
497 = tauB + (RI_Util::array3_to_Vector3(R) * ucell.latvec);
498 const ModuleBase::Vector3<double> tau_delta = tauB_shift - tauA;
499 static const ModuleBase::Vector3<double> tau0(0.0, 0.0, 0.0);
500
501 auto& local_abfs_abfs = overlap_abfs_abfs_local[A];
502 local_abfs_abfs[{B, R}]
503 = m_abfs_abfs.template cal_overlap_matrix<double>(TA,
504 TB,
505 tau0,
506 tau_delta,
507 index_abfs_s,
508 index_abfs_s,
510
511 auto& local_abfs_abf = overlap_abfs_abf_local[A];
512 local_abfs_abf[{B, R}]
513 = m_abfs_abf.template cal_overlap_matrix<double>(TA,
514 TB,
515 tau0,
516 tau_delta,
517 index_abfs_s,
518 index_abfs,
520 }
521 }
522
523#pragma omp critical(RPA_LRI_merge)
524 {
525 for (auto& aPair: overlap_abfs_abfs_local)
526 {
527 auto& aKey = aPair.first;
528 auto& aSubMap = aPair.second;
529 for (auto& subPair: aSubMap)
530 {
531 auto& key = subPair.first;
532 auto& value = subPair.second;
533 overlap_abfs_abfs[aKey][key] = std::move(value);
534 }
535 }
536 for (auto& aPair: overlap_abfs_abf_local)
537 {
538 auto& aKey = aPair.first;
539 auto& aSubMap = aPair.second;
540 for (auto& subPair: aSubMap)
541 {
542 auto& key = subPair.first;
543 auto& value = subPair.second;
544 overlap_abfs_abf[aKey][key] = std::move(value);
545 }
546 }
547 }
548 }
549 // MPI: {ia0, {ia1, R}} to {ia0, ia1}
550 const std::array<Tcell, Ndim> period_Vs_IJ = LRI_CV_Tools::cal_latvec_range<Tcell>(2, ucell, orb_cutoff_);
551 const std::pair<std::vector<TA>, std::vector<std::vector<std::pair<TA, TC>>>> list_As_Vs_atoms
552 = RI::Distribute_Equally::distribute_atoms(this->mpi_comm, atoms, period_Vs, 2, false);
553 const auto list_A0_pair_R = list_As_Vs_atoms.first;
554 const auto list_A1_pair_R = list_As_Vs_atoms.second[0];
555 std::set<TA> atoms00;
556 std::set<TA> atoms01;
557 for (const auto& I: list_A0_pair_R)
558 {
559 atoms00.insert(I);
560 }
561 for (const auto& JR: list_A1_pair_R)
562 {
563 atoms01.insert(JR.first);
564 }
565 std::map<TA, std::map<TAC, RI::Tensor<Tdata>>> overlap_abfs_abfs_IJ
566 = RI_2D_Comm::comm_map2_first(mpi_comm, overlap_abfs_abfs, atoms00, atoms01);
567 overlap_abfs_abfs.clear();
568 std::map<TA, std::map<TAC, RI::Tensor<Tdata>>> overlap_abfs_abf_IJ
569 = RI_2D_Comm::comm_map2_first(mpi_comm, overlap_abfs_abf, atoms00, atoms01);
570 overlap_abfs_abf.clear();
571
572 out_abfs_overlap(ucell, overlap_abfs_abfs_IJ, overlap_abfs_abf_IJ, "shrink_sinvS_", index_abfs_s, index_abfs);
573}
574
575template <typename T, typename Tdata>
577 std::map<TA, std::map<TAC, RI::Tensor<Tdata>>>& overlap_abfs_abfs,
578 std::map<TA, std::map<TAC, RI::Tensor<Tdata>>>& overlap_abfs_abf,
579 std::string filename,
582{
583 ModuleBase::TITLE("RPA_LRI", "out_abfs_overlap");
584 ModuleBase::timer::start("RPA_LRI", "out_abfs_overlap");
585 const double threshold = 1e-15;
586 const auto format = std::scientific;
587 int prec = 15;
588
589 int all_mu_s = 0;
590 int all_mu = 0;
591 std::vector<int> mu_s_shift(ucell.nat);
592 std::vector<int> mu_shift(ucell.nat);
593 for (int I = 0; I != ucell.nat; I++)
594 {
595 mu_s_shift[I] = all_mu_s;
596 mu_shift[I] = all_mu;
597 all_mu_s += index_abfs_s[ucell.iat2it[I]].count_size;
598 all_mu += index_abfs[ucell.iat2it[I]].count_size;
599 }
600 const int nks_tot = PARAM.inp.nspin == 2 ? (int)p_kv->get_nks() / 2 : p_kv->get_nks();
601 std::stringstream ss;
602 ss << filename << GlobalV::MY_RANK << ".txt";
603
604 std::ofstream ofs;
605 ofs.open(ss.str().c_str(), std::ios::out);
606
607 ofs << nks_tot << std::endl;
608
609 // Fourier of ss(R->k), s(R->k)
610 std::map<TA, std::map<TAq, RI::Tensor<std::complex<double>>>> olp_q_ss;
611 std::map<TA, std::map<TAq, RI::Tensor<std::complex<double>>>> olp_q_s;
612 for (int ik = 0; ik != nks_tot; ik++)
613 {
614 for (auto& Ip: overlap_abfs_abfs)
615 {
616 auto I = Ip.first;
617 for (auto& JPp: Ip.second)
618 {
619 auto J = JPp.first.first;
620 auto R = JPp.first.second;
621 auto q = RI_Util::Vector3_to_array3(p_kv->kvec_c[ik]);
622 RI::Tensor<std::complex<double>> tmp_olp_ss
623 = RI::Global_Func::convert<std::complex<double>>(JPp.second);
624 RI::Tensor<std::complex<double>> tmp_olp_s
625 = RI::Global_Func::convert<std::complex<double>>(overlap_abfs_abf[I][{J, R}]);
626 if (olp_q_ss[I][{J, q}].empty())
627 {
628 olp_q_ss[I][{J, q}] = RI::Tensor<std::complex<double>>({tmp_olp_ss.shape[0], tmp_olp_ss.shape[1]});
629 olp_q_s[I][{J, q}] = RI::Tensor<std::complex<double>>({tmp_olp_s.shape[0], tmp_olp_s.shape[1]});
630 }
631 const double arg = 1 * (p_kv->kvec_c[ik] * (RI_Util::array3_to_Vector3(R) * ucell.latvec))
632 * ModuleBase::TWO_PI; // latvec
633 const std::complex<double> kphase = std::complex<double>(cos(arg), sin(arg));
634
635 olp_q_ss[I][{J, q}] = olp_q_ss[I][{J, q}] + tmp_olp_ss * kphase;
636 olp_q_s[I][{J, q}] = olp_q_s[I][{J, q}] + tmp_olp_s * kphase;
637 }
638 }
639 }
640 // for multi-mpi
641 for (int I = 0; I != ucell.nat; I++)
642 {
643 for (int J = 0; J != ucell.nat; J++)
644 {
645 for (int ik = 0; ik != nks_tot; ik++)
646 {
647 auto q = RI_Util::Vector3_to_array3(p_kv->kvec_c[ik]);
648 if (olp_q_ss[I][{J, q}].empty())
649 {
650 auto mu = index_abfs_s[ucell.iat2it[I]].count_size;
651 auto nu = index_abfs_s[ucell.iat2it[J]].count_size;
652 olp_q_ss[I][{J, q}] = RI::Tensor<std::complex<double>>({mu, nu});
653 }
654 if (olp_q_s[I][{J, q}].empty())
655 {
656 auto mu = index_abfs_s[ucell.iat2it[I]].count_size;
657 auto nu = index_abfs[ucell.iat2it[J]].count_size;
658 olp_q_s[I][{J, q}] = RI::Tensor<std::complex<double>>({mu, nu});
659 }
660 for (int ir = 0; ir < olp_q_ss[I][{J, q}].shape[0]; ir++)
661 {
662 for (int ic = 0; ic < olp_q_ss[I][{J, q}].shape[1]; ic++)
663 {
664 Parallel_Reduce::reduce_all<std::complex<double>>(olp_q_ss[I][{J, q}](ir, ic));
665 }
666 for (int ic = 0; ic < olp_q_s[I][{J, q}].shape[1]; ic++)
667 {
668 Parallel_Reduce::reduce_all<std::complex<double>>(olp_q_s[I][{J, q}](ir, ic));
669 }
670 }
671 }
672 }
673 }
674
675 // out_ri_tensor("olp_ss.dat", olp_q_ss, 0.);
676 // Inverse of overlap(q)
677 inverse_olp(ucell, olp_q_ss, index_abfs_s);
678 // out_ri_tensor("olp_ss_inv.dat", olp_q_ss, 0.);
679 // out_ri_tensor("olp_s.dat", olp_q_s, 0.);
680 for (auto& Ip: overlap_abfs_abf)
681 {
682 auto I = Ip.first;
683 size_t mu_num_s = index_abfs_s[ucell.iat2it[I]].count_size;
684 size_t mu_num = index_abfs[ucell.iat2it[I]].count_size;
685
686 for (int ik = 0; ik != nks_tot; ik++)
687 {
688 std::map<size_t, RI::Tensor<std::complex<double>>> sinvS;
689 for (auto& JPp: Ip.second)
690 {
691 auto J = JPp.first.first;
692 auto R = JPp.first.second;
693 if (sinvS[J].empty())
694 {
695 sinvS[J] = RI::Tensor<std::complex<double>>(
696 {overlap_abfs_abfs[I][{J, R}].shape[0], overlap_abfs_abf[I][{J, R}].shape[1]});
697 }
698 }
699 for (const auto& pair: sinvS)
700 {
701 auto J = pair.first;
702 auto q = RI_Util::Vector3_to_array3(p_kv->kvec_c[ik]);
703 for (int K = 0; K != ucell.nat; K++)
704 {
705 sinvS[J] += olp_q_ss.at(I).at({K, q}) * olp_q_s.at(K).at({J, q});
706 }
707 }
708 for (auto& iJU: sinvS)
709 {
710 auto iJ = iJU.first;
711 auto& vq_J = iJU.second;
712 size_t nu_num = index_abfs[ucell.iat2it[iJ]].count_size;
713 ofs << all_mu_s << " " << all_mu << " " << mu_s_shift[I] + 1 << " " << mu_s_shift[I] + mu_num_s
714 << " " << mu_shift[iJ] + 1 << " " << mu_shift[iJ] + nu_num << std::endl;
715 ofs << ik + 1 << " " << p_kv->wk[ik] / 2.0 * PARAM.inp.nspin << std::endl;
716 for (int i = 0; i != vq_J.data->size(); i++)
717 {
718 // ofs << std::setw(25) << std::fixed << std::setprecision(15) << (*vq_J.data)[i].real()
719 // << std::setw(25) << std::fixed << std::setprecision(15) << (*vq_J.data)[i].imag() <<
720 // std::endl;
721 // if (fabs((*vq_J.data)[i].real()) > threshold || fabs((*vq_J.data)[i].imag()) > threshold)
722 ofs << std::showpoint << format << std::setprecision(prec) << (*vq_J.data)[i].real() << " "
723 << std::showpoint << format << std::setprecision(prec) << (*vq_J.data)[i].imag() << "\n";
724 // else
725 // ofs << std::showpoint << format << std::setprecision(prec) << 0.0 << " " << std::showpoint
726 // << format << std::setprecision(prec) << 0.0 << "\n";
727 }
728 }
729 }
730 }
731 ofs.close();
732 ModuleBase::timer::end("RPA_LRI", "out_abfs_overlap");
733}
734
735template <typename T, typename Tdata>
737 std::map<TA, std::map<TAq, RI::Tensor<std::complex<double>>>>& overlap_abfs_abfs,
739{
740 ModuleBase::TITLE("RPA_LRI", "inverse_olp");
741 ModuleBase::timer::start("RPA_LRI", "inverse_olp");
742 const int nks_tot = PARAM.inp.nspin == 2 ? (int)p_kv->get_nks() / 2 : p_kv->get_nks();
743 size_t all_mu_s = 0;
744 std::vector<int> mu_s_shift(ucell.nat);
745 for (int I = 0; I != ucell.nat; I++)
746 {
747 mu_s_shift[I] = all_mu_s;
748 all_mu_s += index_abfs_s[ucell.iat2it[I]].count_size;
749 }
750 RI::Tensor<std::complex<double>> olp_all = RI::Tensor<std::complex<double>>({all_mu_s, all_mu_s});
751 for (int ik = 0; ik < nks_tot; ik++)
752 {
753 for (auto& Ip: overlap_abfs_abfs)
754 {
755 auto I = Ip.first;
756 size_t mu_s_I = index_abfs_s[ucell.iat2it[I]].count_size;
757 for (auto& JPp: Ip.second)
758 {
759 auto J = JPp.first.first;
760 auto q = JPp.first.second;
761 if (q != RI_Util::Vector3_to_array3(p_kv->kvec_c[ik]))
762 continue;
763 // std::cout << "IJ: " << I << "," << J << std::endl;
764 auto mu_s_J = index_abfs_s[ucell.iat2it[J]].count_size;
765 for (int ir = 0; ir < mu_s_I; ir++)
766 {
767 for (int ic = 0; ic < mu_s_J; ic++)
768 {
769 olp_all(mu_s_shift[I] + ir, mu_s_shift[J] + ic) = JPp.second(ir, ic);
770 }
771 }
772 }
773 }
774 // for multi-mpi
775 // for (int ir = 0; ir < all_mu_s; ir++)
776 // {
777 // for (int ic = 0; ic < all_mu_s; ic++)
778 // {
779 // Parallel_Reduce::reduce_all<std::complex<double>>(olp_all(ir, ic));
780 // }
781 // }
782
783 // check Hermitian
784 for (int ir = 0; ir < all_mu_s; ir++)
785 {
786 for (int ic = ir; ic < all_mu_s; ic++)
787 {
788 auto delta = std::abs(olp_all(ir, ic) - std::conj(olp_all(ic, ir)));
789 if (delta > 1e-10)
790 {
791 std::cout << "Warning: olp_all is not Hermitian!" << std::endl;
792 std::cout << "ik,ir,ic: " << ik << "," << ir << "," << ic << std::endl;
793 std::cout << "delta(ir, ic): " << delta << std::endl;
794 }
795 }
796 }
797 // out_pure_ri_tensor("olp_all.dat", olp_all, 0.);
798 auto olp_inv = LRI_CV_Tools::cal_I(olp_all,
799 Inverse_Matrix<std::complex<double>>::Method::syev,
800 GlobalC::exx_info.info_ri.shrink_LU_inv_thr);
801 for (int ir = 0; ir < all_mu_s; ir++)
802 {
803 for (int ic = ir; ic < all_mu_s; ic++)
804 {
805 olp_inv(ic, ir) = std::conj(olp_inv(ir, ic));
806 }
807 }
808 // out_pure_ri_tensor("olp_inv.dat", olp_inv, 0.);
809 for (auto& Ip: overlap_abfs_abfs)
810 {
811 auto I = Ip.first;
812 size_t mu_s_I = index_abfs_s[ucell.iat2it[I]].count_size;
813 for (auto& JPp: Ip.second)
814 {
815 auto q = JPp.first.second;
816 if (q != RI_Util::Vector3_to_array3(p_kv->kvec_c[ik]))
817 continue;
818 auto J = JPp.first.first;
819 auto mu_s_J = index_abfs_s[ucell.iat2it[J]].count_size;
820
821 for (int ir = 0; ir < mu_s_I; ir++)
822 {
823 for (int ic = 0; ic < mu_s_J; ic++)
824 JPp.second(ir, ic) = olp_inv(mu_s_shift[I] + ir, mu_s_shift[J] + ic);
825 }
826 }
827 }
828 }
829 ModuleBase::timer::end("RPA_LRI", "inverse_olp");
830}
831
832// debug function
833// template <typename T, typename Tdata>
834// void RPA_LRI<T, Tdata>::out_pure_ri_tensor(const std::string fn,
835// RI::Tensor<std::complex<double>>& olp,
836// const double threshold)
837// {
838// std::ofstream fs;
839// auto format = std::scientific;
840// int prec = 15;
841// fs.open(fn);
842// int nr = olp.shape[0];
843// int nc = olp.shape[1];
844// size_t nnz = nr * nc;
845// fs << "%%MatrixMarket matrix coordinate complex general" << std::endl;
846// fs << "%" << std::endl;
847
848// fs << nr << " " << nc << " " << nnz << std::endl;
849
850// for (int j = 0; j < nc; j++)
851// {
852// for (int i = 0; i < nr; i++)
853// {
854// auto v = olp(i, j);
855// if (fabs(v.real()) > threshold || fabs(v.imag()) > threshold)
856// fs << i + 1 << " " << j + 1 << " " << std::showpoint << format << std::setprecision(prec) << v.real()
857// << " " << std::showpoint << format << std::setprecision(prec) << v.imag() << "\n";
858// }
859// }
860
861// fs.close();
862// }
863
864// template <typename T, typename Tdata>
865// void RPA_LRI<T, Tdata>::out_pure_ri_tensor(const std::string fn, RI::Tensor<double>& olp, const double threshold)
866// {
867// std::ofstream fs;
868// auto format = std::scientific;
869// int prec = 15;
870// fs.open(fn);
871// int nr = olp.shape[0];
872// int nc = olp.shape[1];
873// size_t nnz = nr * nc;
874// fs << "%%MatrixMarket matrix coordinate complex general" << std::endl;
875// fs << "%" << std::endl;
876
877// fs << nr << " " << nc << " " << nnz << std::endl;
878
879// for (int j = 0; j < nc; j++)
880// {
881// for (int i = 0; i < nr; i++)
882// {
883// auto v = olp(i, j);
884// if (fabs(v) > threshold)
885// fs << i + 1 << " " << j + 1 << " " << std::showpoint << format << std::setprecision(prec) << v << "\n";
886// }
887// }
888
889// fs.close();
890// }
891
892// template <typename T, typename Tdata>
893// void RPA_LRI<T, Tdata>::out_ri_tensor(const std::string fn,
894// std::map<TA, std::map<TAq, RI::Tensor<std::complex<double>>>>& olp,
895// const double threshold)
896// {
897// std::ofstream fs;
898// auto format = std::scientific;
899// int prec = 15;
900// fs.open(fn);
901// for (auto& IJq: olp)
902// {
903// int I = IJq.first;
904// for (auto& Jq: IJq.second)
905// {
906// int J = Jq.first.first;
907// auto q = Jq.first.second;
908// auto mat = Jq.second;
909// int nr = mat.shape[0];
910// int nc = mat.shape[1];
911// size_t nnz = nr * nc;
912// fs << "%%MatrixMarket matrix coordinate complex general" << std::endl;
913// fs << I << " " << J << " " << q.at(0) << " " << q.at(1) << " " << q.at(2) << std::endl;
914// fs << "%" << std::endl;
915
916// fs << nr << " " << nc << " " << nnz << std::endl;
917
918// for (int j = 0; j < nc; j++)
919// {
920// for (int i = 0; i < nr; i++)
921// {
922// auto v = mat(i, j);
923// if (fabs(v.real()) > threshold || fabs(v.imag()) > threshold)
924// fs << i + 1 << " " << j + 1 << " " << std::showpoint << format << std::setprecision(prec)
925// << v.real() << " " << std::showpoint << format << std::setprecision(prec) << v.imag()
926// << "\n";
927// }
928// }
929// }
930// }
931
932// fs.close();
933// }
934
935template <typename T, typename Tdata>
937{
938
939 ModuleBase::TITLE("DFT_RPA_interface", "out_eigen_vector");
940
941 const int nks_tot = PARAM.inp.nspin == 2 ? p_kv->get_nks() / 2 : p_kv->get_nks();
942 const int npsin_tmp = PARAM.inp.nspin == 2 ? 2 : 1;
943 const std::complex<double> zero(0.0, 0.0);
944
945 for (int ik = 0; ik < nks_tot; ik++)
946 {
947 std::stringstream ss;
948 ss << "KS_eigenvector_" << ik << ".dat";
949
950 std::ofstream ofs;
951 if (GlobalV::MY_RANK == 0)
952 {
953 ofs.open(ss.str().c_str(), std::ios::out);
954 }
955 std::vector<ModuleBase::ComplexMatrix> is_wfc_ib_iw(npsin_tmp);
956 for (int is = 0; is < npsin_tmp; is++)
957 {
958 is_wfc_ib_iw[is].create(PARAM.inp.nbands, PARAM.globalv.nlocal);
959 for (int ib_global = 0; ib_global < PARAM.inp.nbands; ++ib_global)
960 {
961 std::vector<std::complex<double>> wfc_iks(PARAM.globalv.nlocal, zero);
962
963 const int ib_local = parav.global2local_col(ib_global);
964
965 if (ib_local >= 0)
966 {
967 for (int ir = 0; ir < psi.get_nbasis(); ir++)
968 {
969 wfc_iks[parav.local2global_row(ir)] = psi(ik + nks_tot * is, ib_local, ir);
970 }
971 }
972
973 std::vector<std::complex<double>> tmp = wfc_iks;
974#ifdef __MPI
975 MPI_Allreduce(&tmp[0], &wfc_iks[0], PARAM.globalv.nlocal, MPI_DOUBLE_COMPLEX, MPI_SUM, MPI_COMM_WORLD);
976#endif
977 for (int iw = 0; iw < PARAM.globalv.nlocal; iw++)
978 {
979 is_wfc_ib_iw[is](ib_global, iw) = wfc_iks[iw];
980 }
981 } // ib
982 } // is
983 ofs << ik + 1 << std::endl;
984 for (int iw = 0; iw < PARAM.globalv.nlocal; iw++)
985 {
986 for (int ib = 0; ib < PARAM.inp.nbands; ib++)
987 {
988 for (int is = 0; is < npsin_tmp; is++)
989 {
990 ofs << std::setw(30) << std::fixed << std::setprecision(15) << is_wfc_ib_iw[is](ib, iw).real()
991 << std::setw(30) << std::fixed << std::setprecision(15) << is_wfc_ib_iw[is](ib, iw).imag()
992 << std::endl;
993 }
994 }
995 }
996 ofs.close();
997 } // ik
998 return;
999}
1000
1001template <typename T, typename Tdata>
1003{
1004 if (GlobalV::MY_RANK != 0)
1005 {
1006 return;
1007 }
1008 ModuleBase::TITLE("DFT_RPA_interface", "out_struc");
1009 double TWOPI_Bohr2A = ModuleBase::TWO_PI * ModuleBase::BOHR_TO_A;
1010 const int nks_tot = PARAM.inp.nspin == 2 ? (int)p_kv->get_nks() / 2 : p_kv->get_nks();
1012 ModuleBase::Matrix3 G_RPA = ucell.G * TWOPI_Bohr2A;
1013 std::stringstream ss;
1014 ss << "stru_out";
1015 std::ofstream ofs;
1016 ofs.open(ss.str().c_str(), std::ios::out);
1017 ofs << lat.e11 << std::setw(15) << lat.e12 << std::setw(15) << lat.e13 << std::endl;
1018 ofs << lat.e21 << std::setw(15) << lat.e22 << std::setw(15) << lat.e23 << std::endl;
1019 ofs << lat.e31 << std::setw(15) << lat.e32 << std::setw(15) << lat.e33 << std::endl;
1020
1021 ofs << G_RPA.e11 << std::setw(15) << G_RPA.e12 << std::setw(15) << G_RPA.e13 << std::endl;
1022 ofs << G_RPA.e21 << std::setw(15) << G_RPA.e22 << std::setw(15) << G_RPA.e23 << std::endl;
1023 ofs << G_RPA.e31 << std::setw(15) << G_RPA.e32 << std::setw(15) << G_RPA.e33 << std::endl;
1024
1025 ofs << ucell.nat << std::endl;
1026 std::string& Coordinate = ucell.Coordinate;
1027 bool direct = (Coordinate == "Direct");
1028 // Only consider Direct or Cartesian
1029 for (int it = 0; it < ucell.ntype; it++)
1030 {
1031 Atom* atom = &ucell.atoms[it];
1032 for (int ia = 0; ia < ucell.atoms[it].na; ia++)
1033 {
1034 const double& x = direct ? ucell.atoms[it].tau[ia].x * ucell.lat0
1035 : ucell.atoms[it].tau[ia].x;
1036 const double& y = direct ? ucell.atoms[it].tau[ia].y * ucell.lat0
1037 : ucell.atoms[it].tau[ia].y;
1038 const double& z = direct ? ucell.atoms[it].tau[ia].z * ucell.lat0
1039 : ucell.atoms[it].tau[ia].z;
1040 ofs << std::setw(15) << std::fixed << std::setprecision(9) << x << std::setw(15) << std::fixed
1041 << std::setprecision(9) << y << std::setw(15) << std::fixed << std::setprecision(9) << z
1042 << std::setw(15) << 1 << std::endl;
1043 }
1044 }
1045
1046 ofs << p_kv->nmp[0] << std::setw(6) << p_kv->nmp[1] << std::setw(6) << p_kv->nmp[2] << std::setw(6) << std::endl;
1047
1048 for (int ik = 0; ik != nks_tot; ik++)
1049 {
1050 ofs << std::setw(15) << std::fixed << std::setprecision(9) << p_kv->kvec_c[ik].x * TWOPI_Bohr2A << std::setw(15)
1051 << std::fixed << std::setprecision(9) << p_kv->kvec_c[ik].y * TWOPI_Bohr2A << std::setw(15) << std::fixed
1052 << std::setprecision(9) << p_kv->kvec_c[ik].z * TWOPI_Bohr2A << std::endl;
1053 }
1054 // added for BZ to IBZ (actually LibRPA interface only support BZ by 2025/03/30)
1055 if (PARAM.inp.symmetry == "-1")
1056 {
1057 for (int ik = 0; ik != nks_tot; ++ik)
1058 {
1059 ofs << (ik + 1) << std::endl;
1060 }
1061 }
1062 ofs.close();
1063 return;
1064}
1065
1066template <typename T, typename Tdata>
1068{
1069 ModuleBase::TITLE("DFT_RPA_interface", "out_bands");
1070 if (GlobalV::MY_RANK != 0)
1071 {
1072 return;
1073 }
1074 const int nks_tot = PARAM.inp.nspin == 2 ? (int)p_kv->get_nks() / 2 : p_kv->get_nks();
1075 const int nspin_tmp = PARAM.inp.nspin == 2 ? 2 : 1;
1076 std::stringstream ss;
1077 ss << "band_out";
1078 std::ofstream ofs;
1079 ofs.open(ss.str().c_str(), std::ios::out);
1080 ofs << nks_tot << std::endl;
1081 ofs << nspin_tmp << std::endl;
1082 ofs << PARAM.inp.nbands << std::endl;
1083 ofs << PARAM.globalv.nlocal << std::endl;
1084 ofs << (pelec->eferm.ef / 2.0) << std::endl;
1085
1086 for (int ik = 0; ik != nks_tot; ik++)
1087 {
1088 for (int is = 0; is != nspin_tmp; is++)
1089 {
1090 ofs << std::setw(6) << ik + 1 << std::setw(6) << is + 1 << std::endl;
1091 for (int ib = 0; ib != PARAM.inp.nbands; ib++)
1092 {
1093 ofs << std::setw(5) << ib + 1 << " " << std::setw(8) << pelec->wg(ik + is * nks_tot, ib) * nks_tot
1094 << std::setw(25) << std::fixed << std::setprecision(15) << pelec->ekb(ik + is * nks_tot, ib) / 2.0
1095 << std::setw(25) << std::fixed << std::setprecision(15)
1096 << pelec->ekb(ik + is * nks_tot, ib) * ModuleBase::Ry_to_eV << std::endl;
1097 }
1098 }
1099 }
1100 ofs.close();
1101 return;
1102}
1103
1104template <typename T, typename Tdata>
1105void RPA_LRI<T, Tdata>::out_Cs(const UnitCell& ucell, std::map<TA, std::map<TAC, RI::Tensor<Tdata>>>& Cs_in, std::string filename)
1106{
1107 ModuleBase::TITLE("DFT_RPA_interface", "out_Cs");
1108 ModuleBase::timer::start("RPA_LRI", "out_Cs");
1109
1110 std::stringstream ss;
1111 ss << filename << GlobalV::MY_RANK << ".txt";
1112 std::ofstream ofs;
1113 ofs.open(ss.str().c_str(), std::ios::out);
1114 ofs << ucell.nat << " " << 0 << std::endl;
1115 for (auto& Ip: Cs_in)
1116 {
1117 size_t I = Ip.first;
1118 size_t i_num = ucell.atoms[ucell.iat2it[I]].nw;
1119 for (auto& JPp: Ip.second)
1120 {
1121 size_t J = JPp.first.first;
1122 auto R = JPp.first.second;
1123 auto& tmp_Cs = JPp.second;
1124 size_t j_num = ucell.atoms[ucell.iat2it[J]].nw;
1125
1126 ofs << I + 1 << " " << J + 1 << " " << R[0] << " " << R[1] << " " << R[2] << " " << i_num
1127 << std::endl;
1128 ofs << j_num << " " << tmp_Cs.shape[0] << std::endl;
1129 for (int i = 0; i != i_num; i++)
1130 {
1131 for (int j = 0; j != j_num; j++)
1132 {
1133 for (int mu = 0; mu != tmp_Cs.shape[0]; mu++)
1134 {
1135 ofs << std::setw(30) << std::fixed << std::setprecision(15) << tmp_Cs(mu, i, j) << std::endl;
1136 }
1137 }
1138 }
1139 }
1140 }
1141 ofs.close();
1142 ModuleBase::timer::end("RPA_LRI", "out_Cs");
1143 return;
1144}
1145
1146template <typename T, typename Tdata>
1148 std::map<TA, std::map<TAC, RI::Tensor<Tdata>>>& Vs,
1149 std::string filename,
1150 Exx_LRI<double>* exx_lri)
1151{
1152 ModuleBase::TITLE("DFT_RPA_interface", "out_coulomb_k");
1153 ModuleBase::timer::start("RPA_LRI", "out_coulomb_k");
1154
1155 int all_mu = 0;
1156 std::vector<int> mu_shift(ucell.nat);
1157 if (exx_lri->exx_objs.empty())
1158 {
1159 throw std::invalid_argument(std::string(__FILE__) + " line " + std::to_string(__LINE__));
1160 }
1161 const auto basis_method = exx_lri->exx_objs.count(Conv_Coulomb_Pot_K::Coulomb_Method::Center2)
1163 : exx_lri->exx_objs.begin()->first;
1164 for (int I = 0; I != ucell.nat; I++)
1165 {
1166 mu_shift[I] = all_mu;
1167 all_mu += exx_lri->exx_objs.at(basis_method).cv.get_index_abfs_size(ucell.iat2it[I]);
1168 }
1169 const int nks_tot = PARAM.inp.nspin == 2 ? (int)p_kv->get_nks() / 2 : p_kv->get_nks();
1170 std::stringstream ss;
1171 ss << filename << GlobalV::MY_RANK << ".txt";
1172
1173 std::ofstream ofs;
1174 ofs.open(ss.str().c_str(), std::ios::out);
1175
1176 ofs << nks_tot << std::endl;
1177 for (auto& Ip: Vs)
1178 {
1179 auto I = Ip.first;
1180 size_t mu_num = exx_lri->exx_objs.at(basis_method).cv.get_index_abfs_size(ucell.iat2it[I]);
1181
1182 for (int ik = 0; ik != nks_tot; ik++)
1183 {
1184 std::map<size_t, RI::Tensor<std::complex<double>>> Vq_k_IJ;
1185 for (auto& JPp: Ip.second)
1186 {
1187 auto J = JPp.first.first;
1188
1189 auto R = JPp.first.second;
1190 if (J < I)
1191 {
1192 continue;
1193 }
1194 RI::Tensor<std::complex<double>> tmp_VR = RI::Global_Func::convert<std::complex<double>>(JPp.second);
1195 const double arg = 1 * (p_kv->kvec_c[ik] * (RI_Util::array3_to_Vector3(R) * ucell.latvec))
1196 * ModuleBase::TWO_PI; // latvec
1197 const std::complex<double> kphase = std::complex<double>(cos(arg), sin(arg));
1198 if (Vq_k_IJ[J].empty())
1199 {
1200 Vq_k_IJ[J] = RI::Tensor<std::complex<double>>({tmp_VR.shape[0], tmp_VR.shape[1]});
1201 }
1202 Vq_k_IJ[J] = Vq_k_IJ[J] + tmp_VR * kphase;
1203 }
1204 for (auto& vq_Jp: Vq_k_IJ)
1205 {
1206 auto iJ = vq_Jp.first;
1207 auto& vq_J = vq_Jp.second;
1208 size_t nu_num = exx_lri->exx_objs.at(basis_method).cv.get_index_abfs_size(ucell.iat2it[iJ]);
1209 ofs << all_mu << " " << mu_shift[I] + 1 << " " << mu_shift[I] + mu_num << " " << mu_shift[iJ] + 1
1210 << " " << mu_shift[iJ] + nu_num << std::endl;
1211 ofs << ik + 1 << " " << p_kv->wk[ik] / 2.0 * PARAM.inp.nspin << std::endl;
1212 for (int i = 0; i != vq_J.data->size(); i++)
1213 {
1214 ofs << std::setw(25) << std::fixed << std::setprecision(15) << (*vq_J.data)[i].real()
1215 << std::setw(25) << std::fixed << std::setprecision(15) << (*vq_J.data)[i].imag() << std::endl;
1216 }
1217 }
1218 }
1219 }
1220 ofs.close();
1221 ModuleBase::timer::end("RPA_LRI", "out_coulomb_k");
1222}
1223
1224
1225// template<typename Tdata>
1226// void RPA_LRI<T, Tdata>::init(const MPI_Comm &mpi_comm_in)
1227// {
1228// if(this->info == this->exx.info)
1229// {
1230// this->lcaos = this->exx.lcaos;
1231// this->abfs = this->exx.abfs;
1232// this->abfs_ccp = this->exx.abfs_ccp;
1233
1234// exx_lri_rpa.cv = std::move(this->exx.cv);
1235// }
1236// else
1237// {
1238// this->lcaos = ...
1239// this->abfs = ...
1240// this->abfs_ccp = ...
1241
1242// exx_lri_rpa.cv.set_orbitals(
1243// this->lcaos, this->abfs, this->abfs_ccp,
1244// this->info.kmesh_times, this->info.ccp_rmesh_times );
1245// }
1246
1247// // for( size_t T=0; T!=this->abfs.size(); ++T )
1248// // GlobalC::exx_info.info_ri.abfs_Lmax = std::max(
1249// GlobalC::exx_info.info_ri.abfs_Lmax, static_cast<int>(this->abfs[T].size())-1
1250// );
1251
1252// }
1253
1254// template<typename Tdata>
1255// void RPA_LRI<T, Tdata>::cal_rpa_ions()
1256// {
1257// // this->rpa_lri.set_parallel(this->mpi_comm, atoms_pos, latvec, period);
1258
1259// if(this->info == this->exx.info)
1260// exx_lri_rpa.cv.Vws = std::move(this->exx.cv.Vws);
1261
1262// const std::array<Tcell,Ndim> period_Vs =
1263// LRI_CV_Tools::cal_latvec_range<Tcell>(1+this->info.ccp_rmesh_times); const
1264// std::pair<std::vector<TA>,
1265// std::vector<std::vector<std::pair<TA,std::array<Tcell,Ndim>>>>> list_As_Vs
1266// = RI::Distribute_Equally::distribute_atoms(this->mpi_comm, atoms, period_Vs,
1267// 2, false);
1268
1269// std::map<TA,std::map<TAC,RI::Tensor<Tdata>>>
1270// Vs = exx_lri_rpa.cv.cal_Vs(
1271// list_As_Vs.first, list_As_Vs.second[0],
1272// {{"writable_Vws",true}});
1273
1274// // Vs[iat0][{iat1,cell1}] 按 (iat0,iat1) 分进程,每个进程有所有 cell1
1275// Vqs = FFT(Vs);
1276// out_Vs(Vqs);
1277
1278// if(this->info == this->exx.info)
1279// exx_lri_rpa.cv.Cws = std::move(this->exx.cv.Cws);
1280
1281// const std::array<Tcell,Ndim> period_Cs =
1282// LRI_CV_Tools::cal_latvec_range<Tcell>(2); const std::pair<std::vector<TA>,
1283// std::vector<std::vector<std::pair<TA,std::array<Tcell,Ndim>>>>> list_As_Cs
1284// = RI::Distribute_Equally::distribute_atoms_periods(this->mpi_comm, atoms,
1285// period_Cs, 2, false);
1286
1287// std::pair<std::map<TA,std::map<TAC,RI::Tensor<Tdata>>>,
1288// std::array<std::map<TA,std::map<TAC,RI::Tensor<Tdata>>>,3>> Cs_dCs =
1289// exx_lri_rpa.cv.cal_Cs_dCs( list_As_Cs.first, list_As_Cs.second[0],
1290// {{"cal_dC",false},
1291// {"writable_Cws",true}, {"writable_dCws",true},
1292// {"writable_Vws",false},
1293// {"writable_dVws",false}}); std::map<TA,std::map<TAC,RI::Tensor<Tdata>>> &Cs
1294// = std::get<0>(Cs_dCs);
1295
1296// out_Cs(Cs);
1297
1298// // rpa_lri.set_Cs(Cs);
1299// }
1300
1301#endif
Exx_LRI< double > exx_lri_rpa(GlobalC::exx_info.info_ri)
const std::complex< double > i
Definition cal_pLpR.cpp:46
Definition atom_spec.h:6
int na
Definition atom_spec.h:27
int nw
Definition atom_spec.h:22
std::vector< ModuleBase::Vector3< double > > tau
Definition atom_spec.h:35
static void print_orbs_size(const UnitCell &ucell, const std::vector< std::vector< std::vector< Numerical_Orbital_Lm > > > &orbs, std::ostream &os)
Definition exx_abfs-construct_orbs.cpp:475
static std::vector< std::vector< std::vector< Numerical_Orbital_Lm > > > abfs_same_atom(const UnitCell &ucell, const LCAO_Orbitals &orb, const std::vector< std::vector< std::vector< Numerical_Orbital_Lm > > > &lcaos, const double kmesh_times_mot, const double times_threshold=0)
Definition exx_abfs-construct_orbs.cpp:80
static std::vector< std::vector< std::vector< Numerical_Orbital_Lm > > > change_orbs(const LCAO_Orbitals &orb_in, const double kmesh_times)
Definition exx_abfs-construct_orbs.cpp:10
static std::vector< std::vector< std::vector< Numerical_Orbital_Lm > > > construct_abfs(const LCAO_Orbitals &orbs, const std::vector< std::string > &files_abfs, const double kmesh_times=1)
Definition exx_abfs-io.cpp:12
Definition Exx_LRI.h:53
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:760
std::map< Conv_Coulomb_Pot_K::Coulomb_Method, Exx_Obj< Tdata > > exx_objs
Definition Exx_LRI.h:126
RI::Exx< TA, Tcell, Ndim, Tdata > exx_lri
Definition Exx_LRI.h:128
Definition Inverse_Matrix.h:15
Definition klist.h:12
int get_nkstot_full() const
Definition klist.h:78
int get_nks() const
Definition klist.h:68
Definition ORB_read.h:18
std::vector< double > cutoffs() const
Definition ORB_read.cpp:39
Definition Matrix_Orbs11.h:22
void init_radial_table()
Definition Matrix_Orbs11.cpp:93
std::shared_ptr< ORB_gaunt_table > MGT
Definition Matrix_Orbs11.h:64
void init(const std::vector< std::vector< std::vector< Numerical_Orbital_Lm > > > &orb_A, const std::vector< std::vector< std::vector< Numerical_Orbital_Lm > > > &orb_B, const UnitCell &ucell, const LCAO_Orbitals &orb, const double kmesh_times)
Definition Matrix_Orbs11.cpp:12
Definition Mix_DMk_2D.h:16
std::vector< const std::vector< std::complex< double > > * > get_DMk_k_out() const
Returns the complex density matrix.
Definition Mix_DMk_2D.cpp:66
Mix_DMk_2D & set_mixing(Base_Mixing::Mixing *mixing_in)
Sets the mixing mode.
Definition Mix_DMk_2D.cpp:20
void mix(const std::vector< std::vector< double > > &dm, const bool flag_restart)
Mixes the double density matrix.
Definition Mix_DMk_2D.cpp:44
std::vector< const std::vector< double > * > get_DMk_gamma_out() const
Returns the double density matrix.
Definition Mix_DMk_2D.cpp:59
Mix_DMk_2D & set_nks(const int nks, const bool gamma_only_in)
Sets the number of k-points and gamma_only flag.
Definition Mix_DMk_2D.cpp:9
3x3 matrix and related mathamatical operations
Definition matrix3.h:19
double e13
Definition matrix3.h:26
double e31
Definition matrix3.h:26
double e11
element e_ij: i_row, j_column
Definition matrix3.h:26
double e33
Definition matrix3.h:26
double e32
Definition matrix3.h:26
double e21
Definition matrix3.h:26
double e12
Definition matrix3.h:26
double e23
Definition matrix3.h:26
double e22
Definition matrix3.h:26
3 elements vector
Definition vector3.h:24
static void start(void)
Start total time calculation.
Definition timer.cpp:44
static void end(const std::string &class_name_in, const std::string &name_in)
Definition timer.cpp:109
Definition symmetry_rotation.h:16
void set_abfs_Lmax(const int l)
Definition symmetry_rotation.h:44
std::vector< std::vector< std::complex< double > > > restore_dm(const K_Vectors &kv, const std::vector< std::vector< std::complex< double > > > &dm_k_ibz, const Parallel_2D &pv) const
Definition symmetry_rotation.cpp:78
void cal_Ms(const K_Vectors &kv, const UnitCell &ucell, const Parallel_2D &pv)
functions to contruct rotation matrix in AO-representation
Definition symmetry_rotation.cpp:19
void find_irreducible_sector(const Symmetry &symm, const Atom *atoms, const Statistics &st, const std::vector< TC > &Rs, const TC &period, const Lattice &lat)
Definition symmetry_rotation.h:39
static int symm_flag
Definition symmetry.h:29
int local2global_row(const int ilr) const
get the global index of a local index (row)
Definition parallel_2d.h:57
int global2local_col(const int igc) const
get the local index of a global index (col)
Definition parallel_2d.h:51
Definition parallel_orbitals.h:9
const Input_para & inp
Definition parameter.h:26
const System_para & globalv
Definition parameter.h:30
std::pair< TA, Tq > TAq
Definition RPA_LRI.h:33
void cal_postSCF_exx(const elecstate::DensityMatrix< T, Tdata > &dm, const MPI_Comm &mpi_comm_in, const UnitCell &ucell, const K_Vectors &kv, const LCAO_Orbitals &orb)
Definition RPA_LRI.hpp:103
void output_cut_coulomb_cs(const UnitCell &ucell, Exx_LRI< double > *exx_lri_rpa)
Definition RPA_LRI.hpp:200
void cal_large_Cs(const UnitCell &ucell, const LCAO_Orbitals &orb, const K_Vectors &kv)
Definition RPA_LRI.hpp:311
void out_abfs_overlap(const UnitCell &ucell, std::map< TA, std::map< TAC, RI::Tensor< Tdata > > > &overlap_abfs_abfs, std::map< TA, std::map< TAC, RI::Tensor< Tdata > > > &overlap_abfs_abf, std::string filename, const ModuleBase::Element_Basis_Index::IndexLNM &index_abfs_s, const ModuleBase::Element_Basis_Index::IndexLNM &index_abfs)
Definition RPA_LRI.hpp:576
void out_Cs(const UnitCell &ucell, std::map< TA, std::map< TAC, RI::Tensor< Tdata > > > &Cs_in, std::string filename)
Definition RPA_LRI.hpp:1105
void out_bands(const elecstate::ElecState *pelec)
Definition RPA_LRI.hpp:1067
void out_coulomb_k(const UnitCell &ucell, std::map< TA, std::map< TAC, RI::Tensor< Tdata > > > &Vs, std::string filename, Exx_LRI< double > *exx_lri)
Definition RPA_LRI.hpp:1147
void inverse_olp(const UnitCell &ucell, std::map< TA, std::map< TAq, RI::Tensor< std::complex< double > > > > &overlap_abfs_abfs, const ModuleBase::Element_Basis_Index::IndexLNM &index_abfs_s)
Definition RPA_LRI.hpp:736
void postSCF(const UnitCell &ucell, const MPI_Comm &mpi_comm_in, const elecstate::DensityMatrix< T, Tdata > &dm, const elecstate::ElecState *pelec, const K_Vectors &kv, const LCAO_Orbitals &orb, const Parallel_Orbitals &parav, const psi::Psi< T > &psi)
Definition RPA_LRI.hpp:37
void out_struc(const UnitCell &ucell)
Definition RPA_LRI.hpp:1002
int TA
Definition RPA_LRI.h:27
void output_ewald_coulomb(const UnitCell &ucell, const K_Vectors &kv, const LCAO_Orbitals &orb)
Definition RPA_LRI.hpp:254
std::pair< TA, TC > TAC
Definition RPA_LRI.h:32
void out_eigen_vector(const Parallel_Orbitals &parav, const psi::Psi< T > &psi)
Definition RPA_LRI.hpp:936
void cal_abfs_overlap(const UnitCell &ucell, const LCAO_Orbitals &orb, const K_Vectors &kv)
Definition RPA_LRI.hpp:418
void init(const MPI_Comm &mpi_comm_in, const K_Vectors &kv_in, const std::vector< double > &orb_cutoff)
Definition RPA_LRI.hpp:79
Definition unitcell.h:15
int *& iat2it
Definition unitcell.h:75
Atom * atoms
Definition unitcell.h:45
double & lat0
Definition unitcell.h:56
ModuleBase::Matrix3 & latvec
Definition unitcell.h:63
Lattice lat
Definition unitcell.h:53
int lmax
Definition unitcell.h:213
int & ntype
Definition unitcell.h:73
ModuleSymmetry::Symmetry symm
Definition unitcell.h:83
int & nat
Definition unitcell.h:74
ModuleBase::Vector3< double > & a2
Definition unitcell.h:64
ModuleBase::Vector3< double > & a3
Definition unitcell.h:64
std::string & Coordinate
Definition unitcell.h:54
int *& iat2ia
Definition unitcell.h:76
ModuleBase::Vector3< double > & a1
Definition unitcell.h:64
Statistics st
Definition unitcell.h:72
ModuleBase::Matrix3 & G
Definition unitcell.h:67
Definition density_matrix.h:70
const std::vector< std::vector< TK > > & get_DMK_vector() const
get pointer vector of DMK
Definition density_matrix.h:198
const Parallel_Orbitals * get_paraV_pointer() const
get pointer of paraV
Definition density_matrix.h:210
Definition elecstate.h:15
fenergy f_en
energies contribute to the total free energy
Definition elecstate.h:148
ModuleBase::matrix wg
occupation weight for each k-point and band
Definition elecstate.h:158
ModuleBase::matrix ekb
band energy at each k point, each band.
Definition elecstate.h:157
Efermi eferm
fermi energies
Definition elecstate.h:149
Definition psi.h:37
Exx_Info exx_info
Definition exx_info.cpp:8
int MY_RANK
global index of process
Definition global_variable.cpp:21
std::ofstream ofs_running
Definition global_variable.cpp:38
RI::Tensor< Tdata > cal_I(const RI::Tensor< Tdata > &m, const typename Inverse_Matrix< Tdata >::Method method=Inverse_Matrix< Tdata >::Method::potrf, const double &threshold_condition_number=0.)
Definition LRI_CV_Tools.hpp:18
Range construct_range(const LCAO_Orbitals &orb)
Definition element_basis_index-ORB.cpp:10
IndexLNM construct_index(const Range &range)
Definition element_basis_index.cpp:12
std::vector< Index_T > IndexLNM
Definition element_basis_index.h:42
std::vector< std::vector< NM > > Range
Definition element_basis_index.h:41
void DONE(std::ofstream &ofs, const std::string &description, const bool only_rank0)
Definition global_function.cpp:80
const double TWO_PI
Definition constants.h:21
const double BOHR_TO_A
Definition constants.h:55
const double Ry_to_eV
Definition constants.h:81
void TITLE(const std::string &class_name, const std::string &function_name, const bool disable)
Definition tool_title.cpp:18
void print_symrot_info_k(const ModuleSymmetry::Symmetry_rotation &symrot, const K_Vectors &kv, const UnitCell &ucell)
Definition symmetry_rotation_output.cpp:54
void print_symrot_info_R(const Symmetry_rotation &symrot, const Symmetry &symm, const int lmax_ao, const std::vector< TC > &Rs)
Definition symmetry_rotation_output.cpp:14
std::map< TA, std::map< TAC, T > > comm_map2_first(const MPI_Comm &mpi_comm, const std::map< TA, std::map< TAC, T > > &Ds_in, const std::set< TA > &s0, const std::set< TA > &s1)
Definition RI_2D_Comm.hpp:495
std::array< Tcell, 3 > Vector3_to_array3(const ModuleBase::Vector3< Tcell > &v)
Definition RI_Util.h:32
std::array< int, 3 > get_Born_vonKarmen_period(const K_Vectors &kv)
Definition RI_Util.hpp:16
std::vector< std::array< Tcell, Ndim > > get_Born_von_Karmen_cells(const std::array< Tcell, Ndim > &Born_von_Karman_period)
Definition RI_Util.hpp:34
ModuleBase::Vector3< Tcell > array3_to_Vector3(const std::array< Tcell, 3 > &v)
Definition RI_Util.h:38
Definition RPA_LRI.hpp:27
void trim_malloc_cache()
Definition RPA_LRI.hpp:28
Definition exx_lip.h:23
Parameter PARAM
Definition parameter.cpp:3
#define threshold
Definition sph_bessel_recursive_test.cpp:4
double hybrid_alpha
Definition exx_info.h:30
Conv_Coulomb_Pot_K::Ccp_Type ccp_type
Definition exx_info.h:29
double ccp_rmesh_times
Definition exx_info.h:69
Exx_Info_Global info_global
Definition exx_info.h:37
Exx_Info_RI info_ri
Definition exx_info.h:86
bool exx_symmetry_realspace
whether to reduce the real-space sector in when using symmetry=1 in EXX calculation
Definition input_parameter.h:563
std::string symmetry
Definition input_parameter.h:27
double rpa_ccp_rmesh_times
Definition input_parameter.h:564
int nspin
LDA ; LSDA ; non-linear spin.
Definition input_parameter.h:88
bool out_ri_cv
Whether to output the coefficient tensor C and ABFs-representation Coulomb matrix V.
Definition input_parameter.h:570
int nbands
number of bands
Definition input_parameter.h:79
bool out_unshrinked_v
whether to output the large Vq matrix in unshrinked auxiliary basis
Definition input_parameter.h:571
int nlocal
total number of local basis.
Definition system_parameter.h:23
bool gamma_only_local
Definition system_parameter.h:38
double ef
Fermi energy.
Definition fp_energy.h:65
double etot
the total free energy
Definition fp_energy.h:18
double etxc
E_xc[n(r)] exchange and correlation energy.
Definition fp_energy.h:24
const std::map< std::string, std::vector< double > > zero
Definition vdwd3_autoset_xcparam.cpp:326