29 use,
intrinsic :: iso_fortran_env
53 complex(real64) :: spin_matrix(2, 2)
66 subroutine target_init_spin(tg, gr, kpoints, namespace, space, ions, qcs, td, w0, oct, ep, restart)
67 class(target_spin_t),
intent(inout) :: tg
68 type(grid_t),
intent(in) :: gr
69 type(kpoints_t),
intent(in) :: kpoints
70 type(namespace_t),
intent(in) :: namespace
71 class(space_t),
intent(in) :: space
72 type(ions_t),
intent(in) :: ions
73 type(opt_control_state_t),
intent(inout) :: qcs
74 type(td_t),
intent(in) :: td
75 real(real64),
intent(in) :: w0
76 type(oct_t),
intent(in) :: oct
77 type(epot_t),
intent(inout) :: ep
78 type(restart_t),
intent(inout) :: restart
82 complex(real64) :: alpha(3)
87 message(1) =
'Info: Using a spin target'
97 if (
parse_block(namespace,
'OCTTargetSpin', blk) == 0)
then
104 alpha = alpha/norm2(abs(alpha))
106 tg%spin_matrix(1, 1) = alpha(3)
107 tg%spin_matrix(2, 2) = -alpha(3)
108 tg%spin_matrix(1, 2) = alpha(1) -
m_zi * alpha(2)
109 tg%spin_matrix(2, 1) = alpha(1) +
m_zi * alpha(2)
116 message(1) =
'If "OCTTargetOperator = oct_tg_spin", then you must'
117 message(2) =
'supply a "OCTTargetSpin" block.'
129 class(target_spin_t),
intent(inout) :: tg
130 type(namespace_t),
intent(in) :: namespace
131 class(space_t),
intent(in) :: space
132 type(grid_t),
intent(in) :: gr
133 character(len=*),
intent(in) :: dir
134 type(ions_t),
intent(in) :: ions
135 type(hamiltonian_elec_t),
intent(in) :: hm
136 type(output_t),
intent(in) :: outp
146 real(real64) function target_j1_spin(tg, namespace, gr, kpoints, qcpsi, ions) result(j1)
147 class(target_spin_t),
intent(inout) :: tg
149 type(
grid_t),
intent(in) :: gr
152 type(
ions_t),
optional,
intent(in) :: ions
155 complex(real64),
allocatable :: zpsi(:, :)
158 push_sub(target_j1_spin)
162 safe_allocate(zpsi(1:gr%np, 1:tg%st%d%dim))
169 j1 = j1 + real(tg%spin_matrix(i,j)*
zmf_dotp(gr, zpsi(:, i), zpsi(:, j)), real64)
173 safe_deallocate_a(zpsi)
176 pop_sub(target_j1_spin)
183 subroutine target_chi_spin(tg, namespace, gr, kpoints, qcpsi_in, qcchi_out, ions)
185 type(namespace_t),
intent(in) :: namespace
186 type(grid_t),
intent(in) :: gr
187 type(kpoints_t),
intent(in) :: kpoints
188 type(opt_control_state_t),
target,
intent(inout) :: qcpsi_in
189 type(opt_control_state_t),
target,
intent(inout) :: qcchi_out
190 type(ions_t),
intent(in) :: ions
193 complex(real64),
allocatable :: zpsi(:, :), zchi(:, :)
194 type(states_elec_t),
pointer :: psi_in, chi_out
198 psi_in => opt_control_point_qs(qcpsi_in)
199 chi_out => opt_control_point_qs(qcchi_out)
201 safe_allocate(zpsi(1:gr%np, 1:tg%st%d%dim))
202 safe_allocate(zchi(1:gr%np, 1:tg%st%d%dim))
204 call states_elec_get_state(psi_in, gr, 1, 1, zpsi)
206 zchi(1:gr%np, 1:tg%st%d%dim) = 0.0_real64
210 call lalg_axpy(gr%np, tg%spin_matrix(i, j), zpsi(:, j), zchi(:, i))
214 call states_elec_set_state(chi_out, gr, 1, 1, zchi)
216 safe_deallocate_a(zpsi)
217 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.