From b0342986ae5ea897e872e934ae6325b33b40be4e Mon Sep 17 00:00:00 2001 From: Max Graml <78024843+MGraml@users.noreply.github.com> Date: Sun, 14 Jun 2026 12:47:27 +0200 Subject: [PATCH] RIRS: fix bounds of grids for geometries with mixed atom kinds (#5391) Co-authored-by: Claude --- src/gw_large_cell_gamma_ri_rs.F | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gw_large_cell_gamma_ri_rs.F b/src/gw_large_cell_gamma_ri_rs.F index 9ca1085bec..7ef7f0267c 100644 --- a/src/gw_large_cell_gamma_ri_rs.F +++ b/src/gw_large_cell_gamma_ri_rs.F @@ -242,7 +242,9 @@ CONTAINS atomic_center(:) = particle_set(atom_idx)%r(:) start_idx = ri_rs_grid_offsets(atom_idx) - end_idx = ri_rs_grid_offsets(atom_idx + 1) - 1 + ! offsets are filled in kind-grouped order, so offsets(atom_idx+1) belongs to an + ! unrelated atom when elements are interleaved in the geometry; span from own kind + end_idx = start_idx + bs_env%ri_rs%grid_cache(ikind)%npts - 1 !! Shift the cached origin grid by the atom's center ri_rs_grid_points(1, start_idx:end_idx) = bs_env%ri_rs%grid_cache(ikind)%raw_points(1, :) + atomic_center(1)