Octopus
target_factory.F90
Go to the documentation of this file.
1!! Copyright (C) 2002-2006 M. Marques, A. Castro, A. Rubio, G. Bertsch
2!!
3!! This program is free software; you can redistribute it and/or modify
4!! it under the terms of the GNU General Public License as published by
5!! the Free Software Foundation; either version 2, or (at your option)
6!! any later version.
7!!
8!! This program is distributed in the hope that it will be useful,
9!! but WITHOUT ANY WARRANTY; without even the implied warranty of
10!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11!! GNU General Public License for more details.
12!!
13!! You should have received a copy of the GNU General Public License
14!! along with this program; if not, write to the Free Software
15!! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16!! 02110-1301, USA.
17!!
18
19#include "global.h"
20
29 use debug_oct_m
30 use epot_oct_m
31 use global_oct_m
32 use grid_oct_m
33 use ions_oct_m
34 use, intrinsic :: iso_fortran_env
41 use parser_oct_m
44 use space_oct_m
46 use target_oct_m
59 use td_oct_m
60 use types_oct_m
62
63 implicit none
64
65 private
66 public :: target_factory_create
67
68contains
69
70 ! ----------------------------------------------------------------------
75 function target_factory_create(gr, kpoints, namespace, space, ions, qcs, td, w0, oct, ep, mc) result(tg)
76 type(grid_t), intent(in) :: gr
77 type(kpoints_t), intent(in) :: kpoints
78 type(namespace_t), intent(in) :: namespace
79 class(space_t), intent(in) :: space
80 type(ions_t), intent(in) :: ions
81 type(opt_control_state_t), intent(inout) :: qcs
82 type(td_t), intent(in) :: td
83 real(real64), intent(in) :: w0
84 type(oct_t), intent(in) :: oct
85 type(epot_t), intent(inout) :: ep
86 type(multicomm_t), intent(in) :: mc
87 class(target_t), pointer :: tg
88
89 integer :: ierr, target_kind
90 type(states_elec_t), pointer :: stin
91 type(restart_t) :: restart
92
93 push_sub(target_factory_create)
94
95 stin => opt_control_point_qs(qcs)
96
97 !%Variable OCTTargetOperator
98 !%Type integer
99 !%Section Calculation Modes::Optimal Control
100 !%Default oct_tg_gstransformation
101 !%Description
102 !% The variable <tt>OCTTargetOperator</tt> prescribes which kind of target functional is
103 !% to be used.
104 !%Option oct_tg_groundstate 1
105 !% The target operator is a projection operator on the ground state, <i>i.e.</i> the
106 !% objective is to populate the ground state as much as possible.
107 !%Option oct_tg_excited 2
108 !% (Experimental) The target operator is an "excited state". This means that the target operator
109 !% is a linear combination of Slater determinants, each one formed by replacing
110 !% in the ground-state Slater determinant one occupied state with one excited
111 !% state (<i>i.e.</i> "single excitations"). The description of which excitations are
112 !% used, and with which weights, should be given in a file called
113 !% <tt>oct-excited-state-target</tt>.
114 !% See the documentation of subroutine <tt>excited_states_elec_init</tt> in the source
115 !% code in order to use this feature.
116 !%Option oct_tg_gstransformation 3
117 !% The target operator is a projection operator on a transformation of the ground-state
118 !% orbitals defined by the block <tt>OCTTargetTransformStates</tt>.
119 !%Option oct_tg_userdefined 4
120 !% (Experimental) Allows to define target state by using <tt>OCTTargetUserdefined</tt>.
121 !%Option oct_tg_jdensity 5
122 !% (Experimental)
123 !%Option oct_tg_local 6
124 !% (Experimental) The target operator is a local operator.
125 !%Option oct_tg_td_local 7
126 !% (Experimental) The target operator is a time-dependent local operator.
127 !%Option oct_tg_exclude_state 8
128 !% (Experimental) Target operator is the projection onto the complement of a given state, given by the
129 !% block <tt>OCTTargetTransformStates</tt>. This means that the target operator is the unity
130 !% operator minus the projector onto that state.
131 !%Option oct_tg_hhg 9
132 !% (Experimental) The target is the optimization of the HHG yield. You must supply the <tt>OCTOptimizeHarmonicSpectrum</tt>
133 !% block, and it attempts to optimize the maximum of the spectrum around each harmonic peak. You may
134 !% use only one of the gradient-less optimization schemes.
135 !%Option oct_tg_velocity 10
136 !% (Experimental) The target is a function of the velocities of the nuclei at the end of the influence of
137 !% the external field, defined by <tt>OCTVelocityTarget</tt>
138 !%Option oct_tg_hhgnew 12
139 !% (Experimental) The target is the optimization of the HHG yield. You must supply the
140 !% <tt>OCTHarmonicWeight</tt> string. It attempts to optimize the integral of the harmonic spectrum multiplied
141 !% by some user-defined weight function.
142 !%Option oct_tg_classical 13
143 !% (Experimental)
144 !%Option oct_tg_spin 14
145 !% (Experimental)
146 !%End
147 call parse_variable(namespace, 'OCTTargetOperator', oct_tg_gstransformation, target_kind)
148 if (target_kind == oct_tg_excited) call messages_experimental('OCTTargetOperator = oct_tg_excited', namespace=namespace)
149 if (target_kind == oct_tg_userdefined) call messages_experimental('OCTTargetOperator = oct_tg_userdefined')
150 if (target_kind == oct_tg_jdensity) call messages_experimental('OCTTargetOperator = oct_tg_jdensity', namespace=namespace)
151 if (target_kind == oct_tg_local) call messages_experimental('OCTTargetOperator = oct_tg_local', namespace=namespace)
152 if (target_kind == oct_tg_td_local) call messages_experimental('OCTTargetOperator = oct_tg_td_local', namespace=namespace)
153 if (target_kind == oct_tg_exclude_state) &
154 call messages_experimental('OCTTargetOperator = oct_tg_exclude_state', namespace=namespace)
155 if (target_kind == oct_tg_hhg) call messages_experimental('OCTTargetOperator = oct_tg_hhg', namespace=namespace)
156 if (target_kind == oct_tg_velocity) call messages_experimental('OCTTargetOperator = oct_tg_velocity', namespace=namespace)
157 if (target_kind == oct_tg_hhgnew) call messages_experimental('OCTTargetOperator = oct_tg_hhgnew', namespace=namespace)
158 if (target_kind == oct_tg_classical) call messages_experimental('OCTTargetOperator = oct_tg_classical', namespace=namespace)
159 if (target_kind == oct_tg_spin) call messages_experimental('OCTTargetOperator = oct_tg_spin', namespace=namespace)
160
161 if (.not. varinfo_valid_option('OCTTargetOperator', target_kind)) then
162 call messages_input_error(namespace, 'OCTTargetOperator')
163 end if
164
165 select case (target_kind)
166 case (oct_tg_groundstate)
167 allocate(target_ground_state_t :: tg)
168 case (oct_tg_excited)
169 allocate(target_excited_t :: tg)
171 allocate(target_exclude_t :: tg)
173 allocate(target_gstransformation_t :: tg)
174 case (oct_tg_userdefined)
175 allocate(target_userdefined_t :: tg)
176 case (oct_tg_jdensity)
177 allocate(target_density_t :: tg)
178 case (oct_tg_local)
179 allocate(target_local_t :: tg)
180 case (oct_tg_td_local)
181 allocate(target_tdlocal_t :: tg)
182 case (oct_tg_hhg)
183 allocate(target_hhg_t :: tg)
184 case (oct_tg_hhgnew)
185 allocate(target_hhgnew_t :: tg)
186 case (oct_tg_velocity)
187 allocate(target_velocity_t :: tg)
188 case (oct_tg_classical)
189 allocate(target_classical_t :: tg)
190 case (oct_tg_spin)
191 allocate(target_spin_t :: tg)
192 case default
193 write(message(1),'(a)') "Target Operator not properly defined."
194 call messages_fatal(1, namespace=namespace)
195 end select
196
197 ! Common initialization shared by every target kind.
198 tg%type = target_kind
199 tg%move_ions = .false.
200 tg%curr_functional = oct_no_curr
201
202 call states_elec_copy(tg%st, stin)
205 call restart%init(namespace, restart_gs, restart_type_load, mc, ierr, mesh=gr, exact=.true.)
206 if (ierr /= 0) then
207 message(1) = "Could not read gs for OCTTargetOperator."
208 call messages_fatal(1, namespace=namespace)
209 end if
210
211 call tg%init(gr, kpoints, namespace, space, ions, qcs, td, w0, oct, ep, restart)
212
213 call restart%end()
214
215 nullify(stin)
216 pop_sub(target_factory_create)
217 end function target_factory_create
218 ! ----------------------------------------------------------------------
219
220end module target_factory_oct_m
221
222!! Local Variables:
223!! mode: f90
224!! coding: utf-8
225!! End:
This module implements the underlying real-space grid.
Definition: grid.F90:119
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
Definition: messages.F90:162
subroutine, public messages_fatal(no_lines, only_root_writes, namespace)
Definition: messages.F90:410
subroutine, public messages_input_error(namespace, var, details, row, column)
Definition: messages.F90:691
subroutine, public messages_experimental(name, namespace)
Definition: messages.F90:1040
This module handles the communicators for the various parallelization strategies.
Definition: multicomm.F90:147
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)
integer, parameter, public restart_gs
Definition: restart.F90:156
integer, parameter, public restart_type_load
Definition: restart.F90:184
subroutine, public states_elec_deallocate_wfns(st)
Deallocates the KS wavefunctions defined within a states_elec_t structure.
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_copy(stout, stin, exclude_wfns, exclude_eigenval, special)
make a (selective) copy of a states_elec_t object
Factory for optimal-control targets.
class(target_t) function, pointer, public target_factory_create(gr, kpoints, namespace, space, ions, qcs, td, w0, oct, ep, mc)
Create and initialize the optimal-control target.
Optimal-control targets: abstract base class and public interface.
Definition: target.F90:132
integer, parameter, public oct_tg_jdensity
Definition: target.F90:246
integer, parameter, public oct_tg_userdefined
Definition: target.F90:246
integer, parameter, public oct_tg_hhgnew
Definition: target.F90:246
integer, parameter, public oct_tg_spin
Definition: target.F90:246
integer, parameter, public oct_no_curr
Definition: target.F90:265
integer, parameter, public oct_tg_velocity
Definition: target.F90:246
integer, parameter, public oct_tg_excited
Definition: target.F90:246
integer, parameter, public oct_tg_gstransformation
Definition: target.F90:246
integer, parameter, public oct_tg_groundstate
Definition: target.F90:246
integer, parameter, public oct_tg_td_local
Definition: target.F90:246
integer, parameter, public oct_tg_local
Definition: target.F90:246
integer, parameter, public oct_tg_hhg
Definition: target.F90:246
integer, parameter, public oct_tg_classical
Definition: target.F90:246
integer, parameter, public oct_tg_exclude_state
Definition: target.F90:246
Definition: td.F90:116
type(type_t), parameter, public type_cmplx
Definition: types.F90:136
Target on the classical degrees of freedom.
Target on the density and/or the current.
Target projecting onto a linear combination of Slater determinants.
Target projecting onto the complement of a set of states.
Target projecting onto the ground state.
Target projecting onto a transformation of the ground state.
Target on the harmonic emission spectrum (peak optimization).
Definition: target_hhg.F90:157
Target on the harmonic spectrum integrated with a weight function.
Definition: target_hhg.F90:175
Target that is a local (static) operator.
Target on the electronic spin.
Time-dependent local target operator.
Target projecting onto a user-defined state.
Target as a function of the ionic velocities.
int true(void)