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

Add support for geometry transformations #1203

Merged
merged 1 commit into from
Oct 24, 2023

Conversation

lucas-flexcompute
Copy link
Collaborator

Support is added through a new Geometry subclass: Transformed and a few convenience functions to instance it from other geometries.

Related issues:

Copy link
Collaborator

@tylerflex tylerflex left a comment

Choose a reason for hiding this comment

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

@lucas-flexcompute this is really comprehensive and will be great to have. Thanks a lot. I jumped in to take a look before noticing this was a draft, so sorry if any of the comments were things that you just hadn't got to yet. Just a few initial thoughts as I read through things.

tests/test_components/test_geometry.py Outdated Show resolved Hide resolved
tidy3d/__init__.py Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
tidy3d/components/geometry/base.py Outdated Show resolved Hide resolved
tidy3d/components/geometry/base.py Show resolved Hide resolved
tests/test_components/test_geometry.py Outdated Show resolved Hide resolved
@lucas-flexcompute lucas-flexcompute marked this pull request as ready for review October 11, 2023 22:05
@weiliangjin2021
Copy link
Collaborator

Very cool feature! Overall looks good.

Copy link
Contributor

@shashwat-sh shashwat-sh left a comment

Choose a reason for hiding this comment

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

I took a quick look - looks good to me! I didn't fully understand all the intersection operation details - will go over it again when you finalize the PR.

tidy3d/components/geometry/base.py Outdated Show resolved Hide resolved
tidy3d/components/geometry/base.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@tylerflex tylerflex left a comment

Choose a reason for hiding this comment

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

Thanks @lucas-flexcompute, I just have a set of minor comments / suggestions. Everything related to the functionality looks really good to me! I'm approving for when the comments are addressed / discussed.

tidy3d/components/geometry/base.py Show resolved Hide resolved
tidy3d/components/geometry/base.py Show resolved Hide resolved
tidy3d/components/geometry/base.py Outdated Show resolved Hide resolved
tidy3d/components/geometry/base.py Outdated Show resolved Hide resolved
tidy3d/components/geometry/base.py Outdated Show resolved Hide resolved
tidy3d/components/geometry/base.py Outdated Show resolved Hide resolved
tidy3d/components/geometry/base.py Outdated Show resolved Hide resolved
tidy3d/components/geometry/polyslab.py Outdated Show resolved Hide resolved
tidy3d/components/geometry/polyslab.py Outdated Show resolved Hide resolved
tidy3d/components/geometry/triangulation.py Show resolved Hide resolved
@lucas-flexcompute
Copy link
Collaborator Author

Because of the discussion about the back-end processing, transformed slanted polyslabs should not be allowed, but if we add the validator in Transformed we might reject geometries too eagerly. If the user is applying several cascaded transforms that result in a valid end result, I think we should allow it. That's why I've added the validator to Structure, where the geometry is frozen.

@lucas-flexcompute lucas-flexcompute force-pushed the lucas/geometry_transformations branch 3 times, most recently from a734d61 to b7e45cb Compare October 19, 2023 18:41
Copy link
Contributor

@shashwat-sh shashwat-sh left a comment

Choose a reason for hiding this comment

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

Looks good to me, just a few minor comments.

tidy3d/components/geometry/base.py Outdated Show resolved Hide resolved
_ = np.linalg.inv(val)
return val

@pydantic.root_validator(skip_on_failure=True)
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the reason for adding skip_on_failure=True here?

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 doesn't make much sense to use this validator if geometry or transform aren't really one of the expected types or the transform is singular. It'll just raise another error. Isn't that what skip_on_failure means?

tidy3d/components/geometry/base.py Outdated Show resolved Hide resolved
"""Prevents the creation of slanted polyslabs rotated out of plane."""
if (
isinstance(val, Transformed)
and isinstance(val.geometry, PolySlab)
Copy link
Collaborator

Choose a reason for hiding this comment

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

what if a geometrygroup or clipper operator is transformed, and it contains a slanted polyslab? is it included here already?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch, I guess not. We'll need a recursive check in this case. Let me think it through and change it.

Support is added through a new `Geometry` subclass: `Transformed` and a
few convenience functions to instance it from other geometries.

Related issues:
- flexcompute/tidy3d-core#25
- flexcompute/tidy3d-core#339

Signed-off-by: Lucas Heitzmann Gabrielli <lucas@flexcompute.com>
@lucas-flexcompute lucas-flexcompute merged commit e8ae0eb into pre/2.5 Oct 24, 2023
12 checks passed
lucas-flexcompute added a commit to flexcompute-readthedocs/tidy3d-docs that referenced this pull request Oct 27, 2023
Based on flexcompute/tidy3d#1203

Signed-off-by: Lucas Heitzmann Gabrielli <lucas@flexcompute.com>
lucas-flexcompute added a commit to flexcompute-readthedocs/tidy3d-docs that referenced this pull request Oct 27, 2023
Based on flexcompute/tidy3d#1203

Signed-off-by: Lucas Heitzmann Gabrielli <lucas@flexcompute.com>
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

Successfully merging this pull request may close these issues.

None yet

4 participants