diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 3afce9b..50667f4 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -1,6 +1,6 @@ name: Testing suite -on: +on: schedule: - cron: "0 11 * * 1" push: diff --git a/CITATION.cff b/CITATION.cff index a614257..116da3d 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -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 diff --git a/README.md b/README.md index 5f58c30..4990421 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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. @@ -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 diff --git a/app/runtime_error_detection/Randomized.F90 b/app/runtime_error_detection/Randomized.F90 index 52da9f2..395980f 100644 --- a/app/runtime_error_detection/Randomized.F90 +++ b/app/runtime_error_detection/Randomized.F90 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/src/WannInt.F90 b/src/WannInt.F90 index 5e93b1c..cc1ec61 100644 --- a/src/WannInt.F90 +++ b/src/WannInt.F90 @@ -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 diff --git a/src/WannInt_utilities.F90 b/src/WannInt_utilities.F90 index 280c776..acdeea0 100644 --- a/src/WannInt_utilities.F90 +++ b/src/WannInt_utilities.F90 @@ -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 @@ -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) @@ -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))) @@ -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)) @@ -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)) diff --git a/test/suites/Extra_Utilities_Suite.F90 b/test/suites/Extra_Utilities_Suite.F90 index 734683c..33ce3db 100644 --- a/test/suites/Extra_Utilities_Suite.F90 +++ b/test/suites/Extra_Utilities_Suite.F90 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 \ No newline at end of file +end module Extra_Utilities_Suite