27#include "./base/base_uses.f90"
33 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_atomic_block'
38 REAL(KIND=
dp),
DIMENSION(:, :, :),
POINTER :: mat => null()
39 END TYPE atom_matrix_type
55 qs_kind_set, nspin, nelectron_spin, ounit, para_env)
56 TYPE(
dbcsr_p_type),
DIMENSION(:),
INTENT(INOUT) :: pmatrix
60 INTEGER,
INTENT(IN) :: nspin
61 INTEGER,
DIMENSION(:),
INTENT(IN) :: nelectron_spin
62 INTEGER,
INTENT(IN) :: ounit
65 CHARACTER(LEN=*),
PARAMETER :: routinen =
'calculate_atomic_block_dm'
67 INTEGER :: handle, icol, ikind, irow, ispin, nc, &
69 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: kind_of
70 INTEGER,
ALLOCATABLE,
DIMENSION(:, :) :: nok
71 REAL(
dp),
DIMENSION(:, :),
POINTER :: pdata
72 REAL(kind=
dp) :: rds, rscale, trps1
73 TYPE(atom_matrix_type),
ALLOCATABLE,
DIMENSION(:) :: pmat
79 CALL timeset(routinen, handle)
81 nkind =
SIZE(atomic_kind_set)
83 ALLOCATE (pmat(nkind))
84 ALLOCATE (nok(2, nkind))
88 atomic_kind => atomic_kind_set(ikind)
89 qs_kind => qs_kind_set(ikind)
90 NULLIFY (pmat(ikind)%mat)
92 WRITE (unit=ounit, fmt=
"(/,T2,A)") &
93 "Guess for atomic kind: "//trim(atomic_kind%name)
96 pmat=pmat(ikind)%mat, nocc=nocc)
97 nok(1:2, ikind) = nocc(1:2)
101 IF (nspin == 2) rscale = 0.5_dp
104 IF ((ounit > 0) .AND. (nspin > 1))
THEN
105 WRITE (unit=ounit, fmt=
"(/,T2,A,I0)")
"Spin ", ispin
108 matrix_p => pmatrix(ispin)%matrix
115 ikind = kind_of(irow)
116 IF (icol .EQ. irow)
THEN
118 pdata(:, :) = pmat(ikind)%mat(:, :, 1)*rscale + &
119 pmat(ikind)%mat(:, :, 2)*rscale
121 pdata(:, :) = pmat(ikind)%mat(:, :, 1)*rscale - &
122 pmat(ikind)%mat(:, :, 2)*rscale
124 nocc(ispin) = nocc(ispin) + nok(ispin, ikind)
129 CALL dbcsr_dot(matrix_p, matrix_s, trps1)
132 IF (nelectron_spin(ispin) > 0)
THEN
133 rds = real(nelectron_spin(ispin),
dp)/trps1
139 WRITE (unit=ounit, fmt=
"(T2,A,I1)") &
140 "Re-scaling the density matrix to get the right number of electrons for spin ", ispin
142 WRITE (unit=ounit, fmt=
"(T2,A)") &
143 "Re-scaling the density matrix to get the right number of electrons"
145 WRITE (ounit,
'(T19,A,T44,A,T67,A)')
"# Electrons",
"Trace(P)",
"Scaling factor"
146 WRITE (ounit,
'(T20,I10,T40,F12.3,T67,F14.3)') nelectron_spin(ispin), trps1, rds
150 CALL para_env%sum(nocc)
151 IF (nelectron_spin(ispin) > nocc(ispin))
THEN
154 rds = (1.0_dp - rds)*nelectron_spin(ispin)
156 rds = rds/real(nc, kind=
dp)
159 WRITE (unit=ounit, fmt=
"(T4,A,/,T4,A,T59,F20.12)") &
160 "More MOs than initial guess orbitals detected", &
161 "Add constant to diagonal elements ", rds
169 IF (
ASSOCIATED(pmat(ikind)%mat))
THEN
170 DEALLOCATE (pmat(ikind)%mat)
175 DEALLOCATE (kind_of, nok)
177 CALL timestop(handle)
calculate the orbitals for a given atomic kind type
subroutine, public calculate_atomic_orbitals(atomic_kind, qs_kind, agrid, iunit, pmat, fmat, density, wavefunction, wfninfo, confine, xc_section, nocc)
...
Define the atomic kind types and their sub types.
subroutine, public get_atomic_kind_set(atomic_kind_set, atom_of_kind, kind_of, natom_of_kind, maxatom, natom, nshell, fist_potential_present, shell_present, shell_adiabatic, shell_check_distance, damping_present)
Get attributes of an atomic kind set.
subroutine, public dbcsr_scale(matrix, alpha_scalar)
...
subroutine, public dbcsr_iterator_next_block(iterator, row, column, block, block_number_argument_has_been_removed, row_size, col_size, row_offset, col_offset)
...
logical function, public dbcsr_iterator_blocks_left(iterator)
...
subroutine, public dbcsr_iterator_stop(iterator)
...
subroutine, public dbcsr_get_info(matrix, nblkrows_total, nblkcols_total, nfullrows_total, nfullcols_total, nblkrows_local, nblkcols_local, nfullrows_local, nfullcols_local, my_prow, my_pcol, local_rows, local_cols, proc_row_dist, proc_col_dist, row_blk_size, col_blk_size, row_blk_offset, col_blk_offset, distribution, name, matrix_type, group)
...
subroutine, public dbcsr_iterator_start(iterator, matrix, shared, dynamic, dynamic_byrows)
...
subroutine, public dbcsr_set(matrix, alpha)
...
subroutine, public dbcsr_add_on_diag(matrix, alpha)
Adds the given scalar to the diagonal of the matrix. Reserves any missing diagonal blocks.
subroutine, public dbcsr_dot(matrix_a, matrix_b, trace)
Computes the dot product of two matrices, also known as the trace of their matrix product.
Defines the basic variable types.
integer, parameter, public dp
Interface to the message passing library MPI.
Routine to return block diagonal density matrix. Blocks correspond to the atomic densities.
subroutine, public calculate_atomic_block_dm(pmatrix, matrix_s, atomic_kind_set, qs_kind_set, nspin, nelectron_spin, ounit, para_env)
returns a block diagonal density matrix. Blocks correspond to the atomic densities.
Define the quickstep kind type and their sub types.
Provides all information about an atomic kind.
stores all the informations relevant to an mpi environment
Provides all information about a quickstep kind.