34 SUBROUTINE libtetrabz_occ(ltetra,bvec,nb,nge,eig,ngw,wght,comm)
BIND(C)
40 INTEGER(C_INT),
INTENT(IN) :: ltetra, nb, nge(3), ngw(3)
41 REAL(c_double),
INTENT(IN) :: bvec(9), eig(nb,product(nge(1:3)))
42 REAL(c_double),
INTENT(OUT) :: wght(nb,product(ngw(1:3)))
43 INTEGER(C_INT),
INTENT(IN),
OPTIONAL :: comm
46 INTEGER :: nt_local, nk_local, nkbz, ik, kintp(8)
47 INTEGER,
ALLOCATABLE :: ik_global(:,:), ik_local(:,:)
48 REAL(8) :: wlsm(4,20), wintp(1,8)
49 REAL(8),
ALLOCATABLE :: wghtd(:,:,:), kvec(:,:)
51 IF(
PRESENT(comm))
THEN
53 & nt_local,nkbz,ik_global,ik_local,kvec,comm)
56 & nt_local,nkbz,ik_global,ik_local,kvec)
61 ALLOCATE(wghtd(nb,1,nk_local))
66 wght(1:nb,1:product(ngw(1:3))) = 0d0
69 wght(1:nb,kintp(1:8)) = wght(1:nb, kintp(1:8)) &
70 & + matmul(wghtd(1:nb,1:1,ik), wintp(1:1,1:8))
72 DEALLOCATE(wghtd, kvec)
80 DEALLOCATE(ik_global, ik_local)
93 INTEGER(C_INT),
INTENT(IN) :: ltetra, nb, nge(3), ngw(3)
94 REAL(c_double),
INTENT(IN) :: bvec(9), nelec, eig(nb,product(nge(1:3)))
95 REAL(c_double),
INTENT(OUT) :: ef
96 REAL(c_double),
INTENT(OUT) :: wght(nb,product(ngw(1:3)))
97 INTEGER(C_INT),
INTENT(IN),
OPTIONAL :: comm
100 INTEGER :: nt_local, nk_local, nkbz, ik, kintp(8)
101 INTEGER,
ALLOCATABLE :: ik_global(:,:), ik_local(:,:)
102 REAL(8) :: wlsm(4,20), wintp(1,8)
103 REAL(8),
ALLOCATABLE :: wghtd(:,:,:), kvec(:,:)
105 INTEGER :: iter, maxiter = 300
106 REAL(8) :: elw, eup, eps= 1d-10, sumkmid
108 IF(
PRESENT(comm))
THEN
110 & nt_local,nkbz,ik_global,ik_local,kvec,comm)
113 & nt_local,nkbz,ik_global,ik_local,kvec)
116 IF(linterpol)
ALLOCATE(wghtd(nb,1,nk_local))
118 elw = minval(eig(1:nb,1:product(nge(1:3))))
119 eup = maxval(eig(1:nb,1:product(nge(1:3))))
125 ef = (eup + elw) / 2.d0
131 sumkmid = sum(wghtd(1:nb,1,1:nk_local))
137 sumkmid = sum(wght(1:nb,1:nk_local))
142 IF(abs(sumkmid - nelec) < eps)
THEN
144 ELSE IF(sumkmid < nelec)
THEN
152 IF(iter >= maxiter) stop
"libtetrabz_fermieng"
158 wght(1:nb,1:product(ngw(1:3))) = 0d0
161 wght(1:nb,kintp(1:8)) = wght(1:nb, kintp(1:8)) &
162 & + matmul(wghtd(1:nb,1:1,ik), wintp(1:1,1:8))
164 DEALLOCATE(wghtd, kvec)
170 DEALLOCATE(ik_global, ik_local)
176 SUBROUTINE libtetrabz_occ_main(wlsm,nt_local,ik_global,ik_local,nb,nkBZ,eig,nk_local,occ,ef)
185 INTEGER,
INTENT(IN) :: nt_local, nb, nkBZ, nk_local, &
186 & ik_global(20,nt_local), ik_local(20,nt_local)
187 REAL(8),
INTENT(IN) :: wlsm(4,20), ef, eig(nb,nkBZ)
188 REAL(8),
INTENT(OUT) :: occ(nb,nk_local)
190 INTEGER :: ib, indx(4), it
191 REAL(8) :: e(4), ei1(4,nb), tsmall(4,4), V, w1(4)
193 occ(1:nb,1:nk_local) = 0d0
202 ei1(1:4,ib) = matmul(wlsm(1:4,1:20), eig(ib,ik_global(1:20,it)))
209 e(1:4) = ei1(1:4, ib) - ef
212 IF(e(1) <= 0d0 .AND. 0d0 < e(2))
THEN
215 w1(indx(1:4)) = w1(indx(1:4)) + v * sum(tsmall(1:4,1:4), 1) * 0.25d0
217 ELSE IF(e(2) <= 0d0 .AND. 0d0 < e(3))
THEN
220 w1(indx(1:4)) = w1(indx(1:4)) + v * sum(tsmall(1:4,1:4), 1) * 0.25d0
223 w1(indx(1:4)) = w1(indx(1:4)) + v * sum(tsmall(1:4,1:4), 1) * 0.25d0
226 w1(indx(1:4)) = w1(indx(1:4)) + v * sum(tsmall(1:4,1:4), 1) * 0.25d0
228 ELSE IF(e(3) <= 0d0 .AND. 0d0 < e(4))
THEN
231 w1(indx(1:4)) = w1(indx(1:4)) + v * sum(tsmall(1:4,1:4), 1) * 0.25d0
234 w1(indx(1:4)) = w1(indx(1:4)) + v * sum(tsmall(1:4,1:4), 1) * 0.25d0
237 w1(indx(1:4)) = w1(indx(1:4)) + v * sum(tsmall(1:4,1:4), 1) * 0.25d0
239 ELSE IF(e(4) <= 0d0)
THEN
249 occ(ib,ik_local(1:20,it)) = occ(ib,ik_local(1:20,it)) &
250 & + matmul(w1(1:4), wlsm(1:4,1:20))
259 occ(1:nb,1:nk_local) = occ(1:nb,1:nk_local) / dble(6 * nkbz)