38#include "./base/base_uses.f90"
44 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_mo_types'
51 LOGICAL :: use_mo_coeff_b = .false.
57 REAL(kind=
dp),
DIMENSION(:),
POINTER :: eigenvalues => null(), &
58 occupation_numbers => null()
57 REAL(kind=
dp),
DIMENSION(:),
POINTER :: eigenvalues => null(), &
…
61 REAL(kind=
dp) :: maxocc = -1
63 INTEGER :: nelectron = -1
64 REAL(kind=
dp) :: n_el_f = -1.0_dp
72 LOGICAL :: uniform_occupation = .false.
74 REAL(kind=
dp) :: kts = -1.0_dp
76 REAL(kind=
dp) :: mu = 0.0_dp
78 REAL(kind=
dp) :: flexible_electron_count = -1.0_dp
109 TYPE(
mo_set_type),
INTENT(INOUT) :: mo_set_new, mo_set_old
113 mo_set_new%maxocc = mo_set_old%maxocc
114 mo_set_new%nelectron = mo_set_old%nelectron
115 mo_set_new%n_el_f = mo_set_old%n_el_f
116 mo_set_new%nao = mo_set_old%nao
117 mo_set_new%nmo = mo_set_old%nmo
118 mo_set_new%homo = mo_set_old%homo
119 mo_set_new%lfomo = mo_set_old%lfomo
120 mo_set_new%uniform_occupation = mo_set_old%uniform_occupation
121 mo_set_new%kTS = mo_set_old%kTS
122 mo_set_new%mu = mo_set_old%mu
123 mo_set_new%flexible_electron_count = mo_set_old%flexible_electron_count
127 CALL cp_fm_to_fm(mo_set_old%mo_coeff, mo_set_new%mo_coeff)
134 mo_set_new%eigenvalues = mo_set_old%eigenvalues
136 mo_set_new%occupation_numbers = mo_set_old%occupation_numbers
154 mo_set_new%maxocc = mo_set_old%maxocc
155 mo_set_new%nelectron = mo_set_old%nelectron
156 mo_set_new%n_el_f = mo_set_old%n_el_f
157 mo_set_new%nao = mo_set_old%nao
158 mo_set_new%nmo = mo_set_old%nmo
159 mo_set_new%homo = mo_set_old%homo
160 mo_set_new%lfomo = mo_set_old%lfomo
161 mo_set_new%uniform_occupation = mo_set_old%uniform_occupation
162 mo_set_new%kTS = mo_set_old%kTS
163 mo_set_new%mu = mo_set_old%mu
164 mo_set_new%flexible_electron_count = mo_set_old%flexible_electron_count
168 NULLIFY (mo_set_new%mo_coeff)
169 ALLOCATE (mo_set_new%mo_coeff)
170 CALL cp_fm_create(mo_set_new%mo_coeff, mo_set_old%mo_coeff%matrix_struct)
171 CALL cp_fm_to_fm(mo_set_old%mo_coeff, mo_set_new%mo_coeff)
173 NULLIFY (mo_set_new%mo_coeff_b)
174 IF (
ASSOCIATED(mo_set_old%mo_coeff_b))
THEN
176 CALL dbcsr_copy(mo_set_new%mo_coeff_b, mo_set_old%mo_coeff_b)
178 mo_set_new%use_mo_coeff_b = mo_set_old%use_mo_coeff_b
180 ALLOCATE (mo_set_new%eigenvalues(nmo))
181 mo_set_new%eigenvalues = mo_set_old%eigenvalues
183 ALLOCATE (mo_set_new%occupation_numbers(nmo))
184 mo_set_new%occupation_numbers = mo_set_old%occupation_numbers
205 flexible_electron_count)
208 INTEGER,
INTENT(IN) :: nao, nmo, nelectron
209 REAL(kind=
dp),
INTENT(IN) :: n_el_f, maxocc, flexible_electron_count
211 mo_set%maxocc = maxocc
212 mo_set%nelectron = nelectron
213 mo_set%n_el_f = n_el_f
218 mo_set%uniform_occupation = .true.
221 mo_set%flexible_electron_count = flexible_electron_count
223 NULLIFY (mo_set%eigenvalues)
224 NULLIFY (mo_set%occupation_numbers)
225 NULLIFY (mo_set%mo_coeff)
226 NULLIFY (mo_set%mo_coeff_b)
227 mo_set%use_mo_coeff_b = .false.
248 TYPE(
cp_fm_type),
INTENT(IN),
OPTIONAL :: fm_ref
250 CHARACTER(LEN=*),
INTENT(in) :: name
252 INTEGER :: nao, nmo, nomo
254 cpassert(.NOT.
ASSOCIATED(mo_set%eigenvalues))
255 cpassert(.NOT.
ASSOCIATED(mo_set%occupation_numbers))
256 cpassert(.NOT.
ASSOCIATED(mo_set%mo_coeff))
258 cpassert(
PRESENT(fm_pool) .NEQV. (
PRESENT(fm_ref) .NEQV.
PRESENT(fm_struct)))
259 NULLIFY (mo_set%mo_coeff)
260 IF (
PRESENT(fm_pool))
THEN
261 ALLOCATE (mo_set%mo_coeff)
263 ELSE IF (
PRESENT(fm_ref))
THEN
264 ALLOCATE (mo_set%mo_coeff)
265 CALL cp_fm_create(mo_set%mo_coeff, fm_ref%matrix_struct, name=name)
266 ELSE IF (
PRESENT(fm_struct))
THEN
267 ALLOCATE (mo_set%mo_coeff)
268 cpassert(
ASSOCIATED(fm_struct))
269 CALL cp_fm_create(mo_set%mo_coeff, fm_struct, name=name)
271 CALL cp_fm_get_info(mo_set%mo_coeff, nrow_global=nao, ncol_global=nmo)
273 cpassert(nao >= mo_set%nao)
274 cpassert(nmo >= mo_set%nmo)
276 ALLOCATE (mo_set%eigenvalues(nmo))
277 mo_set%eigenvalues(:) = 0.0_dp
279 ALLOCATE (mo_set%occupation_numbers(nmo))
281 mo_set%occupation_numbers(:) = 0.0_dp
283 IF (mo_set%nelectron == 0)
THEN
287 IF (
modulo(mo_set%nelectron, int(mo_set%maxocc)) == 0)
THEN
288 nomo = nint(mo_set%nelectron/mo_set%maxocc)
289 mo_set%occupation_numbers(1:nomo) = mo_set%maxocc
291 nomo = int(mo_set%nelectron/mo_set%maxocc) + 1
293 mo_set%occupation_numbers(1:nomo - 1) = mo_set%maxocc
294 mo_set%occupation_numbers(nomo) = mo_set%nelectron - (nomo - 1)*mo_set%maxocc
297 cpassert(nmo >= nomo)
298 cpassert((
SIZE(mo_set%occupation_numbers) == nmo))
301 mo_set%lfomo = nomo + 1
302 mo_set%mu = mo_set%eigenvalues(nomo)
315 TYPE(
mo_set_type),
DIMENSION(2),
INTENT(IN) :: mo_array
316 LOGICAL,
INTENT(in),
OPTIONAL :: convert_dbcsr
318 CHARACTER(LEN=*),
PARAMETER :: routinen =
'mo_set_restrict'
321 LOGICAL :: my_convert_dbcsr
323 CALL timeset(routinen, handle)
325 my_convert_dbcsr = .false.
326 IF (
PRESENT(convert_dbcsr)) my_convert_dbcsr = convert_dbcsr
328 cpassert(mo_array(1)%nmo >= mo_array(2)%nmo)
331 IF (my_convert_dbcsr)
THEN
333 mo_array(2)%nmo, 1, 1, &
334 para_env=mo_array(1)%mo_coeff%matrix_struct%para_env, &
335 blacs_env=mo_array(1)%mo_coeff%matrix_struct%context)
337 CALL cp_fm_to_fm(mo_array(1)%mo_coeff, mo_array(2)%mo_coeff, mo_array(2)%nmo)
340 CALL timestop(handle)
355 IF (
ASSOCIATED(mo_set%eigenvalues))
THEN
356 DEALLOCATE (mo_set%eigenvalues)
357 NULLIFY (mo_set%eigenvalues)
359 IF (
ASSOCIATED(mo_set%occupation_numbers))
THEN
360 DEALLOCATE (mo_set%occupation_numbers)
361 NULLIFY (mo_set%occupation_numbers)
363 IF (
ASSOCIATED(mo_set%mo_coeff))
THEN
365 DEALLOCATE (mo_set%mo_coeff)
366 NULLIFY (mo_set%mo_coeff)
368 IF (
ASSOCIATED(mo_set%mo_coeff_b))
CALL dbcsr_release_p(mo_set%mo_coeff_b)
394 SUBROUTINE get_mo_set(mo_set, maxocc, homo, lfomo, nao, nelectron, n_el_f, nmo, &
395 eigenvalues, occupation_numbers, mo_coeff, mo_coeff_b, &
396 uniform_occupation, kTS, mu, flexible_electron_count)
399 REAL(kind=
dp),
INTENT(OUT),
OPTIONAL :: maxocc
400 INTEGER,
INTENT(OUT),
OPTIONAL :: homo, lfomo, nao, nelectron
401 REAL(kind=
dp),
INTENT(OUT),
OPTIONAL :: n_el_f
402 INTEGER,
INTENT(OUT),
OPTIONAL :: nmo
403 REAL(kind=
dp),
DIMENSION(:),
OPTIONAL,
POINTER :: eigenvalues, occupation_numbers
404 TYPE(
cp_fm_type),
OPTIONAL,
POINTER :: mo_coeff
405 TYPE(
dbcsr_type),
OPTIONAL,
POINTER :: mo_coeff_b
406 LOGICAL,
INTENT(OUT),
OPTIONAL :: uniform_occupation
407 REAL(kind=
dp),
INTENT(OUT),
OPTIONAL :: kts, mu, flexible_electron_count
409 IF (
PRESENT(maxocc)) maxocc = mo_set%maxocc
410 IF (
PRESENT(homo)) homo = mo_set%homo
411 IF (
PRESENT(lfomo)) lfomo = mo_set%lfomo
412 IF (
PRESENT(nao)) nao = mo_set%nao
413 IF (
PRESENT(nelectron)) nelectron = mo_set%nelectron
414 IF (
PRESENT(n_el_f)) n_el_f = mo_set%n_el_f
415 IF (
PRESENT(nmo)) nmo = mo_set%nmo
416 IF (
PRESENT(eigenvalues)) eigenvalues => mo_set%eigenvalues
417 IF (
PRESENT(occupation_numbers))
THEN
418 occupation_numbers => mo_set%occupation_numbers
420 IF (
PRESENT(mo_coeff)) mo_coeff => mo_set%mo_coeff
421 IF (
PRESENT(mo_coeff_b)) mo_coeff_b => mo_set%mo_coeff_b
422 IF (
PRESENT(uniform_occupation)) uniform_occupation = mo_set%uniform_occupation
423 IF (
PRESENT(kts)) kts = mo_set%kTS
424 IF (
PRESENT(mu)) mu = mo_set%mu
425 IF (
PRESENT(flexible_electron_count)) flexible_electron_count = mo_set%flexible_electron_count
394 SUBROUTINE get_mo_set(mo_set, maxocc, homo, lfomo, nao, nelectron, n_el_f, nmo, &
…
449 SUBROUTINE set_mo_set(mo_set, maxocc, homo, lfomo, nao, nelectron, n_el_f, nmo, &
450 eigenvalues, occupation_numbers, uniform_occupation, &
451 kTS, mu, flexible_electron_count)
454 REAL(kind=
dp),
INTENT(IN),
OPTIONAL :: maxocc
455 INTEGER,
INTENT(IN),
OPTIONAL :: homo, lfomo, nao, nelectron
456 REAL(kind=
dp),
INTENT(IN),
OPTIONAL :: n_el_f
457 INTEGER,
INTENT(IN),
OPTIONAL :: nmo
458 REAL(kind=
dp),
DIMENSION(:),
OPTIONAL,
POINTER :: eigenvalues, occupation_numbers
459 LOGICAL,
INTENT(IN),
OPTIONAL :: uniform_occupation
460 REAL(kind=
dp),
INTENT(IN),
OPTIONAL :: kts, mu, flexible_electron_count
462 IF (
PRESENT(maxocc)) mo_set%maxocc = maxocc
463 IF (
PRESENT(homo)) mo_set%homo = homo
464 IF (
PRESENT(lfomo)) mo_set%lfomo = lfomo
465 IF (
PRESENT(nao)) mo_set%nao = nao
466 IF (
PRESENT(nelectron)) mo_set%nelectron = nelectron
467 IF (
PRESENT(n_el_f)) mo_set%n_el_f = n_el_f
468 IF (
PRESENT(nmo)) mo_set%nmo = nmo
469 IF (
PRESENT(eigenvalues))
THEN
470 IF (
ASSOCIATED(mo_set%eigenvalues))
THEN
471 DEALLOCATE (mo_set%eigenvalues)
473 mo_set%eigenvalues => eigenvalues
475 IF (
PRESENT(occupation_numbers))
THEN
476 IF (
ASSOCIATED(mo_set%occupation_numbers))
THEN
477 DEALLOCATE (mo_set%occupation_numbers)
479 mo_set%occupation_numbers => occupation_numbers
481 IF (
PRESENT(uniform_occupation)) mo_set%uniform_occupation = uniform_occupation
482 IF (
PRESENT(kts)) mo_set%kTS = kts
483 IF (
PRESENT(mu)) mo_set%mu = mu
484 IF (
PRESENT(flexible_electron_count)) mo_set%flexible_electron_count = flexible_electron_count
449 SUBROUTINE set_mo_set(mo_set, maxocc, homo, lfomo, nao, nelectron, n_el_f, nmo, &
…
505 INTEGER,
INTENT(IN),
OPTIONAL :: first_mo, last_mo
506 REAL(kind=
dp),
INTENT(IN),
OPTIONAL :: occupation, tolerance
509 INTEGER :: my_first_mo, my_last_mo
510 REAL(kind=
dp) :: my_occupation, my_tolerance
514 IF (
PRESENT(first_mo))
THEN
515 cpassert(first_mo >= lbound(mo_set%eigenvalues, 1))
516 my_first_mo = first_mo
518 my_first_mo = lbound(mo_set%eigenvalues, 1)
521 IF (
PRESENT(last_mo))
THEN
522 cpassert(last_mo <= ubound(mo_set%eigenvalues, 1))
525 my_last_mo = ubound(mo_set%eigenvalues, 1)
528 IF (
PRESENT(occupation))
THEN
529 my_occupation = occupation
531 my_occupation = mo_set%maxocc
534 IF (
PRESENT(tolerance))
THEN
535 my_tolerance = tolerance
537 my_tolerance = epsilon(0.0_dp)
540 has_uniform_occupation = all(abs(mo_set%occupation_numbers(my_first_mo:my_last_mo) - my_occupation) < my_tolerance)
static GRID_HOST_DEVICE int modulo(int a, int m)
Equivalent of Fortran's MODULO, which always return a positive number. https://gcc....
subroutine, public dbcsr_release_p(matrix)
...
subroutine, public dbcsr_copy(matrix_b, matrix_a, name, keep_sparsity, keep_imaginary)
...
subroutine, public dbcsr_init_p(matrix)
...
DBCSR operations in CP2K.
subroutine, public dbcsr_copy_columns_hack(matrix_b, matrix_a, ncol, source_start, target_start, para_env, blacs_env)
hack for dbcsr_copy_columns
pool for for elements that are retained and released
subroutine, public fm_pool_create_fm(pool, element, name)
returns an element, allocating it if none is in the pool
represent the structure of a full matrix
represent a full matrix distributed on many processors
subroutine, public cp_fm_get_info(matrix, name, nrow_global, ncol_global, nrow_block, ncol_block, nrow_local, ncol_local, row_indices, col_indices, local_data, context, nrow_locals, ncol_locals, matrix_struct, para_env)
returns all kind of information about the full matrix
subroutine, public cp_fm_create(matrix, matrix_struct, name, use_sp)
creates a new full matrix with the given structure
Defines the basic variable types.
integer, parameter, public dp
Definition and initialisation of the mo data type.
subroutine, public duplicate_mo_set(mo_set_new, mo_set_old)
allocate a new mo_set, and copy the old data
subroutine, public set_mo_set(mo_set, maxocc, homo, lfomo, nao, nelectron, n_el_f, nmo, eigenvalues, occupation_numbers, uniform_occupation, kts, mu, flexible_electron_count)
Set the components of a MO set data structure.
subroutine, public allocate_mo_set(mo_set, nao, nmo, nelectron, n_el_f, maxocc, flexible_electron_count)
Allocates a mo set and partially initializes it (nao,nmo,nelectron, and flexible_electron_count are v...
subroutine, public mo_set_restrict(mo_array, convert_dbcsr)
make the beta orbitals explicitly equal to the alpha orbitals effectively copying the orbital data
subroutine, public deallocate_mo_set(mo_set)
Deallocate a wavefunction data structure.
logical function, public has_uniform_occupation(mo_set, first_mo, last_mo, occupation, tolerance)
Check if the set of MOs in mo_set specifed by the MO index range [first_mo,last_mo] an integer occupa...
subroutine, public get_mo_set(mo_set, maxocc, homo, lfomo, nao, nelectron, n_el_f, nmo, eigenvalues, occupation_numbers, mo_coeff, mo_coeff_b, uniform_occupation, kts, mu, flexible_electron_count)
Get the components of a MO set data structure.
subroutine, public reassign_allocated_mos(mo_set_new, mo_set_old)
reassign an already allocated mo_set
subroutine, public init_mo_set(mo_set, fm_pool, fm_ref, fm_struct, name)
initializes an allocated mo_set. eigenvalues, mo_coeff, occupation_numbers are valid only after this ...
represent a pool of elements with the same structure
keeps the information about the structure of a full matrix