From 3379e67bb7fb1be4dd367396918e3ad023247653 Mon Sep 17 00:00:00 2001 From: Gavin Ridley Date: Tue, 19 Nov 2019 17:00:42 -0500 Subject: [PATCH] use relative distances for coincidence test in hex lattice --- src/lattice.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lattice.cpp b/src/lattice.cpp index 6f10ed358..092ff3d11 100644 --- a/src/lattice.cpp +++ b/src/lattice.cpp @@ -895,8 +895,12 @@ HexLattice::get_indices(Position r, Direction u) const Position r_t = get_local_position(r, i_xyz); // calculate distance double d = r_t.x*r_t.x + r_t.y*r_t.y; - // check for coincidence - bool on_boundary = coincident(d, d_min); + // check for coincidence. Because the numerical error incurred + // in hex geometry is higher than other geometries, the relative + // coincidence is checked here so that coincidence is successfully + // detected on large hex lattice with particles far from the origin + // which have rounding errors larger than the FP_COINCIDENT thresdhold. + bool on_boundary = coincident(1.0, d_min/d); if (d < d_min || on_boundary) { // normalize r_t and find dot product r_t /= std::sqrt(d);