35 use,
intrinsic :: iso_fortran_env
63 real(real64),
allocatable :: rho(:)
64 real(real64),
allocatable :: td_fitness(:)
65 character(len=200) :: td_local_target
81 subroutine target_init_tdlocal(tg, gr, kpoints, namespace, space, ions, qcs, td, w0, oct, ep, restart)
82 class(target_tdlocal_t),
intent(inout) :: tg
83 type(grid_t),
intent(in) :: gr
84 type(kpoints_t),
intent(in) :: kpoints
85 type(namespace_t),
intent(in) :: namespace
86 class(space_t),
intent(in) :: space
87 type(ions_t),
intent(in) :: ions
88 type(opt_control_state_t),
intent(inout) :: qcs
89 type(td_t),
intent(in) :: td
90 real(real64),
intent(in) :: w0
91 type(oct_t),
intent(in) :: oct
92 type(epot_t),
intent(inout) :: ep
93 type(restart_t),
intent(inout) :: restart
98 tg%move_ions = td%ions_dyn%ions_move()
110 if (
parse_block(namespace,
'OCTTdTarget', blk) == 0)
then
112 safe_allocate(tg%rho(1:gr%np))
115 message(1) =
'If OCTTargetOperator = oct_tg_td_local, you must supply a OCTTdTarget block.'
118 safe_allocate(tg%td_fitness(0:td%max_iter))
129 class(target_tdlocal_t),
intent(inout) :: tg
130 type(oct_t),
intent(in) :: oct
134 safe_deallocate_a(tg%rho)
135 safe_deallocate_a(tg%td_fitness)
143 class(target_tdlocal_t),
intent(inout) :: tg
144 type(namespace_t),
intent(in) :: namespace
145 class(space_t),
intent(in) :: space
146 type(grid_t),
intent(in) :: gr
147 character(len=*),
intent(in) :: dir
148 type(ions_t),
intent(in) :: ions
149 type(hamiltonian_elec_t),
intent(in) :: hm
150 type(output_t),
intent(in) :: outp
157 call dio_function_output(outp%how(0), trim(dir),
'td_local_target', namespace, space, gr, &
158 tg%rho,
units_out%length**(-space%dim), ierr, pos=ions%pos, atoms=ions%atom)
170 type(
grid_t),
intent(in) :: gr
173 type(
ions_t),
optional,
intent(in) :: ions
178 maxiter =
size(tg%td_fitness) - 1
179 j1 =
m_half * tg%dt * tg%td_fitness(0) + &
180 m_half * tg%dt * tg%td_fitness(maxiter) + &
181 tg%dt * sum(tg%td_fitness(1:maxiter-1))
192 type(namespace_t),
intent(in) :: namespace
193 type(grid_t),
intent(in) :: gr
194 type(kpoints_t),
intent(in) :: kpoints
195 type(opt_control_state_t),
target,
intent(inout) :: qcpsi_in
196 type(opt_control_state_t),
target,
intent(inout) :: qcchi_out
197 type(ions_t),
intent(in) :: ions
200 type(states_elec_t),
pointer :: chi_out
203 chi_out => opt_control_point_qs(qcchi_out)
207 do ik = chi_out%d%kpt%start, chi_out%d%kpt%end
208 do ib = chi_out%group%block_start, chi_out%group%block_end
209 call batch_set_zero(chi_out%group%psib(ib, ik))
221 subroutine target_tdcalc_tdlocal(tg, namespace, space, hm, gr, ions, ext_partners, psi, time, max_time)
223 type(namespace_t),
intent(in) :: namespace
224 class(space_t),
intent(in) :: space
225 type(hamiltonian_elec_t),
intent(inout) :: hm
226 type(grid_t),
intent(in) :: gr
227 type(ions_t),
intent(inout) :: ions
228 type(partner_list_t),
intent(in) :: ext_partners
229 type(states_elec_t),
intent(inout) :: psi
230 integer,
intent(in) :: time
231 integer,
intent(in) :: max_time
233 complex(real64),
allocatable :: opsi(:, :), zpsi(:, :)
237 tg%td_fitness(time) = m_zero
239 safe_allocate(zpsi(1:gr%np, 1:psi%d%dim))
242 select case (psi%d%ispin)
245 safe_allocate(opsi(1:gr%np_part, 1))
247 do ist = psi%st_start, psi%st_end
249 call states_elec_get_state(psi, gr, ist, 1, zpsi)
252 opsi(ip, 1) = tg%rho(ip)*zpsi(ip, 1)
255 tg%td_fitness(time) = tg%td_fitness(time) + psi%occ(ist, 1)*real(zmf_dotp(gr, psi%d%dim, zpsi, opsi), real64)
258 safe_deallocate_a(opsi)
259 case (spin_polarized)
260 message(1) =
'Error in target.target_tdcalc: spin_polarized.'
261 call messages_fatal(1)
263 message(1) =
'Error in target.target_tdcalc: spinors.'
264 call messages_fatal(1)
267 safe_deallocate_a(zpsi)
278 type(states_elec_t),
intent(inout) :: psi
279 type(grid_t),
intent(in) :: gr
280 type(kpoints_t),
intent(in) :: kpoints
281 real(real64),
intent(in) :: time
282 type(states_elec_t),
intent(inout) :: inh
283 integer,
intent(in) :: iter
285 integer :: ik, ist, idim
286 complex(real64),
allocatable :: zpsi(:)
290 safe_allocate(zpsi(1:gr%np))
294 do ik = inh%d%kpt%start, inh%d%kpt%end
295 do ist = inh%st_start, inh%st_end
296 do idim = 1, inh%d%dim
297 call states_elec_get_state(psi, gr, idim, ist, ik, zpsi)
298 zpsi(1:gr%np) = -psi%occ(ist, ik)*tg%rho(1:gr%np)*zpsi(1:gr%np)
299 call states_elec_set_state(inh, gr, idim, ist, ik, zpsi)
304 safe_deallocate_a(zpsi)
314 type(grid_t),
intent(in) :: gr
315 real(real64),
intent(in) :: time
318 real(real64) :: xx(gr%box%dim), rr, re, im
323 call mesh_r(gr, ip, rr, coords = xx)
324 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.
This module defines classes and functions for interaction partners.
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)
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 definition of the oct_t data type, which contains some of the basic informat...
This module holds the "opt_control_state_t" datatype, which contains a quantum-classical state.
this module contains the low-level part of the output system
subroutine, public parse_block_string(blk, l, c, res, convert_to_c)
integer function, public parse_block(namespace, name, blk, check_varinfo_)
Optimal-control targets: abstract base class and public interface.
subroutine target_tdcalc_tdlocal(tg, namespace, space, hm, gr, ions, ext_partners, psi, time, max_time)
subroutine target_output_tdlocal(tg, namespace, space, gr, dir, ions, hm, outp)
subroutine target_chi_tdlocal(tg, namespace, gr, kpoints, qcpsi_in, qcchi_out, ions)
subroutine target_end_tdlocal(tg, oct)
subroutine target_inh_tdlocal(tg, psi, gr, kpoints, time, inh, iter)
Inhomogeneous term for the time-dependent local target.
real(real64) function target_j1_tdlocal(tg, namespace, gr, kpoints, qcpsi, ions)
subroutine target_init_tdlocal(tg, gr, kpoints, namespace, space, ions, qcs, td, w0, oct, ep, restart)
subroutine 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
Description of the grid, containing information on derivatives, stencil, and symmetries.
This is the datatype that contains the objects that are propagated: in principle this could be both t...
Abstract optimal-control target.
Time-dependent local target operator.