-
Notifications
You must be signed in to change notification settings - Fork 641
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
Pade approximant based spectral extrapolation #2440
Conversation
Things to do before I would consider this PR "complete":
Suggestions and improvements are welcome. |
I would punt on the SVD approach. You can always add more PRs with additional functionality later. For now, focus on the simplest working routine that's easy to augment later. |
This is why the CI dies (you can download the log as an artifact):
Be sure to include your new module/function in Line 1718 in c376694
|
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.
Good work. We should add a tutorial for this feature after this is merged.
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #2440 +/- ##
==========================================
+ Coverage 72.66% 72.90% +0.24%
==========================================
Files 17 17
Lines 5162 5212 +50
==========================================
+ Hits 3751 3800 +49
- Misses 1411 1412 +1
|
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.
Getting there. Some more suggested changes.
You will also need to create a new entry for the meep/doc/docs/Python_User_Interface.md.in Lines 651 to 655 in c376694
This is necessary for converting its docstrings into Markdown for the readthedocs manual. |
In a separate PR, it would be good to show how to use this to calculate transmission and reflection spectra in problems with single-mode ports and sharp resonances. For example, to compute the transmission/reflection spectrum through N layers of a 2d photonic crystal at normal incidence. |
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.
Just two final comments/suggestions.
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.
After too much delay, this is an initial PR for Pade-approximant based spectral extrapolation, hopefully closing #2192. It essentially works in the same way as
Harminv
(thanks @Alex-Kaylor for help with the initial implementation) by aggregating field and computing an analytic frequency response using the rational Pade Approximant.Like
Harminv
,Pade
is constructed as a class that holds as a member variable (data
) the aggregated field data, parameters for sampling the data, and the computed analytic function.To initialize, one need only provide a field component
c
and a pointpt
at which to perform the computation.Optional arguments include
sample_rate
,start_time
andstop_time
, which sample the collected field data according tosamples = self.data[self.start_time : self.stop_time : self.sample_rate]
.Additionally, there are
m
andn
, which respectively set the orders of the numerator and denominator. Alternatively, one can specifym_frac
orn_frac
, which specifym
andn
as fractions of the length of the collected time series. If none of these are specified, the default behavior is to use half the length of the time series as the order of the numeratorm
, andN-m-2
as the order of the denominator.Speaking of the algorithm, the code is currently implemented by calling the builtin scipy
pade
routine. Separately, I have investigated the behavior of the Trefethen SVD-based algorithm and found it to be much harder to get it to converge (though in theory it is more robust to noise in the input data). Thus, the existing implementation only uses the builtin scipy algorithm, but it would be nice to at least have the option of using either algorithm. The way I have implemented the Trefethen algorithm here provides straightforward potential interchange of Trefethen and scipy.I have also written a test case that compares the center frequency of a peak in the Pade frequency response to the first Harminv mode, included in
test_ring.py
. This case passes when I run it locally withpython3 -m pytest python/tests/test_ring.py
but fails on my fork's CI workflow, I'm sure I'm doing something incorrectly there.