LCOV - code coverage report
Current view: top level - src - input_cp2k_thermostats.F (source / functions) Coverage Total Hit
Test: CP2K Regtests (git:cb5d5fc) Lines: 97.7 % 257 251
Test Date: 2026-04-24 07:01:27 Functions: 100.0 % 16 16

            Line data    Source code
       1              : !--------------------------------------------------------------------------------------------------!
       2              : !   CP2K: A general program to perform molecular dynamics simulations                              !
       3              : !   Copyright 2000-2026 CP2K developers group <https://cp2k.org>                                   !
       4              : !                                                                                                  !
       5              : !   SPDX-License-Identifier: GPL-2.0-or-later                                                      !
       6              : !--------------------------------------------------------------------------------------------------!
       7              : 
       8              : ! **************************************************************************************************
       9              : !> \par History
      10              : !>      10.2005 split input_cp2k into smaller modules [fawzi]
      11              : !> \author teo & fawzi
      12              : ! **************************************************************************************************
      13              : MODULE input_cp2k_thermostats
      14              :    USE bibliography,                    ONLY: Bussi2007,&
      15              :                                               Ceriotti2009,&
      16              :                                               Ceriotti2009b,&
      17              :                                               Jones2011,&
      18              :                                               Nose1984a,&
      19              :                                               Nose1984b
      20              :    USE cp_output_handling,              ONLY: cp_print_key_section_create,&
      21              :                                               high_print_level,&
      22              :                                               low_print_level
      23              :    USE cp_units,                        ONLY: cp_unit_to_cp2k
      24              :    USE input_constants,                 ONLY: &
      25              :         do_constr_atomic, do_constr_molec, do_constr_none, do_region_defined, do_region_global, &
      26              :         do_region_massive, do_region_molecule, do_region_none, do_region_thermal, do_thermo_al, &
      27              :         do_thermo_csvr, do_thermo_gle, do_thermo_nose, do_thermo_same_as_part
      28              :    USE input_cp2k_subsys,               ONLY: create_rng_section
      29              :    USE input_keyword_types,             ONLY: keyword_create,&
      30              :                                               keyword_release,&
      31              :                                               keyword_type
      32              :    USE input_section_types,             ONLY: section_add_keyword,&
      33              :                                               section_add_subsection,&
      34              :                                               section_create,&
      35              :                                               section_release,&
      36              :                                               section_type
      37              :    USE input_val_types,                 ONLY: char_t,&
      38              :                                               integer_t,&
      39              :                                               real_t
      40              :    USE kinds,                           ONLY: dp
      41              :    USE string_utilities,                ONLY: s2a
      42              : #include "./base/base_uses.f90"
      43              : 
      44              :    IMPLICIT NONE
      45              :    PRIVATE
      46              : 
      47              :    LOGICAL, PRIVATE, PARAMETER :: debug_this_module = .TRUE.
      48              :    CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'input_cp2k_thermostats'
      49              : 
      50              :    PUBLIC :: create_thermostat_section, &
      51              :              create_thermo_fast_section, &
      52              :              create_thermo_slow_section, &
      53              :              create_coord_section, &
      54              :              create_region_section, &
      55              :              create_velocity_section, &
      56              :              create_mass_section, &
      57              :              create_gle_section
      58              : 
      59              : !***
      60              : CONTAINS
      61              : ! **************************************************************************************************
      62              : !> \brief Specifies parameter for thermostat for constant temperature ensembles
      63              : !> \param section will contain the coeff section
      64              : !> \param coupled_thermostat ...
      65              : !> \author teo [tlaino] - University of Zurich - 09.2007
      66              : ! **************************************************************************************************
      67        29986 :    SUBROUTINE create_thermo_slow_section(section, coupled_thermostat)
      68              :       TYPE(section_type), POINTER                        :: section
      69              :       LOGICAL, INTENT(IN), OPTIONAL                      :: coupled_thermostat
      70              : 
      71              :       LOGICAL                                            :: my_coupled_thermostat
      72              :       TYPE(keyword_type), POINTER                        :: keyword
      73              :       TYPE(section_type), POINTER                        :: nose_section, region_section
      74              : 
      75        29986 :       CPASSERT(.NOT. ASSOCIATED(section))
      76        29986 :       my_coupled_thermostat = .FALSE.
      77        29986 :       IF (PRESENT(coupled_thermostat)) my_coupled_thermostat = coupled_thermostat
      78        29986 :       NULLIFY (nose_section, region_section)
      79              : 
      80              :       CALL section_create(section, __LOCATION__, name="THERMOSTAT_SLOW", &
      81              :                           description="Specify thermostat type and parameters controlling the thermostat.", &
      82        29986 :                           n_keywords=1, n_subsections=0, repeats=.FALSE.)
      83        29986 :       NULLIFY (keyword)
      84              : 
      85        29986 :       IF (.NOT. my_coupled_thermostat) THEN
      86              :          CALL keyword_create(keyword, __LOCATION__, name="TYPE", &
      87              :                              description="Specify the thermostat used for the constant temperature ensembles.", &
      88              :                              usage="TYPE NOSE", &
      89              :                              default_i_val=do_thermo_nose, &
      90              :                              enum_c_vals=s2a("NOSE"), &
      91              :                              enum_i_vals=[do_thermo_nose], &
      92        29986 :                              enum_desc=s2a("Uses only the Nose-Hoover thermostat."))
      93        29986 :          CALL section_add_keyword(section, keyword)
      94        29986 :          CALL keyword_release(keyword)
      95              : 
      96              :          CALL keyword_create(keyword, __LOCATION__, name="REGION", &
      97              :                              description="Determines the defined region for slow thermostat", &
      98              :                              usage="REGION (GLOBAL||MOLECULE||MASSIVE||DEFINED||NONE)", &
      99              :                              enum_c_vals=s2a("GLOBAL", "MOLECULE", "MASSIVE", "DEFINED", "NONE"), &
     100              :                              enum_i_vals=[do_region_global, do_region_molecule, &
     101              :                                           do_region_massive, do_region_defined, do_region_none], &
     102        29986 :                              default_i_val=do_region_global)
     103        29986 :          CALL section_add_keyword(section, keyword)
     104        29986 :          CALL keyword_release(keyword)
     105              : 
     106        29986 :          CALL create_region_section(region_section, "slow thermostat")
     107        29986 :          CALL section_add_subsection(section, region_section)
     108        29986 :          CALL section_release(region_section)
     109              :       ELSE
     110              :          CALL keyword_create(keyword, __LOCATION__, name="TYPE", &
     111              :                              description="Specify the thermostat used for the constant temperature ensembles.", &
     112              :                              usage="thermostat NOSE", &
     113              :                              default_i_val=do_thermo_same_as_part, &
     114              :                              enum_c_vals=s2a("SAME_AS_PARTICLE", "NOSE", "CSVR"), &
     115              :                              enum_i_vals=[do_thermo_same_as_part, do_thermo_nose, do_thermo_csvr], &
     116              :                              enum_desc=s2a("Use the same kind of thermostat used for particles.", &
     117              :                                            "Uses the Nose-Hoover thermostat.", &
     118            0 :                                            "Uses the canonical sampling through velocity rescaling."))
     119            0 :          CALL section_add_keyword(section, keyword)
     120            0 :          CALL keyword_release(keyword)
     121              :       END IF
     122              : 
     123        29986 :       CALL create_nose_section(nose_section)
     124        29986 :       CALL section_add_subsection(section, nose_section)
     125        29986 :       CALL section_release(nose_section)
     126              : 
     127              :       ! Print Section
     128              : !       CALL create_print_section(subsection)
     129              : !       CALL section_add_subsection(section, subsection)
     130              : !       CALL section_release(subsection)
     131              : 
     132        29986 :    END SUBROUTINE create_thermo_slow_section
     133              : 
     134              : ! **************************************************************************************************
     135              : !> \brief Specifies parameter for thermostat for constant temperature ensembles
     136              : !> \param section will contain the coeff section
     137              : !> \param coupled_thermostat ...
     138              : !> \author teo [tlaino] - University of Zurich - 09.2007
     139              : ! **************************************************************************************************
     140        29986 :    SUBROUTINE create_thermo_fast_section(section, coupled_thermostat)
     141              :       TYPE(section_type), POINTER                        :: section
     142              :       LOGICAL, INTENT(IN), OPTIONAL                      :: coupled_thermostat
     143              : 
     144              :       LOGICAL                                            :: my_coupled_thermostat
     145              :       TYPE(keyword_type), POINTER                        :: keyword
     146              :       TYPE(section_type), POINTER                        :: nose_section, region_section
     147              : 
     148        29986 :       CPASSERT(.NOT. ASSOCIATED(section))
     149        29986 :       my_coupled_thermostat = .FALSE.
     150        29986 :       IF (PRESENT(coupled_thermostat)) my_coupled_thermostat = coupled_thermostat
     151        29986 :       NULLIFY (nose_section, region_section)
     152              : 
     153              :       CALL section_create(section, __LOCATION__, name="THERMOSTAT_FAST", &
     154              :                           description="Specify thermostat type and parameters controlling the thermostat.", &
     155        29986 :                           n_keywords=1, n_subsections=0, repeats=.FALSE.)
     156        29986 :       NULLIFY (keyword)
     157              : 
     158        29986 :       IF (.NOT. my_coupled_thermostat) THEN
     159              :          CALL keyword_create(keyword, __LOCATION__, name="TYPE", &
     160              :                              description="Specify the thermostat used for the constant temperature ensembles.", &
     161              :                              usage="TYPE NOSE", &
     162              :                              default_i_val=do_thermo_nose, &
     163              :                              enum_c_vals=s2a("NOSE"), &
     164              :                              enum_i_vals=[do_thermo_nose], &
     165        29986 :                              enum_desc=s2a("Uses only the Nose-Hoover thermostat."))
     166        29986 :          CALL section_add_keyword(section, keyword)
     167        29986 :          CALL keyword_release(keyword)
     168              : 
     169              :          CALL keyword_create(keyword, __LOCATION__, name="REGION", &
     170              :                              description="Determines the defined region for fast thermostat", &
     171              :                              usage="REGION (GLOBAL||MOLECULE||MASSIVE||DEFINED||NONE)", &
     172              :                              enum_c_vals=s2a("GLOBAL", "MOLECULE", "MASSIVE", "DEFINED", "NONE"), &
     173              :                              enum_i_vals=[do_region_global, do_region_molecule, &
     174              :                                           do_region_massive, do_region_defined, do_region_none], &
     175        29986 :                              default_i_val=do_region_global)
     176        29986 :          CALL section_add_keyword(section, keyword)
     177        29986 :          CALL keyword_release(keyword)
     178              : 
     179        29986 :          CALL create_region_section(region_section, "fast thermostat")
     180        29986 :          CALL section_add_subsection(section, region_section)
     181        29986 :          CALL section_release(region_section)
     182              :       ELSE
     183              :          CALL keyword_create(keyword, __LOCATION__, name="TYPE", &
     184              :                              description="Specify the thermostat used for the constant temperature ensembles.", &
     185              :                              usage="thermostat NOSE", &
     186              :                              default_i_val=do_thermo_same_as_part, &
     187              :                              enum_c_vals=s2a("SAME_AS_PARTICLE", "NOSE", "CSVR"), &
     188              :                              enum_i_vals=[do_thermo_same_as_part, do_thermo_nose, do_thermo_csvr], &
     189              :                              enum_desc=s2a("Use the same kind of thermostat used for particles.", &
     190              :                                            "Uses the Nose-Hoover thermostat.", &
     191            0 :                                            "Uses the canonical sampling through velocity rescaling."))
     192            0 :          CALL section_add_keyword(section, keyword)
     193            0 :          CALL keyword_release(keyword)
     194              :       END IF
     195              : 
     196        29986 :       CALL create_nose_section(nose_section)
     197        29986 :       CALL section_add_subsection(section, nose_section)
     198        29986 :       CALL section_release(nose_section)
     199              : 
     200              :       ! Print Section
     201              : !       CALL create_print_section(subsection)
     202              : !       CALL section_add_subsection(section, subsection)
     203              : !       CALL section_release(subsection)
     204              : 
     205        29986 :    END SUBROUTINE create_thermo_fast_section
     206              : 
     207              : ! **************************************************************************************************
     208              : !> \brief Specifies parameter for thermostat for constant temperature ensembles
     209              : !> \param section will contain the coeff section
     210              : !> \param coupled_thermostat ...
     211              : !> \author teo [tlaino] - University of Zurich - 09.2007
     212              : ! **************************************************************************************************
     213        89958 :    SUBROUTINE create_thermostat_section(section, coupled_thermostat)
     214              :       TYPE(section_type), POINTER                        :: section
     215              :       LOGICAL, INTENT(IN), OPTIONAL                      :: coupled_thermostat
     216              : 
     217              :       LOGICAL                                            :: my_coupled_thermostat
     218              :       TYPE(keyword_type), POINTER                        :: keyword
     219              :       TYPE(section_type), POINTER                        :: al_section, csvr_section, gle_section, &
     220              :                                                             nose_section, region_section, &
     221              :                                                             subsection
     222              : 
     223        89958 :       CPASSERT(.NOT. ASSOCIATED(section))
     224        89958 :       my_coupled_thermostat = .FALSE.
     225        89958 :       IF (PRESENT(coupled_thermostat)) my_coupled_thermostat = coupled_thermostat
     226        89958 :       NULLIFY (csvr_section, gle_section, al_section, nose_section, subsection, region_section)
     227              : 
     228              :       CALL section_create(section, __LOCATION__, name="THERMOSTAT", &
     229              :                           description="Specify thermostat type and parameters controlling the thermostat.", &
     230        89958 :                           n_keywords=1, n_subsections=0, repeats=.FALSE.)
     231        89958 :       NULLIFY (keyword)
     232              : 
     233        89958 :       IF (.NOT. my_coupled_thermostat) THEN
     234              :          CALL keyword_create(keyword, __LOCATION__, name="TYPE", &
     235              :                              description="Specify the thermostat used for the constant temperature ensembles.", &
     236              :                              usage="TYPE NOSE", &
     237              :                              default_i_val=do_thermo_nose, &
     238              :                              enum_c_vals=s2a("NOSE", "CSVR", "GLE", "AD_LANGEVIN"), &
     239              :                              enum_i_vals=[do_thermo_nose, &
     240              :                                           do_thermo_csvr, do_thermo_gle, do_thermo_al], &
     241              :                              enum_desc=s2a("Uses the Nose-Hoover thermostat.", &
     242              :                                            "Uses the canonical sampling through velocity rescaling.", &
     243              :                                            "Uses GLE thermostat", &
     244        59972 :                                            "Uses adaptive-Langevin thermostat"))
     245        59972 :          CALL section_add_keyword(section, keyword)
     246        59972 :          CALL keyword_release(keyword)
     247              : 
     248              :          CALL keyword_create(keyword, __LOCATION__, name="REGION", &
     249              :                              description="Determines the region each thermostat is attached to.", &
     250              :                              usage="REGION (GLOBAL|MOLECULE|MASSIVE|DEFINED|THERMAL|NONE)", &
     251              :                              enum_c_vals=s2a("GLOBAL", "MOLECULE", "MASSIVE", "DEFINED", "THERMAL", "NONE"), &
     252              :                              enum_i_vals=[do_region_global, do_region_molecule, do_region_massive, &
     253              :                                           do_region_defined, do_region_thermal, do_region_none], &
     254              :                              enum_desc=s2a("Apply one thermostat to the whole system (default)", &
     255              :                                            "Apply one thermostat to each molecule kind", &
     256              :                                            "Apply one thermostat to each degree of freedom", &
     257              :                                            "Apply one thermostat to each defined region from THERMOSTAT/DEFINE_REGION", &
     258              :                                            "Apply one thermostat to each defined region from THERMAL_REGION/DEFINE_REGION", &
     259              :                                            "No thermostat is applied"), &
     260        59972 :                              default_i_val=do_region_global)
     261        59972 :          CALL section_add_keyword(section, keyword)
     262        59972 :          CALL keyword_release(keyword)
     263              : 
     264        59972 :          CALL create_region_section(region_section, "thermostat")
     265        59972 :          CALL section_add_subsection(section, region_section)
     266        59972 :          CALL section_release(region_section)
     267              :       ELSE
     268              :          CALL keyword_create(keyword, __LOCATION__, name="TYPE", &
     269              :                              description="Specify the thermostat used for the constant temperature ensembles.", &
     270              :                              usage="TYPE NOSE", &
     271              :                              default_i_val=do_thermo_same_as_part, &
     272              :                              enum_c_vals=s2a("SAME_AS_PARTICLE", "NOSE", "CSVR"), &
     273              :                              enum_i_vals=[do_thermo_same_as_part, do_thermo_nose, do_thermo_csvr], &
     274              :                              enum_desc=s2a("Use the same kind of thermostat used for particles.", &
     275              :                                            "Uses the Nose-Hoover thermostat.", &
     276        29986 :                                            "Uses the canonical sampling through velocity rescaling."))
     277        29986 :          CALL section_add_keyword(section, keyword)
     278        29986 :          CALL keyword_release(keyword)
     279              :       END IF
     280              : 
     281        89958 :       CALL create_nose_section(nose_section)
     282        89958 :       CALL section_add_subsection(section, nose_section)
     283        89958 :       CALL section_release(nose_section)
     284              : 
     285        89958 :       CALL create_csvr_section(csvr_section)
     286        89958 :       CALL section_add_subsection(section, csvr_section)
     287        89958 :       CALL section_release(csvr_section)
     288              : 
     289        89958 :       CALL create_gle_section(gle_section)
     290        89958 :       CALL section_add_subsection(section, gle_section)
     291        89958 :       CALL section_release(gle_section)
     292              : 
     293        89958 :       CALL create_al_section(al_section)
     294        89958 :       CALL section_add_subsection(section, al_section)
     295        89958 :       CALL section_release(al_section)
     296              : 
     297              :       ! Print Section
     298        89958 :       CALL create_print_section(subsection)
     299        89958 :       CALL section_add_subsection(section, subsection)
     300        89958 :       CALL section_release(subsection)
     301              : 
     302        89958 :    END SUBROUTINE create_thermostat_section
     303              : 
     304              : ! **************************************************************************************************
     305              : !> \brief Creates print section for thermostat section
     306              : !> \param section ...
     307              : !> \author teo [tlaino] - University of Zurich - 02.2008
     308              : ! **************************************************************************************************
     309        89958 :    SUBROUTINE create_print_section(section)
     310              :       TYPE(section_type), POINTER                        :: section
     311              : 
     312              :       TYPE(section_type), POINTER                        :: print_key
     313              : 
     314        89958 :       CPASSERT(.NOT. ASSOCIATED(section))
     315        89958 :       NULLIFY (print_key)
     316              :       CALL section_create(section, __LOCATION__, name="PRINT", &
     317              :                           description="Collects all print_keys for thermostat", &
     318        89958 :                           n_keywords=1, n_subsections=0, repeats=.FALSE.)
     319              : 
     320              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "THERMOSTAT_INFO", &
     321              :                                        description="Controls output information of the corresponding thermostat.", &
     322              :                                        print_level=low_print_level, common_iter_levels=1, &
     323        89958 :                                        filename="__STD_OUT__")
     324        89958 :       CALL section_add_subsection(section, print_key)
     325        89958 :       CALL section_release(print_key)
     326              : 
     327              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "TEMPERATURE", &
     328              :                                        description="Controls the output of the temperatures of the regions corresponding to "// &
     329              :                                        "the present thermostat", &
     330              :                                        print_level=high_print_level, common_iter_levels=1, &
     331        89958 :                                        filename="")
     332        89958 :       CALL section_add_subsection(section, print_key)
     333        89958 :       CALL section_release(print_key)
     334              : 
     335              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "ENERGY", &
     336              :                                        description="Controls the output of kinetic energy, and potential energy "// &
     337              :                                        "of the defined thermostat.", print_level=high_print_level, common_iter_levels=1, &
     338        89958 :                                        filename="")
     339        89958 :       CALL section_add_subsection(section, print_key)
     340        89958 :       CALL section_release(print_key)
     341        89958 :    END SUBROUTINE create_print_section
     342              : 
     343              : ! **************************************************************************************************
     344              : !> \brief Creates a section to arbitrary define a region to thermostat
     345              : !> \param section will contain the coeff section
     346              : !> \param label ...
     347              : !> \author teo
     348              : ! **************************************************************************************************
     349       149930 :    SUBROUTINE create_region_section(section, label)
     350              :       TYPE(section_type), POINTER                        :: section
     351              :       CHARACTER(LEN=*), INTENT(IN)                       :: label
     352              : 
     353              :       TYPE(keyword_type), POINTER                        :: keyword
     354              : 
     355       149930 :       CPASSERT(.NOT. ASSOCIATED(section))
     356              : 
     357              :       CALL section_create(section, __LOCATION__, name="DEFINE_REGION", &
     358              :                           description="This section provides the possibility to define arbitrary region "// &
     359              :                           "for the "//TRIM(label)//".", &
     360       149930 :                           n_keywords=1, n_subsections=0, repeats=.TRUE.)
     361              : 
     362       149930 :       NULLIFY (keyword)
     363              :       CALL keyword_create(keyword, __LOCATION__, name="LIST", &
     364              :                           description="Specifies a list of atoms to thermostat.", &
     365              :                           usage="LIST {integer} {integer} .. {integer}", repeats=.TRUE., &
     366       149930 :                           n_var=-1, type_of_var=integer_t)
     367       149930 :       CALL section_add_keyword(section, keyword)
     368       149930 :       CALL keyword_release(keyword)
     369              : 
     370              :       CALL keyword_create(keyword, __LOCATION__, name="MOLNAME", &
     371              :                           variants=["SEGNAME"], &
     372              :                           description="Specifies the name of the molecules to thermostat", &
     373              :                           usage="MOLNAME WAT MEOH", repeats=.TRUE., &
     374       299860 :                           n_var=-1, type_of_var=char_t)
     375       149930 :       CALL section_add_keyword(section, keyword)
     376       149930 :       CALL keyword_release(keyword)
     377              : 
     378              :       CALL keyword_create(keyword, __LOCATION__, name="MM_SUBSYS", &
     379              :                           variants=["PROTEIN"], &
     380              :                           description="In a QM/MM run all  MM atoms are specified as a whole ensemble to be thermostated", &
     381              :                           usage="MM_SUBSYS (NONE|ATOMIC|MOLECULAR)", &
     382              :                           enum_c_vals=s2a("NONE", "ATOMIC", "MOLECULAR"), &
     383              :                           enum_i_vals=[do_constr_none, do_constr_atomic, do_constr_molec], &
     384              :                           enum_desc=s2a("Thermostat nothing", &
     385              :                                         "Only the MM atoms itself", &
     386              :                                         "The full molecule/residue that contains a MM atom"), &
     387       299860 :                           default_i_val=do_constr_none, repeats=.FALSE.)
     388       149930 :       CALL section_add_keyword(section, keyword)
     389       149930 :       CALL keyword_release(keyword)
     390              : 
     391              :       CALL keyword_create(keyword, __LOCATION__, name="QM_SUBSYS", &
     392              :                           description="In a QM/MM run all QM atoms are specified as a whole ensemble to be thermostated", &
     393              :                           usage="QM_SUBSYS (NONE|ATOMIC|MOLECULAR)", &
     394              :                           enum_c_vals=s2a("NONE", "ATOMIC", "MOLECULAR"), &
     395              :                           enum_desc=s2a("Thermostat nothing", &
     396              :                                         "Only the QM atoms itself", &
     397              :                                         "The full molecule/residue that contains a QM atom"), &
     398              :                           enum_i_vals=[do_constr_none, do_constr_atomic, do_constr_molec], &
     399       149930 :                           default_i_val=do_constr_none, repeats=.FALSE.)
     400       149930 :       CALL section_add_keyword(section, keyword)
     401       149930 :       CALL keyword_release(keyword)
     402              : 
     403       149930 :    END SUBROUTINE create_region_section
     404              : 
     405              : ! **************************************************************************************************
     406              : !> \brief ...
     407              : !> \param section will contain the ewald section
     408              : !> \author gloria
     409              : ! **************************************************************************************************
     410       149930 :    SUBROUTINE create_nose_section(section)
     411              :       TYPE(section_type), POINTER                        :: section
     412              : 
     413              :       TYPE(keyword_type), POINTER                        :: keyword
     414              :       TYPE(section_type), POINTER                        :: subsection
     415              : 
     416       149930 :       CPASSERT(.NOT. ASSOCIATED(section))
     417              :       CALL section_create(section, __LOCATION__, name="nose", &
     418              :                           description="paramameters of the Nose Hoover thermostat chain", &
     419       449790 :                           citations=[Nose1984a, Nose1984b])
     420              : 
     421       149930 :       NULLIFY (keyword, subsection)
     422              :       CALL keyword_create(keyword, __LOCATION__, name="length", &
     423              :                           description="length of the Nose-Hoover chain", usage="length integer", &
     424       149930 :                           default_i_val=3)
     425       149930 :       CALL section_add_keyword(section, keyword)
     426       149930 :       CALL keyword_release(keyword)
     427              : 
     428              :       CALL keyword_create(keyword, __LOCATION__, name="Yoshida", &
     429              :                           description="order of the yoshida integrator used for the thermostat", &
     430              :                           usage="Yoshida integer", &
     431       149930 :                           default_i_val=3)
     432       149930 :       CALL section_add_keyword(section, keyword)
     433       149930 :       CALL keyword_release(keyword)
     434              : 
     435              :       CALL keyword_create(keyword, __LOCATION__, name="timecon", &
     436              :                           description="timeconstant of the thermostat chain", &
     437              :                           usage="timecon <REAL>", &
     438              :                           default_r_val=cp_unit_to_cp2k(1000.0_dp, "fs"), &
     439       149930 :                           unit_str="fs")
     440       149930 :       CALL section_add_keyword(section, keyword)
     441       149930 :       CALL keyword_release(keyword)
     442              : 
     443              :       CALL keyword_create(keyword, __LOCATION__, name="mts", &
     444              :                           variants=s2a("multiple_time_steps", "mult_t_steps"), &
     445              :                           description="number of multiple timesteps to be used for the NoseHoover chain", &
     446              :                           usage="mts integer", &
     447       149930 :                           default_i_val=2)
     448       149930 :       CALL section_add_keyword(section, keyword)
     449       149930 :       CALL keyword_release(keyword)
     450              : 
     451       149930 :       CALL create_coord_section(subsection, "NOSE HOOVER")
     452       149930 :       CALL section_add_subsection(section, subsection)
     453       149930 :       CALL section_release(subsection)
     454              : 
     455       149930 :       CALL create_velocity_section(subsection, "NOSE HOOVER")
     456       149930 :       CALL section_add_subsection(section, subsection)
     457       149930 :       CALL section_release(subsection)
     458              : 
     459       149930 :       CALL create_mass_section(subsection, "NOSE HOOVER")
     460       149930 :       CALL section_add_subsection(section, subsection)
     461       149930 :       CALL section_release(subsection)
     462              : 
     463       149930 :       CALL create_force_section(subsection, "NOSE HOOVER")
     464       149930 :       CALL section_add_subsection(section, subsection)
     465       149930 :       CALL section_release(subsection)
     466              : 
     467       149930 :    END SUBROUTINE create_nose_section
     468              : 
     469              : ! **************************************************************************************************
     470              : !> \brief ...
     471              : !> \param section ...
     472              : !> \param
     473              : !> \author
     474              : ! **************************************************************************************************
     475        99540 :    SUBROUTINE create_gle_section(section)
     476              :       TYPE(section_type), POINTER                        :: section
     477              : 
     478              :       TYPE(keyword_type), POINTER                        :: keyword
     479              :       TYPE(section_type), POINTER                        :: subsection
     480              : 
     481        99540 :       CPASSERT(.NOT. ASSOCIATED(section))
     482              :       CALL section_create(section, __LOCATION__, name="GLE", &
     483              :                           description="paramameters of the gle thermostat. This section can be generated "// &
     484              :                           "from <https://gle4md.org/index.html?page=matrix>.", &
     485       298620 :                           citations=[Ceriotti2009, Ceriotti2009b])
     486              : 
     487        99540 :       NULLIFY (keyword, subsection)
     488              : 
     489              :       CALL keyword_create(keyword, __LOCATION__, name="NDIM", &
     490              :                           description="Size of the gle matrix", usage="NDIM 6", &
     491        99540 :                           default_i_val=5)
     492        99540 :       CALL section_add_keyword(section, keyword)
     493        99540 :       CALL keyword_release(keyword)
     494              : 
     495              :       CALL keyword_create(keyword, __LOCATION__, name="A_SCALE", &
     496              :                           description="scaling factor for matrix A (for generic matrix A, depends "// &
     497              :                           "on the characteristic frequency of the system).", usage="A_SCALE 0.5", &
     498        99540 :                           default_r_val=cp_unit_to_cp2k(1.0_dp, "ps^-1"), unit_str="ps^-1")
     499        99540 :       CALL section_add_keyword(section, keyword)
     500        99540 :       CALL keyword_release(keyword)
     501              : 
     502              :       CALL keyword_create(keyword, __LOCATION__, name="A_LIST", &
     503              :                           description="A matrix The defaults give optimal sampling for most "// &
     504              :                           "cristalline and liquid compounds. Generated with the parameters set kv_4-4.a "// &
     505              :                           "centered on w_0=40 cm^-1.", usage="A_LIST real real real", &
     506              :                           type_of_var=real_t, unit_str="internal_cp2k", &
     507        99540 :                           n_var=-1, repeats=.TRUE.)
     508              : !             default_r_vals=(/ &
     509              : !    1.859575861256e+2_dp,  2.726385349840e-1_dp,  1.152610045461e+1_dp, -3.641457826260e+1_dp,  2.317337581602e+2_dp, &
     510              : !   -2.780952471206e-1_dp,  8.595159180871e-5_dp,  7.218904801765e-1_dp, -1.984453934386e-1_dp,  4.240925758342e-1_dp, &
     511              : !   -1.482580813121e+1_dp, -7.218904801765e-1_dp,  1.359090212128e+0_dp,  5.149889628035e+0_dp, -9.994926845099e+0_dp, &
     512              : !   -1.037218912688e+1_dp,  1.984453934386e-1_dp, -5.149889628035e+0_dp,  2.666191089117e+1_dp,  1.150771549531e+1_dp, &
     513              : !    2.180134636042e+2_dp, -4.240925758342e-1_dp,  9.994926845099e+0_dp, -1.150771549531e+1_dp,  3.095839456559e+2_dp /), &
     514        99540 :       CALL section_add_keyword(section, keyword)
     515        99540 :       CALL keyword_release(keyword)
     516              : 
     517              :       CALL keyword_create(keyword, __LOCATION__, name="C_LIST", &
     518              :                           description="C matrix", usage="C_LIST real real real", &
     519              :                           unit_str="K_e", &
     520        99540 :                           type_of_var=real_t, n_var=-1, repeats=.TRUE.)
     521        99540 :       CALL section_add_keyword(section, keyword)
     522        99540 :       CALL keyword_release(keyword)
     523              : 
     524        99540 :       CALL create_thermo_energy_section(subsection)
     525        99540 :       CALL section_add_subsection(section, subsection)
     526        99540 :       CALL section_release(subsection)
     527              : 
     528        99540 :       CALL create_rng_section(subsection)
     529        99540 :       CALL section_add_subsection(section, subsection)
     530        99540 :       CALL section_release(subsection)
     531              : 
     532        99540 :       CALL create_gles_section(subsection)
     533        99540 :       CALL section_add_subsection(section, subsection)
     534        99540 :       CALL section_release(subsection)
     535              : 
     536        99540 :    END SUBROUTINE create_gle_section
     537              : 
     538              : ! **************************************************************************************************
     539              : !> \brief Creates the gles section
     540              : !> \param section the section to create
     541              : !> \author teo
     542              : ! **************************************************************************************************
     543        99540 :    SUBROUTINE create_gles_section(section)
     544              :       TYPE(section_type), POINTER                        :: section
     545              : 
     546              :       TYPE(keyword_type), POINTER                        :: keyword
     547              : 
     548        99540 :       CPASSERT(.NOT. ASSOCIATED(section))
     549              :       CALL section_create(section, __LOCATION__, name="s", &
     550              :                           description="The s variable for GLE used for restart", &
     551        99540 :                           n_keywords=1, n_subsections=0, repeats=.FALSE.)
     552        99540 :       NULLIFY (keyword)
     553              : 
     554              :       CALL keyword_create(keyword, __LOCATION__, name="_DEFAULT_KEYWORD_", &
     555              :                           description="Specify s variable for GLE thermostat ", repeats=.FALSE., &
     556        99540 :                           usage="{Real} ...", type_of_var=real_t, n_var=-1)
     557        99540 :       CALL section_add_keyword(section, keyword)
     558        99540 :       CALL keyword_release(keyword)
     559              : 
     560        99540 :    END SUBROUTINE create_gles_section
     561              : 
     562              : ! **************************************************************************************************
     563              : !> \brief ...
     564              : !> \param section will contain the ewald section
     565              : !> \author teo [tlaino] - University of Zurich - 09.2007
     566              : ! **************************************************************************************************
     567        89958 :    SUBROUTINE create_csvr_section(section)
     568              :       TYPE(section_type), POINTER                        :: section
     569              : 
     570              :       TYPE(keyword_type), POINTER                        :: keyword
     571              :       TYPE(section_type), POINTER                        :: subsection
     572              : 
     573        89958 :       CPASSERT(.NOT. ASSOCIATED(section))
     574              :       CALL section_create(section, __LOCATION__, name="csvr", &
     575              :                           description="Parameters of the canonical sampling through velocity rescaling thermostat.", &
     576       179916 :                           citations=[Bussi2007])
     577              : 
     578        89958 :       NULLIFY (keyword, subsection)
     579              : 
     580              :       CALL keyword_create(keyword, __LOCATION__, name="timecon", &
     581              :                           description="Time constant of the CSVR thermostat. A small time "// &
     582              :                           "constant will result in strong thermostatting (useful for "// &
     583              :                           "initial equilibrations) and a large time constant would be adequate "// &
     584              :                           "to get weak thermostatting in production runs.", &
     585              :                           usage="timecon <REAL>", &
     586              :                           default_r_val=cp_unit_to_cp2k(1000.0_dp, "fs"), &
     587        89958 :                           unit_str="fs")
     588        89958 :       CALL section_add_keyword(section, keyword)
     589        89958 :       CALL keyword_release(keyword)
     590              : 
     591        89958 :       CALL create_thermo_energy_section(subsection)
     592        89958 :       CALL section_add_subsection(section, subsection)
     593        89958 :       CALL section_release(subsection)
     594              : 
     595        89958 :       CALL create_rng_section(subsection)
     596        89958 :       CALL section_add_subsection(section, subsection)
     597        89958 :       CALL section_release(subsection)
     598              : 
     599        89958 :    END SUBROUTINE create_csvr_section
     600              : 
     601              : ! **************************************************************************************************
     602              : !> \brief ...
     603              : !> \param section will contain the adaptive langevin section
     604              : !> \author Noam [bernstei]
     605              : ! **************************************************************************************************
     606        89958 :    SUBROUTINE create_al_section(section)
     607              :       TYPE(section_type), POINTER                        :: section
     608              : 
     609              :       TYPE(keyword_type), POINTER                        :: keyword
     610              :       TYPE(section_type), POINTER                        :: subsection
     611              : 
     612        89958 :       CPASSERT(.NOT. ASSOCIATED(section))
     613              :       CALL section_create(section, __LOCATION__, name="ad_langevin", &
     614              :                           description="Parameters of the adaptive-Langevin thermostat."// &
     615              :                           " Known to work with NVT ensemble, but not tested with"// &
     616              :                           " other ensembles.  Also tested with FIXED_ATOMS constraints, but"// &
     617              :                           " may not work with other constraints (restraints should be OK, but"// &
     618              :                           " haven't been well tested)", &
     619       179916 :                           citations=[Jones2011])
     620              : 
     621        89958 :       NULLIFY (keyword, subsection)
     622              : 
     623              :       CALL keyword_create(keyword, __LOCATION__, name="timecon_nh", &
     624              :                           description="Time constant of the Nose-Hoover part of the AD_LANGEVIN thermostat. A small time "// &
     625              :                           "constant will result in strong thermostatting (useful for "// &
     626              :                           "initial equilibrations) and a large time constant would be adequate "// &
     627              :                           "to get weak thermostatting in production runs.", &
     628              :                           usage="timecon_nh <REAL>", &
     629              :                           default_r_val=cp_unit_to_cp2k(1000.0_dp, "fs"), &
     630        89958 :                           unit_str="fs")
     631        89958 :       CALL section_add_keyword(section, keyword)
     632        89958 :       CALL keyword_release(keyword)
     633              : 
     634              :       CALL keyword_create(keyword, __LOCATION__, name="timecon_langevin", &
     635              :                           description="Time constant of the Langevin part of the AD_LANGEVIN thermostat. A small time "// &
     636              :                           "constant will result in strong thermostatting (useful for "// &
     637              :                           "initial equilibrations) and a large time constant would be adequate "// &
     638              :                           "to get weak thermostatting in production runs.", &
     639              :                           usage="timecon_langevin <REAL>", &
     640              :                           default_r_val=cp_unit_to_cp2k(1000.0_dp, "fs"), &
     641        89958 :                           unit_str="fs")
     642        89958 :       CALL section_add_keyword(section, keyword)
     643        89958 :       CALL keyword_release(keyword)
     644              : 
     645        89958 :       CALL create_thermo_chi_mass_section(subsection, "CHI")
     646        89958 :       CALL section_add_subsection(section, subsection)
     647        89958 :       CALL section_release(subsection)
     648              : 
     649        89958 :       CALL create_thermo_chi_mass_section(subsection, "MASS")
     650        89958 :       CALL section_add_subsection(section, subsection)
     651        89958 :       CALL section_release(subsection)
     652              : 
     653        89958 :    END SUBROUTINE create_al_section
     654              : 
     655              : ! **************************************************************************************************
     656              : !> \brief Creates the thermostat chi restarting section
     657              : !> \param section the section to create
     658              : !> \param sec_name ...
     659              : !> \author teo
     660              : ! **************************************************************************************************
     661       179916 :    SUBROUTINE create_thermo_chi_mass_section(section, sec_name)
     662              :       TYPE(section_type), POINTER                        :: section
     663              :       CHARACTER(len=*)                                   :: sec_name
     664              : 
     665              :       TYPE(keyword_type), POINTER                        :: keyword
     666              : 
     667       179916 :       CPASSERT(.NOT. ASSOCIATED(section))
     668              :       CALL section_create(section, __LOCATION__, name=TRIM(sec_name), &
     669              :                           description="Information to initialize the Ad-Langevin thermostat DOF "//TRIM(sec_name), &
     670       179916 :                           n_keywords=1, n_subsections=0, repeats=.FALSE.)
     671       179916 :       NULLIFY (keyword)
     672              : 
     673              :       CALL keyword_create(keyword, __LOCATION__, name="_DEFAULT_KEYWORD_", &
     674              :                           description="Specify an initial thermostat DOF "//TRIM(sec_name)// &
     675              :                           " for Ad-Langevin thermostat.", repeats=.TRUE., &
     676       179916 :                           unit_str="fs^-1", type_of_var=real_t)
     677       179916 :       CALL section_add_keyword(section, keyword)
     678       179916 :       CALL keyword_release(keyword)
     679              : 
     680       179916 :    END SUBROUTINE create_thermo_chi_mass_section
     681              : 
     682              : ! **************************************************************************************************
     683              : !> \brief Creates the thermostat energy restarting section
     684              : !> \param section the section to create
     685              : !> \author teo
     686              : ! **************************************************************************************************
     687       189498 :    SUBROUTINE create_thermo_energy_section(section)
     688              :       TYPE(section_type), POINTER                        :: section
     689              : 
     690              :       TYPE(keyword_type), POINTER                        :: keyword
     691              : 
     692       189498 :       CPASSERT(.NOT. ASSOCIATED(section))
     693              :       CALL section_create(section, __LOCATION__, name="THERMOSTAT_ENERGY", &
     694              :                           description="Information to initialize the CSVR thermostat energy.", &
     695       189498 :                           n_keywords=1, n_subsections=0, repeats=.FALSE.)
     696       189498 :       NULLIFY (keyword)
     697              : 
     698              :       CALL keyword_create(keyword, __LOCATION__, name="_DEFAULT_KEYWORD_", &
     699              :                           description="Specify an initial thermostat energy for CSVR thermostat.", &
     700       189498 :                           repeats=.TRUE., unit_str="internal_cp2k", type_of_var=real_t)
     701       189498 :       CALL section_add_keyword(section, keyword)
     702       189498 :       CALL keyword_release(keyword)
     703              : 
     704       189498 :    END SUBROUTINE create_thermo_energy_section
     705              : 
     706              : ! **************************************************************************************************
     707              : !> \brief Creates the mass section
     708              : !> \param section the section to create
     709              : !> \param name ...
     710              : !> \author teo
     711              : ! **************************************************************************************************
     712       149930 :    SUBROUTINE create_force_section(section, name)
     713              :       TYPE(section_type), POINTER                        :: section
     714              :       CHARACTER(LEN=*), INTENT(IN)                       :: name
     715              : 
     716              :       TYPE(keyword_type), POINTER                        :: keyword
     717              : 
     718       149930 :       CPASSERT(.NOT. ASSOCIATED(section))
     719              :       CALL section_create(section, __LOCATION__, name="force", &
     720              :                           description="The forces for "//TRIM(name)//" used for restart", &
     721       149930 :                           n_keywords=1, n_subsections=0, repeats=.FALSE.)
     722       149930 :       NULLIFY (keyword)
     723              : 
     724              :       CALL keyword_create(keyword, __LOCATION__, name="_DEFAULT_KEYWORD_", &
     725              :                           description="Specify masses of the system", repeats=.FALSE., &
     726       149930 :                           usage="{Real} ...", type_of_var=real_t, n_var=-1)
     727       149930 :       CALL section_add_keyword(section, keyword)
     728       149930 :       CALL keyword_release(keyword)
     729              : 
     730       149930 :    END SUBROUTINE create_force_section
     731              : 
     732              : ! **************************************************************************************************
     733              : !> \brief Creates the mass section
     734              : !> \param section the section to create
     735              : !> \param name ...
     736              : !> \author teo
     737              : ! **************************************************************************************************
     738       179916 :    SUBROUTINE create_mass_section(section, name)
     739              :       TYPE(section_type), POINTER                        :: section
     740              :       CHARACTER(LEN=*), INTENT(IN)                       :: name
     741              : 
     742              :       TYPE(keyword_type), POINTER                        :: keyword
     743              : 
     744       179916 :       CPASSERT(.NOT. ASSOCIATED(section))
     745              :       CALL section_create(section, __LOCATION__, name="mass", &
     746              :                           description="The masses for "//TRIM(name)//" used for restart", &
     747       179916 :                           n_keywords=1, n_subsections=0, repeats=.FALSE.)
     748       179916 :       NULLIFY (keyword)
     749              : 
     750              :       CALL keyword_create(keyword, __LOCATION__, name="_DEFAULT_KEYWORD_", &
     751              :                           description="Specify masses of the system", repeats=.FALSE., &
     752       179916 :                           usage="{Real} ...", type_of_var=real_t, n_var=-1)
     753       179916 :       CALL section_add_keyword(section, keyword)
     754       179916 :       CALL keyword_release(keyword)
     755              : 
     756       179916 :    END SUBROUTINE create_mass_section
     757              : 
     758              : ! **************************************************************************************************
     759              : !> \brief Creates the velocity section
     760              : !> \param section the section to create
     761              : !> \param name ...
     762              : !> \author teo
     763              : ! **************************************************************************************************
     764       208951 :    SUBROUTINE create_velocity_section(section, name)
     765              :       TYPE(section_type), POINTER                        :: section
     766              :       CHARACTER(LEN=*), INTENT(IN)                       :: name
     767              : 
     768              :       TYPE(keyword_type), POINTER                        :: keyword
     769              : 
     770       208951 :       CPASSERT(.NOT. ASSOCIATED(section))
     771              :       CALL section_create(section, __LOCATION__, name="velocity", &
     772              :                           description="The velocities for "//TRIM(name)//" used for restart", &
     773       208951 :                           n_keywords=1, n_subsections=0, repeats=.FALSE.)
     774       208951 :       NULLIFY (keyword)
     775              : 
     776              :       CALL keyword_create(keyword, __LOCATION__, name="_DEFAULT_KEYWORD_", &
     777              :                           description="Specify velocities of the system", repeats=.TRUE., &
     778       208951 :                           usage="{Real} ...", type_of_var=real_t, n_var=-1)
     779       208951 :       CALL section_add_keyword(section, keyword)
     780       208951 :       CALL keyword_release(keyword)
     781              : 
     782       208951 :    END SUBROUTINE create_velocity_section
     783              : 
     784              : ! **************************************************************************************************
     785              : !> \brief Creates the coord section
     786              : !> \param section the section to create
     787              : !> \param name ...
     788              : !> \author teo
     789              : ! **************************************************************************************************
     790       188547 :    SUBROUTINE create_coord_section(section, name)
     791              :       TYPE(section_type), POINTER                        :: section
     792              :       CHARACTER(LEN=*), INTENT(IN)                       :: name
     793              : 
     794              :       TYPE(keyword_type), POINTER                        :: keyword
     795              : 
     796       188547 :       CPASSERT(.NOT. ASSOCIATED(section))
     797              :       CALL section_create(section, __LOCATION__, name="coord", &
     798              :                           description="The positions for "//TRIM(name)//" used for restart", &
     799       188547 :                           n_keywords=1, n_subsections=0, repeats=.FALSE.)
     800       188547 :       NULLIFY (keyword)
     801              : 
     802              :       CALL keyword_create(keyword, __LOCATION__, name="_DEFAULT_KEYWORD_", &
     803              :                           description="Specify positions of the system", repeats=.TRUE., &
     804       188547 :                           usage="{Real} ...", type_of_var=real_t, n_var=-1)
     805       188547 :       CALL section_add_keyword(section, keyword)
     806       188547 :       CALL keyword_release(keyword)
     807              : 
     808       188547 :    END SUBROUTINE create_coord_section
     809              : 
     810              : END MODULE input_cp2k_thermostats
        

Generated by: LCOV version 2.0-1