(git:6344619)
Loading...
Searching...
No Matches
qs_fb_env_types.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2026 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7
9
10 USE kinds, ONLY: dp
19#include "./base/base_uses.f90"
20
21 IMPLICIT NONE
22
23 PRIVATE
24
25! public types
26 PUBLIC :: fb_env_obj
27
28! public methods
29 PUBLIC :: fb_env_release, &
33 fb_env_get, &
35
36 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'qs_fb_env_types'
37
38! **********************************************************************
39!> \brief wrapper to the simulation parameters used for filtered basis
40!> method
41!> \param rcut : cutoff for included filtered basis set centred at
42!> each atom. These defines the ranges of the atomic
43!> halos. rcut(ikind) gives the range for atom of
44!> global kind ikind
45!> \param atomic_halos : stores information on the neighbors of each
46!> atom ii, which are defined by rcut
47!> \param filter_temperature : parameter controlling the smoothness of
48!> the filter function during the construction
49!> of the filter matrix
50!> \param auto_cutoff_scale : scale multiplied to max atomic orbital
51!> radii used for automatic construction of
52!> rcut
53!> \param eps_default : anything less than it is regarded as zero
54!> \param collective_com : whether the MPI communications are
55!> to be done collectively together
56!> at the start and end of each
57!> filter matrix calculation. This makes
58!> communication more efficient in the
59!> expense of larger memory usage
60!> \param local_atoms : atoms corresponding to the
61!> atomic halos responsible by this processor
62!> \author Lianheng Tong (LT) lianheng.tong@kcl.ac.uk
63! **********************************************************************
64 TYPE fb_env_data
65 REAL(KIND=dp), DIMENSION(:), POINTER :: rcut => null()
66 TYPE(fb_atomic_halo_list_obj) :: atomic_halos = fb_atomic_halo_list_obj()
67 TYPE(fb_trial_fns_obj) :: trial_fns = fb_trial_fns_obj()
68 REAL(KIND=dp) :: filter_temperature = -1.0_dp
69 REAL(KIND=dp) :: auto_cutoff_scale = -1.0_dp
70 REAL(KIND=dp) :: eps_default = -1.0_dp
71 LOGICAL :: collective_com = .false.
72 INTEGER, DIMENSION(:), POINTER :: local_atoms => null()
73 INTEGER :: nlocal_atoms = -1
74 END TYPE fb_env_data
75
76! **************************************************************************************************
77!> \brief the object container which allows for the creation of an array of
78!> pointers to fb_env
79!> \param obj : pointer to a filtered basis environment
80!> \author Lianheng Tong (LT) lianheng.tong@kcl.ac.uk
81! **************************************************************************************************
83 TYPE(fb_env_data), POINTER, PRIVATE :: obj => null()
84 END TYPE fb_env_obj
85
86CONTAINS
87
88! **********************************************************************
89!> \brief releases a given fb_env
90!> \brief ...
91!> \param fb_env : the fb_env to release
92!> \author Lianheng Tong (LT) lianheng.tong@kcl.ac.uk
93! **************************************************************************************************
94 SUBROUTINE fb_env_release(fb_env)
95 TYPE(fb_env_obj), INTENT(INOUT) :: fb_env
96
97 IF (ASSOCIATED(fb_env%obj)) THEN
98 IF (ASSOCIATED(fb_env%obj%rcut)) THEN
99 DEALLOCATE (fb_env%obj%rcut)
100 END IF
101 IF (ASSOCIATED(fb_env%obj%local_atoms)) THEN
102 DEALLOCATE (fb_env%obj%local_atoms)
103 END IF
104 CALL fb_atomic_halo_list_release(fb_env%obj%atomic_halos)
105 CALL fb_trial_fns_release(fb_env%obj%trial_fns)
106 DEALLOCATE (fb_env%obj)
107 ELSE
108 NULLIFY (fb_env%obj)
109 END IF
110 END SUBROUTINE fb_env_release
111
112! **********************************************************************
113!> \brief nullifies a fb_env object, note that this does not
114!> release the original object. This procedure is used mainly
115!> to nullify the pointer inside the object which is used to
116!> point to the actual data content of the object.
117!> \param fb_env : its content must be a NULL fb_env pointer on input,
118!> and the output returns an empty fb_env object
119!> \author Lianheng Tong (LT) lianheng.tong@kcl.ac.uk
120! **************************************************************************************************
121 SUBROUTINE fb_env_nullify(fb_env)
122 TYPE(fb_env_obj), INTENT(INOUT) :: fb_env
123
124 NULLIFY (fb_env%obj)
125 END SUBROUTINE fb_env_nullify
126
127! **********************************************************************
128!> \brief Associates one fb_env object to another
129!> \param a the fb_env object to be associated
130!> \param b the fb_env object that a is to be associated to
131!> \author Lianheng Tong (LT) lianheng.tong@kcl.ac.uk
132! **************************************************************************************************
133 SUBROUTINE fb_env_associate(a, b)
134 TYPE(fb_env_obj), INTENT(OUT) :: a
135 TYPE(fb_env_obj), INTENT(IN) :: b
136
137 a%obj => b%obj
138 END SUBROUTINE fb_env_associate
139
140! **********************************************************************
141!> \brief Checks if a fb_env object is associated with an actual
142!> data content or not
143!> \param fb_env the fb_env object
144!> \return ...
145!> \author Lianheng Tong (LT) lianheng.tong@kcl.ac.uk
146! **************************************************************************************************
147 FUNCTION fb_env_has_data(fb_env) RESULT(res)
148 TYPE(fb_env_obj), INTENT(IN) :: fb_env
149 LOGICAL :: res
150
151 res = ASSOCIATED(fb_env%obj)
152 END FUNCTION fb_env_has_data
153
154! **********************************************************************
155!> \brief creates an empty fb_env object
156!> \param fb_env : its content must be a NULL fb_env pointer on input,
157!> and the output returns an empty fb_env object
158!> \author Lianheng Tong (LT) lianheng.tong@kcl.ac.uk
159! **************************************************************************************************
160 SUBROUTINE fb_env_create(fb_env)
161 TYPE(fb_env_obj), INTENT(INOUT) :: fb_env
162
163 cpassert(.NOT. ASSOCIATED(fb_env%obj))
164 ALLOCATE (fb_env%obj)
165 NULLIFY (fb_env%obj%rcut)
166 CALL fb_atomic_halo_list_nullify(fb_env%obj%atomic_halos)
167 CALL fb_trial_fns_nullify(fb_env%obj%trial_fns)
168 fb_env%obj%filter_temperature = 0.0_dp
169 fb_env%obj%auto_cutoff_scale = 1.0_dp
170 fb_env%obj%eps_default = 0.0_dp
171 fb_env%obj%collective_com = .true.
172 NULLIFY (fb_env%obj%local_atoms)
173 fb_env%obj%nlocal_atoms = 0
174 END SUBROUTINE fb_env_create
175
176! **********************************************************************
177!> \brief initialises a fb_env object to become empty
178!> \brief ...
179!> \param fb_env : the fb_env object, which must not be NULL or
180!> UNDEFINED upon entry
181!> \author Lianheng Tong (LT) lianheng.tong@kcl.ac.uk
182! **************************************************************************************************
183 SUBROUTINE fb_env_init(fb_env)
184 TYPE(fb_env_obj), INTENT(INOUT) :: fb_env
185
186 cpassert(ASSOCIATED(fb_env%obj))
187 IF (ASSOCIATED(fb_env%obj%rcut)) THEN
188 DEALLOCATE (fb_env%obj%rcut)
189 END IF
190 CALL fb_atomic_halo_list_release(fb_env%obj%atomic_halos)
191 CALL fb_trial_fns_release(fb_env%obj%trial_fns)
192 fb_env%obj%filter_temperature = 0.0_dp
193 fb_env%obj%auto_cutoff_scale = 1.0_dp
194 fb_env%obj%eps_default = 0.0_dp
195 fb_env%obj%collective_com = .true.
196 IF (ASSOCIATED(fb_env%obj%local_atoms)) THEN
197 DEALLOCATE (fb_env%obj%local_atoms)
198 END IF
199 fb_env%obj%nlocal_atoms = 0
200 END SUBROUTINE fb_env_init
201
202! **********************************************************************
203!> \brief method to get attributes from a given fb_env object
204!> \brief ...
205!> \param fb_env : the fb_env object in question
206!> \param rcut : outputs pointer to rcut attribute of fb_env (optional)
207!> \param filter_temperature : outputs filter_temperature attribute
208!> of fb_env (optional)
209!> \param auto_cutoff_scale : outputs auto_cutoff_scale attribute
210!> of fb_env (optional)
211!> \param eps_default : outputs eps_default attribute
212!> of fb_env (optional)
213!> \param atomic_halos : outputs pointer to atomic_halos
214!> attribute of fb_env (optional)
215!> \param trial_fns : outputs pointer to trial_fns
216!> attribute of fb_env (optional, do not release it)
217!> \param collective_com : outputs pointer to trial_fns
218!> \param local_atoms : outputs pointer to local_atoms
219!> \param nlocal_atoms : outputs pointer to nlocal_atoms
220!> \author Lianheng Tong (LT) lianheng.tong@kcl.ac.uk
221! **************************************************************************************************
222 SUBROUTINE fb_env_get(fb_env, &
223 rcut, &
224 filter_temperature, &
225 auto_cutoff_scale, &
226 eps_default, &
227 atomic_halos, &
228 trial_fns, &
229 collective_com, &
230 local_atoms, &
231 nlocal_atoms)
232 TYPE(fb_env_obj), INTENT(IN) :: fb_env
233 REAL(kind=dp), DIMENSION(:), OPTIONAL, POINTER :: rcut
234 REAL(kind=dp), INTENT(OUT), OPTIONAL :: filter_temperature, auto_cutoff_scale, &
235 eps_default
236 TYPE(fb_atomic_halo_list_obj), INTENT(OUT), &
237 OPTIONAL :: atomic_halos
238 TYPE(fb_trial_fns_obj), INTENT(OUT), OPTIONAL :: trial_fns
239 LOGICAL, INTENT(OUT), OPTIONAL :: collective_com
240 INTEGER, DIMENSION(:), OPTIONAL, POINTER :: local_atoms
241 INTEGER, INTENT(OUT), OPTIONAL :: nlocal_atoms
242
243 cpassert(ASSOCIATED(fb_env%obj))
244 IF (PRESENT(rcut)) THEN
245 rcut => fb_env%obj%rcut
246 END IF
247 IF (PRESENT(filter_temperature)) THEN
248 filter_temperature = fb_env%obj%filter_temperature
249 END IF
250 IF (PRESENT(auto_cutoff_scale)) THEN
251 auto_cutoff_scale = fb_env%obj%auto_cutoff_scale
252 END IF
253 IF (PRESENT(eps_default)) THEN
254 eps_default = fb_env%obj%eps_default
255 END IF
256 IF (PRESENT(atomic_halos)) THEN
257 CALL fb_atomic_halo_list_associate(atomic_halos, fb_env%obj%atomic_halos)
258 END IF
259 IF (PRESENT(trial_fns)) THEN
260 trial_fns = fb_env%obj%trial_fns
261 END IF
262 IF (PRESENT(collective_com)) THEN
263 collective_com = fb_env%obj%collective_com
264 END IF
265 IF (PRESENT(local_atoms)) THEN
266 local_atoms => fb_env%obj%local_atoms
267 END IF
268 IF (PRESENT(nlocal_atoms)) THEN
269 nlocal_atoms = fb_env%obj%nlocal_atoms
270 END IF
271 END SUBROUTINE fb_env_get
272
273! **********************************************************************
274!> \brief method to set attributes from a given fb_env object
275!> \brief ...
276!> \param fb_env : the fb_env object in question
277!> \param rcut : sets rcut attribute of fb_env (optional)
278!> \param filter_temperature : sets filter_temperature attribute of fb_env (optional)
279!> \param auto_cutoff_scale : sets auto_cutoff_scale attribute of fb_env (optional)
280!> \param eps_default : sets eps_default attribute of fb_env (optional)
281!> \param atomic_halos : sets atomic_halos attribute of fb_env (optional)
282!> \param trial_fns : sets trial_fns attribute of fb_env (optional)
283!> \param collective_com : sets collective_com attribute of fb_env (optional)
284!> \param local_atoms : sets local_atoms attribute of fb_env (optional)
285!> \param nlocal_atoms : sets nlocal_atoms attribute of fb_env (optional)
286!> \author Lianheng Tong (LT) lianheng.tong@kcl.ac.uk
287! **************************************************************************************************
288 SUBROUTINE fb_env_set(fb_env, &
289 rcut, &
290 filter_temperature, &
291 auto_cutoff_scale, &
292 eps_default, &
293 atomic_halos, &
294 trial_fns, &
295 collective_com, &
296 local_atoms, &
297 nlocal_atoms)
298 TYPE(fb_env_obj), INTENT(INOUT) :: fb_env
299 REAL(kind=dp), DIMENSION(:), OPTIONAL, POINTER :: rcut
300 REAL(kind=dp), INTENT(IN), OPTIONAL :: filter_temperature, auto_cutoff_scale, &
301 eps_default
302 TYPE(fb_atomic_halo_list_obj), INTENT(IN), &
303 OPTIONAL :: atomic_halos
304 TYPE(fb_trial_fns_obj), INTENT(IN), OPTIONAL :: trial_fns
305 LOGICAL, INTENT(IN), OPTIONAL :: collective_com
306 INTEGER, DIMENSION(:), OPTIONAL, POINTER :: local_atoms
307 INTEGER, INTENT(IN), OPTIONAL :: nlocal_atoms
308
309 cpassert(ASSOCIATED(fb_env%obj))
310 IF (PRESENT(rcut)) THEN
311 IF (ASSOCIATED(fb_env%obj%rcut)) THEN
312 DEALLOCATE (fb_env%obj%rcut)
313 END IF
314 fb_env%obj%rcut => rcut
315 END IF
316 IF (PRESENT(filter_temperature)) THEN
317 fb_env%obj%filter_temperature = filter_temperature
318 END IF
319 IF (PRESENT(auto_cutoff_scale)) THEN
320 fb_env%obj%auto_cutoff_scale = auto_cutoff_scale
321 END IF
322 IF (PRESENT(eps_default)) THEN
323 fb_env%obj%eps_default = eps_default
324 END IF
325 IF (PRESENT(atomic_halos)) THEN
326 CALL fb_atomic_halo_list_release(fb_env%obj%atomic_halos)
327 CALL fb_atomic_halo_list_associate(fb_env%obj%atomic_halos, atomic_halos)
328 END IF
329 IF (PRESENT(trial_fns)) THEN
330 CALL fb_trial_fns_associate(fb_env%obj%trial_fns, trial_fns)
331 END IF
332 IF (PRESENT(collective_com)) THEN
333 fb_env%obj%collective_com = collective_com
334 END IF
335 IF (PRESENT(local_atoms)) THEN
336 IF (ASSOCIATED(fb_env%obj%local_atoms)) THEN
337 DEALLOCATE (fb_env%obj%local_atoms)
338 END IF
339 fb_env%obj%local_atoms => local_atoms
340 END IF
341 IF (PRESENT(nlocal_atoms)) THEN
342 fb_env%obj%nlocal_atoms = nlocal_atoms
343 END IF
344 END SUBROUTINE fb_env_set
345
346END MODULE qs_fb_env_types
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
subroutine, public fb_atomic_halo_list_release(atomic_halos)
Releases an fb_atomic_halo_list object.
subroutine, public fb_atomic_halo_list_associate(a, b)
Associates one fb_atomic_halo_list object to another.
subroutine, public fb_atomic_halo_list_nullify(atomic_halos)
Nullifies a fb_atomic_halo_list object, note that it does not release the original object....
logical function, public fb_env_has_data(fb_env)
Checks if a fb_env object is associated with an actual data content or not.
subroutine, public fb_env_release(fb_env)
releases a given fb_env
subroutine, public fb_env_get(fb_env, rcut, filter_temperature, auto_cutoff_scale, eps_default, atomic_halos, trial_fns, collective_com, local_atoms, nlocal_atoms)
method to get attributes from a given fb_env object
subroutine, public fb_env_nullify(fb_env)
nullifies a fb_env object, note that this does not release the original object. This procedure is use...
subroutine, public fb_env_set(fb_env, rcut, filter_temperature, auto_cutoff_scale, eps_default, atomic_halos, trial_fns, collective_com, local_atoms, nlocal_atoms)
method to set attributes from a given fb_env object
subroutine, public fb_env_create(fb_env)
creates an empty fb_env object
subroutine, public fb_trial_fns_nullify(trial_fns)
nullifies the content of given object
subroutine, public fb_trial_fns_associate(a, b)
associates the content of an object to that of another object of the same type
subroutine, public fb_trial_fns_release(trial_fns)
releases given object
the object container which allows for the creation of an array of pointers to fb_env
the object container which allows for the creation of an array of pointers to fb_trial_fns objects