(git:9111030)
Loading...
Searching...
No Matches
fist_environment_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!> \par History
10!> gt sept-23-02 added atomic_kind_set to replica_environment_type
11!> to allow use of kind_based neighbor list
12!> CJM rewrite
13!> \author CJM SEPT-01-02
14! **************************************************************************************************
20 USE cell_types, ONLY: cell_release,&
61#include "./base/base_uses.f90"
62
63 IMPLICIT NONE
64 PRIVATE
65
66! **************************************************************************************************
67!> \par History
68!> 11/03
69!> \author CJM
70! **************************************************************************************************
72 PRIVATE
73 LOGICAL :: qmmm = .false.
74 LOGICAL :: shell_model = .false., shell_model_ad = .false.
75 TYPE(qmmm_env_mm_type), POINTER :: qmmm_env => null()
76 TYPE(cell_type), POINTER :: cell_ref => null()
77 TYPE(ewald_environment_type), POINTER :: ewald_env => null()
78 TYPE(ewald_pw_type), POINTER :: ewald_pw => null()
79 TYPE(fist_energy_type), POINTER :: thermo => null()
80 TYPE(mp_para_env_type), POINTER :: para_env => null()
81 TYPE(cp_subsys_type), POINTER :: subsys => null()
82 TYPE(fist_nonbond_env_type), POINTER :: fist_nonbond_env => null()
83 TYPE(section_vals_type), POINTER :: input => null()
84 TYPE(exclusion_type), DIMENSION(:), POINTER :: exclusions => null()
85 TYPE(fist_efield_type), POINTER :: efield => null()
87
88! *** Public data types ***
89 PUBLIC :: fist_environment_type
90
91! *** Public subroutines ***
92 PUBLIC :: fist_env_get, &
96
97 CHARACTER(len=*), PARAMETER, PRIVATE :: modulen = 'fist_environment_types'
98
99!***
100
101CONTAINS
102
103! **************************************************************************************************
104!> \brief Purpose: Get the FIST environment.
105!> \param fist_env the pointer to the fist_env
106!> \param atomic_kind_set ...
107!> \param particle_set ...
108!> \param ewald_pw ...
109!> \param local_particles ...
110!> \param local_molecules ...
111!> \param molecule_kind_set ...
112!> \param molecule_set ...
113!> \param cell ...
114!> \param cell_ref ...
115!> \param ewald_env ...
116!> \param fist_nonbond_env ...
117!> \param thermo ...
118!> \param para_env ...
119!> \param subsys ...
120!> \param qmmm ...
121!> \param qmmm_env ...
122!> \param input ...
123!> \param shell_model ...
124!> \param shell_model_ad ...
125!> \param shell_particle_set ...
126!> \param core_particle_set ...
127!> \param multipoles ...
128!> \param results ...
129!> \param exclusions ...
130!> \param efield ...
131!> \par History
132!> 11/03
133!> \author CJM
134! **************************************************************************************************
135 SUBROUTINE fist_env_get(fist_env, atomic_kind_set, particle_set, ewald_pw, &
136 local_particles, local_molecules, molecule_kind_set, molecule_set, cell, &
137 cell_ref, ewald_env, fist_nonbond_env, thermo, para_env, subsys, qmmm, &
138 qmmm_env, input, shell_model, shell_model_ad, shell_particle_set, &
139 core_particle_set, multipoles, results, exclusions, efield)
140
141 TYPE(fist_environment_type), INTENT(IN) :: fist_env
142 TYPE(atomic_kind_type), OPTIONAL, POINTER :: atomic_kind_set(:)
143 TYPE(particle_type), OPTIONAL, POINTER :: particle_set(:)
144 TYPE(ewald_pw_type), OPTIONAL, POINTER :: ewald_pw
145 TYPE(distribution_1d_type), OPTIONAL, POINTER :: local_particles, local_molecules
146 TYPE(molecule_kind_type), OPTIONAL, POINTER :: molecule_kind_set(:)
147 TYPE(molecule_type), OPTIONAL, POINTER :: molecule_set(:)
148 TYPE(cell_type), OPTIONAL, POINTER :: cell, cell_ref
149 TYPE(ewald_environment_type), OPTIONAL, POINTER :: ewald_env
150 TYPE(fist_nonbond_env_type), OPTIONAL, POINTER :: fist_nonbond_env
151 TYPE(fist_energy_type), OPTIONAL, POINTER :: thermo
152 TYPE(mp_para_env_type), OPTIONAL, POINTER :: para_env
153 TYPE(cp_subsys_type), OPTIONAL, POINTER :: subsys
154 LOGICAL, OPTIONAL :: qmmm
155 TYPE(qmmm_env_mm_type), OPTIONAL, POINTER :: qmmm_env
156 TYPE(section_vals_type), OPTIONAL, POINTER :: input
157 LOGICAL, OPTIONAL :: shell_model, shell_model_ad
158 TYPE(particle_type), OPTIONAL, POINTER :: shell_particle_set(:), &
159 core_particle_set(:)
160 TYPE(multipole_type), OPTIONAL, POINTER :: multipoles
161 TYPE(cp_result_type), OPTIONAL, POINTER :: results
162 TYPE(exclusion_type), DIMENSION(:), OPTIONAL, &
163 POINTER :: exclusions
164 TYPE(fist_efield_type), OPTIONAL, POINTER :: efield
165
166 TYPE(atomic_kind_list_type), POINTER :: atomic_kinds
167 TYPE(molecule_kind_list_type), POINTER :: molecule_kinds
168 TYPE(molecule_list_type), POINTER :: molecules
169 TYPE(multipole_type), POINTER :: fist_multipoles
170 TYPE(particle_list_type), POINTER :: core_particles, particles, &
171 shell_particles
172
173 NULLIFY (atomic_kinds, particles, molecules, molecule_kinds, fist_multipoles)
174
175 IF (PRESENT(input)) input => fist_env%input
176 IF (PRESENT(qmmm)) qmmm = fist_env%qmmm
177 IF (PRESENT(qmmm_env)) qmmm_env => fist_env%qmmm_env
178 IF (PRESENT(cell_ref)) cell_ref => fist_env%cell_ref
179 IF (PRESENT(ewald_env)) ewald_env => fist_env%ewald_env
180 IF (PRESENT(thermo)) thermo => fist_env%thermo
181 IF (PRESENT(exclusions)) exclusions => fist_env%exclusions
182 IF (PRESENT(para_env)) para_env => fist_env%para_env
183 IF (PRESENT(ewald_pw)) ewald_pw => fist_env%ewald_pw
184 IF (PRESENT(fist_nonbond_env)) fist_nonbond_env => fist_env%fist_nonbond_env
185 IF (PRESENT(shell_model)) shell_model = fist_env%shell_model
186 IF (PRESENT(shell_model_ad)) shell_model_ad = fist_env%shell_model_ad
187 IF (PRESENT(subsys)) subsys => fist_env%subsys
188 IF (PRESENT(efield)) efield => fist_env%efield
189
190 IF (ASSOCIATED(fist_env%subsys)) THEN
191 CALL cp_subsys_get(fist_env%subsys, &
192 atomic_kinds=atomic_kinds, &
193 local_molecules=local_molecules, &
194 local_particles=local_particles, &
195 particles=particles, &
196 molecule_kinds=molecule_kinds, &
197 molecules=molecules, &
198 shell_particles=shell_particles, &
199 core_particles=core_particles, &
200 multipoles=fist_multipoles, &
201 results=results, &
202 cell=cell)
203 END IF
204 IF (PRESENT(atomic_kind_set)) atomic_kind_set => atomic_kinds%els
205 IF (PRESENT(particle_set)) particle_set => particles%els
206 IF (PRESENT(molecule_kind_set)) molecule_kind_set => molecule_kinds%els
207 IF (PRESENT(molecule_set)) molecule_set => molecules%els
208 IF (PRESENT(shell_particle_set)) shell_particle_set => shell_particles%els
209 IF (PRESENT(core_particle_set)) core_particle_set => core_particles%els
210 IF (PRESENT(multipoles)) multipoles => fist_multipoles
211 END SUBROUTINE fist_env_get
212
213! **************************************************************************************************
214!> \brief Initialise the FIST environment.
215!> \param fist_env the pointer to the fist_env
216!> \param para_env ...
217!> \par History
218!> 11/03
219!> \author CJM
220! **************************************************************************************************
221 SUBROUTINE init_fist_env(fist_env, para_env)
222
223 TYPE(fist_environment_type), INTENT(OUT) :: fist_env
224 TYPE(mp_para_env_type), POINTER :: para_env
225
226 NULLIFY (fist_env%input)
227 NULLIFY (fist_env%qmmm_env)
228 NULLIFY (fist_env%cell_ref)
229 NULLIFY (fist_env%ewald_env)
230 NULLIFY (fist_env%ewald_pw)
231 NULLIFY (fist_env%thermo)
232 NULLIFY (fist_env%fist_nonbond_env)
233 NULLIFY (fist_env%subsys)
234 NULLIFY (fist_env%exclusions)
235 NULLIFY (fist_env%efield)
236 fist_env%qmmm = .false.
237 fist_env%shell_model = .false.
238 fist_env%shell_model_ad = .false.
239 ALLOCATE (fist_env%qmmm_env)
240 CALL qmmm_env_mm_create(fist_env%qmmm_env)
241 NULLIFY (fist_env%subsys)
242 CALL para_env%retain()
243 fist_env%para_env => para_env
244
245 END SUBROUTINE init_fist_env
246
247! **************************************************************************************************
248!> \brief Set the FIST environment.
249!> \param fist_env the pointer to the fist_env
250!> \param atomic_kind_set ...
251!> \param particle_set ...
252!> \param ewald_pw ...
253!> \param local_particles ...
254!> \param local_molecules ...
255!> \param molecule_kind_set ...
256!> \param molecule_set ...
257!> \param cell_ref ...
258!> \param ewald_env ...
259!> \param fist_nonbond_env ...
260!> \param thermo ...
261!> \param subsys ...
262!> \param qmmm ...
263!> \param qmmm_env ...
264!> \param input ...
265!> \param shell_model ...
266!> \param shell_model_ad ...
267!> \param exclusions ...
268!> \param efield ...
269!> \par History
270!> 11/03
271!> \author CJM
272! **************************************************************************************************
273 SUBROUTINE fist_env_set(fist_env, atomic_kind_set, particle_set, ewald_pw, &
274 local_particles, local_molecules, molecule_kind_set, &
275 molecule_set, cell_ref, ewald_env, &
276 fist_nonbond_env, thermo, subsys, qmmm, qmmm_env, &
277 input, shell_model, shell_model_ad, exclusions, efield)
278
279 TYPE(fist_environment_type), INTENT(INOUT) :: fist_env
280 TYPE(atomic_kind_type), OPTIONAL, POINTER :: atomic_kind_set(:)
281 TYPE(particle_type), OPTIONAL, POINTER :: particle_set(:)
282 TYPE(ewald_pw_type), OPTIONAL, POINTER :: ewald_pw
283 TYPE(distribution_1d_type), OPTIONAL, POINTER :: local_particles, local_molecules
284 TYPE(molecule_kind_type), OPTIONAL, POINTER :: molecule_kind_set(:)
285 TYPE(molecule_type), OPTIONAL, POINTER :: molecule_set(:)
286 TYPE(cell_type), OPTIONAL, POINTER :: cell_ref
287 TYPE(ewald_environment_type), OPTIONAL, POINTER :: ewald_env
288 TYPE(fist_nonbond_env_type), OPTIONAL, POINTER :: fist_nonbond_env
289 TYPE(fist_energy_type), OPTIONAL, POINTER :: thermo
290 TYPE(cp_subsys_type), OPTIONAL, POINTER :: subsys
291 LOGICAL, OPTIONAL :: qmmm
292 TYPE(qmmm_env_mm_type), OPTIONAL, POINTER :: qmmm_env
293 TYPE(section_vals_type), OPTIONAL, POINTER :: input
294 LOGICAL, OPTIONAL :: shell_model, shell_model_ad
295 TYPE(exclusion_type), DIMENSION(:), OPTIONAL, &
296 POINTER :: exclusions
297 TYPE(fist_efield_type), OPTIONAL, POINTER :: efield
298
299 TYPE(atomic_kind_list_type), POINTER :: atomic_kinds
300 TYPE(molecule_kind_list_type), POINTER :: molecule_kinds
301 TYPE(molecule_list_type), POINTER :: molecules
302 TYPE(particle_list_type), POINTER :: particles
303
304 IF (PRESENT(qmmm)) fist_env%qmmm = qmmm
305 IF (PRESENT(qmmm_env)) THEN
306 IF (ASSOCIATED(fist_env%qmmm_env)) THEN
307 CALL qmmm_env_mm_release(fist_env%qmmm_env)
308 DEALLOCATE (fist_env%qmmm_env)
309 END IF
310 fist_env%qmmm_env => qmmm_env
311 END IF
312 IF (PRESENT(ewald_env)) THEN
313 IF (ASSOCIATED(fist_env%ewald_env)) THEN
314 IF (.NOT. ASSOCIATED(fist_env%ewald_env, ewald_env)) THEN
315 CALL ewald_env_release(fist_env%ewald_env)
316 DEALLOCATE (fist_env%ewald_env)
317 END IF
318 END IF
319 fist_env%ewald_env => ewald_env
320 END IF
321 IF (PRESENT(ewald_pw)) THEN
322 IF (ASSOCIATED(fist_env%ewald_pw)) THEN
323 IF (.NOT. ASSOCIATED(fist_env%ewald_pw, ewald_pw)) THEN
324 CALL ewald_pw_release(fist_env%ewald_pw)
325 DEALLOCATE (fist_env%ewald_pw)
326 END IF
327 END IF
328 fist_env%ewald_pw => ewald_pw
329 END IF
330 IF (PRESENT(cell_ref)) THEN
331 CALL cell_retain(cell_ref)
332 CALL cell_release(fist_env%cell_ref)
333 fist_env%cell_ref => cell_ref
334 END IF
335 IF (PRESENT(fist_nonbond_env)) THEN
336 IF (ASSOCIATED(fist_env%fist_nonbond_env)) THEN
337 IF (.NOT. ASSOCIATED(fist_env%fist_nonbond_env, fist_nonbond_env)) THEN
338 CALL fist_nonbond_env_release(fist_env%fist_nonbond_env)
339 DEALLOCATE (fist_env%fist_nonbond_env)
340 END IF
341 END IF
342 fist_env%fist_nonbond_env => fist_nonbond_env
343 END IF
344 IF (PRESENT(input)) THEN
345 CALL section_vals_retain(input)
346 CALL section_vals_release(fist_env%input)
347 fist_env%input => input
348 END IF
349 IF (PRESENT(thermo)) fist_env%thermo => thermo
350 IF (PRESENT(subsys)) THEN
351 IF (ASSOCIATED(fist_env%subsys)) THEN
352 IF (.NOT. ASSOCIATED(fist_env%subsys, subsys)) THEN
353 CALL cp_subsys_release(fist_env%subsys)
354 END IF
355 END IF
356 fist_env%subsys => subsys
357 END IF
358 IF (PRESENT(atomic_kind_set)) THEN
359 CALL atomic_kind_list_create(atomic_kinds, &
360 els_ptr=atomic_kind_set)
361 CALL cp_subsys_set(fist_env%subsys, &
362 atomic_kinds=atomic_kinds)
363 CALL atomic_kind_list_release(atomic_kinds)
364 END IF
365 IF (PRESENT(particle_set)) THEN
366 CALL particle_list_create(particles, &
367 els_ptr=particle_set)
368 CALL cp_subsys_set(fist_env%subsys, &
369 particles=particles)
370 CALL particle_list_release(particles)
371 END IF
372 IF (PRESENT(local_particles)) THEN
373 CALL cp_subsys_set(fist_env%subsys, &
374 local_particles=local_particles)
375 END IF
376 IF (PRESENT(local_molecules)) THEN
377 CALL cp_subsys_set(fist_env%subsys, &
378 local_molecules=local_molecules)
379 END IF
380 IF (PRESENT(molecule_kind_set)) THEN
381 CALL molecule_kind_list_create(molecule_kinds, &
382 els_ptr=molecule_kind_set)
383 CALL cp_subsys_set(fist_env%subsys, &
384 molecule_kinds=molecule_kinds)
385 CALL molecule_kind_list_release(molecule_kinds)
386 END IF
387 IF (PRESENT(molecule_set)) THEN
388 CALL molecule_list_create(molecules, &
389 els_ptr=molecule_set)
390 CALL cp_subsys_set(fist_env%subsys, &
391 molecules=molecules)
392 CALL molecule_list_release(molecules)
393 END IF
394 IF (PRESENT(exclusions)) fist_env%exclusions => exclusions
395 IF (PRESENT(shell_model)) THEN
396 fist_env%shell_model = shell_model
397 END IF
398 IF (PRESENT(shell_model_ad)) THEN
399 fist_env%shell_model_ad = shell_model_ad
400 END IF
401 IF (PRESENT(efield)) fist_env%efield => efield
402
403 END SUBROUTINE fist_env_set
404
405! **************************************************************************************************
406!> \brief allocates and intitializes a fist_env
407!> \param fist_env the object to create
408!> \param para_env the parallel environment for the qs_env
409!> \par History
410!> 12.2002 created [fawzi]
411!> \author Fawzi Mohamed
412! **************************************************************************************************
413 SUBROUTINE fist_env_create(fist_env, para_env)
414 TYPE(fist_environment_type), INTENT(OUT) :: fist_env
415 TYPE(mp_para_env_type), INTENT(IN), POINTER :: para_env
416
417 CALL init_fist_env(fist_env, para_env=para_env)
418 END SUBROUTINE fist_env_create
419
420! **************************************************************************************************
421!> \brief releases the given fist_env (see doc/ReferenceCounting.html)
422!> \param fist_env the object to release
423!> \par History
424!> 12.2002 created [fawzi]
425!> \author Fawzi Mohamed
426! **************************************************************************************************
427 SUBROUTINE fist_env_release(fist_env)
428 TYPE(fist_environment_type), INTENT(INOUT) :: fist_env
429
430 IF (ASSOCIATED(fist_env%qmmm_env)) THEN
431 CALL qmmm_env_mm_release(fist_env%qmmm_env)
432 DEALLOCATE (fist_env%qmmm_env)
433 END IF
434 CALL cell_release(fist_env%cell_ref)
435 IF (ASSOCIATED(fist_env%ewald_pw)) THEN
436 CALL ewald_pw_release(fist_env%ewald_pw)
437 DEALLOCATE (fist_env%ewald_pw)
438 END IF
439 IF (ASSOCIATED(fist_env%ewald_env)) THEN
440 CALL ewald_env_release(fist_env%ewald_env)
441 DEALLOCATE (fist_env%ewald_env)
442 END IF
443 CALL mp_para_env_release(fist_env%para_env)
444 CALL deallocate_fist_energy(fist_env%thermo)
445
446 IF (ASSOCIATED(fist_env%fist_nonbond_env)) THEN
447 CALL fist_nonbond_env_release(fist_env%fist_nonbond_env)
448 DEALLOCATE (fist_env%fist_nonbond_env)
449 END IF
450 CALL cp_subsys_release(fist_env%subsys)
451 CALL section_vals_release(fist_env%input)
452 CALL exclusion_release(fist_env%exclusions)
453
454 IF (ASSOCIATED(fist_env%efield)) THEN
455 DEALLOCATE (fist_env%efield)
456 END IF
457
458 END SUBROUTINE fist_env_release
459
460END MODULE fist_environment_types
represent a simple array based list of the given type
subroutine, public atomic_kind_list_release(list)
releases a list (see doc/ReferenceCounting.html)
subroutine, public atomic_kind_list_create(list, els_ptr, owns_els, n_els)
creates a list
Define the atomic kind types and their sub types.
Handles all functions related to the CELL.
Definition cell_types.F:15
subroutine, public cell_release(cell)
releases the given cell (see doc/ReferenceCounting.html)
Definition cell_types.F:608
subroutine, public cell_retain(cell)
retains the given cell (see doc/ReferenceCounting.html)
Definition cell_types.F:591
set of type/routines to handle the storage of results in force_envs
types that represent a subsys, i.e. a part of the system
subroutine, public cp_subsys_set(subsys, atomic_kinds, particles, local_particles, molecules, molecule_kinds, local_molecules, para_env, colvar_p, shell_particles, core_particles, gci, multipoles, results, cell, cell_ref, use_ref_cell)
sets various propreties of the subsys
subroutine, public cp_subsys_release(subsys)
releases a subsys (see doc/ReferenceCounting.html)
subroutine, public cp_subsys_get(subsys, ref_count, atomic_kinds, atomic_kind_set, particles, particle_set, local_particles, molecules, molecule_set, molecule_kinds, molecule_kind_set, local_molecules, para_env, colvar_p, shell_particles, core_particles, gci, multipoles, natom, nparticle, ncore, nshell, nkind, atprop, virial, results, cell, cell_ref, use_ref_cell)
returns information about various attributes of the given subsys
stores a lists of integer that are local to a processor. The idea is that these integers represent ob...
subroutine, public ewald_env_release(ewald_env)
releases the given ewald_env (see doc/ReferenceCounting.html)
subroutine, public ewald_pw_release(ewald_pw)
releases the memory used by the ewald_pw
an exclusion type
subroutine, public exclusion_release(exclusions)
Release exclusion type.
subroutine, public deallocate_fist_energy(fist_energy)
Deallocate a Fist energy data structure.
subroutine, public fist_env_release(fist_env)
releases the given fist_env (see doc/ReferenceCounting.html)
subroutine, public fist_env_get(fist_env, atomic_kind_set, particle_set, ewald_pw, local_particles, local_molecules, molecule_kind_set, molecule_set, cell, cell_ref, ewald_env, fist_nonbond_env, thermo, para_env, subsys, qmmm, qmmm_env, input, shell_model, shell_model_ad, shell_particle_set, core_particle_set, multipoles, results, exclusions, efield)
Purpose: Get the FIST environment.
subroutine, public fist_env_create(fist_env, para_env)
allocates and intitializes a fist_env
subroutine, public fist_env_set(fist_env, atomic_kind_set, particle_set, ewald_pw, local_particles, local_molecules, molecule_kind_set, molecule_set, cell_ref, ewald_env, fist_nonbond_env, thermo, subsys, qmmm, qmmm_env, input, shell_model, shell_model_ad, exclusions, efield)
Set the FIST environment.
subroutine, public fist_nonbond_env_release(fist_nonbond_env)
releases the given fist_nonbond_env (see doc/ReferenceCounting.html)
objects that represent the structure of input sections and the data contained in an input section
subroutine, public section_vals_retain(section_vals)
retains the given section values (see doc/ReferenceCounting.html)
recursive subroutine, public section_vals_release(section_vals)
releases the given object
Interface to the message passing library MPI.
subroutine, public mp_para_env_release(para_env)
releases the para object (to be called when you don't want anymore the shared copy of this object)
represent a simple array based list of the given type
subroutine, public molecule_kind_list_create(list, els_ptr, owns_els, n_els)
creates a list
subroutine, public molecule_kind_list_release(list)
releases a list (see doc/ReferenceCounting.html)
Define the molecule kind structure types and the corresponding functionality.
represent a simple array based list of the given type
subroutine, public molecule_list_create(list, els_ptr, owns_els, n_els)
creates a list
subroutine, public molecule_list_release(list)
releases a list (see doc/ReferenceCounting.html)
Define the data structure for the molecule information.
Multipole structure: for multipole (fixed and induced) in FF based MD.
represent a simple array based list of the given type
subroutine, public particle_list_create(list, els_ptr, owns_els, n_els)
creates a list
subroutine, public particle_list_release(list)
releases a list (see doc/ReferenceCounting.html)
Define the data structure for the particle information.
subroutine, public qmmm_env_mm_create(qmmm_env)
...
subroutine, public qmmm_env_mm_release(qmmm_env)
releases the given qmmm_env (see doc/ReferenceCounting.html)
Provides all information about an atomic kind.
Type defining parameters related to the simulation cell.
Definition cell_types.F:60
contains arbitrary information which need to be stored
represents a system: atoms, molecules, their pos,vel,...
structure to store local (to a processor) ordered lists of integers.
A type used to store lists of exclusions and onfos.
stores all the informations relevant to an mpi environment