Repository navigation
Round the grid origin to a whole pixel - #3333
Closed
smartalecH wants to merge 1 commit into
Closed
smartalecH wants to merge 1 commit into
smartalecH wants to merge 1 commit into
Conversation
geometry_center was rounded to the nearest half pixel, so a non-integer number of pixels gave the grid an odd origin. The Yee lattice assumes an even origin (see grid_volume::icenter), so sources and monitors were placed half a pixel from the fields and materials, and source deposition depended on the chunk layout. Fixes #1051. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
Author
|
Folded into #3298, which now contains this change (approved in review there). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Alternative to #3298 for #1051, opened as a draft so we can decide which approach is right.
Root cause.
grid_volume::set_origin(const vec&)rounds to the nearest half pixel, so anygeometry_centerthat is not a whole number of pixels gives the grid an odd originio(e.g.0.1at resolution 15 is 1.5 px). The Yee lattice assumesiois even —icenter()documents this andcenter_origin()enforces it — andloop_in_chunks(vec2diel_floor) andgrid_volume::interpolateplace each component on absolute ivec parities. With an oddiothose disagree with where fields and materials are actually stored, so:get_field_point, DFT monitors and otherloop_in_chunksreadouts are likewise half a pixel off,Fix. Round the origin to a whole pixel, as
center_origin()already does, and roundSimulation.geometry_centerthe same way in Python so the two agree. The rounding is documented.Evidence (2D/3D, all six components; point, line, plane and boundary-straddling sources on/off chunk splits; random non-pixel
geometry_center):geometry_centerpre-rounded-np 3/-np 4vs-np 1, 40 configsThe middle column is the key point: master's existing source-deposition code is already chunk-independent once
iois even, so none of #3298'sloop_in_chunks/fix_boundary_sourceschanges are needed.Behavior change. A non-pixel
geometry_centernow snaps to the nearest pixel instead of the nearest half pixel. Such runs previously misplaced sources and monitors relative to the structure.Tests: the chunk-boundary tests from #3298 (unchanged), plus
test_geometry_center_rounded_to_pixel.🤖 Generated with Claude Code