(git:9111030)
Loading...
Searching...
No Matches
metadynamics_utils.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2026 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7
8! **************************************************************************************************
9!> \brief Performs the metadynamics calculation
10!> \par History
11!> 01.2005 created [fawzi and ale]
12!> 11.2007 Teodoro Laino [tlaino] - University of Zurich
13! **************************************************************************************************
15 USE cp_files, ONLY: close_file,&
25 USE input_constants, ONLY: do_fe_meta,&
27 do_wall_m,&
29 do_wall_p,&
46 USE kinds, ONLY: default_path_length,&
47 dp
48 USE machine, ONLY: m_mov
55 USE physcon, ONLY: kelvin
56#include "./base/base_uses.f90"
57
58 IMPLICIT NONE
59 PRIVATE
60
61 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'metadynamics_utils'
62
63 PUBLIC :: metadyn_read, &
69
70CONTAINS
71
72! **************************************************************************************************
73!> \brief reads metadynamics section
74!> \param meta_env ...
75!> \param force_env ...
76!> \param root_section ...
77!> \param para_env ...
78!> \param fe_section ...
79!> \par History
80!> 04.2004 created
81!> \author Teodoro Laino [tlaino] - University of Zurich. 11.2007
82! **************************************************************************************************
83 SUBROUTINE metadyn_read(meta_env, force_env, root_section, para_env, fe_section)
84 TYPE(meta_env_type), POINTER :: meta_env
85 TYPE(force_env_type), POINTER :: force_env
86 TYPE(section_vals_type), POINTER :: root_section
87 TYPE(mp_para_env_type), POINTER :: para_env
88 TYPE(section_vals_type), OPTIONAL, POINTER :: fe_section
89
90 CHARACTER(len=*), PARAMETER :: routinen = 'metadyn_read'
91
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
97 REAL(kind=dp) :: dt
98 TYPE(cp_subsys_type), POINTER :: subsys
99 TYPE(section_vals_type), POINTER :: md_section, metadyn_section, &
100 metavar_section, walkers_section
101
102 NULLIFY (subsys)
103 CALL timeset(routinen, handle)
104
105 CALL section_vals_get(fe_section, explicit=explicit)
106 IF (explicit) THEN
107 number_allocated_colvars = 0
108 CALL force_env_get(force_env, subsys=subsys)
109 IF (ASSOCIATED(subsys%colvar_p)) THEN
110 number_allocated_colvars = SIZE(subsys%colvar_p)
111 END IF
112 CALL section_vals_val_get(fe_section, "METHOD", i_val=id_method)
113 IF (id_method /= do_fe_meta) THEN
114 CALL timestop(handle)
115 RETURN
116 END IF
117 metadyn_section => section_vals_get_subs_vals(fe_section, "METADYN")
118 cpassert(.NOT. ASSOCIATED(meta_env))
119
120 md_section => section_vals_get_subs_vals(root_section, "MOTION%MD")
121 CALL section_vals_val_get(md_section, "TIMESTEP", r_val=dt)
122
123 metavar_section => section_vals_get_subs_vals(metadyn_section, "METAVAR")
124 CALL section_vals_get(metavar_section, n_repetition=n_colvar)
125 ALLOCATE (meta_env)
126 CALL metadyn_create(meta_env, n_colvar=n_colvar, &
127 dt=dt, para_env=para_env, metadyn_section=metadyn_section)
128
129 !Check if using plumed. If so, only get the file name and read nothing else
130 CALL section_vals_val_get(metadyn_section, "USE_PLUMED", l_val=meta_env%use_plumed)
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)
136 RETURN
137 END IF
138
139 CALL section_vals_val_get(metadyn_section, "DO_HILLS", l_val=meta_env%do_hills)
140 CALL section_vals_val_get(metadyn_section, "LAGRANGE", l_val=meta_env%extended_lagrange)
141 CALL section_vals_val_get(metadyn_section, "TAMCSteps", i_val=meta_env%TAMCSteps)
142 IF (meta_env%TAMCSteps < 0) THEN
143 cpabort("TAMCSteps must be positive!")
144 END IF
145 CALL section_vals_val_get(metadyn_section, "Timestep", r_val=meta_env%zdt)
146 IF (meta_env%zdt <= 0.0_dp) THEN
147 cpabort("Timestep must be positive!")
148 END IF
149 CALL section_vals_val_get(metadyn_section, "WW", r_val=meta_env%hills_env%ww)
150 CALL section_vals_val_get(metadyn_section, "NT_HILLS", i_val=meta_env%hills_env%nt_hills)
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!")
158 END IF
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!")
163 END IF
164 !RG Adaptive hills
165 CALL section_vals_val_get(metadyn_section, "MIN_DISP", r_val=meta_env%hills_env%min_disp)
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)
168
169 !Hills tail damping
170 CALL section_vals_val_get(metadyn_section, "HILL_TAIL_CUTOFF", r_val=meta_env%hills_env%tail_cutoff)
171 CALL section_vals_val_get(metadyn_section, "P_EXPONENT", i_val=meta_env%hills_env%p_exp)
172 CALL section_vals_val_get(metadyn_section, "Q_EXPONENT", i_val=meta_env%hills_env%q_exp)
173
174 CALL section_vals_val_get(metadyn_section, "SLOW_GROWTH", l_val=meta_env%hills_env%slow_growth)
175
176 !RG Adaptive hills
177 CALL section_vals_val_get(metadyn_section, "STEP_START_VAL", i_val=meta_env%n_steps)
178 cpassert(meta_env%n_steps >= 0)
179 CALL section_vals_val_get(metadyn_section, "NHILLS_START_VAL", &
180 i_val=meta_env%hills_env%n_hills)
181 CALL section_vals_val_get(metadyn_section, "TEMPERATURE", r_val=meta_env%temp_wanted)
182 CALL section_vals_val_get(metadyn_section, "LANGEVIN", l_val=meta_env%langevin)
183 CALL section_vals_val_get(metadyn_section, "TEMP_TOL", explicit=meta_env%tempcontrol, &
184 r_val=meta_env%toll_temp)
185 CALL section_vals_val_get(metadyn_section, "WELL_TEMPERED", l_val=meta_env%well_tempered)
186 CALL section_vals_val_get(metadyn_section, "DELTA_T", explicit=meta_env%hills_env%wtcontrol, &
187 r_val=meta_env%delta_t)
188 CALL section_vals_val_get(metadyn_section, "WTGAMMA", explicit=check, &
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.")
196 END IF
197 IF (meta_env%extended_lagrange) THEN
198 CALL cp_abort(__location__, &
199 "Well-Tempered metadynamics not possible with extended-lagrangian formulation.")
200 END IF
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.")
204 END IF
205 END IF
206
207 CALL section_vals_val_get(metadyn_section, "COLVAR_AVG_TEMPERATURE_RESTART", &
208 r_val=meta_env%avg_temp)
209 ! Parsing Metavar Section
210 DO i = 1, n_colvar
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)))//") !")
220 END IF
221 END DO
222
223 ! Parsing the Multiple Walkers Info
224 IF (meta_env%do_multiple_walkers) THEN
225 NULLIFY (walkers_status)
226 walkers_section => section_vals_get_subs_vals(metadyn_section, "MULTIPLE_WALKERS")
227
228 ! General setup for walkers
229 CALL section_vals_val_get(walkers_section, "WALKER_ID", &
230 i_val=meta_env%multiple_walkers%walker_id)
231 CALL section_vals_val_get(walkers_section, "NUMBER_OF_WALKERS", &
232 i_val=meta_env%multiple_walkers%walkers_tot_nr)
233 CALL section_vals_val_get(walkers_section, "WALKER_COMM_FREQUENCY", &
234 i_val=meta_env%multiple_walkers%walkers_freq_comm)
235
236 ! Handle status and file names
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))
239 CALL section_vals_val_get(walkers_section, "WALKERS_STATUS", explicit=explicit)
240 IF (explicit) THEN
241 CALL section_vals_val_get(walkers_section, "WALKERS_STATUS", i_vals=walkers_status)
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! ")
249 END IF
250 meta_env%multiple_walkers%walkers_status = walkers_status
251 ELSE
252 meta_env%multiple_walkers%walkers_status = 0
253 END IF
254 meta_env%multiple_walkers%n_hills_local = &
255 meta_env%multiple_walkers%walkers_status(meta_env%multiple_walkers%walker_id)
256
257 CALL section_vals_val_get(walkers_section, "WALKERS_FILE_NAME%_DEFAULT_KEYWORD_", &
258 n_rep_val=n_rep)
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! ")
266 END IF
267 DO i = 1, n_rep
268 CALL section_vals_val_get(walkers_section, "WALKERS_FILE_NAME%_DEFAULT_KEYWORD_", &
269 i_rep_val=i, c_val=walkers_file_name)
270 meta_env%multiple_walkers%walkers_file_name(i) = walkers_file_name
271 END DO
272 END IF
273
274 ! Print Metadynamics Info
275 CALL print_metadyn_info(meta_env, n_colvar, metadyn_section)
276 END IF
277
278 CALL timestop(handle)
279
280 END SUBROUTINE metadyn_read
281
282! **************************************************************************************************
283!> \brief prints information on the metadynamics run
284!> \param meta_env ...
285!> \param n_colvar ...
286!> \param metadyn_section ...
287!> \author Teodoro Laino [tlaino] - University of Zurich. 10.2008
288! **************************************************************************************************
289 SUBROUTINE print_metadyn_info(meta_env, n_colvar, metadyn_section)
290 TYPE(meta_env_type), POINTER :: meta_env
291 INTEGER, INTENT(IN) :: n_colvar
292 TYPE(section_vals_type), POINTER :: metadyn_section
293
294 CHARACTER(len=*), PARAMETER :: routinen = 'print_metadyn_info'
295
296 CHARACTER(LEN=10) :: my_id, my_tag
297 INTEGER :: handle, i, iw, j
298 TYPE(cp_logger_type), POINTER :: logger
299 TYPE(enumeration_type), POINTER :: enum
300 TYPE(keyword_type), POINTER :: keyword
301 TYPE(section_type), POINTER :: section, wall_section, work_section
302
303 CALL timeset(routinen, handle)
304
305 logger => cp_get_default_logger()
306 iw = cp_print_key_unit_nr(logger, metadyn_section, &
307 "PRINT%PROGRAM_RUN_INFO", extension=".metadynLog")
308 NULLIFY (section, enum, keyword)
309 CALL create_metavar_section(section)
310 wall_section => section_get_subsection(section, "WALL")
311 IF (iw > 0) THEN
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
325 END IF
326 WRITE (iw, '(A,T71,F10.4)') ' METADYN| COLVARS restarted average temperature ', &
327 meta_env%avg_temp
328 END IF
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
332 !RG Adaptive hills
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
337 END IF
338 !RG Adaptive hills
339 END IF
340
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
345 ELSE
346 WRITE (iw, '( A,T71,F10.3)') ' METADYN| Temperature parameter (gamma)', meta_env%wtgamma
347 END IF
348 END IF
349
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
359 my_tag = ""
360 IF (i == meta_env%multiple_walkers%walker_id) my_tag = " ( Local )"
361 my_id = '( '//trim(adjustl(cp_to_string(i)))//' )'
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))
367 END DO
368 WRITE (iw, '(/)')
369 END IF
370
371 WRITE (iw, '( A,T71,I10)') ' METADYN| Number of collective variables', meta_env%n_colvar
372 DO i = 1, 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
378 END IF
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)
385 keyword => section_get_keyword(wall_section, "TYPE")
386 CALL keyword_get(keyword, enum=enum)
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)))
389 ! Type of wall IO
390 SELECT CASE (meta_env%metavar(i)%walls(j)%id_type)
391 CASE (do_wall_none)
392 ! Do Nothing
393 cycle
394 CASE (do_wall_reflective)
395 work_section => section_get_subsection(wall_section, "REFLECTIVE")
396 keyword => section_get_keyword(work_section, "DIRECTION")
397 CALL keyword_get(keyword, enum=enum)
398 WRITE (iw, '(A,T70,A11)') ' METAVARS| Wall direction', &
399 adjustr(trim(enum_i2c(enum, meta_env%metavar(i)%walls(j)%id_direction)))
400 CASE (do_wall_quadratic)
401 work_section => section_get_subsection(wall_section, "QUADRATIC")
402 keyword => section_get_keyword(work_section, "DIRECTION")
403 CALL keyword_get(keyword, enum=enum)
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
408 CASE (do_wall_gaussian)
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
413 END SELECT
414 WRITE (iw, '(A,T70,F11.6)') ' METAVARS| Wall location', &
415 meta_env%metavar(i)%walls(j)%pos
416 END DO
417 END IF
418 WRITE (iw, '( A )') ' '//'----------------------------------------------------------------------'
419 END DO
420 END IF
421 CALL section_release(section)
422 CALL cp_print_key_finished_output(iw, logger, metadyn_section, "PRINT%PROGRAM_RUN_INFO")
423
424 CALL timestop(handle)
425
426 END SUBROUTINE print_metadyn_info
427
428! **************************************************************************************************
429!> \brief reads metavar section
430!> \param metavar ...
431!> \param extended_lagrange ...
432!> \param langevin ...
433!> \param icol ...
434!> \param metavar_section ...
435!> \par History
436!> 04.2004 created
437!> \author alessandro laio and fawzi mohamed
438!> Teodoro Laino [tlaino] - University of Zurich. 11.2007
439! **************************************************************************************************
440 SUBROUTINE metavar_read(metavar, extended_lagrange, langevin, icol, metavar_section)
441 TYPE(metavar_type), INTENT(INOUT) :: metavar
442 LOGICAL, INTENT(IN) :: extended_lagrange, langevin
443 INTEGER, INTENT(IN) :: icol
444 TYPE(section_vals_type), OPTIONAL, POINTER :: metavar_section
445
446 CHARACTER(len=*), PARAMETER :: routinen = 'metavar_read'
447
448 INTEGER :: handle, i, n_walls
449 TYPE(section_vals_type), POINTER :: wall_section, work_section
450
451 CALL timeset(routinen, handle)
452
453 CALL section_vals_val_get(metavar_section, "COLVAR", i_rep_section=icol, i_val=metavar%icolvar)
454 CALL section_vals_val_get(metavar_section, "SCALE", i_rep_section=icol, r_val=metavar%delta_s)
455 ! Walls
456 wall_section => section_vals_get_subs_vals(metavar_section, "WALL", i_rep_section=icol)
457 CALL section_vals_get(wall_section, n_repetition=n_walls)
458 IF (n_walls /= 0) THEN
459 metavar%do_wall = .true.
460 ALLOCATE (metavar%walls(n_walls))
461 DO i = 1, 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)
465 CASE (do_wall_none)
466 ! Just cycle..
467 cycle
468 CASE (do_wall_reflective)
469 work_section => section_vals_get_subs_vals(wall_section, "REFLECTIVE", i_rep_section=i)
470 CALL section_vals_val_get(work_section, "DIRECTION", i_val=metavar%walls(i)%id_direction)
471 CASE (do_wall_quadratic)
472 work_section => section_vals_get_subs_vals(wall_section, "QUADRATIC", i_rep_section=i)
473 CALL section_vals_val_get(work_section, "DIRECTION", i_val=metavar%walls(i)%id_direction)
474 CALL section_vals_val_get(work_section, "K", r_val=metavar%walls(i)%k_quadratic)
475 CASE (do_wall_quartic)
476 work_section => section_vals_get_subs_vals(wall_section, "QUARTIC", i_rep_section=i)
477 CALL section_vals_val_get(work_section, "DIRECTION", i_val=metavar%walls(i)%id_direction)
478 CALL section_vals_val_get(work_section, "K", r_val=metavar%walls(i)%k_quartic)
479 SELECT CASE (metavar%walls(i)%id_direction)
480 CASE (do_wall_m)
481 metavar%walls(i)%pos0 = metavar%walls(i)%pos + (0.05_dp/metavar%walls(i)%k_quartic**(0.25_dp))
482 CASE (do_wall_p)
483 metavar%walls(i)%pos0 = metavar%walls(i)%pos - (0.05_dp/metavar%walls(i)%k_quartic**(0.25_dp))
484 END SELECT
485 CASE (do_wall_gaussian)
486 work_section => section_vals_get_subs_vals(wall_section, "GAUSSIAN", i_rep_section=i)
487 CALL section_vals_val_get(work_section, "WW", r_val=metavar%walls(i)%ww_gauss)
488 CALL section_vals_val_get(work_section, "SIGMA", r_val=metavar%walls(i)%sigma_gauss)
489 END SELECT
490 END DO
491 END IF
492 ! Setup few more parameters for extended lagrangian
493 IF (extended_lagrange) THEN
494 CALL section_vals_val_get(metavar_section, "MASS", i_rep_section=icol, r_val=metavar%mass)
495 CALL section_vals_val_get(metavar_section, "LAMBDA", i_rep_section=icol, r_val=metavar%lambda)
496 IF (langevin) THEN
497 CALL section_vals_val_get(metavar_section, "GAMMA", i_rep_section=icol, r_val=metavar%gamma)
498 END IF
499 END IF
500
501 CALL timestop(handle)
502
503 END SUBROUTINE metavar_read
504
505! **************************************************************************************************
506!> \brief Synchronize with the rest of the walkers
507!> \param multiple_walkers ...
508!> \param hills_env ...
509!> \param colvars ...
510!> \param n_colvar ...
511!> \param metadyn_section ...
512!> \author Teodoro Laino [tlaino] - University of Zurich - 10.2008
513! **************************************************************************************************
514 SUBROUTINE synchronize_multiple_walkers(multiple_walkers, hills_env, colvars, &
515 n_colvar, metadyn_section)
516 TYPE(multiple_walkers_type), POINTER :: multiple_walkers
517 TYPE(hills_env_type), POINTER :: hills_env
518 TYPE(metavar_type), DIMENSION(:), POINTER :: colvars
519 INTEGER, INTENT(IN) :: n_colvar
520 TYPE(section_vals_type), POINTER :: metadyn_section
521
522 CHARACTER(len=*), PARAMETER :: routinen = 'synchronize_multiple_walkers'
523
524 CHARACTER(LEN=default_path_length) :: filename, tmpname
525 INTEGER :: delta_hills, handle, i, i_hills, ih, iw, &
526 unit_nr
527 LOGICAL :: exist
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
531 TYPE(cp_logger_type), POINTER :: logger
532 TYPE(mp_para_env_type), POINTER :: para_env
533
534 CALL timeset(routinen, handle)
535
536 logger => cp_get_default_logger()
537 para_env => logger%para_env
538
539 ! Locally dump information on file..
540 IF (para_env%is_source()) THEN
541 ! Generate file name for the specific Hill
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)
550 DO ih = 1, n_colvar
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)
553 END DO
554 IF (hills_env%wtcontrol) WRITE (unit_nr, *) hills_env%invdt_history(hills_env%n_hills)
555 CALL close_file(unit_nr)
556 CALL m_mov(tmpname, filename)
557 END IF
558
559 IF (modulo(multiple_walkers%n_hills_local, multiple_walkers%walkers_freq_comm) == 0) THEN
560 ! Store colvars information
561 ALLOCATE (ss0_save(n_colvar))
562 ALLOCATE (delta_s_save(n_colvar))
563 ALLOCATE (delta_s_ss0_buf(2, 0:n_colvar))
564 delta_s_ss0_buf = 0
565 DO i = 1, n_colvar
566 ss0_save(i) = colvars(i)%ss0
567 delta_s_save(i) = colvars(i)%delta_s
568 END DO
569
570 ! Watch for other walkers's file and update
571 DO i = 1, multiple_walkers%walkers_tot_nr
572 IF (i == multiple_walkers%walker_id) THEN
573 ! Update local counter
574 multiple_walkers%walkers_status(i) = multiple_walkers%n_hills_local
575 cycle
576 END IF
577
578 i_hills = multiple_walkers%walkers_status(i) + 1
579 filename = trim(multiple_walkers%walkers_file_name(i))//"_"// &
580 trim(adjustl(cp_to_string(i_hills)))
581
582 IF (para_env%is_source()) THEN
583 INQUIRE (file=trim(filename), exist=exist)
584 END IF
585 CALL para_env%bcast(exist)
586 DO WHILE (exist)
587 ! Read information from the walker's file
588 ! We shouldn't care too much about the concurrency of these I/O instructions..
589 ! In case, they can be fixed in the future..
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)
595 DO ih = 1, n_colvar
596 READ (unit_nr, *) delta_s_ss0_buf(1, ih)
597 READ (unit_nr, *) delta_s_ss0_buf(2, ih)
598 END DO
599 IF (hills_env%wtcontrol) READ (unit_nr, *) delta_s_ss0_buf(2, 0)
600 CALL close_file(unit_nr)
601 END IF
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)
605 DO ih = 1, n_colvar
606 colvars(ih)%ss0 = delta_s_ss0_buf(1, ih)
607 colvars(ih)%delta_s = delta_s_ss0_buf(2, ih)
608 END DO
609
610 ! Add this hill to the history dependent terms
611 IF (hills_env%wtcontrol) THEN
612 CALL add_hill_single(hills_env, colvars, ww, hills_env%n_hills, n_colvar, invdt=invdt)
613 ELSE
614 CALL add_hill_single(hills_env, colvars, ww, hills_env%n_hills, n_colvar)
615 END IF
616
617 i_hills = i_hills + 1
618 filename = trim(multiple_walkers%walkers_file_name(i))//"_"// &
619 trim(adjustl(cp_to_string(i_hills)))
620 IF (para_env%is_source()) THEN
621 INQUIRE (file=trim(filename), exist=exist)
622 END IF
623 CALL para_env%bcast(exist)
624 END DO
625
626 delta_hills = i_hills - 1 - multiple_walkers%walkers_status(i)
627 multiple_walkers%walkers_status(i) = i_hills - 1
628 iw = cp_print_key_unit_nr(logger, metadyn_section, "PRINT%PROGRAM_RUN_INFO", &
629 extension=".metadynLog")
630 IF (iw > 0) THEN
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), ']'
633 END IF
634 CALL cp_print_key_finished_output(iw, logger, metadyn_section, &
635 "PRINT%PROGRAM_RUN_INFO")
636 END DO
637
638 ! Restore colvars information
639 DO i = 1, n_colvar
640 colvars(i)%ss0 = ss0_save(i)
641 colvars(i)%delta_s = delta_s_save(i)
642 END DO
643 DEALLOCATE (ss0_save)
644 DEALLOCATE (delta_s_save)
645 END IF
646
647 CALL timestop(handle)
648
649 END SUBROUTINE synchronize_multiple_walkers
650
651! **************************************************************************************************
652!> \brief Add a single Hill
653!> \param hills_env ...
654!> \param colvars ...
655!> \param ww ...
656!> \param n_hills ...
657!> \param n_colvar ...
658!> \param invdt ...
659!> \author Teodoro Laino [tlaino] - University of Zurich - 10.2008
660! **************************************************************************************************
661 SUBROUTINE add_hill_single(hills_env, colvars, ww, n_hills, n_colvar, invdt)
662 TYPE(hills_env_type), POINTER :: hills_env
663 TYPE(metavar_type), DIMENSION(:), POINTER :: colvars
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
668
669 CHARACTER(len=*), PARAMETER :: routinen = 'add_hill_single'
670
671 INTEGER :: handle, i
672 LOGICAL :: wtcontrol
673 REAL(kind=dp), DIMENSION(:), POINTER :: tnp
674 REAL(kind=dp), DIMENSION(:, :), POINTER :: tmp
675
676 CALL timeset(routinen, handle)
677
678 wtcontrol = PRESENT(invdt)
679 NULLIFY (tmp, tnp)
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
686 NULLIFY (tmp)
687 END IF
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
694 NULLIFY (tmp)
695 END IF
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
702 NULLIFY (tnp)
703 END IF
704 IF (wtcontrol) THEN
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
711 NULLIFY (tnp)
712 END IF
713 END IF
714 n_hills = n_hills + 1
715 ! Now add the hill
716 DO i = 1, n_colvar
717 hills_env%ss_history(i, n_hills) = colvars(i)%ss0
718 hills_env%delta_s_history(i, n_hills) = colvars(i)%delta_s
719 END DO
720 hills_env%ww_history(n_hills) = ww
721 IF (wtcontrol) hills_env%invdt_history(n_hills) = invdt
722
723 CALL timestop(handle)
724
725 END SUBROUTINE add_hill_single
726
727! **************************************************************************************************
728!> \brief Restart Hills Information
729!> \param ss_history ...
730!> \param delta_s_history ...
731!> \param ww_history ...
732!> \param ww ...
733!> \param n_hills ...
734!> \param n_colvar ...
735!> \param colvars ...
736!> \param metadyn_section ...
737!> \param invdt_history ...
738!> \author Teodoro Laino [tlaino] - University of Zurich - 10.2008
739! **************************************************************************************************
740 SUBROUTINE restart_hills(ss_history, delta_s_history, ww_history, ww, &
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
744 REAL(kind=dp) :: ww
745 INTEGER, INTENT(IN) :: n_hills, n_colvar
746 TYPE(metavar_type), DIMENSION(:), POINTER :: colvars
747 TYPE(section_vals_type), POINTER :: metadyn_section
748 REAL(kind=dp), DIMENSION(:), OPTIONAL, POINTER :: invdt_history
749
750 CHARACTER(len=*), PARAMETER :: routinen = 'restart_hills'
751
752 INTEGER :: handle, i, j, ndum
753 LOGICAL :: explicit, wtcontrol
754 REAL(kind=dp) :: rval
755 REAL(kind=dp), DIMENSION(:), POINTER :: rvals
756 TYPE(section_vals_type), POINTER :: hills_history
757
758 CALL timeset(routinen, handle)
759
760 wtcontrol = PRESENT(invdt_history)
761 NULLIFY (rvals)
762 hills_history => section_vals_get_subs_vals(metadyn_section, "SPAWNED_HILLS_POS")
763 CALL section_vals_get(hills_history, explicit=explicit)
764 IF (explicit) THEN
765 CALL section_vals_val_get(hills_history, "_DEFAULT_KEYWORD_", n_rep_val=ndum)
766 ! ss_history, delta_s_history, ww_history, invdt_history : deallocate and reallocate with the proper size
767 DEALLOCATE (ss_history)
768 DEALLOCATE (delta_s_history)
769 DEALLOCATE (ww_history)
770 IF (wtcontrol) THEN
771 DEALLOCATE (invdt_history)
772 END IF
773 !
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))
778 IF (wtcontrol) THEN
779 ALLOCATE (invdt_history(n_hills))
780 END IF
781 !
782 DO i = 1, n_hills
783 CALL section_vals_val_get(hills_history, "_DEFAULT_KEYWORD_", &
784 i_rep_val=i, r_vals=rvals)
785 cpassert(SIZE(rvals) == n_colvar)
786 ss_history(1:n_colvar, i) = rvals
787 END DO
788 !
789 hills_history => section_vals_get_subs_vals(metadyn_section, "SPAWNED_HILLS_SCALE")
790 CALL section_vals_get(hills_history, explicit=explicit)
791 IF (explicit) THEN
792 ! delta_s_history
793 CALL section_vals_val_get(hills_history, "_DEFAULT_KEYWORD_", n_rep_val=ndum)
794 cpassert(n_hills == ndum)
795 DO i = 1, n_hills
796 CALL section_vals_val_get(hills_history, "_DEFAULT_KEYWORD_", &
797 i_rep_val=i, r_vals=rvals)
798 cpassert(SIZE(rvals) == n_colvar)
799 delta_s_history(1:n_colvar, i) = rvals
800 END DO
801 ELSE
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.")
805 DO i = 1, n_hills
806 DO j = 1, n_colvar
807 delta_s_history(j, i) = colvars(i)%delta_s
808 END DO
809 END DO
810 END IF
811 !
812 hills_history => section_vals_get_subs_vals(metadyn_section, "SPAWNED_HILLS_HEIGHT")
813 CALL section_vals_get(hills_history, explicit=explicit)
814 IF (explicit) THEN
815 ! ww_history
816 CALL section_vals_val_get(hills_history, "_DEFAULT_KEYWORD_", &
817 n_rep_val=ndum)
818 cpassert(n_hills == ndum)
819 DO i = 1, n_hills
820 CALL section_vals_val_get(hills_history, "_DEFAULT_KEYWORD_", &
821 i_rep_val=i, r_val=rval)
822 cpassert(SIZE(rvals) == n_colvar)
823 ww_history(i) = rval
824 END DO
825 ELSE
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. ")
829 ww_history = ww
830 END IF
831 !
832 hills_history => section_vals_get_subs_vals(metadyn_section, "SPAWNED_HILLS_INVDT")
833 CALL section_vals_get(hills_history, explicit=explicit)
834 IF (wtcontrol) THEN
835 IF (explicit) THEN
836 ! invdt_history
837 CALL section_vals_val_get(hills_history, "_DEFAULT_KEYWORD_", &
838 n_rep_val=ndum)
839 cpassert(n_hills == ndum)
840 DO i = 1, n_hills
841 CALL section_vals_val_get(hills_history, "_DEFAULT_KEYWORD_", &
842 i_rep_val=i, r_val=rval)
843 cpassert(SIZE(rvals) == n_colvar)
844 invdt_history(i) = rval
845 END DO
846 ELSE
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
851 END IF
852 ELSE
853 IF (explicit) THEN
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. ")
857 END IF
858 END IF
859 END IF
860
861 CALL timestop(handle)
862
863 END SUBROUTINE restart_hills
864
865! **************************************************************************************************
866!> \brief Retrieves the iteration level for the metadynamics loop
867!> \param meta_env ...
868!> \param iter_nr ...
869!> \author Teodoro Laino [tlaino] - University of Zurich - 10.2008
870! **************************************************************************************************
871 SUBROUTINE get_meta_iter_level(meta_env, iter_nr)
872 TYPE(meta_env_type), POINTER :: meta_env
873 INTEGER, INTENT(OUT) :: iter_nr
874
875 IF (meta_env%do_multiple_walkers) THEN
876 iter_nr = meta_env%multiple_walkers%n_hills_local
877 ELSE
878 iter_nr = meta_env%hills_env%n_hills
879 END IF
880
881 END SUBROUTINE get_meta_iter_level
882
883! **************************************************************************************************
884!> \brief ...
885!> \param meta_env ...
886!> \par History
887!> 11.2007 [created] [tlaino]
888!> \author Teodoro Laino - University of Zurich - 11.2007
889! **************************************************************************************************
890 SUBROUTINE meta_walls(meta_env)
891 TYPE(meta_env_type), POINTER :: meta_env
892
893 INTEGER :: ih, iwall
894 REAL(dp) :: ddp, delta_s, dfunc, diff_ss, dp2, &
895 efunc, ww
896 TYPE(metavar_type), DIMENSION(:), POINTER :: colvars
897
898 colvars => meta_env%metavar
899 ! Forces from the Walls
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)
907 ! Do Nothing.. treated in the main metadyn function
908 cycle
909 CASE (do_wall_quadratic)
910 diff_ss = colvars(ih)%ss0 - colvars(ih)%walls(iwall)%pos
911 IF (colvars(ih)%periodic) THEN
912 ! The difference of a periodic COLVAR is always within [-pi,pi]
913 diff_ss = sign(1.0_dp, asin(sin(diff_ss)))*acos(cos(diff_ss))
914 END IF
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)
918 CASE (do_wall_p)
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
922 END IF
923 CASE (do_wall_m)
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
927 END IF
928 END SELECT
929 CASE (do_wall_quartic)
930 diff_ss = colvars(ih)%ss0 - colvars(ih)%walls(iwall)%pos0
931 IF (colvars(ih)%periodic) THEN
932 ! The difference of a periodic COLVAR is always within [-pi,pi]
933 diff_ss = sign(1.0_dp, asin(sin(diff_ss)))*acos(cos(diff_ss))
934 END IF
935 efunc = colvars(ih)%walls(iwall)%k_quartic*diff_ss*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)
938 CASE (do_wall_p)
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
942 END IF
943 CASE (do_wall_m)
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
947 END IF
948 END SELECT
949 CASE (do_wall_gaussian)
950 diff_ss = colvars(ih)%ss0 - colvars(ih)%walls(iwall)%pos
951 IF (colvars(ih)%periodic) THEN
952 ! The difference of a periodic COLVAR is always within [-pi,pi]
953 diff_ss = sign(1.0_dp, asin(sin(diff_ss)))*acos(cos(diff_ss))
954 END IF
955 ww = colvars(ih)%walls(iwall)%ww_gauss
956 delta_s = colvars(ih)%walls(iwall)%sigma_gauss
957 ddp = (diff_ss)/delta_s
958 dp2 = ddp**2
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
963 END SELECT
964 END DO
965 END IF
966 END DO
967 END SUBROUTINE meta_walls
968
969END MODULE metadynamics_utils
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. 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:311
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:122
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
collects all constants needed in input so that they can be used without circular dependencies
integer, parameter, public do_wall_p
integer, parameter, public do_wall_m
integer, parameter, public do_wall_none
integer, parameter, public do_wall_gaussian
integer, parameter, public do_wall_quartic
integer, parameter, public do_wall_reflective
integer, parameter, public do_wall_quadratic
integer, parameter, public do_fe_meta
subroutine, public create_metavar_section(section)
creates the metavar section
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
type(section_type) function, pointer, public section_get_subsection(section, subsection_name)
returns the requested subsection
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_path_length
Definition kinds.F:58
Machine interface based on Fortran 2003 and POSIX.
Definition machine.F:17
subroutine, public m_mov(source, target)
...
Definition machine.F:695
Interface to the message passing library MPI.
defines types for metadynamics calculation
subroutine, public metadyn_create(meta_env, n_colvar, dt, para_env, metadyn_section)
allocates a metadynamic environment (performs only minimal initialization)
Performs the metadynamics calculation.
subroutine, public synchronize_multiple_walkers(multiple_walkers, hills_env, colvars, n_colvar, metadyn_section)
Synchronize with the rest of the walkers.
subroutine, public metadyn_read(meta_env, force_env, root_section, para_env, fe_section)
reads metadynamics section
subroutine, public get_meta_iter_level(meta_env, iter_nr)
Retrieves the iteration level for the metadynamics loop.
subroutine, public meta_walls(meta_env)
...
subroutine, public restart_hills(ss_history, delta_s_history, ww_history, ww, n_hills, n_colvar, colvars, metadyn_section, invdt_history)
Restart Hills Information.
subroutine, public add_hill_single(hills_env, colvars, ww, n_hills, n_colvar, invdt)
Add a single Hill.
Definition of physical constants:
Definition physcon.F:68
real(kind=dp), parameter, public kelvin
Definition physcon.F:165
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
represent a keyword in the input
represent a section of the input file
stores all the informations relevant to an mpi environment
defines types for COLVAR used in the metadynamics
defines types for multiple walkers run