(git:b279b6b)
nnp_environment_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 Data types for neural network potentials
10 !> \author Christoph Schran (christoph.schran@rub.de)
11 !> \date 2020-10-10
12 ! **************************************************************************************************
16  atomic_kind_list_type
17  USE atomic_kind_types, ONLY: atomic_kind_type
18  USE cell_types, ONLY: cell_release,&
19  cell_retain,&
20  cell_type
21  USE cp_subsys_types, ONLY: cp_subsys_get,&
24  cp_subsys_type
25  USE distribution_1d_types, ONLY: distribution_1d_type
26  USE input_section_types, ONLY: section_vals_type
27  USE kinds, ONLY: default_string_length,&
28  dp
31  molecule_kind_list_type
32  USE molecule_kind_types, ONLY: molecule_kind_type
35  molecule_list_type
36  USE molecule_types, ONLY: molecule_type
39  particle_list_type
40  USE particle_types, ONLY: particle_type
41  USE virial_types, ONLY: virial_type
42 #include "./base/base_uses.f90"
43 
44  IMPLICIT NONE
45 
46  PRIVATE
47 
48  LOGICAL, PRIVATE, PARAMETER :: debug_this_module = .true.
49  CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'nnp_environment_types'
50 
51  !> derived data types
52  PUBLIC :: nnp_type
53  PUBLIC :: nnp_arc_type
54  PUBLIC :: nnp_neighbor_type
55  PUBLIC :: nnp_acsf_rad_type
56  PUBLIC :: nnp_acsf_ang_type
57 
58  ! Public subroutines ***
59  PUBLIC :: nnp_env_release, &
60  nnp_env_set, &
62 
63  INTEGER, PARAMETER, PUBLIC :: &
64  nnp_cut_cos = 1, &
65  nnp_cut_tanh = 2
66 
67  INTEGER, PARAMETER, PUBLIC :: &
68  nnp_actfnct_tanh = 1, &
69  nnp_actfnct_gaus = 2, &
70  nnp_actfnct_lin = 3, &
71  nnp_actfnct_cos = 4, &
72  nnp_actfnct_sig = 5, &
73  nnp_actfnct_invsig = 6, &
74  nnp_actfnct_exp = 7, &
77 
78 ! **************************************************************************************************
79 !> \brief Main data type collecting all relevant data for neural network potentials
80 !> \author Christoph Schran (christoph.schran@rub.de)
81 !> \date 2020-10-10
82 ! **************************************************************************************************
83  TYPE nnp_type
84  TYPE(nnp_acsf_rad_type), DIMENSION(:), POINTER :: rad => null() ! DIM(n_ele)
85  TYPE(nnp_acsf_ang_type), DIMENSION(:), POINTER :: ang => null() ! DIM(n_ele)
86  INTEGER, DIMENSION(:), ALLOCATABLE :: n_rad ! # radial symfnct for this element
87  INTEGER, DIMENSION(:), ALLOCATABLE :: n_ang ! # angular symfnct for this element
88  INTEGER :: n_ele ! # elements
89  CHARACTER(len=2), ALLOCATABLE, DIMENSION(:) :: ele ! elements(n_ele)
90  INTEGER, ALLOCATABLE, DIMENSION(:) :: nuc_ele ! elements(n_ele)
91  LOGICAL :: scale_acsf
92  LOGICAL :: scale_sigma_acsf
93  LOGICAL :: center_acsf
94  LOGICAL :: normnodes
95  INTEGER :: n_radgrp
96  INTEGER :: n_anggrp
97  INTEGER :: cut_type ! cutofftype
98  REAL(kind=dp) :: eshortmin
99  REAL(kind=dp) :: eshortmax
100  REAL(kind=dp) :: scmax !scale
101  REAL(kind=dp) :: scmin !scale
102  REAL(kind=dp) :: max_cut !largest cutoff
103  REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: atom_energies !DIM(n_ele)
104  TYPE(nnp_arc_type), POINTER, DIMENSION(:) :: arc => null() ! DIM(n_ele)
105  INTEGER :: n_committee
106  INTEGER :: n_hlayer
107  INTEGER :: n_layer
108  INTEGER, ALLOCATABLE, DIMENSION(:) :: n_hnodes
109  INTEGER, ALLOCATABLE, DIMENSION(:) :: actfnct
110  INTEGER :: expol ! extrapolation coutner
111  LOGICAL :: output_expol ! output extrapolation
112  ! structures for calculation
113  INTEGER :: num_atoms
114  REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: atomic_energy
115  REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: committee_energy
116  INTEGER, ALLOCATABLE, DIMENSION(:) :: ele_ind, nuc_atoms, sort, sort_inv
117  REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: coord
118  REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :, :) :: myforce
119  REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :, :) :: committee_forces, committee_stress
120  CHARACTER(len=default_string_length), &
121  ALLOCATABLE, DIMENSION(:) :: atoms
122  REAL(kind=dp), DIMENSION(:, :), ALLOCATABLE :: nnp_forces
123  REAL(kind=dp) :: nnp_potential_energy
124  TYPE(cp_subsys_type), POINTER :: subsys => null()
125  TYPE(section_vals_type), POINTER :: nnp_input => null()
126  TYPE(section_vals_type), POINTER :: force_env_input => null()
127  TYPE(cell_type), POINTER :: cell => null()
128  TYPE(cell_type), POINTER :: cell_ref => null()
129  LOGICAL :: use_ref_cell = .false.
130  ! bias
131  LOGICAL :: bias
132  LOGICAL :: bias_align
133  REAL(kind=dp) :: bias_energy
134  REAL(kind=dp) :: bias_kb
135  REAL(kind=dp) :: bias_sigma0
136  REAL(kind=dp) :: bias_sigma
137  REAL(kind=dp), DIMENSION(:, :), ALLOCATABLE :: bias_forces
138  REAL(kind=dp), DIMENSION(:), ALLOCATABLE :: bias_e_avrg
139  END TYPE nnp_type
140 
141 ! **************************************************************************************************
142 !> \brief Symmetry functions group type
143 !> \param n_symf - # of associated sym fncts
144 !> \param symf - indices of associated sym fncts DIM(nsymf)
145 !> \param ele - elements indices rad:DIM(2), ang:DIM(3)
146 !> \param cutoff - associated cutoff value
147 !> \author Christoph Schran (christoph.schran@rub.de)
148 !> \date 2020-10-10
149 ! **************************************************************************************************
150  TYPE nnp_symfgrp_type
151  INTEGER :: n_symf
152  INTEGER, DIMENSION(:), ALLOCATABLE :: symf
153  INTEGER, DIMENSION(:), ALLOCATABLE :: ele_ind
154  CHARACTER(LEN=2), DIMENSION(:), ALLOCATABLE :: ele
155  REAL(kind=dp) :: cutoff
156  END TYPE
157 
158 ! **************************************************************************************************
159 !> \brief Set of radial symmetry function type
160 !> \param y - acsf value - DIM(n_rad)
161 !> \param funccut - distance cutoff bohr - DIM(n_rad)
162 !> \param eta - eta parameter of radial sym fncts bohr^-2 - DIM(n_rad)
163 !> \param rs - r shift parameter of radial sym fncts bohr - DIM(n_rad)
164 !> \param loc_min - minimum of the sym fnct DIM(n_rad)
165 !> \param loc_max - maximum of the sym fnct DIM(n_rad)
166 !> \param loc_av - average of the sym fnct DIM(n_rad)
167 !> \param sigma - SD of the sym fnc DIM(n_rad)
168 !> \param ele - element associated to the sym fnct DIM(n_rad)
169 !> \param nuc_ele - associated atomic number DIM(n_rad)
170 !> \author Christoph Schran (christoph.schran@rub.de)
171 !> \date 2020-10-10
172 ! **************************************************************************************************
173  TYPE nnp_acsf_rad_type
174  REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: y
175  REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: funccut
176  REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: eta
177  REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: rs
178  REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: loc_min
179  REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: loc_max
180  REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: loc_av
181  REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: sigma
182  CHARACTER(len=2), ALLOCATABLE, DIMENSION(:) :: ele
183  INTEGER, ALLOCATABLE, DIMENSION(:) :: nuc_ele
184  INTEGER :: n_symfgrp
185  TYPE(nnp_symfgrp_type), DIMENSION(:), ALLOCATABLE :: symfgrp
186  END TYPE
187 
188 ! **************************************************************************************************
189 !> \brief Set of angular symmetry function type
190 !> \param y - acsf value - DIM(n_ang)
191 !> \param funccut - distance cutoff bohr - DIM(n_ang)
192 !> \param eta - eta param. of angular sym fncts bohr^-2 - DIM(n_ang)
193 !> \param zeta - zeta param. of angular sym fncts DIM(n_ang)
194 !> \param lam - lambda param. of angular sym fncts DIM(n_ang)
195 !> \param loc_min - minimum of the sym fnct DIM(n_ang)
196 !> \param loc_max - maximum of the sym fnct DIM(n_ang)
197 !> \param loc_av - average of the sym fnct DIM(n_ang)
198 !> \param sigma - SD of the sym fnc DIM(n_ang)
199 !> \param ele1,ele2 - elements associated to the sym fnct DIM(n_ang)
200 !> \param nuc_ele2, nuc_ele2 - associated atomic numbers DIM(n_ang)
201 !> \author Christoph Schran (christoph.schran@rub.de)
202 !> \date 2020-10-10
203 ! **************************************************************************************************
204  TYPE nnp_acsf_ang_type
205  REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: y
206  REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: funccut
207  REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: eta
208  REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: zeta
209  REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: prefzeta
210  REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: lam
211  REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: loc_min
212  REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: loc_max
213  REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: loc_av
214  REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: sigma
215  CHARACTER(len=2), ALLOCATABLE, DIMENSION(:) :: ele1
216  CHARACTER(len=2), ALLOCATABLE, DIMENSION(:) :: ele2
217  INTEGER, ALLOCATABLE, DIMENSION(:) :: nuc_ele1
218  INTEGER, ALLOCATABLE, DIMENSION(:) :: nuc_ele2
219  INTEGER :: n_symfgrp
220  TYPE(nnp_symfgrp_type), DIMENSION(:), ALLOCATABLE :: symfgrp
221  END TYPE
222 
223 ! **************************************************************************************************
224 !> \brief Contains neighbors list of an atom
225 !> \param dist - distance vectors + norm DIM(4,nat)
226 !> \param n - number of neighbors
227 !> \author Christoph Schran (christoph.schran@rub.de)
228 !> \date 2020-10-10
229 ! **************************************************************************************************
230  TYPE nnp_neighbor_type
231  INTEGER, DIMENSION(3) :: pbc_copies
232  INTEGER, DIMENSION(:), ALLOCATABLE :: n_rad
233  INTEGER, DIMENSION(:), ALLOCATABLE :: n_ang1
234  INTEGER, DIMENSION(:), ALLOCATABLE :: n_ang2
235  INTEGER, DIMENSION(:, :), ALLOCATABLE :: ind_rad
236  INTEGER, DIMENSION(:, :), ALLOCATABLE :: ind_ang1
237  INTEGER, DIMENSION(:, :), ALLOCATABLE :: ind_ang2
238  REAL(kind=dp), DIMENSION(:, :, :), ALLOCATABLE :: dist_rad
239  REAL(kind=dp), DIMENSION(:, :, :), ALLOCATABLE :: dist_ang1
240  REAL(kind=dp), DIMENSION(:, :, :), ALLOCATABLE :: dist_ang2
241  END TYPE
242 
243 ! **************************************************************************************************
244 !> \brief Data type for artificial neural networks
245 !> \author Christoph Schran (christoph.schran@rub.de)
246 !> \date 2020-10-10
247 ! **************************************************************************************************
248  TYPE nnp_arc_type
249  TYPE(nnp_arc_layer_type), POINTER, DIMENSION(:) :: layer ! DIM(n_layer)
250  INTEGER, ALLOCATABLE, DIMENSION(:) :: n_nodes
251  END TYPE
252 
253 ! **************************************************************************************************
254 !> \brief Data type for individual layer
255 !> \author Christoph Schran (christoph.schran@rub.de)
256 !> \date 2020-10-10
257 ! **************************************************************************************************
258  TYPE nnp_arc_layer_type
259  REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :, :) :: weights ! node weights
260  REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: bweights ! bias weights
261  REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: node ! DIM(n_nodes)
262  REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: node_grad ! DIM(n_nodes)
263  REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: tmp_der ! DIM(n_sym,n_nodes)
264  END TYPE
265 
266 CONTAINS
267 
268 ! **************************************************************************************************
269 !> \brief Release data structure that holds all the information for neural
270 !> network potentials
271 !> \param nnp_env ...
272 !> \date 2020-10-10
273 !> \author Christoph Schran (christoph.schran@rub.de)
274 ! **************************************************************************************************
275  SUBROUTINE nnp_env_release(nnp_env)
276  TYPE(nnp_type), INTENT(INOUT) :: nnp_env
277 
278  INTEGER :: i, j
279 
280  IF (ASSOCIATED(nnp_env%rad)) THEN
281  DO i = 1, nnp_env%n_ele
282  DO j = 1, nnp_env%rad(i)%n_symfgrp
283  DEALLOCATE (nnp_env%rad(i)%symfgrp(j)%symf, &
284  nnp_env%rad(i)%symfgrp(j)%ele, &
285  nnp_env%rad(i)%symfgrp(j)%ele_ind)
286  END DO
287  DEALLOCATE (nnp_env%rad(i)%y, &
288  nnp_env%rad(i)%funccut, &
289  nnp_env%rad(i)%eta, &
290  nnp_env%rad(i)%rs, &
291  nnp_env%rad(i)%loc_min, &
292  nnp_env%rad(i)%loc_max, &
293  nnp_env%rad(i)%loc_av, &
294  nnp_env%rad(i)%sigma, &
295  nnp_env%rad(i)%ele, &
296  nnp_env%rad(i)%nuc_ele, &
297  nnp_env%rad(i)%symfgrp)
298  END DO
299  DEALLOCATE (nnp_env%rad)
300  END IF
301 
302  IF (ASSOCIATED(nnp_env%ang)) THEN
303  DO i = 1, nnp_env%n_ele
304  DO j = 1, nnp_env%ang(i)%n_symfgrp
305  DEALLOCATE (nnp_env%ang(i)%symfgrp(j)%symf, &
306  nnp_env%ang(i)%symfgrp(j)%ele, &
307  nnp_env%ang(i)%symfgrp(j)%ele_ind)
308  END DO
309  DEALLOCATE (nnp_env%ang(i)%y, &
310  nnp_env%ang(i)%funccut, &
311  nnp_env%ang(i)%eta, &
312  nnp_env%ang(i)%zeta, &
313  nnp_env%ang(i)%prefzeta, &
314  nnp_env%ang(i)%lam, &
315  nnp_env%ang(i)%loc_min, &
316  nnp_env%ang(i)%loc_max, &
317  nnp_env%ang(i)%loc_av, &
318  nnp_env%ang(i)%sigma, &
319  nnp_env%ang(i)%ele1, &
320  nnp_env%ang(i)%ele2, &
321  nnp_env%ang(i)%nuc_ele1, &
322  nnp_env%ang(i)%nuc_ele2, &
323  nnp_env%ang(i)%symfgrp)
324  END DO
325  DEALLOCATE (nnp_env%ang)
326  END IF
327 
328  IF (ASSOCIATED(nnp_env%arc)) THEN
329  DO i = 1, nnp_env%n_ele
330  IF (ASSOCIATED(nnp_env%arc(i)%layer)) THEN
331  DO j = 1, nnp_env%n_layer
332  IF (ALLOCATED(nnp_env%arc(i)%layer(j)%node)) THEN
333  DEALLOCATE (nnp_env%arc(i)%layer(j)%node)
334  END IF
335  IF (ALLOCATED(nnp_env%arc(i)%layer(j)%node_grad)) THEN
336  DEALLOCATE (nnp_env%arc(i)%layer(j)%node_grad)
337  END IF
338  IF (ALLOCATED(nnp_env%arc(i)%layer(j)%weights)) THEN
339  DEALLOCATE (nnp_env%arc(i)%layer(j)%weights)
340  END IF
341  IF (ALLOCATED(nnp_env%arc(i)%layer(j)%bweights)) THEN
342  DEALLOCATE (nnp_env%arc(i)%layer(j)%bweights)
343  END IF
344  IF (ALLOCATED(nnp_env%arc(i)%layer(j)%tmp_der)) THEN
345  DEALLOCATE (nnp_env%arc(i)%layer(j)%tmp_der)
346  END IF
347  END DO
348  DEALLOCATE (nnp_env%arc(i)%layer, &
349  nnp_env%arc(i)%n_nodes)
350  END IF
351  END DO
352  DEALLOCATE (nnp_env%arc)
353  END IF
354 
355  IF (ALLOCATED(nnp_env%ele)) DEALLOCATE (nnp_env%ele)
356  IF (ALLOCATED(nnp_env%nuc_ele)) DEALLOCATE (nnp_env%nuc_ele)
357  IF (ALLOCATED(nnp_env%n_hnodes)) DEALLOCATE (nnp_env%n_hnodes)
358  IF (ALLOCATED(nnp_env%actfnct)) DEALLOCATE (nnp_env%actfnct)
359  IF (ALLOCATED(nnp_env%nnp_forces)) DEALLOCATE (nnp_env%nnp_forces)
360  IF (ALLOCATED(nnp_env%atomic_energy)) DEALLOCATE (nnp_env%atomic_energy)
361  IF (ALLOCATED(nnp_env%committee_energy)) DEALLOCATE (nnp_env%committee_energy)
362  IF (ALLOCATED(nnp_env%ele_ind)) DEALLOCATE (nnp_env%ele_ind)
363  IF (ALLOCATED(nnp_env%nuc_atoms)) DEALLOCATE (nnp_env%nuc_atoms)
364  IF (ALLOCATED(nnp_env%sort)) DEALLOCATE (nnp_env%sort)
365  IF (ALLOCATED(nnp_env%sort_inv)) DEALLOCATE (nnp_env%sort_inv)
366  IF (ALLOCATED(nnp_env%coord)) DEALLOCATE (nnp_env%coord)
367  IF (ALLOCATED(nnp_env%myforce)) DEALLOCATE (nnp_env%myforce)
368  IF (ALLOCATED(nnp_env%committee_forces)) DEALLOCATE (nnp_env%committee_forces)
369  IF (ALLOCATED(nnp_env%committee_stress)) DEALLOCATE (nnp_env%committee_stress)
370  IF (ALLOCATED(nnp_env%atoms)) DEALLOCATE (nnp_env%atoms)
371  IF (ALLOCATED(nnp_env%nnp_forces)) DEALLOCATE (nnp_env%nnp_forces)
372 
373  IF (ASSOCIATED(nnp_env%subsys)) THEN
374  CALL cp_subsys_release(nnp_env%subsys)
375  END IF
376  IF (ASSOCIATED(nnp_env%subsys)) THEN
377  CALL cp_subsys_release(nnp_env%subsys)
378  END IF
379  IF (ASSOCIATED(nnp_env%cell)) THEN
380  CALL cell_release(nnp_env%cell)
381  END IF
382  IF (ASSOCIATED(nnp_env%cell_ref)) THEN
383  CALL cell_release(nnp_env%cell_ref)
384  END IF
385 
386  END SUBROUTINE nnp_env_release
387 
388 ! **************************************************************************************************
389 !> \brief Returns various attributes of the nnp environment
390 !> \param nnp_env ...
391 !> \param nnp_forces ...
392 !> \param subsys the particles, molecules,... of this environment
393 !> \param atomic_kind_set The set of all atomic kinds involved
394 !> \param particle_set The set of all particles
395 !> \param local_particles All particles on this particular node
396 !> \param molecule_kind_set The set of all different molecule kinds involved
397 !> \param molecule_set The set of all molecules
398 !> \param local_molecules All molecules on this particular node
399 !> \param nnp_input ...
400 !> \param force_env_input Pointer to the force_env input section
401 !> \param cell The simulation cell
402 !> \param cell_ref The reference simulation cell
403 !> \param use_ref_cell Logical which indicates if reference
404 !> simulation cell is used
405 !> \param nnp_potential_energy ...
406 !> \param virial Dummy virial pointer
407 !> \date 2020-10-10
408 !> \author Christoph Schran (christoph.schran@rub.de)
409 !> \note
410 !> For possible missing arguments see the attributes of
411 !> nnp_type
412 ! **************************************************************************************************
413  SUBROUTINE nnp_env_get(nnp_env, nnp_forces, subsys, &
414  atomic_kind_set, particle_set, local_particles, &
415  molecule_kind_set, molecule_set, local_molecules, &
416  nnp_input, force_env_input, cell, cell_ref, &
417  use_ref_cell, nnp_potential_energy, virial)
418 
419  TYPE(nnp_type), INTENT(IN) :: nnp_env
420  REAL(kind=dp), DIMENSION(:, :), OPTIONAL, POINTER :: nnp_forces
421  TYPE(cp_subsys_type), OPTIONAL, POINTER :: subsys
422  TYPE(atomic_kind_type), DIMENSION(:), OPTIONAL, &
423  POINTER :: atomic_kind_set
424  TYPE(particle_type), DIMENSION(:), OPTIONAL, &
425  POINTER :: particle_set
426  TYPE(distribution_1d_type), OPTIONAL, POINTER :: local_particles
427  TYPE(molecule_kind_type), DIMENSION(:), OPTIONAL, &
428  POINTER :: molecule_kind_set
429  TYPE(molecule_type), DIMENSION(:), OPTIONAL, &
430  POINTER :: molecule_set
431  TYPE(distribution_1d_type), OPTIONAL, POINTER :: local_molecules
432  TYPE(section_vals_type), OPTIONAL, POINTER :: nnp_input, force_env_input
433  TYPE(cell_type), OPTIONAL, POINTER :: cell, cell_ref
434  LOGICAL, INTENT(OUT), OPTIONAL :: use_ref_cell
435  REAL(kind=dp), INTENT(OUT), OPTIONAL :: nnp_potential_energy
436  TYPE(virial_type), OPTIONAL, POINTER :: virial
437 
438  TYPE(atomic_kind_list_type), POINTER :: atomic_kinds
439  TYPE(molecule_kind_list_type), POINTER :: molecule_kinds
440  TYPE(molecule_list_type), POINTER :: molecules
441  TYPE(particle_list_type), POINTER :: particles
442 
443  NULLIFY (atomic_kinds, particles, molecules, molecule_kinds)
444 
445  IF (PRESENT(nnp_potential_energy)) THEN
446  nnp_potential_energy = nnp_env%nnp_potential_energy
447  END IF
448  IF (PRESENT(nnp_forces)) nnp_forces = nnp_env%nnp_forces
449 
450  ! note cell will be overwritten if subsys is associated
451  ! helium_env uses nnp without subsys
452  IF (PRESENT(cell)) cell => nnp_env%cell
453 
454  IF (PRESENT(subsys)) subsys => nnp_env%subsys
455  IF (ASSOCIATED(nnp_env%subsys)) THEN
456  CALL cp_subsys_get(nnp_env%subsys, &
457  atomic_kinds=atomic_kinds, &
458  particles=particles, &
459  molecule_kinds=molecule_kinds, &
460  molecules=molecules, &
461  local_molecules=local_molecules, &
462  local_particles=local_particles, &
463  virial=virial, &
464  cell=cell)
465  END IF
466  IF (PRESENT(atomic_kind_set)) atomic_kind_set => atomic_kinds%els
467  IF (PRESENT(particle_set)) particle_set => particles%els
468  IF (PRESENT(molecule_kind_set)) molecule_kind_set => molecule_kinds%els
469  IF (PRESENT(molecule_set)) molecule_set => molecules%els
470 
471  IF (PRESENT(nnp_input)) nnp_input => nnp_env%nnp_input
472  IF (PRESENT(force_env_input)) force_env_input => nnp_env%force_env_input
473  IF (PRESENT(cell_ref)) cell_ref => nnp_env%cell_ref
474  IF (PRESENT(use_ref_cell)) use_ref_cell = nnp_env%use_ref_cell
475 
476  END SUBROUTINE nnp_env_get
477 
478 ! **************************************************************************************************
479 !> \brief Sets various attributes of the nnp environment
480 !> \param nnp_env ...
481 !> \param nnp_forces ...
482 !> \param subsys the particles, molecules,... of this environment
483 !> \param atomic_kind_set The set of all atomic kinds involved
484 !> \param particle_set The set of all particles
485 !> \param local_particles All particles on this particular node
486 !> \param molecule_kind_set The set of all different molecule kinds involved
487 !> \param molecule_set The set of all molecules
488 !> \param local_molecules All molecules on this particular node
489 !> \param nnp_input ...
490 !> \param force_env_input Pointer to the force_env input section
491 !> \param cell ...
492 !> \param cell_ref The reference simulation cell
493 !> \param use_ref_cell Logical which indicates if reference
494 !> simulation cell is used
495 !> \param nnp_potential_energy ...
496 !> \date 2020-10-10
497 !> \author Christoph Schran (christoph.schran@rub.de)
498 !> \note
499 !> For possible missing arguments see the attributes of nnp_type
500 ! **************************************************************************************************
501  SUBROUTINE nnp_env_set(nnp_env, nnp_forces, subsys, &
502  atomic_kind_set, particle_set, local_particles, &
503  molecule_kind_set, molecule_set, local_molecules, &
504  nnp_input, force_env_input, cell, cell_ref, &
505  use_ref_cell, nnp_potential_energy)
506 
507  TYPE(nnp_type), INTENT(INOUT) :: nnp_env
508  REAL(kind=dp), DIMENSION(:, :), OPTIONAL, POINTER :: nnp_forces
509  TYPE(cp_subsys_type), OPTIONAL, POINTER :: subsys
510  TYPE(atomic_kind_type), DIMENSION(:), OPTIONAL, &
511  POINTER :: atomic_kind_set
512  TYPE(particle_type), DIMENSION(:), OPTIONAL, &
513  POINTER :: particle_set
514  TYPE(distribution_1d_type), OPTIONAL, POINTER :: local_particles
515  TYPE(molecule_kind_type), DIMENSION(:), OPTIONAL, &
516  POINTER :: molecule_kind_set
517  TYPE(molecule_type), DIMENSION(:), OPTIONAL, &
518  POINTER :: molecule_set
519  TYPE(distribution_1d_type), OPTIONAL, POINTER :: local_molecules
520  TYPE(section_vals_type), OPTIONAL, POINTER :: nnp_input, force_env_input
521  TYPE(cell_type), OPTIONAL, POINTER :: cell, cell_ref
522  LOGICAL, INTENT(IN), OPTIONAL :: use_ref_cell
523  REAL(kind=dp), INTENT(IN), OPTIONAL :: nnp_potential_energy
524 
525  TYPE(atomic_kind_list_type), POINTER :: atomic_kinds
526  TYPE(molecule_kind_list_type), POINTER :: molecule_kinds
527  TYPE(molecule_list_type), POINTER :: molecules
528  TYPE(particle_list_type), POINTER :: particles
529 
530  IF (PRESENT(nnp_potential_energy)) THEN
531  nnp_env%nnp_potential_energy = nnp_potential_energy
532  END IF
533  IF (PRESENT(nnp_forces)) nnp_env%nnp_forces(:, :) = nnp_forces
534 
535  IF (PRESENT(subsys)) THEN
536  IF (ASSOCIATED(nnp_env%subsys)) THEN
537  IF (.NOT. ASSOCIATED(nnp_env%subsys, subsys)) THEN
538  CALL cp_subsys_release(nnp_env%subsys)
539  END IF
540  END IF
541  nnp_env%subsys => subsys
542  END IF
543  IF (PRESENT(cell)) THEN
544  IF (ASSOCIATED(cell)) THEN
545  CALL cell_retain(cell)
546  CALL cell_release(nnp_env%cell)
547  nnp_env%cell => cell
548  END IF
549  IF (ASSOCIATED(nnp_env%subsys)) THEN
550  CALL cp_subsys_set(nnp_env%subsys, cell=cell)
551  END IF
552  END IF
553  IF (PRESENT(atomic_kind_set)) THEN
554  CALL atomic_kind_list_create(atomic_kinds, els_ptr=atomic_kind_set)
555  CALL cp_subsys_set(nnp_env%subsys, atomic_kinds=atomic_kinds)
556  CALL atomic_kind_list_release(atomic_kinds)
557  END IF
558  IF (PRESENT(particle_set)) THEN
559  CALL particle_list_create(particles, els_ptr=particle_set)
560  CALL cp_subsys_set(nnp_env%subsys, particles=particles)
561  CALL particle_list_release(particles)
562  END IF
563  IF (PRESENT(molecule_kind_set)) THEN
564  CALL molecule_kind_list_create(molecule_kinds, els_ptr=molecule_kind_set)
565  CALL cp_subsys_set(nnp_env%subsys, molecule_kinds=molecule_kinds)
566  CALL molecule_kind_list_release(molecule_kinds)
567  END IF
568  IF (PRESENT(molecule_set)) THEN
569  CALL molecule_list_create(molecules, els_ptr=molecule_set)
570  CALL cp_subsys_set(nnp_env%subsys, molecules=molecules)
571  CALL molecule_list_release(molecules)
572  END IF
573  IF (PRESENT(local_particles)) THEN
574  CALL cp_subsys_set(nnp_env%subsys, local_particles=local_particles)
575  END IF
576  IF (PRESENT(local_molecules)) THEN
577  CALL cp_subsys_set(nnp_env%subsys, local_molecules=local_molecules)
578  END IF
579 
580  IF (PRESENT(nnp_input)) nnp_env%nnp_input => nnp_input
581  IF (PRESENT(force_env_input)) THEN
582  nnp_env%force_env_input => force_env_input
583  END IF
584  IF (PRESENT(cell_ref)) THEN
585  CALL cell_retain(cell_ref)
586  CALL cell_release(nnp_env%cell_ref)
587  nnp_env%cell_ref => cell_ref
588  END IF
589  IF (PRESENT(use_ref_cell)) nnp_env%use_ref_cell = use_ref_cell
590  END SUBROUTINE nnp_env_set
591 
592 END MODULE nnp_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:559
subroutine, public cell_retain(cell)
retains the given cell (see doc/ReferenceCounting.html)
Definition: cell_types.F:542
types that represent a subsys, i.e. a part of the system
subroutine, public cp_subsys_release(subsys)
releases a subsys (see doc/ReferenceCounting.html)
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)
sets various propreties of the subsys
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)
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...
objects that represent the structure of input sections and the data contained in an input section
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
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.
Data types for neural network potentials.
integer, parameter, public nnp_actfnct_lin
integer, parameter, public nnp_cut_tanh
subroutine, public nnp_env_set(nnp_env, nnp_forces, subsys, atomic_kind_set, particle_set, local_particles, molecule_kind_set, molecule_set, local_molecules, nnp_input, force_env_input, cell, cell_ref, use_ref_cell, nnp_potential_energy)
Sets various attributes of the nnp environment.
integer, parameter, public nnp_actfnct_cos
integer, parameter, public nnp_actfnct_invsig
integer, parameter, public nnp_actfnct_sig
integer, parameter, public nnp_actfnct_exp
integer, parameter, public nnp_cut_cos
derived data types
integer, parameter, public nnp_actfnct_softplus
integer, parameter, public nnp_actfnct_quad
integer, parameter, public nnp_actfnct_gaus
subroutine, public nnp_env_get(nnp_env, nnp_forces, subsys, atomic_kind_set, particle_set, local_particles, molecule_kind_set, molecule_set, local_molecules, nnp_input, force_env_input, cell, cell_ref, use_ref_cell, nnp_potential_energy, virial)
Returns various attributes of the nnp environment.
subroutine, public nnp_env_release(nnp_env)
Release data structure that holds all the information for neural network potentials.
integer, parameter, public nnp_actfnct_tanh
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.