Skip to content

Commit ed63b35

Browse files
committed
Add UT for DeePKS H(R).
1 parent 06494a7 commit ed63b35

File tree

5 files changed

+461
-0
lines changed

5 files changed

+461
-0
lines changed

source/module_hamilt_lcao/module_deepks/test/LCAO_deepks_test.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,36 @@ void test_deepks<T>::check_vdpre()
293293
this->compare_with_ref("v_delta_precalc.dat", "vdpre_ref.dat");
294294
}
295295

296+
template <typename T>
297+
void test_deepks<T>::check_vdrpre()
298+
{
299+
std::vector<torch::Tensor> gevdm;
300+
torch::Tensor vdrpre;
301+
DeePKS_domain::cal_gevdm(ucell.nat, this->ld.inlmax, this->ld.inl2l, this->ld.pdm, gevdm);
302+
// normally use hR to get R_size, here use phialpha[0] only for test case
303+
int R_size = DeePKS_domain::get_R_size<double>(*(this->ld.phialpha[0]));
304+
DeePKS_domain::cal_vdr_precalc(PARAM.sys.nlocal,
305+
this->ld.lmaxd,
306+
this->ld.inlmax,
307+
ucell.nat,
308+
kv.nkstot,
309+
R_size,
310+
this->ld.inl2l,
311+
kv.kvec_d,
312+
this->ld.phialpha,
313+
gevdm,
314+
this->ld.inl_index,
315+
ucell,
316+
ORB,
317+
ParaO,
318+
Test_Deepks::GridD,
319+
vdrpre);
320+
// vdrpre is large, we only check the main element in Bravo lattice vector (0, 0, 0)
321+
torch::Tensor vdrpre_sliced = vdrpre.slice(0, 0, 1, 1).slice(1, 0, 1, 1).slice(2, 0, 1, 1);
322+
DeePKS_domain::check_tensor<double>(vdrpre_sliced, "vdr_precalc.dat", 0); // 0 for rank
323+
this->compare_with_ref("vdr_precalc.dat", "vdrpre_ref.dat");
324+
}
325+
296326
template <typename T>
297327
void test_deepks<T>::check_edelta(std::vector<torch::Tensor>& descriptor)
298328
{

source/module_hamilt_lcao/module_deepks/test/LCAO_deepks_test.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ class test_deepks
9999

100100
void check_vdpre();
101101

102+
void check_vdrpre();
103+
102104
void check_edelta(std::vector<torch::Tensor>& descriptor);
103105

104106
// calculate V_delta

source/module_hamilt_lcao/module_deepks/test/main_deepks.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ void run_tests(test_deepks<T>& test)
7575
test.check_orbpre();
7676

7777
test.check_vdpre();
78+
test.check_vdrpre();
7879

7980
test.check_edelta(descriptor);
8081
test.check_e_deltabands();

0 commit comments

Comments
 (0)