(git:6344619)
Loading...
Searching...
No Matches
qs_kpoint_state.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2026 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7
8! **************************************************************************************************
9!> \brief Methods for preparing and committing k-point orbital states to the QS environment.
10! **************************************************************************************************
14 USE cp_cfm_diag, ONLY: cp_cfm_geeig,&
16 USE cp_cfm_types, ONLY: cp_cfm_create,&
22 USE cp_dbcsr_api, ONLY: dbcsr_p_type
26 USE cp_fm_types, ONLY: cp_fm_get_info,&
31 USE kinds, ONLY: dp
35 USE kpoint_types, ONLY: get_kpoint_info,&
38 USE mathconstants, ONLY: z_one,&
39 z_zero
46 USE qs_mo_types, ONLY: get_mo_set,&
50 USE qs_rho_types, ONLY: qs_rho_get,&
54#include "./base/base_uses.f90"
55
56 IMPLICIT NONE
57 PRIVATE
58
59 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'qs_kpoint_state'
60
64
65CONTAINS
66
67! **************************************************************************************************
68!> \brief Reconstructs fixed-rank complex k-point orbitals from a density kernel.
69!> The density and overlap must first be transferred to kp%ot_hmat and kp%ot_smat. The
70!> largest natural-orbital subspace gives a metric-defined fixed-rank projector without
71!> replacing the guess by the ground-state projector of its initial Hamiltonian.
72!> \param kpoints K-point environment containing the transferred density and overlap matrices.
73! **************************************************************************************************
75 TYPE(kpoint_type), POINTER :: kpoints
76
77 INTEGER :: ikpoint_local, ispin, nao, nmo, nocc
78 LOGICAL :: use_real_wfn
79 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: density_eigenvalues
80 TYPE(cp_cfm_type) :: density_metric, density_work, matrix_p, &
81 matrix_s, matrix_s_work, projected
82 TYPE(cp_cfm_type), POINTER :: cmo_coeff
83 TYPE(cp_fm_struct_type), POINTER :: active_struct, square_struct
84 TYPE(kpoint_env_type), POINTER :: kp
85
86 NULLIFY (active_struct, cmo_coeff, kp, square_struct)
87
88 cpassert(ASSOCIATED(kpoints))
89 cpassert(ASSOCIATED(kpoints%kp_env))
90 CALL get_kpoint_info(kpoints, use_real_wfn=use_real_wfn)
91 IF (use_real_wfn) THEN
92 cpabort("Fixed-density k-point OT initialization requires complex wavefunctions.")
93 END IF
94
95 DO ikpoint_local = 1, SIZE(kpoints%kp_env)
96 kp => kpoints%kp_env(ikpoint_local)%kpoint_env
97 cpassert(ASSOCIATED(kp))
98 cpassert(ASSOCIATED(kp%mos))
99 cpassert(ASSOCIATED(kp%ot_hmat))
100 cpassert(ASSOCIATED(kp%ot_smat))
101 cpassert(SIZE(kp%ot_hmat, 1) >= 2)
102 cpassert(SIZE(kp%ot_hmat, 2) >= SIZE(kp%mos))
103 cpassert(SIZE(kp%ot_smat) >= 2)
104
105 CALL cp_fm_get_info(kp%ot_hmat(1, 1), matrix_struct=square_struct, nrow_global=nao)
106 CALL cp_cfm_create(matrix_p, square_struct, name="natural-orbital density P(k)")
107 CALL cp_cfm_create(matrix_s, square_struct, name="natural-orbital overlap S(k)")
108 CALL cp_fm_to_cfm(kp%ot_smat(1), kp%ot_smat(2), matrix_s)
109
110 DO ispin = 1, SIZE(kp%mos)
111 CALL get_mo_set(kp%mos(ispin), homo=nocc, cmo_coeff=cmo_coeff, nmo=nmo)
112 cpassert(ASSOCIATED(cmo_coeff))
113 cpassert(nocc >= 1 .AND. nocc <= nmo)
114
115 CALL cp_fm_struct_create(active_struct, template_fmstruct=cmo_coeff%matrix_struct, &
116 ncol_global=nocc)
117 CALL cp_fm_to_cfm(kp%ot_hmat(1, ispin), kp%ot_hmat(2, ispin), matrix_p)
118 CALL cp_cfm_create(projected, active_struct, name="fixed-density natural orbitals")
119 CALL cp_cfm_create(density_metric, square_struct, name="natural-orbital metric")
120 CALL cp_cfm_create(density_work, square_struct, name="natural-orbital work")
121 CALL cp_cfm_create(matrix_s_work, square_struct, name="natural-orbital overlap work")
122
123 ! The largest eigenvectors of S*P*S*C = S*C*n are the natural orbitals of
124 ! S**(1/2)*P*S**(1/2). Negating the left-hand side lets the generalized
125 ! eigensolver request only its lowest nocc eigenpairs when supported.
126 CALL parallel_gemm('N', 'N', nao, nao, nao, z_one, matrix_p, matrix_s, &
127 z_zero, density_work)
128 CALL parallel_gemm('N', 'N', nao, nao, nao, z_one, matrix_s, density_work, &
129 z_zero, density_metric)
130 CALL cp_cfm_scale(-z_one, density_metric)
131 CALL cp_cfm_to_cfm(matrix_s, matrix_s_work)
132 ALLOCATE (density_eigenvalues(nocc))
133 CALL cp_cfm_geeig(density_metric, matrix_s_work, projected, &
134 density_eigenvalues, density_work, lowest_subset=.true.)
135 DEALLOCATE (density_eigenvalues)
136
137 CALL cp_cfm_set_all(cmo_coeff, cmplx(0.0_dp, 0.0_dp, kind=dp))
138 CALL cp_cfm_to_cfm(projected, cmo_coeff, nocc)
139 CALL cp_cfm_release(matrix_s_work)
140 CALL cp_cfm_release(density_work)
141 CALL cp_cfm_release(density_metric)
142 CALL cp_cfm_release(projected)
143 CALL cp_fm_struct_release(active_struct)
144 END DO
145
146 CALL cp_cfm_release(matrix_s)
147 CALL cp_cfm_release(matrix_p)
148 END DO
149
151
152! **************************************************************************************************
153!> \brief Rotates a uniformly occupied k-point subspace into Ritz states of the current
154!> Hamiltonian and stores their energy labels. The Hamiltonian must first be transferred
155!> to kp%ot_hmat. Since the rotation is internal to a uniformly occupied subspace, it does
156!> not change the density represented by the orbitals.
157!> \param kpoints K-point environment containing the orbitals and transferred Hamiltonians.
158! **************************************************************************************************
160 TYPE(kpoint_type), POINTER :: kpoints
161
162 INTEGER :: ikpoint_local, ispin, nao, nmo, nocc
163 LOGICAL :: use_real_wfn
164 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: ritz_values
165 REAL(kind=dp), DIMENSION(:), POINTER :: eigenvalues_re
166 TYPE(cp_cfm_type) :: coeff, eigenvectors, hblock, hc, &
167 matrix_h, rotated
168 TYPE(cp_cfm_type), POINTER :: cmo_coeff
169 TYPE(cp_fm_struct_type), POINTER :: active_struct, square_struct
170 TYPE(kpoint_env_type), POINTER :: kp
171
172 NULLIFY (active_struct, cmo_coeff, eigenvalues_re, kp, &
173 square_struct)
174
175 cpassert(ASSOCIATED(kpoints))
176 cpassert(ASSOCIATED(kpoints%kp_env))
177 CALL get_kpoint_info(kpoints, use_real_wfn=use_real_wfn)
178 IF (use_real_wfn) THEN
179 cpabort("Fixed-density k-point OT canonicalization requires complex wavefunctions.")
180 END IF
181
182 DO ikpoint_local = 1, SIZE(kpoints%kp_env)
183 kp => kpoints%kp_env(ikpoint_local)%kpoint_env
184 cpassert(ASSOCIATED(kp))
185 cpassert(ASSOCIATED(kp%mos))
186 cpassert(ASSOCIATED(kp%ot_hmat))
187 cpassert(SIZE(kp%ot_hmat, 1) >= 2)
188 cpassert(SIZE(kp%ot_hmat, 2) >= SIZE(kp%mos))
189
190 CALL cp_fm_get_info(kp%ot_hmat(1, 1), matrix_struct=square_struct, nrow_global=nao)
191 CALL cp_cfm_create(matrix_h, square_struct, name="fixed-density Ritz Hamiltonian")
192
193 DO ispin = 1, SIZE(kp%mos)
194 CALL get_mo_set(kp%mos(ispin), homo=nocc, cmo_coeff=cmo_coeff, nmo=nmo, &
195 eigenvalues=eigenvalues_re)
196 cpassert(ASSOCIATED(cmo_coeff))
197 cpassert(ASSOCIATED(eigenvalues_re))
198 cpassert(nocc >= 1 .AND. nocc <= nmo)
199 cpassert(SIZE(eigenvalues_re) >= nocc)
200
201 CALL cp_fm_struct_create(active_struct, template_fmstruct=cmo_coeff%matrix_struct, &
202 ncol_global=nocc)
203 CALL cp_cfm_create(coeff, active_struct, name="fixed-density Ritz orbitals")
204 CALL cp_cfm_create(hc, active_struct, name="fixed-density Ritz HC")
205 CALL cp_cfm_create(rotated, active_struct, name="fixed-density Ritz rotated orbitals")
206 CALL cp_cfm_create(hblock, active_struct, nrow=nocc, ncol=nocc, &
207 name="fixed-density projected Hamiltonian")
208 CALL cp_cfm_create(eigenvectors, active_struct, nrow=nocc, ncol=nocc, &
209 name="fixed-density Ritz eigenvectors")
210 CALL cp_fm_to_cfm(kp%ot_hmat(1, ispin), kp%ot_hmat(2, ispin), matrix_h)
211 IF (ALLOCATED(kpoints%lowdin_v)) CALL lowdin_kp_apply(kp, kpoints%lowdin_v(:, ispin), cmat=matrix_h)
212 CALL cp_cfm_to_cfm(cmo_coeff, coeff, nocc)
213
214 CALL parallel_gemm('N', 'N', nao, nocc, nao, z_one, matrix_h, coeff, z_zero, hc)
215 CALL parallel_gemm('C', 'N', nocc, nocc, nao, z_one, coeff, hc, z_zero, hblock)
216 ALLOCATE (ritz_values(nocc))
217 CALL cp_cfm_heevd(hblock, eigenvectors, ritz_values)
218 CALL parallel_gemm('N', 'N', nao, nocc, nocc, z_one, coeff, eigenvectors, &
219 z_zero, rotated)
220 CALL cp_cfm_to_cfm(rotated, cmo_coeff, nocc)
221 eigenvalues_re(1:nocc) = ritz_values
222 DEALLOCATE (ritz_values)
223
224 CALL cp_cfm_release(eigenvectors)
225 CALL cp_cfm_release(hblock)
226 CALL cp_cfm_release(rotated)
227 CALL cp_cfm_release(hc)
228 CALL cp_cfm_release(coeff)
229 CALL cp_fm_struct_release(active_struct)
230 END DO
231
232 CALL cp_cfm_release(matrix_h)
233 END DO
234
236
237! **************************************************************************************************
238!> \brief Rebuilds the physical density from the current k-point orbitals and occupations.
239!> \param qs_env QS environment containing the orbital state to commit.
240!> \param update_occupations Recompute occupations from the current MO energies and SCF settings.
241!> \param separate_spin_occupations Fill restricted energy channels independently.
242!> \param fixed_occupations Restore the fixed occupied rank required by OT.
243! **************************************************************************************************
244 SUBROUTINE qs_kpoint_state_commit(qs_env, update_occupations, &
245 separate_spin_occupations, fixed_occupations)
246 TYPE(qs_environment_type), POINTER :: qs_env
247 LOGICAL, INTENT(IN) :: update_occupations
248 LOGICAL, INTENT(IN), OPTIONAL :: separate_spin_occupations, &
249 fixed_occupations
250
251 INTEGER :: ispin
252 LOGICAL :: fixed, separate_spins
253 TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: matrix_s_kp, rho_ao_kp
254 TYPE(kpoint_type), POINTER :: kpoints
255 TYPE(mo_set_type), DIMENSION(:), POINTER :: mos
256 TYPE(neighbor_list_set_p_type), DIMENSION(:), &
257 POINTER :: sab_nl
258 TYPE(qs_energy_type), POINTER :: energy
259 TYPE(qs_rho_type), POINTER :: rho
260 TYPE(qs_scf_env_type), POINTER :: scf_env
261 TYPE(scf_control_type), POINTER :: scf_control
262
263 NULLIFY (energy, kpoints, matrix_s_kp, mos, rho_ao_kp, sab_nl, rho, scf_env, scf_control)
264
265 fixed = .false.
266 separate_spins = .false.
267 IF (PRESENT(fixed_occupations)) fixed = fixed_occupations
268 IF (PRESENT(separate_spin_occupations)) separate_spins = separate_spin_occupations
269 IF (fixed .AND. .NOT. update_occupations) THEN
270 cpabort("Fixed occupations can only be requested while updating occupations.")
271 END IF
272
273 CALL get_qs_env(qs_env, kpoints=kpoints, matrix_s_kp=matrix_s_kp, &
274 energy=energy, rho=rho, scf_env=scf_env, scf_control=scf_control)
275 CALL get_kpoint_info(kpoints, sab_nl=sab_nl)
276
277 IF (update_occupations) THEN
279 kpoints, scf_control%smear, separate_spin_occupations=separate_spins)
280 IF (fixed) CALL qs_kpoint_set_fixed_occupations(kpoints)
281 END IF
282 CALL kpoint_density_matrices(kpoints)
283 CALL qs_rho_get(rho, rho_ao_kp=rho_ao_kp)
284 CALL kpoint_density_transform(kpoints, rho_ao_kp, .false., &
285 matrix_s_kp(1, 1)%matrix, sab_nl, scf_env%scf_work1, &
286 overlap_rs=matrix_s_kp)
287 CALL qs_rho_update_rho(rho, qs_env=qs_env)
288 CALL qs_ks_did_change(qs_env%ks_env, rho_changed=.true.)
289
290 energy%kTS = 0.0_dp
291 energy%efermi = 0.0_dp
292 mos => kpoints%kp_env(1)%kpoint_env%mos
293 cpassert(ASSOCIATED(mos))
294 DO ispin = 1, SIZE(mos)
295 energy%kTS = energy%kTS + mos(ispin)%kTS
296 energy%efermi = energy%efermi + mos(ispin)%mu
297 END DO
298 energy%efermi = energy%efermi/real(SIZE(mos), kind=dp)
299
300 END SUBROUTINE qs_kpoint_state_commit
301
302! **************************************************************************************************
303!> \brief Checks whether every local k-point channel contains nonzero occupied orbitals.
304!> \param kpoints K-point environment.
305!> \param require_full_space Require every available orbital instead of the occupied block.
306!> \return True if every channel contains a nonzero real or imaginary coefficient.
307! **************************************************************************************************
308 FUNCTION qs_kpoint_mos_initialized(kpoints, require_full_space) RESULT(initialized)
309 TYPE(kpoint_type), POINTER :: kpoints
310 LOGICAL, INTENT(IN), OPTIONAL :: require_full_space
311 LOGICAL :: initialized
312
313 INTEGER :: ikpoint_local, ispin, nactive, nmo, nocc
314 LOGICAL :: full_space
315 REAL(kind=dp) :: coefficient_norm
316 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: column_norm
317 TYPE(cp_cfm_type), POINTER :: cmo_coeff
318 TYPE(cp_fm_type), POINTER :: mo_coeff
319 TYPE(kpoint_env_type), POINTER :: kp
320 TYPE(mp_para_env_type), POINTER :: para_env
321
322 NULLIFY (cmo_coeff, kp, mo_coeff, para_env)
323 cpassert(ASSOCIATED(kpoints))
324 cpassert(ASSOCIATED(kpoints%kp_env))
325
326 full_space = .false.
327 IF (PRESENT(require_full_space)) full_space = require_full_space
328 coefficient_norm = huge(1.0_dp)
329 DO ikpoint_local = 1, SIZE(kpoints%kp_env)
330 kp => kpoints%kp_env(ikpoint_local)%kpoint_env
331 cpassert(ASSOCIATED(kp))
332 cpassert(ASSOCIATED(kp%mos))
333 DO ispin = 1, SIZE(kp%mos)
334 CALL get_mo_set(kp%mos(ispin), homo=nocc, cmo_coeff=cmo_coeff, &
335 mo_coeff=mo_coeff, nmo=nmo)
336 nactive = merge(nmo, nocc, full_space)
337 IF (nactive < 1 .OR. nactive > nmo) THEN
338 coefficient_norm = 0.0_dp
339 cycle
340 END IF
341 ALLOCATE (column_norm(nmo))
342 IF (ASSOCIATED(cmo_coeff)) THEN
343 CALL cp_cfm_vectorsnorm(cmo_coeff, column_norm)
344 ELSE
345 cpassert(ASSOCIATED(mo_coeff))
346 CALL cp_fm_vectorsnorm(mo_coeff, column_norm)
347 END IF
348 coefficient_norm = min(coefficient_norm, minval(column_norm(1:nactive)))
349 DEALLOCATE (column_norm)
350 END DO
351 END DO
352
353 CALL get_kpoint_info(kpoints, para_env=para_env)
354 cpassert(ASSOCIATED(para_env))
355 CALL para_env%min(coefficient_norm)
356 initialized = coefficient_norm > 100.0_dp*epsilon(1.0_dp)
357
358 END FUNCTION qs_kpoint_mos_initialized
359
360! **************************************************************************************************
361!> \brief Copies the first k-point spin channel into the remaining channels.
362!> \param kpoints K-point environment.
363!> \param nspin Number of spin channels to populate.
364! **************************************************************************************************
365 SUBROUTINE qs_kpoint_copy_spin_mos(kpoints, nspin)
366 TYPE(kpoint_type), POINTER :: kpoints
367 INTEGER, INTENT(IN) :: nspin
368
369 INTEGER :: ikpoint_local, ispin
370 REAL(kind=dp), DIMENSION(:), POINTER :: eigenvalues_source, eigenvalues_target
371 TYPE(cp_cfm_type), POINTER :: cmo_coeff_source, cmo_coeff_target
372 TYPE(cp_fm_type), POINTER :: mo_coeff_source, mo_coeff_target
373 TYPE(kpoint_env_type), POINTER :: kp
374
375 NULLIFY (cmo_coeff_source, cmo_coeff_target, eigenvalues_source, eigenvalues_target, kp, &
376 mo_coeff_source, mo_coeff_target)
377 cpassert(ASSOCIATED(kpoints))
378 cpassert(ASSOCIATED(kpoints%kp_env))
379 cpassert(nspin >= 1)
380
381 DO ikpoint_local = 1, SIZE(kpoints%kp_env)
382 kp => kpoints%kp_env(ikpoint_local)%kpoint_env
383 cpassert(ASSOCIATED(kp))
384 cpassert(ASSOCIATED(kp%mos))
385 cpassert(SIZE(kp%mos) >= nspin)
386 IF (ASSOCIATED(kp%mos(1)%cmo_coeff)) THEN
387 cmo_coeff_source => kp%mos(1)%cmo_coeff
388 CALL get_mo_set(kp%mos(1), eigenvalues=eigenvalues_source)
389 cpassert(ASSOCIATED(eigenvalues_source))
390 DO ispin = 2, nspin
391 cmo_coeff_target => kp%mos(ispin)%cmo_coeff
392 CALL get_mo_set(kp%mos(ispin), eigenvalues=eigenvalues_target)
393 cpassert(ASSOCIATED(cmo_coeff_target))
394 cpassert(ASSOCIATED(eigenvalues_target))
395 CALL cp_cfm_to_cfm(cmo_coeff_source, cmo_coeff_target)
396 eigenvalues_target(:) = eigenvalues_source(:)
397 END DO
398 ELSE
399 CALL get_mo_set(kp%mos(1), mo_coeff=mo_coeff_source, eigenvalues=eigenvalues_source)
400 cpassert(ASSOCIATED(mo_coeff_source))
401 cpassert(ASSOCIATED(eigenvalues_source))
402 DO ispin = 2, nspin
403 CALL get_mo_set(kp%mos(ispin), mo_coeff=mo_coeff_target, &
404 eigenvalues=eigenvalues_target)
405 cpassert(ASSOCIATED(mo_coeff_target))
406 cpassert(ASSOCIATED(eigenvalues_target))
407 CALL cp_fm_to_fm(mo_coeff_source, mo_coeff_target)
408 eigenvalues_target(:) = eigenvalues_source(:)
409 END DO
410 END IF
411 END DO
412
413 END SUBROUTINE qs_kpoint_copy_spin_mos
414
415! **************************************************************************************************
416!> \brief Restores the fixed occupied rank required by k-point OT.
417!> \param kpoints K-point environment.
418! **************************************************************************************************
420 TYPE(kpoint_type), POINTER :: kpoints
421
422 INTEGER :: ikpoint_local, ispin, nelectron, nmo, &
423 nocc
424 REAL(kind=dp) :: maxocc
425 REAL(kind=dp), DIMENSION(:), POINTER :: occupation_numbers
426 TYPE(kpoint_env_type), POINTER :: kp
427
428 NULLIFY (kp, occupation_numbers)
429 cpassert(ASSOCIATED(kpoints))
430 cpassert(ASSOCIATED(kpoints%kp_env))
431
432 DO ikpoint_local = 1, SIZE(kpoints%kp_env)
433 kp => kpoints%kp_env(ikpoint_local)%kpoint_env
434 cpassert(ASSOCIATED(kp))
435 cpassert(ASSOCIATED(kp%mos))
436 DO ispin = 1, SIZE(kp%mos)
437 CALL get_mo_set(kp%mos(ispin), maxocc=maxocc, nelectron=nelectron, &
438 nmo=nmo, occupation_numbers=occupation_numbers)
439 cpassert(ASSOCIATED(occupation_numbers))
440 ! The fixed rank comes from the spin electron count, not a previous k-point filling.
441 nocc = nint(real(nelectron, kind=dp)/maxocc)
442 IF (nocc < 1 .OR. nocc > nmo) THEN
443 cpabort("Fixed-occupation k-point OT requires a nonempty occupied subspace.")
444 END IF
445 IF (abs(maxocc*real(nocc, kind=dp) - real(nelectron, kind=dp)) > &
446 100.0_dp*epsilon(1.0_dp)) THEN
447 cpabort("Fixed-occupation k-point OT requires uniform integer occupations.")
448 END IF
449 occupation_numbers(:) = 0.0_dp
450 occupation_numbers(1:nocc) = maxocc
451 kp%mos(ispin)%homo = nocc
452 kp%mos(ispin)%kTS = 0.0_dp
453 END DO
454 END DO
455
457
458END MODULE qs_kpoint_state
Basic linear algebra operations for complex full matrices.
subroutine, public cp_cfm_vectorsnorm(matrix, norm_array)
find the norm of each column norm_{j}= sqrt( \sum_{i} A_{ij}*conjg(A_{ij}) ) Complex-valued mirror of...
used for collecting diagonalization schemes available for cp_cfm_type
Definition cp_cfm_diag.F:14
subroutine, public cp_cfm_heevd(matrix, eigenvectors, eigenvalues)
Perform a diagonalisation of a complex matrix.
Definition cp_cfm_diag.F:94
subroutine, public cp_cfm_geeig(amatrix, bmatrix, eigenvectors, eigenvalues, work, lowest_subset)
General Eigenvalue Problem AX = BXE Single option version: Cholesky decomposition of B.
Represents a complex full matrix distributed on many processors.
subroutine, public cp_cfm_release(matrix)
Releases a full matrix.
subroutine, public cp_fm_to_cfm(msourcer, msourcei, mtarget)
Construct a complex full matrix by taking its real and imaginary parts from two separate real-value f...
subroutine, public cp_cfm_create(matrix, matrix_struct, name, nrow, ncol, set_zero)
Creates a new full matrix with the given structure.
subroutine, public cp_cfm_set_all(matrix, alpha, beta)
Set all elements of the full matrix to alpha. Besides, set all diagonal matrix elements to beta (if g...
represent the structure of a full matrix
subroutine, public cp_fm_struct_create(fmstruct, para_env, context, nrow_global, ncol_global, nrow_block, ncol_block, descriptor, first_p_pos, local_leading_dimension, template_fmstruct, square_blocks, force_block)
allocates and initializes a full matrix structure
subroutine, public cp_fm_struct_release(fmstruct)
releases a full matrix structure
represent a full matrix distributed on many processors
Definition cp_fm_types.F:15
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_vectorsnorm(matrix, norm_array)
find the inorm of each column norm_{j}= sqrt( \sum_{i} A_{ij}*A_{ij} )
Add the DFT+U contribution to the Hamiltonian matrix.
Definition dft_plus_u.F:18
subroutine, public lowdin_kp_apply(kp, v, rmat, cmat)
Add B diag(v) B**H before any solver, DIIS residual, or history storage uses H(k).
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
Routines needed for kpoint calculation.
subroutine, public kpoint_density_transform(kpoint, denmat, wtype, tempmat, sab_nl, fmwork, for_aux_fit, pmat_ext, overlap_rs)
generate real space density matrices in DBCSR format
subroutine, public kpoint_set_mo_occupation(kpoint, smear, probe, added_mos_auto, added_mos_auto_grow, separate_spin_occupations)
Given the eigenvalues of all kpoints, calculates the occupation numbers.
subroutine, public kpoint_density_matrices(kpoint, energy_weighted, for_aux_fit)
Calculate kpoint density matrices (rho(k), owned by kpoint groups).
Types and basic routines needed for a kpoint calculation.
subroutine, public get_kpoint_info(kpoint, kp_scheme, nkp_grid, kp_shift, symmetry, verbose, full_grid, use_real_wfn, eps_geo, parallel_group_size, kp_range, nkp, xkp, wkp, para_env, blacs_env_all, para_env_kp, para_env_inter_kp, blacs_env, kp_env, kp_aux_env, mpools, iogrp, nkp_groups, kp_dist, cell_to_index, index_to_cell, sab_nl, sab_nl_nosym, inversion_symmetry_only, symmetry_backend, symmetry_reduction_method, gamma_centered, lattice_fft)
Retrieve information from a kpoint environment.
Definition of mathematical constants and functions.
complex(kind=dp), parameter, public z_one
complex(kind=dp), parameter, public z_zero
Interface to the message passing library MPI.
basic linear algebra operations for full matrixes
subroutine, public get_qs_env(qs_env, atomic_kind_set, qs_kind_set, cell, super_cell, cell_ref, use_ref_cell, kpoints, dft_control, mos, sab_orb, sab_all, qmmm, qmmm_periodic, mimic, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, matrix_vhxc, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, xcint_weights, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, rhoz_cneo_set, ecoul_1c, rho0_s_rs, rho0_s_gs, rhoz_cneo_s_rs, rhoz_cneo_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, lri_env, lri_density, exstate_env, ec_env, harris_env, dispersion_env, gcp_env, vee, rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, wanniercentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs, do_rixs, tb_tblite)
Get the QUICKSTEP environment.
Methods for preparing and committing k-point orbital states to the QS environment.
subroutine, public qs_kpoint_state_commit(qs_env, update_occupations, separate_spin_occupations, fixed_occupations)
Rebuilds the physical density from the current k-point orbitals and occupations.
subroutine, public qs_kpoint_state_prepare_fixed_density(kpoints)
Reconstructs fixed-rank complex k-point orbitals from a density kernel. The density and overlap must ...
subroutine, public qs_kpoint_set_fixed_occupations(kpoints)
Restores the fixed occupied rank required by k-point OT.
logical function, public qs_kpoint_mos_initialized(kpoints, require_full_space)
Checks whether every local k-point channel contains nonzero occupied orbitals.
subroutine, public qs_kpoint_copy_spin_mos(kpoints, nspin)
Copies the first k-point spin channel into the remaining channels.
subroutine, public qs_kpoint_state_canonicalize_fixed(kpoints)
Rotates a uniformly occupied k-point subspace into Ritz states of the current Hamiltonian and stores ...
subroutine, public qs_ks_did_change(ks_env, s_mstruct_changed, rho_changed, potential_changed, full_reset)
tells that some of the things relevant to the ks calculation did change. has to be called when change...
Definition and initialisation of the mo data type.
Definition qs_mo_types.F:22
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, cmo_coeff)
Get the components of a MO set data structure.
Define the neighbor list data types and the corresponding functionality.
methods of the rho structure (defined in qs_rho_types)
subroutine, public qs_rho_update_rho(rho_struct, qs_env, rho_xc_external, local_rho_set, task_list_external, task_list_external_soft, pw_env_external, para_env_external)
updates rho_r and rho_g to the rhorho_ao. if use_kinetic_energy_density also computes tau_r and tau_g...
superstucture that hold various representations of the density and keeps track of which ones are vali...
subroutine, public qs_rho_get(rho_struct, rho_ao, rho_ao_im, rho_ao_kp, rho_ao_im_kp, rho_r, drho_r, rho_g, drho_g, tau_r, tau_g, rho_r_valid, drho_r_valid, rho_g_valid, drho_g_valid, tau_r_valid, tau_g_valid, tot_rho_r, tot_rho_g, rho_r_sccs, soft_valid, complex_rho_ao)
returns info about the density described by this object. If some representation is not available an e...
module that contains the definitions of the scf types
parameters that control an scf iteration
Represent a complex full matrix.
keeps the information about the structure of a full matrix
represent a full matrix
Keeps information about a specific k-point.
Contains information about kpoints.
stores all the informations relevant to an mpi environment
keeps the density in various representations, keeping track of which ones are valid.