30 use,
intrinsic :: iso_fortran_env
67 subroutine target_init_groundstate(tg, gr, kpoints, namespace, space, ions, qcs, td, w0, oct, ep, restart)
68 class(target_ground_state_t),
intent(inout) :: tg
69 type(grid_t),
intent(in) :: gr
70 type(kpoints_t),
intent(in) :: kpoints
71 type(namespace_t),
intent(in) :: namespace
72 class(space_t),
intent(in) :: space
73 type(ions_t),
intent(in) :: ions
74 type(opt_control_state_t),
intent(inout) :: qcs
75 type(td_t),
intent(in) :: td
76 real(real64),
intent(in) :: w0
77 type(oct_t),
intent(in) :: oct
78 type(epot_t),
intent(inout) :: ep
79 type(restart_t),
intent(inout) :: restart
85 message(1) =
'Info: Using Ground State for TargetOperator'
88 call states_elec_load(restart, namespace, space, tg%st, gr, kpoints, fixed_occ=.
true., ierr=ierr)
90 message(1) =
"Unable to read wavefunctions."
94 tg%move_ions = td%ions_dyn%ions_move()
103 class(target_ground_state_t),
intent(inout) :: tg
104 type(namespace_t),
intent(in) :: namespace
105 class(space_t),
intent(in) :: space
106 type(grid_t),
intent(in) :: gr
107 character(len=*),
intent(in) :: dir
108 type(ions_t),
intent(in) :: ions
109 type(hamiltonian_elec_t),
intent(in) :: hm
110 type(output_t),
intent(in) :: outp
115 call output_states(outp, namespace, space, trim(dir), tg%st, gr, ions, hm, -1)
124 real(real64) function target_j1_groundstate(tg, namespace, gr, kpoints, qcpsi, ions) result(j1)
125 class(target_ground_state_t),
intent(inout) :: tg
126 type(namespace_t),
intent(in) :: namespace
127 type(grid_t),
intent(in) :: gr
128 type(kpoints_t),
intent(in) :: kpoints
129 type(opt_control_state_t),
intent(inout) :: qcpsi
130 type(ions_t),
optional,
intent(in) :: ions
133 complex(real64),
allocatable :: zpsi(:, :), zst(:, :)
134 type(states_elec_t),
pointer :: psi
136 push_sub(target_j1_groundstate)
140 safe_allocate(zpsi(1:gr%np, 1:tg%st%d%dim))
141 safe_allocate(zst(1:gr%np, 1:tg%st%d%dim))
146 do ist = psi%st_start, psi%st_end
150 j1 = j1 + psi%occ(ist, ik)*abs(
zmf_dotp(gr, psi%d%dim, zpsi, zst))**2
155 safe_deallocate_a(zpsi)
156 safe_deallocate_a(zst)
159 pop_sub(target_j1_groundstate)
167 type(namespace_t),
intent(in) :: namespace
168 type(grid_t),
intent(in) :: gr
169 type(kpoints_t),
intent(in) :: kpoints
170 type(opt_control_state_t),
target,
intent(inout) :: qcpsi_in
171 type(opt_control_state_t),
target,
intent(inout) :: qcchi_out
172 type(ions_t),
intent(in) :: ions
175 complex(real64) :: olap
176 complex(real64),
allocatable :: zpsi(:, :), zst(:, :), zchi(:, :)
177 type(states_elec_t),
pointer :: psi_in, chi_out
181 psi_in => opt_control_point_qs(qcpsi_in)
182 chi_out => opt_control_point_qs(qcchi_out)
184 safe_allocate(zpsi(1:gr%np, 1:tg%st%d%dim))
185 safe_allocate(zst(1:gr%np, 1:tg%st%d%dim))
186 safe_allocate(zchi(1:gr%np, 1:tg%st%d%dim))
188 do ik = 1, psi_in%nik
189 do ist = psi_in%st_start, psi_in%st_end
191 call states_elec_get_state(psi_in, gr, ist, ik, zpsi)
192 call states_elec_get_state(tg%st, gr, ist, ik, zst)
194 olap = zmf_dotp(gr, zst(:, 1), zpsi(:, 1))
195 zchi(1:gr%np, 1:tg%st%d%dim) = olap*zst(1:gr%np, 1:tg%st%d%dim)
197 call states_elec_set_state(chi_out, gr, ist, ik, zchi)
202 safe_deallocate_a(zpsi)
203 safe_deallocate_a(zst)
204 safe_deallocate_a(zchi)
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.
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)
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_chi_groundstate(tg, namespace, gr, kpoints, qcpsi_in, qcchi_out, ions)
subroutine target_init_groundstate(tg, gr, kpoints, namespace, space, ions, qcs, td, w0, oct, ep, restart)
subroutine target_output_groundstate(tg, namespace, space, gr, dir, ions, hm, outp)
real(real64) function target_j1_groundstate(tg, namespace, gr, kpoints, qcpsi, ions)
Optimal-control targets: abstract base class and public interface.
Target projecting onto the ground state.
Abstract optimal-control target.