37 #include "../base/base_uses.f90"
41 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'neb_md_utils'
67 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: vels
68 TYPE(section_vals_type),
POINTER :: neb_section
69 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
70 INTEGER,
INTENT(IN) :: i_rep, iw
71 TYPE(global_environment_type),
POINTER :: globenv
72 TYPE(neb_type),
POINTER :: neb_env
74 INTEGER :: iatom, ivar, natom, nparticle, nvar
75 REAL(kind=
dp) :: akin, mass, mass_tot, sc, temp, &
77 REAL(kind=
dp),
DIMENSION(3) :: v, vcom
78 TYPE(section_vals_type),
POINTER :: md_section
84 nparticle =
SIZE(vels, 1)
85 natom =
SIZE(particle_set)
88 CALL globenv%gaussian_rng_stream%fill(vels(:, i_rep))
92 IF (neb_env%use_colvar)
THEN
97 mass = particle_set(iatom)%atomic_kind%mass
98 mass_tot = mass_tot + mass
100 vcom(1:3) = vcom(1:3) + mass*v(1:3)
102 vcom(1:3) = vcom(1:3)/mass_tot
106 IF (neb_env%use_colvar)
THEN
108 akin = akin + 0.5_dp*
massunit*vels(ivar, i_rep)*vels(ivar, i_rep)
112 mass = particle_set(iatom)%atomic_kind%mass
115 akin = akin + 0.5_dp*mass*dot_product(v(1:3), v(1:3))
119 temp = 2.0_dp*akin/real(nvar, kind=
dp)
121 sc = sqrt(temp_ext/temp)
122 vels(:, i_rep) = vels(:, i_rep)*sc
126 IF (neb_env%use_colvar)
THEN
128 akin = akin + 0.5_dp*
massunit*vels(ivar, i_rep)*vels(ivar, i_rep)
132 mass = particle_set(iatom)%atomic_kind%mass
134 vcom(1:3) = vcom(1:3) + mass*v(1:3)
135 akin = akin + 0.5_dp*mass*dot_product(v(1:3), v(1:3))
138 vcom(1:3) = vcom(1:3)/mass_tot
141 temp = 2.0_dp*akin/real(nvar, kind=
dp)
143 WRITE (iw,
'(A,T61,F18.2,A2)') &
144 ' NEB| Initial Temperature ', tmp_r1,
" K"
145 WRITE (iw,
'(A,T61,F20.12)') &
146 ' NEB| Centre of mass velocity in direction x:', vcom(1), &
147 ' NEB| Centre of mass velocity in direction y:', vcom(2), &
148 ' NEB| Centre of mass velocity in direction z:', vcom(3)
149 WRITE (iw,
'(T2,"NEB|",75("*"))')
152 vels(:, i_rep) = 0.0_dp
169 TYPE(neb_var_type),
POINTER :: vels
170 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
171 TYPE(section_vals_type),
POINTER :: tc_section, vc_section
172 INTEGER,
INTENT(IN) :: output_unit, istep
174 INTEGER :: i, temp_tol_steps
176 REAL(kind=
dp) :: ext_temp, f_annealing, scale, temp_tol, &
177 temploc, tmp_r1, tmp_r2
178 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: temperatures
187 ALLOCATE (temperatures(
SIZE(vels%wrk, 2)))
191 IF (istep <= temp_tol_steps)
THEN
192 DO i = 2,
SIZE(vels%wrk, 2) - 1
193 temploc = temperatures(i)
194 IF (abs(temploc - ext_temp) > temp_tol)
THEN
195 IF (output_unit > 0)
THEN
198 WRITE (output_unit,
'(T2,"NEB| Replica Nr.",I5,'// &
199 '" - Velocity rescaled from: ",F12.6," to: ",F12.6,".")') &
203 scale = sqrt(ext_temp/temploc)
204 vels%wrk(:, i) = scale*vels%wrk(:, i)
208 DEALLOCATE (temperatures)
214 DO i = 2,
SIZE(vels%wrk, 2) - 1
215 vels%wrk(:, i) = f_annealing*vels%wrk(:, i)
228 TYPE(neb_var_type),
POINTER :: vels, forces
229 TYPE(section_vals_type),
POINTER :: vc_section
232 LOGICAL :: explicit, lval
233 REAL(kind=
dp) :: factor, norm
241 DO i = 2,
SIZE(vels%wrk, 2) - 1
242 norm = dot_product(forces%wrk(:, i), forces%wrk(:, i))
243 factor = dot_product(vels%wrk(:, i), forces%wrk(:, i))
244 IF (factor > 0 .AND. (norm >= epsilon(0.0_dp)))
THEN
245 vels%wrk(:, i) = factor/norm*forces%wrk(:, i)
247 vels%wrk(:, i) = 0.0_dp
253 DO i = 2,
SIZE(vels%wrk, 2) - 1
254 vels%wrk(:, i) = 0.0_dp
273 TYPE(neb_var_type),
POINTER :: vels
274 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
275 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: temperatures
276 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT),
OPTIONAL :: ekin
277 REAL(kind=
dp),
INTENT(IN),
OPTIONAL :: factor
279 INTEGER :: i_rep, iatom, ivar, n_rep, natom, nvar
280 REAL(kind=
dp) :: akin, mass, myfactor, temploc
281 REAL(kind=
dp),
DIMENSION(3) :: v
284 IF (
PRESENT(factor)) myfactor = factor
285 IF (
PRESENT(ekin)) ekin(:) = 0.0_dp
286 temperatures(:) = 0.0_dp
287 nvar =
SIZE(vels%wrk, 1)
288 n_rep =
SIZE(vels%wrk, 2)
289 natom =
SIZE(particle_set)
290 DO i_rep = 2, n_rep - 1
294 akin = akin + 0.5_dp*
massunit*vels%wrk(ivar, i_rep)*vels%wrk(ivar, i_rep)
298 mass = particle_set(iatom)%atomic_kind%mass
300 akin = akin + 0.5_dp*mass*dot_product(v(1:3), v(1:3))
304 IF (
PRESENT(ekin)) ekin(i_rep) = akin
305 temploc = 2.0_dp*akin/real(nvar, kind=
dp)
306 temperatures(i_rep) = temploc*myfactor
real(kind=dp) function, public cp_unit_from_cp2k(value, unit_str, defaults, power)
converts from the internal cp2k units to the given unit
Define type storing the global information of a run. Keep the amount of stored data small....
Defines the basic variable types.
integer, parameter, public dp
Module with utility to perform MD Nudged Elastic Band Calculation.
subroutine, public neb_initialize_velocity(vels, neb_section, particle_set, i_rep, iw, globenv, neb_env)
Initialize velocities of replica in an MD optimized algorithm within NEB.
subroutine, public get_temperatures(vels, particle_set, temperatures, ekin, factor)
Computes temperatures.
subroutine, public control_vels_a(vels, particle_set, tc_section, vc_section, output_unit, istep)
Control on velocities - I part.
subroutine, public control_vels_b(vels, forces, vc_section)
Control on velocities - II part.
Typo for Nudged Elastic Band Calculation.
Define the data structure for the particle information.
pure subroutine, public update_particle_pos_or_vel(iatom, particle_set, x, vector)
Update the atomic position or velocity by x and return the updated atomic position or velocity in x e...
pure real(kind=dp) function, dimension(3), public get_particle_pos_or_vel(iatom, particle_set, vector)
Return the atomic position or velocity of atom iatom in x from a packed vector even if core-shell par...
Definition of physical constants:
real(kind=dp), parameter, public kelvin
real(kind=dp), parameter, public massunit