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
111 lr%is_allocated_rho = .
true.
112 if (
present(allocate_rho)) lr%is_allocated_rho = allocate_rho
115 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))
116 if (lr%is_allocated_rho)
then
117 safe_allocate(lr%zdl_rho(1:mesh%np, 1:st%d%nspin))
120 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))
121 if (lr%is_allocated_rho)
then
122 safe_allocate(lr%ddl_rho(1:mesh%np, 1:st%d%nspin))
126 lr%is_allocated = .
true.
138 type(lr_t),
intent(inout) :: lr
139 type(states_elec_t),
intent(in) :: st
143 assert(lr%is_allocated)
147 if (lr%is_allocated_rho) lr%zdl_rho =
m_zero
150 if (lr%is_allocated_rho) lr%ddl_rho =
m_zero
160 type(lr_t),
intent(inout) :: lr
164 safe_deallocate_a(lr%ddl_psi)
165 safe_deallocate_a(lr%zdl_psi)
167 safe_deallocate_a(lr%ddl_rho)
168 safe_deallocate_a(lr%zdl_rho)
170 safe_deallocate_a(lr%dl_j)
171 lr%is_allocated = .false.
172 lr%is_allocated_rho = .false.
179 subroutine lr_copy(st, mesh, src, dest)
181 class(
mesh_t),
intent(in) :: mesh
182 type(
lr_t),
intent(in) :: src
183 type(
lr_t),
intent(inout) :: dest
189 if (src%is_allocated_rho .and. dest%is_allocated_rho)
then
191 call lalg_copy(mesh%np, st%d%nspin, src%zdl_rho, dest%zdl_rho)
193 call lalg_copy(mesh%np, st%d%nspin, src%ddl_rho, dest%ddl_rho)
196 if (dest%is_allocated_rho)
then
200 dest%ddl_rho(:, :) =
m_zero
205 do ik = st%d%kpt%start, st%d%kpt%end
206 do ist = st%st_start, st%st_end
208 call lalg_copy(mesh%np_part, st%d%dim, src%zdl_psi(:, :, ist, ik), dest%zdl_psi(:, :, ist, ik))
210 call lalg_copy(mesh%np_part, st%d%dim, src%ddl_psi(:, :, ist, ik), dest%ddl_psi(:, :, ist, ik))
223 type(
lr_t),
intent(in) :: this
236 integer,
intent(in) :: jst
237 integer,
intent(in) :: ik
239 real(real64) :: dsmear
244 lr_alpha_j = st%occ(jst, ik) / st%smear%el_per_state
246 dsmear = max(1e-14_real64, st%smear%dsmear)
255#include "linear_response_inc.F90"
258#include "complex.F90"
259#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.