32 use,
intrinsic :: iso_fortran_env
101 real(real64),
allocatable :: dmatrix(:, :)
102 complex(real64),
allocatable :: zmatrix(:, :)
109 type(states_elec_t),
intent(inout) :: st
110 class(space_t),
intent(in) :: space
111 type(grid_t),
intent(in) :: gr
112 type(lr_t),
intent(inout) :: lr
113 type(lr_t),
optional,
intent(inout) :: lr_m
115 integer :: idir, ist, ispin, idim, ndim, np
117 complex(real64),
allocatable :: psi(:, :), gpsi(:,:), gdl_psi(:,:), gdl_psi_m(:,:)
121 if (.not.
allocated(lr%dl_j))
then
122 safe_allocate(lr%dl_j(1:gr%np, 1:space%dim, 1:st%d%nspin))
125 assert(
allocated(lr%zdl_psi))
130 safe_allocate(psi(1:gr%np_part, 1:ndim))
131 safe_allocate(gpsi(1:np, 1:ndim))
132 safe_allocate(gdl_psi(1:np, 1:ndim))
133 if (
present(lr_m))
then
134 safe_allocate(gdl_psi_m(1:np, 1:ndim))
139 do ispin = 1, st%d%nspin
144 do idim = 1, st%d%dim
149 if (
present(lr_m))
then
153 do idir = 1, space%dim
155 lr%dl_j(1:np, idir, ispin) = lr%dl_j(1:np, idir, ispin) + ( &
156 + conjg(psi(1:np, idim))*gdl_psi(1:np, idir) &
157 - psi(1:np, idim)*conjg(gdl_psi_m(1:np, idir)) &
158 + conjg(lr_m%zdl_psi(1:np, idim, ist, ispin)) * gpsi(1:np, idir) &
159 - lr%zdl_psi (1:np, idim, ist, ispin) * conjg(gpsi(1:np, idir)) &
165 do idir = 1, space%dim
167 lr%dl_j(1:np, idir, ispin) = lr%dl_j(1:np, idir, ispin) + ( &
168 + conjg(psi(1:np, idim))*gdl_psi(1:np, idir) &
169 - psi(1:np, idim)*conjg(gdl_psi(1:np, idir)) &
170 + conjg(lr%zdl_psi(1:np, idim, ist, ispin)) * gpsi(1:np, idir) &
171 - lr%zdl_psi(1:np, idim, ist, ispin) * conjg(gpsi(1:np, idir)) &
182 safe_deallocate_a(psi)
183 safe_deallocate_a(gpsi)
184 safe_deallocate_a(gdl_psi)
185 if (
present(lr_m))
then
186 safe_deallocate_a(gdl_psi_m)
195 character(len=12) function freq2str(freq)
result(str)
196 real(real64),
intent(in) :: freq
203 write(str,
'(f11.4)') freq
205 if (abs(freq) <
m_one)
then
206 if (freq >=
m_zero .and. str(1:1) /=
'0') str =
"0"//trim(str)
207 if (freq <
m_zero .and. str(2:2) /=
'0') str =
"-0"//trim(str(2:))
209 str = trim(adjustl(str))
217 character(len=100) function em_rho_tag(freq, dir, dir2, ipert)
result(str)
218 real(real64),
intent(in) :: freq
219 integer,
intent(in) :: dir
220 integer,
optional,
intent(in) :: dir2
221 integer,
optional,
intent(in) :: ipert
223 character(len=12) :: str_tmp
230 write(str,
'(3a,i1)')
'rho_', trim(str_tmp),
'_', dir
231 if (
present(dir2))
write(str,
'(2a,i1)') trim(str),
"_", dir2
232 if (
present(ipert))
write(str,
'(3a)') trim(str),
"_",
index2pert(ipert)
240 character(len=100) function em_wfs_tag(idir, ifactor, idir2, ipert)
result(str)
241 integer,
intent(in) :: idir
242 integer,
intent(in) :: ifactor
243 integer,
optional,
intent(in) :: idir2
244 integer,
optional,
intent(in) :: ipert
248 write(str,
'(3a,i1)')
"wfs_",
index2axis(idir),
"_f", ifactor
249 if (
present(idir2))
write(str,
'(3a)') trim(str),
"_",
index2axis(idir2)
250 if (
present(ipert))
write(str,
'(3a)') trim(str),
"_",
index2pert(ipert)
262 integer pure function
magn_dir(dir, ind) result(dir_out)
263 integer,
intent(in) :: dir, ind
293 character(len=2) pure function
index2pert(ipert) result(ch)
294 integer,
intent(in) :: ipert
313#include "em_resp_calc_inc.F90"
316#include "complex.F90"
317#include "em_resp_calc_inc.F90"
This module implements batches of mesh functions.
This module implements a calculator for the density and defines related functions.
This module calculates the derivatives (gradients, Laplacians, etc.) of a function.
subroutine, public zderivatives_grad(der, ff, op_ff, ghost_update, set_bc, to_cartesian)
apply the gradient to a mesh function
subroutine, public dinhomog_kb_tot(sh, namespace, space, gr, st, hm, ions, idir, idir1, idir2, lr_k, lr_b, lr_k1, lr_k2, lr_kk1, lr_kk2, psi_out)
subroutine, public zlr_calc_magneto_optics_finite(sh, sh_mo, namespace, space, gr, st, hm, ions, nsigma, nfactor, lr_e, lr_b, chi)
subroutine, public dlr_calc_magnetization_periodic(namespace, space, mesh, st, hm, lr_k, magn)
integer pure function, public magn_dir(dir, ind)
subroutine, public dpost_orthogonalize(space, mesh, st, nfactor, nsigma, freq_factor, omega, eta, em_lr, kdotp_em_lr)
subroutine, public zlr_calc_magneto_optics_periodic(sh, sh2, namespace, space, gr, st, hm, ions, nsigma, nfactor, nfactor_ke, freq_factor, lr_e, lr_b, lr_k, lr_ke, lr_kb, frequency, zpol, zpol_kout)
subroutine, public zinhomog_k2_tot(namespace, space, gr, st, hm, ions, idir1, idir2, lr_k1, lr_k2, psi_out)
subroutine, public dlr_calc_beta(sh, namespace, space, gr, st, hm, xc, em_lr, dipole, beta, kdotp_lr, kdotp_em_lr, occ_response, dl_eig)
See (16) in X Andrade et al., J. Chem. Phys. 126, 184106 (2006) for finite systems and (10) in A Dal ...
subroutine, public dlr_calc_susceptibility(namespace, space, gr, st, hm, lr, nsigma, pert, chi_para, chi_dia)
subroutine, public lr_calc_current(st, space, gr, lr, lr_m)
subroutine, public dinhomog_ke_tot(sh, namespace, space, gr, st, hm, ions, idir, nsigma, lr_k, lr_e, lr_kk, psi_out)
subroutine, public dlr_calc_elf(st, space, gr, kpoints, lr, lr_m)
subroutine, public dem_resp_calc_eigenvalues(space, mesh, latt, st, dl_eig)
subroutine, public zinhomog_b(sh, namespace, space, gr, st, hm, ions, idir1, idir2, lr_k1, lr_k2, psi_out)
subroutine, public zcalc_polarizability_periodic(space, mesh, symm, st, em_lr, kdotp_lr, nsigma, zpol, ndir, zpol_k)
alpha_ij(w) = -e sum(m occ, k) [(<u_mk(0)|-id/dk_i)|u_mkj(1)(w)> + <u_mkj(1)(-w)|(-id/dk_i|u_mk(0)>)]
subroutine, public dinhomog_b(sh, namespace, space, gr, st, hm, ions, idir1, idir2, lr_k1, lr_k2, psi_out)
subroutine, public zlr_calc_elf(st, space, gr, kpoints, lr, lr_m)
character(len=2) pure function index2pert(ipert)
subroutine, public dcalc_polarizability_periodic(space, mesh, symm, st, em_lr, kdotp_lr, nsigma, zpol, ndir, zpol_k)
alpha_ij(w) = -e sum(m occ, k) [(<u_mk(0)|-id/dk_i)|u_mkj(1)(w)> + <u_mkj(1)(-w)|(-id/dk_i|u_mk(0)>)]
subroutine, public zpost_orthogonalize(space, mesh, st, nfactor, nsigma, freq_factor, omega, eta, em_lr, kdotp_em_lr)
character(len=100) function, public em_wfs_tag(idir, ifactor, idir2, ipert)
subroutine, public zlr_calc_magnetization_periodic(namespace, space, mesh, st, hm, lr_k, magn)
subroutine, public zinhomog_ke_tot(sh, namespace, space, gr, st, hm, ions, idir, nsigma, lr_k, lr_e, lr_kk, psi_out)
character(len=12) function, public freq2str(freq)
subroutine, public dlr_calc_susceptibility_periodic(namespace, space, symm, mesh, st, hm, lr_k, lr_b, lr_kk, lr_kb, magn)
subroutine, public zlr_calc_susceptibility_periodic(namespace, space, symm, mesh, st, hm, lr_k, lr_b, lr_kk, lr_kb, magn)
subroutine, public zlr_calc_susceptibility(namespace, space, gr, st, hm, lr, nsigma, pert, chi_para, chi_dia)
subroutine, public dlr_calc_magneto_optics_finite(sh, sh_mo, namespace, space, gr, st, hm, ions, nsigma, nfactor, lr_e, lr_b, chi)
character(len=100) function, public em_rho_tag(freq, dir, dir2, ipert)
subroutine, public dinhomog_k2_tot(namespace, space, gr, st, hm, ions, idir1, idir2, lr_k1, lr_k2, psi_out)
subroutine, public zlr_calc_beta(sh, namespace, space, gr, st, hm, xc, em_lr, dipole, beta, kdotp_lr, kdotp_em_lr, occ_response, dl_eig)
See (16) in X Andrade et al., J. Chem. Phys. 126, 184106 (2006) for finite systems and (10) in A Dal ...
subroutine, public zcalc_polarizability_finite(namespace, space, gr, st, hm, lr, nsigma, pert, zpol, doalldirs, ndir)
alpha_ij(w) = - sum(m occ) [<psi_m(0)|r_i|psi_mj(1)(w)> + <psi_mj(1)(-w)|r_i|psi_m(0)>] minus sign is...
subroutine, public dcalc_polarizability_finite(namespace, space, gr, st, hm, lr, nsigma, pert, zpol, doalldirs, ndir)
alpha_ij(w) = - sum(m occ) [<psi_m(0)|r_i|psi_mj(1)(w)> + <psi_mj(1)(-w)|r_i|psi_m(0)>] minus sign is...
subroutine, public dlr_calc_magneto_optics_periodic(sh, sh2, namespace, space, gr, st, hm, ions, nsigma, nfactor, nfactor_ke, freq_factor, lr_e, lr_b, lr_k, lr_ke, lr_kb, frequency, zpol, zpol_kout)
subroutine, public zinhomog_kb_tot(sh, namespace, space, gr, st, hm, ions, idir, idir1, idir2, lr_k, lr_b, lr_k1, lr_k2, lr_kk1, lr_kk2, psi_out)
subroutine, public zem_resp_calc_eigenvalues(space, mesh, latt, st, dl_eig)
real(real64), parameter, public m_two
real(real64), parameter, public m_zero
complex(real64), parameter, public m_zi
real(real64), parameter, public m_one
This module implements the underlying real-space grid.
This module defines functions over batches of mesh functions.
This module defines various routines, operating on mesh functions.
This module defines the meshes, which are used in Octopus.
This module handles spin dimensions of the states and the k-point distribution.
This module is intended to contain simple general-purpose utility functions and procedures.
character pure function, public index2axis(idir)