28 use,
intrinsic :: iso_fortran_env
71 logical,
private :: is_allocated, is_allocated_rho
74 real(real64),
allocatable :: ddl_rho(:,:)
75 real(real64),
allocatable :: ddl_psi(:,:,:,:)
78 complex(real64),
allocatable :: zdl_rho(:,:)
79 complex(real64),
allocatable :: zdl_psi(:,:,:,:)
82 complex(real64),
allocatable :: dl_j(:,:,:)
89 type(lr_t),
intent(out) :: lr
93 lr%is_allocated = .false.
94 lr%is_allocated_rho = .false.
104 type(lr_t),
intent(inout) :: lr
105 type(states_elec_t),
intent(in) :: st
106 class(mesh_t),
intent(in) :: mesh
107 logical,
optional,
intent(in) :: allocate_rho
114 safe_allocate(lr%zdl_psi(1:mesh%np_part, 1:st%d%dim, st%st_start:st%st_end, st%d%kpt%start:st%d%kpt%end))
115 if (lr%is_allocated_rho)
then
116 safe_allocate(lr%zdl_rho(1:mesh%np, 1:st%d%nspin))
119 safe_allocate(lr%ddl_psi(1:mesh%np_part, 1:st%d%dim, st%st_start:st%st_end, st%d%kpt%start:st%d%kpt%end))
120 if (lr%is_allocated_rho)
then
121 safe_allocate(lr%ddl_rho(1:mesh%np, 1:st%d%nspin))
125 lr%is_allocated = .
true.
137 type(lr_t),
intent(inout) :: lr
138 type(states_elec_t),
intent(in) :: st
142 assert(lr%is_allocated)
146 if (lr%is_allocated_rho) lr%zdl_rho =
m_zero
149 if (lr%is_allocated_rho) lr%ddl_rho =
m_zero
159 type(lr_t),
intent(inout) :: lr
163 safe_deallocate_a(lr%ddl_psi)
164 safe_deallocate_a(lr%zdl_psi)
166 safe_deallocate_a(lr%ddl_rho)
167 safe_deallocate_a(lr%zdl_rho)
169 safe_deallocate_a(lr%dl_j)
170 lr%is_allocated = .false.
171 lr%is_allocated_rho = .false.
178 subroutine lr_copy(st, mesh, src, dest)
180 class(
mesh_t),
intent(in) :: mesh
181 type(
lr_t),
intent(in) :: src
182 type(
lr_t),
intent(inout) :: dest
188 if (src%is_allocated_rho .and. dest%is_allocated_rho)
then
190 call lalg_copy(mesh%np, st%d%nspin, src%zdl_rho, dest%zdl_rho)
192 call lalg_copy(mesh%np, st%d%nspin, src%ddl_rho, dest%ddl_rho)
195 if (dest%is_allocated_rho)
then
197 dest%zdl_rho(:, :) =
m_zero
199 dest%ddl_rho(:, :) =
m_zero
204 do ik = st%d%kpt%start, st%d%kpt%end
205 do ist = st%st_start, st%st_end
207 call lalg_copy(mesh%np_part, st%d%dim, src%zdl_psi(:, :, ist, ik), dest%zdl_psi(:, :, ist, ik))
209 call lalg_copy(mesh%np_part, st%d%dim, src%ddl_psi(:, :, ist, ik), dest%ddl_psi(:, :, ist, ik))
222 type(
lr_t),
intent(in) :: this
235 integer,
intent(in) :: jst
236 integer,
intent(in) :: ik
238 real(real64) :: dsmear
243 lr_alpha_j = st%occ(jst, ik) / st%smear%el_per_state
245 dsmear = max(1e-14_real64, st%smear%dsmear)
254#include "linear_response_inc.F90"
257#include "complex.F90"
258#include "linear_response_inc.F90"
Copies a vector x, to a vector y.
This module implements batches of mesh functions.
real(real64), parameter, public m_zero
real(real64), parameter, public m_three
subroutine, public dlr_load_rho(dl_rho, mesh, nspin, restart, rho_tag, ierr)
subroutine, public zlr_orth_response(mesh, st, lr, omega)
subroutine, public dlr_swap_sigma(st, mesh, plus, minus)
subroutine, public dlr_orth_vector(mesh, st, vec, ist, ik, omega, min_proj)
Orthogonalizes a vector vec against all the occupied states. For details on the metallic part,...
subroutine, public zlr_load_rho(dl_rho, mesh, nspin, restart, rho_tag, ierr)
subroutine, public lr_copy(st, mesh, src, dest)
subroutine, public lr_zero(lr, st)
real(real64) function, public lr_alpha_j(st, jst, ik)
subroutine, public lr_allocate(lr, st, mesh, allocate_rho)
subroutine, public lr_init(lr)
subroutine, public lr_dealloc(lr)
subroutine, public zlr_orth_vector(mesh, st, vec, ist, ik, omega, min_proj)
Orthogonalizes a vector vec against all the occupied states. For details on the metallic part,...
subroutine, public dlr_dump_rho(lr, mesh, nspin, restart, rho_tag, ierr)
subroutine, public zlr_build_dl_rho(mesh, st, lr, nsigma)
Computes the variation of the density for the Sternheimer calculations This is given in Eq....
subroutine, public zlr_dump_rho(lr, mesh, nspin, restart, rho_tag, ierr)
subroutine, public dlr_orth_response(mesh, st, lr, omega)
subroutine, public zlr_swap_sigma(st, mesh, plus, minus)
subroutine, public dlr_build_dl_rho(mesh, st, lr, nsigma)
Computes the variation of the density for the Sternheimer calculations This is given in Eq....
logical function, public lr_is_allocated(this)
This module defines various routines, operating on mesh functions.
This module defines the meshes, which are used in Octopus.
integer, parameter, public smear_fixed_occ
pure logical function, public states_are_complex(st)
Describes mesh distribution to nodes.
The states_elec_t class contains all electronic wave functions.