(git:e753828)
Loading...
Searching...
No Matches
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-2026 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!> \author Dhruv Sharma (ds2173@cam.ac.uk)
12!> \date 2020-10-10
13! **************************************************************************************************
19 USE cell_types, ONLY: cell_release,&
28 USE kinds, ONLY: default_string_length,&
29 dp
42 USE virial_types, ONLY: virial_type
43#include "./base/base_uses.f90"
44
45 IMPLICIT NONE
46
47 PRIVATE
48
49 LOGICAL, PRIVATE, PARAMETER :: debug_this_module = .false.
50 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'nnp_environment_types'
51
52 !> derived data types
53 PUBLIC :: nnp_type
54 PUBLIC :: nnp_arc_type
55 PUBLIC :: nnp_neighbor_type
56 PUBLIC :: nnp_neigh_grp_type
57 PUBLIC :: nnp_symfgrp_type
58 PUBLIC :: nnp_acsf_rad_type
59 PUBLIC :: nnp_acsf_ang_type
62 PUBLIC :: nnp_dgdr_grp_type
65
66 ! Public subroutines ***
67 PUBLIC :: nnp_env_release, &
72
73 INTEGER, PARAMETER, PUBLIC :: &
74 nnp_cut_cos = 1, &
75 nnp_cut_tanh = 2
76
77 INTEGER, PARAMETER, PUBLIC :: &
78 nnp_actfnct_tanh = 1, &
79 nnp_actfnct_gaus = 2, &
80 nnp_actfnct_lin = 3, &
81 nnp_actfnct_cos = 4, &
82 nnp_actfnct_sig = 5, &
84 nnp_actfnct_exp = 7, &
87
88! **************************************************************************************************
89!> \brief Main data type collecting all relevant data for neural network potentials
90!> \author Christoph Schran (christoph.schran@rub.de)
91!> \date 2020-10-10
92! **************************************************************************************************
94 TYPE(nnp_acsf_rad_type), DIMENSION(:), POINTER :: rad => null() ! DIM(n_ele)
95 TYPE(nnp_acsf_ang_type), DIMENSION(:), POINTER :: ang => null() ! DIM(n_ele)
96 INTEGER, DIMENSION(:), ALLOCATABLE :: n_rad ! # radial symfnct for this element
97 INTEGER, DIMENSION(:), ALLOCATABLE :: n_ang ! # angular symfnct for this element
98 INTEGER :: n_ele = -1 ! # elements
99 CHARACTER(len=2), ALLOCATABLE, DIMENSION(:) :: ele ! elements(n_ele)
100 INTEGER, ALLOCATABLE, DIMENSION(:) :: nuc_ele ! elements(n_ele)
101 LOGICAL :: scale_acsf = .false.
102 LOGICAL :: scale_sigma_acsf = .false.
103 LOGICAL :: center_acsf = .false.
104 LOGICAL :: normnodes = .false.
105 INTEGER :: n_radgrp = -1
106 INTEGER :: n_anggrp = -1
107 INTEGER :: cut_type = -1 ! cutofftype
108 REAL(kind=dp) :: eshortmin = -1.0_dp
109 REAL(kind=dp) :: eshortmax = -1.0_dp
110 REAL(kind=dp) :: scmax = -1.0_dp !scale
111 REAL(kind=dp) :: scmin = -1.0_dp !scale
112 REAL(kind=dp) :: max_cut = -1.0_dp !largest cutoff
113 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: atom_energies !DIM(n_ele)
114 TYPE(nnp_arc_type), POINTER, DIMENSION(:) :: arc => null() ! DIM(n_ele)
115 INTEGER :: n_committee = -1
116 INTEGER :: n_hlayer = -1
117 INTEGER :: n_layer = -1
118 INTEGER :: rad_spline_n = 8192 ! knots/radial group (RAD_SPLINE_N)
119 REAL(kind=dp) :: verlet_skin = -1.0_dp ! cell-list skin, bohr (VERLET_SKIN; <0 = auto)
120 INTEGER, ALLOCATABLE, DIMENSION(:) :: n_hnodes
121 INTEGER, ALLOCATABLE, DIMENSION(:) :: actfnct
122 INTEGER :: expol = -1 ! extrapolation counter
123 LOGICAL :: output_expol = .false. ! output extrapolation
124 ! structures for calculation
125 INTEGER :: num_atoms = -1
126 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: atomic_energy
127 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: committee_energy
128 INTEGER, ALLOCATABLE, DIMENSION(:) :: ele_ind, nuc_atoms, sort, sort_inv
129 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: coord
130 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :, :) :: myforce
131 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :, :) :: committee_forces, committee_stress
132 CHARACTER(len=default_string_length), &
133 ALLOCATABLE, DIMENSION(:) :: atoms
134 REAL(kind=dp), DIMENSION(:, :), ALLOCATABLE :: nnp_forces
135 REAL(kind=dp) :: nnp_potential_energy = -1.0_dp
136 TYPE(cp_subsys_type), POINTER :: subsys => null()
137 TYPE(section_vals_type), POINTER :: nnp_input => null()
138 TYPE(section_vals_type), POINTER :: force_env_input => null()
139 TYPE(cell_type), POINTER :: cell => null()
140 TYPE(cell_type), POINTER :: cell_ref => null()
141 LOGICAL :: use_ref_cell = .false.
142 ! bias
143 LOGICAL :: bias = .false.
144 LOGICAL :: bias_align = .false.
145 REAL(kind=dp) :: bias_energy = -1.0_dp
146 REAL(kind=dp) :: bias_kb = -1.0_dp
147 REAL(kind=dp) :: bias_sigma0 = -1.0_dp
148 REAL(kind=dp) :: bias_sigma = -1.0_dp
149 REAL(kind=dp), DIMENSION(:, :), ALLOCATABLE :: bias_forces
150 REAL(kind=dp), DIMENSION(:), ALLOCATABLE :: bias_e_avrg
151 ! Per-nnp persistent neighbour-finder state, owned by nnp_type so committee
152 ! and MIX force_evals carry independent caches whose lifetime tracks
153 ! nnp_env_release. Allocated by nnp_prepare_neighbor_cache, freed in
154 ! nnp_env_release; operated on by nnp_cell_list and nnp_neighbor_interface.
155 TYPE(nnp_cell_list_cache_type), ALLOCATABLE :: cell_list_cache
156 TYPE(nnp_neighbor_interface_state_type), ALLOCATABLE :: neighbor_interface_state
157 END TYPE nnp_type
158
159! **************************************************************************************************
160!> \brief Symmetry functions group type
161!> \param n_symf - # of associated sym fncts
162!> \param symf - indices of associated sym fncts DIM(nsymf)
163!> \param ele - elements indices rad:DIM(2), ang:DIM(3)
164!> \param cutoff - associated cutoff value
165!> \author Christoph Schran (christoph.schran@rub.de)
166!> \date 2020-10-10
167! **************************************************************************************************
169 INTEGER :: n_symf = -1
170 INTEGER, DIMENSION(:), ALLOCATABLE :: symf
171 INTEGER, DIMENSION(:), ALLOCATABLE :: ele_ind
172 CHARACTER(LEN=2), DIMENSION(:), ALLOCATABLE :: ele
173 REAL(kind=dp) :: cutoff = -1.0_dp
174 ! Packed per-member parameters: contiguous arrays sized n_symf so the inner
175 ! SF loop streams memory instead of indexing ang(ind)%{eta,zeta,lam,prefzeta}
176 ! through symf(sf). pack_izeta/pack_use_int_zeta skip NINT in the inner loop.
177 REAL(kind=dp), DIMENSION(:), ALLOCATABLE :: pack_eta
178 REAL(kind=dp), DIMENSION(:), ALLOCATABLE :: pack_zeta
179 REAL(kind=dp), DIMENSION(:), ALLOCATABLE :: pack_lam
180 REAL(kind=dp), DIMENSION(:), ALLOCATABLE :: pack_prefzeta
181 INTEGER, DIMENSION(:), ALLOCATABLE :: pack_izeta
182 LOGICAL, DIMENSION(:), ALLOCATABLE :: pack_use_int_zeta
183 ! Group-shared Hermite cubic spline tables (radial groups only). All SFs in
184 ! a group share grp%cutoff, hence one uniform grid (spline_n nodes, spacing
185 ! spline_dx). y(r) and y'(r) are packed sf-first so nnp_calc_rad streams them
186 ! after computing the interpolation parameters once per call.
187 LOGICAL :: spline_built = .false.
188 INTEGER :: spline_n = 0
189 REAL(kind=dp) :: spline_dx = 1.0_dp
190 REAL(kind=dp) :: spline_dx_inv = 1.0_dp
191 REAL(kind=dp) :: spline_x_max = 0.0_dp
192 REAL(kind=dp), DIMENSION(:, :), ALLOCATABLE :: spline_y ! (n_symf, n_grid)
193 REAL(kind=dp), DIMENSION(:, :), ALLOCATABLE :: spline_dy ! (n_symf, n_grid)
194 END TYPE nnp_symfgrp_type
195
196! **************************************************************************************************
197!> \brief Set of radial symmetry function type
198!> \param y - acsf value - DIM(n_rad)
199!> \param funccut - distance cutoff bohr - DIM(n_rad)
200!> \param eta - eta parameter of radial sym fncts bohr^-2 - DIM(n_rad)
201!> \param rs - r shift parameter of radial sym fncts bohr - DIM(n_rad)
202!> \param loc_min - minimum of the sym fnct DIM(n_rad)
203!> \param loc_max - maximum of the sym fnct DIM(n_rad)
204!> \param loc_av - average of the sym fnct DIM(n_rad)
205!> \param sigma - SD of the sym fnc DIM(n_rad)
206!> \param ele - element associated to the sym fnct DIM(n_rad)
207!> \param nuc_ele - associated atomic number DIM(n_rad)
208!> \author Christoph Schran (christoph.schran@rub.de)
209!> \date 2020-10-10
210! **************************************************************************************************
212 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: y
213 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: funccut
214 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: eta
215 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: rs
216 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: loc_min
217 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: loc_max
218 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: loc_av
219 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: sigma
220 CHARACTER(len=2), ALLOCATABLE, DIMENSION(:) :: ele
221 INTEGER, ALLOCATABLE, DIMENSION(:) :: nuc_ele
222 INTEGER :: n_symfgrp = -1
223 TYPE(nnp_symfgrp_type), DIMENSION(:), ALLOCATABLE :: symfgrp
224 END TYPE nnp_acsf_rad_type
225
226! **************************************************************************************************
227!> \brief Set of angular symmetry function type
228!> \param y - acsf value - DIM(n_ang)
229!> \param funccut - distance cutoff bohr - DIM(n_ang)
230!> \param eta - eta param. of angular sym fncts bohr^-2 - DIM(n_ang)
231!> \param zeta - zeta param. of angular sym fncts DIM(n_ang)
232!> \param lam - lambda param. of angular sym fncts DIM(n_ang)
233!> \param loc_min - minimum of the sym fnct DIM(n_ang)
234!> \param loc_max - maximum of the sym fnct DIM(n_ang)
235!> \param loc_av - average of the sym fnct DIM(n_ang)
236!> \param sigma - SD of the sym fnc DIM(n_ang)
237!> \param ele1,ele2 - elements associated to the sym fnct DIM(n_ang)
238!> \param nuc_ele2, nuc_ele2 - associated atomic numbers DIM(n_ang)
239!> \author Christoph Schran (christoph.schran@rub.de)
240!> \date 2020-10-10
241! **************************************************************************************************
243 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: y
244 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: funccut
245 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: eta
246 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: zeta
247 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: prefzeta
248 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: lam
249 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: loc_min
250 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: loc_max
251 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: loc_av
252 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: sigma
253 CHARACTER(len=2), ALLOCATABLE, DIMENSION(:) :: ele1
254 CHARACTER(len=2), ALLOCATABLE, DIMENSION(:) :: ele2
255 INTEGER, ALLOCATABLE, DIMENSION(:) :: nuc_ele1
256 INTEGER, ALLOCATABLE, DIMENSION(:) :: nuc_ele2
257 INTEGER :: n_symfgrp = -1
258 TYPE(nnp_symfgrp_type), DIMENSION(:), ALLOCATABLE :: symfgrp
259 END TYPE nnp_acsf_ang_type
260
261! **************************************************************************************************
262!> \brief Per-SF-group dense neighbour container. cap is the allocated slab size;
263!> the live count is nnp_neighbor_type%n_rad/n_ang1/n_ang2 for the matching
264!> group. ind(j) is the j-th neighbour's atom index; dist(1:3, j) is its
265!> displacement and dist(4, j) its norm. Sized lazily by nnp_neigh_grp_grow.
266! **************************************************************************************************
268 INTEGER :: cap = 0
269 INTEGER, ALLOCATABLE, DIMENSION(:) :: ind ! (cap)
270 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: dist ! (4, cap)
271 END TYPE nnp_neigh_grp_type
272
273! **************************************************************************************************
274!> \brief Contains neighbors list of an atom (per-group dense layout).
275!> \param n_rad/n_ang1/n_ang2 - live neighbor counts per symfgrp
276!> \param rad/ang1/ang2 - per-group dense (ind, dist) containers
277!> \author Christoph Schran (christoph.schran@rub.de)
278!> \date 2020-10-10
279! **************************************************************************************************
281 INTEGER, DIMENSION(3) :: pbc_copies = -1
282 INTEGER, DIMENSION(:), ALLOCATABLE :: n_rad
283 INTEGER, DIMENSION(:), ALLOCATABLE :: n_ang1
284 INTEGER, DIMENSION(:), ALLOCATABLE :: n_ang2
285 TYPE(nnp_neigh_grp_type), ALLOCATABLE, DIMENSION(:) :: rad
286 TYPE(nnp_neigh_grp_type), ALLOCATABLE, DIMENSION(:) :: ang1
287 TYPE(nnp_neigh_grp_type), ALLOCATABLE, DIMENSION(:) :: ang2
288 END TYPE nnp_neighbor_type
289
290! **************************************************************************************************
291!> \brief Linked-cell + Verlet-skin cache for the NNP descriptor neighbour walk.
292!> Persisted across MD steps so the image pool, bin geometry, and
293!> reference positions survive between force evaluations and the
294!> head/next chain can be reused as long as no atom has drifted more
295!> than skin/2. Operated on by nnp_cell_list.F.
296!> \author Dhruv Sharma (ds2173@cam.ac.uk)
297! **************************************************************************************************
299 LOGICAL :: initialized = .false.
300 INTEGER :: num_atoms = -1
301 INTEGER :: n_images = 0
302 INTEGER :: n_cells = 1
303 INTEGER, DIMENSION(3) :: exact_pbc_copies = 0
304 INTEGER, DIMENSION(3) :: list_pbc_copies = 0
305 INTEGER, DIMENSION(3) :: image_copies = 0
306 INTEGER, DIMENSION(3) :: nbin = 1
307 INTEGER, DIMENSION(3) :: bin_span = 0
308 INTEGER, DIMENSION(3) :: perd = 0
309 LOGICAL :: orthorhombic = .false.
310 REAL(kind=dp) :: exact_cutoff = -1.0_dp
311 REAL(kind=dp) :: list_cutoff = -1.0_dp
312 REAL(kind=dp) :: verlet_skin = 0.0_dp
313 REAL(kind=dp), DIMENSION(3) :: lower = 0.0_dp
314 REAL(kind=dp), DIMENSION(3) :: upper = 0.0_dp
315 REAL(kind=dp), DIMENSION(3) :: bin_width = 1.0_dp
316 REAL(kind=dp), DIMENSION(3, 3) :: hmat = 0.0_dp
317 REAL(kind=dp), DIMENSION(3, 3) :: h_inv = 0.0_dp
318 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: coord_primary
319 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: coord_scaled
320 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: ref_coord_primary
321 INTEGER, ALLOCATABLE, DIMENSION(:) :: image_atom
322 INTEGER, ALLOCATABLE, DIMENSION(:) :: head
323 INTEGER, ALLOCATABLE, DIMENSION(:) :: next
324 INTEGER, ALLOCATABLE, DIMENSION(:, :) :: image_shift
325 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: image_translation
327
328! **************************************************************************************************
329!> \brief Species-pair routing table. For one (central element, neighbour element)
330!> pair, lists which radial / angular symmetry-function groups need that
331!> neighbour and the worst-case relevant cutoff.
332!> \author Dhruv Sharma (ds2173@cam.ac.uk)
333! **************************************************************************************************
335 INTEGER :: n_rad = 0
336 INTEGER :: n_ang1 = 0
337 INTEGER :: n_ang2 = 0
338 REAL(kind=dp) :: max_relevant_cutoff = 0.0_dp
339 INTEGER, ALLOCATABLE, DIMENSION(:) :: rad_groups
340 INTEGER, ALLOCATABLE, DIMENSION(:) :: ang1_groups
341 INTEGER, ALLOCATABLE, DIMENSION(:) :: ang2_groups
343
344! **************************************************************************************************
345!> \brief Per-(element, SF-group) dG_k/dr buffer, sized to the group's n_symf (no
346!> max_*_symf padding) and the observed peak neighbour count for the group.
347!> Grown lazily (1.5x) so it settles at the true peak.
348!> \author Dhruv Sharma (ds2173@cam.ac.uk)
349! **************************************************************************************************
351 INTEGER :: cap = 0
352 INTEGER :: n_symf = 0
353 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :, :) :: data ! (3, n_symf, cap)
354 END TYPE nnp_dgdr_grp_type
355
356! **************************************************************************************************
357!> \brief Reusable per-element scratch / persistent caches for the ACSF
358!> descriptor and force assembly. See nnp_neighbor_interface for the
359!> routines that populate and grow these buffers.
360!> \author Dhruv Sharma (ds2173@cam.ac.uk)
361! **************************************************************************************************
363 INTEGER :: max_rad_symf = 0
364 INTEGER :: max_ang_symf = 0
365 INTEGER :: n_input_nodes = 0
366 ! High-water mark of the per-element angular-cache slab, tracked so the 1D
367 ! cutoff caches settle at the true per-element peak.
368 INTEGER :: cache_cap = 0
369 ! There is a bug with some older compilers preventing requiring an explicit
370 ! initialization of allocatable components (see mp2_types.F).
371#if defined(FTN_NO_DEFAULT_INIT)
373 pbc_copies=-1, n_rad=null(), &
374 n_ang1=null(), n_ang2=null(), &
375 rad=null(), ang1=null(), ang2=null())
376#else
377 TYPE(nnp_neighbor_type) :: neighbor = nnp_neighbor_type()
378#endif
379 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: radial_sym
380 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: radial_force
381 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: angular_sym
382 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :, :) :: angular_force
383 ! Per-element persistent cutoff caches reused across this element's central
384 ! atoms. Sized lazily by nnp_workspace_grow_caches to MAX(n_ang1)/MAX(n_ang2).
385 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: fc_cache1
386 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: dfc_cache1
387 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: fc_cache2
388 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: dfc_cache2
389 ! Per-neighbour dG_k/dr storage, replacing the global
390 ! dsymdxyz(3, n_input_nodes, num_atoms) slab. The per-group buffers are
391 ! dense in (3, n_symf_for_group, n_neighbors_in_group), which shrinks the
392 ! working set and keeps each group walk a contiguous stride.
393 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: self_dgdr
394 TYPE(nnp_dgdr_grp_type), ALLOCATABLE, DIMENSION(:) :: dgdr_rad
395 TYPE(nnp_dgdr_grp_type), ALLOCATABLE, DIMENSION(:) :: dgdr_ang_jj
396 TYPE(nnp_dgdr_grp_type), ALLOCATABLE, DIMENSION(:) :: dgdr_ang_kk
398
399! **************************************************************************************************
400!> \brief Persistent neighbour-interface state. Owned by nnp_type so that the
401!> per-nnp pair-routing tables and per-element workspaces survive
402!> across MD steps without leaking between independent &NNP
403!> force_evals. Operated on by nnp_neighbor_interface.F.
404!> \author Dhruv Sharma (ds2173@cam.ac.uk)
405! **************************************************************************************************
407 LOGICAL :: initialized = .false.
408 INTEGER :: n_ele = 0
409 INTEGER, ALLOCATABLE, DIMENSION(:) :: n_rad
410 INTEGER, ALLOCATABLE, DIMENSION(:) :: n_ang
411 INTEGER, ALLOCATABLE, DIMENSION(:) :: n_radgrp
412 INTEGER, ALLOCATABLE, DIMENSION(:) :: n_anggrp
413 TYPE(nnp_neighbor_pair_map_type), ALLOCATABLE, &
414 DIMENSION(:, :) :: pair_map
415 ! (element, thread): one workspace column per OpenMP thread
416 TYPE(nnp_neighbor_workspace_type), ALLOCATABLE, &
417 DIMENSION(:, :) :: workspace
419
420! **************************************************************************************************
421!> \brief Data type for artificial neural networks
422!> \author Christoph Schran (christoph.schran@rub.de)
423!> \date 2020-10-10
424! **************************************************************************************************
426 TYPE(nnp_arc_layer_type), POINTER, DIMENSION(:) :: layer => null() ! DIM(n_layer)
427 INTEGER, ALLOCATABLE, DIMENSION(:) :: n_nodes
428 END TYPE nnp_arc_type
429
430! **************************************************************************************************
431!> \brief Data type for individual layer
432!> \author Christoph Schran (christoph.schran@rub.de)
433!> \date 2020-10-10
434! **************************************************************************************************
435 TYPE nnp_arc_layer_type
436 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :, :) :: weights ! node weights
437 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: bweights ! bias weights
438 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: node ! DIM(n_nodes)
439 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: node_grad ! DIM(n_nodes)
440 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: tmp_der ! DIM(n_sym,n_nodes)
441 END TYPE nnp_arc_layer_type
442
443CONTAINS
444
445! **************************************************************************************************
446!> \brief Release data structure that holds all the information for neural
447!> network potentials
448!> \param nnp_env ...
449!> \date 2020-10-10
450!> \author Christoph Schran (christoph.schran@rub.de)
451! **************************************************************************************************
452 SUBROUTINE nnp_env_release(nnp_env)
453 TYPE(nnp_type), INTENT(INOUT) :: nnp_env
454
455 INTEGER :: i, j
456
457 IF (ASSOCIATED(nnp_env%rad)) THEN
458 DO i = 1, nnp_env%n_ele
459 DO j = 1, nnp_env%rad(i)%n_symfgrp
460 IF (ALLOCATED(nnp_env%rad(i)%symfgrp(j)%symf)) THEN
461 DEALLOCATE (nnp_env%rad(i)%symfgrp(j)%symf, &
462 nnp_env%rad(i)%symfgrp(j)%ele, &
463 nnp_env%rad(i)%symfgrp(j)%ele_ind)
464 END IF
465 IF (ALLOCATED(nnp_env%rad(i)%symfgrp(j)%spline_y)) THEN
466 DEALLOCATE (nnp_env%rad(i)%symfgrp(j)%spline_y)
467 END IF
468 IF (ALLOCATED(nnp_env%rad(i)%symfgrp(j)%spline_dy)) THEN
469 DEALLOCATE (nnp_env%rad(i)%symfgrp(j)%spline_dy)
470 END IF
471 nnp_env%rad(i)%symfgrp(j)%spline_built = .false.
472 END DO
473 DEALLOCATE (nnp_env%rad(i)%y, &
474 nnp_env%rad(i)%funccut, &
475 nnp_env%rad(i)%eta, &
476 nnp_env%rad(i)%rs, &
477 nnp_env%rad(i)%loc_min, &
478 nnp_env%rad(i)%loc_max, &
479 nnp_env%rad(i)%loc_av, &
480 nnp_env%rad(i)%sigma, &
481 nnp_env%rad(i)%ele, &
482 nnp_env%rad(i)%nuc_ele, &
483 nnp_env%rad(i)%symfgrp)
484 END DO
485 DEALLOCATE (nnp_env%rad)
486 END IF
487
488 IF (ASSOCIATED(nnp_env%ang)) THEN
489 DO i = 1, nnp_env%n_ele
490 DO j = 1, nnp_env%ang(i)%n_symfgrp
491 IF (ALLOCATED(nnp_env%ang(i)%symfgrp(j)%symf)) THEN
492 DEALLOCATE (nnp_env%ang(i)%symfgrp(j)%symf, &
493 nnp_env%ang(i)%symfgrp(j)%ele, &
494 nnp_env%ang(i)%symfgrp(j)%ele_ind)
495 END IF
496 IF (ALLOCATED(nnp_env%ang(i)%symfgrp(j)%pack_eta)) THEN
497 DEALLOCATE (nnp_env%ang(i)%symfgrp(j)%pack_eta)
498 END IF
499 IF (ALLOCATED(nnp_env%ang(i)%symfgrp(j)%pack_zeta)) THEN
500 DEALLOCATE (nnp_env%ang(i)%symfgrp(j)%pack_zeta)
501 END IF
502 IF (ALLOCATED(nnp_env%ang(i)%symfgrp(j)%pack_lam)) THEN
503 DEALLOCATE (nnp_env%ang(i)%symfgrp(j)%pack_lam)
504 END IF
505 IF (ALLOCATED(nnp_env%ang(i)%symfgrp(j)%pack_prefzeta)) THEN
506 DEALLOCATE (nnp_env%ang(i)%symfgrp(j)%pack_prefzeta)
507 END IF
508 IF (ALLOCATED(nnp_env%ang(i)%symfgrp(j)%pack_izeta)) THEN
509 DEALLOCATE (nnp_env%ang(i)%symfgrp(j)%pack_izeta)
510 END IF
511 IF (ALLOCATED(nnp_env%ang(i)%symfgrp(j)%pack_use_int_zeta)) THEN
512 DEALLOCATE (nnp_env%ang(i)%symfgrp(j)%pack_use_int_zeta)
513 END IF
514 END DO
515 DEALLOCATE (nnp_env%ang(i)%y, &
516 nnp_env%ang(i)%funccut, &
517 nnp_env%ang(i)%eta, &
518 nnp_env%ang(i)%zeta, &
519 nnp_env%ang(i)%prefzeta, &
520 nnp_env%ang(i)%lam, &
521 nnp_env%ang(i)%loc_min, &
522 nnp_env%ang(i)%loc_max, &
523 nnp_env%ang(i)%loc_av, &
524 nnp_env%ang(i)%sigma, &
525 nnp_env%ang(i)%ele1, &
526 nnp_env%ang(i)%ele2, &
527 nnp_env%ang(i)%nuc_ele1, &
528 nnp_env%ang(i)%nuc_ele2, &
529 nnp_env%ang(i)%symfgrp)
530 END DO
531 DEALLOCATE (nnp_env%ang)
532 END IF
533
534 IF (ASSOCIATED(nnp_env%arc)) THEN
535 DO i = 1, nnp_env%n_ele
536 IF (ASSOCIATED(nnp_env%arc(i)%layer)) THEN
537 DO j = 1, nnp_env%n_layer
538 IF (ALLOCATED(nnp_env%arc(i)%layer(j)%node)) THEN
539 DEALLOCATE (nnp_env%arc(i)%layer(j)%node)
540 END IF
541 IF (ALLOCATED(nnp_env%arc(i)%layer(j)%node_grad)) THEN
542 DEALLOCATE (nnp_env%arc(i)%layer(j)%node_grad)
543 END IF
544 IF (ALLOCATED(nnp_env%arc(i)%layer(j)%weights)) THEN
545 DEALLOCATE (nnp_env%arc(i)%layer(j)%weights)
546 END IF
547 IF (ALLOCATED(nnp_env%arc(i)%layer(j)%bweights)) THEN
548 DEALLOCATE (nnp_env%arc(i)%layer(j)%bweights)
549 END IF
550 IF (ALLOCATED(nnp_env%arc(i)%layer(j)%tmp_der)) THEN
551 DEALLOCATE (nnp_env%arc(i)%layer(j)%tmp_der)
552 END IF
553 END DO
554 DEALLOCATE (nnp_env%arc(i)%layer, &
555 nnp_env%arc(i)%n_nodes)
556 END IF
557 END DO
558 DEALLOCATE (nnp_env%arc)
559 END IF
560
561 IF (ALLOCATED(nnp_env%ele)) DEALLOCATE (nnp_env%ele)
562 IF (ALLOCATED(nnp_env%nuc_ele)) DEALLOCATE (nnp_env%nuc_ele)
563 IF (ALLOCATED(nnp_env%n_hnodes)) DEALLOCATE (nnp_env%n_hnodes)
564 IF (ALLOCATED(nnp_env%actfnct)) DEALLOCATE (nnp_env%actfnct)
565 IF (ALLOCATED(nnp_env%nnp_forces)) DEALLOCATE (nnp_env%nnp_forces)
566 IF (ALLOCATED(nnp_env%atomic_energy)) DEALLOCATE (nnp_env%atomic_energy)
567 IF (ALLOCATED(nnp_env%committee_energy)) DEALLOCATE (nnp_env%committee_energy)
568 IF (ALLOCATED(nnp_env%ele_ind)) DEALLOCATE (nnp_env%ele_ind)
569 IF (ALLOCATED(nnp_env%nuc_atoms)) DEALLOCATE (nnp_env%nuc_atoms)
570 IF (ALLOCATED(nnp_env%sort)) DEALLOCATE (nnp_env%sort)
571 IF (ALLOCATED(nnp_env%sort_inv)) DEALLOCATE (nnp_env%sort_inv)
572 IF (ALLOCATED(nnp_env%coord)) DEALLOCATE (nnp_env%coord)
573 IF (ALLOCATED(nnp_env%myforce)) DEALLOCATE (nnp_env%myforce)
574 IF (ALLOCATED(nnp_env%committee_forces)) DEALLOCATE (nnp_env%committee_forces)
575 IF (ALLOCATED(nnp_env%committee_stress)) DEALLOCATE (nnp_env%committee_stress)
576 IF (ALLOCATED(nnp_env%atoms)) DEALLOCATE (nnp_env%atoms)
577
578 IF (ALLOCATED(nnp_env%cell_list_cache)) THEN
579 CALL nnp_cell_list_cache_release(nnp_env%cell_list_cache)
580 DEALLOCATE (nnp_env%cell_list_cache)
581 END IF
582 IF (ALLOCATED(nnp_env%neighbor_interface_state)) THEN
583 CALL nnp_neighbor_interface_state_release(nnp_env%neighbor_interface_state)
584 DEALLOCATE (nnp_env%neighbor_interface_state)
585 END IF
586
587 IF (ASSOCIATED(nnp_env%subsys)) THEN
588 CALL cp_subsys_release(nnp_env%subsys)
589 END IF
590 IF (ASSOCIATED(nnp_env%cell)) THEN
591 CALL cell_release(nnp_env%cell)
592 END IF
593 IF (ASSOCIATED(nnp_env%cell_ref)) THEN
594 CALL cell_release(nnp_env%cell_ref)
595 END IF
596
597 END SUBROUTINE nnp_env_release
598
599! **************************************************************************************************
600!> \brief Free the allocatable parts of a cell-list cache. Co-located with the
601!> type definition to avoid creating a USE-cycle through nnp_cell_list.
602!> \param cache cell-list cache whose allocatable image-pool and bin arrays are freed
603!> \author Dhruv Sharma (ds2173@cam.ac.uk)
604! **************************************************************************************************
606 TYPE(nnp_cell_list_cache_type), INTENT(INOUT) :: cache
607
608 IF (ALLOCATED(cache%coord_primary)) DEALLOCATE (cache%coord_primary)
609 IF (ALLOCATED(cache%coord_scaled)) DEALLOCATE (cache%coord_scaled)
610 IF (ALLOCATED(cache%ref_coord_primary)) DEALLOCATE (cache%ref_coord_primary)
611 IF (ALLOCATED(cache%image_atom)) DEALLOCATE (cache%image_atom)
612 IF (ALLOCATED(cache%head)) DEALLOCATE (cache%head)
613 IF (ALLOCATED(cache%next)) DEALLOCATE (cache%next)
614 IF (ALLOCATED(cache%image_shift)) DEALLOCATE (cache%image_shift)
615 IF (ALLOCATED(cache%image_translation)) DEALLOCATE (cache%image_translation)
616 cache%initialized = .false.
617 cache%num_atoms = -1
618 cache%n_images = 0
619 END SUBROUTINE nnp_cell_list_cache_release
620
621! **************************************************************************************************
622!> \brief Free the allocatable parts of a neighbour-interface state. Co-located
623!> with the type definition to avoid creating a USE-cycle through
624!> nnp_neighbor_interface.
625!> \param state neighbour-interface state whose pair maps and per-element workspaces are freed
626!> \author Dhruv Sharma (ds2173@cam.ac.uk)
627! **************************************************************************************************
630 INTENT(INOUT) :: state
631
632 INTEGER :: i, j
633
634 IF (ALLOCATED(state%pair_map)) THEN
635 DO i = 1, SIZE(state%pair_map, 1)
636 DO j = 1, SIZE(state%pair_map, 2)
637 IF (ALLOCATED(state%pair_map(i, j)%rad_groups)) DEALLOCATE (state%pair_map(i, j)%rad_groups)
638 IF (ALLOCATED(state%pair_map(i, j)%ang1_groups)) DEALLOCATE (state%pair_map(i, j)%ang1_groups)
639 IF (ALLOCATED(state%pair_map(i, j)%ang2_groups)) DEALLOCATE (state%pair_map(i, j)%ang2_groups)
640 END DO
641 END DO
642 DEALLOCATE (state%pair_map)
643 END IF
644
645 IF (ALLOCATED(state%workspace)) THEN
646 DO j = 1, SIZE(state%workspace, 2)
647 DO i = 1, SIZE(state%workspace, 1)
648 CALL nnp_workspace_release(state%workspace(i, j))
649 END DO
650 END DO
651 DEALLOCATE (state%workspace)
652 END IF
653
654 IF (ALLOCATED(state%n_rad)) DEALLOCATE (state%n_rad)
655 IF (ALLOCATED(state%n_ang)) DEALLOCATE (state%n_ang)
656 IF (ALLOCATED(state%n_radgrp)) DEALLOCATE (state%n_radgrp)
657 IF (ALLOCATED(state%n_anggrp)) DEALLOCATE (state%n_anggrp)
658
659 state%initialized = .false.
660 state%n_ele = 0
662
663! **************************************************************************************************
664!> \brief Free the allocatable parts of one per-element workspace.
665!> \param workspace per-element workspace whose scratch, cutoff caches and dGdr buffers are freed
666!> \author Dhruv Sharma (ds2173@cam.ac.uk)
667! **************************************************************************************************
668 SUBROUTINE nnp_workspace_release(workspace)
669 TYPE(nnp_neighbor_workspace_type), INTENT(INOUT) :: workspace
670
671 INTEGER :: s
672
673 IF (ALLOCATED(workspace%neighbor%rad)) THEN
674 DO s = 1, SIZE(workspace%neighbor%rad)
675 IF (ALLOCATED(workspace%neighbor%rad(s)%ind)) DEALLOCATE (workspace%neighbor%rad(s)%ind)
676 IF (ALLOCATED(workspace%neighbor%rad(s)%dist)) DEALLOCATE (workspace%neighbor%rad(s)%dist)
677 END DO
678 DEALLOCATE (workspace%neighbor%rad)
679 END IF
680 IF (ALLOCATED(workspace%neighbor%ang1)) THEN
681 DO s = 1, SIZE(workspace%neighbor%ang1)
682 IF (ALLOCATED(workspace%neighbor%ang1(s)%ind)) DEALLOCATE (workspace%neighbor%ang1(s)%ind)
683 IF (ALLOCATED(workspace%neighbor%ang1(s)%dist)) DEALLOCATE (workspace%neighbor%ang1(s)%dist)
684 END DO
685 DEALLOCATE (workspace%neighbor%ang1)
686 END IF
687 IF (ALLOCATED(workspace%neighbor%ang2)) THEN
688 DO s = 1, SIZE(workspace%neighbor%ang2)
689 IF (ALLOCATED(workspace%neighbor%ang2(s)%ind)) DEALLOCATE (workspace%neighbor%ang2(s)%ind)
690 IF (ALLOCATED(workspace%neighbor%ang2(s)%dist)) DEALLOCATE (workspace%neighbor%ang2(s)%dist)
691 END DO
692 DEALLOCATE (workspace%neighbor%ang2)
693 END IF
694 IF (ALLOCATED(workspace%neighbor%n_rad)) DEALLOCATE (workspace%neighbor%n_rad)
695 IF (ALLOCATED(workspace%neighbor%n_ang1)) DEALLOCATE (workspace%neighbor%n_ang1)
696 IF (ALLOCATED(workspace%neighbor%n_ang2)) DEALLOCATE (workspace%neighbor%n_ang2)
697 workspace%neighbor%pbc_copies = -1
698
699 IF (ALLOCATED(workspace%radial_sym)) DEALLOCATE (workspace%radial_sym)
700 IF (ALLOCATED(workspace%radial_force)) DEALLOCATE (workspace%radial_force)
701 IF (ALLOCATED(workspace%angular_sym)) DEALLOCATE (workspace%angular_sym)
702 IF (ALLOCATED(workspace%angular_force)) DEALLOCATE (workspace%angular_force)
703 IF (ALLOCATED(workspace%fc_cache1)) DEALLOCATE (workspace%fc_cache1)
704 IF (ALLOCATED(workspace%dfc_cache1)) DEALLOCATE (workspace%dfc_cache1)
705 IF (ALLOCATED(workspace%fc_cache2)) DEALLOCATE (workspace%fc_cache2)
706 IF (ALLOCATED(workspace%dfc_cache2)) DEALLOCATE (workspace%dfc_cache2)
707 IF (ALLOCATED(workspace%self_dGdr)) DEALLOCATE (workspace%self_dGdr)
708
709 IF (ALLOCATED(workspace%dGdr_rad)) THEN
710 DO s = 1, SIZE(workspace%dGdr_rad)
711 IF (ALLOCATED(workspace%dGdr_rad(s)%data)) DEALLOCATE (workspace%dGdr_rad(s)%data)
712 END DO
713 DEALLOCATE (workspace%dGdr_rad)
714 END IF
715 IF (ALLOCATED(workspace%dGdr_ang_jj)) THEN
716 DO s = 1, SIZE(workspace%dGdr_ang_jj)
717 IF (ALLOCATED(workspace%dGdr_ang_jj(s)%data)) DEALLOCATE (workspace%dGdr_ang_jj(s)%data)
718 END DO
719 DEALLOCATE (workspace%dGdr_ang_jj)
720 END IF
721 IF (ALLOCATED(workspace%dGdr_ang_kk)) THEN
722 DO s = 1, SIZE(workspace%dGdr_ang_kk)
723 IF (ALLOCATED(workspace%dGdr_ang_kk(s)%data)) DEALLOCATE (workspace%dGdr_ang_kk(s)%data)
724 END DO
725 DEALLOCATE (workspace%dGdr_ang_kk)
726 END IF
727
728 workspace%max_rad_symf = 0
729 workspace%max_ang_symf = 0
730 workspace%n_input_nodes = 0
731 workspace%cache_cap = 0
732 END SUBROUTINE nnp_workspace_release
733
734! **************************************************************************************************
735!> \brief Returns various attributes of the nnp environment
736!> \param nnp_env ...
737!> \param nnp_forces ...
738!> \param subsys the particles, molecules,... of this environment
739!> \param atomic_kind_set The set of all atomic kinds involved
740!> \param particle_set The set of all particles
741!> \param local_particles All particles on this particular node
742!> \param molecule_kind_set The set of all different molecule kinds involved
743!> \param molecule_set The set of all molecules
744!> \param local_molecules All molecules on this particular node
745!> \param nnp_input ...
746!> \param force_env_input Pointer to the force_env input section
747!> \param cell The simulation cell
748!> \param cell_ref The reference simulation cell
749!> \param use_ref_cell Logical which indicates if reference
750!> simulation cell is used
751!> \param nnp_potential_energy ...
752!> \param virial Dummy virial pointer
753!> \date 2020-10-10
754!> \author Christoph Schran (christoph.schran@rub.de)
755!> \note
756!> For possible missing arguments see the attributes of
757!> nnp_type
758! **************************************************************************************************
759 SUBROUTINE nnp_env_get(nnp_env, nnp_forces, subsys, &
760 atomic_kind_set, particle_set, local_particles, &
761 molecule_kind_set, molecule_set, local_molecules, &
762 nnp_input, force_env_input, cell, cell_ref, &
763 use_ref_cell, nnp_potential_energy, virial)
764
765 TYPE(nnp_type), INTENT(IN) :: nnp_env
766 REAL(kind=dp), DIMENSION(:, :), OPTIONAL, POINTER :: nnp_forces
767 TYPE(cp_subsys_type), OPTIONAL, POINTER :: subsys
768 TYPE(atomic_kind_type), DIMENSION(:), OPTIONAL, &
769 POINTER :: atomic_kind_set
770 TYPE(particle_type), DIMENSION(:), OPTIONAL, &
771 POINTER :: particle_set
772 TYPE(distribution_1d_type), OPTIONAL, POINTER :: local_particles
773 TYPE(molecule_kind_type), DIMENSION(:), OPTIONAL, &
774 POINTER :: molecule_kind_set
775 TYPE(molecule_type), DIMENSION(:), OPTIONAL, &
776 POINTER :: molecule_set
777 TYPE(distribution_1d_type), OPTIONAL, POINTER :: local_molecules
778 TYPE(section_vals_type), OPTIONAL, POINTER :: nnp_input, force_env_input
779 TYPE(cell_type), OPTIONAL, POINTER :: cell, cell_ref
780 LOGICAL, INTENT(OUT), OPTIONAL :: use_ref_cell
781 REAL(kind=dp), INTENT(OUT), OPTIONAL :: nnp_potential_energy
782 TYPE(virial_type), OPTIONAL, POINTER :: virial
783
784 TYPE(atomic_kind_list_type), POINTER :: atomic_kinds
785 TYPE(molecule_kind_list_type), POINTER :: molecule_kinds
786 TYPE(molecule_list_type), POINTER :: molecules
787 TYPE(particle_list_type), POINTER :: particles
788
789 NULLIFY (atomic_kinds, particles, molecules, molecule_kinds)
790
791 IF (PRESENT(nnp_potential_energy)) THEN
792 nnp_potential_energy = nnp_env%nnp_potential_energy
793 END IF
794 IF (PRESENT(nnp_forces)) nnp_forces = nnp_env%nnp_forces
795
796 ! note cell will be overwritten if subsys is associated
797 ! helium_env uses nnp without subsys
798 IF (PRESENT(cell)) cell => nnp_env%cell
799
800 IF (PRESENT(subsys)) subsys => nnp_env%subsys
801 IF (ASSOCIATED(nnp_env%subsys)) THEN
802 CALL cp_subsys_get(nnp_env%subsys, &
803 atomic_kinds=atomic_kinds, &
804 particles=particles, &
805 molecule_kinds=molecule_kinds, &
806 molecules=molecules, &
807 local_molecules=local_molecules, &
808 local_particles=local_particles, &
809 virial=virial, &
810 cell=cell)
811 END IF
812 IF (PRESENT(atomic_kind_set)) atomic_kind_set => atomic_kinds%els
813 IF (PRESENT(particle_set)) particle_set => particles%els
814 IF (PRESENT(molecule_kind_set)) molecule_kind_set => molecule_kinds%els
815 IF (PRESENT(molecule_set)) molecule_set => molecules%els
816
817 IF (PRESENT(nnp_input)) nnp_input => nnp_env%nnp_input
818 IF (PRESENT(force_env_input)) force_env_input => nnp_env%force_env_input
819 IF (PRESENT(cell_ref)) cell_ref => nnp_env%cell_ref
820 IF (PRESENT(use_ref_cell)) use_ref_cell = nnp_env%use_ref_cell
821
822 END SUBROUTINE nnp_env_get
823
824! **************************************************************************************************
825!> \brief Sets various attributes of the nnp environment
826!> \param nnp_env ...
827!> \param nnp_forces ...
828!> \param subsys the particles, molecules,... of this environment
829!> \param atomic_kind_set The set of all atomic kinds involved
830!> \param particle_set The set of all particles
831!> \param local_particles All particles on this particular node
832!> \param molecule_kind_set The set of all different molecule kinds involved
833!> \param molecule_set The set of all molecules
834!> \param local_molecules All molecules on this particular node
835!> \param nnp_input ...
836!> \param force_env_input Pointer to the force_env input section
837!> \param cell ...
838!> \param cell_ref The reference simulation cell
839!> \param use_ref_cell Logical which indicates if reference
840!> simulation cell is used
841!> \param nnp_potential_energy ...
842!> \date 2020-10-10
843!> \author Christoph Schran (christoph.schran@rub.de)
844!> \note
845!> For possible missing arguments see the attributes of nnp_type
846! **************************************************************************************************
847 SUBROUTINE nnp_env_set(nnp_env, nnp_forces, subsys, &
848 atomic_kind_set, particle_set, local_particles, &
849 molecule_kind_set, molecule_set, local_molecules, &
850 nnp_input, force_env_input, cell, cell_ref, &
851 use_ref_cell, nnp_potential_energy)
852
853 TYPE(nnp_type), INTENT(INOUT) :: nnp_env
854 REAL(kind=dp), DIMENSION(:, :), OPTIONAL, POINTER :: nnp_forces
855 TYPE(cp_subsys_type), OPTIONAL, POINTER :: subsys
856 TYPE(atomic_kind_type), DIMENSION(:), OPTIONAL, &
857 POINTER :: atomic_kind_set
858 TYPE(particle_type), DIMENSION(:), OPTIONAL, &
859 POINTER :: particle_set
860 TYPE(distribution_1d_type), OPTIONAL, POINTER :: local_particles
861 TYPE(molecule_kind_type), DIMENSION(:), OPTIONAL, &
862 POINTER :: molecule_kind_set
863 TYPE(molecule_type), DIMENSION(:), OPTIONAL, &
864 POINTER :: molecule_set
865 TYPE(distribution_1d_type), OPTIONAL, POINTER :: local_molecules
866 TYPE(section_vals_type), OPTIONAL, POINTER :: nnp_input, force_env_input
867 TYPE(cell_type), OPTIONAL, POINTER :: cell, cell_ref
868 LOGICAL, INTENT(IN), OPTIONAL :: use_ref_cell
869 REAL(kind=dp), INTENT(IN), OPTIONAL :: nnp_potential_energy
870
871 TYPE(atomic_kind_list_type), POINTER :: atomic_kinds
872 TYPE(molecule_kind_list_type), POINTER :: molecule_kinds
873 TYPE(molecule_list_type), POINTER :: molecules
874 TYPE(particle_list_type), POINTER :: particles
875
876 IF (PRESENT(nnp_potential_energy)) THEN
877 nnp_env%nnp_potential_energy = nnp_potential_energy
878 END IF
879 IF (PRESENT(nnp_forces)) nnp_env%nnp_forces(:, :) = nnp_forces
880
881 IF (PRESENT(subsys)) THEN
882 IF (ASSOCIATED(nnp_env%subsys)) THEN
883 IF (.NOT. ASSOCIATED(nnp_env%subsys, subsys)) THEN
884 CALL cp_subsys_release(nnp_env%subsys)
885 END IF
886 END IF
887 nnp_env%subsys => subsys
888 END IF
889 IF (PRESENT(cell)) THEN
890 IF (ASSOCIATED(cell)) THEN
891 CALL cell_retain(cell)
892 CALL cell_release(nnp_env%cell)
893 nnp_env%cell => cell
894 END IF
895 IF (ASSOCIATED(nnp_env%subsys)) THEN
896 CALL cp_subsys_set(nnp_env%subsys, cell=cell)
897 END IF
898 END IF
899 IF (PRESENT(atomic_kind_set)) THEN
900 CALL atomic_kind_list_create(atomic_kinds, els_ptr=atomic_kind_set)
901 CALL cp_subsys_set(nnp_env%subsys, atomic_kinds=atomic_kinds)
902 CALL atomic_kind_list_release(atomic_kinds)
903 END IF
904 IF (PRESENT(particle_set)) THEN
905 CALL particle_list_create(particles, els_ptr=particle_set)
906 CALL cp_subsys_set(nnp_env%subsys, particles=particles)
907 CALL particle_list_release(particles)
908 END IF
909 IF (PRESENT(molecule_kind_set)) THEN
910 CALL molecule_kind_list_create(molecule_kinds, els_ptr=molecule_kind_set)
911 CALL cp_subsys_set(nnp_env%subsys, molecule_kinds=molecule_kinds)
912 CALL molecule_kind_list_release(molecule_kinds)
913 END IF
914 IF (PRESENT(molecule_set)) THEN
915 CALL molecule_list_create(molecules, els_ptr=molecule_set)
916 CALL cp_subsys_set(nnp_env%subsys, molecules=molecules)
917 CALL molecule_list_release(molecules)
918 END IF
919 IF (PRESENT(local_particles)) THEN
920 CALL cp_subsys_set(nnp_env%subsys, local_particles=local_particles)
921 END IF
922 IF (PRESENT(local_molecules)) THEN
923 CALL cp_subsys_set(nnp_env%subsys, local_molecules=local_molecules)
924 END IF
925
926 IF (PRESENT(nnp_input)) nnp_env%nnp_input => nnp_input
927 IF (PRESENT(force_env_input)) THEN
928 nnp_env%force_env_input => force_env_input
929 END IF
930 IF (PRESENT(cell_ref)) THEN
931 CALL cell_retain(cell_ref)
932 CALL cell_release(nnp_env%cell_ref)
933 nnp_env%cell_ref => cell_ref
934 END IF
935 IF (PRESENT(use_ref_cell)) nnp_env%use_ref_cell = use_ref_cell
936 END SUBROUTINE nnp_env_set
937
938END 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:668
subroutine, public cell_retain(cell)
retains the given cell (see doc/ReferenceCounting.html)
Definition cell_types.F:651
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...
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
subroutine, public nnp_cell_list_cache_release(cache)
Free the allocatable parts of a cell-list cache. Co-located with the type definition to avoid creatin...
integer, parameter, public nnp_actfnct_invsig
integer, parameter, public nnp_actfnct_sig
integer, parameter, public nnp_actfnct_exp
subroutine, public nnp_neighbor_interface_state_release(state)
Free the allocatable parts of a neighbour-interface state. Co-located with the type definition to avo...
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.
Provides all information about an atomic kind.
Type defining parameters related to the simulation cell.
Definition cell_types.F:60
represents a system: atoms, molecules, their pos,vel,...
structure to store local (to a processor) ordered lists of integers.
Set of angular symmetry function type.
Set of radial symmetry function type.
Data type for artificial neural networks.
Linked-cell + Verlet-skin cache for the NNP descriptor neighbour walk. Persisted across MD steps so t...
Per-(element, SF-group) dG_k/dr buffer, sized to the group's n_symf (no max_*_symf padding) and the o...
Per-SF-group dense neighbour container. cap is the allocated slab size; the live count is nnp_neighbo...
Persistent neighbour-interface state. Owned by nnp_type so that the per-nnp pair-routing tables and p...
Species-pair routing table. For one (central element, neighbour element) pair, lists which radial / a...
Contains neighbors list of an atom (per-group dense layout).
Reusable per-element scratch / persistent caches for the ACSF descriptor and force assembly....
Main data type collecting all relevant data for neural network potentials.