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

Homogeneous medium validators with custom medium #1373

Closed
momchil-flex opened this issue Jan 10, 2024 · 8 comments
Closed

Homogeneous medium validators with custom medium #1373

momchil-flex opened this issue Jan 10, 2024 · 8 comments
Assignees

Comments

@momchil-flex
Copy link
Collaborator

We have a validator that is meant to validate that a diffraction monitor is in a homogeneous medium. However, what it actually does is compute the list of mediums that the plane intersects, and make sure that there's only one element in that list. This does not work for custom medium, which is a single medium which may nevertheless still be inhomogeneous physically. This same issue applies to the validator for plane wave/gaussian beam sources, as well as, in some sense, to the [TFSF validator](def _validate_tfsf_structure_intersections) about structure intersections. I am not sure what's a good way to fix this:

  • Error if custom medium found
  • Just warn for the user to make sure that it's homogeneous
  • Actually sample the permittivity and check if it is homogeneous
@tylerflex
Copy link
Collaborator

I think the warning approach might make the most sense to me, in the sense that it's the least restrictive and also fastest.
Maybe we just exclude any custom media from the list and warn?

@momchil-flex
Copy link
Collaborator Author

In fact looking at the solver, TFSF where the source surface crosses a custom medium would straight up not work, or the results may be wrong, even if the custom medium is uniform on those surfaces. We should just validate that out.

For plane wave, diffraction monitor, we could just warn if in custom medium.

@weiliangjin2021
Copy link
Collaborator

What about checking if custom medium is uniform, if not, warn that it should be uniform on the plane?

In fact looking at the solver, TFSF where the source surface crosses a custom medium would straight up not work, or the results may be wrong, even if the custom medium is uniform on those surfaces.

@momchil-flex could you explain a bit more why it doesn't work even for a uniform custom medium?

@momchil-flex
Copy link
Collaborator Author

What about checking if custom medium is uniform, if not, warn that it should be uniform on the plane?

If we actually do the check, we should error if it's not uniform, not warn. But I wonder if the check may be expensive for e.g. a large plane, e.g. a large-area metalens?

In fact looking at the solver, TFSF where the source surface crosses a custom medium would straight up not work, or the results may be wrong, even if the custom medium is uniform on those surfaces.

@momchil-flex could you explain a bit more why it doesn't work even for a uniform custom medium?

Actually I don't remember anymore what I saw when I first commented this. Perhaps I was thinking that the custom medium is ignored in the auxiliary simulation - but now that I look again, I can't really tell. Maybe best to try...

@weiliangjin2021
Copy link
Collaborator

What about checking if custom medium is uniform, if not, warn that it should be uniform on the plane?

If we actually do the check, we should error if it's not uniform, not warn. But I wonder if the check may be expensive for e.g. a large plane, e.g. a large-area metalens?

I mean we only check if the entire custom medium is uniform, but not the intersecting plane. This should be cheap as we don't compute the intersection? And if it's nonuniform, it's still possible that the medium is uniform on the plane, so we just warn.

@momchil-flex
Copy link
Collaborator Author

Is there a cheap way to check this? I guess something like np.amin(arr) == np.amax(arr)? But would this be slow for a large array?

@weiliangjin2021
Copy link
Collaborator

Is there a cheap way to check this? I guess something like np.amin(arr) == np.amax(arr)? But would this be slow for a large array?

It will take at least O(N), N being the number of array size. Will this be too slow?

@momchil-flex
Copy link
Collaborator Author

That's true, I forgot amin/amax is not sorting but just O(N). I think this is fine then.

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

No branches or pull requests

3 participants