16 USE dbcsr_api,
ONLY: dbcsr_release,&
31 #include "./base/base_uses.f90"
37 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'dm_ls_scf_types'
43 INTEGER :: cluster_type = -1
44 LOGICAL :: do_pao = .false.
45 INTEGER,
DIMENSION(:),
ALLOCATABLE :: atom_to_molecule
46 TYPE(dbcsr_type) :: matrix_A
47 TYPE(dbcsr_type) :: matrix_B
50 TYPE ls_mat_history_type
51 INTEGER :: istore = 0, nstore = 0
52 TYPE(dbcsr_type),
DIMENSION(:, :),
ALLOCATABLE :: matrix
55 TYPE ls_scf_curvy_type
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.
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
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()
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
97 TYPE(ls_mat_history_type) :: scf_history = ls_mat_history_type(matrix=null())
98 INTEGER :: extrapolation_order = -1
100 LOGICAL :: has_unit_metric = .false.
102 LOGICAL :: curvy_steps = .false.
103 INTEGER :: s_preconditioner_type = 0
104 INTEGER :: s_inversion_type = 0
105 INTEGER :: purification_method = 0
106 INTEGER :: sign_method = 0
107 INTEGER :: sign_order = 0
108 LOGICAL :: sign_symmetric = .false.
109 INTEGER :: submatrix_sign_method = -1
110 INTEGER :: s_sqrt_method = 0
111 INTEGER :: s_sqrt_order = 0
113 LOGICAL :: needs_s_inv = .false., has_s_preconditioner = .false., fixed_mu = .false., &
114 dynamic_threshold = .false., check_s_inv = .false.
115 LOGICAL :: restart_read = .false., restart_write = .false., non_monotonic = .false.
116 REAL(KIND=
dp) :: eps_filter = 0.0_dp, eps_scf = 0.0_dp
118 REAL(KIND=
dp) :: eps_lanczos = 0.0_dp
119 INTEGER :: max_iter_lanczos = 0
121 REAL(KIND=
dp) :: mixing_fraction = 0.0_dp
122 INTEGER :: max_scf = 0
123 LOGICAL :: ls_diis = .false.
124 INTEGER :: iter_ini_diis = 0
125 INTEGER :: nmixing = 0, max_diis = 0
126 REAL(KIND=
dp) :: eps_diis = 0.0_dp
127 REAL(KIND=
dp) :: energy_init = 0.0_dp
129 TYPE(dbcsr_type) :: matrix_s_inv
130 TYPE(dbcsr_type) :: matrix_s
131 TYPE(dbcsr_type) :: matrix_bs_sqrt, matrix_bs_sqrt_inv
132 TYPE(dbcsr_type) :: matrix_s_sqrt, matrix_s_sqrt_inv
133 TYPE(dbcsr_type),
DIMENSION(:),
ALLOCATABLE :: matrix_ks
134 TYPE(dbcsr_type),
DIMENSION(:),
ALLOCATABLE :: matrix_p
136 LOGICAL :: report_all_sparsities = .false., perform_mu_scan = .false., use_s_sqrt = .false.
138 TYPE(ls_mstruct_type) :: ls_mstruct
139 TYPE(ls_scf_curvy_type) :: curvy_data = ls_scf_curvy_type(matrix_dp=null(), matrix_p=null(), &
140 matrix_psave=null(), matrix_bch=null())
142 TYPE(chebyshev_type) :: chebyshev = chebyshev_type()
144 LOGICAL :: do_rho_mixing = .false.
145 INTEGER :: density_mixing_method = 0
146 TYPE(mixing_storage_type),
POINTER :: mixing_store => null()
148 LOGICAL :: do_transport = .false.
149 LOGICAL :: do_pexsi = .false.
151 LOGICAL :: calculate_forces = .false.
153 TYPE(lib_pexsi_env) :: pexsi
155 TYPE(mp_para_env_type),
POINTER :: para_env => null()
156 LOGICAL :: do_pao = .false.
157 TYPE(pao_env_type) :: pao_env
158 END TYPE ls_scf_env_type
172 TYPE(ls_scf_env_type),
POINTER :: ls_scf_env
174 CHARACTER(len=*),
PARAMETER :: routinen =
'ls_scf_release'
176 INTEGER :: handle, ispin, istore
178 CALL timeset(routinen, handle)
182 DEALLOCATE (ls_scf_env%ls_mstruct%atom_to_molecule)
185 DO istore = 1, min(ls_scf_env%scf_history%istore, ls_scf_env%scf_history%nstore)
186 DO ispin = 1,
SIZE(ls_scf_env%scf_history%matrix, 1)
187 CALL dbcsr_release(ls_scf_env%scf_history%matrix(ispin, istore))
190 DEALLOCATE (ls_scf_env%scf_history%matrix)
192 IF (
ALLOCATED(ls_scf_env%matrix_p))
THEN
193 DO ispin = 1,
SIZE(ls_scf_env%matrix_p)
194 CALL dbcsr_release(ls_scf_env%matrix_p(ispin))
196 DEALLOCATE (ls_scf_env%matrix_p)
199 IF (
ASSOCIATED(ls_scf_env%chebyshev%print_key_dos)) &
201 IF (
ASSOCIATED(ls_scf_env%chebyshev%print_key_cube)) &
203 IF (
ASSOCIATED(ls_scf_env%chebyshev%min_energy))
THEN
204 DEALLOCATE (ls_scf_env%chebyshev%min_energy)
206 IF (
ASSOCIATED(ls_scf_env%chebyshev%max_energy))
THEN
207 DEALLOCATE (ls_scf_env%chebyshev%max_energy)
210 IF (
ASSOCIATED(ls_scf_env%mixing_store))
THEN
212 DEALLOCATE (ls_scf_env%mixing_store)
215 IF (ls_scf_env%do_pexsi)
THEN
219 IF (ls_scf_env%do_pao) &
222 DEALLOCATE (ls_scf_env)
224 CALL timestop(handle)
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.
Defines the basic variable types.
integer, parameter, public dp
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.
subroutine, public pao_finalize(pao)
Finalize the PAO environment.
Environment storing all data that is needed in order to call the DFT driver of the PEXSI library with...
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