(git:71c3ab0)
Loading...
Searching...
No Matches
helium_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 representing superfluid helium
10!> \author hforbert
11!> \date 2009-01-01
12!> \par History
13!> extracted helium_solvent_type from pint_types.F [lwalewski]
14! **************************************************************************************************
16
17 USE cell_types, ONLY: cell_type
21 USE kinds, ONLY: default_string_length,&
22 dp,&
23 int_8
28#include "../base/base_uses.f90"
29
30 IMPLICIT NONE
31
32 PRIVATE
33
34 LOGICAL, PRIVATE, PARAMETER :: debug_this_module = .true.
35 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'helium_types'
36
37 !> Energy contributions - symbolic names for indexing energy arrays
38 INTEGER, PARAMETER, PUBLIC :: &
39 e_id_total = 1, &
40 e_id_potential = 2, &
41 e_id_kinetic = 3, &
42 e_id_interact = 4, &
43 e_id_thermo = 5, &
44 e_id_virial = 6
45
46 !> Number of energy contributions for static array allocation
47 INTEGER, PARAMETER, PUBLIC :: e_num_ids = 10
48
49 !> number of density function identifiers
50 INTEGER, PARAMETER, PUBLIC :: rho_num = 5
51
52 !> density function identifier names
53 INTEGER, PARAMETER, PUBLIC :: &
54 rho_atom_number = 1, &
59
60 !> derived data types
61 PUBLIC :: helium_solvent_type
62 PUBLIC :: helium_solvent_p_type
63 PUBLIC :: int_arr_ptr
64
65 !> functions
67
68! ***************************************************************************
69!> \brief Vector type useful for averaging
70!> \author Lukasz Walewski
71!> \date 2014-09-09
72! ***************************************************************************
73 TYPE helium_vector_type
74
75 !> instantaneous value
76 REAL(kind=dp), DIMENSION(3) :: inst = 0.0_dp
77
78 !> accumulated value
79 REAL(kind=dp), DIMENSION(3) :: accu = 0.0_dp
80
81 !> running average
82 REAL(kind=dp), DIMENSION(3) :: ravr = 0.0_dp
83
84 !> restarted value
85 REAL(kind=dp), DIMENSION(3) :: rstr = 0.0_dp
86
87 END TYPE helium_vector_type
88
89! ***************************************************************************
90!> \brief data structure for solvent helium
91!> \author hforbert
92! ***************************************************************************
94
95 TYPE(section_vals_type), POINTER :: input => null()!< input data structure (the whole tree)
96 TYPE(cp_logger_type), POINTER :: logger => null()
97
98 INTEGER :: num_env = 0!< number of He environments in runtime
99
100 INTEGER :: atoms = 0!< number of atoms
101 INTEGER :: beads = 0!< number of beads per atom (needs to be an integer multiple of the solute's number of beads)
102 INTEGER :: bead_ratio = 0!< ratio of helium beads to system beads
103 REAL(kind=dp) :: density = 0.0_dp !< helium density for free bulk in box
104
105 ! some useful constants
106 !
107 REAL(kind=dp) :: he_mass_au = 0.0_dp! mass of helium 4 in electron masses
108 REAL(kind=dp) :: hb2m = 0.0_dp!< hbar squared over m for 4He in CP2k units
109 REAL(kind=dp) :: tau = 0.0_dp!< 1/(k_B T p) with T - He temperature, p - number of beads
110 REAL(kind=dp) :: wpref = 0.0_dp!< prefactor for calculating superfluid fraction from <(M*W)^2>
111 REAL(kind=dp) :: apref = 0.0_dp!< prefactor for calculating superfluid fraction from <A^2/I_c>
112
113 ! PBC related
114 !
115 LOGICAL :: periodic = .false.!< true if bulk liquid helium in periodic box
116 INTEGER :: cell_shape = 0!< unit cell shape for PBC calculations
117 REAL(kind=dp) :: cell_size = 0.0_dp!< size of the periodic box (helium only)
118 REAL(kind=dp) :: cell_size_inv = 0.0_dp!< 1/cell_size (inverse)
119 REAL(kind=dp), DIMENSION(3, 3) :: cell_m = 0.0_dp!< the unit cell vectors' matrix
120 REAL(kind=dp), DIMENSION(3, 3) :: cell_m_inv = 0.0_dp!< invrse of the unit cell vectors' matrix
121 REAL(kind=dp), DIMENSION(3) :: origin = 0.0_dp!< origin of the cell (first voxel position)
122 REAL(kind=dp) :: droplet_radius = 0.0_dp !< radius of the droplet
123
124 REAL(kind=dp), DIMENSION(3) :: center = 0.0_dp!< COM of solute (if present) or center of
125 ! periodic cell (if periodic) or COM of helium
126
127 INTEGER :: sampling_method = helium_sampling_ceperley
128 ! worm sampling parameters
129 REAL(kind=dp) :: worm_centroid_drmax = 0.0_dp
130 INTEGER :: worm_nstat = 0
131 INTEGER :: worm_staging_l = 0
132 INTEGER :: worm_repeat_crawl = 0
133 INTEGER :: worm_all_limit = 0
134 INTEGER :: worm_centroid_min = 0, worm_centroid_max = 0
135 INTEGER :: worm_staging_min = 0, worm_staging_max = 0
136 INTEGER :: worm_fcrawl_min = 0, worm_fcrawl_max = 0
137 INTEGER :: worm_bcrawl_min = 0, worm_bcrawl_max = 0
138 INTEGER :: worm_head_min = 0, worm_head_max = 0
139 INTEGER :: worm_tail_min = 0, worm_tail_max = 0
140 INTEGER :: worm_swap_min = 0, worm_swap_max = 0
141 INTEGER :: worm_open_close_min = 0, worm_open_close_max = 0
142 INTEGER :: worm_max_open_cycles = 0
143 REAL(kind=dp) :: worm_open_close_scale = 0.0_dp
144 REAL(kind=dp) :: worm_ln_openclose_scale = 0.0_dp
145 LOGICAL :: worm_allow_open = .false., worm_show_statistics = .false.
146
147 ! worm specific variables
148 REAL(kind=dp), DIMENSION(3) :: worm_xtra_bead = 0.0_dp, worm_xtra_bead_work = 0.0_dp
149 INTEGER :: worm_atom_idx = 0, worm_bead_idx = 0
150 INTEGER :: worm_atom_idx_work = 0, worm_bead_idx_work = 0
151 INTEGER :: iw = 0, it = 0
152 LOGICAL :: worm_is_closed = .false.!before isector=1 -> open; isector=0 -> closed
153
154 INTEGER :: iter_norot = 0!< number of iterations to try for a given imaginary time slice rotation (num inner MC loop iters)
155 INTEGER :: iter_rot = 0!< number of rotations to try (total number of iterations is iter_norot*iter_rot)
156 ! (num outer MC loop iters)
157 !
158 INTEGER :: maxcycle = 0!< maximum cyclic permutation change to attempt
159 INTEGER :: m_dist_type = 0!< distribution from which the cycle length m is sampled
160 INTEGER :: m_value = 0!< cycle length sampled with different probability than other lengths
161 REAL(kind=dp) :: m_ratio = 0.0_dp!< probability ratio betw m_value and other possible values of m
162 !
163 INTEGER :: relrot = 0!< relative rotation in imaginary time wrt normal system/starting configuration
164 INTEGER :: bisection = 0 !< power of 2 number for bisection algorithm
165 INTEGER :: bisctlog2 = 0!< log2(bisection)
166
167 REAL(kind=dp) :: e_corr = 0.0_dp !< potential correction energy due to finite box
168 INTEGER :: pdx = 0!< pair density expansion max exponent
169
170 ! MC step counters
171 !
172 INTEGER :: num_steps = 0!< number of iterations in the current run
173 INTEGER :: first_step = 0!< first step, restarted from MOTION%PINT%ITERATION (default value: 0)
174 INTEGER :: last_step = 0
175 INTEGER :: current_step = 0 !< first_step + number of steps performed so far
176
177 ! helium variables
178 !
179 REAL(kind=dp), DIMENSION(:, :, :), POINTER :: pos => null()!< position of the helium atoms DIM(3,atoms,beads)
180 REAL(kind=dp), DIMENSION(:, :, :), POINTER :: savepos => null()!< saved position of the helium atoms DIM(3,atoms,beads)
181 REAL(kind=dp), DIMENSION(:, :, :), POINTER :: work => null()!< same dimensions as pos
182 !
183 INTEGER, DIMENSION(:), POINTER :: permutation => null()!< current permutation state DIM(atoms)
184 INTEGER, DIMENSION(:), POINTER :: savepermutation => null()!< saved permutation state DIM(atoms)
185 INTEGER, DIMENSION(:), POINTER :: iperm => null()!< inverse of the current permutation state DIM(atoms)
186 INTEGER, DIMENSION(:), POINTER :: saveiperm => null()!< saved inverse of the current permutation state DIM(atoms)
187 INTEGER, DIMENSION(:), POINTER :: ptable => null()!< proposed cyclic permutation, DIM(max_cycle)
188 INTEGER(KIND=int_8) :: accepts = 0_int_8!< number of accepted new configurations
189 !
190 REAL(kind=dp), DIMENSION(:, :), POINTER :: tmatrix => null()!< ? permutation probability related
191 REAL(kind=dp), DIMENSION(:, :), POINTER :: pmatrix => null()!< ? permutation probability related
192 ! [use might change/new ones added/etc]
193 REAL(kind=dp) :: pweight = 0.0_dp!< ? permutation probability related
194 REAL(kind=dp), DIMENSION(:, :), POINTER :: ipmatrix => null()
195 INTEGER, DIMENSION(:, :), POINTER :: nmatrix => null()
196
197 TYPE(spline_data_type), POINTER :: vij => null()!< physical pair potential energy
198 TYPE(spline_data_type), POINTER :: u0 => null()!< pair density matrix coefficient (action) endpoint approx
199 TYPE(spline_data_type), POINTER :: e0 => null()!< pair density matrix coefficient (energy) endpoint approx
200 !< raw spline data for pair density matrix off diagonal expansion beyond endpoint approx:
201 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: uoffdiag => null()!< (action)
202 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: eoffdiag => null()!< (energy)
203
204 ! calculated properties
205 !
206 REAL(kind=dp), DIMENSION(e_num_ids) :: energy_inst = 0.0_dp!< energy contributions (instantaneous)
207 REAL(kind=dp), DIMENSION(e_num_ids) :: energy_avrg = 0.0_dp!< energy contributions (averaged)
208 TYPE(helium_vector_type) :: wnumber = helium_vector_type()!< winding number
209 TYPE(helium_vector_type) :: wnmber2 = helium_vector_type()!< winding number squared
210 TYPE(helium_vector_type) :: proarea = helium_vector_type()!< projected area
211 TYPE(helium_vector_type) :: prarea2 = helium_vector_type()!< projected area squared
212 TYPE(helium_vector_type) :: mominer = helium_vector_type()!< moment of inertia
213 INTEGER :: averages_iweight = 0!< weight for restarted averages
214 LOGICAL :: averages_restarted = .false.!< flag indicating whether the averages
215 ! have been restarted
216
217 REAL(kind=dp) :: link_action = 0.0_dp, inter_action = 0.0_dp, pair_action = 0.0_dp
218
219 !
220 INTEGER :: rdf_nbin = 0!< number of bins for RDF
221 INTEGER :: rdf_iweight = 0 !< weight for restarted RDF
222 INTEGER :: rho_iweight = 0!< weight for restarted RHO
223 INTEGER :: rdf_num = 0!< number of X-He-RDFs
224 INTEGER :: rdf_num_ctr = 0 !< number of centers for RDF calc
225 REAL(kind=dp) :: rdf_delr = 0.0_dp!< delta r for RDF
226 REAL(kind=dp) :: rdf_maxr = 0.0_dp!< maximum r for RDF
227 REAL(kind=dp), DIMENSION(:, :), POINTER :: rdf_centers => null() !< positions of RDF solute centers
228 REAL(kind=dp), DIMENSION(:, :), POINTER :: rdf_inst => null()!< RDF (instantaneous/tmp array)
229 REAL(kind=dp), DIMENSION(:, :), POINTER :: rdf_rstr => null()!< RDF (restarted)
230 REAL(kind=dp), DIMENSION(:, :), POINTER :: rdf_accu => null()!< RDF (accumulated for one run)
231 LOGICAL :: rdf_present = .false.
232 LOGICAL :: rdf_sol_he = .false.
233 LOGICAL :: rdf_he_he = .false.
234 !
235 INTEGER :: rho_nbin = 0
236 INTEGER :: rho_num_act = 0!< actual number of density estimators
237 INTEGER :: rho_num_min_len_wdg = 0!< number of optional estimators based on winding cycles
238 INTEGER :: rho_num_min_len_non = 0!< number of optional estimators based on non-winding cycles
239 INTEGER :: rho_num_min_len_all = 0!< number of optional estimators based on all cycles
240 INTEGER, DIMENSION(:), POINTER :: rho_min_len_wdg_vals => null()!< minimum lengths of winding cycles
241 INTEGER, DIMENSION(:), POINTER :: rho_min_len_non_vals => null()!< minimum lengths of non-winding cycles
242 INTEGER, DIMENSION(:), POINTER :: rho_min_len_all_vals => null()!< minimum lengths of all cycles
243 REAL(kind=dp) :: rho_delr = 0.0_dp, rho_maxr = 0.0_dp
244 REAL(kind=dp), DIMENSION(:, :, :, :), POINTER :: rho_inst => null()
245 REAL(kind=dp), DIMENSION(:, :, :, :), POINTER :: rho_rstr => null()
246 REAL(kind=dp), DIMENSION(:, :, :, :), POINTER :: rho_accu => null()
247 LOGICAL :: rho_present = .false.
248 REAL(kind=dp), DIMENSION(:, :, :), POINTER :: rho_incr => null()!< increment for density bining
249
250 TYPE(density_properties_type), DIMENSION(:), POINTER :: rho_property => null()
251
252 REAL(kind=dp), DIMENSION(:, :), POINTER :: num_accepted => null()!< average number of accepted permutations of a given length
253 !! on a given Levy level, plus one additional level which
254 !! counts # of trials, REAL(BISCTLOG2+2, MAX_PERM_CYCLE)
255 !! num_accepted(1,l) - # of trials for perm length l
256 !! num_accepted(2,l) - # of selected perms of length l
257 !! num_accepted(3,l) - # of perms of length l accepted at level 1
258 !! average over He environments/processors
259 REAL(kind=dp), DIMENSION(:), POINTER :: plength_avrg => null()!< permutation length probability distribution DIM(atoms)
260 REAL(kind=dp), DIMENSION(:), POINTER :: plength_inst => null()!< instantaneous permutation length probability DIM(atoms)
261 INTEGER, DIMENSION(:), POINTER :: atom_plength => null()!< length of the permutation cycle the atom belongs to DIM(atoms)
262
263 TYPE(rng_stream_type), POINTER :: rng_stream_uniform => null()!< random number stream with uniform distribution
264 TYPE(rng_stream_type), POINTER :: rng_stream_gaussian => null()!< random number stream with gaussian distribution
265
266 ! variables related to solvated molecular system
267 !
268 LOGICAL :: solute_present = .false.!< switch the interactions with the solute on or off
269 INTEGER :: solute_atoms = 0!< number of solute atoms (pint_env%ndim/3)
270 INTEGER :: solute_beads = 0!< number of solute beads (pint_env%p)
271 INTEGER :: get_helium_forces = 0!< parameter to determine whether the average or last MC force should be taken to MD
272 CHARACTER(LEN=2), DIMENSION(:), POINTER :: solute_element => null()!< element names of solute atoms (pint_env%ndim/3)
273 TYPE(cell_type), POINTER :: solute_cell => null()!< dimensions of the solvated system cell (a,b,c)
274 ! (should be removed at some point)
275 REAL(kind=dp), DIMENSION(:, :), POINTER :: force_avrg => null()!< averaged forces exerted by He solvent
276 ! on the solute DIM(p,ndim)
277 REAL(kind=dp), DIMENSION(:, :), POINTER :: force_inst => null()!< instantaneous forces exerted by He on the solute (p,ndim)
278 CHARACTER(LEN=2), DIMENSION(:), POINTER :: ename => null()
279 INTEGER :: enum = 0
280 INTEGER :: solute_interaction = 0
281
282 LOGICAL :: interaction_pot_scan = .false.!< whether to perform solute-helium interaction scan
283
284 TYPE(nnp_type), POINTER :: nnp => null() !< neural network potential
285 REAL(kind=dp), DIMENSION(:), POINTER :: nnp_sr_cut => null() !< hard core cutoff in addition to the nnp
286
287 ! temporary arrays for optimization
288 !
289 INTEGER, DIMENSION(:), POINTER :: itmp_atoms_1d => null()!< DIM(atoms) - same as permutation
290 INTEGER, DIMENSION(:), POINTER :: itmp_atoms_np_1d => null()!< DIM(atoms*num_env)
291 REAL(kind=dp), DIMENSION(:), POINTER :: rtmp_3_np_1d => null()!< DIM(3*num_env)
292 REAL(kind=dp), DIMENSION(:), POINTER :: rtmp_p_ndim_1d => null()!< DIM(p*ndim)
293 REAL(kind=dp), DIMENSION(:), POINTER :: rtmp_p_ndim_np_1d => null()!< DIM(p*ndim*num_env)
294 REAL(kind=dp), DIMENSION(:), POINTER :: rtmp_3_atoms_beads_1d => null()!< DIM(3*atoms*beads)
295 REAL(kind=dp), DIMENSION(:), POINTER :: rtmp_3_atoms_beads_np_1d => null()
296 REAL(kind=dp), DIMENSION(:, :), POINTER :: rtmp_p_ndim_2d => null()!< DIM(p,ndim)
297 LOGICAL, DIMENSION(:, :, :), POINTER :: ltmp_3_atoms_beads_3d => null()!< DIM(3,atoms,beads) - same as pos
298 LOGICAL, DIMENSION(:), POINTER :: ltmp_atoms_1d => null()!< DIM(atoms) - for unpacking the permutation
299
300 END TYPE helium_solvent_type
301
302! ***************************************************************************
303!> \brief data structure for array of solvent helium environments
304!> \author cschran
305! ***************************************************************************
307 TYPE(helium_solvent_type), POINTER :: helium => null()
308 TYPE(mp_para_env_type), POINTER :: comm => null()
309 INTEGER, DIMENSION(:), POINTER :: env_all => null()
310 END TYPE helium_solvent_p_type
311
312! ***************************************************************************
313!> \brief Container type for properties of a helium density function
314!> \author Lukasz Walewski
315!> \date 2014-09-09
316! ***************************************************************************
317 TYPE density_properties_type
318
319 !> name of this density function
320 CHARACTER(len=default_string_length) :: name = ""
321
322 !> flag indicating whether this function should be calculated
323 LOGICAL :: is_calculated = .false.
324
325 !> number of components that this function is composed of
326 INTEGER :: num_components = 0
327
328 !> suffixes for the filenames storing components of this function
329 CHARACTER(len=default_string_length), DIMENSION(:), POINTER :: filename_suffix => null()
330
331 !> component names
332 CHARACTER(len=default_string_length), DIMENSION(:), POINTER :: component_name => null()
333
334 !> indices locating the components of this function in the global density arrays
335 INTEGER, DIMENSION(:), POINTER :: component_index => null()
336
337 END TYPE density_properties_type
338
339! ***************************************************************************
340!> \brief A pointer to an integer array, data type to be used in arrays of
341!> pointers.
342!> \author Lukasz Walewski
343!> \date 2013-12-11
344! ***************************************************************************
346 INTEGER, DIMENSION(:), POINTER :: iap => null()
347 END TYPE int_arr_ptr
348
349! ***************************************************************************
350!> \brief A pointer to a real array, data type to be used in arrays of
351!> pointers.
352!> \author Lukasz Walewski
353!> \date 2013-12-11
354! ***************************************************************************
355 TYPE real_arr_ptr
356 REAL(kind=dp), DIMENSION(:), POINTER :: rap => null()
357 END TYPE real_arr_ptr
358
359CONTAINS
360
361! ***************************************************************************
362!> \brief Deallocate all arrays pointed to by the pointers stored in the
363!> integer pointer array
364!> \param int_arr_p ...
365!> \date 2013-12-12
366!> \author Lukasz Walewski
367! **************************************************************************************************
368 SUBROUTINE helium_destroy_int_arr_ptr(int_arr_p)
369
370 TYPE(int_arr_ptr), DIMENSION(:), POINTER :: int_arr_p
371
372 INTEGER :: ip
373
374! deallocate memory used by each component of the pointer array
375
376 DO ip = 1, SIZE(int_arr_p)
377 IF (ASSOCIATED(int_arr_p(ip)%iap)) THEN
378 DEALLOCATE (int_arr_p(ip)%iap)
379 END IF
380 END DO
381
382 ! deallocate the memory used for pointer array
383 IF (ASSOCIATED(int_arr_p)) THEN
384 DEALLOCATE (int_arr_p)
385 END IF
386
387 RETURN
388 END SUBROUTINE helium_destroy_int_arr_ptr
389
390! ***************************************************************************
391!> \brief Deallocate all arrays pointed to by the pointers stored in the
392!> real pointer array
393!> \param real_arr_p ...
394!> \date 2013-12-12
395!> \author Lukasz Walewski
396! **************************************************************************************************
397 SUBROUTINE helium_destroy_real_arr_ptr(real_arr_p)
398
399 TYPE(real_arr_ptr), DIMENSION(:), POINTER :: real_arr_p
400
401 INTEGER :: ip
402
403! do not attempt deallocation on null pointer
404
405 IF (.NOT. ASSOCIATED(real_arr_p)) THEN
406 RETURN
407 END IF
408
409 ! deallocate memory used by each component of the pointer array
410 DO ip = 1, SIZE(real_arr_p)
411 IF (ASSOCIATED(real_arr_p(ip)%rap)) THEN
412 DEALLOCATE (real_arr_p(ip)%rap)
413 END IF
414 END DO
415
416 ! deallocate the memory used for pointer array itself
417 IF (ASSOCIATED(real_arr_p)) THEN
418 DEALLOCATE (real_arr_p)
419 END IF
420
421 RETURN
422 END SUBROUTINE helium_destroy_real_arr_ptr
423
424END MODULE helium_types
Handles all functions related to the CELL.
Definition cell_types.F:15
various routines to log and control the output. The idea is that decisions about where to log should ...
Data types representing superfluid helium.
integer, parameter, public e_id_potential
integer, parameter, public e_id_thermo
integer, parameter, public rho_moment_of_inertia
integer, parameter, public rho_winding_number
integer, parameter, public rho_atom_number
density function identifier names
integer, parameter, public rho_winding_cycle
integer, parameter, public rho_projected_area
integer, parameter, public e_id_virial
integer, parameter, public e_num_ids
Number of energy contributions for static array allocation.
subroutine, public helium_destroy_int_arr_ptr(int_arr_p)
Deallocate all arrays pointed to by the pointers stored in the integer pointer array.
integer, parameter, public e_id_interact
integer, parameter, public e_id_kinetic
integer, parameter, public e_id_total
Energy contributions - symbolic names for indexing energy arrays.
integer, parameter, public rho_num
number of density function identifiers
collects all constants needed in input so that they can be used without circular dependencies
integer, parameter, public helium_sampling_ceperley
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 int_8
Definition kinds.F:54
integer, parameter, public dp
Definition kinds.F:34
integer, parameter, public default_string_length
Definition kinds.F:57
Interface to the message passing library MPI.
Data types for neural network potentials.
Parallel (pseudo)random number generator (RNG) for multiple streams and substreams of random numbers.
routines for handling splines_types
Type defining parameters related to the simulation cell.
Definition cell_types.F:60
type of a logger, at the moment it contains just a print level starting at which level it should be l...
data structure for array of solvent helium environments
data structure for solvent helium
A pointer to an integer array, data type to be used in arrays of pointers.
stores all the informations relevant to an mpi environment
Main data type collecting all relevant data for neural network potentials.
Data-structure that holds all needed information about a specific spline interpolation.