68 use,
intrinsic :: iso_fortran_env
116 integer,
parameter :: &
117 CASIDA_EPS_DIFF = 1, &
123 integer,
parameter :: &
133 logical :: states_are_real
134 integer,
allocatable :: n_occ(:)
135 integer,
allocatable :: n_unocc(:)
139 integer :: el_per_state
140 character(len=80) :: trandens
141 character(len=80) :: print_exst
142 real(real64) :: weight_thresh
144 logical :: calc_forces
145 logical :: calc_forces_kernel
146 logical :: calc_forces_scf
148 type(restart_t) :: restart_load
149 type(restart_t) :: restart_dump
151 logical,
allocatable :: is_included(:,:,:)
153 type(states_pair_t),
allocatable :: pair(:)
155 integer,
allocatable :: index(:,:,:)
156 integer,
allocatable :: ind(:)
158 real(real64),
allocatable :: dmat(:,:)
159 real(real64),
allocatable :: dmat_save(:,:)
160 complex(real64),
allocatable :: zmat(:,:)
161 complex(real64),
allocatable :: zmat_save(:,:)
164 real(real64),
allocatable :: dmatB(:,:)
165 complex(real64),
allocatable :: zmatB(:,:)
166 real(real64),
allocatable :: w(:)
167 real(real64),
allocatable :: dtm(:, :)
168 complex(real64),
allocatable :: ztm(:, :)
169 real(real64),
allocatable :: f(:)
170 real(real64),
allocatable :: s(:)
172 real(real64),
allocatable :: rho(:,:)
173 real(real64),
allocatable :: fxc(:,:,:)
174 real(real64) :: kernel_lrc_alpha
176 real(real64),
allocatable :: fxc_grad(:,:,:,:,:)
177 real(real64),
allocatable :: fxc_grad_spin(:,:,:,:)
179 real(real64),
allocatable :: dmat2(:,:)
180 complex(real64),
allocatable :: zmat2(:,:)
181 real(real64),
allocatable :: dlr_hmat2(:,:)
182 complex(real64),
allocatable :: zlr_hmat2(:,:)
183 real(real64),
allocatable :: forces(:,:,:)
184 real(real64),
allocatable :: dw2(:)
185 real(real64),
allocatable :: zw2(:)
189 real(real64),
allocatable :: qvector(:)
190 real(real64),
allocatable :: qf(:)
191 real(real64),
allocatable :: qf_avg(:)
194 logical :: parallel_in_eh_pairs
195 logical :: parallel_in_domains
196 logical :: distributed_matrix
197 logical :: write_matrix
198 integer :: parallel_solver
199 type(mpi_grp_t) :: mpi_grp
200 logical :: fromScratch
201 logical :: has_photons
203 type(photon_mode_t),
pointer :: photon_modes => null()
205 integer :: n, nb_rows, nb_cols, block_size
206 type(blacs_proc_grid_t) :: proc_grid
207 integer :: desc(BLACS_DLEN)
208 type(MPI_Datatype) :: darray
216 real(real64),
allocatable :: dpot(:)
217 complex(real64),
allocatable :: zpot(:)
223 class(*),
intent(inout) :: system
224 logical,
intent(in) :: from_scratch
230 message(1) =
"CalculationMode = casida not implemented for multi-system calculations"
242 logical,
intent(in) :: fromscratch
246 integer :: idir, theorylevel, iatom, ierr, default_int
247 character(len=100) :: restart_filename
248 logical :: is_frac_occ
254 if (sys%hm%pcm%run_pcm)
then
258 if (sys%space%is_periodic())
then
259 message(1) =
"Casida oscillator strengths will be incorrect in periodic systems."
284 message(1) =
'Info: Starting Casida linear-response calculation.'
296 call gs_restart%end()
298 message(1) =
"Previous gs calculation is required."
302 cas%el_per_state = sys%st%smear%el_per_state
305 cas%space_dim = sys%space%dim
306 safe_allocate(cas%n_occ(1:sys%st%nik))
307 safe_allocate(cas%n_unocc(1:sys%st%nik))
309 call casida_count_pairs(sys%st, sys%namespace, cas%n_pairs, cas%n_occ, cas%n_unocc, cas%is_included, is_frac_occ)
310 select case (sys%st%d%ispin)
312 write(
message(1),
'(a,i4,a)')
"Info: Found", cas%n_occ(1),
" occupied states."
313 write(
message(2),
'(a,i4,a)')
"Info: Found", cas%n_unocc(1),
" unoccupied states."
316 write(
message(1),
'(a,i4,a)')
"Info: Found", cas%n_occ(1),
" occupied states with spin up."
317 write(
message(2),
'(a,i4,a)')
"Info: Found", cas%n_unocc(1),
" unoccupied states with spin up."
318 write(
message(3),
'(a,i4,a)')
"Info: Found", cas%n_occ(2),
" occupied states with spin down."
319 write(
message(4),
'(a,i4,a)')
"Info: Found", cas%n_unocc(2),
" unoccupied states with spin down."
325 message(1) =
'Info: Setting up Hamiltonian.'
327 call v_ks_h_setup(sys%namespace, sys%space, sys%gr, sys%ions, sys%ext_partners, sys%st, sys%ks, &
328 sys%hm, calc_eigenval=.false.)
369 message(1) =
"Variational and full Casida theory levels do not apply to complex wavefunctions."
376 call parse_variable(sys%namespace,
'EnablePhotons', .false., cas%has_photons)
378 if (cas%has_photons)
then
380 cas%photon_modes => sys%photons%modes
382 write(
message(1),
'(a,i7,a)')
'INFO: Solving Casida equation with ', &
383 cas%photon_modes%nmodes,
' photon modes.'
384 write(
message(2),
'(a)')
'as described in ACS Photonics 2019, 6, 11, 2757-2778.'
386 cas%pt_nmodes = cas%photon_modes%nmodes
401 call parse_variable(sys%namespace,
'CasidaTransitionDensities',
"0", cas%trandens)
403 if (cas%trandens /=
"0")
then
405 sys%outp%how, sys%outp%output_interval)
418 safe_allocate(cas%qvector(1:cas%space_dim))
419 if (
parse_block(sys%namespace,
'CasidaMomentumTransfer', blk) == 0)
then
420 do idir = 1, cas%space_dim
425 message(1) =
"Info: Calculating IXS/EELS transition rates."
441 call parse_variable(sys%namespace,
'CasidaQuadratureOrder', 5, cas%avg_order)
457 call parse_variable(sys%namespace,
'CasidaCalcTriplet', .false., cas%triplet)
459 cas%triplet = .false.
462 if (cas%triplet)
then
463 message(1) =
"Info: Using triplet kernel. Oscillator strengths will be for spin magnetic-dipole field."
476 call parse_variable(sys%namespace,
'CasidaHermitianConjugate', .false., cas%herm_conj)
491 call parse_variable(sys%namespace,
'CasidaDistributedMatrix', .false., cas%distributed_matrix)
492#ifndef HAVE_SCALAPACK
493 if (cas%distributed_matrix)
then
494 message(1) =
"ScaLAPACK layout requested, but code not compiled with ScaLAPACK"
508 call parse_variable(sys%namespace,
'CasidaWriteDistributedMatrix', .false., cas%write_matrix)
509 if (.not. cas%distributed_matrix .and. cas%write_matrix)
then
510 message(1) =
"CasidaWriteDistributedMatrix con only be used with CasidaDistributedMatrix"
528 default_int = solver_elpa
532 call parse_variable(sys%namespace,
'CasidaParallelEigensolver', default_int, cas%parallel_solver)
537 if (cas%distributed_matrix .and. cas%parallel_solver == solver_elpa)
then
538 message(1) =
"ELPA solver requested, but code not compiled with ELPA"
553 call parse_variable(sys%namespace,
'CasidaPrintExcitations',
"all", cas%print_exst)
554 if (cas%distributed_matrix)
then
556 cas%print_exst =
"none"
557 message(1) =
"Using ScaLAPACK layout, thus disabling output of excited states."
558 message(2) =
"This options creates too many files for large Casida matrices."
574 if (cas%weight_thresh >
m_one)
then
575 message(1) =
'Casida coefficients have values between 0 and 1'
576 message(2) =
'Threshold values reset to default value'
578 cas%weight_thresh = -
m_one
588 call parse_variable(sys%namespace,
'CasidaCalcForces', .false., cas%calc_forces)
589 if (cas%calc_forces)
then
602 call parse_variable(sys%namespace,
'CasidaCalcForcesKernel', .
true., cas%calc_forces_kernel)
612 call parse_variable(sys%namespace,
'CasidaCalcForcesSCF', .false., cas%calc_forces_scf)
614 if (cas%distributed_matrix)
then
615 message(1) =
"Info: Forces calculation not compatible with ScaLAPACK layout."
616 message(2) =
"Using normal layout."
618 cas%distributed_matrix = .false.
626 cas%fromScratch = fromscratch
628 if (cas%fromScratch)
then
629 if (cas%triplet)
then
630 call cas%restart_dump%rm(
'kernel_triplet')
632 call cas%restart_dump%rm(
'kernel')
635 if (cas%calc_forces)
then
636 do iatom = 1, sys%ions%natoms
637 do idir = 1, cas%space_dim
638 write(restart_filename,
'(a,i6.6,a,i1)')
'lr_kernel_', iatom,
'_', idir
639 if (cas%triplet) restart_filename = trim(restart_filename)//
'_triplet'
640 call cas%restart_dump%rm(restart_filename)
642 write(restart_filename,
'(a,i6.6,a,i1)')
'lr_hmat1_', iatom,
'_', idir
643 call cas%restart_dump%rm(restart_filename)
650 if (
bitand(theorylevel, casida_eps_diff) /= 0)
then
651 message(1) =
"Info: Approximating resonance energies through KS eigenvalue differences"
653 cas%type = casida_eps_diff
657 if (sys%st%d%ispin /=
spinors)
then
659 if (sys%hm%theory_level ==
hartree_fock .and. cas%distributed_matrix)
then
661 namespace=sys%namespace)
666 message(1) =
"Info: Calculating matrix elements in the Tamm-Dancoff approximation"
677 message(1) =
"Info: Calculating matrix elements with the CV(2)-DFT theory"
685 message(1) =
"Info: Calculating matrix elements with the full Casida method"
697 message(1) =
"Info: Calculating resonance energies via the Petersilka approximation"
715 subroutine casida_count_pairs(st, namespace, n_pairs, n_occ, n_unocc, is_included, is_frac_occ)
718 integer,
intent(out) :: n_pairs
719 integer,
intent(out) :: n_occ(:)
720 integer,
intent(out) :: n_unocc(:)
721 logical,
allocatable,
intent(out) :: is_included(:,:,:)
723 logical,
intent(out) :: is_frac_occ
725 integer :: ik, ist, ast, n_filled, n_partially_filled, n_half_filled
726 character(len=80) :: nst_string, default, wfn_list
727 real(real64) :: energy_window
728 real(real64) :: fdiff, delta_e
729 real(real64) :: fdiff_tol
730 real(real64) :: delta_e_tol
734 is_frac_occ = .false.
736 call occupied_states(st, namespace, ik, n_filled, n_partially_filled, n_half_filled)
737 if (n_partially_filled > 0 .or. n_half_filled > 0) is_frac_occ = .
true.
738 n_occ(ik) = n_filled + n_partially_filled + n_half_filled
739 n_unocc(ik) = st%nst - n_filled
762 call parse_variable(namespace,
'CasidaThresholdOccupation', 1.0e-12_real64, fdiff_tol)
795 safe_allocate(is_included(st%nst, st%nst , st%nik))
796 is_included(:,:,:) = .false.
798 if (energy_window <
m_zero)
then
799 write(nst_string,
'(i6)') st%nst
800 write(default,
'(a,a)')
"1-", trim(adjustl(nst_string))
801 call parse_variable(namespace,
'CasidaKohnShamStates', default, wfn_list)
803 write(
message(1),
'(a,a)')
"Info: States that form the basis: ", trim(wfn_list)
813 fdiff = st%occ(ist,ik) - st%occ(ast,ik)
814 if (fdiff <= fdiff_tol) cycle
815 n_pairs = n_pairs + 1
816 is_included(ist, ast, ik) = .
true.
823 write(
message(1),
'(a,f12.6,a)')
"Info: including transitions with energy < ", &
832 fdiff = st%occ(ist,ik) - st%occ(ast,ik)
833 if (fdiff <= fdiff_tol) cycle
834 delta_e = st%eigenval(ast, ik) - st%eigenval(ist, ik)
835 if (delta_e <= delta_e_tol) cycle
836 if (delta_e >= energy_window) cycle
837 n_pairs = n_pairs + 1
838 is_included(ist, ast, ik) = .
true.
851 type(
casida_t),
intent(inout) :: cas
854 integer :: ist, ast, jpair, ik, ierr
856 integer :: np, np_rows, np_cols, ii, info
862 cas%kernel_lrc_alpha = sys%ks%xc%lrc%alpha
864 if (cas%distributed_matrix .and. .not. cas%states_are_real)
then
868 write(
message(1),
'(a,i9)')
"Number of occupied-unoccupied pairs: ", cas%n_pairs
871 if (cas%n_pairs < 1)
then
872 message(1) =
"No Casida pairs -- maybe there are no unoccupied states?"
876 if (
mpi_world%is_root())
write(*,
"(1x)")
880 if (cas%parallel_in_eh_pairs)
then
887 if (cas%distributed_matrix .and. .not. cas%parallel_in_eh_pairs)
then
888 message(1) =
"ScaLAPACK layout requested, but 'Other' parallelization strategy not available."
889 message(2) =
"Please set ParOther to use the ScaLAPACK layout."
890 message(3) =
"Continuing without ScaLAPACK layout."
892 cas%distributed_matrix = .false.
896 cas%n = cas%n_pairs + cas%pt_nmodes
899 if (cas%distributed_matrix)
then
903 np = cas%mpi_grp%size
907 if (mod(np, ii) == 0)
then
913 np_rows = np / np_cols
917 cas%block_size = min(64, cas%n / np_rows)
919 cas%block_size = max(5, cas%block_size)
920 write(
message(1),
'(A,I5,A,I5,A,I5,A)')
'Parallel layout: using block size of ',&
921 cas%block_size,
' and a processor grid with ', np_rows,
'x', np_cols, &
922 ' processors (rows x cols)'
928 cas%nb_rows = numroc(cas%n, cas%block_size, cas%proc_grid%myrow, 0, cas%proc_grid%nprow)
929 cas%nb_cols = numroc(cas%n, cas%block_size, cas%proc_grid%mycol, 0, cas%proc_grid%npcol)
932 call descinit(cas%desc(1), cas%n, cas%n, cas%block_size, cas%block_size, 0, 0, &
933 cas%proc_grid%context, cas%nb_rows, info)
942 safe_allocate(cas%pair(1:cas%n))
943 if (cas%states_are_real)
then
944 safe_allocate( cas%dmat(1:cas%nb_rows, 1:cas%nb_cols))
945 safe_allocate( cas%dtm(1:cas%n, 1:cas%space_dim))
948 safe_allocate( cas%zmat(1:cas%nb_rows, 1:cas%nb_cols))
949 safe_allocate( cas%ztm(1:cas%n, 1:cas%space_dim))
951 safe_allocate( cas%f(1:cas%n))
952 safe_allocate( cas%s(1:cas%n_pairs))
953 safe_allocate( cas%w(1:cas%n))
954 safe_allocate( cas%index(1:cas%nst, 1:cas%nst, 1:cas%nik))
955 safe_allocate( cas%ind(1:cas%n))
957 if (cas%calc_forces)
then
958 if (cas%states_are_real)
then
959 safe_allocate(cas%dmat_save(1:cas%n_pairs, 1:cas%n_pairs))
961 safe_allocate(cas%zmat_save(1:cas%n_pairs, 1:cas%n_pairs))
963 safe_allocate(cas%forces(1:cas%space_dim, 1:sys%ions%natoms, 1:cas%n_pairs))
967 safe_allocate( cas%qf (1:cas%n_pairs))
968 safe_allocate( cas%qf_avg(1:cas%n_pairs))
978 if (.not. cas%is_included(ist, ast, ik)) cycle
979 cas%index(ist, ast, ik) = jpair
980 cas%pair(jpair)%i = ist
981 cas%pair(jpair)%a = ast
982 cas%pair(jpair)%kk = ik
987 if (jpair - 1 /= cas%n_pairs)
then
988 message(1) =
"Mismatch in Casida pair counting"
992 if (cas%has_photons)
then
994 do ik = 1, cas%pt_nmodes
995 cas%pair(cas%n_pairs + ik)%i = 1
996 cas%pair(cas%n_pairs + ik)%a = -ik
997 cas%pair(cas%n_pairs + ik)%kk = -ik
1001 safe_deallocate_a(cas%is_included)
1012 type(
casida_t),
intent(inout) :: cas
1016 assert(
allocated(cas%pair))
1017 safe_deallocate_a(cas%pair)
1018 safe_deallocate_a(cas%index)
1019 if (cas%states_are_real)
then
1020 safe_deallocate_a(cas%dmat)
1021 safe_deallocate_a(cas%dtm)
1022 safe_deallocate_a(cas%dmatB)
1024 safe_deallocate_a(cas%zmat)
1025 safe_deallocate_a(cas%ztm)
1026 safe_deallocate_a(cas%zmatB)
1028 safe_deallocate_a(cas%s)
1029 safe_deallocate_a(cas%f)
1030 safe_deallocate_a(cas%w)
1031 safe_deallocate_a(cas%ind)
1034 safe_deallocate_a(cas%qf)
1035 safe_deallocate_a(cas%qf_avg)
1038 safe_deallocate_a(cas%n_occ)
1039 safe_deallocate_a(cas%n_unocc)
1041 if (cas%calc_forces)
then
1042 if (cas%states_are_real)
then
1043 safe_deallocate_a(cas%dmat_save)
1045 safe_deallocate_a(cas%zmat_save)
1047 safe_deallocate_a(cas%forces)
1050 call cas%restart_dump%end()
1051 call cas%restart_load%end()
1053 if (cas%distributed_matrix)
then
1054#ifdef HAVE_SCALAPACK
1059 safe_deallocate_a(cas%qvector)
1070 type(
casida_t),
intent(inout) :: cas
1073 type(
grid_t),
pointer :: gr
1075 real(real64),
allocatable :: rho_spin(:, :)
1076 real(real64),
allocatable :: fxc_spin(:,:,:), fxc_grad(:,:,:,:,:), fxc_grad_spin(:,:,:,:)
1077 character(len=100) :: restart_filename
1082 assert(cas%type >= casida_eps_diff .and. cas%type <=
casida_casida)
1089 if (cas%states_are_real)
then
1092 if (
allocated(cas%dmatB)) cas%dmatB =
m_zero
1096 if (
allocated(cas%zmatB)) cas%zmatB =
m_zero
1106 if (cas%type /= casida_eps_diff .or. cas%calc_forces)
then
1108 safe_allocate(cas%rho(1:gr%np_part, 1:st%d%nspin))
1109 safe_allocate(cas%fxc(1:gr%np, 1:st%d%nspin, 1:st%d%nspin))
1110 cas%gga =
in_family(sys%ks%xc%kernel_family, [xc_family_gga])
1113 if (sys%hm%theory_level ==
hartree_fock) cas%gga = .false.
1115 safe_allocate(cas%fxc_grad(1:gr%np, 1:gr%der%dim, 1:gr%der%dim, 1:st%d%nspin, 1:st%d%nspin))
1117 safe_allocate(cas%fxc_grad_spin(1:gr%np, 1:gr%der%dim, 1:st%d%nspin, 1:st%d%nspin))
1119 safe_allocate(cas%fxc_grad_spin(0, 0, 0, 0))
1122 safe_allocate(cas%fxc_grad(0, 0, 0, 0, 0))
1123 safe_allocate(cas%fxc_grad_spin(0, 0, 0, 0))
1130 else if (cas%triplet)
then
1131 safe_allocate(rho_spin(1:gr%np_part, 1:2))
1132 safe_allocate(fxc_spin(1:gr%np, 1:2, 1:2))
1134 rho_spin(:, 1) =
m_half * cas%rho(:, 1)
1135 rho_spin(:, 2) =
m_half * cas%rho(:, 1)
1138 safe_allocate(fxc_grad(1:gr%np, 1:gr%der%dim, 1:gr%der%dim, 1:2, 1:2))
1139 safe_allocate(fxc_grad_spin(1:gr%np, 1:gr%der%dim, 1:2, 1:2))
1141 cas%fxc_grad(:, :, :, 1, 1) =
m_half * (fxc_grad(:, :, :, 1, 1) - fxc_grad(:, :, :, 1, 2))
1143 safe_deallocate_a(fxc_grad)
1144 safe_deallocate_a(fxc_grad_spin)
1148 cas%fxc(:, 1, 1) =
m_half * (fxc_spin(:, 1, 1) - fxc_spin(:, 1, 2))
1150 safe_deallocate_a(rho_spin)
1151 safe_deallocate_a(fxc_spin)
1154 call xc_get_fxc(sys%ks%xc, gr, sys%namespace, cas%rho, st%d%ispin, cas%fxc, cas%fxc_grad, &
1157 call xc_get_fxc(sys%ks%xc, gr, sys%namespace, cas%rho, st%d%ispin, cas%fxc)
1162 call xc_sic_add_fxc_adsic(sys%namespace, sys%ks%xc, st, gr, cas%rho, cas%fxc, cas%fxc_grad, cas%fxc_grad_spin, cas%triplet)
1167 restart_filename =
'kernel'
1168 if (cas%triplet) restart_filename = trim(restart_filename)//
'_triplet'
1171 if (cas%pt_nmodes > 0)
then
1174 if (cas%states_are_real)
then
1175 safe_allocate(cas%dmatB(1:cas%n_pairs, 1:cas%n_pairs))
1177 safe_allocate(cas%zmatB(1:cas%n_pairs, 1:cas%n_pairs))
1181 select case (cas%type)
1182 case (casida_eps_diff)
1185 if (cas%states_are_real)
then
1186 if (
allocated(cas%dmatB))
then
1187 call dcasida_get_matrix(cas, sys%namespace, sys%hm, st, sys%ks, gr, cas%dmat, cas%fxc, &
1188 cas%fxc_grad, cas%fxc_grad_spin, restart_filename, matrixb=cas%dmatB)
1190 call dcasida_get_matrix(cas, sys%namespace, sys%hm, st, sys%ks, gr, cas%dmat, cas%fxc, &
1191 cas%fxc_grad, cas%fxc_grad_spin, restart_filename)
1195 if (
allocated(cas%zmatB))
then
1196 call zcasida_get_matrix(cas, sys%namespace, sys%hm, st, sys%ks, gr, cas%zmat, cas%fxc, &
1197 cas%fxc_grad, cas%fxc_grad_spin, restart_filename, matrixb=cas%zmatB)
1199 call zcasida_get_matrix(cas, sys%namespace, sys%hm, st, sys%ks, gr, cas%zmat, cas%fxc, &
1200 cas%fxc_grad, cas%fxc_grad_spin, restart_filename)
1207 if (cas%mpi_grp%is_root() .or. cas%distributed_matrix)
then
1208 if (cas%states_are_real)
then
1215 if (cas%calc_forces)
then
1216 if (cas%states_are_real)
then
1223 if (cas%states_are_real)
then
1229 safe_deallocate_a(cas%dmatB)
1230 safe_deallocate_a(cas%zmatB)
1233 if (cas%type /= casida_eps_diff .or. cas%calc_forces)
then
1234 safe_deallocate_a(cas%fxc)
1235 safe_deallocate_a(cas%fxc_grad)
1236 safe_deallocate_a(cas%fxc_grad_spin)
1237 safe_deallocate_a(cas%rho)
1248 real(real64),
allocatable :: w(:)
1255 do ia = 1, cas%n_pairs
1256 cas%w(ia) = st%eigenval(cas%pair(ia)%a, cas%pair(ia)%kk) - &
1257 st%eigenval(cas%pair(ia)%i, cas%pair(ia)%kk)
1259 message(1) =
"There is a negative unocc-occ KS eigenvalue difference for"
1260 write(
message(2),
'("states ",I5," and ",I5," of k-point ",I5,".")') cas%pair(ia)%i, cas%pair(ia)%a, cas%pair(ia)%kk
1261 message(3) =
"This indicates an inconsistency between gs, unocc, and/or casida calculations."
1267 safe_allocate(w(1:
size(cas%w)))
1269 call sort(w, cas%ind)
1270 safe_deallocate_a(w)
1272 if (
mpi_world%is_root())
write(*,
"(1x)")
1280 real(real64) function casida_matrix_factor(cas, sys)
1284 push_sub(casida_matrix_factor)
1286 casida_matrix_factor =
m_one
1289 casida_matrix_factor =
m_two * casida_matrix_factor
1293 casida_matrix_factor =
m_two * casida_matrix_factor
1296 pop_sub(casida_matrix_factor)
1303 type(namespace_t),
intent(in) :: namespace
1305 integer :: iunit, ia
1307 if (.not. mpi_world%is_root())
return
1311 call io_mkdir(casida_dir, namespace)
1312 iunit = io_open(casida_dir//
'q'//trim(
theory_name(cas)), namespace, action=
'write')
1313 write(iunit,
'(a1,a14,1x,a24,1x,a24,1x,a10,3es15.8,a2)')
'#',
'E' ,
'|<f|exp(iq.r)|i>|^2', &
1314 '<|<f|exp(iq.r)|i>|^2>',
'; q = (',cas%qvector(1:cas%space_dim),
')'
1315 write(iunit,
'(a1,a14,1x,a24,1x,a24,1x,10x,a15)')
'#', trim(units_abbrev(units_out%energy)), &
1320 if (cas%avg_order == 0)
then
1321 do ia = 1, cas%n_pairs
1322 write(iunit,
'(es15.8,es15.8)') units_from_atomic(units_out%energy, cas%w(cas%ind(ia))), cas%qf(cas%ind(ia))
1325 do ia = 1, cas%n_pairs
1326 write(iunit,
'(3es15.8)') units_from_atomic(units_out%energy, cas%w(cas%ind(ia))), &
1327 cas%qf (cas%ind(ia)), &
1328 cas%qf_avg(cas%ind(ia))
1332 call io_close(iunit)
1339 character(len=80) pure function theory_name(cas)
1342 select case (cas%type)
1361 type(states_elec_t),
intent(in) :: st
1362 integer,
intent(in) :: ia
1363 integer,
intent(in) :: jb
1367 isnt_degenerate = (abs((st%eigenval(cas%pair(ia)%a, cas%pair(ia)%kk) - st%eigenval(cas%pair(ia)%i, cas%pair(ia)%kk)) &
1368 - (st%eigenval(cas%pair(jb)%a, cas%pair(jb)%kk) - st%eigenval(cas%pair(jb)%i, cas%pair(jb)%kk))) > 1e-8_real64)
1375 type(
casida_t),
intent(inout) :: cas
1376 integer,
intent(in) :: jb_local
1378 if (.not. cas%distributed_matrix)
then
1381#ifdef HAVE_SCALAPACK
1382 jb = indxl2g(jb_local, cas%block_size, cas%proc_grid%myrow, 0, cas%proc_grid%nprow)
1389 type(
casida_t),
intent(inout) :: cas
1390 integer,
intent(in) :: ia_local
1392 if (.not. cas%distributed_matrix)
then
1395#ifdef HAVE_SCALAPACK
1396 ia = indxl2g(ia_local, cas%block_size, cas%proc_grid%mycol, 0, cas%proc_grid%npcol)
1401 subroutine local_indices(cas, ia, jb, on_this_processor, ia_local, jb_local)
1404 integer,
intent(in) :: ia, jb
1405 logical,
intent(out) :: on_this_processor
1406 integer,
intent(out) :: ia_local, jb_local
1407#ifdef HAVE_SCALAPACK
1408 integer :: ia_proc, jb_proc
1411 if (.not. cas%distributed_matrix)
then
1412 on_this_processor = .
true.
1416#ifdef HAVE_SCALAPACK
1417 ia_proc = indxg2p(ia, cas%block_size, cas%proc_grid%mycol, 0, cas%proc_grid%npcol)
1418 jb_proc = indxg2p(jb, cas%block_size, cas%proc_grid%myrow, 0, cas%proc_grid%nprow)
1419 if (cas%proc_grid%mycol == ia_proc .and. cas%proc_grid%myrow == jb_proc)
then
1421 ia_local = indxg2l(ia, cas%block_size, cas%proc_grid%mycol, 0, cas%proc_grid%npcol)
1422 jb_local = indxg2l(jb, cas%block_size, cas%proc_grid%myrow, 0, cas%proc_grid%nprow)
1424 on_this_processor = .false.
1434#include "casida_inc.F90"
1436#include "complex.F90"
1437#include "casida_inc.F90"
subroutine solve_eps_diff
This is the common interface to a sorting routine. It performs the shell algorithm,...
double floor(double __x) __attribute__((__nothrow__
This module implements batches of mesh functions.
This module provides the BLACS processor grid.
subroutine, public blacs_proc_grid_init(this, mpi_grp, procdim)
Initializes a blacs context from an MPI communicator with topological information.
subroutine, public blacs_proc_grid_end(this)
This module handles the calculation mode.
integer, parameter, public p_strategy_other
something else like e-h pairs
integer, parameter, public p_strategy_domains
parallelization in domains
This module implements the Casida equations for excited states.
integer function get_global_col(cas, ia_local)
subroutine zcasida_get_matrix(cas, namespace, hm, st, ks, gr, matrix, fxc, fxc_grad, fxc_grad_spin, restart_file, is_forces, matrixB)
integer, parameter solver_scalapack
subroutine casida_count_pairs(st, namespace, n_pairs, n_occ, n_unocc, is_included, is_frac_occ)
number of occupied-unoccupied pairs for Casida
subroutine zoscillator_strengths(cas, mesh, st)
integer, parameter casida_petersilka
integer, parameter casida_casida
subroutine casida_type_init(cas, sys)
allocates stuff, and constructs the arrays pair_i and pair_j
integer function get_global_row(cas, jb_local)
integer, parameter casida_eps_diff
character(len=80) pure function theory_name(cas)
subroutine dcasida_forces(cas, sys, gr, st)
subroutine local_indices(cas, ia, jb, on_this_processor, ia_local, jb_local)
subroutine zcasida_solve(cas, sys)
subroutine casida_work(sys, cas)
this subroutine calculates electronic excitation energies using the matrix formulation of M....
integer, parameter casida_variational
subroutine dcasida_get_matrix(cas, namespace, hm, st, ks, gr, matrix, fxc, fxc_grad, fxc_grad_spin, restart_file, is_forces, matrixB)
subroutine qcasida_write(cas, namespace)
subroutine zcasida_write(cas, sys)
logical function isnt_degenerate(cas, st, ia, jb)
subroutine, public casida_run(system, from_scratch)
subroutine doscillator_strengths(cas, mesh, st)
subroutine dcasida_write(cas, sys)
real(real64) function casida_matrix_factor(cas, sys)
subroutine casida_run_legacy(sys, fromScratch)
integer, parameter casida_tamm_dancoff
subroutine zcasida_forces(cas, sys, gr, st)
subroutine casida_type_end(cas)
subroutine dcasida_solve(cas, sys)
This module implements a calculator for the density and defines related functions.
subroutine, public states_elec_total_density(st, mesh, total_rho)
This routine calculates the total electronic density.
This module calculates the derivatives (gradients, Laplacians, etc.) of a function.
integer, parameter, public unpolarized
Parameters...
integer, parameter, public spinors
integer, parameter, public spin_polarized
real(real64), parameter, public m_two
real(real64), parameter, public m_zero
integer, parameter, public hartree_fock
integer, parameter, public generalized_kohn_sham_dft
real(real64), parameter, public m_epsilon
real(real64), parameter, public m_half
real(real64), parameter, public m_one
This module implements the underlying real-space grid.
subroutine, public io_function_read_what_how_when(namespace, space, what, how, output_interval, what_tag_in, how_tag_in, output_interval_tag_in, ignore_error)
integer pure function, public kpoints_number(this)
A module to handle KS potential, without the external potential.
integer, parameter, public dft_u_none
System information (time, memory, sysname)
logical function, public loct_isinstringlist(a, s)
subroutine, public loct_progress_bar(a, maxcount)
A wrapper around the progress bar, such that it can be silenced without needing to dress the call wit...
This module defines various routines, operating on mesh functions.
This module defines the meshes, which are used in Octopus.
subroutine, public messages_print_with_emphasis(msg, iunit, namespace)
subroutine, public messages_not_implemented(feature, namespace)
character(len=512), private msg
subroutine, public messages_warning(no_lines, all_nodes, namespace)
subroutine, public messages_obsolete_variable(namespace, name, rep)
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_experimental(name, namespace)
subroutine, public messages_info(no_lines, iunit, debug_only, stress, all_nodes, namespace)
type(mpi_comm), parameter, public mpi_comm_undefined
used to indicate a communicator has not been initialized
type(mpi_grp_t), public mpi_world
subroutine mpi_grp_init(grp, comm)
Initialize MPI group instance.
This module handles the communicators for the various parallelization strategies.
logical pure function, public multicomm_strategy_is_parallel(mc, level)
This module implements the basic mulsisystem class, a container system for other systems.
integer function, public parse_block(namespace, name, blk, check_varinfo_)
subroutine, public photon_mode_set_n_electrons(this, qtot)
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.
integer, parameter, public restart_casida
integer, parameter, public restart_gs
integer, parameter, public restart_type_dump
integer, parameter, public restart_type_load
This module contains interfaces for ScaLAPACK routines Interfaces are from http:
This module is intended to contain "only mathematical" functions and procedures.
pure logical function, public states_are_complex(st)
pure logical function, public states_are_real(st)
This module handles spin dimensions of the states and the k-point distribution.
subroutine, public occupied_states(st, namespace, ik, n_filled, n_partially_filled, n_half_filled, filled, partially_filled, half_filled)
return information about occupied orbitals in many-body state
This module handles reading and writing restart information for the states_elec_t.
subroutine, public states_elec_look_and_load(restart, namespace, space, st, mesh, kpoints, fixed_occ, is_complex, packed)
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_system_t), public units_inp
the units systems for reading and writing
This module is intended to contain simple general-purpose utility functions and procedures.
subroutine, public v_ks_h_setup(namespace, space, gr, ions, ext_partners, st, ks, hm, calc_eigenval, calc_current)
subroutine, public xc_get_fxc(xcs, gr, namespace, rho, ispin, fxc, fxc_grad, fxc_grad_spin)
Returns the exchange-correlation kernel.
logical pure function, public family_is_mgga_with_exc(xcs)
Is the xc function part of the mGGA family with an energy functional.
logical pure function, public family_is_hybrid(xcs)
Returns true if the functional is an hybrid functional.
pure logical function, public in_family(family, xc_families)
subroutine, public xc_write_fxc_info(xcs, iunit, namespace)
subroutine, public xc_sic_write_info(sic, iunit, namespace)
integer, parameter, public sic_adsic
Averaged density SIC.
subroutine, public xc_sic_add_fxc_adsic(namespace, xc, st, gr, rho, fxc, fxc_grad, fxc_grad_spin, triplet)
Adds to fxc the ADSIC contribution.
This class contains all parameters, needed for Casida calculations.
Class describing the electron system.
Description of the grid, containing information on derivatives, stencil, and symmetries.
Container class for lists of system_oct_m::system_t.
The states_elec_t class contains all electronic wave functions.