107#include "../base/base_uses.f90"
113 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'md_run'
129 SUBROUTINE qs_mol_dyn(force_env, globenv, averages, rm_restart_info, hmc_e_initial, hmc_e_final, mdctrl)
134 LOGICAL,
INTENT(IN),
OPTIONAL :: rm_restart_info
135 REAL(kind=
dp),
OPTIONAL :: hmc_e_initial, hmc_e_final
138 LOGICAL :: my_rm_restart_info
143 my_rm_restart_info = .true.
144 IF (
PRESENT(rm_restart_info)) my_rm_restart_info = rm_restart_info
145 NULLIFY (md_env, para_env)
152 para_env => force_env%para_env
158 CALL md_env_create(md_env, md_section, para_env, force_env=force_env)
160 IF (
PRESENT(hmc_e_initial) .AND.
PRESENT(hmc_e_final))
THEN
161 CALL qs_mol_dyn_low(md_env, md_section, motion_section, force_env, globenv, &
162 hmc_e_initial=hmc_e_initial, hmc_e_final=hmc_e_final)
164 CALL qs_mol_dyn_low(md_env, md_section, motion_section, force_env, globenv, mdctrl=mdctrl)
188 SUBROUTINE qs_mol_dyn_low(md_env, md_section, motion_section, force_env, globenv, hmc_e_initial, hmc_e_final, mdctrl)
194 REAL(kind=
dp),
OPTIONAL :: hmc_e_initial, hmc_e_final
197 CHARACTER(LEN=*),
PARAMETER :: routinen =
'qs_mol_dyn_low'
199 CHARACTER(LEN=80) :: md_step_line
200 CHARACTER(LEN=default_string_length) :: my_act, my_pos
201 INTEGER :: handle, i, istep, md_stride, &
202 output_unit, run_type_id
203 INTEGER,
POINTER :: itimes
204 LOGICAL ::
check, ehrenfest_md, save_mem, &
205 should_stop, write_binary_restart_file
206 REAL(kind=
dp) :: dummy, time_iter_start, time_iter_stop
207 REAL(kind=
dp),
POINTER :: constant, time, used_time
220 free_energy_section, global_section, reftraj_section, subsys_section, work_section
226 CALL timeset(routinen, handle)
227 cpassert(
ASSOCIATED(globenv))
228 cpassert(
ASSOCIATED(force_env))
230 NULLIFY (particles, cell, simpar, itimes, used_time, subsys, &
231 md_ener, thermostats, barostat, reftraj, force_env_section, &
232 reftraj_section, work_section, atomic_kinds, &
233 local_particles, time, fe_env, free_energy_section, &
234 constraint_section, thermal_regions, virial, subsys_i)
236 para_env => force_env%para_env
248 force_env_section => force_env%force_env_section
256 "CONSTRAINT_INFO", extension=
".shakeLog", log_filename=.false.)
258 "LAGRANGE_MULTIPLIERS", extension=
".LagrangeMultLog", log_filename=.false.)
270 globenv, global_section)
283 pos=my_pos, act=my_act)
286 CALL set_md_env(md_env, thermostats=thermostats, barostat=barostat, thermal_regions=thermal_regions)
288 CALL get_md_env(md_env, ehrenfest_md=ehrenfest_md)
292 cpabort(
"Ehrenfest MD does not support reftraj ensemble ")
302 force_env_section=force_env_section)
307 IF (simpar%v0 == 0._dp) simpar%v0 = cell%deth
312 l_val=write_binary_restart_file)
313 CALL setup_velocities(force_env, simpar, globenv, md_env, md_section, constraint_section, &
314 write_binary_restart_file)
319 CALL set_md_env(md_env=md_env, simpar=simpar, fe_env=fe_env, cell=cell, &
321 IF (simpar%constraint)
CALL initialize_moving_colvars(force_env, motion_section, simpar)
329 CALL get_md_env(md_env, force_env=force_env, itimes=itimes, constant=constant, &
330 md_ener=md_ener, t=time, used_time=used_time)
347 check = virial%pv_availability
348 IF (.NOT.
check)
THEN
349 CALL cp_abort(__location__, &
350 "Virial evaluation not requested for this run in the input file!"// &
351 " You may consider to switch on the virial evaluation with the keyword: STRESS_TENSOR."// &
352 " Be sure the method you are using can compute the virial!")
354 IF (
ASSOCIATED(force_env%sub_force_env))
THEN
355 DO i = 1,
SIZE(force_env%sub_force_env)
356 IF (
ASSOCIATED(force_env%sub_force_env(i)%force_env))
THEN
357 CALL force_env_get(force_env%sub_force_env(i)%force_env, subsys=subsys_i)
363 IF (.NOT.
check)
THEN
364 CALL cp_abort(__location__, &
365 "Virial evaluation not requested for all the force_eval sections present in"// &
366 " the input file! You have to switch on the virial evaluation with the keyword: STRESS_TENSOR"// &
367 " in each force_eval section. Be sure the method you are using can compute the virial!")
376 CALL cp_iterate(logger%iter_info, iter_nr=itimes)
386 IF (ehrenfest_md)
THEN
388 force_env%qs_env%rtp%dt = simpar%dt
396 IF (
ASSOCIATED(force_env%qs_env))
THEN
400 IF (
ASSOCIATED(force_env%meta_env))
THEN
402 IF (force_env%meta_env%use_plumed .EQV. .true.)
THEN
408 IF (force_env%meta_env%langevin)
THEN
411 IF (force_env%meta_env%well_tempered)
THEN
412 force_env%meta_env%wttemperature = simpar%temp_ext
413 IF (force_env%meta_env%wtgamma > epsilon(1._dp))
THEN
414 dummy = force_env%meta_env%wttemperature*(force_env%meta_env%wtgamma - 1._dp)
415 IF (force_env%meta_env%delta_t > epsilon(1._dp))
THEN
416 check = abs(force_env%meta_env%delta_t - dummy) < 1.e+3_dp*epsilon(1._dp)
417 IF (.NOT.
check)
THEN
418 CALL cp_abort(__location__, &
419 "Inconsistency between DELTA_T and WTGAMMA (both specified):"// &
420 " please, verify that DELTA_T=(WTGAMMA-1)*TEMPERATURE")
423 force_env%meta_env%delta_t = dummy
426 force_env%meta_env%wtgamma = 1._dp &
427 + force_env%meta_env%delta_t/force_env%meta_env%wttemperature
429 force_env%meta_env%invdt = 1._dp/force_env%meta_env%delta_t
436 IF (simpar%do_respa)
THEN
443 CALL cp_subsys_get(subsys, atomic_kinds=atomic_kinds, local_particles=local_particles, &
444 particles=particles, virial=virial)
446 CALL virial_evaluate(atomic_kinds%els, particles%els, local_particles, &
447 virial, force_env%para_env)
455 itimes = reftraj%info%first_snapshot - 1
456 md_stride = reftraj%info%stride
457 IF (
ASSOCIATED(force_env%meta_env))
THEN
458 IF (force_env%meta_env%use_plumed .EQV. .true.)
THEN
465 constraint_section,
"CONSTRAINT_INFO")
467 constraint_section,
"LAGRANGE_MULTIPLIERS")
470 IF (
PRESENT(hmc_e_initial)) hmc_e_initial = md_ener%ekin
472 IF (itimes >= simpar%max_steps)
CALL cp_abort(__location__, &
473 "maximum step number smaller than initial step value")
476 DO istep = 1, simpar%nsteps, md_stride
479 time = time + simpar%dt
481 IF (
ASSOCIATED(force_env%qs_env))
THEN
484 IF (ehrenfest_md) force_env%qs_env%rtp%istep = istep
486 IF (.NOT. logger%iter_info%last_iter(logger%iter_info%n_rlevel))
THEN
487 CALL cp_iterate(logger%iter_info, last=(istep == simpar%nsteps), iter_nr=itimes)
489 CALL cp_iterate(logger%iter_info, last=.true., iter_nr=itimes)
492 IF (output_unit > 0 .AND. &
494 "PRINT%PROGRAM_RUN_INFO"),
cp_p_file))
THEN
495 WRITE (md_step_line, fmt=
"(A,I12,A,I0)")
"MD STEP: ", istep,
" / ", simpar%nsteps
497 WRITE (unit=output_unit, fmt=
"(/,T2,A)") repeat(
"-", len_trim(md_step_line))
498 WRITE (unit=output_unit, fmt=
"(T2,A)") trim(md_step_line)
499 WRITE (unit=output_unit, fmt=
"(T2,A)") repeat(
"-", len_trim(md_step_line))
505 extension=
".shakeLog", log_filename=.false.)
507 logger, constraint_section, &
508 "LAGRANGE_MULTIPLIERS", extension=
".LagrangeMultLog", log_filename=.false.)
520 constraint_section,
"CONSTRAINT_INFO")
522 constraint_section,
"LAGRANGE_MULTIPLIERS")
527 IF (should_stop)
EXIT
541 IF (.NOT. (istep == simpar%nsteps) .AND. logger%iter_info%last_iter(logger%iter_info%n_rlevel)) should_stop = .true.
542 IF (itimes >= simpar%max_steps) should_stop = .true.
545 IF (
PRESENT(mdctrl))
THEN
549 IF (should_stop)
THEN
550 CALL cp_iterate(logger%iter_info, last=.true., iter_nr=itimes)
554 CALL md_output(md_env, md_section, force_env%root_section, .false.)
556 CALL md_output(md_env, md_section, force_env%root_section, should_stop)
571 used_time = time_iter_stop - time_iter_start
572 time_iter_start = time_iter_stop
574 CALL md_output(md_env, md_section, force_env%root_section, should_stop)
581 IF (
PRESENT(hmc_e_final)) hmc_e_final = md_ener%ekin
587 IF (
ASSOCIATED(force_env%meta_env))
THEN
588 IF (force_env%meta_env%use_plumed .EQV. .true.)
THEN
595 CALL timestop(handle)
597 END SUBROUTINE qs_mol_dyn_low
605 SUBROUTINE initialize_moving_colvars(force_env, motion_section, simpar)
620 IF (simpar%do_respa) dt = dt/simpar%n_time_steps
622 DO i = 1,
SIZE(
kinds)
623 IF (.NOT.
ASSOCIATED(
kinds(i)%colv_list)) cycle
625 moving = moving .OR. any(
kinds(i)%colv_list%expected_value_growth_speed /= 0.0_dp)
627 IF (
ASSOCIATED(gci%colv_list))
THEN
629 moving = moving .OR. any(gci%colv_list%expected_value_growth_speed /= 0.0_dp)
631 gci%joint_colvar_checks = moving
632 IF (moving)
CALL force_env_rattle(force_env, dt=dt, shake_tol=simpar%shake_tol, reset=.true.)
633 END SUBROUTINE initialize_moving_colvars
represent a simple array based list of the given type
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)
...
Handles all functions related to the CELL.
Module that handles the COLLECTIVE constraints.
subroutine, public shake_update_colv_low(colv_list, dt, motion_section, initialize)
Cache the actual target rate, including a partially clamped interval.
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
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
subroutine, public force_env_rattle(force_env, dt, shake_tol, log_unit, lagrange_mult, dump_lm, vel, reset)
perform rattle (enforcing of constraints on velocities) This routine can be easily adapted to perform...
Methods to perform free energy and free energy derivatives calculations.
subroutine, public free_energy_evaluate(md_env, converged, fe_section)
Main driver for free energy calculations In this routine we handle specifically biased MD.
defines types for metadynamics calculation
subroutine, public fe_env_create(fe_env, fe_section)
creates the fe_env
Define type storing the global information of a run. Keep the amount of stored data small....
Adaptively Compressed Exchange (ACE) operator for HFX. Reference: Lin, J. Chem. Theory Comput....
subroutine, public hfx_ace_set_dynamic_mode(is_dynamic)
Mark this run as dynamic (GEO_OPT/MD) so Bypass C fires for geo step 0. Call this once from the geo_o...
Defines the basic variable types.
integer, parameter, public dp
integer, parameter, public default_string_length
Machine interface based on Fortran 2003 and POSIX.
subroutine, public m_flush(lunit)
flushes units if the &GLOBAL flag is set accordingly
real(kind=dp) function, public m_walltime()
returns time from a real-time clock, protected against rolling early/easily
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
subroutine, public md_ener_reftraj(md_env, md_ener)
...
subroutine, public initialize_md_ener(md_ener, force_env, simpar)
...
subroutine, public md_energy(md_env, md_ener)
...
subroutine, public md_write_output(md_env)
This routine computes the conserved quantity, temperature and things like that and prints them out.
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
pure logical function, public need_per_atom_wiener_process(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.
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.
Utilities for Molecular Dynamics.
subroutine, public md_output(md_env, md_section, root_section, forced_io)
collects the part of the MD that, basically, does the output
subroutine, public update_expected_temperature(md_env)
update_expected_temperature
Collection of utilities for setting-up and handle velocities in MD runs.
subroutine, public setup_velocities(force_env, simpar, globenv, md_env, md_section, constraint_section, write_binary_restart_file)
Initialize Velocities for MD runs.
subroutine, public angvel_control(md_ener, force_env, md_section, logger)
Set to 0 the angular velocity along MD runs, if required.
subroutine, public temperature_control(simpar, md_env, md_ener, force_env, logger)
Perform all temperature manipulations during a QS MD run.
subroutine, public comvel_control(md_ener, force_env, md_section, logger)
Set to 0 the velocity of the COM along MD runs, if required.
A common interface (wrapper) for a callback into the md_run loop. Currently this is only used by the ...
subroutine, public mdctrl_callback(mdctrl, md_env, should_stop)
This is called by md_run for each step during during its main-loop.
A common interface for passing a callback into the md_run loop.
Interface to the message passing library MPI.
Define the molecule kind structure types and the corresponding functionality.
Define the data structure for the molecule information.
represent a simple array based list of the given type
qs_environment methods that use many other modules
subroutine, public qs_env_time_update(qs_env, time, itimes)
...
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 write_output_reftraj(md_env)
...
subroutine, public initialize_reftraj(reftraj, reftraj_section, md_env)
...
Routines for the real time propagation.
subroutine, public rt_prop_setup(force_env)
creates rtp_type, gets the initial state, either by reading MO's from file or calling SCF run
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.
Thermal regions type: to initialize and control the temperature of different regions.
Setup of regions with different temperature.
subroutine, public print_thermal_regions_langevin(thermal_regions, simpar, pos, act)
print out information regarding to langevin regions defined in thermal_regions section
subroutine, public create_thermal_regions(thermal_regions, md_section, simpar, force_env)
create thermal_regions
subroutine, public create_thermostats(thermostats, md_section, force_env, simpar, para_env, globenv, global_section)
...
Thermostat structure: module containing thermostat available for MD.
Provides an interface to the velocity-verlet based integrator routines for all ensembles.
subroutine, public velocity_verlet(md_env, globenv)
...
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...
subroutine check(condition, label)
Stops with an error message if a test fails.
represent a list of objects
Type defining parameters related to the simulation cell.
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
represent a list of objects
Simulation parameter type for molecular dynamics.