-
Notifications
You must be signed in to change notification settings - Fork 41
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
Add to_gds
to Simulation
, Structure
and Geometry
(#883)
#1194
Conversation
f866444
to
46eb867
Compare
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 @lucas-flexcompute this looks great. I do have a general comment / question:
In the geometry base, we have a from_gds()
classmethod, which loads the geometry from a user-supplied gds Cell
(either gdspy or gdstk). For consistency, do you think it makes sense for this to_gds()
to also accept a Cell
object? I think this way we also never need to worry about importing gdstk or gdspy because the user specifies the cell and we just call whatever methods it has.
Just wondering if you think this is a better or worse alternative to the filename approach and why you chose that, thanks!
We'd still need to import the module to be able to create |
After looking a bit deeper into the cell/file output option: making the argument change the function behavior by type is usually a bad idea… Maybe we leave the |
Yea I agree, let's not have the same function do different things based on inputs. One other option is to expose I guess 4 functions: |
We'd still leave What do you think? |
That sounds great to me. (I wasn't sure what to_gdstk / to_gdspy should return but what you describe sounds good. |
@tylerflex and @tomflexcompute I've updated the interface according to the last discussion. There's some code duplication now that I find hard to avoid, because One alternative would be to create global functions def _to_gds(object, x, y, z, **kwargs):
...
# remove unwanted kwargs
object.to_gdstk(..., **kwargs) or object.to_gdspy(..., **kwargs)
... Any other ideas or preferences? |
I feel in this instance, some code duplication is probably preferable. I looked over the current implementation and I think it works as is. Otherwise, we could have the generic versions accept What is your preference? |
I think I prefer it the way it is right now. Adding an extra member to |
Thanks @lucas-flexcompute . The interface looks good to me. Also works very well based on my limited testing. So as far as my understanding goes, the conversion of tidy3d simulation or structure to gds is based on the permittivity distribution, which makes sense. One corner case I can think of now is when a user only makes half (or even less commonly, a quarter) of a structure and uses symmetry in the simulation (one example would be this). In this case, the exported gds file only contains half of the structure too, In my opinion the ideal behavior of to_gds from a simulation should automatically copy/flip the structure and make a full structure if symmetry is applied. Do you think so? I tested it on this example) and the result gds file contains many fragments instead of one single geometry. Some manual cleaning can be done in KLayout for example to clean it up relatively easily so maybe that's not a huge concern. One last comment I have is that the exported gds contains structures extended outside of the simulation domain. If td.inf is used to create certain geometries, the gds file will contain this huge structure and you really need to zoom in to see the actual device structure. |
Thanks, @tomflexcompute! Yes, what you're proposing makes sense: to limit the gds export region using the simulation bounds and to apply the symmetry conditions. This is the new default behavior. I can add arguments to control that in the method call, but I'm afraid it already has too many parameters. Furthermore, the user can always export directly from Regarding the fragments, that's the conventional way to represent geometries with too many vertices and holes in gds files. The user should be well aware of that if they work with gds files. |
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 @lucas-flexcompute for the new implementation. It looks very good to me. Making the to_gds from Simulation consider symmetry and simulation boundary by default makes sense. Like you said, if an user doesn't want to include this, they can call to_gds from Structure.
@lucas-flexcompute if this is ready to merge, feel free to "rebase and merge" it. I wasn't sure if there were any last minute additions so will let you handle it, thanks. |
2f088eb
to
f316c6c
Compare
Structures with custom medium are intersected with their medium contours at a given permittivity threshold.