-
Notifications
You must be signed in to change notification settings - Fork 13
Forward NFT for KdV #64
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
Conversation
All tests pass, but there's no test added yet that covers fnft__kdv_scatter_bound_states.c
Currently working: Only continuous spectrum of only the slow discretizations. fnft_kdvv_test_sech_2split7A/B give a segfault, therefore outcommented for now.
This scheme uses a slightly different basis than AKNS in order to reduce the order of the polynomials for each sample by 1. This is (still) not implemented in nsev.c, from which the new kdvv.c was copied. In effect this reduces 2SPLIT2A to an alias of 2SPLIT1B, see AKNS_fscatter.c. For KdV the issue is now solved by giving 2SPLIT2A the appropriate similarity transformation.
In contrast to what I said in commit a73feaf: 2SPLIT2A is correctly implemented for NSE. This commit removes the traces of that implementation, which are incorrect for KdV.
4SPLIT4A and 4SPLIT4B not giving reasonable results yet, probably because of the numerical problems of KdV with AKNS for righthanded spectra.
Added _VANILLA to the discretizations that use the AKNS scheme as described in the AKNS paper with r=-1. This way the old names are freed for the AKNS scheme with q=-1, which are numerically advantageous (for right-handed spectra).
Currently working: Continuous spectrum with the slow methods, except for ES4 and TES4
4SPLIT4A and 4SPLIT5B not working yet.
(for continuous spectrum). The problem was that these discritizations require estimation of the first and second derivative of q and r by the midpoint rule. However, for r=-1 (vanilla) or q=-1 (non-vanilla) this midpoint rule does not evaluate to 0. Effectively this reduced the order of these discretizations to 1.
kdv_fscatter didn't use the preprocessed r but a newly computed one. These two discretizations essentially divide the stepsize by two, but in the implementation q, r, and xi are halved instead. Therefore 4SPLIT4A/B require r=-0.5 (vanilla) or q=-0.5 (non-vanilla) instead of -1.
…ic-NSE-implementation-for-Kdv
…ic-NSE-implementation-for-Kdv
This ensures that the discrete spectrum can be found on the positive imaginary axis.
…ic-NSE-implementation-for-Kdv
…ic-NSE-implementation-for-Kdv
// These two discretizations make use of a modification of
// the AKNS basis (cf. akns_pde_KdV), which reduces the order
// of the required polynomials. However, they must be kept
// in this basis to use polynomial rootfinding for the bound
// states. In the end this is corrected using
// fnft__nse_discretization_phase_factor_rho() and /or
// fnft__nse_discretization_phase_factor_b(), which in essence
// calculalate the change of basis to E basis.
The previous calculation ignored the difficulty that comes with complex-valued substep sizes.
|
Documentation needs to be updated. The mex file for KdV also needs to be updated to allow for never discretizations. Maybe we can add another C and MATLAB example for KdV or at least update the current examples. |
'mex_fnft_kdvv' is updated to the level of 'mex_fnft_nsev'. NSEV examples have been adapted for KdV.
I forgot in the previous commit.
The variable norming constants is complex with an imaginary part of 0. If you feed it to stem(), Matlab warns that the imaginary part of the data is ignored.
#64 (comment) > Should there be a check on the validity of the initial guesses here? Fixed.
Forgot to add the conditional for 'bsloc_NEWTON' in 88aa44d . Otherwise these values are ignored and don't need to be checked.
|
Nice, everything seems to work as expected. A few comments:
|
That commit makes the behaviour of However, the most important reason for me to prefer it like this is that the alternative would require putting the ugliness of lines 89--149 back in
With fixed matrix sizes we would need to add 5 separate functions, namely for 2x2 times 2x2, 4x4 times 4x4, 2x2 times 2x4, 2x2 times 2x1 and 4x4 times 4x1. Since the matrix size inputs to I've compared the speed between the implementation before this pull request and a version after this commit and it appears to make no measurable difference. Hence, the implementation with 5 separate functions has no advantage regarding the performance, whereas it does have the disadvantages of code copying. |
Correction: I've tried to reproduce that test, but got a different result. (Probably there was a problem with multiple versions in the Matlab path last time.) It now appears that 1a69d18 caused a 7 to 15% longer runtime for all slow NSE algorithms. Adding and using separate multiplication functions for each matrix size to 07bd054 doesn't make any difference, though. I'll search for the cause and solution and get back to this. |
Ah, I see. That actually depends on what you expect The advantage of this approach is that you only have to understand the AKNS system to maintain this function. With the changes, you would also need to understand things specific to KdV to maintain this function. It would reduce the modularity of the code.
Unless you know already have an idea of what it does, the updated version is not that much easier. I did a quick test, the copying does not seem to have a noticeable influence on the performance. (By the way, we also chose to have the user to prepare the
Did you notice that it just implemented the trapezoidal rule? The error should be close to the midpoint rule, but the advantage is that is easier to us (the integration boundaries do not have to be extended). But in any case, inside
Somehow I missed that there functions where moved into the header file earlier (for no good reason apparently, since the commit mentions that there was no performance gain). |
Indeed, you could avoid that call by changing What
It's the other way around. The trapezoidal rule integrates only from T[0] til T[1], whereas the scattering problems are being solved from a half step size before T[0] til half a step size above T[1]. (cf. |
Removed `misc_l2norm2`, then renamed `misc_l2norm2_full` to `misc_l2norm2`. Any calls to either of the two now call the remaining function.
No description provided.