46  use, 
intrinsic :: iso_fortran_env
 
   92  integer, 
parameter ::      &
 
   93    CASIDA_EPS_DIFF     = 1, &
 
   99  integer, 
parameter ::      &
 
  109    logical              :: states_are_real
 
  110    integer, 
allocatable :: n_occ(:)
 
  111    integer, 
allocatable :: n_unocc(:)
 
  115    integer              :: el_per_state
 
  116    character(len=80)    :: trandens
 
  117    character(len=80)    :: print_exst
 
  118    real(real64)         :: weight_thresh
 
  120    logical              :: calc_forces
 
  121    logical              :: calc_forces_kernel
 
  122    logical              :: calc_forces_scf
 
  124    type(restart_t)      :: restart_load
 
  125    type(restart_t)      :: restart_dump
 
  127    logical, 
allocatable :: is_included(:,:,:)
 
  129    type(states_pair_t), 
allocatable :: pair(:)
 
  130    integer, 
allocatable :: index(:,:,:)
 
  131    integer, 
allocatable :: ind(:)
 
  133    real(real64), 
allocatable   :: dmat(:,:)
 
  134    real(real64), 
allocatable   :: dmat_save(:,:)
 
  135    complex(real64), 
allocatable   :: zmat(:,:)
 
  136    complex(real64), 
allocatable   :: zmat_save(:,:)
 
  137    real(real64), 
allocatable   :: w(:)
 
  138    real(real64), 
allocatable   :: dtm(:, :)
 
  139    complex(real64), 
allocatable   :: ztm(:, :)
 
  140    real(real64), 
allocatable   :: f(:)
 
  141    real(real64), 
allocatable   :: s(:)
 
  143    real(real64), 
allocatable   :: rho(:,:)
 
  144    real(real64), 
allocatable   :: fxc(:,:,:)
 
  145    real(real64)         :: kernel_lrc_alpha
 
  147    real(real64), 
allocatable   :: dmat2(:,:)
 
  148    complex(real64), 
allocatable   :: zmat2(:,:)
 
  149    real(real64), 
allocatable   :: dlr_hmat2(:,:)
 
  150    complex(real64), 
allocatable   :: zlr_hmat2(:,:)
 
  151    real(real64), 
allocatable   :: forces(:,:,:)
 
  152    real(real64), 
allocatable   :: dw2(:)
 
  153    real(real64), 
allocatable   :: zw2(:)
 
  157    real(real64), 
allocatable   :: qvector(:)
 
  158    real(real64), 
allocatable   :: qf(:)
 
  159    real(real64), 
allocatable   :: qf_avg(:)
 
  162    logical              :: parallel_in_eh_pairs
 
  163    logical              :: parallel_in_domains
 
  164    logical              :: distributed_matrix
 
  165    logical              :: write_matrix
 
  166    integer              :: parallel_solver
 
  167    type(mpi_grp_t)      :: mpi_grp
 
  168    logical              :: fromScratch
 
  169    logical              :: has_photons
 
  171    type(photon_mode_t), 
pointer  :: photon_modes => null()
 
  173    integer              :: n, nb_rows, nb_cols, block_size
 
  174    type(blacs_proc_grid_t) :: proc_grid
 
  175    integer              :: desc(BLACS_DLEN)
 
  176    type(MPI_Datatype)   :: darray
 
  184    real(real64), 
allocatable :: dpot(:)
 
  185    complex(real64), 
allocatable :: zpot(:)
 
  220    class(*),        
intent(inout) :: system
 
  221    logical,         
intent(in)    :: from_scratch
 
  227      message(1) = 
"CalculationMode = casida not implemented for multi-system calculations" 
  239    logical,           
intent(in)    :: fromscratch
 
  243    integer :: idir, theorylevel, iatom, ierr, default_int
 
  244    character(len=100) :: restart_filename
 
  245    logical :: is_frac_occ
 
  251    if (sys%hm%pcm%run_pcm) 
then 
  255    if (sys%space%is_periodic()) 
then 
  256      message(1) = 
"Casida oscillator strengths will be incorrect in periodic systems." 
  277    message(1) = 
'Info: Starting Casida linear-response calculation.' 
  285      message(1) = 
"Previous gs calculation is required." 
  289    cas%el_per_state = sys%st%smear%el_per_state
 
  292    cas%space_dim = sys%space%dim
 
  293    safe_allocate(cas%n_occ(1:sys%st%nik))
 
  294    safe_allocate(cas%n_unocc(1:sys%st%nik))
 
  296    call states_elec_count_pairs(sys%st, sys%namespace, cas%n_pairs, cas%n_occ, cas%n_unocc, cas%is_included, is_frac_occ)
 
  297    if (is_frac_occ) 
then 
  302    select case (sys%st%d%ispin)
 
  304      write(
message(1),
'(a,i4,a)') 
"Info: Found", cas%n_occ(1), 
" occupied states." 
  305      write(
message(2),
'(a,i4,a)') 
"Info: Found", cas%n_unocc(1), 
" unoccupied states." 
  308      write(
message(1),
'(a,i4,a)') 
"Info: Found", cas%n_occ(1), 
" occupied states with spin up." 
  309      write(
message(2),
'(a,i4,a)') 
"Info: Found", cas%n_unocc(1), 
" unoccupied states with spin up." 
  310      write(
message(3),
'(a,i4,a)') 
"Info: Found", cas%n_occ(2), 
" occupied states with spin down." 
  311      write(
message(4),
'(a,i4,a)') 
"Info: Found", cas%n_unocc(2), 
" unoccupied states with spin down." 
  317    message(1) = 
'Info: Setting up Hamiltonian.' 
  319    call v_ks_h_setup(sys%namespace, sys%space, sys%gr, sys%ions, sys%ext_partners, sys%st, sys%ks, &
 
  320      sys%hm, calc_eigenval=.false.)
 
  361        message(1) = 
"Variational and full Casida theory levels do not apply to complex wavefunctions." 
  368    call parse_variable(sys%namespace, 
'EnablePhotons', .false., cas%has_photons)
 
  370    if (cas%has_photons) 
then 
  372      cas%photon_modes => sys%photons%modes
 
  374      write(
message(1), 
'(a,i7,a)') 
'INFO: Solving Casida equation with ', &
 
  375        cas%photon_modes%nmodes, 
' photon modes.' 
  376      write(
message(2), 
'(a)') 
'as described in ACS Photonics 2019, 6, 11, 2757-2778.' 
  378      cas%pt_nmodes = cas%photon_modes%nmodes
 
  393    call parse_variable(sys%namespace, 
'CasidaTransitionDensities', 
"0", cas%trandens)
 
  395    if (cas%trandens /= 
"0") 
then 
  397        sys%outp%how, sys%outp%output_interval)
 
  410    safe_allocate(cas%qvector(1:cas%space_dim))
 
  411    if (
parse_block(sys%namespace, 
'CasidaMomentumTransfer', blk) == 0) 
then 
  412      do idir = 1, cas%space_dim
 
  418      message(1) = 
"Info: Calculating IXS/EELS transition rates." 
  434      call parse_variable(sys%namespace, 
'CasidaQuadratureOrder', 5, cas%avg_order)
 
  450      call parse_variable(sys%namespace, 
'CasidaCalcTriplet', .false., cas%triplet)
 
  452      cas%triplet = .false.
 
  455    if (cas%triplet) 
then 
  456      message(1) = 
"Info: Using triplet kernel. Oscillator strengths will be for spin magnetic-dipole field." 
  469    call parse_variable(sys%namespace, 
'CasidaHermitianConjugate', .false., cas%herm_conj)
 
  484    call parse_variable(sys%namespace, 
'CasidaDistributedMatrix', .false., cas%distributed_matrix)
 
  485#ifndef HAVE_SCALAPACK 
  486    if (cas%distributed_matrix) 
then 
  487      message(1) = 
"ScaLAPACK layout requested, but code not compiled with ScaLAPACK" 
  501    call parse_variable(sys%namespace, 
'CasidaWriteDistributedMatrix', .false., cas%write_matrix)
 
  502    if (.not. cas%distributed_matrix .and. cas%write_matrix) 
then 
  503      message(1) = 
"CasidaWriteDistributedMatrix con only be used with CasidaDistributedMatrix" 
  521    default_int = solver_elpa
 
  525    call parse_variable(sys%namespace, 
'CasidaParallelEigensolver', default_int, cas%parallel_solver)
 
  530    if (cas%distributed_matrix .and. cas%parallel_solver == solver_elpa) 
then 
  531      message(1) = 
"ELPA solver requested, but code not compiled with ELPA" 
  546    call parse_variable(sys%namespace, 
'CasidaPrintExcitations', 
"all", cas%print_exst)
 
  547    if (cas%distributed_matrix) 
then 
  549      cas%print_exst = 
"none" 
  550      message(1) = 
"Using ScaLAPACK layout, thus disabling output of excited states." 
  551      message(2) = 
"This options creates too many files for large Casida matrices." 
  567    if (cas%weight_thresh > 
m_one) 
then 
  568      message(1) = 
'Casida coefficients have values between 0 and 1' 
  569      message(2) = 
'Threshold values reset to default value' 
  571      cas%weight_thresh = -
m_one 
  581    call parse_variable(sys%namespace, 
'CasidaCalcForces', .false., cas%calc_forces)
 
  582    if (cas%calc_forces) 
then 
  592      call parse_variable(sys%namespace, 
'CasidaCalcForcesKernel', .
true., cas%calc_forces_kernel)
 
  602      call parse_variable(sys%namespace, 
'CasidaCalcForcesSCF', .false., cas%calc_forces_scf)
 
  604      if (cas%distributed_matrix) 
then 
  605        message(1) = 
"Info: Forces calculation not compatible with ScaLAPACK layout." 
  606        message(2) = 
"Using normal layout." 
  608        cas%distributed_matrix = .false.
 
  615    cas%fromScratch = fromscratch
 
  617    if (cas%fromScratch) 
then  
  618      if (cas%triplet) 
then 
  619        call restart_rm(cas%restart_dump, 
'kernel_triplet')
 
  624      if (cas%calc_forces) 
then 
  625        do iatom = 1, sys%ions%natoms
 
  626          do idir = 1, cas%space_dim
 
  627            write(restart_filename,
'(a,i6.6,a,i1)') 
'lr_kernel_', iatom, 
'_', idir
 
  628            if (cas%triplet) restart_filename = trim(restart_filename)//
'_triplet' 
  629            call restart_rm(cas%restart_dump, restart_filename)
 
  631            write(restart_filename,
'(a,i6.6,a,i1)') 
'lr_hmat1_', iatom, 
'_', idir
 
  632            call restart_rm(cas%restart_dump, restart_filename)
 
  639    if (
bitand(theorylevel, casida_eps_diff) /= 0) 
then 
  640      message(1) = 
"Info: Approximating resonance energies through KS eigenvalue differences" 
  642      cas%type = casida_eps_diff
 
  646    if (sys%st%d%ispin /= 
spinors) 
then 
  650        message(1) = 
"Info: Calculating matrix elements in the Tamm-Dancoff approximation" 
  658        message(1) = 
"Info: Calculating matrix elements with the CV(2)-DFT theory" 
  665        message(1) = 
"Info: Calculating matrix elements with the full Casida method" 
  674        message(1) = 
"Info: Calculating resonance energies via the Petersilka approximation" 
  691    type(
casida_t),      
intent(inout) :: cas
 
  694    integer :: ist, ast, jpair, ik, ierr
 
  696    integer :: np, np_rows, np_cols, ii, info
 
  701    cas%kernel_lrc_alpha = sys%ks%xc%kernel_lrc_alpha
 
  703    if (cas%distributed_matrix .and. .not. cas%states_are_real) 
then 
  707    write(
message(1), 
'(a,i9)') 
"Number of occupied-unoccupied pairs: ", cas%n_pairs
 
  710    if (cas%n_pairs < 1) 
then 
  711      message(1) = 
"No Casida pairs -- maybe there are no unoccupied states?" 
  719    if (cas%parallel_in_eh_pairs) 
then 
  726    if (cas%distributed_matrix .and. .not. cas%parallel_in_eh_pairs) 
then 
  727      message(1) = 
"ScaLAPACK layout requested, but 'Other' parallelization strategy not available." 
  728      message(2) = 
"Please set ParOther to use the ScaLAPACK layout." 
  729      message(3) = 
"Continuing without ScaLAPACK layout." 
  731      cas%distributed_matrix = .false.
 
  735    cas%n = cas%n_pairs + cas%pt_nmodes
 
  738    if (cas%distributed_matrix) 
then 
  742      np = cas%mpi_grp%size
 
  746          if (mod(np, ii) == 0) 
then 
  752      np_rows = np / np_cols
 
  756      cas%block_size = min(64, cas%n / np_rows)
 
  758      cas%block_size = max(5, cas%block_size)
 
  759      write(
message(1), 
'(A,I5,A,I5,A,I5,A)') 
'Parallel layout: using block size of ',&
 
  760        cas%block_size, 
' and a processor grid with ', np_rows, 
'x', np_cols, &
 
  761        ' processors (rows x cols)' 
  767      cas%nb_rows = numroc(cas%n, cas%block_size, cas%proc_grid%myrow, 0, cas%proc_grid%nprow)
 
  768      cas%nb_cols = numroc(cas%n, cas%block_size, cas%proc_grid%mycol, 0, cas%proc_grid%npcol)
 
  771      call descinit(cas%desc(1), cas%n, cas%n, cas%block_size, cas%block_size, 0, 0, &
 
  772        cas%proc_grid%context, cas%nb_rows, info)
 
  782    safe_allocate(cas%pair(1:cas%n))
 
  783    if (cas%states_are_real) 
then 
  784      safe_allocate( cas%dmat(1:cas%nb_rows, 1:cas%nb_cols))
 
  785      safe_allocate(  cas%dtm(1:cas%n, 1:cas%space_dim))
 
  788      safe_allocate( cas%zmat(1:cas%nb_rows, 1:cas%nb_cols))
 
  789      safe_allocate(  cas%ztm(1:cas%n, 1:cas%space_dim))
 
  791    safe_allocate(   cas%f(1:cas%n))
 
  792    safe_allocate(   cas%s(1:cas%n_pairs))
 
  793    safe_allocate(   cas%w(1:cas%n))
 
  794    safe_allocate( cas%index(1:maxval(cas%n_occ), cas%nst - maxval(cas%n_unocc) + 1:cas%nst, 1:cas%nik))
 
  795    safe_allocate( cas%ind(1:cas%n))
 
  797    if (cas%calc_forces) 
then 
  798      if (cas%states_are_real) 
then 
  799        safe_allocate(cas%dmat_save(1:cas%n_pairs, 1:cas%n_pairs))
 
  801        safe_allocate(cas%zmat_save(1:cas%n_pairs, 1:cas%n_pairs))
 
  803      safe_allocate(cas%forces(1:cas%space_dim, 1:sys%ions%natoms, 1:cas%n_pairs))
 
  807      safe_allocate( cas%qf    (1:cas%n_pairs))
 
  808      safe_allocate( cas%qf_avg(1:cas%n_pairs))
 
  816      do ast = cas%n_occ(ik) + 1, cas%nst
 
  817        do ist = 1, cas%n_occ(ik)
 
  818          if (cas%is_included(ist, ast, ik)) 
then 
  819            cas%index(ist, ast, ik) = jpair
 
  820            cas%pair(jpair)%i = ist
 
  821            cas%pair(jpair)%a = ast
 
  822            cas%pair(jpair)%kk = ik
 
  829    if (cas%has_photons) 
then 
  831      do ik = 1, cas%pt_nmodes
 
  832        cas%pair(cas%n_pairs + ik)%i = 1
 
  833        cas%pair(cas%n_pairs + ik)%a = -ik
 
  834        cas%pair(cas%n_pairs + ik)%kk = -ik
 
  838    safe_deallocate_a(cas%is_included)
 
  849    type(
casida_t), 
intent(inout) :: cas
 
  853    assert(
allocated(cas%pair))
 
  854    safe_deallocate_a(cas%pair)
 
  855    safe_deallocate_a(cas%index)
 
  856    if (cas%states_are_real) 
then 
  857      safe_deallocate_a(cas%dmat)
 
  858      safe_deallocate_a(cas%dtm)
 
  860      safe_deallocate_a(cas%zmat)
 
  861      safe_deallocate_a(cas%ztm)
 
  863    safe_deallocate_a(cas%s)
 
  864    safe_deallocate_a(cas%f)
 
  865    safe_deallocate_a(cas%w)
 
  866    safe_deallocate_a(cas%ind)
 
  869      safe_deallocate_a(cas%qf)
 
  870      safe_deallocate_a(cas%qf_avg)
 
  873    safe_deallocate_a(cas%n_occ)
 
  874    safe_deallocate_a(cas%n_unocc)
 
  876    if (cas%calc_forces) 
then 
  877      if (cas%states_are_real) 
then 
  878        safe_deallocate_a(cas%dmat_save)
 
  880        safe_deallocate_a(cas%zmat_save)
 
  882      safe_deallocate_a(cas%forces)
 
  888    if (cas%distributed_matrix) 
then 
  894    safe_deallocate_a(cas%qvector)
 
  905    type(
casida_t),              
intent(inout) :: cas
 
  908    class(
mesh_t),   
pointer :: mesh
 
  910    real(real64), 
allocatable :: rho_spin(:, :)
 
  911    real(real64), 
allocatable :: fxc_spin(:,:,:)
 
  912    character(len=100) :: restart_filename
 
  917    assert(cas%type >= casida_eps_diff .and. cas%type <= 
casida_casida)
 
  924    if (cas%states_are_real) 
then 
  939    if (cas%type /= casida_eps_diff .or. cas%calc_forces) 
then 
  941      safe_allocate(cas%rho(1:mesh%np, 1:st%d%nspin))
 
  942      safe_allocate(cas%fxc(1:mesh%np, 1:st%d%nspin, 1:st%d%nspin))
 
  946      if (cas%triplet) 
then 
  947        safe_allocate(rho_spin(1:mesh%np, 1:2))
 
  948        safe_allocate(fxc_spin(1:mesh%np, 1:2, 1:2))
 
  951        rho_spin(:, 1) = 
m_half * cas%rho(:, 1)
 
  952        rho_spin(:, 2) = 
m_half * cas%rho(:, 1)
 
  955        cas%fxc(:, 1, 1) = 
m_half * (fxc_spin(:, 1, 1) - fxc_spin(:, 1, 2))
 
  957        safe_deallocate_a(rho_spin)
 
  958        safe_deallocate_a(fxc_spin)
 
  960        call xc_get_fxc(sys%ks%xc, mesh, sys%namespace, cas%rho, st%d%ispin, cas%fxc)
 
  969    restart_filename = 
'kernel' 
  970    if (cas%triplet) restart_filename = trim(restart_filename)//
'_triplet' 
  972    select case (cas%type)
 
  973    case (casida_eps_diff)
 
  976      if (cas%states_are_real) 
then 
  977        call dcasida_get_matrix(cas, sys%namespace, sys%hm, st, sys%ks, mesh, cas%dmat, cas%fxc, restart_filename)
 
  980        call zcasida_get_matrix(cas, sys%namespace, sys%hm, st, sys%ks, mesh, cas%zmat, cas%fxc, restart_filename)
 
  987      if (cas%states_are_real) 
then 
  994    if (cas%calc_forces) 
then 
  995      if (cas%states_are_real) 
then 
 1002    if (cas%states_are_real) 
then 
 1009    if (cas%type /= casida_eps_diff .or. cas%calc_forces) 
then 
 1010      safe_deallocate_a(cas%fxc)
 
 1011      safe_deallocate_a(cas%rho)
 
 1022      real(real64), 
allocatable :: w(:)
 
 1029      do ia = 1, cas%n_pairs
 
 1030        cas%w(ia) = st%eigenval(cas%pair(ia)%a, cas%pair(ia)%kk) - &
 
 1031          st%eigenval(cas%pair(ia)%i, cas%pair(ia)%kk)
 
 1033          message(1) = 
"There is a negative unocc-occ KS eigenvalue difference for" 
 1034          write(
message(2),
'("states ",I5," and ",I5," of k-point ",I5,".")') cas%pair(ia)%i, cas%pair(ia)%a, cas%pair(ia)%kk
 
 1035          message(3) = 
"This indicates an inconsistency between gs, unocc, and/or casida calculations." 
 1041      safe_allocate(w(1:cas%n_pairs))
 
 1043      call sort(w, cas%ind)
 
 1044      safe_deallocate_a(w)
 
 1054      type(
v_ks_t),        
intent(in)    :: ks
 
 1056      type(
mesh_t),        
intent(in)    :: mesh
 
 1057      type(
casida_t),      
intent(inout) :: cas
 
 1059      real(real64), 
allocatable :: rho(:, :)
 
 1060      real(real64), 
allocatable :: fxc_sic(:,:,:)
 
 1066        message(1) = 
"Casida calculation with ADSIC not implemented for spin-polarized calculations." 
 1069      if (cas%triplet) 
then 
 1070        message(1) = 
"Casida calculation with ADSIC not implemented for triplet excitations." 
 1074      safe_allocate(fxc_sic(1:mesh%np, 1:st%d%nspin, 1:st%d%nspin))
 
 1075      safe_allocate(rho(1:mesh%np, 1:st%d%nspin))
 
 1077      rho = cas%rho/st%qtot
 
 1079      call xc_get_fxc(ks%xc, mesh, namespace, rho, 1, fxc_sic)
 
 1081      cas%fxc = cas%fxc - fxc_sic/st%qtot
 
 1083      safe_deallocate_a(rho)
 
 1084      safe_deallocate_a(fxc_sic)
 
 1092  real(real64) function casida_matrix_factor(cas, sys)
 
 1096    push_sub(casida_matrix_factor)
 
 1098    casida_matrix_factor = 
m_one 
 1101      casida_matrix_factor = 
m_two * casida_matrix_factor
 
 1105      casida_matrix_factor = 
m_two * casida_matrix_factor
 
 1108    pop_sub(casida_matrix_factor)
 
 1115    type(namespace_t), 
intent(in) :: namespace
 
 1117    integer :: iunit, ia
 
 1119    if (.not. mpi_grp_is_root(mpi_world)) 
return 
 1123    call io_mkdir(casida_dir, namespace)
 
 1124    iunit = io_open(casida_dir//
'q'//trim(
theory_name(cas)), namespace, action=
'write')
 
 1125    write(iunit, 
'(a1,a14,1x,a24,1x,a24,1x,a10,3es15.8,a2)') 
'#',
'E' , 
'|<f|exp(iq.r)|i>|^2', &
 
 1126      '<|<f|exp(iq.r)|i>|^2>',
'; q = (',cas%qvector(1:cas%space_dim),
')' 
 1127    write(iunit, 
'(a1,a14,1x,a24,1x,a24,1x,10x,a15)')        
'#', trim(units_abbrev(units_out%energy)), &
 
 1132    if (cas%avg_order == 0) 
then 
 1133      do ia = 1, cas%n_pairs
 
 1134        write(iunit, 
'(es15.8,es15.8)') units_from_atomic(units_out%energy, cas%w(cas%ind(ia))), cas%qf(cas%ind(ia))
 
 1137      do ia = 1, cas%n_pairs
 
 1138        write(iunit, 
'(3es15.8)') units_from_atomic(units_out%energy, cas%w(cas%ind(ia))), &
 
 1139          cas%qf    (cas%ind(ia)), &
 
 1140          cas%qf_avg(cas%ind(ia))
 
 1144    call io_close(iunit)
 
 1151  character(len=80) pure function theory_name(cas)
 
 1154    select case (cas%type)
 
 1173    type(states_elec_t), 
intent(in) :: st
 
 1174    integer,             
intent(in) :: ia
 
 1175    integer,             
intent(in) :: jb
 
 1179    isnt_degenerate = (abs((st%eigenval(cas%pair(ia)%a, cas%pair(ia)%kk) - st%eigenval(cas%pair(ia)%i, cas%pair(ia)%kk)) &
 
 1180      - (st%eigenval(cas%pair(jb)%a, cas%pair(jb)%kk) - st%eigenval(cas%pair(jb)%i, cas%pair(jb)%kk))) > 1e-8_real64)
 
 1187    type(
casida_t), 
intent(inout) :: cas
 
 1188    integer, 
intent(in) :: jb_local
 
 1190    if (.not. cas%distributed_matrix) 
then 
 1193#ifdef HAVE_SCALAPACK 
 1194      jb = indxl2g(jb_local, cas%block_size, cas%proc_grid%myrow, 0, cas%proc_grid%nprow)
 
 1201    type(
casida_t), 
intent(inout) :: cas
 
 1202    integer, 
intent(in) :: ia_local
 
 1204    if (.not. cas%distributed_matrix) 
then 
 1207#ifdef HAVE_SCALAPACK 
 1208      ia = indxl2g(ia_local, cas%block_size, cas%proc_grid%mycol, 0, cas%proc_grid%npcol)
 
 1213  subroutine local_indices(cas, ia, jb, on_this_processor, ia_local, jb_local)
 
 1216    integer, 
intent(in) :: ia, jb
 
 1217    logical, 
intent(out) :: on_this_processor
 
 1218    integer, 
intent(out) :: ia_local, jb_local
 
 1219#ifdef HAVE_SCALAPACK 
 1220    integer :: ia_proc, jb_proc
 
 1223    if (.not. cas%distributed_matrix) 
then 
 1224      on_this_processor = .
true.
 
 1228#ifdef HAVE_SCALAPACK 
 1229      ia_proc = indxg2p(ia, cas%block_size, cas%proc_grid%mycol, 0, cas%proc_grid%npcol)
 
 1230      jb_proc = indxg2p(jb, cas%block_size, cas%proc_grid%myrow, 0, cas%proc_grid%nprow)
 
 1231      if (cas%proc_grid%mycol == ia_proc .and. cas%proc_grid%myrow == jb_proc) 
then 
 1232        on_this_processor = .
true.
 
 1233        ia_local = indxg2l(ia, cas%block_size, cas%proc_grid%mycol, 0, cas%proc_grid%npcol)
 
 1234        jb_local = indxg2l(jb, cas%block_size, cas%proc_grid%myrow, 0, cas%proc_grid%nprow)
 
 1236        on_this_processor = .false.
 
 1246#include "casida_inc.F90" 
 1248#include "complex.F90" 
 1249#include "casida_inc.F90" 
subroutine fxc_add_adsic(namespace, ks, st, mesh, cas)
 
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_kpoints
parallelization in k-points
 
integer, parameter, public p_strategy_other
something else like e-h pairs
 
integer, parameter, public p_strategy_domains
parallelization in domains
 
type(calc_mode_par_t), public calc_mode_par
Singleton instance of parallel calculation mode.
 
This module implements the Casida equations for excited states.
 
integer function get_global_col(cas, ia_local)
 
integer, parameter solver_scalapack
 
subroutine zoscillator_strengths(cas, mesh, st)
 
integer, parameter casida_petersilka
 
subroutine, public casida_run_init()
 
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 zcasida_forces(cas, sys, mesh, st)
 
subroutine dcasida_forces(cas, sys, mesh, 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 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 zcasida_get_matrix(cas, namespace, hm, st, ks, mesh, matrix, xc, restart_file, is_forces)
 
subroutine casida_run_legacy(sys, fromScratch)
 
subroutine dcasida_get_matrix(cas, namespace, hm, st, ks, mesh, matrix, xc, restart_file, is_forces)
 
integer, parameter casida_tamm_dancoff
 
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.
 
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
 
real(real64), parameter, public m_epsilon
 
real(real64), parameter, public m_half
 
real(real64), parameter, public m_one
 
integer, parameter, public generalized_kohn_sham_dft
 
integer, parameter, public hartree_fock
 
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)
 
integer, parameter, public dft_u_none
 
This module defines various routines, operating on mesh functions.
 
This module defines the meshes, which are used in Octopus.
 
subroutine, public messages_not_implemented(feature, namespace)
 
subroutine, public messages_warning(no_lines, all_nodes, namespace)
 
subroutine, public messages_obsolete_variable(namespace, name, rep)
 
subroutine, public messages_info(no_lines, iunit, verbose_limit, stress, 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_experimental(name, namespace)
 
logical function mpi_grp_is_root(grp)
 
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
 
subroutine, public restart_rm(restart, name)
Remove directory or file "name" that is located inside the current restart directory.
 
integer, parameter, public restart_gs
 
subroutine, public restart_init(restart, namespace, data_type, type, mc, ierr, mesh, dir, exact)
Initializes a restart object.
 
integer, parameter, public restart_type_dump
 
integer, parameter, public restart_type_load
 
subroutine, public restart_end(restart)
 
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 states_elec_count_pairs(st, namespace, n_pairs, n_occ, n_unocc, is_included, is_frac_occ)
number of occupied-unoccupied pairs for Casida
 
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, is_complex, packed)
 
brief This module defines the class unit_t which is used by the unit_systems_oct_m module.
 
This module defines the unit system, used for input and output.
 
type(unit_system_t), public units_inp
the units systems for reading and writing
 
type(unit_t), public unit_one
some special units required for particular quantities
 
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, mesh, namespace, rho, ispin, fxc, zfxc)
 
logical pure function, public family_is_mgga_with_exc(xcs)
Is the xc function part of the mGGA family with an energy functional.
 
integer, parameter, public sic_adsic
Averaged density SIC.
 
This class contains all parameters, needed for Casida calculations.
 
Class describing the electron system.
 
Describes mesh distribution to nodes.
 
Container class for lists of system_oct_m::system_t.
 
The states_elec_t class contains all electronic wave functions.