1!--------------------------------------------------------------------------------------------------!
2!   CP2K: A general program to perform molecular dynamics simulations                              !
3!   Copyright (C) 2000 - 2020  CP2K developers group                                               !
4!--------------------------------------------------------------------------------------------------!
5
6! **************************************************************************************************
7!> \par History
8!>      - taken out of input_cp2k_motion
9!> \author Ole Schuett
10! **************************************************************************************************
11
12MODULE input_cp2k_md
13   USE bibliography,                    ONLY: &
14        Evans1983, Guidon2008, Kantorovich2008, Kantorovich2008a, Kolafa2004, Kuhne2007, &
15        Minary2003, Ricci2003, Tuckerman1992, VandeVondele2002, West2006
16   USE cp_output_handling,              ONLY: add_last_numeric,&
17                                              cp_print_key_section_create,&
18                                              debug_print_level,&
19                                              high_print_level,&
20                                              low_print_level,&
21                                              medium_print_level
22   USE cp_units,                        ONLY: cp_unit_to_cp2k
23   USE input_constants,                 ONLY: &
24        isokin_ensemble, langevin_ensemble, md_init_default, md_init_vib, npe_f_ensemble, &
25        npe_i_ensemble, nph_ensemble, nph_uniaxial_damped_ensemble, nph_uniaxial_ensemble, &
26        npt_f_ensemble, npt_i_ensemble, nve_ensemble, nvt_adiabatic_ensemble, nvt_ensemble, &
27        reftraj_ensemble
28   USE input_cp2k_barostats,            ONLY: create_barostat_section
29   USE input_cp2k_thermostats,          ONLY: create_region_section,&
30                                              create_thermo_fast_section,&
31                                              create_thermo_slow_section,&
32                                              create_thermostat_section
33   USE input_keyword_types,             ONLY: keyword_create,&
34                                              keyword_release,&
35                                              keyword_type
36   USE input_section_types,             ONLY: section_add_keyword,&
37                                              section_add_subsection,&
38                                              section_create,&
39                                              section_release,&
40                                              section_type
41   USE input_val_types,                 ONLY: integer_t,&
42                                              lchar_t,&
43                                              real_t
44   USE kinds,                           ONLY: dp
45   USE string_utilities,                ONLY: s2a
46#include "../base/base_uses.f90"
47
48   IMPLICIT NONE
49   PRIVATE
50
51   LOGICAL, PRIVATE, PARAMETER :: debug_this_module = .TRUE.
52   CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'input_cp2k_md'
53
54   PUBLIC :: create_md_section
55
56CONTAINS
57
58! **************************************************************************************************
59!> \brief ...
60!> \param section will contain the md section
61!> \author fawzi
62! **************************************************************************************************
63   SUBROUTINE create_md_section(section)
64      TYPE(section_type), POINTER                        :: section
65
66      CHARACTER(len=*), PARAMETER :: routineN = 'create_md_section', &
67         routineP = moduleN//':'//routineN
68
69      TYPE(keyword_type), POINTER                        :: keyword
70      TYPE(section_type), POINTER                        :: subsection
71
72      CPASSERT(.NOT. ASSOCIATED(section))
73      CALL section_create(section, __LOCATION__, name="MD", &
74                          description="This section defines the whole set of parameters needed perform an MD run.", &
75                          n_keywords=13, n_subsections=6, repeats=.FALSE.)
76
77      NULLIFY (keyword, subsection)
78      CALL keyword_create(keyword, __LOCATION__, name="ensemble", &
79                          description="The ensemble/integrator that you want to use for MD propagation", &
80                          usage="ensemble nve", &
81                          default_i_val=nve_ensemble, &
82                          enum_c_vals=s2a("NVE", "NVT", "NPT_I", "NPT_F", "MSST", "MSST_DAMPED", &
83                                          "HYDROSTATICSHOCK", "ISOKIN", "REFTRAJ", "LANGEVIN", "NPE_F", &
84                                          "NPE_I", "NVT_ADIABATIC"), &
85                          enum_desc=s2a("constant energy (microcanonical)", &
86                                        "constant temperature and volume (canonical)", &
87                                        "constant temperature and pressure using an isotropic cell", &
88                                        "constant temperature and pressure using a flexible cell", &
89                                        "simulate steady shock (uniaxial)", &
90                                        "simulate steady shock (uniaxial) with extra viscosity", &
91                                        "simulate steady shock with hydrostatic pressure", &
92                                        "constant kinetic energy", &
93                                        "reading frames from a file called reftraj.xyz (e.g. for property calculation)", &
94                                        "langevin dynamics (constant temperature)", &
95                                        "constant pressure ensemble (no thermostat)", &
96                                        "constant pressure ensemble using an isotropic cell (no thermostat)", &
97                                        "adiabatic dynamics in constant temperature and volume ensemble (CAFES)"), &
98                          citations=(/Evans1983, VandeVondele2002, Minary2003, Kolafa2004/), &
99                          enum_i_vals=(/nve_ensemble, nvt_ensemble, npt_i_ensemble, npt_f_ensemble, &
100                                        nph_uniaxial_ensemble, nph_uniaxial_damped_ensemble, nph_ensemble, isokin_ensemble, &
101                                        reftraj_ensemble, langevin_ensemble, npe_f_ensemble, npe_i_ensemble, &
102                                        nvt_adiabatic_ensemble/))
103      CALL section_add_keyword(section, keyword)
104      CALL keyword_release(keyword)
105
106      CALL keyword_create(keyword, __LOCATION__, name="steps", &
107                          description="The number of MD steps to perform, counting from step_start_val. ", &
108                          usage="steps 100", default_i_val=3)
109      CALL section_add_keyword(section, keyword)
110      CALL keyword_release(keyword)
111
112      CALL keyword_create(keyword, __LOCATION__, name="max_steps", &
113                          description="The number of MD steps to perform, counting from step 1", &
114                          usage="max_steps 100", default_i_val=1000000000)
115      CALL section_add_keyword(section, keyword)
116      CALL keyword_release(keyword)
117
118      CALL keyword_create(keyword, __LOCATION__, name="timestep", &
119                          description="The length of an integration step (in case RESPA the large TIMESTEP)", &
120                          usage="timestep 1.0", default_r_val=cp_unit_to_cp2k(value=0.5_dp, unit_str="fs"), &
121                          unit_str="fs")
122      CALL section_add_keyword(section, keyword)
123      CALL keyword_release(keyword)
124
125      CALL keyword_create(keyword, __LOCATION__, name="step_start_val", &
126                          description="The starting step value for the MD", usage="step_start_val <integer>", &
127                          default_i_val=0)
128      CALL section_add_keyword(section, keyword)
129      CALL keyword_release(keyword)
130
131      CALL keyword_create(keyword, __LOCATION__, name="time_start_val", &
132                          description="The starting timer value for the MD", &
133                          usage="time_start_val <real>", default_r_val=cp_unit_to_cp2k(value=0.0_dp, unit_str="fs"), &
134                          unit_str="fs")
135      CALL section_add_keyword(section, keyword)
136      CALL keyword_release(keyword)
137
138      CALL keyword_create(keyword, __LOCATION__, name="econs_start_val", &
139                          description="The starting  value of the conserved quantity", &
140                          usage="econs_start_val <real>", default_r_val=0.0_dp, &
141                          unit_str="hartree")
142      CALL section_add_keyword(section, keyword)
143      CALL keyword_release(keyword)
144
145      CALL keyword_create(keyword, __LOCATION__, name="temperature", &
146                          description="The temperature in K used to initialize "// &
147                          "the velocities with init and pos restart, and in the NPT/NVT simulations", &
148                          usage="temperature 325.0", default_r_val=cp_unit_to_cp2k(value=300.0_dp, unit_str="K"), &
149                          unit_str="K")
150      CALL section_add_keyword(section, keyword)
151      CALL keyword_release(keyword)
152
153      CALL keyword_create(keyword, __LOCATION__, name="temp_tol", &
154                          variants=s2a("temp_to", "temperature_tolerance"), &
155                          description="The maximum accepted deviation of the (global) temperature"// &
156                          "from the desired target temperature before a rescaling of the velocites "// &
157                          "is performed. If it is 0 no rescaling is performed. NOTE: This keyword is "// &
158                          "obsolescent; Using a CSVR thermostat with a short timeconstant is "// &
159                          "recommended as a better alternative.", &
160                          usage="temp_tol 0.0", default_r_val=0.0_dp, unit_str='K')
161      CALL section_add_keyword(section, keyword)
162      CALL keyword_release(keyword)
163
164      CALL keyword_create(keyword, __LOCATION__, name="temp_kind", &
165                          description="Compute the temperature per each kind separately", &
166                          usage="temp_kind LOGICAL", &
167                          default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
168      CALL section_add_keyword(section, keyword)
169      CALL keyword_release(keyword)
170
171      CALL keyword_create(keyword, __LOCATION__, name="scale_temp_kind", &
172                          description="When necessary rescale the temperature per each kind separately", &
173                          usage="scale_temp_kind LOGICAL", &
174                          default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
175      CALL section_add_keyword(section, keyword)
176      CALL keyword_release(keyword)
177
178      CALL keyword_create(keyword, __LOCATION__, name="comvel_tol", &
179                          description="The maximum accepted velocity of the center of mass. "// &
180                          "With Shell-Model, comvel may drift if MD%THERMOSTAT%REGION /= GLOBAL ", &
181                          usage="comvel_tol 0.1", type_of_var=real_t, n_var=1, unit_str="bohr*au_t^-1")
182      CALL section_add_keyword(section, keyword)
183      CALL keyword_release(keyword)
184
185      CALL keyword_create(keyword, __LOCATION__, name="angvel_tol", &
186                          description="The maximum accepted angular velocity. This option is ignored "// &
187                          "when the system is periodic. Removes the components of the velocities that"// &
188                          "project on the external rotational degrees of freedom.", &
189                          usage="angvel_tol 0.1", type_of_var=real_t, n_var=1, unit_str="bohr*au_t^-1")
190      CALL section_add_keyword(section, keyword)
191      CALL keyword_release(keyword)
192
193      CALL keyword_create(keyword, __LOCATION__, name="angvel_zero", &
194                          description="Set the initial angular velocity to zero. This option is ignored "// &
195                          "when the system is periodic or when initial velocities are defined. Technically, "// &
196                          "the part of the random initial velocities that projects on the external "// &
197                          "rotational degrees of freedom is subtracted.", &
198                          usage="angvel_zero LOGICAL", &
199                          default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
200      CALL section_add_keyword(section, keyword)
201      CALL keyword_release(keyword)
202
203      CALL keyword_create(keyword, __LOCATION__, name="ANNEALING", &
204                          description="Specifies the rescaling factor for annealing velocities. "// &
205                          "Automatically enables the annealing procedure. This scheme works only for ensembles "// &
206                          "that do not have thermostats on particles.", &
207                          usage="annealing <REAL>", default_r_val=1.0_dp)
208      CALL section_add_keyword(section, keyword)
209      CALL keyword_release(keyword)
210
211      CALL keyword_create(keyword, __LOCATION__, name="ANNEALING_CELL", &
212                          description="Specifies the rescaling factor for annealing velocities of the CELL "// &
213                          "Automatically enables the annealing procedure for the CELL. This scheme works only "// &
214                          "for ensambles that do not have thermostat on CELLS velocities.", &
215                          usage="ANNEALING_CELL <REAL>", default_r_val=1.0_dp)
216      CALL section_add_keyword(section, keyword)
217      CALL keyword_release(keyword)
218
219      CALL keyword_create(keyword, __LOCATION__, name="TEMPERATURE_ANNEALING", &
220                          description="Specifies the rescaling factor for the external temperature."// &
221                          "This scheme works only for the Langevin ensemble.", &
222                          usage="TEMPERATURE_ANNEALING <REAL>", default_r_val=1.0_dp)
223      CALL section_add_keyword(section, keyword)
224      CALL keyword_release(keyword)
225
226      CALL keyword_create(keyword, __LOCATION__, name="DISPLACEMENT_TOL", &
227                          description="This keyword sets a maximum atomic displacement "// &
228                          " in each Cartesian direction."// &
229                          "The maximum velocity is evaluated and if it is too large to remain"// &
230                          "within the assigned limit, the time step is rescaled accordingly,"// &
231                          "and the first half step of the velocity verlet is repeated.", &
232                          usage="DISPLACEMENT_TOL <REAL>", default_r_val=100.0_dp, &
233                          unit_str='angstrom')
234      CALL section_add_keyword(section, keyword)
235      CALL keyword_release(keyword)
236
237      CALL keyword_create(keyword, __LOCATION__, name="INITIALIZATION_METHOD", &
238                          description="This keyword selects which method to use to initialize MD. "// &
239                          "If velecities are not set explicitly, DEFAULT optioin will assign "// &
240                          "random velocities and then scale according to TEMPERATURE; VIBRATIONAL "// &
241                          "option will then use previously calculated vibrational modes to "// &
242                          "initialise both the atomic positions and velocities so that the "// &
243                          "starting point for MD is as close to canonical ensemble as possible, "// &
244                          "without the need for lengthy equilibration steps. See PRL 96, 115504 "// &
245                          "(2006). The user input atomic positions in this case are expected to "// &
246                          "be already geometry optimised. Further options for VIBRATIONAL mode "// &
247                          "is can be set in INITIAL_VIBRATION subsection. If unspecified, then "// &
248                          "the DEFAULT mode will be used.", &
249                          usage="INITIALIZATION_METHOD DEFAULT", &
250                          default_i_val=md_init_default, &
251                          enum_c_vals=s2a("DEFAULT", "VIBRATIONAL"), &
252                          enum_desc=s2a("Assign random velocities and then scale according to "// &
253                                        "TEMPERATURE", &
254                                        "Initialise positions and velocities to give canonical ensemble "// &
255                                        "with TEMPERATURE, using the method described in PRL 96, 115504 (2006)"), &
256                          enum_i_vals=(/md_init_default, md_init_vib/))
257      CALL section_add_keyword(section, keyword)
258      CALL keyword_release(keyword)
259
260      CALL create_langevin_section(subsection)
261      CALL section_add_subsection(section, subsection)
262      CALL section_release(subsection)
263
264      CALL create_msst_section(subsection)
265      CALL section_add_subsection(section, subsection)
266      CALL section_release(subsection)
267
268      CALL create_barostat_section(subsection)
269      CALL section_add_subsection(section, subsection)
270      CALL section_release(subsection)
271
272      CALL create_thermostat_section(subsection)
273      CALL section_add_subsection(section, subsection)
274      CALL section_release(subsection)
275
276      CALL create_respa_section(subsection)
277      CALL section_add_subsection(section, subsection)
278      CALL section_release(subsection)
279
280      CALL create_shell_section(subsection)
281      CALL section_add_subsection(section, subsection)
282      CALL section_release(subsection)
283
284      CALL create_adiabatic_section(subsection)
285      CALL section_add_subsection(section, subsection)
286      CALL section_release(subsection)
287
288      CALL create_softening_section(subsection)
289      CALL section_add_subsection(section, subsection)
290      CALL section_release(subsection)
291
292      CALL create_reftraj_section(subsection)
293      CALL section_add_subsection(section, subsection)
294      CALL section_release(subsection)
295
296      CALL create_avgs_section(subsection)
297      CALL section_add_subsection(section, subsection)
298      CALL section_release(subsection)
299
300      CALL create_thermal_region_section(subsection)
301      CALL section_add_subsection(section, subsection)
302      CALL section_release(subsection)
303
304      CALL create_md_print_section(subsection)
305      CALL section_add_subsection(section, subsection)
306      CALL section_release(subsection)
307
308      CALL create_cascade_section(subsection)
309      CALL section_add_subsection(section, subsection)
310      CALL section_release(subsection)
311
312      CALL create_vib_init_section(subsection)
313      CALL section_add_subsection(section, subsection)
314      CALL section_release(subsection)
315
316   END SUBROUTINE create_md_section
317
318! **************************************************************************************************
319!> \brief Defines LANGEVIN section
320!> \param section ...
321!> \author teo
322! **************************************************************************************************
323   SUBROUTINE create_langevin_section(section)
324      TYPE(section_type), POINTER                        :: section
325
326      CHARACTER(len=*), PARAMETER :: routineN = 'create_langevin_section', &
327         routineP = moduleN//':'//routineN
328
329      TYPE(keyword_type), POINTER                        :: keyword
330
331      CPASSERT(.NOT. ASSOCIATED(section))
332      CALL section_create(section, __LOCATION__, name="Langevin", &
333                          description="Controls the set of parameters to run a Langevin MD. "// &
334                          "The integrator used follows that given in the article by Ricci et al. "// &
335                          "The user can define regions in the system where the atoms inside "// &
336                          "undergoes Langevin MD, while those outside the regions undergoes "// &
337                          "NVE Born Oppenheimer MD. To define the regions, the user should "// &
338                          "use THERMAL_REGION subsection of MOTION%MD. The theory for "// &
339                          "Langevin MD involving sub-regions can be found in articles by "// &
340                          "Kantorovitch et al. All the references can be found in the links below.", &
341                          citations=(/Ricci2003, Kantorovich2008, Kantorovich2008a/), &
342                          n_keywords=0, n_subsections=1, repeats=.FALSE.)
343      NULLIFY (keyword)
344
345      CALL keyword_create(keyword, __LOCATION__, name="gamma", &
346                          description="Gamma parameter for the Langevin dynamics (LD)", &
347                          usage="gamma 0.001", &
348                          default_r_val=0.0_dp, unit_str='fs^-1')
349      CALL section_add_keyword(section, keyword)
350      CALL keyword_release(keyword)
351
352      CALL keyword_create(keyword, __LOCATION__, name="Noisy_Gamma", &
353                          variants=(/"NoisyGamma"/), &
354                          description="Imaginary Langevin Friction term for LD with noisy forces.", &
355                          citations=(/Kuhne2007/), &
356                          usage="Noisy_Gamma 4.0E-5", default_r_val=0.0_dp, unit_str='fs^-1')
357      CALL section_add_keyword(section, keyword)
358      CALL keyword_release(keyword)
359
360      CALL keyword_create(keyword, __LOCATION__, name="Shadow_Gamma", &
361                          variants=(/"ShadowGamma"/), &
362                          description="Shadow Langevin Friction term for LD with noisy forces in order to adjust Noisy_Gamma.", &
363                          citations=(/Kuhne2007/), &
364                          usage="Shadow_Gamma 0.001", default_r_val=0.0_dp, unit_str='fs^-1')
365      CALL section_add_keyword(section, keyword)
366      CALL keyword_release(keyword)
367   END SUBROUTINE create_langevin_section
368
369! **************************************************************************************************
370!> \brief Defines print section for MD
371!> \param section ...
372!> \author teo
373! **************************************************************************************************
374   SUBROUTINE create_md_print_section(section)
375      TYPE(section_type), POINTER                        :: section
376
377      CHARACTER(len=*), PARAMETER :: routineN = 'create_md_print_section', &
378         routineP = moduleN//':'//routineN
379
380      TYPE(keyword_type), POINTER                        :: keyword
381      TYPE(section_type), POINTER                        :: print_key
382
383      CPASSERT(.NOT. ASSOCIATED(section))
384      CALL section_create(section, __LOCATION__, name="print", &
385                          description="Controls the printing properties during an MD run", &
386                          n_keywords=0, n_subsections=1, repeats=.FALSE.)
387      NULLIFY (print_key, keyword)
388
389      CALL keyword_create(keyword, __LOCATION__, name="FORCE_LAST", &
390                          description="Print the output and restart file if walltime is reached or "// &
391                          "if an external EXIT command is given. It still requires the keyword LAST "// &
392                          "to be present for the specific print key (in case the last step should not "// &
393                          "match with the print_key iteration number).", &
394                          usage="FORCE_LAST LOGICAL", &
395                          default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
396      CALL section_add_keyword(section, keyword)
397      CALL keyword_release(keyword)
398
399      CALL cp_print_key_section_create(print_key, __LOCATION__, "ENERGY", &
400                                       description="Controls the output the ener file", &
401                                       print_level=low_print_level, common_iter_levels=1, &
402                                       filename="")
403      CALL section_add_subsection(section, print_key)
404      CALL section_release(print_key)
405
406      CALL cp_print_key_section_create(print_key, __LOCATION__, "SHELL_ENERGY", &
407                                       description="Controls the output of the shell-energy file (only if shell-model)", &
408                                       print_level=medium_print_level, common_iter_levels=1, &
409                                       filename="")
410      CALL section_add_subsection(section, print_key)
411      CALL section_release(print_key)
412
413      CALL cp_print_key_section_create(print_key, __LOCATION__, "TEMP_KIND", &
414                                       description="Controls the output of the temperature"// &
415                                       " computed separately for each kind", &
416                                       print_level=high_print_level, common_iter_levels=1, &
417                                       filename="")
418      CALL section_add_subsection(section, print_key)
419      CALL section_release(print_key)
420
421      CALL cp_print_key_section_create(print_key, __LOCATION__, "TEMP_SHELL_KIND", &
422                                       description="Controls the output of the temperature of the"// &
423                                       " shell-core motion computed separately for each kind", &
424                                       print_level=high_print_level, common_iter_levels=1, &
425                                       filename="")
426      CALL section_add_subsection(section, print_key)
427      CALL section_release(print_key)
428
429      CALL cp_print_key_section_create(print_key, __LOCATION__, "CENTER_OF_MASS", &
430                                       description="Controls the printing of COM velocity during an MD", &
431                                       print_level=medium_print_level, common_iter_levels=1, &
432                                       filename="__STD_OUT__")
433      CALL section_add_subsection(section, print_key)
434      CALL section_release(print_key)
435
436      CALL cp_print_key_section_create(print_key, __LOCATION__, "COEFFICIENTS", &
437                                       description="Controls the printing of coefficients during an MD run.", &
438                                       print_level=medium_print_level, common_iter_levels=1, &
439                                       filename="")
440      CALL section_add_subsection(section, print_key)
441      CALL section_release(print_key)
442
443      CALL cp_print_key_section_create(print_key, __LOCATION__, "ROTATIONAL_INFO", &
444                                       description="Controls the printing basic info during the calculation of the "// &
445                                       "translational/rotational degrees of freedom.", print_level=low_print_level, &
446                                       add_last=add_last_numeric, filename="__STD_OUT__")
447      CALL keyword_create(keyword, __LOCATION__, name="COORDINATES", &
448                          description="Prints atomic coordinates in the standard orientation. "// &
449                          "Coordinates are not affected during the calculation.", &
450                          default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
451      CALL section_add_keyword(print_key, keyword)
452      CALL keyword_release(keyword)
453      CALL section_add_subsection(section, print_key)
454      CALL section_release(print_key)
455
456      CALL cp_print_key_section_create(print_key, __LOCATION__, "PROGRAM_RUN_INFO", &
457                                       description="Controls the printing of basic and summary information during the"// &
458                                       " Molecular Dynamics", &
459                                       print_level=low_print_level, add_last=add_last_numeric, filename="__STD_OUT__")
460      CALL section_add_subsection(section, print_key)
461      CALL section_release(print_key)
462   END SUBROUTINE create_md_print_section
463
464! **************************************************************************************************
465!> \brief Defines parameters for RESPA integration scheme
466!> \param section will contain the coeff section
467!> \author teo
468! **************************************************************************************************
469   SUBROUTINE create_respa_section(section)
470      TYPE(section_type), POINTER                        :: section
471
472      CHARACTER(len=*), PARAMETER :: routineN = 'create_respa_section', &
473         routineP = moduleN//':'//routineN
474
475      TYPE(keyword_type), POINTER                        :: keyword
476
477      CPASSERT(.NOT. ASSOCIATED(section))
478
479      CALL section_create(section, __LOCATION__, name="RESPA", &
480                          description="Multiple timestep integration based on RESPA (implemented for NVE only)."// &
481                          " RESPA exploits multiple force_eval."// &
482                          " In this case the order of the force_eval maps "// &
483                          " the order of the respa shells from the slowest to the fastest force evaluation."// &
484                          " If force_evals share the same subsys, it's enough then to specify the "// &
485                          " subsys in the force_eval corresponding at the first index in the multiple_force_eval list."// &
486                          " Can be used to speedup classical and ab initio MD simulations.", &
487                          n_keywords=1, n_subsections=0, repeats=.FALSE., &
488                          citations=(/Tuckerman1992, Guidon2008/))
489
490      NULLIFY (keyword)
491      CALL keyword_create(keyword, __LOCATION__, name="FREQUENCY", &
492                          description="The number of reference MD steps between two RESPA corrections.", &
493                          usage="FREQUENCY <INTEGER>", default_i_val=5)
494      CALL section_add_keyword(section, keyword)
495      CALL keyword_release(keyword)
496
497   END SUBROUTINE create_respa_section
498
499! **************************************************************************************************
500!> \brief Defines parameters for REFTRAJ analysis
501!> \param section will contain the coeff section
502!> \author teo
503! **************************************************************************************************
504   SUBROUTINE create_reftraj_section(section)
505      TYPE(section_type), POINTER                        :: section
506
507      CHARACTER(len=*), PARAMETER :: routineN = 'create_reftraj_section', &
508         routineP = moduleN//':'//routineN
509
510      TYPE(keyword_type), POINTER                        :: keyword
511      TYPE(section_type), POINTER                        :: print_key, subsection
512
513      CPASSERT(.NOT. ASSOCIATED(section))
514
515      CALL section_create(section, __LOCATION__, name="REFTRAJ", &
516                          description="Loads an external trajectory file and performs analysis on the"// &
517                          " loaded snapshots.", &
518                          n_keywords=1, n_subsections=1, repeats=.FALSE.)
519
520      NULLIFY (keyword, print_key, subsection)
521
522      CALL keyword_create(keyword, __LOCATION__, name="TRAJ_FILE_NAME", &
523                          description="Specify the filename where the trajectory is stored. "// &
524                          "If you built your own trajectory file make sure it has the trajectory format. "// &
525                          'In particular, each structure has to be enumerated using " i = ..."', &
526                          repeats=.FALSE., &
527                          usage="TRAJ_FILE_NAME <CHARACTER>", default_lc_val="reftraj.xyz")
528      CALL section_add_keyword(section, keyword)
529      CALL keyword_release(keyword)
530
531      CALL keyword_create(keyword, __LOCATION__, name="CELL_FILE_NAME", &
532                          description="Specify the filename where the cell is stored "// &
533                          "(for trajectories generated within variable cell ensembles).", repeats=.FALSE., &
534                          usage="CELL_FILE_NAME <CHARACTER>", default_lc_val="reftraj.cell")
535      CALL section_add_keyword(section, keyword)
536      CALL keyword_release(keyword)
537
538      CALL keyword_create( &
539         keyword, __LOCATION__, name="VARIABLE_VOLUME", &
540         description="Enables the possibility to read a CELL file with information on the CELL size during the MD.", &
541         repeats=.FALSE., default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
542      CALL section_add_keyword(section, keyword)
543      CALL keyword_release(keyword)
544
545      CALL keyword_create(keyword, __LOCATION__, name="FIRST_SNAPSHOT", &
546                          description="Index of the snapshot stored in the trajectory file "// &
547                          "from which to start a REFTRAJ run", &
548                          repeats=.FALSE., usage="FIRST_SNAPSHOT <INTEGER>", default_i_val=1)
549      CALL section_add_keyword(section, keyword)
550      CALL keyword_release(keyword)
551
552      CALL keyword_create(keyword, __LOCATION__, name="LAST_SNAPSHOT", &
553                          description="Index of the last snapshot stored in the trajectory file "// &
554                          "that is read along a REFTRAJ run. Must be specified as default is 0. "// &
555                          "Must be specified exactly as LAST_SNAPSHOT = FIRST_SNAPSHOT + STRIDE*(number of strides) "// &
556                          "to avoid an error 'Unexpected EOF'. Note that STRIDE*(number of strides) "// &
557                          "is simply the number of steps between the first to last snapshot.", &
558                          repeats=.FALSE., usage="LAST_SNAPSHOT", default_i_val=0)
559      CALL section_add_keyword(section, keyword)
560      CALL keyword_release(keyword)
561
562      CALL keyword_create(keyword, __LOCATION__, name="STRIDE", &
563                          description=" Stride in number of snapshot for the  reftraj analysis", &
564                          repeats=.FALSE., usage="STRIDE", default_i_val=1)
565      CALL section_add_keyword(section, keyword)
566      CALL keyword_release(keyword)
567
568      CALL keyword_create(keyword, __LOCATION__, name="eval_energy_forces", &
569                          description="Evaluate energy and forces for each retrieved snapshot during a REFTRAJ run", &
570                          repeats=.FALSE., default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
571      CALL section_add_keyword(section, keyword)
572      CALL keyword_release(keyword)
573
574      CALL keyword_create(keyword, __LOCATION__, name="eval_forces", &
575                          description="Evaluate the forces for each retrieved snapshot during a REFTRAJ run", &
576                          repeats=.FALSE., default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
577      CALL section_add_keyword(section, keyword)
578      CALL keyword_release(keyword)
579
580      CALL create_msd_section(subsection)
581      CALL section_add_subsection(section, subsection)
582      CALL section_release(subsection)
583
584      CALL section_create(subsection, __LOCATION__, name="print", &
585                          description="The section that controls the output of a reftraj run", &
586                          n_keywords=1, n_subsections=0, repeats=.FALSE.)
587
588      NULLIFY (print_key)
589      CALL cp_print_key_section_create(print_key, __LOCATION__, "msd_kind", &
590                                       description="Controls the output of msd per kind", &
591                                       print_level=low_print_level, common_iter_levels=1, &
592                                       filename="")
593      CALL section_add_subsection(subsection, print_key)
594      CALL section_release(print_key)
595
596      CALL cp_print_key_section_create(print_key, __LOCATION__, "msd_molecule", &
597                                       description="Controls the output of msd per molecule kind", &
598                                       print_level=low_print_level, common_iter_levels=1, &
599                                       filename="")
600      CALL section_add_subsection(subsection, print_key)
601      CALL section_release(print_key)
602
603      CALL cp_print_key_section_create(print_key, __LOCATION__, "displaced_atom", &
604                                       description="Controls the output of index and dislacement of "// &
605                                       "atoms that moved away from the initial position of more than a"// &
606                                       "given distance (see msd%disp_tol)", &
607                                       print_level=low_print_level, common_iter_levels=1, &
608                                       filename="")
609      CALL section_add_subsection(subsection, print_key)
610      CALL section_release(print_key)
611
612      CALL section_add_subsection(section, subsection)
613      CALL section_release(subsection)
614
615   END SUBROUTINE create_reftraj_section
616
617! **************************************************************************************************
618!> \brief Defines parameters for MSD calculation along a REFTRAJ analysis
619!> \param section will contain the coeff section
620!> \author MI
621! **************************************************************************************************
622   SUBROUTINE create_msd_section(section)
623      TYPE(section_type), POINTER                        :: section
624
625      CHARACTER(len=*), PARAMETER :: routineN = 'create_msd_section', &
626         routineP = moduleN//':'//routineN
627
628      TYPE(keyword_type), POINTER                        :: keyword
629      TYPE(section_type), POINTER                        :: subsection
630
631      CPASSERT(.NOT. ASSOCIATED(section))
632
633      CALL section_create(section, __LOCATION__, name="MSD", &
634                          description="Loads an external trajectory file and performs analysis on the"// &
635                          " loaded snapshots.", &
636                          n_keywords=3, n_subsections=0, repeats=.FALSE.)
637
638      NULLIFY (keyword, subsection)
639
640      CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
641                          description="controls the activation of core-level spectroscopy simulations", &
642                          usage="&MSD T", &
643                          default_l_val=.FALSE., &
644                          lone_keyword_l_val=.TRUE.)
645      CALL section_add_keyword(section, keyword)
646      CALL keyword_release(keyword)
647
648      CALL keyword_create(keyword, __LOCATION__, name="REF0_FILENAME", &
649                          description="Specify the filename where the initial reference configuration is stored.", &
650                          repeats=.FALSE., usage="REF0_FILENAME <CHARACTER>", default_lc_val="")
651      CALL section_add_keyword(section, keyword)
652      CALL keyword_release(keyword)
653
654      CALL keyword_create(keyword, __LOCATION__, name="MSD_PER_KIND", &
655                          description="Set up the calculation of the MSD for each atomic kind", &
656                          usage="MSD_PER_KIND <LOGICAL>", repeats=.FALSE., &
657                          default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
658      CALL section_add_keyword(section, keyword)
659      CALL keyword_release(keyword)
660
661      CALL keyword_create(keyword, __LOCATION__, name="MSD_PER_MOLKIND", &
662                          description="Set up the calculation of the MSD for each molecule kind."// &
663                          "The position of the center of mass of the molecule is considered.", &
664                          usage="MSD_PER_MOLKIND <LOGICAL>", repeats=.FALSE., &
665                          default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
666      CALL section_add_keyword(section, keyword)
667      CALL keyword_release(keyword)
668
669      CALL keyword_create(keyword, __LOCATION__, name="MSD_PER_REGION", &
670                          description="Set up the calculation of the MSD for each defined region.", &
671                          usage="MSD_PER_REGION <LOGICAL>", repeats=.FALSE., &
672                          default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
673      CALL section_add_keyword(section, keyword)
674      CALL keyword_release(keyword)
675
676      CALL create_region_section(subsection, "MSD calculation")
677      CALL section_add_subsection(section, subsection)
678      CALL section_release(subsection)
679
680      CALL keyword_create(keyword, __LOCATION__, name="DISPLACED_ATOM", &
681                          description="Identify the atoms that moved from their initial"// &
682                          "position of a distance larger than a given tolerance (see msd%displacement_tol).", &
683                          usage="DISPLACED_ATOM <LOGICAL>", repeats=.FALSE., &
684                          default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
685      CALL section_add_keyword(section, keyword)
686      CALL keyword_release(keyword)
687
688      CALL keyword_create(keyword, __LOCATION__, name="displacement_tol", &
689                          description="Lower limit to define displaced atoms", &
690                          usage="DISPLACEMENT_TOL real", &
691                          default_r_val=0._dp, n_var=1, unit_str='bohr')
692      CALL section_add_keyword(section, keyword)
693      CALL keyword_release(keyword)
694
695   END SUBROUTINE create_msd_section
696
697! **************************************************************************************************
698!> \brief ...
699!> \param section will contain the coeff section
700!> \author teo
701! **************************************************************************************************
702   SUBROUTINE create_msst_section(section)
703      TYPE(section_type), POINTER                        :: section
704
705      CHARACTER(len=*), PARAMETER :: routineN = 'create_msst_section', &
706         routineP = moduleN//':'//routineN
707
708      TYPE(keyword_type), POINTER                        :: keyword
709
710      CPASSERT(.NOT. ASSOCIATED(section))
711
712      CALL section_create(section, __LOCATION__, name="msst", &
713                          description="Parameters for Multi-Scale Shock Technique (MSST) "// &
714                          "which simulate the effect of a steady planar shock on a unit cell. "// &
715                          "Reed et. al. Physical Review Letters 90, 235503 (2003).", &
716                          n_keywords=1, n_subsections=0, repeats=.FALSE.)
717
718      NULLIFY (keyword)
719      CALL keyword_create(keyword, __LOCATION__, name="PRESSURE", &
720                          description="Initial pressure", &
721                          usage="PRESSURE real", &
722                          default_r_val=0._dp, n_var=1, unit_str='bar')
723      CALL section_add_keyword(section, keyword)
724      CALL keyword_release(keyword)
725
726      CALL keyword_create(keyword, __LOCATION__, name="ENERGY", &
727                          description="Initial energy", &
728                          usage="ENERGY real", &
729                          default_r_val=0._dp, n_var=1, unit_str='hartree')
730      CALL section_add_keyword(section, keyword)
731      CALL keyword_release(keyword)
732
733      CALL keyword_create(keyword, __LOCATION__, name="VOLUME", &
734                          description="Initial volume", &
735                          usage="VOLUME real", &
736                          default_r_val=0._dp, n_var=1, unit_str='angstrom^3')
737      CALL section_add_keyword(section, keyword)
738      CALL keyword_release(keyword)
739
740      CALL keyword_create(keyword, __LOCATION__, name="CMASS", &
741                          description="Effective cell mass", &
742                          usage="CMASS real", &
743                          default_r_val=0._dp, n_var=1, unit_str='au_m')
744      CALL section_add_keyword(section, keyword)
745      CALL keyword_release(keyword)
746
747      CALL keyword_create(keyword, __LOCATION__, name="VSHOCK", variants=(/"V_SHOCK"/), &
748                          description="Velocity shock", &
749                          usage="VSHOCK real", &
750                          default_r_val=0._dp, n_var=1, unit_str='m/s')
751      CALL section_add_keyword(section, keyword)
752      CALL keyword_release(keyword)
753
754      CALL keyword_create(keyword, __LOCATION__, name="GAMMA", &
755                          description="Damping coefficient for cell volume", &
756                          usage="GAMMA real", &
757                          unit_str='fs^-1', &
758                          default_r_val=0.0_dp)
759      CALL section_add_keyword(section, keyword)
760      CALL keyword_release(keyword)
761
762   END SUBROUTINE create_msst_section
763
764! **************************************************************************************************
765!> \brief section will contain some parameters for the shells dynamics
766!> \param section ...
767! **************************************************************************************************
768   SUBROUTINE create_shell_section(section)
769      TYPE(section_type), POINTER                        :: section
770
771      CHARACTER(len=*), PARAMETER :: routineN = 'create_shell_section', &
772         routineP = moduleN//':'//routineN
773
774      TYPE(keyword_type), POINTER                        :: keyword
775      TYPE(section_type), POINTER                        :: thermo_section
776
777      CPASSERT(.NOT. ASSOCIATED(section))
778
779      CALL section_create(section, __LOCATION__, name="shell", &
780                          description="Parameters of shell model in adiabatic dynamics.", &
781                          n_keywords=4, n_subsections=1, repeats=.FALSE.)
782
783      NULLIFY (keyword, thermo_section)
784
785      CALL keyword_create(keyword, __LOCATION__, name="temperature", &
786                          description="Temperature in K used to control "// &
787                          "the internal velocities of the core-shell motion ", &
788                          usage="temperature 5.0", &
789                          default_r_val=cp_unit_to_cp2k(value=0.0_dp, unit_str="K"), &
790                          unit_str="K")
791      CALL section_add_keyword(section, keyword)
792      CALL keyword_release(keyword)
793
794      CALL keyword_create(keyword, __LOCATION__, name="temp_tol", &
795                          description="Maximum accepted temperature deviation"// &
796                          " from the expected value, for the internal core-shell motion."// &
797                          "If 0, no rescaling is performed", &
798                          usage="temp_tol 0.0", default_r_val=0.0_dp, unit_str='K')
799      CALL section_add_keyword(section, keyword)
800      CALL keyword_release(keyword)
801
802      CALL keyword_create(keyword, __LOCATION__, name="nose_particle", &
803                          description="If nvt or npt, the core and shell velocities are controlled "// &
804                          "by the same thermostat used for the particle. This might favour heat exchange "// &
805                          "and additional rescaling of the internal core-shell velocity is needed (TEMP_TOL)", &
806                          default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
807      CALL section_add_keyword(section, keyword)
808      CALL keyword_release(keyword)
809
810      CALL keyword_create(keyword, __LOCATION__, name="DISPLACEMENT_SHELL_TOL", &
811                          description="This keyword sets a maximum variation of the shell "// &
812                          "core distance in each Cartesian direction."// &
813                          "The maximum internal core-shell velocity is evaluated and"// &
814                          " if it is too large to remain"// &
815                          "within the assigned limit, the time step is rescaled accordingly,"// &
816                          "and the first half step of the velocity verlet is repeated.", &
817                          usage="DISPLACEMENT_SHELL_TOL <REAL>", default_r_val=100.0_dp, &
818                          unit_str='angstrom')
819      CALL section_add_keyword(section, keyword)
820      CALL keyword_release(keyword)
821
822      CALL create_thermostat_section(thermo_section)
823      CALL section_add_subsection(section, thermo_section)
824      CALL section_release(thermo_section)
825
826   END SUBROUTINE create_shell_section
827
828! **************************************************************************************************
829!> \brief section will contain some parameters for the adiabatic dynamics
830!> \param section ...
831! **************************************************************************************************
832   SUBROUTINE create_adiabatic_section(section)
833      TYPE(section_type), POINTER                        :: section
834
835      CHARACTER(len=*), PARAMETER :: routineN = 'create_adiabatic_section', &
836         routineP = moduleN//':'//routineN
837
838      TYPE(keyword_type), POINTER                        :: keyword
839      TYPE(section_type), POINTER                        :: thermo_fast_section, thermo_slow_section
840
841      CPASSERT(.NOT. ASSOCIATED(section))
842
843      CALL section_create(section, __LOCATION__, name="ADIABATIC_DYNAMICS", &
844                          description="Parameters used in canonical adiabatic free energy sampling (CAFES).", &
845                          n_keywords=5, n_subsections=2, repeats=.FALSE., &
846                          citations=(/VandeVondele2002/))
847
848      NULLIFY (keyword, thermo_fast_section, thermo_slow_section)
849
850      CALL keyword_create(keyword, __LOCATION__, name="temp_fast", &
851                          description="Temperature in K used to control "// &
852                          "the fast degrees of freedom ", &
853                          usage="temp_fast 5.0", &
854                          default_r_val=cp_unit_to_cp2k(value=0.0_dp, unit_str="K"), &
855                          unit_str="K")
856      CALL section_add_keyword(section, keyword)
857      CALL keyword_release(keyword)
858
859      CALL keyword_create(keyword, __LOCATION__, name="temp_slow", &
860                          description="Temperature in K used to control "// &
861                          "the slow degrees of freedom ", &
862                          usage="temp_slow 5.0", &
863                          default_r_val=cp_unit_to_cp2k(value=0.0_dp, unit_str="K"), &
864                          unit_str="K")
865      CALL section_add_keyword(section, keyword)
866      CALL keyword_release(keyword)
867
868      CALL keyword_create(keyword, __LOCATION__, name="temp_tol_fast", &
869                          description="Maximum accepted temperature deviation"// &
870                          " from the expected value, for the fast motion."// &
871                          "If 0, no rescaling is performed", &
872                          usage="temp_tol 0.0", default_r_val=0.0_dp, unit_str='K')
873      CALL section_add_keyword(section, keyword)
874      CALL keyword_release(keyword)
875
876      CALL keyword_create(keyword, __LOCATION__, name="temp_tol_slow", &
877                          description="Maximum accepted temperature deviation"// &
878                          " from the expected value, for the slow motion."// &
879                          "If 0, no rescaling is performed", &
880                          usage="temp_tol 0.0", default_r_val=0.0_dp, unit_str='K')
881      CALL section_add_keyword(section, keyword)
882      CALL keyword_release(keyword)
883
884      CALL keyword_create(keyword, __LOCATION__, name="n_resp_fast", &
885                          description="number of respa steps for fast degrees of freedom", &
886                          repeats=.FALSE., default_i_val=1)
887      CALL section_add_keyword(section, keyword)
888      CALL keyword_release(keyword)
889
890      CALL create_thermo_fast_section(thermo_fast_section)
891      CALL section_add_subsection(section, thermo_fast_section)
892      CALL section_release(thermo_fast_section)
893
894      CALL create_thermo_slow_section(thermo_slow_section)
895      CALL section_add_subsection(section, thermo_slow_section)
896      CALL section_release(thermo_slow_section)
897
898   END SUBROUTINE create_adiabatic_section
899
900! **************************************************************************************************
901!> \brief section will contain parameters for the velocity softening
902!> \param section ...
903!> \author Ole Schuett
904! **************************************************************************************************
905   SUBROUTINE create_softening_section(section)
906      TYPE(section_type), POINTER                        :: section
907
908      CHARACTER(len=*), PARAMETER :: routineN = 'create_softening_section', &
909         routineP = moduleN//':'//routineN
910
911      TYPE(keyword_type), POINTER                        :: keyword
912
913      CALL section_create(section, __LOCATION__, name="VELOCITY_SOFTENING", &
914                          description="A method to initialize the velocities along low-curvature " &
915                          //"directions in order to favors MD trajectories to cross rapidly over " &
916                          //"small energy barriers into neighboring basins. " &
917                          //"In each iteration the forces are calculated at a point y, which " &
918                          //"is slightly displaced from the current positions x in the direction " &
919                          //"of the original velocities v. The velocities are then updated with " &
920                          //"the force component F_t, which is perpendicular to N. " &
921                          //"N = v / |v|;  y = x + delta * N;  F_t = F(y) - &lang; F(y) | N &rang; * N; " &
922                          //"v' = v + alpha * F_t")
923
924      NULLIFY (keyword)
925      CALL keyword_create(keyword, __LOCATION__, name="STEPS", &
926                          description="Number of softening iterations performed. " &
927                          //"Typical values are around 40 steps.", &
928                          default_i_val=0)
929      CALL section_add_keyword(section, keyword)
930      CALL keyword_release(keyword)
931
932      CALL keyword_create(keyword, __LOCATION__, name="DELTA", &
933                          description="Displacement used to obtain y.", &
934                          default_r_val=0.1_dp)
935      CALL section_add_keyword(section, keyword)
936      CALL keyword_release(keyword)
937
938      CALL keyword_create(keyword, __LOCATION__, name="ALPHA", &
939                          description="Mixing factor used for updating velocities.", &
940                          default_r_val=0.15_dp)
941      CALL section_add_keyword(section, keyword)
942      CALL keyword_release(keyword)
943
944   END SUBROUTINE create_softening_section
945
946! **************************************************************************************************
947!> \brief input section used to define regions with different temperature
948!>        initialization and control
949!> \param section ...
950!> \par History
951!>   - Added input for langevin regions in thermal regions section
952!>     (2014/02/04, LT)
953! **************************************************************************************************
954   SUBROUTINE create_thermal_region_section(section)
955      TYPE(section_type), POINTER                        :: section
956
957      CHARACTER(len=*), PARAMETER :: routineN = 'create_thermal_region_section', &
958         routineP = moduleN//':'//routineN
959
960      TYPE(keyword_type), POINTER                        :: keyword
961      TYPE(section_type), POINTER                        :: print_key, region_section, subsection
962
963      CPASSERT(.NOT. ASSOCIATED(section))
964
965      CALL section_create(section, __LOCATION__, name="thermal_region", &
966                          description="Define regions where different initialization and control "// &
967                          "of the temperature is used. When MOTION%MD%ENSEMBLE is set to LANGEVIN, "// &
968                          "this section controls if the atoms defined inside and outside the "// &
969                          "thermal regions should undergo Langevin MD or NVE Born-Oppenheimer MD. "// &
970                          "The theory behind Langevin MD using different regions can be found in "// &
971                          "articles by Kantorovitch et al. listed below.", &
972                          citations=(/Kantorovich2008, Kantorovich2008a/), &
973                          n_keywords=0, n_subsections=1, repeats=.FALSE.)
974
975      NULLIFY (region_section)
976      NULLIFY (keyword, subsection)
977
978      CALL keyword_create(keyword, __LOCATION__, name="force_rescaling", &
979                          description="Control the rescaling ot the velocities in all the regions, "// &
980                          "according to the temperature assigned to each reagion, when "// &
981                          "RESTART_VELOCITY in EXT_RESTART is active.", &
982                          default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
983      CALL section_add_keyword(section, keyword)
984      CALL keyword_release(keyword)
985
986      CALL keyword_create(keyword, __LOCATION__, name="do_langevin_default", &
987                          description="If ENSEMBLE is set to LANGEVIN, controls whether the "// &
988                          "atoms NOT defined in the thermal regions to undergo langevin MD "// &
989                          "or not. If not, then the atoms will undergo NVE Born-Oppenheimer MD.", &
990                          usage="do_langevin_default .FALSE.", &
991                          default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
992      CALL section_add_keyword(section, keyword)
993      CALL keyword_release(keyword)
994
995      CALL section_create(region_section, __LOCATION__, name="DEFINE_REGION", &
996                          description="This section provides the possibility to define arbitrary region ", &
997                          n_keywords=3, n_subsections=0, repeats=.TRUE.)
998
999      NULLIFY (keyword)
1000      CALL keyword_create(keyword, __LOCATION__, name="LIST", &
1001                          description="Specifies a list of atoms belonging to the region.", &
1002                          usage="LIST {integer} {integer} .. {integer}", &
1003                          repeats=.TRUE., n_var=-1, type_of_var=integer_t)
1004      CALL section_add_keyword(region_section, keyword)
1005      CALL keyword_release(keyword)
1006
1007      CALL keyword_create(keyword, __LOCATION__, name="temperature", &
1008                          description="The temperature in K used to initialize the velocities "// &
1009                          "of the atoms in this region ", &
1010                          usage="temperature 5.0", &
1011                          default_r_val=cp_unit_to_cp2k(value=0.0_dp, unit_str="K"), &
1012                          unit_str="K")
1013      CALL section_add_keyword(region_section, keyword)
1014      CALL keyword_release(keyword)
1015
1016      CALL keyword_create(keyword, __LOCATION__, name="temp_tol", &
1017                          description="Maximum accepted temperature deviation from the expected "// &
1018                          "value for this region. If temp_tol=0 no rescaling is performed", &
1019                          usage="temp_tol 0.0", &
1020                          default_r_val=0.0_dp, unit_str='K')
1021      CALL section_add_keyword(region_section, keyword)
1022      CALL keyword_release(keyword)
1023
1024      CALL keyword_create(keyword, __LOCATION__, name="do_langevin", &
1025                          description="When ENSEMBLE is set to LANGEVIN, Controls whether "// &
1026                          "the atoms in the thermal region should undergo Langevin MD. If "// &
1027                          "not, then they will undergo NVE Born-Oppenheimer MD.", &
1028                          usage="do_langevin .TRUE.", &
1029                          default_l_val=.TRUE., lone_keyword_l_val=.TRUE.)
1030      CALL section_add_keyword(region_section, keyword)
1031      CALL keyword_release(keyword)
1032
1033      CALL keyword_create(keyword, __LOCATION__, name="noisy_gamma_region", &
1034                          description="Special imaginary Langevin Friction term "// &
1035                          "for Langevin Dynamics with noisy forces for the atoms in this region."// &
1036                          "When set, overrides the general value set by NOISY_GAMMA in the MOTION%MD%LANGEVIN section."// &
1037                          "When unset for a defined region, the general NOISY_GAMMA value applies.", &
1038                          citations=(/Kuhne2007/), usage="noisy_gamma_region 4.0E-5", &
1039                          type_of_var=real_t, &
1040                          unit_str="fs^-1")
1041      CALL section_add_keyword(region_section, keyword)
1042      CALL keyword_release(keyword)
1043
1044      CALL section_add_subsection(section, region_section)
1045      CALL section_release(region_section)
1046
1047      NULLIFY (print_key)
1048      CALL section_create(subsection, __LOCATION__, name="PRINT", &
1049                          description="Collects all print_keys for thermal_regions", &
1050                          n_keywords=1, n_subsections=0, repeats=.FALSE.)
1051
1052      CALL cp_print_key_section_create(print_key, __LOCATION__, "TEMPERATURE", &
1053                                       description="Controls output of temperature per region.", &
1054                                       print_level=high_print_level, common_iter_levels=1, &
1055                                       filename="")
1056      CALL section_add_subsection(subsection, print_key)
1057      CALL section_release(print_key)
1058
1059      CALL cp_print_key_section_create(print_key, __LOCATION__, "LANGEVIN_REGIONS", &
1060                                       description="Controls output of information on which atoms "// &
1061                                       "underwent Langevin MD and which atoms did not.", &
1062                                       print_level=high_print_level, &
1063                                       filename="")
1064      CALL section_add_subsection(subsection, print_key)
1065      CALL section_release(print_key)
1066
1067      CALL section_add_subsection(section, subsection)
1068      CALL section_release(subsection)
1069
1070   END SUBROUTINE create_thermal_region_section
1071
1072! **************************************************************************************************
1073!> \brief   Defines the parameters for the setup of a cascade simulation
1074!> \param section ...
1075!> \date    03.02.2012
1076!> \author  Matthias Krack (MK)
1077!> \version 1.0
1078! **************************************************************************************************
1079   SUBROUTINE create_cascade_section(section)
1080
1081      TYPE(section_type), POINTER                        :: section
1082
1083      CHARACTER(LEN=*), PARAMETER :: routineN = 'create_cascade_section', &
1084         routineP = moduleN//':'//routineN
1085
1086      TYPE(keyword_type), POINTER                        :: keyword
1087      TYPE(section_type), POINTER                        :: subsection
1088
1089      NULLIFY (keyword)
1090      NULLIFY (subsection)
1091      CPASSERT(.NOT. ASSOCIATED(section))
1092
1093      CALL section_create(section, __LOCATION__, name="CASCADE", &
1094                          description="Defines the parameters for the setup of a cascade simulation.", &
1095                          n_keywords=1, &
1096                          n_subsections=1, &
1097                          repeats=.FALSE.)
1098
1099      CALL keyword_create(keyword, __LOCATION__, &
1100                          name="_SECTION_PARAMETERS_", &
1101                          description="Controls the activation of the CASCADE section.", &
1102                          usage="&CASCADE on", &
1103                          default_l_val=.FALSE., &
1104                          lone_keyword_l_val=.TRUE.)
1105      CALL section_add_keyword(section, keyword)
1106      CALL keyword_release(keyword)
1107
1108      CALL keyword_create(keyword, __LOCATION__, name="ENERGY", &
1109                          description="Total energy transferred to the system during the cascade event.", &
1110                          usage="ENERGY 20.0", &
1111                          default_r_val=0.0_dp, &
1112                          unit_str="keV")
1113      CALL section_add_keyword(section, keyword)
1114      CALL keyword_release(keyword)
1115
1116      CALL section_create(subsection, __LOCATION__, name="ATOM_LIST", &
1117                          description="Defines a list of atoms for which the initial velocities are modified", &
1118                          n_keywords=1, &
1119                          n_subsections=0, &
1120                          repeats=.FALSE.)
1121
1122      CALL keyword_create(keyword, __LOCATION__, name="_DEFAULT_KEYWORD_", &
1123                          description="Defines the list of atoms for which the velocities are modified. "// &
1124                          "Each record consists of the atomic index, the velocity vector, and "// &
1125                          "a weight to define which fraction of the total energy is assigned "// &
1126                          "to the current atom:"// &
1127                          "<p><tt><big>Atomic_index v<sub>x</sub> v<sub>y</sub> v<sub>z</sub> "// &
1128                          "Weight</big></tt></p>", &
1129                          usage="{{Integer} {Real} {Real} {Real} {Real}}", &
1130                          repeats=.TRUE., &
1131                          type_of_var=lchar_t)
1132      CALL section_add_keyword(subsection, keyword)
1133      CALL keyword_release(keyword)
1134
1135      CALL section_add_subsection(section, subsection)
1136      CALL section_release(subsection)
1137
1138   END SUBROUTINE create_cascade_section
1139
1140! **************************************************************************************************
1141!> \brief Defines AVERAGES section
1142!> \param section ...
1143!> \author teo
1144! **************************************************************************************************
1145   SUBROUTINE create_avgs_section(section)
1146      TYPE(section_type), POINTER                        :: section
1147
1148      CHARACTER(len=*), PARAMETER :: routineN = 'create_avgs_section', &
1149         routineP = moduleN//':'//routineN
1150
1151      TYPE(keyword_type), POINTER                        :: keyword
1152      TYPE(section_type), POINTER                        :: print_key, subsection
1153
1154      CPASSERT(.NOT. ASSOCIATED(section))
1155      CALL section_create(section, __LOCATION__, name="Averages", &
1156                          description="Controls the calculation of the averages during an MD run.", &
1157                          n_keywords=1, n_subsections=1, repeats=.FALSE.)
1158      NULLIFY (keyword, print_key, subsection)
1159
1160      CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
1161                          description="Controls the calculations of the averages.", &
1162                          usage="&AVERAGES T", default_l_val=.TRUE., lone_keyword_l_val=.TRUE.)
1163      CALL section_add_keyword(section, keyword)
1164      CALL keyword_release(keyword)
1165
1166      CALL keyword_create(keyword, __LOCATION__, name="ACQUISITION_START_TIME", &
1167                          description="Setup up the simulation time when the acquisition process to compute "// &
1168                          " averages is started.", &
1169                          usage="ACQUISITION_START_TIME <REAL>", &
1170                          default_r_val=0.0_dp, unit_str='fs')
1171      CALL section_add_keyword(section, keyword)
1172      CALL keyword_release(keyword)
1173
1174      CALL keyword_create(keyword, __LOCATION__, name="AVERAGE_COLVAR", &
1175                          description="Switch for computing the averages of COLVARs.", &
1176                          usage="AVERAGE_COLVAR <LOGICAL>", default_l_val=.FALSE., &
1177                          lone_keyword_l_val=.TRUE.)
1178      CALL section_add_keyword(section, keyword)
1179      CALL keyword_release(keyword)
1180
1181      CALL cp_print_key_section_create(print_key, __LOCATION__, "PRINT_AVERAGES", &
1182                                       description="Controls the output the averaged quantities", &
1183                                       print_level=debug_print_level + 1, common_iter_levels=1, &
1184                                       filename="")
1185      CALL section_add_subsection(section, print_key)
1186      CALL section_release(print_key)
1187
1188      CALL create_avgs_restart_section(subsection)
1189      CALL section_add_subsection(section, subsection)
1190      CALL section_release(subsection)
1191   END SUBROUTINE create_avgs_section
1192
1193! **************************************************************************************************
1194!> \brief Defines the AVERAGES RESTART section
1195!> \param section ...
1196!> \author teo
1197! **************************************************************************************************
1198   SUBROUTINE create_avgs_restart_section(section)
1199      TYPE(section_type), POINTER                        :: section
1200
1201      CHARACTER(len=*), PARAMETER :: routineN = 'create_avgs_restart_section', &
1202         routineP = moduleN//':'//routineN
1203
1204      TYPE(keyword_type), POINTER                        :: keyword
1205
1206      CPASSERT(.NOT. ASSOCIATED(section))
1207      CALL section_create(section, __LOCATION__, name="RESTART_AVERAGES", &
1208                          description="Stores information for restarting averages.", &
1209                          n_keywords=1, n_subsections=1, repeats=.FALSE.)
1210      NULLIFY (keyword)
1211
1212      CALL keyword_create(keyword, __LOCATION__, name="ITIMES_START", &
1213                          description="TIME STEP starting the evaluation of averages", &
1214                          usage="ITIMES_START <INTEGER>", type_of_var=integer_t, n_var=1)
1215      CALL section_add_keyword(section, keyword)
1216      CALL keyword_release(keyword)
1217
1218      CALL keyword_create(keyword, __LOCATION__, name="AVECPU", &
1219                          description="CPU average", usage="AVECPU <REAL>", &
1220                          type_of_var=real_t, n_var=1)
1221      CALL section_add_keyword(section, keyword)
1222      CALL keyword_release(keyword)
1223
1224      CALL keyword_create(keyword, __LOCATION__, name="AVEHUGONIOT", &
1225                          description="HUGONIOT average", usage="AVEHUGONIOT <REAL>", &
1226                          type_of_var=real_t, n_var=1)
1227      CALL section_add_keyword(section, keyword)
1228      CALL keyword_release(keyword)
1229
1230      CALL keyword_create(keyword, __LOCATION__, name="AVETEMP_BARO", &
1231                          description="BAROSTAT TEMPERATURE average", usage="AVETEMP_BARO <REAL>", &
1232                          type_of_var=real_t, n_var=1)
1233      CALL section_add_keyword(section, keyword)
1234      CALL keyword_release(keyword)
1235
1236      CALL keyword_create(keyword, __LOCATION__, name="AVEPOT", &
1237                          description="POTENTIAL ENERGY average", usage="AVEPOT <REAL>", &
1238                          type_of_var=real_t, n_var=1)
1239      CALL section_add_keyword(section, keyword)
1240      CALL keyword_release(keyword)
1241
1242      CALL keyword_create(keyword, __LOCATION__, name="AVEKIN", &
1243                          description="KINETIC ENERGY average", usage="AVEKIN <REAL>", &
1244                          type_of_var=real_t, n_var=1)
1245      CALL section_add_keyword(section, keyword)
1246      CALL keyword_release(keyword)
1247
1248      CALL keyword_create(keyword, __LOCATION__, name="AVETEMP", &
1249                          description="TEMPERATURE average", usage="AVETEMP <REAL>", &
1250                          type_of_var=real_t, n_var=1)
1251      CALL section_add_keyword(section, keyword)
1252      CALL keyword_release(keyword)
1253
1254      CALL keyword_create(keyword, __LOCATION__, name="AVEKIN_QM", &
1255                          description="QM KINETIC ENERGY average in QMMM runs", usage="AVEKIN_QM <REAL>", &
1256                          type_of_var=real_t, n_var=1)
1257      CALL section_add_keyword(section, keyword)
1258      CALL keyword_release(keyword)
1259
1260      CALL keyword_create(keyword, __LOCATION__, name="AVETEMP_QM", &
1261                          description="QM TEMPERATURE average in QMMM runs", usage="AVETEMP_QM <REAL>", &
1262                          type_of_var=real_t, n_var=1)
1263      CALL section_add_keyword(section, keyword)
1264      CALL keyword_release(keyword)
1265
1266      CALL keyword_create(keyword, __LOCATION__, name="AVEVOL", &
1267                          description="VOLUME average", usage="AVEVOL <REAL>", &
1268                          type_of_var=real_t, n_var=1)
1269      CALL section_add_keyword(section, keyword)
1270      CALL keyword_release(keyword)
1271
1272      CALL keyword_create(keyword, __LOCATION__, name="AVECELL_A", &
1273                          description="CELL VECTOR A average", usage="AVECELL_A <REAL>", &
1274                          type_of_var=real_t, n_var=1)
1275      CALL section_add_keyword(section, keyword)
1276      CALL keyword_release(keyword)
1277
1278      CALL keyword_create(keyword, __LOCATION__, name="AVECELL_B", &
1279                          description="CELL VECTOR B average", usage="AVECELL_B <REAL>", &
1280                          type_of_var=real_t, n_var=1)
1281      CALL section_add_keyword(section, keyword)
1282      CALL keyword_release(keyword)
1283
1284      CALL keyword_create(keyword, __LOCATION__, name="AVECELL_C", &
1285                          description="CELL VECTOR C average", usage="AVECELL_C <REAL>", &
1286                          type_of_var=real_t, n_var=1)
1287      CALL section_add_keyword(section, keyword)
1288      CALL keyword_release(keyword)
1289
1290      CALL keyword_create(keyword, __LOCATION__, name="AVEALPHA", &
1291                          description="ALPHA cell angle average", usage="AVEALPHA <REAL>", &
1292                          type_of_var=real_t, n_var=1)
1293      CALL section_add_keyword(section, keyword)
1294      CALL keyword_release(keyword)
1295
1296      CALL keyword_create(keyword, __LOCATION__, name="AVEBETA", &
1297                          description="BETA cell angle average", usage="AVEBETA <REAL>", &
1298                          type_of_var=real_t, n_var=1)
1299      CALL section_add_keyword(section, keyword)
1300      CALL keyword_release(keyword)
1301
1302      CALL keyword_create(keyword, __LOCATION__, name="AVEGAMMA", &
1303                          description="GAMMA cell angle average", usage="AVEGAMMA <REAL>", &
1304                          type_of_var=real_t, n_var=1)
1305      CALL section_add_keyword(section, keyword)
1306      CALL keyword_release(keyword)
1307
1308      CALL keyword_create(keyword, __LOCATION__, name="AVE_ECONS", &
1309                          description="CONSTANT ENERGY average", usage="AVE_ECONS <REAL>", &
1310                          type_of_var=real_t, n_var=1)
1311      CALL section_add_keyword(section, keyword)
1312      CALL keyword_release(keyword)
1313
1314      CALL keyword_create(keyword, __LOCATION__, name="AVE_PRESS", &
1315                          description="PRESSURE average", usage="AVE_PRESS <REAL>", &
1316                          type_of_var=real_t, n_var=1)
1317      CALL section_add_keyword(section, keyword)
1318      CALL keyword_release(keyword)
1319
1320      CALL keyword_create(keyword, __LOCATION__, name="AVE_PXX", &
1321                          description="P_{XX} average", usage="AVE_PXX <REAL>", &
1322                          type_of_var=real_t, n_var=1)
1323      CALL section_add_keyword(section, keyword)
1324      CALL keyword_release(keyword)
1325
1326      CALL keyword_create(keyword, __LOCATION__, name="AVE_PV_VIR", &
1327                          description="PV VIRIAL average", usage="AVE_PV_VIR <REAL> .. <REAL>", &
1328                          type_of_var=real_t, n_var=9)
1329      CALL section_add_keyword(section, keyword)
1330      CALL keyword_release(keyword)
1331
1332      CALL keyword_create(keyword, __LOCATION__, name="AVE_PV_TOT", &
1333                          description="PV TOTAL average", usage="AVE_PV_TOT <REAL> .. <REAL>", &
1334                          type_of_var=real_t, n_var=9)
1335      CALL section_add_keyword(section, keyword)
1336      CALL keyword_release(keyword)
1337
1338      CALL keyword_create(keyword, __LOCATION__, name="AVE_PV_KIN", &
1339                          description="PV KINETIC average", usage="AVE_PV_KIN <REAL> .. <REAL>", &
1340                          type_of_var=real_t, n_var=9)
1341      CALL section_add_keyword(section, keyword)
1342      CALL keyword_release(keyword)
1343
1344      CALL keyword_create(keyword, __LOCATION__, name="AVE_PV_CNSTR", &
1345                          description="PV CONSTRAINTS average", usage="AVE_PV_CNSTR <REAL> .. <REAL>", &
1346                          type_of_var=real_t, n_var=9)
1347      CALL section_add_keyword(section, keyword)
1348      CALL keyword_release(keyword)
1349
1350      CALL keyword_create(keyword, __LOCATION__, name="AVE_PV_XC", &
1351                          description="PV XC average", usage="AVE_PV_XC <REAL> .. <REAL>", &
1352                          type_of_var=real_t, n_var=9)
1353      CALL section_add_keyword(section, keyword)
1354      CALL keyword_release(keyword)
1355
1356      CALL keyword_create(keyword, __LOCATION__, name="AVE_PV_FOCK_4C", &
1357                          description="PV XC average", usage="AVE_PV_FOCK_4C <REAL> .. <REAL>", &
1358                          type_of_var=real_t, n_var=9)
1359      CALL section_add_keyword(section, keyword)
1360      CALL keyword_release(keyword)
1361
1362      CALL keyword_create(keyword, __LOCATION__, name="AVE_COLVARS", &
1363                          description="COLVARS averages", usage="AVE_COLVARS <REAL> .. <REAL>", &
1364                          type_of_var=real_t, n_var=-1)
1365      CALL section_add_keyword(section, keyword)
1366      CALL keyword_release(keyword)
1367
1368      CALL keyword_create(keyword, __LOCATION__, name="AVE_MMATRIX", &
1369                          description="METRIC TENSOR averages", usage="AVE_MMATRIX <REAL> .. <REAL>", &
1370                          type_of_var=real_t, n_var=-1)
1371      CALL section_add_keyword(section, keyword)
1372      CALL keyword_release(keyword)
1373   END SUBROUTINE create_avgs_restart_section
1374
1375! **************************************************************************************************
1376!> \brief Defines the INITIAL_VIBRATION section
1377!> \param section ...
1378!> \author Lianheng Tong
1379! **************************************************************************************************
1380   SUBROUTINE create_vib_init_section(section)
1381      TYPE(section_type), POINTER                        :: section
1382
1383      CHARACTER(len=*), PARAMETER :: routineN = 'create_vib_init_section', &
1384         routineP = moduleN//':'//routineN
1385
1386      TYPE(keyword_type), POINTER                        :: keyword
1387
1388      CPASSERT(.NOT. ASSOCIATED(section))
1389      CALL section_create(section, __LOCATION__, name="INITIAL_VIBRATION", &
1390                          description="Controls the set of parameters for MD initialisation "// &
1391                          "based on vibration analysis data. The starting atomic coordinates "// &
1392                          "should be based on the relaxed positions obtained from a previous "// &
1393                          "geometry/cell optimisation calculation, and the vibrational "// &
1394                          "frequencies and displacements data should be obtained from a "// &
1395                          "vibrational analysis calculation done based on the relaxed "// &
1396                          "coordinates. The MD initialisation process expects the user has "// &
1397                          "performed both geometry optimisation and vibrational analysis "// &
1398                          "before hand, and won't perform those calculations automatically ", &
1399                          citations=(/West2006/), &
1400                          n_keywords=0, n_subsections=1, repeats=.FALSE.)
1401      NULLIFY (keyword)
1402      CALL keyword_create(keyword, __LOCATION__, name="VIB_EIGS_FILE_NAME", &
1403                          description="The file name of vibrational frequency (eigenvalue)"// &
1404                          "and displacement (eigenvector) data calculated from the a "// &
1405                          "vibrational analysis calculation done previously. This file must "// &
1406                          "be the same unformatted binary file as referred to by "// &
1407                          "VIBRATIONAL_ANALYSIS%PRINT%CARTESIAN_EIGS keyword. If this keyword "// &
1408                          "is not explicitly defined by the user, then the default file "// &
1409                          "name of: <project_name>-<CARTESIAN_EIGS_FILENAME>.eig will be used", &
1410                          usage="VIB_EIGS_FILE_NAME <FILENAME>", &
1411                          type_of_var=lchar_t)
1412      CALL section_add_keyword(section, keyword)
1413      CALL keyword_release(keyword)
1414      NULLIFY (keyword)
1415      CALL keyword_create(keyword, __LOCATION__, name="PHASE", &
1416                          description="Controls the initial ratio of potential and kinetic "// &
1417                          "contribution to the total energy. The contribution is determined by"// &
1418                          "COS**2(2*pi*PHASE) for potential energy, and SIN**2(2*pi*PHASE) "// &
1419                          "for kinetic energy. If PHASE is negative, then for each vibration "// &
1420                          "mode the phase is determined randomly. Otherwise, PHASE must be "// &
1421                          "between 0.0 and 1.0 and will be the same for all vibration modes. "// &
1422                          "If value > 1.0 it will just be treated as 1.0. "// &
1423                          "For example, setting PHASE = 0.25 would set all modes to "// &
1424                          "begin with entirely kinetic energy --- in other words, the initial "// &
1425                          "atomic positions will remain at their optimised location", &
1426                          default_r_val=-1.0_dp, &
1427                          usage="PHASE <REAL>")
1428      CALL section_add_keyword(section, keyword)
1429      CALL keyword_release(keyword)
1430   END SUBROUTINE create_vib_init_section
1431
1432END MODULE input_cp2k_md
1433