RT-TDDFT+RT-BSE : Fourier Transform Outputs#4527
Conversation
src/emd/rt_propagation_output.F
Outdated
| CHARACTER(len=21) :: prefix | ||
| CHARACTER(len=5) :: prefix_format | ||
| COMPLEX(kind=dp), DIMENSION(:), POINTER :: omegas_complex, omegas_pade | ||
| COMPLEX(kind=dp), DIMENSION(:, :), POINTER :: field_results, field_results_pade, & |
There was a problem hiding this comment.
Hint: Most (all?) of these pointers can be downgraded to ALLOCATABLE, TARGET. This prevents accidental memory leaks although you deallocate all variables AFAICS.
There was a problem hiding this comment.
I rewrote the local arrays to be ALLOCATABLE, TARGET, but due to multi_fft requiring pointers, I included additional pointer that point to them.
There was a problem hiding this comment.
multi_fft does not actually need a POINTER. In most cases, you can drop it (and probably also in the interface of some other routines) except from its third argument (result_series) which you can downgrade to ALLOCATABLE because it may be reallocated within multi_fft.
Another issue is the planner routine fft_create_plan_1dm which should not be called with the actual input array because it may be overwritten with some FFTW planning modes (default in CP2K is FFTW_ESTIMATE) (see here). Apparently, this behavior is assumed at several occasions.
There was a problem hiding this comment.
Thank you for the specific suggestions - I rewrote multi_fft so that it now accepts the arrays directly and the pointers are therefore reduced. Inside multi_fft, I left a few pointers to arrays used in fft_alloc - I assume since this is coupling to C arrays, these really have to be pointers.
For the planner routine, I now call fft_create_plan_1dm with empty (allocated but not initialized) arrays and fft_1dm with additional array, which contains copy of the input data (for the results, I reuse the array used in fft_create_plan_1dm). I tested determination of POLARIZABILITY with different FFTW plans (ESTIMATE, MEASURE and PATIENT) on a simple system and the results are identical in all cases, so I hope this approach will be valid.
The Fourier transforms that are carried out in the RT-BSE code can now be done by the FFTW3 library, if it is present
+ preparation for the Fourier transform in TDDFT + unifying the iteration levels between TDDFT and RTBSE + unifying the printing routines of moments trace between TDDFT and RTBSE + providing the access to reference points + making the field in moments_utils optional
Polarizability and moments' Fourier transform now in output
Reading of moments, which are needed for the restart calculations of FT, is implemented
Change in FT leads to a changed grid Verified that the results from the polarizability is essentially the same as before the change.
GreenX is now coupled to the print_ft method, which is applicable for both RT-BSE and RT-TDDFT. RT-X : Output cleanup
- Moved pol elements guess after reading of efields - separated printing of FTs into separate function
Now contains the current Padé section
Specific flag is now set when local moments should (and can) be calculated.
4de3c2a to
b1beaee
Compare
With the new logical flag, allocating 0 elements should no longer be neccessary.
Instead, when the FT fails (given by a stat code), the backup FT is carried out.
Per recomendation of @hfp, local arrays are changed to `ALLOCATABLE, TARGET`, which should be less prone to memory leaks. Nevertheless, multi_fft is left to still accept pointers, so local pointer reassignment is done.
Since pointers are typically not needed, try to avoid them in the FT routines. Also changed the order in FT input arrays + added additional input array - in some cases, the planner routine could overwrite the input array, this should now NOT be the case (thanks to @hfp)
Co-authored-by: Štěpán Marek <stepan.marek@physik.uni-regensburg.de>
Co-authored-by: Štěpán Marek <stepan.marek@physik.uni-regensburg.de>
Following discussion at #4489 (@Anyborr ), this pull request refactors the calculation of Fourier transforms in real-time propagation calculations and allows for printing of polarizability components and Fourier transform of dipole moments in both RT-BSE and RT-TDDFT.
So far, I have only implemented the already present methods for RT-BSE - namely, the printing of the mentioned observables is only available for non-periodic systems.
On a more technical level, I also refactored the FTs, so now the FFTW3 library is used if available.
The input structure changes a little bit - the parameters setting for the Fourier transforms of the observables are now set in a subsection directly in
&REAL_TIME_PROPAGATIONsection, instead of subsection of&RTBSE, since they apply for both RT-BSE and RT-TDDFT. Specifically, new the subsection&FTand its subsection&PADEset these parameters, with reasonable defaults.