56#include "./base/base_uses.f90"
61 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'metadynamics_utils'
83 SUBROUTINE metadyn_read(meta_env, force_env, root_section, para_env, fe_section)
90 CHARACTER(len=*),
PARAMETER :: routinen =
'metadyn_read'
92 CHARACTER(LEN=default_path_length) :: walkers_file_name
93 INTEGER :: handle, i, id_method, n_colvar, n_rep, &
94 number_allocated_colvars
95 INTEGER,
DIMENSION(:),
POINTER :: walkers_status
96 LOGICAL ::
check, explicit
100 metavar_section, walkers_section
103 CALL timeset(routinen, handle)
107 number_allocated_colvars = 0
109 IF (
ASSOCIATED(subsys%colvar_p))
THEN
110 number_allocated_colvars =
SIZE(subsys%colvar_p)
114 CALL timestop(handle)
118 cpassert(.NOT.
ASSOCIATED(meta_env))
127 dt=dt, para_env=para_env, metadyn_section=metadyn_section)
131 IF (meta_env%use_plumed .EQV. .true.)
THEN
132 CALL section_vals_val_get(metadyn_section,
"PLUMED_INPUT_FILE", c_val=meta_env%plumed_input_file)
133 meta_env%plumed_input_file = trim(meta_env%plumed_input_file)//char(0)
134 meta_env%langevin = .false.
135 CALL timestop(handle)
142 IF (meta_env%TAMCSteps < 0)
THEN
143 cpabort(
"TAMCSteps must be positive!")
146 IF (meta_env%zdt <= 0.0_dp)
THEN
147 cpabort(
"Timestep must be positive!")
151 CALL section_vals_val_get(metadyn_section,
"MIN_NT_HILLS", i_val=meta_env%hills_env%min_nt_hills)
152 IF (meta_env%hills_env%nt_hills <= 0)
THEN
153 meta_env%hills_env%min_nt_hills = meta_env%hills_env%nt_hills
154 CALL cp_warn(__location__, &
155 "NT_HILLS has a value <= 0; "// &
156 "Setting MIN_NT_HILLS to the same value! "// &
157 "Overriding input specification!")
159 check = meta_env%hills_env%nt_hills >= meta_env%hills_env%min_nt_hills
160 IF (.NOT.
check)
THEN
161 CALL cp_abort(__location__,
"MIN_NT_HILLS must have a value smaller or equal to NT_HILLS! "// &
162 "Cross check with the input reference!")
166 CALL section_vals_val_get(metadyn_section,
"OLD_HILL_NUMBER", i_val=meta_env%hills_env%old_hill_number)
167 CALL section_vals_val_get(metadyn_section,
"OLD_HILL_STEP", i_val=meta_env%hills_env%old_hill_step)
170 CALL section_vals_val_get(metadyn_section,
"HILL_TAIL_CUTOFF", r_val=meta_env%hills_env%tail_cutoff)
178 cpassert(meta_env%n_steps >= 0)
180 i_val=meta_env%hills_env%n_hills)
184 r_val=meta_env%toll_temp)
187 r_val=meta_env%delta_t)
189 r_val=meta_env%wtgamma)
190 IF (meta_env%well_tempered)
THEN
191 meta_env%hills_env%wtcontrol = meta_env%hills_env%wtcontrol .OR.
check
192 check = meta_env%hills_env%wtcontrol
193 IF (.NOT.
check)
THEN
194 CALL cp_abort(__location__,
"When using Well-Tempered metadynamics, "// &
195 "DELTA_T (or WTGAMMA) should be explicitly specified.")
197 IF (meta_env%extended_lagrange)
THEN
198 CALL cp_abort(__location__, &
199 "Well-Tempered metadynamics not possible with extended-lagrangian formulation.")
201 IF (meta_env%hills_env%min_disp > 0.0_dp)
THEN
202 CALL cp_abort(__location__, &
203 "Well-Tempered metadynamics not possible with Adaptive hills.")
208 r_val=meta_env%avg_temp)
211 CALL metavar_read(meta_env%metavar(i), meta_env%extended_lagrange, &
212 meta_env%langevin, i, metavar_section)
213 check = (meta_env%metavar(i)%icolvar <= number_allocated_colvars)
214 IF (.NOT.
check)
THEN
215 CALL cp_abort(__location__, &
216 "An error occurred in the specification of COLVAR for METAVAR. "// &
217 "Specified COLVAR #("//trim(adjustl(
cp_to_string(meta_env%metavar(i)%icolvar)))//
") "// &
218 "is larger than the maximum number of COLVARS defined in the SUBSYS ("// &
219 trim(adjustl(
cp_to_string(number_allocated_colvars)))//
") !")
224 IF (meta_env%do_multiple_walkers)
THEN
225 NULLIFY (walkers_status)
230 i_val=meta_env%multiple_walkers%walker_id)
232 i_val=meta_env%multiple_walkers%walkers_tot_nr)
234 i_val=meta_env%multiple_walkers%walkers_freq_comm)
237 ALLOCATE (meta_env%multiple_walkers%walkers_status(meta_env%multiple_walkers%walkers_tot_nr))
238 ALLOCATE (meta_env%multiple_walkers%walkers_file_name(meta_env%multiple_walkers%walkers_tot_nr))
242 check = (
SIZE(walkers_status) == meta_env%multiple_walkers%walkers_tot_nr)
243 IF (.NOT.
check)
THEN
244 CALL cp_abort(__location__, &
245 "Number of Walkers specified in the input does not match with the "// &
246 "size of the WALKERS_STATUS. Please check your input and in case "// &
247 "this is a restart run consider the possibility to switch off the "// &
248 "RESTART_WALKERS in the EXT_RESTART section! ")
250 meta_env%multiple_walkers%walkers_status = walkers_status
252 meta_env%multiple_walkers%walkers_status = 0
254 meta_env%multiple_walkers%n_hills_local = &
255 meta_env%multiple_walkers%walkers_status(meta_env%multiple_walkers%walker_id)
259 check = (n_rep == meta_env%multiple_walkers%walkers_tot_nr)
260 IF (.NOT.
check)
THEN
261 CALL cp_abort(__location__, &
262 "Number of Walkers specified in the input does not match with the "// &
263 "number of Walkers File names provided. Please check your input and in case "// &
264 "this is a restart run consider the possibility to switch off the "// &
265 "RESTART_WALKERS in the EXT_RESTART section! ")
269 i_rep_val=i, c_val=walkers_file_name)
270 meta_env%multiple_walkers%walkers_file_name(i) = walkers_file_name
275 CALL print_metadyn_info(meta_env, n_colvar, metadyn_section)
278 CALL timestop(handle)
289 SUBROUTINE print_metadyn_info(meta_env, n_colvar, metadyn_section)
291 INTEGER,
INTENT(IN) :: n_colvar
294 CHARACTER(len=*),
PARAMETER :: routinen =
'print_metadyn_info'
296 CHARACTER(LEN=10) :: my_id, my_tag
297 INTEGER :: handle, i, iw, j
301 TYPE(
section_type),
POINTER :: section, wall_section, work_section
303 CALL timeset(routinen, handle)
307 "PRINT%PROGRAM_RUN_INFO", extension=
".metadynLog")
308 NULLIFY (section, enum, keyword)
312 WRITE (iw,
'( /A )')
' METADYN| Meta Dynamics Protocol '
313 WRITE (iw,
'( A,T71,I10)')
' METADYN| Number of interval time steps to spawn hills', &
314 meta_env%hills_env%nt_hills
315 WRITE (iw,
'( A,T71,I10)')
' METADYN| Number of previously spawned hills', &
316 meta_env%hills_env%n_hills
317 IF (meta_env%extended_lagrange)
THEN
318 WRITE (iw,
'( A )')
' METADYN| Extended Lagrangian Scheme '
319 IF (meta_env%tempcontrol)
WRITE (iw,
'( A,T71,F10.2)') &
320 ' METADYN| Collective Variables Temperature control', meta_env%toll_temp
321 IF (meta_env%langevin)
THEN
322 WRITE (iw,
'(A,T71)')
' METADYN| Langevin Thermostat in use for COLVAR '
323 WRITE (iw,
'(A,T71,F10.4)')
' METADYN| Langevin Thermostat. Target Temperature = ', &
324 meta_env%temp_wanted*
kelvin
326 WRITE (iw,
'(A,T71,F10.4)')
' METADYN| COLVARS restarted average temperature ', &
329 IF (meta_env%do_hills)
THEN
330 WRITE (iw,
'( A )')
' METADYN| Spawning the Hills '
331 WRITE (iw,
'( A,T71,F10.3)')
' METADYN| Height of the Spawned Gaussian', meta_env%hills_env%ww
333 IF (meta_env%hills_env%min_disp > 0.0_dp)
THEN
334 WRITE (iw,
'(A)')
' METADYN| Adapative meta time step is activated'
335 WRITE (iw,
'(A,T71,F10.4)')
' METADYN| Minimum displacement for next hill', &
336 meta_env%hills_env%min_disp
341 IF (meta_env%well_tempered)
THEN
342 WRITE (iw,
'( A )')
' METADYN| Well-Tempered metadynamics '
343 IF (meta_env%delta_t > epsilon(1._dp))
THEN
344 WRITE (iw,
'( A,T71,F10.3)')
' METADYN| Temperature parameter (Delta T) [K]', meta_env%delta_t*
kelvin
346 WRITE (iw,
'( A,T71,F10.3)')
' METADYN| Temperature parameter (gamma)', meta_env%wtgamma
350 IF (meta_env%do_multiple_walkers)
THEN
351 WRITE (iw,
'( A,T71,A10)')
' METADYN| Multiple Walkers',
' ENABLED'
352 WRITE (iw,
'( A,T71,I10)')
' METADYN| Number of Multiple Walkers', &
353 meta_env%multiple_walkers%walkers_tot_nr
354 WRITE (iw,
'( A,T71,I10)')
' METADYN| Local Walker ID', &
355 meta_env%multiple_walkers%walker_id
356 WRITE (iw,
'( A,T71,I10)')
' METADYN| Walker Communication Frequency', &
357 meta_env%multiple_walkers%walkers_freq_comm
358 DO i = 1, meta_env%multiple_walkers%walkers_tot_nr
360 IF (i == meta_env%multiple_walkers%walker_id) my_tag =
" ( Local )"
362 WRITE (iw,
'(/,A,T71,A10)')
' WALKERS| Walker ID'//trim(my_tag), adjustr(my_id)
363 WRITE (iw,
'( A,T71,I10)')
' WALKERS| Number of Hills communicated', &
364 meta_env%multiple_walkers%walkers_status(i)
365 WRITE (iw,
'( A,T24,A57)')
' WALKERS| Base Filename', &
366 adjustr(meta_env%multiple_walkers%walkers_file_name(i) (1:57))
371 WRITE (iw,
'( A,T71,I10)')
' METADYN| Number of collective variables', meta_env%n_colvar
373 WRITE (iw,
'( A )')
' '//
'----------------------------------------------------------------------'
374 WRITE (iw,
'( A,T71,I10)')
' METAVARS| Collective Variable Number', meta_env%metavar(i)%icolvar
375 IF (meta_env%extended_lagrange)
THEN
376 WRITE (iw,
'( A,T71,F10.6)')
' METAVARS| Lambda Parameter', meta_env%metavar(i)%lambda
377 WRITE (iw,
'( A,T66,F15.6)')
' METAVARS| Collective Variable Mass', meta_env%metavar(i)%mass
379 WRITE (iw,
'( A,T71,F10.6)')
' METAVARS| Scaling factor', meta_env%metavar(i)%delta_s
380 IF (meta_env%langevin)
WRITE (iw,
'( A,T71,F10.6)')
' METAVARS| Friction for Langevin Thermostat', &
381 meta_env%metavar(i)%gamma
382 IF (meta_env%metavar(i)%do_wall)
THEN
383 WRITE (iw,
'( A,T71,I10)')
' METAVARS| Number of Walls present',
SIZE(meta_env%metavar(i)%walls)
384 DO j = 1,
SIZE(meta_env%metavar(i)%walls)
387 WRITE (iw,
'(/,A,5X,I10,T50,A,T70,A11)')
' METAVARS| Wall Number:', j,
'Type of Wall:', &
388 adjustr(trim(
enum_i2c(enum, meta_env%metavar(i)%walls(j)%id_type)))
390 SELECT CASE (meta_env%metavar(i)%walls(j)%id_type)
398 WRITE (iw,
'(A,T70,A11)')
' METAVARS| Wall direction', &
399 adjustr(trim(
enum_i2c(enum, meta_env%metavar(i)%walls(j)%id_direction)))
404 WRITE (iw,
'(A,T70,A11)')
' METAVARS| Wall direction', &
405 adjustr(trim(
enum_i2c(enum, meta_env%metavar(i)%walls(j)%id_direction)))
406 WRITE (iw,
'(A,T70,F11.6)')
' METAVARS| Constant K of the quadratic potential', &
407 meta_env%metavar(i)%walls(j)%k_quadratic
409 WRITE (iw,
'(A,T70,F11.6)')
' METAVARS| Height of the Wall Gaussian', &
410 meta_env%metavar(i)%walls(j)%ww_gauss
411 WRITE (iw,
'(A,T70,F11.6)')
' METAVARS| Scale of the Wall Gaussian', &
412 meta_env%metavar(i)%walls(j)%sigma_gauss
414 WRITE (iw,
'(A,T70,F11.6)')
' METAVARS| Wall location', &
415 meta_env%metavar(i)%walls(j)%pos
418 WRITE (iw,
'( A )')
' '//
'----------------------------------------------------------------------'
424 CALL timestop(handle)
426 END SUBROUTINE print_metadyn_info
440 SUBROUTINE metavar_read(metavar, extended_lagrange, langevin, icol, metavar_section)
442 LOGICAL,
INTENT(IN) :: extended_lagrange, langevin
443 INTEGER,
INTENT(IN) :: icol
446 CHARACTER(len=*),
PARAMETER :: routinen =
'metavar_read'
448 INTEGER :: handle, i, n_walls
451 CALL timeset(routinen, handle)
458 IF (n_walls /= 0)
THEN
459 metavar%do_wall = .true.
460 ALLOCATE (metavar%walls(n_walls))
462 CALL section_vals_val_get(wall_section,
"TYPE", i_rep_section=i, i_val=metavar%walls(i)%id_type)
463 CALL section_vals_val_get(wall_section,
"POSITION", i_rep_section=i, r_val=metavar%walls(i)%pos)
464 SELECT CASE (metavar%walls(i)%id_type)
479 SELECT CASE (metavar%walls(i)%id_direction)
481 metavar%walls(i)%pos0 = metavar%walls(i)%pos + (0.05_dp/metavar%walls(i)%k_quartic**(0.25_dp))
483 metavar%walls(i)%pos0 = metavar%walls(i)%pos - (0.05_dp/metavar%walls(i)%k_quartic**(0.25_dp))
493 IF (extended_lagrange)
THEN
501 CALL timestop(handle)
503 END SUBROUTINE metavar_read
515 n_colvar, metadyn_section)
519 INTEGER,
INTENT(IN) :: n_colvar
522 CHARACTER(len=*),
PARAMETER :: routinen =
'synchronize_multiple_walkers'
524 CHARACTER(LEN=default_path_length) :: filename, tmpname
525 INTEGER :: delta_hills, handle, i, i_hills, ih, iw, &
528 REAL(kind=
dp) :: invdt, ww
529 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: delta_s_save, ss0_save
530 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: delta_s_ss0_buf
534 CALL timeset(routinen, handle)
537 para_env => logger%para_env
540 IF (para_env%is_source())
THEN
542 i = multiple_walkers%walker_id
543 filename = trim(multiple_walkers%walkers_file_name(i))//
"_"// &
544 trim(adjustl(
cp_to_string(multiple_walkers%n_hills_local)))
545 tmpname = trim(filename)//
".tmp"
546 CALL open_file(file_name=tmpname, file_status=
"UNKNOWN", &
547 file_form=
"FORMATTED", file_action=
"WRITE", &
548 file_position=
"APPEND", unit_number=unit_nr)
549 WRITE (unit_nr, *) hills_env%ww_history(hills_env%n_hills)
551 WRITE (unit_nr, *) hills_env%ss_history(ih, hills_env%n_hills)
552 WRITE (unit_nr, *) hills_env%delta_s_history(ih, hills_env%n_hills)
554 IF (hills_env%wtcontrol)
WRITE (unit_nr, *) hills_env%invdt_history(hills_env%n_hills)
556 CALL m_mov(tmpname, filename)
559 IF (
modulo(multiple_walkers%n_hills_local, multiple_walkers%walkers_freq_comm) == 0)
THEN
561 ALLOCATE (ss0_save(n_colvar))
562 ALLOCATE (delta_s_save(n_colvar))
563 ALLOCATE (delta_s_ss0_buf(2, 0:n_colvar))
566 ss0_save(i) = colvars(i)%ss0
567 delta_s_save(i) = colvars(i)%delta_s
571 DO i = 1, multiple_walkers%walkers_tot_nr
572 IF (i == multiple_walkers%walker_id)
THEN
574 multiple_walkers%walkers_status(i) = multiple_walkers%n_hills_local
578 i_hills = multiple_walkers%walkers_status(i) + 1
579 filename = trim(multiple_walkers%walkers_file_name(i))//
"_"// &
582 IF (para_env%is_source())
THEN
583 INQUIRE (file=trim(filename), exist=exist)
585 CALL para_env%bcast(exist)
590 IF (para_env%is_source())
THEN
591 CALL open_file(file_name=filename, file_status=
"OLD", &
592 file_form=
"FORMATTED", file_action=
"READ", &
593 file_position=
"REWIND", unit_number=unit_nr)
594 READ (unit_nr, *) delta_s_ss0_buf(1, 0)
596 READ (unit_nr, *) delta_s_ss0_buf(1, ih)
597 READ (unit_nr, *) delta_s_ss0_buf(2, ih)
599 IF (hills_env%wtcontrol)
READ (unit_nr, *) delta_s_ss0_buf(2, 0)
602 CALL para_env%bcast(delta_s_ss0_buf)
603 ww = delta_s_ss0_buf(1, 0)
604 IF (hills_env%wtcontrol) invdt = delta_s_ss0_buf(2, 0)
606 colvars(ih)%ss0 = delta_s_ss0_buf(1, ih)
607 colvars(ih)%delta_s = delta_s_ss0_buf(2, ih)
611 IF (hills_env%wtcontrol)
THEN
612 CALL add_hill_single(hills_env, colvars, ww, hills_env%n_hills, n_colvar, invdt=invdt)
614 CALL add_hill_single(hills_env, colvars, ww, hills_env%n_hills, n_colvar)
617 i_hills = i_hills + 1
618 filename = trim(multiple_walkers%walkers_file_name(i))//
"_"// &
620 IF (para_env%is_source())
THEN
621 INQUIRE (file=trim(filename), exist=exist)
623 CALL para_env%bcast(exist)
626 delta_hills = i_hills - 1 - multiple_walkers%walkers_status(i)
627 multiple_walkers%walkers_status(i) = i_hills - 1
629 extension=
".metadynLog")
631 WRITE (iw,
'(T2,A,I0,A,I0,A,I0,A)')
'WALKERS| Walker #', i,
'. Reading [', delta_hills, &
632 '] Hills. Total number of Hills acquired [', multiple_walkers%walkers_status(i),
']'
635 "PRINT%PROGRAM_RUN_INFO")
640 colvars(i)%ss0 = ss0_save(i)
641 colvars(i)%delta_s = delta_s_save(i)
643 DEALLOCATE (ss0_save)
644 DEALLOCATE (delta_s_save)
647 CALL timestop(handle)
664 REAL(kind=
dp),
INTENT(IN) :: ww
665 INTEGER,
INTENT(INOUT) :: n_hills
666 INTEGER,
INTENT(IN) :: n_colvar
667 REAL(kind=
dp),
INTENT(IN),
OPTIONAL :: invdt
669 CHARACTER(len=*),
PARAMETER :: routinen =
'add_hill_single'
673 REAL(kind=
dp),
DIMENSION(:),
POINTER :: tnp
674 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: tmp
676 CALL timeset(routinen, handle)
678 wtcontrol =
PRESENT(invdt)
680 IF (
SIZE(hills_env%ss_history, 2) < n_hills + 1)
THEN
681 ALLOCATE (tmp(n_colvar, n_hills + 100))
682 tmp(:, :n_hills) = hills_env%ss_history
683 tmp(:, n_hills + 1:) = 0.0_dp
684 DEALLOCATE (hills_env%ss_history)
685 hills_env%ss_history => tmp
688 IF (
SIZE(hills_env%delta_s_history, 2) < n_hills + 1)
THEN
689 ALLOCATE (tmp(n_colvar, n_hills + 100))
690 tmp(:, :n_hills) = hills_env%delta_s_history
691 tmp(:, n_hills + 1:) = 0.0_dp
692 DEALLOCATE (hills_env%delta_s_history)
693 hills_env%delta_s_history => tmp
696 IF (
SIZE(hills_env%ww_history) < n_hills + 1)
THEN
697 ALLOCATE (tnp(n_hills + 100))
698 tnp(1:n_hills) = hills_env%ww_history
699 tnp(n_hills + 1:) = 0.0_dp
700 DEALLOCATE (hills_env%ww_history)
701 hills_env%ww_history => tnp
705 IF (
SIZE(hills_env%invdt_history) < n_hills + 1)
THEN
706 ALLOCATE (tnp(n_hills + 100))
707 tnp(1:n_hills) = hills_env%invdt_history
708 tnp(n_hills + 1:) = 0.0_dp
709 DEALLOCATE (hills_env%invdt_history)
710 hills_env%invdt_history => tnp
714 n_hills = n_hills + 1
717 hills_env%ss_history(i, n_hills) = colvars(i)%ss0
718 hills_env%delta_s_history(i, n_hills) = colvars(i)%delta_s
720 hills_env%ww_history(n_hills) = ww
721 IF (wtcontrol) hills_env%invdt_history(n_hills) = invdt
723 CALL timestop(handle)
741 n_hills, n_colvar, colvars, metadyn_section, invdt_history)
742 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: ss_history, delta_s_history
743 REAL(kind=
dp),
DIMENSION(:),
POINTER :: ww_history
745 INTEGER,
INTENT(IN) :: n_hills, n_colvar
748 REAL(kind=
dp),
DIMENSION(:),
OPTIONAL,
POINTER :: invdt_history
750 CHARACTER(len=*),
PARAMETER :: routinen =
'restart_hills'
752 INTEGER :: handle, i, j, ndum
753 LOGICAL :: explicit, wtcontrol
754 REAL(kind=
dp) :: rval
755 REAL(kind=
dp),
DIMENSION(:),
POINTER :: rvals
758 CALL timeset(routinen, handle)
760 wtcontrol =
PRESENT(invdt_history)
767 DEALLOCATE (ss_history)
768 DEALLOCATE (delta_s_history)
769 DEALLOCATE (ww_history)
771 DEALLOCATE (invdt_history)
774 cpassert(n_hills == ndum)
775 ALLOCATE (ss_history(n_colvar, n_hills))
776 ALLOCATE (delta_s_history(n_colvar, n_hills))
777 ALLOCATE (ww_history(n_hills))
779 ALLOCATE (invdt_history(n_hills))
784 i_rep_val=i, r_vals=rvals)
785 cpassert(
SIZE(rvals) == n_colvar)
786 ss_history(1:n_colvar, i) = rvals
794 cpassert(n_hills == ndum)
797 i_rep_val=i, r_vals=rvals)
798 cpassert(
SIZE(rvals) == n_colvar)
799 delta_s_history(1:n_colvar, i) = rvals
802 CALL cp_warn(__location__, &
803 "Section SPAWNED_HILLS_SCALE is not present! Setting the scales of the "// &
804 "restarted hills according the parameters specified in the input file.")
807 delta_s_history(j, i) = colvars(i)%delta_s
818 cpassert(n_hills == ndum)
821 i_rep_val=i, r_val=rval)
822 cpassert(
SIZE(rvals) == n_colvar)
826 CALL cp_warn(__location__, &
827 "Section SPAWNED_HILLS_HEIGHT is not present! Setting the height of the"// &
828 " restarted hills according the parameters specified in the input file. ")
839 cpassert(n_hills == ndum)
842 i_rep_val=i, r_val=rval)
843 cpassert(
SIZE(rvals) == n_colvar)
844 invdt_history(i) = rval
847 CALL cp_warn(__location__, &
848 "Section SPAWNED_HILLS_INVDT is not present! Restarting from standard"// &
849 " metadynamics run i.e. setting 1/(Delta T) equal to zero. ")
850 invdt_history = 0._dp
854 CALL cp_abort(__location__, &
855 "Found section SPAWNED_HILLS_INVDT while restarting a standard metadynamics run..."// &
856 " Cannot restart metadynamics from well-tempered MetaD runs. ")
861 CALL timestop(handle)
873 INTEGER,
INTENT(OUT) :: iter_nr
875 IF (meta_env%do_multiple_walkers)
THEN
876 iter_nr = meta_env%multiple_walkers%n_hills_local
878 iter_nr = meta_env%hills_env%n_hills
894 REAL(
dp) :: ddp, delta_s, dfunc, diff_ss, dp2, &
898 colvars => meta_env%metavar
900 DO ih = 1,
SIZE(colvars)
901 IF (colvars(ih)%do_wall)
THEN
902 colvars(ih)%epot_walls = 0.0_dp
903 colvars(ih)%ff_walls = 0.0_dp
904 DO iwall = 1,
SIZE(colvars(ih)%walls)
905 SELECT CASE (colvars(ih)%walls(iwall)%id_type)
910 diff_ss = colvars(ih)%ss0 - colvars(ih)%walls(iwall)%pos
911 IF (colvars(ih)%periodic)
THEN
913 diff_ss = sign(1.0_dp, asin(sin(diff_ss)))*acos(cos(diff_ss))
915 efunc = colvars(ih)%walls(iwall)%k_quadratic*diff_ss**2
916 dfunc = 2.0_dp*colvars(ih)%walls(iwall)%k_quadratic*diff_ss
917 SELECT CASE (colvars(ih)%walls(iwall)%id_direction)
919 IF (diff_ss > 0.0_dp)
THEN
920 colvars(ih)%ff_walls = colvars(ih)%ff_walls - dfunc
921 colvars(ih)%epot_walls = colvars(ih)%epot_walls + efunc
924 IF (diff_ss < 0.0_dp)
THEN
925 colvars(ih)%ff_walls = colvars(ih)%ff_walls - dfunc
926 colvars(ih)%epot_walls = colvars(ih)%epot_walls + efunc
930 diff_ss = colvars(ih)%ss0 - colvars(ih)%walls(iwall)%pos0
931 IF (colvars(ih)%periodic)
THEN
933 diff_ss = sign(1.0_dp, asin(sin(diff_ss)))*acos(cos(diff_ss))
935 efunc = colvars(ih)%walls(iwall)%k_quartic*diff_ss**4
936 dfunc = 4.0_dp*colvars(ih)%walls(iwall)%k_quartic*diff_ss**3
937 SELECT CASE (colvars(ih)%walls(iwall)%id_direction)
939 IF (diff_ss > 0.0_dp)
THEN
940 colvars(ih)%ff_walls = colvars(ih)%ff_walls - dfunc
941 colvars(ih)%epot_walls = colvars(ih)%epot_walls + efunc
944 IF (diff_ss < 0.0_dp)
THEN
945 colvars(ih)%ff_walls = colvars(ih)%ff_walls - dfunc
946 colvars(ih)%epot_walls = colvars(ih)%epot_walls + efunc
950 diff_ss = colvars(ih)%ss0 - colvars(ih)%walls(iwall)%pos
951 IF (colvars(ih)%periodic)
THEN
953 diff_ss = sign(1.0_dp, asin(sin(diff_ss)))*acos(cos(diff_ss))
955 ww = colvars(ih)%walls(iwall)%ww_gauss
956 delta_s = colvars(ih)%walls(iwall)%sigma_gauss
957 ddp = (diff_ss)/delta_s
959 efunc = ww*exp(-0.5_dp*dp2)
960 dfunc = -efunc*ddp/delta_s
961 colvars(ih)%ff_walls = colvars(ih)%ff_walls - dfunc
962 colvars(ih)%epot_walls = colvars(ih)%epot_walls + efunc
static GRID_HOST_DEVICE int modulo(int a, int m)
Equivalent of Fortran's MODULO, which always return a positive number. https://gcc....
Utility routines to open and close files.
subroutine, public open_file(file_name, unit_number, file_status, file_form, file_action, file_position, file_pad, file_access, debug)
Opens a file and returns its logical unit number.
subroutine, public close_file(unit_number, file_status)
Closes an open file given by its logical unit number.
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,...
types that represent a subsys, i.e. a part of the system
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
Defines the basic variable types.
integer, parameter, public dp
integer, parameter, public default_path_length
Machine interface based on Fortran 2003 and POSIX.
subroutine, public m_mov(source, target)
...
Interface to the message passing library MPI.
Definition of physical constants:
real(kind=dp), parameter, public kelvin
subroutine check(condition, label)
Stops with an error message if a test fails.
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,...
wrapper to abstract the force evaluation of the various methods
stores all the informations relevant to an mpi environment