Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions source/source_lcao/module_ri/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ if (ENABLE_LIBRI)
exx_opt_orb.cpp
gaussian_abfs.cpp
singular_value.cpp
ExxLriDetail.cpp
)
endif()
add_library(
Expand Down
53 changes: 53 additions & 0 deletions source/source_lcao/module_ri/ExxLriDetail.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//=======================
// AUTHOR : Huanjing Gong
// DATE : 2026-03-17
//=======================


#include "ExxLriDetail.h"

#include "RI_Util.h"
#include "source_cell/klist.h"
#include "source_cell/unitcell.h"

namespace ExxLriDetail
{

double default_spencer_rcut(const UnitCell& ucell, const K_Vectors& kv)
{
return std::pow(0.75 * kv.get_nkstot_full() * ucell.omega / (ModuleBase::PI), 1.0 / 3.0);
}

CoulombParam build_center2_cut_coulomb_param(const CoulombParam& coulomb_param,
const UnitCell& ucell,
const K_Vectors& kv,
bool* synthesized_rcut)
{
CoulombParam center2_param = RI_Util::update_coulomb_param(coulomb_param, ucell, &kv);
const double fallback_rcut = default_spencer_rcut(ucell, kv);
bool used_fallback_rcut = false;

for (auto& param_list: center2_param)
{
if (param_list.first != Conv_Coulomb_Pot_K::Coulomb_Type::Fock)
{
continue;
}
for (auto& param: param_list.second)
{
auto rcut_it = param.find("Rcut");
if (rcut_it == param.end() || rcut_it->second.empty())
{
param["Rcut"] = std::to_string(fallback_rcut);
used_fallback_rcut = true;
}
}
}

if (synthesized_rcut != nullptr)
{
*synthesized_rcut = used_fallback_rcut;
}
return center2_param;
}
}
44 changes: 44 additions & 0 deletions source/source_lcao/module_ri/ExxLriDetail.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//=======================
// AUTHOR : Huanjing Gong
// DATE : 2026-03-17
//=======================

#ifndef EXXLRIDETAIL_H
#define EXXLRIDETAIL_H

#include "conv_coulomb_pot_k.h"
#include "source_base/constants.h"

#include <cmath>
#include <vector>
#include <map>
#include <string>

#if defined(__GLIBC__)
#include <malloc.h>
#endif

class UnitCell;
class K_Vectors;

namespace ExxLriDetail
{
using CoulombParam
= std::map<Conv_Coulomb_Pot_K::Coulomb_Type, std::vector<std::map<std::string, std::string>>>;

inline void trim_malloc_cache()
{
#if defined(__GLIBC__)
malloc_trim(0);
#endif
}

extern double default_spencer_rcut(const UnitCell& ucell, const K_Vectors& kv);

extern CoulombParam build_center2_cut_coulomb_param(const CoulombParam& coulomb_param,
const UnitCell& ucell,
const K_Vectors& kv,
bool* synthesized_rcut = nullptr);
}

#endif
21 changes: 6 additions & 15 deletions source/source_lcao/module_ri/Exx_LRI.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,26 +64,17 @@ class Exx_LRI
Exx_LRI operator=(const Exx_LRI&) = delete;
Exx_LRI operator=(Exx_LRI&&);

void init(
const MPI_Comm &mpi_comm_in,
const UnitCell &ucell,
const K_Vectors &kv_in,
const LCAO_Orbitals& orb);
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);
void init_spencer(const MPI_Comm& mpi_comm_in,
const UnitCell& ucell,
const K_Vectors& kv_in,
const LCAO_Orbitals& orb);
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);
const std::vector<std::vector<std::vector<Numerical_Orbital_Lm>>>& abfs_in = {});
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 = {});
void cal_exx_ions(const UnitCell& ucell, const bool write_cv = false);
void cal_cut_coulomb_cs(
std::map<TA, std::map<TAC, RI::Tensor<Tdata>>>& Vs_cut_IJR,
Expand Down
Loading
Loading