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 29313 : 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 29313 : CPASSERT(.NOT. ASSOCIATED(section))
63 : CALL section_create(section, __LOCATION__, name="barostat", &
64 : description="Parameters of barostat.", &
65 29313 : n_keywords=1, n_subsections=0, repeats=.FALSE.)
66 :
67 29313 : NULLIFY (keyword, subsection, thermo_section)
68 : CALL keyword_create(keyword, __LOCATION__, name="PRESSURE", &
69 : description="Initial pressure", &
70 : usage="PRESSURE real", &
71 29313 : default_r_val=0._dp, unit_str='bar')
72 29313 : CALL section_add_keyword(section, keyword)
73 29313 : 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 29313 : unit_str='fs')
80 29313 : CALL section_add_keyword(section, keyword)
81 29313 : 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 29313 : unit_str='K')
87 29313 : CALL section_add_keyword(section, keyword)
88 29313 : 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 29313 : unit_str='K')
94 29313 : CALL section_add_keyword(section, keyword)
95 29313 : 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 29313 : default_i_val=do_clv_xyz)
104 29313 : CALL section_add_keyword(section, keyword)
105 29313 : CALL keyword_release(keyword)
106 :
107 29313 : CALL create_velocity_section(subsection, "BAROSTAT")
108 29313 : CALL section_add_subsection(section, subsection)
109 29313 : CALL section_release(subsection)
110 :
111 29313 : CALL create_mass_section(subsection, "BAROSTAT")
112 29313 : CALL section_add_subsection(section, subsection)
113 29313 : CALL section_release(subsection)
114 :
115 29313 : CALL create_thermostat_section(thermo_section, coupled_thermostat=.TRUE.)
116 29313 : CALL section_add_subsection(section, thermo_section)
117 29313 : CALL section_release(thermo_section)
118 :
119 29313 : CALL create_print_section(subsection)
120 29313 : CALL section_add_subsection(section, subsection)
121 29313 : CALL section_release(subsection)
122 :
123 29313 : 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 29313 : SUBROUTINE create_print_section(section)
131 : TYPE(section_type), POINTER :: section
132 :
133 : TYPE(section_type), POINTER :: print_key
134 :
135 29313 : CPASSERT(.NOT. ASSOCIATED(section))
136 29313 : NULLIFY (print_key)
137 : CALL section_create(section, __LOCATION__, name="PRINT", &
138 : description="Collects all print_keys for barostat", &
139 29313 : 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 29313 : filename="")
145 29313 : CALL section_add_subsection(section, print_key)
146 29313 : CALL section_release(print_key)
147 29313 : END SUBROUTINE create_print_section
148 :
149 : END MODULE input_cp2k_barostats
|