(git:badb799)
Loading...
Searching...
No Matches
qs_scf_post_tb.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 DFTB
10!> \par History
11!> Started as a copy from the GPW file
12!> - Revise MO information printout (10.05.2021, MK)
13!> \author JHU (03.2013)
14! **************************************************************************************************
18 USE cell_types, ONLY: cell_type,&
19 pbc
23 USE cp_dbcsr_api, ONLY: dbcsr_p_type,&
34 USE cp_fm_types, ONLY: cp_fm_create,&
43 USE cp_output_handling, ONLY: cp_p_file,&
51 USE eeq_method, ONLY: eeq_print
61 USE kinds, ONLY: default_path_length,&
63 dp
64 USE machine, ONLY: m_flush
65 USE mathconstants, ONLY: twopi,&
66 z_one,&
67 z_zero
72 USE mulliken, ONLY: mulliken_charges
75 USE physcon, ONLY: debye
78 USE pw_env_methods, ONLY: pw_env_create,&
80 USE pw_env_types, ONLY: pw_env_get,&
84 USE pw_methods, ONLY: pw_axpy,&
85 pw_copy,&
86 pw_derive,&
87 pw_scale,&
96 USE pw_pool_types, ONLY: pw_pool_p_type,&
98 USE pw_types, ONLY: pw_c1d_gs_type,&
105 USE qs_dos, ONLY: calculate_dos,&
107 USE qs_elf_methods, ONLY: qs_elf_calc
111 USE qs_kind_types, ONLY: get_qs_kind,&
113 USE qs_ks_types, ONLY: get_ks_env,&
119 USE qs_mo_types, ONLY: get_mo_set,&
124 USE qs_rho_types, ONLY: qs_rho_get,&
125 qs_rho_set,&
130 USE qs_scf_types, ONLY: ot_method_nr,&
132 USE qs_scf_wfn_mix, ONLY: wfn_mix
133 USE qs_subsys_types, ONLY: qs_subsys_get,&
136 USE stm_images, ONLY: th_stm_image
140 USE xtb_qresp, ONLY: build_xtb_qresp
141 USE xtb_types, ONLY: get_xtb_atom_param,&
143#include "./base/base_uses.f90"
144
145 IMPLICIT NONE
146 PRIVATE
147
148 ! Global parameters
149 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'qs_scf_post_tb'
151
152! **************************************************************************************************
153
154CONTAINS
155
156! **************************************************************************************************
157!> \brief collects possible post - scf calculations and prints info / computes properties.
158!> \param qs_env ...
159!> \param tb_type ...
160!> \param no_mos ...
161!> \par History
162!> 03.2013 copy of scf_post_gpw
163!> \author JHU
164!> \note
165! **************************************************************************************************
166 SUBROUTINE scf_post_calculation_tb(qs_env, tb_type, no_mos)
167
168 TYPE(qs_environment_type), POINTER :: qs_env
169 CHARACTER(LEN=*) :: tb_type
170 LOGICAL, INTENT(IN) :: no_mos
171
172 CHARACTER(len=*), PARAMETER :: routinen = 'scf_post_calculation_tb'
173
174 CHARACTER(LEN=6) :: ana
175 CHARACTER(LEN=default_string_length) :: aname
176 INTEGER :: after, gfn_type, handle, homo, iat, iatom, ikind, img, ispin, iw, nat, natom, &
177 nkind, nlumo_stm, nlumos, nspins, print_level, unit_nr
178 LOGICAL :: do_cube, do_kpoints, explicit, gfn0, &
179 has_homo, omit_headers, print_it, &
180 rebuild, vdip
181 REAL(kind=dp) :: zeff
182 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: mcharge
183 REAL(kind=dp), DIMENSION(2, 2) :: homo_lumo
184 REAL(kind=dp), DIMENSION(:), POINTER :: echarge, mo_eigenvalues
185 REAL(kind=dp), DIMENSION(:, :), POINTER :: charges
186 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
187 TYPE(cp_1d_r_p_type), DIMENSION(:), POINTER :: unoccupied_evals_stm
188 TYPE(cp_fm_type), DIMENSION(:), POINTER :: unoccupied_orbs_stm
189 TYPE(cp_fm_type), POINTER :: mo_coeff
190 TYPE(cp_logger_type), POINTER :: logger
191 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: ks_rmpv, mo_derivs
192 TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: matrix_ks, matrix_p, matrix_s
193 TYPE(dbcsr_type), POINTER :: mo_coeff_deriv
194 TYPE(dft_control_type), POINTER :: dft_control
195 TYPE(mo_set_type), DIMENSION(:), POINTER :: mos
196 TYPE(mp_para_env_type), POINTER :: para_env
197 TYPE(particle_list_type), POINTER :: particles
198 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
199 TYPE(qs_dftb_atom_type), POINTER :: dftb_kind
200 TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
201 TYPE(qs_rho_type), POINTER :: rho
202 TYPE(qs_scf_env_type), POINTER :: scf_env
203 TYPE(qs_subsys_type), POINTER :: subsys
204 TYPE(scf_control_type), POINTER :: scf_control
205 TYPE(section_vals_type), POINTER :: dft_section, moments_section, print_key, &
206 print_section, sprint_section, &
207 wfn_mix_section
208 TYPE(xtb_atom_type), POINTER :: xtb_kind
209
210 CALL timeset(routinen, handle)
211
212 logger => cp_get_default_logger()
213
214 gfn0 = .false.
215 vdip = .false.
216 CALL get_qs_env(qs_env, dft_control=dft_control)
217 SELECT CASE (trim(tb_type))
218 CASE ("DFTB")
219 CASE ("xTB")
220 gfn_type = dft_control%qs_control%xtb_control%gfn_type
221 gfn0 = (gfn_type == 0)
222 vdip = dft_control%qs_control%xtb_control%var_dipole
223 CASE DEFAULT
224 cpabort("unknown TB type")
225 END SELECT
226
227 cpassert(ASSOCIATED(qs_env))
228 NULLIFY (rho, para_env, matrix_s, matrix_p)
229 CALL get_qs_env(qs_env, scf_env=scf_env, atomic_kind_set=atomic_kind_set, qs_kind_set=qs_kind_set, &
230 rho=rho, natom=natom, para_env=para_env, &
231 particle_set=particle_set, do_kpoints=do_kpoints, matrix_s_kp=matrix_s)
232 nspins = dft_control%nspins
233 CALL qs_rho_get(rho, rho_ao_kp=matrix_p)
234 ! Mulliken charges
235 ALLOCATE (charges(natom, nspins), mcharge(natom))
236 !
237 CALL mulliken_charges(matrix_p, matrix_s, para_env, charges)
238 !
239 nkind = SIZE(atomic_kind_set)
240 DO ikind = 1, nkind
241 CALL get_atomic_kind(atomic_kind_set(ikind), natom=nat)
242 SELECT CASE (trim(tb_type))
243 CASE ("DFTB")
244 CALL get_qs_kind(qs_kind_set(ikind), dftb_parameter=dftb_kind)
245 CALL get_dftb_atom_param(dftb_kind, zeff=zeff)
246 CASE ("xTB")
247 CALL get_qs_kind(qs_kind_set(ikind), xtb_parameter=xtb_kind)
248 CALL get_xtb_atom_param(xtb_kind, zeff=zeff)
249 CASE DEFAULT
250 cpabort("unknown TB type")
251 END SELECT
252 DO iatom = 1, nat
253 iat = atomic_kind_set(ikind)%atom_list(iatom)
254 mcharge(iat) = zeff - sum(charges(iat, 1:nspins))
255 END DO
256 END DO
257
258 dft_section => section_vals_get_subs_vals(qs_env%input, "DFT")
259 print_section => section_vals_get_subs_vals(dft_section, "PRINT")
260
261 ! Mulliken
262 print_key => section_vals_get_subs_vals(print_section, "MULLIKEN")
263 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
264 unit_nr = cp_print_key_unit_nr(logger, print_section, "MULLIKEN", &
265 extension=".mulliken", log_filename=.false.)
266 IF (unit_nr > 0) THEN
267 WRITE (unit=unit_nr, fmt="(/,/,T2,A)") "MULLIKEN POPULATION ANALYSIS"
268 IF (nspins == 1) THEN
269 WRITE (unit=unit_nr, fmt="(/,T2,A,T70,A)") &
270 " # Atom Element Kind Atomic population", " Net charge"
271 DO ikind = 1, nkind
272 CALL get_atomic_kind(atomic_kind_set(ikind), natom=nat)
273 aname = ""
274 SELECT CASE (tb_type)
275 CASE ("DFTB")
276 CALL get_qs_kind(qs_kind_set(ikind), dftb_parameter=dftb_kind)
277 CALL get_dftb_atom_param(dftb_kind, name=aname)
278 CASE ("xTB")
279 CALL get_qs_kind(qs_kind_set(ikind), xtb_parameter=xtb_kind)
280 CALL get_xtb_atom_param(xtb_kind, symbol=aname)
281 CASE DEFAULT
282 cpabort("unknown TB type")
283 END SELECT
284 ana = adjustr(trim(adjustl(aname)))
285 DO iatom = 1, nat
286 iat = atomic_kind_set(ikind)%atom_list(iatom)
287 WRITE (unit=unit_nr, &
288 fmt="(T2,I7,5X,A6,I6,T39,F12.6,T69,F12.6)") &
289 iat, adjustl(ana), ikind, charges(iat, 1), mcharge(iat)
290 END DO
291 END DO
292 WRITE (unit=unit_nr, &
293 fmt="(T2,A,T39,F12.6,T69,F12.6,/)") &
294 "# Total charge", sum(charges(:, 1)), sum(mcharge(:))
295 ELSE
296 WRITE (unit=unit_nr, fmt="(/,T2,A)") &
297 "# Atom Element Kind Atomic population (alpha,beta) Net charge Spin moment"
298 DO ikind = 1, nkind
299 CALL get_atomic_kind(atomic_kind_set(ikind), natom=nat)
300 aname = ""
301 SELECT CASE (tb_type)
302 CASE ("DFTB")
303 CALL get_qs_kind(qs_kind_set(ikind), dftb_parameter=dftb_kind)
304 CALL get_dftb_atom_param(dftb_kind, name=aname)
305 CASE ("xTB")
306 CALL get_qs_kind(qs_kind_set(ikind), xtb_parameter=xtb_kind)
307 CALL get_xtb_atom_param(xtb_kind, symbol=aname)
308 CASE DEFAULT
309 cpabort("unknown TB type")
310 END SELECT
311 ana = adjustr(trim(adjustl(aname)))
312 DO iatom = 1, nat
313 iat = atomic_kind_set(ikind)%atom_list(iatom)
314 WRITE (unit=unit_nr, &
315 fmt="(T2,I6,3X,A6,I6,T29,4(1X,F12.6))") &
316 iat, adjustl(ana), ikind, charges(iat, 1:2), mcharge(iat), &
317 charges(iat, 1) - charges(iat, 2)
318 END DO
319 END DO
320 WRITE (unit=unit_nr, &
321 fmt="(T2,A,T29,4(1X,F12.6),/)") &
322 "# Total charge and spin", sum(charges(:, 1)), sum(charges(:, 2)), sum(mcharge(:))
323 END IF
324 CALL m_flush(unit_nr)
325 END IF
326 CALL cp_print_key_finished_output(unit_nr, logger, print_key)
327 END IF
328
329 ! Compute the Lowdin charges
330 print_key => section_vals_get_subs_vals(print_section, "LOWDIN")
331 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
332 SELECT CASE (tb_type)
333 CASE ("DFTB")
334 cpwarn("Lowdin population analysis not implemented for DFTB method.")
335 CASE ("xTB")
336 unit_nr = cp_print_key_unit_nr(logger, print_section, "LOWDIN", extension=".lowdin", &
337 log_filename=.false.)
338 print_level = 1
339 CALL section_vals_val_get(print_key, "PRINT_GOP", l_val=print_it)
340 IF (print_it) print_level = 2
341 CALL section_vals_val_get(print_key, "PRINT_ALL", l_val=print_it)
342 IF (print_it) print_level = 3
343 IF (do_kpoints) THEN
344 cpwarn("Lowdin charges not implemented for k-point calculations!")
345 ELSE
346 CALL lowdin_population_analysis(qs_env, unit_nr, print_level)
347 END IF
348 CALL cp_print_key_finished_output(unit_nr, logger, print_section, "LOWDIN")
349 CASE DEFAULT
350 cpabort("unknown TB type")
351 END SELECT
352 END IF
353
354 ! EEQ Charges
355 print_key => section_vals_get_subs_vals(print_section, "EEQ_CHARGES")
356 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
357 unit_nr = cp_print_key_unit_nr(logger, print_section, "EEQ_CHARGES", &
358 extension=".eeq", log_filename=.false.)
359 CALL eeq_print(qs_env, unit_nr, print_level, ext=gfn0)
360 CALL cp_print_key_finished_output(unit_nr, logger, print_key)
361 END IF
362
363 ! Hirshfeld
364 print_key => section_vals_get_subs_vals(print_section, "HIRSHFELD")
365 CALL section_vals_get(print_key, explicit=explicit)
366 IF (explicit) THEN
367 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
368 cpwarn("Hirshfeld charges not available for TB methods.")
369 END IF
370 END IF
371
372 ! MAO
373 print_key => section_vals_get_subs_vals(print_section, "MAO_ANALYSIS")
374 CALL section_vals_get(print_key, explicit=explicit)
375 IF (explicit) THEN
376 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
377 cpwarn("MAO analysis not available for TB methods.")
378 END IF
379 END IF
380
381 ! ED
382 print_key => section_vals_get_subs_vals(print_section, "ENERGY_DECOMPOSITION_ANALYSIS")
383 CALL section_vals_get(print_key, explicit=explicit)
384 IF (explicit) THEN
385 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
386 cpwarn("ED analysis not available for TB methods.")
387 END IF
388 END IF
389
390 ! Dipole Moments
391 print_key => section_vals_get_subs_vals(print_section, "MOMENTS")
392 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
393 unit_nr = cp_print_key_unit_nr(logger, print_section, "MOMENTS", &
394 extension=".data", middle_name="tb_dipole", log_filename=.false.)
395 moments_section => section_vals_get_subs_vals(print_section, "MOMENTS")
396 IF (gfn0) THEN
397 NULLIFY (echarge)
398 CALL get_qs_env(qs_env, eeq=echarge)
399 cpassert(ASSOCIATED(echarge))
400 IF (vdip) THEN
401 CALL build_xtb_qresp(qs_env, mcharge)
402 mcharge(1:natom) = echarge(1:natom) - mcharge(1:natom)
403 END IF
404 CALL tb_dipole(qs_env, moments_section, unit_nr, mcharge)
405 ELSE
406 CALL tb_dipole(qs_env, moments_section, unit_nr, mcharge)
407 END IF
408 CALL cp_print_key_finished_output(unit_nr, logger, print_key)
409 END IF
410
411 DEALLOCATE (charges, mcharge)
412
413 ! MO
414 IF (.NOT. no_mos) THEN
415 print_key => section_vals_get_subs_vals(print_section, "MO")
416 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
417 CALL qs_scf_write_mos(qs_env, scf_env, final_mos=.true.)
418 IF (.NOT. do_kpoints) THEN
419 SELECT CASE (tb_type)
420 CASE ("DFTB")
421 CASE ("xTB")
422 sprint_section => section_vals_get_subs_vals(dft_section, "PRINT%MO_MOLDEN")
423 CALL get_qs_env(qs_env, mos=mos)
424 CALL write_mos_molden(mos, qs_kind_set, particle_set, sprint_section)
425 CASE DEFAULT
426 cpabort("Unknown TB type")
427 END SELECT
428 END IF
429 END IF
430 END IF
431
432 ! Wavefunction mixing
433 IF (.NOT. no_mos) THEN
434 wfn_mix_section => section_vals_get_subs_vals(dft_section, "PRINT%WFN_MIX")
435 CALL section_vals_get(wfn_mix_section, explicit=explicit)
436 IF (explicit .AND. .NOT. qs_env%run_rtp) CALL wfn_mix_tb(qs_env, dft_section, scf_env)
437 END IF
438
439 IF (.NOT. no_mos) THEN
440 print_key => section_vals_get_subs_vals(print_section, "DOS")
441 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
442 IF (do_kpoints) THEN
443 CALL calculate_dos_kp(qs_env, dft_section)
444 ELSE
445 CALL get_qs_env(qs_env, mos=mos)
446 CALL calculate_dos(mos, dft_section)
447 END IF
448 END IF
449 END IF
450
451 ! PDOS
452 IF (.NOT. no_mos) THEN
453 print_key => section_vals_get_subs_vals(print_section, "PDOS")
454 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
455 IF (do_kpoints) THEN
456 cpwarn("Projected density of states not implemented for k-points.")
457 ELSE
458 CALL get_qs_env(qs_env, mos=mos, matrix_ks=ks_rmpv)
459 DO ispin = 1, dft_control%nspins
460 IF (scf_env%method == ot_method_nr) THEN
461 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff, &
462 eigenvalues=mo_eigenvalues)
463 IF (ASSOCIATED(qs_env%mo_derivs)) THEN
464 mo_coeff_deriv => qs_env%mo_derivs(ispin)%matrix
465 ELSE
466 mo_coeff_deriv => null()
467 END IF
468 CALL calculate_subspace_eigenvalues(mo_coeff, ks_rmpv(ispin)%matrix, mo_eigenvalues, &
469 do_rotation=.true., &
470 co_rotate_dbcsr=mo_coeff_deriv)
471 CALL set_mo_occupation(mo_set=mos(ispin))
472 END IF
473 IF (dft_control%nspins == 2) THEN
474 CALL calculate_projected_dos(mos(ispin), atomic_kind_set, &
475 qs_kind_set, particle_set, qs_env, dft_section, ispin=ispin)
476 ELSE
477 CALL calculate_projected_dos(mos(ispin), atomic_kind_set, &
478 qs_kind_set, particle_set, qs_env, dft_section)
479 END IF
480 END DO
481 END IF
482 END IF
483 END IF
484
485 ! can we do CUBE files?
486 SELECT CASE (tb_type)
487 CASE ("DFTB")
488 do_cube = .false.
489 rebuild = .false.
490 CASE ("xTB")
491 do_cube = .true.
492 rebuild = .true.
493 CASE DEFAULT
494 cpabort("unknown TB type")
495 END SELECT
496
497 ! Energy Windows for LS code
498 print_key => section_vals_get_subs_vals(print_section, "ENERGY_WINDOWS")
499 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
500 IF (do_cube) THEN
501 IF (do_kpoints) THEN
502 cpwarn("Energy Windows not implemented for k-points.")
503 ELSE
504 IF (rebuild) THEN
505 CALL rebuild_pw_env(qs_env)
506 rebuild = .false.
507 END IF
508 CALL energy_windows(qs_env)
509 END IF
510 ELSE
511 cpwarn("Energy Windows not implemented for TB methods.")
512 END IF
513 END IF
514
515 ! DENSITY CUBE FILE
516 print_key => section_vals_get_subs_vals(print_section, "E_DENSITY_CUBE")
517 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
518 IF (do_cube) THEN
519 IF (rebuild) THEN
520 CALL rebuild_pw_env(qs_env)
521 rebuild = .false.
522 END IF
523 CALL print_e_density(qs_env, print_key)
524 ELSE
525 cpwarn("Electronic density cube file not implemented for TB methods.")
526 END IF
527 END IF
528
529 ! TOTAL DENSITY CUBE FILE
530 print_key => section_vals_get_subs_vals(print_section, "TOT_DENSITY_CUBE")
531 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
532 IF (do_cube) THEN
533 IF (rebuild) THEN
534 CALL rebuild_pw_env(qs_env)
535 rebuild = .false.
536 END IF
537 CALL print_density_cubes(qs_env, print_key, total_density=.true.)
538 ELSE
539 cpwarn("Total density cube file not implemented for TB methods.")
540 END IF
541 END IF
542
543 ! V_Hartree CUBE FILE
544 print_key => section_vals_get_subs_vals(print_section, "V_HARTREE_CUBE")
545 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
546 IF (do_cube) THEN
547 IF (rebuild) THEN
548 CALL rebuild_pw_env(qs_env)
549 rebuild = .false.
550 END IF
551 CALL print_density_cubes(qs_env, print_key, v_hartree=.true.)
552 ELSE
553 cpwarn("Hartree potential cube file not implemented for TB methods.")
554 END IF
555 END IF
556
557 ! EFIELD CUBE FILE
558 print_key => section_vals_get_subs_vals(print_section, "EFIELD_CUBE")
559 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
560 IF (do_cube) THEN
561 IF (rebuild) THEN
562 CALL rebuild_pw_env(qs_env)
563 rebuild = .false.
564 END IF
565 CALL print_density_cubes(qs_env, print_key, efield=.true.)
566 ELSE
567 cpwarn("Efield cube file not implemented for TB methods.")
568 END IF
569 END IF
570
571 ! ELF
572 print_key => section_vals_get_subs_vals(print_section, "ELF_CUBE")
573 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
574 IF (do_cube) THEN
575 IF (rebuild) THEN
576 CALL rebuild_pw_env(qs_env)
577 rebuild = .false.
578 END IF
579 CALL print_elf(qs_env, print_key)
580 ELSE
581 cpwarn("ELF not implemented for TB methods.")
582 END IF
583 END IF
584
585 ! MO CUBES
586 IF (.NOT. no_mos) THEN
587 print_key => section_vals_get_subs_vals(print_section, "MO_CUBES")
588 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
589 IF (do_cube) THEN
590 IF (rebuild) THEN
591 CALL rebuild_pw_env(qs_env)
592 rebuild = .false.
593 END IF
594 CALL print_mo_cubes(qs_env, print_key)
595 ELSE
596 cpwarn("Printing of MO cube files not implemented for TB methods.")
597 END IF
598 END IF
599 END IF
600
601 ! STM
602 IF (.NOT. no_mos) THEN
603 print_key => section_vals_get_subs_vals(print_section, "STM")
604 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
605 IF (do_cube) THEN
606 IF (rebuild) THEN
607 CALL rebuild_pw_env(qs_env)
608 rebuild = .false.
609 END IF
610 IF (do_kpoints) THEN
611 cpwarn("STM not implemented for k-point calculations!")
612 ELSE
613 nlumo_stm = section_get_ival(print_key, "NLUMO")
614 cpassert(.NOT. dft_control%restricted)
615 CALL get_qs_env(qs_env, mos=mos, mo_derivs=mo_derivs, &
616 scf_control=scf_control, matrix_ks=ks_rmpv)
617 CALL make_mo_eig(mos, dft_control%nspins, ks_rmpv, scf_control, mo_derivs)
618 DO ispin = 1, dft_control%nspins
619 CALL get_mo_set(mo_set=mos(ispin), eigenvalues=mo_eigenvalues, homo=homo)
620 homo_lumo(ispin, 1) = mo_eigenvalues(homo)
621 END DO
622 has_homo = .true.
623 NULLIFY (unoccupied_orbs_stm, unoccupied_evals_stm)
624 IF (nlumo_stm > 0) THEN
625 ALLOCATE (unoccupied_orbs_stm(dft_control%nspins))
626 ALLOCATE (unoccupied_evals_stm(dft_control%nspins))
627 CALL make_lumo_tb(qs_env, scf_env, unoccupied_orbs_stm, unoccupied_evals_stm, &
628 nlumo_stm, nlumos)
629 END IF
630
631 CALL get_qs_env(qs_env, subsys=subsys)
632 CALL qs_subsys_get(subsys, particles=particles)
633 CALL th_stm_image(qs_env, print_key, particles, unoccupied_orbs_stm, &
634 unoccupied_evals_stm)
635
636 IF (nlumo_stm > 0) THEN
637 DO ispin = 1, dft_control%nspins
638 DEALLOCATE (unoccupied_evals_stm(ispin)%array)
639 END DO
640 DEALLOCATE (unoccupied_evals_stm)
641 CALL cp_fm_release(unoccupied_orbs_stm)
642 END IF
643 END IF
644 END IF
645 END IF
646 END IF
647
648 ! Write the density matrix
649 CALL get_qs_env(qs_env, matrix_ks_kp=matrix_ks)
650 CALL section_vals_val_get(print_section, "AO_MATRICES%OMIT_HEADERS", l_val=omit_headers)
651 IF (btest(cp_print_key_should_output(logger%iter_info, print_section, &
652 "AO_MATRICES/DENSITY"), cp_p_file)) THEN
653 iw = cp_print_key_unit_nr(logger, print_section, "AO_MATRICES/DENSITY", &
654 extension=".Log")
655 CALL section_vals_val_get(print_section, "AO_MATRICES%NDIGITS", i_val=after)
656 after = min(max(after, 1), 16)
657 DO ispin = 1, dft_control%nspins
658 DO img = 1, SIZE(matrix_p, 2)
659 CALL cp_dbcsr_write_sparse_matrix(matrix_p(ispin, img)%matrix, 4, after, qs_env, &
660 para_env, output_unit=iw, omit_headers=omit_headers)
661 END DO
662 END DO
663 CALL cp_print_key_finished_output(iw, logger, print_section, "AO_MATRICES/DENSITY")
664 END IF
665
666 ! The xTB matrix itself
667 IF (btest(cp_print_key_should_output(logger%iter_info, print_section, &
668 "AO_MATRICES/KOHN_SHAM_MATRIX"), cp_p_file)) THEN
669 iw = cp_print_key_unit_nr(logger, print_section, "AO_MATRICES/KOHN_SHAM_MATRIX", &
670 extension=".Log")
671 CALL section_vals_val_get(print_section, "AO_MATRICES%NDIGITS", i_val=after)
672 after = min(max(after, 1), 16)
673 DO ispin = 1, dft_control%nspins
674 DO img = 1, SIZE(matrix_ks, 2)
675 CALL cp_dbcsr_write_sparse_matrix(matrix_ks(ispin, img)%matrix, 4, after, qs_env, para_env, &
676 output_unit=iw, omit_headers=omit_headers)
677 END DO
678 END DO
679 CALL cp_print_key_finished_output(iw, logger, print_section, "AO_MATRICES/KOHN_SHAM_MATRIX")
680 END IF
681
682 ! these print keys are not supported in TB
683
684 ! V_XC CUBE FILE
685 print_key => section_vals_get_subs_vals(print_section, "V_XC_CUBE")
686 CALL section_vals_get(print_key, explicit=explicit)
687 IF (explicit) THEN
688 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
689 cpwarn("XC potential cube file not available for TB methods.")
690 END IF
691 END IF
692
693 ! Electric field gradients
694 print_key => section_vals_get_subs_vals(print_section, "ELECTRIC_FIELD_GRADIENT")
695 CALL section_vals_get(print_key, explicit=explicit)
696 IF (explicit) THEN
697 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
698 cpwarn("Electric field gradient not implemented for TB methods.")
699 END IF
700 END IF
701
702 ! KINETIC ENERGY
703 print_key => section_vals_get_subs_vals(print_section, "KINETIC_ENERGY")
704 CALL section_vals_get(print_key, explicit=explicit)
705 IF (explicit) THEN
706 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
707 cpwarn("Kinetic energy not available for TB methods.")
708 END IF
709 END IF
710
711 ! Xray diffraction spectrum
712 print_key => section_vals_get_subs_vals(print_section, "XRAY_DIFFRACTION_SPECTRUM")
713 CALL section_vals_get(print_key, explicit=explicit)
714 IF (explicit) THEN
715 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
716 cpwarn("Xray diffraction spectrum not implemented for TB methods.")
717 END IF
718 END IF
719
720 ! EPR Hyperfine Coupling
721 print_key => section_vals_get_subs_vals(print_section, "HYPERFINE_COUPLING_TENSOR")
722 CALL section_vals_get(print_key, explicit=explicit)
723 IF (explicit) THEN
724 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
725 cpwarn("Hyperfine Coupling not implemented for TB methods.")
726 END IF
727 END IF
728
729 ! PLUS_U
730 print_key => section_vals_get_subs_vals(print_section, "PLUS_U")
731 CALL section_vals_get(print_key, explicit=explicit)
732 IF (explicit) THEN
733 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
734 cpwarn("DFT+U method not implemented for TB methods.")
735 END IF
736 END IF
737
738 CALL write_ks_matrix_csr(qs_env, qs_env%input)
739 CALL write_s_matrix_csr(qs_env, qs_env%input)
740
741 CALL timestop(handle)
742
743 END SUBROUTINE scf_post_calculation_tb
744
745! **************************************************************************************************
746!> \brief ...
747!> \param qs_env ...
748!> \param input ...
749!> \param unit_nr ...
750!> \param charges ...
751! **************************************************************************************************
752 SUBROUTINE tb_dipole(qs_env, input, unit_nr, charges)
753
754 TYPE(qs_environment_type), POINTER :: qs_env
755 TYPE(section_vals_type), POINTER :: input
756 INTEGER, INTENT(in) :: unit_nr
757 REAL(kind=dp), DIMENSION(:), INTENT(in) :: charges
758
759 CHARACTER(LEN=default_string_length) :: description, dipole_type
760 COMPLEX(KIND=dp) :: dzeta, dzphase(3), zeta, zphase(3)
761 COMPLEX(KIND=dp), DIMENSION(3) :: dggamma, ggamma
762 INTEGER :: i, iat, ikind, j, nat, reference
763 LOGICAL :: do_berry
764 REAL(kind=dp) :: charge_tot, ci(3), dci(3), dipole(3), dipole_deriv(3), drcc(3), dria(3), &
765 dtheta, gvec(3), q, rcc(3), ria(3), theta, tmp(3), via(3)
766 REAL(kind=dp), DIMENSION(:), POINTER :: ref_point
767 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
768 TYPE(cell_type), POINTER :: cell
769 TYPE(cp_result_type), POINTER :: results
770 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
771
772 NULLIFY (atomic_kind_set, cell, results)
773 CALL get_qs_env(qs_env, atomic_kind_set=atomic_kind_set, &
774 particle_set=particle_set, cell=cell, results=results)
775
776 ! Reference point
777 reference = section_get_ival(input, keyword_name="REFERENCE")
778 NULLIFY (ref_point)
779 description = '[DIPOLE]'
780 CALL section_vals_val_get(input, "REF_POINT", r_vals=ref_point)
781 CALL section_vals_val_get(input, "PERIODIC", l_val=do_berry)
782
783 CALL get_reference_point(rcc, drcc, qs_env=qs_env, reference=reference, ref_point=ref_point)
784
785 ! Dipole deriv will be the derivative of the Dipole(dM/dt=\sum e_j v_j)
786 dipole_deriv = 0.0_dp
787 dipole = 0.0_dp
788 IF (do_berry) THEN
789 dipole_type = "periodic (Berry phase)"
790 rcc = pbc(rcc, cell)
791 charge_tot = 0._dp
792 charge_tot = sum(charges)
793 ria = twopi*matmul(cell%h_inv, rcc)
794 zphase = cmplx(cos(ria), sin(ria), dp)**charge_tot
795
796 dria = twopi*matmul(cell%h_inv, drcc)
797 dzphase = charge_tot*cmplx(-sin(ria), cos(ria), dp)**(charge_tot - 1.0_dp)*dria
798
799 ggamma = z_one
800 dggamma = z_zero
801 DO ikind = 1, SIZE(atomic_kind_set)
802 CALL get_atomic_kind(atomic_kind_set(ikind), natom=nat)
803 DO i = 1, nat
804 iat = atomic_kind_set(ikind)%atom_list(i)
805 ria = particle_set(iat)%r(:)
806 ria = pbc(ria, cell)
807 via = particle_set(iat)%v(:)
808 q = charges(iat)
809 DO j = 1, 3
810 gvec = twopi*cell%h_inv(j, :)
811 theta = sum(ria(:)*gvec(:))
812 dtheta = sum(via(:)*gvec(:))
813 zeta = cmplx(cos(theta), sin(theta), kind=dp)**(-q)
814 dzeta = -q*cmplx(-sin(theta), cos(theta), kind=dp)**(-q - 1.0_dp)*dtheta
815 dggamma(j) = dggamma(j)*zeta + ggamma(j)*dzeta
816 ggamma(j) = ggamma(j)*zeta
817 END DO
818 END DO
819 END DO
820 dggamma = dggamma*zphase + ggamma*dzphase
821 ggamma = ggamma*zphase
822 IF (all(real(ggamma, kind=dp) /= 0.0_dp)) THEN
823 tmp = aimag(ggamma)/real(ggamma, kind=dp)
824 ci = -atan(tmp)
825 dci = -(1.0_dp/(1.0_dp + tmp**2))* &
826 (aimag(dggamma)*real(ggamma, kind=dp) - aimag(ggamma)*real(dggamma, kind=dp))/(real(ggamma, kind=dp))**2
827 dipole = matmul(cell%hmat, ci)/twopi
828 dipole_deriv = matmul(cell%hmat, dci)/twopi
829 END IF
830 ELSE
831 dipole_type = "non-periodic"
832 DO i = 1, SIZE(particle_set)
833 ! no pbc(particle_set(i)%r(:),cell) so that the total dipole is the sum of the molecular dipoles
834 ria = particle_set(i)%r(:)
835 q = charges(i)
836 dipole = dipole + q*(ria - rcc)
837 dipole_deriv(:) = dipole_deriv(:) + q*(particle_set(i)%v(:) - drcc)
838 END DO
839 END IF
840 CALL cp_results_erase(results=results, description=description)
841 CALL put_results(results=results, description=description, &
842 values=dipole(1:3))
843 IF (unit_nr > 0) THEN
844 WRITE (unit_nr, '(/,T2,A,T31,A50)') &
845 'TB_DIPOLE| Dipole type', adjustr(trim(dipole_type))
846 WRITE (unit_nr, "(T2,A,T30,3(1X,F16.8))") "TB_DIPOLE| Ref. Point [Bohr]", rcc
847 WRITE (unit_nr, '(T2,A,T30,3(1X,F16.8))') &
848 'TB_DIPOLE| Moment [a.u.]', dipole(1:3)
849 WRITE (unit_nr, '(T2,A,T30,3(1X,F16.8))') &
850 'TB_DIPOLE| Moment [Debye]', dipole(1:3)*debye
851 WRITE (unit_nr, '(T2,A,T30,3(1X,F16.8))') &
852 'TB_DIPOLE| Derivative [a.u.]', dipole_deriv(1:3)
853 END IF
854
855 END SUBROUTINE tb_dipole
856
857! **************************************************************************************************
858!> \brief computes the MOs and calls the wavefunction mixing routine.
859!> \param qs_env ...
860!> \param dft_section ...
861!> \param scf_env ...
862!> \author Florian Schiffmann
863!> \note
864! **************************************************************************************************
865
866 SUBROUTINE wfn_mix_tb(qs_env, dft_section, scf_env)
867
868 TYPE(qs_environment_type), POINTER :: qs_env
869 TYPE(section_vals_type), POINTER :: dft_section
870 TYPE(qs_scf_env_type), POINTER :: scf_env
871
872 INTEGER :: ispin, nao, nmo, output_unit
873 REAL(dp), DIMENSION(:), POINTER :: mo_eigenvalues
874 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
875 TYPE(cp_fm_struct_type), POINTER :: ao_ao_fmstruct, ao_lumo_struct
876 TYPE(cp_fm_type) :: ks_tmp, mo_tmp, s_tmp, work
877 TYPE(cp_fm_type), DIMENSION(:), POINTER :: lumos
878 TYPE(cp_fm_type), POINTER :: mo_coeff
879 TYPE(cp_logger_type), POINTER :: logger
880 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_ks, matrix_s
881 TYPE(mo_set_type), DIMENSION(:), POINTER :: mos
882 TYPE(mp_para_env_type), POINTER :: para_env
883 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
884 TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
885 TYPE(section_vals_type), POINTER :: wfn_mix_section
886
887 logger => cp_get_default_logger()
888 CALL get_qs_env(qs_env=qs_env, matrix_s=matrix_s, matrix_ks=matrix_ks, &
889 particle_set=particle_set, atomic_kind_set=atomic_kind_set, &
890 qs_kind_set=qs_kind_set, mos=mos, para_env=para_env)
891
892 wfn_mix_section => section_vals_get_subs_vals(dft_section, "PRINT%WFN_MIX")
893
894 CALL get_mo_set(mos(1), mo_coeff=mo_coeff, nao=nao)
895
896 CALL cp_fm_struct_create(fmstruct=ao_ao_fmstruct, nrow_global=nao, ncol_global=nao, &
897 template_fmstruct=mo_coeff%matrix_struct)
898 CALL cp_fm_create(s_tmp, matrix_struct=ao_ao_fmstruct)
899 CALL cp_fm_create(ks_tmp, matrix_struct=ao_ao_fmstruct)
900 CALL cp_fm_create(mo_tmp, matrix_struct=ao_ao_fmstruct)
901 CALL cp_fm_create(work, matrix_struct=ao_ao_fmstruct)
902 ALLOCATE (lumos(SIZE(mos)))
903
904 CALL copy_dbcsr_to_fm(matrix_s(1)%matrix, s_tmp)
905 CALL cp_fm_cholesky_decompose(s_tmp)
906
907 DO ispin = 1, SIZE(mos)
908 CALL get_mo_set(mos(ispin), mo_coeff=mo_coeff, eigenvalues=mo_eigenvalues, nmo=nmo)
909 CALL cp_fm_struct_create(fmstruct=ao_lumo_struct, nrow_global=nao, ncol_global=nao - nmo, &
910 template_fmstruct=mo_coeff%matrix_struct)
911
912 CALL cp_fm_create(lumos(ispin), matrix_struct=ao_lumo_struct)
913 CALL copy_dbcsr_to_fm(matrix_ks(ispin)%matrix, ks_tmp)
914 CALL cp_fm_cholesky_reduce(ks_tmp, s_tmp)
915 CALL choose_eigv_solver(ks_tmp, work, mo_eigenvalues)
916 CALL cp_fm_cholesky_restore(work, nao, s_tmp, mo_tmp, "SOLVE")
917 CALL cp_fm_to_fm_submat(mo_tmp, mo_coeff, nao, nmo, 1, 1, 1, 1)
918 CALL cp_fm_to_fm_submat(mo_tmp, lumos(ispin), nao, nao - nmo, 1, nmo + 1, 1, 1)
919
920 CALL cp_fm_struct_release(ao_lumo_struct)
921 END DO
922
923 output_unit = cp_logger_get_default_io_unit(logger)
924 CALL wfn_mix(mos, particle_set, dft_section, qs_kind_set, para_env, output_unit, &
925 unoccupied_orbs=lumos, scf_env=scf_env, matrix_s=matrix_s)
926
927 CALL cp_fm_release(lumos)
928 CALL cp_fm_release(s_tmp)
929 CALL cp_fm_release(mo_tmp)
930 CALL cp_fm_release(ks_tmp)
931 CALL cp_fm_release(work)
932 CALL cp_fm_struct_release(ao_ao_fmstruct)
933
934 END SUBROUTINE wfn_mix_tb
935
936! **************************************************************************************************
937!> \brief Gets the lumos, and eigenvalues for the lumos
938!> \param qs_env ...
939!> \param scf_env ...
940!> \param unoccupied_orbs ...
941!> \param unoccupied_evals ...
942!> \param nlumo ...
943!> \param nlumos ...
944! **************************************************************************************************
945 SUBROUTINE make_lumo_tb(qs_env, scf_env, unoccupied_orbs, unoccupied_evals, nlumo, nlumos)
946
947 TYPE(qs_environment_type), POINTER :: qs_env
948 TYPE(qs_scf_env_type), POINTER :: scf_env
949 TYPE(cp_fm_type), DIMENSION(:), POINTER :: unoccupied_orbs
950 TYPE(cp_1d_r_p_type), DIMENSION(:), INTENT(INOUT) :: unoccupied_evals
951 INTEGER :: nlumo
952 INTEGER, INTENT(OUT) :: nlumos
953
954 INTEGER :: homo, iounit, ispin, n, nao, nmo
955 TYPE(cp_blacs_env_type), POINTER :: blacs_env
956 TYPE(cp_fm_struct_type), POINTER :: fm_struct_tmp
957 TYPE(cp_fm_type), POINTER :: mo_coeff
958 TYPE(cp_logger_type), POINTER :: logger
959 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: ks_rmpv, matrix_s
960 TYPE(dft_control_type), POINTER :: dft_control
961 TYPE(mo_set_type), DIMENSION(:), POINTER :: mos
962 TYPE(mp_para_env_type), POINTER :: para_env
963 TYPE(preconditioner_type), POINTER :: local_preconditioner
964 TYPE(scf_control_type), POINTER :: scf_control
965
966 NULLIFY (mos, ks_rmpv, scf_control, dft_control, para_env, blacs_env)
967 CALL get_qs_env(qs_env, &
968 mos=mos, &
969 matrix_ks=ks_rmpv, &
970 scf_control=scf_control, &
971 dft_control=dft_control, &
972 matrix_s=matrix_s, &
973 para_env=para_env, &
974 blacs_env=blacs_env)
975
976 logger => cp_get_default_logger()
977 iounit = cp_logger_get_default_io_unit(logger)
978
979 DO ispin = 1, dft_control%nspins
980 NULLIFY (unoccupied_evals(ispin)%array)
981 ! Always write eigenvalues
982 IF (iounit > 0) WRITE (iounit, *) " "
983 IF (iounit > 0) WRITE (iounit, *) " Lowest Eigenvalues of the unoccupied subspace spin ", ispin
984 IF (iounit > 0) WRITE (iounit, fmt='(1X,A)') "-----------------------------------------------------"
985 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff, homo=homo, nao=nao, nmo=nmo)
986 CALL cp_fm_get_info(mo_coeff, nrow_global=n)
987 nlumos = max(1, min(nlumo, nao - nmo))
988 IF (nlumo == -1) nlumos = nao - nmo
989 ALLOCATE (unoccupied_evals(ispin)%array(nlumos))
990 CALL cp_fm_struct_create(fm_struct_tmp, para_env=para_env, context=blacs_env, &
991 nrow_global=n, ncol_global=nlumos)
992 CALL cp_fm_create(unoccupied_orbs(ispin), fm_struct_tmp, name="lumos")
993 CALL cp_fm_struct_release(fm_struct_tmp)
994 CALL cp_fm_init_random(unoccupied_orbs(ispin), nlumos)
995
996 ! the full_all preconditioner makes not much sense for lumos search
997 NULLIFY (local_preconditioner)
998 IF (ASSOCIATED(scf_env%ot_preconditioner)) THEN
999 local_preconditioner => scf_env%ot_preconditioner(1)%preconditioner
1000 ! this one can for sure not be right (as it has to match a given C0)
1001 IF (local_preconditioner%in_use == ot_precond_full_all) THEN
1002 NULLIFY (local_preconditioner)
1003 END IF
1004 END IF
1005
1006 CALL ot_eigensolver(matrix_h=ks_rmpv(ispin)%matrix, matrix_s=matrix_s(1)%matrix, &
1007 matrix_c_fm=unoccupied_orbs(ispin), &
1008 matrix_orthogonal_space_fm=mo_coeff, &
1009 eps_gradient=scf_control%eps_lumos, &
1010 preconditioner=local_preconditioner, &
1011 iter_max=scf_control%max_iter_lumos, &
1012 size_ortho_space=nmo)
1013
1014 CALL calculate_subspace_eigenvalues(unoccupied_orbs(ispin), ks_rmpv(ispin)%matrix, &
1015 unoccupied_evals(ispin)%array, scr=iounit, &
1016 ionode=iounit > 0)
1017
1018 END DO
1019
1020 END SUBROUTINE make_lumo_tb
1021
1022! **************************************************************************************************
1023!> \brief ...
1024!> \param qs_env ...
1025! **************************************************************************************************
1026 SUBROUTINE rebuild_pw_env(qs_env)
1027
1028 TYPE(qs_environment_type), POINTER :: qs_env
1029
1030 LOGICAL :: skip_load_balance_distributed
1031 TYPE(cell_type), POINTER :: cell
1032 TYPE(dft_control_type), POINTER :: dft_control
1033 TYPE(pw_env_type), POINTER :: new_pw_env
1034 TYPE(qs_ks_env_type), POINTER :: ks_env
1035 TYPE(qs_rho_type), POINTER :: rho
1036 TYPE(task_list_type), POINTER :: task_list
1037
1038 CALL get_qs_env(qs_env, ks_env=ks_env, dft_control=dft_control, pw_env=new_pw_env)
1039 IF (.NOT. ASSOCIATED(new_pw_env)) THEN
1040 CALL pw_env_create(new_pw_env)
1041 CALL set_ks_env(ks_env, pw_env=new_pw_env)
1042 CALL pw_env_release(new_pw_env)
1043 END IF
1044 CALL get_qs_env(qs_env, pw_env=new_pw_env, dft_control=dft_control, cell=cell)
1045
1046 new_pw_env%cell_hmat = cell%hmat
1047 CALL pw_env_rebuild(new_pw_env, qs_env=qs_env)
1048
1049 NULLIFY (task_list)
1050 CALL get_ks_env(ks_env, task_list=task_list)
1051 IF (.NOT. ASSOCIATED(task_list)) THEN
1052 CALL allocate_task_list(task_list)
1053 CALL set_ks_env(ks_env, task_list=task_list)
1054 END IF
1055 skip_load_balance_distributed = dft_control%qs_control%skip_load_balance_distributed
1056 CALL generate_qs_task_list(ks_env, task_list, &
1057 reorder_rs_grid_ranks=.true., soft_valid=.false., &
1058 skip_load_balance_distributed=skip_load_balance_distributed)
1059 CALL get_qs_env(qs_env, rho=rho)
1060 CALL qs_rho_rebuild(rho, qs_env=qs_env, rebuild_ao=.false., rebuild_grids=.true.)
1061
1062 END SUBROUTINE rebuild_pw_env
1063
1064! **************************************************************************************************
1065!> \brief ...
1066!> \param qs_env ...
1067!> \param cube_section ...
1068! **************************************************************************************************
1069 SUBROUTINE print_e_density(qs_env, cube_section)
1070
1071 TYPE(qs_environment_type), POINTER :: qs_env
1072 TYPE(section_vals_type), POINTER :: cube_section
1073
1074 CHARACTER(LEN=default_path_length) :: filename, mpi_filename, my_pos_cube
1075 INTEGER :: iounit, ispin, unit_nr
1076 LOGICAL :: append_cube, mpi_io
1077 REAL(kind=dp), DIMENSION(:), POINTER :: tot_rho_r
1078 TYPE(cp_logger_type), POINTER :: logger
1079 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: rho_ao
1080 TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: rho_ao_kp
1081 TYPE(dft_control_type), POINTER :: dft_control
1082 TYPE(particle_list_type), POINTER :: particles
1083 TYPE(pw_c1d_gs_type), DIMENSION(:), POINTER :: rho_g
1084 TYPE(pw_env_type), POINTER :: pw_env
1085 TYPE(pw_pool_p_type), DIMENSION(:), POINTER :: pw_pools
1086 TYPE(pw_pool_type), POINTER :: auxbas_pw_pool
1087 TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: rho_r
1088 TYPE(qs_ks_env_type), POINTER :: ks_env
1089 TYPE(qs_rho_type), POINTER :: rho
1090 TYPE(qs_subsys_type), POINTER :: subsys
1091
1092 CALL get_qs_env(qs_env, dft_control=dft_control)
1093
1094 append_cube = section_get_lval(cube_section, "APPEND")
1095 my_pos_cube = "REWIND"
1096 IF (append_cube) my_pos_cube = "APPEND"
1097
1098 logger => cp_get_default_logger()
1099 iounit = cp_logger_get_default_io_unit(logger)
1100
1101 ! we need to construct the density on a realspace grid
1102 CALL get_qs_env(qs_env, ks_env=ks_env, rho=rho)
1103 NULLIFY (rho_r, rho_g, tot_rho_r)
1104 CALL qs_rho_get(rho, rho_ao_kp=rho_ao_kp, &
1105 rho_r=rho_r, rho_g=rho_g, tot_rho_r=tot_rho_r)
1106 DO ispin = 1, dft_control%nspins
1107 rho_ao => rho_ao_kp(ispin, :)
1108 CALL calculate_rho_elec(matrix_p_kp=rho_ao, &
1109 rho=rho_r(ispin), &
1110 rho_gspace=rho_g(ispin), &
1111 total_rho=tot_rho_r(ispin), &
1112 ks_env=ks_env)
1113 END DO
1114 CALL qs_rho_set(rho, rho_r_valid=.true., rho_g_valid=.true.)
1115
1116 CALL get_qs_env(qs_env, subsys=subsys)
1117 CALL qs_subsys_get(subsys, particles=particles)
1118
1119 IF (dft_control%nspins > 1) THEN
1120 IF (iounit > 0) THEN
1121 WRITE (unit=iounit, fmt="(/,T2,A,T51,2F15.6)") &
1122 "Integrated alpha and beta electronic density:", tot_rho_r(1:2)
1123 END IF
1124 CALL get_qs_env(qs_env=qs_env, pw_env=pw_env)
1125 CALL pw_env_get(pw_env=pw_env, auxbas_pw_pool=auxbas_pw_pool, pw_pools=pw_pools)
1126 block
1127 TYPE(pw_r3d_rs_type) :: rho_elec_rspace
1128 CALL auxbas_pw_pool%create_pw(pw=rho_elec_rspace)
1129 CALL pw_copy(rho_r(1), rho_elec_rspace)
1130 CALL pw_axpy(rho_r(2), rho_elec_rspace)
1131 filename = "ELECTRON_DENSITY"
1132 mpi_io = .true.
1133 unit_nr = cp_print_key_unit_nr(logger, cube_section, '', &
1134 extension=".cube", middle_name=trim(filename), &
1135 file_position=my_pos_cube, log_filename=.false., mpi_io=mpi_io, &
1136 fout=mpi_filename)
1137 IF (iounit > 0) THEN
1138 IF (.NOT. mpi_io) THEN
1139 INQUIRE (unit=unit_nr, name=filename)
1140 ELSE
1141 filename = mpi_filename
1142 END IF
1143 WRITE (unit=iounit, fmt="(T2,A,/,T2,A79)") &
1144 "The sum of alpha and beta density is written in cube file format to the file:", adjustr(trim(filename))
1145 END IF
1146 CALL cp_pw_to_cube(rho_elec_rspace, unit_nr, "SUM OF ALPHA AND BETA DENSITY", &
1147 particles=particles, stride=section_get_ivals(cube_section, "STRIDE"), &
1148 mpi_io=mpi_io)
1149 CALL cp_print_key_finished_output(unit_nr, logger, cube_section, '', mpi_io=mpi_io)
1150 CALL pw_copy(rho_r(1), rho_elec_rspace)
1151 CALL pw_axpy(rho_r(2), rho_elec_rspace, alpha=-1.0_dp)
1152 filename = "SPIN_DENSITY"
1153 mpi_io = .true.
1154 unit_nr = cp_print_key_unit_nr(logger, cube_section, '', &
1155 extension=".cube", middle_name=trim(filename), &
1156 file_position=my_pos_cube, log_filename=.false., mpi_io=mpi_io, &
1157 fout=mpi_filename)
1158 IF (iounit > 0) THEN
1159 IF (.NOT. mpi_io) THEN
1160 INQUIRE (unit=unit_nr, name=filename)
1161 ELSE
1162 filename = mpi_filename
1163 END IF
1164 WRITE (unit=iounit, fmt="(T2,A,/,T2,A79)") &
1165 "The spin density is written in cube file format to the file:", adjustr(trim(filename))
1166 END IF
1167 CALL cp_pw_to_cube(rho_elec_rspace, unit_nr, "SPIN DENSITY", &
1168 particles=particles, &
1169 stride=section_get_ivals(cube_section, "STRIDE"), mpi_io=mpi_io)
1170 CALL cp_print_key_finished_output(unit_nr, logger, cube_section, '', mpi_io=mpi_io)
1171 CALL auxbas_pw_pool%give_back_pw(rho_elec_rspace)
1172 END block
1173 ELSE
1174 IF (iounit > 0) THEN
1175 WRITE (unit=iounit, fmt="(/,T2,A,T66,F15.6)") &
1176 "Integrated electronic density:", tot_rho_r(1)
1177 END IF
1178 filename = "ELECTRON_DENSITY"
1179 mpi_io = .true.
1180 unit_nr = cp_print_key_unit_nr(logger, cube_section, '', &
1181 extension=".cube", middle_name=trim(filename), &
1182 file_position=my_pos_cube, log_filename=.false., mpi_io=mpi_io, &
1183 fout=mpi_filename)
1184 IF (iounit > 0) THEN
1185 IF (.NOT. mpi_io) THEN
1186 INQUIRE (unit=unit_nr, name=filename)
1187 ELSE
1188 filename = mpi_filename
1189 END IF
1190 WRITE (unit=iounit, fmt="(T2,A,/,T2,A79)") &
1191 "The electron density is written in cube file format to the file:", adjustr(trim(filename))
1192 END IF
1193 CALL cp_pw_to_cube(rho_r(1), unit_nr, "ELECTRON DENSITY", &
1194 particles=particles, &
1195 stride=section_get_ivals(cube_section, "STRIDE"), mpi_io=mpi_io)
1196 CALL cp_print_key_finished_output(unit_nr, logger, cube_section, '', mpi_io=mpi_io)
1197 END IF ! nspins
1198
1199 END SUBROUTINE print_e_density
1200! **************************************************************************************************
1201!> \brief ...
1202!> \param qs_env ...
1203!> \param cube_section ...
1204!> \param total_density ...
1205!> \param v_hartree ...
1206!> \param efield ...
1207! **************************************************************************************************
1208 SUBROUTINE print_density_cubes(qs_env, cube_section, total_density, v_hartree, efield)
1209
1210 TYPE(qs_environment_type), POINTER :: qs_env
1211 TYPE(section_vals_type), POINTER :: cube_section
1212 LOGICAL, INTENT(IN), OPTIONAL :: total_density, v_hartree, efield
1213
1214 CHARACTER(len=1), DIMENSION(3), PARAMETER :: cdir = (/"x", "y", "z"/)
1215
1216 CHARACTER(LEN=default_path_length) :: filename, mpi_filename, my_pos_cube
1217 INTEGER :: id, iounit, ispin, nd(3), unit_nr
1218 LOGICAL :: append_cube, mpi_io, my_efield, &
1219 my_total_density, my_v_hartree
1220 REAL(kind=dp) :: total_rho_core_rspace, udvol
1221 REAL(kind=dp), DIMENSION(:), POINTER :: tot_rho_r
1222 TYPE(cell_type), POINTER :: cell
1223 TYPE(cp_logger_type), POINTER :: logger
1224 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: rho_ao
1225 TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: rho_ao_kp
1226 TYPE(dft_control_type), POINTER :: dft_control
1227 TYPE(particle_list_type), POINTER :: particles
1228 TYPE(pw_c1d_gs_type) :: rho_core
1229 TYPE(pw_c1d_gs_type), DIMENSION(:), POINTER :: rho_g
1230 TYPE(pw_env_type), POINTER :: pw_env
1231 TYPE(pw_poisson_parameter_type) :: poisson_params
1232 TYPE(pw_pool_p_type), DIMENSION(:), POINTER :: pw_pools
1233 TYPE(pw_pool_type), POINTER :: auxbas_pw_pool
1234 TYPE(pw_r3d_rs_type) :: rho_tot_rspace
1235 TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: rho_r
1236 TYPE(qs_ks_env_type), POINTER :: ks_env
1237 TYPE(qs_rho_type), POINTER :: rho
1238 TYPE(qs_subsys_type), POINTER :: subsys
1239
1240 CALL get_qs_env(qs_env, cell=cell, dft_control=dft_control)
1241
1242 append_cube = section_get_lval(cube_section, "APPEND")
1243 my_pos_cube = "REWIND"
1244 IF (append_cube) my_pos_cube = "APPEND"
1245
1246 IF (PRESENT(total_density)) THEN
1247 my_total_density = total_density
1248 ELSE
1249 my_total_density = .false.
1250 END IF
1251 IF (PRESENT(v_hartree)) THEN
1252 my_v_hartree = v_hartree
1253 ELSE
1254 my_v_hartree = .false.
1255 END IF
1256 IF (PRESENT(efield)) THEN
1257 my_efield = efield
1258 ELSE
1259 my_efield = .false.
1260 END IF
1261
1262 logger => cp_get_default_logger()
1263 iounit = cp_logger_get_default_io_unit(logger)
1264
1265 ! we need to construct the density on a realspace grid
1266 CALL get_qs_env(qs_env, ks_env=ks_env, rho=rho)
1267 NULLIFY (rho_r, rho_g, tot_rho_r)
1268 CALL qs_rho_get(rho, rho_ao_kp=rho_ao_kp, &
1269 rho_r=rho_r, rho_g=rho_g, tot_rho_r=tot_rho_r)
1270 DO ispin = 1, dft_control%nspins
1271 rho_ao => rho_ao_kp(ispin, :)
1272 CALL calculate_rho_elec(matrix_p_kp=rho_ao, &
1273 rho=rho_r(ispin), &
1274 rho_gspace=rho_g(ispin), &
1275 total_rho=tot_rho_r(ispin), &
1276 ks_env=ks_env)
1277 END DO
1278 CALL qs_rho_set(rho, rho_r_valid=.true., rho_g_valid=.true.)
1279
1280 CALL get_qs_env(qs_env, subsys=subsys)
1281 CALL qs_subsys_get(subsys, particles=particles)
1282
1283 CALL get_qs_env(qs_env=qs_env, pw_env=pw_env)
1284 CALL pw_env_get(pw_env=pw_env, auxbas_pw_pool=auxbas_pw_pool, pw_pools=pw_pools)
1285 CALL auxbas_pw_pool%create_pw(pw=rho_core)
1286 CALL calculate_rho_core(rho_core, total_rho_core_rspace, qs_env)
1287
1288 IF (iounit > 0) THEN
1289 WRITE (unit=iounit, fmt="(/,T2,A,T66,F15.6)") &
1290 "Integrated electronic density:", sum(tot_rho_r(:))
1291 WRITE (unit=iounit, fmt="(T2,A,T66,F15.6)") &
1292 "Integrated core density:", total_rho_core_rspace
1293 END IF
1294
1295 CALL auxbas_pw_pool%create_pw(pw=rho_tot_rspace)
1296 CALL pw_transfer(rho_core, rho_tot_rspace)
1297 DO ispin = 1, dft_control%nspins
1298 CALL pw_axpy(rho_r(ispin), rho_tot_rspace)
1299 END DO
1300
1301 IF (my_total_density) THEN
1302 filename = "TOTAL_DENSITY"
1303 mpi_io = .true.
1304 unit_nr = cp_print_key_unit_nr(logger, cube_section, '', &
1305 extension=".cube", middle_name=trim(filename), file_position=my_pos_cube, &
1306 log_filename=.false., mpi_io=mpi_io, fout=mpi_filename)
1307 IF (iounit > 0) THEN
1308 IF (.NOT. mpi_io) THEN
1309 INQUIRE (unit=unit_nr, name=filename)
1310 ELSE
1311 filename = mpi_filename
1312 END IF
1313 WRITE (unit=iounit, fmt="(T2,A,/,T2,A79)") &
1314 "The total density is written in cube file format to the file:", adjustr(trim(filename))
1315 END IF
1316 CALL cp_pw_to_cube(rho_tot_rspace, unit_nr, "TOTAL DENSITY", &
1317 particles=particles, &
1318 stride=section_get_ivals(cube_section, "STRIDE"), mpi_io=mpi_io)
1319 CALL cp_print_key_finished_output(unit_nr, logger, cube_section, '', mpi_io=mpi_io)
1320 END IF
1321 IF (my_v_hartree .OR. my_efield) THEN
1322 block
1323 TYPE(pw_c1d_gs_type) :: rho_tot_gspace
1324 CALL auxbas_pw_pool%create_pw(pw=rho_tot_gspace)
1325 CALL pw_transfer(rho_tot_rspace, rho_tot_gspace)
1326 poisson_params%solver = pw_poisson_analytic
1327 poisson_params%periodic = cell%perd
1328 poisson_params%ewald_type = do_ewald_none
1329 block
1330 TYPE(greens_fn_type) :: green_fft
1331 TYPE(pw_grid_type), POINTER :: pwdummy
1332 NULLIFY (pwdummy)
1333 CALL pw_green_create(green_fft, poisson_params, cell%hmat, auxbas_pw_pool, pwdummy, pwdummy)
1334 rho_tot_gspace%array(:) = rho_tot_gspace%array(:)*green_fft%influence_fn%array(:)
1335 CALL pw_green_release(green_fft, auxbas_pw_pool)
1336 END block
1337 IF (my_v_hartree) THEN
1338 block
1339 TYPE(pw_r3d_rs_type) :: vhartree
1340 CALL auxbas_pw_pool%create_pw(pw=vhartree)
1341 CALL pw_transfer(rho_tot_gspace, vhartree)
1342 filename = "V_HARTREE"
1343 mpi_io = .true.
1344 unit_nr = cp_print_key_unit_nr(logger, cube_section, '', &
1345 extension=".cube", middle_name=trim(filename), file_position=my_pos_cube, &
1346 log_filename=.false., mpi_io=mpi_io, fout=mpi_filename)
1347 IF (iounit > 0) THEN
1348 IF (.NOT. mpi_io) THEN
1349 INQUIRE (unit=unit_nr, name=filename)
1350 ELSE
1351 filename = mpi_filename
1352 END IF
1353 WRITE (unit=iounit, fmt="(T2,A,/,T2,A79)") &
1354 "The Hartree potential is written in cube file format to the file:", adjustr(trim(filename))
1355 END IF
1356 CALL cp_pw_to_cube(vhartree, unit_nr, "Hartree Potential", &
1357 particles=particles, &
1358 stride=section_get_ivals(cube_section, "STRIDE"), mpi_io=mpi_io)
1359 CALL cp_print_key_finished_output(unit_nr, logger, cube_section, '', mpi_io=mpi_io)
1360 CALL auxbas_pw_pool%give_back_pw(vhartree)
1361 END block
1362 END IF
1363 IF (my_efield) THEN
1364 block
1365 TYPE(pw_c1d_gs_type) :: vhartree
1366 CALL auxbas_pw_pool%create_pw(pw=vhartree)
1367 udvol = 1.0_dp/rho_tot_rspace%pw_grid%dvol
1368 DO id = 1, 3
1369 CALL pw_transfer(rho_tot_gspace, vhartree)
1370 nd = 0
1371 nd(id) = 1
1372 CALL pw_derive(vhartree, nd)
1373 CALL pw_transfer(vhartree, rho_tot_rspace)
1374 CALL pw_scale(rho_tot_rspace, udvol)
1375
1376 filename = "EFIELD_"//cdir(id)
1377 mpi_io = .true.
1378 unit_nr = cp_print_key_unit_nr(logger, cube_section, '', &
1379 extension=".cube", middle_name=trim(filename), file_position=my_pos_cube, &
1380 log_filename=.false., mpi_io=mpi_io, fout=mpi_filename)
1381 IF (iounit > 0) THEN
1382 IF (.NOT. mpi_io) THEN
1383 INQUIRE (unit=unit_nr, name=filename)
1384 ELSE
1385 filename = mpi_filename
1386 END IF
1387 WRITE (unit=iounit, fmt="(T2,A,/,T2,A79)") &
1388 "The Efield is written in cube file format to the file:", adjustr(trim(filename))
1389 END IF
1390 CALL cp_pw_to_cube(rho_tot_rspace, unit_nr, "EFIELD "//cdir(id), &
1391 particles=particles, &
1392 stride=section_get_ivals(cube_section, "STRIDE"), mpi_io=mpi_io)
1393 CALL cp_print_key_finished_output(unit_nr, logger, cube_section, '', mpi_io=mpi_io)
1394 END DO
1395 CALL auxbas_pw_pool%give_back_pw(vhartree)
1396 END block
1397 END IF
1398 CALL auxbas_pw_pool%give_back_pw(rho_tot_gspace)
1399 END block
1400 END IF
1401
1402 CALL auxbas_pw_pool%give_back_pw(rho_tot_rspace)
1403 CALL auxbas_pw_pool%give_back_pw(rho_core)
1404
1405 END SUBROUTINE print_density_cubes
1406
1407! **************************************************************************************************
1408!> \brief ...
1409!> \param qs_env ...
1410!> \param elf_section ...
1411! **************************************************************************************************
1412 SUBROUTINE print_elf(qs_env, elf_section)
1413
1414 TYPE(qs_environment_type), POINTER :: qs_env
1415 TYPE(section_vals_type), POINTER :: elf_section
1416
1417 CHARACTER(LEN=default_path_length) :: filename, mpi_filename, my_pos_cube, &
1418 title
1419 INTEGER :: iounit, ispin, unit_nr
1420 LOGICAL :: append_cube, mpi_io
1421 REAL(kind=dp) :: rho_cutoff
1422 REAL(kind=dp), DIMENSION(:), POINTER :: tot_rho_r
1423 TYPE(cp_logger_type), POINTER :: logger
1424 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: rho_ao
1425 TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: rho_ao_kp
1426 TYPE(dft_control_type), POINTER :: dft_control
1427 TYPE(particle_list_type), POINTER :: particles
1428 TYPE(pw_c1d_gs_type), DIMENSION(:), POINTER :: rho_g
1429 TYPE(pw_env_type), POINTER :: pw_env
1430 TYPE(pw_pool_p_type), DIMENSION(:), POINTER :: pw_pools
1431 TYPE(pw_pool_type), POINTER :: auxbas_pw_pool
1432 TYPE(pw_r3d_rs_type), ALLOCATABLE, DIMENSION(:) :: elf_r
1433 TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: rho_r
1434 TYPE(qs_ks_env_type), POINTER :: ks_env
1435 TYPE(qs_rho_type), POINTER :: rho
1436 TYPE(qs_subsys_type), POINTER :: subsys
1437
1438 logger => cp_get_default_logger()
1439 iounit = cp_logger_get_default_io_unit(logger)
1440
1441 ! we need to construct the density on a realspace grid
1442 CALL get_qs_env(qs_env, dft_control=dft_control, ks_env=ks_env, rho=rho)
1443 NULLIFY (rho_r, rho_g, tot_rho_r)
1444 CALL qs_rho_get(rho, rho_ao_kp=rho_ao_kp, &
1445 rho_r=rho_r, rho_g=rho_g, tot_rho_r=tot_rho_r)
1446 DO ispin = 1, dft_control%nspins
1447 rho_ao => rho_ao_kp(ispin, :)
1448 CALL calculate_rho_elec(matrix_p_kp=rho_ao, &
1449 rho=rho_r(ispin), &
1450 rho_gspace=rho_g(ispin), &
1451 total_rho=tot_rho_r(ispin), &
1452 ks_env=ks_env)
1453 END DO
1454 CALL qs_rho_set(rho, rho_r_valid=.true., rho_g_valid=.true.)
1455
1456 CALL get_qs_env(qs_env, subsys=subsys)
1457 CALL qs_subsys_get(subsys, particles=particles)
1458
1459 ALLOCATE (elf_r(dft_control%nspins))
1460 CALL get_qs_env(qs_env=qs_env, pw_env=pw_env)
1461 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool, pw_pools=pw_pools)
1462 DO ispin = 1, dft_control%nspins
1463 CALL auxbas_pw_pool%create_pw(elf_r(ispin))
1464 CALL pw_zero(elf_r(ispin))
1465 END DO
1466
1467 IF (iounit > 0) THEN
1468 WRITE (unit=iounit, fmt="(/,T2,A)") &
1469 "ELF is computed on the real space grid -----"
1470 END IF
1471 rho_cutoff = section_get_rval(elf_section, "density_cutoff")
1472 CALL qs_elf_calc(qs_env, elf_r, rho_cutoff)
1473
1474 ! write ELF into cube file
1475 append_cube = section_get_lval(elf_section, "APPEND")
1476 my_pos_cube = "REWIND"
1477 IF (append_cube) my_pos_cube = "APPEND"
1478 DO ispin = 1, dft_control%nspins
1479 WRITE (filename, '(a5,I1.1)') "ELF_S", ispin
1480 WRITE (title, *) "ELF spin ", ispin
1481 mpi_io = .true.
1482 unit_nr = cp_print_key_unit_nr(logger, elf_section, '', extension=".cube", &
1483 middle_name=trim(filename), file_position=my_pos_cube, &
1484 log_filename=.false., mpi_io=mpi_io, fout=mpi_filename)
1485 IF (iounit > 0) THEN
1486 IF (.NOT. mpi_io) THEN
1487 INQUIRE (unit=unit_nr, name=filename)
1488 ELSE
1489 filename = mpi_filename
1490 END IF
1491 WRITE (unit=iounit, fmt="(T2,A,/,T2,A79)") &
1492 "ELF is written in cube file format to the file:", adjustr(trim(filename))
1493 END IF
1494
1495 CALL cp_pw_to_cube(elf_r(ispin), unit_nr, title, particles=particles, &
1496 stride=section_get_ivals(elf_section, "STRIDE"), mpi_io=mpi_io)
1497 CALL cp_print_key_finished_output(unit_nr, logger, elf_section, '', mpi_io=mpi_io)
1498
1499 CALL auxbas_pw_pool%give_back_pw(elf_r(ispin))
1500 END DO
1501
1502 DEALLOCATE (elf_r)
1503
1504 END SUBROUTINE print_elf
1505! **************************************************************************************************
1506!> \brief ...
1507!> \param qs_env ...
1508!> \param cube_section ...
1509! **************************************************************************************************
1510 SUBROUTINE print_mo_cubes(qs_env, cube_section)
1511
1512 TYPE(qs_environment_type), POINTER :: qs_env
1513 TYPE(section_vals_type), POINTER :: cube_section
1514
1515 CHARACTER(LEN=default_path_length) :: filename, my_pos_cube, title
1516 INTEGER :: homo, i, ifirst, ilast, iounit, ir, &
1517 ispin, ivector, n_rep, nhomo, nlist, &
1518 nlumo, nmo, shomo, unit_nr
1519 INTEGER, DIMENSION(:), POINTER :: list, list_index
1520 LOGICAL :: append_cube, mpi_io, write_cube
1521 REAL(kind=dp) :: homo_lumo(2, 2)
1522 REAL(kind=dp), DIMENSION(:), POINTER :: mo_eigenvalues
1523 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
1524 TYPE(cell_type), POINTER :: cell
1525 TYPE(cp_fm_type), POINTER :: mo_coeff
1526 TYPE(cp_logger_type), POINTER :: logger
1527 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: ks_rmpv, mo_derivs
1528 TYPE(dft_control_type), POINTER :: dft_control
1529 TYPE(mo_set_type), DIMENSION(:), POINTER :: mos
1530 TYPE(particle_list_type), POINTER :: particles
1531 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
1532 TYPE(pw_c1d_gs_type) :: wf_g
1533 TYPE(pw_env_type), POINTER :: pw_env
1534 TYPE(pw_pool_p_type), DIMENSION(:), POINTER :: pw_pools
1535 TYPE(pw_pool_type), POINTER :: auxbas_pw_pool
1536 TYPE(pw_r3d_rs_type) :: wf_r
1537 TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
1538 TYPE(qs_subsys_type), POINTER :: subsys
1539 TYPE(scf_control_type), POINTER :: scf_control
1540
1541 logger => cp_get_default_logger()
1542 iounit = cp_logger_get_default_io_unit(logger)
1543
1544 CALL get_qs_env(qs_env, mos=mos, matrix_ks=ks_rmpv, scf_control=scf_control)
1545 CALL get_qs_env(qs_env, dft_control=dft_control, mo_derivs=mo_derivs)
1546 CALL make_mo_eig(mos, dft_control%nspins, ks_rmpv, scf_control, mo_derivs)
1547 NULLIFY (mo_eigenvalues)
1548 homo = 0
1549 DO ispin = 1, dft_control%nspins
1550 CALL get_mo_set(mo_set=mos(ispin), eigenvalues=mo_eigenvalues, homo=shomo)
1551 homo_lumo(ispin, 1) = mo_eigenvalues(shomo)
1552 homo = max(homo, shomo)
1553 END DO
1554 write_cube = section_get_lval(cube_section, "WRITE_CUBE")
1555 nlumo = section_get_ival(cube_section, "NLUMO")
1556 nhomo = section_get_ival(cube_section, "NHOMO")
1557 NULLIFY (list_index)
1558 CALL section_vals_val_get(cube_section, "HOMO_LIST", n_rep_val=n_rep)
1559 IF (n_rep > 0) THEN
1560 nlist = 0
1561 DO ir = 1, n_rep
1562 NULLIFY (list)
1563 CALL section_vals_val_get(cube_section, "HOMO_LIST", i_rep_val=ir, i_vals=list)
1564 IF (ASSOCIATED(list)) THEN
1565 CALL reallocate(list_index, 1, nlist + SIZE(list))
1566 DO i = 1, SIZE(list)
1567 list_index(i + nlist) = list(i)
1568 END DO
1569 nlist = nlist + SIZE(list)
1570 END IF
1571 END DO
1572 nhomo = maxval(list_index)
1573 ELSE
1574 IF (nhomo == -1) nhomo = homo
1575 nlist = homo - max(1, homo - nhomo + 1) + 1
1576 ALLOCATE (list_index(nlist))
1577 DO i = 1, nlist
1578 list_index(i) = max(1, homo - nhomo + 1) + i - 1
1579 END DO
1580 END IF
1581
1582 CALL get_qs_env(qs_env=qs_env, pw_env=pw_env)
1583 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool, pw_pools=pw_pools)
1584 CALL auxbas_pw_pool%create_pw(wf_r)
1585 CALL auxbas_pw_pool%create_pw(wf_g)
1586
1587 CALL get_qs_env(qs_env, subsys=subsys)
1588 CALL qs_subsys_get(subsys, particles=particles)
1589
1590 append_cube = section_get_lval(cube_section, "APPEND")
1591 my_pos_cube = "REWIND"
1592 IF (append_cube) THEN
1593 my_pos_cube = "APPEND"
1594 END IF
1595
1596 CALL get_qs_env(qs_env=qs_env, &
1597 atomic_kind_set=atomic_kind_set, &
1598 qs_kind_set=qs_kind_set, &
1599 cell=cell, &
1600 particle_set=particle_set)
1601
1602 IF (nhomo >= 0) THEN
1603 DO ispin = 1, dft_control%nspins
1604 ! Prints the cube files of OCCUPIED ORBITALS
1605 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff, &
1606 eigenvalues=mo_eigenvalues, homo=homo, nmo=nmo)
1607 IF (write_cube) THEN
1608 DO i = 1, nlist
1609 ivector = list_index(i)
1610 IF (ivector > homo) cycle
1611 CALL calculate_wavefunction(mo_coeff, ivector, wf_r, wf_g, atomic_kind_set, qs_kind_set, &
1612 cell, dft_control, particle_set, pw_env)
1613 WRITE (filename, '(a4,I5.5,a1,I1.1)') "WFN_", ivector, "_", ispin
1614 mpi_io = .true.
1615 unit_nr = cp_print_key_unit_nr(logger, cube_section, '', extension=".cube", &
1616 middle_name=trim(filename), file_position=my_pos_cube, &
1617 log_filename=.false., mpi_io=mpi_io)
1618 WRITE (title, *) "WAVEFUNCTION ", ivector, " spin ", ispin, " i.e. HOMO - ", ivector - homo
1619 CALL cp_pw_to_cube(wf_r, unit_nr, title, particles=particles, &
1620 stride=section_get_ivals(cube_section, "STRIDE"), mpi_io=mpi_io)
1621 CALL cp_print_key_finished_output(unit_nr, logger, cube_section, '', mpi_io=mpi_io)
1622 END DO
1623 END IF
1624 END DO
1625 END IF
1626
1627 IF (nlumo /= 0) THEN
1628 DO ispin = 1, dft_control%nspins
1629 ! Prints the cube files of UNOCCUPIED ORBITALS
1630 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff, &
1631 eigenvalues=mo_eigenvalues, homo=homo, nmo=nmo)
1632 IF (write_cube) THEN
1633 ifirst = homo + 1
1634 IF (nlumo == -1) THEN
1635 ilast = nmo
1636 ELSE
1637 ilast = ifirst + nlumo - 1
1638 ilast = min(nmo, ilast)
1639 END IF
1640 DO ivector = ifirst, ilast
1641 CALL calculate_wavefunction(mo_coeff, ivector, wf_r, wf_g, atomic_kind_set, &
1642 qs_kind_set, cell, dft_control, particle_set, pw_env)
1643 WRITE (filename, '(a4,I5.5,a1,I1.1)') "WFN_", ivector, "_", ispin
1644 mpi_io = .true.
1645 unit_nr = cp_print_key_unit_nr(logger, cube_section, '', extension=".cube", &
1646 middle_name=trim(filename), file_position=my_pos_cube, &
1647 log_filename=.false., mpi_io=mpi_io)
1648 WRITE (title, *) "WAVEFUNCTION ", ivector, " spin ", ispin, " i.e. LUMO + ", ivector - ifirst
1649 CALL cp_pw_to_cube(wf_r, unit_nr, title, particles=particles, &
1650 stride=section_get_ivals(cube_section, "STRIDE"), mpi_io=mpi_io)
1651 CALL cp_print_key_finished_output(unit_nr, logger, cube_section, '', mpi_io=mpi_io)
1652 END DO
1653 END IF
1654 END DO
1655 END IF
1656
1657 CALL auxbas_pw_pool%give_back_pw(wf_g)
1658 CALL auxbas_pw_pool%give_back_pw(wf_r)
1659 IF (ASSOCIATED(list_index)) DEALLOCATE (list_index)
1660
1661 END SUBROUTINE print_mo_cubes
1662
1663! **************************************************************************************************
1664
1665END MODULE qs_scf_post_tb
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
various utilities that regard array of different kinds: output, allocation,... maybe it is not a good...
methods related to the blacs parallel environment
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
DBCSR operations in CP2K.
subroutine, public copy_dbcsr_to_fm(matrix, fm)
Copy a DBCSR matrix to a BLACS matrix.
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 cholesky decomposition related routines
subroutine, public cp_fm_cholesky_restore(fm_matrix, neig, fm_matrixb, fm_matrixout, op, pos, transa)
apply Cholesky decomposition op can be "SOLVE" (out = U^-1 * in) or "MULTIPLY" (out = U * in) pos can...
subroutine, public cp_fm_cholesky_decompose(matrix, n, info_out)
used to replace a symmetric positive def. matrix M with its cholesky decomposition U: M = U^T * U,...
subroutine, public cp_fm_cholesky_reduce(matrix, matrixb, itype)
reduce a matrix pencil A,B to normal form B has to be cholesky decomposed with cp_fm_cholesky_decompo...
used for collecting some of the diagonalization schemes available for cp_fm_type. cp_fm_power also mo...
Definition cp_fm_diag.F:17
subroutine, public choose_eigv_solver(matrix, eigenvectors, eigenvalues, info)
Choose the Eigensolver depending on which library is available ELPA seems to be unstable for small sy...
Definition cp_fm_diag.F:234
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_to_fm_submat(msource, mtarget, nrow, ncol, s_firstrow, s_firstcol, t_firstrow, t_firstcol)
copy just a part ot the matrix
subroutine, public cp_fm_init_random(matrix, ncol, start_col)
fills a matrix with random numbers
subroutine, public cp_fm_create(matrix, matrix_struct, name, use_sp)
creates a new full matrix with the given structure
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...
A wrapper around pw_to_cube() which accepts particle_list_type.
subroutine, public cp_pw_to_cube(pw, unit_nr, title, particles, stride, zero_tails, silent, mpi_io)
...
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
collects all constants needed in input so that they can be used without circular dependencies
integer, parameter, public ot_precond_full_all
objects that represent the structure of input sections and the data contained in an input section
real(kind=dp) function, public section_get_rval(section_vals, keyword_name)
...
integer function, dimension(:), pointer, public section_get_ivals(section_vals, keyword_name)
...
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
logical function, public section_get_lval(section_vals, keyword_name)
...
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
integer, parameter, public default_path_length
Definition kinds.F:58
An array-based list which grows on demand. When the internal array is full, a new array of twice the ...
Definition list.F:24
Machine interface based on Fortran 2003 and POSIX.
Definition machine.F:17
subroutine, public m_flush(lunit)
flushes units if the &GLOBAL flag is set accordingly
Definition machine.F:131
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
Utility routines for the memory handling.
Interface to the message passing library MPI.
Functions handling the MOLDEN format. Split from mode_selective.
subroutine, public write_mos_molden(mos, qs_kind_set, particle_set, print_section)
Write out the MOs in molden format for visualisation.
Calculates the moment integrals <a|r^m|b>
subroutine, public get_reference_point(rpoint, drpoint, qs_env, fist_env, reference, ref_point, ifirst, ilast)
...
compute mulliken charges we (currently) define them as c_i = 1/2 [ (PS)_{ii} + (SP)_{ii} ]
Definition mulliken.F:13
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
Provide various population analyses and print the requested output information.
subroutine, public lowdin_population_analysis(qs_env, output_unit, print_level)
Perform a Lowdin population analysis based on a symmetric orthogonalisation of the density matrix usi...
types of preconditioners
computes preconditioners, and implements methods to apply them currently used in qs_ot
methods of pw_env that have dependence on qs_env
subroutine, public pw_env_rebuild(pw_env, qs_env, external_para_env)
rebuilds the pw_env data (necessary if cell or cutoffs change)
subroutine, public pw_env_create(pw_env)
creates a pw_env, if qs_env is given calls pw_env_rebuild
container for various plainwaves related things
subroutine, public pw_env_release(pw_env, para_env)
releases the given pw_env (see doc/ReferenceCounting.html)
subroutine, public pw_env_get(pw_env, pw_pools, cube_info, gridlevel_info, auxbas_pw_pool, auxbas_grid, auxbas_rs_desc, auxbas_rs_grid, rs_descs, rs_grids, xc_pw_pool, vdw_pw_pool, poisson_env, interp_section)
returns the various attributes of the pw env
subroutine, public pw_derive(pw, n)
Calculate the derivative of a plane wave vector.
functions related to the poisson solver on regular grids
subroutine, public pw_green_create(green, poisson_params, cell_hmat, pw_pool, mt_super_ref_pw_grid, dct_pw_grid)
Allocates and sets up the green functions for the fft based poisson solvers.
subroutine, public pw_green_release(gftype, pw_pool)
destroys the type (deallocates data)
integer, parameter, public do_ewald_none
integer, parameter, public pw_poisson_analytic
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
Calculate the plane wave density by collocating the primitive Gaussian functions (pgf).
subroutine, public calculate_rho_elec(matrix_p, matrix_p_kp, rho, rho_gspace, total_rho, ks_env, soft_valid, compute_tau, compute_grad, basis_type, der_type, idir, task_list_external, pw_env_external)
computes the density corresponding to a given density matrix on the grid
subroutine, public calculate_wavefunction(mo_vectors, ivector, rho, rho_gspace, atomic_kind_set, qs_kind_set, cell, dft_control, particle_set, pw_env, basis_type)
maps a given wavefunction on the grid
Definition of the DFTB parameter types.
Working with the DFTB parameter types.
subroutine, public get_dftb_atom_param(dftb_parameter, name, typ, defined, z, zeff, natorb, lmax, skself, occupation, eta, energy, cutoff, xi, di, rcdisp, dudq)
...
Calculation and writing of density of states.
Definition qs_dos.F:14
subroutine, public calculate_dos(mos, dft_section)
Compute and write density of states.
Definition qs_dos.F:59
subroutine, public calculate_dos_kp(qs_env, dft_section)
Compute and write density of states (kpoints)
Definition qs_dos.F:206
Does all kind of post scf calculations for GPW/GAPW.
subroutine, public qs_elf_calc(qs_env, elf_r, rho_cutoff)
...
Does all kind of post scf calculations for GPW/GAPW.
subroutine, public energy_windows(qs_env)
...
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.
subroutine, public set_ks_env(ks_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, complex_ks, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, kinetic, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_ks_im_kp, vppl, rho_core, rho_nlcc, rho_nlcc_g, vee, neighbor_list_id, kpoints, sab_orb, sab_all, sac_ae, sac_ppl, sac_lri, sap_ppnl, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_vdw, sab_scp, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, task_list, task_list_soft, subsys, dft_control, dbcsr_dist, distribution_2d, pw_env, para_env, blacs_env)
...
subroutine, public get_ks_env(ks_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, complex_ks, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, kinetic, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_ks_im_kp, rho, rho_xc, vppl, rho_core, rho_nlcc, rho_nlcc_g, vee, neighbor_list_id, sab_orb, sab_all, sac_ae, sac_ppl, sac_lri, sap_ppnl, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_vdw, sab_scp, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, task_list, task_list_soft, kpoints, do_kpoints, atomic_kind_set, qs_kind_set, cell, cell_ref, use_ref_cell, particle_set, energy, force, local_particles, local_molecules, molecule_kind_set, molecule_set, subsys, cp_subsys, virial, results, atprop, nkind, natom, dft_control, dbcsr_dist, distribution_2d, pw_env, para_env, blacs_env, nelectron_total, nelectron_spin)
...
collects routines that perform operations directly related to MOs
subroutine, public make_mo_eig(mos, nspins, ks_rmpv, scf_control, mo_derivs, admm_env, hairy_probes, probe)
Calculate KS eigenvalues starting from OF MOS.
Set occupation of molecular orbitals.
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)
Get the components of a MO set data structure.
an eigen-space solver for the generalised symmetric eigenvalue problem for sparse matrices,...
subroutine, public ot_eigensolver(matrix_h, matrix_s, matrix_orthogonal_space_fm, matrix_c_fm, preconditioner, eps_gradient, iter_max, size_ortho_space, silent, ot_settings)
...
Calculation and writing of projected density of states The DOS is computed per angular momentum and p...
Definition qs_pdos.F:15
subroutine, public calculate_projected_dos(mo_set, atomic_kind_set, qs_kind_set, particle_set, qs_env, dft_section, ispin, xas_mittle, external_matrix_shalf)
Compute and write projected density of states.
Definition qs_pdos.F:139
methods of the rho structure (defined in qs_rho_types)
subroutine, public qs_rho_rebuild(rho, qs_env, rebuild_ao, rebuild_grids, admm, pw_env_external)
rebuilds rho (if necessary allocating and initializing it)
superstucture that hold various representations of the density and keeps track of which ones are vali...
subroutine, public qs_rho_set(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)
...
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...
Functions to print the KS and S matrix in the CSR format to file.
subroutine, public write_s_matrix_csr(qs_env, input)
writing the overlap matrix in csr format into a file
subroutine, public write_ks_matrix_csr(qs_env, input)
writing the KS matrix in csr format into a file
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 DFTB.
subroutine, public scf_post_calculation_tb(qs_env, tb_type, no_mos)
collects possible post - scf calculations and prints info / computes properties.
subroutine, public make_lumo_tb(qs_env, scf_env, unoccupied_orbs, unoccupied_evals, nlumo, nlumos)
Gets the lumos, and eigenvalues for the lumos.
module that contains the definitions of the scf types
integer, parameter, public ot_method_nr
Does all kind of post scf calculations for GPW/GAPW.
subroutine, public wfn_mix(mos, particle_set, dft_section, qs_kind_set, para_env, output_unit, unoccupied_orbs, scf_env, matrix_s, marked_states, for_rtp)
writes a new 'mixed' set of mos to restart file, without touching the current MOs
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)
...
parameters that control an scf iteration
Calculation of STM image as post processing of an electronic structure calculation,...
Definition stm_images.F:15
subroutine, public th_stm_image(qs_env, stm_section, particles, unoccupied_orbs, unoccupied_evals)
Driver for the calculation of STM image, as post processing of a ground-state electronic structure ca...
Definition stm_images.F:90
generate the tasks lists used by collocate and integrate routines
subroutine, public generate_qs_task_list(ks_env, task_list, reorder_rs_grid_ranks, skip_load_balance_distributed, soft_valid, basis_type, pw_env_external, sab_orb_external)
...
types for task lists
subroutine, public allocate_task_list(task_list)
allocates and initialised the components of the task_list_type
Calculation of charge response in xTB (EEQ only) Reference: Stefan Grimme, Christoph Bannwarth,...
Definition xtb_qresp.F:15
subroutine, public build_xtb_qresp(qs_env, qresp)
...
Definition xtb_qresp.F:83
Definition of the xTB parameter types.
Definition xtb_types.F:20
subroutine, public get_xtb_atom_param(xtb_parameter, symbol, aname, typ, defined, z, zeff, natorb, lmax, nao, lao, rcut, rcov, kx, eta, xgamma, alpha, zneff, nshell, nval, lval, kpoly, kappa, hen, zeta, xi, kappa0, alpg, occupation, electronegativity, chmax, en, kqat2, kcn, kq)
...
Definition xtb_types.F:199
Provides all information about an atomic kind.
Type defining parameters related to the simulation cell.
Definition cell_types.F:55
represent a pointer to a 1d array
represent a blacs multidimensional parallel environment (for the mpi corrispective see cp_paratypes/m...
keeps the information about the structure of a full matrix
represent a full matrix
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
contained for different pw related things
contains all the informations needed by the fft based poisson solvers
parameters for the poisson solver independet of input_section
to create arrays of pools
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
Provides all information about a quickstep kind.
calculation environment to calculate the ks matrix, holds all the needed vars. assumes that the core ...
keeps the density in various representations, keeping track of which ones are valid.