(git:a145afa)
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, &
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! **************************************************************************************************
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! **************************************************************************************************
384 TYPE(colvar_type), POINTER :: colvar => null()
385 END TYPE colvar_p_type
386
387! **************************************************************************************************
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
412CONTAINS
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 SUBROUTINE colvar_create(colvar, colvar_id)
421 TYPE(colvar_type), POINTER :: colvar
422 INTEGER, INTENT(in) :: colvar_id
423
424 cpassert(.NOT. ASSOCIATED(colvar))
425 ALLOCATE (colvar)
426 colvar%type_id = colvar_id
427 colvar%use_points = .false.
428 SELECT CASE (colvar_id)
429 CASE (dist_colvar_id)
430 ALLOCATE (colvar%dist_param)
431 colvar%dist_param%axis_id = do_clv_xyz
432 colvar%dist_param%sign_d = .false.
433 CASE (coord_colvar_id)
434 ALLOCATE (colvar%coord_param)
436 ALLOCATE (colvar%population_param)
437 CASE (gyration_colvar_id)
438 ALLOCATE (colvar%gyration_param)
439 CASE (angle_colvar_id)
440 ALLOCATE (colvar%angle_param)
441 CASE (torsion_colvar_id)
442 ALLOCATE (colvar%torsion_param)
444 ALLOCATE (colvar%plane_distance_param)
446 ALLOCATE (colvar%plane_plane_angle_param)
447 CASE (rotation_colvar_id)
448 ALLOCATE (colvar%rotation_param)
449 CASE (dfunct_colvar_id)
450 ALLOCATE (colvar%dfunct_param)
451 CASE (qparm_colvar_id)
452 ALLOCATE (colvar%qparm_param)
453 CASE (xyz_diag_colvar_id)
454 ALLOCATE (colvar%xyz_diag_param)
455 ! Initialize r0 with dummy..
456 colvar%xyz_diag_param%r0 = huge(0.0_dp)
458 ALLOCATE (colvar%xyz_outerdiag_param)
459 ! Initialize r0 with dummy..
460 colvar%xyz_outerdiag_param%r0 = huge(0.0_dp)
461 CASE (u_colvar_id)
462 ALLOCATE (colvar%u_param)
463 NULLIFY (colvar%u_param%mixed_energy_section)
465 ALLOCATE (colvar%hydronium_shell_param)
467 ALLOCATE (colvar%hydronium_dist_param)
469 ALLOCATE (colvar%acid_hyd_dist_param)
471 ALLOCATE (colvar%acid_hyd_shell_param)
473 ALLOCATE (colvar%reaction_path_param)
475 ALLOCATE (colvar%reaction_path_param)
476 CASE (combine_colvar_id)
477 ALLOCATE (colvar%combine_cvs_param)
478 CASE (rmsd_colvar_id)
479 ALLOCATE (colvar%rmsd_param)
480 CASE (wc_colvar_id)
481 ALLOCATE (colvar%Wc)
482 CASE (hbp_colvar_id)
483 ALLOCATE (colvar%HBP)
485 ALLOCATE (colvar%ring_puckering_param)
486 CASE (mindist_colvar_id)
487 ALLOCATE (colvar%mindist_param)
488 CASE (no_colvar_id)
489 ! Do nothing
490 CASE DEFAULT
491 cpabort("Unknown colvar type")
492 END SELECT
493
494 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 SUBROUTINE colvar_setup(colvar)
502 TYPE(colvar_type), INTENT(INOUT) :: colvar
503
504 INTEGER :: i, idum, iend, ii, istart, j, np
505 INTEGER, DIMENSION(:), POINTER :: list
506
507 SELECT CASE (colvar%type_id)
508 CASE (dist_colvar_id)
509 np = 2
510 i = colvar%dist_param%i_at
511 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 colv_size(colvar, j)
515 ! Create a List of points...
516 ALLOCATE (list(np))
517 list(1) = colvar%dist_param%i_at
518 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 + colvar%coord_param%n_atoms_to_b
522 ! Number of real atoms involved in the colvar
523 colvar%n_atom_s = 0
524 DO ii = 1, colvar%coord_param%n_atoms_from
525 i = colvar%coord_param%i_at_from(ii)
526 colvar%n_atom_s = colvar%n_atom_s + colv_size(colvar, i)
527 END DO
528 DO ii = 1, colvar%coord_param%n_atoms_to
529 i = colvar%coord_param%i_at_to(ii)
530 colvar%n_atom_s = colvar%n_atom_s + colv_size(colvar, i)
531 END DO
532 IF (colvar%coord_param%n_atoms_to_b /= 0) THEN
533 DO ii = 1, colvar%coord_param%n_atoms_to_b
534 i = colvar%coord_param%i_at_to_b(ii)
535 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 ALLOCATE (list(np))
540 idum = 0
541 DO ii = 1, colvar%coord_param%n_atoms_from
542 idum = idum + 1
543 i = colvar%coord_param%i_at_from(ii)
544 list(idum) = i
545 END DO
546 DO ii = 1, colvar%coord_param%n_atoms_to
547 idum = idum + 1
548 i = colvar%coord_param%i_at_to(ii)
549 list(idum) = i
550 END DO
551 IF (colvar%coord_param%n_atoms_to_b /= 0) THEN
552 DO ii = 1, colvar%coord_param%n_atoms_to_b
553 idum = idum + 1
554 i = colvar%coord_param%i_at_to_b(ii)
555 list(idum) = i
556 END DO
557 END IF
558 cpassert(idum == np)
560 np = colvar%population_param%n_atoms_from + colvar%population_param%n_atoms_to
561 ! Number of real atoms involved in the colvar
562 colvar%n_atom_s = 0
563 DO ii = 1, colvar%population_param%n_atoms_from
564 i = colvar%population_param%i_at_from(ii)
565 colvar%n_atom_s = colvar%n_atom_s + colv_size(colvar, i)
566 END DO
567 DO ii = 1, colvar%population_param%n_atoms_to
568 i = colvar%population_param%i_at_to(ii)
569 colvar%n_atom_s = colvar%n_atom_s + colv_size(colvar, i)
570 END DO
571 ! Create a List of points...
572 ALLOCATE (list(np))
573 idum = 0
574 DO ii = 1, colvar%population_param%n_atoms_from
575 idum = idum + 1
576 i = colvar%population_param%i_at_from(ii)
577 list(idum) = i
578 END DO
579 DO ii = 1, colvar%population_param%n_atoms_to
580 idum = idum + 1
581 i = colvar%population_param%i_at_to(ii)
582 list(idum) = i
583 END DO
584 cpassert(idum == np)
585 CASE (gyration_colvar_id)
586 np = colvar%gyration_param%n_atoms
587 ! Number of real atoms involved in the colvar
588 colvar%n_atom_s = 0
589 DO ii = 1, colvar%gyration_param%n_atoms
590 i = colvar%gyration_param%i_at(ii)
591 colvar%n_atom_s = colvar%n_atom_s + colv_size(colvar, i)
592 END DO
593 ! Create a List of points...
594 ALLOCATE (list(np))
595 idum = 0
596 DO ii = 1, colvar%gyration_param%n_atoms
597 idum = idum + 1
598 i = colvar%gyration_param%i_at(ii)
599 list(idum) = i
600 END DO
601 cpassert(idum == np)
602 CASE (angle_colvar_id)
603 np = 3
604 ! Number of real atoms involved in the colvar
605 colvar%n_atom_s = 0
606 DO ii = 1, 3
607 i = colvar%angle_param%i_at_angle(ii)
608 colvar%n_atom_s = colvar%n_atom_s + colv_size(colvar, i)
609 END DO
610 ! Create a List of points...
611 ALLOCATE (list(np))
612 idum = 0
613 DO ii = 1, 3
614 idum = idum + 1
615 i = colvar%angle_param%i_at_angle(ii)
616 list(idum) = i
617 END DO
618 cpassert(idum == np)
619 CASE (torsion_colvar_id)
620 np = 4
621 ! Number of real atoms involved in the colvar
622 colvar%n_atom_s = 0
623 DO ii = 1, 4
624 i = colvar%torsion_param%i_at_tors(ii)
625 colvar%n_atom_s = colvar%n_atom_s + colv_size(colvar, i)
626 END DO
627 ! Create a List of points...
628 ALLOCATE (list(np))
629 idum = 0
630 DO ii = 1, 4
631 idum = idum + 1
632 i = colvar%torsion_param%i_at_tors(ii)
633 list(idum) = i
634 END DO
635 cpassert(idum == np)
637 np = 4
638 ! Number of real atoms involved in the colvar
639 colvar%n_atom_s = 0
640 DO ii = 1, 3
641 i = colvar%plane_distance_param%plane(ii)
642 colvar%n_atom_s = colvar%n_atom_s + colv_size(colvar, i)
643 END DO
644 i = colvar%plane_distance_param%point
645 colvar%n_atom_s = colvar%n_atom_s + colv_size(colvar, i)
646 ! Create a List of points...
647 ALLOCATE (list(np))
648 idum = 0
649 DO ii = 1, 3
650 idum = idum + 1
651 i = colvar%plane_distance_param%plane(ii)
652 list(idum) = i
653 END DO
654 i = colvar%plane_distance_param%point
655 list(4) = i
656 idum = idum + 1
657 cpassert(idum == np)
659 np = 0
660 IF (colvar%plane_plane_angle_param%plane1%type_of_def == plane_def_atoms) np = np + 3
661 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 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 "using atomic positions.")
668 END IF
669
670 ! Number of real atoms involved in the colvar
671 colvar%n_atom_s = 0
672 IF (colvar%plane_plane_angle_param%plane1%type_of_def == plane_def_atoms) THEN
673 DO ii = 1, 3
674 i = colvar%plane_plane_angle_param%plane1%points(ii)
675 colvar%n_atom_s = colvar%n_atom_s + colv_size(colvar, i)
676 END DO
677 END IF
678 IF (colvar%plane_plane_angle_param%plane2%type_of_def == plane_def_atoms) THEN
679 DO ii = 1, 3
680 i = colvar%plane_plane_angle_param%plane2%points(ii)
681 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 ALLOCATE (list(np))
687 idum = 0
688 IF (colvar%plane_plane_angle_param%plane1%type_of_def == plane_def_atoms) THEN
689 DO ii = 1, 3
690 idum = idum + 1
691 i = colvar%plane_plane_angle_param%plane1%points(ii)
692 list(idum) = i
693 END DO
694 END IF
695 IF (colvar%plane_plane_angle_param%plane2%type_of_def == plane_def_atoms) THEN
696 DO ii = 1, 3
697 idum = idum + 1
698 i = colvar%plane_plane_angle_param%plane2%points(ii)
699 list(idum) = i
700 END DO
701 END IF
702 cpassert(idum == np)
703 CASE (dfunct_colvar_id)
704 np = 4
705 ! Number of real atoms involved in the colvar
706 colvar%n_atom_s = 0
707 DO ii = 1, 4
708 i = colvar%dfunct_param%i_at_dfunct(ii)
709 colvar%n_atom_s = colvar%n_atom_s + colv_size(colvar, i)
710 END DO
711 ! Create a List of points...
712 ALLOCATE (list(np))
713 idum = 0
714 DO ii = 1, 4
715 idum = idum + 1
716 i = colvar%dfunct_param%i_at_dfunct(ii)
717 list(idum) = i
718 END DO
719 cpassert(idum == np)
720 CASE (rotation_colvar_id)
721 np = 4
722 ! Number of real atoms involved in the colvar
723 colvar%n_atom_s = 0
724 i = colvar%rotation_param%i_at1_bond1
725 colvar%n_atom_s = colvar%n_atom_s + colv_size(colvar, i)
726 i = colvar%rotation_param%i_at2_bond1
727 colvar%n_atom_s = colvar%n_atom_s + colv_size(colvar, i)
728 i = colvar%rotation_param%i_at1_bond2
729 colvar%n_atom_s = colvar%n_atom_s + colv_size(colvar, i)
730 i = colvar%rotation_param%i_at2_bond2
731 colvar%n_atom_s = colvar%n_atom_s + colv_size(colvar, i)
732 ! Create a List of points...
733 ALLOCATE (list(np))
734 i = colvar%rotation_param%i_at1_bond1
735 list(1) = i
736 i = colvar%rotation_param%i_at2_bond1
737 list(2) = i
738 i = colvar%rotation_param%i_at1_bond2
739 list(3) = i
740 i = colvar%rotation_param%i_at2_bond2
741 list(4) = i
742 CASE (qparm_colvar_id)
743 np = colvar%qparm_param%n_atoms_from + colvar%qparm_param%n_atoms_to
744 ! Number of real atoms involved in the colvar
745 colvar%n_atom_s = 0
746 DO ii = 1, colvar%qparm_param%n_atoms_from
747 i = colvar%qparm_param%i_at_from(ii)
748 colvar%n_atom_s = colvar%n_atom_s + colv_size(colvar, i)
749 END DO
750 DO ii = 1, colvar%qparm_param%n_atoms_to
751 i = colvar%qparm_param%i_at_to(ii)
752 colvar%n_atom_s = colvar%n_atom_s + colv_size(colvar, i)
753 END DO
754 ! Create a List of points...
755 ALLOCATE (list(np))
756 idum = 0
757 DO ii = 1, colvar%qparm_param%n_atoms_from
758 idum = idum + 1
759 i = colvar%qparm_param%i_at_from(ii)
760 list(idum) = i
761 END DO
762 DO ii = 1, colvar%qparm_param%n_atoms_to
763 idum = idum + 1
764 i = colvar%qparm_param%i_at_to(ii)
765 list(idum) = i
766 END DO
767 cpassert(idum == np)
769 np = colvar%hydronium_shell_param%n_oxygens + colvar%hydronium_shell_param%n_hydrogens
770 ALLOCATE (list(np))
771 CALL setup_hydronium_colvars(colvar, hydronium_shell_colvar_id, list)
773 np = colvar%hydronium_dist_param%n_oxygens + colvar%hydronium_dist_param%n_hydrogens
774 ALLOCATE (list(np))
775 CALL setup_hydronium_colvars(colvar, hydronium_dist_colvar_id, list)
777 np = colvar%acid_hyd_dist_param%n_oxygens_water &
778 + colvar%acid_hyd_dist_param%n_oxygens_acid &
779 + colvar%acid_hyd_dist_param%n_hydrogens
780 ALLOCATE (list(np))
781 CALL setup_acid_hydronium_colvars(colvar, acid_hyd_dist_colvar_id, list)
783 np = colvar%acid_hyd_shell_param%n_oxygens_water &
784 + colvar%acid_hyd_shell_param%n_oxygens_acid &
785 + colvar%acid_hyd_shell_param%n_hydrogens
786 ALLOCATE (list(np))
787 CALL setup_acid_hydronium_colvars(colvar, acid_hyd_shell_colvar_id, list)
788 CASE (rmsd_colvar_id)
789 np = colvar%rmsd_param%n_atoms
790 ! Number of real atoms involved in the colvar
791 colvar%n_atom_s = 0
792 DO ii = 1, colvar%rmsd_param%n_atoms
793 i = colvar%rmsd_param%i_rmsd(ii)
794 colvar%n_atom_s = colvar%n_atom_s + colv_size(colvar, i)
795 END DO
796 ! Create a List of points...
797 ALLOCATE (list(np))
798 idum = 0
799 DO ii = 1, colvar%rmsd_param%n_atoms
800 idum = idum + 1
801 i = colvar%rmsd_param%i_rmsd(ii)
802 list(idum) = i
803 END DO
805 colvar%n_atom_s = 0
806 IF (colvar%reaction_path_param%dist_rmsd .OR. colvar%reaction_path_param%rmsd) THEN
807 colvar%n_atom_s = colvar%reaction_path_param%n_components
808 ELSE
809 DO ii = 1, SIZE(colvar%reaction_path_param%colvar_p)
810 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 ALLOCATE (list(colvar%n_atom_s))
814 idum = 0
815 IF (colvar%reaction_path_param%dist_rmsd .OR. colvar%reaction_path_param%rmsd) THEN
816 DO ii = 1, SIZE(colvar%reaction_path_param%i_rmsd)
817 idum = idum + 1
818 i = colvar%reaction_path_param%i_rmsd(ii)
819 list(idum) = i
820 END DO
821 ELSE
822 DO ii = 1, SIZE(colvar%reaction_path_param%colvar_p)
823 DO j = 1, colvar%reaction_path_param%colvar_p(ii)%colvar%n_atom_s
824 idum = idum + 1
825 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 np = 1
831 ! Number of real atoms involved in the colvar
832 colvar%n_atom_s = 0
833 i = colvar%xyz_diag_param%i_atom
834 colvar%n_atom_s = colvar%n_atom_s + colv_size(colvar, i)
835 ! Create a List of points...
836 ALLOCATE (list(np))
837 i = colvar%xyz_diag_param%i_atom
838 list(1) = i
840 np = 2
841 ! Number of real atoms involved in the colvar
842 colvar%n_atom_s = 0
843 i = colvar%xyz_outerdiag_param%i_atoms(1)
844 colvar%n_atom_s = colvar%n_atom_s + colv_size(colvar, i)
845 i = colvar%xyz_outerdiag_param%i_atoms(2)
846 colvar%n_atom_s = colvar%n_atom_s + colv_size(colvar, i)
847 ! Create a List of points...
848 ALLOCATE (list(np))
849 i = colvar%xyz_outerdiag_param%i_atoms(1)
850 list(1) = i
851 i = colvar%xyz_outerdiag_param%i_atoms(2)
852 list(2) = i
853 CASE (u_colvar_id)
854 np = 1
855 ALLOCATE (list(np))
856 colvar%n_atom_s = np; list(1) = 1
857 CASE (wc_colvar_id)
858 np = 3
859 ! Number of real atoms involved in the colvar
860 colvar%n_atom_s = 0
861 DO ii = 1, 3
862 i = colvar%Wc%ids(ii)
863 colvar%n_atom_s = colvar%n_atom_s + colv_size(colvar, i)
864 END DO
865 ! Create a List of points...
866 ALLOCATE (list(np))
867 idum = 0
868 DO ii = 1, 3
869 idum = idum + 1
870 i = colvar%Wc%ids(ii)
871 list(idum) = i
872 END DO
873 cpassert(idum == np)
874 CASE (hbp_colvar_id)
875 np = 3*colvar%HBP%nPoints
876 ! Number of real atoms involved in the colvar
877 colvar%n_atom_s = 0
878 DO j = 1, colvar%HBP%nPoints
879 DO ii = 1, 3
880 i = colvar%HBP%ids(j, ii)
881 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 ALLOCATE (list(np))
886 idum = 0
887 DO j = 1, colvar%HBP%nPoints
888 DO ii = 1, 3
889 idum = idum + 1
890 i = colvar%HBP%ids(j, ii)
891 list(idum) = i
892 END DO
893 END DO
894 cpassert(idum == np)
896 np = colvar%ring_puckering_param%nring
897 ! Number of real atoms involved in the colvar
898 colvar%n_atom_s = 0
899 DO ii = 1, colvar%ring_puckering_param%nring
900 i = colvar%ring_puckering_param%atoms(ii)
901 colvar%n_atom_s = colvar%n_atom_s + colv_size(colvar, i)
902 END DO
903 ! Create a List of points...
904 ALLOCATE (list(np))
905 idum = 0
906 DO ii = 1, colvar%ring_puckering_param%nring
907 idum = idum + 1
908 i = colvar%ring_puckering_param%atoms(ii)
909 list(idum) = i
910 END DO
911 cpassert(idum == np)
912 CASE (mindist_colvar_id)
913 np = colvar%mindist_param%n_dist_from + &
914 colvar%mindist_param%n_coord_from + colvar%mindist_param%n_coord_to
915 ! Number of real atoms involved in the colvar
916 colvar%n_atom_s = 0
917 DO ii = 1, colvar%mindist_param%n_dist_from
918 i = colvar%mindist_param%i_dist_from(ii)
919 colvar%n_atom_s = colvar%n_atom_s + colv_size(colvar, i)
920 END DO
921 DO ii = 1, colvar%mindist_param%n_coord_from
922 i = colvar%mindist_param%i_coord_from(ii)
923 colvar%n_atom_s = colvar%n_atom_s + colv_size(colvar, i)
924 END DO
925 DO ii = 1, colvar%mindist_param%n_coord_to
926 i = colvar%mindist_param%i_coord_to(ii)
927 colvar%n_atom_s = colvar%n_atom_s + colv_size(colvar, i)
928 END DO
929 ! Create a List of points...
930 ALLOCATE (list(np))
931 idum = 0
932 DO ii = 1, colvar%mindist_param%n_dist_from
933 idum = idum + 1
934 i = colvar%mindist_param%i_dist_from(ii)
935 list(idum) = i
936 END DO
937 DO ii = 1, colvar%mindist_param%n_coord_from
938 idum = idum + 1
939 i = colvar%mindist_param%i_coord_from(ii)
940 list(idum) = i
941 END DO
942 DO ii = 1, colvar%mindist_param%n_coord_to
943 idum = idum + 1
944 i = colvar%mindist_param%i_coord_to(ii)
945 list(idum) = i
946 END DO
947 cpassert(idum == np)
948 CASE (combine_colvar_id)
949 colvar%n_atom_s = 0
950 DO ii = 1, SIZE(colvar%combine_cvs_param%colvar_p)
951 colvar%n_atom_s = colvar%n_atom_s + colvar%combine_cvs_param%colvar_p(ii)%colvar%n_atom_s
952 END DO
953 ALLOCATE (list(colvar%n_atom_s))
954 idum = 0
955 DO ii = 1, SIZE(colvar%combine_cvs_param%colvar_p)
956 DO j = 1, colvar%combine_cvs_param%colvar_p(ii)%colvar%n_atom_s
957 idum = idum + 1
958 list(idum) = colvar%combine_cvs_param%colvar_p(ii)%colvar%i_atom(j)
959 END DO
960 END DO
961 END SELECT
962
963 IF (ASSOCIATED(colvar%dsdr)) THEN
964 DEALLOCATE (colvar%dsdr)
965 END IF
966 IF (ASSOCIATED(colvar%i_atom)) THEN
967 DEALLOCATE (colvar%i_atom)
968 END IF
969 ALLOCATE (colvar%dsdr(3, colvar%n_atom_s))
970 ALLOCATE (colvar%i_atom(colvar%n_atom_s))
971 ! And now map real atoms
972 istart = 0
973 iend = 0
974 DO i = 1, SIZE(list)
975 IF (.NOT. colvar%use_points) THEN
976 ! No point centers
977 colvar%i_atom(i) = list(i)
978 iend = iend + 1
979 ELSE
980 IF (ASSOCIATED(colvar%points(list(i))%atoms)) THEN
981 iend = istart + SIZE(colvar%points(list(i))%atoms)
982 colvar%i_atom(istart + 1:iend) = colvar%points(list(i))%atoms
983 istart = iend
984 END IF
985 END IF
986 END DO
987 cpassert(iend == colvar%n_atom_s)
988 DEALLOCATE (list)
989
990 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 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 INTEGER, DIMENSION(:), POINTER :: i_hydrogens, i_oxygens
1006
1007 NULLIFY (i_oxygens, i_hydrogens)
1008
1009 SELECT CASE (colvar_id)
1011 n_oxygens = colvar%hydronium_shell_param%n_oxygens
1012 n_hydrogens = colvar%hydronium_shell_param%n_hydrogens
1013 i_oxygens => colvar%hydronium_shell_param%i_oxygens
1014 i_hydrogens => colvar%hydronium_shell_param%i_hydrogens
1016 n_oxygens = colvar%hydronium_dist_param%n_oxygens
1017 n_hydrogens = colvar%hydronium_dist_param%n_hydrogens
1018 i_oxygens => colvar%hydronium_dist_param%i_oxygens
1019 i_hydrogens => colvar%hydronium_dist_param%i_hydrogens
1020 END SELECT
1021
1022 np = n_oxygens + n_hydrogens
1023 ! Number of real atoms involved in the colvar
1024 colvar%n_atom_s = 0
1025 DO ii = 1, n_oxygens
1026 i = i_oxygens(ii)
1027 colvar%n_atom_s = colvar%n_atom_s + colv_size(colvar, i)
1028 END DO
1029 DO ii = 1, n_hydrogens
1030 i = i_hydrogens(ii)
1031 colvar%n_atom_s = colvar%n_atom_s + colv_size(colvar, i)
1032 END DO
1033 idum = 0
1034 DO ii = 1, n_oxygens
1035 idum = idum + 1
1036 i = i_oxygens(ii)
1037 list(idum) = i
1038 IF (any(i_hydrogens == i)) THEN
1039 cpabort("COLVAR: atoms doubled in OXYGENS and HYDROGENS list")
1040 END IF
1041 END DO
1042 DO ii = 1, n_hydrogens
1043 idum = idum + 1
1044 i = i_hydrogens(ii)
1045 list(idum) = i
1046 END DO
1047 cpassert(idum == np)
1048 DO i = 1, np
1049 DO ii = i + 1, np
1050 IF (list(i) == list(ii)) THEN
1051 IF (i <= n_oxygens) THEN
1052 cpabort("atoms doubled in OXYGENS list")
1053 END IF
1054 IF (i > n_oxygens) THEN
1055 cpabort("atoms doubled in HYDROGENS list")
1056 END IF
1057 END IF
1058 END DO
1059 END DO
1060
1061 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 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 INTEGER, DIMENSION(:), POINTER :: i_hydrogens, i_oxygens_acid, &
1079 i_oxygens_water
1080
1081 NULLIFY (i_oxygens_water, i_oxygens_acid, i_hydrogens)
1082
1083 SELECT CASE (colvar_id)
1085 n_oxygens_water = colvar%acid_hyd_dist_param%n_oxygens_water
1086 n_oxygens_acid = colvar%acid_hyd_dist_param%n_oxygens_acid
1087 n_hydrogens = colvar%acid_hyd_dist_param%n_hydrogens
1088 i_oxygens_water => colvar%acid_hyd_dist_param%i_oxygens_water
1089 i_oxygens_acid => colvar%acid_hyd_dist_param%i_oxygens_acid
1090 i_hydrogens => colvar%acid_hyd_dist_param%i_hydrogens
1092 n_oxygens_water = colvar%acid_hyd_shell_param%n_oxygens_water
1093 n_oxygens_acid = colvar%acid_hyd_shell_param%n_oxygens_acid
1094 n_hydrogens = colvar%acid_hyd_shell_param%n_hydrogens
1095 i_oxygens_water => colvar%acid_hyd_shell_param%i_oxygens_water
1096 i_oxygens_acid => colvar%acid_hyd_shell_param%i_oxygens_acid
1097 i_hydrogens => colvar%acid_hyd_shell_param%i_hydrogens
1098 END SELECT
1099
1100 np = n_oxygens_water + n_oxygens_acid + n_hydrogens
1101 ! Number of real atoms involved in the colvar
1102 colvar%n_atom_s = 0
1103 DO ii = 1, n_oxygens_water
1104 i = i_oxygens_water(ii)
1105 colvar%n_atom_s = colvar%n_atom_s + colv_size(colvar, i)
1106 END DO
1107 DO ii = 1, n_oxygens_acid
1108 i = i_oxygens_acid(ii)
1109 colvar%n_atom_s = colvar%n_atom_s + colv_size(colvar, i)
1110 END DO
1111 DO ii = 1, n_hydrogens
1112 i = i_hydrogens(ii)
1113 colvar%n_atom_s = colvar%n_atom_s + colv_size(colvar, i)
1114 END DO
1115 idum = 0
1116 DO ii = 1, n_oxygens_water
1117 idum = idum + 1
1118 i = i_oxygens_water(ii)
1119 list(idum) = i
1120 IF (any(i_hydrogens == i)) THEN
1121 cpabort("COLVAR: atoms doubled in OXYGENS_WATER and HYDROGENS list")
1122 END IF
1123 IF (any(i_oxygens_acid == i)) THEN
1124 cpabort("COLVAR: atoms doubled in OXYGENS_WATER and OXYGENS_ACID list")
1125 END IF
1126 END DO
1127 DO ii = 1, n_oxygens_acid
1128 idum = idum + 1
1129 i = i_oxygens_acid(ii)
1130 list(idum) = i
1131 IF (any(i_hydrogens == i)) THEN
1132 cpabort("COLVAR: atoms doubled in OXYGENS_ACID and HYDROGENS list")
1133 END IF
1134 END DO
1135 DO ii = 1, n_hydrogens
1136 idum = idum + 1
1137 i = i_hydrogens(ii)
1138 list(idum) = i
1139 END DO
1140 cpassert(idum == np)
1141 DO i = 1, np
1142 DO ii = i + 1, np
1143 IF (list(i) == list(ii)) THEN
1144 IF (i <= n_oxygens_water) THEN
1145 cpabort("atoms doubled in OXYGENS_WATER list")
1146 END IF
1147 IF (i > n_oxygens_water .AND. i <= n_oxygens_water + n_oxygens_acid) THEN
1148 cpabort("atoms doubled in OXYGENS_ACID list")
1149 END IF
1150 IF (i > n_oxygens_water + n_oxygens_acid) THEN
1151 cpabort("atoms doubled in HYDROGENS list")
1152 END IF
1153 END IF
1154 END DO
1155 END DO
1156
1157 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 FUNCTION colv_size(colvar, i) RESULT(my_size)
1167 TYPE(colvar_type), INTENT(IN) :: colvar
1168 INTEGER :: i, my_size
1169
1170 my_size = 1
1171 IF (ASSOCIATED(colvar%points)) THEN
1172 IF (ASSOCIATED(colvar%points(i)%atoms)) THEN
1173 my_size = SIZE(colvar%points(i)%atoms)
1174 ELSE
1175 my_size = 0
1176 END IF
1177 END IF
1178 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 RECURSIVE SUBROUTINE colvar_release(colvar)
1186 TYPE(colvar_type), POINTER :: colvar
1187
1188 INTEGER :: i
1189
1190 cpassert(ASSOCIATED(colvar))
1191 IF (ASSOCIATED(colvar%dsdr)) THEN
1192 DEALLOCATE (colvar%dsdr)
1193 END IF
1194 IF (ASSOCIATED(colvar%i_atom)) THEN
1195 DEALLOCATE (colvar%i_atom)
1196 END IF
1197 IF (ASSOCIATED(colvar%points)) THEN
1198 DO i = 1, SIZE(colvar%points)
1199 IF (ASSOCIATED(colvar%points(i)%atoms)) THEN
1200 DEALLOCATE (colvar%points(i)%atoms)
1201 END IF
1202 IF (ASSOCIATED(colvar%points(i)%weights)) THEN
1203 DEALLOCATE (colvar%points(i)%weights)
1204 END IF
1205 END DO
1206 DEALLOCATE (colvar%points)
1207 END IF
1208 SELECT CASE (colvar%type_id)
1209 CASE (dist_colvar_id)
1210 DEALLOCATE (colvar%dist_param)
1211 CASE (coord_colvar_id)
1212 IF (ASSOCIATED(colvar%coord_param%i_at_from)) THEN
1213 DEALLOCATE (colvar%coord_param%i_at_from)
1214 END IF
1215 IF (ASSOCIATED(colvar%coord_param%i_at_to)) THEN
1216 DEALLOCATE (colvar%coord_param%i_at_to)
1217 END IF
1218 IF (ASSOCIATED(colvar%coord_param%c_kinds_from)) THEN
1219 DEALLOCATE (colvar%coord_param%c_kinds_from)
1220 END IF
1221 IF (ASSOCIATED(colvar%coord_param%c_kinds_to)) THEN
1222 DEALLOCATE (colvar%coord_param%c_kinds_to)
1223 END IF
1224 IF (ASSOCIATED(colvar%coord_param%i_at_to_b)) THEN
1225 DEALLOCATE (colvar%coord_param%i_at_to_b)
1226 END IF
1227 IF (ASSOCIATED(colvar%coord_param%c_kinds_to_b)) THEN
1228 DEALLOCATE (colvar%coord_param%c_kinds_to_b)
1229 END IF
1230 DEALLOCATE (colvar%coord_param)
1232 IF (ASSOCIATED(colvar%population_param%i_at_from)) THEN
1233 DEALLOCATE (colvar%population_param%i_at_from)
1234 END IF
1235 IF (ASSOCIATED(colvar%population_param%i_at_to)) THEN
1236 DEALLOCATE (colvar%population_param%i_at_to)
1237 END IF
1238 IF (ASSOCIATED(colvar%population_param%c_kinds_from)) THEN
1239 DEALLOCATE (colvar%population_param%c_kinds_from)
1240 END IF
1241 IF (ASSOCIATED(colvar%population_param%c_kinds_to)) THEN
1242 DEALLOCATE (colvar%population_param%c_kinds_to)
1243 END IF
1244 DEALLOCATE (colvar%population_param)
1245 CASE (gyration_colvar_id)
1246 IF (ASSOCIATED(colvar%gyration_param%i_at)) THEN
1247 DEALLOCATE (colvar%gyration_param%i_at)
1248 END IF
1249 IF (ASSOCIATED(colvar%gyration_param%c_kinds)) THEN
1250 DEALLOCATE (colvar%gyration_param%c_kinds)
1251 END IF
1252 DEALLOCATE (colvar%gyration_param)
1253 CASE (angle_colvar_id)
1254 DEALLOCATE (colvar%angle_param)
1255 CASE (torsion_colvar_id)
1256 DEALLOCATE (colvar%torsion_param)
1258 DEALLOCATE (colvar%plane_distance_param)
1260 DEALLOCATE (colvar%plane_plane_angle_param)
1261 CASE (dfunct_colvar_id)
1262 DEALLOCATE (colvar%dfunct_param)
1263 CASE (rotation_colvar_id)
1264 DEALLOCATE (colvar%rotation_param)
1265 CASE (qparm_colvar_id)
1266 DEALLOCATE (colvar%qparm_param%i_at_from)
1267 DEALLOCATE (colvar%qparm_param%i_at_to)
1268 DEALLOCATE (colvar%qparm_param)
1269 CASE (xyz_diag_colvar_id)
1270 DEALLOCATE (colvar%xyz_diag_param)
1272 DEALLOCATE (colvar%xyz_outerdiag_param)
1273 CASE (u_colvar_id)
1274 NULLIFY (colvar%u_param%mixed_energy_section)
1275 DEALLOCATE (colvar%u_param)
1277 DEALLOCATE (colvar%hydronium_shell_param%i_oxygens)
1278 DEALLOCATE (colvar%hydronium_shell_param%i_hydrogens)
1279 DEALLOCATE (colvar%hydronium_shell_param)
1281 DEALLOCATE (colvar%hydronium_dist_param%i_oxygens)
1282 DEALLOCATE (colvar%hydronium_dist_param%i_hydrogens)
1283 DEALLOCATE (colvar%hydronium_dist_param)
1285 DEALLOCATE (colvar%acid_hyd_dist_param%i_oxygens_water)
1286 DEALLOCATE (colvar%acid_hyd_dist_param%i_oxygens_acid)
1287 DEALLOCATE (colvar%acid_hyd_dist_param%i_hydrogens)
1288 DEALLOCATE (colvar%acid_hyd_dist_param)
1290 DEALLOCATE (colvar%acid_hyd_shell_param%i_oxygens_water)
1291 DEALLOCATE (colvar%acid_hyd_shell_param%i_oxygens_acid)
1292 DEALLOCATE (colvar%acid_hyd_shell_param%i_hydrogens)
1293 DEALLOCATE (colvar%acid_hyd_shell_param)
1295 IF (colvar%reaction_path_param%dist_rmsd .OR. colvar%reaction_path_param%rmsd) THEN
1296 DEALLOCATE (colvar%reaction_path_param%r_ref)
1297 DEALLOCATE (colvar%reaction_path_param%i_rmsd)
1298 ELSE
1299 DO i = 1, SIZE(colvar%reaction_path_param%colvar_p)
1300 CALL colvar_release(colvar%reaction_path_param%colvar_p(i)%colvar)
1301 END DO
1302 DEALLOCATE (colvar%reaction_path_param%colvar_p)
1303 DEALLOCATE (colvar%reaction_path_param%f_vals)
1304 END IF
1305 DEALLOCATE (colvar%reaction_path_param)
1306 CASE (combine_colvar_id)
1307 DO i = 1, SIZE(colvar%combine_cvs_param%colvar_p)
1308 CALL colvar_release(colvar%combine_cvs_param%colvar_p(i)%colvar)
1309 END DO
1310 DEALLOCATE (colvar%combine_cvs_param%colvar_p)
1311 DEALLOCATE (colvar%combine_cvs_param%c_parameters)
1312 DEALLOCATE (colvar%combine_cvs_param%v_parameters)
1313 DEALLOCATE (colvar%combine_cvs_param%variables)
1314 DEALLOCATE (colvar%combine_cvs_param)
1315 CASE (rmsd_colvar_id)
1316 DEALLOCATE (colvar%rmsd_param%weights)
1317 DEALLOCATE (colvar%rmsd_param%r_ref)
1318 DEALLOCATE (colvar%rmsd_param%i_rmsd)
1319 DEALLOCATE (colvar%rmsd_param)
1320 CASE (wc_colvar_id)
1321 DEALLOCATE (colvar%Wc)
1322 CASE (hbp_colvar_id)
1323 DEALLOCATE (colvar%HBP%ewc)
1324 DEALLOCATE (colvar%HBP%ids)
1325 DEALLOCATE (colvar%HBP)
1327 DEALLOCATE (colvar%ring_puckering_param%atoms)
1328 DEALLOCATE (colvar%ring_puckering_param)
1329 CASE (mindist_colvar_id)
1330 IF (ASSOCIATED(colvar%mindist_param%i_dist_from)) THEN
1331 DEALLOCATE (colvar%mindist_param%i_dist_from)
1332 END IF
1333 IF (ASSOCIATED(colvar%mindist_param%i_coord_from)) THEN
1334 DEALLOCATE (colvar%mindist_param%i_coord_from)
1335 END IF
1336 IF (ASSOCIATED(colvar%mindist_param%i_coord_to)) THEN
1337 DEALLOCATE (colvar%mindist_param%i_coord_to)
1338 END IF
1339 IF (ASSOCIATED(colvar%mindist_param%k_coord_from)) THEN
1340 DEALLOCATE (colvar%mindist_param%k_coord_from)
1341 END IF
1342 IF (ASSOCIATED(colvar%mindist_param%k_coord_to)) THEN
1343 DEALLOCATE (colvar%mindist_param%k_coord_to)
1344 END IF
1345 DEALLOCATE (colvar%mindist_param)
1346 CASE (no_colvar_id)
1347 ! Do nothing
1348 CASE default
1349 cpabort("Unknown colvar type")
1350 END SELECT
1351 DEALLOCATE (colvar)
1352
1353 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 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 my_offset = 0
1370 IF (PRESENT(i_atom_offset)) my_offset = i_atom_offset
1371 CALL colvar_create(colvar_out, colvar_in%type_id)
1372 CALL colvar_clone_points(colvar_out, colvar_in, my_offset)
1373 IF (colvar_in%use_points) my_offset = 0
1374 SELECT CASE (colvar_out%type_id)
1375 CASE (dist_colvar_id)
1376 colvar_out%dist_param%i_at = colvar_in%dist_param%i_at + my_offset
1377 colvar_out%dist_param%j_at = colvar_in%dist_param%j_at + my_offset
1378 colvar_out%dist_param%axis_id = colvar_in%dist_param%axis_id
1379 colvar_out%dist_param%sign_d = colvar_in%dist_param%sign_d
1380 CASE (coord_colvar_id)
1381 colvar_out%coord_param%n_atoms_to = colvar_in%coord_param%n_atoms_to
1382 colvar_out%coord_param%n_atoms_to_b = colvar_in%coord_param%n_atoms_to_b
1383 colvar_out%coord_param%n_atoms_from = colvar_in%coord_param%n_atoms_from
1384 colvar_out%coord_param%nncrd = colvar_in%coord_param%nncrd
1385 colvar_out%coord_param%ndcrd = colvar_in%coord_param%ndcrd
1386 colvar_out%coord_param%r_0 = colvar_in%coord_param%r_0
1387 colvar_out%coord_param%nncrd_b = colvar_in%coord_param%nncrd_b
1388 colvar_out%coord_param%ndcrd_b = colvar_in%coord_param%ndcrd_b
1389 colvar_out%coord_param%r_0_b = colvar_in%coord_param%r_0_b
1390 colvar_out%coord_param%use_kinds_from = colvar_in%coord_param%use_kinds_from
1391 colvar_out%coord_param%use_kinds_to = colvar_in%coord_param%use_kinds_to
1392 colvar_out%coord_param%use_kinds_to_b = colvar_in%coord_param%use_kinds_to_b
1393 IF (colvar_in%coord_param%use_kinds_from) THEN
1394 ! KINDS
1395 ndim = SIZE(colvar_in%coord_param%c_kinds_from)
1396 ALLOCATE (colvar_out%coord_param%c_kinds_from(ndim))
1397 colvar_out%coord_param%c_kinds_from = colvar_in%coord_param%c_kinds_from
1398 ELSE
1399 ! INDEX
1400 ndim = SIZE(colvar_in%coord_param%i_at_from)
1401 ALLOCATE (colvar_out%coord_param%i_at_from(ndim))
1402 colvar_out%coord_param%i_at_from = colvar_in%coord_param%i_at_from + my_offset
1403 END IF
1404 IF (colvar_in%coord_param%use_kinds_to) THEN
1405 ! KINDS
1406 ndim = SIZE(colvar_in%coord_param%c_kinds_to)
1407 ALLOCATE (colvar_out%coord_param%c_kinds_to(ndim))
1408 colvar_out%coord_param%c_kinds_to = colvar_in%coord_param%c_kinds_to
1409 ELSE
1410 ! INDEX
1411 ndim = SIZE(colvar_in%coord_param%i_at_to)
1412 ALLOCATE (colvar_out%coord_param%i_at_to(ndim))
1413 colvar_out%coord_param%i_at_to = colvar_in%coord_param%i_at_to + my_offset
1414 END IF
1415 IF (colvar_in%coord_param%use_kinds_to_b) THEN
1416 ! KINDS
1417 ndim = SIZE(colvar_in%coord_param%c_kinds_to_b)
1418 ALLOCATE (colvar_out%coord_param%c_kinds_to_b(ndim))
1419 colvar_out%coord_param%c_kinds_to_b = colvar_in%coord_param%c_kinds_to_b
1420 ELSE IF (ASSOCIATED(colvar_in%coord_param%i_at_to_b)) THEN
1421 ! INDEX
1422 ndim = SIZE(colvar_in%coord_param%i_at_to_b)
1423 ALLOCATE (colvar_out%coord_param%i_at_to_b(ndim))
1424 colvar_out%coord_param%i_at_to_b = colvar_in%coord_param%i_at_to_b + my_offset
1425 END IF
1426
1428 colvar_out%population_param%n_atoms_to = colvar_in%population_param%n_atoms_to
1429 colvar_out%population_param%n_atoms_from = colvar_in%population_param%n_atoms_from
1430 colvar_out%population_param%nncrd = colvar_in%population_param%nncrd
1431 colvar_out%population_param%ndcrd = colvar_in%population_param%ndcrd
1432 colvar_out%population_param%r_0 = colvar_in%population_param%r_0
1433 colvar_out%population_param%use_kinds_from = colvar_in%population_param%use_kinds_from
1434 colvar_out%population_param%use_kinds_to = colvar_in%population_param%use_kinds_to
1435 IF (colvar_in%population_param%use_kinds_from) THEN
1436 ! KINDS
1437 ndim = SIZE(colvar_in%population_param%c_kinds_from)
1438 ALLOCATE (colvar_out%population_param%c_kinds_from(ndim))
1439 colvar_out%population_param%c_kinds_from = colvar_in%population_param%c_kinds_from
1440 ELSE
1441 ! INDEX
1442 ndim = SIZE(colvar_in%population_param%i_at_from)
1443 ALLOCATE (colvar_out%population_param%i_at_from(ndim))
1444 colvar_out%population_param%i_at_from = colvar_in%population_param%i_at_from + my_offset
1445 END IF
1446 IF (colvar_in%population_param%use_kinds_to) THEN
1447 ! KINDS
1448 ndim = SIZE(colvar_in%population_param%c_kinds_to)
1449 ALLOCATE (colvar_out%population_param%c_kinds_to(ndim))
1450 colvar_out%population_param%c_kinds_to = colvar_in%population_param%c_kinds_to
1451 ELSE
1452 ! INDEX
1453 ndim = SIZE(colvar_in%population_param%i_at_to)
1454 ALLOCATE (colvar_out%population_param%i_at_to(ndim))
1455 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 colvar_out%gyration_param%n_atoms = colvar_in%gyration_param%n_atoms
1460 colvar_out%gyration_param%use_kinds = colvar_in%gyration_param%use_kinds
1461 IF (colvar_in%gyration_param%use_kinds) THEN
1462 ! KINDS
1463 ndim = SIZE(colvar_in%gyration_param%c_kinds)
1464 ALLOCATE (colvar_out%gyration_param%c_kinds(ndim))
1465 colvar_out%gyration_param%c_kinds = colvar_in%gyration_param%c_kinds
1466 ELSE
1467 ! INDEX
1468 ndim = SIZE(colvar_in%gyration_param%i_at)
1469 ALLOCATE (colvar_out%gyration_param%i_at(ndim))
1470 colvar_out%gyration_param%i_at = colvar_in%gyration_param%i_at + my_offset
1471 END IF
1472 CASE (angle_colvar_id)
1473 colvar_out%angle_param%i_at_angle = colvar_in%angle_param%i_at_angle + my_offset
1474 CASE (torsion_colvar_id)
1475 colvar_out%torsion_param%i_at_tors = colvar_in%torsion_param%i_at_tors + my_offset
1476 colvar_out%torsion_param%o0 = colvar_in%torsion_param%o0
1478 colvar_out%plane_distance_param%use_pbc = colvar_in%plane_distance_param%use_pbc
1479 colvar_out%plane_distance_param%plane = colvar_in%plane_distance_param%plane + my_offset
1480 colvar_out%plane_distance_param%point = colvar_in%plane_distance_param%point + my_offset
1482 colvar_out%plane_plane_angle_param%plane1%type_of_def = colvar_in%plane_plane_angle_param%plane1%type_of_def
1483 IF (colvar_out%plane_plane_angle_param%plane1%type_of_def == plane_def_vec) THEN
1484 colvar_out%plane_plane_angle_param%plane1%normal_vec = colvar_in%plane_plane_angle_param%plane1%normal_vec
1485 ELSE
1486 colvar_out%plane_plane_angle_param%plane1%points = colvar_in%plane_plane_angle_param%plane1%points + my_offset
1487 END IF
1488
1489 colvar_out%plane_plane_angle_param%plane2%type_of_def = colvar_in%plane_plane_angle_param%plane2%type_of_def
1490 IF (colvar_out%plane_plane_angle_param%plane2%type_of_def == plane_def_vec) THEN
1491 colvar_out%plane_plane_angle_param%plane2%normal_vec = colvar_in%plane_plane_angle_param%plane2%normal_vec
1492 ELSE
1493 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 colvar_out%rotation_param%i_at1_bond1 = colvar_in%rotation_param%i_at1_bond1 + my_offset
1497 colvar_out%rotation_param%i_at2_bond1 = colvar_in%rotation_param%i_at2_bond1 + my_offset
1498 colvar_out%rotation_param%i_at1_bond2 = colvar_in%rotation_param%i_at1_bond2 + my_offset
1499 colvar_out%rotation_param%i_at2_bond2 = colvar_in%rotation_param%i_at2_bond2 + my_offset
1500 CASE (dfunct_colvar_id)
1501 colvar_out%dfunct_param%i_at_dfunct = colvar_in%dfunct_param%i_at_dfunct + my_offset
1502 colvar_out%dfunct_param%coeff = colvar_in%dfunct_param%coeff
1503 colvar_out%dfunct_param%use_pbc = colvar_in%dfunct_param%use_pbc
1504 CASE (qparm_colvar_id)
1505 colvar_out%qparm_param%n_atoms_to = colvar_in%qparm_param%n_atoms_to
1506 colvar_out%qparm_param%n_atoms_from = colvar_in%qparm_param%n_atoms_from
1507 colvar_out%qparm_param%rcut = colvar_in%qparm_param%rcut
1508 colvar_out%qparm_param%l = colvar_in%qparm_param%l
1509 colvar_out%qparm_param%rstart = colvar_in%qparm_param%rstart
1510 colvar_out%qparm_param%include_images = colvar_in%qparm_param%include_images
1511 ndim = SIZE(colvar_in%qparm_param%i_at_from)
1512 ALLOCATE (colvar_out%qparm_param%i_at_from(ndim))
1513 ndim = SIZE(colvar_in%qparm_param%i_at_to)
1514 ALLOCATE (colvar_out%qparm_param%i_at_to(ndim))
1515 colvar_out%qparm_param%i_at_from = colvar_in%qparm_param%i_at_from + my_offset
1516 colvar_out%qparm_param%i_at_to = colvar_in%qparm_param%i_at_from + my_offset
1517 CASE (xyz_diag_colvar_id)
1518 colvar_out%xyz_diag_param%i_atom = colvar_in%xyz_diag_param%i_atom + my_offset
1519 colvar_out%xyz_diag_param%component = colvar_in%xyz_diag_param%component
1520 colvar_out%xyz_diag_param%r0 = colvar_in%xyz_diag_param%r0
1521 colvar_out%xyz_diag_param%use_pbc = colvar_in%xyz_diag_param%use_pbc
1522 colvar_out%xyz_diag_param%use_absolute_position = colvar_in%xyz_diag_param%use_absolute_position
1524 colvar_out%xyz_outerdiag_param%i_atoms = colvar_in%xyz_outerdiag_param%i_atoms + my_offset
1525 colvar_out%xyz_outerdiag_param%components = colvar_in%xyz_outerdiag_param%components
1526 colvar_out%xyz_outerdiag_param%r0 = colvar_in%xyz_outerdiag_param%r0
1527 colvar_out%xyz_outerdiag_param%use_pbc = colvar_in%xyz_outerdiag_param%use_pbc
1528 CASE (u_colvar_id)
1529 colvar_out%u_param%natom = colvar_in%u_param%natom
1531 colvar_out%hydronium_shell_param%n_hydrogens = colvar_in%hydronium_shell_param%n_hydrogens
1532 colvar_out%hydronium_shell_param%n_oxygens = colvar_in%hydronium_shell_param%n_oxygens
1533 colvar_out%hydronium_shell_param%nh = colvar_in%hydronium_shell_param%nh
1534 colvar_out%hydronium_shell_param%poh = colvar_in%hydronium_shell_param%poh
1535 colvar_out%hydronium_shell_param%poo = colvar_in%hydronium_shell_param%poo
1536 colvar_out%hydronium_shell_param%qoh = colvar_in%hydronium_shell_param%qoh
1537 colvar_out%hydronium_shell_param%qoo = colvar_in%hydronium_shell_param%qoo
1538 colvar_out%hydronium_shell_param%pm = colvar_in%hydronium_shell_param%pm
1539 colvar_out%hydronium_shell_param%qm = colvar_in%hydronium_shell_param%qm
1540 colvar_out%hydronium_shell_param%roo = colvar_in%hydronium_shell_param%roo
1541 colvar_out%hydronium_shell_param%roh = colvar_in%hydronium_shell_param%roh
1542 colvar_out%hydronium_shell_param%lambda = colvar_in%hydronium_shell_param%lambda
1543 ndim = SIZE(colvar_in%hydronium_shell_param%i_oxygens)
1544 ALLOCATE (colvar_out%hydronium_shell_param%i_oxygens(ndim))
1545 ndim = SIZE(colvar_in%hydronium_shell_param%i_hydrogens)
1546 ALLOCATE (colvar_out%hydronium_shell_param%i_hydrogens(ndim))
1547 colvar_out%hydronium_shell_param%i_oxygens = colvar_in%hydronium_shell_param%i_oxygens + my_offset
1548 colvar_out%hydronium_shell_param%i_hydrogens = colvar_in%hydronium_shell_param%i_hydrogens + my_offset
1550 colvar_out%hydronium_dist_param%n_hydrogens = colvar_in%hydronium_dist_param%n_hydrogens
1551 colvar_out%hydronium_dist_param%n_oxygens = colvar_in%hydronium_dist_param%n_oxygens
1552 colvar_out%hydronium_dist_param%nh = colvar_in%hydronium_dist_param%nh
1553 colvar_out%hydronium_dist_param%nn = colvar_in%hydronium_dist_param%nn
1554 colvar_out%hydronium_dist_param%poh = colvar_in%hydronium_dist_param%poh
1555 colvar_out%hydronium_dist_param%qoh = colvar_in%hydronium_dist_param%qoh
1556 colvar_out%hydronium_dist_param%pf = colvar_in%hydronium_dist_param%pf
1557 colvar_out%hydronium_dist_param%qf = colvar_in%hydronium_dist_param%qf
1558 colvar_out%hydronium_dist_param%pm = colvar_in%hydronium_dist_param%pm
1559 colvar_out%hydronium_dist_param%qm = colvar_in%hydronium_dist_param%qm
1560 colvar_out%hydronium_dist_param%roh = colvar_in%hydronium_dist_param%roh
1561 colvar_out%hydronium_dist_param%lambda = colvar_in%hydronium_dist_param%lambda
1562 ndim = SIZE(colvar_in%hydronium_dist_param%i_oxygens)
1563 ALLOCATE (colvar_out%hydronium_dist_param%i_oxygens(ndim))
1564 ndim = SIZE(colvar_in%hydronium_dist_param%i_hydrogens)
1565 ALLOCATE (colvar_out%hydronium_dist_param%i_hydrogens(ndim))
1566 colvar_out%hydronium_dist_param%i_oxygens = colvar_in%hydronium_dist_param%i_oxygens + my_offset
1567 colvar_out%hydronium_dist_param%i_hydrogens = colvar_in%hydronium_dist_param%i_hydrogens + my_offset
1569 colvar_out%acid_hyd_dist_param%n_hydrogens = colvar_in%acid_hyd_dist_param%n_hydrogens
1570 colvar_out%acid_hyd_dist_param%n_oxygens_water = colvar_in%acid_hyd_dist_param%n_oxygens_water
1571 colvar_out%acid_hyd_dist_param%n_oxygens_acid = colvar_in%acid_hyd_dist_param%n_oxygens_acid
1572 colvar_out%acid_hyd_dist_param%nc = colvar_in%acid_hyd_dist_param%nc
1573 colvar_out%acid_hyd_dist_param%pwoh = colvar_in%acid_hyd_dist_param%pwoh
1574 colvar_out%acid_hyd_dist_param%qwoh = colvar_in%acid_hyd_dist_param%qwoh
1575 colvar_out%acid_hyd_dist_param%paoh = colvar_in%acid_hyd_dist_param%paoh
1576 colvar_out%acid_hyd_dist_param%qaoh = colvar_in%acid_hyd_dist_param%qaoh
1577 colvar_out%acid_hyd_dist_param%pcut = colvar_in%acid_hyd_dist_param%pcut
1578 colvar_out%acid_hyd_dist_param%qcut = colvar_in%acid_hyd_dist_param%qcut
1579 colvar_out%acid_hyd_dist_param%rwoh = colvar_in%acid_hyd_dist_param%rwoh
1580 colvar_out%acid_hyd_dist_param%raoh = colvar_in%acid_hyd_dist_param%raoh
1581 colvar_out%acid_hyd_dist_param%lambda = colvar_in%acid_hyd_dist_param%lambda
1582 ndim = SIZE(colvar_in%acid_hyd_dist_param%i_oxygens_water)
1583 ALLOCATE (colvar_out%acid_hyd_dist_param%i_oxygens_water(ndim))
1584 ndim = SIZE(colvar_in%acid_hyd_dist_param%i_oxygens_acid)
1585 ALLOCATE (colvar_out%acid_hyd_dist_param%i_oxygens_acid(ndim))
1586 ndim = SIZE(colvar_in%acid_hyd_dist_param%i_hydrogens)
1587 ALLOCATE (colvar_out%acid_hyd_dist_param%i_hydrogens(ndim))
1588 colvar_out%acid_hyd_dist_param%i_oxygens_water = colvar_in%acid_hyd_dist_param%i_oxygens_water + my_offset
1589 colvar_out%acid_hyd_dist_param%i_oxygens_acid = colvar_in%acid_hyd_dist_param%i_oxygens_acid + my_offset
1590 colvar_out%acid_hyd_dist_param%i_hydrogens = colvar_in%acid_hyd_dist_param%i_hydrogens + my_offset
1592 colvar_out%acid_hyd_shell_param%n_hydrogens = colvar_in%acid_hyd_shell_param%n_hydrogens
1593 colvar_out%acid_hyd_shell_param%n_oxygens_water = colvar_in%acid_hyd_shell_param%n_oxygens_water
1594 colvar_out%acid_hyd_shell_param%n_oxygens_acid = colvar_in%acid_hyd_shell_param%n_oxygens_acid
1595 colvar_out%acid_hyd_shell_param%nc = colvar_in%acid_hyd_shell_param%nc
1596 colvar_out%acid_hyd_shell_param%nh = colvar_in%acid_hyd_shell_param%nh
1597 colvar_out%acid_hyd_shell_param%pwoh = colvar_in%acid_hyd_shell_param%pwoh
1598 colvar_out%acid_hyd_shell_param%qwoh = colvar_in%acid_hyd_shell_param%qwoh
1599 colvar_out%acid_hyd_shell_param%paoh = colvar_in%acid_hyd_shell_param%paoh
1600 colvar_out%acid_hyd_shell_param%qaoh = colvar_in%acid_hyd_shell_param%qaoh
1601 colvar_out%acid_hyd_shell_param%poo = colvar_in%acid_hyd_shell_param%poo
1602 colvar_out%acid_hyd_shell_param%qoo = colvar_in%acid_hyd_shell_param%qoo
1603 colvar_out%acid_hyd_shell_param%pm = colvar_in%acid_hyd_shell_param%pm
1604 colvar_out%acid_hyd_shell_param%qm = colvar_in%acid_hyd_shell_param%qm
1605 colvar_out%acid_hyd_shell_param%pcut = colvar_in%acid_hyd_shell_param%pcut
1606 colvar_out%acid_hyd_shell_param%qcut = colvar_in%acid_hyd_shell_param%qcut
1607 colvar_out%acid_hyd_shell_param%rwoh = colvar_in%acid_hyd_shell_param%rwoh
1608 colvar_out%acid_hyd_shell_param%raoh = colvar_in%acid_hyd_shell_param%raoh
1609 colvar_out%acid_hyd_shell_param%roo = colvar_in%acid_hyd_shell_param%roo
1610 colvar_out%acid_hyd_shell_param%lambda = colvar_in%acid_hyd_shell_param%lambda
1611 ndim = SIZE(colvar_in%acid_hyd_shell_param%i_oxygens_water)
1612 ALLOCATE (colvar_out%acid_hyd_shell_param%i_oxygens_water(ndim))
1613 ndim = SIZE(colvar_in%acid_hyd_shell_param%i_oxygens_acid)
1614 ALLOCATE (colvar_out%acid_hyd_shell_param%i_oxygens_acid(ndim))
1615 ndim = SIZE(colvar_in%acid_hyd_shell_param%i_hydrogens)
1616 ALLOCATE (colvar_out%acid_hyd_shell_param%i_hydrogens(ndim))
1617 colvar_out%acid_hyd_shell_param%i_oxygens_water = colvar_in%acid_hyd_shell_param%i_oxygens_water + my_offset
1618 colvar_out%acid_hyd_shell_param%i_oxygens_acid = colvar_in%acid_hyd_shell_param%i_oxygens_acid + my_offset
1619 colvar_out%acid_hyd_shell_param%i_hydrogens = colvar_in%acid_hyd_shell_param%i_hydrogens + my_offset
1621 colvar_out%reaction_path_param%dist_rmsd = colvar_in%reaction_path_param%dist_rmsd
1622 colvar_out%reaction_path_param%rmsd = colvar_in%reaction_path_param%rmsd
1623 colvar_out%reaction_path_param%nr_frames = colvar_in%reaction_path_param%nr_frames
1624 IF (colvar_in%reaction_path_param%dist_rmsd .OR. colvar_in%reaction_path_param%rmsd) THEN
1625 colvar_out%reaction_path_param%align_frames = colvar_in%reaction_path_param%align_frames
1626 colvar_out%reaction_path_param%subset = colvar_in%reaction_path_param%subset
1627 ndim = SIZE(colvar_in%reaction_path_param%i_rmsd)
1628 ALLOCATE (colvar_out%reaction_path_param%i_rmsd(ndim))
1629 colvar_out%reaction_path_param%i_rmsd = colvar_in%reaction_path_param%i_rmsd
1630 ndim = SIZE(colvar_in%reaction_path_param%r_ref, 1)
1631 ndim2 = SIZE(colvar_in%reaction_path_param%r_ref, 2)
1632 ALLOCATE (colvar_out%reaction_path_param%r_ref(ndim, ndim2))
1633 colvar_out%reaction_path_param%r_ref = colvar_in%reaction_path_param%r_ref
1634 ELSE
1635 ndim = SIZE(colvar_in%reaction_path_param%colvar_p)
1636 ALLOCATE (colvar_out%reaction_path_param%colvar_p(ndim))
1637 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 my_offset)
1641 END DO
1642 colvar_out%reaction_path_param%function_bounds = colvar_in%reaction_path_param%function_bounds
1643 ndim = SIZE(colvar_in%reaction_path_param%f_vals, 1)
1644 ndim2 = SIZE(colvar_in%reaction_path_param%f_vals, 2)
1645 ALLOCATE (colvar_out%reaction_path_param%f_vals(ndim, ndim2))
1646 colvar_out%reaction_path_param%f_vals = colvar_in%reaction_path_param%f_vals
1647 END IF
1648 colvar_out%reaction_path_param%step_size = colvar_in%reaction_path_param%step_size
1649 colvar_out%reaction_path_param%n_components = colvar_in%reaction_path_param%n_components
1650 colvar_out%reaction_path_param%lambda = colvar_in%reaction_path_param%lambda
1651 CASE (combine_colvar_id)
1652 ndim = SIZE(colvar_in%combine_cvs_param%colvar_p)
1653 ALLOCATE (colvar_out%combine_cvs_param%colvar_p(ndim))
1654 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 my_offset)
1658 END DO
1659 colvar_out%combine_cvs_param%lerr = colvar_in%combine_cvs_param%lerr
1660 colvar_out%combine_cvs_param%dx = colvar_in%combine_cvs_param%dx
1661 colvar_out%combine_cvs_param%function = colvar_in%combine_cvs_param%function
1662 !
1663 ndim = SIZE(colvar_in%combine_cvs_param%c_parameters)
1664 ALLOCATE (colvar_out%combine_cvs_param%c_parameters(ndim))
1665 colvar_out%combine_cvs_param%c_parameters = colvar_in%combine_cvs_param%c_parameters
1666 !
1667 ndim = SIZE(colvar_in%combine_cvs_param%v_parameters)
1668 ALLOCATE (colvar_out%combine_cvs_param%v_parameters(ndim))
1669 colvar_out%combine_cvs_param%v_parameters = colvar_in%combine_cvs_param%v_parameters
1670 !
1671 ndim = SIZE(colvar_in%combine_cvs_param%variables)
1672 ALLOCATE (colvar_out%combine_cvs_param%variables(ndim))
1673 colvar_out%combine_cvs_param%variables = colvar_in%combine_cvs_param%variables
1674 CASE (rmsd_colvar_id)
1675 colvar_out%rmsd_param%n_atoms = colvar_in%rmsd_param%n_atoms
1676 colvar_out%rmsd_param%align_frames = colvar_in%rmsd_param%align_frames
1677 colvar_out%rmsd_param%nr_frames = colvar_in%rmsd_param%nr_frames
1678 colvar_out%rmsd_param%subset = colvar_in%rmsd_param%subset
1679 ! INDEX
1680 ndim = SIZE(colvar_in%rmsd_param%i_rmsd)
1681 ALLOCATE (colvar_out%rmsd_param%i_rmsd(ndim))
1682 colvar_out%rmsd_param%i_rmsd = colvar_in%rmsd_param%i_rmsd + my_offset
1683 ! A and Bconfigurations and weights
1684 ndim = SIZE(colvar_in%rmsd_param%weights)
1685 ALLOCATE (colvar_out%rmsd_param%weights(ndim))
1686 colvar_out%rmsd_param%weights = colvar_in%rmsd_param%weights
1687 ndim = SIZE(colvar_in%rmsd_param%r_ref, 1)
1688 ndim2 = SIZE(colvar_in%rmsd_param%r_ref, 2)
1689 ALLOCATE (colvar_out%rmsd_param%r_ref(ndim, ndim2))
1690 colvar_out%rmsd_param%r_ref = colvar_in%rmsd_param%r_ref
1691 CASE (wc_colvar_id)
1692 colvar_out%Wc%ids = colvar_in%Wc%ids + my_offset
1693 colvar_out%Wc%rcut = colvar_in%Wc%rcut
1694 CASE (hbp_colvar_id)
1695 ndim = colvar_out%HBP%nPoints
1696 ALLOCATE (colvar_out%HBP%ids(ndim, 3))
1697 ALLOCATE (colvar_out%HBP%ewc(ndim))
1698 colvar_out%HBP%ids = colvar_in%HBP%ids + my_offset
1699 colvar_out%HBP%ewc = colvar_in%HBP%ewc + my_offset
1700 colvar_out%HBP%nPoints = colvar_in%HBP%nPoints
1701 colvar_out%HBP%rcut = colvar_in%HBP%rcut
1702 colvar_out%HBP%shift = colvar_in%HBP%shift
1704 ndim = colvar_in%ring_puckering_param%nring
1705 colvar_out%ring_puckering_param%nring = colvar_in%ring_puckering_param%nring
1706 colvar_out%ring_puckering_param%iq = colvar_in%ring_puckering_param%iq
1707 ALLOCATE (colvar_out%ring_puckering_param%atoms(ndim))
1708 colvar_out%ring_puckering_param%atoms = colvar_in%ring_puckering_param%atoms + my_offset
1709 CASE (mindist_colvar_id)
1710 colvar_out%mindist_param%n_dist_from = colvar_in%mindist_param%n_dist_from
1711 colvar_out%mindist_param%n_coord_to = colvar_in%mindist_param%n_coord_to
1712 colvar_out%mindist_param%n_coord_from = colvar_in%mindist_param%n_coord_from
1713 colvar_out%mindist_param%p_exp = colvar_in%mindist_param%p_exp
1714 colvar_out%mindist_param%q_exp = colvar_in%mindist_param%q_exp
1715 colvar_out%mindist_param%r_cut = colvar_in%mindist_param%r_cut
1716 colvar_out%mindist_param%lambda = colvar_in%mindist_param%lambda
1717 colvar_out%mindist_param%use_kinds_from = colvar_in%mindist_param%use_kinds_from
1718 colvar_out%mindist_param%use_kinds_to = colvar_in%mindist_param%use_kinds_to
1719 ! INDEX
1720 ndim = SIZE(colvar_in%mindist_param%i_dist_from)
1721 ALLOCATE (colvar_out%mindist_param%i_dist_from(ndim))
1722 colvar_out%mindist_param%i_dist_from = colvar_in%mindist_param%i_dist_from + my_offset
1723 IF (colvar_in%mindist_param%use_kinds_from) THEN
1724 ! KINDS
1725 ndim = SIZE(colvar_in%mindist_param%k_coord_from)
1726 ALLOCATE (colvar_out%mindist_param%k_coord_from(ndim))
1727 colvar_out%mindist_param%k_coord_from = colvar_in%mindist_param%k_coord_from
1728 ELSE
1729 ! INDEX
1730 ndim = SIZE(colvar_in%mindist_param%i_coord_from)
1731 ALLOCATE (colvar_out%mindist_param%i_coord_from(ndim))
1732 colvar_out%mindist_param%i_coord_from = colvar_in%mindist_param%i_coord_from + my_offset
1733 END IF
1734 IF (colvar_in%mindist_param%use_kinds_to) THEN
1735 ! KINDS
1736 ndim = SIZE(colvar_in%mindist_param%k_coord_to)
1737 ALLOCATE (colvar_out%mindist_param%k_coord_to(ndim))
1738 colvar_out%mindist_param%k_coord_to = colvar_in%mindist_param%k_coord_to
1739 ELSE
1740 ! INDEX
1741 ndim = SIZE(colvar_in%mindist_param%i_coord_to)
1742 ALLOCATE (colvar_out%mindist_param%i_coord_to(ndim))
1743 colvar_out%mindist_param%i_coord_to = colvar_in%mindist_param%i_coord_to + my_offset
1744 END IF
1745
1746 END SELECT
1747 CALL colvar_setup(colvar_out)
1748 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 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 colvar_out%use_points = colvar_in%use_points
1765 IF (colvar_in%use_points) THEN
1766 cpassert(ASSOCIATED(colvar_in%points))
1767 npoints = SIZE(colvar_in%points)
1768 ALLOCATE (colvar_out%points(npoints))
1769 DO i = 1, npoints
1770 IF (ASSOCIATED(colvar_in%points(i)%atoms)) THEN
1771 natoms = SIZE(colvar_in%points(i)%atoms)
1772 ALLOCATE (colvar_out%points(i)%atoms(natoms))
1773 colvar_out%points(i)%atoms = colvar_in%points(i)%atoms + offset
1774 ELSE
1775 NULLIFY (colvar_out%points(i)%atoms)
1776 END IF
1777 IF (ASSOCIATED(colvar_in%points(i)%weights)) THEN
1778 natoms = SIZE(colvar_in%points(i)%weights)
1779 ALLOCATE (colvar_out%points(i)%weights(natoms))
1780 colvar_out%points(i)%weights = colvar_in%points(i)%weights
1781 ELSE
1782 NULLIFY (colvar_out%points(i)%weights)
1783 END IF
1784 colvar_out%points(i)%type_id = colvar_in%points(i)%type_id
1785 colvar_out%points(i)%r = colvar_in%points(i)%r
1786 END DO
1787 ELSE
1788 NULLIFY (colvar_out%points)
1789 END IF
1790
1791 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 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 TYPE(colvar_p_type), DIMENSION(:), POINTER :: work
1806
1807 NULLIFY (work)
1808 IF (ASSOCIATED(colvar_set)) THEN
1809 lb1_old = lbound(colvar_set, 1)
1810 ub1_old = ubound(colvar_set, 1)
1811 lb1 = max(lb1_new, lb1_old)
1812 ub1 = min(ub1_new, ub1_old)
1813 ALLOCATE (work(lb1:ub1))
1814 DO j = lb1, ub1
1815 CALL colvar_clone(work(j)%colvar, colvar_set(j)%colvar)
1816 END DO
1817 DO j = lb1, ub1
1818 CALL colvar_release(colvar_set(j)%colvar)
1819 END DO
1820 DEALLOCATE (colvar_set)
1821 END IF
1822
1823 ALLOCATE (colvar_set(lb1_new:ub1_new))
1824
1825 IF (ASSOCIATED(work)) THEN
1826 lb1 = max(lb1_new, lb1_old)
1827 ub1 = min(ub1_new, ub1_old)
1828 DO j = lb1, ub1
1829 CALL colvar_clone(colvar_set(j)%colvar, work(j)%colvar)
1830 END DO
1831 DO j = lb1, ub1
1832 CALL colvar_release(work(j)%colvar)
1833 END DO
1834 DEALLOCATE (work)
1835 END IF
1836 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 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 IF (ASSOCIATED(colvar_p)) THEN
1854 DO i = 1, SIZE(colvar_p)
1855 IF (ASSOCIATED(colvar_p(i)%colvar)) THEN
1856 CALL colvar_release(colvar_p(i)%colvar)
1857 END IF
1858 END DO
1859 DEALLOCATE (colvar_p)
1860 END IF
1861 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 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 SELECT CASE (point%type_id)
1878 CASE (do_clv_geo_center)
1879 r = 0.0_dp
1880 DO i = 1, SIZE(point%atoms)
1881 r = r + particles(point%atoms(i))%r*point%weights(i)
1882 END DO
1883 CASE (do_clv_fix_point)
1884 r = point%r
1885 END SELECT
1886
1887 END SUBROUTINE eval_point_pos
1888
1889! **************************************************************************************************
1890!> \brief ...
1891!> \param point ...
1892!> \param particles ...
1893!> \param m ...
1894! **************************************************************************************************
1895 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 SELECT CASE (point%type_id)
1903 CASE (do_clv_geo_center)
1904 m = 0.0_dp
1905 DO i = 1, SIZE(point%atoms)
1906 m = m + particles(point%atoms(i))%atomic_kind%mass*point%weights(i)
1907 END DO
1908 CASE (do_clv_fix_point)
1909 m = 0.0_dp
1910 END SELECT
1911
1912 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 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 SELECT CASE (points(i)%type_id)
1932 CASE (do_clv_geo_center)
1933 ind = 0
1934 DO j = 1, i - 1
1935 IF (ASSOCIATED(points(j)%atoms)) THEN
1936 ind = ind + SIZE(points(j)%atoms)
1937 END IF
1938 END DO
1939 DO j = 1, SIZE(points(i)%atoms)
1940 fac = points(i)%weights(j)
1941 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 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 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 diff = colvar%ss - b
1963 IF (colvar%type_id == torsion_colvar_id) THEN
1964 ! The difference of a periodic COLVAR is always within [-pi,pi]
1965 diff = sign(1.0_dp, asin(sin(diff)))*acos(cos(diff))
1966 END IF
1967 END FUNCTION diff_colvar
1968
1969END 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 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