(git:fc9bb57)
Loading...
Searching...
No Matches
tamc_run.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 Perform a temperature accelarated hybrid monte carlo (TAHMC) run using QUICKSTEP
10!> \par History
11!> none
12!> \author Alin M Elena
13! **************************************************************************************************
15
19 USE barostat_types, ONLY: barostat_type,&
22 USE cell_types, ONLY: cell_type
24 USE colvar_types, ONLY: hbp_colvar_id,&
34 cp_p_file,&
49 USE input_constants, ONLY: &
60 USE kinds, ONLY: dp
61 USE machine, ONLY: m_walltime
67 USE mc_misc, ONLY: mc_averages_create,&
71 USE mc_types, ONLY: get_mc_par,&
77 USE md_ener_types, ONLY: create_md_ener,&
86 USE md_run, ONLY: qs_mol_dyn
87 USE message_passing, ONLY: mp_comm_type,&
97 USE parallel_rng_types, ONLY: uniform,&
101 USE physcon, ONLY: boltzmann,&
103 joule,&
104 kelvin
109 USE reftraj_types, ONLY: create_reftraj,&
116 USE string_utilities, ONLY: str_comp
122 USE virial_types, ONLY: virial_type
125!!!!! monte carlo part
126#include "../../base/base_uses.f90"
127
128 IMPLICIT NONE
129
130 PRIVATE
131
132 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'tamc_run'
133
134 PUBLIC :: qs_tamc
135
136CONTAINS
137
138! **************************************************************************************************
139!> \brief Driver routine for TAHMC
140!> \param force_env ...
141!> \param globenv ...
142!> \param averages ...
143!> \author Alin M Elena
144!> \note it computes the forces using QuickStep.
145! **************************************************************************************************
146 SUBROUTINE qs_tamc(force_env, globenv, averages)
147
148 TYPE(force_env_type), POINTER :: force_env
149 TYPE(global_environment_type), POINTER :: globenv
150 TYPE(average_quantities_type), OPTIONAL, POINTER :: averages
151
152 CHARACTER(LEN=*), PARAMETER :: routinen = 'qs_tamc'
153
154 CHARACTER(LEN=20) :: ensemble
155 INTEGER :: handle, i, initialstep, iprint, isos, &
156 istep, j, md_stride, nmccycles, &
157 output_unit, rand2skip, run_type_id
158 INTEGER, POINTER :: itimes
159 LOGICAL :: check, explicit, my_rm_restart_info, &
160 save_mem, should_stop
161 REAL(kind=dp) :: auxrandom, inittime, rval, temp, &
162 time_iter_start, time_iter_stop
163 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: an, fz, xieta, zbuff
164 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: r
165 REAL(kind=dp), POINTER :: constant, time, used_time
166 TYPE(atomic_kind_list_type), POINTER :: atomic_kinds
167 TYPE(barostat_type), POINTER :: barostat
168 TYPE(cell_type), POINTER :: cell
169 TYPE(cp_logger_type), POINTER :: logger
170 TYPE(cp_subsys_type), POINTER :: subsys, subsys_i
171 TYPE(distribution_1d_type), POINTER :: local_particles
172 TYPE(free_energy_type), POINTER :: fe_env
173 TYPE(mc_averages_type), POINTER :: mcaverages
174 TYPE(mc_environment_type), POINTER :: mc_env
175 TYPE(mc_moves_type), POINTER :: gmoves, moves
176 TYPE(mc_simpar_type), POINTER :: mc_par
177 TYPE(md_ener_type), POINTER :: md_ener
178 TYPE(md_environment_type), POINTER :: md_env
179 TYPE(meta_env_type), POINTER :: meta_env_saved
180 TYPE(mp_para_env_type), POINTER :: para_env
181 TYPE(particle_list_type), POINTER :: particles
182 TYPE(reftraj_type), POINTER :: reftraj
183 TYPE(rng_stream_type) :: rng_stream_mc
184 TYPE(section_vals_type), POINTER :: constraint_section, force_env_section, &
185 free_energy_section, fs_section, global_section, mc_section, md_section, motion_section, &
186 reftraj_section, subsys_section, work_section
187 TYPE(simpar_type), POINTER :: simpar
188 TYPE(thermal_regions_type), POINTER :: thermal_regions
189 TYPE(thermostats_type), POINTER :: thermostats
190 TYPE(virial_type), POINTER :: virial
191
192 initialstep = 0
193 inittime = 0.0_dp
194
195 CALL timeset(routinen, handle)
196 my_rm_restart_info = .true.
197 NULLIFY (para_env, fs_section, virial)
198 para_env => force_env%para_env
199 motion_section => section_vals_get_subs_vals(force_env%root_section, "MOTION")
200 md_section => section_vals_get_subs_vals(motion_section, "MD")
201
202 ! Real call to MD driver - Low Level
203 ALLOCATE (md_env)
204 CALL md_env_create(md_env, md_section, para_env, force_env=force_env)
205 IF (PRESENT(averages)) CALL set_md_env(md_env, averages=averages)
206
207 cpassert(ASSOCIATED(globenv))
208 cpassert(ASSOCIATED(force_env))
209
210 NULLIFY (particles, cell, simpar, itimes, used_time, subsys, &
211 md_ener, thermostats, barostat, reftraj, force_env_section, &
212 reftraj_section, work_section, atomic_kinds, &
213 local_particles, time, fe_env, free_energy_section, &
214 constraint_section, thermal_regions, subsys_i)
215 logger => cp_get_default_logger()
216 para_env => force_env%para_env
217
218 global_section => section_vals_get_subs_vals(force_env%root_section, "GLOBAL")
219 free_energy_section => section_vals_get_subs_vals(motion_section, "FREE_ENERGY")
220 constraint_section => section_vals_get_subs_vals(motion_section, "CONSTRAINT")
221 CALL section_vals_val_get(global_section, "SAVE_MEM", l_val=save_mem)
222
223 CALL section_vals_val_get(global_section, "RUN_TYPE", i_val=run_type_id)
224
225 CALL create_simpar_type(simpar)
226 force_env_section => force_env%force_env_section
227 subsys_section => section_vals_get_subs_vals(force_env_section, "SUBSYS")
228 CALL cp_add_iter_level(logger%iter_info, "MD")
229 CALL cp_iterate(logger%iter_info, iter_nr=initialstep)
230 ! Read MD section
231 CALL read_md_section(simpar, motion_section, md_section)
232 ! Setup print_keys
233 simpar%info_constraint = cp_print_key_unit_nr(logger, constraint_section, &
234 "CONSTRAINT_INFO", extension=".shakeLog", log_filename=.false.)
235 simpar%lagrange_multipliers = cp_print_key_unit_nr(logger, constraint_section, &
236 "LAGRANGE_MULTIPLIERS", extension=".LagrangeMultLog", log_filename=.false.)
237 simpar%dump_lm = btest(cp_print_key_should_output(logger%iter_info, constraint_section, &
238 "LAGRANGE_MULTIPLIERS"), cp_p_file)
239
240 ! Create the structure for the md energies
241 ALLOCATE (md_ener)
242 CALL create_md_ener(md_ener)
243 CALL set_md_env(md_env, md_ener=md_ener)
244
245 ! If requested setup Thermostats
246 CALL create_thermostats(thermostats, md_section, force_env, simpar, para_env, &
247 globenv, global_section)
248
249 ! If requested setup Barostat
250 CALL create_barostat_type(barostat, md_section, force_env, simpar, globenv)
251
252 ! If requested setup different thermal regions
253 CALL create_thermal_regions(thermal_regions, md_section, simpar, force_env)
254
255 CALL set_md_env(md_env, thermostats=thermostats, barostat=barostat, thermal_regions=thermal_regions)
256
257 IF (simpar%ensemble == reftraj_ensemble) THEN
258 reftraj_section => section_vals_get_subs_vals(md_section, "REFTRAJ")
259 ALLOCATE (reftraj)
260 CALL create_reftraj(reftraj, reftraj_section, para_env)
261 CALL set_md_env(md_env, reftraj=reftraj)
262 END IF
263
264 CALL force_env_get(force_env, subsys=subsys, cell=cell, &
265 force_env_section=force_env_section)
266
267 ! Set V0 if needed
268 IF (simpar%ensemble == nph_uniaxial_ensemble .OR. simpar%ensemble == nph_uniaxial_damped_ensemble) THEN
269 IF (simpar%v0 == 0._dp) simpar%v0 = cell%deth
270 END IF
271
272 ! Setup Free Energy Calculation (if required)
273 CALL fe_env_create(fe_env, free_energy_section)
274 CALL set_md_env(md_env=md_env, simpar=simpar, fe_env=fe_env, cell=cell, &
275 force_env=force_env)
276
277 ! Possibly initialize Wiener processes
278 IF (simpar%ensemble == langevin_ensemble) CALL create_wiener_process(md_env)
279 time_iter_start = m_walltime()
280
281 CALL get_md_env(md_env, force_env=force_env, itimes=itimes, constant=constant, &
282 md_ener=md_ener, t=time, used_time=used_time)
283
284 ! Attach the time counter of the meta_env to the one of the MD
285 CALL set_meta_env(force_env%meta_env, time=time)
286 ! Initialize the md_ener structure
287
288 force_env%meta_env%dt = force_env%meta_env%zdt
289 CALL initialize_md_ener(md_ener, force_env, simpar)
290
291!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! MC setup up
292!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
293
294 NULLIFY (mc_env, mc_par, mcaverages)
295
296 CALL section_vals_get(force_env_section, n_repetition=isos)
297 cpassert(isos == 1)
298! set some values...will use get_globenv if that ever comes around
299
300! initialize the random numbers
301 rng_stream_mc = rng_stream_type(name="Random numbers for monte carlo acc/rej", &
302 distribution_type=uniform)
303
304 NULLIFY (mc_section)
305 ALLOCATE (mc_par)
306
307 mc_section => section_vals_get_subs_vals(force_env%root_section, &
308 "MOTION%MC")
309 CALL section_vals_val_get(mc_section, "ENSEMBLE", &
310 c_val=ensemble)
311 cpassert(str_comp(ensemble, "TRADITIONAL"))
312 CALL section_vals_val_get(mc_section, "NSTEP", &
313 i_val=nmccycles)
314 cpassert(nmccycles > 0)
315 CALL section_vals_val_get(mc_section, "IPRINT", &
316 i_val=iprint)
317 CALL section_vals_val_get(mc_section, "RANDOMTOSKIP", i_val=rand2skip)
318 cpassert(rand2skip >= 0)
319 temp = cp_unit_from_cp2k(simpar%temp_ext, "K")
320
321 CALL set_mc_par(mc_par, ensemble=ensemble, nstep=nmccycles, iprint=iprint, temperature=temp, &
322 beta=1.0_dp/temp/boltzmann*joule, exp_max_val=0.9_dp*log(huge(0.0_dp)), &
323 exp_min_val=0.9_dp*log(tiny(0.0_dp)), max_val=huge(0.0_dp), min_val=0.0_dp, &
324 source=para_env%source, group=para_env, ionode=para_env%is_source(), rand2skip=rand2skip)
325
326 output_unit = cp_logger_get_default_io_unit(logger)
327 IF (output_unit > 0) THEN
328 WRITE (output_unit, '(a,a)') "HMC| Hybrid Monte Carlo Scheme "
329 WRITE (output_unit, '(a,a)') "HMC| Ensemble ", adjustl(ensemble)
330 WRITE (output_unit, '(a,i0)') "HMC| MC Cycles ", nmccycles
331 WRITE (output_unit, '(a,i0,a)') "HMC| Print every ", iprint, " cycles"
332 WRITE (output_unit, '(a,i0)') "HMC| Number of random numbers to skip ", rand2skip
333 WRITE (output_unit, '(a,f16.8,a)') "HMC| Temperature ", temp, "K"
334 END IF
335
336 CALL force_env_get(force_env, subsys=subsys)
337
338 CALL cp_subsys_get(subsys, atomic_kinds=atomic_kinds, local_particles=local_particles, &
339 particles=particles, virial=virial)
340
341 DO i = 1, rand2skip
342 auxrandom = rng_stream_mc%next()
343 DO j = 1, 3*SIZE(particles%els)
344 auxrandom = globenv%gaussian_rng_stream%next()
345 END DO
346 END DO
347
348 ALLOCATE (mc_env)
349 CALL mc_env_create(mc_env)
350 CALL set_mc_env(mc_env, mc_par=mc_par, force_env=force_env)
351!!!!!!!end mc setup
352
353 ! Check for ensembles requiring the stress tensor - takes into account the possibility for
354 ! multiple force_evals
355 IF ((simpar%ensemble == npt_i_ensemble) .OR. &
356 (simpar%ensemble == npt_ia_ensemble) .OR. &
357 (simpar%ensemble == npt_f_ensemble) .OR. &
358 (simpar%ensemble == npe_f_ensemble) .OR. &
359 (simpar%ensemble == npe_i_ensemble) .OR. &
360 (simpar%ensemble == nph_uniaxial_ensemble) .OR. &
361 (simpar%ensemble == nph_uniaxial_damped_ensemble)) THEN
362 check = virial%pv_availability
363 IF (.NOT. check) THEN
364 CALL cp_abort(__location__, &
365 "Virial evaluation not requested for this run in the input file! "// &
366 "You may consider to switch on the virial evaluation with the keyword: STRESS_TENSOR. "// &
367 "Be sure the method you are using can compute the virial!")
368 END IF
369 IF (ASSOCIATED(force_env%sub_force_env)) THEN
370 DO i = 1, SIZE(force_env%sub_force_env)
371 IF (ASSOCIATED(force_env%sub_force_env(i)%force_env)) THEN
372 CALL force_env_get(force_env%sub_force_env(i)%force_env, subsys=subsys_i)
373 CALL cp_subsys_get(subsys_i, virial=virial)
374 check = check .AND. virial%pv_availability
375 END IF
376 END DO
377 END IF
378 IF (.NOT. check) THEN
379 CALL cp_abort(__location__, &
380 "Virial evaluation not requested for all the force_eval sections present in"// &
381 " the input file! You have to switch on the virial evaluation with the keyword: STRESS_TENSOR"// &
382 " in each force_eval section. Be sure the method you are using can compute the virial!")
383 END IF
384 END IF
385
386 ! Computing Forces at zero MD step
387 IF (simpar%ensemble /= reftraj_ensemble) THEN
388 CALL section_vals_val_get(md_section, "STEP_START_VAL", i_val=itimes)
389 CALL section_vals_val_get(md_section, "TIME_START_VAL", r_val=time)
390 CALL section_vals_val_get(md_section, "ECONS_START_VAL", r_val=constant)
391 CALL section_vals_val_set(md_section, "STEP_START_VAL", i_val=initialstep)
392 CALL section_vals_val_set(md_section, "TIME_START_VAL", r_val=inittime)
393 initialstep = itimes
394 CALL cp_iterate(logger%iter_info, iter_nr=itimes)
395 IF (save_mem) THEN
396 work_section => section_vals_get_subs_vals(subsys_section, "VELOCITY")
397 CALL section_vals_remove_values(work_section)
398 work_section => section_vals_get_subs_vals(subsys_section, "SHELL_VELOCITY")
399 CALL section_vals_remove_values(work_section)
400 work_section => section_vals_get_subs_vals(subsys_section, "CORE_VELOCITY")
401 CALL section_vals_remove_values(work_section)
402 END IF
403
404 meta_env_saved => force_env%meta_env
405 NULLIFY (force_env%meta_env)
406 CALL force_env_calc_energy_force(force_env, calc_force=.false.)
407 force_env%meta_env => meta_env_saved
408
409 IF (ASSOCIATED(force_env%qs_env)) THEN
410 force_env%qs_env%sim_time = 0.0_dp
411 force_env%qs_env%sim_step = 0
412 END IF
413 ! Warm-up engines for metadynamics
414 IF (ASSOCIATED(force_env%meta_env)) THEN
415 IF (force_env%meta_env%langevin) THEN
416 CALL create_wiener_process_cv(force_env%meta_env)
417 DO j = 1, (rand2skip - 1)/nmccycles
418 DO i = 1, force_env%meta_env%n_colvar
419 auxrandom = force_env%meta_env%rng(i)%next()
420 auxrandom = force_env%meta_env%rng(i)%next()
421 END DO
422 END DO
423 END IF
424 CALL tamc_force(force_env)
425 END IF
426
427 IF (simpar%do_respa) THEN
428 CALL force_env_calc_energy_force(force_env%sub_force_env(1)%force_env, &
429 calc_force=.true.)
430 END IF
431
432 CALL virial_evaluate(atomic_kinds%els, particles%els, local_particles, &
433 virial, force_env%para_env)
434
435 CALL md_energy(md_env, md_ener)
436 md_stride = 1
437 ELSE
438 CALL get_md_env(md_env, reftraj=reftraj)
439 CALL initialize_reftraj(reftraj, reftraj_section, md_env)
440 itimes = reftraj%info%first_snapshot - 1
441 md_stride = reftraj%info%stride
442 END IF
443
444 CALL cp_print_key_finished_output(simpar%info_constraint, logger, &
445 constraint_section, "CONSTRAINT_INFO")
446 CALL cp_print_key_finished_output(simpar%lagrange_multipliers, logger, &
447 constraint_section, "LAGRANGE_MULTIPLIERS")
448 CALL init_mc_moves(moves)
449 CALL init_mc_moves(gmoves)
450 ALLOCATE (r(1:3, SIZE(particles%els)))
451 CALL mc_averages_create(mcaverages)
452 !!!!! some more buffers
453 ! Allocate random number for Langevin Thermostat acting on COLVARS
454 ALLOCATE (xieta(2*force_env%meta_env%n_colvar))
455 xieta(:) = 0.0_dp
456 ALLOCATE (an(force_env%meta_env%n_colvar))
457 an(:) = 0.0_dp
458 ALLOCATE (fz(force_env%meta_env%n_colvar))
459 fz(:) = 0.0_dp
460 ALLOCATE (zbuff(2*force_env%meta_env%n_colvar))
461 zbuff(:) = 0.0_dp
462
463 IF (output_unit > 0) THEN
464 WRITE (output_unit, '(a)') "HMC|==== Initial average forces"
465 END IF
466 CALL metadyn_write_colvar_header(force_env)
467 moves%hmc%attempts = 0
468 moves%hmc%successes = 0
469 gmoves%hmc%attempts = 0
470 gmoves%hmc%successes = 0
471 IF (initialstep == 0) THEN
472!!! if we come from a restart we shall properly compute the average force
473!!! read the average force up to now
474 DO i = 1, force_env%meta_env%n_colvar
475 fs_section => section_vals_get_subs_vals(force_env%meta_env%metadyn_section, "EXT_LAGRANGE_FS")
476 CALL section_vals_get(fs_section, explicit=explicit)
477 IF (explicit) THEN
478 CALL section_vals_val_get(fs_section, "_DEFAULT_KEYWORD_", &
479 i_rep_val=i, r_val=rval)
480 fz(i) = rval*rand2skip
481 END IF
482 END DO
483
484 CALL hmcsampler(globenv, force_env, mcaverages, r, mc_par, moves, gmoves, rng_stream_mc, output_unit, &
485 fz, zbuff, nskip=rand2skip)
486 CALL cp_iterate(logger%iter_info, last=.false., iter_nr=0)
487 CALL section_vals_val_set(mc_section, "RANDOMTOSKIP", i_val=rand2skip + nmccycles)
488 CALL write_restart(md_env=md_env, root_section=force_env%root_section)
489 END IF
490 IF (output_unit > 0) THEN
491 WRITE (output_unit, '(a)') "HMC|==== end initial average forces"
492 END IF
493
494 CALL metadyn_write_colvar(force_env)
495
496 DO istep = 1, force_env%meta_env%TAMCSteps
497 ! Increase counters
498 itimes = itimes + 1
499 time = time + force_env%meta_env%dt
500 IF (output_unit > 0) THEN
501 WRITE (output_unit, '(a)') "HMC|==================================="
502 WRITE (output_unit, '(a,1x,i0)') "HMC| on z step ", istep
503 END IF
504 !needed when electric field fields are applied
505 IF (ASSOCIATED(force_env%qs_env)) THEN
506 force_env%qs_env%sim_time = time
507 force_env%qs_env%sim_step = itimes
508 force_env%meta_env%time = force_env%qs_env%sim_time
509 END IF
510
511 CALL cp_iterate(logger%iter_info, last=(istep == force_env%meta_env%TAMCSteps), iter_nr=itimes)
512 ! Open possible Shake output units
513 simpar%info_constraint = cp_print_key_unit_nr(logger, constraint_section, "CONSTRAINT_INFO", &
514 extension=".shakeLog", log_filename=.false.)
515 simpar%lagrange_multipliers = cp_print_key_unit_nr( &
516 logger, constraint_section, &
517 "LAGRANGE_MULTIPLIERS", extension=".LagrangeMultLog", log_filename=.false.)
518 simpar%dump_lm = btest(cp_print_key_should_output(logger%iter_info, constraint_section, &
519 "LAGRANGE_MULTIPLIERS"), cp_p_file)
520
521 ! Velocity Verlet Integrator
522
523 moves%hmc%attempts = 0
524 moves%hmc%successes = 0
525 CALL langevinvec(md_env, globenv, mc_env, moves, gmoves, r, &
526 rng_stream_mc, xieta, an, fz, mcaverages, zbuff)
527
528 ! Close Shake output if requested...
529 CALL cp_print_key_finished_output(simpar%info_constraint, logger, &
530 constraint_section, "CONSTRAINT_INFO")
531 CALL cp_print_key_finished_output(simpar%lagrange_multipliers, logger, &
532 constraint_section, "LAGRANGE_MULTIPLIERS")
533 CALL cp_iterate(logger%iter_info, iter_nr=initialstep)
534 CALL metadyn_write_colvar(force_env)
535 ! Free Energy calculation
536! CALL free_energy_evaluate(md_env,should_stop,free_energy_section)
537
538 ! Test for <PROJECT_NAME>.EXIT_MD or for WALL_TIME to exit
539 ! Default:
540 ! IF so we don't overwrite the restart or append to the trajectory
541 ! because the execution could in principle stop inside the SCF where energy
542 ! and forces are not converged.
543 ! But:
544 ! You can force to print the last step (for example if the method used
545 ! to compute energy and forces is not SCF based) activating the print_key
546 ! MOTION%MD%PRINT%FORCE_LAST.
547 CALL external_control(should_stop, "MD", globenv=globenv)
548 IF (should_stop) THEN
549 CALL cp_iterate(logger%iter_info, last=.true., iter_nr=itimes)
550 EXIT
551 END IF
552
553 time_iter_stop = m_walltime()
554 used_time = time_iter_stop - time_iter_start
555 time_iter_start = time_iter_stop
556
557 IF (output_unit > 0) THEN
558 WRITE (output_unit, '(a,1x,i0)') "HMC| end z step ", istep
559 WRITE (output_unit, '(a)') "HMC|==================================="
560 END IF
561 END DO
562 CALL cp_iterate(logger%iter_info, last=.true., iter_nr=itimes)
563 force_env%qs_env%sim_time = 0.0_dp
564 force_env%qs_env%sim_step = 0
565 rand2skip = rand2skip + nmccycles*force_env%meta_env%TAMCSteps
566 IF (initialstep == 0) rand2skip = rand2skip + nmccycles
567 CALL section_vals_val_set(mc_section, "RANDOMTOSKIP", i_val=rand2skip)
568
569 CALL write_restart(md_env=md_env, root_section=force_env%root_section)
570! if we need the final kinetic energy for Hybrid Monte Carlo
571
572 ! Remove the iteration level
573 CALL cp_rm_iter_level(logger%iter_info, "MD")
574
575 ! Deallocate Thermostats and Barostats
576 CALL release_simpar_type(simpar)
577
578 CALL md_env_release(md_env)
579 DEALLOCATE (md_env)
580 ! Clean restartable sections..
581 IF (my_rm_restart_info) CALL remove_restart_info(force_env%root_section)
582 CALL mc_env_release(mc_env)
583 DEALLOCATE (mc_env)
584 DEALLOCATE (mc_par)
585 CALL mc_moves_release(moves)
586 CALL mc_moves_release(gmoves)
587 DEALLOCATE (r)
588 DEALLOCATE (xieta)
589 DEALLOCATE (an)
590 DEALLOCATE (fz)
591 DEALLOCATE (zbuff)
592 CALL mc_averages_release(mcaverages)
593 CALL timestop(handle)
594
595 END SUBROUTINE qs_tamc
596
597! **************************************************************************************************
598!> \brief Propagates velocities for z half a step
599!> \param force_env ...
600!> \param An ...
601!> \author Alin M Elena
602!> \note Vanden-Eijnden Ciccotti C.Phys.Letter 429 (2006) 310-316
603! **************************************************************************************************
604 SUBROUTINE tamc_velocities_colvar(force_env, An)
605 TYPE(force_env_type), POINTER :: force_env
606 REAL(kind=dp), DIMENSION(:), INTENT(INOUT) :: an
607
608 CHARACTER(len=*), PARAMETER :: routinen = 'tamc_velocities_colvar'
609
610 INTEGER :: handle, i_c
611 REAL(kind=dp) :: dt, fft, sigma
612 TYPE(cp_logger_type), POINTER :: logger
613 TYPE(meta_env_type), POINTER :: meta_env
614 TYPE(metavar_type), POINTER :: cv
615
616 NULLIFY (logger, meta_env, cv)
617 meta_env => force_env%meta_env
618 CALL timeset(routinen, handle)
619 logger => cp_get_default_logger()
620 ! Add citation
621 IF (meta_env%langevin) CALL cite_reference(vandencic2006)
622 dt = meta_env%dt
623
624 ! Evolve Velocities
625 meta_env%epot_walls = 0.0_dp
626 DO i_c = 1, meta_env%n_colvar
627 cv => meta_env%metavar(i_c)
628 fft = cv%ff_s + cv%ff_hills
629 sigma = sqrt((meta_env%temp_wanted*kelvin)*2.0_dp*(boltzmann/joule)*cv%gamma/cv%mass)
630 cv%vvp = cv%vvp + 0.5_dp*dt*(fft/cv%mass - cv%gamma*cv%vvp)*(1.0_dp - 0.25_dp*dt*cv%gamma) + an(i_c)
631 meta_env%epot_walls = meta_env%epot_walls + cv%epot_walls
632 END DO
633 CALL timestop(handle)
634 END SUBROUTINE tamc_velocities_colvar
635
636! **************************************************************************************************
637!> \brief propagates z one step
638!> \param force_env ...
639!> \param xieta ...
640!> \author Alin M Elena
641!> \note Vanden-Eijnden Ciccotti C.Phys.Letter 429 (2006) 310-316
642! **************************************************************************************************
643 SUBROUTINE tamc_position_colvar(force_env, xieta)
644 TYPE(force_env_type), POINTER :: force_env
645 REAL(kind=dp), DIMENSION(:), INTENT(INOUT) :: xieta
646
647 CHARACTER(len=*), PARAMETER :: routinen = 'tamc_position_colvar'
648
649 INTEGER :: handle, i_c
650 REAL(kind=dp) :: dt, sigma
651 TYPE(cp_logger_type), POINTER :: logger
652 TYPE(meta_env_type), POINTER :: meta_env
653 TYPE(metavar_type), POINTER :: cv
654
655 NULLIFY (logger, meta_env, cv)
656 meta_env => force_env%meta_env
657! IF (.NOT.ASSOCIATED(meta_env)) RETURN
658
659 CALL timeset(routinen, handle)
660 logger => cp_get_default_logger()
661
662 ! Add citation
663 IF (meta_env%langevin) CALL cite_reference(vandencic2006)
664 dt = meta_env%dt
665
666 ! Update of ss0
667 DO i_c = 1, meta_env%n_colvar
668 cv => meta_env%metavar(i_c)
669 sigma = sqrt((meta_env%temp_wanted*kelvin)*2.0_dp*(boltzmann/joule)*cv%gamma/cv%mass)
670! cv%ss0 =cv%ss0 +dt*cv%vvp
671 cv%ss0 = cv%ss0 + dt*cv%vvp + dt*sqrt(dt/12.0_dp)*sigma*xieta(i_c + meta_env%n_colvar)
672 IF (cv%periodic) THEN
673 ! A periodic COLVAR is always within [-pi,pi]
674 cv%ss0 = sign(1.0_dp, asin(sin(cv%ss0)))*acos(cos(cv%ss0))
675 END IF
676 END DO
677 CALL timestop(handle)
678
679 END SUBROUTINE tamc_position_colvar
680
681! **************************************************************************************************
682!> \brief Computes forces on z
683!> #details also can be used to get the potenzial evergy of z
684!> \param force_env ...
685!> \param zpot ...
686!> \author Alin M Elena
687! **************************************************************************************************
688 SUBROUTINE tamc_force(force_env, zpot)
689 TYPE(force_env_type), POINTER :: force_env
690 REAL(kind=dp), INTENT(inout), OPTIONAL :: zpot
691
692 CHARACTER(len=*), PARAMETER :: routinen = 'tamc_force'
693
694 INTEGER :: handle, i, i_c, icolvar, ii
695 LOGICAL :: explicit
696 REAL(kind=dp) :: diff_ss, dt, rval
697 TYPE(colvar_p_type), DIMENSION(:), POINTER :: colvar_p
698 TYPE(cp_logger_type), POINTER :: logger
699 TYPE(cp_subsys_type), POINTER :: subsys
700 TYPE(meta_env_type), POINTER :: meta_env
701 TYPE(metavar_type), POINTER :: cv
702 TYPE(particle_list_type), POINTER :: particles
703 TYPE(section_vals_type), POINTER :: ss0_section, ss_section, vvp_section
704
705 NULLIFY (logger, meta_env)
706 meta_env => force_env%meta_env
707! IF (.NOT.ASSOCIATED(meta_env)) RETURN
708
709 CALL timeset(routinen, handle)
710 logger => cp_get_default_logger()
711 NULLIFY (colvar_p, subsys, cv, ss0_section, vvp_section, ss_section)
712 CALL force_env_get(force_env, subsys=subsys)
713
714 dt = meta_env%dt
715 IF (.NOT. meta_env%restart) meta_env%n_steps = meta_env%n_steps + 1
716 ! compute ss and the derivative of ss with respect to the atomic positions
717 DO i_c = 1, meta_env%n_colvar
718 cv => meta_env%metavar(i_c)
719 icolvar = cv%icolvar
720 CALL colvar_eval_glob_f(icolvar, force_env)
721 cv%ss = subsys%colvar_p(icolvar)%colvar%ss
722 ! Restart for Extended Lagrangian Metadynamics
723 IF (meta_env%restart) THEN
724 ! Initialize the position of the collective variable in the extended lagrange
725 ss0_section => section_vals_get_subs_vals(meta_env%metadyn_section, "EXT_LAGRANGE_SS0")
726 CALL section_vals_get(ss0_section, explicit=explicit)
727 IF (explicit) THEN
728 CALL section_vals_val_get(ss0_section, "_DEFAULT_KEYWORD_", &
729 i_rep_val=i_c, r_val=rval)
730 cv%ss0 = rval
731 ELSE
732 cv%ss0 = cv%ss
733 END IF
734 vvp_section => section_vals_get_subs_vals(meta_env%metadyn_section, "EXT_LAGRANGE_VVP")
735 CALL section_vals_get(vvp_section, explicit=explicit)
736 IF (explicit) THEN
737 CALL setup_velocities_z(force_env)
738 CALL section_vals_val_get(vvp_section, "_DEFAULT_KEYWORD_", &
739 i_rep_val=i_c, r_val=rval)
740 cv%vvp = rval
741 ELSE
742 CALL setup_velocities_z(force_env)
743 END IF
744 ss_section => section_vals_get_subs_vals(meta_env%metadyn_section, "EXT_LAGRANGE_SS")
745 CALL section_vals_get(ss_section, explicit=explicit)
746 IF (explicit) THEN
747 CALL section_vals_val_get(ss_section, "_DEFAULT_KEYWORD_", &
748 i_rep_val=i_c, r_val=rval)
749 cv%ss = rval
750 END IF
751 END IF
752 !
753 END DO
754 ! forces on the atoms
755 NULLIFY (particles)
756 CALL cp_subsys_get(subsys, colvar_p=colvar_p, &
757 particles=particles)
758
759 meta_env%restart = .false.
760 meta_env%epot_s = 0.0_dp
761 meta_env%epot_walls = 0.0_dp
762 DO i_c = 1, meta_env%n_colvar
763 cv => meta_env%metavar(i_c)
764 diff_ss = cv%ss - cv%ss0
765 IF (cv%periodic) THEN
766 ! The difference of a periodic COLVAR is always within [-pi,pi]
767 diff_ss = sign(1.0_dp, asin(sin(diff_ss)))*acos(cos(diff_ss))
768 END IF
769 cv%epot_s = 0.5_dp*cv%lambda*diff_ss*diff_ss
770 cv%ff_s = cv%lambda*(diff_ss)
771 meta_env%epot_s = meta_env%epot_s + cv%epot_s
772 icolvar = cv%icolvar
773
774 DO ii = 1, colvar_p(icolvar)%colvar%n_atom_s
775 i = colvar_p(icolvar)%colvar%i_atom(ii)
776 particles%els(i)%f = particles%els(i)%f - cv%ff_s*colvar_p(icolvar)%colvar%dsdr(:, ii)
777 END DO
778
779 END DO
780 IF (PRESENT(zpot)) zpot = meta_env%epot_s
781 CALL fix_atom_control(force_env)
782
783 CALL timestop(handle)
784 END SUBROUTINE tamc_force
785
786! **************************************************************************************************
787!> \brief propagates one time step both z systems and samples the x system
788!> \param md_env ...
789!> \param globenv ...
790!> \param mc_env ...
791!> \param moves ...
792!> \param gmoves ...
793!> \param r ...
794!> \param rng_stream_mc ...
795!> \param xieta ...
796!> \param An ...
797!> \param fz ...
798!> \param averages ...
799!> \param zbuff ...
800!> \author Alin M Elena
801! **************************************************************************************************
802 SUBROUTINE langevinvec(md_env, globenv, mc_env, moves, gmoves, r, &
803 rng_stream_mc, xieta, An, fz, averages, zbuff)
804
805 TYPE(md_environment_type), POINTER :: md_env
806 TYPE(global_environment_type), POINTER :: globenv
807 TYPE(mc_environment_type), POINTER :: mc_env
808 TYPE(mc_moves_type), POINTER :: moves, gmoves
809 REAL(kind=dp), DIMENSION(:, :), INTENT(INOUT) :: r
810 TYPE(rng_stream_type), INTENT(INOUT) :: rng_stream_mc
811 REAL(kind=dp), DIMENSION(:), INTENT(INOUT) :: xieta, an, fz
812 TYPE(mc_averages_type), INTENT(INOUT), POINTER :: averages
813 REAL(kind=dp), DIMENSION(:), INTENT(INOUT) :: zbuff
814
815 INTEGER :: iprint, ivar, nparticle, nparticle_kind, &
816 nstep, output_unit
817 REAL(kind=dp) :: dt, gamma, mass, sigma
818 TYPE(atomic_kind_list_type), POINTER :: atomic_kinds
819 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
820 TYPE(cell_type), POINTER :: cell
821 TYPE(cp_logger_type), POINTER :: logger
822 TYPE(cp_subsys_type), POINTER :: subsys
823 TYPE(distribution_1d_type), POINTER :: local_molecules, local_particles
824 TYPE(force_env_type), POINTER :: force_env
825 TYPE(global_constraint_type), POINTER :: gci
826 TYPE(mc_simpar_type), POINTER :: mc_par
827 TYPE(molecule_kind_list_type), POINTER :: molecule_kinds
828 TYPE(molecule_kind_type), DIMENSION(:), POINTER :: molecule_kind_set
829 TYPE(molecule_list_type), POINTER :: molecules
830 TYPE(molecule_type), DIMENSION(:), POINTER :: molecule_set
831 TYPE(mp_para_env_type), POINTER :: para_env
832 TYPE(particle_list_type), POINTER :: particles
833 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
834 TYPE(simpar_type), POINTER :: simpar
835 TYPE(virial_type), POINTER :: virial
836
837 NULLIFY (logger, mc_par)
838 logger => cp_get_default_logger()
839 output_unit = cp_logger_get_default_io_unit(logger)
840
841! quantitites to be nullified for the get_md_env
842 NULLIFY (simpar, force_env, para_env)
843! quantities to be nullified for the force_env_get environment
844 NULLIFY (subsys, cell)
845! quantitites to be nullified for the cp_subsys_get
846 NULLIFY (atomic_kinds, local_particles, particles, local_molecules, molecules, molecule_kinds, gci)
847
848 CALL get_md_env(md_env=md_env, simpar=simpar, force_env=force_env, &
849 para_env=para_env)
850 CALL get_mc_env(mc_env, mc_par=mc_par)
851 CALL get_mc_par(mc_par, nstep=nstep, iprint=iprint)
852
853 dt = simpar%dt
854 CALL force_env_get(force_env=force_env, subsys=subsys, cell=cell)
855
856!!!! this bit should vanish once I understand what the hell is with it
857
858! ! Do some checks on coordinates and box
859 CALL apply_qmmm_walls_reflective(force_env)
860
861 CALL cp_subsys_get(subsys=subsys, atomic_kinds=atomic_kinds, local_particles=local_particles, &
862 particles=particles, local_molecules=local_molecules, molecules=molecules, &
863 molecule_kinds=molecule_kinds, gci=gci, virial=virial)
864
865 nparticle_kind = atomic_kinds%n_els
866 atomic_kind_set => atomic_kinds%els
867 molecule_kind_set => molecule_kinds%els
868
869 nparticle = particles%n_els
870 particle_set => particles%els
871 molecule_set => molecules%els
872 cpassert(ASSOCIATED(force_env%meta_env))
873 cpassert(force_env%meta_env%langevin)
874 ! *** Velocity Verlet for Langevin *** v(t)--> v(t+1/2)
875 !!!!!! noise xi is in the first half, eta in the second half
876 DO ivar = 1, force_env%meta_env%n_colvar
877 xieta(ivar) = force_env%meta_env%rng(ivar)%next()
878 xieta(ivar + force_env%meta_env%n_colvar) = force_env%meta_env%rng(ivar)%next()
879 gamma = force_env%meta_env%metavar(ivar)%gamma
880 mass = force_env%meta_env%metavar(ivar)%mass
881 sigma = sqrt((force_env%meta_env%temp_wanted*kelvin)*2.0_dp*(boltzmann/joule)*gamma/mass)
882 an(ivar) = 0.5_dp*sqrt(dt)*sigma*(xieta(ivar)*(1.0_dp - 0.5_dp*dt*gamma) - &
883 dt*gamma*xieta(ivar + force_env%meta_env%n_colvar)/sqrt(12.0_dp))
884 END DO
885! *** Velocity Verlet for Langeving *** v(t)--> v(t+1/2)
886 CALL tamc_velocities_colvar(force_env, an)
887! *** Velocity Verlet for Langevin S(t)->S(t+1)
888 CALL tamc_position_colvar(force_env, xieta)
889!!!!! start zHMC sampler
890 CALL hmcsampler(globenv, force_env, averages, r, mc_par, moves, gmoves, rng_stream_mc, output_unit, fz, zbuff)
891
892! CALL final_mc_write(mc_par,tmp_moves,&
893! output_unit,energy_check,&
894! initial_energy,final_energy,&
895! averages)
896
897!!!!!!!!!!!!!!!!!!!! end zHMC sampler
898 ! *** Velocity Verlet for Langeving *** v(t+1/2)--> v(t+1)
899 CALL tamc_velocities_colvar(force_env, an)
900! CALL virial_evaluate ( atomic_kind_set, particle_set, &
901! local_particles, virial, para_env)
902
903 END SUBROUTINE langevinvec
904
905! **************************************************************************************************
906!> \brief Driver routin for the canonical sampler using modified HMC
907!> \param globenv ...
908!> \param force_env ...
909!> \param averages ...
910!> \param r ...
911!> \param mc_par ...
912!> \param moves ...
913!> \param gmoves ...
914!> \param rng_stream_mc ...
915!> \param output_unit ...
916!> \param fz ...
917!> \param zbuff ...
918!> \param nskip ...
919!> \author Alin M Elena
920!> \note at the end of this routine %ff_s will contain mean force
921! **************************************************************************************************
922
923 SUBROUTINE hmcsampler(globenv, force_env, averages, r, mc_par, moves, gmoves, rng_stream_mc, output_unit, &
924 fz, zbuff, nskip)
925 TYPE(global_environment_type), POINTER :: globenv
926 TYPE(force_env_type), POINTER :: force_env
927 TYPE(mc_averages_type), POINTER :: averages
928 REAL(kind=dp), DIMENSION(:, :), INTENT(INOUT) :: r
929 TYPE(mc_simpar_type), POINTER :: mc_par
930 TYPE(mc_moves_type), POINTER :: moves, gmoves
931 TYPE(rng_stream_type), INTENT(INOUT) :: rng_stream_mc
932 INTEGER, INTENT(IN) :: output_unit
933 REAL(kind=dp), DIMENSION(:), INTENT(INOUT) :: fz, zbuff
934 INTEGER, INTENT(IN), OPTIONAL :: nskip
935
936 INTEGER :: i, iprint, ishift, it1, j, nsamples, &
937 nstep
938 REAL(kind=dp) :: energy_check, old_epx, old_epz, t1
939 TYPE(meta_env_type), POINTER :: meta_env_saved
940
941 IF (PRESENT(nskip)) THEN
942 nsamples = nskip
943 ishift = nskip
944 ELSE
945 nsamples = 0
946 fz = 0.0_dp
947 ishift = 0
948 END IF
949 CALL get_mc_par(mc_par, nstep=nstep, iprint=iprint)
950 meta_env_saved => force_env%meta_env
951 NULLIFY (force_env%meta_env)
952 CALL force_env_get(force_env, potential_energy=old_epx)
953 force_env%meta_env => meta_env_saved
954
955 old_epz = force_env%meta_env%epot_s
956!!! average energy will be wrong on restarts
957 averages%ave_energy = 0.0_dp
958 t1 = force_env%qs_env%sim_time
959 it1 = force_env%qs_env%sim_step
960 IF (output_unit > 0) THEN
961 WRITE (output_unit, '(a,l4)') "HMC|restart? ", force_env%meta_env%restart
962 WRITE (output_unit, '(a,3(f16.8,1x))') &
963 "HMC|Ep, Epx, Epz ", old_epx + force_env%meta_env%epot_s, old_epx, force_env%meta_env%epot_s
964 WRITE (output_unit, '(a)') "#HMC| No | z.. | theta.. | ff_z... | ff_z/n |"
965 END IF
966 DO i = 1, nstep
967 IF (mod(i, iprint) == 0 .AND. (output_unit > 0)) THEN
968 WRITE (output_unit, '(a,1x,i0)') "HMC|========== On Monte Carlo cycle ", i + ishift
969 WRITE (output_unit, '(a)') "HMC| Attempting a minitrajectory move"
970 WRITE (output_unit, '(a,1x,i0)') "HMC| start mini-trajectory", i + ishift
971 WRITE (output_unit, '(a,1x,i0,1x)', advance="no") "#HMC|0 ", i + ishift
972 DO j = 1, force_env%meta_env%n_colvar
973 WRITE (output_unit, '(f16.8,1x,f16.8,1x,f16.8)', advance="no") force_env%meta_env%metavar(j)%ss0, &
974 force_env%meta_env%metavar(j)%ss, &
975 force_env%meta_env%metavar(j)%ff_s !,fz(j)/real(i+ishift,dp)
976 END DO
977 WRITE (output_unit, *)
978 END IF
979
980 CALL mc_hmc_move(mc_par, force_env, globenv, moves, gmoves, old_epx, old_epz, energy_check, &
981 r, output_unit, rng_stream_mc, zbuff)
982 ! check averages...
983 ! force average for z needed too...
984 averages%ave_energy = averages%ave_energy*real(i - 1, dp)/real(i, dp) + &
985 old_epx/real(i, dp)
986 DO j = 1, force_env%meta_env%n_colvar
987 fz(j) = fz(j) + force_env%meta_env%metavar(j)%ff_s
988 END DO
989 IF (output_unit > 0) THEN
990 WRITE (output_unit, '(a,1x,i0)') "HMC|end mini-trajectory", i + ishift
991!!!!!!!! this prints z and theta(x) --ss0,ss-- needed to determine an acceptable k then
992 ! the instanteneous force and some instanteneous average for force
993 WRITE (output_unit, '(a,1x,i0,1x)', advance="no") "#HMC|1 ", i + ishift
994 DO j = 1, force_env%meta_env%n_colvar
995 WRITE (output_unit, '(f16.8,1x,f16.8,1x,f16.8,1x,f16.8)', advance="no") force_env%meta_env%metavar(j)%ss0, &
996 force_env%meta_env%metavar(j)%ss, &
997 force_env%meta_env%metavar(j)%ff_s, fz(j)/real(i + ishift, dp)
998 END DO
999 WRITE (output_unit, *)
1000 END IF
1001 nsamples = nsamples + 1
1002 IF (mod(i, iprint) == 0 .AND. (output_unit > 0)) THEN
1003 WRITE (output_unit, '(a,f16.8)') "HMC| Running average for potential energy ", averages%ave_energy
1004 WRITE (output_unit, '(a,1x,i0)') "HMC|======== End Monte Carlo cycle ", i + ishift
1005 END IF
1006 END DO
1007 force_env%qs_env%sim_time = t1
1008 force_env%qs_env%sim_step = it1
1009 IF (output_unit > 0) THEN
1010 WRITE (output_unit, '(a,i0,a,i0,a,f16.8)') "HMC| local acceptance ratio: ", moves%hmc%successes, "/", &
1011 moves%hmc%attempts, "=", real(moves%hmc%successes, dp)/real(moves%hmc%attempts, dp)
1012 WRITE (output_unit, '(a,i0,a,i0,a,f16.8)') "HMC| global acceptance ratio: ", gmoves%hmc%successes, "/", &
1013 gmoves%hmc%attempts, "=", real(gmoves%hmc%successes, dp)/real(gmoves%hmc%attempts, dp)
1014 END IF
1015 !average force
1016 DO j = 1, force_env%meta_env%n_colvar
1017 force_env%meta_env%metavar(j)%ff_s = fz(j)/nsamples
1018 END DO
1019 END SUBROUTINE hmcsampler
1020
1021! **************************************************************************************************
1022!> \brief performs a hybrid Monte Carlo move
1023!> \param mc_par ...
1024!> \param force_env ...
1025!> \param globenv ...
1026!> \param moves ...
1027!> \param gmoves ...
1028!> \param old_epx ...
1029!> \param old_epz ...
1030!> \param energy_check ...
1031!> \param r ...
1032!> \param output_unit ...
1033!> \param rng_stream ...
1034!> \param zbuff ...
1035!> \author Alin M Elena
1036!> \note It runs a NVE trajectory, followed by localisation and accepts rejects
1037!> using the biased Hamiltonian, rather than the traditional guiding Hamiltonian
1038! **************************************************************************************************
1039 SUBROUTINE mc_hmc_move(mc_par, force_env, globenv, moves, gmoves, old_epx, old_epz, &
1040 energy_check, r, output_unit, rng_stream, zbuff)
1041
1042 TYPE(mc_simpar_type), POINTER :: mc_par
1043 TYPE(force_env_type), POINTER :: force_env
1044 TYPE(global_environment_type), POINTER :: globenv
1045 TYPE(mc_moves_type), POINTER :: moves, gmoves
1046 REAL(kind=dp), INTENT(INOUT) :: old_epx, old_epz, energy_check
1047 REAL(kind=dp), DIMENSION(:, :), INTENT(INOUT) :: r
1048 INTEGER, INTENT(IN) :: output_unit
1049 TYPE(rng_stream_type), INTENT(INOUT) :: rng_stream
1050 REAL(kind=dp), DIMENSION(:), INTENT(INOUT) :: zbuff
1051
1052 CHARACTER(LEN=*), PARAMETER :: routinen = 'mc_hmc_move'
1053
1054 INTEGER :: handle, iatom, j, natoms, source
1055 LOGICAL :: ionode, localise
1056 REAL(kind=dp) :: beta, energy_term, exp_max_val, &
1057 exp_min_val, new_energy, new_epx, &
1058 new_epz, rand, value, w
1059 TYPE(cp_subsys_type), POINTER :: oldsys
1060 TYPE(mc_ekin_type), POINTER :: hmc_ekin
1061 TYPE(meta_env_type), POINTER :: meta_env_saved
1062 TYPE(mp_comm_type) :: group
1063 TYPE(particle_list_type), POINTER :: particles_set
1064 TYPE(section_vals_type), POINTER :: dft_section, input
1065
1066! begin the timing of the subroutine
1067
1068 CALL timeset(routinen, handle)
1069
1070 CALL get_qs_env(force_env%qs_env, input=input)
1071 dft_section => section_vals_get_subs_vals(input, "DFT")
1072
1073! get a bunch of stuff from mc_par
1074 CALL get_mc_par(mc_par, ionode=ionode, &
1075 beta=beta, exp_max_val=exp_max_val, &
1076 exp_min_val=exp_min_val, source=source, group=group)
1077
1078! nullify some pointers
1079! NULLIFY(particles_set,oldsys,hmc_ekin)
1080 NULLIFY (particles_set, oldsys, meta_env_saved, hmc_ekin)
1081 ! now let's grab the particle positions
1082 CALL force_env_get(force_env, subsys=oldsys)
1083 CALL cp_subsys_get(oldsys, particles=particles_set)
1084 natoms = SIZE(particles_set%els)
1085! do some allocation
1086
1087 ALLOCATE (hmc_ekin)
1088
1089! record the attempt
1090 moves%hmc%attempts = moves%hmc%attempts + 1
1091 gmoves%hmc%attempts = gmoves%hmc%attempts + 1
1092
1093! save the old coordinates just in case we need to go back
1094 DO iatom = 1, natoms
1095 r(1:3, iatom) = particles_set%els(iatom)%r(1:3)
1096 END DO
1097 localise = .true.
1098! the same for collective variables data should be made,ss first half and ff_s the last half
1099 DO j = 1, force_env%meta_env%n_colvar
1100 zbuff(j) = force_env%meta_env%metavar(j)%ss
1101 zbuff(j + force_env%meta_env%n_colvar) = force_env%meta_env%metavar(j)%ff_s
1102 IF ((oldsys%colvar_p(force_env%meta_env%metavar(j)%icolvar)%colvar%type_id == hbp_colvar_id) .OR. &
1103 (oldsys%colvar_p(force_env%meta_env%metavar(j)%icolvar)%colvar%type_id == wc_colvar_id)) THEN
1104 localise = .false.
1105 END IF
1106 END DO
1107
1108! now run the MD simulation
1109 meta_env_saved => force_env%meta_env
1110 NULLIFY (force_env%meta_env)
1111 force_env%qs_env%sim_time = 0.0_dp
1112 force_env%qs_env%sim_step = 0
1113 IF (.NOT. localise) THEN
1114 CALL section_vals_val_set(dft_section, "LOCALIZE%_SECTION_PARAMETERS_", l_val=.false.)
1115 END IF
1116 CALL qs_mol_dyn(force_env, globenv, hmc_e_initial=hmc_ekin%initial_ekin, hmc_e_final=hmc_ekin%final_ekin)
1117 IF (.NOT. localise) THEN
1118 CALL section_vals_val_set(dft_section, "LOCALIZE%_SECTION_PARAMETERS_", l_val=.true.)
1119 CALL scf_post_calculation_gpw(force_env%qs_env)
1120 END IF
1121
1122 CALL force_env_get(force_env, potential_energy=new_epx)
1123
1124 force_env%meta_env => meta_env_saved
1125 CALL tamc_force(force_env, zpot=new_epz)
1126 new_energy = new_epx + new_epz
1127 IF (output_unit > 0) THEN
1128 WRITE (output_unit, '(a,4(f16.8,1x))') &
1129 "HMC|old Ep, Ekx, Epz, Epx ", old_epx + old_epz, hmc_ekin%initial_ekin, old_epz, old_epx
1130 WRITE (output_unit, '(a,4(f16.8,1x))') "HMC|new Ep, Ekx, Epz, Epx ", new_energy, hmc_ekin%final_ekin, new_epz, new_epx
1131 END IF
1132 energy_term = new_energy - old_epx - old_epz + hmc_ekin%final_ekin - hmc_ekin%initial_ekin
1133
1134 value = -beta*(energy_term)
1135! to prevent overflows
1136 IF (value > exp_max_val) THEN
1137 w = 10.0_dp
1138 ELSE IF (value < exp_min_val) THEN
1139 w = 0.0_dp
1140 ELSE
1141 w = exp(value)
1142 END IF
1143
1144 rand = rng_stream%next()
1145 IF (rand < w) THEN
1146! accept the move
1147 moves%hmc%successes = moves%hmc%successes + 1
1148 gmoves%hmc%successes = gmoves%hmc%successes + 1
1149! update energies
1150 energy_check = energy_check + (new_energy - old_epx - old_epz)
1151 old_epx = new_epx
1152 old_epz = new_epz
1153 ELSE
1154! reset the cell and particle positions
1155 DO iatom = 1, natoms
1156 particles_set%els(iatom)%r(1:3) = r(1:3, iatom)
1157 END DO
1158 DO j = 1, force_env%meta_env%n_colvar
1159 force_env%meta_env%metavar(j)%ss = zbuff(j)
1160 force_env%meta_env%metavar(j)%ff_s = zbuff(j + force_env%meta_env%n_colvar)
1161 END DO
1162
1163 END IF
1164
1165 DEALLOCATE (hmc_ekin)
1166
1167! end the timing
1168 CALL timestop(handle)
1169
1170 END SUBROUTINE mc_hmc_move
1171
1172! **************************************************************************************************
1173!> \brief ...
1174!> \param force_env ...
1175! **************************************************************************************************
1176 SUBROUTINE metadyn_write_colvar_header(force_env)
1177 TYPE(force_env_type), POINTER :: force_env
1178
1179 CHARACTER(len=*), PARAMETER :: routinen = 'metadyn_write_colvar_header'
1180
1181 CHARACTER(len=100) :: aux, fmt
1182 CHARACTER(len=255) :: label1, label2, label3, label4, label5, &
1183 label6
1184 INTEGER :: handle, i, iw, m
1185 TYPE(cp_logger_type), POINTER :: logger
1186 TYPE(meta_env_type), POINTER :: meta_env
1187
1188 NULLIFY (logger, meta_env)
1189 meta_env => force_env%meta_env
1190 IF (.NOT. ASSOCIATED(meta_env)) RETURN
1191
1192 CALL timeset(routinen, handle)
1193 logger => cp_get_default_logger()
1194
1195 iw = cp_print_key_unit_nr(logger, meta_env%metadyn_section, &
1196 "PRINT%COLVAR", extension=".metadynLog")
1197 IF (iw > 0) THEN
1198 label1 = ""
1199 label2 = ""
1200 label3 = ""
1201 label4 = ""
1202 label5 = ""
1203 label6 = ""
1204 DO i = 1, meta_env%n_colvar
1205 WRITE (aux, '(a,i0)') "z_", i
1206 label1 = trim(label1)//trim(aux)
1207 m = 15*i - len_trim(label1) - 1
1208 label1 = trim(label1)//repeat(" ", m)//"|"
1209 WRITE (aux, '(a,i0)') "Theta_", i
1210 label2 = trim(label2)//trim(aux)
1211 m = 15*i - len_trim(label2) - 1
1212 label2 = trim(label2)//repeat(" ", m)//"|"
1213 WRITE (aux, '(a,i0)') "F_z", i
1214 label3 = trim(label3)//trim(aux)
1215 m = 15*i - len_trim(label3) - 1
1216 label3 = trim(label3)//repeat(" ", m)//"|"
1217 WRITE (aux, '(a,i0)') "F_h", i
1218 label4 = trim(label4)//trim(aux)
1219 m = 15*i - len_trim(label4) - 1
1220 label4 = trim(label4)//repeat(" ", m)//"|"
1221 WRITE (aux, '(a,i0)') "F_w", i
1222 label5 = trim(label5)//trim(aux)
1223 m = 15*i - len_trim(label5) - 1
1224 label5 = trim(label5)//repeat(" ", m)//"|"
1225 WRITE (aux, '(a,i0)') "v_z", i
1226 label6 = trim(label6)//trim(aux)
1227 m = 15*i - len_trim(label6) - 1
1228 label6 = trim(label6)//repeat(" ", m)//"|"
1229 END DO
1230 WRITE (fmt, '("(a17,6a",i0 ,",4a15)")') meta_env%n_colvar*15
1231 WRITE (iw, trim(fmt)) "#Time[fs] |", &
1232 trim(label1), &
1233 trim(label2), &
1234 trim(label3), &
1235 trim(label4), &
1236 trim(label5), &
1237 trim(label6), &
1238 "Epot_z |", &
1239 "Ene hills |", &
1240 "Epot walls |", &
1241 "Temperature |"
1242
1243 END IF
1244 CALL cp_print_key_finished_output(iw, logger, meta_env%metadyn_section, &
1245 "PRINT%COLVAR")
1246
1247 CALL timestop(handle)
1248
1249 END SUBROUTINE metadyn_write_colvar_header
1250
1251! **************************************************************************************************
1252!> \brief ...
1253!> \param force_env ...
1254! **************************************************************************************************
1255 SUBROUTINE metadyn_write_colvar(force_env)
1256 TYPE(force_env_type), POINTER :: force_env
1257
1258 CHARACTER(len=*), PARAMETER :: routinen = 'metadyn_write_colvar'
1259
1260 INTEGER :: handle, i, i_c, iw
1261 REAL(kind=dp) :: temp
1262 TYPE(cp_logger_type), POINTER :: logger
1263 TYPE(meta_env_type), POINTER :: meta_env
1264 TYPE(metavar_type), POINTER :: cv
1265
1266 NULLIFY (logger, meta_env, cv)
1267 meta_env => force_env%meta_env
1268 IF (.NOT. ASSOCIATED(meta_env)) RETURN
1269
1270 CALL timeset(routinen, handle)
1271 logger => cp_get_default_logger()
1272
1273 IF (meta_env%langevin) THEN
1274 meta_env%ekin_s = 0.0_dp
1275! meta_env%epot_s = 0.0_dp
1276 DO i_c = 1, meta_env%n_colvar
1277 cv => meta_env%metavar(i_c)
1278 meta_env%ekin_s = meta_env%ekin_s + 0.5_dp*cv%mass*cv%vvp**2
1279 END DO
1280 END IF
1281
1282 ! write COLVAR file
1283 iw = cp_print_key_unit_nr(logger, meta_env%metadyn_section, &
1284 "PRINT%COLVAR", extension=".metadynLog")
1285 IF (iw > 0) THEN
1286 IF (meta_env%extended_lagrange) THEN
1287 WRITE (iw, '(f16.8,70f15.8)') meta_env%time*femtoseconds, &
1288 (meta_env%metavar(i)%ss0, i=1, meta_env%n_colvar), &
1289 (meta_env%metavar(i)%ss, i=1, meta_env%n_colvar), &
1290 (meta_env%metavar(i)%ff_s, i=1, meta_env%n_colvar), &
1291 (meta_env%metavar(i)%ff_hills, i=1, meta_env%n_colvar), &
1292 (meta_env%metavar(i)%ff_walls, i=1, meta_env%n_colvar), &
1293 (meta_env%metavar(i)%vvp, i=1, meta_env%n_colvar), &
1294 meta_env%epot_s, &
1295 meta_env%hills_env%energy, &
1296 meta_env%epot_walls, &
1297 (meta_env%ekin_s)*2.0_dp/(real(meta_env%n_colvar, kind=dp))*kelvin
1298 ELSE
1299 WRITE (iw, '(f16.8,40f13.5)') meta_env%time*femtoseconds, &
1300 (meta_env%metavar(i)%ss0, i=1, meta_env%n_colvar), &
1301 (meta_env%metavar(i)%ff_hills, i=1, meta_env%n_colvar), &
1302 (meta_env%metavar(i)%ff_walls, i=1, meta_env%n_colvar), &
1303 meta_env%hills_env%energy, &
1304 meta_env%epot_walls
1305 END IF
1306 END IF
1307 CALL cp_print_key_finished_output(iw, logger, meta_env%metadyn_section, &
1308 "PRINT%COLVAR")
1309 ! Temperature for COLVAR
1310 IF (meta_env%extended_lagrange) THEN
1311 temp = meta_env%ekin_s*2.0_dp/(real(meta_env%n_colvar, kind=dp))*kelvin
1312 meta_env%avg_temp = (meta_env%avg_temp*real(meta_env%n_steps, kind=dp) + &
1313 temp)/real(meta_env%n_steps + 1, kind=dp)
1314 iw = cp_print_key_unit_nr(logger, meta_env%metadyn_section, &
1315 "PRINT%TEMPERATURE_COLVAR", extension=".metadynLog")
1316 IF (iw > 0) THEN
1317 WRITE (iw, '(T2,79("-"))')
1318 WRITE (iw, '( A,T51,f10.2,T71,f10.2)') ' COLVARS INSTANTANEOUS/AVERAGE TEMPERATURE ', &
1319 temp, meta_env%avg_temp
1320 WRITE (iw, '(T2,79("-"))')
1321 END IF
1322 CALL cp_print_key_finished_output(iw, logger, meta_env%metadyn_section, &
1323 "PRINT%TEMPERATURE_COLVAR")
1324 END IF
1325 CALL timestop(handle)
1326
1327 END SUBROUTINE metadyn_write_colvar
1328
1329! **************************************************************************************************
1330!> \brief ...
1331!> \param force_env ...
1332! **************************************************************************************************
1333 SUBROUTINE setup_velocities_z(force_env)
1334 TYPE(force_env_type), POINTER :: force_env
1335
1336 INTEGER :: i_c
1337 REAL(kind=dp) :: ekin_w, fac_t
1338 TYPE(meta_env_type), POINTER :: meta_env
1339 TYPE(metavar_type), POINTER :: cv
1340
1341 NULLIFY (meta_env)
1342 meta_env => force_env%meta_env
1343 meta_env%ekin_s = 0.0_dp
1344 DO i_c = 1, meta_env%n_colvar
1345 cv => meta_env%metavar(i_c)
1346 cv%vvp = force_env%globenv%gaussian_rng_stream%next()
1347 meta_env%ekin_s = meta_env%ekin_s + 0.5_dp*cv%mass*cv%vvp**2
1348 END DO
1349 ekin_w = 0.5_dp*meta_env%temp_wanted*real(meta_env%n_colvar, kind=dp)
1350 fac_t = sqrt(ekin_w/max(meta_env%ekin_s, 1.0e-8_dp))
1351 DO i_c = 1, meta_env%n_colvar
1352 cv => meta_env%metavar(i_c)
1353 cv%vvp = cv%vvp*fac_t
1354 END DO
1355 END SUBROUTINE setup_velocities_z
1356END MODULE tamc_run
represent a simple array based list of the given type
Define the atomic kind types and their sub types.
Handles the type to compute averages during an MD.
Barostat structure: module containing barostat available for MD.
subroutine, public create_barostat_type(barostat, md_section, force_env, simpar, globenv)
...
collects all references to literature in CP2K as new algorithms / method are included from literature...
integer, save, public vandencic2006
Handles all functions related to the CELL.
Definition cell_types.F:15
defines collective variables s({R}) and the derivative of this variable wrt R these can then be used ...
subroutine, public colvar_eval_glob_f(icolvar, force_env)
evaluates the derivatives (dsdr) given and due to the given colvar
Initialize the collective variables types.
integer, parameter, public wc_colvar_id
integer, parameter, public hbp_colvar_id
subroutine, public fix_atom_control(force_env, w)
allows for fix atom constraints
Routines to handle the external control of CP2K.
subroutine, public external_control(should_stop, flag, globenv, target_time, start_time, force_check)
External manipulations during a run : when the <PROJECT_NAME>.EXIT_$runtype command is sent the progr...
various routines to log and control the output. The idea is that decisions about where to log should ...
integer function, public cp_logger_get_default_io_unit(logger)
returns the unit nr for the ionode (-1 on all other processors) skips as well checks if the procs cal...
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,...
integer, parameter, public cp_p_file
subroutine, public cp_iterate(iteration_info, last, iter_nr, increment, iter_nr_out)
adds one to the actual iteration
subroutine, public cp_rm_iter_level(iteration_info, level_name, n_rlevel_att)
Removes an iteration level.
integer function, public cp_print_key_should_output(iteration_info, basis_section, print_key_path, used_print_key, first_time)
returns what should be done with the given property if btest(res,cp_p_store) then the property should...
subroutine, public cp_add_iter_level(iteration_info, level_name, n_rlevel_new)
Adds an iteration level.
types that represent a subsys, i.e. a part of the system
subroutine, public cp_subsys_get(subsys, ref_count, atomic_kinds, atomic_kind_set, particles, particle_set, local_particles, molecules, molecule_set, molecule_kinds, molecule_kind_set, local_molecules, para_env, colvar_p, shell_particles, core_particles, gci, multipoles, natom, nparticle, ncore, nshell, nkind, atprop, virial, results, cell, cell_ref, use_ref_cell)
returns information about various attributes of the given subsys
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:1251
stores a lists of integer that are local to a processor. The idea is that these integers represent ob...
Interface for the force calculations.
recursive subroutine, public force_env_calc_energy_force(force_env, calc_force, consistent_energies, skip_external_control, eval_energy_forces, require_consistent_energy_force, linres, calc_stress_tensor)
Interface routine for force and energy calculations.
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 types for metadynamics calculation
subroutine, public fe_env_create(fe_env, fe_section)
creates the fe_env
Calculation of the incomplete Gamma function F_n(t) for multi-center integrals over Cartesian Gaussia...
Definition gamma.F:15
Define type storing the global information of a run. Keep the amount of stored data small....
collects all constants needed in input so that they can be used without circular dependencies
integer, parameter, public nph_uniaxial_ensemble
integer, parameter, public npt_i_ensemble
integer, parameter, public nph_uniaxial_damped_ensemble
integer, parameter, public npe_f_ensemble
integer, parameter, public langevin_ensemble
integer, parameter, public npe_i_ensemble
integer, parameter, public npt_ia_ensemble
integer, parameter, public npt_f_ensemble
integer, parameter, public reftraj_ensemble
checks the input and perform some automatic "magic" on it
subroutine, public remove_restart_info(input_file)
Removes section used to restart a calculation from an input file in memory.
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....
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
subroutine, public section_vals_remove_values(section_vals)
removes the values of a repetition of the section
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
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
Machine interface based on Fortran 2003 and POSIX.
Definition machine.F:17
real(kind=dp) function, public m_walltime()
returns time from a real-time clock, protected against rolling early/easily
Definition machine.F:141
contains the subroutines for dealing with the mc_env
subroutine, public get_mc_env(mc_env, mc_par, force_env)
provides a method for getting the various structures attached to an mc_env
subroutine, public mc_env_create(mc_env)
creates and initializes an mc_env
subroutine, public set_mc_env(mc_env, mc_par, force_env)
provides a method for attaching various structures to an mc_env
subroutine, public mc_env_release(mc_env)
releases the given mc env
contains miscellaneous subroutines used in the Monte Carlo runs, mostly I/O stuff
Definition mc_misc.F:13
subroutine, public mc_averages_release(averages)
deallocates the structure that holds running averages of MC variables
Definition mc_misc.F:77
subroutine, public mc_averages_create(averages)
initializes the structure that holds running averages of MC variables
Definition mc_misc.F:46
control the handling of the move data in Monte Carlo (MC) simulations
subroutine, public mc_moves_release(moves)
deallocates all the structures and nullifies the pointer
subroutine, public init_mc_moves(moves)
allocates and initializes the structure to record all move attempts/successes
holds all the structure types needed for Monte Carlo, except the mc_environment_type
Definition mc_types.F:15
subroutine, public get_mc_par(mc_par, nstep, nvirial, iuptrans, iupcltrans, iupvolume, nmoves, nswapmoves, rm, cl, diff, nstart, source, group, lbias, ionode, lrestart, lstop, rmvolume, rmcltrans, rmbond, rmangle, rmrot, rmtrans, temperature, pressure, rclus, beta, pmswap, pmvolume, pmtraion, pmtrans, pmcltrans, ensemble, program, restart_file_name, molecules_file, moves_file, coords_file, energy_file, displacement_file, cell_file, dat_file, data_file, box2_file, fft_lib, iprint, rcut, ldiscrete, discrete_step, pmavbmc, pbias, avbmc_atom, avbmc_rmin, avbmc_rmax, rmdihedral, input_file, mc_molecule_info, pmswap_mol, pmavbmc_mol, pmtrans_mol, pmrot_mol, pmtraion_mol, mc_input_file, mc_bias_file, pmvol_box, pmclus_box, virial_temps, exp_min_val, exp_max_val, min_val, max_val, eta, pmhmc, pmhmc_box, lhmc, rand2skip)
...
Definition mc_types.F:405
subroutine, public set_mc_par(mc_par, rm, cl, diff, nstart, rmvolume, rmcltrans, rmbond, rmangle, rmdihedral, rmrot, rmtrans, program, nmoves, nswapmoves, lstop, temperature, pressure, rclus, iuptrans, iupcltrans, iupvolume, pmswap, pmvolume, pmtraion, pmtrans, pmcltrans, beta, rcut, iprint, lbias, nstep, lrestart, ldiscrete, discrete_step, pmavbmc, mc_molecule_info, pmavbmc_mol, pmtrans_mol, pmrot_mol, pmtraion_mol, pmswap_mol, avbmc_rmin, avbmc_rmax, avbmc_atom, pbias, ensemble, pmvol_box, pmclus_box, eta, mc_input_file, mc_bias_file, exp_max_val, exp_min_val, min_val, max_val, pmhmc, pmhmc_box, lhmc, ionode, source, group, rand2skip)
changes the private elements of the mc_parameters_type
Definition mc_types.F:667
Split md_ener module from md_environment_type.
subroutine, public create_md_ener(md_ener)
retains the given md_ener structure
prints all energy info per timestep to the screen or to user defined output files
Definition md_energies.F:16
subroutine, public initialize_md_ener(md_ener, force_env, simpar)
...
subroutine, public md_energy(md_env, md_ener)
...
subroutine, public set_md_env(md_env, itimes, constant, cell, simpar, fe_env, force_env, para_env, init, first_time, thermostats, barostat, reftraj, md_ener, averages, thermal_regions, ehrenfest_md)
Set the integrator environment to the correct program.
subroutine, public md_env_create(md_env, md_section, para_env, force_env)
Creates MD environment Purpose: Initialise the integrator environment. retain the para_env for this e...
subroutine, public md_env_release(md_env)
releases the given md env
subroutine, public get_md_env(md_env, itimes, constant, used_time, cell, simpar, npt, force_env, para_env, reftraj, t, init, first_time, fe_env, thermostats, barostat, thermostat_coeff, thermostat_part, thermostat_shell, thermostat_baro, thermostat_fast, thermostat_slow, md_ener, averages, thermal_regions, ehrenfest_md)
get components of MD environment type
Perform a molecular dynamics (MD) run using QUICKSTEP.
Definition md_run.F:14
subroutine, public qs_mol_dyn(force_env, globenv, averages, rm_restart_info, hmc_e_initial, hmc_e_final, mdctrl)
Main driver module for Molecular Dynamics.
Definition md_run.F:125
Interface to the message passing library MPI.
defines types for metadynamics calculation
subroutine, public set_meta_env(meta_env, time)
sets the meta_env
represent a simple array based list of the given type
Define the molecule kind structure types and the corresponding functionality.
represent a simple array based list of the given type
Define the data structure for the molecule information.
Parallel (pseudo)random number generator (RNG) for multiple streams and substreams of random numbers.
subroutine advance(self, e, c)
Advance the state by n steps, i.e. jump n steps forward, if n > 0, or backward if n < 0.
integer, parameter, public uniform
represent a simple array based list of the given type
Define the data structure for the particle information.
Definition of physical constants:
Definition physcon.F:68
real(kind=dp), parameter, public boltzmann
Definition physcon.F:129
real(kind=dp), parameter, public femtoseconds
Definition physcon.F:153
real(kind=dp), parameter, public joule
Definition physcon.F:159
real(kind=dp), parameter, public kelvin
Definition physcon.F:165
subroutine, public apply_qmmm_walls_reflective(force_env)
Apply reflective QM walls in order to avoid QM atoms escaping from the QM Box.
Definition qmmm_util.F:100
subroutine, public get_qs_env(qs_env, atomic_kind_set, qs_kind_set, cell, super_cell, cell_ref, use_ref_cell, kpoints, dft_control, mos, sab_orb, sab_all, qmmm, qmmm_periodic, mimic, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, matrix_vhxc, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, xcint_weights, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, rhoz_cneo_set, ecoul_1c, rho0_s_rs, rho0_s_gs, rhoz_cneo_s_rs, rhoz_cneo_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, lri_env, lri_density, exstate_env, ec_env, harris_env, dispersion_env, gcp_env, vee, rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, wanniercentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs, do_rixs, tb_tblite)
Get the QUICKSTEP environment.
Does all kind of post scf calculations for GPW/GAPW.
subroutine, public scf_post_calculation_gpw(qs_env, wf_type, do_mp2)
collects possible post - scf calculations and prints info / computes properties.
provides a uniform framework to add references to CP2K cite and output these
subroutine, public cite_reference(key)
marks a given reference as cited.
initialization of the reftraj structure used to analyse previously generated trajectories
subroutine, public create_reftraj(reftraj, reftraj_section, para_env)
...
Initialize the analysis of trajectories to be done by activating the REFTRAJ ensemble.
subroutine, public initialize_reftraj(reftraj, reftraj_section, md_env)
...
Methods for storing MD parameters type.
subroutine, public read_md_section(simpar, motion_section, md_section)
Reads the MD section and setup the simulation parameters type.
Type for storing MD parameters.
subroutine, public release_simpar_type(simpar)
Releases the simulation parameters type.
subroutine, public create_simpar_type(simpar)
Creates the simulation parameters type.
Utilities for string manipulations.
elemental logical function, public str_comp(str1, str2)
...
Perform a temperature accelarated hybrid monte carlo (TAHMC) run using QUICKSTEP.
Definition tamc_run.F:14
subroutine, public qs_tamc(force_env, globenv, averages)
Driver routine for TAHMC.
Definition tamc_run.F:147
Thermal regions type: to initialize and control the temperature of different regions.
Setup of regions with different temperature.
subroutine, public create_thermal_regions(thermal_regions, md_section, simpar, force_env)
create thermal_regions
Methods for Thermostats.
subroutine, public create_thermostats(thermostats, md_section, force_env, simpar, para_env, globenv, global_section)
...
Thermostat structure: module containing thermostat available for MD.
subroutine, public virial_evaluate(atomic_kind_set, particle_set, local_particles, virial, igroup)
Computes the kinetic part of the pressure tensor and updates the full VIRIAL (PV)
Handling of the Wiener process currently employed in turn of the Langevin dynamics.
subroutine, public create_wiener_process(md_env)
Create a Wiener process for Langevin dynamics and initialize an independent random number generator f...
subroutine, public create_wiener_process_cv(meta_env)
Create a Wiener process for Langevin dynamics used for metadynamics and initialize an independent ran...
Provides all information about an atomic kind.
Type defining parameters related to the simulation cell.
Definition cell_types.F:60
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,...
structure to store local (to a processor) ordered lists of integers.
wrapper to abstract the force evaluation of the various methods
contains the initially parsed file and the initial parallel environment
stores all the informations relevant to an mpi environment
defines types for COLVAR used in the metadynamics
Simulation parameter type for molecular dynamics.