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 : !> \brief input sections for the CP2K-native SKALA and GauXC exchange-correlation backends
10 : ! **************************************************************************************************
11 : MODULE input_cp2k_skala
12 : USE input_constants, ONLY: do_gpu_auto,&
13 : do_gpu_device,&
14 : do_gpu_host
15 : USE input_keyword_types, ONLY: keyword_create,&
16 : keyword_release,&
17 : keyword_type
18 : USE input_section_types, ONLY: section_add_keyword,&
19 : section_create,&
20 : section_type
21 : USE kinds, ONLY: dp
22 : USE string_utilities, ONLY: s2a
23 : USE xc_input_constants, ONLY: skala_gapw_atom_composite_grid,&
24 : skala_gapw_common_grid,&
25 : skala_gapw_cp2k_default,&
26 : skala_gapw_direct_valence,&
27 : skala_gapw_paw_one_center,&
28 : skala_gapw_paw_one_center_split
29 : #include "./base/base_uses.f90"
30 :
31 : IMPLICIT NONE
32 : PRIVATE
33 :
34 : CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'input_cp2k_skala'
35 :
36 : PUBLIC :: create_gauxc_section, create_skala_native_section
37 :
38 : CONTAINS
39 :
40 : ! **************************************************************************************************
41 : !> \brief creates the structure of the GAUXC section
42 : !> \param section the section that will be created
43 : !> \author fawzi
44 : ! **************************************************************************************************
45 14913 : SUBROUTINE create_gauxc_section(section)
46 : TYPE(section_type), POINTER :: section
47 :
48 : TYPE(keyword_type), POINTER :: keyword
49 :
50 14913 : CPASSERT(.NOT. ASSOCIATED(section))
51 : CALL section_create(section, __LOCATION__, name="GAUXC", &
52 : description="Use exchange-correlation functionals provided by GauXC. "// &
53 : "The current CP2K bridge uses GauXC's molecular quadrature. Periodic inputs "// &
54 : "are limited to isolated validation cells and are not compact periodic "// &
55 : "material calculations.", &
56 14913 : n_keywords=25, n_subsections=0, repeats=.FALSE.)
57 :
58 14913 : NULLIFY (keyword)
59 :
60 : CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
61 : description="activates the functional", &
62 14913 : lone_keyword_l_val=.TRUE., default_l_val=.FALSE.)
63 14913 : CALL section_add_keyword(section, keyword)
64 14913 : CALL keyword_release(keyword)
65 :
66 : CALL keyword_create(keyword, __LOCATION__, name="FUNCTIONAL", &
67 : description="Functional name used to create the GauXC integrator. "// &
68 : "If MODEL is set, this optional base functional defaults to PBE and "// &
69 : "does not need to be specified for MODEL SKALA inputs.", &
70 14913 : default_c_val="PBE")
71 14913 : CALL section_add_keyword(section, keyword)
72 14913 : CALL keyword_release(keyword)
73 :
74 : CALL keyword_create(keyword, __LOCATION__, name="MODEL", &
75 : description="GauXC Skala model name or path. Use NONE for conventional GauXC. "// &
76 : "MODEL SKALA selects the installed Skala-1.1 model when available; "// &
77 : "other Skala models are supplied as .fun files or model names. "// &
78 : "NLCC pseudopotentials are rejected by the direct molecular GauXC "// &
79 : "Skala path.", &
80 : usage="MODEL SKALA", &
81 14913 : default_c_val="NONE")
82 14913 : CALL section_add_keyword(section, keyword)
83 14913 : CALL keyword_release(keyword)
84 :
85 : CALL keyword_create( &
86 : keyword, __LOCATION__, name="PSEUDOPOTENTIAL_GAPW_REPRESENTATION", &
87 : description="Select the density representation used by an active GauXC model for "// &
88 : "METHOD GAPW/GAPW_XC kinds with GTH or ECP pseudopotentials. "// &
89 : "DIRECT_VALENCE treats those kinds as GPW_TYPE and evaluates the model on "// &
90 : "the direct valence density; this is the default for non-local models such "// &
91 : "as Skala. PAW_ONE_CENTER combines the smooth and all hard-minus-soft "// &
92 : "one-center primitive fields before one model evaluation, retaining all 15 pairwise "// &
93 : "spin-gradient cross terms (14 additional to the smooth-density baseline) and the "// &
94 : "non-local couplings. PAW_ONE_CENTER_SPLIT is a diagnostic that evaluates smooth, hard, "// &
95 : "and soft fields separately. CP2K_DEFAULT retains the representation selected "// &
96 : "by KIND%GPW_TYPE, basis hardness, and DFT%QS%FORCE_PAW. All-electron kinds "// &
97 : "and conventional GauXC MODEL NONE calculations are unaffected. In a mixed "// &
98 : "all-electron/pseudopotential calculation, the selector applies per kind: "// &
99 : "all-electron kinds retain their one-center reconstruction while pseudopotential "// &
100 : "kinds follow the selected representation. No mixed-system-specific input is needed.", &
101 : usage="PSEUDOPOTENTIAL_GAPW_REPRESENTATION DIRECT_VALENCE", &
102 : enum_c_vals=s2a("DIRECT_VALENCE", "PAW_ONE_CENTER", "CP2K_DEFAULT", &
103 : "PAW_ONE_CENTER_SPLIT"), &
104 : enum_i_vals=[skala_gapw_direct_valence, skala_gapw_paw_one_center, &
105 : skala_gapw_cp2k_default, skala_gapw_paw_one_center_split], &
106 : enum_desc=s2a("Use the direct pseudopotential valence density", &
107 : "Reconstruct the GAPW primitive fields before model evaluation", &
108 : "Use the representation selected by the ordinary CP2K GAPW rules", &
109 : "Diagnose the separate smooth plus hard-minus-soft energy expression"), &
110 14913 : default_i_val=skala_gapw_direct_valence)
111 14913 : CALL section_add_keyword(section, keyword)
112 14913 : CALL keyword_release(keyword)
113 :
114 : CALL keyword_create(keyword, __LOCATION__, name="GRID", &
115 : description="Atomic grid size for GauXC. Skala defaults to SUPERFINE "// &
116 : "unless this keyword is set explicitly.", &
117 : usage="GRID fine", &
118 : enum_c_vals=s2a("FINE", "ULTRAFINE", "SUPERFINE", "GM3", "GM5"), &
119 : enum_i_vals=[1, 2, 3, 4, 5], &
120 : enum_desc=s2a("Fine grid (default)", &
121 : "Ultra fine grid", &
122 : "Super fine grid", &
123 : "GM3 grid", &
124 : "GM5 grid"), &
125 14913 : default_i_val=1)
126 14913 : CALL section_add_keyword(section, keyword)
127 14913 : CALL keyword_release(keyword)
128 :
129 : CALL keyword_create(keyword, __LOCATION__, name="RADIAL_QUADRATURE", &
130 : description="Radial quadrature scheme for GauXC", &
131 : usage="RADIAL_QUADRATURE muraknowles", &
132 : enum_c_vals=s2a("MURAKNOWLES", "BECKE", "TREUTLERAHLRICHS", "MURRAYHANDYLAMING"), &
133 : enum_i_vals=[1, 2, 3, 4], &
134 : enum_desc=s2a("Mura-Knowles radial quadrature (default)", &
135 : "Becke radial quadrature", &
136 : "Treutler-Ahlrichs radial quadrature", &
137 : "Murray-Handy-Laming radial quadrature"), &
138 14913 : default_i_val=1)
139 14913 : CALL section_add_keyword(section, keyword)
140 14913 : CALL keyword_release(keyword)
141 :
142 : CALL keyword_create(keyword, __LOCATION__, name="PRUNING_SCHEME", &
143 : description="Pruning scheme for GauXC. Skala defaults to UNPRUNED "// &
144 : "unless this keyword is set explicitly.", &
145 : usage="PRUNING_SCHEME robust", &
146 : enum_c_vals=s2a("ROBUST", "TREUTLER", "UNPRUNED"), &
147 : enum_i_vals=[1, 2, 3], &
148 : enum_desc=s2a("Robust pruning (default)", &
149 : "Treutler pruning", &
150 : "Unpruned grid"), &
151 14913 : default_i_val=1)
152 14913 : CALL section_add_keyword(section, keyword)
153 14913 : CALL keyword_release(keyword)
154 :
155 : CALL keyword_create(keyword, __LOCATION__, name="BATCH_SIZE", &
156 : description="Number of quadrature points processed per GauXC "// &
157 : "integrator batch. Larger batches reduce launch overhead but increase "// &
158 : "device memory use.", &
159 : usage="BATCH_SIZE 512", &
160 14913 : default_i_val=512)
161 14913 : CALL section_add_keyword(section, keyword)
162 14913 : CALL keyword_release(keyword)
163 :
164 : CALL keyword_create(keyword, __LOCATION__, name="DEVICE_RUNTIME_FILL_FRACTION", &
165 : description="Fraction of currently available GPU memory preallocated by "// &
166 : "a GauXC device runtime. Used whenever either LB_EXECUTION_SPACE or "// &
167 : "INT_EXECUTION_SPACE is DEVICE. Lower values leave more memory for "// &
168 : "Skala Torch inference; higher values can reduce allocator churn.", &
169 : usage="DEVICE_RUNTIME_FILL_FRACTION 0.1", &
170 14913 : default_r_val=0.1_dp)
171 14913 : CALL section_add_keyword(section, keyword)
172 14913 : CALL keyword_release(keyword)
173 :
174 : CALL keyword_create(keyword, __LOCATION__, name="MODEL_ATOM_CHUNK_SIZE", &
175 : description="Atom chunk size for GauXC Skala Torch inference. "// &
176 : "A positive value evaluates the Torch model atom block by atom block; "// &
177 : "zero disables chunking; the default leaves GauXC's model-specific policy "// &
178 : "or the GAUXC_ONEDFT_ATOM_CHUNK_SIZE environment variable in control.", &
179 : usage="MODEL_ATOM_CHUNK_SIZE 3", &
180 14913 : default_i_val=-1)
181 14913 : CALL section_add_keyword(section, keyword)
182 14913 : CALL keyword_release(keyword)
183 :
184 : CALL keyword_create(keyword, __LOCATION__, name="PERIODIC_REFERENCE", &
185 : description="Explicitly opt into the limited isolated-cell GauXC reference "// &
186 : "path for periodic CP2K inputs. This path is restricted to Gamma-only, "// &
187 : "single-image METHOD GPW calculations with GTH pseudopotentials and uses "// &
188 : "GauXC's molecular quadrature; compact periodic materials require a "// &
189 : "dedicated periodic GauXC interface.", &
190 : usage="PERIODIC_REFERENCE T", &
191 14913 : default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
192 14913 : CALL section_add_keyword(section, keyword)
193 14913 : CALL keyword_release(keyword)
194 :
195 : CALL keyword_create(keyword, __LOCATION__, name="MOLECULAR_VIRIAL", &
196 : description="Print a molecular XC virial diagnostic computed from GauXC "// &
197 : "nuclear gradients. This is not an analytical periodic stress tensor.", &
198 : usage="MOLECULAR_VIRIAL T", &
199 14913 : default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
200 14913 : CALL section_add_keyword(section, keyword)
201 14913 : CALL keyword_release(keyword)
202 :
203 : CALL keyword_create(keyword, __LOCATION__, name="MOLECULAR_VIRIAL_DEBUG", &
204 : description="Check the GauXC molecular XC virial diagnostic against a "// &
205 : "finite-difference affine scaling of the molecular coordinates.", &
206 : usage="MOLECULAR_VIRIAL_DEBUG T", &
207 14913 : default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
208 14913 : CALL section_add_keyword(section, keyword)
209 14913 : CALL keyword_release(keyword)
210 :
211 : CALL keyword_create(keyword, __LOCATION__, name="MOLECULAR_VIRIAL_DEBUG_DX", &
212 : description="Dimensionless finite-difference step for MOLECULAR_VIRIAL_DEBUG.", &
213 : usage="MOLECULAR_VIRIAL_DEBUG_DX 1.0E-4", &
214 14913 : default_r_val=1.0E-4_dp)
215 14913 : CALL section_add_keyword(section, keyword)
216 14913 : CALL keyword_release(keyword)
217 :
218 : CALL keyword_create(keyword, __LOCATION__, name="USE_GPU", &
219 : description="Select GPU execution for GauXC. AUTO (default) uses "// &
220 : "the GPU when CP2K and GauXC are built with CUDA support. HOST "// &
221 : "forces host-only execution. GPU requires a usable GPU and "// &
222 : "aborts otherwise. Unless set explicitly, both LB_EXECUTION_SPACE "// &
223 : "and INT_EXECUTION_SPACE follow this selection.", &
224 : usage="USE_GPU AUTO", &
225 : enum_c_vals=s2a("AUTO", "HOST", "GPU"), &
226 : enum_i_vals=[do_gpu_auto, do_gpu_host, do_gpu_device], &
227 : enum_desc=s2a("Follow the build configuration", &
228 : "Force host execution", &
229 : "Force GPU execution"), &
230 14913 : default_i_val=do_gpu_auto)
231 14913 : CALL section_add_keyword(section, keyword)
232 14913 : CALL keyword_release(keyword)
233 :
234 : CALL keyword_create(keyword, __LOCATION__, name="LB_EXECUTION_SPACE", &
235 : description="Execution space for the GauXC load balancer. "// &
236 : "Defaults to DEVICE when USE_GPU enables the GPU and HOST "// &
237 : "otherwise. An explicit value overrides that default.", &
238 : usage="LB_EXECUTION_SPACE host", &
239 : enum_c_vals=s2a("HOST", "DEVICE"), &
240 : enum_i_vals=[1, 2], &
241 : enum_desc=s2a("Run on host", &
242 : "Run on device"), &
243 14913 : default_i_val=1)
244 14913 : CALL section_add_keyword(section, keyword)
245 14913 : CALL keyword_release(keyword)
246 :
247 : CALL keyword_create(keyword, __LOCATION__, name="INT_EXECUTION_SPACE", &
248 : description="Execution space for the GauXC quadrature integrator. "// &
249 : "Defaults to DEVICE when USE_GPU enables the GPU and HOST "// &
250 : "otherwise. An explicit value overrides that default.", &
251 : usage="INT_EXECUTION_SPACE host", &
252 : enum_c_vals=s2a("HOST", "DEVICE"), &
253 : enum_i_vals=[1, 2], &
254 : enum_desc=s2a("Run on host", &
255 : "Run on device"), &
256 14913 : default_i_val=1)
257 14913 : CALL section_add_keyword(section, keyword)
258 14913 : CALL keyword_release(keyword)
259 :
260 : CALL keyword_create(keyword, __LOCATION__, name="LWD_KERNEL", &
261 : description="Local work driver kernel used by the GauXC integrator. "// &
262 : "AUTO uses SCHEME1-CUTLASS for device SKALA when GauXC provides it "// &
263 : "and otherwise uses GauXC's default for the selected execution space. "// &
264 : "DEFAULT always uses GauXC's default. "// &
265 : "Device builds with CUTLASS support can use SCHEME1-CUTLASS to run "// &
266 : "the grouped local potential update through CUTLASS.", &
267 : usage="LWD_KERNEL AUTO", &
268 14913 : default_c_val="AUTO")
269 14913 : CALL section_add_keyword(section, keyword)
270 14913 : CALL keyword_release(keyword)
271 :
272 : CALL keyword_create(keyword, __LOCATION__, name="SKALA_RUNTIME", &
273 : description="MPI communicator policy for GauXC Skala. AUTO uses "// &
274 : "the force-evaluation communicator for closed-shell calculations and a "// &
275 : "rank-local replicated runtime for open-shell calculations. MPI forces the "// &
276 : "force-evaluation communicator. SELF forces the previous replicated mode.", &
277 : usage="SKALA_RUNTIME AUTO", &
278 : enum_c_vals=s2a("AUTO", "MPI", "SELF"), &
279 : enum_i_vals=[1, 2, 3], &
280 : enum_desc=s2a("Closed-shell MPI, open-shell replicated (default)", &
281 : "Use the force-evaluation MPI communicator", &
282 : "Use rank-local replicated GauXC runtimes"), &
283 14913 : default_i_val=1)
284 14913 : CALL section_add_keyword(section, keyword)
285 14913 : CALL keyword_release(keyword)
286 :
287 : CALL keyword_create(keyword, __LOCATION__, name="MODEL_GRADIENT_RUNTIME", &
288 : description="MPI communicator policy for GauXC Skala nuclear gradients. "// &
289 : "AUTO uses distributed analytical gradients when the GauXC PR #222 fix is "// &
290 : "verified and energy/VXC uses MPI; otherwise it retains rank-local gradients. "// &
291 : "MPI requires verified support and an MPI energy/VXC runtime. SELF forces "// &
292 : "rank-local gradients. AUTO never overrides SKALA_RUNTIME's open-shell safeguard.", &
293 : usage="MODEL_GRADIENT_RUNTIME AUTO", &
294 : enum_c_vals=s2a("AUTO", "MPI", "SELF"), &
295 : enum_i_vals=[1, 2, 3], &
296 : enum_desc=s2a("Use verified MPI gradients or safe replicated fallback (default)", &
297 : "Use the force-evaluation MPI communicator when supported", &
298 : "Use rank-local replicated gradient runtimes"), &
299 14913 : default_i_val=1)
300 14913 : CALL section_add_keyword(section, keyword)
301 14913 : CALL keyword_release(keyword)
302 :
303 : CALL keyword_create(keyword, __LOCATION__, name="FORCE_NUMERICAL_GRADIENT", &
304 : description="Force central finite differences for the GauXC molecular XC "// &
305 : "nuclear gradient, using a displacement of 1.0E-4 bohr at fixed AO density. "// &
306 : "Diagnostic option; costs six XC energy evaluations per atom. Does not "// &
307 : "affect SKALA_NATIVE or the CP2K one-center contribution.", &
308 : usage="FORCE_NUMERICAL_GRADIENT T", &
309 14913 : default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
310 14913 : CALL section_add_keyword(section, keyword)
311 14913 : CALL keyword_release(keyword)
312 :
313 : CALL keyword_create(keyword, __LOCATION__, name="OUTPUT_PATH", &
314 : description="Optional path to an existing directory for GauXC HDF5 debug output. "// &
315 : "If set, molecule and basis set data are written as separate HDF5 files.", &
316 : usage="OUTPUT_PATH /path/to/output", &
317 14913 : default_c_val="")
318 14913 : CALL section_add_keyword(section, keyword)
319 14913 : CALL keyword_release(keyword)
320 :
321 14913 : END SUBROUTINE create_gauxc_section
322 :
323 : ! **************************************************************************************************
324 : !> \brief creates the structure of the CP2K-native SKALA section
325 : !> \param section the section that will be created
326 : ! **************************************************************************************************
327 14913 : SUBROUTINE create_skala_native_section(section)
328 : TYPE(section_type), POINTER :: section
329 :
330 : TYPE(keyword_type), POINTER :: keyword
331 :
332 14913 : CPASSERT(.NOT. ASSOCIATED(section))
333 : CALL section_create(section, __LOCATION__, name="SKALA_NATIVE", &
334 : description="Evaluate the SKALA TorchScript model on CP2K's native "// &
335 : "real-space grid. This is the CP2K-native SKALA/FTorch implementation "// &
336 : "and is mutually exclusive with the GAUXC section. It supports METHOD "// &
337 : "GPW, GAPW, and GAPW_XC, including analytical gradients and stress.", &
338 14913 : n_keywords=25, n_subsections=0, repeats=.FALSE.)
339 :
340 14913 : NULLIFY (keyword)
341 :
342 : CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
343 : description="activates the CP2K-native SKALA implementation", &
344 14913 : lone_keyword_l_val=.TRUE., default_l_val=.FALSE.)
345 14913 : CALL section_add_keyword(section, keyword)
346 14913 : CALL keyword_release(keyword)
347 :
348 : CALL keyword_create(keyword, __LOCATION__, name="MODEL", &
349 : description="SKALA TorchScript model for the CP2K-native grid path. "// &
350 : "MODEL SKALA resolves the installed SKALA model; an explicit path "// &
351 : "selects a .fun file. With GPU execution the model is resolved from "// &
352 : "SKALA_CUDA_MODEL, otherwise from SKALA_MODEL.", &
353 : usage="MODEL SKALA", &
354 14913 : default_c_val="SKALA")
355 14913 : CALL section_add_keyword(section, keyword)
356 14913 : CALL keyword_release(keyword)
357 :
358 : CALL keyword_create( &
359 : keyword, __LOCATION__, name="PSEUDOPOTENTIAL_GAPW_REPRESENTATION", &
360 : description="Select the density representation used by the CP2K-native SKALA model for "// &
361 : "METHOD GAPW/GAPW_XC kinds with GTH or ECP pseudopotentials. "// &
362 : "DIRECT_VALENCE treats those kinds as GPW_TYPE and evaluates the model on "// &
363 : "the direct valence density; this is the default for non-local models such "// &
364 : "as Skala. PAW_ONE_CENTER combines the smooth and all hard-minus-soft "// &
365 : "one-center primitive fields before one model evaluation, retaining all 15 pairwise "// &
366 : "spin-gradient cross terms (14 additional to the smooth-density baseline) and the "// &
367 : "non-local couplings. PAW_ONE_CENTER_SPLIT is a diagnostic that evaluates smooth, hard, "// &
368 : "and soft fields separately. CP2K_DEFAULT retains the representation selected "// &
369 : "by KIND%GPW_TYPE, basis hardness, and DFT%QS%FORCE_PAW. All-electron kinds "// &
370 : "are unaffected. In a mixed "// &
371 : "all-electron/pseudopotential calculation, the selector applies per kind: "// &
372 : "all-electron kinds retain their one-center reconstruction while pseudopotential "// &
373 : "kinds follow the selected representation. No mixed-system-specific input is needed.", &
374 : usage="PSEUDOPOTENTIAL_GAPW_REPRESENTATION DIRECT_VALENCE", &
375 : enum_c_vals=s2a("DIRECT_VALENCE", "PAW_ONE_CENTER", "CP2K_DEFAULT", &
376 : "PAW_ONE_CENTER_SPLIT"), &
377 : enum_i_vals=[skala_gapw_direct_valence, skala_gapw_paw_one_center, &
378 : skala_gapw_cp2k_default, skala_gapw_paw_one_center_split], &
379 : enum_desc=s2a("Use the direct pseudopotential valence density", &
380 : "Reconstruct the GAPW primitive fields before model evaluation", &
381 : "Use the representation selected by the ordinary CP2K GAPW rules", &
382 : "Diagnose the separate smooth plus hard-minus-soft energy expression"), &
383 14913 : default_i_val=skala_gapw_direct_valence)
384 14913 : CALL section_add_keyword(section, keyword)
385 14913 : CALL keyword_release(keyword)
386 :
387 : CALL keyword_create(keyword, __LOCATION__, name="MODEL_FP64", &
388 : description="Promote float32 numerical state and explicit floating-point casts "// &
389 : "in the native SKALA TorchScript model to double precision. Trained parameter "// &
390 : "values are retained exactly. This improves SCF and geometry-derivative "// &
391 : "consistency for mixed-precision exports. Disable to retain the export's "// &
392 : "original numerical precision.", &
393 : usage="MODEL_FP64 T", &
394 14913 : default_l_val=.TRUE., lone_keyword_l_val=.TRUE.)
395 14913 : CALL section_add_keyword(section, keyword)
396 14913 : CALL keyword_release(keyword)
397 :
398 : CALL keyword_create(keyword, __LOCATION__, name="USE_GPU", &
399 : description="Select GPU execution for the CP2K-native SKALA "// &
400 : "TorchScript model. AUTO (default) uses the GPU when CP2K is "// &
401 : "built with a CUDA-enabled LibTorch. HOST forces CPU execution. "// &
402 : "GPU requires a usable GPU and aborts otherwise. GPU execution "// &
403 : "resolves MODEL SKALA from SKALA_CUDA_MODEL; HOST uses SKALA_MODEL.", &
404 : usage="USE_GPU AUTO", &
405 : enum_c_vals=s2a("AUTO", "HOST", "GPU"), &
406 : enum_i_vals=[do_gpu_auto, do_gpu_host, do_gpu_device], &
407 : enum_desc=s2a("Follow the build configuration", &
408 : "Force CPU execution", &
409 : "Force GPU execution"), &
410 14913 : default_i_val=do_gpu_auto)
411 14913 : CALL section_add_keyword(section, keyword)
412 14913 : CALL keyword_release(keyword)
413 :
414 : CALL keyword_create(keyword, __LOCATION__, name="ATOM_PARTITION", &
415 : description="Atom partition used to build the experimental CP2K-native "// &
416 : "SKALA COMMON_GRID feature block. HARD assigns each native grid point to "// &
417 : "the nearest periodic atom and is intended for legacy energy/VXC-only runs. "// &
418 : "SMOOTH uses a Becke-like fuzzy-cell partition on the native grid and creates "// &
419 : "weighted atom rows. Internal atom-grid weights vanish through a smooth taper "// &
420 : "when sparse rows reach the partition cutoff. Analytical atom forces and stress "// &
421 : "include both the partition and taper derivatives in the SKALA feature response.", &
422 : usage="ATOM_PARTITION SMOOTH", &
423 : enum_c_vals=s2a("HARD", "SMOOTH"), &
424 : enum_i_vals=[1, 2], &
425 : enum_desc=s2a("Assign each grid point to the nearest atom", &
426 : "Use a smooth Becke-like native-grid atom partition"), &
427 14913 : default_i_val=2)
428 14913 : CALL section_add_keyword(section, keyword)
429 14913 : CALL keyword_release(keyword)
430 :
431 : CALL keyword_create( &
432 : keyword, __LOCATION__, name="LAYOUT", &
433 : description="Select the numerical layout for native-grid Skala irrespective of the "// &
434 : "electronic core representation. ATOM_COMPOSITE, the default, evaluates complete "// &
435 : "atom-centered radial/Lebedev blocks. GPW and pseudopotential direct-valence fields "// &
436 : "are interpolated from CP2K's plane-wave grid; GAPW primitive fields are combined "// &
437 : "before nonlinear feature construction. The matching interpolation, partition, and "// &
438 : "one-center adjoints return VXC, forces, and stress to CP2K. Mixed all-electron and "// &
439 : "pseudopotential kinds use the same syntax and are reconstructed per kind. COMMON_GRID retains "// &
440 : "evaluation on CP2K's regular real-space grid as a cutoff-sensitive reference and "// &
441 : "diagnostic layout; mixed core representations require ATOM_COMPOSITE.", &
442 : usage="LAYOUT ATOM_COMPOSITE", &
443 : enum_c_vals=s2a("COMMON_GRID", "ATOM_COMPOSITE"), &
444 : enum_i_vals=[skala_gapw_common_grid, skala_gapw_atom_composite_grid], &
445 : enum_desc=s2a("Evaluate on the common regular real-space grid", &
446 : "Use image-partitioned atom-centered grids"), &
447 14913 : default_i_val=skala_gapw_atom_composite_grid)
448 14913 : CALL section_add_keyword(section, keyword)
449 14913 : CALL keyword_release(keyword)
450 :
451 : CALL keyword_create(keyword, __LOCATION__, name="GAPW_DENSITY_PARTITION", &
452 : description="Hard/soft one-center primitive-field contribution used by "// &
453 : "METHOD GAPW and METHOD GAPW_XC. With PAW_ONE_CENTER, HARD_MINUS_SOFT "// &
454 : "combines smooth, hard, and soft density, gradient, and kinetic-energy-density "// &
455 : "fields before a single nonlinear SKALA evaluation. It is the default. For "// &
456 : "pseudopotential PAW/one-center GAPW this is distinct from KIND%GPW_TYPE, "// &
457 : "which uses the regular-grid valence-density approximation. "// &
458 : "HARD_ONLY, SOFT_ONLY, and NONE are diagnostic variants.", &
459 : usage="GAPW_DENSITY_PARTITION HARD_MINUS_SOFT", &
460 : enum_c_vals=s2a("HARD_MINUS_SOFT", "HARD_ONLY", "SOFT_ONLY", "NONE"), &
461 : enum_i_vals=[1, 2, 3, 4], &
462 : enum_desc=s2a("Use the hard-minus-soft GAPW one-center correction", &
463 : "Use only the hard one-center density", &
464 : "Use only the soft one-center density with the GAPW sign", &
465 : "Disable the GAPW one-center SKALA correction"), &
466 14913 : default_i_val=1)
467 14913 : CALL section_add_keyword(section, keyword)
468 14913 : CALL keyword_release(keyword)
469 :
470 : CALL keyword_create(keyword, __LOCATION__, name="GAPW_COMPOSITE_REFERENCE", &
471 : description="Evaluate native-grid SKALA for METHOD GAPW or GAPW_XC on "// &
472 : "rho and tau reconstructed as smooth plus hard-minus-soft before nonlinear "// &
473 : "feature construction on one common regular grid. No separate one-center "// &
474 : "SKALA energy is added. This expensive, cutoff-sensitive diagnostic is "// &
475 : "intended to validate the nonlinear hard/soft cross terms.", &
476 : usage="GAPW_COMPOSITE_REFERENCE T", &
477 14913 : default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
478 14913 : CALL section_add_keyword(section, keyword)
479 14913 : CALL keyword_release(keyword)
480 :
481 : CALL keyword_create(keyword, __LOCATION__, name="GAPW_COMPOSITE_DIRECT_AO", &
482 : description="Use direct full-ORB rho and tau collocation for the native-grid "// &
483 : "GAPW composite diagnostic. This is the variational all-electron "// &
484 : "counterpart of the reconstructed smooth plus hard-minus-soft fields and "// &
485 : "provides a reference for their common-grid adjoint.", &
486 : usage="GAPW_COMPOSITE_DIRECT_AO T", &
487 14913 : default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
488 14913 : CALL section_add_keyword(section, keyword)
489 14913 : CALL keyword_release(keyword)
490 :
491 : CALL keyword_create(keyword, __LOCATION__, name="GAPW_ATOM_COMPOSITE_REFERENCE", &
492 : description="Replace the native smooth plus separate GAPW one-center SKALA "// &
493 : "terms by one atom-centered evaluation of smooth plus hard-minus-soft "// &
494 : "primitive fields before nonlinear feature construction. The smooth PW "// &
495 : "and one-center VXC adjoints are returned consistently. MPI ranks assemble "// &
496 : "the atom rows collectively; one communicator root evaluates the model and "// &
497 : "broadcasts the energy and feature adjoints.", &
498 : usage="GAPW_ATOM_COMPOSITE_REFERENCE T", &
499 14913 : default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
500 14913 : CALL section_add_keyword(section, keyword)
501 14913 : CALL keyword_release(keyword)
502 :
503 : CALL keyword_create(keyword, __LOCATION__, name="GAPW_ATOM_COMPOSITE_DIAGNOSTIC", &
504 : description="Evaluate an energy-only GAPW diagnostic on the combined "// &
505 : "smooth plus one-center hard-minus-soft density before nonlinear SKALA "// &
506 : "feature construction. The smooth native-grid density is interpolated to "// &
507 : "the atom-centered GAPW quadrature and all atomic grids are evaluated in "// &
508 : "one model call. This single-rank diagnostic does not replace the active "// &
509 : "XC energy or potential.", &
510 : usage="GAPW_ATOM_COMPOSITE_DIAGNOSTIC T", &
511 14913 : default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
512 14913 : CALL section_add_keyword(section, keyword)
513 14913 : CALL keyword_release(keyword)
514 :
515 : CALL keyword_create(keyword, __LOCATION__, &
516 : name="GAPW_ATOM_COMPOSITE_COMPONENTS", &
517 : description="Select which one-center hard-minus-soft fields enter the "// &
518 : "atom-composite SKALA diagnostic. FULL combines rho, gradient, and tau; "// &
519 : "RHO_GRAD and TAU isolate the corresponding reconstruction; SMOOTH "// &
520 : "uses only interpolated smooth fields.", &
521 : usage="GAPW_ATOM_COMPOSITE_COMPONENTS FULL", &
522 : enum_c_vals=s2a("FULL", "RHO_GRAD", "TAU", "SMOOTH"), &
523 : enum_i_vals=[1, 2, 3, 4], &
524 : enum_desc=s2a("Combine rho, gradient, and tau corrections", &
525 : "Combine only rho and gradient corrections", &
526 : "Combine only the tau correction", &
527 : "Use only interpolated smooth fields"), &
528 14913 : default_i_val=1)
529 14913 : CALL section_add_keyword(section, keyword)
530 14913 : CALL keyword_release(keyword)
531 :
532 : CALL keyword_create(keyword, __LOCATION__, &
533 : name="GAPW_ATOM_COMPOSITE_FD_STEP", &
534 : description="Central finite-difference step used by the atom-composite "// &
535 : "feature-VXC diagnostic.", &
536 : usage="GAPW_ATOM_COMPOSITE_FD_STEP 3.0E-3", &
537 14913 : default_r_val=3.0E-3_dp)
538 14913 : CALL section_add_keyword(section, keyword)
539 14913 : CALL keyword_release(keyword)
540 :
541 : CALL keyword_create(keyword, __LOCATION__, name="ATOM_CHUNKS", &
542 : description="Split the CP2K-native SKALA TorchScript "// &
543 : "evaluation into contiguous atom blocks. MPI runs evaluate one atom block per "// &
544 : "rank, while single-rank runs can still use atom subchunks to reduce peak CUDA "// &
545 : "memory. Dynamic feature rows and VXC gradients are routed between their "// &
546 : "local grid and atom-block owner ranks. This is enabled by default; set it to "// &
547 : "false to retain the replicated global feature block. ATOM_COMPOSITE also "// &
548 : "subchunks energy, VXC, force, and stress evaluations along independent atomic "// &
549 : "blocks; COMMON_GRID analytical force and stress runs retain the full "// &
550 : "differentiable tensor graph.", &
551 : usage="ATOM_CHUNKS T", &
552 14913 : default_l_val=.TRUE., lone_keyword_l_val=.TRUE.)
553 14913 : CALL section_add_keyword(section, keyword)
554 14913 : CALL keyword_release(keyword)
555 :
556 : CALL keyword_create(keyword, __LOCATION__, name="ATOM_CHUNK_MAX_ROWS", &
557 : description="Maximum number of atom-grid rows evaluated by one TorchScript "// &
558 : "call in the experimental CP2K-native SKALA GPW atom-chunk path. A positive "// &
559 : "value splits each rank-local atom chunk into contiguous atom subchunks "// &
560 : "whose padded Torch row count stays below the limit. Atomic blocks are not "// &
561 : "divided, so one block can exceed the requested limit. Zero disables "// &
562 : "subchunking; -1 selects an automatic padded-row cap.", &
563 : usage="ATOM_CHUNK_MAX_ROWS 250000", &
564 14913 : default_i_val=-1)
565 14913 : CALL section_add_keyword(section, keyword)
566 14913 : CALL keyword_release(keyword)
567 :
568 : CALL keyword_create(keyword, __LOCATION__, name="DIAGNOSTICS", &
569 : description="Print diagnostic integrals of the CP2K-native SKALA GPW feature "// &
570 : "block, including electron count, spin moment, and summed grid weights.", &
571 : usage="DIAGNOSTICS T", &
572 14913 : default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
573 14913 : CALL section_add_keyword(section, keyword)
574 14913 : CALL keyword_release(keyword)
575 :
576 14913 : END SUBROUTINE create_skala_native_section
577 :
578 : END MODULE input_cp2k_skala
|