(git:42db5d2)
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 TYPE(nnp_neighbor_workspace_type), ALLOCATABLE, &
416 DIMENSION(:) :: workspace
418
419! **************************************************************************************************
420!> \brief Data type for artificial neural networks
421!> \author Christoph Schran (christoph.schran@rub.de)
422!> \date 2020-10-10
423! **************************************************************************************************
425 TYPE(nnp_arc_layer_type), POINTER, DIMENSION(:) :: layer => null() ! DIM(n_layer)
426 INTEGER, ALLOCATABLE, DIMENSION(:) :: n_nodes
427 END TYPE nnp_arc_type
428
429! **************************************************************************************************
430!> \brief Data type for individual layer
431!> \author Christoph Schran (christoph.schran@rub.de)
432!> \date 2020-10-10
433! **************************************************************************************************
434 TYPE nnp_arc_layer_type
435 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :, :) :: weights ! node weights
436 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: bweights ! bias weights
437 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: node ! DIM(n_nodes)
438 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: node_grad ! DIM(n_nodes)
439 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: tmp_der ! DIM(n_sym,n_nodes)
440 END TYPE nnp_arc_layer_type
441
442CONTAINS
443
444! **************************************************************************************************
445!> \brief Release data structure that holds all the information for neural
446!> network potentials
447!> \param nnp_env ...
448!> \date 2020-10-10
449!> \author Christoph Schran (christoph.schran@rub.de)
450! **************************************************************************************************
451 SUBROUTINE nnp_env_release(nnp_env)
452 TYPE(nnp_type), INTENT(INOUT) :: nnp_env
453
454 INTEGER :: i, j
455
456 IF (ASSOCIATED(nnp_env%rad)) THEN
457 DO i = 1, nnp_env%n_ele
458 DO j = 1, nnp_env%rad(i)%n_symfgrp
459 IF (ALLOCATED(nnp_env%rad(i)%symfgrp(j)%symf)) THEN
460 DEALLOCATE (nnp_env%rad(i)%symfgrp(j)%symf, &
461 nnp_env%rad(i)%symfgrp(j)%ele, &
462 nnp_env%rad(i)%symfgrp(j)%ele_ind)
463 END IF
464 IF (ALLOCATED(nnp_env%rad(i)%symfgrp(j)%spline_y)) THEN
465 DEALLOCATE (nnp_env%rad(i)%symfgrp(j)%spline_y)
466 END IF
467 IF (ALLOCATED(nnp_env%rad(i)%symfgrp(j)%spline_dy)) THEN
468 DEALLOCATE (nnp_env%rad(i)%symfgrp(j)%spline_dy)
469 END IF
470 nnp_env%rad(i)%symfgrp(j)%spline_built = .false.
471 END DO
472 DEALLOCATE (nnp_env%rad(i)%y, &
473 nnp_env%rad(i)%funccut, &
474 nnp_env%rad(i)%eta, &
475 nnp_env%rad(i)%rs, &
476 nnp_env%rad(i)%loc_min, &
477 nnp_env%rad(i)%loc_max, &
478 nnp_env%rad(i)%loc_av, &
479 nnp_env%rad(i)%sigma, &
480 nnp_env%rad(i)%ele, &
481 nnp_env%rad(i)%nuc_ele, &
482 nnp_env%rad(i)%symfgrp)
483 END DO
484 DEALLOCATE (nnp_env%rad)
485 END IF
486
487 IF (ASSOCIATED(nnp_env%ang)) THEN
488 DO i = 1, nnp_env%n_ele
489 DO j = 1, nnp_env%ang(i)%n_symfgrp
490 IF (ALLOCATED(nnp_env%ang(i)%symfgrp(j)%symf)) THEN
491 DEALLOCATE (nnp_env%ang(i)%symfgrp(j)%symf, &
492 nnp_env%ang(i)%symfgrp(j)%ele, &
493 nnp_env%ang(i)%symfgrp(j)%ele_ind)
494 END IF
495 IF (ALLOCATED(nnp_env%ang(i)%symfgrp(j)%pack_eta)) THEN
496 DEALLOCATE (nnp_env%ang(i)%symfgrp(j)%pack_eta)
497 END IF
498 IF (ALLOCATED(nnp_env%ang(i)%symfgrp(j)%pack_zeta)) THEN
499 DEALLOCATE (nnp_env%ang(i)%symfgrp(j)%pack_zeta)
500 END IF
501 IF (ALLOCATED(nnp_env%ang(i)%symfgrp(j)%pack_lam)) THEN
502 DEALLOCATE (nnp_env%ang(i)%symfgrp(j)%pack_lam)
503 END IF
504 IF (ALLOCATED(nnp_env%ang(i)%symfgrp(j)%pack_prefzeta)) THEN
505 DEALLOCATE (nnp_env%ang(i)%symfgrp(j)%pack_prefzeta)
506 END IF
507 IF (ALLOCATED(nnp_env%ang(i)%symfgrp(j)%pack_izeta)) THEN
508 DEALLOCATE (nnp_env%ang(i)%symfgrp(j)%pack_izeta)
509 END IF
510 IF (ALLOCATED(nnp_env%ang(i)%symfgrp(j)%pack_use_int_zeta)) THEN
511 DEALLOCATE (nnp_env%ang(i)%symfgrp(j)%pack_use_int_zeta)
512 END IF
513 END DO
514 DEALLOCATE (nnp_env%ang(i)%y, &
515 nnp_env%ang(i)%funccut, &
516 nnp_env%ang(i)%eta, &
517 nnp_env%ang(i)%zeta, &
518 nnp_env%ang(i)%prefzeta, &
519 nnp_env%ang(i)%lam, &
520 nnp_env%ang(i)%loc_min, &
521 nnp_env%ang(i)%loc_max, &
522 nnp_env%ang(i)%loc_av, &
523 nnp_env%ang(i)%sigma, &
524 nnp_env%ang(i)%ele1, &
525 nnp_env%ang(i)%ele2, &
526 nnp_env%ang(i)%nuc_ele1, &
527 nnp_env%ang(i)%nuc_ele2, &
528 nnp_env%ang(i)%symfgrp)
529 END DO
530 DEALLOCATE (nnp_env%ang)
531 END IF
532
533 IF (ASSOCIATED(nnp_env%arc)) THEN
534 DO i = 1, nnp_env%n_ele
535 IF (ASSOCIATED(nnp_env%arc(i)%layer)) THEN
536 DO j = 1, nnp_env%n_layer
537 IF (ALLOCATED(nnp_env%arc(i)%layer(j)%node)) THEN
538 DEALLOCATE (nnp_env%arc(i)%layer(j)%node)
539 END IF
540 IF (ALLOCATED(nnp_env%arc(i)%layer(j)%node_grad)) THEN
541 DEALLOCATE (nnp_env%arc(i)%layer(j)%node_grad)
542 END IF
543 IF (ALLOCATED(nnp_env%arc(i)%layer(j)%weights)) THEN
544 DEALLOCATE (nnp_env%arc(i)%layer(j)%weights)
545 END IF
546 IF (ALLOCATED(nnp_env%arc(i)%layer(j)%bweights)) THEN
547 DEALLOCATE (nnp_env%arc(i)%layer(j)%bweights)
548 END IF
549 IF (ALLOCATED(nnp_env%arc(i)%layer(j)%tmp_der)) THEN
550 DEALLOCATE (nnp_env%arc(i)%layer(j)%tmp_der)
551 END IF
552 END DO
553 DEALLOCATE (nnp_env%arc(i)%layer, &
554 nnp_env%arc(i)%n_nodes)
555 END IF
556 END DO
557 DEALLOCATE (nnp_env%arc)
558 END IF
559
560 IF (ALLOCATED(nnp_env%ele)) DEALLOCATE (nnp_env%ele)
561 IF (ALLOCATED(nnp_env%nuc_ele)) DEALLOCATE (nnp_env%nuc_ele)
562 IF (ALLOCATED(nnp_env%n_hnodes)) DEALLOCATE (nnp_env%n_hnodes)
563 IF (ALLOCATED(nnp_env%actfnct)) DEALLOCATE (nnp_env%actfnct)
564 IF (ALLOCATED(nnp_env%nnp_forces)) DEALLOCATE (nnp_env%nnp_forces)
565 IF (ALLOCATED(nnp_env%atomic_energy)) DEALLOCATE (nnp_env%atomic_energy)
566 IF (ALLOCATED(nnp_env%committee_energy)) DEALLOCATE (nnp_env%committee_energy)
567 IF (ALLOCATED(nnp_env%ele_ind)) DEALLOCATE (nnp_env%ele_ind)
568 IF (ALLOCATED(nnp_env%nuc_atoms)) DEALLOCATE (nnp_env%nuc_atoms)
569 IF (ALLOCATED(nnp_env%sort)) DEALLOCATE (nnp_env%sort)
570 IF (ALLOCATED(nnp_env%sort_inv)) DEALLOCATE (nnp_env%sort_inv)
571 IF (ALLOCATED(nnp_env%coord)) DEALLOCATE (nnp_env%coord)
572 IF (ALLOCATED(nnp_env%myforce)) DEALLOCATE (nnp_env%myforce)
573 IF (ALLOCATED(nnp_env%committee_forces)) DEALLOCATE (nnp_env%committee_forces)
574 IF (ALLOCATED(nnp_env%committee_stress)) DEALLOCATE (nnp_env%committee_stress)
575 IF (ALLOCATED(nnp_env%atoms)) DEALLOCATE (nnp_env%atoms)
576
577 IF (ALLOCATED(nnp_env%cell_list_cache)) THEN
578 CALL nnp_cell_list_cache_release(nnp_env%cell_list_cache)
579 DEALLOCATE (nnp_env%cell_list_cache)
580 END IF
581 IF (ALLOCATED(nnp_env%neighbor_interface_state)) THEN
582 CALL nnp_neighbor_interface_state_release(nnp_env%neighbor_interface_state)
583 DEALLOCATE (nnp_env%neighbor_interface_state)
584 END IF
585
586 IF (ASSOCIATED(nnp_env%subsys)) THEN
587 CALL cp_subsys_release(nnp_env%subsys)
588 END IF
589 IF (ASSOCIATED(nnp_env%cell)) THEN
590 CALL cell_release(nnp_env%cell)
591 END IF
592 IF (ASSOCIATED(nnp_env%cell_ref)) THEN
593 CALL cell_release(nnp_env%cell_ref)
594 END IF
595
596 END SUBROUTINE nnp_env_release
597
598! **************************************************************************************************
599!> \brief Free the allocatable parts of a cell-list cache. Co-located with the
600!> type definition to avoid creating a USE-cycle through nnp_cell_list.
601!> \param cache cell-list cache whose allocatable image-pool and bin arrays are freed
602!> \author Dhruv Sharma (ds2173@cam.ac.uk)
603! **************************************************************************************************
605 TYPE(nnp_cell_list_cache_type), INTENT(INOUT) :: cache
606
607 IF (ALLOCATED(cache%coord_primary)) DEALLOCATE (cache%coord_primary)
608 IF (ALLOCATED(cache%coord_scaled)) DEALLOCATE (cache%coord_scaled)
609 IF (ALLOCATED(cache%ref_coord_primary)) DEALLOCATE (cache%ref_coord_primary)
610 IF (ALLOCATED(cache%image_atom)) DEALLOCATE (cache%image_atom)
611 IF (ALLOCATED(cache%head)) DEALLOCATE (cache%head)
612 IF (ALLOCATED(cache%next)) DEALLOCATE (cache%next)
613 IF (ALLOCATED(cache%image_shift)) DEALLOCATE (cache%image_shift)
614 IF (ALLOCATED(cache%image_translation)) DEALLOCATE (cache%image_translation)
615 cache%initialized = .false.
616 cache%num_atoms = -1
617 cache%n_images = 0
618 END SUBROUTINE nnp_cell_list_cache_release
619
620! **************************************************************************************************
621!> \brief Free the allocatable parts of a neighbour-interface state. Co-located
622!> with the type definition to avoid creating a USE-cycle through
623!> nnp_neighbor_interface.
624!> \param state neighbour-interface state whose pair maps and per-element workspaces are freed
625!> \author Dhruv Sharma (ds2173@cam.ac.uk)
626! **************************************************************************************************
629 INTENT(INOUT) :: state
630
631 INTEGER :: i, j
632
633 IF (ALLOCATED(state%pair_map)) THEN
634 DO i = 1, SIZE(state%pair_map, 1)
635 DO j = 1, SIZE(state%pair_map, 2)
636 IF (ALLOCATED(state%pair_map(i, j)%rad_groups)) DEALLOCATE (state%pair_map(i, j)%rad_groups)
637 IF (ALLOCATED(state%pair_map(i, j)%ang1_groups)) DEALLOCATE (state%pair_map(i, j)%ang1_groups)
638 IF (ALLOCATED(state%pair_map(i, j)%ang2_groups)) DEALLOCATE (state%pair_map(i, j)%ang2_groups)
639 END DO
640 END DO
641 DEALLOCATE (state%pair_map)
642 END IF
643
644 IF (ALLOCATED(state%workspace)) THEN
645 DO i = 1, SIZE(state%workspace)
646 CALL nnp_workspace_release(state%workspace(i))
647 END DO
648 DEALLOCATE (state%workspace)
649 END IF
650
651 IF (ALLOCATED(state%n_rad)) DEALLOCATE (state%n_rad)
652 IF (ALLOCATED(state%n_ang)) DEALLOCATE (state%n_ang)
653 IF (ALLOCATED(state%n_radgrp)) DEALLOCATE (state%n_radgrp)
654 IF (ALLOCATED(state%n_anggrp)) DEALLOCATE (state%n_anggrp)
655
656 state%initialized = .false.
657 state%n_ele = 0
659
660! **************************************************************************************************
661!> \brief Free the allocatable parts of one per-element workspace.
662!> \param workspace per-element workspace whose scratch, cutoff caches and dGdr buffers are freed
663!> \author Dhruv Sharma (ds2173@cam.ac.uk)
664! **************************************************************************************************
665 SUBROUTINE nnp_workspace_release(workspace)
666 TYPE(nnp_neighbor_workspace_type), INTENT(INOUT) :: workspace
667
668 INTEGER :: s
669
670 IF (ALLOCATED(workspace%neighbor%rad)) THEN
671 DO s = 1, SIZE(workspace%neighbor%rad)
672 IF (ALLOCATED(workspace%neighbor%rad(s)%ind)) DEALLOCATE (workspace%neighbor%rad(s)%ind)
673 IF (ALLOCATED(workspace%neighbor%rad(s)%dist)) DEALLOCATE (workspace%neighbor%rad(s)%dist)
674 END DO
675 DEALLOCATE (workspace%neighbor%rad)
676 END IF
677 IF (ALLOCATED(workspace%neighbor%ang1)) THEN
678 DO s = 1, SIZE(workspace%neighbor%ang1)
679 IF (ALLOCATED(workspace%neighbor%ang1(s)%ind)) DEALLOCATE (workspace%neighbor%ang1(s)%ind)
680 IF (ALLOCATED(workspace%neighbor%ang1(s)%dist)) DEALLOCATE (workspace%neighbor%ang1(s)%dist)
681 END DO
682 DEALLOCATE (workspace%neighbor%ang1)
683 END IF
684 IF (ALLOCATED(workspace%neighbor%ang2)) THEN
685 DO s = 1, SIZE(workspace%neighbor%ang2)
686 IF (ALLOCATED(workspace%neighbor%ang2(s)%ind)) DEALLOCATE (workspace%neighbor%ang2(s)%ind)
687 IF (ALLOCATED(workspace%neighbor%ang2(s)%dist)) DEALLOCATE (workspace%neighbor%ang2(s)%dist)
688 END DO
689 DEALLOCATE (workspace%neighbor%ang2)
690 END IF
691 IF (ALLOCATED(workspace%neighbor%n_rad)) DEALLOCATE (workspace%neighbor%n_rad)
692 IF (ALLOCATED(workspace%neighbor%n_ang1)) DEALLOCATE (workspace%neighbor%n_ang1)
693 IF (ALLOCATED(workspace%neighbor%n_ang2)) DEALLOCATE (workspace%neighbor%n_ang2)
694 workspace%neighbor%pbc_copies = -1
695
696 IF (ALLOCATED(workspace%radial_sym)) DEALLOCATE (workspace%radial_sym)
697 IF (ALLOCATED(workspace%radial_force)) DEALLOCATE (workspace%radial_force)
698 IF (ALLOCATED(workspace%angular_sym)) DEALLOCATE (workspace%angular_sym)
699 IF (ALLOCATED(workspace%angular_force)) DEALLOCATE (workspace%angular_force)
700 IF (ALLOCATED(workspace%fc_cache1)) DEALLOCATE (workspace%fc_cache1)
701 IF (ALLOCATED(workspace%dfc_cache1)) DEALLOCATE (workspace%dfc_cache1)
702 IF (ALLOCATED(workspace%fc_cache2)) DEALLOCATE (workspace%fc_cache2)
703 IF (ALLOCATED(workspace%dfc_cache2)) DEALLOCATE (workspace%dfc_cache2)
704 IF (ALLOCATED(workspace%self_dGdr)) DEALLOCATE (workspace%self_dGdr)
705
706 IF (ALLOCATED(workspace%dGdr_rad)) THEN
707 DO s = 1, SIZE(workspace%dGdr_rad)
708 IF (ALLOCATED(workspace%dGdr_rad(s)%data)) DEALLOCATE (workspace%dGdr_rad(s)%data)
709 END DO
710 DEALLOCATE (workspace%dGdr_rad)
711 END IF
712 IF (ALLOCATED(workspace%dGdr_ang_jj)) THEN
713 DO s = 1, SIZE(workspace%dGdr_ang_jj)
714 IF (ALLOCATED(workspace%dGdr_ang_jj(s)%data)) DEALLOCATE (workspace%dGdr_ang_jj(s)%data)
715 END DO
716 DEALLOCATE (workspace%dGdr_ang_jj)
717 END IF
718 IF (ALLOCATED(workspace%dGdr_ang_kk)) THEN
719 DO s = 1, SIZE(workspace%dGdr_ang_kk)
720 IF (ALLOCATED(workspace%dGdr_ang_kk(s)%data)) DEALLOCATE (workspace%dGdr_ang_kk(s)%data)
721 END DO
722 DEALLOCATE (workspace%dGdr_ang_kk)
723 END IF
724
725 workspace%max_rad_symf = 0
726 workspace%max_ang_symf = 0
727 workspace%n_input_nodes = 0
728 workspace%cache_cap = 0
729 END SUBROUTINE nnp_workspace_release
730
731! **************************************************************************************************
732!> \brief Returns various attributes of the nnp environment
733!> \param nnp_env ...
734!> \param nnp_forces ...
735!> \param subsys the particles, molecules,... of this environment
736!> \param atomic_kind_set The set of all atomic kinds involved
737!> \param particle_set The set of all particles
738!> \param local_particles All particles on this particular node
739!> \param molecule_kind_set The set of all different molecule kinds involved
740!> \param molecule_set The set of all molecules
741!> \param local_molecules All molecules on this particular node
742!> \param nnp_input ...
743!> \param force_env_input Pointer to the force_env input section
744!> \param cell The simulation cell
745!> \param cell_ref The reference simulation cell
746!> \param use_ref_cell Logical which indicates if reference
747!> simulation cell is used
748!> \param nnp_potential_energy ...
749!> \param virial Dummy virial pointer
750!> \date 2020-10-10
751!> \author Christoph Schran (christoph.schran@rub.de)
752!> \note
753!> For possible missing arguments see the attributes of
754!> nnp_type
755! **************************************************************************************************
756 SUBROUTINE nnp_env_get(nnp_env, nnp_forces, subsys, &
757 atomic_kind_set, particle_set, local_particles, &
758 molecule_kind_set, molecule_set, local_molecules, &
759 nnp_input, force_env_input, cell, cell_ref, &
760 use_ref_cell, nnp_potential_energy, virial)
761
762 TYPE(nnp_type), INTENT(IN) :: nnp_env
763 REAL(kind=dp), DIMENSION(:, :), OPTIONAL, POINTER :: nnp_forces
764 TYPE(cp_subsys_type), OPTIONAL, POINTER :: subsys
765 TYPE(atomic_kind_type), DIMENSION(:), OPTIONAL, &
766 POINTER :: atomic_kind_set
767 TYPE(particle_type), DIMENSION(:), OPTIONAL, &
768 POINTER :: particle_set
769 TYPE(distribution_1d_type), OPTIONAL, POINTER :: local_particles
770 TYPE(molecule_kind_type), DIMENSION(:), OPTIONAL, &
771 POINTER :: molecule_kind_set
772 TYPE(molecule_type), DIMENSION(:), OPTIONAL, &
773 POINTER :: molecule_set
774 TYPE(distribution_1d_type), OPTIONAL, POINTER :: local_molecules
775 TYPE(section_vals_type), OPTIONAL, POINTER :: nnp_input, force_env_input
776 TYPE(cell_type), OPTIONAL, POINTER :: cell, cell_ref
777 LOGICAL, INTENT(OUT), OPTIONAL :: use_ref_cell
778 REAL(kind=dp), INTENT(OUT), OPTIONAL :: nnp_potential_energy
779 TYPE(virial_type), OPTIONAL, POINTER :: virial
780
781 TYPE(atomic_kind_list_type), POINTER :: atomic_kinds
782 TYPE(molecule_kind_list_type), POINTER :: molecule_kinds
783 TYPE(molecule_list_type), POINTER :: molecules
784 TYPE(particle_list_type), POINTER :: particles
785
786 NULLIFY (atomic_kinds, particles, molecules, molecule_kinds)
787
788 IF (PRESENT(nnp_potential_energy)) THEN
789 nnp_potential_energy = nnp_env%nnp_potential_energy
790 END IF
791 IF (PRESENT(nnp_forces)) nnp_forces = nnp_env%nnp_forces
792
793 ! note cell will be overwritten if subsys is associated
794 ! helium_env uses nnp without subsys
795 IF (PRESENT(cell)) cell => nnp_env%cell
796
797 IF (PRESENT(subsys)) subsys => nnp_env%subsys
798 IF (ASSOCIATED(nnp_env%subsys)) THEN
799 CALL cp_subsys_get(nnp_env%subsys, &
800 atomic_kinds=atomic_kinds, &
801 particles=particles, &
802 molecule_kinds=molecule_kinds, &
803 molecules=molecules, &
804 local_molecules=local_molecules, &
805 local_particles=local_particles, &
806 virial=virial, &
807 cell=cell)
808 END IF
809 IF (PRESENT(atomic_kind_set)) atomic_kind_set => atomic_kinds%els
810 IF (PRESENT(particle_set)) particle_set => particles%els
811 IF (PRESENT(molecule_kind_set)) molecule_kind_set => molecule_kinds%els
812 IF (PRESENT(molecule_set)) molecule_set => molecules%els
813
814 IF (PRESENT(nnp_input)) nnp_input => nnp_env%nnp_input
815 IF (PRESENT(force_env_input)) force_env_input => nnp_env%force_env_input
816 IF (PRESENT(cell_ref)) cell_ref => nnp_env%cell_ref
817 IF (PRESENT(use_ref_cell)) use_ref_cell = nnp_env%use_ref_cell
818
819 END SUBROUTINE nnp_env_get
820
821! **************************************************************************************************
822!> \brief Sets various attributes of the nnp environment
823!> \param nnp_env ...
824!> \param nnp_forces ...
825!> \param subsys the particles, molecules,... of this environment
826!> \param atomic_kind_set The set of all atomic kinds involved
827!> \param particle_set The set of all particles
828!> \param local_particles All particles on this particular node
829!> \param molecule_kind_set The set of all different molecule kinds involved
830!> \param molecule_set The set of all molecules
831!> \param local_molecules All molecules on this particular node
832!> \param nnp_input ...
833!> \param force_env_input Pointer to the force_env input section
834!> \param cell ...
835!> \param cell_ref The reference simulation cell
836!> \param use_ref_cell Logical which indicates if reference
837!> simulation cell is used
838!> \param nnp_potential_energy ...
839!> \date 2020-10-10
840!> \author Christoph Schran (christoph.schran@rub.de)
841!> \note
842!> For possible missing arguments see the attributes of nnp_type
843! **************************************************************************************************
844 SUBROUTINE nnp_env_set(nnp_env, nnp_forces, subsys, &
845 atomic_kind_set, particle_set, local_particles, &
846 molecule_kind_set, molecule_set, local_molecules, &
847 nnp_input, force_env_input, cell, cell_ref, &
848 use_ref_cell, nnp_potential_energy)
849
850 TYPE(nnp_type), INTENT(INOUT) :: nnp_env
851 REAL(kind=dp), DIMENSION(:, :), OPTIONAL, POINTER :: nnp_forces
852 TYPE(cp_subsys_type), OPTIONAL, POINTER :: subsys
853 TYPE(atomic_kind_type), DIMENSION(:), OPTIONAL, &
854 POINTER :: atomic_kind_set
855 TYPE(particle_type), DIMENSION(:), OPTIONAL, &
856 POINTER :: particle_set
857 TYPE(distribution_1d_type), OPTIONAL, POINTER :: local_particles
858 TYPE(molecule_kind_type), DIMENSION(:), OPTIONAL, &
859 POINTER :: molecule_kind_set
860 TYPE(molecule_type), DIMENSION(:), OPTIONAL, &
861 POINTER :: molecule_set
862 TYPE(distribution_1d_type), OPTIONAL, POINTER :: local_molecules
863 TYPE(section_vals_type), OPTIONAL, POINTER :: nnp_input, force_env_input
864 TYPE(cell_type), OPTIONAL, POINTER :: cell, cell_ref
865 LOGICAL, INTENT(IN), OPTIONAL :: use_ref_cell
866 REAL(kind=dp), INTENT(IN), OPTIONAL :: nnp_potential_energy
867
868 TYPE(atomic_kind_list_type), POINTER :: atomic_kinds
869 TYPE(molecule_kind_list_type), POINTER :: molecule_kinds
870 TYPE(molecule_list_type), POINTER :: molecules
871 TYPE(particle_list_type), POINTER :: particles
872
873 IF (PRESENT(nnp_potential_energy)) THEN
874 nnp_env%nnp_potential_energy = nnp_potential_energy
875 END IF
876 IF (PRESENT(nnp_forces)) nnp_env%nnp_forces(:, :) = nnp_forces
877
878 IF (PRESENT(subsys)) THEN
879 IF (ASSOCIATED(nnp_env%subsys)) THEN
880 IF (.NOT. ASSOCIATED(nnp_env%subsys, subsys)) THEN
881 CALL cp_subsys_release(nnp_env%subsys)
882 END IF
883 END IF
884 nnp_env%subsys => subsys
885 END IF
886 IF (PRESENT(cell)) THEN
887 IF (ASSOCIATED(cell)) THEN
888 CALL cell_retain(cell)
889 CALL cell_release(nnp_env%cell)
890 nnp_env%cell => cell
891 END IF
892 IF (ASSOCIATED(nnp_env%subsys)) THEN
893 CALL cp_subsys_set(nnp_env%subsys, cell=cell)
894 END IF
895 END IF
896 IF (PRESENT(atomic_kind_set)) THEN
897 CALL atomic_kind_list_create(atomic_kinds, els_ptr=atomic_kind_set)
898 CALL cp_subsys_set(nnp_env%subsys, atomic_kinds=atomic_kinds)
899 CALL atomic_kind_list_release(atomic_kinds)
900 END IF
901 IF (PRESENT(particle_set)) THEN
902 CALL particle_list_create(particles, els_ptr=particle_set)
903 CALL cp_subsys_set(nnp_env%subsys, particles=particles)
904 CALL particle_list_release(particles)
905 END IF
906 IF (PRESENT(molecule_kind_set)) THEN
907 CALL molecule_kind_list_create(molecule_kinds, els_ptr=molecule_kind_set)
908 CALL cp_subsys_set(nnp_env%subsys, molecule_kinds=molecule_kinds)
909 CALL molecule_kind_list_release(molecule_kinds)
910 END IF
911 IF (PRESENT(molecule_set)) THEN
912 CALL molecule_list_create(molecules, els_ptr=molecule_set)
913 CALL cp_subsys_set(nnp_env%subsys, molecules=molecules)
914 CALL molecule_list_release(molecules)
915 END IF
916 IF (PRESENT(local_particles)) THEN
917 CALL cp_subsys_set(nnp_env%subsys, local_particles=local_particles)
918 END IF
919 IF (PRESENT(local_molecules)) THEN
920 CALL cp_subsys_set(nnp_env%subsys, local_molecules=local_molecules)
921 END IF
922
923 IF (PRESENT(nnp_input)) nnp_env%nnp_input => nnp_input
924 IF (PRESENT(force_env_input)) THEN
925 nnp_env%force_env_input => force_env_input
926 END IF
927 IF (PRESENT(cell_ref)) THEN
928 CALL cell_retain(cell_ref)
929 CALL cell_release(nnp_env%cell_ref)
930 nnp_env%cell_ref => cell_ref
931 END IF
932 IF (PRESENT(use_ref_cell)) nnp_env%use_ref_cell = use_ref_cell
933 END SUBROUTINE nnp_env_set
934
935END 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.