Skip to content

Commit 487555c

Browse files
authored
Update update_cell.cpp to avoid numerical precision error issues. (#6594)
1 parent 9ac9626 commit 487555c

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

source/source_cell/update_cell.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -496,12 +496,13 @@ void periodic_boundary_adjustment(Atom* atoms,
496496
atom->taud[ia][ik] -= 1.0;
497497
}
498498
}
499-
if (atom->taud[ia].x < 0
500-
|| atom->taud[ia].y < 0
501-
|| atom->taud[ia].z < 0
502-
|| atom->taud[ia].x >= 1.0
503-
|| atom->taud[ia].y >= 1.0
504-
|| atom->taud[ia].z >= 1.0)
499+
const double eps = 1e-12;
500+
if (atom->taud[ia].x < -eps
501+
|| atom->taud[ia].y < -eps
502+
|| atom->taud[ia].z < -eps
503+
|| atom->taud[ia].x >= 1.0+eps
504+
|| atom->taud[ia].y >= 1.0+eps
505+
|| atom->taud[ia].z >= 1.0+eps)
505506
{
506507
GlobalV::ofs_warning << " atom type=" << it + 1 << " atom index=" << ia + 1 << std::endl;
507508
GlobalV::ofs_warning << " direct coordinate=" << atom->taud[ia].x << " "

0 commit comments

Comments
 (0)