-
Notifications
You must be signed in to change notification settings - Fork 63
Validate against EMEFieldMonitor with EMELengthSweep #2698
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
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 files reviewed, no comments
@FilipeFcp we will also need to update this notebook: How should we handle that? It is inconvenient to have to run a separate simulation just to visualize the field. I guess we could just get rid of the field visualization in that example. |
Well, we do a separate run in the EME part of this notebook. But I think we can just remove the visualization for the taper. It is not very informative, and we already presented it in the previous example. |
Great, sounds good. I'll make a PR to remove it from that notebook. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No files reviewed, no comments
Diff CoverageDiff: origin/develop...HEAD, staged and unstaged changes
Summary
|
docs PR is merged, @yaugenst-flex let me know when you want me to merge this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @caseyflex this looks good to go, only a minor comment. Sorry this slipped through the cracks!
for i, monitor in enumerate(self.monitors): | ||
if isinstance(monitor, EMEFieldMonitor): | ||
raise SetupError( | ||
f"Monitor at 'monitors[{i}]' is an 'EMEFieldMonitor', " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For GUI it's nice to also have the monitor name, we recently switched to including that for a lot of similar validator errors. So let's do Monitor {monitor.name} at 'monitors[{i}]' is
here.
docs PR: flexcompute/tidy3d-notebooks#340
EMEFieldMonitor gives misleading / incorrect results in EME simulations with EMELengthSweep. This is because while the coefficients and smatrix are swept correctly, the field data is still calculated on the original simulation geometry and grid.
This PR just validates against the combination.
Greptile Summary
This PR addresses a technical limitation in EME (Eigenmode Expansion) simulations by adding validation to prevent the problematic combination of
EMEFieldMonitor
withEMELengthSweep
. The core issue is that during length sweeps, while the EME coefficients and S-matrix are correctly recalculated for each swept geometry, theEMEFieldMonitor
field data remains calculated on the original simulation geometry and grid, creating a fundamental mismatch that leads to misleading or incorrect field results.The solution implements validation in the
_validate_sweep_spec
method of the EME simulation class that checks all monitors and raises aSetupError
if anEMEFieldMonitor
is detected when the sweep specification is anEMELengthSweep
. This validation follows the existing pattern used for other incompatible monitor/sweep combinations likeEMEPeriodicitySweep
andEMEFreqSweep
.The changes also include comprehensive test updates to ensure the validation works correctly and that existing length sweep tests continue to function by filtering out
EMEFieldMonitor
instances from monitor lists when testing sweep functionality. A changelog entry documents this as a fix that disallows the problematic combination.This approach prioritizes user safety by preventing incorrect results rather than attempting to fix the underlying architectural complexity of making field monitors work properly with geometry changes during sweeps.
Confidence score: 5/5