33 use,
intrinsic :: iso_fortran_env
69 integer :: calculation_mode
71 logical :: unitary_transform
72 type(states_elec_t) :: adiabatic_st
75 type(restart_t) :: restart_dump
76 integer :: istart, iend
77 complex(real64),
allocatable :: rho_offd(:, :)
79 real(real64) :: tmodel(2)
80 real(real64),
allocatable :: occ_gs(:, :)
82 real(real64) :: uniform(2)
84 character(len=256) :: epw_file
86 integer :: estart, eend, wnst
89 real(real64) :: astep(3)
91 integer,
allocatable :: kmap(:)
92 type(mpi_grp_t) :: intranode_grp, internode_grp
94 type(MPI_Win) :: window_trans_rate
103 real(real32),
pointer,
volatile :: ave_trans(:)
108 subroutine dmp_init(this, namespace, st, space, hm)
109 class(dmp_t),
intent(inout) :: this
110 type(namespace_t),
intent(in) :: namespace
111 type(states_elec_t),
intent(in) :: st
112 class(space_t),
intent(in) :: space
113 type(hamiltonian_elec_t),
intent(in) :: hm
116 integer :: ncols, nempty
117 real(real64) :: nempty_percent
132 call parse_variable(namespace,
'TDDMPropagationBasis', option__tddmpropagationbasis__adiabatic, this%basis)
157 call parse_variable(namespace,
'TDDMUnitaryTransformFix', .
true., this%unitary_transform)
168 if (this%istart < 1)
then
169 message(1) =
"Input: TDDMBandLowest must be positive."
182 if (this%iend < this%istart .or. this%iend > st%nst)
then
183 message(1) =
"Input: TDDMBandHighest must be within [TDDMBandLowest, total states]."
186 write(
message(1),
'(a, i0, a, i0)')
'Input: Propagating bands ', this%istart,
' - ', this%iend
204 if (
parse_block(namespace,
'TDDMPropagation_uniform_decay', blk) == 0)
then
205 if (this%strategy /= -1)
then
206 message(1) =
"Multiple dissipation strategies are not allowed."
216 message(1) =
"Info: TDDMPropagation uniform decay approximation:"
217 write(
message(2),
'(a, f0.2, 1x, 2a, F0.2, 1x, 2a)')
' [lifetime, temperature] = [', &
221 message(1) =
"Input: TDDMPropagation_uniform_decay block must have 2 columns."
237 if (
parse_block(namespace,
'TDDMPropagation_2Times', blk) == 0)
then
238 if (this%strategy /= -1)
then
239 message(1) =
"Multiple dissipation strategies are not allowed."
249 message(1) =
"Info: TDDMPropagation 2-times approximation:"
250 write(
message(2),
'(a, f12.6, a, f12.6, a,a)') &
251 ' [t1, t2] = [', this%tmodel(1) ,
', ', this%tmodel(2),
'] ', &
255 message(1) =
"Input: TDDMPropagation_2Times block must have 2 columns."
259 if (.not. this%othn)
then
261 message(1) =
"Overriding input: TDDMOrthogonal set to yes for TDDMPropagation_2Times."
276 call parse_variable(namespace,
'TDDMPropagation_from_epw',
'-', this%epw_file)
277 if (trim(this%epw_file) /=
'-')
then
279 write(
message(1),
'(a)')
'Only Monkhorst-Pack k-point meshes are supported in the EPW-DMPropagation strategy.'
282 if (hm%kpoints%reduced%nshifts /= 1)
then
283 write(
message(1),
'(a)')
'Multiple Monkhorst-Pack shifts are not supported in the EPW-DMPropagation strategy.'
286 if (space%dim /= 3)
then
287 write(
message(1),
'(a)')
'Only 3D systems are supported in the EPW-DMPropagation strategy.'
291 if (this%strategy /= -1)
then
292 message(1) =
"Multiple dissipation strategies are not allowed."
296 write(
message(1),
'(a, a)')
"Info: TDDMPropagation transition rates from file: ", trim(this%epw_file)
313 if (this%strategy == 3)
then
315 if (this%estart < this%istart .or. this%estart > this%iend)
then
316 write(
message(1),
'(a)')
'Input: EPWBandLowest must be within [TDDMBandLowest, TDDMBandHighest].'
322 if (this%calculation_mode == option__tddmpropagation__collision_integral .and. this%strategy /= 3)
then
323 message(1) =
"Warning: TDDMPropagation_from_epw is required for collision integral."
324 message(2) =
" Add TDDMPropagation_from_epw and rerun."
330 if (nempty == 0 .and. nempty_percent <
m_epsilon)
then
331 message(1) =
"Warning: TDDMPropagation requires a number of empty states."
332 message(2) =
" Add ExtraStates and rerun."
336 if (st%parallel_in_states)
then
337 message(1) =
"Warning: TDDMPropagation does not support parallel states."
338 message(2) =
" Remove ParallelStates and rerun."
352 type(
dmp_t),
intent(inout) :: dmp
355 type(
grid_t),
intent(in) :: gr
356 type(
ions_t),
intent(in) :: ions
360 logical,
intent(in) :: from_scratch
362 integer :: ierr, act_nst
371 if (from_scratch .or. dmp%basis == option__tddmpropagationbasis__groundstate)
then
378 call states_elec_load(restart_load, namespace, space, dmp%adiabatic_st, gr, hm%kpoints, fixed_occ=st%restart_fixed_occ, &
379 ierr=ierr, label =
": DM-basis")
381 message(1) =
'Unable to read DM-basis wavefunctions.'
385 call restart_load%end()
388 if (dmp%strategy == 2)
then
389 safe_allocate(dmp%occ_gs(1:st%nst, 1:st%nik))
390 dmp%occ_gs = dmp%adiabatic_st%occ
397 if (dmp%basis == option__tddmpropagationbasis__adiabatic)
then
402 act_nst = dmp%iend - dmp%istart + 1
403 safe_allocate(dmp%rho_offd(1:act_nst*(act_nst-1)/2, st%d%kpt%start:st%d%kpt%end))
409 type(
mpi_grp_t),
intent(in) :: system_grp
410 type(
dmp_t),
intent(inout) :: dmp
414 if (dmp%basis == option__tddmpropagationbasis__adiabatic)
then
415 call dmp%restart_dump%end()
422 safe_deallocate_a(dmp%occ_gs)
423 safe_deallocate_a(dmp%rho_offd)
429 subroutine dm_propagation_run(dmp, namespace, space, gr, ions, st, mc, hm, ks, iter, dt, ext_partners, update_energy)
430 type(
dmp_t),
intent(inout) :: dmp
433 type(
grid_t),
intent(in) :: gr
434 type(
ions_t),
intent(in) :: ions
438 type(
v_ks_t),
intent(inout) :: ks
439 integer,
intent(in) :: iter
440 real(real64),
intent(in) :: dt
442 logical,
optional,
intent(in) :: update_energy
444 real(real64),
parameter :: zero = 1.0e-15_real64
446 real(real64) :: nrm2_tdks(st%nst, st%nik), population(3), leak
447 integer :: ik, act_nst
448 logical :: update_energy_
450 complex(real64),
allocatable :: overlap_ad_ks(:, :, :), overlap_resd_ks(:, :, :), rho_mat_k(:, :, :)
451 integer,
allocatable :: nresd_k(:)
456 if (dmp%basis == option__tddmpropagationbasis__adiabatic)
then
457 call eigensolver_init(eigens, namespace, gr, dmp%adiabatic_st, hm, mc, space)
459 call eigens%run(namespace, gr, dmp%adiabatic_st, hm, space, ext_partners, iter)
462 act_nst = dmp%iend - dmp%istart + 1
464 safe_allocate(overlap_ad_ks(1:st%nst, 1:st%nst, st%d%kpt%start:st%d%kpt%end))
465 safe_allocate(overlap_resd_ks(1:st%nst, 1:st%nst, st%d%kpt%start:st%d%kpt%end))
466 safe_allocate(rho_mat_k(2*act_nst, 2*act_nst, st%d%kpt%start:st%d%kpt%end))
467 safe_allocate(nresd_k(st%d%kpt%start:st%d%kpt%end))
469 population = 0.0_real64
475 do ik = st%d%kpt%start, st%d%kpt%end
479 call calc_overlap_state(ik, gr, dmp%adiabatic_st, st, dmp%istart, dmp%iend, dmp%istart, dmp%iend, overlap_ad_ks(:, :, ik))
481 call population_in_adiabatic(ik, dmp%adiabatic_st, st, overlap_ad_ks(:, :, ik), dmp%istart, dmp%iend, population(2))
485 call construct_residuals(gr, namespace, dmp%adiabatic_st, st, ik, dmp%othn, dmp%istart, dmp%iend, &
486 overlap_ad_ks(:, :, ik), nrm2_tdks(:, ik), nresd_k(ik), overlap_resd_ks(:, :, ik), resd_st)
490 overlap_resd_ks(:, :, ik), rho_mat_k(:, :, ik), dmp%rho_offd(:, ik))
494 call broadcast_occupation(dmp%adiabatic_st%occ, dmp%adiabatic_st%d%kpt, st%parallel_in_states, dmp%istart, dmp%iend)
497 call dissipation(hm, st, namespace, nresd_k, dt, dmp, rho_mat_k)
499 do ik = st%d%kpt%start, st%d%kpt%end
501 call update_st(dmp, ik, gr, namespace, nresd_k(ik), overlap_ad_ks(:, :, ik), overlap_resd_ks(:, :, ik), nrm2_tdks(:, ik), &
502 resd_st, st, rho_mat_k(:, :, ik), population(3))
507 safe_deallocate_a(overlap_ad_ks)
508 safe_deallocate_a(overlap_resd_ks)
512 safe_deallocate_a(rho_mat_k)
513 safe_deallocate_a(nresd_k)
515 call st%d%kpt%mpi_grp%allreduce_inplace(population, 3, mpi_double_precision, mpi_sum)
517 write(
message(1),
'(a,E21.14,a,E21.14,a,E21.14,a)')
'DMPopulation: ', population(1), &
518 ' (', population(2),
' in basis ) before damping; ', population(3),
' after damping'
521 leak = population(1) - population(3)
522 if (abs(leak) > zero)
then
523 write(
message(1),
'(a,E15.8,a,I8)')
'Leakage: ', leak,
'(after damping) at time step', iter
526 dmp%adiabatic_st%qtot = population(1)
531 call v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, calc_eigenval = update_energy_, &
532 time = abs(iter * dt), calc_energy = update_energy_)
534 if (dmp%basis == option__tddmpropagationbasis__adiabatic)
then
545 integer,
intent(in) :: ik
547 type(
grid_t),
intent(in) :: gr
548 real(real64),
contiguous,
intent(out) :: nrm2(:)
549 real(real64),
intent(inout) :: pop
551 integer :: ib, i_minst, i_maxst
555 assert(pop >= 0.0_real64)
556 assert(
size(nrm2) == st%nst)
558 do ib = st%group%block_start, st%group%block_end
561 call mesh_batch_nrm2(gr, st%group%psib(ib, ik), nrm2(i_minst:i_maxst), reduce = .false.)
563 nrm2(1:st%nst) = nrm2(1:st%nst)**2
564 if (gr%parallel_in_domains)
then
565 call gr%allreduce(nrm2, dim = st%nst)
568 pop = pop + sum(st%occ(1:st%nst, ik) * nrm2(1:st%nst)) * st%kweights(ik)
578 integer,
intent(in) :: ik
579 type(
grid_t),
intent(in) :: gr
581 complex(real64),
contiguous,
intent(in) :: psi(:,:)
582 integer,
intent(in) :: istart
583 integer,
intent(in) :: iend
584 complex(real64),
intent(out) :: overlap(:)
585 logical,
optional,
intent(in) :: reduce
587 integer :: ib, i_minst, i_maxst, ist
588 complex(real64),
allocatable :: phi(:, :)
592 assert(iend >= istart)
593 assert(ubound(overlap, dim = 1) == st%nst)
595 safe_allocate(phi(1:gr%np, st%d%dim))
599 do ib = st%group%block_start, st%group%block_end
602 if (i_minst >= istart .and. i_maxst <= iend)
then
603 call zmesh_batch_mf_dotp(gr, st%group%psib(ib, ik), psi, overlap(i_minst:i_maxst), reduce=.false., &
604 nst=i_maxst-i_minst+1)
606 do ist = max(i_minst, istart), min(i_maxst, iend)
608 overlap(ist) =
zmf_dotp(gr, st%d%dim, phi, psi, reduce = .false.)
613 safe_deallocate_a(phi)
616 call gr%allreduce(overlap, dim = st%nst)
624 subroutine calc_overlap_state(ik, gr, ad_st, st, istart_ad, iend_ad, istart_st, iend_st, overlap)
625 integer,
intent(in) :: ik
626 type(
grid_t),
intent(in) :: gr
629 integer,
intent(in) :: istart_ad
630 integer,
intent(in) :: iend_ad
631 integer,
intent(in) :: istart_st
632 integer,
intent(in) :: iend_st
633 complex(real64),
intent(out) :: overlap(:, :)
635 integer :: ist, jst, ib, jb, i_minst, i_maxst, j_minst, j_maxst
636 complex(real64),
allocatable :: psi(:, :), dot(:)
640 assert(istart_ad <= iend_ad)
641 assert(istart_st <= iend_st)
642 assert(ubound(overlap, dim = 1) == ad_st%nst)
643 assert(ubound(overlap, dim = 2) == st%nst)
645 safe_allocate(psi(1:gr%np, st%d%dim))
646 safe_allocate(dot(1:st%nst))
650 do jb = st%group%block_start, st%group%block_end
655 if (j_minst >= istart_st .and. j_maxst <= iend_st)
then
656 do ib = ad_st%group%block_start, ad_st%group%block_end
661 if (i_minst >= istart_ad .and. i_maxst <= iend_ad)
then
666 do ist = max(i_minst, istart_ad), min(i_maxst, iend_ad)
668 call zmesh_batch_mf_dotp(gr, st%group%psib(jb, ik), psi, dot(j_minst:j_maxst), reduce=.false., &
669 nst=j_maxst-j_minst+1)
670 overlap(ist, j_minst:j_maxst) = conjg(dot(j_minst:j_maxst))
677 do jst = max(j_minst, istart_st), min(j_maxst, iend_st)
679 call calc_overlap_single(ik, gr, ad_st, psi, istart_ad, iend_ad, overlap(:,jst), reduce=.false.)
684 if (gr%parallel_in_domains)
then
685 call gr%allreduce(overlap)
688 safe_deallocate_a(psi)
689 safe_deallocate_a(dot)
698 integer,
intent(in) :: ik
701 complex(real64),
contiguous,
intent(in) :: overlap(:, :)
702 integer,
intent(in) :: istart
703 integer,
intent(in) :: iend
704 real(real64),
intent(inout) :: pop
710 assert(ubound(overlap, dim = 1) == ad_st%nst)
711 assert(ubound(overlap, dim = 2) == st%nst)
714 ad_st%occ(1:ad_st%nst, ik) = 0.0_real64
715 do jst = istart, iend
716 do ist = istart, iend
717 ad_st%occ(ist, ik) = ad_st%occ(ist, ik) + &
718 (real(overlap(ist, jst))**2 + aimag(overlap(ist, jst))**2) * st%occ(jst, ik)
722 pop = pop + sum(ad_st%occ(istart:iend, ik)) * ad_st%kweights(ik)
744 overlap_ad_ks, nrm2_tdks, nresd, overlap_resd_ks, resd)
745 type(
grid_t),
intent(in) :: gr
749 integer,
intent(in) :: ik
750 logical,
intent(in) :: othn
751 integer,
intent(in) :: istart
752 integer,
intent(in) :: iend
753 complex(real64),
contiguous,
intent(in) :: overlap_ad_ks(:, :)
754 real(real64),
contiguous,
intent(in) :: nrm2_tdks(:)
755 integer,
intent(out) :: nresd
756 complex(real64),
contiguous,
intent(out) :: overlap_resd_ks(:, :)
759 integer :: ib, i, j, i_minst, i_maxst
760 complex(real64),
allocatable :: d_j(:, :), phi(:, :)
761 real(real64),
parameter :: small_rho = 1.0e-14_real64
762 real(real64),
parameter :: small_resd = 1.0e-7_real64
763 real(real64) :: nrm_dj, nrm2_dj
764 logical,
allocatable :: mask(:)
768 assert(istart <= iend)
769 assert(ubound(overlap_ad_ks, dim = 1) == ad_st%nst)
770 assert(ubound(overlap_ad_ks, dim = 2) == st%nst)
771 assert(ubound(overlap_resd_ks, dim = 1) == resd%nst)
772 assert(ubound(overlap_resd_ks, dim = 2) == st%nst)
774 safe_allocate(d_j(1:gr%np, st%d%dim))
775 safe_allocate(phi(1:gr%np, ad_st%d%dim))
776 safe_allocate(mask(1:st%nst))
778 overlap_resd_ks =
m_z0
786 do ib = ad_st%group%block_start, ad_st%group%block_end
789 if (i_minst >= istart .and. i_maxst <= iend)
then
791 ad_st%group%psib(ib, ik), d_j, nst=i_maxst-i_minst+1)
793 do i = max(i_minst, istart), min(i_maxst, iend)
795 call lalg_axpy(gr%np, ad_st%d%dim, -overlap_ad_ks(i, j), phi, d_j)
805 call calc_overlap_single(ik, gr, st, d_j, istart, iend, overlap_resd_ks(j,:), reduce=.false.)
808 nresd = iend - istart + 1
818 nrm2_dj = nrm2_tdks(j) - sum(real(overlap_ad_ks(istart:iend, j))**2) - sum(aimag(overlap_ad_ks(istart:iend, j))**2)
819 if (nrm2_dj > small_rho)
then
822 nrm_dj =
sqrt(nrm2_dj)
827 do ib = ad_st%group%block_start, ad_st%group%block_end
830 if (i_minst >= istart .and. i_maxst <= iend)
then
832 ad_st%group%psib(ib, ik), d_j, nst=i_maxst-i_minst+1)
834 do i = max(i_minst, istart), min(i_maxst, iend)
836 call lalg_axpy(gr%np, ad_st%d%dim, -overlap_ad_ks(i, j) / nrm_dj, phi, d_j)
842 mask(istart:iend) = .false.
848 mask(istart:istart+nresd-1) = .false.
853 if (nrm_dj > small_resd)
then
859 call calc_overlap_single(ik, gr, st, d_j, istart, iend, overlap_resd_ks(istart+nresd-1,:), reduce=.false.)
865 if (gr%parallel_in_domains)
then
866 call gr%allreduce(overlap_resd_ks)
869 overlap_resd_ks = conjg(overlap_resd_ks)
871 safe_deallocate_a(d_j)
872 safe_deallocate_a(phi)
873 safe_deallocate_a(mask)
895 integer,
intent(in) :: nresd
896 integer,
intent(in) :: ik
898 integer,
intent(in) :: istart
899 integer,
intent(in) :: iend
900 complex(real64),
contiguous,
intent(in) :: overlap_ad_ks(:, :)
901 complex(real64),
contiguous,
intent(in) :: overlap_resd_ks(:, :)
902 complex(real64),
contiguous,
intent(out) :: rho_mat(:, :)
903 complex(real64),
contiguous,
intent(out) :: rho_offd(:)
905 integer :: ist, jst, lst, act_nst, idx
906 real(real64) :: sqrt_f
907 complex(real64),
allocatable :: s_ad_scaled(:, :), s_resd_scaled(:, :)
911 act_nst = iend - istart + 1
913 assert(istart <= iend)
914 assert(ubound(overlap_ad_ks, dim = 1) == st%nst)
915 assert(ubound(overlap_ad_ks, dim = 2) == st%nst)
916 assert(ubound(overlap_resd_ks, dim = 1) == st%nst)
917 assert(ubound(overlap_resd_ks, dim = 2) == st%nst)
918 assert(ubound(rho_mat, dim = 1) == 2*act_nst)
919 assert(ubound(rho_mat, dim = 2) == 2*act_nst)
920 assert(ubound(rho_offd, dim = 1) == act_nst*(act_nst-1)/2)
922 safe_allocate(s_ad_scaled(st%nst, st%nst))
924 safe_allocate(s_resd_scaled(st%nst, st%nst))
935 do lst = istart, iend
936 sqrt_f =
sqrt(st%occ(lst, ik))
937 s_ad_scaled(istart:iend, lst) = overlap_ad_ks(istart:iend, lst) * sqrt_f
939 s_resd_scaled(istart:istart+nresd-1, lst) = overlap_resd_ks(istart:istart+nresd-1, lst) * sqrt_f
944 call blas_herk(
'U',
'N', act_nst, act_nst, 1.0_real64, s_ad_scaled(istart,istart), st%nst, 0.0_real64, &
945 rho_mat(1, 1), 2*act_nst)
948 call blas_herk(
'U',
'N', nresd, act_nst, 1.0_real64, s_resd_scaled(istart,istart), st%nst, 0.0_real64, &
949 rho_mat(act_nst+1, act_nst+1), 2*act_nst)
951 call blas_gemm(
'N',
'C', act_nst, nresd, act_nst,
m_z1, s_ad_scaled(istart, istart), st%nst, &
952 s_resd_scaled(istart,istart), st%nst,
m_z0, rho_mat(1, act_nst+1), 2*act_nst)
959 rho_mat(jst, ist) = conjg(rho_mat(ist, jst))
964 rho_mat(act_nst+ist, jst) = conjg(rho_mat(jst, act_nst+ist))
973 rho_mat(act_nst+jst, act_nst+ist) = conjg(rho_mat(act_nst+ist, act_nst+jst))
978 safe_deallocate_a(s_ad_scaled)
979 safe_deallocate_a(s_resd_scaled)
986 rho_offd(idx) = rho_mat(ist, jst)
994 real(real64),
contiguous,
intent(inout) :: occ(:, :)
996 logical,
intent(in) :: parstate
997 integer,
intent(in) :: istart
998 integer,
intent(in) :: iend
1000 integer :: incount, act_nst
1001 integer,
allocatable :: rdispls(:), recvcnts(:)
1002 real(real64),
allocatable :: sendbuffer(:, :), recvbuffer(:, :)
1006 assert(istart <= iend)
1007 assert(ubound(occ, dim = 1) >= iend)
1008 assert(ubound(occ, dim = 2) == kpt%nglobal())
1009 assert(.not. parstate)
1011 if (kpt%parallel)
then
1012 act_nst = iend - istart + 1
1014 safe_allocate(recvcnts(1:kpt%mpi_grp%size))
1015 safe_allocate(rdispls(1:kpt%mpi_grp%size))
1016 safe_allocate(sendbuffer(1:act_nst, kpt%nlocal()))
1017 safe_allocate(recvbuffer(1:act_nst, 1:kpt%nglobal()))
1019 incount = act_nst * kpt%nlocal()
1020 recvcnts(:) = act_nst * kpt%num(:)
1021 sendbuffer(1:act_nst, 1:kpt%nlocal()) = occ(istart:iend, kpt%start:kpt%end)
1026 call kpt%mpi_grp%allgatherv(sendbuffer, incount, mpi_double_precision, &
1027 recvbuffer, recvcnts, rdispls, mpi_double_precision)
1029 occ(istart:iend, 1:kpt%nglobal()) = recvbuffer(1:act_nst, 1:kpt%nglobal())
1031 safe_deallocate_a(sendbuffer)
1032 safe_deallocate_a(recvbuffer)
1033 safe_deallocate_a(recvcnts)
1034 safe_deallocate_a(rdispls)
1056 subroutine dissipation(hm, st, namespace, nresd_k, dt, dmp, rho_mat_k)
1060 integer,
intent(in) :: nresd_k(:)
1061 real(real64),
intent(in) :: dt
1062 type(
dmp_t),
intent(inout) :: dmp
1063 complex(real64),
intent(inout) :: rho_mat_k(:, :, :)
1069 act_nst = dmp%iend - dmp%istart + 1
1071 assert(ubound(nresd_k, dim = 1) == st%d%kpt%nlocal())
1072 assert(ubound(rho_mat_k, dim = 1) == 2*act_nst)
1073 assert(ubound(rho_mat_k, dim = 2) == 2*act_nst)
1074 assert(ubound(rho_mat_k, dim = 3) == st%d%kpt%nlocal())
1076 if (dmp%calculation_mode == option__tddmpropagation__master_equation)
then
1077 select case (dmp%strategy)
1083 call lindblad_from_epw(dmp, hm, st%d%kpt, st%system_grp, namespace, nresd_k, dt, rho_mat_k)
1085 else if (dmp%calculation_mode == option__tddmpropagation__collision_integral)
then
1098 type(
dmp_t),
intent(in) :: dmp
1100 integer,
intent(in) :: nresd_k(:)
1101 real(real64),
intent(in) :: dt
1102 complex(real64),
intent(inout) :: rho_mat_k(:, :, :)
1104 real(real64) :: coeff
1105 real(real64),
allocatable :: rtrans(:, :)
1106 complex(real64),
allocatable :: rho_in(:, :), rho_out(:, :), rho_res(:, :), rho_tmp(:, :)
1107 integer :: iorder, nst, ik, ik_, nresd, act_nst
1108 integer,
parameter :: norder = 4
1112 nst = dmp%adiabatic_st%nst
1113 act_nst = dmp%iend - dmp%istart + 1
1116 safe_allocate(rtrans(1:act_nst, 1:act_nst))
1117 safe_allocate(rho_in(1:2*act_nst, 1:2*act_nst))
1118 safe_allocate(rho_out(1:2*act_nst, 1:2*act_nst))
1119 safe_allocate(rho_res(1:2*act_nst, 1:2*act_nst))
1121 do ik = kpt%start, kpt%end
1122 ik_ = ik - kpt%start + 1
1123 nresd = nresd_k(ik_)
1127 rho_res = 0.0_real64
1128 rho_in(1:2*act_nst, 1:2*act_nst) = rho_mat_k(1:2*act_nst, 1:2*act_nst, ik_)
1131 do iorder = 1, norder-1
1135 coeff = coeff * dt / iorder
1136 rho_res = rho_res + coeff * rho_out
1139 call move_alloc(rho_in, rho_tmp)
1140 call move_alloc(rho_out, rho_in)
1141 call move_alloc(rho_tmp, rho_out)
1145 coeff = coeff * dt / norder
1146 rho_res = rho_res + coeff * rho_out
1148 rho_mat_k(1:2*act_nst, 1:2*act_nst, ik_) = rho_mat_k(1:2*act_nst, 1:2*act_nst, ik_) + rho_res
1151 safe_deallocate_a(rho_in)
1152 safe_deallocate_a(rho_out)
1153 safe_deallocate_a(rtrans)
1154 safe_deallocate_a(rho_res)
1165 real(real64),
contiguous,
intent(in) :: uniform(:)
1167 integer,
intent(in) :: istart
1168 integer,
intent(in) :: iend
1169 integer,
intent(in) :: ik
1170 real(real64),
contiguous,
intent(out) :: rtrans(:, :)
1172 integer :: ist, jst, act_nst
1173 real(real64) :: rate_character, omega, inv_omega, nph, delta_e
1174 real(real64),
parameter :: small_e = 0.002_real64/(
m_two*
p_ry), large_e = 0.5_real64/(
m_two*
p_ry)
1175 real(real64) :: unocc_ist, unocc_jst
1179 act_nst = iend - istart + 1
1181 assert(ubound(rtrans, dim = 1) == act_nst)
1182 assert(ubound(rtrans, dim = 2) == act_nst)
1184 rate_character = 1 / uniform(1)
1186 inv_omega = 1.0_real64 / max(omega, 1.0e-12_real64)
1190 do ist = istart, iend
1191 unocc_ist = 1.0_real64 - ad_st%occ(ist, ik) / ad_st%smear%el_per_state
1193 do jst = ist + 1, iend
1194 delta_e = ad_st%eigenval(jst, ik) - ad_st%eigenval(ist, ik)
1195 if (delta_e < small_e) cycle
1197 if (delta_e < large_e)
then
1198 nph = 1.0_real64/(
exp(delta_e*inv_omega) - 1.0_real64)
1202 unocc_jst = 1.0_real64 - ad_st%occ(jst, ik) / ad_st%smear%el_per_state
1204 rtrans(ist-istart+1, jst-istart+1) = merge(rate_character * unocc_ist * (nph + 1),
m_zero, unocc_ist >
m_zero)
1205 rtrans(jst-istart+1, ist-istart+1) = merge(rate_character * unocc_jst * nph,
m_zero, unocc_jst >
m_zero)
1219 integer,
intent(in) :: nresd
1220 integer,
intent(in) :: istart
1221 integer,
intent(in) :: iend
1222 real(real64),
contiguous,
intent(in) :: rtrans(:, :)
1223 complex(real64),
contiguous,
intent(in) :: den_mat(:, :)
1224 complex(real64),
contiguous,
intent(out) :: l_mat(:, :)
1226 integer :: ist, jst, lst, act_nst
1230 act_nst = iend - istart + 1
1232 assert(ubound(rtrans, dim = 1) == act_nst)
1233 assert(ubound(rtrans, dim = 2) == act_nst)
1234 assert(ubound(den_mat, dim = 1) == 2*act_nst)
1235 assert(ubound(den_mat, dim = 2) == 2*act_nst)
1236 assert(ubound(l_mat, dim = 1) == 2*act_nst)
1237 assert(ubound(l_mat, dim = 2) == 2*act_nst)
1243 if (ist == jst) cycle
1244 do lst = 1, act_nst+nresd
1245 l_mat(ist, lst) = l_mat(ist, lst) -
m_half * rtrans(jst, ist) * den_mat(ist, lst)
1246 l_mat(lst, ist) = l_mat(lst, ist) -
m_half * rtrans(jst, ist) * den_mat(lst, ist)
1248 l_mat(jst, jst) = l_mat(jst, jst) + rtrans(jst, ist) * den_mat(ist, ist)
1264 type(
dmp_t),
intent(in) :: dmp
1266 integer,
intent(in) :: nresd_k(:)
1267 real(real64),
intent(in) :: dt
1268 complex(real64),
intent(inout) :: rho_mat_k(:, :, :)
1270 real(real64) :: decay_T1, decay_T2
1271 integer :: ist, jst, ik, ik_, nresd, act_nst
1275 act_nst = dmp%iend - dmp%istart + 1
1277 decay_t1 =
exp(-dt / dmp%tmodel(1))
1278 decay_t2 =
exp(-dt / dmp%tmodel(2))
1280 do ik = kpt%start, kpt%end
1281 ik_ = ik - kpt%start + 1
1282 nresd = nresd_k(ik_)
1284 do ist = dmp%istart, dmp%iend
1285 rho_mat_k(ist-dmp%istart+1, ist-dmp%istart+1, ik_) = dmp%occ_gs(ist, ik_) + &
1286 (rho_mat_k(ist-dmp%istart+1, ist-dmp%istart+1, ik_) - dmp%occ_gs(ist, ik_)) * decay_t1
1288 do ist = act_nst+1, act_nst+nresd
1289 rho_mat_k(ist, ist, ik_) = rho_mat_k(ist, ist, ik_) * decay_t1
1291 do ist = 1, act_nst+nresd
1292 do jst = ist+1, act_nst+nresd
1293 rho_mat_k(jst, ist, ik_) = rho_mat_k(jst, ist, ik_) * decay_t2
1294 rho_mat_k(ist, jst, ik_) = rho_mat_k(ist, jst, ik_) * decay_t2
1305 subroutine lindblad_from_epw(dmp, hm, kpt, system_grp, namespace, nresd_k, dt, rho_mat_k)
1306 type(
dmp_t),
intent(inout) :: dmp
1309 type(
mpi_grp_t),
intent(in) :: system_grp
1311 integer,
intent(in) :: nresd_k(:)
1312 real(real64),
intent(in) :: dt
1313 complex(real64),
intent(inout) :: rho_mat_k(:, :, :)
1315 real(real64) :: coeff
1316 real(real64),
allocatable :: rho_diag(:, :)
1317 complex(real64),
allocatable :: rho_in(:, :, :), rho_out(:, :, :), rho_tmp(:, :, :)
1318 integer,
parameter :: norder = 4
1319 integer :: ist, iorder, ik, ik_, nik, act_nst
1323 nik = dmp%adiabatic_st%nik
1324 act_nst = dmp%iend - dmp%istart + 1
1326 call dmp%update_trans_rate(hm, system_grp, namespace)
1330 safe_allocate(rho_diag(1:act_nst, nik))
1331 rho_diag(1:act_nst, 1:nik) = dmp%adiabatic_st%occ(dmp%istart:dmp%iend, 1:nik)
1334 safe_allocate_source(rho_in, rho_mat_k)
1335 safe_allocate(rho_out(1:2*act_nst, 1:2*act_nst, 1:kpt%nlocal()))
1339 do iorder = 1, norder - 1
1341 coeff = coeff * dt / iorder
1343 do ik = kpt%start, kpt%end
1344 ik_ = ik - kpt%start + 1
1346 call lindblad_operator_epw(dmp, ik, hm%kpoints%nik_skip, nresd_k(ik_), rho_diag, rho_in(:, :, ik_), rho_out(:, :, ik_))
1348 call lalg_axpy(2*act_nst, 2*act_nst, coeff, rho_out(:, :, ik_), rho_mat_k(:, :, ik_))
1352 do ik = kpt%start, kpt%end
1353 ik_ = ik - kpt%start + 1
1354 do ist = dmp%estart, dmp%eend
1355 rho_diag(ist-dmp%istart+1, ik) = real(rho_out(ist-dmp%istart+1, ist-dmp%istart+1, ik_))
1361 dmp%estart-dmp%istart+1, dmp%eend-dmp%istart+1)
1365 call move_alloc(rho_in, rho_tmp)
1366 call move_alloc(rho_out, rho_in)
1367 call move_alloc(rho_tmp, rho_out)
1371 coeff = coeff * dt / norder
1373 do ik = kpt%start, kpt%end
1374 ik_ = ik - kpt%start + 1
1376 call lindblad_operator_epw(dmp, ik, hm%kpoints%nik_skip, nresd_k(ik_), rho_diag, rho_in(:, :, ik_), rho_out(:, :, ik_))
1378 call lalg_axpy(2*act_nst, 2*act_nst, coeff, rho_out(:, :, ik_), rho_mat_k(:, :, ik_))
1382 safe_deallocate_a(rho_in)
1383 safe_deallocate_a(rho_out)
1384 safe_deallocate_a(rho_diag)
1399 type(
dmp_t),
intent(inout) :: dmp
1402 type(
mpi_grp_t),
intent(in) :: system_grp
1404 integer,
intent(in) :: nresd_k(:)
1405 real(real64),
intent(in) :: dt
1406 complex(real64),
intent(inout) :: rho_mat_k(:, :, :)
1408 real(real64) :: gam, gam_in, gam_out
1409 real(real64),
allocatable :: gam_bnd(:)
1410 real(real64),
parameter :: gthresh = 1.0e-8_real64
1411 integer :: ist, jst, ik, nresd, ik_, nik_skip, act_nst
1415 nik_skip = hm%kpoints%nik_skip
1416 act_nst = dmp%iend - dmp%istart + 1
1418 safe_allocate(gam_bnd(2*dmp%adiabatic_st%nst))
1420 call dmp%update_trans_rate(hm, system_grp, namespace)
1423 do ik = kpt%start, kpt%end
1424 ik_ = ik - kpt%start + 1
1425 nresd = nresd_k(ik_)
1428 gam_bnd = 0.0_real64
1429 do ist = dmp%estart, dmp%eend
1430 call lifetime(dmp, ik, ist, nik_skip, gam_bnd(ist))
1433 do ist = 1, act_nst + nresd
1434 do jst = ist + 1, act_nst + nresd
1435 gam = -(gam_bnd(ist+dmp%istart-1) + gam_bnd(jst+dmp%istart-1)) / 2.0_real64
1438 rho_mat_k(jst, ist, ik_) = rho_mat_k(jst, ist, ik_) *
exp(gam * dt)
1439 rho_mat_k(ist, jst, ik_) = conjg(rho_mat_k(jst, ist, ik_))
1445 do ik = kpt%start, kpt%end
1446 ik_ = ik - kpt%start + 1
1447 do ist = dmp%estart, dmp%eend
1448 call get_gamma(dmp, ik, ist, nik_skip, gam_in, gam_out)
1449 if (gam_out * dt > gthresh)
then
1450 rho_mat_k(ist-dmp%istart+1, ist-dmp%istart+1, ik_) = rho_mat_k(ist-dmp%istart+1, ist-dmp%istart+1, ik_) *&
1451 exp(-gam_out * dt) + (gam_in / gam_out) * (1.0_real64 -
exp(-gam_out * dt))
1454 rho_mat_k(ist-dmp%istart+1, ist-dmp%istart+1, ik_) = rho_mat_k(ist-dmp%istart+1, ist-dmp%istart+1, ik_) *&
1455 (1.0_real64 - gam_out * dt) + gam_in * dt
1460 safe_deallocate_a(gam_bnd)
1467 class(
dmp_t),
intent(inout) :: this
1469 type(
mpi_grp_t),
intent(in) :: system_grp
1474 push_sub_with_profile(dmp_propagation_update_trans_rate)
1478 if (ia /= this%ia)
then
1483 pop_sub_with_profile(dmp_propagation_update_trans_rate)
1490 type(
ions_t),
intent(in) :: ions
1492 type(
mpi_grp_t),
intent(in) :: system_grp
1493 type(
dmp_t),
intent(inout) :: dmp
1495 integer :: ierr, iostat, idim, idir, iqq, totq
1496 integer :: epw_nk(3), oct_nk(3)
1497 real(real64) :: oct_s(3), at(3,3)
1502 if (system_grp%is_root())
then
1503 open(newunit=dmp%iunit, file=trim(dmp%epw_file), form=
'unformatted',
access=
'stream', status=
'old', &
1504 action=
'read', iostat=iostat)
1505 if (iostat /= 0)
then
1507 write(
message(1),
'(a,a)')
'Error opening file: ', trim(dmp%epw_file)
1511 read(dmp%iunit, iostat=ierr) iqq, totq, dmp%wnst, epw_nk(1:3), at, oct_nk(1:3), oct_s(1:3), dmp%astep(1:3), dmp%na(1:3)
1513 write(
message(1),
'(a,a)')
'Error reading header from: ', trim(dmp%epw_file)
1519 call system_grp%bcast(dmp%wnst, 1, mpi_integer, 0)
1520 call system_grp%bcast(at, 9, mpi_double_precision, 0)
1521 call system_grp%bcast(oct_s, 3, mpi_double_precision, 0)
1522 call system_grp%bcast(dmp%astep, 3, mpi_double_precision, 0)
1523 call system_grp%bcast(dmp%na, 3, mpi_integer, 0)
1524 call system_grp%bcast(epw_nk, 3, mpi_integer, 0)
1525 call system_grp%bcast(oct_nk, 3, mpi_integer, 0)
1527 if (any(oct_nk /= hm%kpoints%nik_axis))
then
1528 write(
message(1),
'(a, a)')
'Inconsistent k-point mesh in KPointsGrid and ', trim(dmp%epw_file)
1531 if (any(abs(oct_s - hm%kpoints%full%shifts(:, 1)) >
m_epsilon))
then
1532 write(
message(1),
'(a, a)')
'Inconsistent k-point mesh shifts in KPointsGrid and ', trim(dmp%epw_file)
1536 write(
message(1),
'(3(a,i0), a)')
'Info: Averaged transition rates obtained from a ', epw_nk(1),
' x ', &
1537 epw_nk(2),
' x ', epw_nk(3),
' EPW k-point mesh'
1540 dmp%eend = dmp%estart + dmp%wnst - 1
1541 write(
message(1),
'(a, i0, a, i0)')
'Info: Damping band ', dmp%estart,
' - ', dmp%eend
1543 if (dmp%eend > dmp%iend)
then
1544 write(
message(1),
'(a)')
'The highest damping band cannot exceed TDDMBandHighest.'
1548 write(
message(1),
'(a)')
' EPW Lattice Vectors [1/alat]'
1550 write(
message(1+idim),
'(3f12.6)') (at(idir, idim), idir = 1, 3)
1553 if (any(abs(at - ions%latt%rlattice_primitive) >
m_epsilon))
then
1554 write(
message(1),
'(a)')
'Lattice settings are not fully consistent with those in EPW'
1564 dmp%num = int(product(oct_nk), kind=int64)**2 * int(dmp%wnst, kind=int64)**2
1567 call create_intranode_communicator(system_grp, dmp%intranode_grp, dmp%internode_grp)
1569 call slmpi_create_shared_memory_window(dmp%num, dmp%intranode_grp, dmp%window_trans_rate, ave_trans)
1571 safe_allocate(ave_trans(1:dmp%num))
1579 integer,
intent(in) :: ia
1580 type(
mpi_grp_t),
intent(in) :: system_grp
1582 type(
dmp_t),
intent(inout) :: dmp
1584 integer(int64),
parameter :: header_bytes = 168
1585 integer(int64),
parameter :: epw_bytes = 4
1586 integer(int64) :: offset
1591 if (system_grp%is_root())
then
1593 offset = header_bytes + int(ia - 1, kind=int64) * dmp%num * epw_bytes + 1_int64
1594 read(dmp%iunit, pos=offset, iostat=ierr) ave_trans
1596 write(
message(1),
'(a,a)')
'Error reading transition rates from: ', trim(dmp%epw_file)
1603 if (dmp%intranode_grp%rank == 0)
then
1604 call dmp%internode_grp%bcast(ave_trans(1), dmp%num, mpi_real, 0)
1606 call lmpi_sync_shared_memory_window(dmp%window_trans_rate, dmp%intranode_grp)
1616 type(
mpi_grp_t),
intent(in) :: system_grp
1617 type(
dmp_t),
intent(inout) :: dmp
1621 safe_deallocate_a(dmp%kmap)
1623 if (system_grp%is_root())
then
1628 call lmpi_destroy_shared_memory_window(dmp%window_trans_rate)
1631 safe_deallocate_p(ave_trans)
1642 type(
dmp_t),
intent(inout) :: dmp
1644 integer :: ik, idx, nik, nik_mp
1646 real(real64) :: kred(3), kidx(3)
1647 real(real64),
parameter :: tol = 1.0d-10
1651 nik = dmp%adiabatic_st%nik
1652 nik_mp = nik - kpoints%nik_skip
1653 safe_allocate(dmp%kmap(nik))
1656 dmp%kmap = nik_mp + 1
1660 kred = kpoints%get_point(ik, .false.)
1661 kidx = (kred + 0.5_real64) * real(kpoints%nik_axis, kind=real64) - kpoints%full%shifts(:, 1)
1664 if (ik <= nik_mp)
then
1665 if (any(abs(kidx - nint(kidx)) > tol))
then
1666 write(
message(1),
'(a)')
'K-point mesh is not compatible with EPW input'
1672 kidx_ = modulo(nint(kidx), kpoints%nik_axis)
1674 idx = kidx_(1) * kpoints%nik_axis(2) * kpoints%nik_axis(3) + kidx_(2) * kpoints%nik_axis(3) + &
1681 assert(all(dmp%kmap <= nik_mp))
1688 type(
dmp_t),
intent(in) :: dmp
1692 real(real64) :: ared(3), approx(3)
1693 integer :: apoint_idx(3)
1694 integer :: aidx, idim
1699 if (
allocated(hm%hm_base%uniform_vector_potential))
then
1705 if (dmp%astep(idim) >
m_zero)
then
1706 apoint_idx(idim) = nint(ared(idim) / dmp%astep(idim))
1707 approx(idim) = apoint_idx(idim) * dmp%astep(idim)
1709 apoint_idx(idim) = 0
1710 approx(idim) = 0.0_real64
1713 if (any(abs(apoint_idx) > dmp%na))
then
1714 write(
message(1),
'(a, 3F8.3)')
'Vector potential exceeds mesh range: ', ared
1716 where (apoint_idx < -dmp%na)
1717 apoint_idx = -dmp%na
1719 where (apoint_idx > dmp%na)
1728 aidx = (apoint_idx(1) + dmp%na(1)) * (2 * dmp%na(2) + 1) * (2 * dmp%na(3) + 1) + &
1729 (apoint_idx(2) + dmp%na(2)) * (2 * dmp%na(3) + 1) + &
1730 (apoint_idx(3) + dmp%na(3)) + 1
1732 write(
message(1),
'(a, x, 3F7.3)')
'Approximated vector field damping grid:', approx
1742 function get_trans_rate(dmp, nik_mp, jbnd, ibnd, k, kq, p_block)
result(res)
1743 type(
dmp_t),
intent(in) :: dmp
1744 integer,
intent(in) :: nik_mp
1745 integer,
intent(in) :: jbnd
1746 integer,
intent(in) :: ibnd
1747 integer,
intent(in) :: k
1748 integer,
intent(in) :: kq
1749 logical,
optional,
intent(in) :: p_block
1751 real(real64) :: unocc, res
1753 integer(int64) :: idx
1762 idx = int(kq_-1, kind=int64) * int(nik_mp, kind=int64) * int(dmp%wnst, kind=int64)**2 + &
1763 int((k_-1) * dmp%wnst**2, kind=int64) + &
1764 int((ibnd-dmp%estart)*dmp%wnst + (jbnd-dmp%estart) + 1, kind=int64)
1766 assert(idx >= 1 .and. idx <= dmp%num)
1768 res = real(ave_trans(idx), kind=real64)
1771 unocc = 1.0_real64 - dmp%adiabatic_st%occ(jbnd, kq) / dmp%adiabatic_st%smear%el_per_state
1772 res = res * max(unocc, 0.0_real64)
1786 type(
dmp_t),
intent(in) :: dmp
1787 integer,
intent(in) :: ik
1788 integer,
intent(in) :: nik_skip
1789 integer,
intent(in) :: nresd
1790 real(real64),
contiguous,
intent(in) :: rho_diag(:, :)
1791 complex(real64),
contiguous,
intent(in) :: den_mat(:, :)
1792 complex(real64),
contiguous,
intent(out) :: l_mat(:, :)
1794 integer :: lst, nst, nik_mp, ikq, ibnd, jbnd, act_nst
1798 nst = dmp%adiabatic_st%nst
1799 nik_mp = dmp%adiabatic_st%nik - nik_skip
1800 act_nst = dmp%iend - dmp%istart + 1
1802 assert(ubound(rho_diag, dim = 1) == act_nst)
1803 assert(ubound(rho_diag, dim = 2) == dmp%adiabatic_st%nik)
1804 assert(ubound(den_mat, dim = 1) == 2*act_nst)
1805 assert(ubound(den_mat, dim = 2) == 2*act_nst)
1806 assert(ubound(l_mat, dim = 1) == 2*act_nst)
1807 assert(ubound(l_mat, dim = 2) == 2*act_nst)
1814 do jbnd = dmp%estart, dmp%eend
1815 do ibnd = dmp%estart, dmp%eend
1818 do lst = 1, act_nst+nresd
1819 l_mat(ibnd-dmp%istart+1, lst) = l_mat(ibnd-dmp%istart+1, lst) -
m_half * tr * den_mat(ibnd-dmp%istart+1, lst)
1820 l_mat(lst, ibnd-dmp%istart+1) = l_mat(lst, ibnd-dmp%istart+1) -
m_half * tr * den_mat(lst, ibnd-dmp%istart+1)
1822 l_mat(ibnd-dmp%istart+1, ibnd-dmp%istart+1) = l_mat(ibnd-dmp%istart+1, ibnd-dmp%istart+1) + &
1823 get_trans_rate(dmp, nik_mp, ibnd, jbnd, ikq, ik, p_block=.
true.) * rho_diag(jbnd-dmp%istart+1, ikq)
1836 subroutine lifetime(dmp, ik, ibnd, nik_skip, gam)
1837 type(
dmp_t),
intent(in) :: dmp
1838 integer,
intent(in) :: ik
1839 integer,
intent(in) :: ibnd
1840 integer,
intent(in) :: nik_skip
1841 real(real64),
intent(out) :: gam
1843 integer :: nik_mp, ikq, jbnd
1847 assert(ibnd >= dmp%estart .and. ibnd <= dmp%eend)
1848 nik_mp = dmp%adiabatic_st%nik - nik_skip
1854 do jbnd = dmp%estart, dmp%eend
1857 tr =
get_trans_rate(dmp, nik_mp, ibnd, jbnd, ikq, ik, p_block=.false.)
1858 gam = gam + tr * dmp%adiabatic_st%occ(jbnd, ikq) / dmp%adiabatic_st%smear%el_per_state
1876 subroutine get_gamma(dmp, ik, ibnd, nik_skip, gam_in, gam_out)
1877 type(
dmp_t),
intent(in) :: dmp
1878 integer,
intent(in) :: ik
1879 integer,
intent(in) :: ibnd
1880 integer,
intent(in) :: nik_skip
1881 real(real64),
intent(out) :: gam_in
1882 real(real64),
intent(out) :: gam_out
1884 integer :: nik_mp, ikq, jbnd
1888 assert(ibnd >= dmp%estart .and. ibnd <= dmp%eend)
1889 nik_mp = dmp%adiabatic_st%nik - nik_skip
1894 gam_out = 0.0_real64
1896 do jbnd = dmp%estart, dmp%eend
1898 gam_out = gam_out + tr
1900 gam_in = gam_in + tr * dmp%adiabatic_st%occ(jbnd, ikq)
1923 subroutine update_st(dmp, ik, gr, namespace, nresd, overlap_ad_ks, overlap_resd_ks, nrm2_tdks, resd, st, rho_mat, pop)
1924 type(
dmp_t),
intent(inout) :: dmp
1925 integer,
intent(in) :: ik
1926 type(
grid_t),
intent(in) :: gr
1928 integer,
intent(in) :: nresd
1929 complex(real64),
contiguous,
intent(in) :: overlap_ad_ks(:, :)
1930 complex(real64),
contiguous,
intent(in) :: overlap_resd_ks(:, :)
1931 real(real64),
contiguous,
intent(in) :: nrm2_tdks(:)
1934 complex(real64),
contiguous,
intent(inout) :: rho_mat(:, :)
1935 real(real64),
intent(inout) :: pop
1937 real(real64),
allocatable :: occ_act(:)
1938 complex(real64),
allocatable :: overlap_ad_resd(:, :), overlap_act(:, :)
1939 integer :: ist, jst, nst, istart, iend, act_nst
1943 nst = dmp%adiabatic_st%nst
1946 act_nst = iend - istart + 1
1948 assert(ubound(overlap_ad_ks, dim = 1) == nst)
1949 assert(ubound(overlap_ad_ks, dim = 2) == nst)
1950 assert(ubound(overlap_resd_ks, dim = 1) == nst)
1951 assert(ubound(overlap_resd_ks, dim = 2) == nst)
1952 assert(ubound(rho_mat, dim = 1) == 2*act_nst)
1953 assert(ubound(rho_mat, dim = 2) == 2*act_nst)
1956 safe_allocate(occ_act(1:act_nst+nresd))
1964 assert(nresd == act_nst)
1967 safe_allocate(overlap_ad_resd(1:nst, 1:nst))
1968 safe_allocate(overlap_act(1:act_nst+nresd, 1:act_nst+nresd))
1973 overlap_act(ist, ist) =
m_z1
1977 call calc_overlap_state(ik, gr, dmp%adiabatic_st, resd, istart, iend, istart, iend, overlap_ad_resd)
1980 overlap_act(ist, act_nst+jst) = overlap_ad_resd(ist+istart-1, jst+istart-1)
1981 overlap_act(act_nst+jst, ist) = conjg(overlap_ad_resd(ist+istart-1, jst+istart-1))
1987 overlap_act(act_nst+1:act_nst+nresd, act_nst+1:act_nst+nresd) = overlap_resd_ks(istart:iend, istart:iend)
1988 call blas_gemm(
'C',
'N', nresd, nresd, act_nst, -
m_z1, overlap_ad_resd(istart, istart), nst, &
1989 overlap_ad_ks(istart, istart), nst,
m_z1, overlap_act(act_nst+1, act_nst+1), act_nst+nresd)
1992 call lalg_geneigensolve(act_nst+nresd, rho_mat, overlap_act, occ_act, preserve_mat=.false.)
1996 safe_deallocate_a(overlap_ad_resd)
1997 safe_deallocate_a(overlap_act)
2001 if (dmp%unitary_transform)
then
2003 nrm2_tdks, occ_act, rho_mat, st, pop)
2005 call update_wfc_occ(ik, gr, istart, iend, nresd, dmp%adiabatic_st, resd, occ_act, rho_mat, st, pop)
2008 pop = pop + (sum(st%occ(1:istart-1,ik) * nrm2_tdks(1:istart-1)) + &
2009 sum(st%occ(iend+1:nst,ik) * nrm2_tdks(iend+1:nst))) * st%kweights(ik)
2011 safe_deallocate_a(occ_act)
2023 integer,
intent(in) :: locc
2024 integer,
intent(in) :: npos
2025 integer,
intent(in) :: ik
2027 real(real64),
intent(inout) :: occ(:)
2029 real(real64),
parameter :: small_eig = 1.0e-13_real64
2030 real(real64) :: occ_min
2031 integer :: i, istart
2033 assert(ubound(occ, dim = 1) == locc)
2035 istart = locc - npos + 1
2036 occ_min = occ(istart)
2040 if (occ(i) < occ_min) occ_min = occ(i)
2041 if (occ(i) < 0.0_real64) occ(i) = 0.0_real64
2045 if (occ_min < -small_eig)
then
2046 write(
message(1),
'(a, E9.2, a, I0)')
'Density matrix has negative eigenvalues of ', occ_min,
' at ik = ', ik
2056 subroutine update_wfc_occ(ik, gr, istart, iend, nresd, ad_st, resd, occ, v_mat, st, pop)
2057 integer,
intent(in) :: ik
2058 type(
grid_t),
intent(in) :: gr
2059 integer,
intent(in) :: istart
2060 integer,
intent(in) :: iend
2061 integer,
intent(in) :: nresd
2064 real(real64),
contiguous,
intent(in) :: occ(:)
2065 complex(real64),
contiguous,
intent(in) :: v_mat(:, :)
2067 real(real64),
intent(inout) :: pop
2069 complex(real64),
allocatable :: psi_j(:, :), phi(:, :)
2070 integer :: i, j, ib, i_minst, i_maxst, act_nst
2074 act_nst = iend - istart + 1
2076 assert(ubound(v_mat, dim = 1) == 2*act_nst)
2077 assert(ubound(v_mat, dim = 2) == 2*act_nst)
2079 safe_allocate(psi_j(1:gr%np, st%d%dim))
2080 safe_allocate(phi(1:gr%np, st%d%dim))
2082 do j = act_nst+nresd, nresd+1, -1
2083 psi_j = (0.0_real64, 0.0_real64)
2085 do ib = ad_st%group%block_start, ad_st%group%block_end
2088 if (i_minst >= istart .and. i_maxst <= iend)
then
2090 ad_st%group%psib(ib, ik), psi_j)
2092 do i = max(i_minst, istart), min(i_maxst, iend)
2094 call lalg_axpy(gr%np, ad_st%d%dim, v_mat(i-istart+1, j), phi, psi_j)
2100 do ib = resd%group%block_start, resd%group%block_end
2103 if (i_minst >= istart .and. i_maxst <= istart+nresd-1)
then
2104 call zbatch_axpy_function(gr%np, v_mat(act_nst+i_minst-istart+1:act_nst+i_maxst-istart+1, j), &
2105 resd%group%psib(ib, ik), psi_j)
2107 do i = max(i_minst, istart), min(i_maxst, istart+nresd-1)
2109 call lalg_axpy(gr%np, resd%d%dim, v_mat(act_nst+i-istart+1, j), phi, psi_j)
2120 st%occ(istart:iend, ik) = occ(act_nst+nresd:nresd+1:-1)
2121 pop = pop + sum(st%occ(istart:iend, ik)) * st%kweights(ik)
2123 safe_deallocate_a(psi_j)
2124 safe_deallocate_a(phi)
2144 nrm2_tdks, occ_tilde, v_mat, st, pop)
2145 integer,
intent(in) :: ik
2146 type(
grid_t),
intent(in) :: gr
2147 integer,
intent(in) :: istart
2148 integer,
intent(in) :: iend
2149 integer,
intent(in) :: nresd
2152 complex(real64),
contiguous,
intent(in) :: overlap_ad_ks(:, :)
2153 complex(real64),
contiguous,
intent(in) :: overlap_resd_ks(:, :)
2154 real(real64),
contiguous,
intent(in) :: nrm2_tdks(:)
2155 real(real64),
contiguous,
intent(in) :: occ_tilde(:)
2156 complex(real64),
contiguous,
intent(inout) :: v_mat(:, :)
2158 real(real64),
intent(inout) :: pop
2160 integer :: ist, jst, ib, i_minst, i_maxst, nst, act_nst
2161 complex(real64),
allocatable :: overlap_procrus(:, :), uproj(:, :), utrans(:, :)
2162 complex(real64),
allocatable :: uu(:, :), vt(:, :)
2163 complex(real64),
allocatable :: psi(:, :), phi(:, :)
2164 real(real64),
parameter :: small_occ = 5.0e-15_real64
2165 real(real64) :: sg_values(1:iend-istart+1), rocc_tilde(1:iend-istart+1+nresd), rocc(1:iend-istart+1)
2166 real(real64) :: qtot_transform, nrm2, occ
2171 act_nst = iend - istart + 1
2173 assert(istart <= iend)
2174 assert(ubound(overlap_ad_ks, dim = 1) == nst)
2175 assert(ubound(overlap_ad_ks, dim = 2) == nst)
2176 assert(ubound(overlap_resd_ks, dim = 1) == nst)
2177 assert(ubound(overlap_resd_ks, dim = 2) == nst)
2178 assert(ubound(nrm2_tdks, dim = 1) == nst)
2179 assert(ubound(occ_tilde, dim = 1) == act_nst+nresd)
2180 assert(ubound(v_mat, dim = 1) == 2*act_nst)
2181 assert(ubound(v_mat, dim = 2) == 2*act_nst)
2184 rocc_tilde(1:act_nst+nresd) =
sqrt(max(occ_tilde(1:act_nst+nresd), small_occ))
2185 rocc(1:act_nst) =
sqrt(max(st%occ(istart:iend, ik), small_occ))
2187 safe_allocate(overlap_procrus(1:act_nst+nresd, 1:act_nst))
2192 call blas_gemm(
'C',
'N', act_nst+nresd, act_nst, act_nst,
m_z1, v_mat(1, 1), 2*act_nst, &
2193 overlap_ad_ks(istart, istart), nst,
m_z0, overlap_procrus(1, 1), act_nst+nresd)
2194 call blas_gemm(
'C',
'N', act_nst+nresd, act_nst, nresd,
m_z1, v_mat(1+act_nst, 1), 2*act_nst, &
2195 overlap_resd_ks(istart, istart), nst,
m_z1, overlap_procrus(1, 1), act_nst+nresd)
2197 do ist = 1, act_nst+nresd
2198 overlap_procrus(ist, jst) = overlap_procrus(ist, jst) * rocc_tilde(ist) * rocc(jst)
2202 safe_allocate(uproj(1:act_nst+nresd, 1:act_nst))
2203 safe_allocate(uu(1:act_nst+nresd, 1:act_nst+nresd))
2204 safe_allocate(vt(1:act_nst, 1:act_nst))
2207 uproj = matmul(uu(:,1:act_nst), vt)
2209 safe_deallocate_a(overlap_procrus)
2210 safe_deallocate_a(vt)
2211 safe_deallocate_a(uu)
2213 safe_allocate(utrans(1:act_nst+nresd, 1:act_nst))
2216 do ist = 1, act_nst+nresd
2217 call blas_scal(2*act_nst, cmplx(rocc_tilde(ist), 0.0, real64), v_mat(1, ist), 1)
2220 call blas_gemm(
'N',
'N', act_nst+nresd, act_nst, act_nst+nresd,
m_z1, v_mat(1, 1), 2*act_nst, &
2221 uproj(1, 1), act_nst+nresd,
m_z0, utrans(1, 1), act_nst+nresd)
2223 safe_deallocate_a(uproj)
2224 safe_allocate(psi(1:gr%np, st%d%dim))
2225 safe_allocate(phi(1:gr%np, st%d%dim))
2228 qtot_transform = 0.0_real64
2229 do jst = istart, iend
2230 psi = (0.0_real64, 0.0_real64)
2232 do ib = ad_st%group%block_start, ad_st%group%block_end
2235 if (i_minst >= istart .and. i_maxst <= iend)
then
2237 ad_st%group%psib(ib, ik), psi, nst=i_maxst-i_minst+1)
2239 do ist = max(i_minst, istart), min(i_maxst, iend)
2241 call lalg_axpy(gr%np, ad_st%d%dim, utrans(ist-istart+1, jst-istart+1), phi, psi)
2246 do ib = resd%group%block_start, resd%group%block_end
2249 if (i_minst >= istart .and. i_maxst <= istart+nresd-1)
then
2250 call zbatch_axpy_function(gr%np, utrans(act_nst+i_minst-istart+1:act_nst+i_maxst-istart+1, jst-istart+1), &
2251 resd%group%psib(ib, ik), psi, nst=i_maxst-i_minst+1)
2253 do ist = max(i_minst, istart), min(i_maxst, istart+nresd-1)
2255 call lalg_axpy(gr%np, st%d%dim, utrans(act_nst+ist-istart+1, jst-istart+1), phi, psi)
2259 nrm2 = real(
zmf_dotp(gr, st%d%dim, psi, psi, reduce = .
true.), real64)
2260 qtot_transform = qtot_transform + nrm2
2261 occ = nrm2 / nrm2_tdks(jst)
2262 st%occ(jst, ik) = occ
2267 pop = pop + qtot_transform * st%kweights(ik)
2269 safe_deallocate_a(utrans)
2270 safe_deallocate_a(psi)
2271 safe_deallocate_a(phi)
2279 integer,
intent(in) :: n
2280 complex(real64),
intent(in) :: mat(:, :)
2281 real(real64),
parameter :: tol = 1.0e-14_real64
2283 assert(ubound(mat, dim=1) == n)
2284 assert(ubound(mat, dim=2) == n)
2286 is_hermitian = maxval(abs(mat - transpose(conjg(mat)))) <= tol
2291 class(
dmp_t),
intent(in) :: this
2292 type(c_ptr),
intent(inout) :: out_dm_proj_basis
2293 integer,
intent(in) :: iter
2295 character(len=80) :: aux
2296 integer :: incount, ik, n_offd
2297 integer,
allocatable :: rdispls(:), recvcnts(:)
2298 complex(real64),
allocatable :: rho_offd(:, :)
2303 if (this%adiabatic_st%system_grp%is_root())
then
2306 write(aux,
'(a15,i8)')
"# nspin ", this%adiabatic_st%d%nspin
2310 write(aux,
'(a15,i8)')
"# nik ", this%adiabatic_st%nik
2314 write(aux,
'(a15,2i8)')
"# istart, iend ", this%istart, this%iend
2318 write(aux,
'(a)')
"# loop sequence: "
2321 write(aux,
'(a)')
"# do ik = 1, nik "
2324 write(aux,
'(a)')
"# do ist = istart, iend"
2327 write(aux,
'(a)')
"# write E(ist, ik)"
2331 write(aux,
'(a)')
"# do ik = 1, nik "
2334 write(aux,
'(a)')
"# do ist = istart, iend"
2337 write(aux,
'(a)')
"# write occ(ist, ik)"
2341 write(aux,
'(a)')
"# do ik = 1, nik "
2344 write(aux,
'(a)')
"# write Re(rho_off_diagonal(:)), Im(rho_off_diagonal(:))"
2347 write(aux,
'(a)')
"# ! where 1D array rho_off_diagonal is packed as:"
2350 write(aux,
'(a)')
"# ! do jst = istart, iend ! column"
2353 write(aux,
'(a)')
"# ! do ist = istart, jst-1 ! row"
2357 write(aux,
'(a15)')
"# w(ik) "
2359 call write_iter_double(out_dm_proj_basis, this%adiabatic_st%kweights(1:this%adiabatic_st%nik), this%adiabatic_st%nik)
2367 n_offd = ubound(this%rho_offd, dim = 1)
2369 if (this%adiabatic_st%d%kpt%parallel)
then
2370 if (this%adiabatic_st%d%kpt%mpi_grp%rank == 0)
then
2371 safe_allocate(rho_offd(1:n_offd, this%adiabatic_st%nik))
2373 safe_allocate(recvcnts(1:this%adiabatic_st%d%kpt%mpi_grp%size))
2374 safe_allocate(rdispls(1:this%adiabatic_st%d%kpt%mpi_grp%size))
2376 incount = n_offd * this%adiabatic_st%d%kpt%nlocal()
2377 recvcnts(:) = n_offd * this%adiabatic_st%d%kpt%num(:)
2380 call this%adiabatic_st%d%kpt%mpi_grp%gatherv(this%rho_offd(:, this%adiabatic_st%d%kpt%start:this%adiabatic_st%d%kpt%end), &
2381 incount, mpi_double_complex, rho_offd, recvcnts, rdispls, mpi_double_complex, 0)
2383 safe_deallocate_a(recvcnts)
2384 safe_deallocate_a(rdispls)
2386 safe_allocate_source(rho_offd(1:n_offd, this%adiabatic_st%nik), this%rho_offd)
2390 if (this%adiabatic_st%system_grp%is_root())
then
2395 do ik = 1, this%adiabatic_st%nik
2396 call write_iter_double(out_dm_proj_basis, this%adiabatic_st%eigenval(this%istart:this%iend, ik), this%iend-this%istart+1)
2399 do ik = 1, this%adiabatic_st%nik
2400 call write_iter_double(out_dm_proj_basis, this%adiabatic_st%occ(this%istart:this%iend, ik), this%iend-this%istart+1)
2403 do ik = 1, this%adiabatic_st%nik
2405 call write_iter_double(out_dm_proj_basis, aimag(rho_offd(1:n_offd, ik)), n_offd)
2410 safe_deallocate_a(rho_offd)
2417 subroutine slmpi_create_shared_memory_window(number_of_elements, intranode_grp, window, array)
2419 integer(int64),
intent(in) :: number_of_elements
2420 type(
mpi_grp_t),
intent(in) :: intranode_grp
2421 type(mpi_win),
intent(out) :: window
2422 real(real32),
pointer,
intent(out) :: array(:)
2425 integer(kind=MPI_ADDRESS_KIND) :: window_size
2426 integer :: disp_unit
2431 if (intranode_grp%rank == 0)
then
2432 window_size = number_of_elements * 4_mpi_address_kind
2434 window_size = 0_mpi_address_kind
2436 assert(number_of_elements * 4 < huge(0_mpi_address_kind))
2437 assert(window_size >= 0)
2439 call mpi_win_allocate_shared(window_size, disp_unit, mpi_info_null, &
2440 intranode_grp%comm, ptr, window)
2442 if (intranode_grp%rank /= 0)
then
2443 call mpi_win_shared_query(window, 0, window_size, disp_unit, ptr)
2446 call c_f_pointer(ptr, array, [number_of_elements])
2449 call mpi_win_lock_all(mpi_mode_nocheck, window)
2451 end subroutine slmpi_create_shared_memory_window
int access(const char *__name, int __type) __attribute__((__nothrow__
--------------— gemm ---------------— performs one of the matrix-matrix operations
--------------— syrk, herk ---------------— performs one of the symmetric rank k operations
--------------— scal ---------------— Scales a vector by a constant.
constant times a vector plus a vector
scales a vector by a constant
Prints out to iunit a message in the form: ["InputVariable" = value] where "InputVariable" is given b...
Writes to the corresponding file and adds one to the iteration. Must be called after write_iter_init(...
double exp(double __x) __attribute__((__nothrow__
This module implements common operations on batches of mesh functions.
subroutine, public zbatch_axpy_function(np, aa, xx, psi, nst)
This routine performs a set of axpy operations for each function x of a batch (xx),...
This module contains interfaces for BLAS routines You should not use these routines directly....
This module implements a calculator for the density and defines related functions.
subroutine, public density_calc(st, gr, density, istin, ep, vnl, phase)
Computes the density from the orbitals in st.
subroutine lifetime(dmp, ik, ibnd, nik_skip, gam)
Calculate the total scattering rate (inverse lifetime) for a given state.
subroutine update_wfc_occ(ik, gr, istart, iend, nresd, ad_st, resd, occ, v_mat, st, pop)
Update states directly from diagonalization (no Procrustes).
subroutine iopar_close_trans_rate(system_grp, dmp)
Finalize transition rate resources.
subroutine lindblad_from_epw(dmp, hm, kpt, system_grp, namespace, nresd_k, dt, rho_mat_k)
Evolve the density matrix under EPW-derived Lindblad dissipation.
subroutine check_set_positive(locc, npos, ik, namespace, occ)
Checks and truncates small negative eigenvalues to zero.
subroutine calc_overlap_state(ik, gr, ad_st, st, istart_ad, iend_ad, istart_st, iend_st, overlap)
Calculate the overlap matrix between two states in the (istart, iend) active space.
subroutine lindblad_uniform(dmp, kpt, nresd_k, dt, rho_mat_k)
Evolve the density matrix in time under uniform dissipation.
subroutine construct_density_matrix(nresd, ik, st, istart, iend, overlap_ad_ks, overlap_resd_ks, rho_mat, rho_offd)
Construct the full density matrix in the adiabatic and residual basis.
subroutine, public dm_propagation_init_run(dmp, namespace, space, gr, ions, st, hm, mc, from_scratch)
Initialise the adiabatic states prior to running TD propagation.
integer function get_vector_field_index(dmp, hm, namespace)
Get the flattened 1D index of the current vector potential on the discrete EPW vector field grid.
real(real64) function get_trans_rate(dmp, nik_mp, jbnd, ibnd, k, kq, p_block)
Get transition rate from state (k, ibnd) to (kq, jbnd).
subroutine update_wfc_occ_procrustes(ik, gr, istart, iend, nresd, ad_st, resd, overlap_ad_ks, overlap_resd_ks, nrm2_tdks, occ_tilde, v_mat, st, pop)
Update states using Procrustes transformation to ensure time continuity.
subroutine lindblad_operator_epw(dmp, ik, nik_skip, nresd, rho_diag, den_mat, l_mat)
Calculate the Lindblad dissipator matrix using EPW electron-phonon scattering rates.
subroutine, public dm_end_run(system_grp, dmp)
logical function is_hermitian(n, mat)
Check if a matrix is Hermitian.
subroutine transition_rate_uniform(uniform, ad_st, istart, iend, ik, rtrans)
Calculate state transition rates assuming uniform electron-phonon coupling.
subroutine iopar_read_trans_rate(ia, system_grp, namespace, dmp)
Read in transition rates to the shared memory window and then broadcast via internode communicator.
subroutine broadcast_occupation(occ, kpt, parstate, istart, iend)
subroutine population_in_adiabatic(ik, ad_st, st, overlap, istart, iend, pop)
Calculate number of electrons in the adiabatic basis.
subroutine dmp_init(this, namespace, st, space, hm)
Initialise an instance of density matrix dissipation.
subroutine build_epw_kmap(namespace, kpoints, dmp)
Map internal k-point indices to the 1D EPW Monkhorst-Pack grid and verify mesh compatibility.
subroutine collision_from_epw(dmp, hm, kpt, system_grp, namespace, nresd_k, dt, rho_mat_k)
Evolve the density matrix subject to the electron-phonon collision integral.
subroutine construct_residuals(gr, namespace, ad_st, st, ik, othn, istart, iend, overlap_ad_ks, nrm2_tdks, nresd, overlap_resd_ks, resd)
Construct the residual basis and its overlap with TDKS wavefunctions.
subroutine total_population(ik, st, gr, nrm2, pop)
Calculate total population.
subroutine get_gamma(dmp, ik, ibnd, nik_skip, gam_in, gam_out)
Calculate in/out scattering rates (Gamma) for a specific state (ik, ibnd).
subroutine, public dm_propagation_run(dmp, namespace, space, gr, ions, st, mc, hm, ks, iter, dt, ext_partners, update_energy)
Density matrix propagation.
subroutine dm_propagation_update_trans_rate(this, hm, system_grp, namespace)
Read and update the EPW transition matrix only when the vector field index changes.
subroutine lindblad_2times(dmp, kpt, nresd_k, dt, rho_mat_k)
Evolve the density matrix using the phenomenological two-time (T1/T2) relaxation model.
subroutine lindblad_operator_uniform(nresd, istart, iend, rtrans, den_mat, l_mat)
Calculate the Lindblad dissipator matrix for uniform decay.
subroutine iopar_open_trans_rate(namespace, ions, hm, system_grp, dmp)
Read in metadata of transition rates, build intra/inter communicators and shared memory window.
subroutine td_write_dm_proj_basis(this, out_dm_proj_basis, iter)
Write density matrix information to file.
subroutine dissipation(hm, st, namespace, nresd_k, dt, dmp, rho_mat_k)
Evolve the density matrix in time under dissipation.
subroutine calc_overlap_single(ik, gr, st, psi, istart, iend, overlap, reduce)
Calculates the dot products between a vector of mesh functions and a state within the (istart,...
subroutine update_st(dmp, ik, gr, namespace, nresd, overlap_ad_ks, overlap_resd_ks, nrm2_tdks, resd, st, rho_mat, pop)
Diagonalize the density matrix to update occupations and wavefunctions.
subroutine, public eigensolver_init(eigens, namespace, gr, st, hm, mc, space, deactivate_oracle)
subroutine, public eigensolver_end(eigens)
integer, parameter, public spin_polarized
real(real64), parameter, public m_two
real(real64), parameter, public m_zero
real(real64), parameter, public p_ry
logical pure function, public not_in_openmp()
complex(real64), parameter, public m_z0
real(real64), parameter, public m_epsilon
complex(real64), parameter, public m_z1
real(real64), parameter, public m_half
real(real64), parameter, public m_one
This module implements the underlying real-space grid.
This module defines classes and functions for interaction partners.
integer, parameter, public kpoints_monkh_pack
subroutine, public kpoints_to_reduced(latt, kin, kout)
This module defines functions over batches of mesh functions.
subroutine, public mesh_batch_nrm2(mesh, aa, nrm2, reduce)
Calculate the norms (norm2, not the square!) of a batch of mesh functions.
subroutine, public zmesh_batch_dotp_matrix(mesh, aa, bb, dot, reduce)
Calculate the overlap matrix of two batches.
subroutine, public zmesh_batch_mf_dotp(mesh, aa, psi, dot, reduce, nst)
calculate the dot products between a batch and a vector of mesh functions
This module defines various routines, operating on mesh functions.
subroutine, public messages_not_implemented(feature, namespace)
subroutine, public messages_warning(no_lines, all_nodes, namespace)
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
subroutine, public messages_fatal(no_lines, only_root_writes, namespace)
subroutine, public messages_input_error(namespace, var, details, row, column)
subroutine, public messages_info(no_lines, iunit, debug_only, stress, all_nodes, namespace)
This module contains some common usage patterns of MPI routines.
This module handles the communicators for the various parallelization strategies.
integer function, public parse_block(namespace, name, blk, check_varinfo_)
/* To use the profiling module, call profiling_in and profiling_out with the label of the region as a...
integer, parameter, public restart_dm
integer, parameter, public restart_gs
integer, parameter, public restart_type_dump
integer, parameter, public restart_type_load
subroutine, public zstates_elec_orthogonalize_single_batch(st, mesh, nst, iqn, phi, normalize, mask, overlap, norm, Theta_fi, beta_ij, against_all)
orthogonalize a single wave function against a set of states
integer pure function, public states_elec_block_max(st, ib)
return index of last state in block ib
subroutine, public states_elec_end(st)
finalize the states_elec_t object
subroutine, public states_elec_copy(stout, stin, exclude_wfns, exclude_eigenval, special, dest_type, copy_data)
make a (selective) copy of a states_elec_t object
integer pure function, public states_elec_block_min(st, ib)
return index of first state in block ib
This module handles reading and writing restart information for the states_elec_t.
subroutine, public states_elec_load(restart, namespace, space, st, mesh, kpoints, fixed_occ, ierr, iter, lr, lowest_missing, label, verbose, skip)
returns in ierr: <0 => Fatal error, or nothing read =0 => read all wavefunctions >0 => could only rea...
subroutine, public td_write_print_header_init(out)
subroutine, public td_write_print_header_end(out)
brief This module defines the class unit_t which is used by the unit_systems_oct_m module.
character(len=20) pure function, public units_abbrev(this)
This module defines the unit system, used for input and output.
type(unit_system_t), public units_out
type(unit_t), public unit_kelvin
For converting energies into temperatures.
type(unit_system_t), public units_inp
the units systems for reading and writing
subroutine, public v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, calc_eigenval, time, calc_energy, calc_current, force_semilocal)
Explicit interfaces to C functions, defined in write_iter_low.cc.
subroutine, public write_iter_string(out, string)
Distribution of N instances over mpi_grpsize processes, for the local rank mpi_grprank....
Extension of space that contains the knowledge of the spin dimension.
Description of the grid, containing information on derivatives, stencil, and symmetries.
This is defined even when running serial.
Stores all communicators and groups.
The states_elec_t class contains all electronic wave functions.