31 use,
intrinsic :: iso_fortran_env
68 subroutine target_init_userdefined(tg, gr, kpoints, namespace, space, ions, qcs, td, w0, oct, ep, restart)
69 class(target_userdefined_t),
intent(inout) :: tg
70 type(grid_t),
intent(in) :: gr
71 type(kpoints_t),
intent(in) :: kpoints
72 type(namespace_t),
intent(in) :: namespace
73 class(space_t),
intent(in) :: space
74 type(ions_t),
intent(in) :: ions
75 type(opt_control_state_t),
intent(inout) :: qcs
76 type(td_t),
intent(in) :: td
77 real(real64),
intent(in) :: w0
78 type(oct_t),
intent(in) :: oct
79 type(epot_t),
intent(inout) :: ep
80 type(restart_t),
intent(inout) :: restart
82 integer :: no_states, ib, ip, idim, inst, inik, id, ist, ik
84 real(real64) :: xx(1:gr%box%dim), rr, psi_re, psi_im
85 complex(real64),
allocatable :: zpsi(:, :)
89 message(1) =
'Info: Target is a user-defined state.'
92 tg%move_ions = td%ions_dyn%ions_move()
95 safe_allocate(zpsi(gr%np, 1:tg%st%d%dim))
109 if (
parse_block(namespace,
'OCTTargetUserdefined', blk) == 0)
then
118 do id = 1, tg%st%d%dim
119 do ist = 1, tg%st%nst
123 if (.not. (id == idim .and. ist == inst .and. ik == inik &
124 .and. tg%st%st_start <= ist .and. tg%st%st_end >= ist)) cycle
128 blk, ib - 1, 3, tg%st%user_def_states(id, ist, ik))
138 gr%box%dim, xx, rr,
m_zero, tg%st%user_def_states(id, ist, ik))
140 zpsi(ip, id) = cmplx(psi_re, psi_im, real64)
158 safe_deallocate_a(zpsi)
168 class(
space_t),
intent(in) :: space
169 type(
grid_t),
intent(in) :: gr
170 character(len=*),
intent(in) :: dir
171 type(
ions_t),
intent(in) :: ions
177 call output_states(outp, namespace, space, trim(dir), tg%st, gr, ions, hm, -1)
186 real(real64) function target_j1_userdefined(tg, namespace, gr, kpoints, qcpsi, ions) result(j1)
189 type(
grid_t),
intent(in) :: gr
192 type(
ions_t),
optional,
intent(in) :: ions
195 complex(real64),
allocatable :: zpsi(:, :), zst(:, :)
198 push_sub(target_j1_userdefined)
202 safe_allocate(zpsi(1:gr%np, 1:tg%st%d%dim))
203 safe_allocate(zst(1:gr%np, 1:tg%st%d%dim))
207 do ist = psi%st_start, psi%st_end
212 j1 = j1 + psi%occ(ist, ik)*abs(
zmf_dotp(gr, psi%d%dim, zpsi, zst))**2
216 safe_deallocate_a(zpsi)
217 safe_deallocate_a(zst)
220 pop_sub(target_j1_userdefined)
228 type(namespace_t),
intent(in) :: namespace
229 type(grid_t),
intent(in) :: gr
230 type(kpoints_t),
intent(in) :: kpoints
231 type(opt_control_state_t),
target,
intent(inout) :: qcpsi_in
232 type(opt_control_state_t),
target,
intent(inout) :: qcchi_out
233 type(ions_t),
intent(in) :: ions
236 complex(real64) :: olap
237 complex(real64),
allocatable :: zpsi(:, :), zst(:, :), zchi(:, :)
238 type(states_elec_t),
pointer :: psi_in, chi_out
242 psi_in => opt_control_point_qs(qcpsi_in)
243 chi_out => opt_control_point_qs(qcchi_out)
245 safe_allocate(zpsi(1:gr%np, 1:tg%st%d%dim))
246 safe_allocate(zst(1:gr%np, 1:tg%st%d%dim))
247 safe_allocate(zchi(1:gr%np, 1:tg%st%d%dim))
249 do ik = 1, psi_in%nik
250 do ist = psi_in%st_start, psi_in%st_end
252 call states_elec_get_state(psi_in, gr, ist, ik, zpsi)
253 call states_elec_get_state(tg%st, gr, ist, ik, zst)
255 olap = zmf_dotp(gr, zst(:, 1), zpsi(:, 1))
256 zchi(1:gr%np, 1:tg%st%d%dim) = olap*zst(1:gr%np, 1:tg%st%d%dim)
258 call states_elec_set_state(chi_out, gr, ist, ik, zchi)
263 safe_deallocate_a(zpsi)
264 safe_deallocate_a(zst)
265 safe_deallocate_a(zchi)
This module implements a calculator for the density and defines related functions.
subroutine, public density_calc(st, gr, density, istin)
Computes the density from the orbitals in st.
real(real64), parameter, public m_zero
This module implements the underlying real-space grid.
subroutine, public io_mkdir(fname, namespace, parents)
This module defines various routines, operating on mesh functions.
subroutine, public zmf_normalize(mesh, dim, psi, norm)
Normalize a mesh function psi.
subroutine, public messages_variable_is_block(namespace, name)
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
subroutine, public messages_info(no_lines, iunit, debug_only, stress, all_nodes, 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.
type(states_elec_t) function, pointer, public opt_control_point_qs(ocs)
this module contains the low-level part of the output system
this module contains the output system
subroutine, public output_states(outp, namespace, space, dir, st, gr, ions, hm, iter)
subroutine, public parse_block_string(blk, l, c, res, convert_to_c)
integer function, public parse_block(namespace, name, blk, check_varinfo_)
subroutine, public conv_to_c_string(str)
converts to c string
Optimal-control targets: abstract base class and public interface.
subroutine target_output_userdefined(tg, namespace, space, gr, dir, ions, hm, outp)
subroutine target_chi_userdefined(tg, namespace, gr, kpoints, qcpsi_in, qcchi_out, ions)
subroutine target_init_userdefined(tg, gr, kpoints, namespace, space, ions, qcs, td, w0, oct, ep, restart)
real(real64) function target_j1_userdefined(tg, namespace, gr, kpoints, qcpsi, ions)
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...
The states_elec_t class contains all electronic wave functions.
Abstract optimal-control target.
Target projecting onto a user-defined state.