1!--------------------------------------------------------------------------------------------------!
2!   CP2K: A general program to perform molecular dynamics simulations                              !
3!   Copyright (C) 2000 - 2019  CP2K developers group                                               !
4!--------------------------------------------------------------------------------------------------!
5
6! **************************************************************************************************
7!> \brief Provides an interface to the velocity-verlet based integrator
8!>      routines for all ensembles
9!> \author CJM (11-SEPT-2002)
10! **************************************************************************************************
11MODULE velocity_verlet_control
12
13   USE force_env_types,                 ONLY: force_env_type
14   USE global_types,                    ONLY: global_environment_type
15   USE input_constants,                 ONLY: &
16        isokin_ensemble, langevin_ensemble, npe_f_ensemble, npe_i_ensemble, &
17        nph_uniaxial_damped_ensemble, nph_uniaxial_ensemble, npt_f_ensemble, npt_i_ensemble, &
18        nve_ensemble, nvt_adiabatic_ensemble, nvt_ensemble, reftraj_ensemble
19   USE integrator,                      ONLY: &
20        isokin, langevin, nph_uniaxial, nph_uniaxial_damped, npt_f, npt_i, nve, nve_respa, nvt, &
21        nvt_adiabatic, reftraj
22   USE md_environment_types,            ONLY: get_md_env,&
23                                              md_environment_type
24   USE simpar_types,                    ONLY: simpar_type
25#include "../base/base_uses.f90"
26
27   IMPLICIT NONE
28
29   PRIVATE
30   CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'velocity_verlet_control'
31   PUBLIC :: velocity_verlet
32
33CONTAINS
34
35! **************************************************************************************************
36!> \brief ...
37!> \param md_env ...
38!> \param globenv ...
39!> \par History
40!>      none
41!> \author CJM
42! **************************************************************************************************
43   SUBROUTINE velocity_verlet(md_env, globenv)
44
45      TYPE(md_environment_type), POINTER                 :: md_env
46      TYPE(global_environment_type), POINTER             :: globenv
47
48      CHARACTER(LEN=*), PARAMETER :: routineN = 'velocity_verlet', &
49         routineP = moduleN//':'//routineN
50
51      INTEGER                                            :: handle
52      TYPE(force_env_type), POINTER                      :: force_env
53      TYPE(simpar_type), POINTER                         :: simpar
54
55      CALL timeset(routineN, handle)
56
57      ! Get force environment
58      CALL get_md_env(md_env, force_env=force_env, simpar=simpar)
59
60      ! RESPA implemented only for NVE
61      IF (simpar%do_respa .AND. nve_ensemble .NE. simpar%ensemble) THEN
62         CPABORT("RESPA integrator not implemented for this ensemble")
63      END IF
64
65      ! Choice of the ensemble
66      SELECT CASE (simpar%ensemble)
67      CASE DEFAULT
68         CPABORT("Integrator not implemented")
69      CASE (nve_ensemble)
70         IF (simpar%do_respa) THEN
71            CALL nve_respa(md_env)
72         ELSE
73            CALL nve(md_env, globenv)
74         END IF
75      CASE (nvt_ensemble)
76         CALL nvt(md_env, globenv)
77      CASE (nvt_adiabatic_ensemble)
78         CALL nvt_adiabatic(md_env, globenv)
79      CASE (isokin_ensemble)
80         CALL isokin(md_env)
81      CASE (npt_i_ensemble)
82         CALL npt_i(md_env, globenv)
83      CASE (npt_f_ensemble)
84         CALL npt_f(md_env, globenv)
85      CASE (nph_uniaxial_ensemble)
86         CALL nph_uniaxial(md_env)
87      CASE (nph_uniaxial_damped_ensemble)
88         CALL nph_uniaxial_damped(md_env)
89      CASE (reftraj_ensemble)
90         CALL reftraj(md_env)
91      CASE (langevin_ensemble)
92         CALL langevin(md_env)
93      CASE (npe_f_ensemble)
94         CALL npt_f(md_env, globenv)
95      CASE (npe_i_ensemble)
96         CALL npt_i(md_env, globenv)
97      END SELECT
98
99      CALL timestop(handle)
100
101   END SUBROUTINE velocity_verlet
102
103END MODULE velocity_verlet_control
104