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

improved stop_when_dft_decayed #1711

Closed
stevengj opened this issue Jul 28, 2021 · 2 comments · Fixed by #1740
Closed

improved stop_when_dft_decayed #1711

stevengj opened this issue Jul 28, 2021 · 2 comments · Fixed by #1740

Comments

@stevengj
Copy link
Collaborator

Currently the adjoint code has a stop_when_dft_decayed function by @smartalecH that checks whether the DTFT is converged at the center frequency, but it has one big problem — it calls get_dft_fields, which collects all of the DFT data on every process. (It also seems like it looks at a single frequency, which might be a problem if there is a narrow-band resonance that decays very slowly.)

It would be good to have a parallel, performant version of this, probably implemented in C++. I think a good approach would be to check convergence of the norm of all the spatial points for each frequency separately. That is, for each frequency you compute the L2 norm of all of the spatial points (and maybe all components, or maybe do this per DFT chunk). Then compare this to the norm from a previous timestep (every N timesteps for some N) to see if it is converged (similarly to stop_when_fields_decayed etcetera). This way the storage requirements (to cache the previous norm) are only proportional to the number of frequencies, not the number of spatial points.

@ianwilliamson
Copy link
Contributor

Instead of checking the convergence of the DFT fields, what is your sense on how well it would work to check the decay of the instantaneous energy integrated over the entire sim volume (e.g. via electric_energy_in_box())?

Under reasonable circumstances, i.e. source pulses that cover a similar bandwidth sampled by the DFT frequencies, it seems like this might work pretty well. The check would be to call electric_energy_in_box() every N time steps, and compare the result to the largest value returned by electric_energy_in_box() in the simulation so far. This ratio would be unity as energy fills up the simulation domain, but it would later decay and the simulation could be terminated at some specified cutoff.

One potential advantage of this approach, vs looking at the convergence of fields from one or more DFT monitors, is that it takes into account information across the full simulation volume. For example, you might be optimizing overlaps from mode monitors that are far from the DFT monitor or that are influenced by other high-ish Q structures that are not covered by the DFT monitor. It seems like monitoring only the DFT fields for convergence would miss things like this. Although, for cases where the sim volume is dominated by a design region, the two approaches are probably similar.

Is the calculation performed by electric_energy_in_box() lighter weight or more optimized than the one performed by get_dft_fields ()? If so, that could also be an advantage.

@stevengj
Copy link
Collaborator Author

One difficulty with using electric_energy_in_box over the entire simulation domain is that if you use a point source there is a huge spike (singularity) in the fields at the location of the point source which will dominate the integral…

For example, you might be optimizing overlaps from mode monitors that are far from the DFT monitor

Eigenmode monitors are DFT monitors. My proposal is to look at all the fields in the regions being DFT'ed.

An even simpler approach would just to look the L2 norm of all of the fields in all of the DFT regions, rather than the norm of the DFTs. This is simpler to implement and maybe a bit cheaper.

Is the calculation performed by electric_energy_in_box() lighter weight

Maybe, maybe not; it depends on the size of the DFT regions etc. However, I think that performance considerations are irrelevant here (at least, for anything implemented in C++ and parallelized), since convergence checks are only performed very infrequently (not every timestep).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants