From bd9acff6bed719e2d7c675df44912b5d50a31c76 Mon Sep 17 00:00:00 2001 From: YuLiu98 Date: Mon, 13 Nov 2023 21:35:25 +0800 Subject: [PATCH] Fix: serach_radius is fixed to 0.01 Bohr in test_neighbor --- docs/advanced/input_files/input-main.md | 3 +- .../module_neighbor/sltk_atom_arrange.cpp | 49 ++++++++++--------- .../module_esolver/esolver_ks_lcao_elec.cpp | 10 ++-- 3 files changed, 34 insertions(+), 28 deletions(-) diff --git a/docs/advanced/input_files/input-main.md b/docs/advanced/input_files/input-main.md index b31402c55c1..2c9558d31cc 100644 --- a/docs/advanced/input_files/input-main.md +++ b/docs/advanced/input_files/input-main.md @@ -394,7 +394,7 @@ These variables are used to control general system parameters. - get_wf: Envelope function for LCAO basis. Please see the explanation for variable `nbands_istate` - md: molecular dynamics - test_memory : checks memory required for the calculation. The number is not quite reliable, please use it with care - - test_neighbour : only performs neighbouring atom search + - test_neighbour : only performs neighbouring atom search, please specify a positive [search_radius](#search_radius) manually. - gen_bessel : generates projectors (a series of Bessel functions) for DeePKS; see also keywords bessel_descriptor_lmax, bessel_descriptor_rcut and bessel_descriptor_tolerence. A file named `jle.orb` will be generated which contains the projectors. An example is provided in examples/H2O-deepks-pw - get_S : only works for multi-k calculation with LCAO basis. Generates and writes the overlap matrix to a file named `SR.csr` in the working directory. The format of the file will be the same as that generated by [out_mat_hs2](#out_mat_hs2) - **Default**: scf @@ -825,6 +825,7 @@ These variables are used to control the numerical atomic orbitals related parame - **Type**: Real - **Description**: Searching radius in finding the neighbouring atoms. By default the radius will be automatically determined by the cutoffs of orbitals and nonlocal beta projectors. - **Default**: -1 +- **Unit**: Bohr ### search_pbc diff --git a/source/module_cell/module_neighbor/sltk_atom_arrange.cpp b/source/module_cell/module_neighbor/sltk_atom_arrange.cpp index 4e7d49bd410..2e9a4ab99c2 100644 --- a/source/module_cell/module_neighbor/sltk_atom_arrange.cpp +++ b/source/module_cell/module_neighbor/sltk_atom_arrange.cpp @@ -116,28 +116,33 @@ void atom_arrange::search( if(test_only) { ofs_in << " " << std::setw(5) << "Type" << std::setw(5) << "Atom" << std::setw(8) << "AdjNum" << std::endl; - for (int it = 0;it < ucell.ntype;it++) - { - for (int ia = 0;ia < ucell.atoms[it].na;ia++) - { - grid_d.Find_atom(ucell, ucell.atoms[it].tau[ia], it, ia); - - ofs_in << " " << std::setw(5) << it << std::setw(5) << ia << std::setw(8) << grid_d.getAdjacentNum()+1 << std::endl; - - for(int ad=0; ad < grid_d.getAdjacentNum()+1; ad++) - { - ModuleBase::Vector3 tau = grid_d.getAdjacentTau(ad); - ModuleBase::Vector3 box = grid_d.getBox(ad); - std::cout << std::setw(15) << tau.x << " " << std::setw(15) << tau.y << " " << std::setw(15) << tau.z << " " - << std::setw(8) << box.x << std::setw(8) << box.y << std::setw(8) << box.z << std::endl; - } - } - } - ofs_in << "search neighboring atoms done." << std::endl; - } - - ModuleBase::timer::tick("atom_arrange","search"); - return; + std::cout << std::setw(8) << "Labels" << std::setw(15) << "tau.x" << std::setw(15) << "tau.y" << std::setw(15) + << "tau.z" << std::setw(8) << "box.x" << std::setw(8) << "box.y" << std::setw(8) << "box.z" + << std::endl; + for (int it = 0; it < ucell.ntype; it++) + { + for (int ia = 0; ia < ucell.atoms[it].na; ia++) + { + grid_d.Find_atom(ucell, ucell.atoms[it].tau[ia], it, ia); + + ofs_in << " " << std::setw(5) << it << std::setw(5) << ia << std::setw(8) << grid_d.getAdjacentNum() + 1 + << std::endl; + + for (int ad = 0; ad < grid_d.getAdjacentNum() + 1; ad++) + { + ModuleBase::Vector3 tau = grid_d.getAdjacentTau(ad); + ModuleBase::Vector3 box = grid_d.getBox(ad); + std::cout << std::setw(8) << ucell.atoms[it].label + std::to_string(ia + 1) << std::setw(15) + << tau.x << " " << std::setw(15) << tau.y << " " << std::setw(15) << tau.z << " " + << std::setw(8) << box.x << std::setw(8) << box.y << std::setw(8) << box.z << std::endl; + } + } + } + ofs_in << "search neighboring atoms done." << std::endl; + } + + ModuleBase::timer::tick("atom_arrange", "search"); + return; } diff --git a/source/module_esolver/esolver_ks_lcao_elec.cpp b/source/module_esolver/esolver_ks_lcao_elec.cpp index 154163889b0..acefc0900b2 100644 --- a/source/module_esolver/esolver_ks_lcao_elec.cpp +++ b/source/module_esolver/esolver_ks_lcao_elec.cpp @@ -353,11 +353,11 @@ void ESolver_KS_LCAO::othercalculation(const int istep) if (GlobalV::CALCULATION == "test_neighbour") { // test_search_neighbor(); - GlobalV::SEARCH_RADIUS = atom_arrange::set_sr_NL(GlobalV::ofs_running, - GlobalV::OUT_LEVEL, - GlobalC::ORB.get_rcutmax_Phi(), - GlobalC::ucell.infoNL.get_rcutmax_Beta(), - GlobalV::GAMMA_ONLY_LOCAL); + if (GlobalV::SEARCH_RADIUS < 0) + { + std::cout << " SEARCH_RADIUS : " << GlobalV::SEARCH_RADIUS << std::endl; + std::cout << " please make sure search_radius > 0" << std::endl; + } atom_arrange::search(GlobalV::SEARCH_PBC, GlobalV::ofs_running,