-
Notifications
You must be signed in to change notification settings - Fork 64
feat: initialize topology design regions from simulation geometry #2795
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
base: develop
Are you sure you want to change the base?
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, 1 comment
Diff CoverageDiff: origin/develop...HEAD, staged and unstaged changes
Summary
tidy3d/plugins/autograd/invdes/parametrizations.py
|
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.
Can test in my Smatrix notebook branch in a bit
a148778
to
2f2657e
Compare
2f2657e
to
748b4cb
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.
Worked great in my test notebook, and overall implementation is good. Thank @yaugenst-flex . A couple comments:
- I see no reason to not import this also into the main
tidy3d.plugins.autograd
namespace. I forget why we decided to separate them into.invdes
. do you remember? - In some cases the
param_to_structure
might take not justparams
but also**kwargs
. In my notebook, it tookbeta
so I had to passsfunctools.partial(param_to_structure, beta=1)
, which is not a huge deal but I think it would be kind of nice to just allow passing kwargs into theparam_to_structure
what do you think?
Greptile Summary
Updated On: 2025-09-05 10:24:39 UTC
This PR introduces a new topology optimization initialization feature to the Tidy3D inverse design module. The primary addition is the
initialize_params_from_simulation
function, which allows users to initialize design parameters for topology optimization by matching the permittivity distribution of an existing simulation within a specified design region.The function addresses a common challenge in topology optimization where starting from random or uniform parameter values can lead to poor convergence or suboptimal results. Instead, this implementation uses L-BFGS-B optimization with automatic differentiation to find parameter values that best reproduce the permittivity distribution from a base simulation. The optimization minimizes the L2 error between the base simulation's permittivity and the parameterized structure's permittivity.
Key technical features include:
The function is integrated into the public API through the
__init__.py
file, making it easily discoverable for users. The implementation follows established patterns in the codebase and includes thorough documentation with examples. A comprehensive test suite validates the function's behavior, ensuring shape preservation, bounds compliance, and actual loss reduction during optimization.This addition enhances the inverse design workflow by enabling users to start topology optimization from realistic initial conditions derived from existing simulations, potentially leading to faster convergence and better optimization outcomes.
Important Files Changed
Changed Files
tidy3d/plugins/autograd/invdes/__init__.py
initialize_params_from_simulation
function to the public APICHANGELOG.md
tidy3d/plugins/autograd/invdes/parametrizations.py
initialize_params_from_simulation
function with L-BFGS-B optimization and early stoppingtests/test_plugins/autograd/invdes/test_initialize_params_from_sim.py
Confidence score: 4/5
parametrizations.py
to ensure the permittivity matching and early stopping mechanisms work correctly across different simulation typesSequence Diagram