Skip to content

Commit 2689c6a

Browse files
committed
fix unit test mask error
1 parent 92523c6 commit 2689c6a

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

source/module_cell/module_neighbor/sltk_grid.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,12 @@ void Grid::Construct_Adjacent_final(const FAtom& fatom1,
294294

295295
double dr = delta_x * delta_x + delta_y * delta_y + delta_z * delta_z;
296296

297+
298+
// 20241204 zhanghaochong
299+
// dr == 0 means the same atom
300+
// the atom itself is neighbour atom, but the order itself must on last in the list.
301+
// so we will add itself on find atom function, and skip here.
302+
// I dont know why, but if we add self here, test 701_LJ_MD_Anderson will assert
297303
if (dr != 0.0 && dr <= this->sradius2)
298304
{
299305
all_adj_info[fatom1.type][fatom1.natom].push_back(fatom2);

source/module_cell/module_neighbor/sltk_grid_driver.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,25 @@ void Grid_Driver::Find_atom(const UnitCell& ucell,
4343
local_adjs->adjacent_tau.push_back(ModuleBase::Vector3<double>(atom->x, atom->y, atom->z));
4444
local_adjs->adj_num++;
4545
}
46+
// 20241204 zhanghaochong
47+
// for some unknown reason, the last neighbour atom must be it self
48+
// is self must in last, the order cannot be changed.
49+
// if self not in last, test 701_LJ_MD_Anderson will assert
4650
local_adjs->ntype.push_back(ntype);
4751
local_adjs->natom.push_back(nnumber);
4852
local_adjs->box.push_back(ModuleBase::Vector3<int>(0, 0, 0));
4953
local_adjs->adjacent_tau.push_back(ModuleBase::Vector3<double>(ucell.atoms[ntype].tau[nnumber].x, ucell.atoms[ntype].tau[nnumber].y, ucell.atoms[ntype].tau[nnumber].z));
5054
ModuleBase::timer::tick("Grid_Driver", "Find_atom");
5155
return;
5256
}
57+
void Grid_Driver::Find_atom(const UnitCell& ucell,
58+
const ModuleBase::Vector3<double>& cartesian_posi,
59+
const int& ntype,
60+
const int& nnumber,
61+
AdjacentAtomInfo* adjs)
62+
{
63+
this->Find_atom(ucell, ntype, nnumber, adjs);
64+
}
5365

5466
// filter_adjs delete not adjacent atoms in adjs
5567
void filter_adjs(const std::vector<bool>& is_adj, AdjacentAtomInfo& adjs)

source/module_cell/module_neighbor/sltk_grid_driver.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,7 @@ class Grid_Driver : public Grid
7474
const ModuleBase::Vector3<double>& cartesian_posi,
7575
const int& ntype,
7676
const int& nnumber,
77-
AdjacentAtomInfo* adjs = nullptr)
78-
{
79-
this->Find_atom(ucell, ntype, nnumber, adjs);
80-
}
81-
77+
AdjacentAtomInfo* adjs = nullptr);
8278
//==========================================================
8379
// EXPLAIN : The adjacent information for the input
8480
// cartesian_pos

0 commit comments

Comments
 (0)