-
Notifications
You must be signed in to change notification settings - Fork 626
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
Reverse engineer filtered and projected design variables #2462
Conversation
python/adjoint/reverse_design.py
Outdated
from autograd import grad | ||
|
||
|
||
def reverse_design(target, processing, maxiter=50): |
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.
Would be nice to have docstrings and typehints.
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #2462 +/- ##
==========================================
+ Coverage 73.82% 73.94% +0.11%
==========================================
Files 17 18 +1
Lines 5269 5293 +24
==========================================
+ Hits 3890 3914 +24
Misses 1379 1379
|
python/adjoint/reverse_design.py
Outdated
@@ -0,0 +1,52 @@ | |||
import nlopt |
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.
Maybe change this to a lazy import inside the function, so that NLopt is only required if you want to run this particular function.
Probably add a test. |
python/tests/test_adjoint_solver.py
Outdated
def test_reverse_design(self): | ||
"""Verifies that the reverse_design finds better initialization for specific | ||
design than that design itself as initialization.""" | ||
print("*** TESTING reverse_design ***") |
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.
This is too loose of a test.
I would do a gold master test where you just verify that you reproduce the results of a previous run that you checked manually.
Should pass the new Maybe not needed since the filtering is specified by a user function. |
python/tests/test_adjoint_solver.py
Outdated
return projected_field.flatten() | ||
|
||
reverse_x = mpa.reverse_design(target, processing) | ||
tol = 1e-5 |
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.
Is this value supposed to match the ftol = 1e-5
in reverse_design.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.
Not really. This value is just a small number to ensure future versions will have equally satisfying performance. I changed it to a smaller value.
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.
Sometimes, it is desirable to have some specific initial guess for the topological optimization. With the presence of filtering and projection function, we can do a mini-optimization to reverse engineer the design variables whose filtered projection matches the desired structure.