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

Alternative approach for stop_when_dft_decayed #1847

Closed
wants to merge 3 commits into from

Conversation

mochen4
Copy link
Collaborator

@mochen4 mochen4 commented Dec 8, 2021

Fixes #1831.

With the alternative approach, I couldn't find a default tol/decay_by parameter that would pass the single precision tests. The simplest solution I found is to use the minimum_run_time, as I currently have in this PR.

Alternatively, I could set a specific decay_by for each unit test in test_adjoint_solver.py

@codecov-commenter
Copy link

Codecov Report

Merging #1847 (4b8ac79) into master (2baeaef) will decrease coverage by 0.02%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #1847      +/-   ##
==========================================
- Coverage   73.40%   73.38%   -0.03%     
==========================================
  Files          17       17              
  Lines        4896     4892       -4     
==========================================
- Hits         3594     3590       -4     
  Misses       1302     1302              
Impacted Files Coverage Δ
python/adjoint/optimization_problem.py 56.77% <ø> (ø)
python/adjoint/wrapper.py 98.50% <ø> (ø)
python/simulation.py 76.81% <100.00%> (-0.04%) ⬇️

@stevengj
Copy link
Collaborator

stevengj commented Dec 8, 2021

Would be good to visualize the field in the single-precision case when the decay stagnates — i.e. what modes are causing it to have such a high Q? The fields at the Nyquist frequency, or maybe at zero frequency?

(If it is the zero frequency, then using an integrated source might fix it?)

@mochen4
Copy link
Collaborator Author

mochen4 commented Dec 9, 2021

I noticed the decay stagnated for the eigenmode test in the single-precision case at the traditional forward simulation:

S12_unperturbed = forward_simulation(p, MonitorObject.EIGENMODE, frequencies)
but shouldn't it be basically identical to the forward simulation in OptimizationProblem (which decays fine)? @smartalecH
adjsol_obj, adjsol_grad = adjoint_solver(p, MonitorObject.EIGENMODE, frequencies)

@smartalecH
Copy link
Collaborator

As discussed, I think the issue is that forward_simulation isn't placing DFT monitors in the design region (where you are seeing some high-frequency speckling). The simulation itself should be identical between the two, but the adjoint_solver routine is explicitly waiting for the "speckle" to converge.

@mochen4
Copy link
Collaborator Author

mochen4 commented Dec 9, 2021

Here are a few plots of the field when it stagnates

540 4833374023438fields
579 6500244140625fields
600 0166625976562fields
620 3833618164062fields

@mochen4
Copy link
Collaborator Author

mochen4 commented Dec 9, 2021

The field's high-frequency pattern is probably due to the round-off at single-precision.

@mochen4 mochen4 closed this Dec 9, 2021
@mochen4 mochen4 deleted the dft_decay_min branch January 5, 2022 00:08
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.

stop_when_dft_decayed in single precision
4 participants