72#include "../base/base_uses.f90"
76 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'neb_methods'
77 LOGICAL,
PARAMETER,
PRIVATE :: debug_this_module = .false.
92 SUBROUTINE neb(input, input_declaration, para_env, globenv)
98 CHARACTER(len=*),
PARAMETER :: routinen =
'neb'
100 INTEGER :: handle, ierr, iw, iw2, nrep, &
101 output_unit, prep, proc_dist_type
102 LOGICAL :: check, row_force
111 md_section, motion_section, &
112 neb_section, print_section
114 CALL timeset(routinen, handle)
115 NULLIFY (logger, subsys, f_env, rep_env)
116 NULLIFY (forces, coords, vels, neb_env)
127 nrep = max(1, para_env%num_pe/prep)
128 IF (nrep*prep /= para_env%num_pe .AND. output_unit > 0)
THEN
129 CALL cp_warn(__location__, &
130 "Number of totally requested processors ("//trim(adjustl(
cp_to_string(para_env%num_pe)))//
") "// &
131 "is not compatible with the number of processors requested per replica ("// &
132 trim(adjustl(
cp_to_string(prep)))//
") and the number of replicas ("// &
134 trim(adjustl(
cp_to_string(para_env%num_pe - nrep*prep)))//
"] processors will be wasted!")
138 IF (output_unit > 0)
WRITE (output_unit,
'(T2,"NEB|",A)')
" Replica_env Setup. START"
140 input_declaration=input_declaration, nrep=nrep, prep=prep, row_force=row_force)
141 IF (output_unit > 0)
WRITE (output_unit,
'(T2,"NEB|",A)')
" Replica_env Setup. END"
142 IF (
ASSOCIATED(rep_env))
THEN
143 cpassert(
SIZE(rep_env%local_rep_indices) == 1)
146 particle_set => subsys%particles%els
149 neb_env%force_env => f_env%force_env
150 neb_env%root_section => input
151 neb_env%force_env_section => force_env_section
152 neb_env%motion_print_section => print_section
153 neb_env%neb_section => neb_section
154 neb_env%nsize_xyz = rep_env%ndim
156 check = (neb_env%nsize_xyz >= neb_env%nsize_int)
165 CALL band_header(iw2, neb_env%number_of_replica, nrep, prep)
172 IF (output_unit > 0)
WRITE (output_unit,
'(T2,"NEB|",A)')
" Building initial set of coordinates. START"
178 "PROGRAM_RUN_INFO/INITIAL_CONFIGURATION_INFO")
179 IF (output_unit > 0)
WRITE (output_unit,
'(T2,"NEB|",A)')
" Building initial set of coordinates. END"
183 SELECT CASE (neb_env%opt_type)
185 neb_env%opt_type_label =
"MOLECULAR DYNAMICS"
187 CALL neb_md(rep_env, neb_env, coords, vels, forces, particle_set, output_unit, &
188 md_section, logger, globenv)
190 neb_env%opt_type_label =
"DIIS"
192 CALL neb_diis(rep_env, neb_env, coords, vels, forces, particle_set, output_unit, &
193 diis_section, logger, globenv)
208 CALL timestop(handle)
225 SUBROUTINE neb_md(rep_env, neb_env, coords, vels, forces, particle_set, output_unit, &
226 md_section, logger, globenv)
228 TYPE(
neb_type),
OPTIONAL,
POINTER :: neb_env
231 INTEGER,
INTENT(IN) :: output_unit
236 CHARACTER(len=*),
PARAMETER :: routinen =
'neb_md'
238 INTEGER :: handle, iatom, ic, is, istep, iw, &
239 max_steps, natom, shell_index
240 LOGICAL :: converged, should_stop
242 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: distances, energies
243 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: mass
247 CALL timeset(routinen, handle)
248 NULLIFY (dcoords, tc_section, vc_section)
249 cpassert(
ASSOCIATED(coords))
250 cpassert(
ASSOCIATED(vels))
252 IF (neb_env%id_type ==
do_sm)
THEN
253 cpwarn(
"MD band optimization and String Method incompatible.")
257 extension=
".replicaLog")
264 ALLOCATE (mass(
SIZE(coords%wrk, 1), neb_env%number_of_replica))
265 ALLOCATE (energies(neb_env%number_of_replica))
266 ALLOCATE (distances(neb_env%number_of_replica - 1))
268 IF (neb_env%use_colvar)
THEN
271 natom =
SIZE(particle_set)
274 shell_index = particle_set(iatom)%shell_index
275 IF (shell_index == 0)
THEN
276 mass(ic + 1:ic + 3, :) = 0.5_dp*dt/particle_set(iatom)%atomic_kind%mass
278 is = 3*(natom + shell_index - 1)
279 mass(ic + 1:ic + 3, :) = 0.5_dp*dt/particle_set(iatom)%atomic_kind%shell%mass_core
280 mass(is + 1:is + 3, :) = 0.5_dp*dt/particle_set(iatom)%atomic_kind%shell%mass_shell
285 CALL reorient_images(neb_env%rotate_frames, particle_set, coords, vels, &
286 output_unit, distances, neb_env%number_of_replica)
287 neb_env%avg_distance = sqrt(sum(distances*distances)/real(
SIZE(distances), kind=
dp))
295 particle_set=particle_set, &
299 distances=distances, &
300 output_unit=output_unit)
301 md_opt_loop:
DO istep = 1, max_steps
302 CALL cp_iterate(logger%iter_info, iter_nr=istep)
304 neb_env%istep = istep
306 vels%wrk(:, :) = vels%wrk(:, :) + mass(:, :)*forces%wrk(:, :)
308 CALL control_vels_a(vels, particle_set, tc_section, vc_section, output_unit, &
311 dcoords%wrk(:, :) = dt*vels%wrk(:, :)
312 coords%wrk(:, :) = coords%wrk(:, :) + dcoords%wrk(:, :)
314 CALL reorient_images(neb_env%rotate_frames, particle_set, coords, vels, &
315 output_unit, distances, neb_env%number_of_replica)
316 neb_env%avg_distance = sqrt(sum(distances*distances)/real(
SIZE(distances), kind=
dp))
321 IF (should_stop)
EXIT
325 vels%wrk(:, :) = vels%wrk(:, :) + mass(:, :)*forces%wrk(:, :)
331 particle_set=particle_set, &
335 distances=distances, &
336 output_unit=output_unit)
342 DEALLOCATE (energies)
343 DEALLOCATE (distances)
347 CALL timestop(handle)
349 END SUBROUTINE neb_md
365 SUBROUTINE neb_diis(rep_env, neb_env, coords, vels, forces, particle_set, output_unit, &
366 diis_section, logger, globenv)
368 TYPE(
neb_type),
OPTIONAL,
POINTER :: neb_env
371 INTEGER,
INTENT(IN) :: output_unit
376 CHARACTER(len=*),
PARAMETER :: routinen =
'neb_diis'
378 INTEGER :: handle, istep, iw, iw2, max_sd_steps, &
380 INTEGER,
DIMENSION(:),
POINTER :: set_err
381 LOGICAL :: check_diis, converged, diis_on, do_ls, &
383 REAL(kind=
dp) :: max_stepsize, norm, stepsize, stepsize0
384 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: distances, energies
385 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: crr, err
388 CALL timeset(routinen, handle)
389 NULLIFY (sline, crr, err)
390 neb_env%opt_type_label =
"SD"
392 cpassert(
ASSOCIATED(coords))
393 cpassert(
ASSOCIATED(vels))
394 cpassert(
ASSOCIATED(forces))
396 extension=
".replicaLog")
405 extension=
".diisLog")
411 ALLOCATE (err(product(coords%size_wrk), n_diis))
412 ALLOCATE (crr(product(coords%size_wrk), n_diis))
413 ALLOCATE (set_err(n_diis))
414 ALLOCATE (energies(neb_env%number_of_replica))
415 ALLOCATE (distances(neb_env%number_of_replica - 1))
417 CALL reorient_images(neb_env%rotate_frames, particle_set, coords, vels, &
418 output_unit, distances, neb_env%number_of_replica)
420 neb_env%smoothing, coords%wrk, sline%wrk, distances)
421 neb_env%avg_distance = sqrt(sum(distances*distances)/real(
SIZE(distances), kind=
dp))
428 particle_set=particle_set, &
432 distances=distances, &
434 output_unit=output_unit)
437 neb_env%rotate_frames = .false.
440 DO istep = 1, max_steps
441 CALL cp_iterate(logger%iter_info, iter_nr=istep)
442 neb_env%opt_type_label =
"SD"
444 neb_env%istep = istep
446 norm = sqrt(sum(forces%wrk*forces%wrk))
447 IF (norm < epsilon(0.0_dp))
THEN
452 sline%wrk = forces%wrk/norm
453 IF (do_ls .AND. (.NOT. skip_ls))
THEN
454 CALL neb_ls(stepsize, sline, rep_env, neb_env, coords, energies, forces, &
455 vels, particle_set, iw, output_unit, distances, diis_section, iw2)
457 WRITE (iw2,
'(T2,A,T69,F12.6)')
"SD| Stepsize in SD after linesearch", &
460 stepsize = min(norm*stepsize0, max_stepsize)
462 WRITE (iw2,
'(T2,A,T69,F12.6)')
"SD| Stepsize in SD no linesearch performed", &
465 sline%wrk = stepsize*sline%wrk
466 diis_on =
accept_diis_step(istep > max_sd_steps, n_diis, err, crr, set_err, sline, coords, &
469 neb_env%opt_type_label =
"DIIS"
472 IF (count(set_err == -1) == 1) do_ls = .false.
473 coords%wrk = coords%wrk + sline%wrk
475 CALL reorient_images(neb_env%rotate_frames, particle_set, coords, vels, &
476 output_unit, distances, neb_env%number_of_replica)
478 neb_env%smoothing, coords%wrk, sline%wrk, distances)
479 neb_env%avg_distance = sqrt(sum(distances*distances)/real(
SIZE(distances), kind=
dp))
484 IF (should_stop)
EXIT
489 particle_set=particle_set, &
493 distances=distances, &
495 output_unit=output_unit)
500 DEALLOCATE (energies)
501 DEALLOCATE (distances)
506 CALL timestop(handle)
507 END SUBROUTINE neb_diis
evaluations of colvar for internal coordinates schemes
integer function, public number_of_colvar(force_env, only_intra_colvar, unique)
Gives back the number of colvar defined for a force_eval.
Routines to handle the external control of CP2K.
subroutine, public external_control(should_stop, flag, globenv, target_time, start_time, force_check)
External manipulations during a run : when the <PROJECT_NAME>.EXIT_$runtype command is sent the progr...
various routines to log and control the output. The idea is that decisions about where to log should ...
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,...
subroutine, public cp_iterate(iteration_info, last, iter_nr, increment, iter_nr_out)
adds one to the actual iteration
subroutine, public cp_rm_iter_level(iteration_info, level_name, n_rlevel_att)
Removes an iteration level.
subroutine, public cp_add_iter_level(iteration_info, level_name, n_rlevel_new)
Adds an iteration level.
types that represent a subsys, i.e. a part of the system
interface to use cp2k as library
subroutine, public f_env_add_defaults(f_env_id, f_env, handle)
adds the default environments of the f_env to the stack of the defaults, and returns a new error and ...
subroutine, public f_env_rm_defaults(f_env, ierr, handle)
removes the default environments of the f_env to the stack of the defaults, and sets ierr accordingly...
Interface for the force calculations.
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
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
Interface to the message passing library MPI.
I/O Module for Nudged Elastic Band Calculation.
subroutine, public read_neb_section(neb_env, neb_section)
Read data from the NEB input section.
subroutine, public neb_rep_env_map_info(rep_env, neb_env)
Print some mapping infos in the replica_env setup output files i.e. prints in which files one can fin...
subroutine, public dump_neb_info(neb_env, coords, vels, forces, particle_set, logger, istep, energies, distances, output_unit)
dump print info of a NEB run
Module with utility to perform MD Nudged Elastic Band Calculation.
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.
Module performing a Nudged Elastic Band Calculation.
subroutine, public neb(input, input_declaration, para_env, globenv)
Real subroutine for NEB calculations.
Module with utility to perform MD Nudged Elastic Band Calculation.
logical function, public accept_diis_step(apply_diis, n_diis, err, crr, set_err, sline, coords, check_diis, iw2)
Performs few basic operations for the NEB DIIS optimization.
subroutine, public neb_ls(stepsize, sline, rep_env, neb_env, coords, energies, forces, vels, particle_set, iw, output_unit, distances, diis_section, iw2)
Perform a line minimization search in optimizing a NEB with DIIS.
Typo for Nudged Elastic Band Calculation.
subroutine, public neb_var_release(neb_var)
Releases a variable type for BAND calculation.
subroutine, public neb_var_create(neb_var, neb_env, full_allocation)
Creates a variable type for BAND calculation.
Module with utility for Nudged Elastic Band Calculation.
subroutine, public neb_calc_energy_forces(rep_env, neb_env, coords, energies, forces, particle_set, output_unit)
Driver to compute energy and forces within a NEB, Based on the use of the replica_env.
logical function, public check_convergence(neb_env, dcoords, forces)
Checks for convergence criteria during a NEB run.
subroutine, public build_replica_coords(neb_section, particle_set, coords, vels, neb_env, iw, globenv, para_env)
Constructs or Read the coordinates for all replica.
subroutine, public reorient_images(rotate_frames, particle_set, coords, vels, iw, distances, number_of_replica)
Reorient iteratively all images of the NEB chain in order to have always the smaller RMSD between two...
subroutine, public reparametrize_images(reparametrize_frames, spline_order, smoothing, coords, sline, distances)
Reparametrization of the replica for String Method with splines.
Define the data structure for the particle information.
Definition of physical constants:
real(kind=dp), parameter, public massunit
methods to setup replicas of the same system differing only by atom positions and velocities (as used...
subroutine, public rep_env_create(rep_env, para_env, input, input_declaration, nrep, prep, sync_v, keep_wf_history, row_force)
creates a replica environment together with its force environment
types used to handle many replica of the same system that differ only in atom positions,...
subroutine, public rep_env_release(rep_env)
releases the given replica environment
type of a logger, at the moment it contains just a print level starting at which level it should be l...
represents a system: atoms, molecules, their pos,vel,...
contains the initially parsed file and the initial parallel environment
stores all the informations relevant to an mpi environment
keeps replicated information about the replicas