19 USE iso_c_binding,
ONLY: c_intptr_t
38#include "./base/base_uses.f90"
44 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'pexsi_types'
46 LOGICAL,
PARAMETER,
PRIVATE :: careful_mod = .false.
94 REAL(kind=
dp),
DIMENSION(:),
POINTER :: kts => null()
96 POINTER :: matrix_w => null()
97 INTEGER(KIND=C_INTPTR_T) :: plan = 0_c_intptr_t
98 INTEGER :: nspin = -1, num_ranks_per_pole = -1
101 POINTER :: max_ev_vector => null()
103 INTEGER,
DIMENSION(2) :: mp_dims = -1
105 LOGICAL :: csr_screening = .false., do_adaptive_tol_nel = .false.
106 REAL(kind=
dp) :: adaptive_nel_alpha = -1.0_dp, adaptive_nel_beta = -1.0_dp, &
107 tol_nel_initial = -1.0_dp, tol_nel_target = -1.0_dp
125 INTEGER,
INTENT(IN) :: nspin
127 CHARACTER(len=*),
PARAMETER :: routinen =
'lib_pexsi_init'
129 INTEGER :: handle, ispin, npsymbfact, &
134 IF (logger%para_env%is_source())
THEN
140 CALL timeset(routinen, handle)
145 pexsi_env%mp_group = mp_group
146 associate(numnodes => pexsi_env%mp_group%num_pe)
150 IF ((pexsi_env%num_ranks_per_pole > numnodes) &
151 .OR. (pexsi_env%num_ranks_per_pole == 0))
THEN
152 pexsi_env%num_ranks_per_pole = numnodes
158 DO WHILE (mod(numnodes, pexsi_env%num_ranks_per_pole) /= 0)
159 pexsi_env%num_ranks_per_pole = pexsi_env%num_ranks_per_pole + 1
163 IF ((npsymbfact > pexsi_env%num_ranks_per_pole) .OR. (npsymbfact == 0))
THEN
169 pexsi_env%mp_dims = 0
170 CALL mp_dims_create(pexsi_env%num_ranks_per_pole, pexsi_env%mp_dims)
173 pexsi_env%nspin = nspin
174 ALLOCATE (pexsi_env%kTS(nspin))
175 pexsi_env%kTS(:) = 0.0_dp
176 ALLOCATE (pexsi_env%max_ev_vector(nspin))
177 ALLOCATE (pexsi_env%matrix_w(nspin))
178 DO ispin = 1, pexsi_env%nspin
179 ALLOCATE (pexsi_env%matrix_w(ispin)%matrix)
184 pexsi_env%mp_dims(2), -1)
187 pexsi_env%do_adaptive_tol_nel = .false.
190 IF (unit_nr > 0)
CALL print_pexsi_info(pexsi_env, unit_nr)
192 CALL timestop(handle)
205 CHARACTER(len=*),
PARAMETER :: routinen =
'lib_pexsi_finalize'
207 INTEGER :: handle, ispin
209 CALL timeset(routinen, handle)
210 CALL cp_pexsi_plan_finalize(pexsi_env%plan)
211 DEALLOCATE (pexsi_env%kTS)
212 DEALLOCATE (pexsi_env%max_ev_vector)
213 DO ispin = 1, pexsi_env%nspin
214 DEALLOCATE (pexsi_env%matrix_w(ispin)%matrix)
216 DEALLOCATE (pexsi_env%matrix_w)
217 CALL timestop(handle)
234 INTEGER,
INTENT(IN) :: direction
235 REAL(kind=dp),
INTENT(INOUT),
OPTIONAL :: numelectron
236 TYPE(dbcsr_type),
INTENT(INOUT),
OPTIONAL :: matrix_p
237 TYPE(dbcsr_p_type),
INTENT(INOUT),
OPTIONAL :: matrix_w
238 REAL(kind=dp),
INTENT(INOUT),
OPTIONAL :: kts
240 CHARACTER(len=*),
PARAMETER :: routinen =
'convert_nspin_cp2k_pexsi'
243 REAL(kind=dp) :: scaling
245 CALL timeset(routinen, handle)
247 SELECT CASE (direction)
254 IF (
PRESENT(numelectron)) numelectron = scaling*numelectron
255 IF (
PRESENT(matrix_p))
CALL dbcsr_scale(matrix_p, scaling)
256 IF (
PRESENT(matrix_w))
CALL dbcsr_scale(matrix_w%matrix, scaling)
257 IF (
PRESENT(kts)) kts = scaling*kts
259 CALL timestop(handle)
267 SUBROUTINE print_pexsi_info(pexsi_env, unit_nr)
269 INTEGER,
INTENT(IN) :: unit_nr
271 INTEGER :: npsymbfact, numnodes, numpole, ordering, &
273 REAL(kind=dp) :: gap, muinertiaexpansion, &
274 muinertiatolerance, mumax0, mumin0, &
275 mupexsisafeguard, temperature
277 numnodes = pexsi_env%mp_group%num_pe
279 CALL cp_pexsi_get_options(pexsi_env%options, temperature=temperature, gap=gap, &
280 numpole=numpole, mumin0=mumin0, mumax0=mumax0, muinertiatolerance= &
281 muinertiatolerance, muinertiaexpansion=muinertiaexpansion, &
282 mupexsisafeguard=mupexsisafeguard, ordering=ordering, rowordering=rowordering, &
283 npsymbfact=npsymbfact)
285 WRITE (unit_nr,
'(/A)')
" PEXSI| Initialized with parameters"
286 WRITE (unit_nr,
'(A,T61,E20.3)')
" PEXSI| Electronic temperature", temperature
287 WRITE (unit_nr,
'(A,T61,E20.3)')
" PEXSI| Spectral gap", gap
288 WRITE (unit_nr,
'(A,T61,I20)')
" PEXSI| Number of poles", numpole
289 WRITE (unit_nr,
'(A,T61,E20.3)')
" PEXSI| Target tolerance in number of electrons", &
290 pexsi_env%tol_nel_target
291 WRITE (unit_nr,
'(A,T61,E20.3)')
" PEXSI| Convergence tolerance for inertia counting in mu", &
293 WRITE (unit_nr,
'(A,T61,E20.3)')
" PEXSI| Restart tolerance for inertia counting in mu", &
295 WRITE (unit_nr,
'(A,T61,E20.3)')
" PEXSI| Expansion of mu interval for inertia counting", &
298 WRITE (unit_nr,
'(/A)')
" PEXSI| Parallelization scheme"
299 WRITE (unit_nr,
'(A,T61,I20)')
" PEXSI| Number of poles processed in parallel", &
300 numnodes/pexsi_env%num_ranks_per_pole
301 WRITE (unit_nr,
'(A,T61,I20)')
" PEXSI| Number of processors per pole", &
302 pexsi_env%num_ranks_per_pole
303 WRITE (unit_nr,
'(A,T71,I5,T76,I5)')
" PEXSI| Process grid dimensions", &
304 pexsi_env%mp_dims(1), pexsi_env%mp_dims(2)
305 SELECT CASE (ordering)
307 WRITE (unit_nr,
'(A,T61,A20)')
" PEXSI| Ordering strategy",
"parallel"
309 WRITE (unit_nr,
'(A,T61,A20)')
" PEXSI| Ordering strategy",
"sequential"
311 WRITE (unit_nr,
'(A,T61,A20)')
" PEXSI| Ordering strategy",
"multiple minimum degree"
313 SELECT CASE (rowordering)
315 WRITE (unit_nr,
'(A,T61,A20)')
" PEXSI| Row permutation strategy",
"no row permutation"
317 WRITE (unit_nr,
'(A,T61,A20)')
" PEXSI| Row permutation strategy",
"make diagonal entry larger than off diagonal"
319 IF (ordering == 0)
WRITE (unit_nr,
'(A,T61,I20/)') &
320 " PEXSI| Number of processors for symbolic factorization", npsymbfact
322 END SUBROUTINE print_pexsi_info
collects all references to literature in CP2K as new algorithms / method are included from literature...
integer, save, public lin2009
integer, save, public lin2013
subroutine, public dbcsr_scale(matrix, alpha_scalar)
...
CSR matrix type, DBCSR-CSR conversions, and CSR file I/O built on cp_dbcsr_api.
various routines to log and control the output. The idea is that decisions about where to log should ...
recursive integer function, public cp_logger_get_default_unit_nr(logger, local, skip_not_ionode)
asks the default unit number of the given logger. try to use cp_logger_get_unit_nr
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
Defines the basic variable types.
integer, parameter, public dp
Interface to the message passing library MPI.
subroutine, public mp_dims_create(nodes, dims)
wrapper to MPI_Dims_create
Interface to the PEXSI library, providing wrappers for all PEXSI routines that are called inside CP2K...
subroutine, public cp_pexsi_set_options(pexsi_options, temperature, gap, deltae, numpole, isinertiacount, maxpexsiiter, mumin0, mumax0, mu0, muinertiatolerance, muinertiaexpansion, mupexsisafeguard, numelectronpexsitolerance, matrixtype, issymbolicfactorize, ordering, rowordering, npsymbfact, verbosity)
Set PEXSI internal options.
subroutine, public cp_pexsi_get_options(pexsi_options, temperature, gap, deltae, numpole, isinertiacount, maxpexsiiter, mumin0, mumax0, mu0, muinertiatolerance, muinertiaexpansion, mupexsisafeguard, numelectronpexsitolerance, matrixtype, issymbolicfactorize, ordering, rowordering, npsymbfact, verbosity)
Access PEXSI internal options.
subroutine, public cp_pexsi_plan_finalize(plan)
...
integer(kind=c_intptr_t) function, public cp_pexsi_plan_initialize(comm, numprocrow, numproccol, outputfileindex)
...
Environment storing all data that is needed in order to call the DFT driver of the PEXSI library with...
subroutine, public convert_nspin_cp2k_pexsi(direction, numelectron, matrix_p, matrix_w, kts)
Scale various quantities with factors of 2. This converts spin restricted DFT calculations (PEXSI) to...
integer, parameter, public cp2k_to_pexsi
subroutine, public lib_pexsi_init(pexsi_env, mp_group, nspin)
Initialize PEXSI.
integer, parameter, public pexsi_to_cp2k
subroutine, public lib_pexsi_finalize(pexsi_env)
Release all PEXSI data.
type of a logger, at the moment it contains just a print level starting at which level it should be l...