13#if defined (__HAS_IEEE_EXCEPTIONS)
14 USE ieee_exceptions,
ONLY: ieee_all, ieee_divide_by_zero, ieee_invalid, ieee_overflow, &
15 ieee_get_halting_mode, ieee_set_halting_mode, ieee_support_halting
27#include "./base/base_uses.f90"
31 COMPLEX(KIND=dp),
ALLOCATABLE :: candidates(:, :, :)
32 COMPLEX(KIND=dp),
ALLOCATABLE :: hybrids(:, :, :), rotated_hybrids(:, :, :)
33 COMPLEX(KIND=dp) :: quartet(2, 4)
34 COMPLEX(KIND=dp) :: amn(2, 2, 2), reference(2, 2, 2), rotation(2, 2, 2)
35 COMPLEX(KIND=dp) :: repaired(2, 2, 3)
36 COMPLEX(KIND=dp) :: mixed_reference(4, 3, 2)
38 INTEGER :: anchor, ik, nfail, pivots(2), reference_pivots(2)
39 INTEGER :: empty_groups(4, 0)
40 REAL(kind=
dp) :: angle, min_svalue
43#if defined (__HAS_IEEE_EXCEPTIONS)
44 LOGICAL :: saved_halt(size(ieee_all)), expected_halt(size(ieee_all)), actual_halt(size(ieee_all))
49 CALL para_env%from_dup(comm)
51#if defined (__HAS_IEEE_EXCEPTIONS)
52 CALL ieee_get_halting_mode(ieee_all, saved_halt)
53 IF (ieee_support_halting(ieee_invalid))
CALL ieee_set_halting_mode(ieee_invalid, .true.)
54 IF (ieee_support_halting(ieee_divide_by_zero))
CALL ieee_set_halting_mode(ieee_divide_by_zero, .true.)
55 IF (ieee_support_halting(ieee_overflow))
CALL ieee_set_halting_mode(ieee_overflow, .true.)
56 CALL ieee_get_halting_mode(ieee_all, expected_halt)
58 IF (para_env%is_source())
THEN
59 ALLOCATE (candidates(2, 3, 2))
60 candidates = cmplx(0.0_dp, 0.0_dp, kind=
dp)
62 candidates(1, 1, 1) = 5.0_dp
63 candidates(2, 2, :) = 2.0_dp
64 candidates(1, 3, :) = 0.4_dp
66 ALLOCATE (candidates(0, 0, 0))
69 IF (min_svalue > 1.0e-14_dp) nfail = nfail + 1
71 IF (abs(min_svalue - 0.4_dp) > 1.0e-14_dp) nfail = nfail + 1
72 IF (.NOT. all(pivots == [2, 3])) nfail = nfail + 1
74 reference_pivots = pivots
77 angle = 0.31_dp*real(ik, kind=
dp)
78 rotation(1, 1, ik) = cos(angle)
79 rotation(2, 2, ik) = cos(angle)
80 rotation(1, 2, ik) = cmplx(0.0_dp, sin(angle), kind=
dp)
81 rotation(2, 1, ik) = cmplx(0.0_dp, sin(angle), kind=
dp)
82 IF (para_env%is_source()) candidates(:, :, ik) = matmul(rotation(:, :, ik), candidates(:, :, ik))
85 IF (abs(min_svalue - 0.4_dp) > 1.0e-14_dp) nfail = nfail + 1
86 IF (.NOT. all(pivots == reference_pivots)) nfail = nfail + 1
88 IF (maxval(abs(amn(:, :, ik) - matmul(rotation(:, :, ik), reference(:, :, ik)))) > 1.0e-14_dp)
THEN
92 IF (para_env%is_source()) candidates(:, :, :) = cmplx(0.0_dp, 0.0_dp, kind=
dp)
94 IF (min_svalue /= 0.0_dp) nfail = nfail + 1
95 DEALLOCATE (candidates)
96 IF (para_env%is_source())
THEN
97 ALLOCATE (candidates(2, 5, 2))
100 candidates(1, anchor, ik) = cmplx(0.1_dp*anchor, 0.2_dp*ik, kind=
dp)
101 candidates(2, anchor, ik) = cmplx(-0.3_dp*anchor, 0.05_dp*ik*anchor, kind=
dp)
105 ALLOCATE (candidates(0, 0, 0))
108 IF (para_env%is_source())
THEN
109 IF (.NOT. all(shape(hybrids) == [2, 5, 2])) nfail = nfail + 1
110 IF (maxval(abs(hybrids(:, 1, :) - candidates(:, 5, :))) > 1.0e-14_dp) nfail = nfail + 1
113 quartet = hybrids(:, 2:5, ik)
114 IF (maxval(abs(matmul(quartet, conjg(transpose(quartet))) - &
115 matmul(candidates(:, 1:4, ik), conjg(transpose(candidates(:, 1:4, ik)))))) &
116 > 1.0e-14_dp) nfail = nfail + 1
117 candidates(:, :, ik) = matmul(rotation(:, :, ik), candidates(:, :, ik))
121 IF (para_env%is_source())
THEN
123 IF (maxval(abs(rotated_hybrids(:, :, ik) - matmul(rotation(:, :, ik), hybrids(:, :, ik)))) &
124 > 1.0e-14_dp) nfail = nfail + 1
127 IF (
SIZE(hybrids) /= 0 .OR.
SIZE(rotated_hybrids) /= 0) nfail = nfail + 1
129 DEALLOCATE (hybrids, rotated_hybrids)
130 CALL wannier90_hybrid_candidates(candidates, reshape([1, 2, 3, 4, 5, 2, 3, 4], [4, 2]), hybrids)
131 IF (para_env%is_source())
THEN
132 IF (.NOT. all(shape(hybrids) == [2, 8, 2])) nfail = nfail + 1
134 IF (maxval(abs(sum(hybrids(:, 1:4, ik), dim=2)*0.5_dp - candidates(:, 1, ik))) &
135 > 1.0e-14_dp) nfail = nfail + 1
136 IF (maxval(abs(sum(hybrids(:, 5:8, ik), dim=2)*0.5_dp - candidates(:, 5, ik))) &
137 > 1.0e-14_dp) nfail = nfail + 1
142 IF (para_env%is_source())
THEN
143 IF (maxval(abs(hybrids - candidates)) > 1.0e-14_dp) nfail = nfail + 1
145 DEALLOCATE (hybrids, candidates)
146 IF (para_env%is_source())
THEN
147 ALLOCATE (candidates(2, 4, 3))
148 candidates = cmplx(0.0_dp, 0.0_dp, kind=
dp)
151 candidates(1, 1, 1) = 10.0_dp
152 candidates(1, 1, 3) = 10.0_dp
153 candidates(2, 2, 2) = 10.0_dp
154 candidates(2, 2, 3) = 10.0_dp
155 candidates(1, 3, :) = 1.0_dp
156 candidates(2, 4, :) = 1.0_dp
158 ALLOCATE (candidates(0, 0, 0))
162 IF (min_svalue > 1.0e-14_dp) nfail = nfail + 1
165 IF (abs(min_svalue - 1.0_dp) > 1.0e-14_dp) nfail = nfail + 1
166 IF (.NOT. all(pivots == [3, 4])) nfail = nfail + 1
167 DEALLOCATE (candidates)
168 IF (para_env%is_source())
THEN
169 ALLOCATE (candidates(2, 3, 2))
170 candidates = cmplx(0.0_dp, 0.0_dp, kind=
dp)
171 candidates(1, 1, :) = 1.0_dp
172 candidates(1, 2, :) = 1.0_dp + 1.0e-14_dp
173 candidates(2, 3, :) = 1.0_dp
175 ALLOCATE (candidates(0, 0, 0))
178 IF (.NOT. all(pivots == [1, 3])) nfail = nfail + 1
179 IF (para_env%is_source())
THEN
181 candidates(:, :, ik) = matmul(rotation(:, :, ik), candidates(:, :, ik))
185 IF (.NOT. all(pivots == [1, 3])) nfail = nfail + 1
186 DEALLOCATE (candidates)
189 mixed_reference(1, anchor, ik) = cmplx(0.1_dp*anchor, 0.2_dp*ik, kind=
dp)
190 mixed_reference(2, anchor, ik) = cmplx(-0.3_dp*anchor, 0.05_dp*ik*anchor, kind=
dp)
191 mixed_reference(3, anchor, ik) = cmplx(0.2_dp*anchor**2, 0.3_dp*ik, kind=
dp)
192 mixed_reference(4, anchor, ik) = cmplx(0.7_dp, -0.1_dp*ik*anchor, kind=
dp)
196#if defined (__HAS_IEEE_EXCEPTIONS)
197 CALL ieee_get_halting_mode(ieee_all, actual_halt)
198 IF (any(actual_halt .NEQV. expected_halt)) nfail = nfail + 1
200 CALL ieee_set_halting_mode(ieee_all, .false.)
202 CALL ieee_get_halting_mode(ieee_all, actual_halt)
203 IF (any(actual_halt)) nfail = nfail + 1
204 CALL ieee_set_halting_mode(ieee_all, expected_halt)
207 [-1.5_dp, 1.5_dp, 0.0_dp, 0.0_dp], &
208 [.true., .true., .false., .false.], allowed)
209 IF (any(allowed .NEQV. [.false., .true., .true., .false.])) nfail = nfail + 1
211 [-3.0_dp, 3.0_dp, 0.0_dp, 0.0_dp], &
212 [.true., .true., .false., .true.], allowed)
213 IF (any(allowed .NEQV. [.true., .true., .false., .false.])) nfail = nfail + 1
214#if defined (__HAS_IEEE_EXCEPTIONS)
215 CALL ieee_get_halting_mode(ieee_all, actual_halt)
216 IF (any(actual_halt .NEQV. expected_halt)) nfail = nfail + 1
217 CALL ieee_set_halting_mode(ieee_all, saved_halt)
Defines the basic variable types.
integer, parameter, public dp
Interface to the message passing library MPI.
subroutine, public mp_world_init(mp_comm)
initializes the system default communicator
subroutine, public mp_para_env_release(para_env)
releases the para object (to be called when you don't want anymore the shared copy of this object)
subroutine, public mp_world_finalize()
Finalize the system default communicator and MPI when CP2K owns MPI.
Gauge-covariant selection of fixed trial orbitals for Wannier90.
subroutine, public wannier90_window_mask(eigenvalues, num_wann, windows, window_set, allowed)
Restrict fixed trial selection to the bands admitted by disentanglement windows.
real(kind=dp) function, public wannier90_projection_rank(amn, rank_defect)
Validate the trial rank independently at every k-point.
subroutine, public wannier90_select_projections(candidates, para_env, amn, pivots, min_svalue, anchor_kpoint)
Select the same trial orbitals at every k-point using a mesh-wide pivoted QR.
subroutine, public wannier90_hybrid_candidates(ao, groups, candidates)
Form tetrahedral s/p trials from the full AO bank before selecting projections.
stores all the informations relevant to an mpi environment
program wannier90_projections_unittest
Test mesh-wide rank validation and unitary covariance of AO trial selection.