-
Notifications
You must be signed in to change notification settings - Fork 1
/
xas_control.F
309 lines (258 loc) · 13.1 KB
/
xas_control.F
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
!--------------------------------------------------------------------------------------------------!
! CP2K: A general program to perform molecular dynamics simulations !
! Copyright 2000-2024 CP2K developers group <https://cp2k.org> !
! !
! SPDX-License-Identifier: GPL-2.0-or-later !
!--------------------------------------------------------------------------------------------------!
! **************************************************************************************************
!> \brief Defines control structures, which contain the parameters and the
!> settings for the calculations.
! **************************************************************************************************
MODULE xas_control
USE cp_log_handling, ONLY: cp_get_default_logger,&
cp_logger_type,&
cp_to_string
USE cp_output_handling, ONLY: cp_print_key_finished_output,&
cp_print_key_unit_nr
USE input_constants, ONLY: xas_1s_type,&
xas_dscf,&
xas_tp_fh,&
xas_tp_flex,&
xas_tp_hh,&
xas_tp_xfh,&
xas_tp_xhh,&
xes_tp_val
USE input_section_types, ONLY: section_vals_type,&
section_vals_val_get
USE kinds, ONLY: dp
USE memory_utilities, ONLY: reallocate
#include "./base/base_uses.f90"
IMPLICIT NONE
PRIVATE
! **************************************************************************************************
!> \brief A type that holds controlling information for a xas calculation
! **************************************************************************************************
TYPE xas_control_type
INTEGER :: nexc_atoms = 0
INTEGER :: nexc_search = 0
INTEGER :: spin_channel = 0
INTEGER :: state_type = 0
INTEGER :: xas_method = 0
INTEGER :: dipole_form = 0
INTEGER :: added_mos = 0
INTEGER :: max_iter_added = 0
INTEGER :: ngauss = 0
INTEGER :: stride = 0
INTEGER, DIMENSION(:), POINTER :: exc_atoms => NULL()
INTEGER, DIMENSION(:), POINTER :: orbital_list => NULL()
LOGICAL :: cubes = .FALSE., do_centers = .FALSE.
LOGICAL :: xas_restart = .FALSE.
INTEGER, DIMENSION(:), POINTER :: list_cubes => NULL()
!
REAL(dp) :: eps_added = 0.0_dp, overlap_threshold = 0.0_dp
REAL(dp) :: xes_core_occupation = 0.0_dp
REAL(dp) :: xes_homo_occupation = 0.0_dp
REAL(dp) :: nel_tot = 0.0_dp, xas_core_occupation = 0.0_dp
END TYPE xas_control_type
CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'xas_control'
! *** Public data types ***
PUBLIC :: xas_control_type
! *** Public subroutines ***
PUBLIC :: read_xas_control, write_xas_control, xas_control_create, &
xas_control_release
CONTAINS
! **************************************************************************************************
!> \brief read from input the instructions for a xes/xas calculation
!> \param xas_control control variables
!> error
!> \param xas_section ...
!> \par History
!> 04.2005 created [MI]
! **************************************************************************************************
SUBROUTINE read_xas_control(xas_control, xas_section)
TYPE(xas_control_type), INTENT(INOUT) :: xas_control
TYPE(section_vals_type), POINTER :: xas_section
INTEGER :: i, ir, n_rep, nex_at, nex_st
INTEGER, DIMENSION(:), POINTER :: list
LOGICAL :: hempty, was_present
was_present = .FALSE.
NULLIFY (list)
CALL section_vals_val_get(xas_section, "METHOD", &
i_val=xas_control%xas_method)
CALL section_vals_val_get(xas_section, "DIPOLE_FORM", &
i_val=xas_control%dipole_form)
CALL section_vals_val_get(xas_section, "RESTART", &
l_val=xas_control%xas_restart)
CALL section_vals_val_get(xas_section, "STATE_TYPE", &
i_val=xas_control%state_type)
CALL section_vals_val_get(xas_section, "STATE_SEARCH", &
i_val=xas_control%nexc_search)
CALL section_vals_val_get(xas_section, "SPIN_CHANNEL", &
i_val=xas_control%spin_channel)
CALL section_vals_val_get(xas_section, "XAS_CORE", &
r_val=xas_control%xas_core_occupation)
CALL section_vals_val_get(xas_section, "XAS_TOT_EL", &
r_val=xas_control%nel_tot)
CALL section_vals_val_get(xas_section, "XES_CORE", &
r_val=xas_control%xes_core_occupation)
CALL section_vals_val_get(xas_section, "XES_EMPTY_HOMO", &
l_val=hempty)
IF (hempty) THEN
xas_control%xes_homo_occupation = 0
ELSE
xas_control%xes_homo_occupation = 1
END IF
! It should be further generalized
IF (.NOT. ASSOCIATED(xas_control%exc_atoms)) THEN
CALL section_vals_val_get(xas_section, "ATOMS_LIST", &
n_rep_val=n_rep)
IF (n_rep > 0) THEN
nex_at = 0
DO ir = 1, n_rep
NULLIFY (list)
CALL section_vals_val_get(xas_section, "ATOMS_LIST", &
i_rep_val=ir, i_vals=list)
IF (ASSOCIATED(list)) THEN
CALL reallocate(xas_control%exc_atoms, 1, nex_at + SIZE(list))
DO i = 1, SIZE(list)
xas_control%exc_atoms(i + nex_at) = list(i)
END DO
xas_control%nexc_atoms = nex_at + SIZE(list)
nex_at = nex_at + SIZE(list)
END IF
END DO ! ir
END IF
END IF
IF (.NOT. ASSOCIATED(xas_control%exc_atoms)) THEN
xas_control%nexc_atoms = 1
ALLOCATE (xas_control%exc_atoms(1))
xas_control%exc_atoms(1) = 1
END IF
CALL section_vals_val_get(xas_section, "ADDED_MOS", &
i_val=xas_control%added_mos)
CALL section_vals_val_get(xas_section, "MAX_ITER_ADDED", &
i_val=xas_control%max_iter_added)
CALL section_vals_val_get(xas_section, "EPS_ADDED", &
r_val=xas_control%eps_added)
CALL section_vals_val_get(xas_section, "NGAUSS", &
i_val=xas_control%ngauss)
CALL section_vals_val_get(xas_section, "OVERLAP_THRESHOLD", &
r_val=xas_control%overlap_threshold)
CALL section_vals_val_get(xas_section, "ORBITAL_LIST", &
n_rep_val=n_rep)
IF (n_rep > 0) THEN
nex_st = 0
DO ir = 1, n_rep
NULLIFY (list)
CALL section_vals_val_get(xas_section, "ORBITAL_LIST", &
i_rep_val=ir, i_vals=list)
IF (ASSOCIATED(list)) THEN
CALL reallocate(xas_control%orbital_list, 1, nex_st + SIZE(list))
DO i = 1, SIZE(list)
xas_control%orbital_list(i + nex_st) = list(i)
END DO
nex_st = nex_st + SIZE(list)
END IF
END DO ! ir
ELSE
ALLOCATE (xas_control%orbital_list(1))
xas_control%orbital_list(1) = -1
END IF
END SUBROUTINE read_xas_control
! **************************************************************************************************
!> \brief write on the instructions for a xes/xas calculation
!> \param xas_control control variables
!> error
!> \param dft_section ...
!> \par History
!> 12.2005 created [MI]
! **************************************************************************************************
SUBROUTINE write_xas_control(xas_control, dft_section)
TYPE(xas_control_type), INTENT(IN) :: xas_control
TYPE(section_vals_type), POINTER :: dft_section
INTEGER :: output_unit
TYPE(cp_logger_type), POINTER :: logger
logger => cp_get_default_logger()
output_unit = cp_print_key_unit_nr(logger, dft_section, &
"PRINT%DFT_CONTROL_PARAMETERS", extension=".Log")
IF (output_unit > 0) THEN
SELECT CASE (xas_control%xas_method)
CASE (xas_tp_hh)
WRITE (UNIT=output_unit, FMT="(/,T2,A,T40,A)") &
"XAS| Method:", &
" Transition potential with half hole"
CASE (xas_tp_xhh)
WRITE (UNIT=output_unit, FMT="(/,T2,A,T40,A)") &
"XAS| Method:", &
" Transition potential with excited half hole"
CASE (xas_tp_fh)
WRITE (UNIT=output_unit, FMT="(/,T2,A,T40,A)") &
"XAS| Method:", &
" Transition potential with full hole"
CASE (xas_tp_xfh)
WRITE (UNIT=output_unit, FMT="(/,T2,A,T40,A)") &
"XAS| Method:", &
" Transition potential with excited full hole"
CASE (xes_tp_val)
WRITE (UNIT=output_unit, FMT="(/,T2,A,T40,A)") &
"XAS| Method:", &
" Only XES with full core and hole in lumo"
CASE (xas_tp_flex)
WRITE (UNIT=output_unit, FMT="(/,T2,A,T25,A)") &
"XAS| Method:", &
" Transition potential with occupation of core state given from input"
CASE (xas_dscf)
WRITE (UNIT=output_unit, FMT="(/,T2,A,T40,A)") &
"XAS| Method:", &
" DSCF for the first excited state"
CASE default
CPABORT("unknown xas method "//TRIM(ADJUSTL(cp_to_string(xas_control%xas_method))))
END SELECT
IF (xas_control%xas_restart) THEN
WRITE (UNIT=output_unit, FMT="(/,T2,A,T30,A)") &
"XAS|", " Orbitals read from atom-specific restart file when available"
END IF
END IF
CALL cp_print_key_finished_output(output_unit, logger, dft_section, &
"PRINT%DFT_CONTROL_PARAMETERS")
END SUBROUTINE write_xas_control
! **************************************************************************************************
!> \brief create retain release the xas_control_type
!> \param xas_control ...
!> \par History
!> 04.2005 created [MI]
! **************************************************************************************************
SUBROUTINE xas_control_create(xas_control)
TYPE(xas_control_type), INTENT(OUT) :: xas_control
xas_control%xas_method = xas_tp_hh
xas_control%nexc_atoms = 1
xas_control%spin_channel = 1
xas_control%nexc_search = -1
xas_control%state_type = xas_1s_type
xas_control%xas_restart = .FALSE.
xas_control%added_mos = 0
xas_control%xes_core_occupation = 1.0_dp
xas_control%xes_homo_occupation = 1.0_dp
NULLIFY (xas_control%exc_atoms)
NULLIFY (xas_control%orbital_list)
xas_control%cubes = .FALSE.
xas_control%do_centers = .FALSE.
NULLIFY (xas_control%list_cubes)
END SUBROUTINE xas_control_create
! **************************************************************************************************
!> \brief ...
!> \param xas_control ...
! **************************************************************************************************
SUBROUTINE xas_control_release(xas_control)
TYPE(xas_control_type), INTENT(INOUT) :: xas_control
IF (ASSOCIATED(xas_control%exc_atoms)) THEN
DEALLOCATE (xas_control%exc_atoms)
END IF
IF (ASSOCIATED(xas_control%orbital_list)) THEN
DEALLOCATE (xas_control%orbital_list)
END IF
IF (ASSOCIATED(xas_control%list_cubes)) THEN
DEALLOCATE (xas_control%list_cubes)
END IF
END SUBROUTINE xas_control_release
END MODULE xas_control