(git:27c966b)
Loading...
Searching...
No Matches
time_frequency_grids.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2026 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7
8! **************************************************************************************************
9!> \brief Definition and construction of time/frequency grids for correlation methods.
10!> \par History
11!> 05.2019 Refactored from rpa_ri_gpw [Frederick Stein]
12! **************************************************************************************************
15 USE kinds, ONLY: dp
16 USE mathconstants, ONLY: pi,&
17 z_zero
22#include "./base/base_uses.f90"
23
24 IMPLICIT NONE
25
26 PRIVATE
27
28 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'time_frequency_grids'
29
31 REAL(kind=dp), DIMENSION(:), ALLOCATABLE :: frequency
32 REAL(kind=dp), DIMENSION(:), ALLOCATABLE :: frequency_weights
33 REAL(kind=dp), DIMENSION(:), ALLOCATABLE :: imaginary_time
34 REAL(kind=dp), DIMENSION(:), ALLOCATABLE :: time_weights_at_zero_frequency
35 ! Complete discrete transforms, including cosine/sine factors.
36 ! Matrix rows index output grid points, columns index input grid points.
37 REAL(kind=dp), DIMENSION(:, :), ALLOCATABLE :: cosine_time_to_frequency
38 REAL(kind=dp), DIMENSION(:, :), ALLOCATABLE :: cosine_frequency_to_time
39 REAL(kind=dp), DIMENSION(:, :), ALLOCATABLE :: sine_time_to_frequency
41
42 INTEGER, PARAMETER :: cosine_time_to_frequency = 1, &
43 sine_time_to_frequency = 2, &
44 cosine_frequency_to_time = 3
45 INTEGER, PARAMETER, PUBLIC :: positive_time = 1, negative_time = 2
46
49
50CONTAINS
51
52! **************************************************************************************************
53!> \brief Release all data owned by a time_frequency_grid_type object.
54!> \param grid The grid object to release.
55! **************************************************************************************************
57
58 TYPE(time_frequency_grid_type), INTENT(INOUT) :: grid
59
60 IF (ALLOCATED(grid%frequency)) DEALLOCATE (grid%frequency)
61 IF (ALLOCATED(grid%frequency_weights)) DEALLOCATE (grid%frequency_weights)
62 IF (ALLOCATED(grid%imaginary_time)) DEALLOCATE (grid%imaginary_time)
63 IF (ALLOCATED(grid%time_weights_at_zero_frequency)) DEALLOCATE (grid%time_weights_at_zero_frequency)
64 IF (ALLOCATED(grid%cosine_time_to_frequency)) DEALLOCATE (grid%cosine_time_to_frequency)
65 IF (ALLOCATED(grid%cosine_frequency_to_time)) DEALLOCATE (grid%cosine_frequency_to_time)
66 IF (ALLOCATED(grid%sine_time_to_frequency)) DEALLOCATE (grid%sine_time_to_frequency)
67
68 END SUBROUTINE time_frequency_grid_release
69
70! **************************************************************************************************
71!> \brief Transform real positive/negative-time samples to complex positive-frequency values.
72!> The even part uses the cosine transform and the odd part the sine transform.
73!> \param grid Valid grid with complete cosine/sine time-to-frequency matrices of matching dimensions.
74!> \param samples_tau Real samples indexed (state, time, branch), with branches
75!> positive_time and negative_time. The samples include their physical signs.
76!> \param values_omega Complex output indexed (state, frequency), evaluated at the leading
77!> SIZE(values_omega, 2) positive-frequency nodes of grid.
78! **************************************************************************************************
79 SUBROUTINE transform_time_to_frequency(grid, samples_tau, values_omega)
80 TYPE(time_frequency_grid_type), INTENT(IN) :: grid
81 REAL(kind=dp), DIMENSION(:, :, :), INTENT(IN) :: samples_tau
82 COMPLEX(KIND=dp), DIMENSION(:, :), INTENT(OUT) :: values_omega
83
84 CHARACTER(LEN=*), PARAMETER :: routinen = 'transform_time_to_frequency'
85
86 INTEGER :: handle, ifreq, itime, nstate
87 REAL(kind=dp) :: weight_cos, weight_sin
88 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: samples_even, samples_odd
89
90 CALL timeset(routinen, handle)
91
92 nstate = SIZE(samples_tau, 1)
93 cpassert(SIZE(samples_tau, 3) == 2)
94 cpassert(SIZE(values_omega, 1) == nstate)
95 cpassert(SIZE(samples_tau, 2) == SIZE(grid%cosine_time_to_frequency, 2))
96 cpassert(SIZE(values_omega, 2) <= SIZE(grid%cosine_time_to_frequency, 1))
97
98 ALLOCATE (samples_even(nstate), samples_odd(nstate))
99 values_omega = z_zero
100 DO itime = 1, SIZE(samples_tau, 2)
101 samples_even(:) = 0.5_dp*(samples_tau(:, itime, positive_time) + samples_tau(:, itime, negative_time))
102 samples_odd(:) = 0.5_dp*(samples_tau(:, itime, positive_time) - samples_tau(:, itime, negative_time))
103 DO ifreq = 1, SIZE(values_omega, 2)
104 weight_cos = grid%cosine_time_to_frequency(ifreq, itime)
105 weight_sin = grid%sine_time_to_frequency(ifreq, itime)
106 values_omega(:, ifreq) = values_omega(:, ifreq) + &
107 cmplx(weight_cos*samples_even, weight_sin*samples_odd, kind=dp)
108 END DO
109 END DO
110
111 CALL timestop(handle)
112
113 END SUBROUTINE transform_time_to_frequency
114
115! **************************************************************************************************
116!> \brief Build a Clenshaw-Curtis frequency grid.
117!> \param num_points Number of integration points.
118!> \param grid Grid object to fill.
119! **************************************************************************************************
120 SUBROUTINE build_clenshaw_grid(num_points, grid)
121
122 INTEGER, INTENT(IN) :: num_points
123 TYPE(time_frequency_grid_type), INTENT(OUT) :: grid
124
125 CHARACTER(LEN=*), PARAMETER :: routinen = 'build_clenshaw_grid'
126
127 INTEGER :: handle, jquad
128
129 CALL timeset(routinen, handle)
130
131 cpassert(num_points > 0)
132
133 ALLOCATE (grid%frequency(num_points), grid%frequency_weights(num_points))
134
135 DO jquad = 1, num_points - 1
136 grid%frequency(jquad) = jquad*pi/(2.0_dp*num_points)
137 grid%frequency_weights(jquad) = pi/(num_points*sin(grid%frequency(jquad))**2)
138 END DO
139 grid%frequency(num_points) = pi/2.0_dp
140 grid%frequency_weights(num_points) = &
141 pi/(2.0_dp*num_points*sin(grid%frequency(num_points))**2)
142
143 CALL timestop(handle)
144
145 END SUBROUTINE build_clenshaw_grid
146
147! **************************************************************************************************
148!> \brief Build a minimax time/frequency grid through the common backend boundary.
149!> \param num_points Number of minimax points.
150!> \param energy_min Lower end of the physical energy interval.
151!> \param energy_max Upper end of the physical energy interval.
152!> \param regularization Regularization used for the fitted transform weights.
153!> \param num_points_per_magnitude Number of fitting points per decade.
154!> \param grid Grid object to fill.
155!> \param build_frequency Whether to construct the frequency components.
156!> \param build_time Whether to construct the imaginary-time components.
157!> \param build_transforms Whether to construct the complete time/frequency transform matrices.
158!> \param build_sine Whether to construct the sine time-to-frequency matrix.
159!> \param time_scaling Scaling applied to the imaginary-time abscissas.
160!> \param time_weight_scaling Scaling applied to the imaginary-time weights.
161!> \param max_fit_error Maximum fitting error across all requested transforms.
162!> \param print_warning Whether the minimax coefficient routine prints warnings.
163!> \param unit_nr Output unit used by an external backend.
164!> \param prefer_external_backend Whether to try an available external backend first.
165!> \param used_external_backend Whether the external backend supplied the grid.
166!> \param rcond If present and > 0, relative SVD cutoff of the fitted transform weights, used
167!> instead of the regularization.
168! **************************************************************************************************
169 SUBROUTINE build_minimax_time_frequency_grid(num_points, energy_min, energy_max, regularization, &
170 num_points_per_magnitude, grid, build_frequency, build_time, &
171 build_transforms, build_sine, time_scaling, time_weight_scaling, &
172 max_fit_error, print_warning, unit_nr, prefer_external_backend, &
173 used_external_backend, rcond)
174
175 INTEGER, INTENT(IN) :: num_points
176 REAL(kind=dp), INTENT(IN) :: energy_min, energy_max, regularization
177 INTEGER, INTENT(IN) :: num_points_per_magnitude
178 TYPE(time_frequency_grid_type), INTENT(OUT) :: grid
179 LOGICAL, INTENT(IN) :: build_frequency, build_time, &
180 build_transforms, build_sine
181 REAL(kind=dp), INTENT(IN) :: time_scaling, time_weight_scaling
182 REAL(kind=dp), INTENT(OUT) :: max_fit_error
183 LOGICAL, INTENT(IN) :: print_warning
184 INTEGER, INTENT(IN) :: unit_nr
185 LOGICAL, INTENT(IN) :: prefer_external_backend
186 LOGICAL, INTENT(OUT), OPTIONAL :: used_external_backend
187 REAL(kind=dp), INTENT(IN), OPTIONAL :: rcond
188
189 CHARACTER(LEN=*), PARAMETER :: routinen = 'build_minimax_time_frequency_grid'
190
191 INTEGER :: external_ierr, handle, ierr
192 REAL(kind=dp) :: e_range, max_error
193 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: points_and_weights
194
195 CALL timeset(routinen, handle)
196
197 IF (PRESENT(used_external_backend)) used_external_backend = .false.
198 IF (prefer_external_backend) THEN
199 CALL greenx_get_minimax_grid(unit_nr, num_points, energy_min, energy_max, regularization, &
200 grid%imaginary_time, grid%time_weights_at_zero_frequency, &
201 grid%frequency, grid%frequency_weights, &
202 grid%cosine_time_to_frequency, &
203 grid%cosine_frequency_to_time, &
204 grid%sine_time_to_frequency, external_ierr)
205 IF (external_ierr == 0) THEN
206 max_fit_error = 0.0_dp
207 IF (PRESENT(used_external_backend)) used_external_backend = .true.
208 CALL timestop(handle)
209 RETURN
210 END IF
212 END IF
213
214 cpassert(num_points > 0)
215 cpassert(energy_min > 0.0_dp)
216 cpassert(energy_max >= energy_min)
217 cpassert(time_scaling > 0.0_dp)
218 cpassert(time_weight_scaling > 0.0_dp)
219 cpassert(.NOT. build_transforms .OR. (build_frequency .AND. build_time))
220 cpassert(.NOT. build_sine .OR. build_transforms)
221 max_error = 0.0_dp
222
223 e_range = energy_max/energy_min
224 ALLOCATE (points_and_weights(2*num_points))
225
226 IF (build_frequency) THEN
227 IF (num_points <= 20) THEN
228 CALL get_rpa_minimax_coeff(num_points, e_range, points_and_weights, ierr, print_warning)
229 ELSE
230 CALL get_rpa_minimax_coeff_larger_grid(num_points, e_range, points_and_weights)
231 END IF
232
233 ALLOCATE (grid%frequency(num_points))
234 ALLOCATE (grid%frequency_weights(num_points))
235 grid%frequency(:) = points_and_weights(1:num_points)*energy_min
236 grid%frequency_weights(:) = points_and_weights(num_points + 1:)*energy_min
237 IF (num_points >= 26) grid%frequency_weights(:) = grid%frequency_weights(:)*4.0_dp
238 END IF
239
240 IF (build_time) THEN
241 IF (num_points <= 20) THEN
242 CALL get_exp_minimax_coeff(num_points, e_range, points_and_weights)
243 ELSE
244 CALL get_exp_minimax_coeff_gw(num_points, e_range, points_and_weights)
245 END IF
246
247 ALLOCATE (grid%imaginary_time(num_points))
248 ALLOCATE (grid%time_weights_at_zero_frequency(num_points))
249 grid%imaginary_time(:) = points_and_weights(1:num_points)/time_scaling/energy_min
250 grid%time_weights_at_zero_frequency(:) = points_and_weights(num_points + 1:)/time_weight_scaling/energy_min
251
252 IF (build_transforms) THEN
253 ALLOCATE (grid%cosine_time_to_frequency(num_points, num_points))
254 CALL fit_l_sq_weights(cosine_time_to_frequency, num_points, grid%imaginary_time, &
255 grid%cosine_time_to_frequency, grid%frequency, energy_min, energy_max, &
256 max_error, num_points_per_magnitude, regularization, rcond)
257
258 ALLOCATE (grid%cosine_frequency_to_time(num_points, num_points))
259 CALL fit_l_sq_weights(cosine_frequency_to_time, num_points, grid%imaginary_time, &
260 grid%cosine_frequency_to_time, grid%frequency, energy_min, energy_max, &
261 max_error, num_points_per_magnitude, regularization, rcond)
262
263 IF (build_sine) THEN
264 ALLOCATE (grid%sine_time_to_frequency(num_points, num_points))
265 CALL fit_l_sq_weights(sine_time_to_frequency, num_points, grid%imaginary_time, &
266 grid%sine_time_to_frequency, grid%frequency, energy_min, energy_max, &
267 max_error, num_points_per_magnitude, regularization, rcond)
268 END IF
269 END IF
270 END IF
271
272 max_fit_error = max_error
273
274 CALL timestop(handle)
275
277
278! **************************************************************************************************
279!> \brief Calculate a complete least-squares time/frequency transform matrix.
280!> \param transform_kind Type of transform to fit.
281!> \param num_integ_points Number of integration points.
282!> \param tau_tj Imaginary-time integration points.
283!> \param weights Complete transform coefficients, including cosine/sine factors.
284!> Rows index output grid points, columns index input grid points.
285!> \param omega_tj Frequency integration points.
286!> \param E_min Lower end of the fitting interval.
287!> \param E_max Upper end of the fitting interval.
288!> \param max_error Maximum fitting error.
289!> \param num_points_per_magnitude Number of fitting points per decade.
290!> \param regularization Regularization parameter for the pseudoinverse.
291!> \param rcond If present and > 0, singular values below rcond times the largest one are discarded
292!> (truncated SVD) instead of applying the regularization.
293! **************************************************************************************************
294 SUBROUTINE fit_l_sq_weights(transform_kind, num_integ_points, tau_tj, weights, omega_tj, E_min, E_max, &
295 max_error, num_points_per_magnitude, regularization, rcond)
296
297 INTEGER, INTENT(IN) :: transform_kind, num_integ_points
298 REAL(kind=dp), DIMENSION(:), INTENT(IN) :: tau_tj
299 REAL(kind=dp), DIMENSION(:, :), INTENT(OUT) :: weights
300 REAL(kind=dp), DIMENSION(:), INTENT(IN) :: omega_tj
301 REAL(kind=dp), INTENT(IN) :: e_min, e_max
302 REAL(kind=dp), INTENT(OUT) :: max_error
303 INTEGER, INTENT(IN) :: num_points_per_magnitude
304 REAL(kind=dp), INTENT(IN) :: regularization
305 REAL(kind=dp), INTENT(IN), OPTIONAL :: rcond
306
307 CHARACTER(LEN=*), PARAMETER :: routinen = 'fit_l_sq_weights'
308
309 INTEGER :: handle, iii, info, jjj, jquad, lwork, &
310 num_x_nodes
311 INTEGER, ALLOCATABLE, DIMENSION(:) :: iwork
312 LOGICAL :: sine_transform, time_to_frequency
313 REAL(kind=dp) :: func_val, max_error_tmp, multiplicator, &
314 my_rcond, omega, s_cut, tau, x_value
315 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: sing_values, vec_uty, weight_work, work, &
316 x_values, y_values
317 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: mat_a, mat_sinvvsinvsigma, &
318 mat_sinvvsinvt, mat_u
319
320 CALL timeset(routinen, handle)
321
322 cpassert(transform_kind >= cosine_time_to_frequency)
323 cpassert(transform_kind <= cosine_frequency_to_time)
324 cpassert(SIZE(tau_tj) == num_integ_points)
325 cpassert(SIZE(omega_tj) == num_integ_points)
326 cpassert(SIZE(weights, 1) == num_integ_points)
327 cpassert(SIZE(weights, 2) == num_integ_points)
328
329 time_to_frequency = transform_kind /= cosine_frequency_to_time
330 sine_transform = transform_kind == sine_time_to_frequency
331
332 my_rcond = 0.0_dp
333 IF (PRESENT(rcond)) my_rcond = rcond
334
335 ! take num_points_per_magnitude points per 10-interval
336 num_x_nodes = (int(log10(e_max/e_min)) + 1)*num_points_per_magnitude
337
338 ! take at least as many x points as integration points to have clear
339 ! input for the singular value decomposition
340 num_x_nodes = max(num_x_nodes, num_integ_points)
341
342 ALLOCATE (x_values(num_x_nodes), y_values(num_x_nodes), mat_a(num_x_nodes, num_integ_points), &
343 weight_work(num_integ_points), sing_values(num_integ_points), mat_u(num_x_nodes, num_x_nodes), &
344 mat_sinvvsinvt(num_x_nodes, num_integ_points), work(8*num_integ_points*num_integ_points + &
345 12*num_integ_points + 2*num_x_nodes), iwork(8*num_integ_points), &
346 mat_sinvvsinvsigma(num_integ_points, num_x_nodes), vec_uty(num_x_nodes))
347 mat_sinvvsinvsigma = 0.0_dp
348
349 ! double the value nessary for 'A' to achieve good performance
350 lwork = SIZE(work)
351
352 multiplicator = (e_max/e_min)**(1.0_dp/(real(num_x_nodes, kind=dp) - 1.0_dp))
353 DO iii = 1, num_x_nodes
354 x_values(iii) = e_min*multiplicator**(iii - 1)
355 END DO
356
357 max_error = 0.0_dp
358
359 DO jquad = 1, num_integ_points
360
361 IF (time_to_frequency) THEN
362 omega = omega_tj(jquad)
363
364 IF (sine_transform) THEN
365 ! y=2*omega/(x^2+omega^2)
366 DO iii = 1, num_x_nodes
367 y_values(iii) = 2.0_dp*omega/(x_values(iii)**2 + omega**2)
368 END DO
369 ELSE
370 ! y=2*x/(x^2+omega^2)
371 DO iii = 1, num_x_nodes
372 y_values(iii) = 2.0_dp*x_values(iii)/(x_values(iii)**2 + omega**2)
373 END DO
374 END IF
375
376 DO jjj = 1, num_integ_points
377 DO iii = 1, num_x_nodes
378 IF (sine_transform) THEN
379 mat_a(iii, jjj) = sin(omega*tau_tj(jjj))*exp(-x_values(iii)*tau_tj(jjj))
380 ELSE
381 mat_a(iii, jjj) = cos(omega*tau_tj(jjj))*exp(-x_values(iii)*tau_tj(jjj))
382 END IF
383 END DO
384 END DO
385 ELSE
386 tau = tau_tj(jquad)
387
388 ! y=exp(-x*|tau|)
389 DO iii = 1, num_x_nodes
390 y_values(iii) = exp(-x_values(iii)*tau)
391 END DO
392
393 DO jjj = 1, num_integ_points
394 omega = omega_tj(jjj)
395 DO iii = 1, num_x_nodes
396 x_value = x_values(iii)
397 mat_a(iii, jjj) = cos(tau*omega)*2.0_dp*x_value/(x_value**2 + omega**2)
398 END DO
399 END DO
400 END IF
401
402 ! Singular value decomposition of mat_A
403 CALL dgesdd('A', num_x_nodes, num_integ_points, mat_a, num_x_nodes, sing_values, mat_u, num_x_nodes, &
404 mat_sinvvsinvt, num_x_nodes, work, lwork, iwork, info)
405 cpassert(info == 0)
406
407 ! integration weights = V Sigma U^T y; with rcond > 0, singular values below
408 ! rcond*s_max are discarded (truncated SVD) instead of the Tikhonov regularization
409 IF (my_rcond > 0.0_dp) THEN
410 s_cut = my_rcond*sing_values(1)
411 DO jjj = 1, num_integ_points
412 DO iii = 1, num_integ_points
413 IF (sing_values(jjj) > s_cut) THEN
414 mat_sinvvsinvsigma(iii, jjj) = mat_sinvvsinvt(jjj, iii)/sing_values(jjj)
415 ELSE
416 mat_sinvvsinvsigma(iii, jjj) = 0.0_dp
417 END IF
418 END DO
419 END DO
420 ELSE
421 DO jjj = 1, num_integ_points
422 DO iii = 1, num_integ_points
423 mat_sinvvsinvsigma(iii, jjj) = mat_sinvvsinvt(jjj, iii)*sing_values(jjj) &
424 /(regularization**2 + sing_values(jjj)**2)
425 END DO
426 END DO
427 END IF
428
429 CALL dgemm('T', 'N', num_x_nodes, 1, num_x_nodes, 1.0_dp, mat_u, num_x_nodes, y_values, num_x_nodes, &
430 0.0_dp, vec_uty, num_x_nodes)
431 CALL dgemm('N', 'N', num_integ_points, 1, num_x_nodes, 1.0_dp, mat_sinvvsinvsigma, num_integ_points, &
432 vec_uty, num_x_nodes, 0.0_dp, weight_work, num_integ_points)
433
434 IF (sine_transform) THEN
435 weights(jquad, :) = weight_work(:)*sin(omega*tau_tj(:))
436 ELSE IF (time_to_frequency) THEN
437 weights(jquad, :) = weight_work(:)*cos(omega*tau_tj(:))
438 ELSE
439 weights(jquad, :) = weight_work(:)*cos(tau*omega_tj(:))
440 END IF
441
442 max_error_tmp = 0.0_dp
443 DO iii = 1, num_x_nodes
444 func_val = 0.0_dp
445 IF (time_to_frequency) THEN
446 DO jjj = 1, num_integ_points
447 func_val = func_val + weights(jquad, jjj)*exp(-x_values(iii)*tau_tj(jjj))
448 END DO
449 ELSE
450 DO jjj = 1, num_integ_points
451 omega = omega_tj(jjj)
452 func_val = func_val + weights(jquad, jjj)*2.0_dp*x_values(iii) &
453 /(x_values(iii)**2 + omega**2)
454 END DO
455 END IF
456 max_error_tmp = max(max_error_tmp, abs(y_values(iii) - func_val))
457 END DO
458 max_error = max(max_error, max_error_tmp)
459
460 END DO
461
462 CALL timestop(handle)
463
464 END SUBROUTINE fit_l_sq_weights
465
466! **************************************************************************************************
467!> \brief test the singular value decomposition for the computation of integration weights for the
468!> Fourier transform between time and frequency grid in cubic-scaling RPA
469!> \param nR ...
470!> \param iw ...
471! **************************************************************************************************
472 SUBROUTINE test_least_square_ft(nR, iw)
473 INTEGER, INTENT(IN) :: nr, iw
474
475 REAL(kind=dp), PARAMETER :: rc_max = 1.0e+07_dp
476
477 INTEGER :: ierr, ir, num_integ_points
478 REAL(kind=dp) :: max_error, multiplicator, rc
479 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: tau_tj, tj, x_tw
480 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: weights_cos_tf_t_to_w
481
482 multiplicator = rc_max**(1.0_dp/(real(nr, kind=dp) - 1.0_dp))
483
484 DO num_integ_points = 1, 20
485
486 ALLOCATE (x_tw(2*num_integ_points))
487 x_tw = 0.0_dp
488 ALLOCATE (tau_tj(num_integ_points))
489 tau_tj = 0.0_dp
490 ALLOCATE (weights_cos_tf_t_to_w(num_integ_points, num_integ_points))
491 weights_cos_tf_t_to_w = 0.0_dp
492 ALLOCATE (tj(num_integ_points))
493 tj = 0.0_dp
494
495 DO ir = 0, nr - 1
496
497 rc = 2.0_dp*multiplicator**ir
498
499 ierr = 0
500 CALL get_rpa_minimax_coeff(num_integ_points, rc, x_tw, ierr, print_warning=.false.)
501
502 tj(:) = x_tw(1:num_integ_points)
503
504 x_tw = 0.0_dp
505
506 CALL get_exp_minimax_coeff(num_integ_points, rc, x_tw)
507
508 tau_tj(:) = x_tw(1:num_integ_points)/2.0_dp
509
510 CALL fit_l_sq_weights(cosine_time_to_frequency, num_integ_points, tau_tj, &
511 weights_cos_tf_t_to_w, tj, 1.0_dp, rc, max_error, 200, 0.0_dp)
512
513 IF (iw > 0) THEN
514 WRITE (iw, '(T2, I3, F12.1, ES12.3)') num_integ_points, rc, max_error
515 END IF
516
517 END DO
518
519 DEALLOCATE (x_tw, tau_tj, weights_cos_tf_t_to_w, tj)
520
521 END DO
522
523 END SUBROUTINE test_least_square_ft
524
525END MODULE time_frequency_grids
static void dgemm(const char transa, const char transb, const int m, const int n, const int k, const double alpha, const double *a, const int lda, const double *b, const int ldb, const double beta, double *c, const int ldc)
Convenient wrapper to hide Fortran nature of dgemm_, swapping a and b.
Interface to the Greenx library.
subroutine, public greenx_get_minimax_grid(unit_nr, num_integ_points, emin, emax, regularization_minimax, imaginary_time, time_weights_at_zero_frequency, frequency, frequency_weights, cosine_time_to_frequency, cosine_frequency_to_time, sine_time_to_frequency, ierr)
Get a minimax grid with complete transform matrices from GreenX when it is available.
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
Definition of mathematical constants and functions.
real(kind=dp), parameter, public pi
complex(kind=dp), parameter, public z_zero
Routines to calculate the minimax coefficients in order to approximate 1/x as a sum over exponential ...
subroutine, public get_exp_minimax_coeff_gw(k, e_range, aw)
...
Routines to calculate the minimax coefficients in order to approximate 1/x as a sum over exponential ...
Definition minimax_exp.F:29
subroutine, public get_exp_minimax_coeff(k, rc, aw, mm_error, which_coeffs)
Get best minimax approximation for given input parameters. Automatically chooses the most exact set o...
Routines to calculate the minimax coefficients for approximating 1/x as 1/x ~ 1/pi SUM_{i}...
Definition minimax_rpa.F:14
subroutine, public get_rpa_minimax_coeff_larger_grid(k, e_range, aw)
...
subroutine, public get_rpa_minimax_coeff(k, e_range, aw, ierr, print_warning)
The a_i and w_i coefficient are stored in aw such that the first 1:K elements correspond to a_i and t...
Definition minimax_rpa.F:41
Definition and construction of time/frequency grids for correlation methods.
integer, parameter cosine_time_to_frequency
subroutine, public build_clenshaw_grid(num_points, grid)
Build a Clenshaw-Curtis frequency grid.
subroutine, public transform_time_to_frequency(grid, samples_tau, values_omega)
Transform real positive/negative-time samples to complex positive-frequency values....
integer, parameter, public negative_time
integer, parameter, public positive_time
subroutine, public test_least_square_ft(nr, iw)
test the singular value decomposition for the computation of integration weights for the Fourier tran...
subroutine, public time_frequency_grid_release(grid)
Release all data owned by a time_frequency_grid_type object.
subroutine, public build_minimax_time_frequency_grid(num_points, energy_min, energy_max, regularization, num_points_per_magnitude, grid, build_frequency, build_time, build_transforms, build_sine, time_scaling, time_weight_scaling, max_fit_error, print_warning, unit_nr, prefer_external_backend, used_external_backend, rcond)
Build a minimax time/frequency grid through the common backend boundary.