(git:c01e6a4)
Loading...
Searching...
No Matches
qs_scf_post_se.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2025 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7
8! **************************************************************************************************
9!> \brief Does all kind of post scf calculations for semi-empirical
10!> \par History
11!> Started printing preliminary stuff for MO_CUBES and MO requires some
12!> more work to complete all other functionalities
13!> - Revise MO information printout (10.05.2021, MK)
14!> \author Teodoro Laino (07.2008)
15! **************************************************************************************************
17
18 USE ai_moments, ONLY: moment
22 USE cell_types, ONLY: cell_type,&
23 pbc
31 USE cp_output_handling, ONLY: cp_p_file,&
38 USE eeq_method, ONLY: eeq_print
44 USE kinds, ONLY: default_string_length,&
45 dp
46 USE mathconstants, ONLY: twopi,&
47 z_one,&
48 z_zero
51 USE orbital_pointers, ONLY: coset,&
52 ncoset
55 USE physcon, ONLY: debye
58 USE qs_kind_types, ONLY: get_qs_kind,&
62 USE qs_rho_types, ONLY: qs_rho_get,&
70#include "./base/base_uses.f90"
71
72 IMPLICIT NONE
73 PRIVATE
74
75 ! Global parameters
76 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'qs_scf_post_se'
78
79CONTAINS
80
81! **************************************************************************************************
82!> \brief collects possible post - scf calculations and prints info / computes properties.
83!> specific for Semi-empirical calculations
84!> \param qs_env the qs_env in which the qs_env lives
85!> \par History
86!> 07.2008 created [tlaino] - Split from qs_scf_post (general)
87!> \author tlaino
88!> \note
89!> this function changes mo_eigenvectors and mo_eigenvalues, depending on the print keys.
90!> In particular, MO_CUBES causes the MOs to be rotated to make them eigenstates of the KS
91!> matrix, and mo_eigenvalues is updated accordingly. This can, for unconverged wavefunctions,
92!> change afterwards slightly the forces (hence small numerical differences between MD
93!> with and without the debug print level). Ideally this should not happen...
94! **************************************************************************************************
95 SUBROUTINE scf_post_calculation_se(qs_env)
96
97 TYPE(qs_environment_type), POINTER :: qs_env
98
99 CHARACTER(len=*), PARAMETER :: routinen = 'scf_post_calculation_se'
100
101 INTEGER :: handle, output_unit
102 LOGICAL :: explicit, my_localized_wfn
103 TYPE(cp_logger_type), POINTER :: logger
104 TYPE(mp_para_env_type), POINTER :: para_env
105 TYPE(particle_list_type), POINTER :: particles
106 TYPE(qs_rho_type), POINTER :: rho
107 TYPE(qs_subsys_type), POINTER :: subsys
108 TYPE(section_vals_type), POINTER :: input, print_key, wfn_mix_section
109
110 CALL timeset(routinen, handle)
111
112 ! Writes the data that is already available in qs_env
113 CALL write_available_results(qs_env)
114
115 my_localized_wfn = .false.
116 NULLIFY (rho, subsys, particles, input, print_key, para_env)
117
118 logger => cp_get_default_logger()
119 output_unit = cp_logger_get_default_io_unit(logger)
120
121 cpassert(ASSOCIATED(qs_env))
122 ! Here we start with data that needs a postprocessing...
123 CALL get_qs_env(qs_env, &
124 rho=rho, &
125 input=input, &
126 subsys=subsys, &
127 para_env=para_env)
128 CALL qs_subsys_get(subsys, particles=particles)
129
130 ! Compute Atomic Charges
131 CALL qs_scf_post_charges(input, logger, qs_env, rho, para_env)
132
133 ! Moments of charge distribution
134 CALL qs_scf_post_moments(input, logger, qs_env)
135
136 ! MO_CUBES
137 print_key => section_vals_get_subs_vals(section_vals=input, &
138 subsection_name="DFT%PRINT%MO_CUBES")
139 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
140 cpwarn("Printing of MO cube files not implemented for Semi-Empirical method.")
141 END IF
142
143 ! STM
144 print_key => section_vals_get_subs_vals(section_vals=input, &
145 subsection_name="DFT%PRINT%STM")
146 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
147 cpwarn("STM not implemented for Semi-Empirical method.")
148 END IF
149
150 ! DFT+U
151 print_key => section_vals_get_subs_vals(section_vals=input, &
152 subsection_name="DFT%PRINT%PLUS_U")
153 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
154 cpwarn("DFT+U not available for Semi-Empirical method.")
155 END IF
156
157 ! Kinetic Energy
158 print_key => section_vals_get_subs_vals(section_vals=input, &
159 subsection_name="DFT%PRINT%KINETIC_ENERGY")
160 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
161 cpwarn("Kinetic energy not available for Semi-Empirical method.")
162 END IF
163
164 ! Wavefunction mixing
165 wfn_mix_section => section_vals_get_subs_vals(input, "DFT%PRINT%WFN_MIX")
166 CALL section_vals_get(wfn_mix_section, explicit=explicit)
167 IF (explicit .AND. .NOT. qs_env%run_rtp) THEN
168 cpwarn("Wavefunction mixing not implemented for Semi-Empirical method.")
169 END IF
170
171 ! Print coherent X-ray diffraction spectrum
172 print_key => section_vals_get_subs_vals(section_vals=input, &
173 subsection_name="DFT%PRINT%XRAY_DIFFRACTION_SPECTRUM")
174 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
175 cpwarn("XRAY_DIFFRACTION_SPECTRUM not implemented for Semi-Empirical calculations!")
176 END IF
177
178 ! Calculation of Electric Field Gradients
179 print_key => section_vals_get_subs_vals(section_vals=input, &
180 subsection_name="DFT%PRINT%ELECTRIC_FIELD_GRADIENT")
181 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
182 cpwarn("ELECTRIC_FIELD_GRADIENT not implemented for Semi-Empirical calculations!")
183 END IF
184
185 ! Calculation of EPR Hyperfine Coupling Tensors
186 print_key => section_vals_get_subs_vals(section_vals=input, &
187 subsection_name="DFT%PRINT%HYPERFINE_COUPLING_TENSOR")
188 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), &
189 cp_p_file)) THEN
190 cpwarn("HYPERFINE_COUPLING_TENSOR not implemented for Semi-Empirical calculations!")
191 END IF
192
193 CALL timestop(handle)
194
195 END SUBROUTINE scf_post_calculation_se
196
197! **************************************************************************************************
198!> \brief Computes and prints electric dipole moments
199!> We use the approximation for NDDO from
200!> Pople and Beveridge, Approximate Molecular Orbital Theory,
201!> Mc Graw Hill 1970
202!> mu = \sum_A [ Q_A * R_a + Tr(P_A*D_A) ]
203!> \param input ...
204!> \param logger ...
205!> \param qs_env the qs_env in which the qs_env lives
206! **************************************************************************************************
207 SUBROUTINE qs_scf_post_moments(input, logger, qs_env)
208 TYPE(section_vals_type), POINTER :: input
209 TYPE(cp_logger_type), POINTER :: logger
210 TYPE(qs_environment_type), POINTER :: qs_env
211
212 CHARACTER(LEN=default_string_length) :: description, dipole_type
213 COMPLEX(KIND=dp) :: dzeta, zeta
214 COMPLEX(KIND=dp), DIMENSION(3) :: dggamma, dzphase, ggamma, zphase
215 INTEGER :: i, iat, iatom, ikind, ix, j, nat, natom, &
216 natorb, nkind, nspin, reference, &
217 unit_nr
218 LOGICAL :: do_berry, found
219 REAL(kind=dp) :: charge_tot, ci(3), dci(3), dipole(3), dipole_deriv(3), drcc(3), dria(3), &
220 dtheta, gvec(3), q, rcc(3), ria(3), tcharge(2), theta, tmp(3), via(3), zeff
221 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: ncharge
222 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :, :) :: mom
223 REAL(kind=dp), DIMENSION(:), POINTER :: ref_point
224 REAL(kind=dp), DIMENSION(:, :), POINTER :: pblock
225 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
226 TYPE(cell_type), POINTER :: cell
227 TYPE(cp_result_type), POINTER :: results
228 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_p
229 TYPE(dft_control_type), POINTER :: dft_control
230 TYPE(gto_basis_set_type), POINTER :: basis_set
231 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
232 TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
233 TYPE(qs_rho_type), POINTER :: rho
234 TYPE(section_vals_type), POINTER :: print_key
235 TYPE(semi_empirical_type), POINTER :: se_kind
236
237 NULLIFY (results)
238 print_key => section_vals_get_subs_vals(input, "DFT%PRINT%MOMENTS")
239 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
240 ! Dipole Moments
241 unit_nr = cp_print_key_unit_nr(logger, input, "DFT%PRINT%MOMENTS", &
242 extension=".data", middle_name="se_dipole", log_filename=.false.)
243
244 ! Reference point
245 reference = section_get_ival(print_key, keyword_name="REFERENCE")
246 NULLIFY (ref_point)
247 description = '[DIPOLE]'
248 CALL section_vals_val_get(print_key, "REF_POINT", r_vals=ref_point)
249 CALL section_vals_val_get(print_key, "PERIODIC", l_val=do_berry)
250 CALL get_reference_point(rcc, drcc, qs_env=qs_env, reference=reference, &
251 ref_point=ref_point)
252 !
253 NULLIFY (particle_set)
254 CALL get_qs_env(qs_env=qs_env, &
255 rho=rho, &
256 cell=cell, &
257 atomic_kind_set=atomic_kind_set, &
258 natom=natom, &
259 qs_kind_set=qs_kind_set, &
260 particle_set=particle_set, &
261 results=results, &
262 dft_control=dft_control)
263
264 CALL qs_rho_get(rho, rho_ao=matrix_p)
265 nspin = SIZE(matrix_p)
266 nkind = SIZE(atomic_kind_set)
267 ! net charges
268 ALLOCATE (ncharge(natom))
269 ncharge = 0.0_dp
270 DO ikind = 1, nkind
271 CALL get_atomic_kind(atomic_kind_set(ikind), natom=nat)
272 CALL get_qs_kind(qs_kind_set(ikind), se_parameter=se_kind)
273 CALL get_se_param(se_kind, zeff=zeff, natorb=natorb)
274 DO iatom = 1, nat
275 iat = atomic_kind_set(ikind)%atom_list(iatom)
276 tcharge = 0.0_dp
277 DO i = 1, nspin
278 CALL dbcsr_get_block_p(matrix=matrix_p(i)%matrix, row=iat, col=iat, &
279 block=pblock, found=found)
280 IF (found) THEN
281 DO j = 1, natorb
282 tcharge(i) = tcharge(i) + pblock(j, j)
283 END DO
284 END IF
285 END DO
286 ncharge(iat) = zeff - sum(tcharge)
287 END DO
288 END DO
289 ! Contributions from net atomic charges
290 ! Dipole deriv will be the derivative of the Dipole(dM/dt=\sum e_j v_j)
291 dipole_deriv = 0.0_dp
292 dipole = 0.0_dp
293 IF (do_berry) THEN
294 dipole_type = "periodic (Berry phase)"
295 rcc = pbc(rcc, cell)
296 charge_tot = 0._dp
297 charge_tot = sum(ncharge)
298 ria = twopi*matmul(cell%h_inv, rcc)
299 zphase = cmplx(cos(ria), sin(ria), dp)**charge_tot
300
301 dria = twopi*matmul(cell%h_inv, drcc)
302 dzphase = charge_tot*cmplx(-sin(ria), cos(ria), dp)**(charge_tot - 1.0_dp)*dria
303
304 ggamma = z_one
305 dggamma = z_zero
306 DO ikind = 1, SIZE(atomic_kind_set)
307 CALL get_atomic_kind(atomic_kind_set(ikind), natom=nat)
308 DO i = 1, nat
309 iat = atomic_kind_set(ikind)%atom_list(i)
310 ria = particle_set(iat)%r(:)
311 ria = pbc(ria, cell)
312 via = particle_set(iat)%v(:)
313 q = ncharge(iat)
314 DO j = 1, 3
315 gvec = twopi*cell%h_inv(j, :)
316 theta = sum(ria(:)*gvec(:))
317 dtheta = sum(via(:)*gvec(:))
318 zeta = cmplx(cos(theta), sin(theta), kind=dp)**(-q)
319 dzeta = -q*cmplx(-sin(theta), cos(theta), kind=dp)**(-q - 1.0_dp)*dtheta
320 dggamma(j) = dggamma(j)*zeta + ggamma(j)*dzeta
321 ggamma(j) = ggamma(j)*zeta
322 END DO
323 END DO
324 END DO
325 dggamma = dggamma*zphase + ggamma*dzphase
326 ggamma = ggamma*zphase
327 IF (all(real(ggamma, kind=dp) /= 0.0_dp)) THEN
328 tmp = aimag(ggamma)/real(ggamma, kind=dp)
329 ci = atan(tmp)
330 dci = (1.0_dp/(1.0_dp + tmp**2))* &
331 (aimag(dggamma)*real(ggamma, kind=dp) - aimag(ggamma)* &
332 REAL(dggamma, kind=dp))/(real(ggamma, kind=dp))**2
333 dipole = matmul(cell%hmat, ci)/twopi
334 dipole_deriv = matmul(cell%hmat, dci)/twopi
335 END IF
336 ELSE
337 dipole_type = "non-periodic"
338 DO i = 1, natom
339 ! no pbc(particle_set(i)%r(:),cell) so that the total dipole is the sum of the molecular dipoles
340 ria = particle_set(i)%r(:)
341 q = ncharge(i)
342 dipole = dipole - q*(ria - rcc)
343 dipole_deriv(:) = dipole_deriv(:) - q*(particle_set(i)%v(:) - drcc)
344 END DO
345 END IF
346 ! Contributions from atomic polarization
347 ! No contribution to dipole derivatives
348 DO ikind = 1, nkind
349 CALL get_atomic_kind(atomic_kind_set(ikind), natom=nat)
350 CALL get_qs_kind(qs_kind_set(ikind), basis_set=basis_set)
351 CALL get_qs_kind(qs_kind_set(ikind), se_parameter=se_kind)
352 CALL get_se_param(se_kind, natorb=natorb)
353 ALLOCATE (mom(natorb, natorb, 3))
354 mom = 0.0_dp
355 CALL atomic_moments(mom, basis_set)
356 DO iatom = 1, nat
357 iat = atomic_kind_set(ikind)%atom_list(iatom)
358 DO i = 1, nspin
359 CALL dbcsr_get_block_p(matrix=matrix_p(i)%matrix, row=iat, col=iat, &
360 block=pblock, found=found)
361 IF (found) THEN
362 cpassert(natorb == SIZE(pblock, 1))
363 ix = coset(1, 0, 0) - 1
364 dipole(1) = dipole(1) + sum(pblock*mom(:, :, ix))
365 ix = coset(0, 1, 0) - 1
366 dipole(2) = dipole(2) + sum(pblock*mom(:, :, ix))
367 ix = coset(0, 0, 1) - 1
368 dipole(3) = dipole(3) + sum(pblock*mom(:, :, ix))
369 END IF
370 END DO
371 END DO
372 DEALLOCATE (mom)
373 END DO
374 CALL cp_results_erase(results=results, description=description)
375 CALL put_results(results=results, description=description, &
376 values=dipole(1:3))
377 IF (unit_nr > 0) THEN
378 WRITE (unit_nr, '(/,T2,A,T31,A50)') &
379 'SE_DIPOLE| Dipole type', adjustr(trim(dipole_type))
380 WRITE (unit_nr, '(T2,A,T30,3(1X,F16.8))') &
381 'SE_DIPOLE| Moment [a.u.]', dipole(1:3)
382 WRITE (unit_nr, '(T2,A,T30,3(1X,F16.8))') &
383 'SE_DIPOLE| Moment [Debye]', dipole(1:3)*debye
384 WRITE (unit_nr, '(T2,A,T30,3(1X,F16.8))') &
385 'SE_DIPOLE| Derivative [a.u.]', dipole_deriv(1:3)
386 END IF
387 CALL cp_print_key_finished_output(unit_nr, logger, print_key)
388 END IF
389
390 END SUBROUTINE qs_scf_post_moments
391
392! **************************************************************************************************
393!> \brief Computes the dipole integrals for an atom (a|x|b), a,b on atom A
394!> \param mom ...
395!> \param basis_set ...
396! **************************************************************************************************
397 SUBROUTINE atomic_moments(mom, basis_set)
398 REAL(kind=dp), DIMENSION(:, :, :) :: mom
399 TYPE(gto_basis_set_type), POINTER :: basis_set
400
401 INTEGER :: i, iset, jset, ncoa, ncob, nm, nset, &
402 sgfa, sgfb
403 INTEGER, DIMENSION(:), POINTER :: la_max, la_min, npgf, nsgf
404 INTEGER, DIMENSION(:, :), POINTER :: first_sgf
405 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: work
406 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :, :) :: mab
407 REAL(kind=dp), DIMENSION(3) :: rac, rbc
408 REAL(kind=dp), DIMENSION(:, :), POINTER :: rpgf, sphi, zet
409
410 rac = 0.0_dp
411 rbc = 0.0_dp
412
413 first_sgf => basis_set%first_sgf
414 la_max => basis_set%lmax
415 la_min => basis_set%lmin
416 npgf => basis_set%npgf
417 nset = basis_set%nset
418 nsgf => basis_set%nsgf_set
419 rpgf => basis_set%pgf_radius
420 sphi => basis_set%sphi
421 zet => basis_set%zet
422
423 nm = 0
424 DO iset = 1, nset
425 ncoa = npgf(iset)*ncoset(la_max(iset))
426 nm = max(nm, ncoa)
427 END DO
428 ALLOCATE (mab(nm, nm, 4), work(nm, nm))
429
430 DO iset = 1, nset
431 ncoa = npgf(iset)*ncoset(la_max(iset))
432 sgfa = first_sgf(1, iset)
433 DO jset = 1, nset
434 ncob = npgf(jset)*ncoset(la_max(jset))
435 sgfb = first_sgf(1, jset)
436 !*** Calculate the primitive integrals ***
437 CALL moment(la_max(iset), npgf(iset), zet(:, iset), rpgf(:, iset), la_min(iset), &
438 la_max(jset), npgf(jset), zet(:, jset), rpgf(:, jset), 1, rac, rbc, mab)
439 !*** Contraction step ***
440 DO i = 1, 3
441 CALL dgemm("N", "N", ncoa, nsgf(jset), ncob, 1.0_dp, mab(1, 1, i), SIZE(mab, 1), &
442 sphi(1, sgfb), SIZE(sphi, 1), 0.0_dp, work(1, 1), SIZE(work, 1))
443 CALL dgemm("T", "N", nsgf(iset), nsgf(jset), ncoa, 1.0_dp, sphi(1, sgfa), SIZE(sphi, 1), &
444 work(1, 1), SIZE(work, 1), 1.0_dp, mom(sgfa, sgfb, i), SIZE(mom, 1))
445 END DO
446 END DO
447 END DO
448 DEALLOCATE (mab, work)
449
450 END SUBROUTINE atomic_moments
451! **************************************************************************************************
452!> \brief Computes and Prints Atomic Charges with several methods
453!> \param input ...
454!> \param logger ...
455!> \param qs_env the qs_env in which the qs_env lives
456!> \param rho ...
457!> \param para_env ...
458! **************************************************************************************************
459 SUBROUTINE qs_scf_post_charges(input, logger, qs_env, rho, para_env)
460 TYPE(section_vals_type), POINTER :: input
461 TYPE(cp_logger_type), POINTER :: logger
462 TYPE(qs_environment_type), POINTER :: qs_env
463 TYPE(qs_rho_type), POINTER :: rho
464 TYPE(mp_para_env_type), POINTER :: para_env
465
466 CHARACTER(LEN=2) :: aname
467 INTEGER :: i, iat, iatom, ikind, j, nat, natom, &
468 natorb, nkind, nspin, unit_nr
469 LOGICAL :: found
470 REAL(kind=dp) :: npe, zeff
471 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: mcharge
472 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: charges
473 REAL(kind=dp), DIMENSION(:, :), POINTER :: pblock
474 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
475 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_p
476 TYPE(dft_control_type), POINTER :: dft_control
477 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
478 TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
479 TYPE(section_vals_type), POINTER :: print_key
480 TYPE(semi_empirical_type), POINTER :: se_kind
481
482 NULLIFY (particle_set)
483 CALL get_qs_env(qs_env=qs_env, &
484 atomic_kind_set=atomic_kind_set, &
485 natom=natom, &
486 qs_kind_set=qs_kind_set, &
487 particle_set=particle_set, &
488 dft_control=dft_control)
489
490 ! Compute the mulliken charges
491 print_key => section_vals_get_subs_vals(input, "DFT%PRINT%MULLIKEN")
492 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
493 unit_nr = cp_print_key_unit_nr(logger, input, "DFT%PRINT%MULLIKEN", extension=".mulliken", log_filename=.false.)
494 CALL qs_rho_get(rho, rho_ao=matrix_p)
495 nspin = SIZE(matrix_p)
496 npe = real(para_env%num_pe, kind=dp)
497 ALLOCATE (charges(natom, nspin), mcharge(natom))
498 charges = 0.0_dp
499 mcharge = 0.0_dp
500 ! calculate atomic charges
501 nkind = SIZE(atomic_kind_set)
502 DO ikind = 1, nkind
503 CALL get_atomic_kind(atomic_kind_set(ikind), natom=nat)
504 CALL get_qs_kind(qs_kind_set(ikind), se_parameter=se_kind)
505 CALL get_se_param(se_kind, zeff=zeff, natorb=natorb)
506 DO iatom = 1, nat
507 iat = atomic_kind_set(ikind)%atom_list(iatom)
508 DO i = 1, nspin
509 CALL dbcsr_get_block_p(matrix=matrix_p(i)%matrix, row=iat, col=iat, &
510 block=pblock, found=found)
511 IF (found) THEN
512 DO j = 1, natorb
513 charges(iat, i) = charges(iat, i) + pblock(j, j)
514 END DO
515 END IF
516 END DO
517 mcharge(iat) = zeff/npe - sum(charges(iat, 1:nspin))
518 END DO
519 END DO
520 !
521 CALL para_env%sum(charges)
522 CALL para_env%sum(mcharge)
523 !
524 IF (unit_nr > 0) THEN
525 WRITE (unit=unit_nr, fmt="(/,/,T2,A)") "POPULATION ANALYSIS"
526 IF (nspin == 1) THEN
527 WRITE (unit=unit_nr, fmt="(/,T2,A,T70,A)") &
528 " # Atom Element Kind Atomic population", " Net charge"
529 DO ikind = 1, nkind
530 CALL get_atomic_kind(atomic_kind_set(ikind), natom=nat)
531 CALL get_qs_kind(qs_kind_set(ikind), se_parameter=se_kind, element_symbol=aname)
532 DO iatom = 1, nat
533 iat = atomic_kind_set(ikind)%atom_list(iatom)
534 WRITE (unit=unit_nr, &
535 fmt="(T2,I7,6X,A2,3X,I6,T39,F12.6,T69,F12.6)") &
536 iat, aname, ikind, charges(iat, 1), mcharge(iat)
537 END DO
538 END DO
539 WRITE (unit=unit_nr, &
540 fmt="(T2,A,T39,F12.6,T69,F12.6,/)") &
541 "# Total charge", sum(charges(:, 1)), sum(mcharge(:))
542 ELSE
543 WRITE (unit=unit_nr, fmt="(/,T2,A)") &
544 "# Atom Element Kind Atomic population (alpha,beta) Net charge Spin moment"
545 DO ikind = 1, nkind
546 CALL get_atomic_kind(atomic_kind_set(ikind), natom=nat)
547 CALL get_qs_kind(qs_kind_set(ikind), se_parameter=se_kind, element_symbol=aname)
548 DO iatom = 1, nat
549 iat = atomic_kind_set(ikind)%atom_list(iatom)
550 WRITE (unit=unit_nr, &
551 fmt="(T2,I6,5X,A2,2X,I6,T29,4(1X,F12.6))") &
552 iat, aname, ikind, charges(iat, 1:2), mcharge(iat), charges(iat, 1) - charges(iat, 2)
553 END DO
554 END DO
555 WRITE (unit=unit_nr, &
556 fmt="(T2,A,T29,4(1X,F12.6),/)") &
557 "# Total charge and spin", sum(charges(:, 1)), sum(charges(:, 2)), sum(mcharge(:))
558 END IF
559 END IF
560
561 CALL cp_print_key_finished_output(unit_nr, logger, input, "DFT%PRINT%MULLIKEN")
562
563 DEALLOCATE (charges, mcharge)
564 END IF
565
566 ! EEQ Charges
567 print_key => section_vals_get_subs_vals(input, "DFT%PRINT%EEQ_CHARGES")
568 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
569 unit_nr = cp_print_key_unit_nr(logger, input, "DFT%PRINT%EEQ_CHARGES", &
570 extension=".eeq", log_filename=.false.)
571 CALL eeq_print(qs_env, unit_nr, print_level=1, ext=.false.)
572 CALL cp_print_key_finished_output(unit_nr, logger, print_key)
573 END IF
574
575 ! Compute the Lowdin charges
576 print_key => section_vals_get_subs_vals(input, "DFT%PRINT%LOWDIN")
577 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
578 cpwarn("Lowdin charges not available for semi-empirical calculations!")
579 END IF
580
581 ! Hirshfeld charges
582 print_key => section_vals_get_subs_vals(input, "DFT%PRINT%HIRSHFELD")
583 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
584 cpwarn("Hirshfeld charges not available for semi-empirical calculations!")
585 END IF
586
587 ! MAO
588 print_key => section_vals_get_subs_vals(input, "DFT%PRINT%MAO_ANALYSIS")
589 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
590 cpwarn("MAO analysis not available for semi-empirical calculations!")
591 END IF
592
593 ! ED
594 print_key => section_vals_get_subs_vals(input, "DFT%PRINT%ENERGY_DECOMPOSITION_ANALYSIS")
595 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
596 cpwarn("ED analysis not available for semi-empirical calculations!")
597 END IF
598
599 END SUBROUTINE qs_scf_post_charges
600
601! **************************************************************************************************
602!> \brief Write QS results always available (if switched on through the print_keys)
603!> \param qs_env the qs_env in which the qs_env lives
604! **************************************************************************************************
605 SUBROUTINE write_available_results(qs_env)
606 TYPE(qs_environment_type), POINTER :: qs_env
607
608 CHARACTER(len=*), PARAMETER :: routinen = 'write_available_results'
609
610 INTEGER :: after, handle, ispin, iw, output_unit
611 LOGICAL :: omit_headers
612 TYPE(cp_logger_type), POINTER :: logger
613 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: ks_rmpv, rho_ao
614 TYPE(dft_control_type), POINTER :: dft_control
615 TYPE(mp_para_env_type), POINTER :: para_env
616 TYPE(particle_list_type), POINTER :: particles
617 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
618 TYPE(qs_rho_type), POINTER :: rho
619 TYPE(qs_scf_env_type), POINTER :: scf_env
620 TYPE(qs_subsys_type), POINTER :: subsys
621 TYPE(section_vals_type), POINTER :: dft_section, input
622
623 CALL timeset(routinen, handle)
624 NULLIFY (dft_control, particle_set, rho, ks_rmpv, dft_section, input, &
625 particles, subsys, para_env, rho_ao)
626 logger => cp_get_default_logger()
627 output_unit = cp_logger_get_default_io_unit(logger)
628
629 cpassert(ASSOCIATED(qs_env))
630 CALL get_qs_env(qs_env, &
631 dft_control=dft_control, &
632 particle_set=particle_set, &
633 rho=rho, &
634 matrix_ks=ks_rmpv, &
635 input=input, &
636 subsys=subsys, &
637 scf_env=scf_env, &
638 para_env=para_env)
639 CALL qs_subsys_get(subsys, particles=particles)
640 CALL qs_rho_get(rho, rho_ao=rho_ao)
641
642 ! Print MO information if requested
643 CALL qs_scf_write_mos(qs_env, scf_env, final_mos=.true.)
644
645 ! Aat the end of SCF printout the projected DOS for each atomic kind
646 dft_section => section_vals_get_subs_vals(input, "DFT")
647 IF (btest(cp_print_key_should_output(logger%iter_info, dft_section, "PRINT%PDOS") &
648 , cp_p_file)) THEN
649 cpwarn("PDOS not implemented for Semi-Empirical calculations!")
650 END IF
651
652 ! Print the total density (electronic + core charge)
653 IF (btest(cp_print_key_should_output(logger%iter_info, input, &
654 "DFT%PRINT%TOT_DENSITY_CUBE"), cp_p_file)) THEN
655 cpwarn("TOT_DENSITY_CUBE not implemented for Semi-Empirical calculations!")
656 END IF
657
658 ! Write cube file with electron density
659 IF (btest(cp_print_key_should_output(logger%iter_info, input, &
660 "DFT%PRINT%E_DENSITY_CUBE"), cp_p_file)) THEN
661 cpwarn("E_DENSITY_CUBE not implemented for Semi-Empirical calculations!")
662 END IF ! print key
663
664 ! Write cube file with EFIELD
665 IF (btest(cp_print_key_should_output(logger%iter_info, input, &
666 "DFT%PRINT%EFIELD_CUBE"), cp_p_file)) THEN
667 cpwarn("EFIELD_CUBE not implemented for Semi-Empirical calculations!")
668 END IF ! print key
669
670 ! Write cube file with ELF
671 IF (btest(cp_print_key_should_output(logger%iter_info, input, &
672 "DFT%PRINT%ELF_CUBE"), cp_p_file)) THEN
673 cpwarn("ELF function not implemented for Semi-Empirical calculations!")
674 END IF ! print key
675
676 ! Print the hartree potential
677 IF (btest(cp_print_key_should_output(logger%iter_info, input, &
678 "DFT%PRINT%V_HARTREE_CUBE"), cp_p_file)) THEN
679 cpwarn("V_HARTREE_CUBE not implemented for Semi-Empirical calculations!")
680 END IF
681
682 ! Print the XC potential
683 IF (btest(cp_print_key_should_output(logger%iter_info, input, &
684 "DFT%PRINT%V_XC_CUBE"), cp_p_file)) THEN
685 cpwarn("V_XC_CUBE not available for Semi-Empirical calculations!")
686 END IF
687
688 ! Write the density matrix
689 CALL section_vals_val_get(input, "DFT%PRINT%AO_MATRICES%OMIT_HEADERS", l_val=omit_headers)
690 IF (btest(cp_print_key_should_output(logger%iter_info, input, &
691 "DFT%PRINT%AO_MATRICES/DENSITY"), cp_p_file)) THEN
692 iw = cp_print_key_unit_nr(logger, input, "DFT%PRINT%AO_MATRICES/DENSITY", &
693 extension=".Log")
694 CALL section_vals_val_get(input, "DFT%PRINT%AO_MATRICES%NDIGITS", i_val=after)
695 after = min(max(after, 1), 16)
696 DO ispin = 1, dft_control%nspins
697 CALL cp_dbcsr_write_sparse_matrix(rho_ao(ispin)%matrix, 4, after, qs_env, &
698 para_env, output_unit=iw, omit_headers=omit_headers)
699 END DO
700 CALL cp_print_key_finished_output(iw, logger, input, &
701 "DFT%PRINT%AO_MATRICES/DENSITY")
702 END IF
703
704 ! The Kohn-Sham matrix itself
705 IF (btest(cp_print_key_should_output(logger%iter_info, input, &
706 "DFT%PRINT%AO_MATRICES/KOHN_SHAM_MATRIX"), cp_p_file)) THEN
707 CALL qs_ks_update_qs_env(qs_env, calculate_forces=.false., just_energy=.false.)
708 CALL qs_ks_did_change(qs_env%ks_env, rho_changed=.true.)
709 iw = cp_print_key_unit_nr(logger, input, "DFT%PRINT%AO_MATRICES/KOHN_SHAM_MATRIX", &
710 extension=".Log")
711 CALL section_vals_val_get(input, "DFT%PRINT%AO_MATRICES%NDIGITS", i_val=after)
712 after = min(max(after, 1), 16)
713 CALL cp_dbcsr_write_sparse_matrix(ks_rmpv(1)%matrix, 4, after, qs_env, &
714 para_env, output_unit=iw, omit_headers=omit_headers)
715 CALL cp_print_key_finished_output(iw, logger, input, &
716 "DFT%PRINT%AO_MATRICES/KOHN_SHAM_MATRIX")
717 END IF
718
719 CALL timestop(handle)
720
721 END SUBROUTINE write_available_results
722
723END MODULE qs_scf_post_se
static void dgemm(const char transa, const char transb, const int m, const int n, const int k, const double alpha, const double *a, const int lda, const double *b, const int ldb, const double beta, double *c, const int ldc)
Convenient wrapper to hide Fortran nature of dgemm_, swapping a and b.
Calculation of the moment integrals over Cartesian Gaussian-type functions.
Definition ai_moments.F:17
subroutine, public moment(la_max, npgfa, zeta, rpgfa, la_min, lb_max, npgfb, zetb, rpgfb, lc_max, rac, rbc, mab)
...
Definition ai_moments.F:986
Define the atomic kind types and their sub types.
subroutine, public get_atomic_kind(atomic_kind, fist_potential, element_symbol, name, mass, kind_number, natom, atom_list, rcov, rvdw, z, qeff, apol, cpol, mm_radius, shell, shell_active, damping)
Get attributes of an atomic kind.
Handles all functions related to the CELL.
Definition cell_types.F:15
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
subroutine, public dbcsr_get_block_p(matrix, row, col, block, found, row_size, col_size)
...
DBCSR output in CP2K.
subroutine, public cp_dbcsr_write_sparse_matrix(sparse_matrix, before, after, qs_env, para_env, first_row, last_row, first_col, last_col, scale, output_unit, omit_headers)
...
various routines to log and control the output. The idea is that decisions about where to log should ...
integer function, public cp_logger_get_default_io_unit(logger)
returns the unit nr for the ionode (-1 on all other processors) skips as well checks if the procs cal...
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
routines to handle the output, The idea is to remove the decision of wheter to output and what to out...
integer function, public cp_print_key_unit_nr(logger, basis_section, print_key_path, extension, middle_name, local, log_filename, ignore_should_output, file_form, file_position, file_action, file_status, do_backup, on_file, is_new_file, mpi_io, fout)
...
subroutine, public cp_print_key_finished_output(unit_nr, logger, basis_section, print_key_path, local, ignore_should_output, on_file, mpi_io)
should be called after you finish working with a unit obtained with cp_print_key_unit_nr,...
integer, parameter, public cp_p_file
integer function, public cp_print_key_should_output(iteration_info, basis_section, print_key_path, used_print_key, first_time)
returns what should be done with the given property if btest(res,cp_p_store) then the property should...
set of type/routines to handle the storage of results in force_envs
subroutine, public cp_results_erase(results, description, nval)
erase a part of result_list
set of type/routines to handle the storage of results in force_envs
Calculation of charge equilibration method.
Definition eeq_method.F:12
subroutine, public eeq_print(qs_env, iounit, print_level, ext)
...
Definition eeq_method.F:124
objects that represent the structure of input sections and the data contained in an input section
integer function, public section_get_ival(section_vals, keyword_name)
...
recursive type(section_vals_type) function, pointer, public section_vals_get_subs_vals(section_vals, subsection_name, i_rep_section, can_return_null)
returns the values of the requested subsection
subroutine, public section_vals_get(section_vals, ref_count, n_repetition, n_subs_vals_rep, section, explicit)
returns various attributes about the section_vals
subroutine, public section_vals_val_get(section_vals, keyword_name, i_rep_section, i_rep_val, n_rep_val, val, l_val, i_val, r_val, c_val, l_vals, i_vals, r_vals, c_vals, explicit)
returns the requested value
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
integer, parameter, public default_string_length
Definition kinds.F:57
Definition of mathematical constants and functions.
complex(kind=dp), parameter, public z_one
real(kind=dp), parameter, public twopi
complex(kind=dp), parameter, public z_zero
Interface to the message passing library MPI.
Calculates the moment integrals <a|r^m|b>
subroutine, public get_reference_point(rpoint, drpoint, qs_env, fist_env, reference, ref_point, ifirst, ilast)
...
Provides Cartesian and spherical orbital pointers and indices.
integer, dimension(:), allocatable, public ncoset
integer, dimension(:, :, :), allocatable, public coset
represent a simple array based list of the given type
Define the data structure for the particle information.
Definition of physical constants:
Definition physcon.F:68
real(kind=dp), parameter, public debye
Definition physcon.F:201
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, 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, 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, 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.
Define the quickstep kind type and their sub types.
subroutine, public get_qs_kind(qs_kind, basis_set, basis_type, ncgf, nsgf, all_potential, tnadd_potential, gth_potential, sgp_potential, upf_potential, cneo_potential, se_parameter, dftb_parameter, xtb_parameter, dftb3_param, zatom, zeff, elec_conf, mao, lmax_dftb, alpha_core_charge, ccore_charge, core_charge, core_charge_radius, paw_proj_set, paw_atom, hard_radius, hard0_radius, max_rad_local, covalent_radius, vdw_radius, gpw_type_forced, harmonics, max_iso_not0, max_s_harm, grid_atom, ngrid_ang, ngrid_rad, lmax_rho0, dft_plus_u_atom, l_of_dft_plus_u, n_of_dft_plus_u, u_minus_j, u_of_dft_plus_u, j_of_dft_plus_u, alpha_of_dft_plus_u, beta_of_dft_plus_u, j0_of_dft_plus_u, occupation_of_dft_plus_u, dispersion, bs_occupation, magnetization, no_optimize, addel, laddel, naddel, orbitals, max_scf, eps_scf, smear, u_ramping, u_minus_j_target, eps_u_ramping, init_u_ramping_each_scf, reltmat, ghost, floating, name, element_symbol, pao_basis_size, pao_model_file, pao_potentials, pao_descriptors, nelec)
Get attributes of an atomic kind.
routines that build the Kohn-Sham matrix (i.e calculate the coulomb and xc parts
subroutine, public qs_ks_update_qs_env(qs_env, calculate_forces, just_energy, print_active)
updates the Kohn Sham matrix of the given qs_env (facility method)
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...
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...
subroutine, public qs_scf_write_mos(qs_env, scf_env, final_mos)
Write the MO eigenvector, eigenvalues, and occupation numbers to the output unit.
Does all kind of post scf calculations for semi-empirical.
subroutine, public scf_post_calculation_se(qs_env)
collects possible post - scf calculations and prints info / computes properties. specific for Semi-em...
module that contains the definitions of the scf types
types that represent a quickstep subsys
subroutine, public qs_subsys_get(subsys, atomic_kinds, atomic_kind_set, particles, particle_set, local_particles, molecules, molecule_set, molecule_kinds, molecule_kind_set, local_molecules, para_env, colvar_p, shell_particles, core_particles, gci, multipoles, natom, nparticle, ncore, nshell, nkind, atprop, virial, results, cell, cell_ref, use_ref_cell, energy, force, qs_kind_set, cp_subsys, nelectron_total, nelectron_spin)
...
Definition of the semi empirical parameter types.
subroutine, public get_se_param(sep, name, typ, defined, z, zeff, natorb, eheat, beta, sto_exponents, uss, upp, udd, uff, alp, eisol, gss, gsp, gpp, gp2, acoul, nr, de, ass, asp, app, hsp, gsd, gpd, gdd, ppddg, dpddg, ngauss)
Get info from the semi-empirical type.
Provides all information about an atomic kind.
Type defining parameters related to the simulation cell.
Definition cell_types.F:55
type of a logger, at the moment it contains just a print level starting at which level it should be l...
contains arbitrary information which need to be stored
stores all the informations relevant to an mpi environment
Provides all information about a quickstep kind.
keeps the density in various representations, keeping track of which ones are valid.