73#include "../base/base_uses.f90"
77 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'neb_methods'
78 LOGICAL,
PARAMETER,
PRIVATE :: debug_this_module = .false.
93 SUBROUTINE neb(input, input_declaration, para_env, globenv)
99 CHARACTER(len=*),
PARAMETER :: routinen =
'neb'
101 INTEGER :: handle, ierr, iw, iw2, nrep, &
102 output_unit, prep, proc_dist_type
103 LOGICAL :: check, row_force
112 md_section, motion_section, &
113 neb_section, print_section
115 CALL timeset(routinen, handle)
116 NULLIFY (logger, subsys, f_env, rep_env)
117 NULLIFY (forces, coords, vels, neb_env)
128 nrep = max(1, para_env%num_pe/prep)
129 IF (nrep*prep /= para_env%num_pe .AND. output_unit > 0)
THEN
130 CALL cp_warn(__location__, &
131 "Number of totally requested processors ("//trim(adjustl(
cp_to_string(para_env%num_pe)))//
") "// &
132 "is not compatible with the number of processors requested per replica ("// &
133 trim(adjustl(
cp_to_string(prep)))//
") and the number of replicas ("// &
135 trim(adjustl(
cp_to_string(para_env%num_pe - nrep*prep)))//
"] processors will be wasted!")
139 IF (output_unit > 0)
WRITE (output_unit,
'(T2,"NEB|",A)')
" Replica_env Setup. START"
141 input_declaration=input_declaration, nrep=nrep, prep=prep, row_force=row_force)
142 IF (output_unit > 0)
WRITE (output_unit,
'(T2,"NEB|",A)')
" Replica_env Setup. END"
143 IF (
ASSOCIATED(rep_env))
THEN
144 cpassert(
SIZE(rep_env%local_rep_indices) == 1)
147 particle_set => subsys%particles%els
150 neb_env%force_env => f_env%force_env
151 neb_env%root_section => input
152 neb_env%force_env_section => force_env_section
153 neb_env%motion_print_section => print_section
154 neb_env%neb_section => neb_section
155 neb_env%nsize_xyz = rep_env%ndim
157 check = (neb_env%nsize_xyz >= neb_env%nsize_int)
166 CALL band_header(iw2, neb_env%number_of_replica, nrep, prep)
173 IF (output_unit > 0)
WRITE (output_unit,
'(T2,"NEB|",A)')
" Building initial set of coordinates. START"
179 "PROGRAM_RUN_INFO/INITIAL_CONFIGURATION_INFO")
180 IF (output_unit > 0)
WRITE (output_unit,
'(T2,"NEB|",A)')
" Building initial set of coordinates. END"
184 SELECT CASE (neb_env%opt_type)
186 neb_env%opt_type_label =
"MOLECULAR DYNAMICS"
188 CALL neb_md(rep_env, neb_env, coords, vels, forces, particle_set, output_unit, &
189 md_section, logger, globenv)
191 neb_env%opt_type_label =
"DIIS"
193 CALL neb_diis(rep_env, neb_env, coords, vels, forces, particle_set, output_unit, &
194 diis_section, logger, globenv)
209 CALL timestop(handle)
226 SUBROUTINE neb_md(rep_env, neb_env, coords, vels, forces, particle_set, output_unit, &
227 md_section, logger, globenv)
229 TYPE(
neb_type),
OPTIONAL,
POINTER :: neb_env
232 INTEGER,
INTENT(IN) :: output_unit
237 CHARACTER(len=*),
PARAMETER :: routinen =
'neb_md'
239 INTEGER :: handle, iatom, ic, is, istep, iw, &
240 max_steps, natom, shell_index
241 LOGICAL :: converged, should_stop
243 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: distances, energies
244 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: mass
248 CALL timeset(routinen, handle)
249 NULLIFY (dcoords, tc_section, vc_section)
250 cpassert(
ASSOCIATED(coords))
251 cpassert(
ASSOCIATED(vels))
253 IF (neb_env%id_type ==
do_sm)
THEN
254 cpwarn(
"MD band optimization and String Method incompatible.")
258 extension=
".replicaLog")
265 ALLOCATE (mass(
SIZE(coords%wrk, 1), neb_env%number_of_replica))
266 ALLOCATE (energies(neb_env%number_of_replica))
267 ALLOCATE (distances(neb_env%number_of_replica - 1))
269 IF (neb_env%use_colvar)
THEN
272 natom =
SIZE(particle_set)
275 shell_index = particle_set(iatom)%shell_index
276 IF (shell_index == 0)
THEN
277 mass(ic + 1:ic + 3, :) = 0.5_dp*dt/particle_set(iatom)%atomic_kind%mass
279 is = 3*(natom + shell_index - 1)
280 mass(ic + 1:ic + 3, :) = 0.5_dp*dt/particle_set(iatom)%atomic_kind%shell%mass_core
281 mass(is + 1:is + 3, :) = 0.5_dp*dt/particle_set(iatom)%atomic_kind%shell%mass_shell
286 CALL reorient_images(neb_env%rotate_frames, particle_set, coords, vels, &
287 output_unit, distances, neb_env%number_of_replica)
288 neb_env%avg_distance = sqrt(sum(distances*distances)/real(
SIZE(distances), kind=
dp))
296 particle_set=particle_set, &
300 distances=distances, &
301 output_unit=output_unit)
302 md_opt_loop:
DO istep = 1, max_steps
303 CALL cp_iterate(logger%iter_info, iter_nr=istep)
305 neb_env%istep = istep
307 vels%wrk(:, :) = vels%wrk(:, :) + mass(:, :)*forces%wrk(:, :)
309 CALL control_vels_a(vels, particle_set, tc_section, vc_section, output_unit, &
312 dcoords%wrk(:, :) = dt*vels%wrk(:, :)
313 coords%wrk(:, :) = coords%wrk(:, :) + dcoords%wrk(:, :)
315 CALL reorient_images(neb_env%rotate_frames, particle_set, coords, vels, &
316 output_unit, distances, neb_env%number_of_replica)
317 neb_env%avg_distance = sqrt(sum(distances*distances)/real(
SIZE(distances), kind=
dp))
322 IF (should_stop)
EXIT md_opt_loop
326 vels%wrk(:, :) = vels%wrk(:, :) + mass(:, :)*forces%wrk(:, :)
332 particle_set=particle_set, &
336 distances=distances, &
337 output_unit=output_unit)
340 IF (output_unit > 0)
THEN
341 WRITE (unit=output_unit, fmt=
"(/,T2,A)") repeat(
"*", 79)
342 WRITE (unit=output_unit, fmt=
"(T2,A,T32,A,T78,A)") &
343 "***",
"BAND TASK COMPLETED",
"***"
344 WRITE (unit=output_unit, fmt=
"(T2,A)") repeat(
"*", 79)
349 CALL dump_neb_final(neb_env, energies, coords, particle_set, logger, output_unit, converged)
351 DEALLOCATE (energies)
352 DEALLOCATE (distances)
356 CALL timestop(handle)
358 END SUBROUTINE neb_md
374 SUBROUTINE neb_diis(rep_env, neb_env, coords, vels, forces, particle_set, output_unit, &
375 diis_section, logger, globenv)
377 TYPE(
neb_type),
OPTIONAL,
POINTER :: neb_env
380 INTEGER,
INTENT(IN) :: output_unit
385 CHARACTER(len=*),
PARAMETER :: routinen =
'neb_diis'
387 INTEGER :: handle, istep, iw, iw2, max_sd_steps, &
389 INTEGER,
DIMENSION(:),
POINTER :: set_err
390 LOGICAL :: check_diis, converged, diis_on, do_ls, &
392 REAL(kind=
dp) :: max_stepsize, norm, stepsize, stepsize0
393 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: distances, energies
394 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: crr, err
397 CALL timeset(routinen, handle)
398 NULLIFY (sline, crr, err)
399 neb_env%opt_type_label =
"SD"
401 cpassert(
ASSOCIATED(coords))
402 cpassert(
ASSOCIATED(vels))
403 cpassert(
ASSOCIATED(forces))
405 extension=
".replicaLog")
414 extension=
".diisLog")
420 ALLOCATE (err(product(coords%size_wrk), n_diis))
421 ALLOCATE (crr(product(coords%size_wrk), n_diis))
422 ALLOCATE (set_err(n_diis))
423 ALLOCATE (energies(neb_env%number_of_replica))
424 ALLOCATE (distances(neb_env%number_of_replica - 1))
426 CALL reorient_images(neb_env%rotate_frames, particle_set, coords, vels, &
427 output_unit, distances, neb_env%number_of_replica)
429 neb_env%smoothing, coords%wrk, sline%wrk, distances)
430 neb_env%avg_distance = sqrt(sum(distances*distances)/real(
SIZE(distances), kind=
dp))
437 particle_set=particle_set, &
441 distances=distances, &
443 output_unit=output_unit)
446 neb_env%rotate_frames = .false.
449 DO istep = 1, max_steps
450 CALL cp_iterate(logger%iter_info, iter_nr=istep)
451 neb_env%opt_type_label =
"SD"
453 neb_env%istep = istep
455 norm = sqrt(sum(forces%wrk*forces%wrk))
456 IF (norm < epsilon(0.0_dp))
THEN
461 sline%wrk = forces%wrk/norm
462 IF (do_ls .AND. (.NOT. skip_ls))
THEN
463 CALL neb_ls(stepsize, sline, rep_env, neb_env, coords, energies, forces, &
464 vels, particle_set, iw, output_unit, distances, diis_section, iw2)
466 WRITE (iw2,
'(T2,A,T69,F12.6)')
"SD| Stepsize in SD after linesearch", &
469 stepsize = min(norm*stepsize0, max_stepsize)
471 WRITE (iw2,
'(T2,A,T69,F12.6)')
"SD| Stepsize in SD no linesearch performed", &
474 sline%wrk = stepsize*sline%wrk
475 diis_on =
accept_diis_step(istep > max_sd_steps, n_diis, err, crr, set_err, sline, coords, &
478 neb_env%opt_type_label =
"DIIS"
481 IF (count(set_err == -1) == 1) do_ls = .false.
482 coords%wrk = coords%wrk + sline%wrk
484 CALL reorient_images(neb_env%rotate_frames, particle_set, coords, vels, &
485 output_unit, distances, neb_env%number_of_replica)
487 neb_env%smoothing, coords%wrk, sline%wrk, distances)
488 neb_env%avg_distance = sqrt(sum(distances*distances)/real(
SIZE(distances), kind=
dp))
493 IF (should_stop)
EXIT
498 particle_set=particle_set, &
502 distances=distances, &
504 output_unit=output_unit)
508 IF (output_unit > 0)
THEN
509 WRITE (unit=output_unit, fmt=
"(/,T2,A)") repeat(
"*", 79)
510 WRITE (unit=output_unit, fmt=
"(T2,A,T32,A,T78,A)") &
511 "***",
"BAND TASK COMPLETED",
"***"
512 WRITE (unit=output_unit, fmt=
"(T2,A)") repeat(
"*", 79)
517 CALL dump_neb_final(neb_env, energies, coords, particle_set, logger, output_unit, converged)
518 DEALLOCATE (energies)
519 DEALLOCATE (distances)
526 CALL timestop(handle)
527 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
subroutine, public dump_neb_final(neb_env, energies, coords, particle_set, logger, output_unit, converged)
dump final structures after 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.
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.
logical function, public check_convergence(neb_env, dcoords, forces, logger)
Checks for convergence criteria during a NEB run.
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