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