30#include "./base/base_uses.f90"
35 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_active_space_types'
46 LOGICAL :: redo_poisson = .false.
47 LOGICAL :: store_wfn = .false.
48 REAL(KIND=
dp) :: cutoff = 0.0_dp
49 REAL(KIND=
dp) :: rel_cutoff = 0.0_dp
50 REAL(KIND=
dp) :: eps_grid = 0.0_dp
51 REAL(KIND=
dp) :: eps_filter = 0.0_dp
52 INTEGER :: print_level = 0
53 INTEGER :: group_size = 0
58 INTEGER :: operator = 0
59 LOGICAL :: enlarge_cell = .false.
60 REAL(kind=
dp) :: omega = 0.0_dp
61 INTEGER,
DIMENSION(3) :: periodicity = 0
62 REAL(kind=
dp),
DIMENSION(3) :: eri_cell = 0
63 REAL(kind=
dp),
DIMENSION(3) :: eri_cell_angles = 0
64 REAL(kind=
dp) :: cutoff_radius = 0.0_dp
65 REAL(kind=
dp) :: eps_integral = 0.0_dp
66 TYPE(eri_gpw_type) :: eri_gpw = eri_gpw_type()
67 TYPE(dbcsr_csr_p_type), &
68 DIMENSION(:),
POINTER :: eri => null()
73 PROCEDURE :: eri_foreach => eri_type_eri_foreach
85 INTEGER :: nelec_active = 0
86 INTEGER :: nelec_inactive = 0
87 INTEGER :: nelec_total = 0
88 INTEGER,
POINTER,
DIMENSION(:, :) :: active_orbitals => null()
89 INTEGER,
POINTER,
DIMENSION(:, :) :: inactive_orbitals => null()
90 INTEGER :: nmo_active = 0
91 INTEGER :: nmo_inactive = 0
92 INTEGER :: multiplicity = 0
94 LOGICAL :: molecule = .false.
96 REAL(kind=
dp) :: energy_total = 0.0_dp
97 REAL(kind=
dp) :: energy_ref = 0.0_dp
98 REAL(kind=
dp) :: energy_inactive = 0.0_dp
99 REAL(kind=
dp) :: energy_active = 0.0_dp
100 REAL(kind=
dp) :: alpha = 0.0_dp
101 LOGICAL :: do_scf_embedding = .false.
103 LOGICAL :: fcidump = .false.
104 CHARACTER(LEN=default_path_length) :: qcschema_filename =
''
107 TYPE(
mo_set_type),
DIMENSION(:),
POINTER :: mos_inactive => null()
108 TYPE(
cp_fm_type),
DIMENSION(:),
POINTER :: p_active => null()
112 TYPE(
cp_fm_type),
DIMENSION(:),
POINTER :: fock_sub => null()
132 INTEGER,
INTENT(in) :: i, j, k, l
133 REAL(kind=
dp),
INTENT(in) :: val
148 IF (
ASSOCIATED(active_space_env))
THEN
152 ALLOCATE (active_space_env)
153 NULLIFY (active_space_env%active_orbitals, active_space_env%inactive_orbitals)
154 NULLIFY (active_space_env%mos_active, active_space_env%mos_inactive)
155 NULLIFY (active_space_env%ks_sub, active_space_env%p_active)
156 NULLIFY (active_space_env%vxc_sub, active_space_env%h_sub)
157 NULLIFY (active_space_env%fock_sub, active_space_env%pmat_inactive)
170 IF (
ASSOCIATED(active_space_env))
THEN
172 IF (
ASSOCIATED(active_space_env%active_orbitals))
THEN
173 DEALLOCATE (active_space_env%active_orbitals)
176 IF (
ASSOCIATED(active_space_env%inactive_orbitals))
THEN
177 DEALLOCATE (active_space_env%inactive_orbitals)
180 IF (
ASSOCIATED(active_space_env%mos_active))
THEN
181 DO imo = 1,
SIZE(active_space_env%mos_active)
184 DEALLOCATE (active_space_env%mos_active)
187 IF (
ASSOCIATED(active_space_env%mos_inactive))
THEN
188 DO imo = 1,
SIZE(active_space_env%mos_inactive)
191 DEALLOCATE (active_space_env%mos_inactive)
194 CALL release_eri_type(active_space_env%eri)
203 IF (
ASSOCIATED(active_space_env%pmat_inactive)) &
206 DEALLOCATE (active_space_env)
215 SUBROUTINE release_eri_type(eri_env)
220 IF (
ASSOCIATED(eri_env%eri))
THEN
222 DO i = 1,
SIZE(eri_env%eri)
223 CALL dbcsr_csr_destroy(eri_env%eri(i)%csr_mat)
224 DEALLOCATE (eri_env%eri(i)%csr_mat)
227 CALL eri_env%comm_exchange%free()
228 DEALLOCATE (eri_env%eri)
232 END SUBROUTINE release_eri_type
244 INTEGER,
INTENT(IN) :: i, j, n
250 ij = (i - 1)*n - ((i - 1)*(i - 2))/2 + (j - i + 1)
252 cpassert(ij <= (n*(n + 1))/2 .AND. 0 <= ij)
266 INTEGER,
INTENT(IN) :: ij, n
267 INTEGER,
INTENT(OUT) :: i, j
273 m0 = (i - 1)*n - ((i - 1)*(i - 2))/2
278 cpassert(i > 0 .AND. i <= n)
279 cpassert(j > 0 .AND. j <= n)
297 SUBROUTINE eri_type_eri_foreach(this, nspin, active_orbitals, fobj, spin1, spin2)
300 INTEGER,
DIMENSION(:, :),
INTENT(IN) :: active_orbitals
301 INTEGER,
OPTIONAL :: spin1, spin2
303 CHARACTER(LEN=*),
PARAMETER :: routinen =
"eri_type_eri_foreach"
305 INTEGER :: i1, i12, i12l, i2, i3, i34, i34l, i4, m1, m2, m3, m4, &
306 irptr, nspin, nindex, nmo, proc, nonzero_elements_local, handle, dummy_int(1)
307 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: colind, offsets, nonzero_elements_global
308 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: erival
309 REAL(kind=
dp) :: erint, dummy_real(1)
312 CALL timeset(routinen, handle)
314 IF (.NOT.
PRESENT(spin1))
THEN
317 IF (.NOT.
PRESENT(spin2))
THEN
324 associate(eri => this%eri(nspin)%csr_mat, norb => this%norb)
325 nindex = (norb*(norb + 1))/2
326 CALL mp_group%set_handle(eri%mp_group%get_handle())
327 nmo =
SIZE(active_orbitals, 1)
329 ALLOCATE (erival(nindex), colind(nindex))
330 ALLOCATE (offsets(0:mp_group%num_pe - 1), &
331 nonzero_elements_global(0:mp_group%num_pe - 1))
334 i1 = active_orbitals(m1, spin1)
336 i2 = active_orbitals(m2, spin1)
338 i12l = (i12 - 1)/this%comm_exchange%num_pe + 1
345 nonzero_elements_local = 0
346 IF (mod(i12 - 1, this%comm_exchange%num_pe) == this%comm_exchange%mepos) &
347 nonzero_elements_local = eri%nzerow_local(i12l)
348 CALL mp_group%allgather(nonzero_elements_local, nonzero_elements_global)
352 DO proc = 1, mp_group%num_pe - 1
353 offsets(proc) = offsets(proc - 1) + nonzero_elements_global(proc - 1)
355 nindex = offsets(mp_group%num_pe - 1) + nonzero_elements_global(mp_group%num_pe - 1)
357 IF (mod(i12 - 1, this%comm_exchange%num_pe) == this%comm_exchange%mepos)
THEN
358 irptr = eri%rowptr_local(i12l)
361 CALL mp_group%allgatherv(eri%colind_local(irptr:irptr + nonzero_elements_local - 1), &
362 colind(1:nindex), nonzero_elements_global, offsets)
363 CALL mp_group%allgatherv(eri%nzval_local%r_dp(irptr:irptr + nonzero_elements_local - 1), &
364 erival(1:nindex), nonzero_elements_global, offsets)
366 CALL mp_group%allgatherv(dummy_int(1:0), colind(1:nindex), nonzero_elements_global, offsets)
367 CALL mp_group%allgatherv(dummy_real(1:0), erival(1:nindex), nonzero_elements_global, offsets)
376 IF (active_orbitals(m3, spin2) == i3)
THEN
382 IF (active_orbitals(m4, spin2) == i4)
THEN
388 IF (.NOT. fobj%func(m1, m2, m3, m4, erint))
RETURN
395 CALL timestop(handle)
396 END SUBROUTINE eri_type_eri_foreach
The function signature to be implemented by a child of eri_type_eri_element_func
DBCSR operations in CP2K.
represent a full matrix distributed on many processors
Defines the basic variable types.
integer, parameter, public dp
integer, parameter, public default_path_length
Interface to the message passing library MPI.
type(mp_comm_type), parameter, public mp_comm_null
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)
The module to read/write QCSchema HDF5 files for interfacing CP2K with other programs.
The types needed for the calculation of active space Hamiltonians.
subroutine, public release_active_space_type(active_space_env)
Releases all quantities in the active space environment.
subroutine, public csr_idx_from_combined(ij, n, i, j)
extracts indices i and j from combined index ij
integer function, public csr_idx_to_combined(i, j, n)
calculates combined index (ij)
subroutine, public create_active_space_type(active_space_env)
Creates an active space environment type, nullifying all quantities.
Definition and initialisation of the mo data type.
subroutine, public deallocate_mo_set(mo_set)
Deallocate a wavefunction data structure.
stores all the informations relevant to an mpi environment
Abstract function object for the eri_type_eri_foreach method.