Skip to content
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
ea9d72a
renew deepks unit test
xuan112358 Oct 26, 2024
9cf3fe5
renew deepks unit test
xuan112358 Oct 29, 2024
20e432e
reduce deepks-unitest's dependence on other modules
xuan112358 Oct 31, 2024
baa79bd
fix the bug of "Couldn't find orbital files for descriptor"
xuan112358 Oct 31, 2024
cee7445
fix bugs of read orbitals and init orb&ParaO
xuan112358 Nov 4, 2024
ac43ad8
fix the bug of DMR ; change the names of files being compared
xuan112358 Nov 7, 2024
24e0eda
fix: calculate H_V_delta
xuan112358 Nov 15, 2024
2589452
fix : cal_H_V_delta for check_e_deltabands
xuan112358 Nov 24, 2024
bd632ce
fix : Add pointer for GridD in deepks operator. use Test_Deepks::Grid…
xuan112358 Nov 26, 2024
1095bcb
fix : modify deepks operator to support insert_pair in initilize_HR i…
xuan112358 Dec 1, 2024
329329e
Merge branch 'develop' of https://github.com/deepmodeling/abacus-deve…
xuan112358 Dec 2, 2024
83a9c1e
fix : undefined reference of test_hsolver_sdft when using mpiicpx and…
xuan112358 Dec 2, 2024
afe6ed2
update intergrate test result. Note modification in deepks operator f…
xuan112358 Dec 3, 2024
44b9632
remove some useless code
xuan112358 Dec 3, 2024
4e26d04
remove nnr in deepks unittest
xuan112358 Dec 3, 2024
ebe2254
Merge branch 'deepmodeling:develop' into deepks_unittest
xuan112358 Dec 3, 2024
2dcef6e
fix: cutoff for overlap_orb_alpha_ in deepks test
xuan112358 Dec 26, 2024
d61b3ac
fix : psialpha ref of gamma only case , just change the order of neig…
xuan112358 Dec 26, 2024
4932a8c
fix uninitilized nmax_total in unitcell; simplize cal_descriptor
xuan112358 Dec 27, 2024
4f6ce2a
Merge branch 'develop' into deepks_unittest
xuan112358 Dec 29, 2024
b807175
restore deepks unit test in gamma-only case
xuan112358 Dec 29, 2024
2a47a7d
modify STRU of SiO2 in deepks test to reduce the number of neighbor a…
xuan112358 Dec 29, 2024
55f6b79
Merge branch 'develop' into deepks_unittest
xuan112358 Dec 29, 2024
379775f
fix a bug when merge
xuan112358 Dec 29, 2024
01c1aee
fix : setup nonlocal for ucell
xuan112358 Dec 30, 2024
5dd5a88
rename phialpha_ref.dat for multi-k
xuan112358 Dec 30, 2024
b4686e1
modify STRU of H2O_multik in deepks test to reduce the number of neig…
xuan112358 Dec 30, 2024
95c52bd
fix : add module paw dependence in deepks unittest
xuan112358 Dec 30, 2024
60e78b5
fix : rename descriptor file
xuan112358 Dec 31, 2024
43ad6d2
Merge branch 'develop' into deepks_unittest
xuan112358 Dec 31, 2024
3ab46f2
fix : modify result.ref for SiO2. The privious modification don't cha…
xuan112358 Dec 31, 2024
b508ab6
Merge branch 'develop' into deepks_unittest
xuan112358 Dec 31, 2024
4448b0e
Merge branch 'develop' into deepks_unittest
xuan112358 Jan 1, 2025
d589690
Merge branch 'develop' into deepks_unittest
xuan112358 Jan 2, 2025
884c789
Merge branch 'develop' into deepks_unittest
xuan112358 Jan 3, 2025
c2c992d
update CMakeLists.txt
xuan112358 Jan 3, 2025
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
3 changes: 1 addition & 2 deletions source/module_basis/module_ao/ORB_read.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void LCAO_Orbitals::init(
this->orbital_file.push_back(orbital_dir + orbital_file[it]);
}
}

this->descriptor_file = descriptor_file;
#ifdef __MPI
bcast_files(ntype, my_rank);
#endif
Expand Down Expand Up @@ -263,7 +263,6 @@ void LCAO_Orbitals::Read_Orbitals(std::ofstream& ofs_in,

delete[] this->Alpha;
this->Alpha = new Numerical_Orbital[1]; // not related to atom type -- remain to be discussed

this->Read_Descriptor(ofs_in, force_flag, my_rank);
}

Expand Down
2 changes: 1 addition & 1 deletion source/module_basis/module_nao/two_center_bundle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void TwoCenterBundle::tabulate()
{
overlap_orb_alpha = std::unique_ptr<TwoCenterIntegrator>(new TwoCenterIntegrator);
overlap_orb_alpha->tabulate(*orb_, *alpha_, 'S', nr, cutoff);
ModuleBase::Memory::record("TwoCenterTable: Descriptor", overlap_orb_beta->table_memory());
ModuleBase::Memory::record("TwoCenterTable: Descriptor", overlap_orb_alpha->table_memory());
}

if (orb_onsite_)
Expand Down
1 change: 1 addition & 0 deletions source/module_cell/unitcell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,7 @@ void UnitCell::cal_nwfc(std::ofstream& log) {
//========================
this->lmax = 0;
this->nmax = 0;
this->nmax_total = 0;
for (int it = 0; it < ntype; it++) {
lmax = std::max(lmax, atoms[it].nwl);
for (int l = 0; l < atoms[it].nwl + 1; l++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ void hamilt::DeePKS<hamilt::OperatorLCAO<TK, TR>>::initialize_HR(const Grid_Driv
auto* paraV = this->hR->get_paraV(); // get parallel orbitals from HR
// TODO: if paraV is nullptr, AtomPair can not use paraV for constructor, I will repair it in the future.

// this->H_V_delta = new HContainer<TR>(paraV);
this->H_V_delta = new HContainer<TR>(paraV);
if (std::is_same<TK, double>::value)
{
this->H_V_delta = new HContainer<TR>(paraV);
//this->H_V_delta = new HContainer<TR>(paraV);
this->H_V_delta->fix_gamma();
}

Expand Down Expand Up @@ -123,10 +123,10 @@ void hamilt::DeePKS<hamilt::OperatorLCAO<TK, TR>>::initialize_HR(const Grid_Driv
R_index2.y - R_index1.y,
R_index2.z - R_index1.z,
paraV);
if (std::is_same<TK, double>::value)
{
this->H_V_delta->insert_pair(tmp);
}
// if (std::is_same<TK, double>::value)
// {
this->H_V_delta->insert_pair(tmp);
// }
}
}
if (pre_cal_nlm)
Expand All @@ -135,15 +135,14 @@ void hamilt::DeePKS<hamilt::OperatorLCAO<TK, TR>>::initialize_HR(const Grid_Driv
}
}
// allocate the memory of BaseMatrix in HR, and set the new values to zero
if (std::is_same<TK, double>::value)
{
// only gamma-only has full size of Hamiltonian of DeePKS now,
// multi-k keep same size of nonlocal operator, H_V_delta will be allocated by hR
this->H_V_delta->allocate(nullptr, true);
// expand hR with H_V_delta, only gamma-only case now
this->hR->add(*this->H_V_delta);
this->hR->allocate(nullptr, false);
}
// if (std::is_same<TK, double>::value)
// {
this->H_V_delta->allocate(nullptr, true);
// expand hR with H_V_delta
// update : for computational rigor, gamma-only and multi-k cases both have full size of Hamiltonian of DeePKS now
this->hR->add(*this->H_V_delta);
this->hR->allocate(nullptr, false);
// }

ModuleBase::timer::tick("DeePKS", "initialize_HR");
}
Expand All @@ -165,11 +164,11 @@ void hamilt::DeePKS<hamilt::OperatorLCAO<TK, TR>>::contributeHR()
GlobalC::ld.cal_descriptor(this->ucell->nat);
GlobalC::ld.cal_gedm(this->ucell->nat);

// recalculate the H_V_delta
if (this->H_V_delta == nullptr)
{
this->H_V_delta = new hamilt::HContainer<TR>(*this->hR);
}
// // recalculate the H_V_delta
// if (this->H_V_delta == nullptr)
// {
// this->H_V_delta = new hamilt::HContainer<std::complex<double>>(*this->hR);
// }
this->H_V_delta->set_zero();
this->calculate_HR();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class DeePKS<OperatorLCAO<TK, TR>> : public OperatorLCAO<TK, TR>
// LCAO_Deepks* ld = nullptr;

const UnitCell* ucell = nullptr;
Grid_Driver* gridD = nullptr;

const Grid_Driver* gd = nullptr;

Expand Down
6 changes: 3 additions & 3 deletions source/module_hamilt_lcao/module_deepks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ if(ENABLE_DEEPKS)
endif()

# I will rewrite the test later, the current test rely on too many modules
# if(BUILD_TESTING)
# add_subdirectory(test)
# endif()
if(BUILD_TESTING)
add_subdirectory(test)
endif()
endif()

Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ void LCAO_Deepks::cal_projected_DM(const elecstate::DensityMatrix<TK, double>* d

void LCAO_Deepks::check_projected_dm()
{
const std::string file_projdm = PARAM.globalv.global_out_dir + "deepks_projdm.dat";
const std::string file_projdm = PARAM.globalv.global_out_dir + "pdm.dat";
std::ofstream ofs(file_projdm.c_str());

const int pdm_size = (this->lmaxd * 2 + 1) * (this->lmaxd * 2 + 1);
Expand Down
21 changes: 5 additions & 16 deletions source/module_hamilt_lcao/module_deepks/cal_descriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ void LCAO_Deepks::cal_descriptor(const int nat) {
return;
}

// init pdm_tensor and d_tensor
torch::Tensor tmp;

// if pdm_tensor and d_tensor is not empty, clear it !!
if (!this->d_tensor.empty())
{
Expand All @@ -63,23 +60,15 @@ void LCAO_Deepks::cal_descriptor(const int nat) {
for (int inl = 0; inl < this->inlmax; ++inl)
{
const int nm = 2 * inl_l[inl] + 1;
tmp = torch::ones({nm, nm},
torch::TensorOptions().dtype(torch::kFloat64));

for (int m1 = 0; m1 < nm; ++m1)
{
for (int m2 = 0; m2 < nm; ++m2)
{
tmp.index_put_({m1, m2}, this->pdm[inl][m1 * nm + m2]);
}
}
torch::TensorOptions options = torch::TensorOptions()
.dtype(torch::kFloat64)
.requires_grad(true);

// torch::Tensor tmp = torch::from_blob(this->pdm[inl], { nm, nm },
// torch::requires_grad());
torch::Tensor tmp = torch::from_blob(this->pdm[inl], { nm, nm }, options).clone();

tmp.requires_grad_(true);
this->pdm_tensor.push_back(tmp);
this->d_tensor.push_back(torch::ones({nm}, torch::requires_grad(true)));
this->d_tensor.push_back(torch::ones({nm}, options));
}

// cal d_tensor
Expand Down
64 changes: 33 additions & 31 deletions source/module_hamilt_lcao/module_deepks/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,44 +1,46 @@
add_executable(
test_deepks
main_deepks.cpp klist_1.cpp LCAO_deepks_test_prep.cpp LCAO_deepks_test.cpp nnr.cpp
main_deepks.cpp klist_1.cpp LCAO_deepks_test_prep.cpp LCAO_deepks_test.cpp
../../../module_cell/unitcell.cpp
../../../module_cell/atom_spec.cpp
../../../module_cell/atom_pseudo.cpp
../../../module_cell/read_atoms.cpp
../../../module_cell/setup_nonlocal.cpp
../../../module_cell/pseudo.cpp
../../../module_cell/read_pp.cpp
../../../module_cell/read_pp_complete.cpp
../../../module_cell/read_pp_upf100.cpp
../../../module_cell/read_pp_upf201.cpp
../../../module_cell/read_pp_vwr.cpp
../../../module_cell/read_pp_blps.cpp
../../../module_hamilt_pw/hamilt_pwdft/soc.cpp
../../../module_io/output.cpp
../../../module_elecstate/read_pseudo.cpp
../../../module_elecstate/cal_nelec_nband.cpp
../../../module_elecstate/module_dm/density_matrix.cpp
../../../module_elecstate/module_dm/density_matrix_io.cpp
../../../module_hamilt_lcao/module_hcontainer/base_matrix.cpp
../../../module_hamilt_lcao/module_hcontainer/hcontainer.cpp
../../../module_hamilt_lcao/module_hcontainer/atom_pair.cpp
../../../module_hamilt_lcao/module_hcontainer/func_transfer.cpp
../../../module_hamilt_lcao/module_hcontainer/func_folding.cpp
../../../module_hamilt_lcao/module_hcontainer/transfer.cpp
../../../module_hamilt_lcao/hamilt_lcaodft/operator_lcao/deepks_lcao.cpp
../../../module_hamilt_lcao/hamilt_lcaodft/operator_lcao/operator_lcao.cpp
../../../module_hamilt_general/operator.cpp
)

if(ENABLE_COVERAGE)
add_coverage(test_deepks)
endif()

get_target_property(ABACUS_LINK_LIBRARIES ${ABACUS_BIN_NAME} LINK_LIBRARIES)
target_link_libraries(
test_deepks
base cell symmetry md surchem xc_
neighbor orb io_basic io_advanced relax gint driver esolver hsolver psi elecstate
hamilt_general hamilt_pwdft hamilt_lcao tddft hamilt_ofdft hamilt_stodft planewave
pthread vdw dftu deltaspin hcontainer
deepks device numerical_atomic_orbitals container psi_initializer psi_overall_init
${ABACUS_LINK_LIBRARIES}
base device parameter deepks psi planewave neighbor container
orb gint numerical_atomic_orbitals paw
${math_libs}
)

if(ENABLE_PAW)
target_link_libraries(
test_deepks
paw
)
endif()

if(USE_ELPA)
target_link_libraries(
test_deepks
genelpa
)
endif()
if(USE_CUDA)
target_link_libraries(diag_cusolver)
if(ENABLE_COVERAGE)
add_coverage(test_deepks)
endif()

if (ENABLE_LIBRI)
target_link_libraries(test_deepks
ri)
endif()

install(
TARGETS test_deepks
Expand Down
Loading
Loading