32 use,
intrinsic :: iso_fortran_env
67 type(grid_t),
intent(in) :: gr
68 type(namespace_t),
intent(in) :: namespace
69 type(target_t),
intent(inout) :: tg
70 type(td_t),
intent(in) :: td
87 if (
parse_block(namespace,
'OCTTdTarget', blk) == 0)
then
90 safe_allocate(tg%rho(1:gr%np))
93 message(1) =
'If OCTTargetOperator = oct_tg_td_local, you must supply a OCTTdTarget block.'
96 safe_allocate(tg%td_fitness(0:td%max_iter))
107 type(target_t),
intent(inout) :: tg
111 safe_deallocate_a(tg%rho)
112 safe_deallocate_a(tg%td_fitness)
120 type(target_t),
intent(inout) :: tg
121 type(namespace_t),
intent(in) :: namespace
122 class(space_t),
intent(in) :: space
123 type(grid_t),
intent(in) :: gr
124 character(len=*),
intent(in) :: dir
125 type(ions_t),
intent(in) :: ions
126 type(output_t),
intent(in) :: outp
133 call dio_function_output(outp%how(0), trim(dir),
'td_local_target', namespace, space, gr, &
134 tg%rho,
units_out%length**(-space%dim), ierr, pos=ions%pos, atoms=ions%atom)
143 real(real64) function target_j1_tdlocal(tg) result(j1)
144 type(target_t),
intent(in) :: tg
147 push_sub(target_j1_tdlocal)
149 maxiter =
size(tg%td_fitness) - 1
150 j1 =
m_half * tg%dt * tg%td_fitness(0) + &
151 m_half * tg%dt * tg%td_fitness(maxiter) + &
152 tg%dt * sum(tg%td_fitness(1:maxiter-1))
155 pop_sub(target_j1_tdlocal)
162 type(states_elec_t),
intent(inout) :: chi_out
169 do ik = chi_out%d%kpt%start, chi_out%d%kpt%end
170 do ib = chi_out%group%block_start, chi_out%group%block_end
171 call batch_set_zero(chi_out%group%psib(ib, ik))
183 type(target_t),
intent(inout) :: tg
184 type(grid_t),
intent(in) :: gr
185 type(states_elec_t),
intent(in) :: psi
186 integer,
intent(in) :: time
188 complex(real64),
allocatable :: opsi(:, :), zpsi(:, :)
192 tg%td_fitness(time) = m_zero
194 safe_allocate(zpsi(1:gr%np, 1:psi%d%dim))
197 select case (psi%d%ispin)
200 safe_allocate(opsi(1:gr%np_part, 1))
202 do ist = psi%st_start, psi%st_end
204 call states_elec_get_state(psi, gr, ist, 1, zpsi)
207 opsi(ip, 1) = tg%rho(ip)*zpsi(ip, 1)
210 tg%td_fitness(time) = tg%td_fitness(time) + psi%occ(ist, 1)*real(zmf_dotp(gr, psi%d%dim, zpsi, opsi), real64)
213 safe_deallocate_a(opsi)
214 case (spin_polarized)
215 message(1) =
'Error in target.target_tdcalc: spin_polarized.'
216 call messages_fatal(1)
218 message(1) =
'Error in target.target_tdcalc: spinors.'
219 call messages_fatal(1)
222 safe_deallocate_a(zpsi)
231 type(target_t),
intent(inout) :: tg
232 type(grid_t),
intent(in) :: gr
233 real(real64),
intent(in) :: time
236 real(real64) :: xx(gr%box%dim), rr, re, im
241 call mesh_r(gr, ip, rr, coords = xx)
242 call parse_expression(re, im, gr%box%dim, xx, rr, time, tg%td_local_target)
This module implements common operations on batches of mesh functions.
real(real64), parameter, public m_zero
real(real64), parameter, public m_half
This module implements the underlying real-space grid.
subroutine, public dio_function_output(how, dir, fname, namespace, space, mesh, ff, unit, ierr, pos, atoms, grp, root)
Top-level IO routine for functions defined on the mesh.
subroutine, public io_mkdir(fname, namespace, parents)
logical pure function, public ion_dynamics_ions_move(this)
This module defines various routines, operating on mesh functions.
This module defines the meshes, which are used in Octopus.
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
subroutine, public messages_fatal(no_lines, only_root_writes, namespace)
this module contains the low-level part of the output system
integer function, public parse_block(namespace, name, blk, check_varinfo_)
subroutine, public conv_to_c_string(str)
converts to c string
subroutine, public target_output_tdlocal(tg, namespace, space, gr, dir, ions, outp)
subroutine, public target_init_tdlocal(gr, namespace, tg, td)
subroutine, public target_end_tdlocal(tg)
subroutine, public target_tdcalc_tdlocal(tg, gr, psi, time)
subroutine, public target_chi_tdlocal(chi_out)
real(real64) function, public target_j1_tdlocal(tg)
subroutine, public target_build_tdlocal(tg, gr, time)
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_out