(git:374b731)
Loading...
Searching...
No Matches
xas_control.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2024 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7
8! **************************************************************************************************
9!> \brief Defines control structures, which contain the parameters and the
10!> settings for the calculations.
11! **************************************************************************************************
13
19 USE input_constants, ONLY: xas_1s_type,&
20 xas_dscf,&
21 xas_tp_fh,&
23 xas_tp_hh,&
29 USE kinds, ONLY: dp
31#include "./base/base_uses.f90"
32
33 IMPLICIT NONE
34
35 PRIVATE
36
37! **************************************************************************************************
38!> \brief A type that holds controlling information for a xas calculation
39! **************************************************************************************************
41 INTEGER :: nexc_atoms = 0
42 INTEGER :: nexc_search = 0
43 INTEGER :: spin_channel = 0
44 INTEGER :: state_type = 0
45 INTEGER :: xas_method = 0
46 INTEGER :: dipole_form = 0
47 INTEGER :: added_mos = 0
48 INTEGER :: max_iter_added = 0
49 INTEGER :: ngauss = 0
50 INTEGER :: stride = 0
51 INTEGER, DIMENSION(:), POINTER :: exc_atoms => null()
52 INTEGER, DIMENSION(:), POINTER :: orbital_list => null()
53 LOGICAL :: cubes = .false., do_centers = .false.
54 LOGICAL :: xas_restart = .false.
55 INTEGER, DIMENSION(:), POINTER :: list_cubes => null()
56!
57 REAL(dp) :: eps_added = 0.0_dp, overlap_threshold = 0.0_dp
58 REAL(dp) :: xes_core_occupation = 0.0_dp
59 REAL(dp) :: xes_homo_occupation = 0.0_dp
60 REAL(dp) :: nel_tot = 0.0_dp, xas_core_occupation = 0.0_dp
61 END TYPE xas_control_type
62
63 CHARACTER(len=*), PARAMETER, PRIVATE :: modulen = 'xas_control'
64
65! *** Public data types ***
66
67 PUBLIC :: xas_control_type
68
69! *** Public subroutines ***
70
73
74CONTAINS
75
76! **************************************************************************************************
77!> \brief read from input the instructions for a xes/xas calculation
78!> \param xas_control control variables
79!> error
80!> \param xas_section ...
81!> \par History
82!> 04.2005 created [MI]
83! **************************************************************************************************
84 SUBROUTINE read_xas_control(xas_control, xas_section)
85
86 TYPE(xas_control_type), INTENT(INOUT) :: xas_control
87 TYPE(section_vals_type), POINTER :: xas_section
88
89 INTEGER :: i, ir, n_rep, nex_at, nex_st
90 INTEGER, DIMENSION(:), POINTER :: list
91 LOGICAL :: hempty, was_present
92
93 was_present = .false.
94
95 NULLIFY (list)
96
97 CALL section_vals_val_get(xas_section, "METHOD", &
98 i_val=xas_control%xas_method)
99
100 CALL section_vals_val_get(xas_section, "DIPOLE_FORM", &
101 i_val=xas_control%dipole_form)
102
103 CALL section_vals_val_get(xas_section, "RESTART", &
104 l_val=xas_control%xas_restart)
105
106 CALL section_vals_val_get(xas_section, "STATE_TYPE", &
107 i_val=xas_control%state_type)
108
109 CALL section_vals_val_get(xas_section, "STATE_SEARCH", &
110 i_val=xas_control%nexc_search)
111
112 CALL section_vals_val_get(xas_section, "SPIN_CHANNEL", &
113 i_val=xas_control%spin_channel)
114
115 CALL section_vals_val_get(xas_section, "XAS_CORE", &
116 r_val=xas_control%xas_core_occupation)
117
118 CALL section_vals_val_get(xas_section, "XAS_TOT_EL", &
119 r_val=xas_control%nel_tot)
120
121 CALL section_vals_val_get(xas_section, "XES_CORE", &
122 r_val=xas_control%xes_core_occupation)
123
124 CALL section_vals_val_get(xas_section, "XES_EMPTY_HOMO", &
125 l_val=hempty)
126 IF (hempty) THEN
127 xas_control%xes_homo_occupation = 0
128 ELSE
129 xas_control%xes_homo_occupation = 1
130 END IF
131
132! It should be further generalized
133 IF (.NOT. ASSOCIATED(xas_control%exc_atoms)) THEN
134 CALL section_vals_val_get(xas_section, "ATOMS_LIST", &
135 n_rep_val=n_rep)
136
137 IF (n_rep > 0) THEN
138 nex_at = 0
139 DO ir = 1, n_rep
140 NULLIFY (list)
141 CALL section_vals_val_get(xas_section, "ATOMS_LIST", &
142 i_rep_val=ir, i_vals=list)
143
144 IF (ASSOCIATED(list)) THEN
145 CALL reallocate(xas_control%exc_atoms, 1, nex_at + SIZE(list))
146 DO i = 1, SIZE(list)
147 xas_control%exc_atoms(i + nex_at) = list(i)
148 END DO
149 xas_control%nexc_atoms = nex_at + SIZE(list)
150 nex_at = nex_at + SIZE(list)
151 END IF
152 END DO ! ir
153 END IF
154 END IF
155
156 IF (.NOT. ASSOCIATED(xas_control%exc_atoms)) THEN
157 xas_control%nexc_atoms = 1
158 ALLOCATE (xas_control%exc_atoms(1))
159 xas_control%exc_atoms(1) = 1
160 END IF
161
162 CALL section_vals_val_get(xas_section, "ADDED_MOS", &
163 i_val=xas_control%added_mos)
164
165 CALL section_vals_val_get(xas_section, "MAX_ITER_ADDED", &
166 i_val=xas_control%max_iter_added)
167
168 CALL section_vals_val_get(xas_section, "EPS_ADDED", &
169 r_val=xas_control%eps_added)
170
171 CALL section_vals_val_get(xas_section, "NGAUSS", &
172 i_val=xas_control%ngauss)
173
174 CALL section_vals_val_get(xas_section, "OVERLAP_THRESHOLD", &
175 r_val=xas_control%overlap_threshold)
176
177 CALL section_vals_val_get(xas_section, "ORBITAL_LIST", &
178 n_rep_val=n_rep)
179 IF (n_rep > 0) THEN
180 nex_st = 0
181 DO ir = 1, n_rep
182 NULLIFY (list)
183 CALL section_vals_val_get(xas_section, "ORBITAL_LIST", &
184 i_rep_val=ir, i_vals=list)
185
186 IF (ASSOCIATED(list)) THEN
187 CALL reallocate(xas_control%orbital_list, 1, nex_st + SIZE(list))
188 DO i = 1, SIZE(list)
189 xas_control%orbital_list(i + nex_st) = list(i)
190 END DO
191 nex_st = nex_st + SIZE(list)
192 END IF
193 END DO ! ir
194 ELSE
195 ALLOCATE (xas_control%orbital_list(1))
196 xas_control%orbital_list(1) = -1
197 END IF
198
199 END SUBROUTINE read_xas_control
200
201! **************************************************************************************************
202!> \brief write on the instructions for a xes/xas calculation
203!> \param xas_control control variables
204!> error
205!> \param dft_section ...
206!> \par History
207!> 12.2005 created [MI]
208! **************************************************************************************************
209 SUBROUTINE write_xas_control(xas_control, dft_section)
210
211 TYPE(xas_control_type), INTENT(IN) :: xas_control
212 TYPE(section_vals_type), POINTER :: dft_section
213
214 INTEGER :: output_unit
215 TYPE(cp_logger_type), POINTER :: logger
216
217 logger => cp_get_default_logger()
218 output_unit = cp_print_key_unit_nr(logger, dft_section, &
219 "PRINT%DFT_CONTROL_PARAMETERS", extension=".Log")
220 IF (output_unit > 0) THEN
221 SELECT CASE (xas_control%xas_method)
222 CASE (xas_tp_hh)
223 WRITE (unit=output_unit, fmt="(/,T2,A,T40,A)") &
224 "XAS| Method:", &
225 " Transition potential with half hole"
226 CASE (xas_tp_xhh)
227 WRITE (unit=output_unit, fmt="(/,T2,A,T40,A)") &
228 "XAS| Method:", &
229 " Transition potential with excited half hole"
230 CASE (xas_tp_fh)
231 WRITE (unit=output_unit, fmt="(/,T2,A,T40,A)") &
232 "XAS| Method:", &
233 " Transition potential with full hole"
234 CASE (xas_tp_xfh)
235 WRITE (unit=output_unit, fmt="(/,T2,A,T40,A)") &
236 "XAS| Method:", &
237 " Transition potential with excited full hole"
238 CASE (xes_tp_val)
239 WRITE (unit=output_unit, fmt="(/,T2,A,T40,A)") &
240 "XAS| Method:", &
241 " Only XES with full core and hole in lumo"
242 CASE (xas_tp_flex)
243 WRITE (unit=output_unit, fmt="(/,T2,A,T25,A)") &
244 "XAS| Method:", &
245 " Transition potential with occupation of core state given from input"
246 CASE (xas_dscf)
247 WRITE (unit=output_unit, fmt="(/,T2,A,T40,A)") &
248 "XAS| Method:", &
249 " DSCF for the first excited state"
250 CASE default
251 cpabort("unknown xas method "//trim(adjustl(cp_to_string(xas_control%xas_method))))
252 END SELECT
253 IF (xas_control%xas_restart) THEN
254 WRITE (unit=output_unit, fmt="(/,T2,A,T30,A)") &
255 "XAS|", " Orbitals read from atom-specific restart file when available"
256 END IF
257 END IF
258 CALL cp_print_key_finished_output(output_unit, logger, dft_section, &
259 "PRINT%DFT_CONTROL_PARAMETERS")
260 END SUBROUTINE write_xas_control
261
262! **************************************************************************************************
263!> \brief create retain release the xas_control_type
264!> \param xas_control ...
265!> \par History
266!> 04.2005 created [MI]
267! **************************************************************************************************
268 SUBROUTINE xas_control_create(xas_control)
269
270 TYPE(xas_control_type), INTENT(OUT) :: xas_control
271
272 xas_control%xas_method = xas_tp_hh
273 xas_control%nexc_atoms = 1
274 xas_control%spin_channel = 1
275 xas_control%nexc_search = -1
276 xas_control%state_type = xas_1s_type
277 xas_control%xas_restart = .false.
278 xas_control%added_mos = 0
279 xas_control%xes_core_occupation = 1.0_dp
280 xas_control%xes_homo_occupation = 1.0_dp
281 NULLIFY (xas_control%exc_atoms)
282 NULLIFY (xas_control%orbital_list)
283 xas_control%cubes = .false.
284 xas_control%do_centers = .false.
285 NULLIFY (xas_control%list_cubes)
286
287 END SUBROUTINE xas_control_create
288
289! **************************************************************************************************
290!> \brief ...
291!> \param xas_control ...
292! **************************************************************************************************
293 SUBROUTINE xas_control_release(xas_control)
294
295 TYPE(xas_control_type), INTENT(INOUT) :: xas_control
296
297 IF (ASSOCIATED(xas_control%exc_atoms)) THEN
298 DEALLOCATE (xas_control%exc_atoms)
299 END IF
300 IF (ASSOCIATED(xas_control%orbital_list)) THEN
301 DEALLOCATE (xas_control%orbital_list)
302 END IF
303 IF (ASSOCIATED(xas_control%list_cubes)) THEN
304 DEALLOCATE (xas_control%list_cubes)
305 END IF
306
307 END SUBROUTINE xas_control_release
308
309END MODULE xas_control
various routines to log and control the output. The idea is that decisions about where to log should ...
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
routines to handle the output, The idea is to remove the decision of wheter to output and what to out...
integer function, public cp_print_key_unit_nr(logger, basis_section, print_key_path, extension, middle_name, local, log_filename, ignore_should_output, file_form, file_position, file_action, file_status, do_backup, on_file, is_new_file, mpi_io, fout)
...
subroutine, public cp_print_key_finished_output(unit_nr, logger, basis_section, print_key_path, local, ignore_should_output, on_file, mpi_io)
should be called after you finish working with a unit obtained with cp_print_key_unit_nr,...
collects all constants needed in input so that they can be used without circular dependencies
integer, parameter, public xas_1s_type
integer, parameter, public xas_dscf
integer, parameter, public xas_tp_xhh
integer, parameter, public xas_tp_xfh
integer, parameter, public xas_tp_fh
integer, parameter, public xas_tp_flex
integer, parameter, public xas_tp_hh
integer, parameter, public xes_tp_val
objects that represent the structure of input sections and the data contained in an input section
subroutine, public section_vals_val_get(section_vals, keyword_name, i_rep_section, i_rep_val, n_rep_val, val, l_val, i_val, r_val, c_val, l_vals, i_vals, r_vals, c_vals, explicit)
returns the requested value
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
An array-based list which grows on demand. When the internal array is full, a new array of twice the ...
Definition list.F:24
Utility routines for the memory handling.
Defines control structures, which contain the parameters and the settings for the calculations.
Definition xas_control.F:12
subroutine, public xas_control_release(xas_control)
...
subroutine, public read_xas_control(xas_control, xas_section)
read from input the instructions for a xes/xas calculation
Definition xas_control.F:85
subroutine, public xas_control_create(xas_control)
create retain release the xas_control_type
subroutine, public write_xas_control(xas_control, dft_section)
write on the instructions for a xes/xas calculation
Initialize the XAS orbitals for specific core excitations Either the GS orbitals are used as initial ...
Definition xas_restart.F:20
type of a logger, at the moment it contains just a print level starting at which level it should be l...
A type that holds controlling information for a xas calculation.
Definition xas_control.F:40