32 use,
intrinsic :: iso_fortran_env
62 type(excited_states_t) :: est
76 subroutine target_init_excited(tg, gr, kpoints, namespace, space, ions, qcs, td, w0, oct, ep, restart)
77 class(target_excited_t),
intent(inout) :: tg
78 type(grid_t),
intent(in) :: gr
79 type(kpoints_t),
intent(in) :: kpoints
80 type(namespace_t),
intent(in) :: namespace
81 class(space_t),
intent(in) :: space
82 type(ions_t),
intent(in) :: ions
83 type(opt_control_state_t),
intent(inout) :: qcs
84 type(td_t),
intent(in) :: td
85 real(real64),
intent(in) :: w0
86 type(oct_t),
intent(in) :: oct
87 type(epot_t),
intent(inout) :: ep
88 type(restart_t),
intent(inout) :: restart
90 integer :: ierr, nik, dim
94 message(1) =
'Info: TargetOperator is a linear combination of Slater determinants.'
97 tg%move_ions = td%ions_dyn%ions_move()
102 message(1) =
"Unable to read states information."
106 tg%st%st_end = tg%st%nst
108 safe_deallocate_a(tg%st%occ)
109 safe_deallocate_a(tg%st%eigenval)
110 safe_deallocate_a(tg%st%node)
112 safe_allocate( tg%st%occ(1:tg%st%nst, 1:tg%st%nik))
113 safe_allocate(tg%st%eigenval(1:tg%st%nst, 1:tg%st%nik))
114 safe_allocate( tg%st%node(1:tg%st%nst))
115 if (tg%st%d%ispin ==
spinors)
then
116 safe_deallocate_a(tg%st%spin)
117 safe_allocate(tg%st%spin(1:3, 1:tg%st%nst, 1:tg%st%nik))
122 call states_elec_load(restart, namespace, space, tg%st, gr, kpoints, fixed_occ=.
true., ierr=ierr)
124 message(1) =
"Unable to read wavefunctions."
136 class(target_excited_t),
intent(inout) :: tg
137 type(namespace_t),
intent(in) :: namespace
138 class(space_t),
intent(in) :: space
139 type(grid_t),
intent(in) :: gr
140 character(len=*),
intent(in) :: dir
141 type(ions_t),
intent(in) :: ions
142 type(hamiltonian_elec_t),
intent(in) :: hm
143 type(output_t),
intent(in) :: outp
148 call output_states(outp, namespace, space, trim(dir)//
'/st', tg%est%st, gr, ions, hm, -1)
158 real(real64) function target_j1_excited(tg, namespace, gr, kpoints, qcpsi, ions) result(j1)
164 type(
ions_t),
optional,
intent(in) :: ions
168 push_sub(target_j1_excited)
175 pop_sub(target_j1_excited)
183 type(namespace_t),
intent(in) :: namespace
184 type(grid_t),
intent(in) :: gr
185 type(kpoints_t),
intent(in) :: kpoints
186 type(opt_control_state_t),
target,
intent(inout) :: qcpsi_in
187 type(opt_control_state_t),
target,
intent(inout) :: qcchi_out
188 type(ions_t),
intent(in) :: ions
190 complex(real64),
allocatable :: cI(:), dI(:), mat(:, :, :), mm(:, :, :, :), mk(:, :), lambda(:, :)
191 complex(real64),
allocatable :: zpsi(:, :), zchi(:, :)
192 integer :: ik, ist, jst, ia, ib, n_pairs, nst, nik, jj, idim, ip
193 type(states_elec_t),
pointer :: psi_in, chi_out
196 psi_in => opt_control_point_qs(qcpsi_in)
197 chi_out => opt_control_point_qs(qcchi_out)
199 n_pairs = tg%est%n_pairs
204 safe_allocate(zpsi(1:gr%np, 1:psi_in%d%dim))
205 safe_allocate(zchi(1:gr%np, 1:psi_in%d%dim))
206 safe_allocate(ci(1:n_pairs))
207 safe_allocate(di(1:n_pairs))
208 safe_allocate(mat(1:tg%est%st%nst, 1:nst, 1:psi_in%nik))
209 safe_allocate(mm(1:nst, 1:nst, 1:nik, 1:n_pairs))
210 safe_allocate(mk(1:gr%np_part, 1:psi_in%d%dim))
211 safe_allocate(lambda(1:n_pairs, 1:n_pairs))
213 call zstates_elec_matrix(tg%est%st, psi_in, gr, mat)
216 ci(ia) = tg%est%weight(ia)
217 call zstates_elec_matrix_swap(mat, tg%est%pair(ia))
218 mm(1:nst, 1:nst, 1:nik, ia) = mat(1:nst, 1:nik, 1:nik)
219 di(ia) = zstates_elec_mpdotp(namespace, gr, tg%est%st, psi_in, mat)
220 if (abs(di(ia)) > 1.0e-12_real64)
then
222 call lalg_inverse(nst, mm(1:nst, 1:nst, ik, ia),
'dir')
225 call zstates_elec_matrix_swap(mat, tg%est%pair(ia))
230 lambda(ia, ib) = conjg(ci(ib)) * ci(ia) * conjg(di(ia)) * di(ib)
234 select case (psi_in%d%ispin)
236 write(message(1),
'(a)')
'Internal error in target.target_chi: unpolarized.'
237 call messages_fatal(1, namespace=namespace)
239 case (spin_polarized)
240 assert(chi_out%nik == 2)
243 do ist = chi_out%st_start, chi_out%st_end
245 zchi(1:gr%np, 1:psi_in%d%dim) = m_z0
248 if (ik /= tg%est%pair(ia)%kk) cycle
249 if (abs(di(ia)) < 1.0e-12_real64) cycle
251 if (abs(di(ib)) < 1.0e-12_real64) cycle
255 if (jst == tg%est%pair(ib)%i) jj = tg%est%pair(ia)%a
256 call states_elec_get_state(tg%est%st, gr, jj, ik, zpsi)
258 do idim = 1, psi_in%d%dim
260 mk(ip, idim) = mk(ip, idim) + conjg(mm(ist, jst, ik, ib))*zpsi(ip, idim)
265 call lalg_axpy(gr%np_part, psi_in%d%dim, m_z1*lambda(ib, ia), mk, zchi)
270 call states_elec_set_state(chi_out, gr, ist, ik, zchi)
276 assert(chi_out%nik == 1)
278 do ist = chi_out%st_start, chi_out%st_end
280 zchi(1:gr%np, 1:psi_in%d%dim) = m_z0
283 if (abs(di(ia)) < 1.0e-12_real64) cycle
286 if (abs(di(ib)) < 1.0e-12_real64) cycle
290 if (jst == tg%est%pair(ib)%i) jj = tg%est%pair(ia)%a
291 call states_elec_get_state(tg%est%st, gr, jj, ik, zpsi)
293 do idim = 1, psi_in%d%dim
295 mk(ip, idim) = mk(ip, idim) + conjg(mm(ist, jst, 1, ib))*zpsi(ip, idim)
300 call lalg_axpy(gr%np_part, 2, m_z1*lambda(ib, ia), mk, zchi)
304 call states_elec_set_state(chi_out, gr, ist, ik, zchi)
310 safe_deallocate_a(zpsi)
311 safe_deallocate_a(zchi)
312 safe_deallocate_a(ci)
313 safe_deallocate_a(di)
314 safe_deallocate_a(mat)
315 safe_deallocate_a(mm)
316 safe_deallocate_a(mk)
317 safe_deallocate_a(lambda)
integer, parameter, public spinors
subroutine, public excited_states_output(excited_state, dirname, namespace)
subroutine, public excited_states_init(excited_state, ground_state, filename, namespace)
Fills in an excited_state structure, by reading a file called "filename". This file describes the "pr...
This module implements the underlying real-space grid.
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)
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 states_elec_allocate_wfns(st, mesh, wfs_type, skip, packed)
Allocates the KS wavefunctions defined within a states_elec_t structure.
subroutine, public states_elec_look(restart, nik, dim, nst, ierr)
Reads the 'states' file in the restart directory, and finds out the nik, dim, and nst contained in it...
This module handles reading and writing restart information for the states_elec_t.
subroutine, public states_elec_load(restart, namespace, space, st, mesh, kpoints, fixed_occ, ierr, iter, lr, lowest_missing, label, verbose, skip)
returns in ierr: <0 => Fatal error, or nothing read =0 => read all wavefunctions >0 => could only rea...
subroutine target_output_excited(tg, namespace, space, gr, dir, ions, hm, outp)
real(real64) function target_j1_excited(tg, namespace, gr, kpoints, qcpsi, ions)
subroutine target_chi_excited(tg, namespace, gr, kpoints, qcpsi_in, qcchi_out, ions)
subroutine target_init_excited(tg, gr, kpoints, namespace, space, ions, qcs, td, w0, oct, ep, restart)
Optimal-control targets: abstract base class and public interface.
type(type_t), parameter, public type_cmplx
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.
Target projecting onto a linear combination of Slater determinants.
Abstract optimal-control target.