-
Notifications
You must be signed in to change notification settings - Fork 1
/
colvar_methods.F
6098 lines (5624 loc) · 272 KB
/
colvar_methods.F
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
!--------------------------------------------------------------------------------------------------!
! CP2K: A general program to perform molecular dynamics simulations !
! Copyright 2000-2024 CP2K developers group <https://cp2k.org> !
! !
! SPDX-License-Identifier: GPL-2.0-or-later !
!--------------------------------------------------------------------------------------------------!
! **************************************************************************************************
!> \brief defines collective variables s({R}) and the derivative of this variable wrt R
!> these can then be used in constraints, restraints and metadynamics ...
!> \par History
!> 04.2004 created
!> 01.2006 Refactored [Joost VandeVondele]
!> \author Alessandro Laio,Fawzi Mohamed
! **************************************************************************************************
MODULE colvar_methods
USE cell_types, ONLY: cell_type,&
pbc
USE colvar_types, ONLY: &
HBP_colvar_id, Wc_colvar_id, acid_hyd_dist_colvar_id, acid_hyd_shell_colvar_id, &
angle_colvar_id, colvar_create, colvar_setup, colvar_type, combine_colvar_id, &
coord_colvar_id, dfunct_colvar_id, dist_colvar_id, distance_from_path_colvar_id, &
do_clv_fix_point, do_clv_geo_center, do_clv_x, do_clv_xy, do_clv_xz, do_clv_y, do_clv_yz, &
do_clv_z, eval_point_der, eval_point_mass, eval_point_pos, gyration_colvar_id, &
hydronium_dist_colvar_id, hydronium_shell_colvar_id, mindist_colvar_id, plane_def_atoms, &
plane_def_vec, plane_distance_colvar_id, plane_plane_angle_colvar_id, &
population_colvar_id, qparm_colvar_id, reaction_path_colvar_id, ring_puckering_colvar_id, &
rmsd_colvar_id, rotation_colvar_id, torsion_colvar_id, u_colvar_id, xyz_diag_colvar_id, &
xyz_outerdiag_colvar_id
USE constraint_fxd, ONLY: check_fixed_atom_cns_colv
USE cp_log_handling, ONLY: cp_get_default_logger,&
cp_logger_get_default_io_unit,&
cp_logger_type,&
cp_to_string
USE cp_output_handling, ONLY: cp_print_key_finished_output,&
cp_print_key_unit_nr
USE cp_parser_methods, ONLY: parser_get_next_line,&
parser_get_object
USE cp_parser_types, ONLY: cp_parser_type,&
parser_create,&
parser_release
USE cp_subsys_types, ONLY: cp_subsys_get,&
cp_subsys_p_type,&
cp_subsys_type
USE cp_units, ONLY: cp_unit_to_cp2k
USE force_env_types, ONLY: force_env_get,&
force_env_type,&
use_mixed_force
USE force_fields_util, ONLY: get_generic_info
USE fparser, ONLY: EvalErrType,&
evalf,&
evalfd,&
finalizef,&
initf,&
parsef
USE input_constants, ONLY: rmsd_all,&
rmsd_list,&
rmsd_weightlist
USE input_cp2k_colvar, ONLY: create_colvar_xyz_d_section,&
create_colvar_xyz_od_section
USE input_enumeration_types, ONLY: enum_i2c,&
enumeration_type
USE input_keyword_types, ONLY: keyword_get,&
keyword_type
USE input_section_types, ONLY: section_get_keyword,&
section_release,&
section_type,&
section_vals_get,&
section_vals_get_subs_vals,&
section_vals_type,&
section_vals_val_get
USE kahan_sum, ONLY: accurate_sum
USE kinds, ONLY: default_path_length,&
default_string_length,&
dp
USE mathconstants, ONLY: fac,&
maxfac,&
pi,&
twopi
USE mathlib, ONLY: vector_product
USE memory_utilities, ONLY: reallocate
USE message_passing, ONLY: mp_para_env_type
USE mixed_energy_types, ONLY: mixed_force_type
USE mixed_environment_utils, ONLY: get_subsys_map_index
USE molecule_kind_types, ONLY: fixd_constraint_type
USE particle_list_types, ONLY: particle_list_p_type,&
particle_list_type
USE particle_types, ONLY: particle_type
USE qs_environment_types, ONLY: get_qs_env,&
qs_environment_type
USE rmsd, ONLY: rmsd3
USE spherical_harmonics, ONLY: dlegendre,&
legendre
USE string_utilities, ONLY: compress,&
uppercase
USE wannier_states_types, ONLY: wannier_centres_type
#include "./base/base_uses.f90"
IMPLICIT NONE
PRIVATE
CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'colvar_methods'
REAL(KIND=dp), PRIVATE, PARAMETER :: tolerance_acos = 1.0E-5_dp
PUBLIC :: colvar_read, &
colvar_eval_glob_f, &
colvar_eval_mol_f
CONTAINS
! **************************************************************************************************
!> \brief reads a colvar from the input
!> \param colvar the place where to store what will be read
!> \param icol number of the current colvar (repetition in colvar_section)
!> \param colvar_section the colvar section
!> \param para_env ...
!> \par History
!> 04.2004 created [alessandro laio and fawzi mohamed]
!> \author teo
! **************************************************************************************************
RECURSIVE SUBROUTINE colvar_read(colvar, icol, colvar_section, para_env)
TYPE(colvar_type), POINTER :: colvar
INTEGER, INTENT(IN) :: icol
TYPE(section_vals_type), POINTER :: colvar_section
TYPE(mp_para_env_type), POINTER :: para_env
CHARACTER(len=*), PARAMETER :: routineN = 'colvar_read'
CHARACTER(LEN=3) :: fmid
CHARACTER(LEN=7) :: tag, tag_comp, tag_comp1, tag_comp2
CHARACTER(LEN=default_path_length) :: path_function
CHARACTER(LEN=default_string_length) :: tmpStr, tmpStr2
CHARACTER(LEN=default_string_length), &
DIMENSION(:), POINTER :: c_kinds, my_par
INTEGER :: handle, i, iatm, icomponent, iend, &
ifunc, ii, isize, istart, iw, iw1, j, &
k, kk, n_var, n_var_k, ncol, ndim, &
nr_frame, v_count
INTEGER, DIMENSION(:), POINTER :: iatms
INTEGER, DIMENSION(:, :), POINTER :: p_bounds
LOGICAL :: check, use_mixed_energy
LOGICAL, DIMENSION(26) :: my_subsection
REAL(dp), DIMENSION(:), POINTER :: s1, wei, weights
REAL(dp), DIMENSION(:, :), POINTER :: p_range, s1v
REAL(KIND=dp), DIMENSION(1) :: my_val
REAL(KIND=dp), DIMENSION(:), POINTER :: g_range, grid_point, grid_sp, my_vals, &
range
TYPE(cp_logger_type), POINTER :: logger
TYPE(enumeration_type), POINTER :: enum
TYPE(keyword_type), POINTER :: keyword
TYPE(section_type), POINTER :: section
TYPE(section_vals_type), POINTER :: acid_hyd_dist_section, acid_hyd_shell_section, &
angle_section, colvar_subsection, combine_section, coordination_section, dfunct_section, &
distance_from_path_section, distance_section, frame_section, gyration_section, &
HBP_section, hydronium_dist_section, hydronium_shell_section, mindist_section, &
path_section, plane_dist_section, plane_plane_angle_section, plane_sections, &
point_section, population_section, qparm_section, reaction_path_section, &
ring_puckering_section, rmsd_section, rotation_section, torsion_section, u_section, &
Wc_section, wrk_section
TYPE(section_vals_type), POINTER :: xyz_diag_section, xyz_outerdiag_section
CALL timeset(routineN, handle)
NULLIFY (logger, c_kinds, iatms)
logger => cp_get_default_logger()
my_subsection = .FALSE.
distance_section => section_vals_get_subs_vals(colvar_section, "DISTANCE", i_rep_section=icol)
dfunct_section => section_vals_get_subs_vals(colvar_section, "DISTANCE_FUNCTION", &
i_rep_section=icol)
angle_section => section_vals_get_subs_vals(colvar_section, "ANGLE", i_rep_section=icol)
torsion_section => section_vals_get_subs_vals(colvar_section, "TORSION", i_rep_section=icol)
coordination_section => section_vals_get_subs_vals(colvar_section, "COORDINATION", i_rep_section=icol)
plane_dist_section => section_vals_get_subs_vals(colvar_section, "DISTANCE_POINT_PLANE", i_rep_section=icol)
plane_plane_angle_section &
=> section_vals_get_subs_vals(colvar_section, "ANGLE_PLANE_PLANE", i_rep_section=icol)
rotation_section => section_vals_get_subs_vals(colvar_section, "BOND_ROTATION", i_rep_section=icol)
qparm_section => section_vals_get_subs_vals(colvar_section, "QPARM", i_rep_section=icol)
hydronium_shell_section => section_vals_get_subs_vals(colvar_section, "HYDRONIUM_SHELL", i_rep_section=icol)
hydronium_dist_section => section_vals_get_subs_vals(colvar_section, "HYDRONIUM_DISTANCE", i_rep_section=icol)
acid_hyd_dist_section => section_vals_get_subs_vals(colvar_section, "ACID_HYDRONIUM_DISTANCE", i_rep_section=icol)
acid_hyd_shell_section &
=> section_vals_get_subs_vals(colvar_section, "ACID_HYDRONIUM_SHELL", i_rep_section=icol)
reaction_path_section => section_vals_get_subs_vals(colvar_section, "REACTION_PATH", i_rep_section=icol, &
can_return_null=.TRUE.)
distance_from_path_section &
=> section_vals_get_subs_vals(colvar_section, "DISTANCE_FROM_PATH", &
i_rep_section=icol, can_return_null=.TRUE.)
combine_section => section_vals_get_subs_vals(colvar_section, "COMBINE_COLVAR", i_rep_section=icol, &
can_return_null=.TRUE.)
population_section => section_vals_get_subs_vals(colvar_section, "POPULATION", i_rep_section=icol)
gyration_section => section_vals_get_subs_vals(colvar_section, "GYRATION_RADIUS", i_rep_section=icol)
rmsd_section => section_vals_get_subs_vals(colvar_section, "RMSD", i_rep_section=icol)
xyz_diag_section => section_vals_get_subs_vals(colvar_section, "XYZ_DIAG", i_rep_section=icol)
xyz_outerdiag_section => section_vals_get_subs_vals(colvar_section, "XYZ_OUTERDIAG", i_rep_section=icol)
u_section => section_vals_get_subs_vals(colvar_section, "U", i_rep_section=icol)
Wc_section => section_vals_get_subs_vals(colvar_section, "WC", i_rep_section=icol)
HBP_section => section_vals_get_subs_vals(colvar_section, "HBP", i_rep_section=icol)
ring_puckering_section &
=> section_vals_get_subs_vals(colvar_section, "RING_PUCKERING", i_rep_section=icol)
mindist_section => section_vals_get_subs_vals(colvar_section, "CONDITIONED_DISTANCE", i_rep_section=icol)
CALL section_vals_get(distance_section, explicit=my_subsection(1))
CALL section_vals_get(angle_section, explicit=my_subsection(2))
CALL section_vals_get(torsion_section, explicit=my_subsection(3))
CALL section_vals_get(coordination_section, explicit=my_subsection(4))
CALL section_vals_get(plane_dist_section, explicit=my_subsection(5))
CALL section_vals_get(rotation_section, explicit=my_subsection(6))
CALL section_vals_get(dfunct_section, explicit=my_subsection(7))
CALL section_vals_get(qparm_section, explicit=my_subsection(8))
CALL section_vals_get(hydronium_shell_section, explicit=my_subsection(9))
! These are just special cases since they are not present in their own defition of COLVARS
IF (ASSOCIATED(reaction_path_section)) THEN
CALL section_vals_get(reaction_path_section, &
explicit=my_subsection(10))
END IF
IF (ASSOCIATED(distance_from_path_section)) THEN
CALL section_vals_get(distance_from_path_section, &
explicit=my_subsection(16))
END IF
IF (ASSOCIATED(combine_section)) THEN
CALL section_vals_get(combine_section, explicit=my_subsection(11))
END IF
CALL section_vals_get(population_section, explicit=my_subsection(12))
CALL section_vals_get(plane_plane_angle_section, &
explicit=my_subsection(13))
CALL section_vals_get(gyration_section, explicit=my_subsection(14))
CALL section_vals_get(rmsd_section, explicit=my_subsection(15))
CALL section_vals_get(xyz_diag_section, explicit=my_subsection(17))
CALL section_vals_get(xyz_outerdiag_section, explicit=my_subsection(18))
CALL section_vals_get(u_section, explicit=my_subsection(19))
CALL section_vals_get(Wc_section, explicit=my_subsection(20))
CALL section_vals_get(HBP_section, explicit=my_subsection(21))
CALL section_vals_get(ring_puckering_section, &
explicit=my_subsection(22))
CALL section_vals_get(mindist_section, explicit=my_subsection(23))
CALL section_vals_get(acid_hyd_dist_section, explicit=my_subsection(24))
CALL section_vals_get(acid_hyd_shell_section, explicit=my_subsection(25))
CALL section_vals_get(hydronium_dist_section, explicit=my_subsection(26))
! Only one colvar can be present
CPASSERT(COUNT(my_subsection) == 1)
CPASSERT(.NOT. ASSOCIATED(colvar))
IF (my_subsection(1)) THEN
! Distance
wrk_section => distance_section
CALL colvar_create(colvar, dist_colvar_id)
CALL colvar_check_points(colvar, distance_section)
CALL section_vals_val_get(distance_section, "ATOMS", i_vals=iatms)
colvar%dist_param%i_at = iatms(1)
colvar%dist_param%j_at = iatms(2)
CALL section_vals_val_get(distance_section, "AXIS", i_val=colvar%dist_param%axis_id)
CALL section_vals_val_get(distance_section, "SIGN", l_val=colvar%dist_param%sign_d)
ELSE IF (my_subsection(2)) THEN
! Angle
wrk_section => angle_section
CALL colvar_create(colvar, angle_colvar_id)
CALL colvar_check_points(colvar, angle_section)
CALL section_vals_val_get(angle_section, "ATOMS", i_vals=iatms)
colvar%angle_param%i_at_angle = iatms
ELSE IF (my_subsection(3)) THEN
! Torsion
wrk_section => torsion_section
CALL colvar_create(colvar, torsion_colvar_id)
CALL colvar_check_points(colvar, torsion_section)
CALL section_vals_val_get(torsion_section, "ATOMS", i_vals=iatms)
colvar%torsion_param%i_at_tors = iatms
colvar%torsion_param%o0 = 0.0_dp
ELSE IF (my_subsection(4)) THEN
! Coordination
wrk_section => coordination_section
CALL colvar_create(colvar, coord_colvar_id)
CALL colvar_check_points(colvar, coordination_section)
NULLIFY (colvar%coord_param%i_at_from, colvar%coord_param%c_kinds_from)
NULLIFY (colvar%coord_param%i_at_to, colvar%coord_param%c_kinds_to)
NULLIFY (colvar%coord_param%i_at_to_b, colvar%coord_param%c_kinds_to_b)
! This section can be repeated
CALL section_vals_val_get(coordination_section, "ATOMS_FROM", n_rep_val=n_var)
ndim = 0
IF (n_var /= 0) THEN
! INDEX LIST
DO k = 1, n_var
CALL section_vals_val_get(coordination_section, "ATOMS_FROM", i_rep_val=k, i_vals=iatms)
CALL reallocate(colvar%coord_param%i_at_from, 1, ndim + SIZE(iatms))
colvar%coord_param%i_at_from(ndim + 1:ndim + SIZE(iatms)) = iatms
ndim = ndim + SIZE(iatms)
END DO
colvar%coord_param%n_atoms_from = ndim
colvar%coord_param%use_kinds_from = .FALSE.
ELSE
! KINDS
CALL section_vals_val_get(coordination_section, "KINDS_FROM", n_rep_val=n_var)
CPASSERT(n_var > 0)
DO k = 1, n_var
CALL section_vals_val_get(coordination_section, "KINDS_FROM", i_rep_val=k, c_vals=c_kinds)
CALL reallocate(colvar%coord_param%c_kinds_from, 1, ndim + SIZE(c_kinds))
colvar%coord_param%c_kinds_from(ndim + 1:ndim + SIZE(c_kinds)) = c_kinds
ndim = ndim + SIZE(c_kinds)
END DO
colvar%coord_param%n_atoms_from = 0
colvar%coord_param%use_kinds_from = .TRUE.
! Uppercase the label
DO k = 1, ndim
CALL uppercase(colvar%coord_param%c_kinds_from(k))
END DO
END IF
! This section can be repeated
CALL section_vals_val_get(coordination_section, "ATOMS_TO", n_rep_val=n_var)
ndim = 0
IF (n_var /= 0) THEN
! INDEX LIST
DO k = 1, n_var
CALL section_vals_val_get(coordination_section, "ATOMS_TO", i_rep_val=k, i_vals=iatms)
CALL reallocate(colvar%coord_param%i_at_to, 1, ndim + SIZE(iatms))
colvar%coord_param%i_at_to(ndim + 1:ndim + SIZE(iatms)) = iatms
ndim = ndim + SIZE(iatms)
END DO
colvar%coord_param%n_atoms_to = ndim
colvar%coord_param%use_kinds_to = .FALSE.
ELSE
! KINDS
CALL section_vals_val_get(coordination_section, "KINDS_TO", n_rep_val=n_var)
CPASSERT(n_var > 0)
DO k = 1, n_var
CALL section_vals_val_get(coordination_section, "KINDS_TO", i_rep_val=k, c_vals=c_kinds)
CALL reallocate(colvar%coord_param%c_kinds_to, 1, ndim + SIZE(c_kinds))
colvar%coord_param%c_kinds_to(ndim + 1:ndim + SIZE(c_kinds)) = c_kinds
ndim = ndim + SIZE(c_kinds)
END DO
colvar%coord_param%n_atoms_to = 0
colvar%coord_param%use_kinds_to = .TRUE.
! Uppercase the label
DO k = 1, ndim
CALL uppercase(colvar%coord_param%c_kinds_to(k))
END DO
END IF
! Let's finish reading the other parameters
CALL section_vals_val_get(coordination_section, "R0", r_val=colvar%coord_param%r_0)
CALL section_vals_val_get(coordination_section, "NN", i_val=colvar%coord_param%nncrd)
CALL section_vals_val_get(coordination_section, "ND", i_val=colvar%coord_param%ndcrd)
! This section can be repeated
CALL section_vals_val_get(coordination_section, "ATOMS_TO_B", n_rep_val=n_var)
CALL section_vals_val_get(coordination_section, "KINDS_TO_B", n_rep_val=n_var_k)
ndim = 0
IF (n_var /= 0 .OR. n_var_k /= 0) THEN
colvar%coord_param%do_chain = .TRUE.
IF (n_var /= 0) THEN
! INDEX LIST
DO k = 1, n_var
CALL section_vals_val_get(coordination_section, "ATOMS_TO_B", i_rep_val=k, i_vals=iatms)
CALL reallocate(colvar%coord_param%i_at_to_b, 1, ndim + SIZE(iatms))
colvar%coord_param%i_at_to_b(ndim + 1:ndim + SIZE(iatms)) = iatms
ndim = ndim + SIZE(iatms)
END DO
colvar%coord_param%n_atoms_to_b = ndim
colvar%coord_param%use_kinds_to_b = .FALSE.
ELSE
! KINDS
CALL section_vals_val_get(coordination_section, "KINDS_TO_B", n_rep_val=n_var_k)
CPASSERT(n_var_k > 0)
DO k = 1, n_var_k
CALL section_vals_val_get(coordination_section, "KINDS_TO_B", i_rep_val=k, c_vals=c_kinds)
CALL reallocate(colvar%coord_param%c_kinds_to_b, 1, ndim + SIZE(c_kinds))
colvar%coord_param%c_kinds_to_b(ndim + 1:ndim + SIZE(c_kinds)) = c_kinds
ndim = ndim + SIZE(c_kinds)
END DO
colvar%coord_param%n_atoms_to_b = 0
colvar%coord_param%use_kinds_to_b = .TRUE.
! Uppercase the label
DO k = 1, ndim
CALL uppercase(colvar%coord_param%c_kinds_to_b(k))
END DO
END IF
! Let's finish reading the other parameters
CALL section_vals_val_get(coordination_section, "R0_B", r_val=colvar%coord_param%r_0_b)
CALL section_vals_val_get(coordination_section, "NN_B", i_val=colvar%coord_param%nncrd_b)
CALL section_vals_val_get(coordination_section, "ND_B", i_val=colvar%coord_param%ndcrd_b)
ELSE
colvar%coord_param%do_chain = .FALSE.
colvar%coord_param%n_atoms_to_b = 0
colvar%coord_param%use_kinds_to_b = .FALSE.
NULLIFY (colvar%coord_param%i_at_to_b)
NULLIFY (colvar%coord_param%c_kinds_to_b)
colvar%coord_param%nncrd_b = 0
colvar%coord_param%ndcrd_b = 0
colvar%coord_param%r_0_b = 0._dp
END IF
ELSE IF (my_subsection(5)) THEN
! Distance point from plane
wrk_section => plane_dist_section
CALL colvar_create(colvar, plane_distance_colvar_id)
CALL colvar_check_points(colvar, plane_dist_section)
CALL section_vals_val_get(plane_dist_section, "ATOMS_PLANE", i_vals=iatms)
CPASSERT(SIZE(iatms) == 3)
colvar%plane_distance_param%plane = iatms
CALL section_vals_val_get(plane_dist_section, "ATOM_POINT", i_val=iatm)
colvar%plane_distance_param%point = iatm
CALL section_vals_val_get(plane_dist_section, "PBC", l_val=colvar%plane_distance_param%use_pbc)
ELSE IF (my_subsection(6)) THEN
! Rotation colvar of a segment w.r.t. another segment
wrk_section => rotation_section
CALL colvar_create(colvar, rotation_colvar_id)
CALL colvar_check_points(colvar, rotation_section)
CALL section_vals_val_get(rotation_section, "P1_BOND1", i_val=colvar%rotation_param%i_at1_bond1)
CALL section_vals_val_get(rotation_section, "P2_BOND1", i_val=colvar%rotation_param%i_at2_bond1)
CALL section_vals_val_get(rotation_section, "P1_BOND2", i_val=colvar%rotation_param%i_at1_bond2)
CALL section_vals_val_get(rotation_section, "P2_BOND2", i_val=colvar%rotation_param%i_at2_bond2)
ELSE IF (my_subsection(7)) THEN
! Difference of two distances
wrk_section => dfunct_section
CALL colvar_create(colvar, dfunct_colvar_id)
CALL colvar_check_points(colvar, dfunct_section)
CALL section_vals_val_get(dfunct_section, "ATOMS", i_vals=iatms)
colvar%dfunct_param%i_at_dfunct = iatms
CALL section_vals_val_get(dfunct_section, "COEFFICIENT", r_val=colvar%dfunct_param%coeff)
CALL section_vals_val_get(dfunct_section, "PBC", l_val=colvar%dfunct_param%use_pbc)
ELSE IF (my_subsection(8)) THEN
! Q Parameter
wrk_section => qparm_section
CALL colvar_create(colvar, qparm_colvar_id)
CALL colvar_check_points(colvar, qparm_section)
CALL section_vals_val_get(qparm_section, "RCUT", r_val=colvar%qparm_param%rcut)
CALL section_vals_val_get(qparm_section, "RSTART", r_val=colvar%qparm_param%rstart)
CALL section_vals_val_get(qparm_section, "INCLUDE_IMAGES", l_val=colvar%qparm_param%include_images)
!CALL section_vals_val_get(qparm_section, "ALPHA", r_val=colvar%qparm_param%alpha)
CALL section_vals_val_get(qparm_section, "L", i_val=colvar%qparm_param%l)
NULLIFY (colvar%qparm_param%i_at_from)
NULLIFY (colvar%qparm_param%i_at_to)
CALL section_vals_val_get(qparm_section, "ATOMS_FROM", n_rep_val=n_var)
ndim = 0
DO k = 1, n_var
CALL section_vals_val_get(qparm_section, "ATOMS_FROM", i_rep_val=k, i_vals=iatms)
CALL reallocate(colvar%qparm_param%i_at_from, 1, ndim + SIZE(iatms))
colvar%qparm_param%i_at_from(ndim + 1:ndim + SIZE(iatms)) = iatms
ndim = ndim + SIZE(iatms)
END DO
colvar%qparm_param%n_atoms_from = ndim
! This section can be repeated
CALL section_vals_val_get(qparm_section, "ATOMS_TO", n_rep_val=n_var)
ndim = 0
DO k = 1, n_var
CALL section_vals_val_get(qparm_section, "ATOMS_TO", i_rep_val=k, i_vals=iatms)
CALL reallocate(colvar%qparm_param%i_at_to, 1, ndim + SIZE(iatms))
colvar%qparm_param%i_at_to(ndim + 1:ndim + SIZE(iatms)) = iatms
ndim = ndim + SIZE(iatms)
END DO
colvar%qparm_param%n_atoms_to = ndim
ELSE IF (my_subsection(9)) THEN
! Hydronium
CALL colvar_create(colvar, hydronium_shell_colvar_id)
NULLIFY (colvar%hydronium_shell_param%i_oxygens)
NULLIFY (colvar%hydronium_shell_param%i_hydrogens)
CALL read_hydronium_colvars(hydronium_shell_section, colvar, hydronium_shell_colvar_id, &
colvar%hydronium_shell_param%n_oxygens, &
colvar%hydronium_shell_param%n_hydrogens, &
colvar%hydronium_shell_param%i_oxygens, &
colvar%hydronium_shell_param%i_hydrogens)
ELSE IF (my_subsection(10) .OR. my_subsection(16)) THEN
!reaction path or distance from reaction path
IF (my_subsection(10)) THEN
path_section => reaction_path_section
CALL colvar_create(colvar, reaction_path_colvar_id)
fmid = "POS"
ifunc = 1
ELSE IF (my_subsection(16)) THEN
path_section => distance_from_path_section
CALL colvar_create(colvar, distance_from_path_colvar_id)
fmid = "DIS"
ifunc = 2
END IF
colvar%use_points = .FALSE.
CALL section_vals_val_get(path_section, "LAMBDA", r_val=colvar%reaction_path_param%lambda)
CALL section_vals_val_get(path_section, "DISTANCES_RMSD", l_val=colvar%reaction_path_param%dist_rmsd)
CALL section_vals_val_get(path_section, "RMSD", l_val=colvar%reaction_path_param%rmsd)
IF (colvar%reaction_path_param%dist_rmsd .AND. colvar%reaction_path_param%rmsd) THEN
CPABORT("CV REACTION PATH: only one between DISTANCES_RMSD and RMSD can be used ")
END IF
IF (colvar%reaction_path_param%dist_rmsd .OR. colvar%reaction_path_param%rmsd) THEN
NULLIFY (colvar%reaction_path_param%i_rmsd, colvar%reaction_path_param%r_ref)
frame_section => section_vals_get_subs_vals(path_section, "FRAME")
CALL section_vals_get(frame_section, n_repetition=nr_frame)
colvar%reaction_path_param%nr_frames = nr_frame
CALL read_frames(frame_section, para_env, nr_frame, colvar%reaction_path_param%r_ref, &
colvar%reaction_path_param%n_components)
CALL section_vals_val_get(path_section, "SUBSET_TYPE", i_val=colvar%reaction_path_param%subset)
IF (colvar%reaction_path_param%subset == rmsd_all) THEN
ALLOCATE (colvar%reaction_path_param%i_rmsd(colvar%reaction_path_param%n_components))
DO i = 1, colvar%reaction_path_param%n_components
colvar%reaction_path_param%i_rmsd(i) = i
END DO
ELSE IF (colvar%reaction_path_param%subset == rmsd_list) THEN
! This section can be repeated
CALL section_vals_val_get(path_section, "ATOMS", n_rep_val=n_var)
ndim = 0
IF (n_var /= 0) THEN
! INDEX LIST
DO k = 1, n_var
CALL section_vals_val_get(path_section, "ATOMS", i_rep_val=k, i_vals=iatms)
CALL reallocate(colvar%reaction_path_param%i_rmsd, 1, ndim + SIZE(iatms))
colvar%reaction_path_param%i_rmsd(ndim + 1:ndim + SIZE(iatms)) = iatms
ndim = ndim + SIZE(iatms)
END DO
colvar%reaction_path_param%n_components = ndim
ELSE
CPABORT("CV REACTION PATH: if SUBSET_TYPE=LIST a list of atoms needs to be provided ")
END IF
END IF
CALL section_vals_val_get(path_section, "ALIGN_FRAMES", l_val=colvar%reaction_path_param%align_frames)
ELSE
colvar_subsection => section_vals_get_subs_vals(path_section, "COLVAR")
CALL section_vals_get(colvar_subsection, n_repetition=ncol)
ALLOCATE (colvar%reaction_path_param%colvar_p(ncol))
IF (ncol > 0) THEN
DO i = 1, ncol
NULLIFY (colvar%reaction_path_param%colvar_p(i)%colvar)
CALL colvar_read(colvar%reaction_path_param%colvar_p(i)%colvar, i, colvar_subsection, para_env)
END DO
ELSE
CPABORT("CV REACTION PATH: the number of CV to define the path must be >0 ")
END IF
colvar%reaction_path_param%n_components = ncol
NULLIFY (range)
CALL section_vals_val_get(path_section, "RANGE", r_vals=range)
CALL section_vals_val_get(path_section, "STEP_SIZE", r_val=colvar%reaction_path_param%step_size)
iend = CEILING(MAX(RANGE(1), RANGE(2))/colvar%reaction_path_param%step_size)
istart = FLOOR(MIN(RANGE(1), RANGE(2))/colvar%reaction_path_param%step_size)
colvar%reaction_path_param%function_bounds(1) = istart
colvar%reaction_path_param%function_bounds(2) = iend
colvar%reaction_path_param%nr_frames = 2 !iend - istart + 1
ALLOCATE (colvar%reaction_path_param%f_vals(ncol, istart:iend))
CALL section_vals_val_get(path_section, "VARIABLE", c_vals=my_par, i_rep_val=1)
CALL section_vals_val_get(path_section, "FUNCTION", n_rep_val=ncol)
check = (ncol == SIZE(colvar%reaction_path_param%colvar_p))
CPASSERT(check)
CALL initf(ncol)
DO i = 1, ncol
CALL section_vals_val_get(path_section, "FUNCTION", c_val=path_function, i_rep_val=i)
CALL compress(path_function, full=.TRUE.)
CALL parsef(i, TRIM(path_function), my_par)
DO j = istart, iend
my_val = REAL(j, kind=dp)*colvar%reaction_path_param%step_size
colvar%reaction_path_param%f_vals(i, j) = evalf(i, my_val)
END DO
END DO
CALL finalizef()
iw1 = cp_print_key_unit_nr(logger, path_section, &
"MAP", middle_name=fmid, extension=".dat", file_status="REPLACE")
IF (iw1 > 0) THEN
CALL section_vals_val_get(path_section, "MAP%GRID_SPACING", n_rep_val=ncol)
ALLOCATE (grid_sp(ncol))
DO i = 1, ncol
CALL section_vals_val_get(path_section, "MAP%GRID_SPACING", r_val=grid_sp(i))
END DO
CALL section_vals_val_get(path_section, "MAP%RANGE", n_rep_val=ncol)
CPASSERT(ncol == SIZE(grid_sp))
ALLOCATE (p_range(2, ncol))
ALLOCATE (p_bounds(2, ncol))
DO i = 1, ncol
CALL section_vals_val_get(path_section, "MAP%RANGE", r_vals=g_range)
p_range(:, i) = g_range(:)
p_bounds(2, i) = CEILING(MAX(p_range(1, i), p_range(2, i))/grid_sp(i))
p_bounds(1, i) = FLOOR(MIN(p_range(1, i), p_range(2, i))/grid_sp(i))
END DO
ALLOCATE (s1v(2, istart:iend))
ALLOCATE (s1(2))
ALLOCATE (grid_point(ncol))
v_count = 0
kk = rec_eval_grid(iw1, ncol, colvar%reaction_path_param%f_vals, v_count, &
grid_point, grid_sp, colvar%reaction_path_param%step_size, istart, &
iend, s1v, s1, p_bounds, colvar%reaction_path_param%lambda, ifunc=ifunc, &
nconf=colvar%reaction_path_param%nr_frames)
DEALLOCATE (grid_sp)
DEALLOCATE (p_range)
DEALLOCATE (p_bounds)
DEALLOCATE (s1v)
DEALLOCATE (s1)
DEALLOCATE (grid_point)
END IF
CALL cp_print_key_finished_output(iw1, logger, path_section, &
"MAP")
END IF
ELSE IF (my_subsection(11)) THEN
! combine colvar
CALL colvar_create(colvar, combine_colvar_id)
colvar%use_points = .FALSE.
colvar_subsection => section_vals_get_subs_vals(combine_section, "COLVAR")
CALL section_vals_get(colvar_subsection, n_repetition=ncol)
ALLOCATE (colvar%combine_cvs_param%colvar_p(ncol))
! In case we need to print some information..
iw = cp_print_key_unit_nr(logger, colvar_section, &
"PRINT%PROGRAM_RUN_INFO", extension=".colvarLog")
IF (iw > 0) THEN
WRITE (iw, '( A )') ' '// &
'**********************************************************************'
WRITE (iw, '( A,I8)') ' COLVARS| COLVAR INPUT INDEX: ', icol
WRITE (iw, '( A,T49,4I8)') ' COLVARS| COMBINATION OF THE FOLLOWING COLVARS:'
END IF
CALL cp_print_key_finished_output(iw, logger, colvar_section, &
"PRINT%PROGRAM_RUN_INFO")
! Parsing the real COLVARs
DO i = 1, ncol
NULLIFY (colvar%combine_cvs_param%colvar_p(i)%colvar)
CALL colvar_read(colvar%combine_cvs_param%colvar_p(i)%colvar, i, colvar_subsection, para_env)
END DO
! Function definition
CALL section_vals_val_get(combine_section, "FUNCTION", c_val=colvar%combine_cvs_param%function)
CALL compress(colvar%combine_cvs_param%function, full=.TRUE.)
! Variables
CALL section_vals_val_get(combine_section, "VARIABLES", c_vals=my_par)
ALLOCATE (colvar%combine_cvs_param%variables(SIZE(my_par)))
colvar%combine_cvs_param%variables = my_par
! Check that the number of COLVAR provided is equal to the number of variables..
IF (SIZE(my_par) /= ncol) &
CALL cp_abort(__LOCATION__, &
"Number of defined COLVAR for COMBINE_COLVAR is different from the "// &
"number of variables! It is not possible to define COLVARs in a COMBINE_COLVAR "// &
"and avoid their usage in the combininig function!")
! Parameters
ALLOCATE (colvar%combine_cvs_param%c_parameters(0))
CALL section_vals_val_get(combine_section, "PARAMETERS", n_rep_val=ncol)
DO i = 1, ncol
isize = SIZE(colvar%combine_cvs_param%c_parameters)
CALL section_vals_val_get(combine_section, "PARAMETERS", c_vals=my_par, i_rep_val=i)
CALL reallocate(colvar%combine_cvs_param%c_parameters, 1, isize + SIZE(my_par))
colvar%combine_cvs_param%c_parameters(isize + 1:isize + SIZE(my_par)) = my_par
END DO
ALLOCATE (colvar%combine_cvs_param%v_parameters(0))
CALL section_vals_val_get(combine_section, "VALUES", n_rep_val=ncol)
DO i = 1, ncol
isize = SIZE(colvar%combine_cvs_param%v_parameters)
CALL section_vals_val_get(combine_section, "VALUES", r_vals=my_vals, i_rep_val=i)
CALL reallocate(colvar%combine_cvs_param%v_parameters, 1, isize + SIZE(my_vals))
colvar%combine_cvs_param%v_parameters(isize + 1:isize + SIZE(my_vals)) = my_vals
END DO
! Info on derivative evaluation
CALL section_vals_val_get(combine_section, "DX", r_val=colvar%combine_cvs_param%dx)
CALL section_vals_val_get(combine_section, "ERROR_LIMIT", r_val=colvar%combine_cvs_param%lerr)
ELSE IF (my_subsection(12)) THEN
! Population
wrk_section => population_section
CALL colvar_create(colvar, population_colvar_id)
CALL colvar_check_points(colvar, population_section)
NULLIFY (colvar%population_param%i_at_from, colvar%population_param%c_kinds_from)
NULLIFY (colvar%population_param%i_at_to, colvar%population_param%c_kinds_to)
! This section can be repeated
CALL section_vals_val_get(population_section, "ATOMS_FROM", n_rep_val=n_var)
ndim = 0
IF (n_var /= 0) THEN
! INDEX LIST
DO k = 1, n_var
CALL section_vals_val_get(population_section, "ATOMS_FROM", i_rep_val=k, i_vals=iatms)
CALL reallocate(colvar%population_param%i_at_from, 1, ndim + SIZE(iatms))
colvar%population_param%i_at_from(ndim + 1:ndim + SIZE(iatms)) = iatms
ndim = ndim + SIZE(iatms)
END DO
colvar%population_param%n_atoms_from = ndim
colvar%population_param%use_kinds_from = .FALSE.
ELSE
! KINDS
CALL section_vals_val_get(population_section, "KINDS_FROM", n_rep_val=n_var)
CPASSERT(n_var > 0)
DO k = 1, n_var
CALL section_vals_val_get(population_section, "KINDS_FROM", i_rep_val=k, c_vals=c_kinds)
CALL reallocate(colvar%population_param%c_kinds_from, 1, ndim + SIZE(c_kinds))
colvar%population_param%c_kinds_from(ndim + 1:ndim + SIZE(c_kinds)) = c_kinds
ndim = ndim + SIZE(c_kinds)
END DO
colvar%population_param%n_atoms_from = 0
colvar%population_param%use_kinds_from = .TRUE.
! Uppercase the label
DO k = 1, ndim
CALL uppercase(colvar%population_param%c_kinds_from(k))
END DO
END IF
! This section can be repeated
CALL section_vals_val_get(population_section, "ATOMS_TO", n_rep_val=n_var)
ndim = 0
IF (n_var /= 0) THEN
! INDEX LIST
DO k = 1, n_var
CALL section_vals_val_get(population_section, "ATOMS_TO", i_rep_val=k, i_vals=iatms)
CALL reallocate(colvar%population_param%i_at_to, 1, ndim + SIZE(iatms))
colvar%population_param%i_at_to(ndim + 1:ndim + SIZE(iatms)) = iatms
ndim = ndim + SIZE(iatms)
END DO
colvar%population_param%n_atoms_to = ndim
colvar%population_param%use_kinds_to = .FALSE.
ELSE
! KINDS
CALL section_vals_val_get(population_section, "KINDS_TO", n_rep_val=n_var)
CPASSERT(n_var > 0)
DO k = 1, n_var
CALL section_vals_val_get(population_section, "KINDS_TO", i_rep_val=k, c_vals=c_kinds)
CALL reallocate(colvar%population_param%c_kinds_to, 1, ndim + SIZE(c_kinds))
colvar%population_param%c_kinds_to(ndim + 1:ndim + SIZE(c_kinds)) = c_kinds
ndim = ndim + SIZE(c_kinds)
END DO
colvar%population_param%n_atoms_to = 0
colvar%population_param%use_kinds_to = .TRUE.
! Uppercase the label
DO k = 1, ndim
CALL uppercase(colvar%population_param%c_kinds_to(k))
END DO
END IF
! Let's finish reading the other parameters
CALL section_vals_val_get(population_section, "R0", r_val=colvar%population_param%r_0)
CALL section_vals_val_get(population_section, "NN", i_val=colvar%population_param%nncrd)
CALL section_vals_val_get(population_section, "ND", i_val=colvar%population_param%ndcrd)
CALL section_vals_val_get(population_section, "N0", i_val=colvar%population_param%n0)
CALL section_vals_val_get(population_section, "SIGMA", r_val=colvar%population_param%sigma)
ELSE IF (my_subsection(13)) THEN
! Angle between two planes
wrk_section => plane_plane_angle_section
CALL colvar_create(colvar, plane_plane_angle_colvar_id)
CALL colvar_check_points(colvar, plane_plane_angle_section)
! Read the specification of the two planes
plane_sections => section_vals_get_subs_vals(plane_plane_angle_section, "PLANE")
CALL section_vals_get(plane_sections, n_repetition=n_var)
IF (n_var /= 2) &
CPABORT("PLANE_PLANE_ANGLE Colvar section: Two PLANE sections must be provided!")
! Plane 1
CALL section_vals_val_get(plane_sections, "DEF_TYPE", i_rep_section=1, &
i_val=colvar%plane_plane_angle_param%plane1%type_of_def)
IF (colvar%plane_plane_angle_param%plane1%type_of_def == plane_def_vec) THEN
CALL section_vals_val_get(plane_sections, "NORMAL_VECTOR", i_rep_section=1, &
r_vals=s1)
colvar%plane_plane_angle_param%plane1%normal_vec = s1
ELSE
CALL section_vals_val_get(plane_sections, "ATOMS", i_rep_section=1, &
i_vals=iatms)
colvar%plane_plane_angle_param%plane1%points = iatms
END IF
! Plane 2
CALL section_vals_val_get(plane_sections, "DEF_TYPE", i_rep_section=2, &
i_val=colvar%plane_plane_angle_param%plane2%type_of_def)
IF (colvar%plane_plane_angle_param%plane2%type_of_def == plane_def_vec) THEN
CALL section_vals_val_get(plane_sections, "NORMAL_VECTOR", i_rep_section=2, &
r_vals=s1)
colvar%plane_plane_angle_param%plane2%normal_vec = s1
ELSE
CALL section_vals_val_get(plane_sections, "ATOMS", i_rep_section=2, &
i_vals=iatms)
colvar%plane_plane_angle_param%plane2%points = iatms
END IF
ELSE IF (my_subsection(14)) THEN
! Gyration Radius
wrk_section => gyration_section
CALL colvar_create(colvar, gyration_colvar_id)
CALL colvar_check_points(colvar, gyration_section)
NULLIFY (colvar%gyration_param%i_at, colvar%gyration_param%c_kinds)
! This section can be repeated
CALL section_vals_val_get(gyration_section, "ATOMS", n_rep_val=n_var)
ndim = 0
IF (n_var /= 0) THEN
! INDEX LIST
DO k = 1, n_var
CALL section_vals_val_get(gyration_section, "ATOMS", i_rep_val=k, i_vals=iatms)
CALL reallocate(colvar%gyration_param%i_at, 1, ndim + SIZE(iatms))
colvar%gyration_param%i_at(ndim + 1:ndim + SIZE(iatms)) = iatms
ndim = ndim + SIZE(iatms)
END DO
colvar%gyration_param%n_atoms = ndim
colvar%gyration_param%use_kinds = .FALSE.
ELSE
! KINDS
CALL section_vals_val_get(gyration_section, "KINDS", n_rep_val=n_var)
CPASSERT(n_var > 0)
DO k = 1, n_var
CALL section_vals_val_get(gyration_section, "KINDS", i_rep_val=k, c_vals=c_kinds)
CALL reallocate(colvar%gyration_param%c_kinds, 1, ndim + SIZE(c_kinds))
colvar%gyration_param%c_kinds(ndim + 1:ndim + SIZE(c_kinds)) = c_kinds
ndim = ndim + SIZE(c_kinds)
END DO
colvar%gyration_param%n_atoms = 0
colvar%gyration_param%use_kinds = .TRUE.
! Uppercase the label
DO k = 1, ndim
CALL uppercase(colvar%gyration_param%c_kinds(k))
END DO
END IF
ELSE IF (my_subsection(15)) THEN
! RMSD_AB
wrk_section => rmsd_section
CALL colvar_create(colvar, rmsd_colvar_id)
NULLIFY (colvar%rmsd_param%i_rmsd, colvar%rmsd_param%r_ref, colvar%rmsd_param%weights)
frame_section => section_vals_get_subs_vals(rmsd_section, "FRAME")
CALL section_vals_get(frame_section, n_repetition=nr_frame)
colvar%rmsd_param%nr_frames = nr_frame
! Calculation is aborted if reference frame are less than 1 and more than 2
CPASSERT(nr_frame >= 1 .AND. nr_frame <= 2)
CALL read_frames(frame_section, para_env, nr_frame, colvar%rmsd_param%r_ref, &
colvar%rmsd_param%n_atoms)
ALLOCATE (colvar%rmsd_param%weights(colvar%rmsd_param%n_atoms))
colvar%rmsd_param%weights = 0.0_dp
CALL section_vals_val_get(rmsd_section, "SUBSET_TYPE", i_val=colvar%rmsd_param%subset)
IF (colvar%rmsd_param%subset == rmsd_all) THEN
ALLOCATE (colvar%rmsd_param%i_rmsd(colvar%rmsd_param%n_atoms))
DO i = 1, colvar%rmsd_param%n_atoms
colvar%rmsd_param%i_rmsd(i) = i
END DO
ELSE IF (colvar%rmsd_param%subset == rmsd_list) THEN
! This section can be repeated
CALL section_vals_val_get(rmsd_section, "ATOMS", n_rep_val=n_var)
ndim = 0
IF (n_var /= 0) THEN
! INDEX LIST
DO k = 1, n_var
CALL section_vals_val_get(rmsd_section, "ATOMS", i_rep_val=k, i_vals=iatms)
CALL reallocate(colvar%rmsd_param%i_rmsd, 1, ndim + SIZE(iatms))
colvar%rmsd_param%i_rmsd(ndim + 1:ndim + SIZE(iatms)) = iatms
ndim = ndim + SIZE(iatms)
END DO
colvar%rmsd_param%n_atoms = ndim
ELSE
CPABORT("CV RMSD: if SUBSET_TYPE=LIST a list of atoms needs to be provided ")
END IF
ELSE IF (colvar%rmsd_param%subset == rmsd_weightlist) THEN
CALL section_vals_val_get(rmsd_section, "ATOMS", n_rep_val=n_var)
ndim = 0
IF (n_var /= 0) THEN
! INDEX LIST
DO k = 1, n_var
CALL section_vals_val_get(rmsd_section, "ATOMS", i_rep_val=k, i_vals=iatms)
CALL reallocate(colvar%rmsd_param%i_rmsd, 1, ndim + SIZE(iatms))
colvar%rmsd_param%i_rmsd(ndim + 1:ndim + SIZE(iatms)) = iatms
ndim = ndim + SIZE(iatms)
END DO
colvar%rmsd_param%n_atoms = ndim
ELSE
CPABORT("CV RMSD: if SUBSET_TYPE=WEIGHT_LIST a list of atoms needs to be provided ")
END IF
CALL section_vals_val_get(rmsd_section, "WEIGHTS", n_rep_val=n_var)
ndim = 0
IF (n_var /= 0) THEN
! INDEX LIST
DO k = 1, n_var
CALL section_vals_val_get(rmsd_section, "WEIGHTS", i_rep_val=k, r_vals=wei)
CALL reallocate(weights, 1, ndim + SIZE(wei))
weights(ndim + 1:ndim + SIZE(wei)) = wei
ndim = ndim + SIZE(wei)
END DO
IF (ndim /= colvar%rmsd_param%n_atoms) &
CALL cp_abort(__LOCATION__, "CV RMSD: list of atoms and list of "// &
"weights need to contain same number of entries. ")
DO i = 1, ndim
ii = colvar%rmsd_param%i_rmsd(i)
colvar%rmsd_param%weights(ii) = weights(i)
END DO
DEALLOCATE (weights)
ELSE
CPABORT("CV RMSD: if SUBSET_TYPE=WEIGHT_LIST a list of weights need to be provided. ")
END IF
ELSE
CPABORT("CV RMSD: unknown SUBSET_TYPE.")
END IF
CALL section_vals_val_get(rmsd_section, "ALIGN_FRAMES", l_val=colvar%rmsd_param%align_frames)
ELSE IF (my_subsection(17)) THEN
! Work on XYZ positions of atoms
wrk_section => xyz_diag_section
CALL colvar_create(colvar, xyz_diag_colvar_id)
CALL colvar_check_points(colvar, wrk_section)
CALL section_vals_val_get(wrk_section, "ATOM", i_val=iatm)
CALL section_vals_val_get(wrk_section, "COMPONENT", i_val=icomponent)
CALL section_vals_val_get(wrk_section, "PBC", l_val=colvar%xyz_diag_param%use_pbc)
CALL section_vals_val_get(wrk_section, "ABSOLUTE_POSITION", l_val=colvar%xyz_diag_param%use_absolute_position)
colvar%xyz_diag_param%i_atom = iatm
colvar%xyz_diag_param%component = icomponent
ELSE IF (my_subsection(18)) THEN
! Work on the outer diagonal (two atoms A,B) XYZ positions
wrk_section => xyz_outerdiag_section
CALL colvar_create(colvar, xyz_outerdiag_colvar_id)
CALL colvar_check_points(colvar, wrk_section)
CALL section_vals_val_get(wrk_section, "ATOMS", i_vals=iatms)
colvar%xyz_outerdiag_param%i_atoms = iatms
CALL section_vals_val_get(wrk_section, "COMPONENT_A", i_val=icomponent)
colvar%xyz_outerdiag_param%components(1) = icomponent
CALL section_vals_val_get(wrk_section, "COMPONENT_B", i_val=icomponent)
colvar%xyz_outerdiag_param%components(2) = icomponent
CALL section_vals_val_get(wrk_section, "PBC", l_val=colvar%xyz_outerdiag_param%use_pbc)
ELSE IF (my_subsection(19)) THEN
! Energy
wrk_section => u_section
CALL colvar_create(colvar, u_colvar_id)
colvar%u_param%mixed_energy_section => section_vals_get_subs_vals(wrk_section, "MIXED")
CALL section_vals_get(colvar%u_param%mixed_energy_section, explicit=use_mixed_energy)
IF (.NOT. use_mixed_energy) NULLIFY (colvar%u_param%mixed_energy_section)
ELSE IF (my_subsection(20)) THEN
! Wc hydrogen bond
wrk_section => Wc_section
CALL colvar_create(colvar, Wc_colvar_id)
CALL colvar_check_points(colvar, Wc_section)
CALL section_vals_val_get(Wc_section, "ATOMS", i_vals=iatms)
CALL section_vals_val_get(wrk_section, "RCUT", r_val=my_val(1))
colvar%Wc%rcut = cp_unit_to_cp2k(my_val(1), "angstrom")
colvar%Wc%ids = iatms
ELSE IF (my_subsection(21)) THEN
! HBP colvar
wrk_section => HBP_section
CALL colvar_create(colvar, HBP_colvar_id)
CALL colvar_check_points(colvar, HBP_section)
CALL section_vals_val_get(wrk_section, "NPOINTS", i_val=colvar%HBP%nPoints)
CALL section_vals_val_get(wrk_section, "RCUT", r_val=my_val(1))
colvar%HBP%rcut = cp_unit_to_cp2k(my_val(1), "angstrom")
CALL section_vals_val_get(wrk_section, "RCUT", r_val=colvar%HBP%shift)
ALLOCATE (colvar%HBP%ids(colvar%HBP%nPoints, 3))
ALLOCATE (colvar%HBP%ewc(colvar%HBP%nPoints))
DO i = 1, colvar%HBP%nPoints
CALL section_vals_val_get(wrk_section, "ATOMS", i_rep_val=i, i_vals=iatms)
colvar%HBP%ids(i, :) = iatms
END DO
ELSE IF (my_subsection(22)) THEN
! Ring Puckering
CALL colvar_create(colvar, ring_puckering_colvar_id)
CALL section_vals_val_get(ring_puckering_section, "ATOMS", i_vals=iatms)
colvar%ring_puckering_param%nring = SIZE(iatms)
ALLOCATE (colvar%ring_puckering_param%atoms(SIZE(iatms)))
colvar%ring_puckering_param%atoms = iatms
CALL section_vals_val_get(ring_puckering_section, "COORDINATE", &
i_val=colvar%ring_puckering_param%iq)
! test the validity of the parameters
ndim = colvar%ring_puckering_param%nring
IF (ndim <= 3) &
CPABORT("CV Ring Puckering: Ring size has to be 4 or larger. ")
ii = colvar%ring_puckering_param%iq
IF (ABS(ii) == 1 .OR. ii < -(ndim - 1)/2 .OR. ii > ndim/2) &
CPABORT("CV Ring Puckering: Invalid coordinate number.")
ELSE IF (my_subsection(23)) THEN
! Minimum Distance
wrk_section => mindist_section
CALL colvar_create(colvar, mindist_colvar_id)
CALL colvar_check_points(colvar, mindist_section)
NULLIFY (colvar%mindist_param%i_dist_from, colvar%mindist_param%i_coord_from, &
colvar%mindist_param%k_coord_from, colvar%mindist_param%i_coord_to, &
colvar%mindist_param%k_coord_to)
CALL section_vals_val_get(mindist_section, "ATOMS_DISTANCE", i_vals=iatms)
colvar%mindist_param%n_dist_from = SIZE(iatms)
ALLOCATE (colvar%mindist_param%i_dist_from(SIZE(iatms)))
colvar%mindist_param%i_dist_from = iatms
CALL section_vals_val_get(mindist_section, "ATOMS_FROM", n_rep_val=n_var)
ndim = 0
IF (n_var /= 0) THEN
! INDEX LIST
DO k = 1, n_var
CALL section_vals_val_get(mindist_section, "ATOMS_FROM", i_rep_val=k, i_vals=iatms)
CALL reallocate(colvar%mindist_param%i_coord_from, 1, ndim + SIZE(iatms))
colvar%mindist_param%i_coord_from(ndim + 1:ndim + SIZE(iatms)) = iatms
ndim = ndim + SIZE(iatms)
END DO
colvar%mindist_param%n_coord_from = ndim
colvar%mindist_param%use_kinds_from = .FALSE.
ELSE
!KINDS
CALL section_vals_val_get(mindist_section, "KINDS_FROM", n_rep_val=n_var)
CPASSERT(n_var > 0)
DO k = 1, n_var
CALL section_vals_val_get(mindist_section, "KINDS_FROM", i_rep_val=k, c_vals=c_kinds)
CALL reallocate(colvar%mindist_param%k_coord_from, 1, ndim + SIZE(c_kinds))
colvar%mindist_param%k_coord_from(ndim + 1:ndim + SIZE(c_kinds)) = c_kinds
ndim = ndim + SIZE(c_kinds)
END DO
colvar%mindist_param%n_coord_from = 0
colvar%mindist_param%use_kinds_from = .TRUE.
! Uppercase the label
DO k = 1, ndim
CALL uppercase(colvar%mindist_param%k_coord_from(k))
END DO
END IF
CALL section_vals_val_get(mindist_section, "ATOMS_TO", n_rep_val=n_var)
ndim = 0
IF (n_var /= 0) THEN
! INDEX LIST
DO k = 1, n_var
CALL section_vals_val_get(mindist_section, "ATOMS_TO", i_rep_val=k, i_vals=iatms)
CALL reallocate(colvar%mindist_param%i_coord_to, 1, ndim + SIZE(iatms))
colvar%mindist_param%i_coord_to(ndim + 1:ndim + SIZE(iatms)) = iatms
ndim = ndim + SIZE(iatms)
END DO
colvar%mindist_param%n_coord_to = ndim
colvar%mindist_param%use_kinds_to = .FALSE.
ELSE
!KINDS
CALL section_vals_val_get(mindist_section, "KINDS_TO", n_rep_val=n_var)