Skip to content

Commit c2eba66

Browse files
committed
Refactor: move exx files
1 parent bba6408 commit c2eba66

5 files changed

Lines changed: 398 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: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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+
13+
namespace ExxLriDetail
14+
{
15+
16+
double default_spencer_rcut(const UnitCell& ucell, const K_Vectors& kv)
17+
{
18+
return std::pow(0.75 * kv.get_nkstot_full() * ucell.omega / (ModuleBase::PI), 1.0 / 3.0);
19+
}
20+
21+
CoulombParam build_center2_cut_coulomb_param(const CoulombParam& coulomb_param,
22+
const UnitCell& ucell,
23+
const K_Vectors& kv,
24+
bool* synthesized_rcut)
25+
{
26+
CoulombParam center2_param = RI_Util::update_coulomb_param(coulomb_param, ucell, &kv);
27+
const double fallback_rcut = default_spencer_rcut(ucell, kv);
28+
bool used_fallback_rcut = false;
29+
30+
for (auto& param_list: center2_param)
31+
{
32+
if (param_list.first != Conv_Coulomb_Pot_K::Coulomb_Type::Fock)
33+
{
34+
continue;
35+
}
36+
for (auto& param: param_list.second)
37+
{
38+
auto rcut_it = param.find("Rcut");
39+
if (rcut_it == param.end() || rcut_it->second.empty())
40+
{
41+
param["Rcut"] = std::to_string(fallback_rcut);
42+
used_fallback_rcut = true;
43+
}
44+
}
45+
}
46+
47+
if (synthesized_rcut != nullptr)
48+
{
49+
*synthesized_rcut = used_fallback_rcut;
50+
}
51+
return center2_param;
52+
}
53+
}
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)