48 use,
intrinsic :: iso_fortran_env
96 integer,
parameter :: &
97 CASIDA_EPS_DIFF = 1, &
103 integer,
parameter :: &
113 logical :: states_are_real
114 integer,
allocatable :: n_occ(:)
115 integer,
allocatable :: n_unocc(:)
119 integer :: el_per_state
120 character(len=80) :: trandens
121 character(len=80) :: print_exst
122 real(real64) :: weight_thresh
124 logical :: calc_forces
125 logical :: calc_forces_kernel
126 logical :: calc_forces_scf
128 type(restart_t) :: restart_load
129 type(restart_t) :: restart_dump
131 logical,
allocatable :: is_included(:,:,:)
133 type(states_pair_t),
allocatable :: pair(:)
135 integer,
allocatable :: index(:,:,:)
136 integer,
allocatable :: ind(:)
138 real(real64),
allocatable :: dmat(:,:)
139 real(real64),
allocatable :: dmat_save(:,:)
140 complex(real64),
allocatable :: zmat(:,:)
141 complex(real64),
allocatable :: zmat_save(:,:)
142 real(real64),
allocatable :: w(:)
143 real(real64),
allocatable :: dtm(:, :)
144 complex(real64),
allocatable :: ztm(:, :)
145 real(real64),
allocatable :: f(:)
146 real(real64),
allocatable :: s(:)
148 real(real64),
allocatable :: rho(:,:)
149 real(real64),
allocatable :: fxc(:,:,:)
150 real(real64) :: kernel_lrc_alpha
152 real(real64),
allocatable :: fxc_grad(:,:,:,:,:)
153 real(real64),
allocatable :: fxc_grad_spin(:,:,:,:)
155 real(real64),
allocatable :: dmat2(:,:)
156 complex(real64),
allocatable :: zmat2(:,:)
157 real(real64),
allocatable :: dlr_hmat2(:,:)
158 complex(real64),
allocatable :: zlr_hmat2(:,:)
159 real(real64),
allocatable :: forces(:,:,:)
160 real(real64),
allocatable :: dw2(:)
161 real(real64),
allocatable :: zw2(:)
165 real(real64),
allocatable :: qvector(:)
166 real(real64),
allocatable :: qf(:)
167 real(real64),
allocatable :: qf_avg(:)
170 logical :: parallel_in_eh_pairs
171 logical :: parallel_in_domains
172 logical :: distributed_matrix
173 logical :: write_matrix
174 integer :: parallel_solver
175 type(mpi_grp_t) :: mpi_grp
176 logical :: fromScratch
177 logical :: has_photons
179 type(photon_mode_t),
pointer :: photon_modes => null()
181 integer :: n, nb_rows, nb_cols, block_size
182 type(blacs_proc_grid_t) :: proc_grid
183 integer :: desc(BLACS_DLEN)
184 type(MPI_Datatype) :: darray
192 real(real64),
allocatable :: dpot(:)
193 complex(real64),
allocatable :: zpot(:)
199 class(*),
intent(inout) :: system
200 logical,
intent(in) :: from_scratch
206 message(1) =
"CalculationMode = casida not implemented for multi-system calculations"
218 logical,
intent(in) :: fromscratch
222 integer :: idir, theorylevel, iatom, ierr, default_int
223 character(len=100) :: restart_filename
224 logical :: is_frac_occ
230 if (sys%hm%pcm%run_pcm)
then
234 if (sys%space%is_periodic())
then
235 message(1) =
"Casida oscillator strengths will be incorrect in periodic systems."
256 message(1) =
'Info: Starting Casida linear-response calculation.'
268 call gs_restart%end()
270 message(1) =
"Previous gs calculation is required."
274 cas%el_per_state = sys%st%smear%el_per_state
277 cas%space_dim = sys%space%dim
278 safe_allocate(cas%n_occ(1:sys%st%nik))
279 safe_allocate(cas%n_unocc(1:sys%st%nik))
281 call casida_count_pairs(sys%st, sys%namespace, cas%n_pairs, cas%n_occ, cas%n_unocc, cas%is_included, is_frac_occ)
282 select case (sys%st%d%ispin)
284 write(
message(1),
'(a,i4,a)')
"Info: Found", cas%n_occ(1),
" occupied states."
285 write(
message(2),
'(a,i4,a)')
"Info: Found", cas%n_unocc(1),
" unoccupied states."
288 write(
message(1),
'(a,i4,a)')
"Info: Found", cas%n_occ(1),
" occupied states with spin up."
289 write(
message(2),
'(a,i4,a)')
"Info: Found", cas%n_unocc(1),
" unoccupied states with spin up."
290 write(
message(3),
'(a,i4,a)')
"Info: Found", cas%n_occ(2),
" occupied states with spin down."
291 write(
message(4),
'(a,i4,a)')
"Info: Found", cas%n_unocc(2),
" unoccupied states with spin down."
297 message(1) =
'Info: Setting up Hamiltonian.'
299 call v_ks_h_setup(sys%namespace, sys%space, sys%gr, sys%ions, sys%ext_partners, sys%st, sys%ks, &
300 sys%hm, calc_eigenval=.false.)
341 message(1) =
"Variational and full Casida theory levels do not apply to complex wavefunctions."
348 call parse_variable(sys%namespace,
'EnablePhotons', .false., cas%has_photons)
350 if (cas%has_photons)
then
352 cas%photon_modes => sys%photons%modes
354 write(
message(1),
'(a,i7,a)')
'INFO: Solving Casida equation with ', &
355 cas%photon_modes%nmodes,
' photon modes.'
356 write(
message(2),
'(a)')
'as described in ACS Photonics 2019, 6, 11, 2757-2778.'
358 cas%pt_nmodes = cas%photon_modes%nmodes
373 call parse_variable(sys%namespace,
'CasidaTransitionDensities',
"0", cas%trandens)
375 if (cas%trandens /=
"0")
then
377 sys%outp%how, sys%outp%output_interval)
390 safe_allocate(cas%qvector(1:cas%space_dim))
391 if (
parse_block(sys%namespace,
'CasidaMomentumTransfer', blk) == 0)
then
392 do idir = 1, cas%space_dim
397 message(1) =
"Info: Calculating IXS/EELS transition rates."
413 call parse_variable(sys%namespace,
'CasidaQuadratureOrder', 5, cas%avg_order)
429 call parse_variable(sys%namespace,
'CasidaCalcTriplet', .false., cas%triplet)
431 cas%triplet = .false.
434 if (cas%triplet)
then
435 message(1) =
"Info: Using triplet kernel. Oscillator strengths will be for spin magnetic-dipole field."
448 call parse_variable(sys%namespace,
'CasidaHermitianConjugate', .false., cas%herm_conj)
463 call parse_variable(sys%namespace,
'CasidaDistributedMatrix', .false., cas%distributed_matrix)
464#ifndef HAVE_SCALAPACK
465 if (cas%distributed_matrix)
then
466 message(1) =
"ScaLAPACK layout requested, but code not compiled with ScaLAPACK"
480 call parse_variable(sys%namespace,
'CasidaWriteDistributedMatrix', .false., cas%write_matrix)
481 if (.not. cas%distributed_matrix .and. cas%write_matrix)
then
482 message(1) =
"CasidaWriteDistributedMatrix con only be used with CasidaDistributedMatrix"
500 default_int = solver_elpa
504 call parse_variable(sys%namespace,
'CasidaParallelEigensolver', default_int, cas%parallel_solver)
509 if (cas%distributed_matrix .and. cas%parallel_solver == solver_elpa)
then
510 message(1) =
"ELPA solver requested, but code not compiled with ELPA"
525 call parse_variable(sys%namespace,
'CasidaPrintExcitations',
"all", cas%print_exst)
526 if (cas%distributed_matrix)
then
528 cas%print_exst =
"none"
529 message(1) =
"Using ScaLAPACK layout, thus disabling output of excited states."
530 message(2) =
"This options creates too many files for large Casida matrices."
546 if (cas%weight_thresh >
m_one)
then
547 message(1) =
'Casida coefficients have values between 0 and 1'
548 message(2) =
'Threshold values reset to default value'
550 cas%weight_thresh = -
m_one
560 call parse_variable(sys%namespace,
'CasidaCalcForces', .false., cas%calc_forces)
561 if (cas%calc_forces)
then
571 call parse_variable(sys%namespace,
'CasidaCalcForcesKernel', .
true., cas%calc_forces_kernel)
581 call parse_variable(sys%namespace,
'CasidaCalcForcesSCF', .false., cas%calc_forces_scf)
583 if (cas%distributed_matrix)
then
584 message(1) =
"Info: Forces calculation not compatible with ScaLAPACK layout."
585 message(2) =
"Using normal layout."
587 cas%distributed_matrix = .false.
595 cas%fromScratch = fromscratch
597 if (cas%fromScratch)
then
598 if (cas%triplet)
then
599 call cas%restart_dump%rm(
'kernel_triplet')
601 call cas%restart_dump%rm(
'kernel')
604 if (cas%calc_forces)
then
605 do iatom = 1, sys%ions%natoms
606 do idir = 1, cas%space_dim
607 write(restart_filename,
'(a,i6.6,a,i1)')
'lr_kernel_', iatom,
'_', idir
608 if (cas%triplet) restart_filename = trim(restart_filename)//
'_triplet'
609 call cas%restart_dump%rm(restart_filename)
611 write(restart_filename,
'(a,i6.6,a,i1)')
'lr_hmat1_', iatom,
'_', idir
612 call cas%restart_dump%rm(restart_filename)
619 if (
bitand(theorylevel, casida_eps_diff) /= 0)
then
620 message(1) =
"Info: Approximating resonance energies through KS eigenvalue differences"
622 cas%type = casida_eps_diff
626 if (sys%st%d%ispin /=
spinors)
then
630 message(1) =
"Info: Calculating matrix elements in the Tamm-Dancoff approximation"
638 message(1) =
"Info: Calculating matrix elements with the CV(2)-DFT theory"
645 message(1) =
"Info: Calculating matrix elements with the full Casida method"
654 message(1) =
"Info: Calculating resonance energies via the Petersilka approximation"
671 subroutine casida_count_pairs(st, namespace, n_pairs, n_occ, n_unocc, is_included, is_frac_occ)
674 integer,
intent(out) :: n_pairs
675 integer,
intent(out) :: n_occ(:)
676 integer,
intent(out) :: n_unocc(:)
677 logical,
allocatable,
intent(out) :: is_included(:,:,:)
679 logical,
intent(out) :: is_frac_occ
681 integer :: ik, ist, ast, n_filled, n_partially_filled, n_half_filled
682 character(len=80) :: nst_string, default, wfn_list
683 real(real64) :: energy_window
684 real(real64) :: fdiff, delta_e
685 real(real64) :: fdiff_tol
686 real(real64) :: delta_e_tol
690 is_frac_occ = .false.
692 call occupied_states(st, namespace, ik, n_filled, n_partially_filled, n_half_filled)
693 if (n_partially_filled > 0 .or. n_half_filled > 0) is_frac_occ = .
true.
694 n_occ(ik) = n_filled + n_partially_filled + n_half_filled
695 n_unocc(ik) = st%nst - n_filled
718 call parse_variable(namespace,
'CasidaThresholdOccupation', 1.0e-12_real64, fdiff_tol)
751 safe_allocate(is_included(st%nst, st%nst , st%nik))
752 is_included(:,:,:) = .false.
754 if (energy_window <
m_zero)
then
755 write(nst_string,
'(i6)') st%nst
756 write(default,
'(a,a)')
"1-", trim(adjustl(nst_string))
757 call parse_variable(namespace,
'CasidaKohnShamStates', default, wfn_list)
759 write(
message(1),
'(a,a)')
"Info: States that form the basis: ", trim(wfn_list)
769 fdiff = st%occ(ist,ik) - st%occ(ast,ik)
770 if (fdiff <= fdiff_tol) cycle
771 n_pairs = n_pairs + 1
772 is_included(ist, ast, ik) = .
true.
779 write(
message(1),
'(a,f12.6,a)')
"Info: including transitions with energy < ", &
788 fdiff = st%occ(ist,ik) - st%occ(ast,ik)
789 if (fdiff <= fdiff_tol) cycle
790 delta_e = st%eigenval(ast, ik) - st%eigenval(ist, ik)
791 if (delta_e <= delta_e_tol) cycle
792 if (delta_e >= energy_window) cycle
793 n_pairs = n_pairs + 1
794 is_included(ist, ast, ik) = .
true.
807 type(
casida_t),
intent(inout) :: cas
810 integer :: ist, ast, jpair, ik, ierr
812 integer :: np, np_rows, np_cols, ii, info
818 cas%kernel_lrc_alpha = sys%ks%xc%lrc%alpha
820 if (cas%distributed_matrix .and. .not. cas%states_are_real)
then
824 write(
message(1),
'(a,i9)')
"Number of occupied-unoccupied pairs: ", cas%n_pairs
827 if (cas%n_pairs < 1)
then
828 message(1) =
"No Casida pairs -- maybe there are no unoccupied states?"
832 if (
mpi_world%is_root())
write(*,
"(1x)")
836 if (cas%parallel_in_eh_pairs)
then
843 if (cas%distributed_matrix .and. .not. cas%parallel_in_eh_pairs)
then
844 message(1) =
"ScaLAPACK layout requested, but 'Other' parallelization strategy not available."
845 message(2) =
"Please set ParOther to use the ScaLAPACK layout."
846 message(3) =
"Continuing without ScaLAPACK layout."
848 cas%distributed_matrix = .false.
852 cas%n = cas%n_pairs + cas%pt_nmodes
855 if (cas%distributed_matrix)
then
859 np = cas%mpi_grp%size
863 if (mod(np, ii) == 0)
then
869 np_rows = np / np_cols
873 cas%block_size = min(64, cas%n / np_rows)
875 cas%block_size = max(5, cas%block_size)
876 write(
message(1),
'(A,I5,A,I5,A,I5,A)')
'Parallel layout: using block size of ',&
877 cas%block_size,
' and a processor grid with ', np_rows,
'x', np_cols, &
878 ' processors (rows x cols)'
884 cas%nb_rows = numroc(cas%n, cas%block_size, cas%proc_grid%myrow, 0, cas%proc_grid%nprow)
885 cas%nb_cols = numroc(cas%n, cas%block_size, cas%proc_grid%mycol, 0, cas%proc_grid%npcol)
888 call descinit(cas%desc(1), cas%n, cas%n, cas%block_size, cas%block_size, 0, 0, &
889 cas%proc_grid%context, cas%nb_rows, info)
898 safe_allocate(cas%pair(1:cas%n))
899 if (cas%states_are_real)
then
900 safe_allocate( cas%dmat(1:cas%nb_rows, 1:cas%nb_cols))
901 safe_allocate( cas%dtm(1:cas%n, 1:cas%space_dim))
904 safe_allocate( cas%zmat(1:cas%nb_rows, 1:cas%nb_cols))
905 safe_allocate( cas%ztm(1:cas%n, 1:cas%space_dim))
907 safe_allocate( cas%f(1:cas%n))
908 safe_allocate( cas%s(1:cas%n_pairs))
909 safe_allocate( cas%w(1:cas%n))
910 safe_allocate( cas%index(1:cas%nst, 1:cas%nst, 1:cas%nik))
911 safe_allocate( cas%ind(1:cas%n))
913 if (cas%calc_forces)
then
914 if (cas%states_are_real)
then
915 safe_allocate(cas%dmat_save(1:cas%n_pairs, 1:cas%n_pairs))
917 safe_allocate(cas%zmat_save(1:cas%n_pairs, 1:cas%n_pairs))
919 safe_allocate(cas%forces(1:cas%space_dim, 1:sys%ions%natoms, 1:cas%n_pairs))
923 safe_allocate( cas%qf (1:cas%n_pairs))
924 safe_allocate( cas%qf_avg(1:cas%n_pairs))
934 if (.not. cas%is_included(ist, ast, ik)) cycle
935 cas%index(ist, ast, ik) = jpair
936 cas%pair(jpair)%i = ist
937 cas%pair(jpair)%a = ast
938 cas%pair(jpair)%kk = ik
943 if (jpair - 1 /= cas%n_pairs)
then
944 message(1) =
"Mismatch in Casida pair counting"
948 if (cas%has_photons)
then
950 do ik = 1, cas%pt_nmodes
951 cas%pair(cas%n_pairs + ik)%i = 1
952 cas%pair(cas%n_pairs + ik)%a = -ik
953 cas%pair(cas%n_pairs + ik)%kk = -ik
957 safe_deallocate_a(cas%is_included)
968 type(
casida_t),
intent(inout) :: cas
972 assert(
allocated(cas%pair))
973 safe_deallocate_a(cas%pair)
974 safe_deallocate_a(cas%index)
975 if (cas%states_are_real)
then
976 safe_deallocate_a(cas%dmat)
977 safe_deallocate_a(cas%dtm)
979 safe_deallocate_a(cas%zmat)
980 safe_deallocate_a(cas%ztm)
982 safe_deallocate_a(cas%s)
983 safe_deallocate_a(cas%f)
984 safe_deallocate_a(cas%w)
985 safe_deallocate_a(cas%ind)
988 safe_deallocate_a(cas%qf)
989 safe_deallocate_a(cas%qf_avg)
992 safe_deallocate_a(cas%n_occ)
993 safe_deallocate_a(cas%n_unocc)
995 if (cas%calc_forces)
then
996 if (cas%states_are_real)
then
997 safe_deallocate_a(cas%dmat_save)
999 safe_deallocate_a(cas%zmat_save)
1001 safe_deallocate_a(cas%forces)
1004 call cas%restart_dump%end()
1005 call cas%restart_load%end()
1007 if (cas%distributed_matrix)
then
1008#ifdef HAVE_SCALAPACK
1013 safe_deallocate_a(cas%qvector)
1024 type(
casida_t),
intent(inout) :: cas
1027 type(
grid_t),
pointer :: gr
1029 real(real64),
allocatable :: rho_spin(:, :)
1030 real(real64),
allocatable :: fxc_spin(:,:,:), fxc_grad(:,:,:,:,:), fxc_grad_spin(:,:,:,:)
1031 character(len=100) :: restart_filename
1036 assert(cas%type >= casida_eps_diff .and. cas%type <=
casida_casida)
1043 if (cas%states_are_real)
then
1058 if (cas%type /= casida_eps_diff .or. cas%calc_forces)
then
1060 safe_allocate(cas%rho(1:gr%np_part, 1:st%d%nspin))
1061 safe_allocate(cas%fxc(1:gr%np, 1:st%d%nspin, 1:st%d%nspin))
1062 cas%gga =
in_family(sys%ks%xc%kernel_family, [xc_family_gga])
1064 safe_allocate(cas%fxc_grad(1:gr%np, 1:gr%der%dim, 1:gr%der%dim, 1:st%d%nspin, 1:st%d%nspin))
1066 safe_allocate(cas%fxc_grad_spin(1:gr%np, 1:gr%der%dim, 1:st%d%nspin, 1:st%d%nspin))
1068 safe_allocate(cas%fxc_grad_spin(0, 0, 0, 0))
1071 safe_allocate(cas%fxc_grad(0, 0, 0, 0, 0))
1072 safe_allocate(cas%fxc_grad_spin(0, 0, 0, 0))
1076 if (cas%triplet)
then
1077 safe_allocate(rho_spin(1:gr%np_part, 1:2))
1078 safe_allocate(fxc_spin(1:gr%np, 1:2, 1:2))
1080 rho_spin(:, 1) =
m_half * cas%rho(:, 1)
1081 rho_spin(:, 2) =
m_half * cas%rho(:, 1)
1084 safe_allocate(fxc_grad(1:gr%np, 1:gr%der%dim, 1:gr%der%dim, 1:2, 1:2))
1085 safe_allocate(fxc_grad_spin(1:gr%np, 1:gr%der%dim, 1:2, 1:2))
1087 cas%fxc_grad(:, :, :, 1, 1) =
m_half * (fxc_grad(:, :, :, 1, 1) - fxc_grad(:, :, :, 1, 2))
1089 safe_deallocate_a(fxc_grad)
1090 safe_deallocate_a(fxc_grad_spin)
1094 cas%fxc(:, 1, 1) =
m_half * (fxc_spin(:, 1, 1) - fxc_spin(:, 1, 2))
1096 safe_deallocate_a(rho_spin)
1097 safe_deallocate_a(fxc_spin)
1100 call xc_get_fxc(sys%ks%xc, gr, sys%namespace, cas%rho, st%d%ispin, cas%fxc, cas%fxc_grad, &
1103 call xc_get_fxc(sys%ks%xc, gr, sys%namespace, cas%rho, st%d%ispin, cas%fxc)
1108 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)
1113 restart_filename =
'kernel'
1114 if (cas%triplet) restart_filename = trim(restart_filename)//
'_triplet'
1116 select case (cas%type)
1117 case (casida_eps_diff)
1120 if (cas%states_are_real)
then
1121 call dcasida_get_matrix(cas, sys%namespace, sys%hm, st, sys%ks, gr, cas%dmat, cas%fxc, &
1122 cas%fxc_grad, cas%fxc_grad_spin, restart_filename)
1125 call zcasida_get_matrix(cas, sys%namespace, sys%hm, st, sys%ks, gr, cas%zmat, cas%fxc, &
1126 cas%fxc_grad, cas%fxc_grad_spin, restart_filename)
1132 if (cas%mpi_grp%is_root() .or. cas%distributed_matrix)
then
1133 if (cas%states_are_real)
then
1140 if (cas%calc_forces)
then
1141 if (cas%states_are_real)
then
1148 if (cas%states_are_real)
then
1155 if (cas%type /= casida_eps_diff .or. cas%calc_forces)
then
1156 safe_deallocate_a(cas%fxc)
1157 safe_deallocate_a(cas%fxc_grad)
1158 safe_deallocate_a(cas%fxc_grad_spin)
1159 safe_deallocate_a(cas%rho)
1170 real(real64),
allocatable :: w(:)
1177 do ia = 1, cas%n_pairs
1178 cas%w(ia) = st%eigenval(cas%pair(ia)%a, cas%pair(ia)%kk) - &
1179 st%eigenval(cas%pair(ia)%i, cas%pair(ia)%kk)
1181 message(1) =
"There is a negative unocc-occ KS eigenvalue difference for"
1182 write(
message(2),
'("states ",I5," and ",I5," of k-point ",I5,".")') cas%pair(ia)%i, cas%pair(ia)%a, cas%pair(ia)%kk
1183 message(3) =
"This indicates an inconsistency between gs, unocc, and/or casida calculations."
1189 safe_allocate(w(1:
size(cas%w)))
1191 call sort(w, cas%ind)
1192 safe_deallocate_a(w)
1194 if (
mpi_world%is_root())
write(*,
"(1x)")
1202 real(real64) function casida_matrix_factor(cas, sys)
1206 push_sub(casida_matrix_factor)
1208 casida_matrix_factor =
m_one
1211 casida_matrix_factor =
m_two * casida_matrix_factor
1215 casida_matrix_factor =
m_two * casida_matrix_factor
1218 pop_sub(casida_matrix_factor)
1225 type(namespace_t),
intent(in) :: namespace
1227 integer :: iunit, ia
1229 if (.not. mpi_world%is_root())
return
1233 call io_mkdir(casida_dir, namespace)
1234 iunit = io_open(casida_dir//
'q'//trim(
theory_name(cas)), namespace, action=
'write')
1235 write(iunit,
'(a1,a14,1x,a24,1x,a24,1x,a10,3es15.8,a2)')
'#',
'E' ,
'|<f|exp(iq.r)|i>|^2', &
1236 '<|<f|exp(iq.r)|i>|^2>',
'; q = (',cas%qvector(1:cas%space_dim),
')'
1237 write(iunit,
'(a1,a14,1x,a24,1x,a24,1x,10x,a15)')
'#', trim(units_abbrev(units_out%energy)), &
1242 if (cas%avg_order == 0)
then
1243 do ia = 1, cas%n_pairs
1244 write(iunit,
'(es15.8,es15.8)') units_from_atomic(units_out%energy, cas%w(cas%ind(ia))), cas%qf(cas%ind(ia))
1247 do ia = 1, cas%n_pairs
1248 write(iunit,
'(3es15.8)') units_from_atomic(units_out%energy, cas%w(cas%ind(ia))), &
1249 cas%qf (cas%ind(ia)), &
1250 cas%qf_avg(cas%ind(ia))
1254 call io_close(iunit)
1261 character(len=80) pure function theory_name(cas)
1264 select case (cas%type)
1283 type(states_elec_t),
intent(in) :: st
1284 integer,
intent(in) :: ia
1285 integer,
intent(in) :: jb
1289 isnt_degenerate = (abs((st%eigenval(cas%pair(ia)%a, cas%pair(ia)%kk) - st%eigenval(cas%pair(ia)%i, cas%pair(ia)%kk)) &
1290 - (st%eigenval(cas%pair(jb)%a, cas%pair(jb)%kk) - st%eigenval(cas%pair(jb)%i, cas%pair(jb)%kk))) > 1e-8_real64)
1297 type(
casida_t),
intent(inout) :: cas
1298 integer,
intent(in) :: jb_local
1300 if (.not. cas%distributed_matrix)
then
1303#ifdef HAVE_SCALAPACK
1304 jb = indxl2g(jb_local, cas%block_size, cas%proc_grid%myrow, 0, cas%proc_grid%nprow)
1311 type(
casida_t),
intent(inout) :: cas
1312 integer,
intent(in) :: ia_local
1314 if (.not. cas%distributed_matrix)
then
1317#ifdef HAVE_SCALAPACK
1318 ia = indxl2g(ia_local, cas%block_size, cas%proc_grid%mycol, 0, cas%proc_grid%npcol)
1323 subroutine local_indices(cas, ia, jb, on_this_processor, ia_local, jb_local)
1326 integer,
intent(in) :: ia, jb
1327 logical,
intent(out) :: on_this_processor
1328 integer,
intent(out) :: ia_local, jb_local
1329#ifdef HAVE_SCALAPACK
1330 integer :: ia_proc, jb_proc
1333 if (.not. cas%distributed_matrix)
then
1334 on_this_processor = .
true.
1338#ifdef HAVE_SCALAPACK
1339 ia_proc = indxg2p(ia, cas%block_size, cas%proc_grid%mycol, 0, cas%proc_grid%npcol)
1340 jb_proc = indxg2p(jb, cas%block_size, cas%proc_grid%myrow, 0, cas%proc_grid%nprow)
1341 if (cas%proc_grid%mycol == ia_proc .and. cas%proc_grid%myrow == jb_proc)
then
1343 ia_local = indxg2l(ia, cas%block_size, cas%proc_grid%mycol, 0, cas%proc_grid%npcol)
1344 jb_local = indxg2l(jb, cas%block_size, cas%proc_grid%myrow, 0, cas%proc_grid%nprow)
1346 on_this_processor = .false.
1356#include "casida_inc.F90"
1358#include "complex.F90"
1359#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)
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 dcasida_get_matrix(cas, namespace, hm, st, ks, gr, matrix, fxc, fxc_grad, fxc_grad_spin, restart_file, is_forces)
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....
subroutine zcasida_get_matrix(cas, namespace, hm, st, ks, gr, matrix, fxc, fxc_grad, fxc_grad_spin, restart_file, is_forces)
integer, parameter casida_variational
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.
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.