22 use,
intrinsic :: iso_fortran_env, only: real64
54 integer :: n_simplices
56 integer,
allocatable :: simplices(:,:)
82 function simplex_init(dim, naxis, nshifts, shift, kpoints, equiv, opt)
result(this)
83 integer,
intent(in) :: dim
84 integer,
intent(in) :: naxis(1:dim)
85 integer,
intent(in) :: nshifts
86 real(real64),
intent(in) :: shift(:,:)
87 real(real64),
intent(in) :: kpoints(:,:)
88 integer,
intent(in),
optional :: equiv(:)
89 logical,
intent(in) :: opt
90 type(simplex_t),
pointer :: this
92 real(real64) :: kmin(dim)
93 integer :: ik, npoints
96 integer,
allocatable :: kl123(:,:,:)
98 integer :: rdim, raxis(3)
102 if (nshifts /= 1)
then
103 message(1) =
"The linear tetrahedron method only works for automatic k-point grids with a single shift"
108 safe_allocate_source(kl123(1:naxis(1), 1:naxis(2), 1:naxis(3)), -1)
110 npoints = product(naxis)
111 kmin = minval(kpoints, 2)
114 ix(:) = nint((kpoints(:,ik) - kmin) * naxis + 1)
115 assert(kl123(ix(1), ix(2), ix(3)) == -1)
116 if (
present(equiv))
then
117 kl123(ix(1), ix(2), ix(3)) = equiv(ik)
119 kl123(ix(1), ix(2), ix(3)) = ik
123 rdim = sum(merge(1, 0, naxis > 1))
124 raxis(1:rdim) = pack(naxis, naxis > 1)
126 if (any(raxis(1:rdim) /= naxis(1:rdim)))
then
127 message(1) =
"The periodic dimensions must be consecutive"
136 integer,
parameter :: submesh_segments(1,2) = reshape([ &
137 1, 2 ], shape(submesh_segments), order=[2, 1])
139 integer,
parameter :: b(4,2) = reshape([ &
144 ], shape(b), order=[2, 1])
146 integer :: i, ip1, it, n
147 integer :: corners(2,1), v(2,1), c(1)
148 integer :: this_segment(2), this_corner
150 this%n_points = npoints
151 this%n_simplices = npoints
153 this%sdim = merge(4, 2, opt)
154 safe_allocate(this%simplices(this%n_simplices, this%sdim))
157 ip1 = modulo(i, raxis(1)) + 1
158 corners(:,:) = reshape([ i , ip1 ], shape(corners), order=[2, 1])
160 do it = 1,
size(submesh_segments, 1)
161 n = (it - 1) + 1 * (i - 1) + 1
162 this_segment(:) = submesh_segments(it, :)
163 v(1,:) = corners(this_segment(1), :)
164 v(2,:) = corners(this_segment(2), :)
166 c(:) = b(ik,1) * v(1,:) + b(ik,2) * v(2,:)
167 c(:) = modulo(c(:) - 1, raxis(1:rdim)) + 1
168 this_corner = kl123(c(1), 1, 1)
169 this%simplices(n,ik) = this_corner
176 integer,
parameter :: submesh_triangles(2,3) = reshape([ &
178 1, 4, 3], shape(submesh_triangles), order=[2, 1])
180 integer,
parameter :: b(10,3) = reshape([ &
191 ], shape(b), order=[2, 1])
193 integer :: i, j, ip1, jp1, it, n
194 integer :: corners(4,2), v(3,2), c(2)
195 integer :: this_triangle(3), this_corner
197 this%n_points = npoints
198 this%n_simplices = 2 * npoints
200 this%sdim = merge(10, 3, opt)
201 safe_allocate(this%simplices(this%n_simplices, this%sdim))
205 ip1 = modulo(i, raxis(1)) + 1
206 jp1 = modulo(j, raxis(2)) + 1
207 corners(:,:) = reshape([ &
211 i , jp1 ], shape(corners), order=[2, 1])
213 do it = 1,
size(submesh_triangles, 1)
214 n = (it - 1) + 2 * ((j - 1) + raxis(2) * (i - 1)) + 1
215 this_triangle(:) = submesh_triangles(it, :)
216 v(1,:) = corners(this_triangle(1), :)
217 v(2,:) = corners(this_triangle(2), :)
218 v(3,:) = corners(this_triangle(3), :)
220 c(:) = b(ik,1) * v(1,:) + b(ik,2) * v(2,:) + b(ik,3) * v(3,:)
221 c(:) = modulo(c(:) - 1, raxis(1:rdim)) + 1
222 this_corner = kl123(c(1), c(2), 1)
223 this%simplices(n,ik) = this_corner
231 integer,
parameter :: submesh_tetras(6,4) = reshape([ &
237 2, 3, 4, 6], shape(submesh_tetras), order=[2, 1])
239 integer,
parameter :: b(20,4) = reshape([ &
260 ], shape(b), order=[2, 1])
262 integer :: i, j, k, ip1, jp1, kp1, it, n
263 integer :: corners(8,3), v(4,3), c(3)
264 integer :: this_tetra(4), this_corner
266 this%n_points = npoints
267 this%n_simplices = 6 * npoints
269 this%sdim = merge(20, 4, opt)
270 safe_allocate(this%simplices(this%n_simplices, this%sdim))
275 ip1 = modulo(i, raxis(1)) + 1
276 jp1 = modulo(j, raxis(2)) + 1
277 kp1 = modulo(k, raxis(3)) + 1
278 corners(:,:) = reshape([ &
286 ip1 , jp1 , kp1 ], shape(corners), order=[2, 1])
288 do it = 1,
size(submesh_tetras, 1)
289 n = (it - 1) + 6 * ((k - 1) + raxis(3) * ((j - 1) + raxis(2) * (i - 1))) + 1
290 this_tetra(:) = submesh_tetras(it, :)
291 v(1,:) = corners(this_tetra(1), :)
292 v(2,:) = corners(this_tetra(2), :)
293 v(3,:) = corners(this_tetra(3), :)
294 v(4,:) = corners(this_tetra(4), :)
296 c(:) = b(ik,1) * v(1,:) + b(ik,2) * v(2,:) + b(ik,3) * v(3,:) + b(ik,4) * v(4,:)
297 c(:) = modulo(c(:) - 1, raxis(1:rdim)) + 1
298 this_corner = kl123(c(1), c(2), c(3))
299 this%simplices(n,ik) = this_corner
308 safe_deallocate_a(kl123)
319 safe_deallocate_a(this%simplices)
331 integer,
intent(in) :: rdim
332 real(real64),
intent(in) :: esimplex(:)
333 real(real64),
intent(in) :: ef
334 real(real64),
intent(out) :: weights(:)
335 real(real64),
intent(out) :: dos(:)
358 integer,
intent(in) :: rdim
359 real(real64),
intent(in) :: esimplex(:)
360 real(real64),
intent(in) :: ef
361 real(real64),
intent(out) :: dos(:)
384 real(real64),
intent(in) :: esegment(:)
385 real(real64),
intent(in) :: ef
386 real(real64),
intent(out) :: weights(:)
387 real(real64),
intent(out) :: dos(:)
389 real(real64) :: e(2), e1, e2
390 real(real64) :: w(2), d(2)
393 real(real64),
parameter :: vt_vg = 1.0_real64
394 real(real64),
parameter :: vt_2vg = vt_vg / 2.0_real64
396 real(real64),
parameter :: p(2,4) = 1.0_real64 / 60.0_real64 * reshape([ &
398 1 , 64 , -2 , -3 ], shape(p), order=[2, 1])
402 select case (
size(esegment))
409 do i = 1,
size(esegment)
410 e(:) = e(:) + p(:,i) * esegment(i)
425 elseif (e2 < ef)
then
428 elseif (e1 < ef .and. ef <= e2)
then
430 real(real64) :: e21, c
432 c = vt_2vg * (ef - e1) / e21
435 2.0_real64 - (ef - e1) / e21, &
438 d(:) = vt_vg / e21 * [ &
439 m_one - (ef - e1) / e21, &
447 select case (
size(esegment))
449 weights(idx) = w + sum(d) * (sum(e) - 2.0_real64 * e) / 12.0_real64
463 real(real64),
intent(in) :: esegment(:)
464 real(real64),
intent(in) :: ef
465 real(real64),
intent(out) :: dos(:)
467 real(real64) :: e(2), e1, e2
471 real(real64),
parameter :: vt_vg = 1.0_real64
473 real(real64),
parameter :: p(2,4) = 1.0_real64 / 60.0_real64 * reshape([ &
475 1 , 64 , -2 , -3 ], shape(p), order=[2, 1])
479 select case (
size(esegment))
486 do i = 1,
size(esegment)
487 e(:) = e(:) + p(:,i) * esegment(i)
499 if (ef <= e1 .or. e2 < ef)
then
501 elseif (e1 < ef .and. ef <= e2)
then
506 d(:) = vt_vg / e21 * [ &
507 m_one - (ef - e1) / e21, &
530 real(real64),
intent(in) :: etriangle(:)
531 real(real64),
intent(in) :: ef
532 real(real64),
intent(out) :: weights(:)
533 real(real64),
intent(out) :: dos(:)
535 real(real64) :: e(3), e1, e2, e3
536 real(real64) :: w(3), d(3)
539 real(real64),
parameter :: vt_vg = 1.0_real64 / 2.0_real64
540 real(real64),
parameter :: vt_3vg = vt_vg / 3.0_real64
542 real(real64),
parameter :: p(3,10) = 1.0_real64 / 360.0_real64 * reshape([ &
543 402 , 0 , 6 , -13 , 5 , -17 , -13 , -11 , 7 , -6 , &
544 6 , 396 , 6 , -9 , -15 , 3 , 3 , -15 , -9 , -6 , &
545 6 , 0 , 402 , 7 , -11 , -13 , -17 , 5 , -13 , -6 &
546 ], shape(p), order=[2, 1])
550 select case (
size(etriangle))
557 do i = 1,
size(etriangle)
558 e(:) = e(:) + p(:,i) * etriangle(i)
574 elseif (e3 < ef)
then
577 elseif (e1 < ef .and. ef <= e2)
then
579 real(real64) :: e21, e31, c
582 c = vt_3vg * (ef - e1) ** 2 / (e21 * e31)
585 3.0_real64 - (ef - e1) * (m_one / e21 + m_one / e31), &
589 d(:) = vt_vg * (ef - e1) / (e21 * e31) * [&
590 2.0_real64 - (ef - e1) * (m_one / e31 + m_one / e21), &
594 elseif (e2 < ef .and. ef <= e3)
then
596 real(real64) :: e23, e31, c1, c2
600 c2 = vt_3vg * (ef - e3) ** 2 / (e23 * e31)
603 c1 - c2 * (ef - e3) / e31, &
604 c1 + c2 * (ef - e3) / e23, &
605 c1 + c2 * (3.0_real64 - (ef - e3) * (m_one / e23 - m_one / e31))]
607 d(:) = vt_vg * (ef - e3) / (e23 * e31) * [ &
610 2.0_real64 - (ef - e3) * (m_one / e23 - m_one / e31)]
617 select case (
size(etriangle))
619 weights(idx) = w + sum(d) * (sum(e) - 3.0_real64 * e) / 24.0_real64
636 real(real64),
intent(in) :: etriangle(:)
637 real(real64),
intent(in) :: ef
638 real(real64),
intent(out) :: dos(:)
640 real(real64) :: e(3), e1, e2, e3
644 real(real64),
parameter :: vt_vg = 1.0_real64 / 2.0_real64
646 real(real64),
parameter :: p(3,10) = 1.0_real64 / 360.0_real64 * reshape([ &
647 402 , 0 , 6 , -13 , 5 , -17 , -13 , -11 , 7 , -6 , &
648 6 , 396 , 6 , -9 , -15 , 3 , 3 , -15 , -9 , -6 , &
649 6 , 0 , 402 , 7 , -11 , -13 , -17 , 5 , -13 , -6 &
650 ], shape(p), order=[2, 1])
654 select case (
size(etriangle))
661 do i = 1,
size(etriangle)
662 e(:) = e(:) + p(:,i) * etriangle(i)
675 if (ef <= e1 .or. e3 < ef)
then
677 elseif (e1 < ef .and. ef <= e2)
then
679 real(real64) :: e21, e31
683 d(:) = vt_vg * (ef - e1) / (e21 * e31) * [&
684 (2.0_real64 - (ef - e1) * (m_one / e31 + m_one / e21)), &
688 elseif (e2 < ef .and. ef <= e3)
then
690 real(real64) :: e23, e31
694 d(:) = vt_vg * (ef - e3) / (e23 * e31) * [ &
697 2.0_real64 - (ef - e3) * (m_one / e23 - m_one / e31)]
722 real(real64),
intent(in) :: etetra(:)
723 real(real64),
intent(in) :: ef
724 real(real64),
intent(out) :: weights(:)
725 real(real64),
intent(out) :: dos(:)
727 real(real64) :: e(4), e1, e2, e3, e4
728 real(real64) :: w(4), d(4)
731 real(real64),
parameter :: vt_vg = 1.0_real64 / 6.0_real64
732 real(real64),
parameter :: vt_4vg = vt_vg / 4.0_real64
734 real(real64),
parameter :: p(4,20) = 1.0_real64 / 1260.0_real64 * reshape([ &
735 1440, 0 , 30 , 0 , -38 , 7 , 17 , -28 , -56 , 9 , -46 , 9 , -38 , -28 , 17 , 7 , -18 , -18 , 12 , -18 , &
736 0 , 1440, 0 , 30 , -28 , -38 , 7 , 17 , 9 , -56 , 9 , -46 , 7 , -38 , -28 , 17 , -18 , -18 , -18 , 12 , &
737 30 , 0 , 1440, 0 , 17 , -28 , -38 , 7 , -46 , 9 , -56 , 9 , 17 , 7 , -38 , -28 , 12 , -18 , -18 , -18 , &
738 0 , 30 , 0 , 1440, 7 , 17 , -28 , -38 , 9 , -46 , 9 , -56 , -28 , 17 , 7 , -38 , -18 , 12 , -18 , -18 &
739 ], shape(p), order=[2, 1])
743 select case (
size(etetra))
750 do i = 1,
size(etetra)
751 e(:) = e(:) + p(:,i) * etetra(i)
768 elseif (e4 < ef)
then
771 elseif (e1 < ef .and. ef <= e2)
then
773 real(real64) :: e21, e31, e41, c
777 c = vt_4vg * (ef - e1) ** 3 / (e21 * e31 * e41)
780 4.0_real64 - (ef - e1) * (m_one / e21 + m_one / e31 + m_one / e41), &
786 real(real64) :: f12, f13, f14, f21, f31, f41, g
787 f21 = (ef - e1) / (e2 - e1)
788 f31 = (ef - e1) / (e3 - e1)
789 f41 = (ef - e1) / (e4 - e1)
793 g = f31 * f41 / (e2 - e1)
794 d(:) = vt_vg * g * [&
800 elseif (e2 < ef .and. ef <= e3)
then
802 real(real64) :: e21, e31, e32, e41, e42, c1, c2, c3
808 c1 = vt_4vg * (ef - e1) ** 2 / (e41 * e31)
809 c2 = vt_4vg * (ef - e1) * (ef - e2) * (e3 - ef) / (e41 * e32 * e31)
810 c3 = vt_4vg * (ef - e2) ** 2 * (e4 - ef) / (e42 * e32 * e41)
813 c1 + (c1 + c2) * (e3 - ef) / e31 + (c1 + c2 + c3) * (e4 - ef) / e41, &
814 c1 + c2 + c3 + (c2 + c3) * (e3 - ef) / e32 + c3 * (e4 - ef) / e42, &
815 (c1 + c2) * (ef - e1) / e31 + (c2 + c3) * (ef - e2) / e32, &
816 (c1 + c2 + c3) * (ef - e1) / e41 + c3 * (ef - e2) / e42]
819 real(real64) :: f13, f14, f23, f24, f31, f32, f41, f42, g, delta
821 f31 = (ef - e1) / (e3 - e1)
822 f41 = (ef - e1) / (e4 - e1)
823 f32 = (ef - e2) / (e3 - e2)
824 f42 = (ef - e2) / (e4 - e2)
829 g = 3.0_real64 / delta * (f23 * f31 + f32 * f24)
831 g * f14 / 3.0_real64 + f13 * f31 * f23 / delta, &
832 g * f23 / 3.0_real64 + f24 * f24 * f32 / delta, &
833 g * f32 / 3.0_real64 + f31 * f31 * f23 / delta, &
834 g * f41 / 3.0_real64 + f42 * f24 * f32 / delta]
836 elseif (e3 < ef .and. ef <= e4)
then
838 real(real64) :: e41, e42, e43, c
842 c = vt_4vg * (e4 - ef) ** 3 / (e41 * e42 * e43)
844 w(:) = vt_4vg - c * [ &
848 4.0_real64 - (e4 - ef) * (m_one / e41 + m_one / e42 + m_one / e43)]
851 real(real64) :: f14, f24, f34, f41, f42, f43, g
852 f14 = (ef - e4) / (e1 - e4)
853 f24 = (ef - e4) / (e2 - e4)
854 f34 = (ef - e4) / (e3 - e4)
858 g = f14 * f24 / (e4 - e3)
859 d(:) = vt_vg * g *[ &
870 select case (
size(etetra))
872 weights(idx) = w + sum(d) * (sum(e) - 4.0_real64 * e) / 40.0_real64
892 real(real64),
intent(in) :: etetra(:)
893 real(real64),
intent(in) :: ef
894 real(real64),
intent(out) :: dos(:)
896 real(real64) :: e(4), e1, e2, e3, e4
900 real(real64),
parameter :: vt_vg = 1.0_real64 / 6.0_real64
902 real(real64),
parameter :: p(4,20) = 1.0_real64 / 1260.0_real64 * reshape([ &
903 1440, 0 , 30 , 0 , -38 , 7 , 17 , -28 , -56 , 9 , -46 , 9 , -38 , -28 , 17 , 7 , -18 , -18 , 12 , -18 , &
904 0 , 1440, 0 , 30 , -28 , -38 , 7 , 17 , 9 , -56 , 9 , -46 , 7 , -38 , -28 , 17 , -18 , -18 , -18 , 12 , &
905 30 , 0 , 1440, 0 , 17 , -28 , -38 , 7 , -46 , 9 , -56 , 9 , 17 , 7 , -38 , -28 , 12 , -18 , -18 , -18 , &
906 0 , 30 , 0 , 1440, 7 , 17 , -28 , -38 , 9 , -46 , 9 , -56 , -28 , 17 , 7 , -38 , -18 , 12 , -18 , -18 &
907 ], shape(p), order=[2, 1])
911 select case (
size(etetra))
918 do i = 1,
size(etetra)
919 e(:) = e(:) + p(:,i) * etetra(i)
933 if (e1 >= ef .or. e4 < ef)
then
935 elseif (e1 < ef .and. ef <= e2)
then
937 real(real64) :: f12, f13, f14, f21, f31, f41, g
938 f21 = (ef - e1) / (e2 - e1)
939 f31 = (ef - e1) / (e3 - e1)
940 f41 = (ef - e1) / (e4 - e1)
944 g = f31 * f41 / (e2 - e1)
945 d(:) = vt_vg * g * [&
951 elseif (e2 < ef .and. ef <= e3)
then
953 real(real64) :: f13, f14, f23, f24, f31, f32, f41, f42, g, delta
955 f31 = (ef - e1) / (e3 - e1)
956 f41 = (ef - e1) / (e4 - e1)
957 f32 = (ef - e2) / (e3 - e2)
958 f42 = (ef - e2) / (e4 - e2)
963 g = 3.0_real64 / delta * (f23 * f31 + f32 * f24)
965 g * f14 / 3.0_real64 + f13 * f31 * f23 / delta, &
966 g * f23 / 3.0_real64 + f24 * f24 * f32 / delta, &
967 g * f32 / 3.0_real64 + f31 * f31 * f23 / delta, &
968 g * f41 / 3.0_real64 + f42 * f24 * f32 / delta]
970 elseif (e3 < ef .and. ef <= e4)
then
972 real(real64) :: f14, f24, f34, f41, f42, f43, g
973 f14 = (ef - e4) / (e1 - e4)
974 f24 = (ef - e4) / (e2 - e4)
975 f34 = (ef - e4) / (e3 - e4)
979 g = f14 * f24 / (e4 - e3)
980 d(:) = vt_vg * g *[ &
This is the common interface to a sorting routine. It performs the shell algorithm,...
type(debug_t), save, public debug
subroutine, public debug_pop_sub(sub_name)
Pop a routine from the debug trace.
subroutine, public debug_push_sub(sub_name)
Push a routine to the debug trace.
real(real64), parameter, public m_two
real(real64), parameter, public m_zero
integer(int64), public global_sizeof
logical pure function, public not_in_openmp()
character(len=100), public global_alloc_errmsg
integer, public global_alloc_err
real(real64), parameter, public m_one
subroutine, public alloc_error(size, file, line)
subroutine, public messages_not_implemented(feature, namespace)
subroutine, public dealloc_error(size, file, line)
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
subroutine, public messages_fatal(no_lines, only_root_writes, namespace)
type(profile_vars_t), target, save, public prof_vars
integer, parameter, public profiling_memory
subroutine, public profiling_out(label)
Increment out counter and sum up difference between entry and exit time.
subroutine, public profiling_in(label, exclude)
Increment in counter and save entry time.
subroutine, public profiling_memory_deallocate(var, file, line, size)
subroutine, public profiling_memory_allocate(var, file, line, size_)
subroutine, public simplex_weights(rdim, esimplex, eF, weights, dos)
Get the weights and DOS contribution of a single simplex.
subroutine, public simplex_weights_2d(etriangle, eF, weights, dos)
Get the weights and DOS contribution of a single tetrahedron.
subroutine, public simplex_dos_3d(etetra, eF, dos)
Get only the DOS contribution of a single tetrahedron.
type(simplex_t) function, pointer, public simplex_init(dim, naxis, nshifts, shift, kpoints, equiv, opt)
Constructor for linear simplex methods.
subroutine, public simplex_dos_1d(esegment, eF, dos)
Get only the DOS contribution of a single segment.
subroutine, public simplex_end(this)
Destructor for linear simplex methods.
subroutine, public simplex_weights_1d(esegment, eF, weights, dos)
Get the weights and DOS contribution of a single segment.
subroutine, public simplex_dos_2d(etriangle, eF, dos)
Get only the DOS contribution of a single triangle.
subroutine, public simplex_weights_3d(etetra, eF, weights, dos)
Get the weights and DOS contribution of a single tetrahedron.
subroutine, public simplex_dos(rdim, esimplex, eF, dos)
Get only the DOS contribution of a single simplex.
This module is intended to contain "only mathematical" functions and procedures.