Line data Source code
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 Initialize the collective variables types
10 : !> \par History
11 : !> 5.2004 created [fawzi and alessandro]
12 : !> 1.2009 Fabio Sterpone : added the population COLVAR
13 : !> \author Teodoro Laino
14 : ! **************************************************************************************************
15 : MODULE colvar_types
16 :
17 : USE input_section_types, ONLY: section_vals_type
18 : USE kinds, ONLY: default_path_length,&
19 : default_string_length,&
20 : dp
21 : USE particle_types, ONLY: particle_type
22 : #include "../base/base_uses.f90"
23 :
24 : IMPLICIT NONE
25 :
26 : PRIVATE
27 :
28 : CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'colvar_types'
29 :
30 : INTEGER, PARAMETER, PUBLIC :: plane_def_atoms = 0, &
31 : plane_def_vec = 1
32 :
33 : INTEGER, PARAMETER, PUBLIC :: do_clv_geo_center = 0, &
34 : do_clv_fix_point = 1, &
35 : do_clv_xyz = 0, &
36 : do_clv_x = 1, &
37 : do_clv_y = 2, &
38 : do_clv_z = 3, &
39 : do_clv_xy = 4, &
40 : do_clv_xz = 5, &
41 : do_clv_yz = 6
42 : PUBLIC :: colvar_type, &
43 : colvar_p_type, &
44 : colvar_p_reallocate, &
45 : colvar_p_release, &
46 : colvar_create, &
47 : colvar_clone, &
48 : colvar_setup, &
49 : colvar_release, &
50 : colvar_counters, &
51 : eval_point_der, &
52 : eval_point_pos, &
53 : eval_point_mass, &
54 : diff_colvar
55 :
56 : INTEGER, PARAMETER, PUBLIC :: no_colvar_id = -2, &
57 : dist_colvar_id = 1, &
58 : coord_colvar_id = 2, &
59 : torsion_colvar_id = 3, &
60 : angle_colvar_id = 4, &
61 : plane_distance_colvar_id = 5, &
62 : rotation_colvar_id = 6, &
63 : dfunct_colvar_id = 7, &
64 : qparm_colvar_id = 8, &
65 : hydronium_shell_colvar_id = 9, &
66 : reaction_path_colvar_id = 10, &
67 : combine_colvar_id = 11, &
68 : population_colvar_id = 12, &
69 : plane_plane_angle_colvar_id = 13, &
70 : gyration_colvar_id = 14, &
71 : rmsd_colvar_id = 15, &
72 : distance_from_path_colvar_id = 16, &
73 : xyz_diag_colvar_id = 17, &
74 : xyz_outerdiag_colvar_id = 18, &
75 : u_colvar_id = 19, &
76 : Wc_colvar_id = 20, &
77 : hbp_colvar_id = 21, &
78 : ring_puckering_colvar_id = 22, &
79 : mindist_colvar_id = 23, &
80 : acid_hyd_dist_colvar_id = 24, &
81 : acid_hyd_shell_colvar_id = 25, &
82 : hydronium_dist_colvar_id = 26
83 :
84 : ! **************************************************************************************************
85 : !> \brief parameters for the distance collective variable
86 : !> \param i_at ,j_at: indexes of the two atoms between which you calculate
87 : !> the distance
88 : !> \author alessandro laio and fawzi mohamed
89 : ! **************************************************************************************************
90 : TYPE dist_colvar_type
91 : INTEGER :: i_at = 0, j_at = 0, axis_id = 0
92 : LOGICAL :: sign_d = .FALSE.
93 : END TYPE dist_colvar_type
94 :
95 : ! **************************************************************************************************
96 : TYPE coord_colvar_type
97 : LOGICAL :: do_chain = .FALSE., use_kinds_from = .FALSE., use_kinds_to = .FALSE., &
98 : use_kinds_to_b = .FALSE.
99 : INTEGER :: n_atoms_to = 0, &
100 : n_atoms_from = 0, &
101 : nncrd = 0, &
102 : ndcrd = 0, &
103 : n_atoms_to_b = 0, &
104 : nncrd_b = 0, &
105 : ndcrd_b = 0
106 : INTEGER, POINTER, DIMENSION(:) :: i_at_from => NULL(), &
107 : i_at_to => NULL(), &
108 : i_at_to_b => NULL()
109 : CHARACTER(LEN=default_string_length), DIMENSION(:), POINTER :: c_kinds_from => NULL(), &
110 : c_kinds_to => NULL(), &
111 : c_kinds_to_b => NULL()
112 : REAL(KIND=dp) :: r_0 = 0.0_dp, r_0_b = 0.0_dp
113 : END TYPE coord_colvar_type
114 :
115 : ! **************************************************************************************************
116 : TYPE population_colvar_type
117 : LOGICAL :: use_kinds_from = .FALSE., use_kinds_to = .FALSE.
118 : INTEGER :: n_atoms_to = 0, &
119 : n_atoms_from = 0, &
120 : nncrd = 0, &
121 : ndcrd = 0, &
122 : n0 = 0
123 : INTEGER, POINTER, DIMENSION(:) :: i_at_from => NULL(), &
124 : i_at_to => NULL()
125 : CHARACTER(LEN=default_string_length), DIMENSION(:), POINTER :: c_kinds_from => NULL(), &
126 : c_kinds_to => NULL()
127 : REAL(KIND=dp) :: r_0 = 0.0_dp, sigma = 0.0_dp
128 : END TYPE population_colvar_type
129 :
130 : ! **************************************************************************************************
131 : TYPE gyration_colvar_type
132 : LOGICAL :: use_kinds = .FALSE.
133 : INTEGER :: n_atoms = 0
134 : INTEGER, POINTER, DIMENSION(:) :: i_at => NULL()
135 : CHARACTER(LEN=default_string_length), DIMENSION(:), POINTER :: c_kinds => NULL()
136 : END TYPE gyration_colvar_type
137 :
138 : ! **************************************************************************************************
139 : TYPE torsion_colvar_type
140 : REAL(KIND=dp) :: o0 = 0.0_dp
141 : INTEGER, DIMENSION(4) :: i_at_tors = 0
142 : END TYPE torsion_colvar_type
143 :
144 : ! **************************************************************************************************
145 : TYPE plane_distance_colvar_type
146 : LOGICAL :: use_pbc = .FALSE.
147 : INTEGER, DIMENSION(3) :: plane = -1
148 : INTEGER :: point = -1
149 : END TYPE plane_distance_colvar_type
150 :
151 : ! **************************************************************************************************
152 : TYPE plane_def_type
153 : INTEGER :: type_of_def = -1
154 : INTEGER, DIMENSION(3) :: points = 0
155 : REAL(KIND=dp), DIMENSION(3) :: normal_vec = 0.0_dp
156 : END TYPE plane_def_type
157 :
158 : TYPE plane_plane_angle_colvar_type
159 : TYPE(plane_def_type) :: plane1 = plane_def_type(), plane2 = plane_def_type()
160 : END TYPE plane_plane_angle_colvar_type
161 :
162 : ! **************************************************************************************************
163 : TYPE angle_colvar_type
164 : INTEGER, DIMENSION(3) :: i_at_angle = 0
165 : END TYPE angle_colvar_type
166 :
167 : ! **************************************************************************************************
168 : TYPE rotation_colvar_type
169 : INTEGER :: i_at1_bond1 = 0, &
170 : i_at2_bond1 = 0, &
171 : i_at1_bond2 = 0, &
172 : i_at2_bond2 = 0
173 : END TYPE rotation_colvar_type
174 :
175 : ! **************************************************************************************************
176 : TYPE dfunct_colvar_type
177 : INTEGER, DIMENSION(4) :: i_at_dfunct = 0
178 : LOGICAL :: use_pbc = .FALSE.
179 : REAL(KIND=dp) :: coeff = 0.0_dp
180 : END TYPE dfunct_colvar_type
181 :
182 : ! **************************************************************************************************
183 : TYPE qparm_colvar_type
184 : INTEGER :: l = 0
185 : INTEGER :: n_atoms_to = 0, &
186 : n_atoms_from = 0
187 : INTEGER, POINTER, DIMENSION(:) :: i_at_from => NULL(), &
188 : i_at_to => NULL()
189 : REAL(KIND=dp) :: rcut = 0.0_dp, rstart = 0.0_dp
190 : LOGICAL :: include_images = .FALSE.
191 : END TYPE qparm_colvar_type
192 :
193 : ! **************************************************************************************************
194 : TYPE hydronium_shell_colvar_type
195 : INTEGER :: n_oxygens = -1, &
196 : n_hydrogens = -1, &
197 : poh = -1, qoh = -1, poo = -1, qoo = -1, &
198 : pm = -1, qm = -1
199 : INTEGER, POINTER, DIMENSION(:) :: i_oxygens => NULL(), &
200 : i_hydrogens => NULL()
201 : REAL(KIND=dp) :: roo = 0.0_dp, roh = 0.0_dp, lambda = 0.0_dp, nh = 0.0_dp
202 : END TYPE hydronium_shell_colvar_type
203 :
204 : ! **************************************************************************************************
205 : TYPE hydronium_dist_colvar_type
206 : INTEGER :: n_oxygens = -1, &
207 : n_hydrogens = -1, &
208 : poh = -1, qoh = -1, &
209 : pf = -1, qf = -1, pm = -1, qm = -1
210 : INTEGER, POINTER, DIMENSION(:) :: i_oxygens => NULL(), &
211 : i_hydrogens => NULL()
212 : REAL(KIND=dp) :: roh = 0.0_dp, lambda = 0.0_dp, nh = 0.0_dp, nn = 0.0_dp
213 : END TYPE hydronium_dist_colvar_type
214 :
215 : ! **************************************************************************************************
216 : TYPE acid_hyd_dist_colvar_type
217 : INTEGER :: n_oxygens_water = -1, &
218 : n_oxygens_acid = -1, &
219 : n_hydrogens = -1, &
220 : pwoh = -1, qwoh = -1, paoh = -1, qaoh = -1, pcut = -1, qcut = -1
221 : INTEGER, POINTER, DIMENSION(:) :: i_oxygens_water => NULL(), i_oxygens_acid => NULL(), &
222 : i_hydrogens => NULL()
223 : REAL(KIND=dp) :: rwoh = 0.0_dp, raoh = 0.0_dp, lambda = 0.0_dp, nc = 0.0_dp
224 : END TYPE acid_hyd_dist_colvar_type
225 :
226 : ! **************************************************************************************************
227 : TYPE acid_hyd_shell_colvar_type
228 : INTEGER :: n_oxygens_water = -1, &
229 : n_oxygens_acid = -1, &
230 : n_hydrogens = -1, &
231 : pwoh = -1, qwoh = -1, paoh = -1, qaoh = -1, &
232 : poo = -1, qoo = -1, pcut = -1, qcut = -1, pm = -1, qm = -1
233 : INTEGER, POINTER, DIMENSION(:) :: i_oxygens_water => NULL(), i_oxygens_acid => NULL(), &
234 : i_hydrogens => NULL()
235 : REAL(KIND=dp) :: rwoh = 0.0_dp, raoh = 0.0_dp, roo = 0.0_dp, lambda = 0.0_dp, nc = 0.0_dp, nh = 0.0_dp
236 : END TYPE acid_hyd_shell_colvar_type
237 :
238 : ! **************************************************************************************************
239 : TYPE reaction_path_colvar_type
240 : INTEGER :: type_id = -1
241 : INTEGER :: n_components = -1, nr_frames = -1, subset = -1
242 : INTEGER, DIMENSION(2) :: function_bounds = -1
243 : INTEGER, POINTER, DIMENSION(:) :: i_rmsd => NULL()
244 : LOGICAL :: align_frames = .FALSE., dist_rmsd = .FALSE., rmsd = .FALSE.
245 : REAL(KIND=dp), DIMENSION(:, :), POINTER :: f_vals => NULL()
246 : REAL(KIND=dp), DIMENSION(:, :), POINTER :: r_ref => NULL()
247 : REAL(KIND=dp) :: lambda = 0.0_dp
248 : REAL(KIND=dp) :: step_size = 0.0_dp
249 : TYPE(colvar_p_type), POINTER, DIMENSION(:) :: colvar_p => NULL()
250 : END TYPE reaction_path_colvar_type
251 :
252 : ! **************************************************************************************************
253 : TYPE combine_colvar_type
254 : INTEGER :: type_id = -1
255 : TYPE(colvar_p_type), POINTER, DIMENSION(:) :: colvar_p => NULL()
256 : REAL(KIND=dp) :: lerr = 0.0_dp, dx = 0.0_dp
257 : CHARACTER(LEN=default_path_length) :: FUNCTION = ""
258 : CHARACTER(LEN=default_string_length), &
259 : DIMENSION(:), POINTER :: c_parameters => NULL(), variables => NULL()
260 : REAL(KIND=dp), DIMENSION(:), POINTER :: v_parameters => NULL()
261 : END TYPE combine_colvar_type
262 : ! **************************************************************************************************
263 : TYPE rmsd_colvar_type
264 : INTEGER :: n_atoms = 0, nr_frames = 0, subset = 0
265 : INTEGER, POINTER, DIMENSION(:) :: i_rmsd => NULL()
266 : LOGICAL :: align_frames = .FALSE.
267 : REAL(KIND=dp), DIMENSION(:), POINTER :: weights => NULL()
268 : REAL(KIND=dp), DIMENSION(:, :), POINTER :: r_ref => NULL()
269 : END TYPE rmsd_colvar_type
270 :
271 : ! **************************************************************************************************
272 : TYPE point_type
273 : INTEGER :: type_id = -1
274 : INTEGER, DIMENSION(:), POINTER :: atoms => NULL()
275 : REAL(KIND=dp), DIMENSION(:), POINTER :: weights => NULL()
276 : REAL(KIND=dp), DIMENSION(3) :: r = 0.0_dp
277 : END TYPE point_type
278 :
279 : ! **************************************************************************************************
280 : TYPE xyz_diag_colvar_type
281 : LOGICAL :: use_pbc = .FALSE.
282 : LOGICAL :: use_absolute_position = .FALSE.
283 : INTEGER :: i_atom = 0
284 : INTEGER :: component = 0
285 : REAL(KIND=dp), DIMENSION(3) :: r0 = 0.0_dp
286 : END TYPE xyz_diag_colvar_type
287 :
288 : ! **************************************************************************************************
289 : TYPE xyz_outerdiag_colvar_type
290 : LOGICAL :: use_pbc = .FALSE.
291 : INTEGER, DIMENSION(2) :: i_atoms = 0
292 : INTEGER, DIMENSION(2) :: components = 0
293 : REAL(KIND=dp), DIMENSION(3, 2) :: r0 = 0.0_dp
294 : END TYPE xyz_outerdiag_colvar_type
295 :
296 : ! **************************************************************************************************
297 : TYPE u_colvar_type
298 : TYPE(section_vals_type), POINTER :: mixed_energy_section => NULL()
299 : INTEGER :: natom = -1
300 : END TYPE u_colvar_type
301 :
302 : ! **************************************************************************************************
303 : TYPE Wc_colvar_type
304 : INTEGER :: ids(3) = -1 ! first is the Od, second the H, third the Oa
305 : REAL(KIND=dp) :: ewc = 0.0_dp
306 : REAL(KIND=dp) :: rcut = 0.0_dp
307 : END TYPE Wc_colvar_type
308 :
309 : ! **************************************************************************************************
310 : TYPE HBP_colvar_type
311 : INTEGER :: nPoints = -1 ! number of the points in the path
312 : INTEGER, POINTER :: ids(:, :) => NULL() ! first is the Od, second the H,
313 : ! third the Oa and contains a row for each intermediate point in the path
314 : REAL(KIND=dp), POINTER :: ewc(:) => NULL() ! one for each point in the path
315 : REAL(KIND=dp) :: rcut = 0.0_dp
316 : REAL(KIND=dp) :: shift = 0.0_dp ! shift applied for each term in the collective variable
317 : END TYPE HBP_colvar_type
318 :
319 : ! **************************************************************************************************
320 : TYPE ring_puckering_colvar_type
321 : INTEGER :: nring = -1
322 : INTEGER, POINTER, DIMENSION(:) :: atoms => NULL()
323 : INTEGER :: iq = -1
324 : END TYPE ring_puckering_colvar_type
325 :
326 : ! **************************************************************************************************
327 : TYPE mindist_colvar_type
328 : LOGICAL :: use_kinds_from = .FALSE., use_kinds_to = .FALSE.
329 : INTEGER :: n_coord_to = 0, &
330 : n_coord_from = 0, &
331 : n_dist_from = 0, &
332 : p_exp = 0, &
333 : q_exp = 0
334 : INTEGER, POINTER, DIMENSION(:) :: i_coord_from => NULL(), &
335 : i_coord_to => NULL(), &
336 : i_dist_from => NULL()
337 : CHARACTER(LEN=default_string_length), DIMENSION(:), POINTER :: k_coord_from => NULL(), &
338 : k_coord_to => NULL()
339 : REAL(KIND=dp) :: lambda = 0.0_dp, r_cut = 0.0_dp
340 : END TYPE mindist_colvar_type
341 :
342 : ! **************************************************************************************************
343 : !> \brief parameters for a collective variable
344 : !> \author alessandro laio and fawzi mohamed
345 : ! **************************************************************************************************
346 : TYPE colvar_type
347 : INTEGER :: type_id = -1
348 : LOGICAL :: use_points = .FALSE.
349 : REAL(kind=dp) :: ss = 0.0_dp ! Value of the colvar
350 : REAL(kind=dp), DIMENSION(:, :), POINTER :: dsdr => NULL() ! Derivative of colvar (3,:)
351 : INTEGER, DIMENSION(:), POINTER :: i_atom => NULL() ! Mapping of dsdr
352 : INTEGER :: n_atom_s = -1
353 : ! Available COLVAR types
354 : TYPE(dist_colvar_type), POINTER :: dist_param => NULL()
355 : TYPE(coord_colvar_type), POINTER :: coord_param => NULL()
356 : TYPE(population_colvar_type), POINTER :: population_param => NULL()
357 : TYPE(gyration_colvar_type), POINTER :: gyration_param => NULL()
358 : TYPE(torsion_colvar_type), POINTER :: torsion_param => NULL()
359 : TYPE(angle_colvar_type), POINTER :: angle_param => NULL()
360 : TYPE(plane_distance_colvar_type), POINTER :: plane_distance_param => NULL()
361 : TYPE(plane_plane_angle_colvar_type), POINTER :: plane_plane_angle_param => NULL()
362 : TYPE(rotation_colvar_type), POINTER :: rotation_param => NULL()
363 : TYPE(dfunct_colvar_type), POINTER :: dfunct_param => NULL()
364 : TYPE(qparm_colvar_type), POINTER :: qparm_param => NULL()
365 : TYPE(hydronium_shell_colvar_type), POINTER :: hydronium_shell_param => NULL()
366 : TYPE(hydronium_dist_colvar_type), POINTER :: hydronium_dist_param => NULL()
367 : TYPE(acid_hyd_dist_colvar_type), POINTER :: acid_hyd_dist_param => NULL()
368 : TYPE(acid_hyd_shell_colvar_type), POINTER :: acid_hyd_shell_param => NULL()
369 : TYPE(reaction_path_colvar_type), POINTER :: reaction_path_param => NULL()
370 : TYPE(combine_colvar_type), POINTER :: combine_cvs_param => NULL()
371 : TYPE(rmsd_colvar_type), POINTER :: rmsd_param => NULL()
372 : TYPE(xyz_diag_colvar_type), POINTER :: xyz_diag_param => NULL()
373 : TYPE(xyz_outerdiag_colvar_type), POINTER :: xyz_outerdiag_param => NULL()
374 : TYPE(u_colvar_type), POINTER :: u_param => NULL()
375 : TYPE(point_type), DIMENSION(:), POINTER :: points => NULL()
376 : TYPE(Wc_colvar_type), POINTER :: Wc => NULL()
377 : TYPE(HBP_colvar_type), POINTER :: HBP => NULL()
378 : TYPE(ring_puckering_colvar_type), POINTER :: ring_puckering_param => NULL()
379 : TYPE(mindist_colvar_type), POINTER :: mindist_param => NULL()
380 : END TYPE colvar_type
381 :
382 : ! **************************************************************************************************
383 : TYPE colvar_p_type
384 : TYPE(colvar_type), POINTER :: colvar => NULL()
385 : END TYPE colvar_p_type
386 :
387 : ! **************************************************************************************************
388 : TYPE colvar_counters
389 : INTEGER :: ndist = 0
390 : INTEGER :: nangle = 0
391 : INTEGER :: ntorsion = 0
392 : INTEGER :: ncoord = 0
393 : INTEGER :: nplane_dist = 0
394 : INTEGER :: nplane_angle = 0
395 : INTEGER :: nrot = 0
396 : INTEGER :: ndfunct = 0
397 : INTEGER :: nqparm = 0
398 : INTEGER :: nhydronium_shell = 0
399 : INTEGER :: nhydronium_dist = 0
400 : INTEGER :: nacid_hyd_dist = 0
401 : INTEGER :: nacid_hyd_shell = 0
402 : INTEGER :: nreactionpath = 0
403 : INTEGER :: ncombinecvs = 0
404 : INTEGER :: nrestraint = 0
405 : INTEGER :: npopulation = 0
406 : INTEGER :: ngyration = 0
407 : INTEGER :: nxyz_diag = 0
408 : INTEGER :: nxyz_outerdiag = 0
409 : INTEGER :: ntot = 0
410 : END TYPE colvar_counters
411 :
412 : CONTAINS
413 :
414 : ! **************************************************************************************************
415 : !> \brief initializes a colvar_param type
416 : !> \param colvar the colvat to initialize
417 : !> \param colvar_id ...
418 : !> \author alessandro laio and fawzi mohamed
419 : ! **************************************************************************************************
420 5676 : SUBROUTINE colvar_create(colvar, colvar_id)
421 : TYPE(colvar_type), POINTER :: colvar
422 : INTEGER, INTENT(in) :: colvar_id
423 :
424 5676 : CPASSERT(.NOT. ASSOCIATED(colvar))
425 5676 : ALLOCATE (colvar)
426 5676 : colvar%type_id = colvar_id
427 : colvar%use_points = .FALSE.
428 5000 : SELECT CASE (colvar_id)
429 : CASE (dist_colvar_id)
430 5000 : ALLOCATE (colvar%dist_param)
431 : colvar%dist_param%axis_id = do_clv_xyz
432 5000 : colvar%dist_param%sign_d = .FALSE.
433 : CASE (coord_colvar_id)
434 60 : ALLOCATE (colvar%coord_param)
435 : CASE (population_colvar_id)
436 8 : ALLOCATE (colvar%population_param)
437 : CASE (gyration_colvar_id)
438 2 : ALLOCATE (colvar%gyration_param)
439 : CASE (angle_colvar_id)
440 1100 : ALLOCATE (colvar%angle_param)
441 : CASE (torsion_colvar_id)
442 960 : ALLOCATE (colvar%torsion_param)
443 : CASE (plane_distance_colvar_id)
444 140 : ALLOCATE (colvar%plane_distance_param)
445 : CASE (plane_plane_angle_colvar_id)
446 272 : ALLOCATE (colvar%plane_plane_angle_param)
447 : CASE (rotation_colvar_id)
448 2 : ALLOCATE (colvar%rotation_param)
449 : CASE (dfunct_colvar_id)
450 108 : ALLOCATE (colvar%dfunct_param)
451 : CASE (qparm_colvar_id)
452 2 : ALLOCATE (colvar%qparm_param)
453 : CASE (xyz_diag_colvar_id)
454 150 : ALLOCATE (colvar%xyz_diag_param)
455 : ! Initialize r0 with dummy..
456 120 : colvar%xyz_diag_param%r0 = HUGE(0.0_dp)
457 : CASE (xyz_outerdiag_colvar_id)
458 480 : ALLOCATE (colvar%xyz_outerdiag_param)
459 : ! Initialize r0 with dummy..
460 270 : colvar%xyz_outerdiag_param%r0 = HUGE(0.0_dp)
461 : CASE (u_colvar_id)
462 6 : ALLOCATE (colvar%u_param)
463 6 : NULLIFY (colvar%u_param%mixed_energy_section)
464 : CASE (hydronium_shell_colvar_id)
465 2 : ALLOCATE (colvar%hydronium_shell_param)
466 : CASE (hydronium_dist_colvar_id)
467 2 : ALLOCATE (colvar%hydronium_dist_param)
468 : CASE (acid_hyd_dist_colvar_id)
469 2 : ALLOCATE (colvar%acid_hyd_dist_param)
470 : CASE (acid_hyd_shell_colvar_id)
471 2 : ALLOCATE (colvar%acid_hyd_shell_param)
472 : CASE (reaction_path_colvar_id)
473 64 : ALLOCATE (colvar%reaction_path_param)
474 : CASE (distance_from_path_colvar_id)
475 32 : ALLOCATE (colvar%reaction_path_param)
476 : CASE (combine_colvar_id)
477 20 : ALLOCATE (colvar%combine_cvs_param)
478 : CASE (rmsd_colvar_id)
479 4 : ALLOCATE (colvar%rmsd_param)
480 : CASE (Wc_colvar_id)
481 0 : ALLOCATE (colvar%Wc)
482 : CASE (HBP_colvar_id)
483 2 : ALLOCATE (colvar%HBP)
484 : CASE (ring_puckering_colvar_id)
485 36 : ALLOCATE (colvar%ring_puckering_param)
486 : CASE (mindist_colvar_id)
487 0 : ALLOCATE (colvar%mindist_param)
488 : CASE (no_colvar_id)
489 : ! Do nothing
490 : CASE DEFAULT
491 5676 : CPABORT("Unknown colvar type")
492 : END SELECT
493 :
494 5676 : END SUBROUTINE colvar_create
495 :
496 : ! **************************************************************************************************
497 : !> \brief Finalize the setup of the collective variable
498 : !> \param colvar the colvar to initialize
499 : !> \author Teodoro Laino, [teo] 09.03.2006
500 : ! **************************************************************************************************
501 5706 : SUBROUTINE colvar_setup(colvar)
502 : TYPE(colvar_type), INTENT(INOUT) :: colvar
503 :
504 : INTEGER :: i, idum, iend, ii, istart, j, np
505 5706 : INTEGER, DIMENSION(:), POINTER :: list
506 :
507 10706 : SELECT CASE (colvar%type_id)
508 : CASE (dist_colvar_id)
509 5000 : np = 2
510 5000 : i = colvar%dist_param%i_at
511 5000 : j = colvar%dist_param%j_at
512 : ! Number of real atoms involved in the colvar
513 : colvar%n_atom_s = COLV_SIZE(colvar, i) + &
514 5000 : COLV_SIZE(colvar, j)
515 : ! Create a List of points...
516 5000 : ALLOCATE (list(np))
517 5000 : list(1) = colvar%dist_param%i_at
518 5000 : list(2) = colvar%dist_param%j_at
519 : CASE (coord_colvar_id)
520 : np = colvar%coord_param%n_atoms_from + colvar%coord_param%n_atoms_to &
521 68 : + colvar%coord_param%n_atoms_to_b
522 : ! Number of real atoms involved in the colvar
523 68 : colvar%n_atom_s = 0
524 130 : DO ii = 1, colvar%coord_param%n_atoms_from
525 62 : i = colvar%coord_param%i_at_from(ii)
526 130 : colvar%n_atom_s = colvar%n_atom_s + COLV_SIZE(colvar, i)
527 : END DO
528 168 : DO ii = 1, colvar%coord_param%n_atoms_to
529 100 : i = colvar%coord_param%i_at_to(ii)
530 168 : colvar%n_atom_s = colvar%n_atom_s + COLV_SIZE(colvar, i)
531 : END DO
532 68 : IF (colvar%coord_param%n_atoms_to_b /= 0) THEN
533 8 : DO ii = 1, colvar%coord_param%n_atoms_to_b
534 4 : i = colvar%coord_param%i_at_to_b(ii)
535 8 : colvar%n_atom_s = colvar%n_atom_s + COLV_SIZE(colvar, i)
536 : END DO
537 : END IF
538 : ! Create a List of points...
539 196 : ALLOCATE (list(np))
540 68 : idum = 0
541 130 : DO ii = 1, colvar%coord_param%n_atoms_from
542 62 : idum = idum + 1
543 62 : i = colvar%coord_param%i_at_from(ii)
544 130 : list(idum) = i
545 : END DO
546 168 : DO ii = 1, colvar%coord_param%n_atoms_to
547 100 : idum = idum + 1
548 100 : i = colvar%coord_param%i_at_to(ii)
549 168 : list(idum) = i
550 : END DO
551 68 : IF (colvar%coord_param%n_atoms_to_b /= 0) THEN
552 8 : DO ii = 1, colvar%coord_param%n_atoms_to_b
553 4 : idum = idum + 1
554 4 : i = colvar%coord_param%i_at_to_b(ii)
555 8 : list(idum) = i
556 : END DO
557 : END IF
558 68 : CPASSERT(idum == np)
559 : CASE (population_colvar_id)
560 16 : np = colvar%population_param%n_atoms_from + colvar%population_param%n_atoms_to
561 : ! Number of real atoms involved in the colvar
562 16 : colvar%n_atom_s = 0
563 32 : DO ii = 1, colvar%population_param%n_atoms_from
564 16 : i = colvar%population_param%i_at_from(ii)
565 32 : colvar%n_atom_s = colvar%n_atom_s + COLV_SIZE(colvar, i)
566 : END DO
567 32 : DO ii = 1, colvar%population_param%n_atoms_to
568 16 : i = colvar%population_param%i_at_to(ii)
569 32 : colvar%n_atom_s = colvar%n_atom_s + COLV_SIZE(colvar, i)
570 : END DO
571 : ! Create a List of points...
572 48 : ALLOCATE (list(np))
573 16 : idum = 0
574 32 : DO ii = 1, colvar%population_param%n_atoms_from
575 16 : idum = idum + 1
576 16 : i = colvar%population_param%i_at_from(ii)
577 32 : list(idum) = i
578 : END DO
579 32 : DO ii = 1, colvar%population_param%n_atoms_to
580 16 : idum = idum + 1
581 16 : i = colvar%population_param%i_at_to(ii)
582 32 : list(idum) = i
583 : END DO
584 16 : CPASSERT(idum == np)
585 : CASE (gyration_colvar_id)
586 4 : np = colvar%gyration_param%n_atoms
587 : ! Number of real atoms involved in the colvar
588 4 : colvar%n_atom_s = 0
589 30 : DO ii = 1, colvar%gyration_param%n_atoms
590 26 : i = colvar%gyration_param%i_at(ii)
591 30 : colvar%n_atom_s = colvar%n_atom_s + COLV_SIZE(colvar, i)
592 : END DO
593 : ! Create a List of points...
594 10 : ALLOCATE (list(np))
595 4 : idum = 0
596 30 : DO ii = 1, colvar%gyration_param%n_atoms
597 26 : idum = idum + 1
598 26 : i = colvar%gyration_param%i_at(ii)
599 30 : list(idum) = i
600 : END DO
601 4 : CPASSERT(idum == np)
602 : CASE (angle_colvar_id)
603 220 : np = 3
604 : ! Number of real atoms involved in the colvar
605 220 : colvar%n_atom_s = 0
606 880 : DO ii = 1, 3
607 660 : i = colvar%angle_param%i_at_angle(ii)
608 880 : colvar%n_atom_s = colvar%n_atom_s + COLV_SIZE(colvar, i)
609 : END DO
610 : ! Create a List of points...
611 220 : ALLOCATE (list(np))
612 220 : idum = 0
613 880 : DO ii = 1, 3
614 660 : idum = idum + 1
615 660 : i = colvar%angle_param%i_at_angle(ii)
616 880 : list(idum) = i
617 : END DO
618 220 : CPASSERT(idum == np)
619 : CASE (torsion_colvar_id)
620 160 : np = 4
621 : ! Number of real atoms involved in the colvar
622 160 : colvar%n_atom_s = 0
623 800 : DO ii = 1, 4
624 640 : i = colvar%torsion_param%i_at_tors(ii)
625 800 : colvar%n_atom_s = colvar%n_atom_s + COLV_SIZE(colvar, i)
626 : END DO
627 : ! Create a List of points...
628 160 : ALLOCATE (list(np))
629 160 : idum = 0
630 800 : DO ii = 1, 4
631 640 : idum = idum + 1
632 640 : i = colvar%torsion_param%i_at_tors(ii)
633 800 : list(idum) = i
634 : END DO
635 160 : CPASSERT(idum == np)
636 : CASE (plane_distance_colvar_id)
637 28 : np = 4
638 : ! Number of real atoms involved in the colvar
639 28 : colvar%n_atom_s = 0
640 112 : DO ii = 1, 3
641 84 : i = colvar%plane_distance_param%plane(ii)
642 112 : colvar%n_atom_s = colvar%n_atom_s + COLV_SIZE(colvar, i)
643 : END DO
644 28 : i = colvar%plane_distance_param%point
645 28 : colvar%n_atom_s = colvar%n_atom_s + COLV_SIZE(colvar, i)
646 : ! Create a List of points...
647 28 : ALLOCATE (list(np))
648 28 : idum = 0
649 112 : DO ii = 1, 3
650 84 : idum = idum + 1
651 84 : i = colvar%plane_distance_param%plane(ii)
652 112 : list(idum) = i
653 : END DO
654 28 : i = colvar%plane_distance_param%point
655 28 : list(4) = i
656 28 : idum = idum + 1
657 28 : CPASSERT(idum == np)
658 : CASE (plane_plane_angle_colvar_id)
659 16 : np = 0
660 16 : IF (colvar%plane_plane_angle_param%plane1%type_of_def == plane_def_atoms) np = np + 3
661 16 : IF (colvar%plane_plane_angle_param%plane2%type_of_def == plane_def_atoms) np = np + 3
662 : ! if np is equal to zero this means that this is not a COLLECTIVE variable..
663 8 : IF (np == 0) THEN
664 : CALL cp_abort(__LOCATION__, &
665 : "PLANE_PLANE_ANGLE Colvar defined using two normal vectors! This is "// &
666 : "not a COLLECTIVE VARIABLE! One of the two planes must be defined "// &
667 0 : "using atomic positions.")
668 : END IF
669 :
670 : ! Number of real atoms involved in the colvar
671 16 : colvar%n_atom_s = 0
672 16 : IF (colvar%plane_plane_angle_param%plane1%type_of_def == plane_def_atoms) THEN
673 64 : DO ii = 1, 3
674 48 : i = colvar%plane_plane_angle_param%plane1%points(ii)
675 64 : colvar%n_atom_s = colvar%n_atom_s + COLV_SIZE(colvar, i)
676 : END DO
677 : END IF
678 16 : IF (colvar%plane_plane_angle_param%plane2%type_of_def == plane_def_atoms) THEN
679 32 : DO ii = 1, 3
680 24 : i = colvar%plane_plane_angle_param%plane2%points(ii)
681 32 : colvar%n_atom_s = colvar%n_atom_s + COLV_SIZE(colvar, i)
682 : END DO
683 : END IF
684 :
685 : ! Create a List of points...
686 32 : ALLOCATE (list(np))
687 16 : idum = 0
688 16 : IF (colvar%plane_plane_angle_param%plane1%type_of_def == plane_def_atoms) THEN
689 64 : DO ii = 1, 3
690 48 : idum = idum + 1
691 48 : i = colvar%plane_plane_angle_param%plane1%points(ii)
692 64 : list(idum) = i
693 : END DO
694 : END IF
695 16 : IF (colvar%plane_plane_angle_param%plane2%type_of_def == plane_def_atoms) THEN
696 32 : DO ii = 1, 3
697 24 : idum = idum + 1
698 24 : i = colvar%plane_plane_angle_param%plane2%points(ii)
699 32 : list(idum) = i
700 : END DO
701 : END IF
702 16 : CPASSERT(idum == np)
703 : CASE (dfunct_colvar_id)
704 18 : np = 4
705 : ! Number of real atoms involved in the colvar
706 18 : colvar%n_atom_s = 0
707 90 : DO ii = 1, 4
708 72 : i = colvar%dfunct_param%i_at_dfunct(ii)
709 90 : colvar%n_atom_s = colvar%n_atom_s + COLV_SIZE(colvar, i)
710 : END DO
711 : ! Create a List of points...
712 18 : ALLOCATE (list(np))
713 18 : idum = 0
714 90 : DO ii = 1, 4
715 72 : idum = idum + 1
716 72 : i = colvar%dfunct_param%i_at_dfunct(ii)
717 90 : list(idum) = i
718 : END DO
719 18 : CPASSERT(idum == np)
720 : CASE (rotation_colvar_id)
721 2 : np = 4
722 : ! Number of real atoms involved in the colvar
723 2 : colvar%n_atom_s = 0
724 2 : i = colvar%rotation_param%i_at1_bond1
725 2 : colvar%n_atom_s = colvar%n_atom_s + COLV_SIZE(colvar, i)
726 2 : i = colvar%rotation_param%i_at2_bond1
727 2 : colvar%n_atom_s = colvar%n_atom_s + COLV_SIZE(colvar, i)
728 2 : i = colvar%rotation_param%i_at1_bond2
729 2 : colvar%n_atom_s = colvar%n_atom_s + COLV_SIZE(colvar, i)
730 2 : i = colvar%rotation_param%i_at2_bond2
731 2 : colvar%n_atom_s = colvar%n_atom_s + COLV_SIZE(colvar, i)
732 : ! Create a List of points...
733 2 : ALLOCATE (list(np))
734 : i = colvar%rotation_param%i_at1_bond1
735 2 : list(1) = i
736 : i = colvar%rotation_param%i_at2_bond1
737 2 : list(2) = i
738 : i = colvar%rotation_param%i_at1_bond2
739 2 : list(3) = i
740 : i = colvar%rotation_param%i_at2_bond2
741 2 : list(4) = i
742 : CASE (qparm_colvar_id)
743 2 : np = colvar%qparm_param%n_atoms_from + colvar%qparm_param%n_atoms_to
744 : ! Number of real atoms involved in the colvar
745 2 : colvar%n_atom_s = 0
746 218 : DO ii = 1, colvar%qparm_param%n_atoms_from
747 216 : i = colvar%qparm_param%i_at_from(ii)
748 218 : colvar%n_atom_s = colvar%n_atom_s + COLV_SIZE(colvar, i)
749 : END DO
750 218 : DO ii = 1, colvar%qparm_param%n_atoms_to
751 216 : i = colvar%qparm_param%i_at_to(ii)
752 218 : colvar%n_atom_s = colvar%n_atom_s + COLV_SIZE(colvar, i)
753 : END DO
754 : ! Create a List of points...
755 6 : ALLOCATE (list(np))
756 2 : idum = 0
757 218 : DO ii = 1, colvar%qparm_param%n_atoms_from
758 216 : idum = idum + 1
759 216 : i = colvar%qparm_param%i_at_from(ii)
760 218 : list(idum) = i
761 : END DO
762 218 : DO ii = 1, colvar%qparm_param%n_atoms_to
763 216 : idum = idum + 1
764 216 : i = colvar%qparm_param%i_at_to(ii)
765 218 : list(idum) = i
766 : END DO
767 2 : CPASSERT(idum == np)
768 : CASE (hydronium_shell_colvar_id)
769 2 : np = colvar%hydronium_shell_param%n_oxygens + colvar%hydronium_shell_param%n_hydrogens
770 6 : ALLOCATE (list(np))
771 2 : CALL setup_hydronium_colvars(colvar, hydronium_shell_colvar_id, list)
772 : CASE (hydronium_dist_colvar_id)
773 2 : np = colvar%hydronium_dist_param%n_oxygens + colvar%hydronium_dist_param%n_hydrogens
774 6 : ALLOCATE (list(np))
775 2 : CALL setup_hydronium_colvars(colvar, hydronium_dist_colvar_id, list)
776 : CASE (acid_hyd_dist_colvar_id)
777 : np = colvar%acid_hyd_dist_param%n_oxygens_water &
778 : + colvar%acid_hyd_dist_param%n_oxygens_acid &
779 2 : + colvar%acid_hyd_dist_param%n_hydrogens
780 6 : ALLOCATE (list(np))
781 2 : CALL setup_acid_hydronium_colvars(colvar, acid_hyd_dist_colvar_id, list)
782 : CASE (acid_hyd_shell_colvar_id)
783 : np = colvar%acid_hyd_shell_param%n_oxygens_water &
784 : + colvar%acid_hyd_shell_param%n_oxygens_acid &
785 2 : + colvar%acid_hyd_shell_param%n_hydrogens
786 6 : ALLOCATE (list(np))
787 2 : CALL setup_acid_hydronium_colvars(colvar, acid_hyd_shell_colvar_id, list)
788 : CASE (rmsd_colvar_id)
789 4 : np = colvar%rmsd_param%n_atoms
790 : ! Number of real atoms involved in the colvar
791 4 : colvar%n_atom_s = 0
792 28 : DO ii = 1, colvar%rmsd_param%n_atoms
793 24 : i = colvar%rmsd_param%i_rmsd(ii)
794 28 : colvar%n_atom_s = colvar%n_atom_s + COLV_SIZE(colvar, i)
795 : END DO
796 : ! Create a List of points...
797 12 : ALLOCATE (list(np))
798 4 : idum = 0
799 28 : DO ii = 1, colvar%rmsd_param%n_atoms
800 24 : idum = idum + 1
801 24 : i = colvar%rmsd_param%i_rmsd(ii)
802 28 : list(idum) = i
803 : END DO
804 : CASE (reaction_path_colvar_id, distance_from_path_colvar_id)
805 24 : colvar%n_atom_s = 0
806 24 : IF (colvar%reaction_path_param%dist_rmsd .OR. colvar%reaction_path_param%rmsd) THEN
807 8 : colvar%n_atom_s = colvar%reaction_path_param%n_components
808 : ELSE
809 48 : DO ii = 1, SIZE(colvar%reaction_path_param%colvar_p)
810 48 : colvar%n_atom_s = colvar%n_atom_s + colvar%reaction_path_param%colvar_p(ii)%colvar%n_atom_s
811 : END DO
812 : END IF
813 72 : ALLOCATE (list(colvar%n_atom_s))
814 24 : idum = 0
815 24 : IF (colvar%reaction_path_param%dist_rmsd .OR. colvar%reaction_path_param%rmsd) THEN
816 80 : DO ii = 1, SIZE(colvar%reaction_path_param%i_rmsd)
817 72 : idum = idum + 1
818 72 : i = colvar%reaction_path_param%i_rmsd(ii)
819 80 : list(idum) = i
820 : END DO
821 : ELSE
822 48 : DO ii = 1, SIZE(colvar%reaction_path_param%colvar_p)
823 112 : DO j = 1, colvar%reaction_path_param%colvar_p(ii)%colvar%n_atom_s
824 64 : idum = idum + 1
825 96 : list(idum) = colvar%reaction_path_param%colvar_p(ii)%colvar%i_atom(j)
826 : END DO
827 : END DO
828 : END IF
829 : CASE (xyz_diag_colvar_id)
830 30 : np = 1
831 : ! Number of real atoms involved in the colvar
832 30 : colvar%n_atom_s = 0
833 30 : i = colvar%xyz_diag_param%i_atom
834 30 : colvar%n_atom_s = colvar%n_atom_s + COLV_SIZE(colvar, i)
835 : ! Create a List of points...
836 30 : ALLOCATE (list(np))
837 : i = colvar%xyz_diag_param%i_atom
838 30 : list(1) = i
839 : CASE (xyz_outerdiag_colvar_id)
840 30 : np = 2
841 : ! Number of real atoms involved in the colvar
842 30 : colvar%n_atom_s = 0
843 30 : i = colvar%xyz_outerdiag_param%i_atoms(1)
844 30 : colvar%n_atom_s = colvar%n_atom_s + COLV_SIZE(colvar, i)
845 30 : i = colvar%xyz_outerdiag_param%i_atoms(2)
846 30 : colvar%n_atom_s = colvar%n_atom_s + COLV_SIZE(colvar, i)
847 : ! Create a List of points...
848 30 : ALLOCATE (list(np))
849 : i = colvar%xyz_outerdiag_param%i_atoms(1)
850 30 : list(1) = i
851 : i = colvar%xyz_outerdiag_param%i_atoms(2)
852 30 : list(2) = i
853 : CASE (u_colvar_id)
854 6 : np = 1
855 6 : ALLOCATE (list(np))
856 6 : colvar%n_atom_s = np; list(1) = 1
857 : CASE (Wc_colvar_id)
858 0 : np = 3
859 : ! Number of real atoms involved in the colvar
860 0 : colvar%n_atom_s = 0
861 0 : DO ii = 1, 3
862 0 : i = colvar%Wc%ids(ii)
863 0 : colvar%n_atom_s = colvar%n_atom_s + COLV_SIZE(colvar, i)
864 : END DO
865 : ! Create a List of points...
866 0 : ALLOCATE (list(np))
867 0 : idum = 0
868 0 : DO ii = 1, 3
869 0 : idum = idum + 1
870 0 : i = colvar%Wc%ids(ii)
871 0 : list(idum) = i
872 : END DO
873 0 : CPASSERT(idum == np)
874 : CASE (HBP_colvar_id)
875 2 : np = 3*colvar%HBP%nPoints
876 : ! Number of real atoms involved in the colvar
877 2 : colvar%n_atom_s = 0
878 4 : DO j = 1, colvar%HBP%nPoints
879 10 : DO ii = 1, 3
880 6 : i = colvar%HBP%ids(j, ii)
881 8 : colvar%n_atom_s = colvar%n_atom_s + COLV_SIZE(colvar, i)
882 : END DO
883 : END DO
884 : ! Create a List of points...
885 6 : ALLOCATE (list(np))
886 2 : idum = 0
887 4 : DO j = 1, colvar%HBP%nPoints
888 10 : DO ii = 1, 3
889 6 : idum = idum + 1
890 6 : i = colvar%HBP%ids(j, ii)
891 8 : list(idum) = i
892 : END DO
893 : END DO
894 2 : CPASSERT(idum == np)
895 : CASE (ring_puckering_colvar_id)
896 36 : np = colvar%ring_puckering_param%nring
897 : ! Number of real atoms involved in the colvar
898 36 : colvar%n_atom_s = 0
899 238 : DO ii = 1, colvar%ring_puckering_param%nring
900 202 : i = colvar%ring_puckering_param%atoms(ii)
901 238 : colvar%n_atom_s = colvar%n_atom_s + COLV_SIZE(colvar, i)
902 : END DO
903 : ! Create a List of points...
904 108 : ALLOCATE (list(np))
905 36 : idum = 0
906 238 : DO ii = 1, colvar%ring_puckering_param%nring
907 202 : idum = idum + 1
908 202 : i = colvar%ring_puckering_param%atoms(ii)
909 238 : list(idum) = i
910 : END DO
911 36 : CPASSERT(idum == np)
912 : CASE (mindist_colvar_id)
913 : np = colvar%mindist_param%n_dist_from + &
914 0 : colvar%mindist_param%n_coord_from + colvar%mindist_param%n_coord_to
915 : ! Number of real atoms involved in the colvar
916 0 : colvar%n_atom_s = 0
917 0 : DO ii = 1, colvar%mindist_param%n_dist_from
918 0 : i = colvar%mindist_param%i_dist_from(ii)
919 0 : colvar%n_atom_s = colvar%n_atom_s + COLV_SIZE(colvar, i)
920 : END DO
921 0 : DO ii = 1, colvar%mindist_param%n_coord_from
922 0 : i = colvar%mindist_param%i_coord_from(ii)
923 0 : colvar%n_atom_s = colvar%n_atom_s + COLV_SIZE(colvar, i)
924 : END DO
925 0 : DO ii = 1, colvar%mindist_param%n_coord_to
926 0 : i = colvar%mindist_param%i_coord_to(ii)
927 0 : colvar%n_atom_s = colvar%n_atom_s + COLV_SIZE(colvar, i)
928 : END DO
929 : ! Create a List of points...
930 0 : ALLOCATE (list(np))
931 0 : idum = 0
932 0 : DO ii = 1, colvar%mindist_param%n_dist_from
933 0 : idum = idum + 1
934 0 : i = colvar%mindist_param%i_dist_from(ii)
935 0 : list(idum) = i
936 : END DO
937 0 : DO ii = 1, colvar%mindist_param%n_coord_from
938 0 : idum = idum + 1
939 0 : i = colvar%mindist_param%i_coord_from(ii)
940 0 : list(idum) = i
941 : END DO
942 0 : DO ii = 1, colvar%mindist_param%n_coord_to
943 0 : idum = idum + 1
944 0 : i = colvar%mindist_param%i_coord_to(ii)
945 0 : list(idum) = i
946 : END DO
947 0 : CPASSERT(idum == np)
948 : CASE (combine_colvar_id)
949 32 : colvar%n_atom_s = 0
950 96 : DO ii = 1, SIZE(colvar%combine_cvs_param%colvar_p)
951 96 : colvar%n_atom_s = colvar%n_atom_s + colvar%combine_cvs_param%colvar_p(ii)%colvar%n_atom_s
952 : END DO
953 96 : ALLOCATE (list(colvar%n_atom_s))
954 32 : idum = 0
955 96 : DO ii = 1, SIZE(colvar%combine_cvs_param%colvar_p)
956 352 : DO j = 1, colvar%combine_cvs_param%colvar_p(ii)%colvar%n_atom_s
957 256 : idum = idum + 1
958 320 : list(idum) = colvar%combine_cvs_param%colvar_p(ii)%colvar%i_atom(j)
959 : END DO
960 : END DO
961 : END SELECT
962 :
963 5706 : IF (ASSOCIATED(colvar%dsdr)) THEN
964 30 : DEALLOCATE (colvar%dsdr)
965 : END IF
966 5706 : IF (ASSOCIATED(colvar%i_atom)) THEN
967 30 : DEALLOCATE (colvar%i_atom)
968 : END IF
969 17108 : ALLOCATE (colvar%dsdr(3, colvar%n_atom_s))
970 17108 : ALLOCATE (colvar%i_atom(colvar%n_atom_s))
971 : ! And now map real atoms
972 5706 : istart = 0
973 5706 : iend = 0
974 18734 : DO i = 1, SIZE(list)
975 18734 : IF (.NOT. colvar%use_points) THEN
976 : ! No point centers
977 12762 : colvar%i_atom(i) = list(i)
978 12762 : iend = iend + 1
979 : ELSE
980 266 : IF (ASSOCIATED(colvar%points(list(i))%atoms)) THEN
981 256 : iend = istart + SIZE(colvar%points(list(i))%atoms)
982 616 : colvar%i_atom(istart + 1:iend) = colvar%points(list(i))%atoms
983 : istart = iend
984 : END IF
985 : END IF
986 : END DO
987 5706 : CPASSERT(iend == colvar%n_atom_s)
988 5706 : DEALLOCATE (list)
989 :
990 5706 : END SUBROUTINE colvar_setup
991 :
992 : ! **************************************************************************************************
993 : !> \brief Finalize the setup of the collective variable for the autoionization of water
994 : !> \param colvar the colvar to initialize
995 : !> \param colvar_id ...
996 : !> \param list ...
997 : !> \author Dorothea Golze
998 : ! **************************************************************************************************
999 4 : SUBROUTINE setup_hydronium_colvars(colvar, colvar_id, list)
1000 : TYPE(colvar_type), INTENT(INOUT) :: colvar
1001 : INTEGER, INTENT(IN) :: colvar_id
1002 : INTEGER, DIMENSION(:), INTENT(INOUT) :: list
1003 :
1004 : INTEGER :: i, idum, ii, n_hydrogens, n_oxygens, np
1005 4 : INTEGER, DIMENSION(:), POINTER :: i_hydrogens, i_oxygens
1006 :
1007 4 : NULLIFY (i_oxygens, i_hydrogens)
1008 :
1009 6 : SELECT CASE (colvar_id)
1010 : CASE (hydronium_shell_colvar_id)
1011 2 : n_oxygens = colvar%hydronium_shell_param%n_oxygens
1012 2 : n_hydrogens = colvar%hydronium_shell_param%n_hydrogens
1013 2 : i_oxygens => colvar%hydronium_shell_param%i_oxygens
1014 2 : i_hydrogens => colvar%hydronium_shell_param%i_hydrogens
1015 : CASE (hydronium_dist_colvar_id)
1016 2 : n_oxygens = colvar%hydronium_dist_param%n_oxygens
1017 2 : n_hydrogens = colvar%hydronium_dist_param%n_hydrogens
1018 2 : i_oxygens => colvar%hydronium_dist_param%i_oxygens
1019 2 : i_hydrogens => colvar%hydronium_dist_param%i_hydrogens
1020 : END SELECT
1021 :
1022 4 : np = n_oxygens + n_hydrogens
1023 : ! Number of real atoms involved in the colvar
1024 4 : colvar%n_atom_s = 0
1025 20 : DO ii = 1, n_oxygens
1026 16 : i = i_oxygens(ii)
1027 20 : colvar%n_atom_s = colvar%n_atom_s + COLV_SIZE(colvar, i)
1028 : END DO
1029 40 : DO ii = 1, n_hydrogens
1030 36 : i = i_hydrogens(ii)
1031 40 : colvar%n_atom_s = colvar%n_atom_s + COLV_SIZE(colvar, i)
1032 : END DO
1033 : idum = 0
1034 20 : DO ii = 1, n_oxygens
1035 16 : idum = idum + 1
1036 16 : i = i_oxygens(ii)
1037 16 : list(idum) = i
1038 164 : IF (ANY(i_hydrogens == i)) THEN
1039 0 : CPABORT("COLVAR: atoms doubled in OXYGENS and HYDROGENS list")
1040 : END IF
1041 : END DO
1042 40 : DO ii = 1, n_hydrogens
1043 36 : idum = idum + 1
1044 36 : i = i_hydrogens(ii)
1045 40 : list(idum) = i
1046 : END DO
1047 4 : CPASSERT(idum == np)
1048 56 : DO i = 1, np
1049 368 : DO ii = i + 1, np
1050 364 : IF (list(i) == list(ii)) THEN
1051 0 : IF (i <= n_oxygens) THEN
1052 0 : CPABORT("atoms doubled in OXYGENS list")
1053 : END IF
1054 0 : IF (i > n_oxygens) THEN
1055 0 : CPABORT("atoms doubled in HYDROGENS list")
1056 : END IF
1057 : END IF
1058 : END DO
1059 : END DO
1060 :
1061 4 : END SUBROUTINE setup_hydronium_colvars
1062 :
1063 : ! **************************************************************************************************
1064 : !> \brief Finalize the setup of the collective variable for the dissociation
1065 : !> of a carboxylic acid in water
1066 : !> \param colvar the colvar to initialize
1067 : !> \param colvar_id ...
1068 : !> \param list ...
1069 : !> \author Dorothea Golze
1070 : ! **************************************************************************************************
1071 4 : SUBROUTINE setup_acid_hydronium_colvars(colvar, colvar_id, list)
1072 : TYPE(colvar_type), INTENT(INOUT) :: colvar
1073 : INTEGER, INTENT(IN) :: colvar_id
1074 : INTEGER, DIMENSION(:), INTENT(INOUT) :: list
1075 :
1076 : INTEGER :: i, idum, ii, n_hydrogens, &
1077 : n_oxygens_acid, n_oxygens_water, np
1078 4 : INTEGER, DIMENSION(:), POINTER :: i_hydrogens, i_oxygens_acid, &
1079 4 : i_oxygens_water
1080 :
1081 4 : NULLIFY (i_oxygens_water, i_oxygens_acid, i_hydrogens)
1082 :
1083 6 : SELECT CASE (colvar_id)
1084 : CASE (acid_hyd_dist_colvar_id)
1085 2 : n_oxygens_water = colvar%acid_hyd_dist_param%n_oxygens_water
1086 2 : n_oxygens_acid = colvar%acid_hyd_dist_param%n_oxygens_acid
1087 2 : n_hydrogens = colvar%acid_hyd_dist_param%n_hydrogens
1088 2 : i_oxygens_water => colvar%acid_hyd_dist_param%i_oxygens_water
1089 2 : i_oxygens_acid => colvar%acid_hyd_dist_param%i_oxygens_acid
1090 2 : i_hydrogens => colvar%acid_hyd_dist_param%i_hydrogens
1091 : CASE (acid_hyd_shell_colvar_id)
1092 2 : n_oxygens_water = colvar%acid_hyd_shell_param%n_oxygens_water
1093 2 : n_oxygens_acid = colvar%acid_hyd_shell_param%n_oxygens_acid
1094 2 : n_hydrogens = colvar%acid_hyd_shell_param%n_hydrogens
1095 2 : i_oxygens_water => colvar%acid_hyd_shell_param%i_oxygens_water
1096 2 : i_oxygens_acid => colvar%acid_hyd_shell_param%i_oxygens_acid
1097 2 : i_hydrogens => colvar%acid_hyd_shell_param%i_hydrogens
1098 : END SELECT
1099 :
1100 4 : np = n_oxygens_water + n_oxygens_acid + n_hydrogens
1101 : ! Number of real atoms involved in the colvar
1102 4 : colvar%n_atom_s = 0
1103 12 : DO ii = 1, n_oxygens_water
1104 8 : i = i_oxygens_water(ii)
1105 12 : colvar%n_atom_s = colvar%n_atom_s + COLV_SIZE(colvar, i)
1106 : END DO
1107 12 : DO ii = 1, n_oxygens_acid
1108 8 : i = i_oxygens_acid(ii)
1109 12 : colvar%n_atom_s = colvar%n_atom_s + COLV_SIZE(colvar, i)
1110 : END DO
1111 24 : DO ii = 1, n_hydrogens
1112 20 : i = i_hydrogens(ii)
1113 24 : colvar%n_atom_s = colvar%n_atom_s + COLV_SIZE(colvar, i)
1114 : END DO
1115 : idum = 0
1116 12 : DO ii = 1, n_oxygens_water
1117 8 : idum = idum + 1
1118 8 : i = i_oxygens_water(ii)
1119 8 : list(idum) = i
1120 48 : IF (ANY(i_hydrogens == i)) THEN
1121 0 : CPABORT("COLVAR: atoms doubled in OXYGENS_WATER and HYDROGENS list")
1122 : END IF
1123 28 : IF (ANY(i_oxygens_acid == i)) THEN
1124 0 : CPABORT("COLVAR: atoms doubled in OXYGENS_WATER and OXYGENS_ACID list")
1125 : END IF
1126 : END DO
1127 12 : DO ii = 1, n_oxygens_acid
1128 8 : idum = idum + 1
1129 8 : i = i_oxygens_acid(ii)
1130 8 : list(idum) = i
1131 52 : IF (ANY(i_hydrogens == i)) THEN
1132 0 : CPABORT("COLVAR: atoms doubled in OXYGENS_ACID and HYDROGENS list")
1133 : END IF
1134 : END DO
1135 24 : DO ii = 1, n_hydrogens
1136 20 : idum = idum + 1
1137 20 : i = i_hydrogens(ii)
1138 24 : list(idum) = i
1139 : END DO
1140 4 : CPASSERT(idum == np)
1141 40 : DO i = 1, np
1142 184 : DO ii = i + 1, np
1143 180 : IF (list(i) == list(ii)) THEN
1144 0 : IF (i <= n_oxygens_water) THEN
1145 0 : CPABORT("atoms doubled in OXYGENS_WATER list")
1146 : END IF
1147 0 : IF (i > n_oxygens_water .AND. i <= n_oxygens_water + n_oxygens_acid) THEN
1148 0 : CPABORT("atoms doubled in OXYGENS_ACID list")
1149 : END IF
1150 0 : IF (i > n_oxygens_water + n_oxygens_acid) THEN
1151 0 : CPABORT("atoms doubled in HYDROGENS list")
1152 : END IF
1153 : END IF
1154 : END DO
1155 : END DO
1156 :
1157 4 : END SUBROUTINE setup_acid_hydronium_colvars
1158 :
1159 : ! **************************************************************************************************
1160 : !> \brief Gives back the size of an array of integer. If not associated gives back 1
1161 : !> \param colvar ...
1162 : !> \param i ...
1163 : !> \return ...
1164 : !> \author Teodoro Laino - 03.2007
1165 : ! **************************************************************************************************
1166 12630 : FUNCTION colv_size(colvar, i) RESULT(my_size)
1167 : TYPE(colvar_type), INTENT(IN) :: colvar
1168 : INTEGER :: i, my_size
1169 :
1170 12630 : my_size = 1
1171 12630 : IF (ASSOCIATED(colvar%points)) THEN
1172 266 : IF (ASSOCIATED(colvar%points(i)%atoms)) THEN
1173 256 : my_size = SIZE(colvar%points(i)%atoms)
1174 : ELSE
1175 : my_size = 0
1176 : END IF
1177 : END IF
1178 12630 : END FUNCTION colv_size
1179 :
1180 : ! **************************************************************************************************
1181 : !> \brief releases the memory that might have been allocated by the colvar
1182 : !> \param colvar the colvar to deallocate
1183 : !> \author alessandro laio and fawzi mohamed
1184 : ! **************************************************************************************************
1185 5676 : RECURSIVE SUBROUTINE colvar_release(colvar)
1186 : TYPE(colvar_type), POINTER :: colvar
1187 :
1188 : INTEGER :: i
1189 :
1190 5676 : CPASSERT(ASSOCIATED(colvar))
1191 5676 : IF (ASSOCIATED(colvar%dsdr)) THEN
1192 5676 : DEALLOCATE (colvar%dsdr)
1193 : END IF
1194 5676 : IF (ASSOCIATED(colvar%i_atom)) THEN
1195 5676 : DEALLOCATE (colvar%i_atom)
1196 : END IF
1197 5676 : IF (ASSOCIATED(colvar%points)) THEN
1198 366 : DO i = 1, SIZE(colvar%points)
1199 266 : IF (ASSOCIATED(colvar%points(i)%atoms)) THEN
1200 256 : DEALLOCATE (colvar%points(i)%atoms)
1201 : END IF
1202 366 : IF (ASSOCIATED(colvar%points(i)%weights)) THEN
1203 256 : DEALLOCATE (colvar%points(i)%weights)
1204 : END IF
1205 : END DO
1206 100 : DEALLOCATE (colvar%points)
1207 : END IF
1208 10676 : SELECT CASE (colvar%type_id)
1209 : CASE (dist_colvar_id)
1210 5000 : DEALLOCATE (colvar%dist_param)
1211 : CASE (coord_colvar_id)
1212 60 : IF (ASSOCIATED(colvar%coord_param%i_at_from)) THEN
1213 60 : DEALLOCATE (colvar%coord_param%i_at_from)
1214 : END IF
1215 60 : IF (ASSOCIATED(colvar%coord_param%i_at_to)) THEN
1216 60 : DEALLOCATE (colvar%coord_param%i_at_to)
1217 : END IF
1218 60 : IF (ASSOCIATED(colvar%coord_param%c_kinds_from)) THEN
1219 8 : DEALLOCATE (colvar%coord_param%c_kinds_from)
1220 : END IF
1221 60 : IF (ASSOCIATED(colvar%coord_param%c_kinds_to)) THEN
1222 8 : DEALLOCATE (colvar%coord_param%c_kinds_to)
1223 : END IF
1224 60 : IF (ASSOCIATED(colvar%coord_param%i_at_to_b)) THEN
1225 4 : DEALLOCATE (colvar%coord_param%i_at_to_b)
1226 : END IF
1227 60 : IF (ASSOCIATED(colvar%coord_param%c_kinds_to_b)) THEN
1228 2 : DEALLOCATE (colvar%coord_param%c_kinds_to_b)
1229 : END IF
1230 60 : DEALLOCATE (colvar%coord_param)
1231 : CASE (population_colvar_id)
1232 8 : IF (ASSOCIATED(colvar%population_param%i_at_from)) THEN
1233 8 : DEALLOCATE (colvar%population_param%i_at_from)
1234 : END IF
1235 8 : IF (ASSOCIATED(colvar%population_param%i_at_to)) THEN
1236 8 : DEALLOCATE (colvar%population_param%i_at_to)
1237 : END IF
1238 8 : IF (ASSOCIATED(colvar%population_param%c_kinds_from)) THEN
1239 0 : DEALLOCATE (colvar%population_param%c_kinds_from)
1240 : END IF
1241 8 : IF (ASSOCIATED(colvar%population_param%c_kinds_to)) THEN
1242 8 : DEALLOCATE (colvar%population_param%c_kinds_to)
1243 : END IF
1244 8 : DEALLOCATE (colvar%population_param)
1245 : CASE (gyration_colvar_id)
1246 2 : IF (ASSOCIATED(colvar%gyration_param%i_at)) THEN
1247 2 : DEALLOCATE (colvar%gyration_param%i_at)
1248 : END IF
1249 2 : IF (ASSOCIATED(colvar%gyration_param%c_kinds)) THEN
1250 2 : DEALLOCATE (colvar%gyration_param%c_kinds)
1251 : END IF
1252 2 : DEALLOCATE (colvar%gyration_param)
1253 : CASE (angle_colvar_id)
1254 220 : DEALLOCATE (colvar%angle_param)
1255 : CASE (torsion_colvar_id)
1256 160 : DEALLOCATE (colvar%torsion_param)
1257 : CASE (plane_distance_colvar_id)
1258 28 : DEALLOCATE (colvar%plane_distance_param)
1259 : CASE (plane_plane_angle_colvar_id)
1260 16 : DEALLOCATE (colvar%plane_plane_angle_param)
1261 : CASE (dfunct_colvar_id)
1262 18 : DEALLOCATE (colvar%dfunct_param)
1263 : CASE (rotation_colvar_id)
1264 2 : DEALLOCATE (colvar%rotation_param)
1265 : CASE (qparm_colvar_id)
1266 2 : DEALLOCATE (colvar%qparm_param%i_at_from)
1267 2 : DEALLOCATE (colvar%qparm_param%i_at_to)
1268 2 : DEALLOCATE (colvar%qparm_param)
1269 : CASE (xyz_diag_colvar_id)
1270 30 : DEALLOCATE (colvar%xyz_diag_param)
1271 : CASE (xyz_outerdiag_colvar_id)
1272 30 : DEALLOCATE (colvar%xyz_outerdiag_param)
1273 : CASE (u_colvar_id)
1274 6 : NULLIFY (colvar%u_param%mixed_energy_section)
1275 6 : DEALLOCATE (colvar%u_param)
1276 : CASE (hydronium_shell_colvar_id)
1277 2 : DEALLOCATE (colvar%hydronium_shell_param%i_oxygens)
1278 2 : DEALLOCATE (colvar%hydronium_shell_param%i_hydrogens)
1279 2 : DEALLOCATE (colvar%hydronium_shell_param)
1280 : CASE (hydronium_dist_colvar_id)
1281 2 : DEALLOCATE (colvar%hydronium_dist_param%i_oxygens)
1282 2 : DEALLOCATE (colvar%hydronium_dist_param%i_hydrogens)
1283 2 : DEALLOCATE (colvar%hydronium_dist_param)
1284 : CASE (acid_hyd_dist_colvar_id)
1285 2 : DEALLOCATE (colvar%acid_hyd_dist_param%i_oxygens_water)
1286 2 : DEALLOCATE (colvar%acid_hyd_dist_param%i_oxygens_acid)
1287 2 : DEALLOCATE (colvar%acid_hyd_dist_param%i_hydrogens)
1288 2 : DEALLOCATE (colvar%acid_hyd_dist_param)
1289 : CASE (acid_hyd_shell_colvar_id)
1290 2 : DEALLOCATE (colvar%acid_hyd_shell_param%i_oxygens_water)
1291 2 : DEALLOCATE (colvar%acid_hyd_shell_param%i_oxygens_acid)
1292 2 : DEALLOCATE (colvar%acid_hyd_shell_param%i_hydrogens)
1293 2 : DEALLOCATE (colvar%acid_hyd_shell_param)
1294 : CASE (reaction_path_colvar_id, distance_from_path_colvar_id)
1295 24 : IF (colvar%reaction_path_param%dist_rmsd .OR. colvar%reaction_path_param%rmsd) THEN
1296 8 : DEALLOCATE (colvar%reaction_path_param%r_ref)
1297 8 : DEALLOCATE (colvar%reaction_path_param%i_rmsd)
1298 : ELSE
1299 48 : DO i = 1, SIZE(colvar%reaction_path_param%colvar_p)
1300 48 : CALL colvar_release(colvar%reaction_path_param%colvar_p(i)%colvar)
1301 : END DO
1302 16 : DEALLOCATE (colvar%reaction_path_param%colvar_p)
1303 16 : DEALLOCATE (colvar%reaction_path_param%f_vals)
1304 : END IF
1305 24 : DEALLOCATE (colvar%reaction_path_param)
1306 : CASE (combine_colvar_id)
1307 60 : DO i = 1, SIZE(colvar%combine_cvs_param%colvar_p)
1308 60 : CALL colvar_release(colvar%combine_cvs_param%colvar_p(i)%colvar)
1309 : END DO
1310 20 : DEALLOCATE (colvar%combine_cvs_param%colvar_p)
1311 20 : DEALLOCATE (colvar%combine_cvs_param%c_parameters)
1312 20 : DEALLOCATE (colvar%combine_cvs_param%v_parameters)
1313 20 : DEALLOCATE (colvar%combine_cvs_param%variables)
1314 20 : DEALLOCATE (colvar%combine_cvs_param)
1315 : CASE (rmsd_colvar_id)
1316 4 : DEALLOCATE (colvar%rmsd_param%weights)
1317 4 : DEALLOCATE (colvar%rmsd_param%r_ref)
1318 4 : DEALLOCATE (colvar%rmsd_param%i_rmsd)
1319 4 : DEALLOCATE (colvar%rmsd_param)
1320 : CASE (Wc_colvar_id)
1321 0 : DEALLOCATE (colvar%Wc)
1322 : CASE (HBP_colvar_id)
1323 2 : DEALLOCATE (colvar%HBP%ewc)
1324 2 : DEALLOCATE (colvar%HBP%ids)
1325 2 : DEALLOCATE (colvar%HBP)
1326 : CASE (ring_puckering_colvar_id)
1327 36 : DEALLOCATE (colvar%ring_puckering_param%atoms)
1328 36 : DEALLOCATE (colvar%ring_puckering_param)
1329 : CASE (mindist_colvar_id)
1330 0 : IF (ASSOCIATED(colvar%mindist_param%i_dist_from)) THEN
1331 0 : DEALLOCATE (colvar%mindist_param%i_dist_from)
1332 : END IF
1333 0 : IF (ASSOCIATED(colvar%mindist_param%i_coord_from)) THEN
1334 0 : DEALLOCATE (colvar%mindist_param%i_coord_from)
1335 : END IF
1336 0 : IF (ASSOCIATED(colvar%mindist_param%i_coord_to)) THEN
1337 0 : DEALLOCATE (colvar%mindist_param%i_coord_to)
1338 : END IF
1339 0 : IF (ASSOCIATED(colvar%mindist_param%k_coord_from)) THEN
1340 0 : DEALLOCATE (colvar%mindist_param%k_coord_from)
1341 : END IF
1342 0 : IF (ASSOCIATED(colvar%mindist_param%k_coord_to)) THEN
1343 0 : DEALLOCATE (colvar%mindist_param%k_coord_to)
1344 : END IF
1345 0 : DEALLOCATE (colvar%mindist_param)
1346 : CASE (no_colvar_id)
1347 : ! Do nothing
1348 : CASE default
1349 5676 : CPABORT("Unknown colvar type")
1350 : END SELECT
1351 5676 : DEALLOCATE (colvar)
1352 :
1353 5676 : END SUBROUTINE colvar_release
1354 :
1355 : ! **************************************************************************************************
1356 : !> \brief Clone a colvar type
1357 : !> \param colvar_out ...
1358 : !> \param colvar_in the colvar to deallocate
1359 : !> \param i_atom_offset ...
1360 : !> \author Teodoro Laino [tlaino] 04.2006
1361 : ! **************************************************************************************************
1362 4986 : RECURSIVE SUBROUTINE colvar_clone(colvar_out, colvar_in, i_atom_offset)
1363 : TYPE(colvar_type), INTENT(INOUT), POINTER :: colvar_out
1364 : TYPE(colvar_type), INTENT(IN) :: colvar_in
1365 : INTEGER, INTENT(IN), OPTIONAL :: i_atom_offset
1366 :
1367 : INTEGER :: i, my_offset, ndim, ndim2
1368 :
1369 4986 : my_offset = 0
1370 4986 : IF (PRESENT(i_atom_offset)) my_offset = i_atom_offset
1371 4986 : CALL colvar_create(colvar_out, colvar_in%type_id)
1372 4986 : CALL colvar_clone_points(colvar_out, colvar_in, my_offset)
1373 4986 : IF (colvar_in%use_points) my_offset = 0
1374 9598 : SELECT CASE (colvar_out%type_id)
1375 : CASE (dist_colvar_id)
1376 4612 : colvar_out%dist_param%i_at = colvar_in%dist_param%i_at + my_offset
1377 4612 : colvar_out%dist_param%j_at = colvar_in%dist_param%j_at + my_offset
1378 4612 : colvar_out%dist_param%axis_id = colvar_in%dist_param%axis_id
1379 4612 : colvar_out%dist_param%sign_d = colvar_in%dist_param%sign_d
1380 : CASE (coord_colvar_id)
1381 6 : colvar_out%coord_param%n_atoms_to = colvar_in%coord_param%n_atoms_to
1382 6 : colvar_out%coord_param%n_atoms_to_b = colvar_in%coord_param%n_atoms_to_b
1383 6 : colvar_out%coord_param%n_atoms_from = colvar_in%coord_param%n_atoms_from
1384 6 : colvar_out%coord_param%nncrd = colvar_in%coord_param%nncrd
1385 6 : colvar_out%coord_param%ndcrd = colvar_in%coord_param%ndcrd
1386 6 : colvar_out%coord_param%r_0 = colvar_in%coord_param%r_0
1387 6 : colvar_out%coord_param%nncrd_b = colvar_in%coord_param%nncrd_b
1388 6 : colvar_out%coord_param%ndcrd_b = colvar_in%coord_param%ndcrd_b
1389 6 : colvar_out%coord_param%r_0_b = colvar_in%coord_param%r_0_b
1390 6 : colvar_out%coord_param%use_kinds_from = colvar_in%coord_param%use_kinds_from
1391 6 : colvar_out%coord_param%use_kinds_to = colvar_in%coord_param%use_kinds_to
1392 6 : colvar_out%coord_param%use_kinds_to_b = colvar_in%coord_param%use_kinds_to_b
1393 6 : IF (colvar_in%coord_param%use_kinds_from) THEN
1394 : ! KINDS
1395 0 : ndim = SIZE(colvar_in%coord_param%c_kinds_from)
1396 0 : ALLOCATE (colvar_out%coord_param%c_kinds_from(ndim))
1397 0 : colvar_out%coord_param%c_kinds_from = colvar_in%coord_param%c_kinds_from
1398 : ELSE
1399 : ! INDEX
1400 6 : ndim = SIZE(colvar_in%coord_param%i_at_from)
1401 18 : ALLOCATE (colvar_out%coord_param%i_at_from(ndim))
1402 12 : colvar_out%coord_param%i_at_from = colvar_in%coord_param%i_at_from + my_offset
1403 : END IF
1404 6 : IF (colvar_in%coord_param%use_kinds_to) THEN
1405 : ! KINDS
1406 0 : ndim = SIZE(colvar_in%coord_param%c_kinds_to)
1407 0 : ALLOCATE (colvar_out%coord_param%c_kinds_to(ndim))
1408 0 : colvar_out%coord_param%c_kinds_to = colvar_in%coord_param%c_kinds_to
1409 : ELSE
1410 : ! INDEX
1411 6 : ndim = SIZE(colvar_in%coord_param%i_at_to)
1412 18 : ALLOCATE (colvar_out%coord_param%i_at_to(ndim))
1413 18 : colvar_out%coord_param%i_at_to = colvar_in%coord_param%i_at_to + my_offset
1414 : END IF
1415 6 : IF (colvar_in%coord_param%use_kinds_to_b) THEN
1416 : ! KINDS
1417 0 : ndim = SIZE(colvar_in%coord_param%c_kinds_to_b)
1418 0 : ALLOCATE (colvar_out%coord_param%c_kinds_to_b(ndim))
1419 0 : colvar_out%coord_param%c_kinds_to_b = colvar_in%coord_param%c_kinds_to_b
1420 6 : ELSE IF (ASSOCIATED(colvar_in%coord_param%i_at_to_b)) THEN
1421 : ! INDEX
1422 0 : ndim = SIZE(colvar_in%coord_param%i_at_to_b)
1423 0 : ALLOCATE (colvar_out%coord_param%i_at_to_b(ndim))
1424 0 : colvar_out%coord_param%i_at_to_b = colvar_in%coord_param%i_at_to_b + my_offset
1425 : END IF
1426 :
1427 : CASE (population_colvar_id)
1428 0 : colvar_out%population_param%n_atoms_to = colvar_in%population_param%n_atoms_to
1429 0 : colvar_out%population_param%n_atoms_from = colvar_in%population_param%n_atoms_from
1430 0 : colvar_out%population_param%nncrd = colvar_in%population_param%nncrd
1431 0 : colvar_out%population_param%ndcrd = colvar_in%population_param%ndcrd
1432 0 : colvar_out%population_param%r_0 = colvar_in%population_param%r_0
1433 0 : colvar_out%population_param%use_kinds_from = colvar_in%population_param%use_kinds_from
1434 0 : colvar_out%population_param%use_kinds_to = colvar_in%population_param%use_kinds_to
1435 0 : IF (colvar_in%population_param%use_kinds_from) THEN
1436 : ! KINDS
1437 0 : ndim = SIZE(colvar_in%population_param%c_kinds_from)
1438 0 : ALLOCATE (colvar_out%population_param%c_kinds_from(ndim))
1439 0 : colvar_out%population_param%c_kinds_from = colvar_in%population_param%c_kinds_from
1440 : ELSE
1441 : ! INDEX
1442 0 : ndim = SIZE(colvar_in%population_param%i_at_from)
1443 0 : ALLOCATE (colvar_out%population_param%i_at_from(ndim))
1444 0 : colvar_out%population_param%i_at_from = colvar_in%population_param%i_at_from + my_offset
1445 : END IF
1446 0 : IF (colvar_in%population_param%use_kinds_to) THEN
1447 : ! KINDS
1448 0 : ndim = SIZE(colvar_in%population_param%c_kinds_to)
1449 0 : ALLOCATE (colvar_out%population_param%c_kinds_to(ndim))
1450 0 : colvar_out%population_param%c_kinds_to = colvar_in%population_param%c_kinds_to
1451 : ELSE
1452 : ! INDEX
1453 0 : ndim = SIZE(colvar_in%population_param%i_at_to)
1454 0 : ALLOCATE (colvar_out%population_param%i_at_to(ndim))
1455 0 : colvar_out%population_param%i_at_to = colvar_in%population_param%i_at_to + my_offset
1456 : END IF
1457 :
1458 : CASE (gyration_colvar_id)
1459 0 : colvar_out%gyration_param%n_atoms = colvar_in%gyration_param%n_atoms
1460 0 : colvar_out%gyration_param%use_kinds = colvar_in%gyration_param%use_kinds
1461 0 : IF (colvar_in%gyration_param%use_kinds) THEN
1462 : ! KINDS
1463 0 : ndim = SIZE(colvar_in%gyration_param%c_kinds)
1464 0 : ALLOCATE (colvar_out%gyration_param%c_kinds(ndim))
1465 0 : colvar_out%gyration_param%c_kinds = colvar_in%gyration_param%c_kinds
1466 : ELSE
1467 : ! INDEX
1468 0 : ndim = SIZE(colvar_in%gyration_param%i_at)
1469 0 : ALLOCATE (colvar_out%gyration_param%i_at(ndim))
1470 0 : colvar_out%gyration_param%i_at = colvar_in%gyration_param%i_at + my_offset
1471 : END IF
1472 : CASE (angle_colvar_id)
1473 672 : colvar_out%angle_param%i_at_angle = colvar_in%angle_param%i_at_angle + my_offset
1474 : CASE (torsion_colvar_id)
1475 570 : colvar_out%torsion_param%i_at_tors = colvar_in%torsion_param%i_at_tors + my_offset
1476 114 : colvar_out%torsion_param%o0 = colvar_in%torsion_param%o0
1477 : CASE (plane_distance_colvar_id)
1478 0 : colvar_out%plane_distance_param%use_pbc = colvar_in%plane_distance_param%use_pbc
1479 0 : colvar_out%plane_distance_param%plane = colvar_in%plane_distance_param%plane + my_offset
1480 0 : colvar_out%plane_distance_param%point = colvar_in%plane_distance_param%point + my_offset
1481 : CASE (plane_plane_angle_colvar_id)
1482 12 : colvar_out%plane_plane_angle_param%plane1%type_of_def = colvar_in%plane_plane_angle_param%plane1%type_of_def
1483 12 : IF (colvar_out%plane_plane_angle_param%plane1%type_of_def == plane_def_vec) THEN
1484 0 : colvar_out%plane_plane_angle_param%plane1%normal_vec = colvar_in%plane_plane_angle_param%plane1%normal_vec
1485 : ELSE
1486 48 : colvar_out%plane_plane_angle_param%plane1%points = colvar_in%plane_plane_angle_param%plane1%points + my_offset
1487 : END IF
1488 :
1489 12 : colvar_out%plane_plane_angle_param%plane2%type_of_def = colvar_in%plane_plane_angle_param%plane2%type_of_def
1490 12 : IF (colvar_out%plane_plane_angle_param%plane2%type_of_def == plane_def_vec) THEN
1491 24 : colvar_out%plane_plane_angle_param%plane2%normal_vec = colvar_in%plane_plane_angle_param%plane2%normal_vec
1492 : ELSE
1493 24 : colvar_out%plane_plane_angle_param%plane2%points = colvar_in%plane_plane_angle_param%plane2%points + my_offset
1494 : END IF
1495 : CASE (rotation_colvar_id)
1496 0 : colvar_out%rotation_param%i_at1_bond1 = colvar_in%rotation_param%i_at1_bond1 + my_offset
1497 0 : colvar_out%rotation_param%i_at2_bond1 = colvar_in%rotation_param%i_at2_bond1 + my_offset
1498 0 : colvar_out%rotation_param%i_at1_bond2 = colvar_in%rotation_param%i_at1_bond2 + my_offset
1499 0 : colvar_out%rotation_param%i_at2_bond2 = colvar_in%rotation_param%i_at2_bond2 + my_offset
1500 : CASE (dfunct_colvar_id)
1501 60 : colvar_out%dfunct_param%i_at_dfunct = colvar_in%dfunct_param%i_at_dfunct + my_offset
1502 12 : colvar_out%dfunct_param%coeff = colvar_in%dfunct_param%coeff
1503 12 : colvar_out%dfunct_param%use_pbc = colvar_in%dfunct_param%use_pbc
1504 : CASE (qparm_colvar_id)
1505 0 : colvar_out%qparm_param%n_atoms_to = colvar_in%qparm_param%n_atoms_to
1506 0 : colvar_out%qparm_param%n_atoms_from = colvar_in%qparm_param%n_atoms_from
1507 0 : colvar_out%qparm_param%rcut = colvar_in%qparm_param%rcut
1508 0 : colvar_out%qparm_param%l = colvar_in%qparm_param%l
1509 0 : colvar_out%qparm_param%rstart = colvar_in%qparm_param%rstart
1510 0 : colvar_out%qparm_param%include_images = colvar_in%qparm_param%include_images
1511 0 : ndim = SIZE(colvar_in%qparm_param%i_at_from)
1512 0 : ALLOCATE (colvar_out%qparm_param%i_at_from(ndim))
1513 0 : ndim = SIZE(colvar_in%qparm_param%i_at_to)
1514 0 : ALLOCATE (colvar_out%qparm_param%i_at_to(ndim))
1515 0 : colvar_out%qparm_param%i_at_from = colvar_in%qparm_param%i_at_from + my_offset
1516 0 : colvar_out%qparm_param%i_at_to = colvar_in%qparm_param%i_at_from + my_offset
1517 : CASE (xyz_diag_colvar_id)
1518 24 : colvar_out%xyz_diag_param%i_atom = colvar_in%xyz_diag_param%i_atom + my_offset
1519 24 : colvar_out%xyz_diag_param%component = colvar_in%xyz_diag_param%component
1520 96 : colvar_out%xyz_diag_param%r0 = colvar_in%xyz_diag_param%r0
1521 24 : colvar_out%xyz_diag_param%use_pbc = colvar_in%xyz_diag_param%use_pbc
1522 24 : colvar_out%xyz_diag_param%use_absolute_position = colvar_in%xyz_diag_param%use_absolute_position
1523 : CASE (xyz_outerdiag_colvar_id)
1524 72 : colvar_out%xyz_outerdiag_param%i_atoms = colvar_in%xyz_outerdiag_param%i_atoms + my_offset
1525 72 : colvar_out%xyz_outerdiag_param%components = colvar_in%xyz_outerdiag_param%components
1526 216 : colvar_out%xyz_outerdiag_param%r0 = colvar_in%xyz_outerdiag_param%r0
1527 24 : colvar_out%xyz_outerdiag_param%use_pbc = colvar_in%xyz_outerdiag_param%use_pbc
1528 : CASE (u_colvar_id)
1529 0 : colvar_out%u_param%natom = colvar_in%u_param%natom
1530 : CASE (hydronium_shell_colvar_id)
1531 0 : colvar_out%hydronium_shell_param%n_hydrogens = colvar_in%hydronium_shell_param%n_hydrogens
1532 0 : colvar_out%hydronium_shell_param%n_oxygens = colvar_in%hydronium_shell_param%n_oxygens
1533 0 : colvar_out%hydronium_shell_param%nh = colvar_in%hydronium_shell_param%nh
1534 0 : colvar_out%hydronium_shell_param%poh = colvar_in%hydronium_shell_param%poh
1535 0 : colvar_out%hydronium_shell_param%poo = colvar_in%hydronium_shell_param%poo
1536 0 : colvar_out%hydronium_shell_param%qoh = colvar_in%hydronium_shell_param%qoh
1537 0 : colvar_out%hydronium_shell_param%qoo = colvar_in%hydronium_shell_param%qoo
1538 0 : colvar_out%hydronium_shell_param%pm = colvar_in%hydronium_shell_param%pm
1539 0 : colvar_out%hydronium_shell_param%qm = colvar_in%hydronium_shell_param%qm
1540 0 : colvar_out%hydronium_shell_param%roo = colvar_in%hydronium_shell_param%roo
1541 0 : colvar_out%hydronium_shell_param%roh = colvar_in%hydronium_shell_param%roh
1542 0 : colvar_out%hydronium_shell_param%lambda = colvar_in%hydronium_shell_param%lambda
1543 0 : ndim = SIZE(colvar_in%hydronium_shell_param%i_oxygens)
1544 0 : ALLOCATE (colvar_out%hydronium_shell_param%i_oxygens(ndim))
1545 0 : ndim = SIZE(colvar_in%hydronium_shell_param%i_hydrogens)
1546 0 : ALLOCATE (colvar_out%hydronium_shell_param%i_hydrogens(ndim))
1547 0 : colvar_out%hydronium_shell_param%i_oxygens = colvar_in%hydronium_shell_param%i_oxygens + my_offset
1548 0 : colvar_out%hydronium_shell_param%i_hydrogens = colvar_in%hydronium_shell_param%i_hydrogens + my_offset
1549 : CASE (hydronium_dist_colvar_id)
1550 0 : colvar_out%hydronium_dist_param%n_hydrogens = colvar_in%hydronium_dist_param%n_hydrogens
1551 0 : colvar_out%hydronium_dist_param%n_oxygens = colvar_in%hydronium_dist_param%n_oxygens
1552 0 : colvar_out%hydronium_dist_param%nh = colvar_in%hydronium_dist_param%nh
1553 0 : colvar_out%hydronium_dist_param%nn = colvar_in%hydronium_dist_param%nn
1554 0 : colvar_out%hydronium_dist_param%poh = colvar_in%hydronium_dist_param%poh
1555 0 : colvar_out%hydronium_dist_param%qoh = colvar_in%hydronium_dist_param%qoh
1556 0 : colvar_out%hydronium_dist_param%pf = colvar_in%hydronium_dist_param%pf
1557 0 : colvar_out%hydronium_dist_param%qf = colvar_in%hydronium_dist_param%qf
1558 0 : colvar_out%hydronium_dist_param%pm = colvar_in%hydronium_dist_param%pm
1559 0 : colvar_out%hydronium_dist_param%qm = colvar_in%hydronium_dist_param%qm
1560 0 : colvar_out%hydronium_dist_param%roh = colvar_in%hydronium_dist_param%roh
1561 0 : colvar_out%hydronium_dist_param%lambda = colvar_in%hydronium_dist_param%lambda
1562 0 : ndim = SIZE(colvar_in%hydronium_dist_param%i_oxygens)
1563 0 : ALLOCATE (colvar_out%hydronium_dist_param%i_oxygens(ndim))
1564 0 : ndim = SIZE(colvar_in%hydronium_dist_param%i_hydrogens)
1565 0 : ALLOCATE (colvar_out%hydronium_dist_param%i_hydrogens(ndim))
1566 0 : colvar_out%hydronium_dist_param%i_oxygens = colvar_in%hydronium_dist_param%i_oxygens + my_offset
1567 0 : colvar_out%hydronium_dist_param%i_hydrogens = colvar_in%hydronium_dist_param%i_hydrogens + my_offset
1568 : CASE (acid_hyd_dist_colvar_id)
1569 0 : colvar_out%acid_hyd_dist_param%n_hydrogens = colvar_in%acid_hyd_dist_param%n_hydrogens
1570 0 : colvar_out%acid_hyd_dist_param%n_oxygens_water = colvar_in%acid_hyd_dist_param%n_oxygens_water
1571 0 : colvar_out%acid_hyd_dist_param%n_oxygens_acid = colvar_in%acid_hyd_dist_param%n_oxygens_acid
1572 0 : colvar_out%acid_hyd_dist_param%nc = colvar_in%acid_hyd_dist_param%nc
1573 0 : colvar_out%acid_hyd_dist_param%pwoh = colvar_in%acid_hyd_dist_param%pwoh
1574 0 : colvar_out%acid_hyd_dist_param%qwoh = colvar_in%acid_hyd_dist_param%qwoh
1575 0 : colvar_out%acid_hyd_dist_param%paoh = colvar_in%acid_hyd_dist_param%paoh
1576 0 : colvar_out%acid_hyd_dist_param%qaoh = colvar_in%acid_hyd_dist_param%qaoh
1577 0 : colvar_out%acid_hyd_dist_param%pcut = colvar_in%acid_hyd_dist_param%pcut
1578 0 : colvar_out%acid_hyd_dist_param%qcut = colvar_in%acid_hyd_dist_param%qcut
1579 0 : colvar_out%acid_hyd_dist_param%rwoh = colvar_in%acid_hyd_dist_param%rwoh
1580 0 : colvar_out%acid_hyd_dist_param%raoh = colvar_in%acid_hyd_dist_param%raoh
1581 0 : colvar_out%acid_hyd_dist_param%lambda = colvar_in%acid_hyd_dist_param%lambda
1582 0 : ndim = SIZE(colvar_in%acid_hyd_dist_param%i_oxygens_water)
1583 0 : ALLOCATE (colvar_out%acid_hyd_dist_param%i_oxygens_water(ndim))
1584 0 : ndim = SIZE(colvar_in%acid_hyd_dist_param%i_oxygens_acid)
1585 0 : ALLOCATE (colvar_out%acid_hyd_dist_param%i_oxygens_acid(ndim))
1586 0 : ndim = SIZE(colvar_in%acid_hyd_dist_param%i_hydrogens)
1587 0 : ALLOCATE (colvar_out%acid_hyd_dist_param%i_hydrogens(ndim))
1588 0 : colvar_out%acid_hyd_dist_param%i_oxygens_water = colvar_in%acid_hyd_dist_param%i_oxygens_water + my_offset
1589 0 : colvar_out%acid_hyd_dist_param%i_oxygens_acid = colvar_in%acid_hyd_dist_param%i_oxygens_acid + my_offset
1590 0 : colvar_out%acid_hyd_dist_param%i_hydrogens = colvar_in%acid_hyd_dist_param%i_hydrogens + my_offset
1591 : CASE (acid_hyd_shell_colvar_id)
1592 0 : colvar_out%acid_hyd_shell_param%n_hydrogens = colvar_in%acid_hyd_shell_param%n_hydrogens
1593 0 : colvar_out%acid_hyd_shell_param%n_oxygens_water = colvar_in%acid_hyd_shell_param%n_oxygens_water
1594 0 : colvar_out%acid_hyd_shell_param%n_oxygens_acid = colvar_in%acid_hyd_shell_param%n_oxygens_acid
1595 0 : colvar_out%acid_hyd_shell_param%nc = colvar_in%acid_hyd_shell_param%nc
1596 0 : colvar_out%acid_hyd_shell_param%nh = colvar_in%acid_hyd_shell_param%nh
1597 0 : colvar_out%acid_hyd_shell_param%pwoh = colvar_in%acid_hyd_shell_param%pwoh
1598 0 : colvar_out%acid_hyd_shell_param%qwoh = colvar_in%acid_hyd_shell_param%qwoh
1599 0 : colvar_out%acid_hyd_shell_param%paoh = colvar_in%acid_hyd_shell_param%paoh
1600 0 : colvar_out%acid_hyd_shell_param%qaoh = colvar_in%acid_hyd_shell_param%qaoh
1601 0 : colvar_out%acid_hyd_shell_param%poo = colvar_in%acid_hyd_shell_param%poo
1602 0 : colvar_out%acid_hyd_shell_param%qoo = colvar_in%acid_hyd_shell_param%qoo
1603 0 : colvar_out%acid_hyd_shell_param%pm = colvar_in%acid_hyd_shell_param%pm
1604 0 : colvar_out%acid_hyd_shell_param%qm = colvar_in%acid_hyd_shell_param%qm
1605 0 : colvar_out%acid_hyd_shell_param%pcut = colvar_in%acid_hyd_shell_param%pcut
1606 0 : colvar_out%acid_hyd_shell_param%qcut = colvar_in%acid_hyd_shell_param%qcut
1607 0 : colvar_out%acid_hyd_shell_param%rwoh = colvar_in%acid_hyd_shell_param%rwoh
1608 0 : colvar_out%acid_hyd_shell_param%raoh = colvar_in%acid_hyd_shell_param%raoh
1609 0 : colvar_out%acid_hyd_shell_param%roo = colvar_in%acid_hyd_shell_param%roo
1610 0 : colvar_out%acid_hyd_shell_param%lambda = colvar_in%acid_hyd_shell_param%lambda
1611 0 : ndim = SIZE(colvar_in%acid_hyd_shell_param%i_oxygens_water)
1612 0 : ALLOCATE (colvar_out%acid_hyd_shell_param%i_oxygens_water(ndim))
1613 0 : ndim = SIZE(colvar_in%acid_hyd_shell_param%i_oxygens_acid)
1614 0 : ALLOCATE (colvar_out%acid_hyd_shell_param%i_oxygens_acid(ndim))
1615 0 : ndim = SIZE(colvar_in%acid_hyd_shell_param%i_hydrogens)
1616 0 : ALLOCATE (colvar_out%acid_hyd_shell_param%i_hydrogens(ndim))
1617 0 : colvar_out%acid_hyd_shell_param%i_oxygens_water = colvar_in%acid_hyd_shell_param%i_oxygens_water + my_offset
1618 0 : colvar_out%acid_hyd_shell_param%i_oxygens_acid = colvar_in%acid_hyd_shell_param%i_oxygens_acid + my_offset
1619 0 : colvar_out%acid_hyd_shell_param%i_hydrogens = colvar_in%acid_hyd_shell_param%i_hydrogens + my_offset
1620 : CASE (reaction_path_colvar_id, distance_from_path_colvar_id)
1621 6 : colvar_out%reaction_path_param%dist_rmsd = colvar_in%reaction_path_param%dist_rmsd
1622 6 : colvar_out%reaction_path_param%rmsd = colvar_in%reaction_path_param%rmsd
1623 6 : colvar_out%reaction_path_param%nr_frames = colvar_in%reaction_path_param%nr_frames
1624 6 : IF (colvar_in%reaction_path_param%dist_rmsd .OR. colvar_in%reaction_path_param%rmsd) THEN
1625 0 : colvar_out%reaction_path_param%align_frames = colvar_in%reaction_path_param%align_frames
1626 0 : colvar_out%reaction_path_param%subset = colvar_in%reaction_path_param%subset
1627 0 : ndim = SIZE(colvar_in%reaction_path_param%i_rmsd)
1628 0 : ALLOCATE (colvar_out%reaction_path_param%i_rmsd(ndim))
1629 0 : colvar_out%reaction_path_param%i_rmsd = colvar_in%reaction_path_param%i_rmsd
1630 0 : ndim = SIZE(colvar_in%reaction_path_param%r_ref, 1)
1631 0 : ndim2 = SIZE(colvar_in%reaction_path_param%r_ref, 2)
1632 0 : ALLOCATE (colvar_out%reaction_path_param%r_ref(ndim, ndim2))
1633 0 : colvar_out%reaction_path_param%r_ref = colvar_in%reaction_path_param%r_ref
1634 : ELSE
1635 6 : ndim = SIZE(colvar_in%reaction_path_param%colvar_p)
1636 30 : ALLOCATE (colvar_out%reaction_path_param%colvar_p(ndim))
1637 18 : DO i = 1, ndim
1638 : CALL colvar_clone(colvar_out%reaction_path_param%colvar_p(i)%colvar, &
1639 : colvar_in%reaction_path_param%colvar_p(i)%colvar, &
1640 18 : my_offset)
1641 : END DO
1642 18 : colvar_out%reaction_path_param%function_bounds = colvar_in%reaction_path_param%function_bounds
1643 6 : ndim = SIZE(colvar_in%reaction_path_param%f_vals, 1)
1644 6 : ndim2 = SIZE(colvar_in%reaction_path_param%f_vals, 2)
1645 24 : ALLOCATE (colvar_out%reaction_path_param%f_vals(ndim, ndim2))
1646 70224 : colvar_out%reaction_path_param%f_vals = colvar_in%reaction_path_param%f_vals
1647 : END IF
1648 6 : colvar_out%reaction_path_param%step_size = colvar_in%reaction_path_param%step_size
1649 6 : colvar_out%reaction_path_param%n_components = colvar_in%reaction_path_param%n_components
1650 6 : colvar_out%reaction_path_param%lambda = colvar_in%reaction_path_param%lambda
1651 : CASE (combine_colvar_id)
1652 8 : ndim = SIZE(colvar_in%combine_cvs_param%colvar_p)
1653 40 : ALLOCATE (colvar_out%combine_cvs_param%colvar_p(ndim))
1654 24 : DO i = 1, ndim
1655 : CALL colvar_clone(colvar_out%combine_cvs_param%colvar_p(i)%colvar, &
1656 : colvar_in%combine_cvs_param%colvar_p(i)%colvar, &
1657 24 : my_offset)
1658 : END DO
1659 8 : colvar_out%combine_cvs_param%lerr = colvar_in%combine_cvs_param%lerr
1660 8 : colvar_out%combine_cvs_param%dx = colvar_in%combine_cvs_param%dx
1661 8 : colvar_out%combine_cvs_param%function = colvar_in%combine_cvs_param%function
1662 : !
1663 8 : ndim = SIZE(colvar_in%combine_cvs_param%c_parameters)
1664 24 : ALLOCATE (colvar_out%combine_cvs_param%c_parameters(ndim))
1665 16 : colvar_out%combine_cvs_param%c_parameters = colvar_in%combine_cvs_param%c_parameters
1666 : !
1667 8 : ndim = SIZE(colvar_in%combine_cvs_param%v_parameters)
1668 24 : ALLOCATE (colvar_out%combine_cvs_param%v_parameters(ndim))
1669 16 : colvar_out%combine_cvs_param%v_parameters = colvar_in%combine_cvs_param%v_parameters
1670 : !
1671 8 : ndim = SIZE(colvar_in%combine_cvs_param%variables)
1672 24 : ALLOCATE (colvar_out%combine_cvs_param%variables(ndim))
1673 24 : colvar_out%combine_cvs_param%variables = colvar_in%combine_cvs_param%variables
1674 : CASE (rmsd_colvar_id)
1675 0 : colvar_out%rmsd_param%n_atoms = colvar_in%rmsd_param%n_atoms
1676 0 : colvar_out%rmsd_param%align_frames = colvar_in%rmsd_param%align_frames
1677 0 : colvar_out%rmsd_param%nr_frames = colvar_in%rmsd_param%nr_frames
1678 0 : colvar_out%rmsd_param%subset = colvar_in%rmsd_param%subset
1679 : ! INDEX
1680 0 : ndim = SIZE(colvar_in%rmsd_param%i_rmsd)
1681 0 : ALLOCATE (colvar_out%rmsd_param%i_rmsd(ndim))
1682 0 : colvar_out%rmsd_param%i_rmsd = colvar_in%rmsd_param%i_rmsd + my_offset
1683 : ! A and Bconfigurations and weights
1684 0 : ndim = SIZE(colvar_in%rmsd_param%weights)
1685 0 : ALLOCATE (colvar_out%rmsd_param%weights(ndim))
1686 0 : colvar_out%rmsd_param%weights = colvar_in%rmsd_param%weights
1687 0 : ndim = SIZE(colvar_in%rmsd_param%r_ref, 1)
1688 0 : ndim2 = SIZE(colvar_in%rmsd_param%r_ref, 2)
1689 0 : ALLOCATE (colvar_out%rmsd_param%r_ref(ndim, ndim2))
1690 0 : colvar_out%rmsd_param%r_ref = colvar_in%rmsd_param%r_ref
1691 : CASE (Wc_colvar_id)
1692 0 : colvar_out%Wc%ids = colvar_in%Wc%ids + my_offset
1693 0 : colvar_out%Wc%rcut = colvar_in%Wc%rcut
1694 : CASE (HBP_colvar_id)
1695 0 : ndim = colvar_out%HBP%nPoints
1696 0 : ALLOCATE (colvar_out%HBP%ids(ndim, 3))
1697 0 : ALLOCATE (colvar_out%HBP%ewc(ndim))
1698 0 : colvar_out%HBP%ids = colvar_in%HBP%ids + my_offset
1699 0 : colvar_out%HBP%ewc = colvar_in%HBP%ewc + my_offset
1700 0 : colvar_out%HBP%nPoints = colvar_in%HBP%nPoints
1701 0 : colvar_out%HBP%rcut = colvar_in%HBP%rcut
1702 0 : colvar_out%HBP%shift = colvar_in%HBP%shift
1703 : CASE (ring_puckering_colvar_id)
1704 0 : ndim = colvar_in%ring_puckering_param%nring
1705 0 : colvar_out%ring_puckering_param%nring = colvar_in%ring_puckering_param%nring
1706 0 : colvar_out%ring_puckering_param%iq = colvar_in%ring_puckering_param%iq
1707 0 : ALLOCATE (colvar_out%ring_puckering_param%atoms(ndim))
1708 0 : colvar_out%ring_puckering_param%atoms = colvar_in%ring_puckering_param%atoms + my_offset
1709 : CASE (mindist_colvar_id)
1710 0 : colvar_out%mindist_param%n_dist_from = colvar_in%mindist_param%n_dist_from
1711 0 : colvar_out%mindist_param%n_coord_to = colvar_in%mindist_param%n_coord_to
1712 0 : colvar_out%mindist_param%n_coord_from = colvar_in%mindist_param%n_coord_from
1713 0 : colvar_out%mindist_param%p_exp = colvar_in%mindist_param%p_exp
1714 0 : colvar_out%mindist_param%q_exp = colvar_in%mindist_param%q_exp
1715 0 : colvar_out%mindist_param%r_cut = colvar_in%mindist_param%r_cut
1716 0 : colvar_out%mindist_param%lambda = colvar_in%mindist_param%lambda
1717 0 : colvar_out%mindist_param%use_kinds_from = colvar_in%mindist_param%use_kinds_from
1718 0 : colvar_out%mindist_param%use_kinds_to = colvar_in%mindist_param%use_kinds_to
1719 : ! INDEX
1720 0 : ndim = SIZE(colvar_in%mindist_param%i_dist_from)
1721 0 : ALLOCATE (colvar_out%mindist_param%i_dist_from(ndim))
1722 0 : colvar_out%mindist_param%i_dist_from = colvar_in%mindist_param%i_dist_from + my_offset
1723 0 : IF (colvar_in%mindist_param%use_kinds_from) THEN
1724 : ! KINDS
1725 0 : ndim = SIZE(colvar_in%mindist_param%k_coord_from)
1726 0 : ALLOCATE (colvar_out%mindist_param%k_coord_from(ndim))
1727 0 : colvar_out%mindist_param%k_coord_from = colvar_in%mindist_param%k_coord_from
1728 : ELSE
1729 : ! INDEX
1730 0 : ndim = SIZE(colvar_in%mindist_param%i_coord_from)
1731 0 : ALLOCATE (colvar_out%mindist_param%i_coord_from(ndim))
1732 0 : colvar_out%mindist_param%i_coord_from = colvar_in%mindist_param%i_coord_from + my_offset
1733 : END IF
1734 4986 : IF (colvar_in%mindist_param%use_kinds_to) THEN
1735 : ! KINDS
1736 0 : ndim = SIZE(colvar_in%mindist_param%k_coord_to)
1737 0 : ALLOCATE (colvar_out%mindist_param%k_coord_to(ndim))
1738 0 : colvar_out%mindist_param%k_coord_to = colvar_in%mindist_param%k_coord_to
1739 : ELSE
1740 : ! INDEX
1741 0 : ndim = SIZE(colvar_in%mindist_param%i_coord_to)
1742 0 : ALLOCATE (colvar_out%mindist_param%i_coord_to(ndim))
1743 0 : colvar_out%mindist_param%i_coord_to = colvar_in%mindist_param%i_coord_to + my_offset
1744 : END IF
1745 :
1746 : END SELECT
1747 4986 : CALL colvar_setup(colvar_out)
1748 4986 : END SUBROUTINE colvar_clone
1749 :
1750 : ! **************************************************************************************************
1751 : !> \brief Clone points type of a colvar type
1752 : !> \param colvar_out ...
1753 : !> \param colvar_in the colvar to deallocate
1754 : !> \param offset ...
1755 : !> \author Teodoro Laino [tlaino] 03.2007
1756 : ! **************************************************************************************************
1757 4986 : SUBROUTINE colvar_clone_points(colvar_out, colvar_in, offset)
1758 : TYPE(colvar_type), INTENT(INOUT) :: colvar_out
1759 : TYPE(colvar_type), INTENT(IN) :: colvar_in
1760 : INTEGER, INTENT(IN) :: offset
1761 :
1762 : INTEGER :: i, natoms, npoints
1763 :
1764 4986 : colvar_out%use_points = colvar_in%use_points
1765 4986 : IF (colvar_in%use_points) THEN
1766 74 : CPASSERT(ASSOCIATED(colvar_in%points))
1767 74 : npoints = SIZE(colvar_in%points)
1768 634 : ALLOCATE (colvar_out%points(npoints))
1769 264 : DO i = 1, npoints
1770 190 : IF (ASSOCIATED(colvar_in%points(i)%atoms)) THEN
1771 182 : natoms = SIZE(colvar_in%points(i)%atoms)
1772 546 : ALLOCATE (colvar_out%points(i)%atoms(natoms))
1773 444 : colvar_out%points(i)%atoms = colvar_in%points(i)%atoms + offset
1774 : ELSE
1775 8 : NULLIFY (colvar_out%points(i)%atoms)
1776 : END IF
1777 190 : IF (ASSOCIATED(colvar_in%points(i)%weights)) THEN
1778 182 : natoms = SIZE(colvar_in%points(i)%weights)
1779 546 : ALLOCATE (colvar_out%points(i)%weights(natoms))
1780 444 : colvar_out%points(i)%weights = colvar_in%points(i)%weights
1781 : ELSE
1782 8 : NULLIFY (colvar_out%points(i)%weights)
1783 : END IF
1784 190 : colvar_out%points(i)%type_id = colvar_in%points(i)%type_id
1785 834 : colvar_out%points(i)%r = colvar_in%points(i)%r
1786 : END DO
1787 : ELSE
1788 4912 : NULLIFY (colvar_out%points)
1789 : END IF
1790 :
1791 4986 : END SUBROUTINE colvar_clone_points
1792 :
1793 : ! **************************************************************************************************
1794 : !> \brief Change the dimension of a colvar_p_type
1795 : !> \param colvar_set ...
1796 : !> \param lb1_new ...
1797 : !> \param ub1_new ...
1798 : !> \author Teodoro Laino [tlaino] 04.2006
1799 : ! **************************************************************************************************
1800 16 : SUBROUTINE colvar_p_reallocate(colvar_set, lb1_new, ub1_new)
1801 : TYPE(colvar_p_type), DIMENSION(:), POINTER :: colvar_set
1802 : INTEGER, INTENT(IN) :: lb1_new, ub1_new
1803 :
1804 : INTEGER :: j, lb1, lb1_old, ub1, ub1_old
1805 16 : TYPE(colvar_p_type), DIMENSION(:), POINTER :: work
1806 :
1807 16 : NULLIFY (work)
1808 16 : IF (ASSOCIATED(colvar_set)) THEN
1809 0 : lb1_old = LBOUND(colvar_set, 1)
1810 0 : ub1_old = UBOUND(colvar_set, 1)
1811 0 : lb1 = MAX(lb1_new, lb1_old)
1812 0 : ub1 = MIN(ub1_new, ub1_old)
1813 0 : ALLOCATE (work(lb1:ub1))
1814 0 : DO j = lb1, ub1
1815 0 : CALL colvar_clone(work(j)%colvar, colvar_set(j)%colvar)
1816 : END DO
1817 0 : DO j = lb1, ub1
1818 0 : CALL colvar_release(colvar_set(j)%colvar)
1819 : END DO
1820 0 : DEALLOCATE (colvar_set)
1821 : END IF
1822 :
1823 228 : ALLOCATE (colvar_set(lb1_new:ub1_new))
1824 :
1825 16 : IF (ASSOCIATED(work)) THEN
1826 0 : lb1 = MAX(lb1_new, lb1_old)
1827 0 : ub1 = MIN(ub1_new, ub1_old)
1828 0 : DO j = lb1, ub1
1829 0 : CALL colvar_clone(colvar_set(j)%colvar, work(j)%colvar)
1830 : END DO
1831 0 : DO j = lb1, ub1
1832 0 : CALL colvar_release(work(j)%colvar)
1833 : END DO
1834 0 : DEALLOCATE (work)
1835 : END IF
1836 16 : END SUBROUTINE colvar_p_reallocate
1837 :
1838 : ! **************************************************************************************************
1839 : !> \brief Deallocate a set of colvar_p_type
1840 : !> \param colvar_p ...
1841 : !> \par History
1842 : !> 07.2003 created [fawzi]
1843 : !> 01.2014 moved from cp_subsys_release() into separate routine.
1844 : !> \author Ole Schuett
1845 : ! **************************************************************************************************
1846 11500 : SUBROUTINE colvar_p_release(colvar_p)
1847 : TYPE(colvar_p_type), DIMENSION(:), POINTER :: colvar_p
1848 :
1849 : INTEGER :: i
1850 :
1851 : ! Colvar info
1852 :
1853 11500 : IF (ASSOCIATED(colvar_p)) THEN
1854 11413 : DO i = 1, SIZE(colvar_p)
1855 11413 : IF (ASSOCIATED(colvar_p(i)%colvar)) THEN
1856 466 : CALL colvar_release(colvar_p(i)%colvar)
1857 : END IF
1858 : END DO
1859 10947 : DEALLOCATE (colvar_p)
1860 : END IF
1861 11500 : END SUBROUTINE colvar_p_release
1862 :
1863 : ! **************************************************************************************************
1864 : !> \brief Evaluate the position of the geometrical point
1865 : !> \param point ...
1866 : !> \param particles ...
1867 : !> \param r ...
1868 : !> \author Teodoro Laino - 03.2007
1869 : ! **************************************************************************************************
1870 8644 : SUBROUTINE eval_point_pos(point, particles, r)
1871 : TYPE(point_type), INTENT(IN) :: point
1872 : TYPE(particle_type), DIMENSION(:), INTENT(IN) :: particles
1873 : REAL(KIND=dp), DIMENSION(3), INTENT(OUT) :: r
1874 :
1875 : INTEGER :: i
1876 :
1877 17186 : SELECT CASE (point%type_id)
1878 : CASE (do_clv_geo_center)
1879 8542 : r = 0.0_dp
1880 18088 : DO i = 1, SIZE(point%atoms)
1881 46726 : r = r + particles(point%atoms(i))%r*point%weights(i)
1882 : END DO
1883 : CASE (do_clv_fix_point)
1884 9052 : r = point%r
1885 : END SELECT
1886 :
1887 8644 : END SUBROUTINE eval_point_pos
1888 :
1889 : ! **************************************************************************************************
1890 : !> \brief ...
1891 : !> \param point ...
1892 : !> \param particles ...
1893 : !> \param m ...
1894 : ! **************************************************************************************************
1895 0 : SUBROUTINE eval_point_mass(point, particles, m)
1896 : TYPE(point_type), INTENT(IN) :: point
1897 : TYPE(particle_type), DIMENSION(:), INTENT(IN) :: particles
1898 : REAL(KIND=dp), INTENT(OUT) :: m
1899 :
1900 : INTEGER :: i
1901 :
1902 0 : SELECT CASE (point%type_id)
1903 : CASE (do_clv_geo_center)
1904 0 : m = 0.0_dp
1905 0 : DO i = 1, SIZE(point%atoms)
1906 0 : m = m + particles(point%atoms(i))%atomic_kind%mass*point%weights(i)
1907 : END DO
1908 : CASE (do_clv_fix_point)
1909 0 : m = 0.0_dp
1910 : END SELECT
1911 :
1912 0 : END SUBROUTINE eval_point_mass
1913 :
1914 : ! **************************************************************************************************
1915 : !> \brief Evaluate the position of the geometrical point
1916 : !> \param points ...
1917 : !> \param i ...
1918 : !> \param dsdr ...
1919 : !> \param f ...
1920 : !> \author Teodoro Laino - 03.2007
1921 : ! **************************************************************************************************
1922 8664 : SUBROUTINE eval_point_der(points, i, dsdr, f)
1923 : TYPE(point_type), DIMENSION(:), INTENT(IN) :: points
1924 : INTEGER, INTENT(IN) :: i
1925 : REAL(KIND=dp), DIMENSION(:, :), INTENT(INOUT) :: dsdr
1926 : REAL(KIND=dp), DIMENSION(3), INTENT(IN) :: f
1927 :
1928 : INTEGER :: ind, j
1929 : REAL(KIND=dp) :: fac
1930 :
1931 8664 : SELECT CASE (points(i)%type_id)
1932 : CASE (do_clv_geo_center)
1933 : ind = 0
1934 17054 : DO j = 1, i - 1
1935 17054 : IF (ASSOCIATED(points(j)%atoms)) THEN
1936 8492 : ind = ind + SIZE(points(j)%atoms)
1937 : END IF
1938 : END DO
1939 26792 : DO j = 1, SIZE(points(i)%atoms)
1940 9566 : fac = points(i)%weights(j)
1941 46826 : dsdr(:, ind + j) = dsdr(:, ind + j) + f*fac
1942 : END DO
1943 : CASE (do_clv_fix_point)
1944 : ! Do nothing if it's a fixed point in space
1945 : END SELECT
1946 :
1947 8664 : END SUBROUTINE eval_point_der
1948 :
1949 : ! **************************************************************************************************
1950 : !> \brief subtract b from the ss value of a colvar: general function for handling
1951 : !> periodic/non-periodic colvar
1952 : !> \param colvar ...
1953 : !> \param b ...
1954 : !> \return ...
1955 : !> \author Teodoro Laino [tlaino] - University of Zurich 10.2008
1956 : ! **************************************************************************************************
1957 366739 : FUNCTION diff_colvar(colvar, b) RESULT(diff)
1958 : TYPE(colvar_type), INTENT(IN) :: colvar
1959 : REAL(KIND=dp), INTENT(IN) :: b
1960 : REAL(KIND=dp) :: diff
1961 :
1962 366739 : diff = colvar%ss - b
1963 366739 : IF (colvar%type_id == torsion_colvar_id) THEN
1964 : ! The difference of a periodic COLVAR is always within [-pi,pi]
1965 1584 : diff = SIGN(1.0_dp, ASIN(SIN(diff)))*ACOS(COS(diff))
1966 : END IF
1967 366739 : END FUNCTION diff_colvar
1968 :
1969 0 : END MODULE colvar_types
|