(git:374b731)
Loading...
Searching...
No Matches
dimer_utils.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2024 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7
8! **************************************************************************************************
9!> \brief Contains utilities for a Dimer Method calculations
10!> \par History
11!> none
12!> \author Luca Bellucci and Teodoro Laino - created [tlaino] - 01.2008
13! **************************************************************************************************
21 USE kinds, ONLY: dp
23#include "../base/base_uses.f90"
24
25 IMPLICIT NONE
26 PRIVATE
27
28 LOGICAL, PRIVATE, PARAMETER :: debug_this_module = .true.
29 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'dimer_utils'
30
32 REAL(kind=dp), PARAMETER, PUBLIC :: dimer_thrs = epsilon(0.0_dp)*1.0e4_dp
33
34CONTAINS
35
36! **************************************************************************************************
37!> \brief Performs a rotation of the unit dimer vector
38!> \param nvec ...
39!> \param theta ...
40!> \param dt ...
41!> \par History
42!> none
43!> \author Luca Bellucci and Teodoro Laino - created [tlaino] - 01.2008
44! **************************************************************************************************
45 SUBROUTINE rotate_dimer(nvec, theta, dt)
46 REAL(kind=dp), DIMENSION(:), POINTER :: nvec, theta
47 REAL(kind=dp) :: dt
48
49 INTEGER :: output_unit
50 LOGICAL :: check
51
52 output_unit = cp_logger_get_default_io_unit()
53
54 ! Orthogonality check for the rotation..
55 check = abs(dot_product(nvec, theta)) < max(1.0e-9_dp, dimer_thrs)
56 IF (.NOT. check .AND. (output_unit > 0)) THEN
57 WRITE (output_unit, *) "NVEC and THETA should be orthogonal! Residue: ", &
58 abs(dot_product(nvec, theta))
59 END IF
60 cpassert(check)
61 nvec = nvec*cos(dt) + theta*sin(dt)
62
63 END SUBROUTINE rotate_dimer
64
65! **************************************************************************************************
66!> \brief Updates the orientation of the dimer vector in the input file
67!> \param dimer_env ...
68!> \param motion_section ...
69!> \par History
70!> none
71!> \author Luca Bellucci and Teodoro Laino - created [tlaino] - 01.2008
72! **************************************************************************************************
73 SUBROUTINE update_dimer_vec(dimer_env, motion_section)
74 TYPE(dimer_env_type), POINTER :: dimer_env
75 TYPE(section_vals_type), POINTER :: motion_section
76
77 INTEGER :: i, i_rep_val, isize, j, size_array
78 REAL(kind=dp), DIMENSION(:), POINTER :: array
79 TYPE(section_vals_type), POINTER :: nvec_section
80
81 nvec_section => section_vals_get_subs_vals(motion_section, &
82 "GEO_OPT%TRANSITION_STATE%DIMER%DIMER_VECTOR")
83 ! Clean the content of the section first..
84 CALL section_vals_remove_values(nvec_section)
85 ! Fill in the section with the present values..
86 size_array = 6
87 isize = 0
88 i_rep_val = 0
89 main_loop: DO i = 1, SIZE(dimer_env%nvec), size_array
90 ALLOCATE (array(size_array))
91 i_rep_val = i_rep_val + 1
92 DO j = 1, size_array
93 isize = isize + 1
94 array(j) = dimer_env%nvec(isize)
95 IF (isize == SIZE(dimer_env%nvec)) THEN
96 CALL reallocate(array, 1, j)
97 CALL section_vals_val_set(nvec_section, "_DEFAULT_KEYWORD_", r_vals_ptr=array, &
98 i_rep_val=i_rep_val)
99 EXIT main_loop
100 END IF
101 END DO
102 CALL section_vals_val_set(nvec_section, "_DEFAULT_KEYWORD_", r_vals_ptr=array, &
103 i_rep_val=i_rep_val)
104 END DO main_loop
105 cpassert(isize == SIZE(dimer_env%nvec))
106 END SUBROUTINE update_dimer_vec
107
108! **************************************************************************************************
109!> \brief This function orthonormalize the vector for the rotational search
110!> \param gradient ...
111!> \param dimer_env ...
112!> \param norm ...
113!> \par History
114!> none
115!> \author Luca Bellucci and Teodoro Laino - created [tlaino] - 01.2008
116! **************************************************************************************************
117 SUBROUTINE get_theta(gradient, dimer_env, norm)
118 REAL(kind=dp), DIMENSION(:) :: gradient
119 TYPE(dimer_env_type), POINTER :: dimer_env
120 REAL(kind=dp), INTENT(OUT) :: norm
121
122 gradient = gradient - dot_product(gradient, dimer_env%nvec)*dimer_env%nvec
123 norm = sqrt(dot_product(gradient, gradient))
124 IF (norm < epsilon(0.0_dp)) THEN
125 ! This means that NVEC is totally aligned with minimum curvature mode
126 gradient = 0.0_dp
127 ELSE
128 gradient = gradient/norm
129 END IF
130 END SUBROUTINE get_theta
131
132END MODULE dimer_utils
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...
Contains types used for a Dimer Method calculations.
Definition dimer_types.F:14
Contains utilities for a Dimer Method calculations.
Definition dimer_utils.F:14
subroutine, public update_dimer_vec(dimer_env, motion_section)
Updates the orientation of the dimer vector in the input file.
Definition dimer_utils.F:74
subroutine, public rotate_dimer(nvec, theta, dt)
Performs a rotation of the unit dimer vector.
Definition dimer_utils.F:46
subroutine, public get_theta(gradient, dimer_env, norm)
This function orthonormalize the vector for the rotational search.
real(kind=dp), parameter, public dimer_thrs
Definition dimer_utils.F:32
objects that represent the structure of input sections and the data contained in an input section
subroutine, public section_vals_val_set(section_vals, keyword_name, i_rep_section, i_rep_val, val, l_val, i_val, r_val, c_val, l_vals_ptr, i_vals_ptr, r_vals_ptr, c_vals_ptr)
sets the requested value
subroutine, public section_vals_remove_values(section_vals)
removes the values of a repetition of the section
recursive type(section_vals_type) function, pointer, public section_vals_get_subs_vals(section_vals, subsection_name, i_rep_section, can_return_null)
returns the values of the requested subsection
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
Utility routines for the memory handling.
Defines the environment for a Dimer Method calculation.
Definition dimer_types.F:94