Repository navigation
Preserve double precision in VACUUM observer-grid construction - #294
matt-pharr merged 4 commits into
Conversation
|
@claude review this |
|
Claude finished @logan-nc's task in 42s —— View job Review of PR #294: Cartesian vacuum query coordinatesI reviewed Summary: The opt-in design is sound.
Issues
Minor
Not verifiedI did not review the test logic in Recommendation: Fix item 1 (the line-length problem at |
|
@krystophny the llm says your implementation is sound, but as a human I see a lot of new code spent changing what is an intended behavior with no clear use case motivating so much change. The grid is intentionally snapped because the Fortran vacuum code gives incorrect numbers for near-surface evaluation points. This is something @jhalpern30 is improving in his Julia implantation. The GPEC behavior has been around forever and is the official io... the primary approach to using gpec should be to use this irregular grid in your post processing. You can interpolation regular grid from there if you wish. If you have a use case where you need the incorrect singularity-caused garbage at points near the control surface please explain the workflow a bit to us in human terms. In my experience, the post-processing is worse this way. If it's just the real4 rounding of unsnapped points away from the controlsurface that's the issue, i think this could be a much more simple fix to move those to real8 without requiring a new opt-in flag. I fully support that. The new test suite seems like it would be a good direction to go if we planned a long term modernization of the Fortran code but is perhaps a bit odd to add here in a limited capacity just before the final Fortran release (1.6) is expected. I'd be curious what @matt-pharr and @parkjk think about the pros/cons of it. |
|
Agreed with @logan-nc regarding the point-snapping - the vacuum code can't properly evaluate the vacuum fields just outside but not on the surface, it can only do exactly on the surface or sufficiently far from it, hence the snapping behavior. It seems that this PR would allow (but not fix) evaluation much closer than currently allowed, which I think @logan-nc has shown can already be rather finicky in its current state. And agreed that interpolating these values on whatever grid you want in postprocessing is probably the way to go. At some point I'll be implementing the near-singular quadrature in Julia, so if you have a motivating example that needs precise fields very close to the surface, I'd be happy to do it sooner rather than later. |
|
Thanks for checking this. I reduced the code changes to the minimum and do the rest in post-processing now. |
|
@logan-nc I agree with your comments about tests + additions. Let's keep it minimal. This PR is good as-revised. |
VACUUM constructs its Cartesian observer grid through single-precision temporary arrays and single-precision grid-spacing expressions. This loses coordinate precision even though the caller and stored observer coordinates use double precision. The patch changes the two temporary-array declarations to
REAL(r8)and the two spacing constants to1.0_r8.Thanks to Nik and Jake for explaining the near-surface quadrature limitation. This four-line patch preserves the existing snapping, surface traces, evaluator, public API, and output formats. Grid resampling belongs in downstream postprocessing, where snapped or unsupported samples can be masked without accepting inaccurate near-surface evaluations. The separate field-content limitation in issue 171 remains open.
Downstream native-cell resampling is available in rmp_torque, with explicit validity masks and separate inside/outside interpolation. TC24 pins the same feature on top of its existing converter lineage.
Validation against upstream
developat5be646f2d67f0d6002c531ff2b855e701103bbec: the independent weighted-endpoint grid oracle fails on the base at4.30e-8relative error and passes this patch at1.48e-16. Independent inside/outside surface-trace checks pass on both versions, with identical snapped coordinates, flags, and printed fields. The native GPEC/DCON build and both registered focused CTests pass. The regression harness is retained outside this PR; the upstream diff contains only these four precision changes. Gremlin remains blocked before capture by the existing declared-Git-dependency tool defect; these results come from native CMake/CTest.Chris&AI