(git:34ef472)
neb_io.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 I/O Module for Nudged Elastic Band Calculation
10 !> \note
11 !> Numerical accuracy for parallel runs:
12 !> Each replica starts the SCF run from the one optimized
13 !> in a previous run. It may happen then energies and derivatives
14 !> of a serial run and a parallel run could be slightly different
15 !> 'cause of a different starting density matrix.
16 !> Exact results are obtained using:
17 !> EXTRAPOLATION USE_GUESS in QS section (Teo 09.2006)
18 !> \author Teodoro Laino 10.2006
19 ! **************************************************************************************************
20 MODULE neb_io
21  USE cell_types, ONLY: cell_type
22  USE cp2k_info, ONLY: get_runtime_info
23  USE cp_files, ONLY: close_file,&
24  open_file
27  cp_logger_type,&
29  cp_to_string
32  USE cp_units, ONLY: cp_unit_from_cp2k
35  f_env_type
36  USE force_env_types, ONLY: force_env_get,&
38  USE header, ONLY: cp2k_footer
39  USE input_constants, ONLY: band_md_opt,&
40  do_sm,&
41  dump_xmol,&
42  pot_neb_fe,&
43  pot_neb_full,&
48  enumeration_type
49  USE input_keyword_types, ONLY: keyword_get,&
50  keyword_type
53  section_type,&
56  section_vals_type,&
59  USE kinds, ONLY: default_path_length,&
61  dp
62  USE machine, ONLY: m_flush
64  USE neb_types, ONLY: neb_type,&
65  neb_var_type
68  particle_type
69  USE physcon, ONLY: angstrom
70  USE replica_types, ONLY: replica_env_type
71 #include "../base/base_uses.f90"
72 
73  IMPLICIT NONE
74  PRIVATE
75  CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'neb_io'
76 
77  PUBLIC :: read_neb_section, &
78  dump_neb_info, &
82 
83 CONTAINS
84 
85 ! **************************************************************************************************
86 !> \brief Read data from the NEB input section
87 !> \param neb_env ...
88 !> \param neb_section ...
89 !> \author Teodoro Laino 09.2006
90 ! **************************************************************************************************
91  SUBROUTINE read_neb_section(neb_env, neb_section)
92  TYPE(neb_type), POINTER :: neb_env
93  TYPE(section_vals_type), POINTER :: neb_section
94 
95  LOGICAL :: explicit
96  TYPE(section_vals_type), POINTER :: wrk_section
97 
98  cpassert(ASSOCIATED(neb_env))
99  neb_env%istep = 0
100  CALL section_vals_val_get(neb_section, "BAND_TYPE", i_val=neb_env%id_type)
101  CALL section_vals_val_get(neb_section, "NUMBER_OF_REPLICA", i_val=neb_env%number_of_replica)
102  CALL section_vals_val_get(neb_section, "K_SPRING", r_val=neb_env%K)
103  CALL section_vals_val_get(neb_section, "ROTATE_FRAMES", l_val=neb_env%rotate_frames)
104  CALL section_vals_val_get(neb_section, "ALIGN_FRAMES", l_val=neb_env%align_frames)
105  CALL section_vals_val_get(neb_section, "OPTIMIZE_BAND%OPTIMIZE_END_POINTS", l_val=neb_env%optimize_end_points)
106  ! Climb Image NEB
107  CALL section_vals_val_get(neb_section, "CI_NEB%NSTEPS_IT", i_val=neb_env%nsteps_it)
108  ! Band Optimization Type
109  CALL section_vals_val_get(neb_section, "OPTIMIZE_BAND%OPT_TYPE", i_val=neb_env%opt_type)
110  ! Use colvars
111  CALL section_vals_val_get(neb_section, "USE_COLVARS", l_val=neb_env%use_colvar)
112  CALL section_vals_val_get(neb_section, "POT_TYPE", i_val=neb_env%pot_type)
113  ! Before continuing let's do some consistency check between keywords
114  IF (neb_env%pot_type /= pot_neb_full) THEN
115  ! Requires the use of colvars
116  IF (.NOT. neb_env%use_colvar) &
117  CALL cp_abort(__location__, &
118  "A potential energy function based on free energy or minimum energy"// &
119  " was requested without enabling the usage of COLVARS. Both methods"// &
120  " are based on COLVARS definition.")
121  ! Moreover let's check if the proper sections have been defined..
122  SELECT CASE (neb_env%pot_type)
123  CASE (pot_neb_fe)
124  wrk_section => section_vals_get_subs_vals(neb_env%root_section, "MOTION%MD")
125  CALL section_vals_get(wrk_section, explicit=explicit)
126  IF (.NOT. explicit) &
127  CALL cp_abort(__location__, &
128  "A free energy BAND (colvars projected) calculation is requested"// &
129  " but NONE MD section was defined in the input.")
130  CASE (pot_neb_me)
131  wrk_section => section_vals_get_subs_vals(neb_env%root_section, "MOTION%GEO_OPT")
132  CALL section_vals_get(wrk_section, explicit=explicit)
133  IF (.NOT. explicit) &
134  CALL cp_abort(__location__, &
135  "A minimum energy BAND (colvars projected) calculation is requested"// &
136  " but NONE GEO_OPT section was defined in the input.")
137  END SELECT
138  ELSE
139  IF (neb_env%use_colvar) &
140  CALL cp_abort(__location__, &
141  "A band calculation was requested with a full potential energy. USE_COLVAR cannot"// &
142  " be set for this kind of calculation!")
143  END IF
144  ! String Method
145  CALL section_vals_val_get(neb_section, "STRING_METHOD%SMOOTHING", r_val=neb_env%smoothing)
146  CALL section_vals_val_get(neb_section, "STRING_METHOD%SPLINE_ORDER", i_val=neb_env%spline_order)
147  neb_env%reparametrize_frames = .false.
148  IF (neb_env%id_type == do_sm) THEN
149  neb_env%reparametrize_frames = .true.
150  END IF
151  END SUBROUTINE read_neb_section
152 
153 ! **************************************************************************************************
154 !> \brief dump print info of a NEB run
155 !> \param neb_env ...
156 !> \param coords ...
157 !> \param vels ...
158 !> \param forces ...
159 !> \param particle_set ...
160 !> \param logger ...
161 !> \param istep ...
162 !> \param energies ...
163 !> \param distances ...
164 !> \param output_unit ...
165 !> \author Teodoro Laino 09.2006
166 ! **************************************************************************************************
167  SUBROUTINE dump_neb_info(neb_env, coords, vels, forces, particle_set, logger, &
168  istep, energies, distances, output_unit)
169  TYPE(neb_type), POINTER :: neb_env
170  TYPE(neb_var_type), POINTER :: coords
171  TYPE(neb_var_type), OPTIONAL, POINTER :: vels, forces
172  TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
173  TYPE(cp_logger_type), POINTER :: logger
174  INTEGER, INTENT(IN) :: istep
175  REAL(kind=dp), DIMENSION(:), INTENT(IN) :: energies, distances
176  INTEGER, INTENT(IN) :: output_unit
177 
178  CHARACTER(len=*), PARAMETER :: routinen = 'dump_neb_info'
179 
180  CHARACTER(LEN=20) :: mytype
181  CHARACTER(LEN=default_string_length) :: line, title, unit_str
182  INTEGER :: crd, ener, frc, handle, i, irep, ndig, &
183  ndigl, ttst, vel
184  LOGICAL :: explicit, lval, print_kind
185  REAL(kind=dp) :: f_ann, tmp_r1, unit_conv
186  REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: ekin, temperatures
187  TYPE(cell_type), POINTER :: cell
188  TYPE(enumeration_type), POINTER :: enum
189  TYPE(keyword_type), POINTER :: keyword
190  TYPE(section_type), POINTER :: section
191  TYPE(section_vals_type), POINTER :: tc_section, vc_section
192 
193  CALL timeset(routinen, handle)
194  ndig = ceiling(log10(real(neb_env%number_of_replica + 1, kind=dp)))
195  CALL force_env_get(neb_env%force_env, cell=cell)
196  DO irep = 1, neb_env%number_of_replica
197  ndigl = ceiling(log10(real(irep + 1, kind=dp)))
198  WRITE (line, '(A,'//cp_to_string(ndig)//'("0"),T'//cp_to_string(11 + ndig + 1 - ndigl)//',I0)') "Replica_nr_", irep
199  crd = cp_print_key_unit_nr(logger, neb_env%motion_print_section, "TRAJECTORY", &
200  extension=".xyz", file_form="FORMATTED", middle_name="pos-"//trim(line))
201  IF (PRESENT(vels)) THEN
202  vel = cp_print_key_unit_nr(logger, neb_env%motion_print_section, "VELOCITIES", &
203  extension=".xyz", file_form="FORMATTED", middle_name="vel-"//trim(line))
204  END IF
205  IF (PRESENT(forces)) THEN
206  frc = cp_print_key_unit_nr(logger, neb_env%motion_print_section, "FORCES", &
207  extension=".xyz", file_form="FORMATTED", middle_name="force-"//trim(line))
208  END IF
209  ! Dump Trajectory
210  IF (crd > 0) THEN
211  ! Gather units of measure for output
212  CALL section_vals_val_get(neb_env%motion_print_section, "TRAJECTORY%UNIT", &
213  c_val=unit_str)
214  CALL section_vals_val_get(neb_env%motion_print_section, "TRAJECTORY%PRINT_ATOM_KIND", &
215  l_val=print_kind)
216  unit_conv = cp_unit_from_cp2k(1.0_dp, trim(unit_str))
217  ! This information can be digested by Molden
218  WRITE (unit=title, fmt="(A,I8,A,F20.10)") " i =", istep, ", E =", energies(irep)
219  CALL write_particle_coordinates(particle_set, crd, dump_xmol, "POS", title, &
220  cell=cell, array=coords%xyz(:, irep), unit_conv=unit_conv, &
221  print_kind=print_kind)
222  CALL m_flush(crd)
223  END IF
224  ! Dump Velocities
225  IF (vel > 0 .AND. PRESENT(vels)) THEN
226  ! Gather units of measure for output
227  CALL section_vals_val_get(neb_env%motion_print_section, "VELOCITIES%UNIT", &
228  c_val=unit_str)
229  CALL section_vals_val_get(neb_env%motion_print_section, "VELOCITIES%PRINT_ATOM_KIND", &
230  l_val=print_kind)
231  unit_conv = cp_unit_from_cp2k(1.0_dp, trim(unit_str))
232  WRITE (unit=title, fmt="(A,I8,A,F20.10)") " i =", istep, ", E =", energies(irep)
233  CALL write_particle_coordinates(particle_set, vel, dump_xmol, "VEL", title, &
234  cell=cell, array=vels%xyz(:, irep), unit_conv=unit_conv, &
235  print_kind=print_kind)
236  CALL m_flush(vel)
237  END IF
238  ! Dump Forces
239  IF (frc > 0 .AND. PRESENT(forces)) THEN
240  ! Gather units of measure for output
241  CALL section_vals_val_get(neb_env%motion_print_section, "FORCES%UNIT", &
242  c_val=unit_str)
243  CALL section_vals_val_get(neb_env%motion_print_section, "FORCES%PRINT_ATOM_KIND", &
244  l_val=print_kind)
245  unit_conv = cp_unit_from_cp2k(1.0_dp, trim(unit_str))
246  WRITE (unit=title, fmt="(A,I8,A,F20.10)") " i =", istep, ", E =", energies(irep)
247  CALL write_particle_coordinates(particle_set, frc, dump_xmol, "FRC", title, &
248  cell=cell, array=forces%xyz(:, irep), unit_conv=unit_conv, &
249  print_kind=print_kind)
250  CALL m_flush(frc)
251  END IF
252  CALL cp_print_key_finished_output(crd, logger, neb_env%motion_print_section, &
253  "TRAJECTORY")
254  IF (PRESENT(vels)) THEN
255  CALL cp_print_key_finished_output(vel, logger, neb_env%motion_print_section, &
256  "VELOCITIES")
257  END IF
258  IF (PRESENT(forces)) THEN
259  CALL cp_print_key_finished_output(frc, logger, neb_env%motion_print_section, &
260  "FORCES")
261  END IF
262  END DO
263  ! NEB summary info on screen
264  IF (output_unit > 0) THEN
265  tc_section => section_vals_get_subs_vals(neb_env%neb_section, "OPTIMIZE_BAND%MD%TEMP_CONTROL")
266  vc_section => section_vals_get_subs_vals(neb_env%neb_section, "OPTIMIZE_BAND%MD%VEL_CONTROL")
267  ALLOCATE (temperatures(neb_env%number_of_replica))
268  ALLOCATE (ekin(neb_env%number_of_replica))
269  CALL get_temperatures(vels, particle_set, temperatures, ekin=ekin)
270  WRITE (output_unit, '(/)', advance="NO")
271  WRITE (output_unit, fmt='(A,A)') ' **************************************', &
272  '*****************************************'
273  NULLIFY (section, keyword, enum)
274  CALL create_band_section(section)
275  keyword => section_get_keyword(section, "BAND_TYPE")
276  CALL keyword_get(keyword, enum=enum)
277  mytype = trim(enum_i2c(enum, neb_env%id_type))
278  WRITE (output_unit, fmt='(A,T61,A)') &
279  ' BAND TYPE =', adjustr(mytype)
280  CALL section_release(section)
281  WRITE (output_unit, fmt='(A,T61,A)') &
282  ' BAND TYPE OPTIMIZATION =', adjustr(neb_env%opt_type_label(1:20))
283  WRITE (output_unit, '( A,T71,I10 )') &
284  ' STEP NUMBER =', istep
285  IF (neb_env%rotate_frames) WRITE (output_unit, '( A,T71,L10 )') &
286  ' RMSD DISTANCE DEFINITION =', neb_env%rotate_frames
287  ! velocity control parameters output
288  CALL section_vals_get(vc_section, explicit=explicit)
289  IF (explicit) THEN
290  CALL section_vals_val_get(vc_section, "PROJ_VELOCITY_VERLET", l_val=lval)
291  IF (lval) WRITE (output_unit, '( A,T71,L10 )') &
292  ' PROJECTED VELOCITY VERLET =', lval
293  CALL section_vals_val_get(vc_section, "SD_LIKE", l_val=lval)
294  IF (lval) WRITE (output_unit, '( A,T71,L10)') &
295  ' STEEPEST DESCENT LIKE =', lval
296  CALL section_vals_val_get(vc_section, "ANNEALING", r_val=f_ann)
297  IF (f_ann /= 1.0_dp) THEN
298  WRITE (output_unit, '( A,T71,F10.5)') &
299  ' ANNEALING FACTOR = ', f_ann
300  END IF
301  END IF
302  ! temperature control parameters output
303  CALL section_vals_get(tc_section, explicit=explicit)
304  IF (explicit) THEN
305  CALL section_vals_val_get(tc_section, "TEMP_TOL_STEPS", i_val=ttst)
306  IF (istep <= ttst) THEN
307  CALL section_vals_val_get(tc_section, "TEMPERATURE", r_val=f_ann)
308  tmp_r1 = cp_unit_from_cp2k(f_ann, "K")
309  WRITE (output_unit, '( A,T71,F10.5)') &
310  ' TEMPERATURE TARGET =', tmp_r1
311  END IF
312  END IF
313  WRITE (output_unit, '( A,T71,I10 )') &
314  ' NUMBER OF NEB REPLICA =', neb_env%number_of_replica
315  WRITE (output_unit, '( A,T17,4F16.6)') &
316  ' DISTANCES REP =', distances(1:min(4, SIZE(distances)))
317  IF (SIZE(distances) > 4) THEN
318  WRITE (output_unit, '( T17,4F16.6)') distances(5:SIZE(distances))
319  END IF
320  WRITE (output_unit, '( A,T17,4F16.6)') &
321  ' ENERGIES [au] =', energies(1:min(4, SIZE(energies)))
322  IF (SIZE(energies) > 4) THEN
323  WRITE (output_unit, '( T17,4F16.6)') energies(5:SIZE(energies))
324  END IF
325  IF (neb_env%opt_type == band_md_opt) THEN
326  WRITE (output_unit, '( A,T33,4(1X,F11.5))') &
327  ' REPLICA TEMPERATURES (K) =', temperatures(1:min(4, SIZE(temperatures)))
328  DO i = 5, SIZE(temperatures), 4
329  WRITE (output_unit, '( T33,4(1X,F11.5))') &
330  temperatures(i:min(i + 3, SIZE(temperatures)))
331  END DO
332  END IF
333  WRITE (output_unit, '( A,T56,F25.14)') &
334  ' BAND TOTAL ENERGY [au] =', sum(energies(:) + ekin(:)) + &
335  neb_env%spring_energy
336  WRITE (output_unit, fmt='(A,A)') ' **************************************', &
337  '*****************************************'
338  DEALLOCATE (ekin)
339  DEALLOCATE (temperatures)
340  END IF
341  ! Ener file
342  ener = cp_print_key_unit_nr(logger, neb_env%neb_section, "ENERGY", &
343  extension=".ener", file_form="FORMATTED")
344  IF (ener > 0) THEN
345  WRITE (line, '(I0)') 2*neb_env%number_of_replica - 1
346  WRITE (ener, '(I10,'//trim(line)//'(1X,F20.9))') istep, &
347  energies, distances
348  END IF
349  CALL cp_print_key_finished_output(ener, logger, neb_env%neb_section, &
350  "ENERGY")
351 
352  ! Dump Restarts
353  CALL cp_add_default_logger(logger)
354  CALL write_restart(force_env=neb_env%force_env, &
355  root_section=neb_env%root_section, &
356  coords=coords, &
357  vels=vels)
358  CALL cp_rm_default_logger()
359 
360  CALL timestop(handle)
361 
362  END SUBROUTINE dump_neb_info
363 
364 ! **************************************************************************************************
365 !> \brief dump coordinates of a replica NEB
366 !> \param particle_set ...
367 !> \param coords ...
368 !> \param i_rep ...
369 !> \param ienum ...
370 !> \param iw ...
371 !> \param use_colvar ...
372 !> \author Teodoro Laino 09.2006
373 ! **************************************************************************************************
374  SUBROUTINE dump_replica_coordinates(particle_set, coords, i_rep, ienum, iw, use_colvar)
375 
376  TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
377  TYPE(neb_var_type), POINTER :: coords
378  INTEGER, INTENT(IN) :: i_rep, ienum, iw
379  LOGICAL, INTENT(IN) :: use_colvar
380 
381  INTEGER :: iatom, j
382  REAL(kind=dp), DIMENSION(3) :: r
383 
384  IF (iw > 0) THEN
385  WRITE (iw, '(/,T2,"NEB|",75("*"))')
386  WRITE (iw, '(T2,"NEB|",1X,A,I0,A)') &
387  "Geometry for Replica Nr. ", ienum, " in Angstrom"
388  DO iatom = 1, SIZE(particle_set)
389  r(1:3) = get_particle_pos_or_vel(iatom, particle_set, coords%xyz(:, i_rep))
390  WRITE (iw, '(T2,"NEB|",1X,A10,5X,3F15.9)') &
391  trim(particle_set(iatom)%atomic_kind%name), r(1:3)*angstrom
392  END DO
393  IF (use_colvar) THEN
394  WRITE (iw, '(/,T2,"NEB|",1X,A10)') "COLLECTIVE VARIABLES:"
395  WRITE (iw, '(T2,"NEB|",16X,3F15.9)') &
396  (coords%int(j, i_rep), j=1, SIZE(coords%int(:, :), 1))
397  END IF
398  WRITE (iw, '(T2,"NEB|",75("*"))')
399  CALL m_flush(iw)
400  END IF
401 
402  END SUBROUTINE dump_replica_coordinates
403 
404 ! **************************************************************************************************
405 !> \brief Handles the correct file names during a band calculation
406 !> \param rep_env ...
407 !> \param irep ...
408 !> \param n_rep ...
409 !> \param istep ...
410 !> \author Teodoro Laino 06.2009
411 ! **************************************************************************************************
412  SUBROUTINE handle_band_file_names(rep_env, irep, n_rep, istep)
413  TYPE(replica_env_type), POINTER :: rep_env
414  INTEGER, INTENT(IN) :: irep, n_rep, istep
415 
416  CHARACTER(len=*), PARAMETER :: routinen = 'handle_band_file_names'
417 
418  CHARACTER(LEN=default_path_length) :: output_file_path, replica_proj_name
419  INTEGER :: handle, handle2, i, ierr, j, lp, unit_nr
420  TYPE(cp_logger_type), POINTER :: logger, sub_logger
421  TYPE(f_env_type), POINTER :: f_env
422  TYPE(section_vals_type), POINTER :: root_section
423 
424  CALL timeset(routinen, handle)
425  CALL f_env_add_defaults(f_env_id=rep_env%f_env_id, f_env=f_env, &
426  handle=handle2)
427  logger => cp_get_default_logger()
428  CALL force_env_get(f_env%force_env, root_section=root_section)
429  j = irep + (rep_env%local_rep_indices(1) - 1)
430  ! Get replica_project_name
431  replica_proj_name = get_replica_project_name(rep_env, n_rep, j)
432  lp = len_trim(replica_proj_name)
433  CALL section_vals_val_set(root_section, "GLOBAL%PROJECT_NAME", &
434  c_val=trim(replica_proj_name))
435  logger%iter_info%project_name = replica_proj_name
436 
437  ! We change the file on which is pointing the global logger and error
438  output_file_path = replica_proj_name(1:lp)//".out"
439  CALL section_vals_val_set(root_section, "GLOBAL%OUTPUT_FILE_NAME", &
440  c_val=trim(output_file_path))
441  IF (logger%default_global_unit_nr > 0) THEN
442  CALL close_file(logger%default_global_unit_nr)
443  CALL open_file(file_name=output_file_path, file_status="UNKNOWN", &
444  file_action="WRITE", file_position="APPEND", &
445  unit_number=logger%default_global_unit_nr, &
446  skip_get_unit_number=.true.)
447  WRITE (unit=logger%default_global_unit_nr, fmt="(/,(T2,A79))") &
448  "*******************************************************************************", &
449  "** BAND EVALUATION OF ENERGIES AND FORCES **", &
450  "*******************************************************************************"
451  WRITE (unit=logger%default_global_unit_nr, fmt="(T2,A,T79,A)") "**", "**"
452  WRITE (unit=logger%default_global_unit_nr, fmt="(T2,A,T79,A)") "**", "**"
453  WRITE (unit=logger%default_global_unit_nr, fmt="(T2,A,I5,T41,A,I5,T79,A)") &
454  "** Replica Env Nr. :", rep_env%local_rep_indices(1) - 1, "Replica Band Nr. :", j, "**"
455  WRITE (unit=logger%default_global_unit_nr, fmt="(T2,A,I5,T79,A)") &
456  "** Band Step Nr. :", istep, "**"
457  WRITE (unit=logger%default_global_unit_nr, fmt="(T2,A79)") &
458  "*******************************************************************************"
459  END IF
460 
461  ! Handle specific case for mixed_env
462  SELECT CASE (f_env%force_env%in_use)
463  CASE (use_mixed_force)
464  DO i = 1, f_env%force_env%mixed_env%ngroups
465  IF (modulo(i - 1, f_env%force_env%mixed_env%ngroups) == &
466  f_env%force_env%mixed_env%group_distribution(f_env%force_env%mixed_env%para_env%mepos)) THEN
467  sub_logger => f_env%force_env%mixed_env%sub_logger(i)%p
468  sub_logger%iter_info%project_name = replica_proj_name(1:lp)//"-r-"//trim(adjustl(cp_to_string(i)))
469 
470  unit_nr = sub_logger%default_global_unit_nr
471  IF (unit_nr > 0) THEN
472  CALL close_file(unit_nr)
473 
474  output_file_path = replica_proj_name(1:lp)//"-r-"//trim(adjustl(cp_to_string(i)))//".out"
475  CALL open_file(file_name=output_file_path, file_status="UNKNOWN", &
476  file_action="WRITE", file_position="APPEND", &
477  unit_number=unit_nr, skip_get_unit_number=.true.)
478  END IF
479  END IF
480  END DO
481  END SELECT
482 
483  CALL f_env_rm_defaults(f_env=f_env, ierr=ierr, handle=handle2)
484  cpassert(ierr == 0)
485  CALL timestop(handle)
486 
487  END SUBROUTINE handle_band_file_names
488 
489 ! **************************************************************************************************
490 !> \brief Constructs project names for BAND replicas
491 !> \param rep_env ...
492 !> \param n_rep ...
493 !> \param j ...
494 !> \return ...
495 !> \author Teodoro Laino 06.2009
496 ! **************************************************************************************************
497  FUNCTION get_replica_project_name(rep_env, n_rep, j) RESULT(replica_proj_name)
498  TYPE(replica_env_type), POINTER :: rep_env
499  INTEGER, INTENT(IN) :: n_rep, j
500  CHARACTER(LEN=default_path_length) :: replica_proj_name
501 
502  CHARACTER(LEN=default_string_length) :: padding
503  INTEGER :: i, lp, ndigits
504 
505 ! Setup new replica project name and output file
506 
507  replica_proj_name = rep_env%original_project_name
508  ! Find padding
509  ndigits = ceiling(log10(real(n_rep + 1, kind=dp))) - &
510  ceiling(log10(real(j + 1, kind=dp)))
511  padding = ""
512  DO i = 1, ndigits
513  padding(i:i) = "0"
514  END DO
515  lp = len_trim(replica_proj_name)
516  replica_proj_name(lp + 1:len(replica_proj_name)) = "-BAND"// &
517  trim(padding)//adjustl(cp_to_string(j))
518  END FUNCTION get_replica_project_name
519 
520 ! **************************************************************************************************
521 !> \brief Print some mapping infos in the replica_env setup output files
522 !> i.e. prints in which files one can find information for each band
523 !> replica
524 !> \param rep_env ...
525 !> \param neb_env ...
526 !> \author Teodoro Laino 06.2009
527 ! **************************************************************************************************
528  SUBROUTINE neb_rep_env_map_info(rep_env, neb_env)
529  TYPE(replica_env_type), POINTER :: rep_env
530  TYPE(neb_type), POINTER :: neb_env
531 
532  CHARACTER(LEN=default_path_length) :: replica_proj_name
533  INTEGER :: handle2, ierr, irep, n_rep, n_rep_neb, &
534  output_unit
535  TYPE(cp_logger_type), POINTER :: logger
536  TYPE(f_env_type), POINTER :: f_env
537 
538  n_rep_neb = neb_env%number_of_replica
539  n_rep = rep_env%nrep
540  CALL f_env_add_defaults(f_env_id=rep_env%f_env_id, f_env=f_env, &
541  handle=handle2)
542  logger => cp_get_default_logger()
543  output_unit = logger%default_global_unit_nr
544  IF (output_unit > 0) THEN
545  WRITE (unit=output_unit, fmt='(/,(T2,A79))') &
546  "*******************************************************************************", &
547  "** MAPPING OF BAND REPLICA TO REPLICA ENV **", &
548  "*******************************************************************************"
549  WRITE (unit=output_unit, fmt='(T2,A,I6,T32,A,T79,A)') &
550  "** Replica Env Nr.: ", rep_env%local_rep_indices(1) - 1, &
551  "working on the following BAND replicas", "**"
552  WRITE (unit=output_unit, fmt='(T2,A79)') &
553  "** **"
554  END IF
555  DO irep = 1, n_rep_neb, n_rep
556  replica_proj_name = get_replica_project_name(rep_env, n_rep_neb, irep + rep_env%local_rep_indices(1) - 1)
557  IF (output_unit > 0) THEN
558  WRITE (unit=output_unit, fmt='(T2,A,I6,T32,A,T79,A)') &
559  "** Band Replica Nr.: ", irep + rep_env%local_rep_indices(1) - 1, &
560  "Output available on file: "//trim(replica_proj_name)//".out", "**"
561  END IF
562  END DO
563  IF (output_unit > 0) THEN
564  WRITE (unit=output_unit, fmt='(T2,A79)') &
565  "** **", &
566  "*******************************************************************************"
567  WRITE (unit=output_unit, fmt='(/)')
568  END IF
569  ! update runtime info before printing the footer
570  CALL get_runtime_info()
571  ! print footer
572  CALL cp2k_footer(output_unit)
573  CALL f_env_rm_defaults(f_env=f_env, ierr=ierr, handle=handle2)
574  cpassert(ierr == 0)
575  END SUBROUTINE neb_rep_env_map_info
576 
577 END MODULE neb_io
static GRID_HOST_DEVICE int modulo(int a, int m)
Equivalent of Fortran's MODULO, which always return a positive number. https://gcc....
Definition: grid_common.h:117
Handles all functions related to the CELL.
Definition: cell_types.F:15
some minimal info about CP2K, including its version and license
Definition: cp2k_info.F:16
subroutine, public get_runtime_info()
...
Definition: cp2k_info.F:310
Utility routines to open and close files. Tracking of preconnections.
Definition: cp_files.F:16
subroutine, public open_file(file_name, file_status, file_form, file_action, file_position, file_pad, unit_number, debug, skip_get_unit_number, file_access)
Opens the requested file using a free unit number.
Definition: cp_files.F:308
subroutine, public close_file(unit_number, file_status, keep_preconnection)
Close an open file given by its logical unit number. Optionally, keep the file and unit preconnected.
Definition: cp_files.F:119
various routines to log and control the output. The idea is that decisions about where to log should ...
subroutine, public cp_rm_default_logger()
the cousin of cp_add_default_logger, decrements the stack, so that the default logger is what it has ...
subroutine, public cp_add_default_logger(logger)
adds a default logger. MUST be called before logging occours
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,...
unit conversion facility
Definition: cp_units.F:30
real(kind=dp) function, public cp_unit_from_cp2k(value, unit_str, defaults, power)
converts from the internal cp2k units to the given unit
Definition: cp_units.F:1179
interface to use cp2k as library
Definition: f77_interface.F:20
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.
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)
returns various attributes about the force environment
Definition: header.F:13
subroutine, public cp2k_footer(iw, wdir)
...
Definition: header.F:69
collects all constants needed in input so that they can be used without circular dependencies
integer, parameter, public pot_neb_me
integer, parameter, public band_md_opt
integer, parameter, public pot_neb_fe
integer, parameter, public dump_xmol
integer, parameter, public do_sm
integer, parameter, public pot_neb_full
subroutine, public create_band_section(section)
creates the section for a BAND run
Set of routines to dump the restart file of CP2K.
subroutine, public write_restart(md_env, force_env, root_section, coords, vels, pint_env, helium_env)
checks if a restart needs to be written and does so, updating all necessary fields in the input file....
represents an enumeration, i.e. a mapping between integers and strings
character(len=default_string_length) function, public enum_i2c(enum, i)
maps an integer to a string
represents keywords in an input
subroutine, public keyword_get(keyword, names, usage, description, type_of_var, n_var, default_value, lone_keyword_value, repeats, enum, citations)
...
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
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
recursive subroutine, public section_release(section)
releases the given keyword list (see doc/ReferenceCounting.html)
recursive type(keyword_type) function, pointer, public section_get_keyword(section, keyword_name)
returns the requested keyword
subroutine, public section_vals_get(section_vals, ref_count, n_repetition, n_subs_vals_rep, section, explicit)
returns various attributes about the section_vals
subroutine, public section_vals_val_get(section_vals, keyword_name, i_rep_section, i_rep_val, n_rep_val, val, l_val, i_val, r_val, c_val, l_vals, i_vals, r_vals, c_vals, explicit)
returns the requested value
Defines the basic variable types.
Definition: kinds.F:23
integer, parameter, public dp
Definition: kinds.F:34
integer, parameter, public default_string_length
Definition: kinds.F:57
integer, parameter, public default_path_length
Definition: kinds.F:58
Machine interface based on Fortran 2003 and POSIX.
Definition: machine.F:17
subroutine, public m_flush(lunit)
flushes units if the &GLOBAL flag is set accordingly
Definition: machine.F:106
I/O Module for Nudged Elastic Band Calculation.
Definition: neb_io.F:20
subroutine, public read_neb_section(neb_env, neb_section)
Read data from the NEB input section.
Definition: neb_io.F:92
subroutine, public dump_replica_coordinates(particle_set, coords, i_rep, ienum, iw, use_colvar)
dump coordinates of a replica NEB
Definition: neb_io.F:375
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...
Definition: neb_io.F:529
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
Definition: neb_io.F:169
subroutine, public handle_band_file_names(rep_env, irep, n_rep, istep)
Handles the correct file names during a band calculation.
Definition: neb_io.F:413
Module with utility to perform MD Nudged Elastic Band Calculation.
Definition: neb_md_utils.F:20
subroutine, public get_temperatures(vels, particle_set, temperatures, ekin, factor)
Computes temperatures.
Definition: neb_md_utils.F:272
Typo for Nudged Elastic Band Calculation.
Definition: neb_types.F:20
Define methods related to particle_type.
subroutine, public write_particle_coordinates(particle_set, iunit, output_format, content, title, cell, array, unit_conv, charge_occup, charge_beta, charge_extended, print_kind)
Should be able to write a few formats e.g. xmol, and some binary format (dcd) some format can be used...
Define the data structure for the particle information.
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:
Definition: physcon.F:68
real(kind=dp), parameter, public angstrom
Definition: physcon.F:144
types used to handle many replica of the same system that differ only in atom positions,...
Definition: replica_types.F:21