-
Notifications
You must be signed in to change notification settings - Fork 66
feat(invdes): smoothed projection #2996
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
feat(invdes): smoothed projection #2996
Conversation
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.
4 files reviewed, 3 comments
b262065 to
3ac1e93
Compare
Diff CoverageDiff: origin/develop...HEAD, staged and unstaged changes
Summary
tidy3d/plugins/autograd/invdes/projections.pyLines 133-141 133 (2025).
134 """
135 # sanity checks
136 if array.ndim != 2:
! 137 raise ValueError(f"Smoothed projection expects a 2d-array, but got shape {array.shape=}")
138
139 # smoothing kernel is circle (or ellipse for non-uniform grid)
140 # we choose smoothing kernel with unit area, which is r~=0.56, a bit larger than (arbitrary) default r=0.55 in paper
141 dx = dy = scaling_factor |
yaugenst-flex
left a comment
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 @mahlau-flex this is really nice to have!
5108710 to
ccc0834
Compare
yaugenst-flex
left a comment
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 @mahlau-flex looks great! Only minor formatting nits on the docstring.
ccc0834 to
7d37e5b
Compare
yaugenst-flex
left a comment
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.
LGTM!
7d37e5b to
b02286a
Compare
b02286a to
c2399de
Compare
c2399de to
cc5ff01
Compare
Smoothed projection from the paper https://arxiv.org/pdf/2503.20189
Greptile Overview
Greptile Summary
This PR adds
smoothed_projection, a new inverse design projection function that supports subpixel smoothing with β→∞, based on the paper by Alec Hammond (arxiv.org/pdf/2503.20189). The implementation integrates out discontinuities in the projection function, allowing smooth gradient flow even at infinite projection strength.Key changes:
smoothed_projectionfunction inprojections.pywith comprehensive documentation__all__Issues found:
Confidence Score: 4/5
tidy3d/plugins/autograd/invdes/projections.pyneeds typo correctionsImportant Files Changed
File Analysis
Sequence Diagram
sequenceDiagram participant User participant smoothed_projection participant tanh_projection participant np_gradient User->>smoothed_projection: array, beta, eta Note over smoothed_projection: Assert array.ndim == 2 smoothed_projection->>tanh_projection: array, beta, eta tanh_projection-->>smoothed_projection: rho_projected smoothed_projection->>np_gradient: array np_gradient-->>smoothed_projection: rho_filtered_grad Note over smoothed_projection: Compute gradient norm<br/>and sanitize for divide-by-zero Note over smoothed_projection: Calculate distance d to interface<br/>d = (eta - array) / grad_norm Note over smoothed_projection: Determine needs_smoothing:<br/>interface within voxel? Note over smoothed_projection: Compute fill factors F and F_minus<br/>using analytic expressions Note over smoothed_projection: Calculate bounds:<br/>rho_filtered_minus, rho_filtered_plus smoothed_projection->>tanh_projection: rho_filtered_minus, beta, eta tanh_projection-->>smoothed_projection: rho_minus_eff_projected smoothed_projection->>tanh_projection: rho_filtered_plus, beta, eta tanh_projection-->>smoothed_projection: rho_plus_eff_projected Note over smoothed_projection: Apply smoothing at interfaces<br/>rho_projected_smoothed = (1-F)*minus + F*plus Note over smoothed_projection: Use np.where to select:<br/>smoothed or standard projection smoothed_projection-->>User: smoothed resultContext used:
dashboard- Require a changelog entry for any PR that is not purely an internal refactor. (source)