Skip to content

Commit

Permalink
Fix end of files.
Browse files Browse the repository at this point in the history
  • Loading branch information
irukoa committed Feb 18, 2024
1 parent db8e67c commit d6ed5da
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Testing suite

on:
on:
schedule:
- cron: "0 11 * * 1"
push:
Expand Down
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ repository-code: 'https://github.com/irukoa/WannInt'
url: 'https://github.com/irukoa/WannInt'
abstract: >-
Wannier Interpolation. A Fortran library with utilities
to compute the resolution of quantum mechanical
to compute the resolution of quantum mechanical
operators in the Brillouin zone of a crystal.
keywords:
- Fortran
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ where
- `logical, optional, intent(in) :: all` if present and true, all the derivatives of the Hamiltonian from 0 up to derivative are computed.
- `H` is the output value.
- If `derivative` and `all` are not present, `H` is `complex(dp) :: H(Cr%num_bands(), Cr%num_bands())` and represents the Hamiltonian $H_{nm}(\textbf{k})$.
- If `derivative = n` is present and `all` is not present, `H` is MAC's `complex_dp` `type(container) :: H` and stores the Hamiltonians $n$ th derivative $H_{nm}^{lp\cdots }(\textbf{k})$. The container represents an array with shape `(Cr%num_bands(), Cr%num_bands(), 3, ..., 3)` where the number of indices is $n + 2$.
- If `derivative = n` is present and `all` is not present, `H` is MAC's `complex_dp` `type(container) :: H` and stores the Hamiltonians $n$ th derivative $H_{nm}^{lp\cdots }(\textbf{k})$. The container represents an array with shape `(Cr%num_bands(), Cr%num_bands(), 3, ..., 3)` where the number of indices is $n + 2$.
- If `derivative = n` is present and `all` is present and `true`, `H` is MAC's `complex_dp` `type(container), allocatable :: H(:)` and stores, in each index, the Hamiltonians $n$ th derivative $H_{nm}^{lp\cdots }(\textbf{k})$. Each container `H(i)` represents an array with shape `(Cr%num_bands(), Cr%num_bands(), 3, ..., 3)` where the number of indices is $n + 2$. The Hamiltonian (no derivative) is stored in `H(1)`.
- If `derivative = n` is present and `all` is present and `false`, `H` is MAC's `complex_dp` `type(container), allocatable :: H(:)` and stores, in the first index if the container, the Hamiltonians $n$ th derivative.

Expand All @@ -251,7 +251,7 @@ where
- `logical, optional, intent(in) :: all` if present and true, all the derivatives of the Berry connection from 0 up to derivative are computed.
- `A` is the output value.
- If `derivative` and `all` are not present, `A` is `complex(dp) :: H(Cr%num_bands(), Cr%num_bands(), 3)` and represents the Berry connection $A_{nm}^{j}(\textbf{k})$.
- If `derivative = n` is present and `all` is not present, `A` is MAC's `complex_dp` `type(container) :: A` and stores the Berry connection $n$ th derivative $A_{nm}^{j \ lp\cdots }(\textbf{k})$. The container represents an array with shape `(Cr%num_bands(), Cr%num_bands(), 3, 3, ..., 3)` where the number of indices is $n + 3$.
- If `derivative = n` is present and `all` is not present, `A` is MAC's `complex_dp` `type(container) :: A` and stores the Berry connection $n$ th derivative $A_{nm}^{j \ lp\cdots }(\textbf{k})$. The container represents an array with shape `(Cr%num_bands(), Cr%num_bands(), 3, 3, ..., 3)` where the number of indices is $n + 3$.
- If `derivative = n` is present and `all` is present and `true`, `A` is MAC's `complex_dp` `type(container), allocatable :: A(:)` and stores, in each index, the Berry connection's $n$ th derivative $A_{nm}^{j \ lp\cdots }(\textbf{k})$. Each container `A(i)` represents an array with shape `(Cr%num_bands(), Cr%num_bands(), 3, 3, ..., 3)` where the number of indices is $n + 3$. The Berry connection (no derivative) is stored in `A(1)`.
- If `derivative = n` is present and `all` is present and `false`, `A` is MAC's `complex_dp` `type(container), allocatable :: A(:)` and stores, in the first index if the container, the Berry connection's $n$ th derivative.

Expand All @@ -270,7 +270,7 @@ delta = dirac_delta(x, smr)
where
- `real(dp), intent(in) :: x, smr` are the evaluation point $x$ and smearing $\sigma$, respectively.
- `real(dp) :: delta` is an approximation to $\delta(x)$.

## Subspace degeneracy calculator

The library includes a utility to calculate the degeneracy of subspaces. It can be called by
Expand Down
20 changes: 10 additions & 10 deletions app/runtime_error_detection/Randomized.F90
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ subroutine random_exec_h_b1(nbnd, nr, nder)
write (error_unit, fmt="(A)") "All variables allocated."
alloc_container_res = dummy%hamiltonian(kpt=[0.0_wp, 0.0_wp, 0.0_wp], derivative=nder, all=.true.)
if (abs(abs(alloc_container_res(1)%cdp_storage(1))/real(dummy%nrpts()) - 1.0_wp) > tol*epsilon(1.0_wp)) &
error stop "Mismatch with reference."
error stop "Mismatch with reference."

end subroutine random_exec_h_b1

Expand Down Expand Up @@ -162,7 +162,7 @@ subroutine random_exec_h_b2(nbnd, nr, nder)
write (error_unit, fmt="(A)") "All variables allocated."
contained_res = dummy%hamiltonian(kpt=[0.0_wp, 0.0_wp, 0.0_wp], derivative=nder)
if (abs(abs(contained_res%cdp_storage(1))/real(dummy%nrpts())) > tol*epsilon(1.0_wp)) &
error stop "Mismatch with reference."
error stop "Mismatch with reference."

end subroutine random_exec_h_b2

Expand Down Expand Up @@ -197,8 +197,8 @@ subroutine random_exec_h_b3(nbnd, nr)

write (error_unit, fmt="(A)") "All variables allocated."
resH = dummy%hamiltonian(kpt=[0.0_wp, 0.0_wp, 0.0_wp])
if(abs(abs(resH(1, 1))/real(dummy%nrpts()) - 1.0_wp) > tol*epsilon(1.0_wp)) &
error stop "Mismatch with reference."
if (abs(abs(resH(1, 1))/real(dummy%nrpts()) - 1.0_wp) > tol*epsilon(1.0_wp)) &
error stop "Mismatch with reference."

end subroutine random_exec_h_b3

Expand Down Expand Up @@ -233,8 +233,8 @@ subroutine random_exec_a_b1(nbnd, nr, nder)

write (error_unit, fmt="(A)") "All variables allocated."
alloc_container_res = dummy%berry_connection(kpt=[0.0_wp, 0.0_wp, 0.0_wp], derivative=nder, all=.true.)
if(abs(abs(alloc_container_res(1)%cdp_storage(1))/real(dummy%nrpts()) - 1.0_wp) > tol*epsilon(1.0_wp)) &
error stop "Mismatch with reference."
if (abs(abs(alloc_container_res(1)%cdp_storage(1))/real(dummy%nrpts()) - 1.0_wp) > tol*epsilon(1.0_wp)) &
error stop "Mismatch with reference."

end subroutine random_exec_a_b1

Expand Down Expand Up @@ -270,8 +270,8 @@ subroutine random_exec_a_b2(nbnd, nr, nder)

write (error_unit, fmt="(A)") "All variables allocated."
contained_res = dummy%berry_connection(kpt=[0.0_wp, 0.0_wp, 0.0_wp], derivative=nder)
if(abs(abs(contained_res%cdp_storage(1))/real(dummy%nrpts())) > tol*epsilon(1.0_wp)) &
error stop "Mismatch with reference."
if (abs(abs(contained_res%cdp_storage(1))/real(dummy%nrpts())) > tol*epsilon(1.0_wp)) &
error stop "Mismatch with reference."

end subroutine random_exec_a_b2

Expand Down Expand Up @@ -306,8 +306,8 @@ subroutine random_exec_a_b3(nbnd, nr)

write (error_unit, fmt="(A)") "All variables allocated."
resA = dummy%berry_connection(kpt=[0.0_wp, 0.0_wp, 0.0_wp])
if(abs(abs(resA(1, 1, 1))/real(dummy%nrpts()) - 1.0_wp) > tol*epsilon(1.0_wp)) &
error stop "Mismatch with reference."
if (abs(abs(resA(1, 1, 1))/real(dummy%nrpts()) - 1.0_wp) > tol*epsilon(1.0_wp)) &
error stop "Mismatch with reference."

end subroutine random_exec_a_b3

Expand Down
4 changes: 2 additions & 2 deletions src/WannInt.F90
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ module WannInt
use WannInt_kinds, only: wp => dp
use WannInt_definitions, only: cmplx_0, cmplx_i, pi
use WannInt_utilities, only: diagonalize, dirac_delta, &
deg_list, schur, &
SVD, expsh, logu
deg_list, schur, &
SVD, expsh, logu
use MAC, only: container_specifier, container

implicit none
Expand Down
12 changes: 6 additions & 6 deletions src/WannInt_utilities.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module WannInt_utilities

use WannInt_kinds, only: wp => dp
use WannInt_definitions, only: cmplx_0, cmplx_1, cmplx_i, &
pi
pi

implicit none

Expand Down Expand Up @@ -179,7 +179,7 @@ pure function deg_list(eig, degen_thr)
integer :: i, j, dim

if (degen_thr < 0.0_wp) error stop &
"WannInt: Error #3: 'degen_thr' must be a positive real."
"WannInt: Error #3: 'degen_thr' must be a positive real."

deg_list = 0
dim = size(eig)
Expand Down Expand Up @@ -223,10 +223,10 @@ subroutine schur(matrix, Z, S, T)
!==============================================!

complex(wp), intent(in) :: matrix(:, :)
complex(wp), intent(out) :: Z(size(matrix(:, 1)), size(matrix(1, :)))
complex(wp), intent(out) :: Z(size(matrix(:, 1)), size(matrix(1, :)))

complex(wp), optional, intent(out) :: S(size(matrix(:, 1)), size(matrix(1, :)))
complex(wp), optional, intent(out) :: T(size(matrix(:, 1)))
complex(wp), optional, intent(out) :: T(size(matrix(:, 1)))

complex(wp) :: B(size(matrix(:, 1)), size(matrix(1, :)))
complex(wp) :: eig(size(matrix(:, 1)))
Expand Down Expand Up @@ -356,7 +356,7 @@ function expsh(matrix)

integer :: i

call diagonalize(matrix = -cmplx_i*matrix, P = P, D = D)
call diagonalize(matrix=-cmplx_i*matrix, P=P, D=D)

do i = 1, size(matrix(:, 1))
D(i, i) = exp(cmplx_i*D(i, i))
Expand Down Expand Up @@ -385,7 +385,7 @@ function logu(matrix)

integer :: i

call schur(matrix = matrix, Z = Z, S = S)
call schur(matrix=matrix, Z=Z, S=S)

do i = 1, size(matrix(:, 1))
S(i, i) = log(S(i, i))
Expand Down
38 changes: 18 additions & 20 deletions test/suites/Extra_Utilities_Suite.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ module Extra_Utilities_Suite
use WannInt_kinds, only: wp => dp
use WannInt_definitions, only: cmplx_i, pi
use WannInt_utilities, only: diagonalize, &
dirac_delta, deg_list, &
schur, SVD, expsh, logu
dirac_delta, deg_list, &
schur, SVD, expsh, logu
use WannInt, only: crystal
use testdrive, only: new_unittest, unittest_type, error_type
implicit none
Expand Down Expand Up @@ -33,7 +33,7 @@ subroutine test_dirac_delta(error)
x = 0.01_wp
smr = 0.1_wp

if(abs(dirac_delta(x, smr) - 3.9695254747701179_wp)>tol*epsilon(1.0_wp)) then
if (abs(dirac_delta(x, smr) - 3.9695254747701179_wp) > tol*epsilon(1.0_wp)) then
allocate (error)
return
endif
Expand Down Expand Up @@ -64,14 +64,14 @@ subroutine test_deg_list(error)
call diagonalize(matrix=H, P=R, eig=eig)

dg_lts = deg_list(eig, 0.0001_wp)
if(dg_lts(2)/=3) then
if (dg_lts(2) /= 3) then
allocate (error)
return
endif

eig = 0.0_wp
dg_lts = deg_list(eig, 0.0001_wp)
if(dg_lts(1)/=Si%num_bands()) then
if (dg_lts(1) /= Si%num_bands()) then
allocate (error)
return
endif
Expand All @@ -97,9 +97,9 @@ subroutine test_SVD(error)

matches = 0
do i = 1, 3
if(abs(eig(i)) < tol*epsilon(1.0_wp)) matches = matches + 1
if (abs(eig(i)) < tol*epsilon(1.0_wp)) matches = matches + 1
enddo
if(matches /= 1) then
if (matches /= 1) then
allocate (error)
return
endif
Expand All @@ -118,37 +118,35 @@ subroutine test_exp_and_log(error)
call random_seed()
call random_number(nr)

n = nint(2.0_wp + 28.0_wp * nr)
n = nint(2.0_wp + 28.0_wp*nr)
n = 30

allocate(rnd1(n, n), rnd2(n, n), eig(n), m(n, n), res(n, n), p(n, n))
allocate (rnd1(n, n), rnd2(n, n), eig(n), m(n, n), res(n, n), p(n, n))

call random_number(rnd1)
rnd1 = 1.0_wp + 9.0_wp * rnd1
rnd1 = 1.0_wp + 9.0_wp*rnd1
call random_number(rnd2)
rnd2 = 1.0_wp + 9.0_wp * rnd2
rnd2 = 1.0_wp + 9.0_wp*rnd2

m = cmplx(rnd1, rnd2, wp)
m = (m - conjg(transpose(m)))/2.0_wp
call diagonalize(matrix = cmplx_i*m, P = p, eig = eig)
call diagonalize(matrix=cmplx_i*m, P=p, eig=eig)
sv = eig(1)

res = logu(matrix = expsh(matrix = m))
call diagonalize(matrix = cmplx_i*res, P = p, eig = eig)
res = logu(matrix=expsh(matrix=m))
call diagonalize(matrix=cmplx_i*res, P=p, eig=eig)

matches = 0
do i = 1, n
if(abs(aimag(log(exp(cmplx_i*sv))) - eig(i))< 1.0E-5_wp) matches = matches + 1
if (abs(aimag(log(exp(cmplx_i*sv))) - eig(i)) < 1.0E-5_wp) matches = matches + 1
enddo
if(matches < 1) then
if (matches < 1) then
allocate (error)
return
endif

deallocate(rnd1, rnd2, eig, m, res, p)
deallocate (rnd1, rnd2, eig, m, res, p)

end subroutine test_exp_and_log



end module Extra_Utilities_Suite
end module Extra_Utilities_Suite

0 comments on commit d6ed5da

Please sign in to comment.