(git:ed6f26b)
Loading...
Searching...
No Matches
negf_integr_cc.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2025 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7
8! **************************************************************************************************
9!> \brief Adaptive Clenshaw-Curtis quadrature algorithm to integrate a complex-valued function in
10!> a complex plane
11!> \par History
12!> * 05.2017 created [Sergey Chulkov]
13! **************************************************************************************************
17 USE cp_cfm_types, ONLY: cp_cfm_create,&
24 USE cp_fm_types, ONLY: cp_fm_create,&
28 USE fft_tools, ONLY: fft_alloc,&
29 fft_dealloc,&
31 USE kahan_sum, ONLY: accurate_sum
32 USE kinds, ONLY: dp,&
33 int_8
34 USE mathconstants, ONLY: z_one,&
35 z_zero
41#include "./base/base_uses.f90"
42
43 IMPLICIT NONE
44 PRIVATE
45
46 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'negf_integr_cc'
47 LOGICAL, PARAMETER, PRIVATE :: debug_this_module = .true.
48
49 INTEGER, PARAMETER, PUBLIC :: cc_interval_full = 0, &
51
52 INTEGER, PARAMETER, PUBLIC :: cc_shape_linear = contour_shape_linear, &
54
55 PUBLIC :: ccquad_type
56
57 PUBLIC :: ccquad_init, &
62
63! **************************************************************************************************
64!> \brief Adaptive Clenshaw-Curtis environment.
65! **************************************************************************************************
67 !> integration lower and upper bounds
68 COMPLEX(kind=dp) :: a = z_zero, b = z_zero
69 !> integration interval:
70 !> cc_interval_full -- [a .. b],
71 !> grid density: 'a' .. . . . . . .. 'b';
72 !> cc_interval_half -- [a .. 2b-a], assuming int_{b}^{2b-a} f(x) dx = 0,
73 !> grid density: 'a' .. . . . 'b'
74 INTEGER :: interval_id = -1
75 !> integration shape
76 INTEGER :: shape_id = -1
77 !> estimated error
78 REAL(kind=dp) :: error = -1.0_dp
79 !> approximate integral value
80 TYPE(cp_cfm_type), POINTER :: integral => null()
81 !> error estimate for every element of the 'integral' matrix
82 TYPE(cp_fm_type), POINTER :: error_fm => null()
83 !> weights associated with matrix elements; the 'error' variable contains the value Trace(error_fm * weights)
84 TYPE(cp_fm_type), POINTER :: weights => null()
85 !> integrand value at grid points. Due to symmetry of Clenshaw-Curtis quadratures,
86 !> we only need to keep the left half-interval
87 TYPE(cp_cfm_type), ALLOCATABLE, DIMENSION(:) :: zdata_cache
88 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: tnodes
89 END TYPE ccquad_type
90
91CONTAINS
92
93! **************************************************************************************************
94!> \brief Initialise a Clenshaw-Curtis quadrature environment variable.
95!> \param cc_env environment variable to initialise
96!> \param xnodes points at which an integrand needs to be computed (initialised on exit)
97!> \param nnodes initial number of points to compute (initialised on exit)
98!> \param a integral lower bound
99!> \param b integral upper bound
100!> \param interval_id full [-1 .. 1] or half [-1 .. 0] interval
101!> \param shape_id shape of a curve along which the integral will be evaluated
102!> \param weights weights associated with matrix elements; used to compute cumulative error
103!> \param tnodes_restart list of nodes over the interval [-1 .. 1] from a previous integral evaluation.
104!> If present, the same set of 'xnodes' will be used to compute this integral.
105!> \par History
106!> * 05.2017 created [Sergey Chulkov]
107!> \note Clenshaw-Curtis quadratures are defined on the interval [-1 .. 1] and have non-uniforms node
108!> distribution which is symmetric and much sparse about 0. When the half-interval [-1 .. 0]
109!> is requested, the integrand value on another subinterval (0 .. 1] is assumed to be zero.
110!> Half interval mode is typically useful for rapidly decaying integrands (e.g. multiplied by
111!> Fermi function), so we do not actually need a fine grid spacing on this tail.
112! **************************************************************************************************
113 SUBROUTINE ccquad_init(cc_env, xnodes, nnodes, a, b, interval_id, shape_id, weights, tnodes_restart)
114 TYPE(ccquad_type), INTENT(out) :: cc_env
115 INTEGER, INTENT(inout) :: nnodes
116 COMPLEX(kind=dp), DIMENSION(nnodes), INTENT(out) :: xnodes
117 COMPLEX(kind=dp), INTENT(in) :: a, b
118 INTEGER, INTENT(in) :: interval_id, shape_id
119 TYPE(cp_fm_type), INTENT(IN) :: weights
120 REAL(kind=dp), DIMENSION(nnodes), INTENT(in), &
121 OPTIONAL :: tnodes_restart
122
123 CHARACTER(len=*), PARAMETER :: routinen = 'ccquad_init'
124
125 INTEGER :: handle, icol, ipoint, irow, ncols, &
126 nnodes_half, nrows
127 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :), &
128 POINTER :: w_data, w_data_my
129 TYPE(cp_fm_struct_type), POINTER :: fm_struct
130
131 CALL timeset(routinen, handle)
132
133 cpassert(nnodes > 2)
134
135 ! ensure that MOD(nnodes-1, 2) == 0
136 nnodes = 2*((nnodes - 1)/2) + 1
137
138 cc_env%interval_id = interval_id
139 cc_env%shape_id = shape_id
140 cc_env%a = a
141 cc_env%b = b
142 cc_env%error = huge(0.0_dp)
143
144 NULLIFY (cc_env%integral, cc_env%error_fm, cc_env%weights)
145 ALLOCATE (cc_env%weights)
146 CALL cp_fm_get_info(weights, local_data=w_data, nrow_local=nrows, ncol_local=ncols, matrix_struct=fm_struct)
147 CALL cp_fm_create(cc_env%weights, fm_struct)
148 CALL cp_fm_get_info(cc_env%weights, local_data=w_data_my)
149
150 ! use the explicit loop to avoid temporary arrays
151 DO icol = 1, ncols
152 DO irow = 1, nrows
153 w_data_my(irow, icol) = abs(w_data(irow, icol))
154 END DO
155 END DO
156
157 SELECT CASE (interval_id)
158 CASE (cc_interval_full)
159 nnodes_half = nnodes/2 + 1
160 CASE (cc_interval_half)
161 nnodes_half = nnodes
162 CASE DEFAULT
163 cpabort("Unimplemented interval type")
164 END SELECT
165
166 ALLOCATE (cc_env%tnodes(nnodes))
167
168 IF (PRESENT(tnodes_restart)) THEN
169 cc_env%tnodes(1:nnodes) = tnodes_restart(1:nnodes)
170 ELSE
171 CALL equidistant_nodes_a_b(-1.0_dp, 0.0_dp, nnodes_half, cc_env%tnodes)
172
173 ! rescale all but the end-points, as they are transformed into themselves (-1.0 -> -1.0; 0.0 -> 0.0).
174 ! Moreover, by applying this rescaling transformation to the end-points we cannot guarantee the exact
175 ! result due to rounding errors in evaluation of COS function.
176 IF (nnodes_half > 2) &
177 CALL rescale_nodes_cos(nnodes_half - 2, cc_env%tnodes(2:))
178
179 SELECT CASE (interval_id)
180 CASE (cc_interval_full)
181 ! reflect symmetric nodes
182 DO ipoint = nnodes_half - 1, 1, -1
183 cc_env%tnodes(nnodes_half + ipoint) = -cc_env%tnodes(nnodes_half - ipoint)
184 END DO
185 CASE (cc_interval_half)
186 ! rescale half-interval : [-1 .. 0] -> [-1 .. 1]
187 cc_env%tnodes(1:nnodes_half) = 2.0_dp*cc_env%tnodes(1:nnodes_half) + 1.0_dp
188 END SELECT
189 END IF
190
191 CALL rescale_normalised_nodes(nnodes, cc_env%tnodes, a, b, shape_id, xnodes)
192
193 CALL timestop(handle)
194 END SUBROUTINE ccquad_init
195
196! **************************************************************************************************
197!> \brief Release a Clenshaw-Curtis quadrature environment variable.
198!> \param cc_env environment variable to release (modified on exit)
199!> \par History
200!> * 05.2017 created [Sergey Chulkov]
201! **************************************************************************************************
202 SUBROUTINE ccquad_release(cc_env)
203 TYPE(ccquad_type), INTENT(inout) :: cc_env
204
205 CHARACTER(len=*), PARAMETER :: routinen = 'ccquad_release'
206
207 INTEGER :: handle, ipoint
208
209 CALL timeset(routinen, handle)
210
211 IF (ASSOCIATED(cc_env%error_fm)) THEN
212 CALL cp_fm_release(cc_env%error_fm)
213 DEALLOCATE (cc_env%error_fm)
214 NULLIFY (cc_env%error_fm)
215 END IF
216
217 IF (ASSOCIATED(cc_env%weights)) THEN
218 CALL cp_fm_release(cc_env%weights)
219 DEALLOCATE (cc_env%weights)
220 NULLIFY (cc_env%weights)
221 END IF
222
223 IF (ASSOCIATED(cc_env%integral)) THEN
224 CALL cp_cfm_release(cc_env%integral)
225 DEALLOCATE (cc_env%integral)
226 NULLIFY (cc_env%integral)
227 END IF
228
229 IF (ALLOCATED(cc_env%zdata_cache)) THEN
230 DO ipoint = SIZE(cc_env%zdata_cache), 1, -1
231 CALL cp_cfm_release(cc_env%zdata_cache(ipoint))
232 END DO
233
234 DEALLOCATE (cc_env%zdata_cache)
235 END IF
236
237 IF (ALLOCATED(cc_env%tnodes)) DEALLOCATE (cc_env%tnodes)
238
239 CALL timestop(handle)
240 END SUBROUTINE ccquad_release
241
242! **************************************************************************************************
243!> \brief Get the next set of points at which the integrand needs to be computed. These points are
244!> then can be used to refine the integral approximation.
245!> \param cc_env environment variable (modified on exit)
246!> \param xnodes_next set of additional points (allocated and initialised on exit)
247!> \par History
248!> * 05.2017 created [Sergey Chulkov]
249! **************************************************************************************************
250 SUBROUTINE ccquad_double_number_of_points(cc_env, xnodes_next)
251 TYPE(ccquad_type), INTENT(inout) :: cc_env
252 COMPLEX(kind=dp), ALLOCATABLE, DIMENSION(:), &
253 INTENT(inout) :: xnodes_next
254
255 CHARACTER(len=*), PARAMETER :: routinen = 'ccquad_double_number_of_points'
256
257 INTEGER :: handle, ipoint, nnodes_exist, &
258 nnodes_half, nnodes_next
259 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: tnodes, tnodes_old
260
261 CALL timeset(routinen, handle)
262
263 cpassert(.NOT. ALLOCATED(xnodes_next))
264 cpassert(ASSOCIATED(cc_env%integral))
265 cpassert(ASSOCIATED(cc_env%error_fm))
266 cpassert(ALLOCATED(cc_env%zdata_cache))
267
268 ! due to symmetry of Clenshaw-Curtis quadratures, we only need to keep the left half-interval [-1 .. 0]
269 nnodes_exist = SIZE(cc_env%zdata_cache)
270 ! new nodes will be placed between the existed ones, so the number of nodes
271 ! on the left half-interval [-1 .. 0] is equal to nnodes_exist - 1
272 nnodes_half = nnodes_exist - 1
273
274 SELECT CASE (cc_env%interval_id)
275 CASE (cc_interval_full)
276 ! double number of nodes as we have 2 half-intervals [-1 .. 0] and [0 .. 1]
277 nnodes_next = 2*nnodes_half
278 CASE (cc_interval_half)
279 nnodes_next = nnodes_half
280 CASE DEFAULT
281 cpabort("Unimplemented interval type")
282 END SELECT
283
284 ALLOCATE (xnodes_next(nnodes_next))
285 ALLOCATE (tnodes(nnodes_next))
286
287 CALL equidistant_nodes_a_b(0.5_dp/real(nnodes_half, kind=dp) - 1.0_dp, &
288 -0.5_dp/real(nnodes_half, kind=dp), &
289 nnodes_half, tnodes)
290
291 CALL rescale_nodes_cos(nnodes_half, tnodes)
292
293 SELECT CASE (cc_env%interval_id)
294 CASE (cc_interval_full)
295 ! reflect symmetric nodes
296 DO ipoint = 1, nnodes_half
297 tnodes(nnodes_half + ipoint) = -tnodes(nnodes_half - ipoint + 1)
298 END DO
299 CASE (cc_interval_half)
300 ! rescale half-interval : [-1 .. 0] -> [-1 .. 1]
301 tnodes(1:nnodes_half) = 2.0_dp*tnodes(1:nnodes_half) + 1.0_dp
302 END SELECT
303
304 ! append new tnodes to the cache
305 CALL move_alloc(cc_env%tnodes, tnodes_old)
306 nnodes_exist = SIZE(tnodes_old)
307
308 ALLOCATE (cc_env%tnodes(nnodes_exist + nnodes_next))
309 cc_env%tnodes(1:nnodes_exist) = tnodes_old(1:nnodes_exist)
310 cc_env%tnodes(nnodes_exist + 1:nnodes_exist + nnodes_next) = tnodes(1:nnodes_next)
311 DEALLOCATE (tnodes_old)
312
313 ! rescale nodes [-1 .. 1] -> [a .. b] according to the shape
314 CALL rescale_normalised_nodes(nnodes_next, tnodes, cc_env%a, cc_env%b, cc_env%shape_id, xnodes_next)
315
316 DEALLOCATE (tnodes)
317 CALL timestop(handle)
318 END SUBROUTINE ccquad_double_number_of_points
319
320! **************************************************************************************************
321!> \brief Prepare Clenshaw-Curtis environment for the subsequent refinement of the integral.
322!> \param cc_env environment variable (modified on exit)
323!> \param zdata_next additional integrand value at additional points (modified on exit)
324!> \par History
325!> * 05.2017 created [Sergey Chulkov]
326!> \note Due to symmetry of Clenshaw-Curtis quadratures (weight(x) == weight(-x)), we do not need to
327!> keep all the matrices from 'zdata_next', only 'zdata_next(x) + zdata_next(-x)' is needed.
328!> In order to reduce the number of matrix allocations, we move some of the matrices from the
329!> end of the 'zdata_new' array to the 'cc_env%zdata_cache' array, and nullify the corresponding
330!> pointers at 'zdata_next' array. So the calling subroutine need to release the remained
331!> matrices or reuse them but taking into account the missed ones.
332! **************************************************************************************************
333 SUBROUTINE ccquad_reduce_and_append_zdata(cc_env, zdata_next)
334 TYPE(ccquad_type), INTENT(inout) :: cc_env
335 TYPE(cp_cfm_type), DIMENSION(:), INTENT(inout) :: zdata_next
336
337 CHARACTER(len=*), PARAMETER :: routinen = 'ccquad_reduce_and_append_zdata'
338 TYPE(cp_cfm_type), PARAMETER :: cfm_null = cp_cfm_type()
339
340 COMPLEX(kind=dp), ALLOCATABLE, DIMENSION(:) :: zscale
341 INTEGER :: handle, ipoint, nnodes_exist, &
342 nnodes_half, nnodes_next
343 TYPE(cp_cfm_type), ALLOCATABLE, DIMENSION(:) :: zdata_tmp
344
345 CALL timeset(routinen, handle)
346
347 nnodes_next = SIZE(zdata_next)
348 cpassert(nnodes_next > 0)
349
350 ! compute weights of new points on a complex contour according to their values of the 't' parameter
351 nnodes_exist = SIZE(cc_env%tnodes)
352 cpassert(nnodes_exist >= nnodes_next)
353
354 ALLOCATE (zscale(nnodes_next))
355 CALL rescale_normalised_nodes(nnodes_next, cc_env%tnodes(nnodes_exist - nnodes_next + 1:nnodes_exist), &
356 cc_env%a, cc_env%b, cc_env%shape_id, weights=zscale)
357
358 IF (cc_env%interval_id == cc_interval_half) zscale(:) = 2.0_dp*zscale(:)
359
360 ! rescale integrand values
361 DO ipoint = 1, nnodes_next
362 CALL cp_cfm_scale(zscale(ipoint), zdata_next(ipoint))
363 END DO
364 DEALLOCATE (zscale)
365
366 ! squash points with the same clenshaw-curtis weights together
367 IF (ALLOCATED(cc_env%zdata_cache)) THEN
368 nnodes_exist = SIZE(cc_env%zdata_cache)
369 ELSE
370 nnodes_exist = 0
371 END IF
372
373 SELECT CASE (cc_env%interval_id)
374 CASE (cc_interval_full)
375 IF (ALLOCATED(cc_env%zdata_cache)) THEN
376 cpassert(nnodes_exist == nnodes_next/2 + 1)
377 nnodes_half = nnodes_exist - 1
378 ELSE
379 cpassert(mod(nnodes_next, 2) == 1)
380 nnodes_half = nnodes_next/2 + 1
381 END IF
382 CASE (cc_interval_half)
383 IF (ALLOCATED(cc_env%zdata_cache)) THEN
384 cpassert(nnodes_exist == nnodes_next + 1)
385 END IF
386
387 nnodes_half = nnodes_next
388 END SELECT
389
390 IF (cc_env%interval_id == cc_interval_full) THEN
391 DO ipoint = nnodes_next/2, 1, -1
392 CALL cp_cfm_scale_and_add(z_one, zdata_next(ipoint), z_one, zdata_next(nnodes_next - ipoint + 1))
393 END DO
394 END IF
395
396 IF (ALLOCATED(cc_env%zdata_cache)) THEN
397 ! note that nnodes_half+1 == nnodes_exist for both half- and full-intervals
398 ALLOCATE (zdata_tmp(nnodes_half + nnodes_exist))
399
400 DO ipoint = 1, nnodes_half
401 zdata_tmp(2*ipoint - 1) = cc_env%zdata_cache(ipoint)
402 zdata_tmp(2*ipoint) = zdata_next(ipoint)
403 zdata_next(ipoint) = cfm_null
404 END DO
405 zdata_tmp(nnodes_half + nnodes_exist) = cc_env%zdata_cache(nnodes_exist)
406
407 CALL move_alloc(zdata_tmp, cc_env%zdata_cache)
408 ELSE
409 CALL cp_cfm_scale(2.0_dp, zdata_next(nnodes_half))
410
411 ALLOCATE (cc_env%zdata_cache(nnodes_half))
412
413 DO ipoint = 1, nnodes_half
414 cc_env%zdata_cache(ipoint) = zdata_next(ipoint)
415 zdata_next(ipoint) = cfm_null
416 END DO
417 END IF
418
419 CALL timestop(handle)
420 END SUBROUTINE ccquad_reduce_and_append_zdata
421
422! **************************************************************************************************
423!> \brief Refine approximated integral.
424!> \param cc_env environment variable (modified on exit)
425!> \par History
426!> * 05.2017 created [Sergey Chulkov]
427! **************************************************************************************************
428 SUBROUTINE ccquad_refine_integral(cc_env)
429 TYPE(ccquad_type), INTENT(inout) :: cc_env
430
431 CHARACTER(len=*), PARAMETER :: routinen = 'ccquad_refine_integral'
432
433 COMPLEX(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), &
434 POINTER :: ztmp, ztmp_dct
435 INTEGER :: handle, icol, ipoint, irow, ncols_local, nintervals, nintervals_half, &
436 nintervals_half_plus_1, nintervals_half_plus_2, nintervals_plus_2, nrows_local, stat
437 LOGICAL :: equiv
438 REAL(kind=dp) :: rscale
439 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: weights
440 TYPE(cp_fm_struct_type), POINTER :: fm_struct
441
442! TYPE(fft_plan_type) :: fft_plan
443! INTEGER(kind=int_8) :: plan
444
445 CALL timeset(routinen, handle)
446
447 cpassert(ALLOCATED(cc_env%zdata_cache))
448
449 nintervals_half_plus_1 = SIZE(cc_env%zdata_cache)
450 nintervals_half = nintervals_half_plus_1 - 1
451 nintervals_half_plus_2 = nintervals_half_plus_1 + 1
452 nintervals = 2*nintervals_half
453 nintervals_plus_2 = nintervals + 2
454 cpassert(nintervals_half > 1)
455
456 IF (.NOT. ASSOCIATED(cc_env%integral)) THEN
457 CALL cp_cfm_get_info(cc_env%zdata_cache(1), matrix_struct=fm_struct)
458 equiv = cp_fm_struct_equivalent(fm_struct, cc_env%weights%matrix_struct)
459 cpassert(equiv)
460
461 ALLOCATE (cc_env%integral)
462 CALL cp_cfm_create(cc_env%integral, fm_struct)
463 NULLIFY (cc_env%error_fm)
464 ALLOCATE (cc_env%error_fm)
465 CALL cp_fm_create(cc_env%error_fm, fm_struct)
466 END IF
467
468 IF (debug_this_module) THEN
469 DO ipoint = 1, nintervals_half_plus_1
470 equiv = cp_fm_struct_equivalent(cc_env%zdata_cache(ipoint)%matrix_struct, cc_env%integral%matrix_struct)
471 cpassert(equiv)
472 END DO
473 END IF
474
475 CALL cp_cfm_get_info(cc_env%integral, nrow_local=nrows_local, ncol_local=ncols_local)
476
477 ALLOCATE (weights(nintervals_half))
478
479 ! omit the trivial weights(1) = 0.5
480 DO ipoint = 2, nintervals_half
481 rscale = real(2*(ipoint - 1), kind=dp)
482 weights(ipoint) = 1.0_dp/(1.0_dp - rscale*rscale)
483 END DO
484 ! weights(1) <- weights(intervals_half + 1)
485 rscale = real(nintervals, kind=dp)
486 weights(1) = 1.0_dp/(1.0_dp - rscale*rscale)
487
488 ! 1.0 / nintervals
489 rscale = 1.0_dp/rscale
490
491 CALL fft_alloc(ztmp, [nintervals, nrows_local, ncols_local])
492 CALL fft_alloc(ztmp_dct, [nintervals, nrows_local, ncols_local])
493
494!$OMP PARALLEL DO DEFAULT(NONE), PRIVATE(icol, ipoint, irow), &
495!$OMP SHARED(cc_env, ncols_local, nintervals_half, nintervals_half_plus_1, nintervals_half_plus_2, nrows_local, ztmp)
496 DO icol = 1, ncols_local
497 DO irow = 1, nrows_local
498 DO ipoint = 1, nintervals_half_plus_1
499 ztmp(ipoint, irow, icol) = cc_env%zdata_cache(ipoint)%local_data(irow, icol)
500 END DO
501
502 DO ipoint = 2, nintervals_half
503 ztmp(nintervals_half + ipoint, irow, icol) = ztmp(nintervals_half_plus_2 - ipoint, irow, icol)
504 END DO
505 END DO
506 END DO
507!$OMP END PARALLEL DO
508
509 CALL fft_fw1d(nintervals, nrows_local*ncols_local, .false., ztmp, ztmp_dct, 1.0_dp, stat)
510 IF (stat /= 0) THEN
511 CALL cp_abort(__location__, &
512 "An FFT library is required for Clenshaw-Curtis quadrature. "// &
513 "You can use an alternative integration method instead.")
514 END IF
515
516!$OMP PARALLEL DO DEFAULT(NONE), PRIVATE(icol, ipoint, irow), &
517!$OMP SHARED(cc_env, rscale, ncols_local, nintervals_half, nintervals_half_plus_1, nintervals_plus_2), &
518!$OMP SHARED(nrows_local, weights, ztmp_dct)
519 DO icol = 1, ncols_local
520 DO irow = 1, nrows_local
521 ztmp_dct(1, irow, icol) = 0.5_dp*ztmp_dct(1, irow, icol)
522 DO ipoint = 2, nintervals_half
523 ztmp_dct(ipoint, irow, icol) = 0.5_dp*weights(ipoint)*(ztmp_dct(ipoint, irow, icol) + &
524 ztmp_dct(nintervals_plus_2 - ipoint, irow, icol))
525 END DO
526 ztmp_dct(nintervals_half_plus_1, irow, icol) = weights(1)*ztmp_dct(nintervals_half_plus_1, irow, icol)
527
528 cc_env%integral%local_data(irow, icol) = rscale*accurate_sum(ztmp_dct(1:nintervals_half_plus_1, irow, icol))
529 cc_env%error_fm%local_data(irow, icol) = rscale*abs(ztmp_dct(nintervals_half_plus_1, irow, icol))
530 END DO
531 END DO
532!$OMP END PARALLEL DO
533
534 CALL fft_dealloc(ztmp)
535 CALL fft_dealloc(ztmp_dct)
536
537 CALL cp_fm_trace(cc_env%error_fm, cc_env%weights, cc_env%error)
538
539 DEALLOCATE (weights)
540 CALL timestop(handle)
541 END SUBROUTINE ccquad_refine_integral
542
543END MODULE negf_integr_cc
Basic linear algebra operations for complex full matrices.
subroutine, public cp_cfm_scale_and_add(alpha, matrix_a, beta, matrix_b)
Scale and add two BLACS matrices (a = alpha*a + beta*b).
Represents a complex full matrix distributed on many processors.
subroutine, public cp_cfm_create(matrix, matrix_struct, name)
Creates a new full matrix with the given structure.
subroutine, public cp_cfm_release(matrix)
Releases a full matrix.
subroutine, public cp_cfm_get_info(matrix, name, nrow_global, ncol_global, nrow_block, ncol_block, nrow_local, ncol_local, row_indices, col_indices, local_data, context, matrix_struct, para_env)
Returns information about a full matrix.
basic linear algebra operations for full matrices
represent the structure of a full matrix
logical function, public cp_fm_struct_equivalent(fmstruct1, fmstruct2)
returns true if the two matrix structures are equivalent, false otherwise.
represent a full matrix distributed on many processors
Definition cp_fm_types.F:15
subroutine, public cp_fm_get_info(matrix, name, nrow_global, ncol_global, nrow_block, ncol_block, nrow_local, ncol_local, row_indices, col_indices, local_data, context, nrow_locals, ncol_locals, matrix_struct, para_env)
returns all kind of information about the full matrix
subroutine, public cp_fm_create(matrix, matrix_struct, name, use_sp)
creates a new full matrix with the given structure
subroutine, public fft_fw1d(n, m, trans, zin, zout, scale, stat)
Performs m 1-D forward FFT-s of size n.
Definition fft_tools.F:331
sums arrays of real/complex numbers with much reduced round-off as compared to a naive implementation...
Definition kahan_sum.F:29
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public int_8
Definition kinds.F:54
integer, parameter, public dp
Definition kinds.F:34
Definition of mathematical constants and functions.
complex(kind=dp), parameter, public z_one
complex(kind=dp), parameter, public z_zero
Adaptive Clenshaw-Curtis quadrature algorithm to integrate a complex-valued function in a complex pla...
integer, parameter, public cc_shape_linear
subroutine, public ccquad_refine_integral(cc_env)
Refine approximated integral.
integer, parameter, public cc_interval_full
subroutine, public ccquad_double_number_of_points(cc_env, xnodes_next)
Get the next set of points at which the integrand needs to be computed. These points are then can be ...
subroutine, public ccquad_release(cc_env)
Release a Clenshaw-Curtis quadrature environment variable.
integer, parameter, public cc_interval_half
subroutine, public ccquad_init(cc_env, xnodes, nnodes, a, b, interval_id, shape_id, weights, tnodes_restart)
Initialise a Clenshaw-Curtis quadrature environment variable.
integer, parameter, public cc_shape_arc
subroutine, public ccquad_reduce_and_append_zdata(cc_env, zdata_next)
Prepare Clenshaw-Curtis environment for the subsequent refinement of the integral.
Helper functions for integration routines.
subroutine, public rescale_normalised_nodes(nnodes, tnodes, a, b, shape_id, xnodes, weights)
subroutine, public rescale_nodes_cos(nnodes, tnodes)
Rescale nodes tnodes(i) = cos(pi/2 * (1-tnodes(i))); tnodes \in [-1 .. 1] .
integer, parameter, public contour_shape_arc
integer, parameter, public contour_shape_linear
Represent a complex full matrix.
keeps the information about the structure of a full matrix
represent a full matrix
Adaptive Clenshaw-Curtis environment.