1!--------------------------------------------------------------------------------------------------!
2!   CP2K: A general program to perform molecular dynamics simulations                              !
3!   Copyright (C) 2000 - 2020  CP2K developers group                                               !
4!--------------------------------------------------------------------------------------------------!
5
6! **************************************************************************************************
7!> \brief builds the input structure for the ATOM module
8!> \author jgh
9! **************************************************************************************************
10MODULE input_cp2k_atom
11   USE cp_output_handling,              ONLY: cp_print_key_section_create,&
12                                              debug_print_level,&
13                                              high_print_level,&
14                                              medium_print_level,&
15                                              silent_print_level
16   USE input_constants,                 ONLY: &
17        atom_basis_run, atom_energy_run, atom_no_run, atom_pseudo_run, barrier_conf, &
18        contracted_gto, do_analytic, do_dkh0_atom, do_dkh1_atom, do_dkh2_atom, do_dkh3_atom, &
19        do_gapw_gcs, do_gapw_gct, do_gapw_log, do_nonrel_atom, do_numeric, do_rhf_atom, &
20        do_rks_atom, do_rohf_atom, do_sczoramp_atom, do_semi_analytic, do_uhf_atom, do_uks_atom, &
21        do_zoramp_atom, ecp_pseudo, gaussian, geometrical_gto, gth_pseudo, no_conf, no_pseudo, &
22        numerical, poly_conf, sgp_pseudo, slater, upf_pseudo
23   USE input_cp2k_xc,                   ONLY: create_xc_section
24   USE input_keyword_types,             ONLY: keyword_create,&
25                                              keyword_release,&
26                                              keyword_type
27   USE input_section_types,             ONLY: section_add_keyword,&
28                                              section_add_subsection,&
29                                              section_create,&
30                                              section_release,&
31                                              section_type
32   USE input_val_types,                 ONLY: char_t,&
33                                              integer_t,&
34                                              lchar_t,&
35                                              logical_t,&
36                                              real_t
37   USE kinds,                           ONLY: dp
38   USE string_utilities,                ONLY: s2a
39#include "./base/base_uses.f90"
40
41   IMPLICIT NONE
42   PRIVATE
43
44   LOGICAL, PRIVATE, PARAMETER :: debug_this_module = .TRUE.
45   CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'input_cp2k_atom'
46
47   PUBLIC :: create_atom_section
48
49! **************************************************************************************************
50
51CONTAINS
52
53! **************************************************************************************************
54!> \brief Creates the input section for the atom code
55!> \param section the section to create
56!> \author jgh
57! **************************************************************************************************
58   SUBROUTINE create_atom_section(section)
59      TYPE(section_type), POINTER                        :: section
60
61      CHARACTER(len=*), PARAMETER :: routineN = 'create_atom_section', &
62         routineP = moduleN//':'//routineN
63
64      TYPE(keyword_type), POINTER                        :: keyword
65      TYPE(section_type), POINTER                        :: subsection
66
67      CPASSERT(.NOT. ASSOCIATED(section))
68      CALL section_create(section, __LOCATION__, name="ATOM", &
69                          description="Section handling input for atomic calculations.", &
70                          n_keywords=1, n_subsections=1, repeats=.FALSE.)
71      NULLIFY (keyword, subsection)
72
73      CALL keyword_create(keyword, __LOCATION__, name="ATOMIC_NUMBER", &
74                          description="Specify the atomic number", &
75                          default_i_val=1)
76      CALL section_add_keyword(section, keyword)
77      CALL keyword_release(keyword)
78
79      CALL keyword_create(keyword, __LOCATION__, name="ELEMENT", &
80                          description="Specify the element to be calculated", &
81                          usage="ELEMENT char", n_var=1, type_of_var=char_t, &
82                          default_c_val="H")
83      CALL section_add_keyword(section, keyword)
84      CALL keyword_release(keyword)
85
86      CALL keyword_create(keyword, __LOCATION__, name="RUN_TYPE", &
87                          description="Type of run that you want to perform "// &
88                          "[ENERGY,BASIS_OPTIMIZATION,PSEUDOPOTENTIAL_OPTIMIZATION,,...] ", &
89                          usage="RUN_TYPE (NONE|ENERGY|BASIS_OPTIMIZATION|PSEUDOPOTENTIAL_OPTIMIZATION)", &
90                          default_i_val=atom_energy_run, &
91                          enum_c_vals=s2a("NONE", "ENERGY", "BASIS_OPTIMIZATION", "PSEUDOPOTENTIAL_OPTIMIZATION"), &
92                          enum_i_vals=(/atom_no_run, atom_energy_run, atom_basis_run, atom_pseudo_run/), &
93                          enum_desc=s2a("Perform no run", &
94                                        "Perform energy optimization", &
95                                        "Perform basis optimization", &
96                                        "Perform pseudopotential optimization"))
97      CALL section_add_keyword(section, keyword)
98      CALL keyword_release(keyword)
99
100      CALL keyword_create(keyword, __LOCATION__, name="COULOMB_INTEGRALS", &
101                          description="Method to calculate Coulomb integrals", &
102                          usage="COULOMB_INTEGRALS (ANALYTIC|SEMI_ANALYTIC|NUMERIC)", &
103                          default_i_val=do_numeric, &
104                          enum_c_vals=(/"ANALYTIC                 ", &
105                                        "SEMI_ANALYTIC            ", &
106                                        "NUMERIC                  "/), &
107                          enum_i_vals=(/do_analytic, do_semi_analytic, do_numeric/), &
108                          enum_desc=s2a("Use analytical method", &
109                                        "Use semi-analytical method", &
110                                        "Use numerical method"))
111      CALL section_add_keyword(section, keyword)
112      CALL keyword_release(keyword)
113
114      CALL keyword_create(keyword, __LOCATION__, name="EXCHANGE_INTEGRALS", &
115                          description="Method to calculate Exchange integrals", &
116                          usage="EXCHANGE_INTEGRALS (ANALYTIC|SEMI_ANALYTIC|NUMERIC)", &
117                          default_i_val=do_numeric, &
118                          enum_c_vals=(/"ANALYTIC                 ", &
119                                        "SEMI_ANALYTIC            ", &
120                                        "NUMERIC                  "/), &
121                          enum_i_vals=(/do_analytic, do_semi_analytic, do_numeric/), &
122                          enum_desc=s2a("Use analytical method. Not available for longrange Hartree-Fock", &
123                                        "Use semi-analytical method", &
124                                        "Use numerical method"))
125      CALL section_add_keyword(section, keyword)
126      CALL keyword_release(keyword)
127
128      CALL keyword_create(keyword, __LOCATION__, name="CORE", &
129                          description="Specifies the core electrons for a pseudopotential", &
130                          usage="CORE 1s2 ... or CORE [Ne] or CORE none for 0 electron cores", repeats=.FALSE., &
131                          n_var=-1, type_of_var=char_t)
132      CALL section_add_keyword(section, keyword)
133      CALL keyword_release(keyword)
134
135      CALL keyword_create(keyword, __LOCATION__, name="ELECTRON_CONFIGURATION", &
136                          description="Specifies the electron configuration. "// &
137                          "Optional the multiplicity (m) and a core state [XX] can be declared", &
138                          usage="ELECTRON_CONFIGURATION (1) [Ne] 3s2 ... ", repeats=.TRUE., &
139                          n_var=-1, type_of_var=char_t)
140      CALL section_add_keyword(section, keyword)
141      CALL keyword_release(keyword)
142
143      CALL keyword_create(keyword, __LOCATION__, name="MAX_ANGULAR_MOMENTUM", &
144                          description="Specifies the largest angular momentum calculated [0-3]", &
145                          usage="MAX_ANGULAR_MOMENTUM 3", repeats=.FALSE., &
146                          default_i_val=3)
147      CALL section_add_keyword(section, keyword)
148      CALL keyword_release(keyword)
149
150      CALL keyword_create(keyword, __LOCATION__, name="CALCULATE_STATES", &
151                          description="Specifies the number of states calculated per l value", &
152                          usage="CALCULATE_STATES  5 5 5 3 ", repeats=.FALSE., &
153                          default_i_val=0, n_var=-1, type_of_var=integer_t)
154      CALL section_add_keyword(section, keyword)
155      CALL keyword_release(keyword)
156
157      CALL keyword_create(keyword, __LOCATION__, name="USE_GAUSS_HERMITE", &
158                          description="Whether a Gauss-Hermite grid is to be used for the numerical integration of "// &
159                          "longrange exchange integrals", &
160                          usage="USE_GAUSS_HERMITE TRUE", repeats=.FALSE., &
161                          default_l_val=.FALSE.)
162      CALL section_add_keyword(section, keyword)
163      CALL keyword_release(keyword)
164
165      CALL keyword_create(keyword, __LOCATION__, name="GRID_POINTS_GH", &
166                          description="Number of grid points for Gauss-Hermite grid", &
167                          usage="GRID_POINTS_GH 100", repeats=.FALSE., &
168                          default_i_val=100)
169      CALL section_add_keyword(section, keyword)
170      CALL keyword_release(keyword)
171
172      CALL create_atom_print_section(subsection)
173      CALL section_add_subsection(section, subsection)
174      CALL section_release(subsection)
175
176      CALL create_atom_aebasis_section(subsection)
177      CALL section_add_subsection(section, subsection)
178      CALL section_release(subsection)
179
180      CALL create_atom_ppbasis_section(subsection)
181      CALL section_add_subsection(section, subsection)
182      CALL section_release(subsection)
183
184      CALL create_atom_method_section(subsection)
185      CALL section_add_subsection(section, subsection)
186      CALL section_release(subsection)
187
188      CALL create_optimization_section(subsection)
189      CALL section_add_subsection(section, subsection)
190      CALL section_release(subsection)
191
192      CALL create_potential_section(subsection)
193      CALL section_add_subsection(section, subsection)
194      CALL section_release(subsection)
195
196      CALL create_powell_section(subsection)
197      CALL section_add_subsection(section, subsection)
198      CALL section_release(subsection)
199
200   END SUBROUTINE create_atom_section
201
202! **************************************************************************************************
203!> \brief Create the print atom section
204!> \param section the section to create
205!> \author jgh
206! **************************************************************************************************
207   SUBROUTINE create_atom_print_section(section)
208      TYPE(section_type), POINTER                        :: section
209
210      CHARACTER(len=*), PARAMETER :: routineN = 'create_atom_print_section', &
211         routineP = moduleN//':'//routineN
212
213      TYPE(keyword_type), POINTER                        :: keyword
214      TYPE(section_type), POINTER                        :: print_key, subsection
215
216      CPASSERT(.NOT. ASSOCIATED(section))
217      CALL section_create(section, __LOCATION__, name="print", &
218                          description="Section of possible print options specific of the ATOM code.", &
219                          n_keywords=0, n_subsections=1, repeats=.FALSE.)
220
221      NULLIFY (print_key, keyword)
222
223      ! Print key section
224      CALL cp_print_key_section_create(print_key, __LOCATION__, "PROGRAM_BANNER", &
225                                       description="Controls the printing of the banner of the ATOM program", &
226                                       print_level=silent_print_level, filename="__STD_OUT__")
227      CALL section_add_subsection(section, print_key)
228      CALL section_release(print_key)
229
230      ! Print key section
231      CALL cp_print_key_section_create(print_key, __LOCATION__, "METHOD_INFO", &
232                                       description="Controls the printing of method information", &
233                                       print_level=medium_print_level, filename="__STD_OUT__")
234      CALL section_add_subsection(section, print_key)
235      CALL section_release(print_key)
236
237      ! Print key section
238      CALL cp_print_key_section_create(print_key, __LOCATION__, "BASIS_SET", &
239                                       description="Controls the printing of the basis sets", &
240                                       print_level=high_print_level, filename="__STD_OUT__")
241      CALL section_add_subsection(section, print_key)
242      CALL section_release(print_key)
243
244      ! Print key section
245      CALL cp_print_key_section_create(print_key, __LOCATION__, "POTENTIAL", &
246                                       description="Controls the printing of the potentials", &
247                                       print_level=high_print_level, filename="__STD_OUT__")
248      CALL section_add_subsection(section, print_key)
249      CALL section_release(print_key)
250
251      ! Print key section
252      CALL cp_print_key_section_create( &
253         print_key, __LOCATION__, "FIT_DENSITY", &
254         description="Fit the total electronic density to a linear combination of Gaussian functions", &
255         print_level=high_print_level, filename="__STD_OUT__")
256      CALL keyword_create(keyword, __LOCATION__, name="NUM_GTO", &
257                          description="Number of Gaussian type functions for density fit", &
258                          usage="NUM_GTO integer ", type_of_var=integer_t, &
259                          default_i_val=40)
260      CALL section_add_keyword(print_key, keyword)
261      CALL keyword_release(keyword)
262      CALL section_add_subsection(section, print_key)
263      CALL section_release(print_key)
264
265      ! Print key section
266      CALL cp_print_key_section_create(print_key, __LOCATION__, "FIT_KGPOT", &
267                                       description="Fit an approximation to the non-additive"// &
268                                       " kinetic energy potential used in KG", &
269                                       print_level=high_print_level, filename="__STD_OUT__")
270      CALL keyword_create(keyword, __LOCATION__, name="NUM_GAUSSIAN", &
271                          description="Number of Gaussian terms for the fit", &
272                          usage="NUM_GAUSSIAN integer ", type_of_var=integer_t, &
273                          default_i_val=1)
274      CALL section_add_keyword(print_key, keyword)
275      CALL keyword_release(keyword)
276      CALL keyword_create(keyword, __LOCATION__, name="NUM_POLYNOM", &
277                          description="Number of terms in the polynomial expansion", &
278                          usage="NUM_POLYNOM integer ", type_of_var=integer_t, &
279                          default_i_val=4)
280      CALL section_add_keyword(print_key, keyword)
281      CALL keyword_release(keyword)
282      CALL section_add_subsection(section, print_key)
283      CALL section_release(print_key)
284
285      ! Print key section
286      CALL cp_print_key_section_create(print_key, __LOCATION__, "RESPONSE_BASIS", &
287                                       description="Calculate a response basis set contraction scheme", &
288                                       print_level=high_print_level, filename="__STD_OUT__")
289      CALL keyword_create(keyword, __LOCATION__, name="DELTA_CHARGE", &
290                          description="Variation of charge used in finite difference calculation", &
291                          usage="DELTA_CHARGE real ", type_of_var=real_t, &
292                          default_r_val=0.05_dp)
293      CALL section_add_keyword(print_key, keyword)
294      CALL keyword_release(keyword)
295      CALL keyword_create(keyword, __LOCATION__, name="DERIVATIVES", &
296                          description="Number of wavefunction derivatives to calculate", &
297                          usage="DERIVATIVES integer ", type_of_var=integer_t, &
298                          default_i_val=2)
299      CALL section_add_keyword(print_key, keyword)
300      CALL keyword_release(keyword)
301      CALL section_add_subsection(section, print_key)
302      CALL section_release(print_key)
303
304      ! Print key section
305      CALL cp_print_key_section_create(print_key, __LOCATION__, "GEOMETRICAL_RESPONSE_BASIS", &
306                                       description="Calculate a response basis set based on a set of geometrical exponents", &
307                                       print_level=high_print_level, filename="__STD_OUT__")
308      !
309      CALL keyword_create(keyword, __LOCATION__, name="DELTA_CHARGE", &
310                          description="Variation of charge used in finite difference calculation", &
311                          usage="DELTA_CHARGE real ", type_of_var=real_t, &
312                          default_r_val=0.05_dp)
313      CALL section_add_keyword(print_key, keyword)
314      CALL keyword_release(keyword)
315      !
316      CALL keyword_create(keyword, __LOCATION__, name="DERIVATIVES", &
317                          description="Number of wavefunction derivatives to calculate", &
318                          usage="DERIVATIVES integer ", type_of_var=integer_t, &
319                          default_i_val=3)
320      CALL section_add_keyword(print_key, keyword)
321      CALL keyword_release(keyword)
322      !
323      CALL keyword_create(keyword, __LOCATION__, name="QUADRATURE", &
324                          description="Algorithm to construct the atomic radial grids", &
325                          usage="QUADRATURE (GC_SIMPLE|GC_TRANSFORMED|GC_LOG)", &
326                          enum_c_vals=s2a("GC_SIMPLE", "GC_TRANSFORMED", "GC_LOG"), &
327                          enum_i_vals=(/do_gapw_gcs, do_gapw_gct, do_gapw_log/), &
328                          enum_desc=s2a("Gauss-Chebyshev quadrature", &
329                                        "Transformed Gauss-Chebyshev quadrature", &
330                                        "Logarithmic transformed Gauss-Chebyshev quadrature"), &
331                          default_i_val=do_gapw_log)
332      CALL section_add_keyword(print_key, keyword)
333      CALL keyword_release(keyword)
334      !
335      CALL keyword_create(keyword, __LOCATION__, name="GRID_POINTS", &
336                          description="Number of radial grid points", &
337                          usage="GRID_POINTS integer", &
338                          default_i_val=400)
339      CALL section_add_keyword(print_key, keyword)
340      CALL keyword_release(keyword)
341      !
342      CALL keyword_create(keyword, __LOCATION__, name="NUM_GTO_CORE", &
343                          description="Number of Gaussian type functions for s, p, d, ... "// &
344                          "for the main body of the basis", &
345                          usage="NUM_GTO 6 ", n_var=1, type_of_var=integer_t, &
346                          default_i_val=-1)
347      CALL section_add_keyword(print_key, keyword)
348      CALL keyword_release(keyword)
349      CALL keyword_create(keyword, __LOCATION__, name="NUM_GTO_EXTENDED", &
350                          description="Number of Gaussian type functions for s, p, d, ... "// &
351                          "for the extension set", &
352                          usage="NUM_GTO 4 ", n_var=1, type_of_var=integer_t, &
353                          default_i_val=-1)
354      CALL section_add_keyword(print_key, keyword)
355      CALL keyword_release(keyword)
356      CALL keyword_create(keyword, __LOCATION__, name="NUM_GTO_POLARIZATION", &
357                          description="Number of Gaussian type functions for the polarization set", &
358                          usage="NUM_GTO 4 ", n_var=1, type_of_var=integer_t, &
359                          default_i_val=-1)
360      CALL section_add_keyword(print_key, keyword)
361      CALL keyword_release(keyword)
362      CALL keyword_create(keyword, __LOCATION__, name="EXTENSION_BASIS", &
363                          description="Number of basis functions for s, p, d, ... "// &
364                          "for the extension set", &
365                          usage="EXTENSION_BASIS 4 3 2 1 ", n_var=-1, type_of_var=integer_t, &
366                          default_i_val=-1)
367      CALL section_add_keyword(print_key, keyword)
368      CALL keyword_release(keyword)
369      CALL keyword_create(keyword, __LOCATION__, name="GEOMETRICAL_FACTOR", &
370                          description="Geometrical basis: factor C in a*C^k (initial value for optimization)", &
371                          usage="GEOMETRICAL_FACTOR real", &
372                          default_r_val=2.3_dp)
373      CALL section_add_keyword(print_key, keyword)
374      CALL keyword_release(keyword)
375      CALL keyword_create(keyword, __LOCATION__, name="GEO_START_VALUE", &
376                          description="Geometrical basis: starting value a in a*C^k (initial value for optimization)", &
377                          usage="GEO_START_VALUE real", &
378                          default_r_val=0.06_dp)
379      CALL section_add_keyword(print_key, keyword)
380      CALL keyword_release(keyword)
381      CALL keyword_create(keyword, __LOCATION__, name="CONFINEMENT", &
382                          description="Onset value of barrier confinement potential [Bohr]", &
383                          usage="CONFINEMENT real", &
384                          default_r_val=8.00_dp)
385      CALL section_add_keyword(print_key, keyword)
386      CALL keyword_release(keyword)
387      CALL keyword_create(keyword, __LOCATION__, name="NAME_BODY", &
388                          description="Specifies the body of the basis set name ", &
389                          usage="NAME_BODY <char>", &
390                          type_of_var=char_t, default_c_val="GRB", n_var=-1)
391      CALL section_add_keyword(print_key, keyword)
392      CALL keyword_release(keyword)
393      !
394      CALL section_add_subsection(section, print_key)
395      CALL section_release(print_key)
396
397      ! Print key section
398      CALL cp_print_key_section_create(print_key, __LOCATION__, "SCF_INFO", &
399                                       description="Controls the printing of SCF information", &
400                                       print_level=medium_print_level, filename="__STD_OUT__")
401      CALL section_add_subsection(section, print_key)
402      CALL section_release(print_key)
403
404      ! Print key section
405      CALL cp_print_key_section_create(print_key, __LOCATION__, "ORBITALS", &
406                                       description="Controls the printing of the optimized orbitals information", &
407                                       print_level=high_print_level, filename="__STD_OUT__")
408      CALL section_add_subsection(section, print_key)
409      CALL section_release(print_key)
410
411      ! Print key section
412      CALL cp_print_key_section_create(print_key, __LOCATION__, "ANALYZE_BASIS", &
413                                       description="Calculates some basis set analysis data", &
414                                       print_level=high_print_level, filename="__STD_OUT__")
415      CALL keyword_create(keyword, __LOCATION__, name="OVERLAP_CONDITION_NUMBER", &
416                          description="Condition number of the basis set overlap matrix calculated for a cubic crystal", &
417                          usage="OVERLAP_CONDITION_NUMBER <logical>", type_of_var=logical_t, default_l_val=.FALSE.)
418      CALL section_add_keyword(print_key, keyword)
419      CALL keyword_release(keyword)
420      CALL keyword_create(keyword, __LOCATION__, name="COMPLETENESS", &
421                          description="Calculate a completeness estimate for the basis set.", &
422                          usage="COMPLETENESS <logical>", type_of_var=logical_t, default_l_val=.FALSE.)
423      CALL section_add_keyword(print_key, keyword)
424      CALL keyword_release(keyword)
425      CALL section_add_subsection(section, print_key)
426      CALL section_release(print_key)
427
428      ! Print key section
429      CALL cp_print_key_section_create(print_key, __LOCATION__, "FIT_PSEUDO", &
430                                       description="Controls the printing of FIT PSEUDO task", &
431                                       print_level=medium_print_level, filename="__STD_OUT__")
432      CALL section_add_subsection(section, print_key)
433      CALL section_release(print_key)
434
435      ! Print key section
436      CALL cp_print_key_section_create(print_key, __LOCATION__, "FIT_BASIS", &
437                                       description="Controls the printing of FIT BASIS task", &
438                                       print_level=medium_print_level, filename="__STD_OUT__")
439      CALL section_add_subsection(section, print_key)
440      CALL section_release(print_key)
441
442      ! Print key section
443      CALL cp_print_key_section_create(print_key, __LOCATION__, "UPF_FILE", &
444                                       description="Write GTH pseudopotential in UPF format", &
445                                       print_level=high_print_level, filename="__STD_OUT__")
446      CALL section_add_subsection(section, print_key)
447      CALL section_release(print_key)
448
449      ! Print key section
450      CALL cp_print_key_section_create(print_key, __LOCATION__, "SEPARABLE_GAUSSIAN_PSEUDO", &
451                                       description="Creates a representation of the pseudopotential in separable "// &
452                                       " form using Gaussian functions.", &
453                                       print_level=debug_print_level, filename="__STD_OUT__")
454      CALL section_add_subsection(section, print_key)
455      CALL section_release(print_key)
456
457      ! Print key section: ADMM Analysis
458      CALL cp_print_key_section_create(print_key, __LOCATION__, "ADMM", &
459                                       description="Analysis of ADMM approximation to exact exchange", &
460                                       print_level=high_print_level, filename="__STD_OUT__")
461
462      NULLIFY (subsection)
463      CALL section_create(subsection, __LOCATION__, name="ADMM_BASIS", &
464                          description="Section of basis set information for ADMM calculations.", &
465                          n_keywords=0, n_subsections=0, repeats=.FALSE.)
466      CALL atom_basis_section(subsection)
467      CALL section_add_subsection(print_key, subsection)
468      CALL section_release(subsection)
469      CALL section_add_subsection(section, print_key)
470      CALL section_release(print_key)
471
472   END SUBROUTINE create_atom_print_section
473
474! **************************************************************************************************
475!> \brief Create the all-electron basis section
476!> \param section the section to create
477!> \author jgh
478! **************************************************************************************************
479   SUBROUTINE create_atom_aebasis_section(section)
480      TYPE(section_type), POINTER                        :: section
481
482      CHARACTER(len=*), PARAMETER :: routineN = 'create_atom_aebasis_section', &
483         routineP = moduleN//':'//routineN
484
485      CPASSERT(.NOT. ASSOCIATED(section))
486      CALL section_create(section, __LOCATION__, name="AE_BASIS", &
487                          description="Section of basis set information for all-electron calculations.", &
488                          n_keywords=0, n_subsections=0, repeats=.FALSE.)
489
490      CALL atom_basis_section(section)
491
492   END SUBROUTINE create_atom_aebasis_section
493
494! **************************************************************************************************
495!> \brief Create the pseudopotential basis section
496!> \param section the section to create
497!> \author jgh
498! **************************************************************************************************
499   SUBROUTINE create_atom_ppbasis_section(section)
500      TYPE(section_type), POINTER                        :: section
501
502      CHARACTER(len=*), PARAMETER :: routineN = 'create_atom_ppbasis_section', &
503         routineP = moduleN//':'//routineN
504
505      CPASSERT(.NOT. ASSOCIATED(section))
506      CALL section_create(section, __LOCATION__, name="PP_BASIS", &
507                          description="Section of basis set information for pseudopotential calculations.", &
508                          n_keywords=0, n_subsections=0, repeats=.FALSE.)
509
510      CALL atom_basis_section(section)
511
512   END SUBROUTINE create_atom_ppbasis_section
513
514! **************************************************************************************************
515!> \brief Keywords in the atom basis section
516!> \param section the section to fill
517!> \author jgh
518! **************************************************************************************************
519   SUBROUTINE atom_basis_section(section)
520      TYPE(section_type), POINTER                        :: section
521
522      CHARACTER(len=*), PARAMETER :: routineN = 'atom_basis_section', &
523         routineP = moduleN//':'//routineN
524
525      TYPE(keyword_type), POINTER                        :: keyword
526      TYPE(section_type), POINTER                        :: subsection
527
528      CPASSERT(ASSOCIATED(section))
529      NULLIFY (keyword)
530
531      CALL keyword_create(keyword, __LOCATION__, name="BASIS_TYPE", &
532                          description="Basis set type", &
533                          usage="BASIS_TYPE (GAUSSIAN|GEOMETRICAL_GTO|CONTRACTED_GTO|SLATER|NUMERICAL)", &
534                          default_i_val=gaussian, &
535                          enum_c_vals=(/"GAUSSIAN                 ", &
536                                        "GEOMETRICAL_GTO          ", &
537                                        "CONTRACTED_GTO           ", &
538                                        "SLATER                   ", &
539                                        "NUMERICAL                "/), &
540                          enum_i_vals=(/gaussian, geometrical_gto, contracted_gto, slater, numerical/), &
541                          enum_desc=s2a("Gaussian type orbitals", &
542                                        "Geometrical Gaussian type orbitals", &
543                                        "Contracted Gaussian type orbitals", &
544                                        "Slater-type orbitals", &
545                                        "Numerical basis type"))
546      CALL section_add_keyword(section, keyword)
547      CALL keyword_release(keyword)
548
549      CALL keyword_create(keyword, __LOCATION__, name="NUM_GTO", &
550                          description="Number of Gaussian type functions for s, p, d, ...", &
551                          usage="NUM_GTO 5 5 5 ", n_var=-1, type_of_var=integer_t, &
552                          default_i_val=-1)
553      CALL section_add_keyword(section, keyword)
554      CALL keyword_release(keyword)
555
556      CALL keyword_create(keyword, __LOCATION__, name="NUM_SLATER", &
557                          description="Number of Slater type functions for s, p, d, ...", &
558                          usage="NUM_SLATER 5 5 5 ", n_var=-1, type_of_var=integer_t, &
559                          default_i_val=-1)
560      CALL section_add_keyword(section, keyword)
561      CALL keyword_release(keyword)
562
563      CALL keyword_create(keyword, __LOCATION__, name="START_INDEX", &
564                          description="Starting index for Geometrical Basis sets", &
565                          usage="START_INDEX 0 2 5 4 ", n_var=-1, type_of_var=integer_t, &
566                          default_i_val=0)
567      CALL section_add_keyword(section, keyword)
568      CALL keyword_release(keyword)
569
570      CALL keyword_create(keyword, __LOCATION__, name="S_EXPONENTS", &
571                          description="Exponents for s functions", &
572                          usage="S_EXPONENTS 1.0 2.0 ... ", n_var=-1, type_of_var=real_t)
573      CALL section_add_keyword(section, keyword)
574      CALL keyword_release(keyword)
575      CALL keyword_create(keyword, __LOCATION__, name="P_EXPONENTS", &
576                          description="Exponents for p functions", &
577                          usage="P_EXPONENTS 1.0 2.0 ... ", n_var=-1, type_of_var=real_t)
578      CALL section_add_keyword(section, keyword)
579      CALL keyword_release(keyword)
580      CALL keyword_create(keyword, __LOCATION__, name="D_EXPONENTS", &
581                          description="Exponents for d functions", &
582                          usage="D_EXPONENTS 1.0 2.0 ... ", n_var=-1, type_of_var=real_t)
583      CALL section_add_keyword(section, keyword)
584      CALL keyword_release(keyword)
585      CALL keyword_create(keyword, __LOCATION__, name="F_EXPONENTS", &
586                          description="Exponents for f functions", &
587                          usage="F_EXPONENTS 1.0 2.0 ... ", n_var=-1, type_of_var=real_t)
588      CALL section_add_keyword(section, keyword)
589      CALL keyword_release(keyword)
590
591      CALL keyword_create(keyword, __LOCATION__, name="S_QUANTUM_NUMBERS", &
592                          description="Main quantum numbers for s functions", &
593                          usage="S_QUANTUM_NUMBERS 1 2 ... ", n_var=-1, type_of_var=integer_t)
594      CALL section_add_keyword(section, keyword)
595      CALL keyword_release(keyword)
596      CALL keyword_create(keyword, __LOCATION__, name="P_QUANTUM_NUMBERS", &
597                          description="Main quantum numbers for p functions", &
598                          usage="P_QUANTUM_NUMBERS 2 3 ... ", n_var=-1, type_of_var=integer_t)
599      CALL section_add_keyword(section, keyword)
600      CALL keyword_release(keyword)
601      CALL keyword_create(keyword, __LOCATION__, name="D_QUANTUM_NUMBERS", &
602                          description="Main quantum numbers for d functions", &
603                          usage="D_QUANTUM_NUMBERS 3 4 ... ", n_var=-1, type_of_var=integer_t)
604      CALL section_add_keyword(section, keyword)
605      CALL keyword_release(keyword)
606      CALL keyword_create(keyword, __LOCATION__, name="F_QUANTUM_NUMBERS", &
607                          description="Main quantum numbers for f functions", &
608                          usage="F_QUANTUM_NUMBERS 4 5 ... ", n_var=-1, type_of_var=integer_t)
609      CALL section_add_keyword(section, keyword)
610      CALL keyword_release(keyword)
611
612      CALL keyword_create(keyword, __LOCATION__, name="GEOMETRICAL_FACTOR", &
613                          description="Geometrical basis: factor C in a*C^k", &
614                          usage="GEOMETRICAL_FACTOR real", &
615                          default_r_val=2.6_dp)
616      CALL section_add_keyword(section, keyword)
617      CALL keyword_release(keyword)
618
619      CALL keyword_create(keyword, __LOCATION__, name="GEO_START_VALUE", &
620                          description="Geometrical basis: starting value a in a*C^k", &
621                          usage="GEO_START_VALUE real", &
622                          default_r_val=0.016_dp)
623      CALL section_add_keyword(section, keyword)
624      CALL keyword_release(keyword)
625
626      CALL keyword_create(keyword, __LOCATION__, name="BASIS_SET_FILE_NAME", &
627                          description="Name of the basis set file, may include a path", &
628                          usage="BASIS_SET_FILE_NAME <FILENAME>", &
629                          default_lc_val="BASIS_SET")
630      CALL section_add_keyword(section, keyword)
631      CALL keyword_release(keyword)
632
633      CALL keyword_create(keyword, __LOCATION__, name="BASIS_SET", &
634                          variants=s2a("ORBITAL_BASIS_SET", "ORB_BASIS"), &
635                          description="The contracted Gaussian basis set", &
636                          usage="BASIS_SET DZVP", default_c_val=" ", &
637                          n_var=1)
638      CALL section_add_keyword(section, keyword)
639      CALL keyword_release(keyword)
640
641      CALL keyword_create(keyword, __LOCATION__, name="QUADRATURE", &
642                          description="Algorithm to construct the atomic radial grids", &
643                          usage="QUADRATURE (GC_SIMPLE|GC_TRANSFORMED|GC_LOG)", &
644                          enum_c_vals=s2a("GC_SIMPLE", "GC_TRANSFORMED", "GC_LOG"), &
645                          enum_i_vals=(/do_gapw_gcs, do_gapw_gct, do_gapw_log/), &
646                          enum_desc=s2a("Gauss-Chebyshev quadrature", &
647                                        "Transformed Gauss-Chebyshev quadrature", &
648                                        "Logarithmic transformed Gauss-Chebyshev quadrature"), &
649                          default_i_val=do_gapw_log)
650      CALL section_add_keyword(section, keyword)
651      CALL keyword_release(keyword)
652
653      CALL keyword_create(keyword, __LOCATION__, name="GRID_POINTS", &
654                          description="Number of radial grid points", &
655                          usage="GRID_POINTS integer", &
656                          default_i_val=400)
657      CALL section_add_keyword(section, keyword)
658      CALL keyword_release(keyword)
659
660      CALL keyword_create(keyword, __LOCATION__, name="EPS_EIGENVALUE", &
661                          description="Cutoff of overlap matrix eigenvalues included into basis", &
662                          usage="EPS_EIGENVALUE real", &
663                          default_r_val=1.e-12_dp)
664      CALL section_add_keyword(section, keyword)
665      CALL keyword_release(keyword)
666
667      NULLIFY (subsection)
668      CALL create_basis_section(subsection)
669      CALL section_add_subsection(section, subsection)
670      CALL section_release(subsection)
671
672   END SUBROUTINE atom_basis_section
673
674! **************************************************************************************************
675!> \brief Create the method section for Atom calculations
676!> \param section the section to create
677!> \author jgh
678! **************************************************************************************************
679   SUBROUTINE create_atom_method_section(section)
680      TYPE(section_type), POINTER                        :: section
681
682      CHARACTER(len=*), PARAMETER :: routineN = 'create_atom_method_section', &
683         routineP = moduleN//':'//routineN
684
685      TYPE(keyword_type), POINTER                        :: keyword
686      TYPE(section_type), POINTER                        :: subsection
687
688      NULLIFY (subsection, keyword)
689      CPASSERT(.NOT. ASSOCIATED(section))
690      CALL section_create(section, __LOCATION__, name="METHOD", &
691                          description="Section of information on method to use.", &
692                          n_keywords=0, n_subsections=2, repeats=.TRUE.)
693
694      CALL keyword_create(keyword, __LOCATION__, name="METHOD_TYPE", &
695                          description="Type of electronic structure method to be used", &
696                          usage="METHOD_TYPE (KOHN-SHAM|RKS|UKS|HARTREE-FOCK|RHF|UHF|ROHF)", &
697                          default_i_val=do_rks_atom, &
698                          enum_c_vals=(/"KOHN-SHAM                ", &
699                                        "RKS                      ", &
700                                        "UKS                      ", &
701                                        "HARTREE-FOCK             ", &
702                                        "RHF                      ", &
703                                        "UHF                      ", &
704                                        "ROHF                     "/), &
705                          enum_i_vals=(/do_rks_atom, do_rks_atom, do_uks_atom, do_rhf_atom, &
706                                        do_rhf_atom, do_uhf_atom, do_rohf_atom/), &
707                          enum_desc=s2a("Kohn-Sham electronic structure method", &
708                                        "Restricted Kohn-Sham electronic structure method", &
709                                        "Unrestricted Kohn-Sham electronic structure method", &
710                                        "Hartree-Fock electronic structure method", &
711                                        "Restricted Hartree-Fock electronic structure method", &
712                                        "Unrestricted Hartree-Fock electronic structure method", &
713                                        "Restricted open-shell Hartree-Fock electronic structure method"))
714      CALL section_add_keyword(section, keyword)
715      CALL keyword_release(keyword)
716
717      CALL keyword_create(keyword, __LOCATION__, name="RELATIVISTIC", &
718                          description="Type of scalar relativistic method to be used", &
719                          usage="RELATIVISTIC (OFF|ZORA(MP)|scZORA(MP)|DKH(0)|DKH(1)|DKH(2)|DKH(3))", &
720                          default_i_val=do_nonrel_atom, &
721                          enum_c_vals=(/"OFF                      ", &
722                                        "ZORA(MP)                 ", &
723                                        "scZORA(MP)               ", &
724                                        "DKH(0)                   ", &
725                                        "DKH(1)                   ", &
726                                        "DKH(2)                   ", &
727                                        "DKH(3)                   "/), &
728                          enum_i_vals=(/do_nonrel_atom, do_zoramp_atom, do_sczoramp_atom, do_dkh0_atom, &
729                                        do_dkh1_atom, do_dkh2_atom, do_dkh3_atom/), &
730                          enum_desc=s2a("Use no scalar relativistic method", &
731                                        "Use ZORA method with atomic model potential", &
732                                        "Use scaled ZORA method with atomic model potential", &
733                                        "Use Douglas-Kroll-Hess Hamiltonian of order 0", &
734                                        "Use Douglas-Kroll-Hess Hamiltonian of order 1", &
735                                        "Use Douglas-Kroll-Hess Hamiltonian of order 2", &
736                                        "Use Douglas-Kroll-Hess Hamiltonian of order 3"))
737      CALL section_add_keyword(section, keyword)
738      CALL keyword_release(keyword)
739
740      CALL create_xc_section(subsection)
741      CALL section_add_subsection(section, subsection)
742      CALL section_release(subsection)
743
744! ZMP creating zubsection for the zmp calculations
745      CALL create_zmp_section(subsection)
746      CALL section_add_subsection(section, subsection)
747      CALL section_release(subsection)
748
749      CALL create_external_vxc(subsection)
750      CALL section_add_subsection(section, subsection)
751      CALL section_release(subsection)
752
753   END SUBROUTINE create_atom_method_section
754
755! **************************************************************************************************
756!> \brief Create the ZMP subsection for Atom calculations
757!>
758!> \param section ...
759!> \author D. Varsano [daniele.varsano@nano.cnr.it]
760! **************************************************************************************************
761   SUBROUTINE create_zmp_section(section)
762      TYPE(section_type), POINTER                        :: section
763
764      CHARACTER(len=*), PARAMETER :: routineN = 'create_zmp_section', &
765         routineP = moduleN//':'//routineN
766
767      TYPE(keyword_type), POINTER                        :: keyword
768      TYPE(section_type), POINTER                        :: subsection
769
770      NULLIFY (subsection, keyword)
771      CPASSERT(.NOT. ASSOCIATED(section))
772      CALL section_create(section, __LOCATION__, name="ZMP", &
773                          description="Section used to specify ZMP Potentials.", &
774                          n_keywords=3, n_subsections=0, repeats=.FALSE.)
775
776      CALL keyword_create(keyword, __LOCATION__, name="FILE_DENSITY", &
777                          description="Specifies the filename containing the target density ", &
778                          usage="FILE_DENSITY <FILENAME>", &
779                          type_of_var=char_t, default_c_val="RHO_O.dat", n_var=-1)
780      CALL section_add_keyword(section, keyword)
781      CALL keyword_release(keyword)
782
783      CALL keyword_create(keyword, __LOCATION__, name="GRID_TOL", &
784                          description="Tolerance in the equivalence of read-grid in ZMP method", &
785                          usage="GRID_TOL <REAL>", default_r_val=1.E-12_dp)
786      CALL section_add_keyword(section, keyword)
787      CALL keyword_release(keyword)
788
789      CALL keyword_create(keyword, __LOCATION__, name="LAMBDA", &
790                          description="Parameter used for the constraint in ZMP method", &
791                          usage="LAMBDA <REAL>", default_r_val=10.0_dp)
792      CALL section_add_keyword(section, keyword)
793      CALL keyword_release(keyword)
794
795      CALL keyword_create(keyword, __LOCATION__, name="DM", &
796                          description="read external density from density matrix", &
797                          usage="DM <LOGICAL>", type_of_var=logical_t, default_l_val=.FALSE.)
798      CALL section_add_keyword(section, keyword)
799      CALL keyword_release(keyword)
800
801      CALL create_zmp_restart_section(subsection)
802      CALL section_add_subsection(section, subsection)
803      CALL section_release(subsection)
804
805   END SUBROUTINE create_zmp_section
806
807! **************************************************************************************************
808!> \brief Create the ZMP restart subsection for Atom calculations
809!>
810!> \param section ...
811!> \author D. Varsano [daniele.varsano@nano.cnr.it]
812! **************************************************************************************************
813   SUBROUTINE create_zmp_restart_section(section)
814      TYPE(section_type), POINTER                        :: section
815
816      CHARACTER(len=*), PARAMETER :: routineN = 'create_zmp_restart_section', &
817         routineP = moduleN//':'//routineN
818
819      TYPE(keyword_type), POINTER                        :: keyword
820
821      NULLIFY (keyword)
822      CPASSERT(.NOT. ASSOCIATED(section))
823      CALL section_create(section, __LOCATION__, name="RESTART", &
824                          description="Section used to specify the restart option in the ZMP"// &
825                          "procedure, and the file that must be read.", &
826                          n_keywords=1, n_subsections=0, repeats=.FALSE.)
827
828      CALL keyword_create(keyword, __LOCATION__, name="FILE_RESTART", &
829                          description="Specifies the filename containing the restart file density ", &
830                          usage="FILE_RESTART <FILENAME>", &
831                          type_of_var=char_t, default_c_val="RESTART.wfn", n_var=-1)
832      CALL section_add_keyword(section, keyword)
833      CALL keyword_release(keyword)
834
835   END SUBROUTINE create_zmp_restart_section
836
837! **************************************************************************************************
838!> \brief Subroutine to create the external v_xc potential
839!>
840!> \param section ...
841!> \author D. Varsano [daniele.varsano@nano.cnr.it]
842! **************************************************************************************************
843   SUBROUTINE create_external_vxc(section)
844      TYPE(section_type), POINTER                        :: section
845
846      CHARACTER(len=*), PARAMETER :: routineN = 'create_external_vxc', &
847         routineP = moduleN//':'//routineN
848
849      TYPE(keyword_type), POINTER                        :: keyword
850
851      NULLIFY (keyword)
852      CPASSERT(.NOT. ASSOCIATED(section))
853      CALL section_create(section, __LOCATION__, name="EXTERNAL_VXC", &
854                          description="Section used to specify exernal VXC Potentials.", &
855                          n_keywords=1, n_subsections=0, repeats=.FALSE.)
856
857      CALL keyword_create(keyword, __LOCATION__, name="FILE_VXC", &
858                          description="Specifies the filename containing the external vxc ", &
859                          usage="FILE_VXC <FILENAME>", &
860                          type_of_var=char_t, default_c_val="VXC.dat", n_var=-1)
861      CALL section_add_keyword(section, keyword)
862      CALL keyword_release(keyword)
863
864      CALL keyword_create(keyword, __LOCATION__, name="GRID_TOL", &
865                          description="Tolerance in the equivalence of read-grid in ZMP method", &
866                          usage="GRID_TOL <REAL>", default_r_val=1.E-12_dp)
867      CALL section_add_keyword(section, keyword)
868      CALL keyword_release(keyword)
869
870   END SUBROUTINE create_external_vxc
871
872! **************************************************************************************************
873!> \brief Create the optimization section for Atom calculations
874!> \param section the section to create
875!> \author jgh
876! **************************************************************************************************
877   SUBROUTINE create_optimization_section(section)
878      TYPE(section_type), POINTER                        :: section
879
880      CHARACTER(len=*), PARAMETER :: routineN = 'create_optimization_section', &
881         routineP = moduleN//':'//routineN
882
883      TYPE(keyword_type), POINTER                        :: keyword
884
885      NULLIFY (keyword)
886      CPASSERT(.NOT. ASSOCIATED(section))
887      CALL section_create(section, __LOCATION__, name="OPTIMIZATION", &
888                          description="Section of information on optimization thresholds and algorithms.", &
889                          n_keywords=0, n_subsections=1, repeats=.FALSE.)
890
891      CALL keyword_create(keyword, __LOCATION__, name="MAX_ITER", &
892                          description="Maximum number of iterations for optimization", &
893                          usage="MAX_ITER  50", default_i_val=200)
894      CALL section_add_keyword(section, keyword)
895      CALL keyword_release(keyword)
896
897      CALL keyword_create(keyword, __LOCATION__, name="EPS_SCF", &
898                          description="Convergence criterion for SCF", &
899                          usage="EPS_SCF 1.e-10", default_r_val=1.e-6_dp)
900      CALL section_add_keyword(section, keyword)
901      CALL keyword_release(keyword)
902
903      CALL keyword_create(keyword, __LOCATION__, name="DAMPING", &
904                          description="Damping parameter for extrapolation method", &
905                          usage="DAMPING 0.4", default_r_val=0.4_dp)
906      CALL section_add_keyword(section, keyword)
907      CALL keyword_release(keyword)
908
909      CALL keyword_create(keyword, __LOCATION__, name="EPS_DIIS", &
910                          description="Starting DIIS method at convergence to EPS_DIIS", &
911                          usage="EPS_DIIS  0.01", default_r_val=10000._dp)
912      CALL section_add_keyword(section, keyword)
913      CALL keyword_release(keyword)
914
915      CALL keyword_create(keyword, __LOCATION__, name="N_DIIS", &
916                          description="Maximum number of DIIS vectors", &
917                          usage="N_DIIS  6", default_i_val=5)
918      CALL section_add_keyword(section, keyword)
919      CALL keyword_release(keyword)
920
921   END SUBROUTINE create_optimization_section
922
923! **************************************************************************************************
924!> \brief Create the potential section for Atom calculations
925!> \param section the section to create
926!> \author jgh
927! **************************************************************************************************
928   SUBROUTINE create_potential_section(section)
929      TYPE(section_type), POINTER                        :: section
930
931      CHARACTER(len=*), PARAMETER :: routineN = 'create_potential_section', &
932         routineP = moduleN//':'//routineN
933
934      TYPE(keyword_type), POINTER                        :: keyword
935      TYPE(section_type), POINTER                        :: subsection
936
937      NULLIFY (keyword)
938      CPASSERT(.NOT. ASSOCIATED(section))
939      CALL section_create(section, __LOCATION__, name="POTENTIAL", &
940                          description="Section of information on potential.", &
941                          n_keywords=0, n_subsections=1, repeats=.FALSE.)
942
943      CALL keyword_create(keyword, __LOCATION__, name="CONFINEMENT_TYPE", &
944                          description="Define functional form of confinement potential.", &
945                          usage="CONFINEMENT_TYPE (NONE|POLYNOM|BARRIER)", &
946                          default_i_val=poly_conf, &
947                          enum_c_vals=(/"NONE                     ", &
948                                        "POLYNOM                  ", &
949                                        "BARRIER                  "/), &
950                          enum_i_vals=(/no_conf, poly_conf, barrier_conf/), &
951                          enum_desc=s2a("Do not use confinement potential", &
952                                        "Use polynomial confinement potential: a*(R/b)^c", &
953                                        "Use a smooth barrier potential: a*F[R-c)/b]"))
954      CALL section_add_keyword(section, keyword)
955      CALL keyword_release(keyword)
956
957      CALL keyword_create(keyword, __LOCATION__, name="CONFINEMENT", &
958                          description="Definition of parameters for confinement potential (a,b,c)", &
959                          usage="CONFINEMENT prefactor range exponent (POLYNOM)"// &
960                          "CONFINEMENT prefactor range r_onset (BARRIER)", &
961                          default_r_vals=(/0._dp, 0._dp, 0._dp/), &
962                          repeats=.FALSE., n_var=-1)
963      CALL section_add_keyword(section, keyword)
964      CALL keyword_release(keyword)
965
966      CALL keyword_create(keyword, __LOCATION__, name="PSEUDO_TYPE", &
967                          description="Pseudopotential type", &
968                          usage="PSEUDO_TYPE (NONE|GTH|UPF|ECP)", &
969                          default_i_val=no_pseudo, &
970                          enum_c_vals=(/"NONE                     ", &
971                                        "GTH                      ", &
972                                        "UPF                      ", &
973                                        "SGP                      ", &
974                                        "ECP                      "/), &
975                          enum_i_vals=(/no_pseudo, gth_pseudo, upf_pseudo, sgp_pseudo, ecp_pseudo/), &
976                          enum_desc=s2a("Do not use pseudopotentials", &
977                                        "Use Goedecker-Teter-Hutter pseudopotentials", &
978                                        "Use UPF norm-conserving pseudopotentials", &
979                                        "Use SGP norm-conserving pseudopotentials", &
980                                        "Use ECP semi-local pseudopotentials"))
981      CALL section_add_keyword(section, keyword)
982      CALL keyword_release(keyword)
983
984      CALL keyword_create(keyword, __LOCATION__, name="POTENTIAL_FILE_NAME", &
985                          description="Name of the pseudo potential file, may include a path", &
986                          usage="POTENTIAL_FILE_NAME <FILENAME>", &
987                          default_lc_val="POTENTIAL")
988      CALL section_add_keyword(section, keyword)
989      CALL keyword_release(keyword)
990
991      CALL keyword_create(keyword, __LOCATION__, name="POTENTIAL_NAME", &
992                          variants=(/"POT_NAME"/), &
993                          description="The name of the pseudopotential for the defined kind.", &
994                          usage="POTENTIAL_NAME <PSEUDO-POTENTIAL-NAME>", default_c_val=" ", n_var=1)
995      CALL section_add_keyword(section, keyword)
996      CALL keyword_release(keyword)
997
998      NULLIFY (subsection)
999      CALL create_gthpotential_section(subsection)
1000      CALL section_add_subsection(section, subsection)
1001      CALL section_release(subsection)
1002
1003      NULLIFY (subsection)
1004      CALL create_ecp_section(subsection)
1005      CALL section_add_subsection(section, subsection)
1006      CALL section_release(subsection)
1007
1008   END SUBROUTINE create_potential_section
1009
1010! **************************************************************************************************
1011!> \brief Creates the &GTH_POTENTIAL section
1012!> \param section the section to create
1013!> \author teo
1014! **************************************************************************************************
1015   SUBROUTINE create_gthpotential_section(section)
1016      TYPE(section_type), POINTER                        :: section
1017
1018      CHARACTER(len=*), PARAMETER :: routineN = 'create_gthpotential_section', &
1019         routineP = moduleN//':'//routineN
1020
1021      TYPE(keyword_type), POINTER                        :: keyword
1022
1023      CALL section_create(section, __LOCATION__, name="GTH_POTENTIAL", &
1024                          description="Section used to specify Potentials.", &
1025                          n_keywords=1, n_subsections=0, repeats=.FALSE.)
1026      NULLIFY (keyword)
1027      CALL keyword_create(keyword, __LOCATION__, name="_DEFAULT_KEYWORD_", &
1028                          description="CP2K Pseudo Potential Standard Format (GTH, ALL or KG)", &
1029                          repeats=.TRUE., type_of_var=lchar_t)
1030      CALL section_add_keyword(section, keyword)
1031      CALL keyword_release(keyword)
1032   END SUBROUTINE create_gthpotential_section
1033
1034! **************************************************************************************************
1035!> \brief Creates the &ECP section
1036!> \param section the section to create
1037!> \author jgh
1038! **************************************************************************************************
1039   SUBROUTINE create_ecp_section(section)
1040      TYPE(section_type), POINTER                        :: section
1041
1042      CHARACTER(len=*), PARAMETER :: routineN = 'create_ecp_section', &
1043         routineP = moduleN//':'//routineN
1044
1045      TYPE(keyword_type), POINTER                        :: keyword
1046
1047      CALL section_create(section, __LOCATION__, name="ECP", &
1048                          description="Section used to specify ECP's.", &
1049                          n_keywords=1, n_subsections=0, repeats=.FALSE.)
1050      NULLIFY (keyword)
1051      CALL keyword_create(keyword, __LOCATION__, name="_DEFAULT_KEYWORD_", &
1052                          description="Effective Core Potentials definition", &
1053                          repeats=.TRUE., type_of_var=lchar_t)
1054      CALL section_add_keyword(section, keyword)
1055      CALL keyword_release(keyword)
1056   END SUBROUTINE create_ecp_section
1057
1058! **************************************************************************************************
1059!> \brief Creates the &BASIS section
1060!> \param section the section to create
1061!> \author teo
1062! **************************************************************************************************
1063   SUBROUTINE create_basis_section(section)
1064      TYPE(section_type), POINTER                        :: section
1065
1066      CHARACTER(len=*), PARAMETER :: routineN = 'create_basis_section', &
1067         routineP = moduleN//':'//routineN
1068
1069      TYPE(keyword_type), POINTER                        :: keyword
1070
1071      CALL section_create(section, __LOCATION__, name="basis", &
1072                          description="Section used to specify a general basis set for QM calculations.", &
1073                          n_keywords=1, n_subsections=0, repeats=.FALSE.)
1074      NULLIFY (keyword)
1075      CALL keyword_create(keyword, __LOCATION__, name="_DEFAULT_KEYWORD_", &
1076                          description="CP2K Basis Set Standard Format", repeats=.TRUE., &
1077                          type_of_var=lchar_t)
1078      CALL section_add_keyword(section, keyword)
1079      CALL keyword_release(keyword)
1080   END SUBROUTINE create_basis_section
1081
1082! **************************************************************************************************
1083!> \brief Creates the &POWELL section
1084!> \param section the section to create
1085!> \author teo
1086! **************************************************************************************************
1087   SUBROUTINE create_powell_section(section)
1088      TYPE(section_type), POINTER                        :: section
1089
1090      CHARACTER(len=*), PARAMETER :: routineN = 'create_powell_section', &
1091         routineP = moduleN//':'//routineN
1092
1093      TYPE(keyword_type), POINTER                        :: keyword
1094
1095      CALL section_create(section, __LOCATION__, name="powell", &
1096                          description="Section defines basic parameters for Powell optimization", &
1097                          n_keywords=4, n_subsections=0, repeats=.FALSE.)
1098
1099      NULLIFY (keyword)
1100      CALL keyword_create(keyword, __LOCATION__, name="ACCURACY", &
1101                          description="Final accuracy requested in optimization (RHOEND)", &
1102                          usage="ACCURACY 0.00001", &
1103                          default_r_val=1.e-6_dp)
1104      CALL section_add_keyword(section, keyword)
1105      CALL keyword_release(keyword)
1106
1107      CALL keyword_create(keyword, __LOCATION__, name="STEP_SIZE", &
1108                          description="Initial step size for search algorithm (RHOBEG)", &
1109                          usage="STEP_SIZE 0.005", &
1110                          default_r_val=0.005_dp)
1111      CALL section_add_keyword(section, keyword)
1112      CALL keyword_release(keyword)
1113
1114      CALL keyword_create(keyword, __LOCATION__, name="MAX_FUN", &
1115                          description="Maximum number of function evaluations", &
1116                          usage="MAX_FUN 1000", &
1117                          default_i_val=5000)
1118      CALL section_add_keyword(section, keyword)
1119      CALL keyword_release(keyword)
1120
1121      CALL keyword_create(keyword, __LOCATION__, name="MAX_INIT", &
1122                          description="Maximum number of re-initialization of Powell method", &
1123                          usage="MAX_INIT 5", &
1124                          default_i_val=1)
1125      CALL section_add_keyword(section, keyword)
1126      CALL keyword_release(keyword)
1127
1128      CALL keyword_create(keyword, __LOCATION__, name="STEP_SIZE_SCALING", &
1129                          description="Scaling of Step Size on re-initialization of Powell method", &
1130                          usage="STEP_SIZE_SCALING 0.80", &
1131                          default_r_val=0.75_dp)
1132      CALL section_add_keyword(section, keyword)
1133      CALL keyword_release(keyword)
1134
1135      CALL keyword_create(keyword, __LOCATION__, name="WEIGHT_POT_VIRTUAL", &
1136                          description="Weight for virtual states in pseudopotential optimization", &
1137                          usage="WEIGHT_POT_VIRTUAL 1.0", &
1138                          default_r_val=1._dp)
1139      CALL section_add_keyword(section, keyword)
1140      CALL keyword_release(keyword)
1141
1142      CALL keyword_create(keyword, __LOCATION__, name="WEIGHT_POT_SEMICORE", &
1143                          description="Weight for semi core states in pseudopotential optimization", &
1144                          usage="WEIGHT_POT_SEMICORE 1.0", &
1145                          default_r_val=1._dp)
1146      CALL section_add_keyword(section, keyword)
1147      CALL keyword_release(keyword)
1148
1149      CALL keyword_create(keyword, __LOCATION__, name="WEIGHT_POT_VALENCE", &
1150                          description="Weight for valence states in pseudopotential optimization", &
1151                          usage="WEIGHT_POT_VALENCE 1.0", &
1152                          default_r_val=1.0_dp)
1153      CALL section_add_keyword(section, keyword)
1154      CALL keyword_release(keyword)
1155
1156      CALL keyword_create(keyword, __LOCATION__, name="WEIGHT_POT_NODE", &
1157                          description="Weight for node mismatch in pseudopotential optimization", &
1158                          usage="WEIGHT_POT_NODE 1.0", &
1159                          default_r_val=1.0_dp)
1160      CALL section_add_keyword(section, keyword)
1161      CALL keyword_release(keyword)
1162
1163      CALL keyword_create(keyword, __LOCATION__, name="WEIGHT_DELTA_ENERGY", &
1164                          description="Weight for energy differences in pseudopotential optimization", &
1165                          usage="WEIGHT_DELTA_ENERGY 1.0", &
1166                          default_r_val=1._dp)
1167      CALL section_add_keyword(section, keyword)
1168      CALL keyword_release(keyword)
1169
1170      CALL keyword_create(keyword, __LOCATION__, name="WEIGHT_ELECTRON_CONFIGURATION", &
1171                          description="Weight for different electronic states in optimization", &
1172                          usage="WEIGHT_ELECTRON_CONFIGURATION 1.0 0.1 ...", &
1173                          n_var=-1, type_of_var=real_t, default_r_val=1.0_dp)
1174      CALL section_add_keyword(section, keyword)
1175      CALL keyword_release(keyword)
1176
1177      CALL keyword_create(keyword, __LOCATION__, name="WEIGHT_METHOD", &
1178                          description="Weight for different methods in optimization", &
1179                          usage="WEIGHT_METHOD 1.0 0.1 ...", &
1180                          n_var=-1, type_of_var=real_t, default_r_val=1.0_dp)
1181      CALL section_add_keyword(section, keyword)
1182      CALL keyword_release(keyword)
1183
1184      CALL keyword_create(keyword, __LOCATION__, name="TARGET_POT_VIRTUAL", &
1185                          description="Target accuracy for virtual state eigenvalues in pseudopotential optimization", &
1186                          usage="TARGET_POT_VIRTUAL 0.0001", &
1187                          default_r_val=1.0e-3_dp, unit_str="hartree")
1188      CALL section_add_keyword(section, keyword)
1189      CALL keyword_release(keyword)
1190
1191      CALL keyword_create(keyword, __LOCATION__, name="TARGET_POT_VALENCE", &
1192                          description="Target accuracy for valence state eigenvalues in pseudopotential optimization", &
1193                          usage="TARGET_POT_VALENCE 0.0001", &
1194                          default_r_val=1.0e-5_dp, unit_str="hartree")
1195      CALL section_add_keyword(section, keyword)
1196      CALL keyword_release(keyword)
1197
1198      CALL keyword_create(keyword, __LOCATION__, name="TARGET_POT_SEMICORE", &
1199                          description="Target accuracy for semicore state eigenvalues in pseudopotential optimization", &
1200                          usage="TARGET_POT_SEMICORE 0.01", &
1201                          default_r_val=1.0e-3_dp, unit_str="hartree")
1202      CALL section_add_keyword(section, keyword)
1203      CALL keyword_release(keyword)
1204
1205      CALL keyword_create(keyword, __LOCATION__, name="TARGET_DELTA_ENERGY", &
1206                          description="Target accuracy for energy differences in pseudopotential optimization", &
1207                          usage="TARGET_DELTA_ENERGY 0.01", &
1208                          default_r_val=1.0e-4_dp, unit_str="hartree")
1209      CALL section_add_keyword(section, keyword)
1210      CALL keyword_release(keyword)
1211
1212      CALL keyword_create(keyword, __LOCATION__, name="TARGET_PSIR0", &
1213                          description="Minimum value for the wavefunctions at r=0 (only occupied states)"// &
1214                          " Value=0 means keeping wfn(r=0)=0", &
1215                          usage="TARGET_PSIR0 0.50", &
1216                          default_r_val=0._dp)
1217      CALL section_add_keyword(section, keyword)
1218      CALL keyword_release(keyword)
1219
1220      CALL keyword_create(keyword, __LOCATION__, name="WEIGHT_PSIR0", &
1221                          description="Weight for the wavefunctions at r=0 (only occupied states)", &
1222                          usage="WEIGHT_PSIR0 0.01", &
1223                          default_r_val=0._dp)
1224      CALL section_add_keyword(section, keyword)
1225      CALL keyword_release(keyword)
1226
1227      CALL keyword_create(keyword, __LOCATION__, name="RCOV_MULTIPLICATION", &
1228                          description="Multiply Rcov integration limit for charge conservation", &
1229                          usage="RCOV_MULTIPLICATION  1.10", &
1230                          default_r_val=1._dp)
1231      CALL section_add_keyword(section, keyword)
1232      CALL keyword_release(keyword)
1233
1234      CALL keyword_create(keyword, __LOCATION__, name="SEMICORE_LEVEL", &
1235                          description="Energy at which to consider a full shell as semicore", &
1236                          usage="SEMICORE_LEVEL 1.0", &
1237                          default_r_val=1._dp, unit_str="hartree")
1238      CALL section_add_keyword(section, keyword)
1239      CALL keyword_release(keyword)
1240
1241      CALL keyword_create(keyword, __LOCATION__, name="NOOPT_NLCC", &
1242                          description="Don't optimize NLCC parameters.", &
1243                          usage="NOOPT_NLCC T", &
1244                          type_of_var=logical_t, &
1245                          default_l_val=.FALSE.)
1246      CALL section_add_keyword(section, keyword)
1247      CALL keyword_release(keyword)
1248
1249      CALL keyword_create(keyword, __LOCATION__, name="PREOPT_NLCC", &
1250                          description="Optimize NLCC parameters by fitting core charge density.", &
1251                          usage="PREOPT_NLCC T", &
1252                          type_of_var=logical_t, &
1253                          default_l_val=.FALSE.)
1254      CALL section_add_keyword(section, keyword)
1255      CALL keyword_release(keyword)
1256
1257   END SUBROUTINE create_powell_section
1258
1259! **************************************************************************************************
1260
1261END MODULE input_cp2k_atom
1262