Skip to content

Commit 8fccc4e

Browse files
committed
Remove and combine some files in DeePKS.
1 parent 96d0d7d commit 8fccc4e

File tree

11 files changed

+93
-286
lines changed

11 files changed

+93
-286
lines changed

source/Makefile.Objects

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ OBJS_DEEPKS=LCAO_deepks.o\
209209
deepks_vdelta.o\
210210
deepks_vdpre.o\
211211
deepks_vdrpre.o\
212-
deepks_hmat.o\
213212
deepks_pdm.o\
214213
deepks_phialpha.o\
215214
LCAO_deepks_io.o\

source/module_hamilt_lcao/module_deepks/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ if(ENABLE_DEEPKS)
1212
deepks_vdelta.cpp
1313
deepks_vdpre.cpp
1414
deepks_vdrpre.cpp
15-
deepks_hmat.cpp
1615
deepks_pdm.cpp
1716
deepks_phialpha.cpp
1817
LCAO_deepks_io.cpp

source/module_hamilt_lcao/module_deepks/LCAO_deepks.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include "deepks_descriptor.h"
88
#include "deepks_force.h"
99
#include "deepks_fpre.h"
10-
#include "deepks_hmat.h"
1110
#include "deepks_orbital.h"
1211
#include "deepks_orbpre.h"
1312
#include "deepks_pdm.h"
@@ -57,10 +56,10 @@ class LCAO_Deepks
5756
public:
5857
///(Unit: Ry) Correction energy provided by NN
5958
double E_delta = 0.0;
60-
///(Unit: Ry) \f$tr(\rho H_\delta), \rho = \sum_i{c_{i, \mu}c_{i,\nu}} \f$ (for gamma_only)
59+
///(Unit: Ry) \f$tr(\rho H_\delta), \rho = \sum_i{c_{i, \mu}c_{i,\nu}} \f$
6160
double e_delta_band = 0.0;
6261

63-
/// Correction term to the Hamiltonian matrix: \f$\langle\phi|V_\delta|\phi\rangle\f$ (for gamma only)
62+
/// Correction term to the Hamiltonian matrix: \f$\langle\phi|V_\delta|\phi\rangle\f$
6463
/// The first dimension is for k-points V_delta(k)
6564
std::vector<std::vector<T>> V_delta;
6665

source/module_hamilt_lcao/module_deepks/deepks_hmat.cpp

Lines changed: 0 additions & 117 deletions
This file was deleted.

source/module_hamilt_lcao/module_deepks/deepks_hmat.h

Lines changed: 0 additions & 31 deletions
This file was deleted.

source/module_hamilt_lcao/module_deepks/deepks_orbital.cpp

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,73 @@ void DeePKS_domain::cal_o_delta(const std::vector<TH>& dm_hl,
6969
return;
7070
}
7171

72+
template <typename TK, typename TH>
73+
void DeePKS_domain::collect_h_mat(const Parallel_Orbitals& pv,
74+
const std::vector<std::vector<TK>>& h_in,
75+
std::vector<TH>& h_out,
76+
const int nlocal,
77+
const int nks)
78+
{
79+
ModuleBase::TITLE("DeePKS_domain", "collect_h_tot");
80+
81+
// construct the total H matrix
82+
for (int k = 0; k < nks; k++)
83+
{
84+
#ifdef __MPI
85+
int ir = 0;
86+
int ic = 0;
87+
for (int i = 0; i < nlocal; i++)
88+
{
89+
std::vector<TK> lineH(nlocal - i, TK(0.0));
90+
91+
ir = pv.global2local_row(i);
92+
if (ir >= 0)
93+
{
94+
// data collection
95+
for (int j = i; j < nlocal; j++)
96+
{
97+
ic = pv.global2local_col(j);
98+
if (ic >= 0)
99+
{
100+
int iic = 0;
101+
if (ModuleBase::GlobalFunc::IS_COLUMN_MAJOR_KS_SOLVER(PARAM.inp.ks_solver))
102+
{
103+
iic = ir + ic * pv.nrow;
104+
}
105+
else
106+
{
107+
iic = ir * pv.ncol + ic;
108+
}
109+
lineH[j - i] = h_in[k][iic];
110+
}
111+
}
112+
}
113+
else
114+
{
115+
// do nothing
116+
}
117+
118+
Parallel_Reduce::reduce_all(lineH.data(), nlocal - i);
119+
120+
for (int j = i; j < nlocal; j++)
121+
{
122+
h_out[k](i, j) = lineH[j - i];
123+
h_out[k](j, i) = h_out[k](i, j); // H is a symmetric matrix
124+
}
125+
}
126+
#else
127+
for (int i = 0; i < nlocal; i++)
128+
{
129+
for (int j = i; j < nlocal; j++)
130+
{
131+
h_out[k](i, j) = h_in[k][i * nlocal + j];
132+
h_out[k](j, i) = h_out[k](i, j); // H is a symmetric matrix
133+
}
134+
}
135+
#endif
136+
}
137+
}
138+
72139
template void DeePKS_domain::cal_o_delta<double, ModuleBase::matrix>(const std::vector<ModuleBase::matrix>& dm_hl,
73140
const std::vector<std::vector<double>>& h_delta,
74141
// std::vector<double>& o_delta,
@@ -84,4 +151,18 @@ template void DeePKS_domain::cal_o_delta<std::complex<double>, ModuleBase::Compl
84151
const Parallel_Orbitals& pv,
85152
const int nks);
86153

154+
template void DeePKS_domain::collect_h_mat<double, ModuleBase::matrix>(
155+
const Parallel_Orbitals& pv,
156+
const std::vector<std::vector<double>>& h_in,
157+
std::vector<ModuleBase::matrix>& h_out,
158+
const int nlocal,
159+
const int nks);
160+
161+
template void DeePKS_domain::collect_h_mat<std::complex<double>, ModuleBase::ComplexMatrix>(
162+
const Parallel_Orbitals& pv,
163+
const std::vector<std::vector<std::complex<double>>>& h_in,
164+
std::vector<ModuleBase::ComplexMatrix>& h_out,
165+
const int nlocal,
166+
const int nks);
167+
87168
#endif

source/module_hamilt_lcao/module_deepks/deepks_orbital.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ namespace DeePKS_domain
2020
// which is defind as sum_mu,nu rho^{hl}_mu,nu <chi_mu|alpha>V(D)<alpha|chi_nu>
2121
// where rho^{hl}_mu,nu = C_{L\mu}C_{L\nu} - C_{H\mu}C_{H\nu}, L for LUMO, H for HOMO
2222

23-
// There are 1 subroutines in this file:
23+
// There are 2 subroutines in this file:
2424
// 1. cal_o_delta, which is used for O_delta calculation
25+
// 2. collect_h_mat, which collect H(k) data from different processes
2526

2627
template <typename TK, typename TH>
2728
void cal_o_delta(const std::vector<TH>& dm_hl,
@@ -30,6 +31,14 @@ void cal_o_delta(const std::vector<TH>& dm_hl,
3031
ModuleBase::matrix& o_delta,
3132
const Parallel_Orbitals& pv,
3233
const int nks);
34+
35+
// Collect data in h_in to matrix h_out. Note that left lower trianger in h_out is filled
36+
template <typename TK, typename TH>
37+
void collect_h_mat(const Parallel_Orbitals& pv,
38+
const std::vector<std::vector<TK>>& h_in,
39+
std::vector<TH>& h_out,
40+
const int nlocal,
41+
const int nks);
3342
} // namespace DeePKS_domain
3443

3544
#endif

source/module_hamilt_lcao/module_deepks/doxygen/conf_dpks

Lines changed: 0 additions & 9 deletions
This file was deleted.

source/module_hamilt_lcao/module_deepks/sphinx/requirements.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)