27 use,
intrinsic :: iso_fortran_env
70 logical,
private :: is_allocated, is_allocated_rho
73 real(real64),
allocatable :: ddl_rho(:,:)
74 real(real64),
allocatable :: ddl_psi(:,:,:,:)
77 complex(real64),
allocatable :: zdl_rho(:,:)
78 complex(real64),
allocatable :: zdl_psi(:,:,:,:)
81 complex(real64),
allocatable :: dl_j(:,:,:)
82 real(real64),
allocatable :: ddl_de(:,:)
83 real(real64),
allocatable :: ddl_elf(:,:)
84 complex(real64),
allocatable :: zdl_de(:,:)
85 complex(real64),
allocatable :: zdl_elf(:,:)
93 type(lr_t),
intent(out) :: lr
97 lr%is_allocated = .false.
107 type(lr_t),
intent(inout) :: lr
108 type(states_elec_t),
intent(in) :: st
109 class(mesh_t),
intent(in) :: mesh
110 logical,
optional,
intent(in) :: allocate_rho
114 lr%is_allocated_rho = .
true.
115 if (
present(allocate_rho)) lr%is_allocated_rho = allocate_rho
118 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))
119 if (lr%is_allocated_rho)
then
120 safe_allocate(lr%zdl_rho(1:mesh%np, 1:st%d%nspin))
123 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))
124 if (lr%is_allocated_rho)
then
125 safe_allocate(lr%ddl_rho(1:mesh%np, 1:st%d%nspin))
129 lr%is_allocated = .
true.
141 type(lr_t),
intent(inout) :: lr
142 type(states_elec_t),
intent(in) :: st
146 assert(lr%is_allocated)
150 if (lr%is_allocated_rho) lr%zdl_rho =
m_zero
153 if (lr%is_allocated_rho) lr%ddl_rho =
m_zero
163 type(
lr_t),
intent(inout) :: lr
167 safe_deallocate_a(lr%ddl_psi)
168 safe_deallocate_a(lr%zdl_psi)
170 safe_deallocate_a(lr%ddl_rho)
171 safe_deallocate_a(lr%zdl_rho)
173 safe_deallocate_a(lr%dl_j)
174 safe_deallocate_a(lr%ddl_de)
175 safe_deallocate_a(lr%ddl_elf)
176 safe_deallocate_a(lr%zdl_de)
177 safe_deallocate_a(lr%zdl_elf)
184 subroutine lr_copy(st, mesh, src, dest)
186 class(
mesh_t),
intent(in) :: mesh
187 type(
lr_t),
intent(in) :: src
188 type(
lr_t),
intent(inout) :: dest
194 if (src%is_allocated_rho .and. dest%is_allocated_rho)
then
196 call lalg_copy(mesh%np, st%d%nspin, src%zdl_rho, dest%zdl_rho)
198 call lalg_copy(mesh%np, st%d%nspin, src%ddl_rho, dest%ddl_rho)
201 if (dest%is_allocated_rho)
then
203 dest%zdl_rho(:, :) =
m_zero
205 dest%ddl_rho(:, :) =
m_zero
210 do ik = st%d%kpt%start, st%d%kpt%end
211 do ist = st%st_start, st%st_end
213 call lalg_copy(mesh%np_part, st%d%dim, src%zdl_psi(:, :, ist, ik), dest%zdl_psi(:, :, ist, ik))
215 call lalg_copy(mesh%np_part, st%d%dim, src%ddl_psi(:, :, ist, ik), dest%ddl_psi(:, :, ist, ik))
228 type(
lr_t),
intent(in) :: this
241 integer,
intent(in) :: jst
242 integer,
intent(in) :: ik
244 real(real64) :: dsmear
249 lr_alpha_j = st%occ(jst, ik) / st%smear%el_per_state
251 dsmear = max(1e-14_real64, st%smear%dsmear)
260#include "linear_response_inc.F90"
263#include "complex.F90"
264#include "linear_response_inc.F90"
Copies a vector x, to a vector y.
real(real64), parameter, public m_zero
real(real64), parameter, public m_three
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 vec against all the occupied states. For details on the metallic part,...
subroutine, public lr_copy(st, mesh, src, dest)
subroutine, public lr_zero(lr, st)
subroutine, public zlr_dump_rho(lr, space, mesh, nspin, restart, rho_tag, ierr)
real(real64) function, public lr_alpha_j(st, jst, ik)
subroutine, public dlr_load_rho(dl_rho, space, mesh, nspin, restart, rho_tag, ierr)
subroutine, public dlr_dump_rho(lr, space, mesh, nspin, restart, rho_tag, ierr)
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 vec against all the occupied states. For details on the metallic part,...
subroutine, public zlr_build_dl_rho(mesh, st, lr, nsigma)
subroutine, public zlr_load_rho(dl_rho, space, 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)
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.