Open ianwilliamson opened 3 years ago
It would certainly be possible to implement this…
In most cases (e.g. the adjoint solver), the cost of the eigenmode solver is negligible compared to the FDTD timestepping, which is why this optimization has not been a priority up to now. I agree that it could be more of problem if you want to perform the overlap calculation every few timesteps to check convergence.
Aside from this particular use case, I do think a more general interface for overlap integrals would be rather useful!
It seems that every time a mode overlap calculation is performed via
get_eigenmode_coefficients()
, MPB is called to solve for the eigenmodes of the cross section. I am wondering if there is some way to reuse or cache the results of these MPB calculations. Alternatively, perhapsget_eigenmode_coefficients()
could return a reference to the MPB results that could be used in subsequent calls toget_eigenmode_coefficients()
. Thus, the eigenmode calculcation could be avoided and the function would only need to perform the overlap calculation. Perhaps this would end up being just a more general interface for performing overlap integrals?One example of where this might be useful is when using a step function to monitor the convergence of the mode overlaps for deciding when to terminate a simulation. I imagine this feature could also be useful for your adjoint module to avoid redundant eigenmode calculations on the waveguide cross sections (which are not changing during optimization). When many frequencies or monitors are of interest, the overhead here could be significant.