16 #include "./base/base_uses.f90"
20 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'negf_integr_utils'
21 LOGICAL,
PARAMETER,
PRIVATE :: debug_this_module = .true.
30 INTERFACE equidistant_nodes_a_b
31 MODULE PROCEDURE equidistant_dnodes_a_b
32 MODULE PROCEDURE equidistant_znodes_a_b
46 SUBROUTINE equidistant_dnodes_a_b(a, b, nnodes, xnodes)
47 REAL(kind=
dp),
INTENT(in) :: a, b
48 INTEGER,
INTENT(in) :: nnodes
49 REAL(kind=
dp),
DIMENSION(nnodes),
INTENT(out) :: xnodes
52 REAL(kind=
dp) :: rscale
56 rscale = (b - a)/real(nnodes - 1, kind=
dp)
58 xnodes(i) = a + rscale*real(i - 1, kind=
dp)
60 END SUBROUTINE equidistant_dnodes_a_b
70 SUBROUTINE equidistant_znodes_a_b(a, b, nnodes, xnodes)
71 COMPLEX(kind=dp),
INTENT(in) :: a, b
72 INTEGER,
INTENT(in) :: nnodes
73 COMPLEX(kind=dp),
DIMENSION(nnodes),
INTENT(out) :: xnodes
76 COMPLEX(kind=dp) :: rscale
80 rscale = (b - a)/real(nnodes - 1, kind=
dp)
82 xnodes(i) = a + rscale*real(i - 1, kind=
dp)
84 END SUBROUTINE equidistant_znodes_a_b
87 INTEGER,
INTENT(in) :: nnodes
88 REAL(kind=
dp),
DIMENSION(nnodes),
INTENT(in) :: tnodes
89 COMPLEX(kind=dp),
INTENT(in) :: a, b
90 INTEGER,
INTENT(in) :: shape_id
91 COMPLEX(kind=dp),
DIMENSION(nnodes),
INTENT(out), &
92 OPTIONAL :: xnodes, weights
94 CHARACTER(len=*),
PARAMETER :: routinen =
'rescale_normalised_nodes'
97 REAL(kind=
dp) :: rscale
98 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: tnodes_angle
100 CALL timeset(routinen, handle)
102 SELECT CASE (shape_id)
104 IF (
PRESENT(xnodes)) &
107 IF (
PRESENT(weights)) &
111 ALLOCATE (tnodes_angle(nnodes))
113 tnodes_angle(:) = tnodes(:)
116 IF (
PRESENT(xnodes)) &
119 IF (
PRESENT(weights))
THEN
123 weights(i) = rscale*cmplx(sin(tnodes_angle(i)), -cos(tnodes_angle(i)), kind=
dp)
127 DEALLOCATE (tnodes_angle)
129 cpabort(
"Unimplemented integration shape")
132 CALL timestop(handle)
153 COMPLEX(kind=dp),
INTENT(in) :: a, b
154 REAL(kind=
dp) :: radius
156 COMPLEX(kind=dp) :: b_minus_a
162 radius = 0.5_dp*real(b_minus_a*conjg(b_minus_a), kind=
dp)/real(b_minus_a, kind=
dp)
183 COMPLEX(kind=dp),
INTENT(in) :: a, b
186 COMPLEX(kind=dp) :: b_minus_a
187 REAL(kind=
dp) :: delta2, l2
193 l2 = real(b_minus_a,
dp)
195 delta2 = aimag(b_minus_a)
196 delta2 = delta2*delta2
198 phi = acos((l2 - delta2)/(l2 + delta2))
201 PURE FUNCTION get_axis_rotation_angle(a, b)
RESULT(phi)
202 COMPLEX(kind=dp),
INTENT(in) :: a, b
205 COMPLEX(kind=dp) :: b_minus_a
208 phi = acos(real(b_minus_a,
dp)/abs(b_minus_a))
209 END FUNCTION get_axis_rotation_angle
223 INTEGER,
INTENT(in) :: nnodes
224 REAL(kind=
dp),
DIMENSION(:),
INTENT(in) :: tnodes_angle
225 COMPLEX(kind=dp),
INTENT(in) :: a, b
226 COMPLEX(kind=dp),
DIMENSION(:),
INTENT(out) :: xnodes
228 COMPLEX(kind=dp) :: origin
230 REAL(kind=
dp) :: radius
233 origin = a + cmplx(radius, 0.0_dp, kind=
dp)
236 xnodes(i) = origin + radius*cmplx(cos(tnodes_angle(i)), sin(tnodes_angle(i)), kind=
dp)
248 INTEGER,
INTENT(in) :: nnodes
249 REAL(kind=
dp),
DIMENSION(nnodes),
INTENT(inout) :: tnodes
251 tnodes(:) = cos(0.5_dp*
pi*(1.0_dp - tnodes(:)))
265 INTEGER,
INTENT(in) :: nnodes
266 REAL(kind=
dp),
DIMENSION(nnodes),
INTENT(in) :: tnodes
267 COMPLEX(kind=dp),
INTENT(in) :: a, b
268 COMPLEX(kind=dp),
DIMENSION(nnodes),
INTENT(out) :: xnodes
270 COMPLEX(kind=dp) :: half_len, median
272 median = 0.5_dp*(b + a)
273 half_len = 0.5_dp*(b - a)
275 xnodes(:) = median + half_len*tnodes(:)
289 COMPLEX(kind=dp),
INTENT(in) :: a, b
290 INTEGER,
INTENT(in) :: nnodes
291 REAL(kind=
dp),
DIMENSION(nnodes),
INTENT(inout) :: tnodes
293 REAL(kind=
dp) :: half_pi_minus_phi, phi
296 half_pi_minus_phi = 0.5_dp*(
pi - phi)
298 tnodes(:) = phi + half_pi_minus_phi*(1.0_dp - tnodes(:))
Defines the basic variable types.
integer, parameter, public dp
Definition of mathematical constants and functions.
real(kind=dp), parameter, public pi
Helper functions for integration routines.
subroutine, public rescale_nodes_arc(nnodes, tnodes_angle, a, b, xnodes)
Rescale nodes [pi, phi] -> arc[a, b] .
pure real(kind=dp) function, public get_arc_smallest_angle(a, b)
Compute the angle phi.
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] .
pure real(kind=dp) function, public get_arc_radius(a, b)
Compute arc radius.
integer, parameter, public contour_shape_arc
subroutine, public rescale_nodes_pi_phi(a, b, nnodes, tnodes)
Rescale nodes [-1, 1] -> [pi, phi] .
integer, parameter, public contour_shape_linear
subroutine, public rescale_nodes_linear(nnodes, tnodes, a, b, xnodes)
Rescale nodes [-1, 1] -> [a, b] .