(git:db0abe2)
Loading...
Searching...
No Matches
dm_ls_scf_types.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 Types needed for a linear scaling quickstep SCF run based on the density
10!> matrix
11!> \par History
12!> 2010.10 created [Joost VandeVondele]
13!> \author Joost VandeVondele
14! **************************************************************************************************
16 USE cp_dbcsr_api, ONLY: dbcsr_release,&
22 USE kinds, ONLY: dp
25 USE pao_types, ONLY: pao_env_type,&
27 USE pexsi_types, ONLY: lib_pexsi_env,&
31#include "./base/base_uses.f90"
32
33 IMPLICIT NONE
34
35 PRIVATE
36
37 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'dm_ls_scf_types'
38
41
43 INTEGER :: cluster_type = -1
44 LOGICAL :: do_pao = .false.
45 INTEGER, DIMENSION(:), ALLOCATABLE :: atom_to_molecule
46 TYPE(dbcsr_type) :: matrix_a = dbcsr_type()
47 TYPE(dbcsr_type) :: matrix_b = dbcsr_type()
48 END TYPE ls_mstruct_type
49
50 TYPE ls_mat_history_type
51 INTEGER :: istore = 0, nstore = 0
52 TYPE(dbcsr_type), DIMENSION(:, :), ALLOCATABLE :: matrix
53 END TYPE ls_mat_history_type
54
56 TYPE(dbcsr_type), DIMENSION(:), ALLOCATABLE :: matrix_dp
57 TYPE(dbcsr_type), DIMENSION(:), ALLOCATABLE :: matrix_p
58 TYPE(dbcsr_type), DIMENSION(:, :), ALLOCATABLE :: matrix_psave
59 TYPE(dbcsr_type), DIMENSION(:, :), ALLOCATABLE :: matrix_bch
60 REAL(kind=dp), DIMENSION(2) :: step_size = 0.0_dp
61 REAL(kind=dp), DIMENSION(2) :: shift = 0.0_dp
62 REAL(kind=dp), DIMENSION(2) :: cg_denom = 0.0_dp
63 REAL(kind=dp), DIMENSION(2) :: cg_numer = 0.0_dp
64 REAL(kind=dp), DIMENSION(6) :: energies = 0.0_dp
65 INTEGER :: line_search_step = 0
66 INTEGER, DIMENSION(2) :: bch_saved = 0
67 LOGICAL :: double_step_size = .false.
68 LOGICAL, DIMENSION(2) :: fix_shift = .false.
69
70 INTEGER :: line_search_type = 0
71 INTEGER :: n_bch_hist = 0
72 REAL(kind=dp) :: scale_filter = 0.0_dp
73 REAL(kind=dp) :: filter_factor = 0.0_dp
74 REAL(kind=dp) :: min_shift = 0.0_dp
75 REAL(kind=dp) :: min_filter = 0.0_dp
76 END TYPE ls_scf_curvy_type
77
78 TYPE chebyshev_type
79 LOGICAL :: compute_chebyshev = .false.
80 INTEGER :: n_chebyshev = 0
81 INTEGER :: n_gridpoint_dos = 0
82 REAL(kind=dp), DIMENSION(:), POINTER :: min_energy => null()
83 REAL(kind=dp), DIMENSION(:), POINTER :: max_energy => null()
84 TYPE(section_vals_type), POINTER :: print_key_dos => null()
85 TYPE(section_vals_type), POINTER :: print_key_cube => null()
86 END TYPE chebyshev_type
87
89 INTEGER :: nspins = 0, natoms = 0
90 INTEGER :: nelectron_total = 0
91 INTEGER, DIMENSION(2) :: nelectron_spin = 0
92 REAL(kind=dp), DIMENSION(2) :: mu_spin = 0.0_dp
93 REAL(kind=dp), DIMENSION(2) :: homo_spin = 0.0_dp
94 REAL(kind=dp), DIMENSION(2) :: lumo_spin = 0.0_dp
95
96#if defined(FTN_NO_DEFAULT_INIT)
97 TYPE(ls_mat_history_type) :: scf_history = ls_mat_history_type(matrix=null())
98#else
99 TYPE(ls_mat_history_type) :: scf_history = ls_mat_history_type()
100#endif
101 INTEGER :: extrapolation_order = -1
102
103 LOGICAL :: has_unit_metric = .false.
104
105 LOGICAL :: curvy_steps = .false.
106 INTEGER :: s_preconditioner_type = 0
107 INTEGER :: s_inversion_type = 0
108 INTEGER :: purification_method = 0
109 INTEGER :: sign_method = 0
110 INTEGER :: sign_order = 0
111 LOGICAL :: sign_symmetric = .false.
112 INTEGER :: submatrix_sign_method = -1
113 INTEGER :: s_sqrt_method = 0
114 INTEGER :: s_sqrt_order = 0
115
116 LOGICAL :: needs_s_inv = .false., has_s_preconditioner = .false., fixed_mu = .false., &
117 dynamic_threshold = .false., check_s_inv = .false.
118 LOGICAL :: restart_read = .false., restart_write = .false., non_monotonic = .false.
119 REAL(kind=dp) :: eps_filter = 0.0_dp, eps_scf = 0.0_dp
120
121 REAL(kind=dp) :: eps_lanczos = 0.0_dp
122 INTEGER :: max_iter_lanczos = 0
123
124 REAL(kind=dp) :: mixing_fraction = 0.0_dp
125 INTEGER :: max_scf = 0
126 LOGICAL :: ls_diis = .false.
127 INTEGER :: iter_ini_diis = 0
128 INTEGER :: nmixing = 0, max_diis = 0
129 REAL(kind=dp) :: eps_diis = 0.0_dp
130 REAL(kind=dp) :: energy_init = 0.0_dp
131
132 TYPE(dbcsr_type) :: matrix_s_inv = dbcsr_type()
133 TYPE(dbcsr_type) :: matrix_s = dbcsr_type()
134 TYPE(dbcsr_type) :: matrix_bs_sqrt = dbcsr_type(), matrix_bs_sqrt_inv = dbcsr_type()
135 TYPE(dbcsr_type) :: matrix_s_sqrt = dbcsr_type(), matrix_s_sqrt_inv = dbcsr_type()
136 TYPE(dbcsr_type), DIMENSION(:), ALLOCATABLE :: matrix_ks
137 TYPE(dbcsr_type), DIMENSION(:), ALLOCATABLE :: matrix_p
138
139 LOGICAL :: report_all_sparsities = .false., perform_mu_scan = .false., use_s_sqrt = .false.
140
141#if defined(FTN_NO_DEFAULT_INIT)
142 TYPE(ls_mstruct_type) :: ls_mstruct = ls_mstruct_type(atom_to_molecule=null())
143 TYPE(ls_scf_curvy_type) :: curvy_data = ls_scf_curvy_type(matrix_dp=null(), matrix_p=null(), &
144 matrix_psave=null(), matrix_bch=null())
145#else
146 TYPE(ls_mstruct_type) :: ls_mstruct = ls_mstruct_type()
147 TYPE(ls_scf_curvy_type) :: curvy_data = ls_scf_curvy_type()
148#endif
149
150 TYPE(chebyshev_type) :: chebyshev = chebyshev_type()
151
152 LOGICAL :: do_rho_mixing = .false.
153 INTEGER :: density_mixing_method = 0
154 TYPE(mixing_storage_type), POINTER :: mixing_store => null()
155
156 LOGICAL :: do_transport = .false.
157 LOGICAL :: do_pexsi = .false.
158
159 LOGICAL :: calculate_forces = .false.
160
161 TYPE(lib_pexsi_env) :: pexsi = lib_pexsi_env()
162
163 TYPE(mp_para_env_type), POINTER :: para_env => null()
164 LOGICAL :: do_pao = .false.
165 TYPE(pao_env_type) :: pao_env
166 END TYPE ls_scf_env_type
167
168 PUBLIC :: ls_scf_release
169
170CONTAINS
171
172! **************************************************************************************************
173!> \brief release the LS type.
174!> \param ls_scf_env ...
175!> \par History
176!> 2012.11 created [Joost VandeVondele]
177!> \author Joost VandeVondele
178! **************************************************************************************************
179 SUBROUTINE ls_scf_release(ls_scf_env)
180 TYPE(ls_scf_env_type), POINTER :: ls_scf_env
181
182 CHARACTER(len=*), PARAMETER :: routinen = 'ls_scf_release'
183
184 INTEGER :: handle, ispin, istore
185
186 CALL timeset(routinen, handle)
187
188 CALL mp_para_env_release(ls_scf_env%para_env)
189
190 DEALLOCATE (ls_scf_env%ls_mstruct%atom_to_molecule)
191
192 ! set up the buffer for the history of matrices
193 DO istore = 1, min(ls_scf_env%scf_history%istore, ls_scf_env%scf_history%nstore)
194 DO ispin = 1, SIZE(ls_scf_env%scf_history%matrix, 1)
195 CALL dbcsr_release(ls_scf_env%scf_history%matrix(ispin, istore))
196 END DO
197 END DO
198 DEALLOCATE (ls_scf_env%scf_history%matrix)
199
200 IF (ALLOCATED(ls_scf_env%matrix_p)) THEN
201 DO ispin = 1, SIZE(ls_scf_env%matrix_p)
202 CALL dbcsr_release(ls_scf_env%matrix_p(ispin))
203 END DO
204 DEALLOCATE (ls_scf_env%matrix_p)
205 END IF
206
207 IF (ASSOCIATED(ls_scf_env%chebyshev%print_key_dos)) THEN
208 CALL section_vals_release(ls_scf_env%chebyshev%print_key_dos)
209 END IF
210 IF (ASSOCIATED(ls_scf_env%chebyshev%print_key_cube)) THEN
211 CALL section_vals_release(ls_scf_env%chebyshev%print_key_cube)
212 END IF
213 IF (ASSOCIATED(ls_scf_env%chebyshev%min_energy)) THEN
214 DEALLOCATE (ls_scf_env%chebyshev%min_energy)
215 END IF
216 IF (ASSOCIATED(ls_scf_env%chebyshev%max_energy)) THEN
217 DEALLOCATE (ls_scf_env%chebyshev%max_energy)
218 END IF
219
220 IF (ASSOCIATED(ls_scf_env%mixing_store)) THEN
221 CALL mixing_storage_release(ls_scf_env%mixing_store)
222 DEALLOCATE (ls_scf_env%mixing_store)
223 END IF
224
225 IF (ls_scf_env%do_pexsi) THEN
226 CALL lib_pexsi_finalize(ls_scf_env%pexsi)
227 END IF
228
229 IF (ls_scf_env%do_pao) THEN
230 CALL pao_finalize(ls_scf_env%pao_env)
231 END IF
232
233 DEALLOCATE (ls_scf_env)
234
235 CALL timestop(handle)
236
237 END SUBROUTINE ls_scf_release
238
239END MODULE dm_ls_scf_types
subroutine, public dbcsr_release(matrix)
...
Types needed for a linear scaling quickstep SCF run based on the density matrix.
subroutine, public ls_scf_release(ls_scf_env)
release the LS type.
collects all constants needed in input so that they can be used without circular dependencies
integer, parameter, public ls_cluster_molecular
integer, parameter, public ls_cluster_atomic
objects that represent the structure of input sections and the data contained in an input section
recursive subroutine, public section_vals_release(section_vals)
releases the given object
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
Interface to the message passing library MPI.
subroutine, public mp_para_env_release(para_env)
releases the para object (to be called when you don't want anymore the shared copy of this object)
Types used by the PAO machinery.
Definition pao_types.F:12
subroutine, public pao_finalize(pao)
Finalize the PAO environment.
Definition pao_types.F:240
Environment storing all data that is needed in order to call the DFT driver of the PEXSI library with...
Definition pexsi_types.F:18
subroutine, public lib_pexsi_finalize(pexsi_env)
Release all PEXSI data.
module that contains the definitions of the scf types
subroutine, public mixing_storage_release(mixing_store)
releases a mixing_storage
stores all the informations relevant to an mpi environment
All PEXSI related data.
Definition pexsi_types.F:87