Skip to content

Commit 4a0e113

Browse files
committed
1. ABFs group
1 parent c677ec6 commit 4a0e113

File tree

13 files changed

+632
-53
lines changed

13 files changed

+632
-53
lines changed

source/source_base/element_basis_index.cpp

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,37 @@
88
namespace ModuleBase
99
{
1010

11-
Element_Basis_Index::IndexLNM
12-
Element_Basis_Index::construct_index( const Range &range )
11+
Element_Basis_Index::Index_T
12+
Element_Basis_Index::construct_index( const std::vector<NM> &range )
1313
{
14-
IndexLNM index;
14+
Index_T index;
15+
std::size_t count=0;
1516
index.resize( range.size() );
16-
for( std::size_t T=0; T!=range.size(); ++T )
17+
for( std::size_t L=0; L!=range.size(); ++L )
1718
{
18-
std::size_t count=0;
19-
index[T].resize( range[T].size() );
20-
for( std::size_t L=0; L!=range[T].size(); ++L )
19+
index[L].resize( range[L].N );
20+
for( std::size_t N=0; N!=range[L].N; ++N )
2121
{
22-
index[T][L].resize( range[T][L].N );
23-
for( std::size_t N=0; N!=range[T][L].N; ++N )
22+
index[L][N].resize( range[L].M );
23+
for( std::size_t M=0; M!=range[L].M; ++M )
2424
{
25-
index[T][L][N].resize( range[T][L].M );
26-
for( std::size_t M=0; M!=range[T][L].M; ++M )
27-
{
28-
index[T][L][N][M] = count;
29-
++count;
30-
}
25+
index[L][N][M] = count;
26+
++count;
3127
}
32-
index[T][L].N = range[T][L].N;
33-
index[T][L].M = range[T][L].M;
3428
}
35-
index[T].count_size = count;
29+
index[L].N = range[L].N;
30+
index[L].M = range[L].M;
3631
}
32+
index.count_size = count;
33+
return index;
34+
}
35+
36+
Element_Basis_Index::IndexLNM
37+
Element_Basis_Index::construct_index( const Range &range )
38+
{
39+
IndexLNM index(range.size());
40+
for( std::size_t T=0; T!=range.size(); ++T )
41+
{ index[T] = construct_index(range[T]); }
3742
return index;
3843
}
3944

source/source_base/element_basis_index.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include <cstddef>
1010
#include <vector>
11+
#include <map>
1112

1213
namespace ModuleBase
1314
{
@@ -42,8 +43,11 @@ namespace Element_Basis_Index
4243
typedef std::vector<Index_T> IndexLNM; // index[T][L][N][M]
4344

4445
extern IndexLNM construct_index( const Range &range );
46+
template<typename Tkey> extern std::map<Tkey, Index_T> construct_index( const std::map<Tkey, std::vector<NM>> &range );
4547
}
4648

4749
}
4850

51+
#include "element_basis_index.hpp"
52+
4953
#endif
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//==========================================================
2+
// AUTHOR : Peize Lin
3+
// DATE : 2025-12-14
4+
//==========================================================
5+
6+
#pragma once
7+
8+
#include "element_basis_index.h"
9+
10+
namespace ModuleBase
11+
{
12+
13+
template<typename Tkey>
14+
std::map<Tkey, Element_Basis_Index::Index_T>
15+
Element_Basis_Index::construct_index( const std::map<Tkey, std::vector<NM>> &range )
16+
{
17+
std::map<Tkey, Element_Basis_Index::Index_T> index(range.size());
18+
for( const auto &range_T : range )
19+
{ index[range_T.first] = construct_index(range_T.second); }
20+
return index;
21+
}
22+
23+
}

source/source_hamilt/module_xc/exx_info.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ struct Exx_Info
5757

5858
double pca_threshold = 0;
5959
std::vector<std::string> files_abfs;
60+
std::map<std::string, std::string> files_abfs_group;
6061
double C_threshold = 0;
6162
double V_threshold = 0;
6263
double dm_threshold = 0;
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
//=======================
2+
// AUTHOR : Peize Lin
3+
// DATE : 2022-08-17
4+
//=======================
5+
6+
#ifndef EXX_LRI_H
7+
#define EXX_LRI_H
8+
9+
#include "LRI_CV.h"
10+
#include "source_hamilt/module_xc/exx_info.h"
11+
#include "source_basis/module_ao/ORB_atomic_lm.h"
12+
#include "source_base/matrix.h"
13+
#include <RI/physics/Exx.h>
14+
15+
#include <vector>
16+
#include <array>
17+
#include <map>
18+
#include <deque>
19+
#include <mpi.h>
20+
21+
#include "module_exx_symmetry/symmetry_rotation.h"
22+
23+
class Parallel_Orbitals;
24+
25+
template<typename T, typename Tdata>
26+
class RPA_LRI;
27+
28+
template<typename T, typename Tdata>
29+
class Exx_LRI_Interface;
30+
31+
namespace LR
32+
{
33+
template<typename T, typename TR>
34+
class ESolver_LR;
35+
36+
template<typename T>
37+
class OperatorLREXX;
38+
}
39+
40+
template<typename Tdata>
41+
class Exx_Obj
42+
{
43+
// match with Conv_Coulomb_Pot_K::Coulomb_Method
44+
public:
45+
LRI_CV<Tdata> cv;
46+
std::map<std::string, std::vector<std::vector<Numerical_Orbital_Lm>>> abfs_ccp;
47+
};
48+
49+
template<typename Tdata>
50+
class Exx_LRI
51+
{
52+
private:
53+
using TA = int;
54+
using Tcell = int;
55+
static constexpr std::size_t Ndim = 3;
56+
using TC = std::array<Tcell,Ndim>;
57+
using TAC = std::pair<TA,TC>;
58+
using TatomR = std::array<double,Ndim>; // tmp
59+
60+
public:
61+
Exx_LRI(const Exx_Info::Exx_Info_RI& info_in) :info(info_in) {}
62+
Exx_LRI operator=(const Exx_LRI&) = delete;
63+
Exx_LRI operator=(Exx_LRI&&);
64+
65+
std::map<std::string, std::pair<int,int>> group;
66+
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);
72+
void cal_exx_ions(const UnitCell& ucell, const bool write_cv = false);
73+
void cal_exx_elec(
74+
const std::vector<std::map<TA, std::map<TAC, RI::Tensor<Tdata>>>>& Ds,
75+
const UnitCell& ucell,
76+
const Parallel_Orbitals& pv,
77+
const ModuleSymmetry::Symmetry_rotation* p_symrot = nullptr);
78+
void cal_exx_force(const int& nat);
79+
void cal_exx_stress(const double& omega, const double& lat0);
80+
81+
void reset_Cs(const std::map<TA, std::map<TAC, RI::Tensor<Tdata>>>& Cs_in) { this->exx_lri.set_Cs(Cs_in, this->info.C_threshold); }
82+
void reset_Vs(const std::map<TA, std::map<TAC, RI::Tensor<Tdata>>>& Vs_in) { this->exx_lri.set_Vs(Vs_in, this->info.V_threshold); }
83+
//std::vector<std::vector<int>> get_abfs_nchis() const;
84+
85+
std::vector< std::map<TA, std::map<TAC, RI::Tensor<Tdata>>>> Hexxs;
86+
double Eexx;
87+
ModuleBase::matrix force_exx;
88+
ModuleBase::matrix stress_exx;
89+
90+
91+
private:
92+
const Exx_Info::Exx_Info_RI &info;
93+
MPI_Comm mpi_comm;
94+
const K_Vectors *p_kv = nullptr;
95+
ORB_gaunt_table MGT;
96+
std::vector<double> orb_cutoff_;
97+
98+
std::vector<std::vector<std::vector<Numerical_Orbital_Lm>>> lcaos;
99+
std::map<std::string, std::vector<std::vector<Numerical_Orbital_Lm>>> abfs;
100+
//std::vector<std::vector<std::vector<Numerical_Orbital_Lm>>> abfs_ccp;
101+
std::map<Conv_Coulomb_Pot_K::Coulomb_Method, Exx_Obj<Tdata>> exx_objs;
102+
//LRI_CV<Tdata> cv;
103+
RI::Exx<TA,Tcell,Ndim,Tdata> exx_lri;
104+
std::map<Conv_Coulomb_Pot_K::Coulomb_Method,
105+
std::pair<bool,
106+
std::map<Conv_Coulomb_Pot_K::Coulomb_Type,
107+
std::vector<std::map<std::string,std::string>>>>> coulomb_settings;
108+
109+
void post_process_Hexx( std::map<TA, std::map<TAC, RI::Tensor<Tdata>>> &Hexxs_io ) const;
110+
double post_process_Eexx(const double& Eexx_in) const;
111+
112+
friend class RPA_LRI<double, Tdata>;
113+
friend class RPA_LRI<std::complex<double>, Tdata>;
114+
friend class Exx_LRI_Interface<double, Tdata>;
115+
friend class Exx_LRI_Interface<std::complex<double>, Tdata>;
116+
friend class LR::ESolver_LR<double, double>;
117+
friend class LR::ESolver_LR<std::complex<double>, double>;
118+
friend class LR::OperatorLREXX<double>;
119+
friend class LR::OperatorLREXX<std::complex<double>>;
120+
};
121+
122+
#include "Exx_LRI.hpp"
123+
124+
#endif

0 commit comments

Comments
 (0)