31 use,
intrinsic :: iso_fortran_env
59 character(len=80) :: excluded_states_list
72 subroutine target_init_exclude(tg, gr, kpoints, namespace, space, ions, qcs, td, w0, oct, ep, restart)
73 class(target_exclude_t),
intent(inout) :: tg
74 type(grid_t),
intent(in) :: gr
75 type(kpoints_t),
intent(in) :: kpoints
76 type(namespace_t),
intent(in) :: namespace
77 class(space_t),
intent(in) :: space
78 type(ions_t),
intent(in) :: ions
79 type(opt_control_state_t),
intent(inout) :: qcs
80 type(td_t),
intent(in) :: td
81 real(real64),
intent(in) :: w0
82 type(oct_t),
intent(in) :: oct
83 type(epot_t),
intent(inout) :: ep
84 type(restart_t),
intent(inout) :: restart
88 tg%move_ions = td%ions_dyn%ions_move()
91 message(1) =
'Info: The target functional is the exclusion of a number of states defined by'
92 message(2) =
' "OCTExcludedStates".'
104 call parse_variable(namespace,
'OCTExcludedStates',
'1', tg%excluded_states_list)
115 class(target_exclude_t),
intent(inout) :: tg
116 type(namespace_t),
intent(in) :: namespace
117 class(space_t),
intent(in) :: space
118 type(grid_t),
intent(in) :: gr
119 character(len=*),
intent(in) :: dir
120 type(ions_t),
intent(in) :: ions
121 type(hamiltonian_elec_t),
intent(in) :: hm
122 type(output_t),
intent(in) :: outp
127 call output_states(outp, namespace, space, trim(dir), tg%st, gr, ions, hm, -1)
136 real(real64) function target_j1_exclude(tg, namespace, gr, kpoints, qcpsi, ions) result(j1)
137 class(target_exclude_t),
intent(inout) :: tg
138 type(namespace_t),
intent(in) :: namespace
139 type(grid_t),
intent(in) :: gr
140 type(kpoints_t),
intent(in) :: kpoints
141 type(opt_control_state_t),
intent(inout) :: qcpsi
142 type(ions_t),
optional,
intent(in) :: ions
145 complex(real64),
allocatable :: zpsi1(:, :), zpsi(:, :)
146 type(states_elec_t),
pointer :: psi
148 push_sub(target_j1_exclude)
152 safe_allocate(zpsi(1:gr%np, 1:tg%st%d%dim))
153 safe_allocate(zpsi1(1:gr%np, 1:tg%st%d%dim))
158 do ist = 1, tg%st%nst
161 j1 = j1 - abs(
zmf_dotp(gr, psi%d%dim, zpsi, zpsi1))**2
165 safe_deallocate_a(zpsi)
166 safe_deallocate_a(zpsi1)
169 pop_sub(target_j1_exclude)
177 type(namespace_t),
intent(in) :: namespace
178 type(grid_t),
intent(in) :: gr
179 type(kpoints_t),
intent(in) :: kpoints
180 type(opt_control_state_t),
target,
intent(inout) :: qcpsi_in
181 type(opt_control_state_t),
target,
intent(inout) :: qcchi_out
182 type(ions_t),
intent(in) :: ions
185 complex(real64) :: olap
186 complex(real64),
allocatable :: zpsi(:, :), zst(:, :), zchi(:, :)
187 type(states_elec_t),
pointer :: psi_in, chi_out
190 psi_in => opt_control_point_qs(qcpsi_in)
191 chi_out => opt_control_point_qs(qcchi_out)
193 do ib = chi_out%group%block_start, chi_out%group%block_end
194 call psi_in%group%psib(ib, 1)%copy_data_to(gr%np, chi_out%group%psib(ib, 1))
197 safe_allocate(zpsi(1:gr%np, 1:tg%st%d%dim))
198 safe_allocate(zst(1:gr%np, 1:tg%st%d%dim))
199 safe_allocate(zchi(1:gr%np, 1:tg%st%d%dim))
201 call states_elec_get_state(chi_out, gr, 1, 1, zchi)
203 do ist = 1, tg%st%nst
204 if (loct_isinstringlist(ist, tg%excluded_states_list))
then
205 call states_elec_get_state(psi_in, gr, ist, 1, zpsi)
206 call states_elec_get_state(tg%st, gr, ist, 1, zst)
207 olap = zmf_dotp(gr, psi_in%d%dim, zst, zpsi)
208 zchi(1:gr%np, 1:tg%st%d%dim) = zchi(1:gr%np, 1:tg%st%d%dim) - olap*zst(1:gr%np, 1:tg%st%d%dim)
212 call states_elec_set_state(chi_out, gr, 1, 1, zchi)
214 safe_deallocate_a(zpsi)
215 safe_deallocate_a(zst)
216 safe_deallocate_a(zchi)
real(real64), parameter, public m_one
This module implements the underlying real-space grid.
subroutine, public io_mkdir(fname, namespace, parents)
System information (time, memory, sysname)
logical function, public loct_isinstringlist(a, s)
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_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_deallocate_wfns(st)
Deallocates the KS wavefunctions defined within a states_elec_t structure.
This module handles reading and writing restart information for the states_elec_t.
subroutine, public states_elec_look_and_load(restart, namespace, space, st, mesh, kpoints, fixed_occ, is_complex, packed)
real(real64) function target_j1_exclude(tg, namespace, gr, kpoints, qcpsi, ions)
subroutine target_init_exclude(tg, gr, kpoints, namespace, space, ions, qcs, td, w0, oct, ep, restart)
subroutine target_output_exclude(tg, namespace, space, gr, dir, ions, hm, outp)
subroutine target_chi_exclude(tg, namespace, gr, kpoints, qcpsi_in, qcchi_out, ions)
Optimal-control targets: abstract base class and public interface.
Target projecting onto the complement of a set of states.
Abstract optimal-control target.