LCOV - code coverage report
Current view: top level - src/motion/thermostat - input_cp2k_barostats.F (source / functions) Hit Total Coverage
Test: CP2K Regtests (git:4dc10b3) Lines: 40 40 100.0 %
Date: 2024-11-21 06:45:46 Functions: 2 2 100.0 %

          Line data    Source code
       1             : !--------------------------------------------------------------------------------------------------!
       2             : !   CP2K: A general program to perform molecular dynamics simulations                              !
       3             : !   Copyright 2000-2024 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_barostats
      14             :    USE barostat_types,                  ONLY: do_clv_x,&
      15             :                                               do_clv_xy,&
      16             :                                               do_clv_xyz,&
      17             :                                               do_clv_xz,&
      18             :                                               do_clv_y,&
      19             :                                               do_clv_yz,&
      20             :                                               do_clv_z
      21             :    USE cp_output_handling,              ONLY: cp_print_key_section_create,&
      22             :                                               high_print_level
      23             :    USE cp_units,                        ONLY: cp_unit_to_cp2k
      24             :    USE input_cp2k_thermostats,          ONLY: create_mass_section,&
      25             :                                               create_thermostat_section,&
      26             :                                               create_velocity_section
      27             :    USE input_keyword_types,             ONLY: keyword_create,&
      28             :                                               keyword_release,&
      29             :                                               keyword_type
      30             :    USE input_section_types,             ONLY: section_add_keyword,&
      31             :                                               section_add_subsection,&
      32             :                                               section_create,&
      33             :                                               section_release,&
      34             :                                               section_type
      35             :    USE input_val_types,                 ONLY: real_t
      36             :    USE kinds,                           ONLY: dp
      37             :    USE string_utilities,                ONLY: s2a
      38             : #include "../../base/base_uses.f90"
      39             : 
      40             :    IMPLICIT NONE
      41             :    PRIVATE
      42             : 
      43             :    LOGICAL, PRIVATE, PARAMETER :: debug_this_module = .TRUE.
      44             :    CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'input_cp2k_barostats'
      45             : 
      46             :    PUBLIC :: create_barostat_section
      47             : 
      48             : !***
      49             : CONTAINS
      50             : 
      51             : ! **************************************************************************************************
      52             : !> \brief ...
      53             : !> \param section will contain the coeff section
      54             : !> \author teo
      55             : ! **************************************************************************************************
      56       28669 :    SUBROUTINE create_barostat_section(section)
      57             :       TYPE(section_type), POINTER                        :: section
      58             : 
      59             :       TYPE(keyword_type), POINTER                        :: keyword
      60             :       TYPE(section_type), POINTER                        :: subsection, thermo_section
      61             : 
      62       28669 :       CPASSERT(.NOT. ASSOCIATED(section))
      63             :       CALL section_create(section, __LOCATION__, name="barostat", &
      64             :                           description="Parameters of barostat.", &
      65       28669 :                           n_keywords=1, n_subsections=0, repeats=.FALSE.)
      66             : 
      67       28669 :       NULLIFY (keyword, subsection, thermo_section)
      68             :       CALL keyword_create(keyword, __LOCATION__, name="PRESSURE", &
      69             :                           description="Initial pressure", &
      70             :                           usage="PRESSURE real", &
      71       28669 :                           default_r_val=0._dp, unit_str='bar')
      72       28669 :       CALL section_add_keyword(section, keyword)
      73       28669 :       CALL keyword_release(keyword)
      74             : 
      75             :       CALL keyword_create(keyword, __LOCATION__, name="TIMECON", &
      76             :                           description="Barostat time constant", &
      77             :                           usage="TIMECON real", &
      78             :                           default_r_val=cp_unit_to_cp2k(1000.0_dp, "fs"), &
      79       28669 :                           unit_str='fs')
      80       28669 :       CALL section_add_keyword(section, keyword)
      81       28669 :       CALL keyword_release(keyword)
      82             : 
      83             :       CALL keyword_create(keyword, __LOCATION__, name="TEMPERATURE", &
      84             :                           description="Barostat initial temperature. If not set, the ensemble temperature is used instead.", &
      85             :                           usage="TEMPERATURE real", type_of_var=real_t, &
      86       28669 :                           unit_str='K')
      87       28669 :       CALL section_add_keyword(section, keyword)
      88       28669 :       CALL keyword_release(keyword)
      89             : 
      90             :       CALL keyword_create(keyword, __LOCATION__, name="TEMP_TOL", &
      91             :                           description="Maximum oscillation of the Barostat temperature imposed by rescaling.", &
      92             :                           usage="TEMP_TOL real", default_r_val=0._dp, &
      93       28669 :                           unit_str='K')
      94       28669 :       CALL section_add_keyword(section, keyword)
      95       28669 :       CALL keyword_release(keyword)
      96             : 
      97             :       CALL keyword_create(keyword, __LOCATION__, name="VIRIAL", &
      98             :                           description="For NPT_F only: allows the screening of one or more components of the virial in order"// &
      99             :                           " to relax the cell only along specific cartesian axis", &
     100             :                           usage="VIRIAL (XYZ | X | Y | Z | XY| XZ | YZ)", &
     101             :                           enum_c_vals=s2a("XYZ", "X", "Y", "Z", "XY", "XZ", "YZ"), &
     102             :                           enum_i_vals=(/do_clv_xyz, do_clv_x, do_clv_y, do_clv_z, do_clv_xy, do_clv_xz, do_clv_yz/), &
     103       28669 :                           default_i_val=do_clv_xyz)
     104       28669 :       CALL section_add_keyword(section, keyword)
     105       28669 :       CALL keyword_release(keyword)
     106             : 
     107       28669 :       CALL create_velocity_section(subsection, "BAROSTAT")
     108       28669 :       CALL section_add_subsection(section, subsection)
     109       28669 :       CALL section_release(subsection)
     110             : 
     111       28669 :       CALL create_mass_section(subsection, "BAROSTAT")
     112       28669 :       CALL section_add_subsection(section, subsection)
     113       28669 :       CALL section_release(subsection)
     114             : 
     115       28669 :       CALL create_thermostat_section(thermo_section, coupled_thermostat=.TRUE.)
     116       28669 :       CALL section_add_subsection(section, thermo_section)
     117       28669 :       CALL section_release(thermo_section)
     118             : 
     119       28669 :       CALL create_print_section(subsection)
     120       28669 :       CALL section_add_subsection(section, subsection)
     121       28669 :       CALL section_release(subsection)
     122             : 
     123       28669 :    END SUBROUTINE create_barostat_section
     124             : 
     125             : ! **************************************************************************************************
     126             : !> \brief Creates print section for barostat section
     127             : !> \param section ...
     128             : !> \author teo [tlaino] - University of Zurich - 02.2008
     129             : ! **************************************************************************************************
     130       28669 :    SUBROUTINE create_print_section(section)
     131             :       TYPE(section_type), POINTER                        :: section
     132             : 
     133             :       TYPE(section_type), POINTER                        :: print_key
     134             : 
     135       28669 :       CPASSERT(.NOT. ASSOCIATED(section))
     136       28669 :       NULLIFY (print_key)
     137             :       CALL section_create(section, __LOCATION__, name="PRINT", &
     138             :                           description="Collects all print_keys for barostat", &
     139       28669 :                           n_keywords=1, n_subsections=0, repeats=.FALSE.)
     140             : 
     141             :       CALL cp_print_key_section_create(print_key, __LOCATION__, "ENERGY", &
     142             :                                        description="Controls the output of kinetic energy, and potential energy "// &
     143             :                                        "of the defined barostat.", print_level=high_print_level, common_iter_levels=1, &
     144       28669 :                                        filename="")
     145       28669 :       CALL section_add_subsection(section, print_key)
     146       28669 :       CALL section_release(print_key)
     147       28669 :    END SUBROUTINE create_print_section
     148             : 
     149             : END MODULE input_cp2k_barostats

Generated by: LCOV version 1.15