(git:92574dc)
Loading...
Searching...
No Matches
eeq_input.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2026 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7
8! **************************************************************************************************
9!> \brief Input definition and setup for EEQ model
10!> \author JGH [2024]
11! **************************************************************************************************
21 USE kinds, ONLY: dp
22#include "./base/base_uses.f90"
23
24 IMPLICIT NONE
25 PRIVATE
26
28 LOGICAL :: direct = .false.
29 LOGICAL :: sparse = .false.
30 REAL(kind=dp) :: eps_diis = 1.0e-09_dp
31 REAL(kind=dp) :: alpha = 0.75_dp
32 INTEGER :: mdiis = 12
33 INTEGER :: sdiis = 3
34 INTEGER :: max_diis = 500
35 INTEGER :: sparse_threshold = 256
36 END TYPE eeq_solver_type
37
38 CHARACTER(len=*), PARAMETER, PRIVATE :: modulen = 'eeq_input'
39
40 PUBLIC :: eeq_solver_type
41 PUBLIC :: read_eeq_param
43
44CONTAINS
45
46! **************************************************************************************************
47!> \brief ...
48!> \param section ...
49! **************************************************************************************************
50 SUBROUTINE create_eeq_control_section(section)
51 TYPE(section_type), POINTER :: section
52
53 TYPE(keyword_type), POINTER :: keyword
54
55 cpassert(.NOT. ASSOCIATED(section))
56 CALL section_create(section, __location__, name="EEQ", &
57 description="Parameters needed for EEQ method and solver", &
58 n_keywords=1, n_subsections=1, repeats=.false.)
59
60 NULLIFY (keyword)
61 CALL keyword_create(keyword, __location__, name="DIRECT", &
62 description="Use a direct method to solve the EEQ equations in PBC (matrix solver)", &
63 usage="DIRECT", default_l_val=.false., lone_keyword_l_val=.true.)
64 CALL section_add_keyword(section, keyword)
65 CALL keyword_release(keyword)
66
67 CALL keyword_create(keyword, __location__, name="SPARSE", &
68 description="Use the matrix-free projected-CG solver for periodic EEQ. "// &
69 "The short-range response is stored sparsely and the translationally invariant "// &
70 "long-range Coulomb response is applied by the FFT-based SPME operator. "// &
71 "This path is shared by methods using CP2K EEQ charges, including GFN0-xTB "// &
72 "and the internal DFT-D4 implementation.", &
73 usage="SPARSE", default_l_val=.false., lone_keyword_l_val=.true.)
74 CALL section_add_keyword(section, keyword)
75 CALL keyword_release(keyword)
76
77 CALL keyword_create(keyword, __location__, name="SPARSE_THRESHOLD", &
78 description="Automatically use the sparse periodic EEQ solver at or above "// &
79 "this number of atoms for every method using CP2K EEQ charges. A non-positive "// &
80 "value disables automatic selection.", &
81 usage="SPARSE_THRESHOLD 256", default_i_val=256)
82 CALL section_add_keyword(section, keyword)
83 CALL keyword_release(keyword)
84
85 CALL keyword_create(keyword, __location__, name="EPS_DIIS", &
86 description="Accuracy for the iterative solver.", &
87 usage="EPS_DIIS 1.0E-10", default_r_val=1.0e-10_dp)
88 CALL section_add_keyword(section, keyword)
89 CALL keyword_release(keyword)
90
91 CALL keyword_create(keyword, __location__, name="ALPHA", &
92 description="Step length of initial steepest descent steps.", &
93 usage="ALPHA 1.0", default_r_val=0.75_dp)
94 CALL section_add_keyword(section, keyword)
95 CALL keyword_release(keyword)
96
97 CALL keyword_create(keyword, __location__, name="MAX_DIIS", &
98 description="Max. number of iterations for EEQ solver.", &
99 usage="MAX_DIIS 100", default_i_val=500)
100 CALL section_add_keyword(section, keyword)
101 CALL keyword_release(keyword)
102
103 CALL keyword_create(keyword, __location__, name="MDIIS", &
104 description="Max. number of DIIS vectors used.", &
105 usage="MDIIS 10", default_i_val=12)
106 CALL section_add_keyword(section, keyword)
107 CALL keyword_release(keyword)
108
109 CALL keyword_create(keyword, __location__, name="SDIIS", &
110 description="Number of vectors accumulated before starting DIIS.", &
111 usage="SDIIS 4", default_i_val=3)
112 CALL section_add_keyword(section, keyword)
113 CALL keyword_release(keyword)
114
115 END SUBROUTINE create_eeq_control_section
116
117! **************************************************************************************************
118!> \brief ...
119!> \param eeq_section ...
120!> \param eeq_sparam ...
121! **************************************************************************************************
122 SUBROUTINE read_eeq_param(eeq_section, eeq_sparam)
123
124 TYPE(section_vals_type), POINTER :: eeq_section
125 TYPE(eeq_solver_type), INTENT(INOUT) :: eeq_sparam
126
127 CALL section_vals_val_get(eeq_section, "DIRECT", l_val=eeq_sparam%direct)
128 CALL section_vals_val_get(eeq_section, "SPARSE", l_val=eeq_sparam%sparse)
129 CALL section_vals_val_get(eeq_section, "SPARSE_THRESHOLD", i_val=eeq_sparam%sparse_threshold)
130 CALL section_vals_val_get(eeq_section, "EPS_DIIS", r_val=eeq_sparam%eps_diis)
131 CALL section_vals_val_get(eeq_section, "ALPHA", r_val=eeq_sparam%alpha)
132 CALL section_vals_val_get(eeq_section, "MAX_DIIS", i_val=eeq_sparam%max_diis)
133 CALL section_vals_val_get(eeq_section, "MDIIS", i_val=eeq_sparam%mdiis)
134 CALL section_vals_val_get(eeq_section, "SDIIS", i_val=eeq_sparam%sdiis)
135
136 END SUBROUTINE read_eeq_param
137
138END MODULE eeq_input
Input definition and setup for EEQ model.
Definition eeq_input.F:12
subroutine, public create_eeq_control_section(section)
...
Definition eeq_input.F:51
subroutine, public read_eeq_param(eeq_section, eeq_sparam)
...
Definition eeq_input.F:123
represents keywords in an input
subroutine, public keyword_release(keyword)
releases the given keyword (see doc/ReferenceCounting.html)
subroutine, public keyword_create(keyword, location, name, description, usage, type_of_var, n_var, repeats, variants, default_val, default_l_val, default_r_val, default_lc_val, default_c_val, default_i_val, default_l_vals, default_r_vals, default_c_vals, default_i_vals, lone_keyword_val, lone_keyword_l_val, lone_keyword_r_val, lone_keyword_c_val, lone_keyword_i_val, lone_keyword_l_vals, lone_keyword_r_vals, lone_keyword_c_vals, lone_keyword_i_vals, enum_c_vals, enum_i_vals, enum, enum_strict, enum_desc, unit_str, citations, deprecation_notice, removed)
creates a keyword object
objects that represent the structure of input sections and the data contained in an input section
subroutine, public section_create(section, location, name, description, n_keywords, n_subsections, repeats, citations, deprecation_notice)
creates a list of keywords
subroutine, public section_add_keyword(section, keyword)
adds a keyword to the given section
subroutine, public section_vals_val_get(section_vals, keyword_name, i_rep_section, i_rep_val, n_rep_val, val, l_val, i_val, r_val, c_val, l_vals, i_vals, r_vals, c_vals, explicit)
returns the requested value
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
represent a keyword in the input
represent a section of the input file