[Fortran] 纯文本查看 复制代码
function get_r(k) result(r)
implicit none
real(8) , intent(in) :: k(2)
complex(8) :: r(2, 6, 6)
! r is a three dimension array
r = 0.d0
r(1, 1, 1) = -a0*r0
r(1, 4, 4) = a0*r0
r(1, 5, 5) = -a0*r0
end function get_r
function get_v(k) result(v)
implicit none
real(8), intent(in) :: k(2)
complex(8) :: v(2, 6, 6)
complex(8) :: f1(2)
complex(8) :: H(6, 6), r(2, 6, 6)
integer :: i
v = 0.d0
f1(:) = CI*(rprimd(:, 1)*exp(2.d0*Pi*CI*k(1))+rprimd(:, 2)*exp(2.d0*Pi*CI*k(2)))
v(:, 1, 2) = t1*f1; v(:, 2, 1) = dconjg(v(:, 1, 2))
v(:, 3, 4) = t1*f1; v(:, 4, 3) = dconjg(v(:, 3, 4))
v(:, 5, 6) = t1*f1; v(:, 6, 5) = dconjg(v(:, 5, 6))
call get_H(k)
call get_r(k)
do i = 1, 2, 1
v(i, :, :) = (v(i, :, :) - CI*(Matmul(r(i, :, :), H) - MatMul(H, r(i, :, :))))/h_bar
end do
end function get_v