(git:3d5d2e5)
Loading...
Searching...
No Matches
atomic_kind_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
8! **************************************************************************************************
9!> \brief Define the atomic kind types and their sub types
10!> \author Matthias Krack (MK)
11!> \date 02.01.2002
12!> \version 1.0
13!>
14!> <b>Modification history:</b>
15!> - 01.2002 creation [MK]
16!> - 04.2002 added pao [fawzi]
17!> - 09.2002 adapted for POL/KG use [GT]
18!> - 02.2004 flexible normalization of basis sets [jgh]
19!> - 03.2004 attach/detach routines [jgh]
20!> - 10.2004 removed pao [fawzi]
21!> - 08.2014 moevd qs-related stuff into new qs_kind_types.F [Ole Schuett]
22! **************************************************************************************************
29 USE kinds, ONLY: default_string_length,&
30 dp
33#include "../base/base_uses.f90"
34
35 IMPLICIT NONE
36
37 PRIVATE
38
39 ! Global parameters (only in this module)
40
41 CHARACTER(LEN=*), PARAMETER, PRIVATE :: moduleN = 'atomic_kind_types'
42
43!> \brief Provides all information about an atomic kind
44! **************************************************************************************************
46 TYPE(fist_potential_type), POINTER :: fist_potential => null()
47 CHARACTER(LEN=default_string_length) :: name = ""
48 CHARACTER(LEN=2) :: element_symbol = ""
49 REAL(kind=dp) :: mass = 0.0_dp
50 INTEGER :: kind_number = -1
51 INTEGER :: natom = -1
52 INTEGER, DIMENSION(:), POINTER :: atom_list => null()
53 LOGICAL :: shell_active = .false.
54 TYPE(shell_kind_type), POINTER :: shell => null()
55 TYPE(damping_p_type), POINTER :: damping => null()
56 END TYPE atomic_kind_type
57
58 ! Public subroutines
59
65
66 ! Public data types
67 PUBLIC :: atomic_kind_type
68
69CONTAINS
70
71! **************************************************************************************************
72!> \brief Destructor routine for a set of atomic kinds
73!> \param atomic_kind_set ...
74!> \date 02.01.2002
75!> \author Matthias Krack (MK)
76!> \version 2.0
77! **************************************************************************************************
78 SUBROUTINE deallocate_atomic_kind_set(atomic_kind_set)
79
80 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
81
82 INTEGER :: ikind, nkind
83
84 IF (.NOT. ASSOCIATED(atomic_kind_set)) THEN
85 CALL cp_abort(__location__, &
86 "The pointer atomic_kind_set is not associated and "// &
87 "cannot be deallocated")
88 END IF
89
90 nkind = SIZE(atomic_kind_set)
91
92 DO ikind = 1, nkind
93 IF (ASSOCIATED(atomic_kind_set(ikind)%fist_potential)) THEN
94 CALL deallocate_potential(atomic_kind_set(ikind)%fist_potential)
95 END IF
96 IF (ASSOCIATED(atomic_kind_set(ikind)%atom_list)) THEN
97 DEALLOCATE (atomic_kind_set(ikind)%atom_list)
98 END IF
99 IF (ASSOCIATED(atomic_kind_set(ikind)%shell)) DEALLOCATE (atomic_kind_set(ikind)%shell)
100
101 CALL damping_p_release(atomic_kind_set(ikind)%damping)
102 END DO
103 DEALLOCATE (atomic_kind_set)
104 END SUBROUTINE deallocate_atomic_kind_set
105
106! **************************************************************************************************
107!> \brief Get attributes of an atomic kind.
108!> \param atomic_kind ...
109!> \param fist_potential ...
110!> \param element_symbol ...
111!> \param name ...
112!> \param mass ...
113!> \param kind_number ...
114!> \param natom ...
115!> \param atom_list ...
116!> \param rcov ...
117!> \param rvdw ...
118!> \param z ...
119!> \param qeff ...
120!> \param apol ...
121!> \param cpol ...
122!> \param mm_radius ...
123!> \param shell ...
124!> \param shell_active ...
125!> \param damping ...
126! **************************************************************************************************
127 SUBROUTINE get_atomic_kind(atomic_kind, fist_potential, &
128 element_symbol, name, mass, kind_number, natom, atom_list, &
129 rcov, rvdw, z, qeff, apol, cpol, mm_radius, &
130 shell, shell_active, damping)
131
132 TYPE(atomic_kind_type), INTENT(IN) :: atomic_kind
133 TYPE(fist_potential_type), OPTIONAL, POINTER :: fist_potential
134 CHARACTER(LEN=2), INTENT(OUT), OPTIONAL :: element_symbol
135 CHARACTER(LEN=default_string_length), &
136 INTENT(OUT), OPTIONAL :: name
137 REAL(kind=dp), INTENT(OUT), OPTIONAL :: mass
138 INTEGER, INTENT(OUT), OPTIONAL :: kind_number, natom
139 INTEGER, DIMENSION(:), OPTIONAL, POINTER :: atom_list
140 REAL(kind=dp), INTENT(OUT), OPTIONAL :: rcov, rvdw
141 INTEGER, INTENT(OUT), OPTIONAL :: z
142 REAL(kind=dp), INTENT(OUT), OPTIONAL :: qeff, apol, cpol, mm_radius
143 TYPE(shell_kind_type), OPTIONAL, POINTER :: shell
144 LOGICAL, INTENT(OUT), OPTIONAL :: shell_active
145 TYPE(damping_p_type), OPTIONAL, POINTER :: damping
146
147 IF (PRESENT(fist_potential)) fist_potential => atomic_kind%fist_potential
148 IF (PRESENT(element_symbol)) element_symbol = atomic_kind%element_symbol
149 IF (PRESENT(name)) name = atomic_kind%name
150 IF (PRESENT(mass)) mass = atomic_kind%mass
151 IF (PRESENT(kind_number)) kind_number = atomic_kind%kind_number
152 IF (PRESENT(natom)) natom = atomic_kind%natom
153 IF (PRESENT(atom_list)) atom_list => atomic_kind%atom_list
154
155 IF (PRESENT(z)) THEN
156 CALL get_ptable_info(atomic_kind%element_symbol, number=z)
157 END IF
158 IF (PRESENT(rcov)) THEN
159 CALL get_ptable_info(atomic_kind%element_symbol, covalent_radius=rcov)
160 END IF
161 IF (PRESENT(rvdw)) THEN
162 CALL get_ptable_info(atomic_kind%element_symbol, vdw_radius=rvdw)
163 END IF
164 IF (PRESENT(qeff)) THEN
165 IF (ASSOCIATED(atomic_kind%fist_potential)) THEN
166 CALL get_potential(potential=atomic_kind%fist_potential, qeff=qeff)
167 ELSE
168 qeff = -huge(0.0_dp)
169 END IF
170 END IF
171 IF (PRESENT(apol)) THEN
172 IF (ASSOCIATED(atomic_kind%fist_potential)) THEN
173 CALL get_potential(potential=atomic_kind%fist_potential, apol=apol)
174 ELSE
175 apol = -huge(0.0_dp)
176 END IF
177 END IF
178 IF (PRESENT(cpol)) THEN
179 IF (ASSOCIATED(atomic_kind%fist_potential)) THEN
180 CALL get_potential(potential=atomic_kind%fist_potential, cpol=cpol)
181 ELSE
182 cpol = -huge(0.0_dp)
183 END IF
184 END IF
185 IF (PRESENT(mm_radius)) THEN
186 IF (ASSOCIATED(atomic_kind%fist_potential)) THEN
187 CALL get_potential(potential=atomic_kind%fist_potential, mm_radius=mm_radius)
188 ELSE
189 mm_radius = -huge(0.0_dp)
190 END IF
191 END IF
192 IF (PRESENT(shell)) shell => atomic_kind%shell
193 IF (PRESENT(shell_active)) shell_active = atomic_kind%shell_active
194 IF (PRESENT(damping)) damping => atomic_kind%damping
195
196 END SUBROUTINE get_atomic_kind
197
198! **************************************************************************************************
199!> \brief Get attributes of an atomic kind set.
200!> \param atomic_kind_set ...
201!> \param atom_of_kind ...
202!> \param kind_of ...
203!> \param natom_of_kind ...
204!> \param maxatom ...
205!> \param natom ...
206!> \param nshell ...
207!> \param fist_potential_present ...
208!> \param shell_present ...
209!> \param shell_adiabatic ...
210!> \param shell_check_distance ...
211!> \param damping_present ...
212! **************************************************************************************************
213 SUBROUTINE get_atomic_kind_set(atomic_kind_set, atom_of_kind, kind_of, natom_of_kind, maxatom, &
214 natom, nshell, fist_potential_present, shell_present, &
215 shell_adiabatic, shell_check_distance, damping_present)
216
217 TYPE(atomic_kind_type), DIMENSION(:), INTENT(IN) :: atomic_kind_set
218 INTEGER, ALLOCATABLE, DIMENSION(:), OPTIONAL :: atom_of_kind, kind_of, natom_of_kind
219 INTEGER, INTENT(OUT), OPTIONAL :: maxatom, natom, nshell
220 LOGICAL, INTENT(OUT), OPTIONAL :: fist_potential_present, shell_present, &
221 shell_adiabatic, shell_check_distance, &
222 damping_present
223
224 INTEGER :: atom_a, iatom, ikind, my_natom
225
226 ! Compute number of atoms which is needed for possible allocations later.
227 my_natom = 0
228 DO ikind = 1, SIZE(atomic_kind_set)
229 my_natom = my_natom + atomic_kind_set(ikind)%natom
230 END DO
231
232 IF (PRESENT(maxatom)) maxatom = 0
233 IF (PRESENT(natom)) natom = my_natom
234 IF (PRESENT(nshell)) nshell = 0
235 IF (PRESENT(shell_present)) shell_present = .false.
236 IF (PRESENT(shell_adiabatic)) shell_adiabatic = .false.
237 IF (PRESENT(shell_check_distance)) shell_check_distance = .false.
238 IF (PRESENT(damping_present)) damping_present = .false.
239 IF (PRESENT(atom_of_kind)) THEN
240 ALLOCATE (atom_of_kind(my_natom))
241 atom_of_kind(:) = 0
242 END IF
243 IF (PRESENT(kind_of)) THEN
244 ALLOCATE (kind_of(my_natom))
245 kind_of(:) = 0
246 END IF
247 IF (PRESENT(natom_of_kind)) THEN
248 ALLOCATE (natom_of_kind(SIZE(atomic_kind_set)))
249 natom_of_kind(:) = 0
250 END IF
251
252 DO ikind = 1, SIZE(atomic_kind_set)
253 associate(atomic_kind => atomic_kind_set(ikind))
254 IF (PRESENT(maxatom)) THEN
255 maxatom = max(maxatom, atomic_kind%natom)
256 END IF
257 IF (PRESENT(fist_potential_present)) THEN
258 IF (ASSOCIATED(atomic_kind%fist_potential)) THEN
259 fist_potential_present = .true.
260 END IF
261 END IF
262 IF (PRESENT(shell_present)) THEN
263 IF (ASSOCIATED(atomic_kind%shell)) THEN
264 shell_present = .true.
265 END IF
266 END IF
267 IF (PRESENT(shell_adiabatic) .AND. ASSOCIATED(atomic_kind%shell)) THEN
268 IF (.NOT. shell_adiabatic) THEN
269 shell_adiabatic = (atomic_kind%shell%massfrac /= 0.0_dp)
270 END IF
271 END IF
272 IF (PRESENT(shell_check_distance) .AND. ASSOCIATED(atomic_kind%shell)) THEN
273 IF (.NOT. shell_check_distance) THEN
274 shell_check_distance = (atomic_kind%shell%max_dist > 0.0_dp)
275 END IF
276 END IF
277 IF (PRESENT(damping_present)) THEN
278 IF (ASSOCIATED(atomic_kind%damping)) THEN
279 damping_present = .true.
280 END IF
281 END IF
282 IF (PRESENT(atom_of_kind)) THEN
283 DO iatom = 1, atomic_kind%natom
284 atom_a = atomic_kind%atom_list(iatom)
285 atom_of_kind(atom_a) = iatom
286 END DO
287 END IF
288 IF (PRESENT(kind_of)) THEN
289 DO iatom = 1, atomic_kind%natom
290 atom_a = atomic_kind%atom_list(iatom)
291 kind_of(atom_a) = ikind
292 END DO
293 END IF
294 IF (PRESENT(natom_of_kind)) THEN
295 natom_of_kind(ikind) = atomic_kind%natom
296 END IF
297 END associate
298 END DO
299
300 END SUBROUTINE get_atomic_kind_set
301
302! **************************************************************************************************
303!> \brief Set the components of an atomic kind data set.
304!> \param atomic_kind ...
305!> \param element_symbol ...
306!> \param name ...
307!> \param mass ...
308!> \param kind_number ...
309!> \param natom ...
310!> \param atom_list ...
311!> \param fist_potential ...
312!> \param shell ...
313!> \param shell_active ...
314!> \param damping ...
315! **************************************************************************************************
316 SUBROUTINE set_atomic_kind(atomic_kind, element_symbol, name, mass, kind_number, &
317 natom, atom_list, &
318 fist_potential, shell, &
319 shell_active, damping)
320
321 TYPE(atomic_kind_type), INTENT(INOUT) :: atomic_kind
322 CHARACTER(LEN=*), INTENT(IN), OPTIONAL :: element_symbol, name
323 REAL(kind=dp), INTENT(IN), OPTIONAL :: mass
324 INTEGER, INTENT(IN), OPTIONAL :: kind_number, natom
325 INTEGER, DIMENSION(:), INTENT(IN), OPTIONAL :: atom_list
326 TYPE(fist_potential_type), OPTIONAL, POINTER :: fist_potential
327 TYPE(shell_kind_type), OPTIONAL, POINTER :: shell
328 LOGICAL, INTENT(IN), OPTIONAL :: shell_active
329 TYPE(damping_p_type), OPTIONAL, POINTER :: damping
330
331 INTEGER :: n
332
333 IF (PRESENT(element_symbol)) atomic_kind%element_symbol = element_symbol
334 IF (PRESENT(name)) atomic_kind%name = name
335 IF (PRESENT(mass)) atomic_kind%mass = mass
336 IF (PRESENT(kind_number)) atomic_kind%kind_number = kind_number
337 IF (PRESENT(natom)) atomic_kind%natom = natom
338 IF (PRESENT(atom_list)) THEN
339 n = SIZE(atom_list)
340 IF (n > 0) THEN
341 IF (ASSOCIATED(atomic_kind%atom_list)) THEN
342 DEALLOCATE (atomic_kind%atom_list)
343 END IF
344 ALLOCATE (atomic_kind%atom_list(n))
345 atomic_kind%atom_list(:) = atom_list(:)
346 atomic_kind%natom = n
347 ELSE
348 cpabort("An invalid atom_list was supplied")
349 END IF
350 END IF
351 IF (PRESENT(fist_potential)) atomic_kind%fist_potential => fist_potential
352 IF (PRESENT(shell)) THEN
353 IF (ASSOCIATED(atomic_kind%shell)) THEN
354 IF (.NOT. ASSOCIATED(atomic_kind%shell, shell)) THEN
355 DEALLOCATE (atomic_kind%shell)
356 END IF
357 END IF
358 atomic_kind%shell => shell
359 END IF
360 IF (PRESENT(shell_active)) atomic_kind%shell_active = shell_active
361
362 IF (PRESENT(damping)) atomic_kind%damping => damping
363
364 END SUBROUTINE set_atomic_kind
365
366! **************************************************************************************************
367!> \brief Determines if the atomic_kind is HYDROGEN
368!> \param atomic_kind ...
369!> \return ...
370!> \author Teodoro Laino [tlaino] - University of Zurich 10.2008
371! **************************************************************************************************
372 ELEMENTAL FUNCTION is_hydrogen(atomic_kind) RESULT(res)
373 TYPE(atomic_kind_type), INTENT(IN) :: atomic_kind
374 LOGICAL :: res
375
376 res = trim(atomic_kind%element_symbol) == "H"
377 END FUNCTION is_hydrogen
378
379END MODULE atomic_kind_types
Define the atomic kind types and their sub types.
subroutine, public get_atomic_kind_set(atomic_kind_set, atom_of_kind, kind_of, natom_of_kind, maxatom, natom, nshell, fist_potential_present, shell_present, shell_adiabatic, shell_check_distance, damping_present)
Get attributes of an atomic kind set.
subroutine, public set_atomic_kind(atomic_kind, element_symbol, name, mass, kind_number, natom, atom_list, fist_potential, shell, shell_active, damping)
Set the components of an atomic kind data set.
subroutine, public get_atomic_kind(atomic_kind, fist_potential, element_symbol, name, mass, kind_number, natom, atom_list, rcov, rvdw, z, qeff, apol, cpol, mm_radius, shell, shell_active, damping)
Get attributes of an atomic kind.
subroutine, public deallocate_atomic_kind_set(atomic_kind_set)
Destructor routine for a set of atomic kinds.
elemental logical function, public is_hydrogen(atomic_kind)
Determines if the atomic_kind is HYDROGEN.
subroutine, public damping_p_release(damping)
Release Data-structure that contains damping information.
Definition of the atomic potential types.
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
integer, parameter, public default_string_length
Definition kinds.F:57
Periodic Table related data definitions.
subroutine, public get_ptable_info(symbol, number, amass, ielement, covalent_radius, metallic_radius, vdw_radius, found)
Pass information about the kind given the element symbol.
Provides all information about an atomic kind.