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

Field projection monitor intersects structures outside of the simulation domain and still causes error #1902

Open
tomflexcompute opened this issue Aug 14, 2024 · 7 comments
Assignees
Labels
Bug something isnt working

Comments

@tomflexcompute
Copy link
Contributor

Field projection monitors such as FieldProjectionAngleMonitor can not intersect any structures whose medium is not background. Currently the validator seems to check outside of the simulation domain as well. For example, in a 2D simulation, I can have a cylinder of length 2 in the direction where the simulation domain has 0 size. Then if I have a 3D field projection monitor that intersects the cylinder at z=0.5, it will cause an error.

I think this error should be avoided since there is no intersection in the simulation domain and thus the result should still be correct.

@momchil-flex
Copy link
Collaborator

@QimingFlex could you take this?

@QimingFlex
Copy link
Contributor

Will work on it shortly.

@QimingFlex
Copy link
Contributor

In theory, a 2-D simulation represents an infinitely extended system along the 0-dim. Currently in Tidy3D, if we ensure that both the monitor and geometry sizes along the 0-dim are set to td.inf, we can avoid such errors, which aligns well with the theoretical concept. I propose implementing a simulation-level validator that would be triggered if users specify a non-td.inf size along the 0-dimension for either the geometry or monitor in a 2D simulation. This approach would help maintain consistency with the theoretical model. What are your thoughts on this? @momchil-flex @tomflexcompute

@tomflexcompute
Copy link
Contributor Author

Thanks @QimingFlex . I think it's a good idea but has some practical complications. First issue is it will break some backward compatibility. Users who set an arbitrary value for length in 2D simulation will error if we implement this. More importantly it might not work in some cases. For example if user creates a box using the from_bounds method, they can not directly set the size to td.inf. For PolySlab I don't know if it's possible to set the min and max to td.inf either.

@QimingFlex
Copy link
Contributor

Thanks @tomflexcompute ! I was also puzzled by from_bounds as this generally can't create structures that end by PMLs. If users want to achieve that, they would need use center and size.

@momchil-flex
Copy link
Collaborator

Yeah @QimingFlex in many cases we have to sacrifice defining things "rigorously" for the convenience of the user. In this particular case, and in general, only structures defined withing the simulation domain matter, for convenience things that lie outside of it can be whatever and we still handle it well. For example, think again of the grating coupler example where a user may be able to easily switch between a 2D and a 3D simulation. It is very convenient to be able to use the same structures and just change the size of the simulation domain, and everything just works.

Thus for this issue we should just fix the validator to maybe first take the intersection of the field projection monitor with the simulation domain, before doing the homogeneous medium check.

@QimingFlex
Copy link
Contributor

Thanks @momchil-flex. The grating coupler is a good example of such implementation. The validator basically checks if the monitor intersects with any structures, and won't raise an error if the monitor size along the 0-dim is larger than the structure. I think we can ignore the size along the 0-dimn for that intersection check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug something isnt working
Projects
None yet
Development

No branches or pull requests

3 participants