Skip to content

Commit d83621a

Browse files
linpeizePeizeLin
andauthored
Refactor: move exx files (#7352)
* Refactor: move exx files * fix TO_STRING --------- Co-authored-by: linpz <linpz@mail.ustc.edu.cn> Co-authored-by: PeizeLin <78645006+PeizeLin@users.noreply.github.com>
1 parent 078df41 commit d83621a

5 files changed

Lines changed: 399 additions & 446 deletions

File tree

source/source_lcao/module_ri/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ if (ENABLE_LIBRI)
2222
exx_opt_orb.cpp
2323
gaussian_abfs.cpp
2424
singular_value.cpp
25+
ExxLriDetail.cpp
2526
)
2627
endif()
2728
add_library(
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
//=======================
2+
// AUTHOR : Huanjing Gong
3+
// DATE : 2026-03-17
4+
//=======================
5+
6+
7+
#include "ExxLriDetail.h"
8+
9+
#include "RI_Util.h"
10+
#include "source_cell/klist.h"
11+
#include "source_cell/unitcell.h"
12+
#include "source_base/global_function.h"
13+
14+
namespace ExxLriDetail
15+
{
16+
17+
double default_spencer_rcut(const UnitCell& ucell, const K_Vectors& kv)
18+
{
19+
return std::pow(0.75 * kv.get_nkstot_full() * ucell.omega / (ModuleBase::PI), 1.0 / 3.0);
20+
}
21+
22+
CoulombParam build_center2_cut_coulomb_param(const CoulombParam& coulomb_param,
23+
const UnitCell& ucell,
24+
const K_Vectors& kv,
25+
bool* synthesized_rcut)
26+
{
27+
CoulombParam center2_param = RI_Util::update_coulomb_param(coulomb_param, ucell, &kv);
28+
const double fallback_rcut = default_spencer_rcut(ucell, kv);
29+
bool used_fallback_rcut = false;
30+
31+
for (auto& param_list: center2_param)
32+
{
33+
if (param_list.first != Conv_Coulomb_Pot_K::Coulomb_Type::Fock)
34+
{
35+
continue;
36+
}
37+
for (auto& param: param_list.second)
38+
{
39+
auto rcut_it = param.find("Rcut");
40+
if (rcut_it == param.end() || rcut_it->second.empty())
41+
{
42+
param["Rcut"] = ModuleBase::GlobalFunc::TO_STRING(fallback_rcut);
43+
used_fallback_rcut = true;
44+
}
45+
}
46+
}
47+
48+
if (synthesized_rcut != nullptr)
49+
{
50+
*synthesized_rcut = used_fallback_rcut;
51+
}
52+
return center2_param;
53+
}
54+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
//=======================
2+
// AUTHOR : Huanjing Gong
3+
// DATE : 2026-03-17
4+
//=======================
5+
6+
#ifndef EXXLRIDETAIL_H
7+
#define EXXLRIDETAIL_H
8+
9+
#include "conv_coulomb_pot_k.h"
10+
#include "source_base/constants.h"
11+
12+
#include <cmath>
13+
#include <vector>
14+
#include <map>
15+
#include <string>
16+
17+
#if defined(__GLIBC__)
18+
#include <malloc.h>
19+
#endif
20+
21+
class UnitCell;
22+
class K_Vectors;
23+
24+
namespace ExxLriDetail
25+
{
26+
using CoulombParam
27+
= std::map<Conv_Coulomb_Pot_K::Coulomb_Type, std::vector<std::map<std::string, std::string>>>;
28+
29+
inline void trim_malloc_cache()
30+
{
31+
#if defined(__GLIBC__)
32+
malloc_trim(0);
33+
#endif
34+
}
35+
36+
extern double default_spencer_rcut(const UnitCell& ucell, const K_Vectors& kv);
37+
38+
extern CoulombParam build_center2_cut_coulomb_param(const CoulombParam& coulomb_param,
39+
const UnitCell& ucell,
40+
const K_Vectors& kv,
41+
bool* synthesized_rcut = nullptr);
42+
}
43+
44+
#endif

source/source_lcao/module_ri/Exx_LRI.h

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -64,26 +64,17 @@ class Exx_LRI
6464
Exx_LRI operator=(const Exx_LRI&) = delete;
6565
Exx_LRI operator=(Exx_LRI&&);
6666

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);
7267
void init(
7368
const MPI_Comm &mpi_comm_in,
7469
const UnitCell &ucell,
7570
const K_Vectors &kv_in,
7671
const LCAO_Orbitals& orb,
77-
const std::vector<std::vector<std::vector<Numerical_Orbital_Lm>>>& abfs_in);
78-
void init_spencer(const MPI_Comm& mpi_comm_in,
79-
const UnitCell& ucell,
80-
const K_Vectors& kv_in,
81-
const LCAO_Orbitals& orb);
82-
void init_spencer(const MPI_Comm& mpi_comm_in,
83-
const UnitCell& ucell,
84-
const K_Vectors& kv_in,
85-
const LCAO_Orbitals& orb,
86-
const std::vector<std::vector<std::vector<Numerical_Orbital_Lm>>>& abfs_in);
72+
const std::vector<std::vector<std::vector<Numerical_Orbital_Lm>>>& abfs_in = {});
73+
void init_spencer(const MPI_Comm& mpi_comm_in,
74+
const UnitCell& ucell,
75+
const K_Vectors& kv_in,
76+
const LCAO_Orbitals& orb,
77+
const std::vector<std::vector<std::vector<Numerical_Orbital_Lm>>>& abfs_in = {});
8778
void cal_exx_ions(const UnitCell& ucell, const bool write_cv = false);
8879
void cal_cut_coulomb_cs(
8980
std::map<TA, std::map<TAC, RI::Tensor<Tdata>>>& Vs_cut_IJR,

0 commit comments

Comments
 (0)