Skip to content

Commit 92523c6

Browse files
committed
fix a atom self must on last bug
1 parent 168628b commit 92523c6

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

source/module_cell/module_neighbor/sltk_grid.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ 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-
if (dr <= this->sradius2)
297+
if (dr != 0.0 && dr <= this->sradius2)
298298
{
299299
all_adj_info[fatom1.type][fatom1.natom].push_back(fatom2);
300300
}

source/module_cell/module_neighbor/sltk_grid_driver.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ Grid_Driver::~Grid_Driver()
2222
{
2323
}
2424

25-
void Grid_Driver::Find_atom(const int& ntype,
26-
const int& nnumber,
25+
void Grid_Driver::Find_atom(const UnitCell& ucell,
26+
const int ntype,
27+
const int nnumber,
2728
AdjacentAtomInfo* adjs)
2829
{
2930
ModuleBase::timer::tick("Grid_Driver", "Find_atom");
@@ -42,8 +43,10 @@ void Grid_Driver::Find_atom(const int& ntype,
4243
local_adjs->adjacent_tau.push_back(ModuleBase::Vector3<double>(atom->x, atom->y, atom->z));
4344
local_adjs->adj_num++;
4445
}
45-
local_adjs->adj_num--;
46-
46+
local_adjs->ntype.push_back(ntype);
47+
local_adjs->natom.push_back(nnumber);
48+
local_adjs->box.push_back(ModuleBase::Vector3<int>(0, 0, 0));
49+
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));
4750
ModuleBase::timer::tick("Grid_Driver", "Find_atom");
4851
return;
4952
}

source/module_cell/module_neighbor/sltk_grid_driver.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,9 @@ class Grid_Driver : public Grid
6363
// 2. And store results into parameter adjs when adjs is
6464
// NOT NULL
6565
//==========================================================
66-
void Find_atom(const int& ntype,
67-
const int& nnumber,
66+
void Find_atom(const UnitCell& ucell,
67+
const int ntype,
68+
const int nnumber,
6869
AdjacentAtomInfo* adjs = nullptr);
6970

7071
// cartesian_posi and ucell is deprecated 20241204 zhanghaochong
@@ -75,7 +76,7 @@ class Grid_Driver : public Grid
7576
const int& nnumber,
7677
AdjacentAtomInfo* adjs = nullptr)
7778
{
78-
this->Find_atom(ntype, nnumber, adjs);
79+
this->Find_atom(ucell, ntype, nnumber, adjs);
7980
}
8081

8182
//==========================================================

0 commit comments

Comments
 (0)