(git:744416f)
Loading...
Searching...
No Matches
tmc_analysis_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 module provides variables for the TMC analysis tool
10!> \par History
11!> 02.2013 created [Mandes Schoenherr]
12!> \author Mandes
13! **************************************************************************************************
14
16 USE cell_types, ONLY: cell_type
17 USE kinds, ONLY: default_path_length,&
19 dp
20 USE tmc_tree_types, ONLY: tree_type
21 USE tmc_types, ONLY: tmc_atom_type
22#include "../base/base_uses.f90"
23
24 IMPLICIT NONE
25
26 PRIVATE
27
28 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'tmc_analysis_types'
29
38
39 CHARACTER(LEN=default_path_length), PARAMETER, &
40 PUBLIC :: tmc_ana_density_file_name = "tmc_ana_density.dat"
41 CHARACTER(LEN=default_path_length), PARAMETER, &
42 PUBLIC :: tmc_ana_pair_correl_file_name = "tmc_ana_g_r.dat"
43
44 INTEGER, PARAMETER, PUBLIC :: ana_type_default = 0
45 INTEGER, PARAMETER, PUBLIC :: ana_type_ice = 1
46 INTEGER, PARAMETER, PUBLIC :: ana_type_sym_xyz = 2
47
49 TYPE(tmc_analysis_env), POINTER :: temp => null()
50 END TYPE tmc_ana_list_type
51
53 INTEGER :: io_unit = -1
54 CHARACTER(len=default_string_length), &
55 DIMENSION(:), POINTER :: dirs => null()
56 CHARACTER(LEN=default_path_length) :: out_file_prefix = ""
57 INTEGER :: conf_offset = 0
58 TYPE(cell_type), POINTER :: cell => null()
59 TYPE(tmc_atom_type), DIMENSION(:), POINTER :: atoms => null()
60 INTEGER :: dim_per_elem = 3
61 INTEGER :: nr_dim = -1
62 REAL(kind=dp) :: temperature = 0.0_dp
63 TYPE(tree_type), POINTER :: last_elem => null()
64 INTEGER :: from_elem = -1, to_elem = -1
65 INTEGER :: id_traj = -1, id_cell = -1, id_frc = -1, id_dip = -1, id_ener = -1
66 INTEGER :: lc_traj = 0, lc_cell = 0, lc_frc = 0, lc_dip = 0, lc_ener = 0
67 CHARACTER(LEN=default_path_length) :: costum_pos_file_name = ""
68 CHARACTER(LEN=default_path_length) :: costum_dip_file_name = ""
69 CHARACTER(LEN=default_path_length) :: costum_cell_file_name = ""
70 LOGICAL :: restart = .true., restarted = .false.
71 LOGICAL :: print_test_output = .false.
72
73 TYPE(density_3d_type), POINTER :: density_3d => null()
74 TYPE(pair_correl_type), POINTER :: pair_correl => null()
75 TYPE(dipole_moment_type), POINTER :: dip_mom => null()
76 TYPE(dipole_analysis_type), POINTER :: dip_ana => null()
77 TYPE(displacement_type), POINTER :: displace => null()
78 END TYPE tmc_analysis_env
79
80 TYPE density_3d_type
81 INTEGER :: conf_counter = 0
82 INTEGER, DIMENSION(3) :: nr_bins = 0
83 REAL(kind=dp) :: sum_vol = 0.0_dp
84 REAL(kind=dp) :: sum_vol2 = 0.0_dp
85 REAL(kind=dp), DIMENSION(3) :: sum_box_length = 0.0_dp
86 REAL(kind=dp), DIMENSION(3) :: sum_box_length2 = 0.0_dp
87 REAL(kind=dp), DIMENSION(:, :, :), POINTER :: sum_density => null(), sum_dens2 => null()
88 LOGICAL :: print_dens = .true.
89 END TYPE density_3d_type
90
92 INTEGER :: conf_counter = 0
93 INTEGER :: nr_bins = 0
94 REAL(kind=dp) :: step_length = -1.0_dp
95 TYPE(atom_pairs_type), DIMENSION(:), POINTER :: pairs => null()
96 REAL(kind=dp), DIMENSION(:, :), POINTER :: g_r => null()
97 REAL(kind=dp) :: sum_box_scale(3) = 0.0_dp
98 END TYPE pair_correl_type
99
101 CHARACTER(LEN=default_string_length) :: f_n = ""
102 CHARACTER(LEN=default_string_length) :: s_n = ""
103 INTEGER :: pair_count = 0
104 END TYPE atom_pairs_type
105
107 INTEGER :: conf_counter = 0
108 TYPE(tmc_atom_type), DIMENSION(:), POINTER :: charges_inp => null()
109 REAL(kind=dp), DIMENSION(:), POINTER :: charges => null()
110 REAL(kind=dp), DIMENSION(:), POINTER :: last_dip_cl => null()
111 LOGICAL :: print_cl_dip = .true.
112 END TYPE dipole_moment_type
113
114 TYPE dipole_analysis_type
115 REAL(kind=dp) :: conf_counter = 0
116 INTEGER :: ana_type = -1
117 LOGICAL :: print_diel_const_traj = .true.
118 ! squared dipoles per volume
119 REAL(kind=dp) :: mu2_pv_s = 0.0_dp
120 ! dipole per square root ov volume per direction
121 REAL(kind=dp), DIMENSION(:), POINTER :: mu_psv => null(), mu_pv => null(), mu2_pv => null()
122 ! dipole dipole correlation matrix (per volume)
123 REAL(kind=dp), DIMENSION(:, :), POINTER :: mu2_pv_mat => null()
124
125 END TYPE dipole_analysis_type
126
127 TYPE displacement_type
128 INTEGER :: conf_counter = 0
129 REAL(kind=dp) :: disp = 0.0_dp
130 LOGICAL :: print_disp = .true.
131 END TYPE displacement_type
132
133CONTAINS
134
135! **************************************************************************************************
136!> \brief creates a new structure environment for TMC analysis
137!> \param tmc_ana structure with parameters for TMC analysis
138!> \author Mandes 02.2013
139! **************************************************************************************************
140 SUBROUTINE tmc_ana_env_create(tmc_ana)
141 TYPE(tmc_analysis_env), POINTER :: tmc_ana
142
143 cpassert(.NOT. ASSOCIATED(tmc_ana))
144
145 ALLOCATE (tmc_ana)
146
147 END SUBROUTINE tmc_ana_env_create
148
149! **************************************************************************************************
150!> \brief releases the structure environment for TMC analysis
151!> \param tmc_ana structure with parameters for TMC analysis
152!> \author Mandes 02.2013
153! **************************************************************************************************
154 SUBROUTINE tmc_ana_env_release(tmc_ana)
155 TYPE(tmc_analysis_env), POINTER :: tmc_ana
156
157 cpassert(ASSOCIATED(tmc_ana))
158
159 IF (ASSOCIATED(tmc_ana%dirs)) THEN
160 DEALLOCATE (tmc_ana%dirs)
161 END IF
162
163 IF (ASSOCIATED(tmc_ana%density_3d)) THEN
164 CALL tmc_ana_dens_release(tmc_ana%density_3d)
165 END IF
166 IF (ASSOCIATED(tmc_ana%pair_correl)) THEN
167 CALL tmc_ana_pair_correl_release(tmc_ana%pair_correl)
168 END IF
169
170 IF (ASSOCIATED(tmc_ana%dip_mom)) THEN
171 CALL tmc_ana_dipole_moment_release(tmc_ana%dip_mom)
172 END IF
173
174 IF (ASSOCIATED(tmc_ana%dip_ana)) THEN
175 CALL tmc_ana_dipole_analysis_release(tmc_ana%dip_ana)
176 END IF
177
178 IF (ASSOCIATED(tmc_ana%displace)) THEN
179 CALL tmc_ana_displacement_release(ana_disp=tmc_ana%displace)
180 END IF
181
182 DEALLOCATE (tmc_ana)
183
184 END SUBROUTINE tmc_ana_env_release
185
186 !============================================================================
187 ! density calculations
188 !============================================================================
189
190! **************************************************************************************************
191!> \brief creates a new structure environment for TMC analysis
192!> \param ana_dens structure with parameters for TMC density analysis
193!> \param nr_bins ...
194!> \author Mandes 02.2013
195! **************************************************************************************************
196 SUBROUTINE tmc_ana_density_create(ana_dens, nr_bins)
197 TYPE(density_3d_type), POINTER :: ana_dens
198 INTEGER, DIMENSION(3) :: nr_bins
199
200 cpassert(.NOT. ASSOCIATED(ana_dens))
201
202 ALLOCATE (ana_dens)
203
204 ana_dens%nr_bins(:) = nr_bins(:)
205
206 ALLOCATE (ana_dens%sum_density(nr_bins(1), nr_bins(2), nr_bins(3)))
207 ALLOCATE (ana_dens%sum_dens2(nr_bins(1), nr_bins(2), nr_bins(3)))
208 ana_dens%sum_density = 0.0_dp
209 ana_dens%sum_dens2 = 0.0_dp
210 END SUBROUTINE tmc_ana_density_create
211
212! **************************************************************************************************
213!> \brief releases the structure environment for TMC analysis
214!> \param ana_dens structure with parameters for TMC analysis
215!> \author Mandes 02.2013
216! **************************************************************************************************
217 SUBROUTINE tmc_ana_dens_release(ana_dens)
218 TYPE(density_3d_type), POINTER :: ana_dens
219
220 cpassert(ASSOCIATED(ana_dens))
221
222 DEALLOCATE (ana_dens%sum_density)
223 DEALLOCATE (ana_dens%sum_dens2)
224 DEALLOCATE (ana_dens)
225 END SUBROUTINE tmc_ana_dens_release
226
227 !============================================================================
228 ! radial distribution function
229 !============================================================================
230
231! **************************************************************************************************
232!> \brief creates a new structure environment for TMC analysis
233!> \param ana_pair_correl ...
234!> \param nr_bins ...
235!> \param
236!> \author Mandes 02.2013
237! **************************************************************************************************
238 SUBROUTINE tmc_ana_pair_correl_create(ana_pair_correl, nr_bins)
239 TYPE(pair_correl_type), POINTER :: ana_pair_correl
240 INTEGER :: nr_bins
241
242 cpassert(.NOT. ASSOCIATED(ana_pair_correl))
243 ALLOCATE (ana_pair_correl)
244
245 ana_pair_correl%nr_bins = nr_bins
246 END SUBROUTINE tmc_ana_pair_correl_create
247
248! **************************************************************************************************
249!> \brief releases the structure environment for TMC analysis
250!> \param ana_pair_correl ...
251!> \param
252!> \author Mandes 02.2013
253! **************************************************************************************************
254 SUBROUTINE tmc_ana_pair_correl_release(ana_pair_correl)
255 TYPE(pair_correl_type), POINTER :: ana_pair_correl
256
257 cpassert(ASSOCIATED(ana_pair_correl))
258
259 DEALLOCATE (ana_pair_correl%g_r)
260 DEALLOCATE (ana_pair_correl%pairs)
261 DEALLOCATE (ana_pair_correl)
262 END SUBROUTINE tmc_ana_pair_correl_release
263
264! **************************************************************************************************
265!> \brief search the pair of two atom types in list
266!> \param pair_list ...
267!> \param n1 atom names
268!> \param n2 atom names
269!> \param list_end ...
270!> \return ...
271!> \author Mandes 02.2013
272! **************************************************************************************************
273 FUNCTION search_pair_in_list(pair_list, n1, n2, list_end) RESULT(ind)
274 TYPE(atom_pairs_type), DIMENSION(:), POINTER :: pair_list
275 CHARACTER(LEN=default_string_length) :: n1, n2
276 INTEGER, OPTIONAL :: list_end
277 INTEGER :: ind
278
279 INTEGER :: last, list_nr
280
281 cpassert(ASSOCIATED(pair_list))
282 IF (PRESENT(list_end)) THEN
283 cpassert(list_end <= SIZE(pair_list))
284 last = list_end
285 ELSE
286 last = SIZE(pair_list)
287 END IF
288
289 ind = -1
290
291 list_search: DO list_nr = 1, last
292 IF ((pair_list(list_nr)%f_n == n1 .AND. &
293 pair_list(list_nr)%s_n == n2) .OR. &
294 (pair_list(list_nr)%f_n == n2 .AND. &
295 pair_list(list_nr)%s_n == n1)) THEN
296 ind = list_nr
297 EXIT list_search
298 END IF
299 END DO list_search
300 END FUNCTION search_pair_in_list
301
302 !============================================================================
303 ! classical cell dipole moment
304 !============================================================================
305
306! **************************************************************************************************
307!> \brief creates a new structure environment for TMC analysis
308!> \param ana_dip_mom ...
309!> \param charge_atm ...
310!> \param charge ...
311!> \param dim_per_elem ...
312!> \param
313!> \author Mandes 02.2013
314! **************************************************************************************************
315 SUBROUTINE tmc_ana_dipole_moment_create(ana_dip_mom, charge_atm, charge, &
316 dim_per_elem)
317 TYPE(dipole_moment_type), POINTER :: ana_dip_mom
318 CHARACTER(LEN=default_string_length), POINTER :: charge_atm(:)
319 REAL(kind=dp), POINTER :: charge(:)
320 INTEGER :: dim_per_elem
321
322 INTEGER :: i
323
324 cpassert(.NOT. ASSOCIATED(ana_dip_mom))
325 ALLOCATE (ana_dip_mom)
326
327 ALLOCATE (ana_dip_mom%charges_inp(SIZE(charge)))
328 DO i = 1, SIZE(charge)
329 ana_dip_mom%charges_inp(i)%name = charge_atm(i)
330 ana_dip_mom%charges_inp(i)%mass = charge(i)
331 END DO
332
333 ALLOCATE (ana_dip_mom%last_dip_cl(dim_per_elem))
334 ! still the initialization routine has to be called
335
336 END SUBROUTINE tmc_ana_dipole_moment_create
337
338! **************************************************************************************************
339!> \brief releases the structure environment for TMC analysis
340!> \param ana_dip_mom ...
341!> \param
342!> \author Mandes 02.2013
343! **************************************************************************************************
344 SUBROUTINE tmc_ana_dipole_moment_release(ana_dip_mom)
345 TYPE(dipole_moment_type), POINTER :: ana_dip_mom
346
347 cpassert(ASSOCIATED(ana_dip_mom))
348
349 IF (ASSOCIATED(ana_dip_mom%charges_inp)) DEALLOCATE (ana_dip_mom%charges_inp)
350 IF (ASSOCIATED(ana_dip_mom%charges)) DEALLOCATE (ana_dip_mom%charges)
351 DEALLOCATE (ana_dip_mom%last_dip_cl)
352 DEALLOCATE (ana_dip_mom)
353 END SUBROUTINE tmc_ana_dipole_moment_release
354
355! **************************************************************************************************
356!> \brief creates a new structure environment for TMC analysis
357!> \param ana_dip_ana ...
358!> \param
359!> \author Mandes 02.2013
360! **************************************************************************************************
361 SUBROUTINE tmc_ana_dipole_analysis_create(ana_dip_ana)
362 TYPE(dipole_analysis_type), POINTER :: ana_dip_ana
363
364 cpassert(.NOT. ASSOCIATED(ana_dip_ana))
365 ALLOCATE (ana_dip_ana)
366
367 ALLOCATE (ana_dip_ana%mu_psv(3))
368 ana_dip_ana%mu_psv = 0.0_dp
369 ALLOCATE (ana_dip_ana%mu_pv(3))
370 ana_dip_ana%mu_pv = 0.0_dp
371 ALLOCATE (ana_dip_ana%mu2_pv(3))
372 ana_dip_ana%mu2_pv = 0.0_dp
373 ALLOCATE (ana_dip_ana%mu2_pv_mat(3, 3))
374 ana_dip_ana%mu2_pv_mat = 0.0_dp
375 END SUBROUTINE tmc_ana_dipole_analysis_create
376
377! **************************************************************************************************
378!> \brief releases the structure environment for TMC analysis
379!> \param ana_dip_ana ...
380!> \param
381!> \author Mandes 02.2013
382! **************************************************************************************************
383 SUBROUTINE tmc_ana_dipole_analysis_release(ana_dip_ana)
384 TYPE(dipole_analysis_type), POINTER :: ana_dip_ana
385
386 cpassert(ASSOCIATED(ana_dip_ana))
387
388 DEALLOCATE (ana_dip_ana%mu_psv)
389 DEALLOCATE (ana_dip_ana%mu_pv)
390 DEALLOCATE (ana_dip_ana%mu2_pv)
391 DEALLOCATE (ana_dip_ana%mu2_pv_mat)
392
393 DEALLOCATE (ana_dip_ana)
394 END SUBROUTINE tmc_ana_dipole_analysis_release
395
396 !============================================================================
397 ! particle displacement in cell (from one configuration to the next)
398 !============================================================================
399
400! **************************************************************************************************
401!> \brief creates a new structure environment for TMC analysis
402!> \param ana_disp ...
403!> \param dim_per_elem ...
404!> \param
405!> \author Mandes 02.2013
406! **************************************************************************************************
407 SUBROUTINE tmc_ana_displacement_create(ana_disp, dim_per_elem)
408 TYPE(displacement_type), POINTER :: ana_disp
409 INTEGER :: dim_per_elem
410
411 cpassert(.NOT. ASSOCIATED(ana_disp))
412 cpassert(dim_per_elem > 0)
413 mark_used(dim_per_elem)
414
415 ALLOCATE (ana_disp)
416
417 END SUBROUTINE tmc_ana_displacement_create
418
419! **************************************************************************************************
420!> \brief releases a structure environment for TMC analysis
421!> \param ana_disp ...
422!> \param
423!> \author Mandes 02.2013
424! **************************************************************************************************
425 SUBROUTINE tmc_ana_displacement_release(ana_disp)
426 TYPE(displacement_type), POINTER :: ana_disp
427
428 cpassert(ASSOCIATED(ana_disp))
429
430 DEALLOCATE (ana_disp)
431 END SUBROUTINE tmc_ana_displacement_release
432END MODULE tmc_analysis_types
Handles all functions related to the CELL.
Definition cell_types.F:15
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
integer, parameter, public default_path_length
Definition kinds.F:58
module provides variables for the TMC analysis tool
integer function, public search_pair_in_list(pair_list, n1, n2, list_end)
search the pair of two atom types in list
subroutine, public tmc_ana_displacement_create(ana_disp, dim_per_elem)
creates a new structure environment for TMC analysis
subroutine, public tmc_ana_dipole_analysis_create(ana_dip_ana)
creates a new structure environment for TMC analysis
subroutine, public tmc_ana_dipole_moment_create(ana_dip_mom, charge_atm, charge, dim_per_elem)
creates a new structure environment for TMC analysis
subroutine, public tmc_ana_env_create(tmc_ana)
creates a new structure environment for TMC analysis
subroutine, public tmc_ana_env_release(tmc_ana)
releases the structure environment for TMC analysis
integer, parameter, public ana_type_default
integer, parameter, public ana_type_ice
character(len=default_path_length), parameter, public tmc_ana_pair_correl_file_name
character(len=default_path_length), parameter, public tmc_ana_density_file_name
integer, parameter, public ana_type_sym_xyz
subroutine, public tmc_ana_density_create(ana_dens, nr_bins)
creates a new structure environment for TMC analysis
subroutine, public tmc_ana_pair_correl_create(ana_pair_correl, nr_bins)
creates a new structure environment for TMC analysis
module handles definition of the tree nodes for the global and
module handles definition of the tree nodes for the global and
Definition tmc_types.F:34
Type defining parameters related to the simulation cell.
Definition cell_types.F:60