31 use,
intrinsic :: iso_fortran_env
67 class(mesh_t),
intent(in) :: mesh
68 type(namespace_t),
intent(in) :: namespace
69 class(space_t),
intent(in) :: space
70 type(target_t),
intent(inout) :: tg
71 type(td_t),
intent(in) :: td
72 type(restart_t),
intent(in) :: restart
73 type(kpoints_t),
intent(in) :: kpoints
75 integer :: ierr, nik, dim
79 message(1) =
'Info: TargetOperator is a linear combination of Slater determinants.'
82 tg%move_ions = td%ions_dyn%ions_move()
87 message(1) =
"Unable to read states information."
91 tg%st%st_end = tg%st%nst
93 safe_deallocate_a(tg%st%occ)
94 safe_deallocate_a(tg%st%eigenval)
95 safe_deallocate_a(tg%st%node)
97 safe_allocate( tg%st%occ(1:tg%st%nst, 1:tg%st%nik))
98 safe_allocate(tg%st%eigenval(1:tg%st%nst, 1:tg%st%nik))
99 safe_allocate( tg%st%node(1:tg%st%nst))
100 if (tg%st%d%ispin ==
spinors)
then
101 safe_deallocate_a(tg%st%spin)
102 safe_allocate(tg%st%spin(1:3, 1:tg%st%nst, 1:tg%st%nik))
107 call states_elec_load(restart, namespace, space, tg%st, mesh, kpoints, ierr)
109 message(1) =
"Unable to read wavefunctions."
121 type(target_t),
intent(in) :: tg
122 type(namespace_t),
intent(in) :: namespace
123 class(space_t),
intent(in) :: space
124 type(grid_t),
intent(in) :: gr
125 character(len=*),
intent(in) :: dir
126 type(ions_t),
intent(in) :: ions
127 type(hamiltonian_elec_t),
intent(in) :: hm
128 type(output_t),
intent(in) :: outp
133 call output_states(outp, namespace, space, trim(dir)//
'/st', tg%est%st, gr, ions, hm, -1)
143 real(real64) function target_j1_excited(tg, namespace, gr, psi) result(j1)
144 type(target_t),
intent(in) :: tg
145 type(namespace_t),
intent(in) :: namespace
146 type(grid_t),
intent(in) :: gr
147 type(states_elec_t),
intent(in) :: psi
149 push_sub(target_j1_excited)
153 pop_sub(target_j1_excited)
160 type(target_t),
intent(in) :: tg
161 type(namespace_t),
intent(in) :: namespace
162 type(grid_t),
intent(in) :: gr
163 type(states_elec_t),
intent(in) :: psi_in
164 type(states_elec_t),
intent(inout) :: chi_out
166 complex(real64),
allocatable :: ci(:), di(:), mat(:, :, :), mm(:, :, :, :), mk(:, :), lambda(:, :)
167 complex(real64),
allocatable :: zpsi(:, :), zchi(:, :)
168 integer :: ik, ist, jst, ia, ib, n_pairs, nst, kpoints, jj, idim, ip
171 n_pairs = tg%est%n_pairs
176 safe_allocate(zpsi(1:gr%np, 1:psi_in%d%dim))
177 safe_allocate(zchi(1:gr%np, 1:psi_in%d%dim))
178 safe_allocate(ci(1:n_pairs))
179 safe_allocate(di(1:n_pairs))
180 safe_allocate(mat(1:tg%est%st%nst, 1:nst, 1:psi_in%nik))
181 safe_allocate(mm(1:nst, 1:nst, 1:kpoints, 1:n_pairs))
182 safe_allocate(mk(1:gr%np_part, 1:psi_in%d%dim))
183 safe_allocate(lambda(1:n_pairs, 1:n_pairs))
185 call zstates_elec_matrix(tg%est%st, psi_in, gr, mat)
188 ci(ia) = tg%est%weight(ia)
189 call zstates_elec_matrix_swap(mat, tg%est%pair(ia))
190 mm(1:nst, 1:nst, 1:kpoints, ia) = mat(1:nst, 1:kpoints, 1:kpoints)
191 di(ia) = zstates_elec_mpdotp(namespace, gr, tg%est%st, psi_in, mat)
192 if (abs(di(ia)) > 1.0e-12_real64)
then
194 call lalg_inverse(nst, mm(1:nst, 1:nst, ik, ia),
'dir')
197 call zstates_elec_matrix_swap(mat, tg%est%pair(ia))
202 lambda(ia, ib) = conjg(ci(ib)) * ci(ia) * conjg(di(ia)) * di(ib)
206 select case (psi_in%d%ispin)
208 write(message(1),
'(a)')
'Internal error in target.target_chi: unpolarized.'
209 call messages_fatal(1, namespace=namespace)
211 case (spin_polarized)
212 assert(chi_out%nik == 2)
215 do ist = chi_out%st_start, chi_out%st_end
217 zchi(1:gr%np, 1:psi_in%d%dim) = m_z0
220 if (ik /= tg%est%pair(ia)%kk) cycle
221 if (abs(di(ia)) < 1.0e-12_real64) cycle
223 if (abs(di(ib)) < 1.0e-12_real64) cycle
227 if (jst == tg%est%pair(ib)%i) jj = tg%est%pair(ia)%a
228 call states_elec_get_state(tg%est%st, gr, jj, ik, zpsi)
230 do idim = 1, psi_in%d%dim
232 mk(ip, idim) = mk(ip, idim) + conjg(mm(ist, jst, ik, ib))*zpsi(ip, idim)
237 call lalg_axpy(gr%np_part, psi_in%d%dim, m_z1, lambda(ib, ia)*mk(:, :), zchi)
242 call states_elec_set_state(chi_out, gr, ist, ik, zchi)
248 assert(chi_out%nik == 1)
250 do ist = chi_out%st_start, chi_out%st_end
252 zchi(1:gr%np, 1:psi_in%d%dim) = m_z0
255 if (abs(di(ia)) < 1.0e-12_real64) cycle
258 if (abs(di(ib)) < 1.0e-12_real64) cycle
262 if (jst == tg%est%pair(ib)%i) jj = tg%est%pair(ia)%a
263 call states_elec_get_state(tg%est%st, gr, jj, ik, zpsi)
265 do idim = 1, psi_in%d%dim
267 mk(ip, idim) = mk(ip, idim) + conjg(mm(ist, jst, 1, ib))*zpsi(ip, idim)
272 call lalg_axpy(gr%np_part, 2, m_z1, lambda(ib, ia)*mk(:, :), zchi)
276 call states_elec_set_state(chi_out, gr, ist, ik, zchi)
282 safe_deallocate_a(zpsi)
283 safe_deallocate_a(zchi)
284 safe_deallocate_a(ci)
285 safe_deallocate_a(di)
286 safe_deallocate_a(mat)
287 safe_deallocate_a(mm)
288 safe_deallocate_a(mk)
289 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 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, 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, public target_init_excited(mesh, namespace, space, tg, td, restart, kpoints)
subroutine, public target_output_excited(tg, namespace, space, gr, dir, ions, hm, outp)
real(real64) function, public target_j1_excited(tg, namespace, gr, psi)
subroutine, public target_chi_excited(tg, namespace, gr, psi_in, chi_out)
type(type_t), public type_cmplx