(git:374b731)
Loading...
Searching...
No Matches
xas_env_types.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 define create destroy get and put information
10!> in xas_env to calculate the x-ray absorption spectra
11!> \par History
12!> created 05.2005
13!> \author MI (05.2005)
14! **************************************************************************************************
16
23 USE cp_fm_types, ONLY: cp_fm_release,&
25 USE dbcsr_api, ONLY: dbcsr_p_type
26 USE kinds, ONLY: dp
29 USE qs_scf_types, ONLY: qs_scf_env_type,&
33#include "./base/base_uses.f90"
34
35 IMPLICIT NONE
36 PRIVATE
37
38 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'xas_env_types'
39
40! *** Public data types ***
41
42 PUBLIC :: xas_environment_type
43
44! *** Public subroutines ***
45
47
48! **************************************************************************************************
49!> \param nao number of atomic orbitals in the basis
50!> \param exc_state state that is now excited (this change atom by atom)
51!> \param nvirtual number of empy states to take into account for the spectrum
52!> \param state_of_atom for each atom the states that have to be excited (global index)
53!> dimension is the number of atoms to be excited by the largest number of included states
54!> \param atom_of_state atom to which each state is assigned,
55!> dimension is the number of states occupied that might be excited
56!> \param nexc_states number of states to be excited per atom
57!> dimension is the number of atoms to be excited
58!> \param type_of_state character of the state (1s,2s,2p...)
59!> \param spectrum for each excitation the energy and the oscillator strength
60!> \param centers_wfn for each wfn the center of charge (optimized by localization)
61!> \param groundstate_coeff temporary storage for the original mos coefficients
62!> \param ostrength_sm sin and cos integrals computed for the contracted GTO functions
63!> \param dip_fm_set fm for the sin and cos integrals to define the pos operator
64!> \param qs_loc_env environment for the localization procedure
65!> \par History
66!> created 05-2005
67!> \author MI
68! **************************************************************************************************
70 INTEGER :: nao = 0, exc_state = 0, xas_estate = 0
71 INTEGER :: nexc_search = 0, nexc_atoms = 0
72 INTEGER :: spin_channel = 0
73 INTEGER :: nvirtual = 0, nvirtual2 = 0
74 INTEGER :: unoccupied_max_iter = 0
75
76 INTEGER, DIMENSION(:), POINTER :: atom_of_state => null()
77 INTEGER, DIMENSION(:), POINTER :: type_of_state => null()
78 INTEGER, DIMENSION(:), POINTER :: mykind_of_atom => null()
79 INTEGER, DIMENSION(:), POINTER :: mykind_of_kind => null()
80 INTEGER, DIMENSION(:), POINTER :: exc_atoms => null()
81 INTEGER, DIMENSION(:), POINTER :: nexc_states => null()
82 INTEGER, DIMENSION(:, :), POINTER :: state_of_atom => null()
83
84 REAL(dp) :: ip_energy = 0.0_dp, occ_estate = 0.0_dp, unoccupied_eps = 0.0_dp, xas_nelectron = 0.0_dp, homo_occ = 0.0_dp
85 REAL(dp), DIMENSION(:), POINTER :: all_evals => null()
86 REAL(dp), DIMENSION(:), POINTER :: unoccupied_evals => null()
87 REAL(dp), DIMENSION(:, :), POINTER :: spectrum => null()
88 REAL(dp), DIMENSION(:, :), POINTER :: centers_wfn => null()
89 TYPE(cp_2d_r_p_type), DIMENSION(:), POINTER :: stogto_overlap => null()
90 TYPE(gto_basis_set_p_type), DIMENSION(:), POINTER :: my_gto_basis => null()
91 TYPE(cp_fm_type), DIMENSION(:), POINTER :: groundstate_coeff => null()
92 TYPE(cp_fm_type), DIMENSION(:, :), POINTER :: dip_fm_set => null()
93 TYPE(cp_fm_pool_p_type), DIMENSION(:), &
94 POINTER :: ao_mo_fm_pools => null()
95 TYPE(cp_fm_type), POINTER :: excvec_coeff => null()
96 TYPE(cp_fm_type), POINTER :: excvec_overlap => null()
97 TYPE(cp_fm_type), POINTER :: unoccupied_orbs => null()
98 TYPE(cp_fm_type), POINTER :: all_vectors => null()
99 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: ostrength_sm => null()
100 TYPE(qs_loc_env_type), POINTER :: qs_loc_env => null()
101 TYPE(qs_scf_env_type), POINTER :: scf_env => null()
102 TYPE(scf_control_type), POINTER :: scf_control => null()
103
104 END TYPE xas_environment_type
105
106CONTAINS
107! **************************************************************************************************
108!> \brief ...
109!> \param xas_env ...
110!> \param exc_state ...
111!> \param nao ...
112!> \param nvirtual ...
113!> \param nvirtual2 ...
114!> \param centers_wfn ...
115!> \param atom_of_state ...
116!> \param exc_atoms ...
117!> \param nexc_states ...
118!> \param type_of_state ...
119!> \param mykind_of_atom ...
120!> \param mykind_of_kind ...
121!> \param state_of_atom ...
122!> \param spectrum ...
123!> \param groundstate_coeff ...
124!> \param ostrength_sm ...
125!> \param dip_fm_set ...
126!> \param excvec_coeff ...
127!> \param excvec_overlap ...
128!> \param unoccupied_orbs ...
129!> \param unoccupied_evals ...
130!> \param unoccupied_max_iter ...
131!> \param unoccupied_eps ...
132!> \param all_vectors ...
133!> \param all_evals ...
134!> \param my_gto_basis ...
135!> \param qs_loc_env ...
136!> \param stogto_overlap ...
137!> \param occ_estate ...
138!> \param xas_nelectron ...
139!> \param xas_estate ...
140!> \param nexc_atoms ...
141!> \param nexc_search ...
142!> \param spin_channel ...
143!> \param scf_env ...
144!> \param scf_control ...
145! **************************************************************************************************
146 SUBROUTINE get_xas_env(xas_env, exc_state, nao, nvirtual, nvirtual2, &
147 centers_wfn, atom_of_state, exc_atoms, nexc_states, type_of_state, mykind_of_atom, &
148 mykind_of_kind, state_of_atom, spectrum, groundstate_coeff, ostrength_sm, &
149 dip_fm_set, excvec_coeff, excvec_overlap, &
150 unoccupied_orbs, unoccupied_evals, unoccupied_max_iter, unoccupied_eps, &
151 all_vectors, all_evals, my_gto_basis, qs_loc_env, &
152 stogto_overlap, occ_estate, xas_nelectron, xas_estate, nexc_atoms, nexc_search, spin_channel, &
153 scf_env, scf_control)
154
155 TYPE(xas_environment_type), INTENT(IN) :: xas_env
156 INTEGER, INTENT(OUT), OPTIONAL :: exc_state, nao, nvirtual, nvirtual2
157 REAL(dp), DIMENSION(:, :), OPTIONAL, POINTER :: centers_wfn
158 INTEGER, DIMENSION(:), OPTIONAL, POINTER :: atom_of_state, exc_atoms, nexc_states, &
159 type_of_state, mykind_of_atom, &
160 mykind_of_kind
161 INTEGER, DIMENSION(:, :), OPTIONAL, POINTER :: state_of_atom
162 REAL(dp), DIMENSION(:, :), OPTIONAL, POINTER :: spectrum
163 TYPE(cp_fm_type), DIMENSION(:), OPTIONAL, POINTER :: groundstate_coeff
164 TYPE(dbcsr_p_type), DIMENSION(:), OPTIONAL, &
165 POINTER :: ostrength_sm
166 TYPE(cp_fm_type), DIMENSION(:, :), OPTIONAL, &
167 POINTER :: dip_fm_set
168 TYPE(cp_fm_type), OPTIONAL, POINTER :: excvec_coeff, excvec_overlap, &
169 unoccupied_orbs
170 REAL(dp), DIMENSION(:), OPTIONAL, POINTER :: unoccupied_evals
171 INTEGER, INTENT(OUT), OPTIONAL :: unoccupied_max_iter
172 REAL(dp), OPTIONAL :: unoccupied_eps
173 TYPE(cp_fm_type), OPTIONAL, POINTER :: all_vectors
174 REAL(dp), DIMENSION(:), OPTIONAL, POINTER :: all_evals
175 TYPE(gto_basis_set_p_type), DIMENSION(:), &
176 OPTIONAL, POINTER :: my_gto_basis
177 TYPE(qs_loc_env_type), OPTIONAL, POINTER :: qs_loc_env
178 TYPE(cp_2d_r_p_type), DIMENSION(:), OPTIONAL, &
179 POINTER :: stogto_overlap
180 REAL(dp), INTENT(OUT), OPTIONAL :: occ_estate, xas_nelectron
181 INTEGER, INTENT(OUT), OPTIONAL :: xas_estate, nexc_atoms, nexc_search, &
182 spin_channel
183 TYPE(qs_scf_env_type), OPTIONAL, POINTER :: scf_env
184 TYPE(scf_control_type), OPTIONAL, POINTER :: scf_control
185
186 IF (PRESENT(exc_state)) exc_state = xas_env%exc_state
187 IF (PRESENT(nao)) nao = xas_env%nao
188 IF (PRESENT(nvirtual)) nvirtual = xas_env%nvirtual
189 IF (PRESENT(nvirtual2)) nvirtual2 = xas_env%nvirtual2
190 IF (PRESENT(xas_nelectron)) xas_nelectron = xas_env%xas_nelectron
191 IF (PRESENT(occ_estate)) occ_estate = xas_env%occ_estate
192 IF (PRESENT(xas_estate)) xas_estate = xas_env%xas_estate
193 IF (PRESENT(nexc_search)) nexc_search = xas_env%nexc_search
194 IF (PRESENT(nexc_states)) nexc_states => xas_env%nexc_states
195 IF (PRESENT(spin_channel)) spin_channel = xas_env%spin_channel
196 IF (PRESENT(nexc_atoms)) nexc_atoms = xas_env%nexc_atoms
197 IF (PRESENT(unoccupied_eps)) unoccupied_eps = xas_env%unoccupied_eps
198 IF (PRESENT(unoccupied_max_iter)) unoccupied_max_iter = xas_env%unoccupied_max_iter
199 IF (PRESENT(centers_wfn)) centers_wfn => xas_env%centers_wfn
200 IF (PRESENT(atom_of_state)) atom_of_state => xas_env%atom_of_state
201 IF (PRESENT(exc_atoms)) exc_atoms => xas_env%exc_atoms
202 IF (PRESENT(type_of_state)) type_of_state => xas_env%type_of_state
203 IF (PRESENT(state_of_atom)) state_of_atom => xas_env%state_of_atom
204 IF (PRESENT(mykind_of_atom)) mykind_of_atom => xas_env%mykind_of_atom
205 IF (PRESENT(mykind_of_kind)) mykind_of_kind => xas_env%mykind_of_kind
206 IF (PRESENT(unoccupied_evals)) unoccupied_evals => xas_env%unoccupied_evals
207 IF (PRESENT(all_evals)) all_evals => xas_env%all_evals
208 IF (PRESENT(spectrum)) spectrum => xas_env%spectrum
209 IF (PRESENT(groundstate_coeff)) groundstate_coeff => xas_env%groundstate_coeff
210 IF (PRESENT(ostrength_sm)) ostrength_sm => xas_env%ostrength_sm
211 IF (PRESENT(excvec_overlap)) excvec_overlap => xas_env%excvec_overlap
212 IF (PRESENT(unoccupied_orbs)) unoccupied_orbs => xas_env%unoccupied_orbs
213 IF (PRESENT(all_vectors)) all_vectors => xas_env%all_vectors
214 IF (PRESENT(dip_fm_set)) dip_fm_set => xas_env%dip_fm_set
215 IF (PRESENT(qs_loc_env)) qs_loc_env => xas_env%qs_loc_env
216 IF (PRESENT(excvec_coeff)) excvec_coeff => xas_env%excvec_coeff
217 IF (PRESENT(my_gto_basis)) my_gto_basis => xas_env%my_gto_basis
218 IF (PRESENT(stogto_overlap)) stogto_overlap => xas_env%stogto_overlap
219 IF (PRESENT(scf_env)) scf_env => xas_env%scf_env
220 IF (PRESENT(scf_control)) scf_control => xas_env%scf_control
221 END SUBROUTINE get_xas_env
222
223! **************************************************************************************************
224!> \brief ...
225!> \param xas_env ...
226!> \param nexc_search ...
227!> \param spin_channel ...
228!> \param nexc_atoms ...
229!> \param nvirtual ...
230!> \param nvirtual2 ...
231!> \param ip_energy ...
232!> \param occ_estate ...
233!> \param qs_loc_env ...
234!> \param xas_estate ...
235!> \param xas_nelectron ...
236!> \param homo_occ ...
237!> \param scf_env ...
238!> \param scf_control ...
239! **************************************************************************************************
240 SUBROUTINE set_xas_env(xas_env, nexc_search, spin_channel, nexc_atoms, &
241 nvirtual, nvirtual2, ip_energy, occ_estate, qs_loc_env, &
242 xas_estate, xas_nelectron, homo_occ, scf_env, scf_control)
243
244 TYPE(xas_environment_type), INTENT(INOUT) :: xas_env
245 INTEGER, INTENT(IN), OPTIONAL :: nexc_search, spin_channel, nexc_atoms, &
246 nvirtual, nvirtual2
247 REAL(dp), INTENT(IN), OPTIONAL :: ip_energy, occ_estate
248 TYPE(qs_loc_env_type), OPTIONAL, POINTER :: qs_loc_env
249 INTEGER, INTENT(IN), OPTIONAL :: xas_estate
250 REAL(dp), INTENT(IN), OPTIONAL :: xas_nelectron, homo_occ
251 TYPE(qs_scf_env_type), OPTIONAL, POINTER :: scf_env
252 TYPE(scf_control_type), OPTIONAL, POINTER :: scf_control
253
254 IF (PRESENT(nexc_search)) xas_env%nexc_search = nexc_search
255 IF (PRESENT(spin_channel)) xas_env%spin_channel = spin_channel
256 IF (PRESENT(nexc_atoms)) xas_env%nexc_atoms = nexc_atoms
257 IF (PRESENT(nvirtual)) xas_env%nvirtual = nvirtual
258 IF (PRESENT(nvirtual2)) xas_env%nvirtual2 = nvirtual2
259 IF (PRESENT(occ_estate)) xas_env%occ_estate = occ_estate
260 IF (PRESENT(xas_nelectron)) xas_env%xas_nelectron = xas_nelectron
261 IF (PRESENT(homo_occ)) xas_env%homo_occ = homo_occ
262 IF (PRESENT(xas_estate)) xas_env%xas_estate = xas_estate
263 IF (PRESENT(ip_energy)) xas_env%ip_energy = ip_energy
264 IF (PRESENT(qs_loc_env)) THEN
265 IF (ASSOCIATED(xas_env%qs_loc_env)) THEN
266 IF (.NOT. ASSOCIATED(xas_env%qs_loc_env, qs_loc_env)) THEN
267 CALL qs_loc_env_release(xas_env%qs_loc_env)
268 DEALLOCATE (xas_env%qs_loc_env)
269 END IF
270 END IF
271 xas_env%qs_loc_env => qs_loc_env
272 END IF
273 IF (PRESENT(scf_env)) THEN ! accept also null pointers ?
274 IF (ASSOCIATED(xas_env%scf_env)) THEN
275 IF (ASSOCIATED(xas_env%scf_env, scf_env)) THEN
276 CALL scf_env_release(xas_env%scf_env)
277 DEALLOCATE (xas_env%scf_env)
278 END IF
279 END IF
280 xas_env%scf_env => scf_env
281 END IF
282 IF (PRESENT(scf_control)) THEN ! accept also null pointers?
283 IF (ASSOCIATED(xas_env%scf_control)) THEN
284 IF (.NOT. ASSOCIATED(xas_env%scf_control, scf_control)) THEN
285 CALL scf_c_release(xas_env%scf_control)
286 DEALLOCATE (xas_env%scf_control)
287 END IF
288 END IF
289 xas_env%scf_control => scf_control
290 END IF
291
292 END SUBROUTINE set_xas_env
293
294! **************************************************************************************************
295!> \brief ...
296!> \param xas_env ...
297! **************************************************************************************************
298 SUBROUTINE xas_env_create(xas_env)
299
300 TYPE(xas_environment_type), INTENT(OUT) :: xas_env
301
302 xas_env%nvirtual = 0
303 xas_env%nvirtual2 = 0
304
305 NULLIFY (xas_env%ao_mo_fm_pools)
306 NULLIFY (xas_env%my_gto_basis)
307 NULLIFY (xas_env%atom_of_state)
308 NULLIFY (xas_env%nexc_states)
309 NULLIFY (xas_env%state_of_atom)
310 NULLIFY (xas_env%exc_atoms)
311 NULLIFY (xas_env%excvec_coeff, xas_env%excvec_overlap)
312 NULLIFY (xas_env%type_of_state, xas_env%mykind_of_atom)
313 NULLIFY (xas_env%type_of_state, xas_env%mykind_of_kind)
314 NULLIFY (xas_env%groundstate_coeff, xas_env%dip_fm_set)
315 NULLIFY (xas_env%ostrength_sm, xas_env%qs_loc_env, xas_env%spectrum)
316 NULLIFY (xas_env%all_evals, xas_env%all_vectors)
317 NULLIFY (xas_env%unoccupied_evals, xas_env%unoccupied_orbs)
318 NULLIFY (xas_env%stogto_overlap)
319 NULLIFY (xas_env%scf_env)
320 NULLIFY (xas_env%scf_control)
321
322 END SUBROUTINE xas_env_create
323
324! **************************************************************************************************
325!> \brief ...
326!> \param xas_env ...
327! **************************************************************************************************
328 SUBROUTINE xas_env_release(xas_env)
329
330 TYPE(xas_environment_type), INTENT(INOUT) :: xas_env
331
332 INTEGER :: ik
333
334 DEALLOCATE (xas_env%state_of_atom, xas_env%atom_of_state)
335 DEALLOCATE (xas_env%nexc_states)
336 DEALLOCATE (xas_env%type_of_state)
337 DEALLOCATE (xas_env%mykind_of_atom)
338 DEALLOCATE (xas_env%mykind_of_kind)
339 DEALLOCATE (xas_env%exc_atoms)
340 DEALLOCATE (xas_env%centers_wfn)
341 IF (ASSOCIATED(xas_env%all_evals)) THEN
342 DEALLOCATE (xas_env%all_evals)
343 END IF
344 IF (ASSOCIATED(xas_env%unoccupied_evals)) THEN
345 DEALLOCATE (xas_env%unoccupied_evals)
346 END IF
347 CALL fm_pools_give_back_fm_vect(xas_env%ao_mo_fm_pools, &
348 xas_env%groundstate_coeff)
349
350 CALL cp_fm_release(xas_env%dip_fm_set)
351
352 IF (ASSOCIATED(xas_env%excvec_coeff)) THEN
353 CALL cp_fm_release(xas_env%excvec_coeff)
354 DEALLOCATE (xas_env%excvec_coeff)
355 NULLIFY (xas_env%excvec_coeff)
356 END IF
357 IF (ASSOCIATED(xas_env%excvec_overlap)) THEN
358 CALL cp_fm_release(xas_env%excvec_overlap)
359 DEALLOCATE (xas_env%excvec_overlap)
360 NULLIFY (xas_env%excvec_overlap)
361 END IF
362 IF (ASSOCIATED(xas_env%unoccupied_orbs)) THEN
363 CALL cp_fm_release(xas_env%unoccupied_orbs)
364 DEALLOCATE (xas_env%unoccupied_orbs)
365 NULLIFY (xas_env%unoccupied_orbs)
366 END IF
367 NULLIFY (xas_env%ao_mo_fm_pools)
368 IF (ASSOCIATED(xas_env%all_vectors) .AND. xas_env%nvirtual .GT. 0) THEN
369 CALL cp_fm_release(xas_env%all_vectors)
370 DEALLOCATE (xas_env%all_vectors)
371 NULLIFY (xas_env%all_vectors)
372 ELSE
373 NULLIFY (xas_env%all_vectors)
374 END IF
375
376 IF (ASSOCIATED(xas_env%ostrength_sm)) THEN
377 CALL dbcsr_deallocate_matrix_set(xas_env%ostrength_sm)
378 END IF
379 IF (ASSOCIATED(xas_env%qs_loc_env)) THEN
380 CALL qs_loc_env_release(xas_env%qs_loc_env)
381 DEALLOCATE (xas_env%qs_loc_env)
382 END IF
383
384 IF (ASSOCIATED(xas_env%my_gto_basis)) THEN
385 DO ik = 1, SIZE(xas_env%my_gto_basis, 1)
386 CALL deallocate_gto_basis_set(xas_env%my_gto_basis(ik)%gto_basis_set)
387 END DO
388 DEALLOCATE (xas_env%my_gto_basis)
389 END IF
390
391 IF (ASSOCIATED(xas_env%stogto_overlap)) THEN
392 DO ik = 1, SIZE(xas_env%stogto_overlap, 1)
393 DEALLOCATE (xas_env%stogto_overlap(ik)%array)
394 END DO
395 DEALLOCATE (xas_env%stogto_overlap)
396 END IF
397
398 IF (ASSOCIATED(xas_env%scf_env)) THEN
399 CALL scf_env_release(xas_env%scf_env)
400 DEALLOCATE (xas_env%scf_env)
401 END IF
402 IF (ASSOCIATED(xas_env%scf_control)) THEN
403 CALL scf_c_release(xas_env%scf_control)
404 DEALLOCATE (xas_env%scf_control)
405 END IF
406
407 END SUBROUTINE xas_env_release
408
409END MODULE xas_env_types
410
subroutine, public deallocate_gto_basis_set(gto_basis_set)
...
various utilities that regard array of different kinds: output, allocation,... maybe it is not a good...
DBCSR operations in CP2K.
pool for for elements that are retained and released
represent a full matrix distributed on many processors
Definition cp_fm_types.F:15
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
New version of the module for the localization of the molecular orbitals This should be able to use d...
subroutine, public qs_loc_env_release(qs_loc_env)
...
module that contains the definitions of the scf types
subroutine, public scf_env_release(scf_env)
releases an scf_env (see doc/ReferenceCounting.html)
parameters that control an scf iteration
subroutine, public scf_c_release(scf_control)
releases the given scf_control (see cp2k/doc/ReferenceCounting.html)
define create destroy get and put information in xas_env to calculate the x-ray absorption spectra
subroutine, public xas_env_release(xas_env)
...
subroutine, public set_xas_env(xas_env, nexc_search, spin_channel, nexc_atoms, nvirtual, nvirtual2, ip_energy, occ_estate, qs_loc_env, xas_estate, xas_nelectron, homo_occ, scf_env, scf_control)
...
subroutine, public xas_env_create(xas_env)
...
subroutine, public get_xas_env(xas_env, exc_state, nao, nvirtual, nvirtual2, centers_wfn, atom_of_state, exc_atoms, nexc_states, type_of_state, mykind_of_atom, mykind_of_kind, state_of_atom, spectrum, groundstate_coeff, ostrength_sm, dip_fm_set, excvec_coeff, excvec_overlap, unoccupied_orbs, unoccupied_evals, unoccupied_max_iter, unoccupied_eps, all_vectors, all_evals, my_gto_basis, qs_loc_env, stogto_overlap, occ_estate, xas_nelectron, xas_estate, nexc_atoms, nexc_search, spin_channel, scf_env, scf_control)
...
represent a pointer to a 2d array
represent a full matrix
contains all the info needed by quickstep to calculate the spread of a selected set of orbitals and i...