Skip to content
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

minor fix bloch validator #1930

Merged
merged 1 commit into from
Aug 30, 2024
Merged

minor fix bloch validator #1930

merged 1 commit into from
Aug 30, 2024

Conversation

tylerflex
Copy link
Collaborator

This was just something I noticed. The old code led to false positive warnings if the test_val was just a little bit less than an integer.. this is more robust.

tidy3d/components/simulation.py Show resolved Hide resolved
# "order 0 will not correspond to the angle of propagation "
# "of the source. Consider using 'BlochBoundary.from_source()'.",
# custom_loc=["boundary_spec", "xyz"[dim]],
# )
Copy link
Collaborator

Choose a reason for hiding this comment

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

The way I read this, this was specifically added to avoid confusion when using such a source + a DiffractionMonitor. How about we only warn in that case then, i.e. check if a DiffractionMonitor is present rather than say "if using a diffraction monitor". This should fix your adjoint-specific annoyance with these warnings.

I remember at least one user was confused about this at the time.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So I tried doing this, but the way our validators are set up in simulation, these don't have access to the monitors unfortunately. If I try to change anything, it breaks a ton of tests.. not sure if it's better to try to just rearrange things in simulation or simply remove the warning

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I came up with a solution that works, just added a separate validator for "monitors" and configured things to only check this condition if DiffractionMonitors are present there. seems to work properly.

docs/notebooks Outdated
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

develop submodule is out of date..

@tylerflex tylerflex added 2.7 will go into version 2.7.* .3 labels Aug 30, 2024
@momchil-flex
Copy link
Collaborator

This still doesn't look quite right though. The warning about the source k not being an integer multiple of the Bloch vector should always be there, even without diffraction monitors. This is because this setup seems unphysical (the source does not match the boundary conditions) and is extremely unlikely to be correct. I'm not sure why we left it as warning and not a straight out error but either way it should be there even without DiffractionMonitor.

@tylerflex
Copy link
Collaborator Author

This still doesn't look quite right though. The warning about the source k not being an integer multiple of the Bloch vector should always be there, even without diffraction monitors. This is because this setup seems unphysical (the source does not match the boundary conditions) and is extremely unlikely to be correct. I'm not sure why we left it as warning and not a straight out error but either way it should be there even without DiffractionMonitor.

Unless I'm mistaken, this is how I have it set up. There are two validators, one checks that k is an integer multiple of the Bloch vector and is always triggered. The other checks that the Bloch vector is exactly equal to k, and is only checked now if a diffraction monitor is present. Could you take another look and verify whether it's consistent?

Copy link
Collaborator

@momchil-flex momchil-flex left a comment

Choose a reason for hiding this comment

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

Ah sorry my bad. Then it's just the docstring that needs to be changed.

tidy3d/components/simulation.py Outdated Show resolved Hide resolved
@momchil-flex momchil-flex merged commit 94d3284 into develop Aug 30, 2024
15 checks passed
@momchil-flex momchil-flex deleted the tyler/fix/bloch branch August 30, 2024 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.7 will go into version 2.7.* .3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants