28 use,
intrinsic :: iso_fortran_env
52 complex(real64) :: spin_matrix(2, 2)
65 subroutine target_init_spin(tg, gr, kpoints, namespace, space, ions, qcs, td, w0, oct, ep, restart)
66 class(target_spin_t),
intent(inout) :: tg
67 type(grid_t),
intent(in) :: gr
68 type(kpoints_t),
intent(in) :: kpoints
69 type(namespace_t),
intent(in) :: namespace
70 class(space_t),
intent(in) :: space
71 type(ions_t),
intent(in) :: ions
72 type(opt_control_state_t),
intent(inout) :: qcs
73 type(td_t),
intent(in) :: td
74 real(real64),
intent(in) :: w0
75 type(oct_t),
intent(in) :: oct
76 type(epot_t),
intent(inout) :: ep
77 type(restart_t),
intent(inout) :: restart
81 complex(real64) :: alpha(3)
86 message(1) =
'Info: Using a spin target'
96 if (
parse_block(namespace,
'OCTTargetSpin', blk) == 0)
then
103 alpha = alpha/norm2(abs(alpha))
105 tg%spin_matrix(1, 1) = alpha(3)
106 tg%spin_matrix(2, 2) = -alpha(3)
107 tg%spin_matrix(1, 2) = alpha(1) -
m_zi * alpha(2)
108 tg%spin_matrix(2, 1) = alpha(1) +
m_zi * alpha(2)
115 message(1) =
'If "OCTTargetOperator = oct_tg_spin", then you must'
116 message(2) =
'supply a "OCTTargetSpin" block.'
128 class(target_spin_t),
intent(inout) :: tg
129 type(namespace_t),
intent(in) :: namespace
130 class(space_t),
intent(in) :: space
131 type(grid_t),
intent(in) :: gr
132 character(len=*),
intent(in) :: dir
133 type(ions_t),
intent(in) :: ions
134 type(hamiltonian_elec_t),
intent(in) :: hm
135 type(output_t),
intent(in) :: outp
145 real(real64) function target_j1_spin(tg, namespace, gr, kpoints, qcpsi, ions) result(j1)
146 class(target_spin_t),
intent(inout) :: tg
148 type(
grid_t),
intent(in) :: gr
151 type(
ions_t),
optional,
intent(in) :: ions
154 complex(real64),
allocatable :: zpsi(:, :)
157 push_sub(target_j1_spin)
161 safe_allocate(zpsi(1:gr%np, 1:tg%st%d%dim))
168 j1 = j1 + real(tg%spin_matrix(i,j)*
zmf_dotp(gr, zpsi(:, i), zpsi(:, j)), real64)
172 safe_deallocate_a(zpsi)
175 pop_sub(target_j1_spin)
182 subroutine target_chi_spin(tg, namespace, gr, kpoints, qcpsi_in, qcchi_out, ions)
184 type(namespace_t),
intent(in) :: namespace
185 type(grid_t),
intent(in) :: gr
186 type(kpoints_t),
intent(in) :: kpoints
187 type(opt_control_state_t),
target,
intent(inout) :: qcpsi_in
188 type(opt_control_state_t),
target,
intent(inout) :: qcchi_out
189 type(ions_t),
intent(in) :: ions
192 complex(real64),
allocatable :: zpsi(:, :), zchi(:, :)
193 type(states_elec_t),
pointer :: psi_in, chi_out
197 psi_in => opt_control_point_qs(qcpsi_in)
198 chi_out => opt_control_point_qs(qcchi_out)
200 safe_allocate(zpsi(1:gr%np, 1:tg%st%d%dim))
201 safe_allocate(zchi(1:gr%np, 1:tg%st%d%dim))
203 call states_elec_get_state(psi_in, gr, 1, 1, zpsi)
205 zchi(1:gr%np, 1:tg%st%d%dim) = 0.0_real64
209 zchi(1:gr%np, i) = zchi(1:gr%np, i) + tg%spin_matrix(i, j)*zpsi(1:gr%np, j)
213 call states_elec_set_state(chi_out, gr, 1, 1, zchi)
215 safe_deallocate_a(zpsi)
216 safe_deallocate_a(zchi)
real(real64), parameter, public m_zero
complex(real64), parameter, public m_z0
complex(real64), parameter, public m_zi
This module implements the underlying real-space grid.
This module defines various routines, operating on mesh functions.
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_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
logical function, public parse_is_defined(namespace, name)
integer function, public parse_block(namespace, name, blk, check_varinfo_)
Optimal-control targets: abstract base class and public interface.
subroutine target_init_spin(tg, gr, kpoints, namespace, space, ions, qcs, td, w0, oct, ep, restart)
subroutine target_output_spin(tg, namespace, space, gr, dir, ions, hm, outp)
The spin target has no associated output.
real(real64) function target_j1_spin(tg, namespace, gr, kpoints, qcpsi, ions)
subroutine target_chi_spin(tg, namespace, gr, kpoints, qcpsi_in, qcchi_out, 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 on the electronic spin.