99#include "./base/base_uses.f90"
104 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'colvar_methods'
105 REAL(KIND=
dp),
PRIVATE,
PARAMETER :: tolerance_acos = 1.0e-5_dp
124 RECURSIVE SUBROUTINE colvar_read(colvar, icol, colvar_section, para_env, cell)
126 INTEGER,
INTENT(IN) :: icol
129 TYPE(
cell_type),
OPTIONAL,
POINTER :: cell
131 CHARACTER(len=*),
PARAMETER :: routinen =
'colvar_read'
133 CHARACTER(LEN=3) :: fmid
134 CHARACTER(LEN=7) :: tag, tag_comp, tag_comp1, tag_comp2
135 CHARACTER(LEN=default_path_length) :: path_function
136 CHARACTER(LEN=default_string_length) :: tmpstr, tmpstr2
137 CHARACTER(LEN=default_string_length), &
138 DIMENSION(:),
POINTER :: c_kinds, my_par
139 INTEGER :: handle, i, iatm, icomponent, iend, &
140 ifunc, ii, isize, istart, iw, iw1, j, &
141 k, kk, n_var, n_var_k, ncol, ndim, &
143 INTEGER,
DIMENSION(:),
POINTER :: iatms
144 INTEGER,
DIMENSION(:, :),
POINTER :: p_bounds
145 LOGICAL :: check, use_mixed_energy
146 LOGICAL,
DIMENSION(27) :: my_subsection
147 REAL(
dp),
DIMENSION(:),
POINTER :: s1, wei, weights
148 REAL(
dp),
DIMENSION(:, :),
POINTER :: p_range, s1v
149 REAL(kind=
dp),
DIMENSION(1) :: my_val
150 REAL(kind=
dp),
DIMENSION(:),
POINTER :: g_range, grid_point, grid_sp, my_vals, &
156 TYPE(
section_vals_type),
POINTER :: acid_hyd_dist_section, acid_hyd_shell_section, &
157 angle_section, colvar_subsection, combine_section, coordination_section, dfunct_section, &
158 distance_from_path_section, distance_section, frame_section, gyration_section, &
159 hbp_section, hydronium_dist_section, hydronium_shell_section, mindist_section, &
160 path_section, plane_dist_section, plane_plane_angle_section, plane_sections, &
161 point_section, population_section, qparm_section, reaction_path_section, &
162 ring_puckering_section, rmsd_section, rotation_section, torsion_section, u_section, &
163 voronoiipz_section, wc_section
164 TYPE(
section_vals_type),
POINTER :: wrk_section, xyz_diag_section, xyz_outerdiag_section
166 CALL timeset(routinen, handle)
167 NULLIFY (logger, c_kinds, iatms)
169 my_subsection = .false.
177 plane_plane_angle_section &
186 acid_hyd_shell_section &
189 can_return_null=.true.)
190 distance_from_path_section &
192 i_rep_section=icol, can_return_null=.true.)
194 can_return_null=.true.)
203 ring_puckering_section &
217 IF (
ASSOCIATED(reaction_path_section))
THEN
219 explicit=my_subsection(10))
221 IF (
ASSOCIATED(distance_from_path_section))
THEN
223 explicit=my_subsection(16))
225 IF (
ASSOCIATED(combine_section))
THEN
230 explicit=my_subsection(13))
239 explicit=my_subsection(22))
247 cpassert(count(my_subsection) == 1)
248 cpassert(.NOT.
ASSOCIATED(colvar))
250 IF (my_subsection(1))
THEN
252 wrk_section => distance_section
254 CALL colvar_check_points(colvar, distance_section, cell)
256 colvar%dist_param%i_at = iatms(1)
257 colvar%dist_param%j_at = iatms(2)
260 ELSE IF (my_subsection(2))
THEN
262 wrk_section => angle_section
264 CALL colvar_check_points(colvar, angle_section, cell)
266 colvar%angle_param%i_at_angle = iatms
267 ELSE IF (my_subsection(3))
THEN
269 wrk_section => torsion_section
271 CALL colvar_check_points(colvar, torsion_section, cell)
273 colvar%torsion_param%i_at_tors = iatms
274 colvar%torsion_param%o0 = 0.0_dp
275 ELSE IF (my_subsection(4))
THEN
277 wrk_section => coordination_section
279 CALL colvar_check_points(colvar, coordination_section, cell)
280 NULLIFY (colvar%coord_param%i_at_from, colvar%coord_param%c_kinds_from)
281 NULLIFY (colvar%coord_param%i_at_to, colvar%coord_param%c_kinds_to)
282 NULLIFY (colvar%coord_param%i_at_to_b, colvar%coord_param%c_kinds_to_b)
290 CALL reallocate(colvar%coord_param%i_at_from, 1, ndim +
SIZE(iatms))
291 colvar%coord_param%i_at_from(ndim + 1:ndim +
SIZE(iatms)) = iatms
292 ndim = ndim +
SIZE(iatms)
294 colvar%coord_param%n_atoms_from = ndim
295 colvar%coord_param%use_kinds_from = .false.
302 CALL reallocate(colvar%coord_param%c_kinds_from, 1, ndim +
SIZE(c_kinds))
303 colvar%coord_param%c_kinds_from(ndim + 1:ndim +
SIZE(c_kinds)) = c_kinds
304 ndim = ndim +
SIZE(c_kinds)
306 colvar%coord_param%n_atoms_from = 0
307 colvar%coord_param%use_kinds_from = .true.
310 CALL uppercase(colvar%coord_param%c_kinds_from(k))
320 CALL reallocate(colvar%coord_param%i_at_to, 1, ndim +
SIZE(iatms))
321 colvar%coord_param%i_at_to(ndim + 1:ndim +
SIZE(iatms)) = iatms
322 ndim = ndim +
SIZE(iatms)
324 colvar%coord_param%n_atoms_to = ndim
325 colvar%coord_param%use_kinds_to = .false.
332 CALL reallocate(colvar%coord_param%c_kinds_to, 1, ndim +
SIZE(c_kinds))
333 colvar%coord_param%c_kinds_to(ndim + 1:ndim +
SIZE(c_kinds)) = c_kinds
334 ndim = ndim +
SIZE(c_kinds)
336 colvar%coord_param%n_atoms_to = 0
337 colvar%coord_param%use_kinds_to = .true.
340 CALL uppercase(colvar%coord_param%c_kinds_to(k))
351 IF (n_var /= 0 .OR. n_var_k /= 0)
THEN
352 colvar%coord_param%do_chain = .true.
357 CALL reallocate(colvar%coord_param%i_at_to_b, 1, ndim +
SIZE(iatms))
358 colvar%coord_param%i_at_to_b(ndim + 1:ndim +
SIZE(iatms)) = iatms
359 ndim = ndim +
SIZE(iatms)
361 colvar%coord_param%n_atoms_to_b = ndim
362 colvar%coord_param%use_kinds_to_b = .false.
366 cpassert(n_var_k > 0)
369 CALL reallocate(colvar%coord_param%c_kinds_to_b, 1, ndim +
SIZE(c_kinds))
370 colvar%coord_param%c_kinds_to_b(ndim + 1:ndim +
SIZE(c_kinds)) = c_kinds
371 ndim = ndim +
SIZE(c_kinds)
373 colvar%coord_param%n_atoms_to_b = 0
374 colvar%coord_param%use_kinds_to_b = .true.
377 CALL uppercase(colvar%coord_param%c_kinds_to_b(k))
385 colvar%coord_param%do_chain = .false.
386 colvar%coord_param%n_atoms_to_b = 0
387 colvar%coord_param%use_kinds_to_b = .false.
388 NULLIFY (colvar%coord_param%i_at_to_b)
389 NULLIFY (colvar%coord_param%c_kinds_to_b)
390 colvar%coord_param%nncrd_b = 0
391 colvar%coord_param%ndcrd_b = 0
392 colvar%coord_param%r_0_b = 0._dp
395 ELSE IF (my_subsection(5))
THEN
397 wrk_section => plane_dist_section
399 CALL colvar_check_points(colvar, plane_dist_section, cell)
401 cpassert(
SIZE(iatms) == 3)
402 colvar%plane_distance_param%plane = iatms
404 colvar%plane_distance_param%point = iatm
406 ELSE IF (my_subsection(6))
THEN
408 wrk_section => rotation_section
410 CALL colvar_check_points(colvar, rotation_section, cell)
411 CALL section_vals_val_get(rotation_section,
"P1_BOND1", i_val=colvar%rotation_param%i_at1_bond1)
412 CALL section_vals_val_get(rotation_section,
"P2_BOND1", i_val=colvar%rotation_param%i_at2_bond1)
413 CALL section_vals_val_get(rotation_section,
"P1_BOND2", i_val=colvar%rotation_param%i_at1_bond2)
414 CALL section_vals_val_get(rotation_section,
"P2_BOND2", i_val=colvar%rotation_param%i_at2_bond2)
415 ELSE IF (my_subsection(7))
THEN
417 wrk_section => dfunct_section
419 CALL colvar_check_points(colvar, dfunct_section, cell)
421 colvar%dfunct_param%i_at_dfunct = iatms
424 ELSE IF (my_subsection(8))
THEN
426 wrk_section => qparm_section
428 CALL colvar_check_points(colvar, qparm_section, cell)
431 CALL section_vals_val_get(qparm_section,
"INCLUDE_IMAGES", l_val=colvar%qparm_param%include_images)
434 NULLIFY (colvar%qparm_param%i_at_from)
435 NULLIFY (colvar%qparm_param%i_at_to)
440 CALL reallocate(colvar%qparm_param%i_at_from, 1, ndim +
SIZE(iatms))
441 colvar%qparm_param%i_at_from(ndim + 1:ndim +
SIZE(iatms)) = iatms
442 ndim = ndim +
SIZE(iatms)
444 colvar%qparm_param%n_atoms_from = ndim
450 CALL reallocate(colvar%qparm_param%i_at_to, 1, ndim +
SIZE(iatms))
451 colvar%qparm_param%i_at_to(ndim + 1:ndim +
SIZE(iatms)) = iatms
452 ndim = ndim +
SIZE(iatms)
454 colvar%qparm_param%n_atoms_to = ndim
455 ELSE IF (my_subsection(9))
THEN
458 NULLIFY (colvar%hydronium_shell_param%i_oxygens)
459 NULLIFY (colvar%hydronium_shell_param%i_hydrogens)
461 colvar%hydronium_shell_param%n_oxygens, &
462 colvar%hydronium_shell_param%n_hydrogens, &
463 colvar%hydronium_shell_param%i_oxygens, &
464 colvar%hydronium_shell_param%i_hydrogens)
465 ELSE IF (my_subsection(10) .OR. my_subsection(16))
THEN
467 IF (my_subsection(10))
THEN
468 path_section => reaction_path_section
472 ELSE IF (my_subsection(16))
THEN
473 path_section => distance_from_path_section
478 colvar%use_points = .false.
480 CALL section_vals_val_get(path_section,
"DISTANCES_RMSD", l_val=colvar%reaction_path_param%dist_rmsd)
482 IF (colvar%reaction_path_param%dist_rmsd .AND. colvar%reaction_path_param%rmsd)
THEN
483 cpabort(
"CV REACTION PATH: only one between DISTANCES_RMSD and RMSD can be used ")
485 IF (colvar%reaction_path_param%dist_rmsd .OR. colvar%reaction_path_param%rmsd)
THEN
486 NULLIFY (colvar%reaction_path_param%i_rmsd, colvar%reaction_path_param%r_ref)
490 colvar%reaction_path_param%nr_frames = nr_frame
491 CALL read_frames(frame_section, para_env, nr_frame, colvar%reaction_path_param%r_ref, &
492 colvar%reaction_path_param%n_components)
494 IF (colvar%reaction_path_param%subset ==
rmsd_all)
THEN
495 ALLOCATE (colvar%reaction_path_param%i_rmsd(colvar%reaction_path_param%n_components))
496 DO i = 1, colvar%reaction_path_param%n_components
497 colvar%reaction_path_param%i_rmsd(i) = i
499 ELSE IF (colvar%reaction_path_param%subset ==
rmsd_list)
THEN
507 CALL reallocate(colvar%reaction_path_param%i_rmsd, 1, ndim +
SIZE(iatms))
508 colvar%reaction_path_param%i_rmsd(ndim + 1:ndim +
SIZE(iatms)) = iatms
509 ndim = ndim +
SIZE(iatms)
511 colvar%reaction_path_param%n_components = ndim
513 cpabort(
"CV REACTION PATH: if SUBSET_TYPE=LIST a list of atoms needs to be provided ")
517 CALL section_vals_val_get(path_section,
"ALIGN_FRAMES", l_val=colvar%reaction_path_param%align_frames)
521 ALLOCATE (colvar%reaction_path_param%colvar_p(ncol))
524 NULLIFY (colvar%reaction_path_param%colvar_p(i)%colvar)
525 CALL colvar_read(colvar%reaction_path_param%colvar_p(i)%colvar, i, colvar_subsection, para_env, cell)
528 cpabort(
"CV REACTION PATH: the number of CV to define the path must be >0 ")
530 colvar%reaction_path_param%n_components = ncol
533 CALL section_vals_val_get(path_section,
"STEP_SIZE", r_val=colvar%reaction_path_param%step_size)
534 iend = ceiling(max(range(1), range(2))/colvar%reaction_path_param%step_size)
535 istart = floor(min(range(1), range(2))/colvar%reaction_path_param%step_size)
536 colvar%reaction_path_param%function_bounds(1) = istart
537 colvar%reaction_path_param%function_bounds(2) = iend
538 colvar%reaction_path_param%nr_frames = 2
539 ALLOCATE (colvar%reaction_path_param%f_vals(ncol, istart:iend))
542 check = (ncol ==
SIZE(colvar%reaction_path_param%colvar_p))
547 CALL compress(path_function, full=.true.)
548 CALL parsef(i, trim(path_function), my_par)
550 my_val = real(j, kind=
dp)*colvar%reaction_path_param%step_size
551 colvar%reaction_path_param%f_vals(i, j) =
evalf(i, my_val)
557 "MAP", middle_name=fmid, extension=
".dat", file_status=
"REPLACE")
560 ALLOCATE (grid_sp(ncol))
565 cpassert(ncol ==
SIZE(grid_sp))
566 ALLOCATE (p_range(2, ncol))
567 ALLOCATE (p_bounds(2, ncol))
570 p_range(:, i) = g_range(:)
571 p_bounds(2, i) = ceiling(max(p_range(1, i), p_range(2, i))/grid_sp(i))
572 p_bounds(1, i) = floor(min(p_range(1, i), p_range(2, i))/grid_sp(i))
574 ALLOCATE (s1v(2, istart:iend))
576 ALLOCATE (grid_point(ncol))
578 kk = rec_eval_grid(iw1, ncol, colvar%reaction_path_param%f_vals, v_count, &
579 grid_point, grid_sp, colvar%reaction_path_param%step_size, istart, &
580 iend, s1v, s1, p_bounds, colvar%reaction_path_param%lambda, ifunc=ifunc, &
581 nconf=colvar%reaction_path_param%nr_frames)
584 DEALLOCATE (p_bounds)
587 DEALLOCATE (grid_point)
593 ELSE IF (my_subsection(11))
THEN
596 colvar%use_points = .false.
599 ALLOCATE (colvar%combine_cvs_param%colvar_p(ncol))
602 "PRINT%PROGRAM_RUN_INFO", extension=
".colvarLog")
604 WRITE (iw,
'( A )')
' '// &
605 '**********************************************************************'
606 WRITE (iw,
'( A,I8)')
' COLVARS| COLVAR INPUT INDEX: ', icol
607 WRITE (iw,
'( A,T49,4I8)')
' COLVARS| COMBINATION OF THE FOLLOWING COLVARS:'
610 "PRINT%PROGRAM_RUN_INFO")
613 NULLIFY (colvar%combine_cvs_param%colvar_p(i)%colvar)
614 CALL colvar_read(colvar%combine_cvs_param%colvar_p(i)%colvar, i, colvar_subsection, para_env, cell)
618 CALL compress(colvar%combine_cvs_param%function, full=.true.)
621 ALLOCATE (colvar%combine_cvs_param%variables(
SIZE(my_par)))
622 colvar%combine_cvs_param%variables = my_par
624 IF (
SIZE(my_par) /= ncol)
THEN
625 CALL cp_abort(__location__, &
626 "Number of defined COLVAR for COMBINE_COLVAR is different from the "// &
627 "number of variables! It is not possible to define COLVARs in a COMBINE_COLVAR "// &
628 "and avoid their usage in the combininig function!")
631 ALLOCATE (colvar%combine_cvs_param%c_parameters(0))
634 isize =
SIZE(colvar%combine_cvs_param%c_parameters)
636 CALL reallocate(colvar%combine_cvs_param%c_parameters, 1, isize +
SIZE(my_par))
637 colvar%combine_cvs_param%c_parameters(isize + 1:isize +
SIZE(my_par)) = my_par
639 ALLOCATE (colvar%combine_cvs_param%v_parameters(0))
642 isize =
SIZE(colvar%combine_cvs_param%v_parameters)
644 CALL reallocate(colvar%combine_cvs_param%v_parameters, 1, isize +
SIZE(my_vals))
645 colvar%combine_cvs_param%v_parameters(isize + 1:isize +
SIZE(my_vals)) = my_vals
650 ELSE IF (my_subsection(12))
THEN
652 wrk_section => population_section
654 CALL colvar_check_points(colvar, population_section, cell)
656 NULLIFY (colvar%population_param%i_at_from, colvar%population_param%c_kinds_from)
657 NULLIFY (colvar%population_param%i_at_to, colvar%population_param%c_kinds_to)
666 CALL reallocate(colvar%population_param%i_at_from, 1, ndim +
SIZE(iatms))
667 colvar%population_param%i_at_from(ndim + 1:ndim +
SIZE(iatms)) = iatms
668 ndim = ndim +
SIZE(iatms)
670 colvar%population_param%n_atoms_from = ndim
671 colvar%population_param%use_kinds_from = .false.
678 CALL reallocate(colvar%population_param%c_kinds_from, 1, ndim +
SIZE(c_kinds))
679 colvar%population_param%c_kinds_from(ndim + 1:ndim +
SIZE(c_kinds)) = c_kinds
680 ndim = ndim +
SIZE(c_kinds)
682 colvar%population_param%n_atoms_from = 0
683 colvar%population_param%use_kinds_from = .true.
686 CALL uppercase(colvar%population_param%c_kinds_from(k))
696 CALL reallocate(colvar%population_param%i_at_to, 1, ndim +
SIZE(iatms))
697 colvar%population_param%i_at_to(ndim + 1:ndim +
SIZE(iatms)) = iatms
698 ndim = ndim +
SIZE(iatms)
700 colvar%population_param%n_atoms_to = ndim
701 colvar%population_param%use_kinds_to = .false.
708 CALL reallocate(colvar%population_param%c_kinds_to, 1, ndim +
SIZE(c_kinds))
709 colvar%population_param%c_kinds_to(ndim + 1:ndim +
SIZE(c_kinds)) = c_kinds
710 ndim = ndim +
SIZE(c_kinds)
712 colvar%population_param%n_atoms_to = 0
713 colvar%population_param%use_kinds_to = .true.
716 CALL uppercase(colvar%population_param%c_kinds_to(k))
725 ELSE IF (my_subsection(13))
THEN
727 wrk_section => plane_plane_angle_section
729 CALL colvar_check_points(colvar, plane_plane_angle_section, cell)
734 cpabort(
"PLANE_PLANE_ANGLE Colvar section: Two PLANE sections must be provided!")
738 i_val=colvar%plane_plane_angle_param%plane1%type_of_def)
739 IF (colvar%plane_plane_angle_param%plane1%type_of_def ==
plane_def_vec)
THEN
742 colvar%plane_plane_angle_param%plane1%normal_vec = s1
743 IF (
PRESENT(cell))
THEN
744 IF (
ASSOCIATED(cell))
THEN
751 colvar%plane_plane_angle_param%plane1%points = iatms
756 i_val=colvar%plane_plane_angle_param%plane2%type_of_def)
757 IF (colvar%plane_plane_angle_param%plane2%type_of_def ==
plane_def_vec)
THEN
760 colvar%plane_plane_angle_param%plane2%normal_vec = s1
761 IF (
PRESENT(cell))
THEN
762 IF (
ASSOCIATED(cell))
THEN
769 colvar%plane_plane_angle_param%plane2%points = iatms
771 ELSE IF (my_subsection(14))
THEN
773 wrk_section => gyration_section
775 CALL colvar_check_points(colvar, gyration_section, cell)
777 NULLIFY (colvar%gyration_param%i_at, colvar%gyration_param%c_kinds)
786 CALL reallocate(colvar%gyration_param%i_at, 1, ndim +
SIZE(iatms))
787 colvar%gyration_param%i_at(ndim + 1:ndim +
SIZE(iatms)) = iatms
788 ndim = ndim +
SIZE(iatms)
790 colvar%gyration_param%n_atoms = ndim
791 colvar%gyration_param%use_kinds = .false.
798 CALL reallocate(colvar%gyration_param%c_kinds, 1, ndim +
SIZE(c_kinds))
799 colvar%gyration_param%c_kinds(ndim + 1:ndim +
SIZE(c_kinds)) = c_kinds
800 ndim = ndim +
SIZE(c_kinds)
802 colvar%gyration_param%n_atoms = 0
803 colvar%gyration_param%use_kinds = .true.
806 CALL uppercase(colvar%gyration_param%c_kinds(k))
809 ELSE IF (my_subsection(15))
THEN
811 wrk_section => rmsd_section
814 NULLIFY (colvar%rmsd_param%i_rmsd, colvar%rmsd_param%r_ref, colvar%rmsd_param%weights)
819 colvar%rmsd_param%nr_frames = nr_frame
821 cpassert(nr_frame >= 1 .AND. nr_frame <= 2)
822 CALL read_frames(frame_section, para_env, nr_frame, colvar%rmsd_param%r_ref, &
823 colvar%rmsd_param%n_atoms)
824 ALLOCATE (colvar%rmsd_param%weights(colvar%rmsd_param%n_atoms))
825 colvar%rmsd_param%weights = 0.0_dp
827 IF (colvar%rmsd_param%subset ==
rmsd_all)
THEN
828 ALLOCATE (colvar%rmsd_param%i_rmsd(colvar%rmsd_param%n_atoms))
829 DO i = 1, colvar%rmsd_param%n_atoms
830 colvar%rmsd_param%i_rmsd(i) = i
832 ELSE IF (colvar%rmsd_param%subset ==
rmsd_list)
THEN
840 CALL reallocate(colvar%rmsd_param%i_rmsd, 1, ndim +
SIZE(iatms))
841 colvar%rmsd_param%i_rmsd(ndim + 1:ndim +
SIZE(iatms)) = iatms
842 ndim = ndim +
SIZE(iatms)
844 colvar%rmsd_param%n_atoms = ndim
846 cpabort(
"CV RMSD: if SUBSET_TYPE=LIST a list of atoms needs to be provided ")
855 CALL reallocate(colvar%rmsd_param%i_rmsd, 1, ndim +
SIZE(iatms))
856 colvar%rmsd_param%i_rmsd(ndim + 1:ndim +
SIZE(iatms)) = iatms
857 ndim = ndim +
SIZE(iatms)
859 colvar%rmsd_param%n_atoms = ndim
861 cpabort(
"CV RMSD: if SUBSET_TYPE=WEIGHT_LIST a list of atoms needs to be provided ")
870 weights(ndim + 1:ndim +
SIZE(wei)) = wei
871 ndim = ndim +
SIZE(wei)
873 IF (ndim /= colvar%rmsd_param%n_atoms)
THEN
874 CALL cp_abort(__location__,
"CV RMSD: list of atoms and list of "// &
875 "weights need to contain same number of entries. ")
878 ii = colvar%rmsd_param%i_rmsd(i)
879 colvar%rmsd_param%weights(ii) = weights(i)
883 cpabort(
"CV RMSD: if SUBSET_TYPE=WEIGHT_LIST a list of weights need to be provided. ")
887 cpabort(
"CV RMSD: unknown SUBSET_TYPE.")
892 ELSE IF (my_subsection(17))
THEN
894 wrk_section => xyz_diag_section
896 CALL colvar_check_points(colvar, wrk_section, cell)
900 CALL section_vals_val_get(wrk_section,
"ABSOLUTE_POSITION", l_val=colvar%xyz_diag_param%use_absolute_position)
901 colvar%xyz_diag_param%i_atom = iatm
902 colvar%xyz_diag_param%component = icomponent
903 ELSE IF (my_subsection(18))
THEN
905 wrk_section => xyz_outerdiag_section
907 CALL colvar_check_points(colvar, wrk_section, cell)
909 colvar%xyz_outerdiag_param%i_atoms = iatms
911 colvar%xyz_outerdiag_param%components(1) = icomponent
913 colvar%xyz_outerdiag_param%components(2) = icomponent
915 ELSE IF (my_subsection(19))
THEN
917 wrk_section => u_section
920 CALL section_vals_get(colvar%u_param%mixed_energy_section, explicit=use_mixed_energy)
921 IF (.NOT. use_mixed_energy)
NULLIFY (colvar%u_param%mixed_energy_section)
922 ELSE IF (my_subsection(20))
THEN
924 wrk_section => wc_section
926 CALL colvar_check_points(colvar, wc_section, cell)
930 colvar%Wc%ids = iatms
931 ELSE IF (my_subsection(21))
THEN
933 wrk_section => hbp_section
935 CALL colvar_check_points(colvar, hbp_section, cell)
941 ALLOCATE (colvar%HBP%ids(colvar%HBP%nPoints, 3))
942 ALLOCATE (colvar%HBP%ewc(colvar%HBP%nPoints))
943 DO i = 1, colvar%HBP%nPoints
945 colvar%HBP%ids(i, :) = iatms
947 ELSE IF (my_subsection(22))
THEN
951 colvar%ring_puckering_param%nring =
SIZE(iatms)
952 ALLOCATE (colvar%ring_puckering_param%atoms(
SIZE(iatms)))
953 colvar%ring_puckering_param%atoms = iatms
955 i_val=colvar%ring_puckering_param%iq)
957 ndim = colvar%ring_puckering_param%nring
959 cpabort(
"CV Ring Puckering: Ring size has to be 4 or larger. ")
961 ii = colvar%ring_puckering_param%iq
962 IF (abs(ii) == 1 .OR. ii < -(ndim - 1)/2 .OR. ii > ndim/2)
THEN
963 cpabort(
"CV Ring Puckering: Invalid coordinate number.")
965 ELSE IF (my_subsection(23))
THEN
967 wrk_section => mindist_section
969 CALL colvar_check_points(colvar, mindist_section, cell)
970 NULLIFY (colvar%mindist_param%i_dist_from, colvar%mindist_param%i_coord_from, &
971 colvar%mindist_param%k_coord_from, colvar%mindist_param%i_coord_to, &
972 colvar%mindist_param%k_coord_to)
974 colvar%mindist_param%n_dist_from =
SIZE(iatms)
975 ALLOCATE (colvar%mindist_param%i_dist_from(
SIZE(iatms)))
976 colvar%mindist_param%i_dist_from = iatms
983 CALL reallocate(colvar%mindist_param%i_coord_from, 1, ndim +
SIZE(iatms))
984 colvar%mindist_param%i_coord_from(ndim + 1:ndim +
SIZE(iatms)) = iatms
985 ndim = ndim +
SIZE(iatms)
987 colvar%mindist_param%n_coord_from = ndim
988 colvar%mindist_param%use_kinds_from = .false.
995 CALL reallocate(colvar%mindist_param%k_coord_from, 1, ndim +
SIZE(c_kinds))
996 colvar%mindist_param%k_coord_from(ndim + 1:ndim +
SIZE(c_kinds)) = c_kinds
997 ndim = ndim +
SIZE(c_kinds)
999 colvar%mindist_param%n_coord_from = 0
1000 colvar%mindist_param%use_kinds_from = .true.
1003 CALL uppercase(colvar%mindist_param%k_coord_from(k))
1009 IF (n_var /= 0)
THEN
1013 CALL reallocate(colvar%mindist_param%i_coord_to, 1, ndim +
SIZE(iatms))
1014 colvar%mindist_param%i_coord_to(ndim + 1:ndim +
SIZE(iatms)) = iatms
1015 ndim = ndim +
SIZE(iatms)
1017 colvar%mindist_param%n_coord_to = ndim
1018 colvar%mindist_param%use_kinds_to = .false.
1025 CALL reallocate(colvar%mindist_param%k_coord_to, 1, ndim +
SIZE(c_kinds))
1026 colvar%mindist_param%k_coord_to(ndim + 1:ndim +
SIZE(c_kinds)) = c_kinds
1027 ndim = ndim +
SIZE(c_kinds)
1029 colvar%mindist_param%n_coord_to = 0
1030 colvar%mindist_param%use_kinds_to = .true.
1033 CALL uppercase(colvar%mindist_param%k_coord_to(k))
1042 ELSE IF (my_subsection(24))
THEN
1045 NULLIFY (colvar%acid_hyd_dist_param%i_oxygens_water)
1046 NULLIFY (colvar%acid_hyd_dist_param%i_oxygens_acid)
1047 NULLIFY (colvar%acid_hyd_dist_param%i_hydrogens)
1049 colvar%acid_hyd_dist_param%n_oxygens_water, &
1050 colvar%acid_hyd_dist_param%n_oxygens_acid, &
1051 colvar%acid_hyd_dist_param%n_hydrogens, &
1052 colvar%acid_hyd_dist_param%i_oxygens_water, &
1053 colvar%acid_hyd_dist_param%i_oxygens_acid, &
1054 colvar%acid_hyd_dist_param%i_hydrogens)
1055 ELSE IF (my_subsection(25))
THEN
1058 NULLIFY (colvar%acid_hyd_shell_param%i_oxygens_water)
1059 NULLIFY (colvar%acid_hyd_shell_param%i_oxygens_acid)
1060 NULLIFY (colvar%acid_hyd_shell_param%i_hydrogens)
1062 colvar%acid_hyd_shell_param%n_oxygens_water, &
1063 colvar%acid_hyd_shell_param%n_oxygens_acid, &
1064 colvar%acid_hyd_shell_param%n_hydrogens, &
1065 colvar%acid_hyd_shell_param%i_oxygens_water, &
1066 colvar%acid_hyd_shell_param%i_oxygens_acid, &
1067 colvar%acid_hyd_shell_param%i_hydrogens)
1068 ELSE IF (my_subsection(26))
THEN
1071 NULLIFY (colvar%hydronium_dist_param%i_oxygens)
1072 NULLIFY (colvar%hydronium_dist_param%i_hydrogens)
1074 colvar%hydronium_dist_param%n_oxygens, &
1075 colvar%hydronium_dist_param%n_hydrogens, &
1076 colvar%hydronium_dist_param%i_oxygens, &
1077 colvar%hydronium_dist_param%i_hydrogens)
1078 ELSE IF (my_subsection(27))
THEN
1080 cpassert(
ASSOCIATED(voronoiipz_section))
1081 CALL read_voronoiipz_colvars(voronoiipz_section, colvar)
1086 "PRINT%PROGRAM_RUN_INFO", extension=
".colvarLog")
1089 IF (colvar%use_points) tag =
"POINTS:"
1092 WRITE (iw,
'( A )')
' '// &
1093 '----------------------------------------------------------------------'
1094 WRITE (iw,
'( A,I8)')
' COLVARS| COLVAR INPUT INDEX: ', icol
1097 SELECT CASE (colvar%type_id)
1099 WRITE (iw,
'( A,T57,3I8)')
' COLVARS| ANGLE >>> '//tag, &
1100 colvar%angle_param%i_at_angle
1102 WRITE (iw,
'( A,T49,4I8)')
' COLVARS| DISTANCE DIFFERENCE >>> '//tag, &
1103 colvar%dfunct_param%i_at_dfunct
1105 WRITE (iw,
'( A,T57,3I8)')
' COLVARS| PLANE DISTANCE - PLANE >>> '//tag, &
1106 colvar%plane_distance_param%plane
1107 WRITE (iw,
'( A,T73,1I8)')
' COLVARS| PLANE DISTANCE - POINT >>> '//tag, &
1108 colvar%plane_distance_param%point
1110 IF (colvar%plane_plane_angle_param%plane1%type_of_def ==
plane_def_atoms)
THEN
1111 WRITE (iw,
'( A,T57,3I8)')
' COLVARS| PLANE-PLANE ANGLE - PLANE 1 (ATOMS) >>> '//tag, &
1112 colvar%plane_plane_angle_param%plane1%points
1114 WRITE (iw,
'( A,T57,3F8.3)')
' COLVARS| PLANE-PLANE ANGLE - PLANE 1 (VECTOR) >>> '//tag, &
1115 colvar%plane_plane_angle_param%plane1%normal_vec
1118 IF (colvar%plane_plane_angle_param%plane2%type_of_def ==
plane_def_atoms)
THEN
1119 WRITE (iw,
'( A,T57,3I8)')
' COLVARS| PLANE-PLANE ANGLE - PLANE 1 (ATOMS) >>> '//tag, &
1120 colvar%plane_plane_angle_param%plane2%points
1122 WRITE (iw,
'( A,T57,3F8.3)')
' COLVARS| PLANE-PLANE ANGLE - PLANE 1 (VECTOR) >>> '//tag, &
1123 colvar%plane_plane_angle_param%plane2%normal_vec
1126 WRITE (iw,
'( A,T49,4I8)')
' COLVARS| TORSION >>> '//tag, &
1127 colvar%torsion_param%i_at_tors
1129 WRITE (iw,
'( A,T65,2I8)')
' COLVARS| BOND >>> '//tag, &
1130 colvar%dist_param%i_at, colvar%dist_param%j_at
1132 IF (colvar%coord_param%do_chain)
THEN
1133 WRITE (iw,
'( A)')
' COLVARS| COORDINATION CHAIN FC(from->to)*FC(to->to_B)>> '
1135 IF (colvar%coord_param%use_kinds_from)
THEN
1136 WRITE (iw,
'( A,T71,A10)') (
' COLVARS| COORDINATION >>> FROM KINDS', &
1137 adjustr(colvar%coord_param%c_kinds_from(kk) (1:10)), &
1138 kk=1,
SIZE(colvar%coord_param%c_kinds_from))
1140 WRITE (iw,
'( A,T71,I10)') (
' COLVARS| COORDINATION >>> FROM '//tag, &
1141 colvar%coord_param%i_at_from(kk), &
1142 kk=1,
SIZE(colvar%coord_param%i_at_from))
1144 IF (colvar%coord_param%use_kinds_to)
THEN
1145 WRITE (iw,
'( A,T71,A10)') (
' COLVARS| COORDINATION >>> TO KINDS', &
1146 adjustr(colvar%coord_param%c_kinds_to(kk) (1:10)), &
1147 kk=1,
SIZE(colvar%coord_param%c_kinds_to))
1149 WRITE (iw,
'( A,T71,I10)') (
' COLVARS| COORDINATION >>> TO '//tag, &
1150 colvar%coord_param%i_at_to(kk), &
1151 kk=1,
SIZE(colvar%coord_param%i_at_to))
1153 WRITE (iw,
'( A,T71,F10.5)')
' COLVARS| R0', colvar%coord_param%r_0
1154 WRITE (iw,
'( A,T71,I10)')
' COLVARS| NN', colvar%coord_param%nncrd
1155 WRITE (iw,
'( A,T71,I10)')
' COLVARS| ND', colvar%coord_param%ndcrd
1156 IF (colvar%coord_param%do_chain)
THEN
1157 IF (colvar%coord_param%use_kinds_to_b)
THEN
1158 WRITE (iw,
'( A,T71,A10)') (
' COLVARS| COORDINATION >>> TO KINDS B', &
1159 adjustr(colvar%coord_param%c_kinds_to_b(kk) (1:10)), &
1160 kk=1,
SIZE(colvar%coord_param%c_kinds_to_b))
1162 WRITE (iw,
'( A,T71,I10)') (
' COLVARS| COORDINATION >>> TO '//tag//
' B', &
1163 colvar%coord_param%i_at_to_b(kk), &
1164 kk=1,
SIZE(colvar%coord_param%i_at_to_b))
1166 WRITE (iw,
'( A,T71,F10.5)')
' COLVARS| R0 B', colvar%coord_param%r_0_b
1167 WRITE (iw,
'( A,T71,I10)')
' COLVARS| NN B', colvar%coord_param%nncrd_b
1168 WRITE (iw,
'( A,T71,I10)')
' COLVARS| ND B', colvar%coord_param%ndcrd_b
1171 IF (colvar%population_param%use_kinds_from)
THEN
1172 WRITE (iw,
'( A,T71,A10)') (
' COLVARS| POPULATION based on coordination >>> FROM KINDS', &
1173 adjustr(colvar%population_param%c_kinds_from(kk) (1:10)), &
1174 kk=1,
SIZE(colvar%population_param%c_kinds_from))
1176 WRITE (iw,
'( A,T71,I10)') (
' COLVARS| POPULATION based on coordination >>> FROM '//tag, &
1177 colvar%population_param%i_at_from(kk), &
1178 kk=1,
SIZE(colvar%population_param%i_at_from))
1180 IF (colvar%population_param%use_kinds_to)
THEN
1181 WRITE (iw,
'( A,T71,A10)') (
' COLVARS| POPULATION based on coordination >>> TO KINDS', &
1182 adjustr(colvar%population_param%c_kinds_to(kk) (1:10)), &
1183 kk=1,
SIZE(colvar%population_param%c_kinds_to))
1185 WRITE (iw,
'( A,T71,I10)') (
' COLVARS| POPULATION based on coordination >>> TO '//tag, &
1186 colvar%population_param%i_at_to(kk), &
1187 kk=1,
SIZE(colvar%population_param%i_at_to))
1189 WRITE (iw,
'( A,T71,F10.5)')
' COLVARS| R0', colvar%population_param%r_0
1190 WRITE (iw,
'( A,T71,I10)')
' COLVARS| NN', colvar%population_param%nncrd
1191 WRITE (iw,
'( A,T71,I10)')
' COLVARS| ND', colvar%population_param%ndcrd
1192 WRITE (iw,
'( A,T71,I10)')
' COLVARS| N0', colvar%population_param%n0
1193 WRITE (iw,
'( A,T71,F10.5)')
' COLVARS| SIGMA', colvar%population_param%sigma
1195 IF (colvar%gyration_param%use_kinds)
THEN
1196 WRITE (iw,
'( A,T71,A10)') (
' COLVARS| Gyration Radius >>> KINDS', &
1197 adjustr(colvar%gyration_param%c_kinds(kk) (1:10)), &
1198 kk=1,
SIZE(colvar%gyration_param%c_kinds))
1200 WRITE (iw,
'( A,T71,I10)') (
' COLVARS| Gyration Radius >>> ATOMS '//tag, &
1201 colvar%gyration_param%i_at(kk), &
1202 kk=1,
SIZE(colvar%gyration_param%i_at))
1205 WRITE (iw,
'( A,T71,I10)')
' COLVARS| BOND_ROTATION - POINT 1 LINE 1 >>> '//tag, &
1206 colvar%rotation_param%i_at1_bond1
1207 WRITE (iw,
'( A,T71,I10)')
' COLVARS| BOND_ROTATION - POINT 2 LINE 1 >>> '//tag, &
1208 colvar%rotation_param%i_at2_bond1
1209 WRITE (iw,
'( A,T71,I10)')
' COLVARS| BOND_ROTATION - POINT 1 LINE 2 >>> '//tag, &
1210 colvar%rotation_param%i_at1_bond2
1211 WRITE (iw,
'( A,T71,I10)')
' COLVARS| BOND_ROTATION - POINT 2 LINE 2 >>> '//tag, &
1212 colvar%rotation_param%i_at2_bond2
1214 WRITE (iw,
'( A,T71,I10)') (
' COLVARS| Q-PARM >>> FROM '//tag, &
1215 colvar%qparm_param%i_at_from(kk), &
1216 kk=1,
SIZE(colvar%qparm_param%i_at_from))
1217 WRITE (iw,
'( A,T71,I10)') (
' COLVARS| Q-PARM >>> TO '//tag, &
1218 colvar%qparm_param%i_at_to(kk), &
1219 kk=1,
SIZE(colvar%qparm_param%i_at_to))
1220 WRITE (iw,
'( A,T71,F10.5)')
' COLVARS| RCUT', colvar%qparm_param%rcut
1221 WRITE (iw,
'( A,T71,F10.5)')
' COLVARS| RSTART', colvar%qparm_param%rstart
1222 WRITE (iw,
'( A,T71,L10)')
' COLVARS| INCLUDE IMAGES', colvar%qparm_param%include_images
1224 WRITE (iw,
'( A,T71,I10)')
' COLVARS| L', colvar%qparm_param%l
1226 WRITE (iw,
'( A)')
' COLVARS| COMBINING FUNCTION : '// &
1227 trim(colvar%combine_cvs_param%function)
1228 WRITE (iw,
'( A)', advance=
"NO")
' COLVARS| VARIABLES : '
1229 DO i = 1,
SIZE(colvar%combine_cvs_param%variables)
1230 WRITE (iw,
'( A)', advance=
"NO") &
1231 trim(colvar%combine_cvs_param%variables(i))//
" "
1234 WRITE (iw,
'( A)')
' COLVARS| DEFINED PARAMETERS [label] [value]:'
1235 DO i = 1,
SIZE(colvar%combine_cvs_param%c_parameters)
1236 WRITE (iw,
'( A,A7,F9.3)')
' ', &
1237 trim(colvar%combine_cvs_param%c_parameters(i)), colvar%combine_cvs_param%v_parameters(i)
1239 WRITE (iw,
'( A,T71,G10.5)')
' COLVARS| ERROR ON DERIVATIVE EVALUATION', &
1240 colvar%combine_cvs_param%lerr
1241 WRITE (iw,
'( A,T71,G10.5)')
' COLVARS| DX', &
1242 colvar%combine_cvs_param%dx
1244 cpwarn(
"Description header for REACTION_PATH COLVAR missing!")
1246 cpwarn(
"Description header for REACTION_PATH COLVAR missing!")
1248 WRITE (iw,
'( A,T71,I10)')
' COLVARS| POH', colvar%hydronium_shell_param%poh
1249 WRITE (iw,
'( A,T71,I10)')
' COLVARS| QOH', colvar%hydronium_shell_param%qoh
1250 WRITE (iw,
'( A,T71,I10)')
' COLVARS| POO', colvar%hydronium_shell_param%poo
1251 WRITE (iw,
'( A,T71,I10)')
' COLVARS| QOO', colvar%hydronium_shell_param%qoo
1252 WRITE (iw,
'( A,T71,F10.5)')
' COLVARS| ROO', colvar%hydronium_shell_param%roo
1253 WRITE (iw,
'( A,T71,F10.5)')
' COLVARS| ROH', colvar%hydronium_shell_param%roh
1254 WRITE (iw,
'( A,T71,F10.5)')
' COLVARS| NH', colvar%hydronium_shell_param%nh
1255 WRITE (iw,
'( A,T71,F10.5)')
' COLVARS| LAMBDA', colvar%hydronium_shell_param%lambda
1257 WRITE (iw,
'( A,T71,I10)')
' COLVARS| POH', colvar%hydronium_dist_param%poh
1258 WRITE (iw,
'( A,T71,I10)')
' COLVARS| QOH', colvar%hydronium_dist_param%qoh
1259 WRITE (iw,
'( A,T71,F10.5)')
' COLVARS| ROH', colvar%hydronium_dist_param%roh
1260 WRITE (iw,
'( A,T71,I10)')
' COLVARS| PM', colvar%hydronium_dist_param%pm
1261 WRITE (iw,
'( A,T71,I10)')
' COLVARS| QM', colvar%hydronium_dist_param%qm
1262 WRITE (iw,
'( A,T71,F10.5)')
' COLVARS| NH', colvar%hydronium_dist_param%nh
1263 WRITE (iw,
'( A,T71,I10)')
' COLVARS| PF', colvar%hydronium_dist_param%pf
1264 WRITE (iw,
'( A,T71,I10)')
' COLVARS| QF', colvar%hydronium_dist_param%qf
1265 WRITE (iw,
'( A,T71,F10.5)')
' COLVARS| NN', colvar%hydronium_dist_param%nn
1267 WRITE (iw,
'( A,T71,I10)')
' COLVARS| PAOH', colvar%acid_hyd_dist_param%paoh
1268 WRITE (iw,
'( A,T71,I10)')
' COLVARS| QAOH', colvar%acid_hyd_dist_param%qaoh
1269 WRITE (iw,
'( A,T71,I10)')
' COLVARS| PWOH', colvar%acid_hyd_dist_param%pwoh
1270 WRITE (iw,
'( A,T71,I10)')
' COLVARS| QWOH', colvar%acid_hyd_dist_param%qwoh
1271 WRITE (iw,
'( A,T71,I10)')
' COLVARS| PCUT', colvar%acid_hyd_dist_param%pcut
1272 WRITE (iw,
'( A,T71,I10)')
' COLVARS| QCUT', colvar%acid_hyd_dist_param%qcut
1273 WRITE (iw,
'( A,T71,F10.5)')
' COLVARS| RAOH', colvar%acid_hyd_dist_param%raoh
1274 WRITE (iw,
'( A,T71,F10.5)')
' COLVARS| RWOH', colvar%acid_hyd_dist_param%rwoh
1275 WRITE (iw,
'( A,T71,F10.5)')
' COLVARS| NC', colvar%acid_hyd_dist_param%nc
1276 WRITE (iw,
'( A,T71,F10.5)')
' COLVARS| LAMBDA', colvar%acid_hyd_dist_param%lambda
1278 WRITE (iw,
'( A,T71,I10)')
' COLVARS| PAOH', colvar%acid_hyd_shell_param%paoh
1279 WRITE (iw,
'( A,T71,I10)')
' COLVARS| QAOH', colvar%acid_hyd_shell_param%qaoh
1280 WRITE (iw,
'( A,T71,I10)')
' COLVARS| PWOH', colvar%acid_hyd_shell_param%pwoh
1281 WRITE (iw,
'( A,T71,I10)')
' COLVARS| QWOH', colvar%acid_hyd_shell_param%qwoh
1282 WRITE (iw,
'( A,T71,I10)')
' COLVARS| POO', colvar%acid_hyd_shell_param%poo
1283 WRITE (iw,
'( A,T71,I10)')
' COLVARS| QOO', colvar%acid_hyd_shell_param%qoo
1284 WRITE (iw,
'( A,T71,I10)')
' COLVARS| PM', colvar%acid_hyd_shell_param%pm
1285 WRITE (iw,
'( A,T71,I10)')
' COLVARS| QM', colvar%acid_hyd_shell_param%qm
1286 WRITE (iw,
'( A,T71,I10)')
' COLVARS| PCUT', colvar%acid_hyd_shell_param%pcut
1287 WRITE (iw,
'( A,T71,I10)')
' COLVARS| QCUT', colvar%acid_hyd_shell_param%qcut
1288 WRITE (iw,
'( A,T71,F10.5)')
' COLVARS| RAOH', colvar%acid_hyd_shell_param%raoh
1289 WRITE (iw,
'( A,T71,F10.5)')
' COLVARS| RWOH', colvar%acid_hyd_shell_param%rwoh
1290 WRITE (iw,
'( A,T71,F10.5)')
' COLVARS| ROO', colvar%acid_hyd_shell_param%roo
1291 WRITE (iw,
'( A,T71,F10.5)')
' COLVARS| NH', colvar%acid_hyd_shell_param%nh
1292 WRITE (iw,
'( A,T71,F10.5)')
' COLVARS| NC', colvar%acid_hyd_shell_param%nc
1293 WRITE (iw,
'( A,T71,F10.5)')
' COLVARS| LAMBDA', colvar%acid_hyd_shell_param%lambda
1295 cpwarn(
"Description header for RMSD COLVAR missing!")
1297 NULLIFY (section, keyword, enum)
1301 tag_comp = trim(
enum_i2c(enum, colvar%xyz_diag_param%component))
1304 WRITE (iw,
'( A,T57,3I8)')
' COLVARS| POSITION ('//trim(tag_comp) &
1305 //
') >>> '//tag, colvar%xyz_diag_param%i_atom
1307 NULLIFY (section, keyword, enum)
1311 tag_comp1 = trim(
enum_i2c(enum, colvar%xyz_outerdiag_param%components(1)))
1314 tag_comp2 = trim(
enum_i2c(enum, colvar%xyz_outerdiag_param%components(2)))
1317 WRITE (iw,
'( A,T57,3I8)')
' COLVARS| CROSS TERM POSITION ('//trim(tag_comp1) &
1318 //
" * "//trim(tag_comp2)//
') >>> '//tag, colvar%xyz_outerdiag_param%i_atoms
1320 WRITE (iw,
'( A,T77,A4)')
' COLVARS| ENERGY >>> '//tag,
'all!'
1322 WRITE (iw,
'( A,T57,F16.8)')
' COLVARS| Wc >>> RCUT: ', &
1324 WRITE (iw,
'( A,T57,3I8)')
' COLVARS| Wc >>> '//tag, &
1327 WRITE (iw,
'( A,T57,I8)')
' COLVARS| HBP >>> NPOINTS', &
1329 WRITE (iw,
'( A,T57,F16.8)')
' COLVARS| HBP >>> RCUT', &
1331 WRITE (iw,
'( A,T57,F16.8)')
' COLVARS| HBP >>> RCUT', &
1333 DO i = 1, colvar%HBP%nPoints
1334 WRITE (iw,
'( A,T57,3I8)')
' COLVARS| HBP >>> '//tag, &
1335 colvar%HBP%ids(i, :)
1338 WRITE (iw,
'( A,T57,I8)')
' COLVARS| Ring Puckering >>> ring size', &
1339 colvar%ring_puckering_param%nring
1340 IF (colvar%ring_puckering_param%iq == 0)
THEN
1341 WRITE (iw,
'( A,T40,A)')
' COLVARS| Ring Puckering >>> coordinate', &
1342 ' Total Puckering Amplitude'
1343 ELSE IF (colvar%ring_puckering_param%iq > 0)
THEN
1344 WRITE (iw,
'( A,T35,A,T57,I8)')
' COLVARS| Ring Puckering >>> coordinate', &
1345 ' Puckering Amplitude', &
1346 colvar%ring_puckering_param%iq
1348 WRITE (iw,
'( A,T35,A,T57,I8)')
' COLVARS| Ring Puckering >>> coordinate', &
1349 ' Puckering Angle', &
1350 colvar%ring_puckering_param%iq
1353 WRITE (iw,
'( A)')
' COLVARS| CONDITIONED DISTANCE>> '
1354 WRITE (iw,
'( A,T71,I10)') (
' COLVARS| COND.DISTANCE >>> DISTANCE FROM '//tag, &
1355 colvar%mindist_param%i_dist_from(kk), &
1356 kk=1,
SIZE(colvar%mindist_param%i_dist_from))
1357 IF (colvar%mindist_param%use_kinds_from)
THEN
1358 WRITE (iw,
'( A,T71,A10)') (
' COLVARS| COND.DIST. >>> COORDINATION FROM KINDS ', &
1359 adjustr(colvar%mindist_param%k_coord_from(kk) (1:10)), &
1360 kk=1,
SIZE(colvar%mindist_param%k_coord_from))
1362 WRITE (iw,
'( A,T71,I10)') (
' COLVARS| COND.DIST. >>> COORDINATION FROM '//tag, &
1363 colvar%mindist_param%i_coord_from(kk), &
1364 kk=1,
SIZE(colvar%mindist_param%i_coord_from))
1366 IF (colvar%mindist_param%use_kinds_to)
THEN
1367 WRITE (iw,
'( A,T71,A10)') (
' COLVARS| COND.DIST. >>> COORDINATION TO KINDS ', &
1368 adjustr(colvar%mindist_param%k_coord_to(kk) (1:10)), &
1369 kk=1,
SIZE(colvar%mindist_param%k_coord_to))
1371 WRITE (iw,
'( A,T71,I10)') (
' COLVARS| COND.DIST. >>> COORDINATION TO '//tag, &
1372 colvar%mindist_param%i_coord_to(kk), &
1373 kk=1,
SIZE(colvar%mindist_param%i_coord_to))
1375 WRITE (iw,
'( A,T71,F10.5)')
' COLVARS| R0', colvar%mindist_param%r_cut
1376 WRITE (iw,
'( A,T71,I10)')
' COLVARS| NN', colvar%mindist_param%p_exp
1377 WRITE (iw,
'( A,T71,I10)')
' COLVARS| ND', colvar%mindist_param%q_exp
1378 WRITE (iw,
'( A,T71,F10.5)')
' COLVARS| LAMBDA', colvar%mindist_param%lambda
1381 IF (colvar%use_points)
THEN
1382 WRITE (iw,
'( A)')
' COLVARS| INFORMATION ON DEFINED GEOMETRICAL POINTS'
1383 DO kk = 1,
SIZE(colvar%points)
1387 WRITE (iw,
'( A)')
' COLVARS| POINT Nr.'//trim(tmpstr2)//
' OF TYPE: '//trim(tmpstr)
1388 IF (
ASSOCIATED(colvar%points(kk)%atoms))
THEN
1389 WRITE (iw,
'( A)')
' COLVARS| ATOMS BUILDING THE GEOMETRICAL POINT'
1390 WRITE (iw,
'( A, I10)') (
' COLVARS| ATOM:', colvar%points(kk)%atoms(k), k=1,
SIZE(colvar%points(kk)%atoms))
1392 WRITE (iw,
'( A,4X,3F12.6)')
' COLVARS| XYZ POSITION OF FIXED POINT:', colvar%points(kk)%r
1398 WRITE (iw,
'( A )')
' '// &
1399 '----------------------------------------------------------------------'
1401 WRITE (iw,
'( A )')
' '// &
1402 '**********************************************************************'
1406 "PRINT%PROGRAM_RUN_INFO")
1407 CALL timestop(handle)
1421 SUBROUTINE read_hydronium_colvars(section, colvar, colvar_id, n_oxygens, n_hydrogens, &
1422 i_oxygens, i_hydrogens)
1425 INTEGER,
INTENT(IN) :: colvar_id
1426 INTEGER,
INTENT(OUT) :: n_oxygens, n_hydrogens
1427 INTEGER,
DIMENSION(:),
POINTER :: i_oxygens, i_hydrogens
1429 INTEGER :: k, n_var, ndim
1430 INTEGER,
DIMENSION(:),
POINTER :: iatms
1438 CALL reallocate(i_oxygens, 1, ndim +
SIZE(iatms))
1439 i_oxygens(ndim + 1:ndim +
SIZE(iatms)) = iatms
1440 ndim = ndim +
SIZE(iatms)
1448 CALL reallocate(i_hydrogens, 1, ndim +
SIZE(iatms))
1449 i_hydrogens(ndim + 1:ndim +
SIZE(iatms)) = iatms
1450 ndim = ndim +
SIZE(iatms)
1454 SELECT CASE (colvar_id)
1479 END SUBROUTINE read_hydronium_colvars
1495 SUBROUTINE read_acid_hydronium_colvars(section, colvar, colvar_id, n_oxygens_water, &
1496 n_oxygens_acid, n_hydrogens, i_oxygens_water, &
1497 i_oxygens_acid, i_hydrogens)
1500 INTEGER,
INTENT(IN) :: colvar_id
1501 INTEGER,
INTENT(OUT) :: n_oxygens_water, n_oxygens_acid, &
1503 INTEGER,
DIMENSION(:),
POINTER :: i_oxygens_water, i_oxygens_acid, &
1506 INTEGER :: k, n_var, ndim
1507 INTEGER,
DIMENSION(:),
POINTER :: iatms
1515 CALL reallocate(i_oxygens_water, 1, ndim +
SIZE(iatms))
1516 i_oxygens_water(ndim + 1:ndim +
SIZE(iatms)) = iatms
1517 ndim = ndim +
SIZE(iatms)
1519 n_oxygens_water = ndim
1525 CALL reallocate(i_oxygens_acid, 1, ndim +
SIZE(iatms))
1526 i_oxygens_acid(ndim + 1:ndim +
SIZE(iatms)) = iatms
1527 ndim = ndim +
SIZE(iatms)
1529 n_oxygens_acid = ndim
1535 CALL reallocate(i_hydrogens, 1, ndim +
SIZE(iatms))
1536 i_hydrogens(ndim + 1:ndim +
SIZE(iatms)) = iatms
1537 ndim = ndim +
SIZE(iatms)
1541 SELECT CASE (colvar_id)
1572 END SUBROUTINE read_acid_hydronium_colvars
1581 SUBROUTINE colvar_check_points(colvar, section, cell)
1584 TYPE(
cell_type),
OPTIONAL,
POINTER :: cell
1586 INTEGER :: i, irep, natoms, npoints, nrep, nweights
1587 INTEGER,
DIMENSION(:),
POINTER :: atoms
1589 REAL(kind=
dp),
DIMENSION(:),
POINTER :: r, weights
1592 NULLIFY (point_sections)
1595 cpassert(
ASSOCIATED(colvar))
1599 colvar%use_points = .true.
1601 ALLOCATE (colvar%points(npoints))
1606 NULLIFY (colvar%points(i)%atoms)
1607 NULLIFY (colvar%points(i)%weights)
1608 CALL section_vals_val_get(point_sections,
"TYPE", i_rep_section=i, i_val=colvar%points(i)%type_id)
1609 SELECT CASE (colvar%points(i)%type_id)
1612 CALL section_vals_val_get(point_sections,
"ATOMS", i_rep_section=i, n_rep_val=nrep, i_vals=atoms)
1614 CALL section_vals_val_get(point_sections,
"ATOMS", i_rep_section=i, i_rep_val=irep, i_vals=atoms)
1615 natoms = natoms +
SIZE(atoms)
1617 ALLOCATE (colvar%points(i)%atoms(natoms))
1620 CALL section_vals_val_get(point_sections,
"ATOMS", i_rep_section=i, i_rep_val=irep, i_vals=atoms)
1621 colvar%points(i)%atoms(natoms + 1:) = atoms(:)
1622 natoms = natoms +
SIZE(atoms)
1625 ALLOCATE (colvar%points(i)%weights(natoms))
1626 colvar%points(i)%weights = 1.0_dp/real(natoms, kind=
dp)
1632 colvar%points(i)%weights(nweights + 1:) = weights(:)
1633 nweights = nweights +
SIZE(weights)
1635 cpassert(natoms == nweights)
1640 colvar%points(i)%r = r
1641 IF (
PRESENT(cell))
THEN
1647 END SUBROUTINE colvar_check_points
1663 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(IN), &
1666 OPTIONAL,
POINTER :: fixd_list
1669 LOGICAL :: colvar_ok
1671 colvar_ok =
ASSOCIATED(colvar)
1674 IF (
PRESENT(pos))
THEN
1675 DO i = 1,
SIZE(colvar%i_atom)
1676 j = colvar%i_atom(i)
1677 particles(j)%r = pos(:, j)
1681 colvar%dsdr = 0.0_dp
1682 SELECT CASE (colvar%type_id)
1684 CALL dist_colvar(colvar, cell, particles=particles)
1686 CALL coord_colvar(colvar, cell, particles=particles)
1688 CALL population_colvar(colvar, cell, particles=particles)
1690 CALL gyration_radius_colvar(colvar, cell, particles=particles)
1692 CALL torsion_colvar(colvar, cell, particles=particles)
1694 CALL angle_colvar(colvar, cell, particles=particles)
1696 CALL dfunct_colvar(colvar, cell, particles=particles)
1698 CALL plane_distance_colvar(colvar, cell, particles=particles)
1700 CALL plane_plane_angle_colvar(colvar, cell, particles=particles)
1702 CALL rotation_colvar(colvar, cell, particles=particles)
1704 CALL qparm_colvar(colvar, cell, particles=particles)
1706 CALL hydronium_shell_colvar(colvar, cell, particles=particles)
1708 CALL hydronium_dist_colvar(colvar, cell, particles=particles)
1710 CALL acid_hyd_dist_colvar(colvar, cell, particles=particles)
1712 CALL acid_hyd_shell_colvar(colvar, cell, particles=particles)
1714 CALL rmsd_colvar(colvar, particles=particles)
1716 CALL reaction_path_colvar(colvar, cell, particles=particles)
1718 CALL distance_from_path_colvar(colvar, cell, particles=particles)
1720 CALL combine_colvar(colvar, cell, particles=particles)
1722 CALL xyz_diag_colvar(colvar, cell, particles=particles)
1724 CALL xyz_outerdiag_colvar(colvar, cell, particles=particles)
1726 CALL ring_puckering_colvar(colvar, cell, particles=particles)
1728 CALL mindist_colvar(colvar, cell, particles=particles)
1730 cpabort(
"need force_env!")
1733 CALL wc_colvar(colvar, cell, particles=particles)
1736 CALL hbp_colvar(colvar, cell, particles=particles)
1738 CALL colvar_eval_voronoiipz(colvar, cell, particles=particles)
1740 cpabort(
"Unknown colvar type for colvar_eval_mol_f")
1760 LOGICAL :: colvar_ok
1766 NULLIFY (subsys, cell, colvar, qs_env)
1767 CALL force_env_get(force_env, subsys=subsys, cell=cell, qs_env=qs_env)
1768 colvar_ok =
ASSOCIATED(subsys%colvar_p)
1771 colvar => subsys%colvar_p(icolvar)%colvar
1773 colvar%dsdr = 0.0_dp
1774 SELECT CASE (colvar%type_id)
1776 CALL dist_colvar(colvar, cell, subsys=subsys)
1778 CALL coord_colvar(colvar, cell, subsys=subsys)
1780 CALL population_colvar(colvar, cell, subsys=subsys)
1782 CALL gyration_radius_colvar(colvar, cell, subsys=subsys)
1784 CALL torsion_colvar(colvar, cell, subsys=subsys, no_riemann_sheet_op=.true.)
1786 CALL angle_colvar(colvar, cell, subsys=subsys)
1788 CALL dfunct_colvar(colvar, cell, subsys=subsys)
1790 CALL plane_distance_colvar(colvar, cell, subsys=subsys)
1792 CALL plane_plane_angle_colvar(colvar, cell, subsys=subsys)
1794 CALL rotation_colvar(colvar, cell, subsys=subsys)
1796 CALL qparm_colvar(colvar, cell, subsys=subsys)
1798 CALL hydronium_shell_colvar(colvar, cell, subsys=subsys)
1800 CALL hydronium_dist_colvar(colvar, cell, subsys=subsys)
1802 CALL acid_hyd_dist_colvar(colvar, cell, subsys=subsys)
1804 CALL acid_hyd_shell_colvar(colvar, cell, subsys=subsys)
1806 CALL rmsd_colvar(colvar, subsys=subsys)
1808 CALL reaction_path_colvar(colvar, cell, subsys=subsys)
1810 CALL distance_from_path_colvar(colvar, cell, subsys=subsys)
1812 CALL combine_colvar(colvar, cell, subsys=subsys)
1814 CALL xyz_diag_colvar(colvar, cell, subsys=subsys)
1816 CALL xyz_outerdiag_colvar(colvar, cell, subsys=subsys)
1818 CALL u_colvar(colvar, force_env=force_env)
1820 CALL wc_colvar(colvar, cell, subsys=subsys, qs_env=qs_env)
1822 CALL hbp_colvar(colvar, cell, subsys=subsys, qs_env=qs_env)
1824 CALL ring_puckering_colvar(colvar, cell, subsys=subsys)
1826 CALL mindist_colvar(colvar, cell, subsys=subsys)
1828 CALL colvar_eval_voronoiipz(colvar, cell, subsys=subsys)
1830 cpabort(
"Unknown colvar type for colvar_eval_glob_f")
1844 SUBROUTINE colvar_recursive_eval(colvar, cell, particles)
1851 colvar%dsdr = 0.0_dp
1852 SELECT CASE (colvar%type_id)
1854 CALL dist_colvar(colvar, cell, particles=particles)
1856 CALL coord_colvar(colvar, cell, particles=particles)
1858 CALL torsion_colvar(colvar, cell, particles=particles)
1860 CALL angle_colvar(colvar, cell, particles=particles)
1862 CALL dfunct_colvar(colvar, cell, particles=particles)
1864 CALL plane_distance_colvar(colvar, cell, particles=particles)
1866 CALL plane_plane_angle_colvar(colvar, cell, particles=particles)
1868 CALL rotation_colvar(colvar, cell, particles=particles)
1870 CALL qparm_colvar(colvar, cell, particles=particles)
1872 CALL hydronium_shell_colvar(colvar, cell, particles=particles)
1874 CALL hydronium_dist_colvar(colvar, cell, particles=particles)
1876 CALL acid_hyd_dist_colvar(colvar, cell, particles=particles)
1878 CALL acid_hyd_shell_colvar(colvar, cell, particles=particles)
1880 CALL rmsd_colvar(colvar, particles=particles)
1882 CALL reaction_path_colvar(colvar, cell, particles=particles)
1884 CALL distance_from_path_colvar(colvar, cell, particles=particles)
1886 CALL combine_colvar(colvar, cell, particles=particles)
1888 CALL xyz_diag_colvar(colvar, cell, particles=particles)
1890 CALL xyz_outerdiag_colvar(colvar, cell, particles=particles)
1892 CALL ring_puckering_colvar(colvar, cell, particles=particles)
1894 CALL mindist_colvar(colvar, cell, particles=particles)
1896 cpabort(
"need force_env!")
1898 CALL wc_colvar(colvar, cell, particles=particles)
1900 CALL hbp_colvar(colvar, cell, particles=particles)
1902 CALL colvar_eval_voronoiipz(colvar, cell, particles=particles)
1904 cpabort(
"Unknown colvar type for colvar_recursive_eval")
1906 END SUBROUTINE colvar_recursive_eval
1916 SUBROUTINE get_coordinates(colvar, i, ri, my_particles)
1918 INTEGER,
INTENT(IN) :: i
1919 REAL(kind=
dp),
DIMENSION(3),
INTENT(OUT) :: ri
1922 IF (colvar%use_points)
THEN
1925 ri(:) = my_particles(i)%r(:)
1928 END SUBROUTINE get_coordinates
1938 SUBROUTINE get_mass(colvar, i, mi, my_particles)
1940 INTEGER,
INTENT(IN) :: i
1941 REAL(kind=
dp),
INTENT(OUT) :: mi
1944 IF (colvar%use_points)
THEN
1947 mi = my_particles(i)%atomic_kind%mass
1950 END SUBROUTINE get_mass
1959 SUBROUTINE put_derivative(colvar, i, fi)
1961 INTEGER,
INTENT(IN) :: i
1962 REAL(kind=
dp),
DIMENSION(3),
INTENT(IN) :: fi
1964 IF (colvar%use_points)
THEN
1967 colvar%dsdr(:, i) = colvar%dsdr(:, i) + fi
1970 END SUBROUTINE put_derivative
1980 SUBROUTINE xyz_diag_colvar(colvar, cell, subsys, particles)
1985 POINTER :: particles
1988 REAL(
dp) :: fi(3), r, r0(3), ss(3), xi(3), xpi(3)
1992 NULLIFY (particles_i)
1995 IF (
PRESENT(particles))
THEN
1996 my_particles => particles
1998 cpassert(
PRESENT(subsys))
2000 my_particles => particles_i%els
2002 i = colvar%xyz_diag_param%i_atom
2004 CALL get_coordinates(colvar, i, xpi, my_particles)
2007 IF (.NOT. colvar%xyz_diag_param%use_absolute_position)
THEN
2008 IF (all(colvar%xyz_diag_param%r0 == huge(0.0_dp)))
THEN
2009 colvar%xyz_diag_param%r0 = xpi
2011 r0 = colvar%xyz_diag_param%r0
2016 IF (colvar%xyz_diag_param%use_pbc)
THEN
2017 ss = matmul(cell%h_inv, xpi - r0)
2019 xi = matmul(cell%hmat, ss)
2024 IF (.NOT. colvar%xyz_diag_param%use_absolute_position)
THEN
2025 SELECT CASE (colvar%xyz_diag_param%component)
2045 r = xi(1)**2 + xi(2)**2 + xi(3)**2
2048 SELECT CASE (colvar%xyz_diag_param%component)
2065 cpabort(
"xyz_diag_colvar not implemented for anything which is not a single component")
2071 CALL put_derivative(colvar, 1, fi)
2073 END SUBROUTINE xyz_diag_colvar
2083 SUBROUTINE xyz_outerdiag_colvar(colvar, cell, subsys, particles)
2088 POINTER :: particles
2091 REAL(
dp) :: fi(3, 2), r, r0(3), ss(3), xi(3, 2), &
2096 NULLIFY (particles_i)
2099 IF (
PRESENT(particles))
THEN
2100 my_particles => particles
2102 cpassert(
PRESENT(subsys))
2104 my_particles => particles_i%els
2107 i = colvar%xyz_outerdiag_param%i_atoms(k)
2109 CALL get_coordinates(colvar, i, xpi, my_particles)
2110 r0 = colvar%xyz_outerdiag_param%r0(:, k)
2111 IF (all(colvar%xyz_outerdiag_param%r0(:, k) == huge(0.0_dp))) r0 = xpi
2113 IF (colvar%xyz_outerdiag_param%use_pbc)
THEN
2114 ss = matmul(cell%h_inv, xpi - r0)
2116 xi(:, k) = matmul(cell%hmat, ss)
2121 SELECT CASE (colvar%xyz_outerdiag_param%components(k))
2146 IF (xi(l, 1) /= 0.0_dp) fi(l, 1) = fi(l, 1) + xi(i, 2)
2147 r = r + xi(l, 1)*xi(i, 2)
2149 IF (xi(i, 2) /= 0.0_dp) fi(i, 2) = sum(xi(:, 1))
2153 CALL put_derivative(colvar, 1, fi(:, 1))
2154 CALL put_derivative(colvar, 2, fi(:, 2))
2156 END SUBROUTINE xyz_outerdiag_colvar
2166 SUBROUTINE u_colvar(colvar, force_env)
2170 CHARACTER(LEN=default_path_length) :: coupling_function
2171 CHARACTER(LEN=default_string_length) :: def_error, this_error
2172 CHARACTER(LEN=default_string_length), &
2173 DIMENSION(:),
POINTER :: parameters
2174 INTEGER :: iatom, iforce_eval, iparticle, &
2175 jparticle, natom, natom_iforce, &
2177 INTEGER,
DIMENSION(:),
POINTER :: glob_natoms, map_index
2178 REAL(
dp) :: dedf, dx, err, fi(3), lerr, &
2180 REAL(kind=
dp),
DIMENSION(:),
POINTER :: values
2189 IF (
PRESENT(force_env))
THEN
2190 NULLIFY (particles_main, subsys_main)
2192 CALL cp_subsys_get(subsys=subsys_main, particles=particles_main)
2193 natom =
SIZE(particles_main%els)
2194 colvar%n_atom_s = natom
2195 colvar%u_param%natom = natom
2199 colvar%i_atom(iatom) = iatom
2202 IF (.NOT.
ASSOCIATED(colvar%u_param%mixed_energy_section))
THEN
2203 CALL force_env_get(force_env, potential_energy=potential_energy)
2204 colvar%ss = potential_energy
2208 fi(:) = -particles_main%els(iatom)%f
2209 CALL put_derivative(colvar, iatom, fi)
2213 CALL cp_abort(__location__, &
2214 'ASSERTION (cond) failed at line '//
cp_to_string(__line__)// &
2215 ' A combination of mixed force_eval energies has been requested as '// &
2216 ' collective variable, but the MIXED env is not in use! Aborting.')
2218 CALL force_env_get(force_env, force_env_section=force_env_section)
2220 NULLIFY (values, parameters, subsystems, particles, global_forces, map_index, glob_natoms)
2221 nforce_eval =
SIZE(force_env%sub_force_env)
2222 ALLOCATE (glob_natoms(nforce_eval))
2223 ALLOCATE (subsystems(nforce_eval))
2224 ALLOCATE (particles(nforce_eval))
2226 ALLOCATE (global_forces(nforce_eval))
2229 DO iforce_eval = 1, nforce_eval
2230 NULLIFY (subsystems(iforce_eval)%subsys, particles(iforce_eval)%list)
2231 IF (.NOT.
ASSOCIATED(force_env%sub_force_env(iforce_eval)%force_env)) cycle
2233 CALL force_env_get(force_env=force_env%sub_force_env(iforce_eval)%force_env, &
2234 subsys=subsystems(iforce_eval)%subsys)
2237 particles=particles(iforce_eval)%list)
2240 natom_iforce =
SIZE(particles(iforce_eval)%list%els)
2243 IF (force_env%sub_force_env(iforce_eval)%force_env%para_env%is_source())
THEN
2244 glob_natoms(iforce_eval) = natom_iforce
2249 CALL force_env%para_env%sync()
2250 CALL force_env%para_env%sum(glob_natoms)
2253 DO iforce_eval = 1, nforce_eval
2254 ALLOCATE (global_forces(iforce_eval)%forces(3, glob_natoms(iforce_eval)))
2255 global_forces(iforce_eval)%forces = 0.0_dp
2256 IF (
ASSOCIATED(force_env%sub_force_env(iforce_eval)%force_env))
THEN
2257 IF (force_env%sub_force_env(iforce_eval)%force_env%para_env%is_source())
THEN
2259 DO iparticle = 1, glob_natoms(iforce_eval)
2260 global_forces(iforce_eval)%forces(:, iparticle) = &
2261 particles(iforce_eval)%list%els(iparticle)%f
2265 CALL force_env%para_env%sum(global_forces(iforce_eval)%forces)
2268 wrk_section => colvar%u_param%mixed_energy_section
2270 CALL get_generic_info(wrk_section,
"ENERGY_FUNCTION", coupling_function, parameters, &
2271 values, force_env%mixed_env%energies)
2273 CALL parsef(1, trim(coupling_function), parameters)
2275 colvar%ss =
evalf(1, values)
2278 DO iforce_eval = 1, nforce_eval
2281 dedf =
evalfd(1, iforce_eval, values, dx, err)
2282 IF (abs(err) > lerr)
THEN
2283 WRITE (this_error,
"(A,G12.6,A)")
"(", err,
")"
2284 WRITE (def_error,
"(A,G12.6,A)")
"(", lerr,
")"
2287 CALL cp_warn(__location__, &
2288 'ASSERTION (cond) failed at line '//
cp_to_string(__line__)// &
2289 ' Error '//trim(this_error)//
' in computing numerical derivatives larger then'// &
2290 trim(def_error)//
' .')
2295 nforce_eval, map_index)
2298 DO iparticle = 1, glob_natoms(iforce_eval)
2299 jparticle = map_index(iparticle)
2300 fi = -dedf*global_forces(iforce_eval)%forces(:, iparticle)
2301 CALL put_derivative(colvar, jparticle, fi)
2304 IF (
ASSOCIATED(map_index))
THEN
2305 DEALLOCATE (map_index)
2309 DO iforce_eval = 1, nforce_eval
2310 DEALLOCATE (global_forces(iforce_eval)%forces)
2312 DEALLOCATE (glob_natoms)
2314 DEALLOCATE (parameters)
2315 DEALLOCATE (global_forces)
2316 DEALLOCATE (subsystems)
2317 DEALLOCATE (particles)
2320 cpabort(
"need force_env!")
2322 END SUBROUTINE u_colvar
2332 SUBROUTINE plane_distance_colvar(colvar, cell, subsys, particles)
2338 POINTER :: particles
2340 INTEGER :: i, j, k, l
2341 REAL(
dp) :: a, b, dsdxpn(3), dxpndxi(3, 3), dxpndxj(3, 3), dxpndxk(3, 3), fi(3), fj(3), &
2342 fk(3), fl(3), r12, ri(3), rj(3), rk(3), rl(3), ss(3), xpij(3), xpkj(3), xpl(3), xpn(3)
2346 NULLIFY (particles_i)
2349 IF (
PRESENT(particles))
THEN
2350 my_particles => particles
2352 cpassert(
PRESENT(subsys))
2354 my_particles => particles_i%els
2356 i = colvar%plane_distance_param%plane(1)
2357 j = colvar%plane_distance_param%plane(2)
2358 k = colvar%plane_distance_param%plane(3)
2359 l = colvar%plane_distance_param%point
2361 CALL get_coordinates(colvar, i, ri, my_particles)
2362 CALL get_coordinates(colvar, j, rj, my_particles)
2363 CALL get_coordinates(colvar, k, rk, my_particles)
2364 CALL get_coordinates(colvar, l, rl, my_particles)
2367 xpl = rl - (ri + rj + rk)/3.0_dp
2368 IF (colvar%plane_distance_param%use_pbc)
THEN
2370 ss = matmul(cell%h_inv, ri - rj)
2372 xpij = matmul(cell%hmat, ss)
2374 ss = matmul(cell%h_inv, rk - rj)
2376 xpkj = matmul(cell%hmat, ss)
2378 ss = matmul(cell%h_inv, rl - (ri + rj + rk)/3.0_dp)
2380 xpl = matmul(cell%hmat, ss)
2383 xpn(1) = xpij(2)*xpkj(3) - xpij(3)*xpkj(2)
2384 xpn(2) = xpij(3)*xpkj(1) - xpij(1)*xpkj(3)
2385 xpn(3) = xpij(1)*xpkj(2) - xpij(2)*xpkj(1)
2386 a = dot_product(xpn, xpn)
2387 b = dot_product(xpl, xpn)
2390 dsdxpn(1) = xpl(1)/r12 - b*xpn(1)/(r12*a)
2391 dsdxpn(2) = xpl(2)/r12 - b*xpn(2)/(r12*a)
2392 dsdxpn(3) = xpl(3)/r12 - b*xpn(3)/(r12*a)
2394 dxpndxi(1, 1) = 0.0_dp
2395 dxpndxi(1, 2) = 1.0_dp*xpkj(3)
2396 dxpndxi(1, 3) = -1.0_dp*xpkj(2)
2397 dxpndxi(2, 1) = -1.0_dp*xpkj(3)
2398 dxpndxi(2, 2) = 0.0_dp
2399 dxpndxi(2, 3) = 1.0_dp*xpkj(1)
2400 dxpndxi(3, 1) = 1.0_dp*xpkj(2)
2401 dxpndxi(3, 2) = -1.0_dp*xpkj(1)
2402 dxpndxi(3, 3) = 0.0_dp
2404 dxpndxj(1, 1) = 0.0_dp
2405 dxpndxj(1, 2) = -1.0_dp*xpkj(3) + xpij(3)
2406 dxpndxj(1, 3) = -1.0_dp*xpij(2) + xpkj(2)
2407 dxpndxj(2, 1) = -1.0_dp*xpij(3) + xpkj(3)
2408 dxpndxj(2, 2) = 0.0_dp
2409 dxpndxj(2, 3) = -1.0_dp*xpkj(1) + xpij(1)
2410 dxpndxj(3, 1) = -1.0_dp*xpkj(2) + xpij(2)
2411 dxpndxj(3, 2) = -1.0_dp*xpij(1) + xpkj(1)
2412 dxpndxj(3, 3) = 0.0_dp
2414 dxpndxk(1, 1) = 0.0_dp
2415 dxpndxk(1, 2) = -1.0_dp*xpij(3)
2416 dxpndxk(1, 3) = 1.0_dp*xpij(2)
2417 dxpndxk(2, 1) = 1.0_dp*xpij(3)
2418 dxpndxk(2, 2) = 0.0_dp
2419 dxpndxk(2, 3) = -1.0_dp*xpij(1)
2420 dxpndxk(3, 1) = -1.0_dp*xpij(2)
2421 dxpndxk(3, 2) = 1.0_dp*xpij(1)
2422 dxpndxk(3, 3) = 0.0_dp
2424 fi(:) = matmul(dsdxpn, dxpndxi) - xpn/(3.0_dp*r12)
2425 fj(:) = matmul(dsdxpn, dxpndxj) - xpn/(3.0_dp*r12)
2426 fk(:) = matmul(dsdxpn, dxpndxk) - xpn/(3.0_dp*r12)
2429 CALL put_derivative(colvar, 1, fi)
2430 CALL put_derivative(colvar, 2, fj)
2431 CALL put_derivative(colvar, 3, fk)
2432 CALL put_derivative(colvar, 4, fl)
2434 END SUBROUTINE plane_distance_colvar
2445 SUBROUTINE plane_plane_angle_colvar(colvar, cell, subsys, particles)
2451 POINTER :: particles
2453 INTEGER :: i1, i2, j1, j2, k1, k2, np
2455 REAL(
dp) :: a1, a2, d, dnorm_dxpn(3), dprod12_dxpn(3), dsdxpn(3), dt_dxpn(3), dxpndxi(3, 3), &
2456 dxpndxj(3, 3), dxpndxk(3, 3), fi(3), fj(3), fk(3), fmod, norm1, norm2, prod_12, ri1(3), &
2457 ri2(3), rj1(3), rj2(3), rk1(3), rk2(3), ss(3), t, xpij1(3), xpij2(3), xpkj1(3), xpkj2(3), &
2462 NULLIFY (particles_i)
2466 IF (
PRESENT(particles))
THEN
2467 my_particles => particles
2469 cpassert(
PRESENT(subsys))
2471 my_particles => particles_i%els
2475 IF (colvar%plane_plane_angle_param%plane1%type_of_def ==
plane_def_atoms)
THEN
2476 i1 = colvar%plane_plane_angle_param%plane1%points(1)
2477 j1 = colvar%plane_plane_angle_param%plane1%points(2)
2478 k1 = colvar%plane_plane_angle_param%plane1%points(3)
2481 CALL get_coordinates(colvar, i1, ri1, my_particles)
2482 CALL get_coordinates(colvar, j1, rj1, my_particles)
2483 CALL get_coordinates(colvar, k1, rk1, my_particles)
2486 ss = matmul(cell%h_inv, ri1 - rj1)
2488 xpij1 = matmul(cell%hmat, ss)
2491 ss = matmul(cell%h_inv, rk1 - rj1)
2493 xpkj1 = matmul(cell%hmat, ss)
2496 xpn1(1) = xpij1(2)*xpkj1(3) - xpij1(3)*xpkj1(2)
2497 xpn1(2) = xpij1(3)*xpkj1(1) - xpij1(1)*xpkj1(3)
2498 xpn1(3) = xpij1(1)*xpkj1(2) - xpij1(2)*xpkj1(1)
2500 xpn1 = colvar%plane_plane_angle_param%plane1%normal_vec
2502 a1 = dot_product(xpn1, xpn1)
2504 cpassert(norm1 /= 0.0_dp)
2507 IF (colvar%plane_plane_angle_param%plane2%type_of_def ==
plane_def_atoms)
THEN
2508 i2 = colvar%plane_plane_angle_param%plane2%points(1)
2509 j2 = colvar%plane_plane_angle_param%plane2%points(2)
2510 k2 = colvar%plane_plane_angle_param%plane2%points(3)
2513 CALL get_coordinates(colvar, i2, ri2, my_particles)
2514 CALL get_coordinates(colvar, j2, rj2, my_particles)
2515 CALL get_coordinates(colvar, k2, rk2, my_particles)
2518 ss = matmul(cell%h_inv, ri2 - rj2)
2520 xpij2 = matmul(cell%hmat, ss)
2523 ss = matmul(cell%h_inv, rk2 - rj2)
2525 xpkj2 = matmul(cell%hmat, ss)
2528 xpn2(1) = xpij2(2)*xpkj2(3) - xpij2(3)*xpkj2(2)
2529 xpn2(2) = xpij2(3)*xpkj2(1) - xpij2(1)*xpkj2(3)
2530 xpn2(3) = xpij2(1)*xpkj2(2) - xpij2(2)*xpkj2(1)
2532 xpn2 = colvar%plane_plane_angle_param%plane2%normal_vec
2534 a2 = dot_product(xpn2, xpn2)
2536 cpassert(norm2 /= 0.0_dp)
2539 prod_12 = dot_product(xpn1, xpn2)
2543 t = min(1.0_dp, abs(t))*sign(1.0_dp, t)
2546 IF ((abs(colvar%ss) < tolerance_acos) .OR. (abs(colvar%ss -
pi) < tolerance_acos))
THEN
2549 fmod = -1.0_dp/sin(colvar%ss)
2554 IF (colvar%plane_plane_angle_param%plane1%type_of_def ==
plane_def_atoms)
THEN
2556 dnorm_dxpn = 1.0_dp/norm1*xpn1
2557 dt_dxpn = (dprod12_dxpn*d - prod_12*dnorm_dxpn*norm2)/d**2
2559 dsdxpn(1) = fmod*dt_dxpn(1)
2560 dsdxpn(2) = fmod*dt_dxpn(2)
2561 dsdxpn(3) = fmod*dt_dxpn(3)
2563 dxpndxi(1, 1) = 0.0_dp
2564 dxpndxi(1, 2) = 1.0_dp*xpkj1(3)
2565 dxpndxi(1, 3) = -1.0_dp*xpkj1(2)
2566 dxpndxi(2, 1) = -1.0_dp*xpkj1(3)
2567 dxpndxi(2, 2) = 0.0_dp
2568 dxpndxi(2, 3) = 1.0_dp*xpkj1(1)
2569 dxpndxi(3, 1) = 1.0_dp*xpkj1(2)
2570 dxpndxi(3, 2) = -1.0_dp*xpkj1(1)
2571 dxpndxi(3, 3) = 0.0_dp
2573 dxpndxj(1, 1) = 0.0_dp
2574 dxpndxj(1, 2) = -1.0_dp*xpkj1(3) + xpij1(3)
2575 dxpndxj(1, 3) = -1.0_dp*xpij1(2) + xpkj1(2)
2576 dxpndxj(2, 1) = -1.0_dp*xpij1(3) + xpkj1(3)
2577 dxpndxj(2, 2) = 0.0_dp
2578 dxpndxj(2, 3) = -1.0_dp*xpkj1(1) + xpij1(1)
2579 dxpndxj(3, 1) = -1.0_dp*xpkj1(2) + xpij1(2)
2580 dxpndxj(3, 2) = -1.0_dp*xpij1(1) + xpkj1(1)
2581 dxpndxj(3, 3) = 0.0_dp
2583 dxpndxk(1, 1) = 0.0_dp
2584 dxpndxk(1, 2) = -1.0_dp*xpij1(3)
2585 dxpndxk(1, 3) = 1.0_dp*xpij1(2)
2586 dxpndxk(2, 1) = 1.0_dp*xpij1(3)
2587 dxpndxk(2, 2) = 0.0_dp
2588 dxpndxk(2, 3) = -1.0_dp*xpij1(1)
2589 dxpndxk(3, 1) = -1.0_dp*xpij1(2)
2590 dxpndxk(3, 2) = 1.0_dp*xpij1(1)
2591 dxpndxk(3, 3) = 0.0_dp
2593 fi = matmul(dsdxpn, dxpndxi)
2594 fj = matmul(dsdxpn, dxpndxj)
2595 fk = matmul(dsdxpn, dxpndxk)
2598 CALL put_derivative(colvar, np + 1, fi)
2599 CALL put_derivative(colvar, np + 2, fj)
2600 CALL put_derivative(colvar, np + 3, fk)
2605 IF (colvar%plane_plane_angle_param%plane2%type_of_def ==
plane_def_atoms)
THEN
2607 dnorm_dxpn = 1.0_dp/norm2*xpn2
2608 dt_dxpn = (dprod12_dxpn*d - prod_12*dnorm_dxpn*norm1)/d**2
2610 dsdxpn(1) = fmod*dt_dxpn(1)
2611 dsdxpn(2) = fmod*dt_dxpn(2)
2612 dsdxpn(3) = fmod*dt_dxpn(3)
2614 dxpndxi(1, 1) = 0.0_dp
2615 dxpndxi(1, 2) = 1.0_dp*xpkj1(3)
2616 dxpndxi(1, 3) = -1.0_dp*xpkj1(2)
2617 dxpndxi(2, 1) = -1.0_dp*xpkj1(3)
2618 dxpndxi(2, 2) = 0.0_dp
2619 dxpndxi(2, 3) = 1.0_dp*xpkj1(1)
2620 dxpndxi(3, 1) = 1.0_dp*xpkj1(2)
2621 dxpndxi(3, 2) = -1.0_dp*xpkj1(1)
2622 dxpndxi(3, 3) = 0.0_dp
2624 dxpndxj(1, 1) = 0.0_dp
2625 dxpndxj(1, 2) = -1.0_dp*xpkj1(3) + xpij1(3)
2626 dxpndxj(1, 3) = -1.0_dp*xpij1(2) + xpkj1(2)
2627 dxpndxj(2, 1) = -1.0_dp*xpij1(3) + xpkj1(3)
2628 dxpndxj(2, 2) = 0.0_dp
2629 dxpndxj(2, 3) = -1.0_dp*xpkj1(1) + xpij1(1)
2630 dxpndxj(3, 1) = -1.0_dp*xpkj1(2) + xpij1(2)
2631 dxpndxj(3, 2) = -1.0_dp*xpij1(1) + xpkj1(1)
2632 dxpndxj(3, 3) = 0.0_dp
2634 dxpndxk(1, 1) = 0.0_dp
2635 dxpndxk(1, 2) = -1.0_dp*xpij1(3)
2636 dxpndxk(1, 3) = 1.0_dp*xpij1(2)
2637 dxpndxk(2, 1) = 1.0_dp*xpij1(3)
2638 dxpndxk(2, 2) = 0.0_dp
2639 dxpndxk(2, 3) = -1.0_dp*xpij1(1)
2640 dxpndxk(3, 1) = -1.0_dp*xpij1(2)
2641 dxpndxk(3, 2) = 1.0_dp*xpij1(1)
2642 dxpndxk(3, 3) = 0.0_dp
2644 fi = matmul(dsdxpn, dxpndxi)
2645 fj = matmul(dsdxpn, dxpndxj)
2646 fk = matmul(dsdxpn, dxpndxk)
2649 CALL put_derivative(colvar, np + 1, fi)
2650 CALL put_derivative(colvar, np + 2, fj)
2651 CALL put_derivative(colvar, np + 3, fk)
2654 END SUBROUTINE plane_plane_angle_colvar
2664 SUBROUTINE rotation_colvar(colvar, cell, subsys, particles)
2669 POINTER :: particles
2672 REAL(
dp) :: a, b, fmod, t0, t1, t2, t3, xdum(3), &
2674 REAL(kind=
dp) :: dp1b1(3), dp1b2(3), dp2b1(3), dp2b2(3), &
2675 ss(3), xp1b1(3), xp1b2(3), xp2b1(3), &
2680 NULLIFY (particles_i)
2683 IF (
PRESENT(particles))
THEN
2684 my_particles => particles
2686 cpassert(
PRESENT(subsys))
2688 my_particles => particles_i%els
2690 i = colvar%rotation_param%i_at1_bond1
2691 CALL get_coordinates(colvar, i, xp1b1, my_particles)
2692 i = colvar%rotation_param%i_at2_bond1
2693 CALL get_coordinates(colvar, i, xp2b1, my_particles)
2694 i = colvar%rotation_param%i_at1_bond2
2695 CALL get_coordinates(colvar, i, xp1b2, my_particles)
2696 i = colvar%rotation_param%i_at2_bond2
2697 CALL get_coordinates(colvar, i, xp2b2, my_particles)
2699 ss = matmul(cell%h_inv, xp1b1 - xp2b1)
2701 xij = matmul(cell%hmat, ss)
2703 ss = matmul(cell%h_inv, xp1b2 - xp2b2)
2705 xkj = matmul(cell%hmat, ss)
2710 t1 = 1.0_dp/(a**3.0_dp*b)
2711 t2 = 1.0_dp/(a*b**3.0_dp)
2712 t3 = dot_product(xij, xkj)
2713 colvar%ss = acos(t3*t0)
2714 IF ((abs(colvar%ss) < tolerance_acos) .OR. (abs(colvar%ss -
pi) < tolerance_acos))
THEN
2717 fmod = -1.0_dp/sin(colvar%ss)
2719 dp1b1 = xkj(:)*t0 - xij(:)*t1*t3
2720 dp2b1 = -xkj(:)*t0 + xij(:)*t1*t3
2721 dp1b2 = xij(:)*t0 - xkj(:)*t2*t3
2722 dp2b2 = -xij(:)*t0 + xkj(:)*t2*t3
2725 idum = colvar%rotation_param%i_at1_bond1
2726 CALL put_derivative(colvar, idum, xdum)
2728 idum = colvar%rotation_param%i_at2_bond1
2729 CALL put_derivative(colvar, idum, xdum)
2731 idum = colvar%rotation_param%i_at1_bond2
2732 CALL put_derivative(colvar, idum, xdum)
2734 idum = colvar%rotation_param%i_at2_bond2
2735 CALL put_derivative(colvar, idum, xdum)
2737 END SUBROUTINE rotation_colvar
2748 SUBROUTINE dfunct_colvar(colvar, cell, subsys, particles)
2753 POINTER :: particles
2755 INTEGER :: i, j, k, l
2756 REAL(
dp) :: fi(3), fj(3), fk(3), fl(3), r12, r34, &
2757 ss(3), xij(3), xkl(3), xpi(3), xpj(3), &
2762 NULLIFY (particles_i)
2765 IF (
PRESENT(particles))
THEN
2766 my_particles => particles
2768 cpassert(
PRESENT(subsys))
2770 my_particles => particles_i%els
2772 i = colvar%dfunct_param%i_at_dfunct(1)
2773 j = colvar%dfunct_param%i_at_dfunct(2)
2775 CALL get_coordinates(colvar, i, xpi, my_particles)
2776 CALL get_coordinates(colvar, j, xpj, my_particles)
2777 IF (colvar%dfunct_param%use_pbc)
THEN
2778 ss = matmul(cell%h_inv, xpi - xpj)
2780 xij = matmul(cell%hmat, ss)
2784 r12 = sqrt(xij(1)**2 + xij(2)**2 + xij(3)**2)
2786 k = colvar%dfunct_param%i_at_dfunct(3)
2787 l = colvar%dfunct_param%i_at_dfunct(4)
2788 CALL get_coordinates(colvar, k, xpk, my_particles)
2789 CALL get_coordinates(colvar, l, xpl, my_particles)
2790 IF (colvar%dfunct_param%use_pbc)
THEN
2791 ss = matmul(cell%h_inv, xpk - xpl)
2793 xkl = matmul(cell%hmat, ss)
2797 r34 = sqrt(xkl(1)**2 + xkl(2)**2 + xkl(3)**2)
2799 colvar%ss = r12 + colvar%dfunct_param%coeff*r34
2802 fk(:) = colvar%dfunct_param%coeff*xkl/r34
2803 fl(:) = -colvar%dfunct_param%coeff*xkl/r34
2804 CALL put_derivative(colvar, 1, fi)
2805 CALL put_derivative(colvar, 2, fj)
2806 CALL put_derivative(colvar, 3, fk)
2807 CALL put_derivative(colvar, 4, fl)
2809 END SUBROUTINE dfunct_colvar
2819 SUBROUTINE angle_colvar(colvar, cell, subsys, particles)
2824 POINTER :: particles
2827 REAL(
dp) :: a, b, fi(3), fj(3), fk(3), fmod, ri(3), &
2828 rj(3), rk(3), ss(3), t0, t1, t2, t3, &
2833 NULLIFY (particles_i)
2836 IF (
PRESENT(particles))
THEN
2837 my_particles => particles
2839 cpassert(
PRESENT(subsys))
2841 my_particles => particles_i%els
2843 i = colvar%angle_param%i_at_angle(1)
2844 j = colvar%angle_param%i_at_angle(2)
2845 k = colvar%angle_param%i_at_angle(3)
2846 CALL get_coordinates(colvar, i, ri, my_particles)
2847 CALL get_coordinates(colvar, j, rj, my_particles)
2848 CALL get_coordinates(colvar, k, rk, my_particles)
2850 ss = matmul(cell%h_inv, ri - rj)
2852 xij = matmul(cell%hmat, ss)
2854 ss = matmul(cell%h_inv, rk - rj)
2856 xkj = matmul(cell%hmat, ss)
2861 t1 = 1.0_dp/(a**3.0_dp*b)
2862 t2 = 1.0_dp/(a*b**3.0_dp)
2863 t3 = dot_product(xij, xkj)
2864 colvar%ss = acos(t3*t0)
2865 IF ((abs(colvar%ss) < tolerance_acos) .OR. (abs(colvar%ss -
pi) < tolerance_acos))
THEN
2868 fmod = -1.0_dp/sin(colvar%ss)
2870 fi(:) = xkj(:)*t0 - xij(:)*t1*t3
2871 fj(:) = -xkj(:)*t0 + xij(:)*t1*t3 - xij(:)*t0 + xkj(:)*t2*t3
2872 fk(:) = xij(:)*t0 - xkj(:)*t2*t3
2876 CALL put_derivative(colvar, 1, fi)
2877 CALL put_derivative(colvar, 2, fj)
2878 CALL put_derivative(colvar, 3, fk)
2880 END SUBROUTINE angle_colvar
2890 SUBROUTINE dist_colvar(colvar, cell, subsys, particles)
2895 POINTER :: particles
2898 REAL(
dp) :: fi(3), fj(3), r12, ss(3), xij(3), &
2903 NULLIFY (particles_i)
2906 IF (
PRESENT(particles))
THEN
2907 my_particles => particles
2909 cpassert(
PRESENT(subsys))
2911 my_particles => particles_i%els
2913 i = colvar%dist_param%i_at
2914 j = colvar%dist_param%j_at
2915 CALL get_coordinates(colvar, i, xpi, my_particles)
2916 CALL get_coordinates(colvar, j, xpj, my_particles)
2917 ss = matmul(cell%h_inv, xpi - xpj)
2919 xij = matmul(cell%hmat, ss)
2920 SELECT CASE (colvar%dist_param%axis_id)
2939 r12 = sqrt(xij(1)**2 + xij(2)**2 + xij(3)**2)
2941 IF (colvar%dist_param%sign_d)
THEN
2942 SELECT CASE (colvar%dist_param%axis_id)
2960 CALL put_derivative(colvar, 1, fi)
2961 CALL put_derivative(colvar, 2, fj)
2963 END SUBROUTINE dist_colvar
2974 SUBROUTINE torsion_colvar(colvar, cell, subsys, particles, no_riemann_sheet_op)
2980 POINTER :: particles
2981 LOGICAL,
INTENT(IN),
OPTIONAL :: no_riemann_sheet_op
2984 LOGICAL :: no_riemann_sheet
2985 REAL(
dp) ::
angle, cosine, dedphi, dedxia, dedxib, dedxic, dedxid, dedxt, dedxu, dedyia, &
2986 dedyib, dedyic, dedyid, dedyt, dedyu, dedzia, dedzib, dedzic, dedzid, dedzt, dedzu, dt, &
2987 e, ftmp(3), o0, rcb, rt2, rtmp(3), rtru, ru2, sine, ss(3), xba, xca, xcb, xdb, xdc, xt, &
2988 xtu, xu, yba, yca, ycb, ydb, ydc, yt, ytu, yu, zba, zca, zcb, zdb, zdc, zt, ztu, zu
2989 REAL(
dp),
DIMENSION(3, 4) :: rr
2993 NULLIFY (particles_i)
2995 IF (
PRESENT(particles))
THEN
2996 my_particles => particles
2998 cpassert(
PRESENT(subsys))
3000 my_particles => particles_i%els
3002 no_riemann_sheet = .false.
3003 IF (
PRESENT(no_riemann_sheet_op)) no_riemann_sheet = no_riemann_sheet_op
3005 i = colvar%torsion_param%i_at_tors(ii)
3006 CALL get_coordinates(colvar, i, rtmp, my_particles)
3007 rr(:, ii) = rtmp(1:3)
3009 o0 = colvar%torsion_param%o0
3011 ss = matmul(cell%h_inv, rr(:, 2) - rr(:, 1))
3013 ss = matmul(cell%hmat, ss)
3018 ss = matmul(cell%h_inv, rr(:, 3) - rr(:, 2))
3020 ss = matmul(cell%hmat, ss)
3025 ss = matmul(cell%h_inv, rr(:, 4) - rr(:, 3))
3027 ss = matmul(cell%hmat, ss)
3032 xt = yba*zcb - ycb*zba
3033 yt = zba*xcb - zcb*xba
3034 zt = xba*ycb - xcb*yba
3035 xu = ycb*zdc - ydc*zcb
3036 yu = zcb*xdc - zdc*xcb
3037 zu = xcb*ydc - xdc*ycb
3041 rt2 = xt*xt + yt*yt + zt*zt
3042 ru2 = xu*xu + yu*yu + zu*zu
3043 rtru = sqrt(rt2*ru2)
3044 IF (rtru /= 0.0_dp)
THEN
3045 rcb = sqrt(xcb*xcb + ycb*ycb + zcb*zcb)
3046 cosine = (xt*xu + yt*yu + zt*zu)/rtru
3047 sine = (xcb*xtu + ycb*ytu + zcb*ztu)/(rcb*rtru)
3048 cosine = min(1.0_dp, max(-1.0_dp, cosine))
3049 angle = acos(cosine)
3053 dt = mod(2.0e4_dp*
pi + dt - o0, 2.0_dp*
pi)
3054 IF (dt >
pi) dt = dt - 2.0_dp*
pi
3056 colvar%torsion_param%o0 = dt
3066 ss = matmul(cell%h_inv, rr(:, 3) - rr(:, 1))
3068 ss = matmul(cell%hmat, ss)
3073 ss = matmul(cell%h_inv, rr(:, 4) - rr(:, 2))
3075 ss = matmul(cell%hmat, ss)
3080 dedxt = dedphi*(yt*zcb - ycb*zt)/(rt2*rcb)
3081 dedyt = dedphi*(zt*xcb - zcb*xt)/(rt2*rcb)
3082 dedzt = dedphi*(xt*ycb - xcb*yt)/(rt2*rcb)
3083 dedxu = -dedphi*(yu*zcb - ycb*zu)/(ru2*rcb)
3084 dedyu = -dedphi*(zu*xcb - zcb*xu)/(ru2*rcb)
3085 dedzu = -dedphi*(xu*ycb - xcb*yu)/(ru2*rcb)
3089 dedxia = zcb*dedyt - ycb*dedzt
3090 dedyia = xcb*dedzt - zcb*dedxt
3091 dedzia = ycb*dedxt - xcb*dedyt
3092 dedxib = yca*dedzt - zca*dedyt + zdc*dedyu - ydc*dedzu
3093 dedyib = zca*dedxt - xca*dedzt + xdc*dedzu - zdc*dedxu
3094 dedzib = xca*dedyt - yca*dedxt + ydc*dedxu - xdc*dedyu
3095 dedxic = zba*dedyt - yba*dedzt + ydb*dedzu - zdb*dedyu
3096 dedyic = xba*dedzt - zba*dedxt + zdb*dedxu - xdb*dedzu
3097 dedzic = yba*dedxt - xba*dedyt + xdb*dedyu - ydb*dedxu
3098 dedxid = zcb*dedyu - ycb*dedzu
3099 dedyid = xcb*dedzu - zcb*dedxu
3100 dedzid = ycb*dedxu - xcb*dedyu
3117 IF (no_riemann_sheet) colvar%ss = atan2(sin(e), cos(e))
3121 CALL put_derivative(colvar, 1, ftmp)
3125 CALL put_derivative(colvar, 2, ftmp)
3129 CALL put_derivative(colvar, 3, ftmp)
3133 CALL put_derivative(colvar, 4, ftmp)
3134 END SUBROUTINE torsion_colvar
3143 SUBROUTINE qparm_colvar(colvar, cell, subsys, particles)
3148 POINTER :: particles
3150 INTEGER :: aa, bb, cc, i, idim, ii, j, jj, l, mm, &
3151 n_atoms_from, n_atoms_to, ncells(3)
3152 LOGICAL :: include_images
3153 REAL(kind=
dp) :: denominator_tolerance, fact, ftmp(3), im_qlm, inv_n_atoms_from, nbond, &
3154 pre_fac, ql, qparm, r1cut, rcut, re_qlm, rij, rij_shift, shift(3), ss(3), ss0(3), xij(3), &
3156 REAL(kind=
dp),
DIMENSION(3) :: d_im_qlm_dxi, d_nbond_dxi, d_ql_dxi, &
3157 d_re_qlm_dxi, xpi, xpj
3161 n_atoms_to = colvar%qparm_param%n_atoms_to
3162 n_atoms_from = colvar%qparm_param%n_atoms_from
3163 rcut = colvar%qparm_param%rcut
3164 l = colvar%qparm_param%l
3165 r1cut = colvar%qparm_param%rstart
3166 include_images = colvar%qparm_param%include_images
3167 NULLIFY (particles_i)
3169 IF (
PRESENT(particles))
THEN
3170 my_particles => particles
3172 cpassert(
PRESENT(subsys))
3174 my_particles => particles_i%els
3176 cpassert(r1cut < rcut)
3177 denominator_tolerance = 1.0e-8_dp
3180 inv_n_atoms_from = 1.0_dp/real(n_atoms_from, kind=
dp)
3181 DO ii = 1, n_atoms_from
3182 i = colvar%qparm_param%i_at_from(ii)
3183 CALL get_coordinates(colvar, i, xpi, my_particles)
3186 d_ql_dxi(:) = 0.0_dp
3192 d_re_qlm_dxi(:) = 0.0_dp
3193 d_im_qlm_dxi(:) = 0.0_dp
3194 d_nbond_dxi(:) = 0.0_dp
3196 jloop:
DO jj = 1, n_atoms_to
3198 j = colvar%qparm_param%i_at_to(jj)
3199 CALL get_coordinates(colvar, j, xpj, my_particles)
3201 IF (include_images)
THEN
3203 cpassert(cell%orthorhombic)
3207 xij(:) = xpj(:) - xpi(:)
3208 ss = matmul(cell%h_inv, xij)
3214 shift(idim) = 1.0_dp
3215 xij_shift = matmul(cell%hmat, shift)
3216 rij_shift = norm2(xij_shift)
3217 ncells(idim) = floor(rcut/rij_shift - 0.5)
3221 DO aa = -ncells(1), ncells(1)
3222 DO bb = -ncells(2), ncells(2)
3223 DO cc = -ncells(3), ncells(3)
3225 IF (i == j .AND. aa == 0 .AND. bb == 0 .AND. cc == 0) cycle
3226 shift(1) = real(aa, kind=
dp)
3227 shift(2) = real(bb, kind=
dp)
3228 shift(3) = real(cc, kind=
dp)
3229 xij = matmul(cell%hmat, ss0(:) + shift(:))
3231 IF (rij > rcut) cycle
3234 CALL accumulate_qlm_over_neigbors(xij, rij, rcut, r1cut, &
3235 denominator_tolerance, l, mm, nbond, re_qlm, im_qlm, &
3236 d_re_qlm_dxi, d_im_qlm_dxi, d_nbond_dxi)
3244 IF (i == j) cycle jloop
3245 xij(:) = xpj(:) - xpi(:)
3247 IF (rij > rcut) cycle jloop
3250 CALL accumulate_qlm_over_neigbors(xij, rij, rcut, r1cut, &
3251 denominator_tolerance, l, mm, nbond, re_qlm, im_qlm, &
3252 d_re_qlm_dxi, d_im_qlm_dxi, d_nbond_dxi)
3262 IF (nbond < denominator_tolerance)
THEN
3263 cpwarn(
"QPARM: number of neighbors is very close to zero!")
3266 d_nbond_dxi(:) = d_nbond_dxi(:)/nbond
3267 re_qlm = re_qlm/nbond
3268 d_re_qlm_dxi(:) = d_re_qlm_dxi(:)/nbond - d_nbond_dxi(:)*re_qlm
3269 im_qlm = im_qlm/nbond
3270 d_im_qlm_dxi(:) = d_im_qlm_dxi(:)/nbond - d_nbond_dxi(:)*im_qlm
3272 ql = ql + fact*(re_qlm*re_qlm + im_qlm*im_qlm)
3273 d_ql_dxi(:) = d_ql_dxi(:) &
3274 + fact*2.0_dp*(re_qlm*d_re_qlm_dxi(:) + im_qlm*d_im_qlm_dxi(:))
3278 pre_fac = (4.0_dp*
pi)/(2.0_dp*l + 1)
3279 qparm = qparm + sqrt(pre_fac*ql)
3280 ftmp(:) = 0.5_dp*sqrt(pre_fac/ql)*d_ql_dxi(:)
3282 ftmp(:) = -1.0_dp*ftmp(:)
3284 CALL put_derivative(colvar, ii, ftmp)
3288 colvar%ss = qparm*inv_n_atoms_from
3289 colvar%dsdr(:, :) = colvar%dsdr(:, :)*inv_n_atoms_from
3291 END SUBROUTINE qparm_colvar
3309 SUBROUTINE accumulate_qlm_over_neigbors(xij, rij, rcut, r1cut, &
3310 denominator_tolerance, ll, mm, nbond, re_qlm, im_qlm, &
3311 d_re_qlm_dxi, d_im_qlm_dxi, d_nbond_dxi)
3313 REAL(kind=
dp),
INTENT(IN) :: xij(3), rij, rcut, r1cut, &
3314 denominator_tolerance
3315 INTEGER,
INTENT(IN) :: ll, mm
3316 REAL(kind=
dp),
INTENT(INOUT) :: nbond, re_qlm, im_qlm, d_re_qlm_dxi(3), &
3317 d_im_qlm_dxi(3), d_nbond_dxi(3)
3319 REAL(kind=
dp) :: bond, costheta, dplm, dylm, exp0, &
3320 exp_fac, fi, plm, pre_fac, sqrt_c1
3321 REAL(kind=
dp),
DIMENSION(3) :: dcostheta, dfi
3325 IF (rij > rcut)
THEN
3330 IF (rij < r1cut)
THEN
3334 exp0 = exp((r1cut - rcut)/(rij - rcut) - (r1cut - rcut)/(r1cut - rij))
3335 bond = 1.0_dp/(1.0_dp + exp0)
3336 exp_fac = ((rcut - r1cut)/(rij - rcut)**2 + (rcut - r1cut)/(r1cut - rij)**2)*exp0/(1.0_dp + exp0)**2
3339 IF (bond > 1.0_dp)
THEN
3340 cpabort(
"bond > 1.0_dp")
3343 nbond = nbond + bond
3344 IF (abs(xij(1)) < denominator_tolerance &
3345 .AND. abs(xij(2)) < denominator_tolerance)
THEN
3348 fi = atan2(xij(2), xij(1))
3351 costheta = xij(3)/rij
3352 IF (costheta > 1.0_dp) costheta = 1.0_dp
3353 IF (costheta < -1.0_dp) costheta = -1.0_dp
3358 IF ((ll + abs(mm)) >
maxfac)
THEN
3359 cpabort(
"(l+m) > maxfac")
3362 sqrt_c1 = sqrt(((2*ll + 1)*
fac(ll - abs(mm)))/(4*
pi*
fac(ll + abs(mm))))
3363 pre_fac = bond*sqrt_c1
3366 re_qlm = re_qlm + pre_fac*plm*cos(mm*fi)
3367 im_qlm = im_qlm + pre_fac*plm*sin(mm*fi)
3369 dcostheta(:) = xij(:)*xij(3)/(rij**3)
3370 dcostheta(3) = dcostheta(3) - 1.0_dp/rij
3374 dfi(1) = xij(2)/(xij(1)**2 + xij(2)**2)
3375 dfi(2) = -xij(1)/(xij(1)**2 + xij(2)**2)
3377 d_re_qlm_dxi(:) = d_re_qlm_dxi(:) &
3378 + exp_fac*sqrt_c1*plm*cos(mm*fi)*xij(:)/rij &
3379 + dylm*dcostheta(:)*cos(mm*fi) &
3380 + pre_fac*plm*mm*(-1.0_dp)*sin(mm*fi)*dfi(:)
3381 d_im_qlm_dxi(:) = d_im_qlm_dxi(:) &
3382 + exp_fac*sqrt_c1*plm*sin(mm*fi)*xij(:)/rij &
3383 + dylm*dcostheta(:)*sin(mm*fi) &
3384 + pre_fac*plm*mm*(+1.0_dp)*cos(mm*fi)*dfi(:)
3385 d_nbond_dxi(:) = d_nbond_dxi(:) + exp_fac*xij(:)/rij
3387 END SUBROUTINE accumulate_qlm_over_neigbors
3399 SUBROUTINE hydronium_shell_colvar(colvar, cell, subsys, particles)
3404 POINTER :: particles
3406 INTEGER :: i, ii, j, jj, n_hydrogens, n_oxygens, &
3407 pm, poh, poo, qm, qoh, qoo
3408 REAL(
dp) :: drji, fscalar, invden, lambda, nh, num, &
3409 qtot, rji(3), roh, roo, rrel
3410 REAL(
dp),
ALLOCATABLE,
DIMENSION(:) :: m, noh, noo, qloc
3411 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: dm, dnoh, dnoo
3412 REAL(
dp),
DIMENSION(3) :: rpi, rpj
3416 n_oxygens = colvar%hydronium_shell_param%n_oxygens
3417 n_hydrogens = colvar%hydronium_shell_param%n_hydrogens
3418 nh = colvar%hydronium_shell_param%nh
3419 poh = colvar%hydronium_shell_param%poh
3420 qoh = colvar%hydronium_shell_param%qoh
3421 poo = colvar%hydronium_shell_param%poo
3422 qoo = colvar%hydronium_shell_param%qoo
3423 roo = colvar%hydronium_shell_param%roo
3424 roh = colvar%hydronium_shell_param%roh
3425 lambda = colvar%hydronium_shell_param%lambda
3426 pm = colvar%hydronium_shell_param%pm
3427 qm = colvar%hydronium_shell_param%qm
3429 NULLIFY (particles_i)
3431 IF (
PRESENT(particles))
THEN
3432 my_particles => particles
3434 cpassert(
PRESENT(subsys))
3436 my_particles => particles_i%els
3439 ALLOCATE (dnoh(3, n_hydrogens, n_oxygens))
3440 ALLOCATE (noh(n_oxygens))
3441 ALLOCATE (m(n_oxygens))
3442 ALLOCATE (dm(3, n_hydrogens, n_oxygens))
3444 ALLOCATE (dnoo(3, n_oxygens, n_oxygens))
3445 ALLOCATE (noo(n_oxygens))
3447 ALLOCATE (qloc(n_oxygens))
3457 DO ii = 1, n_oxygens
3458 i = colvar%hydronium_shell_param%i_oxygens(ii)
3459 rpi(:) = my_particles(i)%r(1:3)
3461 DO jj = 1, n_hydrogens
3462 j = colvar%hydronium_shell_param%i_hydrogens(jj)
3463 rpj(:) = my_particles(j)%r(1:3)
3464 rji =
pbc(rpj, rpi, cell)
3465 drji = sqrt(sum(rji**2))
3467 num = (1.0_dp - rrel**poh)
3468 invden = 1.0_dp/(1.0_dp - rrel**qoh)
3469 IF (abs(1.0_dp - rrel) > 1.0e-6_dp)
THEN
3470 noh(ii) = noh(ii) + num*invden
3471 fscalar = ((-poh*(rrel**(poh - 1))*invden) &
3472 + num*(invden)**2*qoh*(rrel**(qoh - 1)))/(drji*roh)
3473 dnoh(1:3, jj, ii) = rji(1:3)*fscalar
3476 noh(ii) = noh(ii) + real(poh,
dp)/real(qoh,
dp)
3477 fscalar = real(poh*(poh - qoh),
dp)/(real(2*qoh,
dp)*roh*drji)
3478 dnoh(1:3, jj, ii) = rji(1:3)*fscalar
3481 m(ii) = 1.0_dp - (1.0_dp - (noh(ii)/nh)**pm)/ &
3482 (1.0_dp - (noh(ii)/nh)**qm)
3485 DO jj = 1, n_oxygens
3487 j = colvar%hydronium_shell_param%i_oxygens(jj)
3488 rpj(:) = my_particles(j)%r(1:3)
3489 rji =
pbc(rpj, rpi, cell)
3490 drji = sqrt(sum(rji**2))
3492 num = (1.0_dp - rrel**poo)
3493 invden = 1.0_dp/(1.0_dp - rrel**qoo)
3494 IF (abs(1.0_dp - rrel) > 1.0e-6_dp)
THEN
3495 noo(ii) = noo(ii) + num*invden
3496 fscalar = ((-poo*(rrel**(poo - 1))*invden) &
3497 + num*(invden)**2*qoo*(rrel**(qoo - 1)))/(drji*roo)
3498 dnoo(1:3, jj, ii) = rji(1:3)*fscalar
3501 noo(ii) = noo(ii) + real(poo,
dp)/real(qoo,
dp)
3502 fscalar = real(poo*(poo - qoo),
dp)/(real(2*qoo,
dp)*roo*drji)
3503 dnoo(1:3, jj, ii) = rji(1:3)*fscalar
3510 DO ii = 1, n_oxygens
3511 qloc(ii) = exp(lambda*m(ii)*noo(ii))
3512 qtot = qtot + qloc(ii)
3515 DO ii = 1, n_oxygens
3517 DO jj = 1, n_hydrogens
3518 dm(1:3, jj, ii) = (pm*((noh(ii)/nh)**(pm - 1))*dnoh(1:3, jj, ii))/nh/ &
3519 (1.0_dp - (noh(ii)/nh)**qm) - &
3520 (1.0_dp - (noh(ii)/nh)**pm)/ &
3521 ((1.0_dp - (noh(ii)/nh)**qm)**2)* &
3522 qm*dnoh(1:3, jj, ii)*(noh(ii)/nh)**(qm - 1)/nh
3524 colvar%dsdr(1:3, ii) = colvar%dsdr(1:3, ii) + qloc(ii)*dm(1:3, jj, ii)*noo(ii)/qtot
3525 colvar%dsdr(1:3, n_oxygens + jj) = colvar%dsdr(1:3, n_oxygens + jj) &
3526 - qloc(ii)*dm(1:3, jj, ii)*noo(ii)/qtot
3529 DO jj = 1, n_oxygens
3530 colvar%dsdr(1:3, ii) = colvar%dsdr(1:3, ii) + qloc(ii)*m(ii)*dnoo(1:3, jj, ii)/qtot
3531 colvar%dsdr(1:3, jj) = colvar%dsdr(1:3, jj) &
3532 - qloc(ii)*m(ii)*dnoo(1:3, jj, ii)/qtot
3536 colvar%ss = log(qtot)/lambda
3545 END SUBROUTINE hydronium_shell_colvar
3556 SUBROUTINE hydronium_dist_colvar(colvar, cell, subsys, particles)
3561 POINTER :: particles
3563 INTEGER :: i, ii, j, jj, k, kk, n_hydrogens, &
3564 n_oxygens, offseth, pf, pm, poh, qf, &
3566 REAL(
dp) :: drji, drki, fscalar, invden, lambda, nh, nn, num, rion, rion_den, rion_num, &
3567 rji(3), rki(3), roh, rrel, sum_expfac_f, sum_expfac_noh
3568 REAL(
dp),
ALLOCATABLE,
DIMENSION(:) :: dexpfac_f, dexpfac_noh, df, dm, &
3569 expfac_f, expfac_f_rki, expfac_noh, f, &
3571 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: dexpfac_f_rki
3572 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: ddist_rki, dnoh
3573 REAL(
dp),
DIMENSION(3) :: rpi, rpj, rpk
3577 n_oxygens = colvar%hydronium_dist_param%n_oxygens
3578 n_hydrogens = colvar%hydronium_dist_param%n_hydrogens
3579 poh = colvar%hydronium_dist_param%poh
3580 qoh = colvar%hydronium_dist_param%qoh
3581 roh = colvar%hydronium_dist_param%roh
3582 pm = colvar%hydronium_dist_param%pm
3583 qm = colvar%hydronium_dist_param%qm
3584 nh = colvar%hydronium_dist_param%nh
3585 pf = colvar%hydronium_dist_param%pf
3586 qf = colvar%hydronium_dist_param%qf
3587 nn = colvar%hydronium_dist_param%nn
3588 lambda = colvar%hydronium_dist_param%lambda
3590 NULLIFY (particles_i)
3592 IF (
PRESENT(particles))
THEN
3593 my_particles => particles
3595 cpassert(
PRESENT(subsys))
3597 my_particles => particles_i%els
3600 ALLOCATE (dnoh(3, n_hydrogens, n_oxygens))
3601 ALLOCATE (noh(n_oxygens))
3602 ALLOCATE (m(n_oxygens), dm(n_oxygens))
3603 ALLOCATE (f(n_oxygens), df(n_oxygens))
3604 ALLOCATE (expfac_noh(n_oxygens), dexpfac_noh(n_oxygens))
3605 ALLOCATE (expfac_f(n_oxygens), dexpfac_f(n_oxygens))
3606 ALLOCATE (ddist_rki(3, n_oxygens, n_oxygens))
3607 ALLOCATE (expfac_f_rki(n_oxygens))
3608 ALLOCATE (dexpfac_f_rki(n_oxygens, n_oxygens))
3620 sum_expfac_noh = 0._dp
3621 sum_expfac_f = 0._dp
3623 expfac_f_rki = 0._dp
3624 dexpfac_f_rki = 0._dp
3627 DO ii = 1, n_oxygens
3628 i = colvar%hydronium_dist_param%i_oxygens(ii)
3629 rpi(:) = my_particles(i)%r(1:3)
3630 DO jj = 1, n_hydrogens
3631 j = colvar%hydronium_dist_param%i_hydrogens(jj)
3632 rpj(:) = my_particles(j)%r(1:3)
3633 rji =
pbc(rpj, rpi, cell)
3634 drji = sqrt(sum(rji**2))
3636 num = (1.0_dp - rrel**poh)
3637 invden = 1.0_dp/(1.0_dp - rrel**qoh)
3638 IF (abs(1.0_dp - rrel) > 1.0e-6_dp)
THEN
3639 noh(ii) = noh(ii) + num*invden
3640 fscalar = ((-poh*(rrel**(poh - 1))*invden) &
3641 + num*(invden)**2*qoh*(rrel**(qoh - 1)))/(drji*roh)
3642 dnoh(1:3, jj, ii) = rji(1:3)*fscalar
3645 noh(ii) = noh(ii) + real(poh,
dp)/real(qoh,
dp)
3646 fscalar = real(poh*(poh - qoh),
dp)/(real(2*qoh,
dp)*roh*drji)
3647 dnoh(1:3, jj, ii) = rji(1:3)*fscalar
3653 DO ii = 1, n_oxygens
3654 num = 1.0_dp - (noh(ii)/nh)**pm
3655 invden = 1.0_dp/(1.0_dp - (noh(ii)/nh)**qm)
3656 m(ii) = 1.0_dp - num*invden
3657 dm(ii) = (pm*(noh(ii)/nh)**(pm - 1)*invden - qm*num*(invden**2)* &
3658 (noh(ii)/nh)**(qm - 1))/nh
3659 expfac_noh(ii) = exp(lambda*noh(ii))
3660 dexpfac_noh(ii) = lambda*expfac_noh(ii)
3661 sum_expfac_noh = sum_expfac_noh + expfac_noh(ii)
3665 DO ii = 1, n_oxygens
3666 i = colvar%hydronium_dist_param%i_oxygens(ii)
3667 num = 1.0_dp - (noh(ii)/nn)**pf
3668 invden = 1.0_dp/(1.0_dp - (noh(ii)/nn)**qf)
3670 df(ii) = (-pf*(noh(ii)/nn)**(pf - 1)*invden + qf*num*(invden**2)* &
3671 (noh(ii)/nn)**(qf - 1))/nn
3672 expfac_f(ii) = exp(lambda*f(ii))
3673 dexpfac_f(ii) = lambda*expfac_f(ii)
3674 sum_expfac_f = sum_expfac_f + expfac_f(ii)
3678 DO ii = 1, n_oxygens
3679 i = colvar%hydronium_dist_param%i_oxygens(ii)
3680 rpi(:) = my_particles(i)%r(1:3)
3681 DO kk = 1, n_oxygens
3683 k = colvar%hydronium_dist_param%i_oxygens(kk)
3684 rpk(:) = my_particles(k)%r(1:3)
3685 rki =
pbc(rpk, rpi, cell)
3686 drki = sqrt(sum(rki**2))
3687 expfac_f_rki(ii) = expfac_f_rki(ii) + drki*expfac_f(kk)
3688 ddist_rki(1:3, kk, ii) = rki(1:3)/drki
3689 dexpfac_f_rki(kk, ii) = drki*dexpfac_f(kk)
3691 rion_num = rion_num + m(ii)*expfac_noh(ii)*expfac_f_rki(ii)
3695 rion_den = sum_expfac_noh*sum_expfac_f
3696 rion = rion_num/rion_den
3701 DO ii = 1, n_oxygens
3702 DO jj = 1, n_hydrogens
3703 colvar%dsdr(1:3, ii) = colvar%dsdr(1:3, ii) &
3704 + dm(ii)*dnoh(1:3, jj, ii)*expfac_noh(ii) &
3705 *expfac_f_rki(ii)/rion_den
3706 colvar%dsdr(1:3, offseth + jj) = colvar%dsdr(1:3, offseth + jj) &
3707 - dm(ii)*dnoh(1:3, jj, ii)*expfac_noh(ii) &
3708 *expfac_f_rki(ii)/rion_den
3709 colvar%dsdr(1:3, ii) = colvar%dsdr(1:3, ii) &
3710 + m(ii)*dexpfac_noh(ii)*dnoh(1:3, jj, ii) &
3711 *expfac_f_rki(ii)/rion_den
3712 colvar%dsdr(1:3, offseth + jj) = colvar%dsdr(1:3, offseth + jj) &
3713 - m(ii)*dexpfac_noh(ii)*dnoh(1:3, jj, ii) &
3714 *expfac_f_rki(ii)/rion_den
3716 DO kk = 1, n_oxygens
3718 colvar%dsdr(1:3, kk) = colvar%dsdr(1:3, kk) &
3719 - m(ii)*expfac_noh(ii)*ddist_rki(1:3, kk, ii) &
3720 *expfac_f(kk)/rion_den
3721 colvar%dsdr(1:3, ii) = colvar%dsdr(1:3, ii) &
3722 + m(ii)*expfac_noh(ii)*ddist_rki(1:3, kk, ii) &
3723 *expfac_f(kk)/rion_den
3724 DO jj = 1, n_hydrogens
3725 colvar%dsdr(1:3, kk) = colvar%dsdr(1:3, kk) &
3726 + m(ii)*expfac_noh(ii)*dexpfac_f_rki(kk, ii) &
3727 *df(kk)*dnoh(1:3, jj, kk)/rion_den
3728 colvar%dsdr(1:3, offseth + jj) = colvar%dsdr(1:3, offseth + jj) &
3729 - m(ii)*expfac_noh(ii)*dexpfac_f_rki(kk, ii) &
3730 *df(kk)*dnoh(1:3, jj, kk)/rion_den
3735 DO ii = 1, n_oxygens
3736 DO jj = 1, n_hydrogens
3737 colvar%dsdr(1:3, ii) = colvar%dsdr(1:3, ii) &
3738 - rion_num*sum_expfac_f*dexpfac_noh(ii) &
3739 *dnoh(1:3, jj, ii)/(rion_den**2)
3740 colvar%dsdr(1:3, offseth + jj) = colvar%dsdr(1:3, offseth + jj) &
3741 + rion_num*sum_expfac_f*dexpfac_noh(ii) &
3742 *dnoh(1:3, jj, ii)/(rion_den**2)
3743 colvar%dsdr(1:3, ii) = colvar%dsdr(1:3, ii) &
3744 - rion_num*sum_expfac_noh*dexpfac_f(ii)*df(ii) &
3745 *dnoh(1:3, jj, ii)/(rion_den**2)
3746 colvar%dsdr(1:3, offseth + jj) = colvar%dsdr(1:3, offseth + jj) &
3747 + rion_num*sum_expfac_noh*dexpfac_f(ii)*df(ii) &
3748 *dnoh(1:3, jj, ii)/(rion_den**2)
3752 DEALLOCATE (noh, m, f, expfac_noh, expfac_f)
3753 DEALLOCATE (dnoh, dm, df, dexpfac_noh, dexpfac_f)
3754 DEALLOCATE (ddist_rki, expfac_f_rki, dexpfac_f_rki)
3756 END SUBROUTINE hydronium_dist_colvar
3769 SUBROUTINE acid_hyd_dist_colvar(colvar, cell, subsys, particles)
3774 POINTER :: particles
3776 INTEGER :: i, ii, j, jj, k, kk, n_hydrogens, &
3777 n_oxygens_acid, n_oxygens_water, &
3778 offseth, offseto, paoh, pcut, pwoh, &
3780 REAL(
dp),
ALLOCATABLE,
DIMENSION(:) :: dexpfac, expfac, nwoh
3781 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: dexpfac_rik
3782 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: ddist_rik, dnaoh, dnwoh
3783 REAL(kind=
dp) :: dfcut, drik, drji, drjk, fbrace, fcut, fscalar, invden, invden_cut, lambda, &
3784 naoh, nc, num, num_cut, raoh, rik(3), rion, rion_den, rion_num, rji(3), rjk(3), rpi(3), &
3785 rpj(3), rpk(3), rrel, rwoh
3789 NULLIFY (my_particles, particles_i)
3791 n_oxygens_water = colvar%acid_hyd_dist_param%n_oxygens_water
3792 n_oxygens_acid = colvar%acid_hyd_dist_param%n_oxygens_acid
3793 n_hydrogens = colvar%acid_hyd_dist_param%n_hydrogens
3794 pwoh = colvar%acid_hyd_dist_param%pwoh
3795 qwoh = colvar%acid_hyd_dist_param%qwoh
3796 paoh = colvar%acid_hyd_dist_param%paoh
3797 qaoh = colvar%acid_hyd_dist_param%qaoh
3798 pcut = colvar%acid_hyd_dist_param%pcut
3799 qcut = colvar%acid_hyd_dist_param%qcut
3800 rwoh = colvar%acid_hyd_dist_param%rwoh
3801 raoh = colvar%acid_hyd_dist_param%raoh
3802 nc = colvar%acid_hyd_dist_param%nc
3803 lambda = colvar%acid_hyd_dist_param%lambda
3804 ALLOCATE (expfac(n_oxygens_water))
3805 ALLOCATE (nwoh(n_oxygens_water))
3806 ALLOCATE (dnwoh(3, n_hydrogens, n_oxygens_water))
3807 ALLOCATE (dnaoh(3, n_hydrogens, n_oxygens_acid))
3808 ALLOCATE (dexpfac(n_oxygens_water))
3809 ALLOCATE (ddist_rik(3, n_oxygens_water, n_oxygens_acid))
3810 ALLOCATE (dexpfac_rik(n_oxygens_water, n_oxygens_acid))
3815 dnaoh(:, :, :) = 0._dp
3816 dnwoh(:, :, :) = 0._dp
3817 ddist_rik(:, :, :) = 0._dp
3819 dexpfac_rik(:, :) = 0._dp
3822 IF (
PRESENT(particles))
THEN
3823 my_particles => particles
3825 cpassert(
PRESENT(subsys))
3827 my_particles => particles_i%els
3831 DO ii = 1, n_oxygens_water
3832 i = colvar%acid_hyd_dist_param%i_oxygens_water(ii)
3833 rpi(:) = my_particles(i)%r(1:3)
3834 DO jj = 1, n_hydrogens
3835 j = colvar%acid_hyd_dist_param%i_hydrogens(jj)
3836 rpj(:) = my_particles(j)%r(1:3)
3837 rji =
pbc(rpj, rpi, cell)
3838 drji = sqrt(sum(rji**2))
3840 num = 1.0_dp - rrel**pwoh
3841 invden = 1.0_dp/(1.0_dp - rrel**qwoh)
3842 IF (abs(1.0_dp - rrel) > 1.0e-6_dp)
THEN
3843 nwoh(ii) = nwoh(ii) + num*invden
3844 fscalar = (-pwoh*(rrel**(pwoh - 1))*invden &
3845 + num*(invden**2)*qwoh*(rrel**(qwoh - 1)))/(drji*rwoh)
3846 dnwoh(1:3, jj, ii) = rji(1:3)*fscalar
3849 nwoh(ii) = nwoh(ii) + real(pwoh,
dp)/real(qwoh,
dp)
3850 fscalar = real(pwoh*(pwoh - qwoh),
dp)/(real(2*qwoh,
dp)*rwoh*drji)
3851 dnwoh(1:3, jj, ii) = rji(1:3)*fscalar
3854 expfac(ii) = exp(lambda*nwoh(ii))
3855 dexpfac(ii) = lambda*expfac(ii)
3856 rion_den = rion_den + expfac(ii)
3860 DO kk = 1, n_oxygens_acid
3861 k = colvar%acid_hyd_dist_param%i_oxygens_acid(kk)
3862 rpk(:) = my_particles(k)%r(1:3)
3863 DO ii = 1, n_oxygens_water
3864 i = colvar%acid_hyd_dist_param%i_oxygens_water(ii)
3865 rpi(:) = my_particles(i)%r(1:3)
3866 rik =
pbc(rpi, rpk, cell)
3867 drik = sqrt(sum(rik**2))
3868 rion_num = rion_num + drik*expfac(ii)
3869 ddist_rik(1:3, ii, kk) = rik(1:3)/drik
3870 dexpfac_rik(ii, kk) = drik*dexpfac(ii)
3875 DO kk = 1, n_oxygens_acid
3876 k = colvar%acid_hyd_dist_param%i_oxygens_acid(kk)
3877 rpk(:) = my_particles(k)%r(1:3)
3878 DO jj = 1, n_hydrogens
3879 j = colvar%acid_hyd_dist_param%i_hydrogens(jj)
3880 rpj(:) = my_particles(j)%r(1:3)
3881 rjk =
pbc(rpj, rpk, cell)
3882 drjk = sqrt(sum(rjk**2))
3884 num = 1.0_dp - rrel**paoh
3885 invden = 1.0_dp/(1.0_dp - rrel**qaoh)
3886 IF (abs(1.0_dp - rrel) > 1.0e-6_dp)
THEN
3887 naoh = naoh + num*invden
3888 fscalar = (-paoh*(rrel**(paoh - 1))*invden &
3889 + num*(invden**2)*qaoh*(rrel**(qaoh - 1)))/(drjk*raoh)
3890 dnaoh(1:3, jj, kk) = rjk(1:3)*fscalar
3893 naoh = naoh + real(paoh,
dp)/real(qaoh,
dp)
3894 fscalar = real(paoh*(paoh - qaoh),
dp)/(real(2*qaoh,
dp)*raoh*drjk)
3895 dnaoh(1:3, jj, kk) = rjk(1:3)*fscalar
3899 num_cut = 1.0_dp - (naoh/nc)**pcut
3900 invden_cut = 1.0_dp/(1.0_dp - (naoh/nc)**qcut)
3901 fcut = num_cut*invden_cut
3905 fbrace = rion_num/rion_den/n_oxygens_acid
3910 dfcut = ((-pcut*(naoh/nc)**(pcut - 1)*invden_cut) &
3911 + num_cut*(invden_cut**2)*qcut*(naoh/nc)**(qcut - 1))/nc
3912 offseto = n_oxygens_water
3913 offseth = n_oxygens_water + n_oxygens_acid
3914 DO kk = 1, n_oxygens_acid
3915 DO jj = 1, n_hydrogens
3916 colvar%dsdr(1:3, offseto + kk) = colvar%dsdr(1:3, offseto + kk) &
3917 + dfcut*dnaoh(1:3, jj, kk)*fbrace
3918 colvar%dsdr(1:3, offseth + jj) = colvar%dsdr(1:3, offseth + jj) &
3919 - dfcut*dnaoh(1:3, jj, kk)*fbrace
3925 DO kk = 1, n_oxygens_acid
3926 DO ii = 1, n_oxygens_water
3927 colvar%dsdr(1:3, offseto + kk) = colvar%dsdr(1:3, offseto + kk) &
3928 + fcut*ddist_rik(1:3, ii, kk)*expfac(ii)/rion_den/n_oxygens_acid
3930 colvar%dsdr(1:3, ii) = colvar%dsdr(1:3, ii) &
3931 - fcut*ddist_rik(1:3, ii, kk)*expfac(ii)/rion_den/n_oxygens_acid
3933 DO jj = 1, n_hydrogens
3934 colvar%dsdr(1:3, ii) = colvar%dsdr(1:3, ii) &
3935 + fcut*dexpfac_rik(ii, kk)*dnwoh(1:3, jj, ii)/rion_den/n_oxygens_acid
3937 colvar%dsdr(1:3, offseth + jj) = colvar%dsdr(1:3, offseth + jj) &
3938 - fcut*dexpfac_rik(ii, kk)*dnwoh(1:3, jj, ii)/rion_den/n_oxygens_acid
3944 DO ii = 1, n_oxygens_water
3945 DO jj = 1, n_hydrogens
3946 colvar%dsdr(1:3, ii) = colvar%dsdr(1:3, ii) &
3947 - fcut*rion_num*dexpfac(ii)*dnwoh(1:3, jj, ii)/2.0_dp/(rion_den**2)
3948 colvar%dsdr(1:3, offseth + jj) = colvar%dsdr(1:3, offseth + jj) &
3949 + fcut*rion_num*dexpfac(ii)*dnwoh(1:3, jj, ii)/2.0_dp/(rion_den**2)
3953 END SUBROUTINE acid_hyd_dist_colvar
3966 SUBROUTINE acid_hyd_shell_colvar(colvar, cell, subsys, particles)
3971 POINTER :: particles
3973 INTEGER :: i, ii, j, jj, k, kk, n_hydrogens, n_oxygens_acid, n_oxygens_water, offseth, &
3974 offseto, paoh, pcut, pm, poo, pwoh, qaoh, qcut, qm, qoo, qwoh, tt
3975 REAL(
dp),
ALLOCATABLE,
DIMENSION(:) :: dm, m, noo, nwoh, qloc
3976 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: dnaoh, dnoo, dnwoh
3977 REAL(kind=
dp) :: dfcut, drji, drjk, drki, fcut, fscalar, invden, invden_cut, lambda, naoh, &
3978 nc, nh, num, num_cut, qsol, qtot, raoh, rji(3), rjk(3), rki(3), roo, rpi(3), rpj(3), &
3983 NULLIFY (my_particles, particles_i)
3985 n_oxygens_water = colvar%acid_hyd_shell_param%n_oxygens_water
3986 n_oxygens_acid = colvar%acid_hyd_shell_param%n_oxygens_acid
3987 n_hydrogens = colvar%acid_hyd_shell_param%n_hydrogens
3988 pwoh = colvar%acid_hyd_shell_param%pwoh
3989 qwoh = colvar%acid_hyd_shell_param%qwoh
3990 paoh = colvar%acid_hyd_shell_param%paoh
3991 qaoh = colvar%acid_hyd_shell_param%qaoh
3992 poo = colvar%acid_hyd_shell_param%poo
3993 qoo = colvar%acid_hyd_shell_param%qoo
3994 pm = colvar%acid_hyd_shell_param%pm
3995 qm = colvar%acid_hyd_shell_param%qm
3996 pcut = colvar%acid_hyd_shell_param%pcut
3997 qcut = colvar%acid_hyd_shell_param%qcut
3998 rwoh = colvar%acid_hyd_shell_param%rwoh
3999 raoh = colvar%acid_hyd_shell_param%raoh
4000 roo = colvar%acid_hyd_shell_param%roo
4001 nc = colvar%acid_hyd_shell_param%nc
4002 nh = colvar%acid_hyd_shell_param%nh
4003 lambda = colvar%acid_hyd_shell_param%lambda
4004 ALLOCATE (nwoh(n_oxygens_water))
4005 ALLOCATE (dnwoh(3, n_hydrogens, n_oxygens_water))
4006 ALLOCATE (dnaoh(3, n_hydrogens, n_oxygens_acid))
4007 ALLOCATE (m(n_oxygens_water))
4008 ALLOCATE (dm(n_oxygens_water))
4009 ALLOCATE (noo(n_oxygens_water))
4010 ALLOCATE (dnoo(3, n_oxygens_water + n_oxygens_acid, n_oxygens_water))
4011 ALLOCATE (qloc(n_oxygens_water))
4015 dnaoh(:, :, :) = 0._dp
4016 dnwoh(:, :, :) = 0._dp
4017 dnoo(:, :, :) = 0._dp
4023 IF (
PRESENT(particles))
THEN
4024 my_particles => particles
4026 cpassert(
PRESENT(subsys))
4028 my_particles => particles_i%els
4032 DO ii = 1, n_oxygens_water
4033 i = colvar%acid_hyd_shell_param%i_oxygens_water(ii)
4034 rpi(:) = my_particles(i)%r(1:3)
4035 DO jj = 1, n_hydrogens
4036 j = colvar%acid_hyd_shell_param%i_hydrogens(jj)
4037 rpj(:) = my_particles(j)%r(1:3)
4038 rji =
pbc(rpj, rpi, cell)
4039 drji = sqrt(sum(rji**2))
4041 num = 1.0_dp - rrel**pwoh
4042 invden = 1.0_dp/(1.0_dp - rrel**qwoh)
4043 IF (abs(1.0_dp - rrel) > 1.0e-6_dp)
THEN
4044 nwoh(ii) = nwoh(ii) + num*invden
4045 fscalar = (-pwoh*(rrel**(pwoh - 1))*invden &
4046 + num*(invden**2)*qwoh*(rrel**(qwoh - 1)))/(drji*rwoh)
4047 dnwoh(1:3, jj, ii) = rji(1:3)*fscalar
4050 nwoh(ii) = nwoh(ii) + real(pwoh,
dp)/real(qwoh,
dp)
4051 fscalar = real(pwoh*(pwoh - qwoh),
dp)/(real(2*qwoh,
dp)*rwoh*drji)
4052 dnwoh(1:3, jj, ii) = rji(1:3)*fscalar
4058 DO ii = 1, n_oxygens_water
4059 num = 1.0_dp - (nwoh(ii)/nh)**pm
4060 invden = 1.0_dp/(1.0_dp - (nwoh(ii)/nh)**qm)
4061 m(ii) = 1.0_dp - num*invden
4062 dm(ii) = (pm*(nwoh(ii)/nh)**(pm - 1)*invden - qm*num*(invden**2)* &
4063 (nwoh(ii)/nh)**(qm - 1))/nh
4067 DO ii = 1, n_oxygens_water
4068 i = colvar%acid_hyd_shell_param%i_oxygens_water(ii)
4069 rpi(:) = my_particles(i)%r(1:3)
4070 DO kk = 1, n_oxygens_water + n_oxygens_acid
4072 IF (kk <= n_oxygens_water)
THEN
4073 k = colvar%acid_hyd_shell_param%i_oxygens_water(kk)
4074 rpk(:) = my_particles(k)%r(1:3)
4076 tt = kk - n_oxygens_water
4077 k = colvar%acid_hyd_shell_param%i_oxygens_acid(tt)
4078 rpk(:) = my_particles(k)%r(1:3)
4080 rki =
pbc(rpk, rpi, cell)
4081 drki = sqrt(sum(rki**2))
4083 num = 1.0_dp - rrel**poo
4084 invden = 1.0_dp/(1.0_dp - rrel**qoo)
4085 IF (abs(1.0_dp - rrel) > 1.0e-6_dp)
THEN
4086 noo(ii) = noo(ii) + num*invden
4087 fscalar = (-poo*(rrel**(poo - 1))*invden &
4088 + num*(invden**2)*qoo*(rrel**(qoo - 1)))/(drki*roo)
4089 dnoo(1:3, kk, ii) = rki(1:3)*fscalar
4092 noo(ii) = noo(ii) + real(poo,
dp)/real(qoo,
dp)
4093 fscalar = real(poo*(poo - qoo),
dp)/(real(2*qoo,
dp)*roo*drki)
4094 dnoo(1:3, kk, ii) = rki(1:3)*fscalar
4100 DO kk = 1, n_oxygens_acid
4101 k = colvar%acid_hyd_shell_param%i_oxygens_acid(kk)
4102 rpk(:) = my_particles(k)%r(1:3)
4103 DO jj = 1, n_hydrogens
4104 j = colvar%acid_hyd_shell_param%i_hydrogens(jj)
4105 rpj(:) = my_particles(j)%r(1:3)
4106 rjk =
pbc(rpj, rpk, cell)
4107 drjk = sqrt(sum(rjk**2))
4109 num = 1.0_dp - rrel**paoh
4110 invden = 1.0_dp/(1.0_dp - rrel**qaoh)
4111 IF (abs(1.0_dp - rrel) > 1.0e-6_dp)
THEN
4112 naoh = naoh + num*invden
4113 fscalar = (-paoh*(rrel**(paoh - 1))*invden &
4114 + num*(invden**2)*qaoh*(rrel**(qaoh - 1)))/(drjk*raoh)
4115 dnaoh(1:3, jj, kk) = rjk(1:3)*fscalar
4118 naoh = naoh + real(paoh,
dp)/real(qaoh,
dp)
4119 fscalar = real(paoh*(paoh - qaoh),
dp)/(real(2*qaoh,
dp)*raoh*drjk)
4120 dnaoh(1:3, jj, kk) = rjk(1:3)*fscalar
4124 num_cut = 1.0_dp - (naoh/nc)**pcut
4125 invden_cut = 1.0_dp/(1.0_dp - (naoh/nc)**qcut)
4126 fcut = num_cut*invden_cut
4129 DO ii = 1, n_oxygens_water
4130 qloc(ii) = exp(lambda*m(ii)*noo(ii))
4131 qtot = qtot + qloc(ii)
4133 qsol = log(qtot)/lambda
4134 colvar%ss = fcut*qsol
4137 dfcut = ((-pcut*(naoh/nc)**(pcut - 1)*invden_cut) &
4138 + num_cut*(invden_cut**2)*qcut*(naoh/nc)**(qcut - 1))/nc
4139 offseto = n_oxygens_water
4140 offseth = n_oxygens_water + n_oxygens_acid
4141 DO kk = 1, n_oxygens_acid
4142 DO jj = 1, n_hydrogens
4143 colvar%dsdr(1:3, offseto + kk) = colvar%dsdr(1:3, offseto + kk) &
4144 + dfcut*dnaoh(1:3, jj, kk)*qsol
4145 colvar%dsdr(1:3, offseth + jj) = colvar%dsdr(1:3, offseth + jj) &
4146 - dfcut*dnaoh(1:3, jj, kk)*qsol
4152 DO ii = 1, n_oxygens_water
4153 fscalar = fcut*qloc(ii)*dm(ii)*noo(ii)/qtot
4154 DO jj = 1, n_hydrogens
4155 colvar%dsdr(1:3, ii) = colvar%dsdr(1:3, ii) &
4156 + fscalar*dnwoh(1:3, jj, ii)
4157 colvar%dsdr(1:3, offseth + jj) = colvar%dsdr(1:3, offseth + jj) &
4158 - fscalar*dnwoh(1:3, jj, ii)
4162 DO ii = 1, n_oxygens_water
4163 fscalar = fcut*qloc(ii)*m(ii)/qtot
4164 DO kk = 1, n_oxygens_water + n_oxygens_acid
4166 colvar%dsdr(1:3, ii) = colvar%dsdr(1:3, ii) + fscalar*dnoo(1:3, kk, ii)
4167 colvar%dsdr(1:3, kk) = colvar%dsdr(1:3, kk) - fscalar*dnoo(1:3, kk, ii)
4171 END SUBROUTINE acid_hyd_shell_colvar
4183 SUBROUTINE coord_colvar(colvar, cell, subsys, particles)
4188 POINTER :: particles
4190 INTEGER :: i, ii, j, jj, k, kk, n_atoms_from, &
4191 n_atoms_to_a, n_atoms_to_b, p_a, p_b, &
4193 REAL(
dp) :: dfunc_ij, dfunc_jk, func_ij, func_jk, func_k, inv_n_atoms_from, invden_ij, &
4194 invden_jk, ncoord, num_ij, num_jk, r_0_a, r_0_b, rdist_ij, rdist_jk, rij, rjk
4195 REAL(
dp),
DIMENSION(3) :: ftmp_i, ftmp_j, ftmp_k, ss, xij, xjk, &
4203 NULLIFY (particles_i)
4205 IF (
PRESENT(particles))
THEN
4206 my_particles => particles
4208 cpassert(
PRESENT(subsys))
4210 my_particles => particles_i%els
4212 n_atoms_to_a = colvar%coord_param%n_atoms_to
4213 n_atoms_to_b = colvar%coord_param%n_atoms_to_b
4214 n_atoms_from = colvar%coord_param%n_atoms_from
4215 p_a = colvar%coord_param%nncrd
4216 q_a = colvar%coord_param%ndcrd
4217 r_0_a = colvar%coord_param%r_0
4218 p_b = colvar%coord_param%nncrd_b
4219 q_b = colvar%coord_param%ndcrd_b
4220 r_0_b = colvar%coord_param%r_0_b
4223 inv_n_atoms_from = 1.0_dp/real(n_atoms_from, kind=
dp)
4224 DO ii = 1, n_atoms_from
4225 i = colvar%coord_param%i_at_from(ii)
4226 CALL get_coordinates(colvar, i, xpi, my_particles)
4227 DO jj = 1, n_atoms_to_a
4228 j = colvar%coord_param%i_at_to(jj)
4229 CALL get_coordinates(colvar, j, xpj, my_particles)
4232 ss = matmul(cell%h_inv, xpi(:) - xpj(:))
4234 xij = matmul(cell%hmat, ss)
4235 rij = sqrt(xij(1)**2 + xij(2)**2 + xij(3)**2)
4236 IF (rij < 1.0e-8_dp) cycle
4237 rdist_ij = rij/r_0_a
4238 IF (abs(1.0_dp - rdist_ij) > epsilon(0.0_dp)*1.0e+4_dp)
THEN
4239 num_ij = (1.0_dp - rdist_ij**p_a)
4240 invden_ij = 1.0_dp/(1.0_dp - rdist_ij**q_a)
4241 func_ij = num_ij*invden_ij
4242 IF (rij < 1.0e-8_dp)
THEN
4246 dfunc_ij = (-p_a*rdist_ij**(p_a - 1)*invden_ij &
4247 + num_ij*(invden_ij)**2*q_a*rdist_ij**(q_a - 1))/(rij*r_0_a)
4251 func_ij = real(p_a, kind=
dp)/real(q_a, kind=
dp)
4252 dfunc_ij = real(p_a, kind=
dp)*real((-q_a + p_a), kind=
dp)/(real(2*q_a, kind=
dp)*r_0_a)
4254 IF (n_atoms_to_b /= 0)
THEN
4256 DO kk = 1, n_atoms_to_b
4257 k = colvar%coord_param%i_at_to_b(kk)
4259 CALL get_coordinates(colvar, k, xpk, my_particles)
4260 ss = matmul(cell%h_inv, xpj(:) - xpk(:))
4262 xjk = matmul(cell%hmat, ss)
4263 rjk = sqrt(xjk(1)**2 + xjk(2)**2 + xjk(3)**2)
4264 IF (rjk < 1.0e-8_dp) cycle
4265 rdist_jk = rjk/r_0_b
4266 IF (abs(1.0_dp - rdist_jk) > epsilon(0.0_dp)*1.0e+4_dp)
THEN
4267 num_jk = (1.0_dp - rdist_jk**p_b)
4268 invden_jk = 1.0_dp/(1.0_dp - rdist_jk**q_b)
4269 func_jk = num_jk*invden_jk
4270 IF (rjk < 1.0e-8_dp)
THEN
4274 dfunc_jk = (-p_b*rdist_jk**(p_b - 1)*invden_jk &
4275 + num_jk*(invden_jk)**2*q_b*rdist_jk**(q_b - 1))/(rjk*r_0_b)
4279 func_jk = real(p_b, kind=
dp)/real(q_b, kind=
dp)
4280 dfunc_jk = real(p_b, kind=
dp)*real((-q_b + p_b), kind=
dp)/(real(2*q_b, kind=
dp)*r_0_b)
4282 func_k = func_k + func_jk
4283 ftmp_k = -func_ij*dfunc_jk*xjk
4284 CALL put_derivative(colvar, n_atoms_from + n_atoms_to_a + kk, ftmp_k)
4286 ftmp_j = -dfunc_ij*xij*func_jk + func_ij*dfunc_jk*xjk
4287 CALL put_derivative(colvar, n_atoms_from + jj, ftmp_j)
4292 ftmp_j = -dfunc_ij*xij
4293 CALL put_derivative(colvar, n_atoms_from + jj, ftmp_j)
4295 ncoord = ncoord + func_ij*func_k
4296 ftmp_i = dfunc_ij*xij*func_k
4297 CALL put_derivative(colvar, ii, ftmp_i)
4300 colvar%ss = ncoord*inv_n_atoms_from
4301 colvar%dsdr(:, :) = colvar%dsdr(:, :)*inv_n_atoms_from
4302 END SUBROUTINE coord_colvar
4311 SUBROUTINE mindist_colvar(colvar, cell, subsys, particles)
4317 POINTER :: particles
4319 INTEGER :: i, ii, j, jj, n_coord_from, n_coord_to, &
4321 REAL(
dp) :: den_n, den_q, fscalar, ftemp_i(3), inv_den_n, inv_den_q, lambda, num_n, num_q, &
4322 qfunc, r12, r_cut, rfact, rij(3), rpi(3), rpj(3)
4323 REAL(
dp),
DIMENSION(:),
POINTER :: dqfunc_dnl, expnl, nlcoord, sum_rij
4324 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: dnlcoord, dqfunc_dr
4331 NULLIFY (particles_i)
4333 IF (
PRESENT(particles))
THEN
4334 my_particles => particles
4336 cpassert(
PRESENT(subsys))
4338 my_particles => particles_i%els
4341 n_dist_from = colvar%mindist_param%n_dist_from
4342 n_coord_from = colvar%mindist_param%n_coord_from
4343 n_coord_to = colvar%mindist_param%n_coord_to
4344 p = colvar%mindist_param%p_exp
4345 q = colvar%mindist_param%q_exp
4346 r_cut = colvar%mindist_param%r_cut
4347 lambda = colvar%mindist_param%lambda
4349 NULLIFY (nlcoord, dnlcoord, dqfunc_dr, dqfunc_dnl, expnl, sum_rij)
4350 ALLOCATE (nlcoord(n_coord_from))
4351 ALLOCATE (dnlcoord(3, n_coord_from, n_coord_to))
4352 ALLOCATE (expnl(n_coord_from))
4353 ALLOCATE (sum_rij(n_coord_from))
4354 ALLOCATE (dqfunc_dr(3, n_dist_from, n_coord_from))
4355 ALLOCATE (dqfunc_dnl(n_coord_from))
4362 DO i = 1, n_coord_from
4363 ii = colvar%mindist_param%i_coord_from(i)
4364 rpi = my_particles(ii)%r(1:3)
4365 DO j = 1, n_coord_to
4366 jj = colvar%mindist_param%i_coord_to(j)
4367 rpj = my_particles(jj)%r(1:3)
4368 rij =
pbc(rpj, rpi, cell)
4369 r12 = sqrt(rij(1)*rij(1) + rij(2)*rij(2) + rij(3)*rij(3))
4371 num_n = 1.0_dp - rfact**p
4372 den_n = 1.0_dp - rfact**q
4373 inv_den_n = 1.0_dp/den_n
4374 IF (abs(inv_den_n) < 1.e-10_dp)
THEN
4375 inv_den_n = 1.e-10_dp
4379 fscalar = (-p*rfact**(p - 1) + num_n*q*rfact**(q - 1)*inv_den_n)*inv_den_n/(r_cut*r12)
4381 dnlcoord(1, i, j) = rij(1)*fscalar
4382 dnlcoord(2, i, j) = rij(2)*fscalar
4383 dnlcoord(3, i, j) = rij(3)*fscalar
4385 nlcoord(i) = nlcoord(i) + num_n*inv_den_n
4387 expnl(i) = exp(lambda*nlcoord(i))
4388 den_q = den_q + expnl(i)
4390 inv_den_q = 1.0_dp/den_q
4397 DO i = 1, n_dist_from
4398 ii = colvar%mindist_param%i_dist_from(i)
4399 rpi = my_particles(ii)%r(1:3)
4400 DO j = 1, n_coord_from
4401 jj = colvar%mindist_param%i_coord_from(j)
4402 rpj = my_particles(jj)%r(1:3)
4403 rij =
pbc(rpj, rpi, cell)
4404 r12 = sqrt(rij(1)*rij(1) + rij(2)*rij(2) + rij(3)*rij(3))
4406 num_q = num_q + r12*expnl(j)
4408 sum_rij(j) = sum_rij(j) + r12
4409 dqfunc_dr(1, i, j) = expnl(j)*rij(1)/r12
4410 dqfunc_dr(2, i, j) = expnl(j)*rij(2)/r12
4411 dqfunc_dr(3, i, j) = expnl(j)*rij(3)/r12
4418 qfunc = num_q*inv_den_q
4419 dqfunc_dr = dqfunc_dr*inv_den_q
4422 DO i = 1, n_coord_from
4423 dqfunc_dnl(i) = lambda*expnl(i)*inv_den_q*(sum_rij(i) - num_q*inv_den_q)
4427 DO i = 1, n_dist_from
4428 DO j = 1, n_coord_from
4429 ftemp_i(1) = dqfunc_dr(1, i, j)
4430 ftemp_i(2) = dqfunc_dr(2, i, j)
4431 ftemp_i(3) = dqfunc_dr(3, i, j)
4433 CALL put_derivative(colvar, i, ftemp_i)
4434 CALL put_derivative(colvar, j + n_dist_from, -ftemp_i)
4438 DO i = 1, n_coord_from
4439 DO j = 1, n_coord_to
4440 ftemp_i(1) = dqfunc_dnl(i)*dnlcoord(1, i, j)
4441 ftemp_i(2) = dqfunc_dnl(i)*dnlcoord(2, i, j)
4442 ftemp_i(3) = dqfunc_dnl(i)*dnlcoord(3, i, j)
4444 CALL put_derivative(colvar, i + n_dist_from, ftemp_i)
4445 CALL put_derivative(colvar, j + n_dist_from + n_coord_from, -ftemp_i)
4450 DEALLOCATE (nlcoord)
4451 DEALLOCATE (dnlcoord)
4453 DEALLOCATE (dqfunc_dr)
4454 DEALLOCATE (sum_rij)
4455 DEALLOCATE (dqfunc_dnl)
4457 END SUBROUTINE mindist_colvar
4467 SUBROUTINE combine_colvar(colvar, cell, subsys, particles)
4472 POINTER :: particles
4474 CHARACTER(LEN=default_string_length) :: def_error, this_error
4475 CHARACTER(LEN=default_string_length), &
4476 ALLOCATABLE,
DIMENSION(:) :: my_par
4477 INTEGER :: i, ii, j, ncolv, ndim
4479 REAL(
dp),
ALLOCATABLE,
DIMENSION(:) :: dss_vals, my_val, ss_vals
4480 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: fi
4485 IF (
PRESENT(particles))
THEN
4486 my_particles => particles
4488 cpassert(
PRESENT(subsys))
4490 my_particles => particles_i%els
4493 ncolv =
SIZE(colvar%combine_cvs_param%colvar_p)
4494 ALLOCATE (ss_vals(ncolv))
4495 ALLOCATE (dss_vals(ncolv))
4499 CALL colvar_recursive_eval(colvar%combine_cvs_param%colvar_p(i)%colvar, cell, my_particles)
4500 ss_vals(i) = colvar%combine_cvs_param%colvar_p(i)%colvar%ss
4505 ndim =
SIZE(colvar%combine_cvs_param%c_parameters) + &
4506 SIZE(colvar%combine_cvs_param%variables)
4507 ALLOCATE (my_par(ndim))
4508 my_par(1:
SIZE(colvar%combine_cvs_param%variables)) = colvar%combine_cvs_param%variables
4509 my_par(
SIZE(colvar%combine_cvs_param%variables) + 1:) = colvar%combine_cvs_param%c_parameters
4510 ALLOCATE (my_val(ndim))
4511 my_val(1:
SIZE(colvar%combine_cvs_param%variables)) = ss_vals
4512 my_val(
SIZE(colvar%combine_cvs_param%variables) + 1:) = colvar%combine_cvs_param%v_parameters
4513 CALL parsef(1, trim(colvar%combine_cvs_param%function), my_par)
4514 colvar%ss =
evalf(1, my_val)
4516 dss_vals(i) =
evalfd(1, i, my_val, colvar%combine_cvs_param%dx, err)
4517 IF ((abs(err) > colvar%combine_cvs_param%lerr))
THEN
4518 WRITE (this_error,
"(A,G12.6,A)")
"(", err,
")"
4519 WRITE (def_error,
"(A,G12.6,A)")
"(", colvar%combine_cvs_param%lerr,
")"
4522 CALL cp_warn(__location__, &
4523 'ASSERTION (cond) failed at line '//
cp_to_string(__line__)// &
4524 ' Error '//trim(this_error)//
' in computing numerical derivatives larger then'// &
4525 trim(def_error)//
' . ')
4533 ALLOCATE (fi(3, colvar%n_atom_s))
4536 DO j = 1, colvar%combine_cvs_param%colvar_p(i)%colvar%n_atom_s
4538 fi(:, ii) = colvar%combine_cvs_param%colvar_p(i)%colvar%dsdr(:, j)*dss_vals(i)
4542 DO i = 1, colvar%n_atom_s
4543 CALL put_derivative(colvar, i, fi(:, i))
4547 DEALLOCATE (ss_vals)
4548 DEALLOCATE (dss_vals)
4549 END SUBROUTINE combine_colvar
4565 SUBROUTINE reaction_path_colvar(colvar, cell, subsys, particles)
4570 POINTER :: particles
4576 IF (
PRESENT(particles))
THEN
4577 my_particles => particles
4579 cpassert(
PRESENT(subsys))
4581 my_particles => particles_i%els
4584 IF (colvar%reaction_path_param%dist_rmsd)
THEN
4585 CALL rpath_dist_rmsd(colvar, my_particles)
4586 ELSE IF (colvar%reaction_path_param%rmsd)
THEN
4587 CALL rpath_rmsd(colvar, my_particles)
4589 CALL rpath_colvar(colvar, cell, my_particles)
4592 END SUBROUTINE reaction_path_colvar
4603 SUBROUTINE rpath_colvar(colvar, cell, particles)
4608 INTEGER :: i, iend, ii, istart, j, k, ncolv, nconf
4609 REAL(
dp) :: lambda, step_size
4610 REAL(
dp),
ALLOCATABLE,
DIMENSION(:) :: s1, ss_vals
4611 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: ds1, f_vals, fi, s1v
4612 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: ds1v
4614 istart = colvar%reaction_path_param%function_bounds(1)
4615 iend = colvar%reaction_path_param%function_bounds(2)
4617 nconf = colvar%reaction_path_param%nr_frames
4618 step_size = colvar%reaction_path_param%step_size
4619 ncolv = colvar%reaction_path_param%n_components
4620 lambda = colvar%reaction_path_param%lambda
4621 ALLOCATE (f_vals(ncolv, istart:iend))
4622 f_vals(:, :) = colvar%reaction_path_param%f_vals
4623 ALLOCATE (ss_vals(ncolv))
4626 CALL colvar_recursive_eval(colvar%reaction_path_param%colvar_p(i)%colvar, cell, particles)
4627 ss_vals(i) = colvar%reaction_path_param%colvar_p(i)%colvar%ss
4630 ALLOCATE (s1v(2, istart:iend))
4631 ALLOCATE (ds1v(ncolv, 2, istart:iend))
4634 ALLOCATE (ds1(ncolv, 2))
4637 s1v(1, k) = real(k, kind=
dp)*step_size*exp(-lambda*dot_product(ss_vals(:) - f_vals(:, k), ss_vals(:) - f_vals(:, k)))
4638 s1v(2, k) = exp(-lambda*dot_product(ss_vals(:) - f_vals(:, k), ss_vals(:) - f_vals(:, k)))
4640 ds1v(j, 1, k) = f_vals(j, k)*s1v(1, k)
4641 ds1v(j, 2, k) = f_vals(j, k)*s1v(2, k)
4651 colvar%ss = s1(1)/s1(2)/real(nconf - 1,
dp)
4653 ALLOCATE (fi(3, colvar%n_atom_s))
4657 DO j = 1, colvar%reaction_path_param%colvar_p(i)%colvar%n_atom_s
4659 fi(:, ii) = colvar%reaction_path_param%colvar_p(i)%colvar%dsdr(:, j)*lambda* &
4660 (ds1(i, 1)/s1(2)/real(nconf - 1,
dp) - colvar%ss*ds1(i, 2)/s1(2))*2.0_dp
4664 DO i = 1, colvar%n_atom_s
4665 CALL put_derivative(colvar, i, fi(:, i))
4670 DEALLOCATE (ss_vals)
4676 END SUBROUTINE rpath_colvar
4687 SUBROUTINE rpath_dist_rmsd(colvar, particles)
4691 INTEGER :: i, iat, ii, ik, natom, nconf, rmsd_atom
4692 INTEGER,
DIMENSION(:),
POINTER :: iatom
4693 REAL(
dp) :: lambda, my_rmsd, s1(2), sum_exp
4694 REAL(
dp),
ALLOCATABLE,
DIMENSION(:) :: r, r0, vec_dif
4695 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: dvec_dif, fi, riat, s1v
4696 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: ds1
4697 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :, :, :) :: ds1v
4698 REAL(
dp),
DIMENSION(:, :),
POINTER :: path_conf
4700 nconf = colvar%reaction_path_param%nr_frames
4701 rmsd_atom = colvar%reaction_path_param%n_components
4702 lambda = colvar%reaction_path_param%lambda
4703 path_conf => colvar%reaction_path_param%r_ref
4704 iatom => colvar%reaction_path_param%i_rmsd
4706 natom =
SIZE(particles)
4708 ALLOCATE (r0(3*natom))
4709 ALLOCATE (r(3*natom))
4710 ALLOCATE (riat(3, rmsd_atom))
4711 ALLOCATE (vec_dif(rmsd_atom))
4712 ALLOCATE (dvec_dif(3, rmsd_atom))
4713 ALLOCATE (s1v(2, nconf))
4714 ALLOCATE (ds1v(3, rmsd_atom, 2, nconf))
4715 ALLOCATE (ds1(3, rmsd_atom, 2))
4718 r0(ii + 1) = particles(i)%r(1)
4719 r0(ii + 2) = particles(i)%r(2)
4720 r0(ii + 3) = particles(i)%r(3)
4723 DO iat = 1, rmsd_atom
4725 riat(:, iat) = particles(ii)%r
4731 r(ii + 1) = path_conf(ii + 1, ik)
4732 r(ii + 2) = path_conf(ii + 2, ik)
4733 r(ii + 3) = path_conf(ii + 3, ik)
4736 CALL rmsd3(particles, r, r0, output_unit=-1, my_val=my_rmsd, rotate=.true.)
4739 DO iat = 1, rmsd_atom
4742 vec_dif(iat) = (riat(1, iat) - r(ii + 1))**2 + (riat(2, iat) - r(ii + 2))**2 &
4743 + (riat(3, iat) - r(ii + 3))**2
4744 sum_exp = sum_exp + vec_dif(iat)
4747 s1v(1, ik) = real(ik - 1,
dp)*exp(-lambda*sum_exp)
4748 s1v(2, ik) = exp(-lambda*sum_exp)
4749 DO iat = 1, rmsd_atom
4752 ds1v(1, iat, 1, ik) = r(ii + 1)*s1v(1, ik)
4753 ds1v(1, iat, 2, ik) = r(ii + 1)*s1v(2, ik)
4754 ds1v(2, iat, 1, ik) = r(ii + 2)*s1v(1, ik)
4755 ds1v(2, iat, 2, ik) = r(ii + 2)*s1v(2, ik)
4756 ds1v(3, iat, 1, ik) = r(ii + 3)*s1v(1, ik)
4757 ds1v(3, iat, 2, ik) = r(ii + 3)*s1v(2, ik)
4764 DO iat = 1, rmsd_atom
4771 colvar%ss = s1(1)/s1(2)/real(nconf - 1,
dp)
4773 ALLOCATE (fi(3, rmsd_atom))
4775 DO iat = 1, rmsd_atom
4776 fi(1, iat) = 2.0_dp*lambda/s1(2)/real(nconf - 1,
dp)*(ds1(1, iat, 1) - ds1(1, iat, 2)*s1(1)/s1(2))
4777 fi(2, iat) = 2.0_dp*lambda/s1(2)/real(nconf - 1,
dp)*(ds1(2, iat, 1) - ds1(2, iat, 2)*s1(1)/s1(2))
4778 fi(3, iat) = 2.0_dp*lambda/s1(2)/real(nconf - 1,
dp)*(ds1(3, iat, 1) - ds1(3, iat, 2)*s1(1)/s1(2))
4779 CALL put_derivative(colvar, iat, fi(:, iat))
4786 DEALLOCATE (vec_dif)
4787 DEALLOCATE (dvec_dif)
4792 END SUBROUTINE rpath_dist_rmsd
4799 SUBROUTINE rpath_rmsd(colvar, particles)
4803 INTEGER :: i, iat, ii, ik, natom, nconf, rmsd_atom
4804 INTEGER,
DIMENSION(:),
POINTER :: iatom
4805 REAL(
dp) :: lambda, my_rmsd, s1(2)
4806 REAL(
dp),
ALLOCATABLE,
DIMENSION(:) :: r, r0
4807 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: fi, riat, s1v
4808 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: ds1
4809 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :, :, :) :: ds1v
4810 REAL(
dp),
DIMENSION(:, :),
POINTER :: path_conf
4811 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: weight
4812 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: drmsd
4814 nconf = colvar%reaction_path_param%nr_frames
4815 rmsd_atom = colvar%reaction_path_param%n_components
4816 lambda = colvar%reaction_path_param%lambda
4817 path_conf => colvar%reaction_path_param%r_ref
4818 iatom => colvar%reaction_path_param%i_rmsd
4820 natom =
SIZE(particles)
4822 ALLOCATE (r0(3*natom))
4823 ALLOCATE (r(3*natom))
4824 ALLOCATE (riat(3, rmsd_atom))
4825 ALLOCATE (s1v(2, nconf))
4826 ALLOCATE (ds1v(3, rmsd_atom, 2, nconf))
4827 ALLOCATE (ds1(3, rmsd_atom, 2))
4828 ALLOCATE (drmsd(3, natom))
4830 ALLOCATE (weight(natom))
4834 r0(ii + 1) = particles(i)%r(1)
4835 r0(ii + 2) = particles(i)%r(2)
4836 r0(ii + 3) = particles(i)%r(3)
4839 DO iat = 1, rmsd_atom
4841 riat(:, iat) = particles(ii)%r
4846 DO iat = 1, rmsd_atom
4854 r(ii + 1) = path_conf(ii + 1, ik)
4855 r(ii + 2) = path_conf(ii + 2, ik)
4856 r(ii + 3) = path_conf(ii + 3, ik)
4859 CALL rmsd3(particles, r0, r, output_unit=-1, weights=weight, my_val=my_rmsd, &
4860 rotate=.false., drmsd3=drmsd)
4862 s1v(1, ik) = real(ik - 1,
dp)*exp(-lambda*my_rmsd)
4863 s1v(2, ik) = exp(-lambda*my_rmsd)
4864 DO iat = 1, rmsd_atom
4866 ds1v(1, iat, 1, ik) = drmsd(1, i)*s1v(1, ik)
4867 ds1v(1, iat, 2, ik) = drmsd(1, i)*s1v(2, ik)
4868 ds1v(2, iat, 1, ik) = drmsd(2, i)*s1v(1, ik)
4869 ds1v(2, iat, 2, ik) = drmsd(2, i)*s1v(2, ik)
4870 ds1v(3, iat, 1, ik) = drmsd(3, i)*s1v(1, ik)
4871 ds1v(3, iat, 2, ik) = drmsd(3, i)*s1v(2, ik)
4878 DO iat = 1, rmsd_atom
4885 colvar%ss = s1(1)/s1(2)/real(nconf - 1,
dp)
4887 ALLOCATE (fi(3, rmsd_atom))
4889 DO iat = 1, rmsd_atom
4890 fi(1, iat) = -lambda/s1(2)/real(nconf - 1,
dp)*(ds1(1, iat, 1) - ds1(1, iat, 2)*s1(1)/s1(2))
4891 fi(2, iat) = -lambda/s1(2)/real(nconf - 1,
dp)*(ds1(2, iat, 1) - ds1(2, iat, 2)*s1(1)/s1(2))
4892 fi(3, iat) = -lambda/s1(2)/real(nconf - 1,
dp)*(ds1(3, iat, 1) - ds1(3, iat, 2)*s1(1)/s1(2))
4893 CALL put_derivative(colvar, iat, fi(:, iat))
4906 END SUBROUTINE rpath_rmsd
4918 SUBROUTINE distance_from_path_colvar(colvar, cell, subsys, particles)
4923 POINTER :: particles
4929 IF (
PRESENT(particles))
THEN
4930 my_particles => particles
4932 cpassert(
PRESENT(subsys))
4934 my_particles => particles_i%els
4937 IF (colvar%reaction_path_param%dist_rmsd)
THEN
4938 CALL dpath_dist_rmsd(colvar, my_particles)
4939 ELSE IF (colvar%reaction_path_param%rmsd)
THEN
4940 CALL dpath_rmsd(colvar, my_particles)
4942 CALL dpath_colvar(colvar, cell, my_particles)
4945 END SUBROUTINE distance_from_path_colvar
4957 SUBROUTINE dpath_colvar(colvar, cell, particles)
4962 INTEGER :: i, iend, ii, istart, j, k, ncolv
4963 REAL(
dp) :: lambda, s1
4964 REAL(
dp),
ALLOCATABLE,
DIMENSION(:) :: ds1, s1v, ss_vals
4965 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: ds1v, f_vals, fi
4967 istart = colvar%reaction_path_param%function_bounds(1)
4968 iend = colvar%reaction_path_param%function_bounds(2)
4970 ncolv = colvar%reaction_path_param%n_components
4971 lambda = colvar%reaction_path_param%lambda
4972 ALLOCATE (f_vals(ncolv, istart:iend))
4973 f_vals(:, :) = colvar%reaction_path_param%f_vals
4974 ALLOCATE (ss_vals(ncolv))
4977 CALL colvar_recursive_eval(colvar%reaction_path_param%colvar_p(i)%colvar, cell, particles)
4978 ss_vals(i) = colvar%reaction_path_param%colvar_p(i)%colvar%ss
4981 ALLOCATE (s1v(istart:iend))
4982 ALLOCATE (ds1v(ncolv, istart:iend))
4983 ALLOCATE (ds1(ncolv))
4986 s1v(k) = exp(-lambda*dot_product(ss_vals(:) - f_vals(:, k), ss_vals(:) - f_vals(:, k)))
4988 ds1v(j, k) = f_vals(j, k)*s1v(k)
4996 colvar%ss = -1.0_dp/lambda*log(s1)
4998 ALLOCATE (fi(3, colvar%n_atom_s))
5002 DO j = 1, colvar%reaction_path_param%colvar_p(i)%colvar%n_atom_s
5004 fi(:, ii) = colvar%reaction_path_param%colvar_p(i)%colvar%dsdr(:, j)* &
5005 2.0_dp*(ss_vals(i) - ds1(i)/s1)
5009 DO i = 1, colvar%n_atom_s
5010 CALL put_derivative(colvar, i, fi(:, i))
5015 DEALLOCATE (ss_vals)
5020 END SUBROUTINE dpath_colvar
5031 SUBROUTINE dpath_dist_rmsd(colvar, particles)
5036 INTEGER :: i, iat, ii, ik, natom, nconf, rmsd_atom
5037 INTEGER,
DIMENSION(:),
POINTER :: iatom
5038 REAL(
dp) :: lambda, s1, sum_exp
5039 REAL(
dp),
ALLOCATABLE,
DIMENSION(:) :: r, r0, s1v, vec_dif
5040 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: ds1, dvec_dif, fi, riat
5041 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: ds1v
5042 REAL(
dp),
DIMENSION(:, :),
POINTER :: path_conf
5044 nconf = colvar%reaction_path_param%nr_frames
5045 rmsd_atom = colvar%reaction_path_param%n_components
5046 lambda = colvar%reaction_path_param%lambda
5047 path_conf => colvar%reaction_path_param%r_ref
5048 iatom => colvar%reaction_path_param%i_rmsd
5050 natom =
SIZE(particles)
5052 ALLOCATE (r0(3*natom))
5053 ALLOCATE (r(3*natom))
5054 ALLOCATE (riat(3, rmsd_atom))
5055 ALLOCATE (vec_dif(rmsd_atom))
5056 ALLOCATE (dvec_dif(3, rmsd_atom))
5057 ALLOCATE (s1v(nconf))
5058 ALLOCATE (ds1v(3, rmsd_atom, nconf))
5059 ALLOCATE (ds1(3, rmsd_atom))
5062 r0(ii + 1) = particles(i)%r(1)
5063 r0(ii + 2) = particles(i)%r(2)
5064 r0(ii + 3) = particles(i)%r(3)
5067 DO iat = 1, rmsd_atom
5069 riat(:, iat) = particles(ii)%r
5075 r(ii + 1) = path_conf(ii + 1, ik)
5076 r(ii + 2) = path_conf(ii + 2, ik)
5077 r(ii + 3) = path_conf(ii + 3, ik)
5080 CALL rmsd3(particles, r, r0, output_unit=-1, rotate=.true.)
5083 DO iat = 1, rmsd_atom
5086 vec_dif(iat) = (riat(1, iat) - r(ii + 1))**2 + (riat(2, iat) - r(ii + 2))**2 + (riat(3, iat) - r(ii + 3))**2
5087 sum_exp = sum_exp + vec_dif(iat)
5088 dvec_dif(1, iat) = r(ii + 1)
5089 dvec_dif(2, iat) = r(ii + 2)
5090 dvec_dif(3, iat) = r(ii + 3)
5092 s1v(ik) = exp(-lambda*sum_exp)
5093 DO iat = 1, rmsd_atom
5094 ds1v(1, iat, ik) = dvec_dif(1, iat)*s1v(ik)
5095 ds1v(2, iat, ik) = dvec_dif(2, iat)*s1v(ik)
5096 ds1v(3, iat, ik) = dvec_dif(3, iat)*s1v(ik)
5101 DO iat = 1, rmsd_atom
5106 colvar%ss = -1.0_dp/lambda*log(s1)
5108 ALLOCATE (fi(3, rmsd_atom))
5110 DO iat = 1, rmsd_atom
5111 fi(:, iat) = 2.0_dp*(riat(:, iat) - ds1(:, iat)/s1)
5112 CALL put_derivative(colvar, iat, fi(:, iat))
5119 DEALLOCATE (vec_dif)
5120 DEALLOCATE (dvec_dif)
5124 END SUBROUTINE dpath_dist_rmsd
5131 SUBROUTINE dpath_rmsd(colvar, particles)
5136 INTEGER :: i, iat, ii, ik, natom, nconf, rmsd_atom
5137 INTEGER,
DIMENSION(:),
POINTER :: iatom
5138 REAL(
dp) :: lambda, my_rmsd, s1
5139 REAL(
dp),
ALLOCATABLE,
DIMENSION(:) :: r, r0, s1v
5140 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: ds1, fi, riat
5141 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: ds1v
5142 REAL(
dp),
DIMENSION(:, :),
POINTER :: path_conf
5143 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: weight
5144 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: drmsd
5146 nconf = colvar%reaction_path_param%nr_frames
5147 rmsd_atom = colvar%reaction_path_param%n_components
5148 lambda = colvar%reaction_path_param%lambda
5149 path_conf => colvar%reaction_path_param%r_ref
5150 iatom => colvar%reaction_path_param%i_rmsd
5152 natom =
SIZE(particles)
5154 ALLOCATE (r0(3*natom))
5155 ALLOCATE (r(3*natom))
5156 ALLOCATE (riat(3, rmsd_atom))
5157 ALLOCATE (s1v(nconf))
5158 ALLOCATE (ds1v(3, rmsd_atom, nconf))
5159 ALLOCATE (ds1(3, rmsd_atom))
5160 ALLOCATE (drmsd(3, natom))
5162 ALLOCATE (weight(natom))
5166 r0(ii + 1) = particles(i)%r(1)
5167 r0(ii + 2) = particles(i)%r(2)
5168 r0(ii + 3) = particles(i)%r(3)
5171 DO iat = 1, rmsd_atom
5173 riat(:, iat) = particles(ii)%r
5178 DO iat = 1, rmsd_atom
5186 r(ii + 1) = path_conf(ii + 1, ik)
5187 r(ii + 2) = path_conf(ii + 2, ik)
5188 r(ii + 3) = path_conf(ii + 3, ik)
5191 CALL rmsd3(particles, r0, r, output_unit=-1, weights=weight, my_val=my_rmsd, &
5192 rotate=.false., drmsd3=drmsd)
5194 s1v(ik) = exp(-lambda*my_rmsd)
5195 DO iat = 1, rmsd_atom
5197 ds1v(1, iat, ik) = drmsd(1, i)*s1v(ik)
5198 ds1v(2, iat, ik) = drmsd(2, i)*s1v(ik)
5199 ds1v(3, iat, ik) = drmsd(3, i)*s1v(ik)
5204 DO iat = 1, rmsd_atom
5209 colvar%ss = -1.0_dp/lambda*log(s1)
5211 ALLOCATE (fi(3, rmsd_atom))
5213 DO iat = 1, rmsd_atom
5214 fi(:, iat) = ds1(:, iat)/s1
5215 CALL put_derivative(colvar, iat, fi(:, iat))
5228 END SUBROUTINE dpath_rmsd
5239 SUBROUTINE population_colvar(colvar, cell, subsys, particles)
5244 POINTER :: particles
5246 INTEGER :: i, ii, jj, n_atoms_from, n_atoms_to, &
5248 REAL(
dp) :: dfunc, dfunc_coord, ftmp(3), func, func_coord, inv_n_atoms_from, invden, n_0, &
5249 ncoord, norm, num, population, r12, r_0, rdist, sigma, ss(3), xij(3)
5250 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: ftmp_coord
5251 REAL(
dp),
DIMENSION(3) :: xpi, xpj
5258 NULLIFY (particles_i)
5260 IF (
PRESENT(particles))
THEN
5261 my_particles => particles
5263 cpassert(
PRESENT(subsys))
5265 my_particles => particles_i%els
5267 n_atoms_to = colvar%population_param%n_atoms_to
5268 n_atoms_from = colvar%population_param%n_atoms_from
5269 nncrd = colvar%population_param%nncrd
5270 ndcrd = colvar%population_param%ndcrd
5271 r_0 = colvar%population_param%r_0
5272 n_0 = colvar%population_param%n0
5273 sigma = colvar%population_param%sigma
5275 ALLOCATE (ftmp_coord(3, n_atoms_to))
5281 colvar%dsdr = 0.0_dp
5282 inv_n_atoms_from = 1.0_dp/real(n_atoms_from, kind=
dp)
5284 norm = sqrt(
pi*2.0_dp)*sigma
5287 DO ii = 1, n_atoms_from
5288 i = colvar%population_param%i_at_from(ii)
5289 CALL get_coordinates(colvar, i, xpi, my_particles)
5290 DO jj = 1, n_atoms_to
5291 i = colvar%population_param%i_at_to(jj)
5292 CALL get_coordinates(colvar, i, xpj, my_particles)
5293 ss = matmul(cell%h_inv, xpi(:) - xpj(:))
5295 xij = matmul(cell%hmat, ss)
5296 r12 = sqrt(xij(1)**2 + xij(2)**2 + xij(3)**2)
5297 IF (r12 < 1.0e-8_dp) cycle
5299 num = (1.0_dp - rdist**nncrd)
5300 invden = 1.0_dp/(1.0_dp - rdist**ndcrd)
5301 func_coord = num*invden
5302 dfunc_coord = (-nncrd*rdist**(nncrd - 1)*invden &
5303 + num*(invden)**2*ndcrd*rdist**(ndcrd - 1))/(r12*r_0)
5305 ncoord = ncoord + func_coord
5306 ftmp_coord(1, jj) = dfunc_coord*xij(1)
5307 ftmp_coord(2, jj) = dfunc_coord*xij(2)
5308 ftmp_coord(3, jj) = dfunc_coord*xij(3)
5311 func = exp(-(ncoord - n_0)**2/(2.0_dp*sigma*sigma))
5312 dfunc = -func*(ncoord - n_0)/(sigma*sigma)
5314 population = population + norm*func
5315 DO jj = 1, n_atoms_to
5316 ftmp(1) = ftmp_coord(1, jj)*dfunc
5317 ftmp(2) = ftmp_coord(2, jj)*dfunc
5318 ftmp(3) = ftmp_coord(3, jj)*dfunc
5319 CALL put_derivative(colvar, ii, ftmp)
5320 ftmp(1) = -ftmp_coord(1, jj)*dfunc
5321 ftmp(2) = -ftmp_coord(2, jj)*dfunc
5322 ftmp(3) = -ftmp_coord(3, jj)*dfunc
5323 CALL put_derivative(colvar, n_atoms_from + jj, ftmp)
5327 colvar%ss = population
5328 END SUBROUTINE population_colvar
5340 SUBROUTINE gyration_radius_colvar(colvar, cell, subsys, particles)
5346 POINTER :: particles
5348 INTEGER :: i, ii, n_atoms
5349 REAL(
dp) :: dri2, func, gyration, inv_n, mass_tot, mi
5350 REAL(
dp),
DIMENSION(3) :: dfunc, dxi, ftmp, ss, xpcom, xpi
5354 NULLIFY (particles_i, my_particles)
5356 IF (
PRESENT(particles))
THEN
5357 my_particles => particles
5359 cpassert(
PRESENT(subsys))
5361 my_particles => particles_i%els
5363 n_atoms = colvar%gyration_param%n_atoms
5364 inv_n = 1.0_dp/n_atoms
5370 i = colvar%gyration_param%i_at(ii)
5371 CALL get_coordinates(colvar, i, xpi, my_particles)
5372 CALL get_mass(colvar, i, mi, my_particles)
5373 xpcom(:) = xpcom(:) + xpi(:)*mi
5374 mass_tot = mass_tot + mi
5376 xpcom(:) = xpcom(:)/mass_tot
5382 i = colvar%gyration_param%i_at(ii)
5383 CALL get_coordinates(colvar, i, xpi, my_particles)
5384 ss = matmul(cell%h_inv, xpi(:) - xpcom(:))
5386 dxi = matmul(cell%hmat, ss)
5387 dri2 = (dxi(1)**2 + dxi(2)**2 + dxi(3)**2)
5389 dfunc(:) = dfunc(:) + dxi(:)
5391 gyration = sqrt(inv_n*func)
5394 i = colvar%gyration_param%i_at(ii)
5395 CALL get_coordinates(colvar, i, xpi, my_particles)
5396 CALL get_mass(colvar, i, mi, my_particles)
5397 ss = matmul(cell%h_inv, xpi(:) - xpcom(:))
5399 dxi = matmul(cell%hmat, ss)
5400 ftmp(1) = dxi(1) - dfunc(1)*mi/mass_tot
5401 ftmp(2) = dxi(2) - dfunc(2)*mi/mass_tot
5402 ftmp(3) = dxi(3) - dfunc(3)*mi/mass_tot
5403 ftmp(:) = ftmp(:)*inv_n/gyration
5404 CALL put_derivative(colvar, ii, ftmp)
5406 colvar%ss = gyration
5408 END SUBROUTINE gyration_radius_colvar
5419 SUBROUTINE rmsd_colvar(colvar, subsys, particles)
5423 POINTER :: particles
5425 CALL rmsd_colvar_low(colvar, subsys, particles)
5426 END SUBROUTINE rmsd_colvar
5441 SUBROUTINE rmsd_colvar_low(colvar, subsys, particles)
5446 POINTER :: particles
5448 INTEGER :: i, ii, natom, nframes
5449 REAL(kind=
dp) :: cv_val, f1, ftmp(3)
5450 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: der, r,
rmsd
5451 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: r0
5452 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: drmsd
5453 REAL(kind=
dp),
DIMENSION(:),
POINTER :: weights
5457 NULLIFY (my_particles, particles_i, weights)
5459 IF (
PRESENT(particles))
THEN
5460 my_particles => particles
5462 cpassert(
PRESENT(subsys))
5464 my_particles => particles_i%els
5467 natom =
SIZE(my_particles)
5468 nframes = colvar%rmsd_param%nr_frames
5469 ALLOCATE (drmsd(3, natom, nframes))
5472 ALLOCATE (r0(3*natom, nframes))
5473 ALLOCATE (
rmsd(nframes))
5474 ALLOCATE (der(nframes))
5475 ALLOCATE (r(3*natom))
5477 weights => colvar%rmsd_param%weights
5480 r(ii + 1) = my_particles(i)%r(1)
5481 r(ii + 2) = my_particles(i)%r(2)
5482 r(ii + 3) = my_particles(i)%r(3)
5484 r0(:, :) = colvar%rmsd_param%r_ref
5487 CALL rmsd3(my_particles, r, r0(:, 1), output_unit=-1, weights=weights, my_val=
rmsd(1), rotate=.false., drmsd3=drmsd(:, :, 1))
5489 IF (nframes == 2)
THEN
5490 CALL rmsd3(my_particles, r, r0(:, 2), output_unit=-1, weights=weights, &
5491 my_val=
rmsd(2), rotate=.false., drmsd3=drmsd(:, :, 2))
5497 der(1) = f1 - cv_val*f1
5499 der(2) = -f1 - cv_val*f1
5501 DO i = 1, colvar%rmsd_param%n_atoms
5502 ii = colvar%rmsd_param%i_rmsd(i)
5503 IF (weights(ii) > 0.0_dp)
THEN
5504 ftmp(1) = der(1)*drmsd(1, ii, 1) + der(2)*drmsd(1, ii, 2)
5505 ftmp(2) = der(1)*drmsd(2, ii, 1) + der(2)*drmsd(2, ii, 2)
5506 ftmp(3) = der(1)*drmsd(3, ii, 1) + der(2)*drmsd(3, ii, 2)
5507 CALL put_derivative(colvar, i, ftmp)
5510 ELSE IF (nframes == 1)
THEN
5513 cv_val = sqrt(
rmsd(1))
5515 IF (cv_val /= 0.0_dp) f1 = 0.5_dp/cv_val
5516 DO i = 1, colvar%rmsd_param%n_atoms
5517 ii = colvar%rmsd_param%i_rmsd(i)
5518 IF (weights(ii) > 0.0_dp)
THEN
5519 ftmp(1) = f1*drmsd(1, ii, 1)
5520 ftmp(2) = f1*drmsd(2, ii, 1)
5521 ftmp(3) = f1*drmsd(3, ii, 1)
5522 CALL put_derivative(colvar, i, ftmp)
5526 cpabort(
"RMSD implemented only for 1 and 2 reference frames!")
5536 END SUBROUTINE rmsd_colvar_low
5548 SUBROUTINE ring_puckering_colvar(colvar, cell, subsys, particles)
5553 POINTER :: particles
5555 INTEGER :: i, ii, j, jj, m, nring
5556 REAL(kind=
dp) :: a, at, b, da, db, ds, kr, rpxpp, svar
5557 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: cosj, sinj, z
5558 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: r
5559 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: nforce, zforce
5560 REAL(kind=
dp),
DIMENSION(3) :: ftmp, nv, r0, rp, rpp, uv
5561 REAL(kind=
dp),
DIMENSION(3, 3) :: dnvp, dnvpp
5566 IF (
PRESENT(particles))
THEN
5567 my_particles => particles
5569 cpassert(
PRESENT(subsys))
5571 my_particles => particles_i%els
5574 nring = colvar%ring_puckering_param%nring
5575 ALLOCATE (r(3, nring), z(nring), cosj(nring), sinj(nring))
5576 ALLOCATE (nforce(3, 3, nring), zforce(nring, nring, 3))
5578 i = colvar%ring_puckering_param%atoms(ii)
5579 CALL get_coordinates(colvar, i, r(:, ii), my_particles)
5584 r(:, ii) =
pbc(r(:, ii), r0, cell)
5589 r0(:) = r0(:) + r(:, ii)
5591 kr = 1._dp/real(nring, kind=
dp)
5594 r(:, ii) = r(:, ii) - r0(:)
5600 cosj(ii) = cos(
twopi*(ii - 1)*kr)
5601 sinj(ii) = sin(
twopi*(ii - 1)*kr)
5602 rp(:) = rp(:) + r(:, ii)*sinj(ii)
5603 rpp(:) = rpp(:) + r(:, ii)*cosj(ii)
5606 nv = nv/sqrt(sum(nv**2))
5610 rpxpp = sqrt(sum(uv**2))
5615 dnvp(:, i) = uv - nv*sum(uv*nv)
5619 dnvpp(:, i) = uv - nv*sum(uv*nv)
5622 nforce(:, :, ii) = dnvp(:, :)*sinj(ii) + dnvpp(:, :)*cosj(ii)
5627 z(ii) = sum(r(:, ii)*nv(:))
5633 zforce(ii, jj, :) = nv
5635 zforce(ii, jj, :) = 0._dp
5639 zforce(ii, jj, i) = zforce(ii, jj, i) + r(j, ii)*nforce(j, i, jj)
5645 IF (colvar%ring_puckering_param%iq == 0)
THEN
5647 svar = sqrt(sum(z**2))
5651 ftmp(:) = ftmp(:) + zforce(jj, ii, :)*z(jj)
5654 CALL put_derivative(colvar, ii, ftmp)
5657 m = abs(colvar%ring_puckering_param%iq)
5659 IF (mod(nring, 2) == 0 .AND. colvar%ring_puckering_param%iq == nring/2)
THEN
5663 IF (mod(ii, 2) == 0)
THEN
5669 svar = svar*sqrt(kr)
5673 IF (mod(jj, 2) == 0)
THEN
5674 ftmp(:) = ftmp(:) - zforce(jj, ii, :)*sqrt(kr)
5676 ftmp(:) = ftmp(:) + zforce(jj, ii, :)*sqrt(kr)
5679 CALL put_derivative(colvar, ii, -ftmp)
5682 cpassert(m <= (nring - 1)/2)
5686 a = a + z(ii)*cos(
twopi*m*(ii - 1)*kr)
5687 b = b - z(ii)*sin(
twopi*m*(ii - 1)*kr)
5689 a = a*sqrt(2._dp*kr)
5690 b = b*sqrt(2._dp*kr)
5691 IF (colvar%ring_puckering_param%iq > 0)
THEN
5693 svar = sqrt(a*a + b*b)
5699 IF (at >
pi/2._dp)
THEN
5700 svar = 2.5_dp*
pi - at
5702 svar = 0.5_dp*
pi - at
5710 ds = da*cos(
twopi*m*(ii - 1)*kr)
5711 ds = ds - db*sin(
twopi*m*(ii - 1)*kr)
5712 ftmp(:) = ftmp(:) + ds*sqrt(2._dp*kr)*zforce(ii, jj, :)
5714 CALL put_derivative(colvar, jj, ftmp)
5721 DEALLOCATE (r, z, cosj, sinj, nforce, zforce)
5723 END SUBROUTINE ring_puckering_colvar
5745 RECURSIVE FUNCTION rec_eval_grid(iw1, ncol, f_vals, v_count, &
5746 gp, grid_sp, step_size, istart, iend, s1v, s1, p_bounds, lambda, ifunc, nconf)
RESULT(k)
5747 INTEGER :: iw1, ncol
5748 REAL(
dp),
DIMENSION(:, :),
POINTER :: f_vals
5750 REAL(
dp),
DIMENSION(:),
POINTER :: gp, grid_sp
5751 REAL(
dp) :: step_size
5752 INTEGER :: istart, iend
5753 REAL(
dp),
DIMENSION(:, :),
POINTER :: s1v
5754 REAL(
dp),
DIMENSION(:),
POINTER :: s1
5755 INTEGER,
DIMENSION(:, :),
POINTER :: p_bounds
5757 INTEGER :: ifunc, nconf, k
5759 INTEGER :: count1, i
5762 IF (v_count < ncol)
THEN
5763 count1 = v_count + 1
5764 DO i = p_bounds(1, count1), p_bounds(2, count1)
5765 gp(count1) = real(i, kind=
dp)*grid_sp(count1)
5766 k = rec_eval_grid(iw1, ncol, f_vals, count1, gp, grid_sp, step_size, &
5767 istart, iend, s1v, s1, p_bounds, lambda, ifunc, nconf)
5769 ELSE IF (v_count == ncol .AND. ifunc == 1)
THEN
5771 s1v(1, i) = real(i, kind=
dp)*step_size*exp(-lambda*dot_product(gp(:) - f_vals(:, i), &
5772 gp(:) - f_vals(:, i)))
5773 s1v(2, i) = exp(-lambda*dot_product(gp(:) - f_vals(:, i), gp(:) - f_vals(:, i)))
5778 WRITE (iw1,
'(5F10.5)') gp(:), s1(1)/s1(2)/real(nconf - 1,
dp)
5779 ELSE IF (v_count == ncol .AND. ifunc == 2)
THEN
5781 s1v(1, i) = exp(-lambda*dot_product(gp(:) - f_vals(:, i), gp(:) - f_vals(:, i)))
5785 WRITE (iw1,
'(5F10.5)') gp(:), -lambda*log(s1(1))
5787 END FUNCTION rec_eval_grid
5800 SUBROUTINE read_frames(frame_section, para_env, nr_frames, r_ref, n_atoms)
5804 INTEGER,
INTENT(IN) :: nr_frames
5805 REAL(
dp),
DIMENSION(:, :),
POINTER :: r_ref
5806 INTEGER,
INTENT(OUT) :: n_atoms
5808 CHARACTER(LEN=default_path_length) :: filename
5809 CHARACTER(LEN=default_string_length) :: dummy_char
5810 INTEGER :: i, j, natom
5811 LOGICAL :: explicit, my_end
5812 REAL(kind=
dp),
DIMENSION(:),
POINTER :: rptr
5825 ALLOCATE (r_ref(3*natom, nr_frames))
5828 cpassert(3*natom ==
SIZE(r_ref, 1))
5832 i_rep_val=j, r_vals=rptr)
5833 r_ref((j - 1)*3 + 1:(j - 1)*3 + 3, i) = rptr(1:3)
5839 cpassert(trim(filename) /=
"")
5841 CALL parser_create(parser, filename, para_env=para_env, parse_white_lines=.true.)
5847 ALLOCATE (r_ref(3*natom, nr_frames))
5850 cpassert(3*natom ==
SIZE(r_ref, 1))
5856 CALL cp_abort(__location__, &
5857 "Number of lines in XYZ format not equal to the number of atoms."// &
5858 " Error in XYZ format for COORD_A (CV rmsd). Very probably the"// &
5859 " line with title is missing or is empty. Please check the XYZ file and rerun your job!")
5861 READ (parser%input_line, *) dummy_char, rptr(1:3)
5872 END SUBROUTINE read_frames
5883 SUBROUTINE wc_colvar(colvar, cell, subsys, particles, qs_env)
5884 TYPE(colvar_type),
POINTER :: colvar
5885 TYPE(cell_type),
POINTER :: cell
5886 TYPE(cp_subsys_type),
OPTIONAL,
POINTER :: subsys
5887 TYPE(particle_type),
DIMENSION(:), &
5888 OPTIONAL,
POINTER :: particles
5889 TYPE(qs_environment_type),
POINTER,
OPTIONAL :: qs_env
5891 INTEGER :: od, h, oa
5892 REAL(dp) :: rod(3), roa(3), rh(3), &
5893 x, y, s(3), xv(3), dmin, amin
5894 INTEGER :: idmin, iamin, i, j
5895 TYPE(particle_list_type),
POINTER :: particles_i
5896 TYPE(particle_type),
DIMENSION(:), &
5897 POINTER :: my_particles
5898 TYPE(wannier_centres_type),
DIMENSION(:),
POINTER :: wc
5899 INTEGER,
ALLOCATABLE :: wcai(:), wcdi(:)
5900 INTEGER :: nwca, nwcd
5903 NULLIFY (particles_i, wc)
5905 cpassert(colvar%type_id == wc_colvar_id)
5906 IF (
PRESENT(particles))
THEN
5907 my_particles => particles
5909 cpassert(
PRESENT(subsys))
5910 CALL cp_subsys_get(subsys, particles=particles_i)
5911 my_particles => particles_i%els
5913 CALL get_qs_env(qs_env, wanniercentres=wc)
5914 rcut = colvar%Wc%rcut
5915 od = colvar%Wc%ids(1)
5916 h = colvar%Wc%ids(2)
5917 oa = colvar%Wc%ids(3)
5918 CALL get_coordinates(colvar, od, rod, my_particles)
5919 CALL get_coordinates(colvar, h, rh, my_particles)
5920 CALL get_coordinates(colvar, oa, roa, my_particles)
5921 ALLOCATE (wcai(
SIZE(wc(1)%WannierHamDiag)))
5922 ALLOCATE (wcdi(
SIZE(wc(1)%WannierHamDiag)))
5925 DO j = 1,
SIZE(wc(1)%WannierHamDiag)
5926 x = distance(rod - wc(1)%centres(:, j))
5927 y = distance(roa - wc(1)%centres(:, j))
5939 dmin = distance(rh - wc(1)%centres(:, wcdi(1)))
5940 amin = distance(rh - wc(1)%centres(:, wcai(1)))
5945 x = distance(rh - wc(1)%centres(:, wcdi(i)))
5952 x = distance(rh - wc(1)%centres(:, wcai(i)))
5959 colvar%ss = wc(1)%WannierHamDiag(idmin) - wc(1)%WannierHamDiag(iamin)
5969 REAL(dp) function distance(rij)
5970 REAL(dp),
INTENT(in) :: rij(3)
5972 s = matmul(cell%h_inv, rij)
5974 xv = matmul(cell%hmat, s)
5975 distance = norm2(xv)
5976 END FUNCTION distance
5978 END SUBROUTINE wc_colvar
5989 SUBROUTINE hbp_colvar(colvar, cell, subsys, particles, qs_env)
5990 TYPE(colvar_type),
POINTER :: colvar
5991 TYPE(cell_type),
POINTER :: cell
5992 TYPE(cp_subsys_type),
OPTIONAL,
POINTER :: subsys
5993 TYPE(particle_type),
DIMENSION(:), &
5994 OPTIONAL,
POINTER :: particles
5995 TYPE(qs_environment_type),
OPTIONAL,
POINTER :: qs_env
5997 INTEGER :: od, h, oa
5998 REAL(dp) :: rod(3), roa(3), rh(3), &
5999 x, y, s(3), xv(3), dmin, amin
6000 INTEGER :: idmin, iamin, i, j, il, output_unit
6001 TYPE(particle_list_type),
POINTER :: particles_i
6002 TYPE(particle_type),
DIMENSION(:), &
6003 POINTER :: my_particles
6004 TYPE(wannier_centres_type), &
6005 DIMENSION(:),
POINTER :: wc
6006 INTEGER,
ALLOCATABLE :: wcai(:), wcdi(:)
6007 INTEGER :: nwca, nwcd
6010 NULLIFY (particles_i, wc)
6011 output_unit = cp_logger_get_default_io_unit()
6013 cpassert(colvar%type_id == hbp_colvar_id)
6014 IF (
PRESENT(particles))
THEN
6015 my_particles => particles
6017 cpassert(
PRESENT(subsys))
6018 CALL cp_subsys_get(subsys, particles=particles_i)
6019 my_particles => particles_i%els
6021 CALL get_qs_env(qs_env, wanniercentres=wc)
6022 rcut = colvar%HBP%rcut
6023 ALLOCATE (wcai(
SIZE(wc(1)%WannierHamDiag)))
6024 ALLOCATE (wcdi(
SIZE(wc(1)%WannierHamDiag)))
6026 DO il = 1, colvar%HBP%nPoints
6027 od = colvar%HBP%ids(il, 1)
6028 h = colvar%HBP%ids(il, 2)
6029 oa = colvar%HBP%ids(il, 3)
6030 CALL get_coordinates(colvar, od, rod, my_particles)
6031 CALL get_coordinates(colvar, h, rh, my_particles)
6032 CALL get_coordinates(colvar, oa, roa, my_particles)
6035 DO j = 1,
SIZE(wc(1)%WannierHamDiag)
6036 x = distance(rod - wc(1)%centres(:, j))
6037 y = distance(roa - wc(1)%centres(:, j))
6049 dmin = distance(rh - wc(1)%centres(:, wcdi(1)))
6050 amin = distance(rh - wc(1)%centres(:, wcai(1)))
6055 x = distance(rh - wc(1)%centres(:, wcdi(i)))
6062 x = distance(rh - wc(1)%centres(:, wcai(i)))
6068 colvar%HBP%ewc(il) = colvar%HBP%shift + wc(1)%WannierHamDiag(idmin) - wc(1)%WannierHamDiag(iamin)
6069 colvar%ss = colvar%ss + colvar%HBP%shift + wc(1)%WannierHamDiag(idmin) - wc(1)%WannierHamDiag(iamin)
6071 IF (output_unit > 0)
THEN
6072 DO il = 1, colvar%HBP%nPoints
6073 WRITE (output_unit,
'(a,1(f16.8,1x))')
"HBP| = ", colvar%HBP%ewc(il)
6075 WRITE (output_unit,
'(a,1(f16.8,1x))')
"HBP|\theta(x) = ", colvar%ss
6086 REAL(dp) function distance(rij)
6087 REAL(dp),
INTENT(in) :: rij(3)
6089 s = matmul(cell%h_inv, rij)
6091 xv = matmul(cell%hmat, s)
6092 distance = norm2(xv)
6093 END FUNCTION distance
6095 END SUBROUTINE hbp_colvar
6104 SUBROUTINE colvar_eval_voronoiipz(colvar, cell, subsys, particles)
6105 TYPE(colvar_type),
POINTER :: colvar
6106 TYPE(cell_type),
POINTER :: cell
6107 TYPE(cp_subsys_type),
OPTIONAL,
POINTER :: subsys
6108 TYPE(particle_type),
DIMENSION(:),
OPTIONAL, &
6109 POINTER :: particles
6111 INTEGER :: i, iatom, j, jatom, n_atoms_a, &
6112 n_atoms_o, n_atoms_b, zidx
6113 REAL(kind=dp) :: charge_deriv, cutoff, denominator, &
6114 distance, exponent_max, factor, ion_z, &
6115 lambda, weighted_charge_deriv, zdist, zmid
6116 REAL(kind=dp),
ALLOCATABLE,
DIMENSION(:) :: charge, charge_factor
6117 REAL(kind=dp),
ALLOCATABLE,
DIMENSION(:, :) :: inv_distance, weight
6118 REAL(kind=dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: distance_vector
6119 TYPE(particle_type),
DIMENSION(:),
POINTER :: my_particles
6121 cpassert(colvar%type_id == voronoiipz_colvar_id)
6122 IF (
PRESENT(particles))
THEN
6123 my_particles => particles
6125 cpassert(
PRESENT(subsys))
6126 my_particles => subsys%particles%els
6129 n_atoms_a =
SIZE(colvar%voronoiipz_params%group_a)
6130 n_atoms_b =
SIZE(colvar%voronoiipz_params%group_b)
6131 n_atoms_o = n_atoms_a - colvar%voronoiipz_params%nrx
6132 cutoff = colvar%voronoiipz_params%nl_cutoff
6133 lambda = colvar%voronoiipz_params%lambda
6134 zidx = colvar%voronoiipz_params%zidx
6135 zmid = colvar%voronoiipz_params%zmid
6137 ALLOCATE (charge(n_atoms_a), charge_factor(n_atoms_a))
6138 ALLOCATE (distance_vector(3, n_atoms_a, n_atoms_b))
6139 ALLOCATE (inv_distance(n_atoms_a, n_atoms_b), weight(n_atoms_a, n_atoms_b))
6141 charge_factor = 0.0_dp
6142 distance_vector = 0.0_dp
6143 inv_distance = 0.0_dp
6149 jatom = colvar%voronoiipz_params%group_b(j)
6150 exponent_max = -huge(0.0_dp)
6152 iatom = colvar%voronoiipz_params%group_a(i)
6153 distance_vector(:, i, j) = pbc(my_particles(iatom)%r, my_particles(jatom)%r, cell)
6154 distance = norm2(distance_vector(:, i, j))
6155 IF (distance <= cutoff)
THEN
6156 IF (distance <= epsilon(0.0_dp))
THEN
6157 cpabort(
"VORONOIIPZ is undefined for coincident GROUPA and GROUPB atoms")
6159 inv_distance(i, j) = 1.0_dp/distance
6160 weight(i, j) = lambda*distance
6161 exponent_max = max(exponent_max, weight(i, j))
6165 denominator = 0.0_dp
6167 IF (inv_distance(i, j) > 0.0_dp)
THEN
6168 weight(i, j) = exp(weight(i, j) - exponent_max)
6169 denominator = denominator + weight(i, j)
6172 IF (denominator <= 0.0_dp)
THEN
6173 cpabort(
"VORONOIIPZ found a GROUPB atom without a GROUPA neighbor inside NL_CUTOFF")
6175 weight(:, j) = weight(:, j)/denominator
6178 charge(:) = sum(weight, dim=2)
6180 IF (i <= n_atoms_o)
THEN
6181 charge(i) = charge(i) - colvar%voronoiipz_params%d0
6183 SELECT CASE (i - n_atoms_o)
6185 charge(i) = charge(i) - colvar%voronoiipz_params%d1
6187 charge(i) = charge(i) - colvar%voronoiipz_params%d2
6189 charge(i) = charge(i) - colvar%voronoiipz_params%d3
6196 IF (charge(i) > 0.0_dp)
THEN
6197 iatom = colvar%voronoiipz_params%group_a(i)
6198 zdist = my_particles(iatom)%r(zidx) - zmid
6199 ion_z = ion_z + abs(zdist)*charge(i)**2
6200 charge_factor(i) = 2.0_dp*abs(zdist)*charge(i)
6201 IF (zdist > 0.0_dp)
THEN
6202 colvar%dsdr(zidx, i) = colvar%dsdr(zidx, i) + charge(i)**2
6203 ELSE IF (zdist < 0.0_dp)
THEN
6204 colvar%dsdr(zidx, i) = colvar%dsdr(zidx, i) - charge(i)**2
6211 weighted_charge_deriv = sum(weight(:, j)*charge_factor)
6213 IF (weight(i, j) > 0.0_dp)
THEN
6214 charge_deriv = charge_factor(i) - weighted_charge_deriv
6215 factor = lambda*weight(i, j)*charge_deriv*inv_distance(i, j)
6216 colvar%dsdr(:, i) = colvar%dsdr(:, i) - factor*distance_vector(:, i, j)
6217 colvar%dsdr(:, n_atoms_a + j) = colvar%dsdr(:, n_atoms_a + j) + &
6218 factor*distance_vector(:, i, j)
6224 DEALLOCATE (charge, charge_factor, distance_vector, inv_distance, weight)
6226 END SUBROUTINE colvar_eval_voronoiipz
6233 SUBROUTINE read_voronoiipz_colvars(voronoiipz_section, colvar)
6234 TYPE(section_vals_type),
POINTER :: voronoiipz_section
6235 TYPE(colvar_type),
POINTER :: colvar
6237 INTEGER :: i, j, n_atoms_a
6238 INTEGER,
DIMENSION(:),
POINTER :: atom_list
6240 CALL section_vals_val_get(voronoiipz_section,
"LAMBDA", r_val=colvar%voronoiipz_params%lambda)
6241 CALL section_vals_val_get(voronoiipz_section,
"ZIDX", i_val=colvar%voronoiipz_params%zidx)
6242 CALL section_vals_val_get(voronoiipz_section,
"NRX", i_val=colvar%voronoiipz_params%nrx)
6243 CALL section_vals_val_get(voronoiipz_section,
"ZMID", r_val=colvar%voronoiipz_params%zmid)
6244 CALL section_vals_val_get(voronoiipz_section,
"D_0", r_val=colvar%voronoiipz_params%d0)
6245 CALL section_vals_val_get(voronoiipz_section,
"D_1", r_val=colvar%voronoiipz_params%d1)
6246 CALL section_vals_val_get(voronoiipz_section,
"D_2", r_val=colvar%voronoiipz_params%d2)
6247 CALL section_vals_val_get(voronoiipz_section,
"D_3", r_val=colvar%voronoiipz_params%d3)
6248 CALL section_vals_val_get(voronoiipz_section,
"NL_CUTOFF", r_val=colvar%voronoiipz_params%nl_cutoff)
6251 CALL section_vals_val_get(voronoiipz_section,
"GROUPA", i_vals=atom_list)
6252 IF (.NOT.
ASSOCIATED(atom_list))
THEN
6253 cpabort(
"VORONOIIPZ requires a non-empty GROUPA")
6255 IF (
SIZE(atom_list) == 0) cpabort(
"VORONOIIPZ requires a non-empty GROUPA")
6256 ALLOCATE (colvar%voronoiipz_params%group_a(
SIZE(atom_list)))
6257 colvar%voronoiipz_params%group_a = atom_list
6260 CALL section_vals_val_get(voronoiipz_section,
"GROUPB", i_vals=atom_list)
6261 IF (.NOT.
ASSOCIATED(atom_list))
THEN
6262 cpabort(
"VORONOIIPZ requires a non-empty GROUPB")
6264 IF (
SIZE(atom_list) == 0) cpabort(
"VORONOIIPZ requires a non-empty GROUPB")
6265 ALLOCATE (colvar%voronoiipz_params%group_b(
SIZE(atom_list)))
6266 colvar%voronoiipz_params%group_b = atom_list
6268 n_atoms_a =
SIZE(colvar%voronoiipz_params%group_a)
6269 IF (colvar%voronoiipz_params%zidx < 1 .OR. colvar%voronoiipz_params%zidx > 3)
THEN
6270 cpabort(
"VORONOIIPZ ZIDX must be 1, 2, or 3")
6272 IF (colvar%voronoiipz_params%nrx < 0 .OR. colvar%voronoiipz_params%nrx > 3 .OR. &
6273 colvar%voronoiipz_params%nrx >= n_atoms_a)
THEN
6274 cpabort(
"VORONOIIPZ NRX must be between zero and three and smaller than the size of GROUPA")
6276 IF (colvar%voronoiipz_params%nl_cutoff <= 0.0_dp)
THEN
6277 cpabort(
"VORONOIIPZ NL_CUTOFF must be positive")
6279 IF (any(colvar%voronoiipz_params%group_a <= 0) .OR. &
6280 any(colvar%voronoiipz_params%group_b <= 0))
THEN
6281 cpabort(
"VORONOIIPZ atom indices must be positive")
6284 IF (any(colvar%voronoiipz_params%group_a(i) == colvar%voronoiipz_params%group_a(i + 1:)))
THEN
6285 cpabort(
"VORONOIIPZ GROUPA contains duplicate atom indices")
6287 IF (any(colvar%voronoiipz_params%group_a(i) == colvar%voronoiipz_params%group_b))
THEN
6288 cpabort(
"VORONOIIPZ GROUPA and GROUPB must be disjoint")
6291 DO j = 1,
SIZE(colvar%voronoiipz_params%group_b)
6292 IF (any(colvar%voronoiipz_params%group_b(j) == colvar%voronoiipz_params%group_b(j + 1:)))
THEN
6293 cpabort(
"VORONOIIPZ GROUPB contains duplicate atom indices")
6297 END SUBROUTINE read_voronoiipz_colvars
Handles all functions related to the CELL.
subroutine, public cell_transform_input_cartesian(cell, vector)
Transform a Cartesian real-space vector from the user input cell frame into CP2K's canonical internal...
defines collective variables s({R}) and the derivative of this variable wrt R these can then be used ...
subroutine, public colvar_eval_glob_f(icolvar, force_env)
evaluates the derivatives (dsdr) given and due to the given colvar
recursive subroutine, public colvar_read(colvar, icol, colvar_section, para_env, cell)
reads a colvar from the input
subroutine, public colvar_eval_mol_f(colvar, cell, particles, pos, fixd_list)
evaluates the derivatives (dsdr) given and due to the given colvar variables in a molecular environme...
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
integer, parameter, public voronoiipz_colvar_id
integer, parameter, public distance_from_path_colvar_id
integer, parameter, public rmsd_colvar_id
integer, parameter, public mindist_colvar_id
integer, parameter, public wc_colvar_id
integer, parameter, public acid_hyd_dist_colvar_id
integer, parameter, public xyz_outerdiag_colvar_id
integer, parameter, public do_clv_xz
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
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
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
subroutine, public check_fixed_atom_cns_colv(fixd_list, colvar)
...
various routines to log and control the output. The idea is that decisions about where to log should ...
integer function, public cp_logger_get_default_io_unit(logger)
returns the unit nr for the ionode (-1 on all other processors) skips as well checks if the procs cal...
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
routines to handle the output, The idea is to remove the decision of wheter to output and what to out...
integer function, public cp_print_key_unit_nr(logger, basis_section, print_key_path, extension, middle_name, local, log_filename, ignore_should_output, file_form, file_position, file_action, file_status, do_backup, on_file, is_new_file, mpi_io, fout)
...
subroutine, public cp_print_key_finished_output(unit_nr, logger, basis_section, print_key_path, local, ignore_should_output, on_file, mpi_io)
should be called after you finish working with a unit obtained with cp_print_key_unit_nr,...
Utility routines to read data from files. Kept as close as possible to the old parser because.
subroutine, public parser_get_next_line(parser, nline, at_end)
Read the next input line and broadcast the input information. Skip (nline-1) lines and skip also all ...
Utility routines to read data from files. Kept as close as possible to the old parser because.
subroutine, public parser_release(parser)
releases the parser
subroutine, public parser_create(parser, file_name, unit_nr, para_env, end_section_label, separator_chars, comment_char, continuation_char, quote_char, section_char, parse_white_lines, initial_variables, apply_preprocessing)
Start a parser run. Initial variables allow to @SET stuff before opening the file.
types that represent a subsys, i.e. a part of the system
subroutine, public cp_subsys_get(subsys, ref_count, atomic_kinds, atomic_kind_set, particles, particle_set, local_particles, molecules, molecule_set, molecule_kinds, molecule_kind_set, local_molecules, para_env, colvar_p, shell_particles, core_particles, gci, multipoles, natom, nparticle, ncore, nshell, nkind, atprop, virial, results, cell, cell_ref, use_ref_cell)
returns information about various attributes of the given subsys
real(kind=dp) function, public cp_unit_to_cp2k(value, unit_str, defaults, power)
converts to the internal cp2k units to the given unit
Interface for the force calculations.
integer, parameter, public use_mixed_force
recursive subroutine, public force_env_get(force_env, in_use, fist_env, qs_env, meta_env, fp_env, subsys, para_env, potential_energy, additional_potential, kinetic_energy, harmonic_shell, kinetic_shell, cell, sub_force_env, qmmm_env, qmmmx_env, eip_env, pwdft_env, globenv, input, force_env_section, method_name_id, root_section, mixed_env, nnp_env, embed_env, ipi_env)
returns various attributes about the force environment
subroutine, public get_generic_info(gen_section, func_name, xfunction, parameters, values, var_values, size_variables, i_rep_sec, input_variables)
Reads from the input structure all information for generic functions.
This public domain function parser module is intended for applications where a set of mathematical ex...
subroutine, public parsef(i, funcstr, var)
Parse ith function string FuncStr and compile it into bytecode.
real(rn) function, public evalf(i, val)
...
integer, public evalerrtype
real(kind=rn) function, public evalfd(id_fun, ipar, vals, h, err)
Evaluates derivatives.
subroutine, public finalizef()
...
subroutine, public initf(n)
...
sums arrays of real/complex numbers with much reduced round-off as compared to a naive implementation...
Defines the basic variable types.
integer, parameter, public dp
integer, parameter, public default_string_length
integer, parameter, public default_path_length
Definition of mathematical constants and functions.
real(kind=dp), parameter, public pi
real(kind=dp), parameter, public twopi
integer, parameter, public maxfac
real(kind=dp), dimension(0:maxfac), parameter, public fac
Collection of simple mathematical functions and subroutines.
pure real(kind=dp) function, public angle(a, b)
Calculation of the angle between the vectors a and b. The angle is returned in radians.
pure real(kind=dp) function, dimension(3), public vector_product(a, b)
Calculation of the vector product c = a x b.
Utility routines for the memory handling.
Interface to the message passing library MPI.
subroutine, public get_subsys_map_index(mapping_section, natom, iforce_eval, nforce_eval, map_index, force_eval_embed)
performs mapping of the subsystems of different force_eval
Define the molecule kind structure types and the corresponding functionality.
represent a simple array based list of the given type
Define the data structure for the particle information.
subroutine, public get_qs_env(qs_env, atomic_kind_set, qs_kind_set, cell, super_cell, cell_ref, use_ref_cell, kpoints, dft_control, mos, sab_orb, sab_all, qmmm, qmmm_periodic, mimic, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, matrix_vhxc, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, xcint_weights, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, rhoz_cneo_set, ecoul_1c, rho0_s_rs, rho0_s_gs, rhoz_cneo_s_rs, rhoz_cneo_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, lri_env, lri_density, exstate_env, ec_env, harris_env, dispersion_env, gcp_env, vee, rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, wanniercentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs, do_rixs, tb_tblite)
Get the QUICKSTEP environment.
Defines functions to perform rmsd in 3D.
subroutine, public rmsd3(particle_set, r, r0, output_unit, weights, my_val, rotate, transl, rot, drmsd3)
Computes the RMSD in 3D. Provides also derivatives.
Calculate spherical harmonics.
real(kind=dp) function, public legendre(x, l, m)
...
real(kind=dp) function, public dlegendre(x, l, m)
...
Utilities for string manipulations.
subroutine, public compress(string, full)
Eliminate multiple space characters in a string. If full is .TRUE., then all spaces are eliminated.
elemental subroutine, public uppercase(string)
Convert all lower case characters in a string to upper case.
defines the type needed for computing wannier states expectations
Type defining parameters related to the simulation cell.
parameters for a collective variable
type of a logger, at the moment it contains just a print level starting at which level it should be l...
represent a pointer to a subsys, to be able to create arrays of pointers
represents a system: atoms, molecules, their pos,vel,...
wrapper to abstract the force evaluation of the various methods
stores all the informations relevant to an mpi environment
represents a pointer to a list
represent a list of objects