Skip to content

feat: add validation for grid spacing in AutoGrid #2453

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

rahul-flex
Copy link
Contributor

@rahul-flex rahul-flex commented May 13, 2025

Extend Simulation._post_init_validators to compute the minimum cell size (dl) after AutoGrid construction and validate it against threshold [1e-7 µm]. Addresses this issue.

Note: The pytest takes a lot of time and memory to run locally, because it builds the full grid before running the dl check.

(3e21, True), # dl<1e-6 → fail
(1e14, False), # dl>1e-7 → pass
],
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you just make the simulation size 1e7 smaller wouldn't that avoid the long runtime of the test?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it reduces the runtime. Thanks!

("freq0", "expect_error"),
[
(3e21, True), # dl<1e-6 → fail
(1e14, False), # dl>1e-7 → pass
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1e-6 for both

@@ -3596,6 +3619,9 @@ def _post_init_validators(self) -> None:
self._validate_custom_source_time()
self._validate_mode_object_bends()
self._warn_mode_object_pml()
_validate_min_grid_spacing(
self.grid, threshold=1e-7, msg_prefix=f"'{self.__class__.__name__}'"
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's do 1e-6, even that sounds too large, but to be consistent with the uniform grid validator. Or maybe we should increase the threshold for both? I don't know if I missed anything in the other discussion but wouldn't even 1e-5 be more than reasonable (hard to imagine any simulation that needs to go even below 1e-4). @yaugenst ?

@yaugenst-flex yaugenst-flex linked an issue May 19, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Validate units after AutoGrid generation
2 participants