(git:0341268)
Loading...
Searching...
No Matches
input_cp2k_kpoints.F
Go to the documentation of this file.
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!> \brief function that build the kpoints section of the input
10!> \par History
11!> init [07.2014]
12!> \author JGH
13! **************************************************************************************************
15 USE bibliography, ONLY: macdonald1978,&
23 USE input_val_types, ONLY: char_t,&
24 enum_t,&
25 real_t
26 USE kinds, ONLY: default_path_length,&
27 dp
28 USE string_utilities, ONLY: newline,&
29 s2a
30#include "./base/base_uses.f90"
31
32 IMPLICIT NONE
33 PRIVATE
34
35 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'input_cp2k_kpoints'
36
37 INTEGER, PARAMETER :: use_real_wfn = 101, &
38 use_complex_wfn = 100, &
43 lattice_fft_auto = 400, &
44 lattice_fft_on = 401, &
45 lattice_fft_off = 402
46
53
54CONTAINS
55
56! **************************************************************************************************
57!> \brief Creates the Kpoints section
58!> SECTION: &kpoint... &end
59!> SCHEME [None, Gamma, Monkhorst-Pack, MacDonald, General]
60!> { nx ny nz }
61!> { nx ny nz sx sy sz }
62!> KPOINT x1 y1 z1 w1
63!> SYMMETRY [on, off]
64!> WAVEFUNCTION [real, complex]
65!> FULL_GRID [on, off]
66!> LATTICE_FFT [auto, on, off]
67!> INVERSION_SYMMETRY_ONLY [on, off]
68!> DEBUG_FULL_KPOINT_SYMMETRY [on, off]
69!> SYMMETRY_BACKEND [K290, SPGLIB]
70!> SYMMETRY_REDUCTION_METHOD [K290, SPGLIB]
71!> VERBOSE [on, off]
72!> EPS_SYMMETRY value
73!> PARALLEL_GROUP_SIZE [-1,0,n]
74!>
75!> \param section the section to create
76!> \author JGH
77! **************************************************************************************************
78 SUBROUTINE create_kpoints_section(section)
79 TYPE(section_type), POINTER :: section
80
81 TYPE(keyword_type), POINTER :: keyword
82
83 cpassert(.NOT. ASSOCIATED(section))
84 CALL section_create(section, __location__, name="KPOINTS", &
85 description="Controls Brillouin-zone sampling with k-points.", &
86 n_keywords=1, n_subsections=0, repeats=.false.)
87
88 NULLIFY (keyword)
89 CALL keyword_create(keyword, __location__, name="SCHEME", &
90 description="K-point generation scheme. Available options are:"//newline// &
91 "- `NONE`"//newline// &
92 "- `GAMMA`"//newline// &
93 "- `MONKHORST-PACK`"//newline// &
94 "- `MACDONALD`"//newline// &
95 "- `GENERAL`"//newline// &
96 newline// &
97 "For `MONKHORST-PACK` the number of k points in all 3 dimensions has to"// &
98 " be supplied along with the keyword. For `MACDONALD` also the list of shifts."// &
99 " E.g. `MONKHORST-PACK 12 12 8`, `MACDONALD 4 4 4 0.25 0.25 0.25`."// &
100 " `GENERAL` uses explicitly listed k-points. If symmetry reduction is requested,"// &
101 " the explicit set must be equally weighted and closed under the selected operations.", &
102 usage="SCHEME {KPMETHOD} {integer} {integer} ..", &
103 citations=[monkhorst1976, macdonald1978], &
104 n_var=-1, type_of_var=char_t)
105 CALL section_add_keyword(section, keyword)
106 CALL keyword_release(keyword)
107
108 CALL keyword_create(keyword, __location__, name="GAMMA_CENTERED", &
109 description="Generate a gamma-centered variant of the "// &
110 "Monkhorst-Pack or MacDonald mesh. This shifts the original mesh so "// &
111 "it can include the Gamma point, and makes sense only when an "// &
112 "even number of subdivisions is used. For MacDonald meshes, the "// &
113 "explicit shift is applied after the gamma-centering shift.", &
114 usage="GAMMA_CENTERED <LOGICAL>", &
115 default_l_val=.false., lone_keyword_l_val=.true.)
116 CALL section_add_keyword(section, keyword)
117 CALL keyword_release(keyword)
118
119 CALL keyword_create(keyword, __location__, name="KPOINT", &
120 description="Specify kpoint coordinates and weight. ", &
121 usage="KPOINT x y z w", repeats=.true., &
122 n_var=4, type_of_var=real_t)
123 CALL section_add_keyword(section, keyword)
124 CALL keyword_release(keyword)
125
126 CALL keyword_create(keyword, __location__, name="UNITS", &
127 description="Special k-points are defined either in units"// &
128 " of reciprocal lattice vectors or in Cartesian coordinates in units of 2Pi/len."// &
129 " B_VECTOR: in multiples of the reciprocal lattice vectors (b)."// &
130 " CART_ANGSTROM: In units of 2*Pi/Angstrom."// &
131 " CART_BOHR: In units of 2*Pi/Bohr.", &
132 usage="UNITS <value>", type_of_var=char_t, default_c_val="B_VECTOR")
133 CALL section_add_keyword(section, keyword)
134 CALL keyword_release(keyword)
135
136 CALL keyword_create(keyword, __location__, name="SYMMETRY", &
137 description="Use symmetry to reduce the number of kpoints.", &
138 usage="SYMMETRY <LOGICAL>", &
139 default_l_val=.false., lone_keyword_l_val=.true.)
140 CALL section_add_keyword(section, keyword)
141 CALL keyword_release(keyword)
142
143 CALL keyword_create(keyword, __location__, name="FULL_GRID", &
144 description="Use the full, non-symmetry-reduced k-point grid.", &
145 usage="FULL_GRID <LOGICAL>", &
146 default_l_val=.false., lone_keyword_l_val=.true.)
147 CALL section_add_keyword(section, keyword)
148 CALL keyword_release(keyword)
149
150 CALL keyword_create(keyword, __location__, name="LATTICE_FFT", &
151 description="Control the FFT-based transformation of real-space matrices "// &
152 "to complete regular k-point grids. AUTO uses the lattice FFT for at least "// &
153 "27 k points when the grid and memory requirements are satisfied. ON bypasses "// &
154 "this performance threshold. OFF always uses the established direct phase sum. "// &
155 "Unsupported, incomplete, or oversized grids retain the direct fallback.", &
156 usage="LATTICE_FFT AUTO", type_of_var=enum_t, &
157 enum_c_vals=s2a("AUTO", "ON", "OFF"), &
159 enum_desc=s2a("Select the FFT from a conservative cost threshold.", &
160 "Prefer the FFT whenever the grid and memory checks allow it.", &
161 "Always use the direct real-cell to k-point transform."), &
162 default_i_val=lattice_fft_auto)
163 CALL section_add_keyword(section, keyword)
164 CALL keyword_release(keyword)
165
166 CALL keyword_create(keyword, __location__, name="INVERSION_SYMMETRY_ONLY", &
167 description="Restrict k-point reduction to k-space inversion "// &
168 "(time-reversal) symmetry.", &
169 usage="INVERSION_SYMMETRY_ONLY <LOGICAL>", &
170 default_l_val=.false., lone_keyword_l_val=.true.)
171 CALL section_add_keyword(section, keyword)
172 CALL keyword_release(keyword)
173
174 CALL keyword_create(keyword, __location__, name="DEBUG_FULL_KPOINT_SYMMETRY", &
175 description="Use full atomic k-point symmetry also for DEBUG finite-difference "// &
176 "points. This is enabled by default so analytical and finite-difference "// &
177 "evaluations use the symmetry of their current geometry. Disable it to restrict "// &
178 "DEBUG finite-difference energies to inversion/time-reversal symmetry.", &
179 usage="DEBUG_FULL_KPOINT_SYMMETRY <LOGICAL>", &
180 default_l_val=.true., lone_keyword_l_val=.true.)
181 CALL section_add_keyword(section, keyword)
182 CALL keyword_release(keyword)
183
184 CALL keyword_create(keyword, __location__, name="SYMMETRY_BACKEND", &
185 description="Select the backend used to provide and apply atomic "// &
186 "k-point symmetry operations. K290 is the established default. "// &
187 "SPGLIB uses the symmetry operations returned by SPGLIB, including "// &
188 "their fractional translations. This applies to Monkhorst-Pack, MacDonald, and "// &
189 "closed GENERAL k-point sets. If "// &
190 "SYMMETRY_REDUCTION_METHOD is not specified, it follows the selected backend.", &
191 usage="SYMMETRY_BACKEND K290", type_of_var=enum_t, &
192 enum_c_vals=s2a("K290", "SPGLIB"), &
194 enum_desc=s2a("Use the existing K290 k-point symmetry backend.", &
195 "Use SPGLIB symmetry operations as k-point symmetry backend."), &
196 default_i_val=use_k290_kpoint_backend)
197 CALL section_add_keyword(section, keyword)
198 CALL keyword_release(keyword)
199
200 CALL keyword_create(keyword, __location__, name="SYMMETRY_REDUCTION_METHOD", &
201 description="Select the method used to reduce Monkhorst-Pack and MacDonald "// &
202 "k-point meshes when atomic symmetry is enabled. K290 is the established "// &
203 "default. SPGLIB uses the symmetry operations returned by SPGLIB for the "// &
204 "k-point reduction. GENERAL k-point lists can be reduced when the explicit set is "// &
205 "equally weighted and closed under the selected operations. With "// &
206 "SYMMETRY_BACKEND K290 this can be used as a comparison mode using K290 "// &
207 "operations for SPGLIB-generated mappings.", &
208 usage="SYMMETRY_REDUCTION_METHOD K290", type_of_var=enum_t, &
209 enum_c_vals=s2a("K290", "SPGLIB"), &
211 enum_desc=s2a("Use the existing K290 k-point symmetry reduction method.", &
212 "Use SPGLIB symmetry operations for k-point reduction."), &
213 default_i_val=use_k290_kpoint_symmetry)
214 CALL section_add_keyword(section, keyword)
215 CALL keyword_release(keyword)
216
217 CALL keyword_create(keyword, __location__, name="VERBOSE", &
218 description="Verbose output information.", &
219 usage="VERBOSE <LOGICAL>", &
220 default_l_val=.false., lone_keyword_l_val=.true.)
221 CALL section_add_keyword(section, keyword)
222 CALL keyword_release(keyword)
223
224 CALL keyword_create(keyword, __location__, name="EPS_SYMMETRY", variants=["EPS_GEO"], &
225 description="Accuracy in k-point symmetry determination."//newline// &
226 "EPS_GEO is accepted as an alias.", &
227 usage="EPS_SYMMETRY <real>", &
228 default_r_val=1.0e-6_dp)
229 CALL section_add_keyword(section, keyword)
230 CALL keyword_release(keyword)
231
232 CALL keyword_create(keyword, __location__, name="PARALLEL_GROUP_SIZE", &
233 description="Number of MPI processes to be used for a single k-point."// &
234 " This number must divide the total number of processes."// &
235 " The number of groups must divide the total number of kpoints."// &
236 " Value=-1 (smallest possible number of processes per group, satisfying the constraints)."// &
237 " Value=0 (all processes)."// &
238 " Value=n (exactly n processes).", &
239 usage="PARALLEL_GROUP_SIZE <integer>", &
240 default_i_val=-1)
241 CALL section_add_keyword(section, keyword)
242 CALL keyword_release(keyword)
243
244 CALL keyword_create(keyword, __location__, name="WAVEFUNCTIONS", &
245 description="Select whether real or complex wavefunctions should be used "// &
246 "when allowed by the k-point set. REAL wavefunctions can only represent "// &
247 "Gamma or special k-points and symmetry operations with real Bloch phases. "// &
248 "Use COMPLEX for general atomic k-point symmetries with nontrivial phases.", &
249 usage="WAVEFUNCTIONS REAL", &
250 default_i_val=use_complex_wfn, &
251 enum_c_vals=s2a("REAL", "COMPLEX"), &
252 enum_desc=s2a("Use real wavefunctions (if possible by kpoints specified).", &
253 "Use complex wavefunctions (default)."), &
254 enum_i_vals=[use_real_wfn, use_complex_wfn])
255 CALL section_add_keyword(section, keyword)
256 CALL keyword_release(keyword)
257
258 END SUBROUTINE create_kpoints_section
259
260! **************************************************************************************************
261!> \brief ...
262!> \param section ...
263!> \param section_name ...
264!> \author JGH
265! **************************************************************************************************
266 SUBROUTINE create_kpoint_set_section(section, section_name)
267 TYPE(section_type), POINTER :: section
268 CHARACTER(LEN=*), OPTIONAL :: section_name
269
270 CHARACTER(len=default_path_length) :: my_section_name
271 TYPE(keyword_type), POINTER :: keyword
272
273 IF (PRESENT(section_name)) THEN
274 my_section_name = section_name
275 ELSE
276 my_section_name = "KPOINT_SET"
277 END IF
278
279 cpassert(.NOT. ASSOCIATED(section))
280 CALL section_create(section, __location__, name=my_section_name, &
281 description="Specifies a k-point line to be calculated.", &
282 n_keywords=0, n_subsections=0, repeats=.true.)
283 ! keywords
284 NULLIFY (keyword)
285 CALL keyword_create(keyword, __location__, name="SPECIAL_POINT", &
286 description="Name and coordinates of a special k-point", &
287 usage="SPECIAL_POINT GAMMA 0.0 0.0 0.0", n_var=-1, type_of_var=char_t, repeats=.true.)
288 CALL section_add_keyword(section, keyword)
289 CALL keyword_release(keyword)
290 !
291 CALL keyword_create(keyword, __location__, name="NPOINTS", &
292 description="Number of k-points along the line.", &
293 default_i_val=0)
294 CALL section_add_keyword(section, keyword)
295 CALL keyword_release(keyword)
296 !
297 CALL keyword_create(keyword, __location__, name="UNITS", &
298 description="Special k-points are defined either in units"// &
299 " of reciprocal lattice vectors or in Cartesian coordinates in units of 2Pi/len."// &
300 " B_VECTOR: in multiples of the reciprocal lattice vectors (b)."// &
301 " CART_ANGSTROM: In units of 2*Pi/Angstrom."// &
302 " CART_BOHR: In units of 2*Pi/Bohr.", &
303 usage="UNITS <value>", type_of_var=char_t, default_c_val="B_VECTOR")
304 CALL section_add_keyword(section, keyword)
305 CALL keyword_release(keyword)
306
307 END SUBROUTINE create_kpoint_set_section
308
309END MODULE input_cp2k_kpoints
collects all references to literature in CP2K as new algorithms / method are included from literature...
integer, save, public monkhorst1976
integer, save, public macdonald1978
function that build the kpoints section of the input
integer, parameter, public use_spglib_kpoint_symmetry
integer, parameter, public lattice_fft_auto
integer, parameter, public use_k290_kpoint_symmetry
subroutine, public create_kpoints_section(section)
Creates the Kpoints section SECTION: &kpoint... &end SCHEME [None, Gamma, Monkhorst-Pack,...
integer, parameter, public lattice_fft_off
integer, parameter, public use_real_wfn
subroutine, public create_kpoint_set_section(section, section_name)
...
integer, parameter, public lattice_fft_on
integer, parameter, public use_spglib_kpoint_backend
integer, parameter, public use_k290_kpoint_backend
integer, parameter, public use_complex_wfn
represents keywords in an input
subroutine, public keyword_release(keyword)
releases the given keyword (see doc/ReferenceCounting.html)
subroutine, public keyword_create(keyword, location, name, description, usage, type_of_var, n_var, repeats, variants, default_val, default_l_val, default_r_val, default_lc_val, default_c_val, default_i_val, default_l_vals, default_r_vals, default_c_vals, default_i_vals, lone_keyword_val, lone_keyword_l_val, lone_keyword_r_val, lone_keyword_c_val, lone_keyword_i_val, lone_keyword_l_vals, lone_keyword_r_vals, lone_keyword_c_vals, lone_keyword_i_vals, enum_c_vals, enum_i_vals, enum, enum_strict, enum_desc, unit_str, citations, deprecation_notice, removed)
creates a keyword object
objects that represent the structure of input sections and the data contained in an input section
subroutine, public section_create(section, location, name, description, n_keywords, n_subsections, repeats, citations, deprecation_notice)
creates a list of keywords
subroutine, public section_add_keyword(section, keyword)
adds a keyword to the given section
a wrapper for basic fortran types.
integer, parameter, public real_t
integer, parameter, public char_t
integer, parameter, public enum_t
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
integer, parameter, public default_path_length
Definition kinds.F:58
Utilities for string manipulations.
character(len=1), parameter, public newline
represent a keyword in the input
represent a section of the input file