(git:4cf809f)
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-2026 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,&
108 USE qs_elf_methods, ONLY: qs_elf_calc
112 USE qs_kind_types, ONLY: get_qs_kind,&
114 USE qs_ks_types, ONLY: get_ks_env,&
120 USE qs_mo_types, ONLY: get_mo_set,&
126 USE qs_rho_types, ONLY: qs_rho_get,&
127 qs_rho_set,&
134 USE qs_scf_types, ONLY: ot_method_nr,&
136 USE qs_scf_wfn_mix, ONLY: wfn_mix
137 USE qs_subsys_types, ONLY: qs_subsys_get,&
140 USE stm_images, ONLY: th_stm_image
144 USE xtb_qresp, ONLY: build_xtb_qresp
145 USE xtb_types, ONLY: get_xtb_atom_param,&
147#include "./base/base_uses.f90"
148
149 IMPLICIT NONE
150 PRIVATE
151
152 ! Global parameters
153 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'qs_scf_post_tb'
155
156! **************************************************************************************************
157
158CONTAINS
159
160! **************************************************************************************************
161!> \brief collects possible post - scf calculations and prints info / computes properties.
162!> \param qs_env ...
163!> \param tb_type ...
164!> \param no_mos ...
165!> \par History
166!> 03.2013 copy of scf_post_gpw
167!> \author JHU
168!> \note
169! **************************************************************************************************
170 SUBROUTINE scf_post_calculation_tb(qs_env, tb_type, no_mos)
171
172 TYPE(qs_environment_type), POINTER :: qs_env
173 CHARACTER(LEN=*) :: tb_type
174 LOGICAL, INTENT(IN) :: no_mos
175
176 CHARACTER(len=*), PARAMETER :: routinen = 'scf_post_calculation_tb'
177
178 CHARACTER(LEN=6) :: ana
179 CHARACTER(LEN=default_string_length) :: aname
180 INTEGER :: after, gfn_type, handle, homo, iat, iatom, ikind, img, ispin, iw, nat, natom, &
181 nkind, nlumo_stm, nlumos, nspins, print_level, unit_nr
182 LOGICAL :: do_cube, do_dos, do_kpoints, do_pdos, do_pdos_raw, do_projected_dos, explicit, &
183 gfn0, has_homo, omit_headers, print_it, rebuild, vdip
184 REAL(kind=dp) :: zeff
185 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: mcharge, zcharge
186 REAL(kind=dp), DIMENSION(2, 2) :: homo_lumo
187 REAL(kind=dp), DIMENSION(:), POINTER :: echarge, mo_eigenvalues
188 REAL(kind=dp), DIMENSION(:, :), POINTER :: charges
189 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
190 TYPE(cell_type), POINTER :: cell
191 TYPE(cp_1d_r_p_type), DIMENSION(:), POINTER :: unoccupied_evals_stm
192 TYPE(cp_fm_type), DIMENSION(:), POINTER :: unoccupied_orbs_stm
193 TYPE(cp_fm_type), POINTER :: mo_coeff
194 TYPE(cp_logger_type), POINTER :: logger
195 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: ks_rmpv, mo_derivs
196 TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: matrix_ks, matrix_p, matrix_s
197 TYPE(dbcsr_type), POINTER :: mo_coeff_deriv
198 TYPE(dft_control_type), POINTER :: dft_control
199 TYPE(mo_set_type), DIMENSION(:), POINTER :: mos
200 TYPE(mp_para_env_type), POINTER :: para_env
201 TYPE(particle_list_type), POINTER :: particles
202 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
203 TYPE(qs_dftb_atom_type), POINTER :: dftb_kind
204 TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
205 TYPE(qs_rho_type), POINTER :: rho
206 TYPE(qs_scf_env_type), POINTER :: scf_env
207 TYPE(qs_subsys_type), POINTER :: subsys
208 TYPE(scf_control_type), POINTER :: scf_control
209 TYPE(section_vals_type), POINTER :: dft_section, moments_section, print_key, &
210 print_section, sprint_section, &
211 wfn_mix_section
212 TYPE(xtb_atom_type), POINTER :: xtb_kind
213
214 CALL timeset(routinen, handle)
215
216 logger => cp_get_default_logger()
217
218 gfn0 = .false.
219 vdip = .false.
220 CALL get_qs_env(qs_env, dft_control=dft_control)
221 SELECT CASE (trim(tb_type))
222 CASE ("DFTB")
223 CASE ("xTB")
224 gfn_type = dft_control%qs_control%xtb_control%gfn_type
225 gfn0 = (gfn_type == 0)
226 vdip = dft_control%qs_control%xtb_control%var_dipole
227 CASE DEFAULT
228 cpabort("unknown TB type")
229 END SELECT
230
231 cpassert(ASSOCIATED(qs_env))
232 NULLIFY (rho, para_env, matrix_s, matrix_p)
233 CALL get_qs_env(qs_env, scf_env=scf_env, atomic_kind_set=atomic_kind_set, qs_kind_set=qs_kind_set, &
234 rho=rho, natom=natom, para_env=para_env, &
235 particle_set=particle_set, do_kpoints=do_kpoints, matrix_s_kp=matrix_s)
236 nspins = dft_control%nspins
237 CALL qs_rho_get(rho, rho_ao_kp=matrix_p)
238 ! Mulliken charges
239 ALLOCATE (charges(natom, nspins), mcharge(natom))
240 !
241 CALL mulliken_charges(matrix_p, matrix_s, para_env, charges)
242 !
243 ALLOCATE (zcharge(natom))
244 nkind = SIZE(atomic_kind_set)
245 DO ikind = 1, nkind
246 CALL get_atomic_kind(atomic_kind_set(ikind), natom=nat)
247 SELECT CASE (trim(tb_type))
248 CASE ("DFTB")
249 CALL get_qs_kind(qs_kind_set(ikind), dftb_parameter=dftb_kind)
250 CALL get_dftb_atom_param(dftb_kind, zeff=zeff)
251 CASE ("xTB")
252 CALL get_qs_kind(qs_kind_set(ikind), xtb_parameter=xtb_kind)
253 CALL get_xtb_atom_param(xtb_kind, zeff=zeff)
254 CASE DEFAULT
255 cpabort("unknown TB type")
256 END SELECT
257 DO iatom = 1, nat
258 iat = atomic_kind_set(ikind)%atom_list(iatom)
259 mcharge(iat) = zeff - sum(charges(iat, 1:nspins))
260 zcharge(iat) = zeff
261 END DO
262 END DO
263
264 dft_section => section_vals_get_subs_vals(qs_env%input, "DFT")
265 print_section => section_vals_get_subs_vals(dft_section, "PRINT")
266
267 ! Mulliken
268 print_key => section_vals_get_subs_vals(print_section, "MULLIKEN")
269 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
270 unit_nr = cp_print_key_unit_nr(logger, print_section, "MULLIKEN", &
271 extension=".mulliken", log_filename=.false.)
272 IF (unit_nr > 0) THEN
273 WRITE (unit=unit_nr, fmt="(/,/,T2,A)") "MULLIKEN POPULATION ANALYSIS"
274 IF (nspins == 1) THEN
275 WRITE (unit=unit_nr, fmt="(/,T2,A,T70,A)") &
276 " # Atom Element Kind Atomic population", " Net charge"
277 DO ikind = 1, nkind
278 CALL get_atomic_kind(atomic_kind_set(ikind), natom=nat)
279 aname = ""
280 SELECT CASE (tb_type)
281 CASE ("DFTB")
282 CALL get_qs_kind(qs_kind_set(ikind), dftb_parameter=dftb_kind)
283 CALL get_dftb_atom_param(dftb_kind, name=aname)
284 CASE ("xTB")
285 CALL get_qs_kind(qs_kind_set(ikind), xtb_parameter=xtb_kind)
286 CALL get_xtb_atom_param(xtb_kind, symbol=aname)
287 CASE DEFAULT
288 cpabort("unknown TB type")
289 END SELECT
290 ana = adjustr(trim(adjustl(aname)))
291 DO iatom = 1, nat
292 iat = atomic_kind_set(ikind)%atom_list(iatom)
293 WRITE (unit=unit_nr, &
294 fmt="(T2,I7,5X,A6,I6,T39,F12.6,T69,F12.6)") &
295 iat, adjustl(ana), ikind, charges(iat, 1), mcharge(iat)
296 END DO
297 END DO
298 WRITE (unit=unit_nr, &
299 fmt="(T2,A,T39,F12.6,T69,F12.6,/)") &
300 "# Total charge", sum(charges(:, 1)), sum(mcharge(:))
301 ELSE
302 WRITE (unit=unit_nr, fmt="(/,T2,A)") &
303 "# Atom Element Kind Atomic population (alpha,beta) Net charge Spin moment"
304 DO ikind = 1, nkind
305 CALL get_atomic_kind(atomic_kind_set(ikind), natom=nat)
306 aname = ""
307 SELECT CASE (tb_type)
308 CASE ("DFTB")
309 CALL get_qs_kind(qs_kind_set(ikind), dftb_parameter=dftb_kind)
310 CALL get_dftb_atom_param(dftb_kind, name=aname)
311 CASE ("xTB")
312 CALL get_qs_kind(qs_kind_set(ikind), xtb_parameter=xtb_kind)
313 CALL get_xtb_atom_param(xtb_kind, symbol=aname)
314 CASE DEFAULT
315 cpabort("unknown TB type")
316 END SELECT
317 ana = adjustr(trim(adjustl(aname)))
318 DO iatom = 1, nat
319 iat = atomic_kind_set(ikind)%atom_list(iatom)
320 WRITE (unit=unit_nr, &
321 fmt="(T2,I6,3X,A6,I6,T29,4(1X,F12.6))") &
322 iat, adjustl(ana), ikind, charges(iat, 1:2), mcharge(iat), &
323 charges(iat, 1) - charges(iat, 2)
324 END DO
325 END DO
326 WRITE (unit=unit_nr, &
327 fmt="(T2,A,T29,4(1X,F12.6),/)") &
328 "# Total charge and spin", sum(charges(:, 1)), sum(charges(:, 2)), sum(mcharge(:))
329 END IF
330 CALL m_flush(unit_nr)
331 END IF
332 CALL cp_print_key_finished_output(unit_nr, logger, print_key)
333 END IF
334
335 ! Compute the Lowdin charges
336 print_key => section_vals_get_subs_vals(print_section, "LOWDIN")
337 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
338 SELECT CASE (tb_type)
339 CASE ("DFTB")
340 cpwarn("Lowdin population analysis not implemented for DFTB method.")
341 CASE ("xTB")
342 unit_nr = cp_print_key_unit_nr(logger, print_section, "LOWDIN", extension=".lowdin", &
343 log_filename=.false.)
344 print_level = 1
345 CALL section_vals_val_get(print_key, "PRINT_GOP", l_val=print_it)
346 IF (print_it) print_level = 2
347 CALL section_vals_val_get(print_key, "PRINT_ALL", l_val=print_it)
348 IF (print_it) print_level = 3
349 IF (do_kpoints) THEN
350 cpwarn("Lowdin charges not implemented for k-point calculations!")
351 ELSE
352 CALL lowdin_population_analysis(qs_env, unit_nr, print_level)
353 END IF
354 CALL cp_print_key_finished_output(unit_nr, logger, print_section, "LOWDIN")
355 CASE DEFAULT
356 cpabort("unknown TB type")
357 END SELECT
358 END IF
359
360 ! EEQ Charges
361 print_key => section_vals_get_subs_vals(print_section, "EEQ_CHARGES")
362 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
363 unit_nr = cp_print_key_unit_nr(logger, print_section, "EEQ_CHARGES", &
364 extension=".eeq", log_filename=.false.)
365 CALL eeq_print(qs_env, unit_nr, print_level, ext=gfn0)
366 CALL cp_print_key_finished_output(unit_nr, logger, print_key)
367 END IF
368
369 ! Hirshfeld
370 print_key => section_vals_get_subs_vals(print_section, "HIRSHFELD")
371 CALL section_vals_get(print_key, explicit=explicit)
372 IF (explicit) THEN
373 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
374 cpwarn("Hirshfeld charges not available for TB methods.")
375 END IF
376 END IF
377
378 ! MAO
379 print_key => section_vals_get_subs_vals(print_section, "MAO_ANALYSIS")
380 CALL section_vals_get(print_key, explicit=explicit)
381 IF (explicit) THEN
382 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
383 cpwarn("MAO analysis not available for TB methods.")
384 END IF
385 END IF
386
387 ! ED
388 print_key => section_vals_get_subs_vals(print_section, "ENERGY_DECOMPOSITION_ANALYSIS")
389 CALL section_vals_get(print_key, explicit=explicit)
390 IF (explicit) THEN
391 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
392 cpwarn("ED analysis not available for TB methods.")
393 END IF
394 END IF
395
396 ! Dipole Moments
397 print_key => section_vals_get_subs_vals(print_section, "MOMENTS")
398 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
399 unit_nr = cp_print_key_unit_nr(logger, print_section, "MOMENTS", &
400 extension=".data", middle_name="tb_dipole", log_filename=.false.)
401 moments_section => section_vals_get_subs_vals(print_section, "MOMENTS")
402 IF (gfn0) THEN
403 NULLIFY (echarge)
404 CALL get_qs_env(qs_env, eeq=echarge)
405 cpassert(ASSOCIATED(echarge))
406 IF (vdip) THEN
407 CALL build_xtb_qresp(qs_env, mcharge)
408 mcharge(1:natom) = echarge(1:natom) - mcharge(1:natom)
409 END IF
410 CALL tb_dipole(qs_env, moments_section, unit_nr, mcharge)
411 ELSE
412 CALL tb_dipole(qs_env, moments_section, unit_nr, mcharge)
413 END IF
414 CALL cp_print_key_finished_output(unit_nr, logger, print_key)
415 END IF
416
417 DEALLOCATE (charges, mcharge)
418
419 ! MO
420 IF (.NOT. no_mos) THEN
421 print_key => section_vals_get_subs_vals(print_section, "MO")
422 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
423 CALL qs_scf_write_mos(qs_env, scf_env, final_mos=.true.)
424 IF (.NOT. do_kpoints) THEN
425 SELECT CASE (tb_type)
426 CASE ("DFTB")
427 CASE ("xTB")
428 sprint_section => section_vals_get_subs_vals(dft_section, "PRINT%MO_MOLDEN")
429 CALL get_qs_env(qs_env, mos=mos, cell=cell)
430 CALL write_mos_molden(mos, qs_kind_set, particle_set, sprint_section, cell=cell, &
431 qs_env=qs_env, calc_energies=.true.)
432 CASE DEFAULT
433 cpabort("Unknown TB type")
434 END SELECT
435 END IF
436 END IF
437 END IF
438
439 ! Wavefunction mixing
440 IF (.NOT. no_mos) THEN
441 wfn_mix_section => section_vals_get_subs_vals(dft_section, "PRINT%WFN_MIX")
442 CALL section_vals_get(wfn_mix_section, explicit=explicit)
443 IF (explicit .AND. .NOT. qs_env%run_rtp) CALL wfn_mix_tb(qs_env, dft_section, scf_env)
444 END IF
445
446 IF (.NOT. no_mos) THEN
447 print_key => section_vals_get_subs_vals(print_section, "DOS")
448 do_dos = btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)
449 CALL get_dos_pdos_flags(print_key, do_dos, do_projected_dos, do_pdos, do_pdos_raw)
450 IF (do_dos) THEN
451 IF (do_kpoints) THEN
452 CALL calculate_dos_kp(qs_env, dft_section)
453 ELSE
454 CALL get_qs_env(qs_env, mos=mos)
455 CALL calculate_dos(mos, dft_section, smearing_enabled=dft_control%smear)
456 END IF
457 END IF
458
459 ! Projected density-of-states outputs
460 IF (do_projected_dos) THEN
461 IF (do_kpoints) THEN
462 CALL calculate_projected_dos_kp(qs_env, dft_section, pdos_print_key="PRINT%DOS", &
463 write_pdos=do_pdos, write_pdos_raw=do_pdos_raw)
464 ELSE
465 CALL get_qs_env(qs_env, mos=mos, matrix_ks=ks_rmpv)
466 DO ispin = 1, dft_control%nspins
467 IF (scf_env%method == ot_method_nr) THEN
468 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff, &
469 eigenvalues=mo_eigenvalues)
470 IF (ASSOCIATED(qs_env%mo_derivs)) THEN
471 mo_coeff_deriv => qs_env%mo_derivs(ispin)%matrix
472 ELSE
473 mo_coeff_deriv => null()
474 END IF
475 CALL calculate_subspace_eigenvalues(mo_coeff, ks_rmpv(ispin)%matrix, mo_eigenvalues, &
476 do_rotation=.true., &
477 co_rotate_dbcsr=mo_coeff_deriv)
478 CALL set_mo_occupation(mo_set=mos(ispin))
479 END IF
480 IF (dft_control%nspins == 2) THEN
481 CALL calculate_projected_dos(mos(ispin), atomic_kind_set, &
482 qs_kind_set, particle_set, qs_env, dft_section, ispin=ispin, &
483 pdos_print_key="PRINT%DOS", write_pdos=do_pdos, write_pdos_raw=do_pdos_raw)
484 ELSE
485 CALL calculate_projected_dos(mos(ispin), atomic_kind_set, &
486 qs_kind_set, particle_set, qs_env, dft_section, &
487 pdos_print_key="PRINT%DOS", write_pdos=do_pdos, write_pdos_raw=do_pdos_raw)
488 END IF
489 END DO
490 END IF
491 END IF
492 END IF
493
494 ! can we do CUBE files?
495 SELECT CASE (tb_type)
496 CASE ("DFTB")
497 do_cube = .false.
498 rebuild = .false.
499 CASE ("xTB")
500 do_cube = .true.
501 rebuild = .true.
502 CASE DEFAULT
503 cpabort("unknown TB type")
504 END SELECT
505
506 ! Energy Windows for LS code
507 print_key => section_vals_get_subs_vals(print_section, "ENERGY_WINDOWS")
508 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
509 IF (do_cube) THEN
510 IF (do_kpoints) THEN
511 cpwarn("Energy Windows not implemented for k-points.")
512 ELSE
513 IF (rebuild) THEN
514 CALL rebuild_pw_env(qs_env)
515 rebuild = .false.
516 END IF
517 CALL energy_windows(qs_env)
518 END IF
519 ELSE
520 cpwarn("Energy Windows not implemented for TB methods.")
521 END IF
522 END IF
523
524 ! DENSITY CUBE FILE
525 print_key => section_vals_get_subs_vals(print_section, "E_DENSITY_CUBE")
526 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
527 IF (do_cube) THEN
528 IF (rebuild) THEN
529 CALL rebuild_pw_env(qs_env)
530 rebuild = .false.
531 END IF
532 CALL print_e_density(qs_env, zcharge, print_key)
533 ELSE
534 cpwarn("Electronic density cube file not implemented for TB methods.")
535 END IF
536 END IF
537
538 ! TOTAL DENSITY CUBE FILE
539 print_key => section_vals_get_subs_vals(print_section, "TOT_DENSITY_CUBE")
540 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
541 IF (do_cube) THEN
542 IF (rebuild) THEN
543 CALL rebuild_pw_env(qs_env)
544 rebuild = .false.
545 END IF
546 CALL print_density_cubes(qs_env, zcharge, print_key, total_density=.true.)
547 ELSE
548 cpwarn("Total density cube file not implemented for TB methods.")
549 END IF
550 END IF
551
552 ! V_Hartree CUBE FILE
553 print_key => section_vals_get_subs_vals(print_section, "V_HARTREE_CUBE")
554 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
555 IF (do_cube) THEN
556 IF (rebuild) THEN
557 CALL rebuild_pw_env(qs_env)
558 rebuild = .false.
559 END IF
560 CALL print_density_cubes(qs_env, zcharge, print_key, v_hartree=.true.)
561 ELSE
562 cpwarn("Hartree potential cube file not implemented for TB methods.")
563 END IF
564 END IF
565
566 ! EFIELD CUBE FILE
567 print_key => section_vals_get_subs_vals(print_section, "EFIELD_CUBE")
568 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
569 IF (do_cube) THEN
570 IF (rebuild) THEN
571 CALL rebuild_pw_env(qs_env)
572 rebuild = .false.
573 END IF
574 CALL print_density_cubes(qs_env, zcharge, print_key, efield=.true.)
575 ELSE
576 cpwarn("Efield cube file not implemented for TB methods.")
577 END IF
578 END IF
579
580 ! ELF
581 print_key => section_vals_get_subs_vals(print_section, "ELF_CUBE")
582 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
583 IF (do_cube) THEN
584 IF (rebuild) THEN
585 CALL rebuild_pw_env(qs_env)
586 rebuild = .false.
587 END IF
588 CALL print_elf(qs_env, zcharge, print_key)
589 ELSE
590 cpwarn("ELF not implemented for TB methods.")
591 END IF
592 END IF
593
594 ! MO CUBES
595 IF (.NOT. no_mos) THEN
596 print_key => section_vals_get_subs_vals(print_section, "MO_CUBES")
597 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
598 IF (do_cube) THEN
599 IF (rebuild) THEN
600 CALL rebuild_pw_env(qs_env)
601 rebuild = .false.
602 END IF
603 CALL print_mo_cubes(qs_env, zcharge, print_key)
604 ELSE
605 cpwarn("Printing of MO cube files not implemented for TB methods.")
606 END IF
607 END IF
608 END IF
609
610 ! STM
611 IF (.NOT. no_mos) THEN
612 print_key => section_vals_get_subs_vals(print_section, "STM")
613 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
614 IF (do_cube) THEN
615 IF (rebuild) THEN
616 CALL rebuild_pw_env(qs_env)
617 rebuild = .false.
618 END IF
619 IF (do_kpoints) THEN
620 cpwarn("STM not implemented for k-point calculations!")
621 ELSE
622 nlumo_stm = section_get_ival(print_key, "NLUMO")
623 cpassert(.NOT. dft_control%restricted)
624 CALL get_qs_env(qs_env, mos=mos, mo_derivs=mo_derivs, &
625 scf_control=scf_control, matrix_ks=ks_rmpv)
626 CALL make_mo_eig(mos, dft_control%nspins, ks_rmpv, scf_control, mo_derivs)
627 DO ispin = 1, dft_control%nspins
628 CALL get_mo_set(mo_set=mos(ispin), eigenvalues=mo_eigenvalues, homo=homo)
629 homo_lumo(ispin, 1) = mo_eigenvalues(homo)
630 END DO
631 has_homo = .true.
632 NULLIFY (unoccupied_orbs_stm, unoccupied_evals_stm)
633 IF (nlumo_stm > 0) THEN
634 ALLOCATE (unoccupied_orbs_stm(dft_control%nspins))
635 ALLOCATE (unoccupied_evals_stm(dft_control%nspins))
636 CALL make_lumo_tb(qs_env, scf_env, unoccupied_orbs_stm, unoccupied_evals_stm, &
637 nlumo_stm, nlumos)
638 END IF
639
640 CALL get_qs_env(qs_env, subsys=subsys)
641 CALL qs_subsys_get(subsys, particles=particles)
642 CALL th_stm_image(qs_env, print_key, particles, unoccupied_orbs_stm, &
643 unoccupied_evals_stm)
644
645 IF (nlumo_stm > 0) THEN
646 DO ispin = 1, dft_control%nspins
647 DEALLOCATE (unoccupied_evals_stm(ispin)%array)
648 END DO
649 DEALLOCATE (unoccupied_evals_stm)
650 CALL cp_fm_release(unoccupied_orbs_stm)
651 END IF
652 END IF
653 END IF
654 END IF
655 END IF
656
657 ! Write the density matrix
658 CALL get_qs_env(qs_env, matrix_ks_kp=matrix_ks)
659 CALL section_vals_val_get(print_section, "AO_MATRICES%OMIT_HEADERS", l_val=omit_headers)
660 IF (btest(cp_print_key_should_output(logger%iter_info, print_section, &
661 "AO_MATRICES/DENSITY"), cp_p_file)) THEN
662 iw = cp_print_key_unit_nr(logger, print_section, "AO_MATRICES/DENSITY", &
663 extension=".Log")
664 CALL section_vals_val_get(print_section, "AO_MATRICES%NDIGITS", i_val=after)
665 after = min(max(after, 1), 16)
666 DO ispin = 1, dft_control%nspins
667 DO img = 1, SIZE(matrix_p, 2)
668 CALL cp_dbcsr_write_sparse_matrix(matrix_p(ispin, img)%matrix, 4, after, qs_env, &
669 para_env, output_unit=iw, omit_headers=omit_headers)
670 END DO
671 END DO
672 CALL cp_print_key_finished_output(iw, logger, print_section, "AO_MATRICES/DENSITY")
673 END IF
674
675 ! The xTB matrix itself
676 IF (btest(cp_print_key_should_output(logger%iter_info, print_section, &
677 "AO_MATRICES/KOHN_SHAM_MATRIX"), cp_p_file)) THEN
678 iw = cp_print_key_unit_nr(logger, print_section, "AO_MATRICES/KOHN_SHAM_MATRIX", &
679 extension=".Log")
680 CALL section_vals_val_get(print_section, "AO_MATRICES%NDIGITS", i_val=after)
681 after = min(max(after, 1), 16)
682 DO ispin = 1, dft_control%nspins
683 DO img = 1, SIZE(matrix_ks, 2)
684 CALL cp_dbcsr_write_sparse_matrix(matrix_ks(ispin, img)%matrix, 4, after, qs_env, para_env, &
685 output_unit=iw, omit_headers=omit_headers)
686 END DO
687 END DO
688 CALL cp_print_key_finished_output(iw, logger, print_section, "AO_MATRICES/KOHN_SHAM_MATRIX")
689 END IF
690
691 ! these print keys are not supported in TB
692
693 ! V_XC CUBE FILE
694 print_key => section_vals_get_subs_vals(print_section, "V_XC_CUBE")
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("XC potential cube file not available for TB methods.")
699 END IF
700 END IF
701
702 ! Electric field gradients
703 print_key => section_vals_get_subs_vals(print_section, "ELECTRIC_FIELD_GRADIENT")
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("Electric field gradient not implemented for TB methods.")
708 END IF
709 END IF
710
711 ! KINETIC ENERGY
712 print_key => section_vals_get_subs_vals(print_section, "KINETIC_ENERGY")
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("Kinetic energy not available for TB methods.")
717 END IF
718 END IF
719
720 ! Xray diffraction spectrum
721 print_key => section_vals_get_subs_vals(print_section, "XRAY_DIFFRACTION_SPECTRUM")
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("Xray diffraction spectrum not implemented for TB methods.")
726 END IF
727 END IF
728
729 ! EPR Hyperfine Coupling
730 print_key => section_vals_get_subs_vals(print_section, "HYPERFINE_COUPLING_TENSOR")
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("Hyperfine Coupling not implemented for TB methods.")
735 END IF
736 END IF
737
738 ! PLUS_U
739 print_key => section_vals_get_subs_vals(print_section, "PLUS_U")
740 CALL section_vals_get(print_key, explicit=explicit)
741 IF (explicit) THEN
742 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
743 cpwarn("DFT+U method not implemented for TB methods.")
744 END IF
745 END IF
746
747 CALL write_ks_matrix_csr(qs_env, qs_env%input)
748 CALL write_s_matrix_csr(qs_env, qs_env%input)
749 CALL write_hcore_matrix_csr(qs_env, qs_env%input)
750 CALL write_p_matrix_csr(qs_env, qs_env%input)
751
752 DEALLOCATE (zcharge)
753
754 CALL timestop(handle)
755
756 END SUBROUTINE scf_post_calculation_tb
757
758! **************************************************************************************************
759!> \brief ...
760!> \param qs_env ...
761!> \param input ...
762!> \param unit_nr ...
763!> \param charges ...
764! **************************************************************************************************
765 SUBROUTINE tb_dipole(qs_env, input, unit_nr, charges)
766
767 TYPE(qs_environment_type), POINTER :: qs_env
768 TYPE(section_vals_type), POINTER :: input
769 INTEGER, INTENT(in) :: unit_nr
770 REAL(kind=dp), DIMENSION(:), INTENT(in) :: charges
771
772 CHARACTER(LEN=default_string_length) :: description, dipole_type
773 COMPLEX(KIND=dp) :: dzeta, dzphase(3), zeta, zphase(3)
774 COMPLEX(KIND=dp), DIMENSION(3) :: dggamma, ggamma
775 INTEGER :: i, iat, ikind, j, nat, reference
776 LOGICAL :: do_berry
777 REAL(kind=dp) :: charge_tot, ci(3), dci(3), dipole(3), dipole_deriv(3), drcc(3), dria(3), &
778 dtheta, gvec(3), q, rcc(3), ria(3), theta, tmp(3), via(3)
779 REAL(kind=dp), DIMENSION(:), POINTER :: ref_point
780 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
781 TYPE(cell_type), POINTER :: cell
782 TYPE(cp_result_type), POINTER :: results
783 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
784
785 NULLIFY (atomic_kind_set, cell, results)
786 CALL get_qs_env(qs_env, atomic_kind_set=atomic_kind_set, &
787 particle_set=particle_set, cell=cell, results=results)
788
789 ! Reference point
790 reference = section_get_ival(input, keyword_name="REFERENCE")
791 NULLIFY (ref_point)
792 description = '[DIPOLE]'
793 CALL section_vals_val_get(input, "REF_POINT", r_vals=ref_point)
794 CALL section_vals_val_get(input, "PERIODIC", l_val=do_berry)
795
796 CALL get_reference_point(rcc, drcc, qs_env=qs_env, reference=reference, ref_point=ref_point)
797
798 ! Dipole deriv will be the derivative of the Dipole(dM/dt=\sum e_j v_j)
799 dipole_deriv = 0.0_dp
800 dipole = 0.0_dp
801 IF (do_berry) THEN
802 dipole_type = "periodic (Berry phase)"
803 rcc = pbc(rcc, cell)
804 charge_tot = 0._dp
805 charge_tot = sum(charges)
806 ria = twopi*matmul(cell%h_inv, rcc)
807 zphase = cmplx(cos(ria), sin(ria), dp)**charge_tot
808
809 dria = twopi*matmul(cell%h_inv, drcc)
810 dzphase = charge_tot*cmplx(-sin(ria), cos(ria), dp)**(charge_tot - 1.0_dp)*dria
811
812 ggamma = z_one
813 dggamma = z_zero
814 DO ikind = 1, SIZE(atomic_kind_set)
815 CALL get_atomic_kind(atomic_kind_set(ikind), natom=nat)
816 DO i = 1, nat
817 iat = atomic_kind_set(ikind)%atom_list(i)
818 ria = particle_set(iat)%r(:)
819 ria = pbc(ria, cell)
820 via = particle_set(iat)%v(:)
821 q = charges(iat)
822 DO j = 1, 3
823 gvec = twopi*cell%h_inv(j, :)
824 theta = sum(ria(:)*gvec(:))
825 dtheta = sum(via(:)*gvec(:))
826 zeta = cmplx(cos(theta), sin(theta), kind=dp)**(-q)
827 dzeta = -q*cmplx(-sin(theta), cos(theta), kind=dp)**(-q - 1.0_dp)*dtheta
828 dggamma(j) = dggamma(j)*zeta + ggamma(j)*dzeta
829 ggamma(j) = ggamma(j)*zeta
830 END DO
831 END DO
832 END DO
833 dggamma = dggamma*zphase + ggamma*dzphase
834 ggamma = ggamma*zphase
835 IF (all(real(ggamma, kind=dp) /= 0.0_dp)) THEN
836 tmp = aimag(ggamma)/real(ggamma, kind=dp)
837 ci = -atan(tmp)
838 dci = -(1.0_dp/(1.0_dp + tmp**2))* &
839 (aimag(dggamma)*real(ggamma, kind=dp) - aimag(ggamma)*real(dggamma, kind=dp))/(real(ggamma, kind=dp))**2
840 dipole = matmul(cell%hmat, ci)/twopi
841 dipole_deriv = matmul(cell%hmat, dci)/twopi
842 END IF
843 ELSE
844 dipole_type = "non-periodic"
845 DO i = 1, SIZE(particle_set)
846 ! no pbc(particle_set(i)%r(:),cell) so that the total dipole is the sum of the molecular dipoles
847 ria = particle_set(i)%r(:)
848 q = charges(i)
849 dipole = dipole + q*(ria - rcc)
850 dipole_deriv(:) = dipole_deriv(:) + q*(particle_set(i)%v(:) - drcc)
851 END DO
852 END IF
853 CALL cp_results_erase(results=results, description=description)
854 CALL put_results(results=results, description=description, &
855 values=dipole(1:3))
856 IF (unit_nr > 0) THEN
857 WRITE (unit_nr, '(/,T2,A,T31,A50)') &
858 'TB_DIPOLE| Dipole type', adjustr(trim(dipole_type))
859 WRITE (unit_nr, "(T2,A,T30,3(1X,F16.8))") "TB_DIPOLE| Ref. Point [Bohr]", rcc
860 WRITE (unit_nr, '(T2,A,T30,3(1X,F16.8))') &
861 'TB_DIPOLE| Moment [a.u.]', dipole(1:3)
862 WRITE (unit_nr, '(T2,A,T30,3(1X,F16.8))') &
863 'TB_DIPOLE| Moment [Debye]', dipole(1:3)*debye
864 WRITE (unit_nr, '(T2,A,T30,3(1X,F16.8))') &
865 'TB_DIPOLE| Derivative [a.u.]', dipole_deriv(1:3)
866 END IF
867
868 END SUBROUTINE tb_dipole
869
870! **************************************************************************************************
871!> \brief computes the MOs and calls the wavefunction mixing routine.
872!> \param qs_env ...
873!> \param dft_section ...
874!> \param scf_env ...
875!> \author Florian Schiffmann
876!> \note
877! **************************************************************************************************
878
879 SUBROUTINE wfn_mix_tb(qs_env, dft_section, scf_env)
880
881 TYPE(qs_environment_type), POINTER :: qs_env
882 TYPE(section_vals_type), POINTER :: dft_section
883 TYPE(qs_scf_env_type), POINTER :: scf_env
884
885 INTEGER :: ispin, nao, nmo, output_unit
886 REAL(dp), DIMENSION(:), POINTER :: mo_eigenvalues
887 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
888 TYPE(cp_fm_struct_type), POINTER :: ao_ao_fmstruct, ao_lumo_struct
889 TYPE(cp_fm_type) :: ks_tmp, mo_tmp, s_tmp, work
890 TYPE(cp_fm_type), DIMENSION(:), POINTER :: lumos
891 TYPE(cp_fm_type), POINTER :: mo_coeff
892 TYPE(cp_logger_type), POINTER :: logger
893 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_ks, matrix_s
894 TYPE(mo_set_type), DIMENSION(:), POINTER :: mos
895 TYPE(mp_para_env_type), POINTER :: para_env
896 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
897 TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
898 TYPE(section_vals_type), POINTER :: wfn_mix_section
899
900 logger => cp_get_default_logger()
901 CALL get_qs_env(qs_env=qs_env, matrix_s=matrix_s, matrix_ks=matrix_ks, &
902 particle_set=particle_set, atomic_kind_set=atomic_kind_set, &
903 qs_kind_set=qs_kind_set, mos=mos, para_env=para_env)
904
905 wfn_mix_section => section_vals_get_subs_vals(dft_section, "PRINT%WFN_MIX")
906
907 CALL get_mo_set(mos(1), mo_coeff=mo_coeff, nao=nao)
908
909 CALL cp_fm_struct_create(fmstruct=ao_ao_fmstruct, nrow_global=nao, ncol_global=nao, &
910 template_fmstruct=mo_coeff%matrix_struct)
911 CALL cp_fm_create(s_tmp, matrix_struct=ao_ao_fmstruct)
912 CALL cp_fm_create(ks_tmp, matrix_struct=ao_ao_fmstruct)
913 CALL cp_fm_create(mo_tmp, matrix_struct=ao_ao_fmstruct)
914 CALL cp_fm_create(work, matrix_struct=ao_ao_fmstruct)
915 ALLOCATE (lumos(SIZE(mos)))
916
917 CALL copy_dbcsr_to_fm(matrix_s(1)%matrix, s_tmp)
918 CALL cp_fm_cholesky_decompose(s_tmp)
919
920 DO ispin = 1, SIZE(mos)
921 CALL get_mo_set(mos(ispin), mo_coeff=mo_coeff, eigenvalues=mo_eigenvalues, nmo=nmo)
922 CALL cp_fm_struct_create(fmstruct=ao_lumo_struct, nrow_global=nao, ncol_global=nao - nmo, &
923 template_fmstruct=mo_coeff%matrix_struct)
924
925 CALL cp_fm_create(lumos(ispin), matrix_struct=ao_lumo_struct)
926 CALL copy_dbcsr_to_fm(matrix_ks(ispin)%matrix, ks_tmp)
927 CALL cp_fm_cholesky_reduce(ks_tmp, s_tmp)
928 CALL choose_eigv_solver(ks_tmp, work, mo_eigenvalues)
929 CALL cp_fm_cholesky_restore(work, nao, s_tmp, mo_tmp, "SOLVE")
930 CALL cp_fm_to_fm_submat(mo_tmp, mo_coeff, nao, nmo, 1, 1, 1, 1)
931 CALL cp_fm_to_fm_submat(mo_tmp, lumos(ispin), nao, nao - nmo, 1, nmo + 1, 1, 1)
932
933 CALL cp_fm_struct_release(ao_lumo_struct)
934 END DO
935
936 output_unit = cp_logger_get_default_io_unit(logger)
937 CALL wfn_mix(mos, particle_set, dft_section, qs_kind_set, para_env, output_unit, &
938 unoccupied_orbs=lumos, scf_env=scf_env, matrix_s=matrix_s)
939
940 CALL cp_fm_release(lumos)
941 CALL cp_fm_release(s_tmp)
942 CALL cp_fm_release(mo_tmp)
943 CALL cp_fm_release(ks_tmp)
944 CALL cp_fm_release(work)
945 CALL cp_fm_struct_release(ao_ao_fmstruct)
946
947 END SUBROUTINE wfn_mix_tb
948
949! **************************************************************************************************
950!> \brief Gets the lumos, and eigenvalues for the lumos
951!> \param qs_env ...
952!> \param scf_env ...
953!> \param unoccupied_orbs ...
954!> \param unoccupied_evals ...
955!> \param nlumo ...
956!> \param nlumos ...
957! **************************************************************************************************
958 SUBROUTINE make_lumo_tb(qs_env, scf_env, unoccupied_orbs, unoccupied_evals, nlumo, nlumos)
959
960 TYPE(qs_environment_type), POINTER :: qs_env
961 TYPE(qs_scf_env_type), POINTER :: scf_env
962 TYPE(cp_fm_type), DIMENSION(:), POINTER :: unoccupied_orbs
963 TYPE(cp_1d_r_p_type), DIMENSION(:), INTENT(INOUT) :: unoccupied_evals
964 INTEGER :: nlumo
965 INTEGER, INTENT(OUT) :: nlumos
966
967 INTEGER :: homo, iounit, ispin, n, nao, nmo
968 TYPE(cp_blacs_env_type), POINTER :: blacs_env
969 TYPE(cp_fm_struct_type), POINTER :: fm_struct_tmp
970 TYPE(cp_fm_type), POINTER :: mo_coeff
971 TYPE(cp_logger_type), POINTER :: logger
972 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: ks_rmpv, matrix_s
973 TYPE(dft_control_type), POINTER :: dft_control
974 TYPE(mo_set_type), DIMENSION(:), POINTER :: mos
975 TYPE(mp_para_env_type), POINTER :: para_env
976 TYPE(preconditioner_type), POINTER :: local_preconditioner
977 TYPE(scf_control_type), POINTER :: scf_control
978
979 NULLIFY (mos, ks_rmpv, scf_control, dft_control, para_env, blacs_env)
980 CALL get_qs_env(qs_env, &
981 mos=mos, &
982 matrix_ks=ks_rmpv, &
983 scf_control=scf_control, &
984 dft_control=dft_control, &
985 matrix_s=matrix_s, &
986 para_env=para_env, &
987 blacs_env=blacs_env)
988
989 logger => cp_get_default_logger()
990 iounit = cp_logger_get_default_io_unit(logger)
991
992 DO ispin = 1, dft_control%nspins
993 NULLIFY (unoccupied_evals(ispin)%array)
994 ! Always write eigenvalues
995 IF (iounit > 0) WRITE (iounit, *) " "
996 IF (iounit > 0) WRITE (iounit, *) " Lowest Eigenvalues of the unoccupied subspace spin ", ispin
997 IF (iounit > 0) WRITE (iounit, fmt='(1X,A)') "-----------------------------------------------------"
998 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff, homo=homo, nao=nao, nmo=nmo)
999 CALL cp_fm_get_info(mo_coeff, nrow_global=n)
1000 nlumos = max(1, min(nlumo, nao - nmo))
1001 IF (nlumo == -1) nlumos = nao - nmo
1002 ALLOCATE (unoccupied_evals(ispin)%array(nlumos))
1003 CALL cp_fm_struct_create(fm_struct_tmp, para_env=para_env, context=blacs_env, &
1004 nrow_global=n, ncol_global=nlumos)
1005 CALL cp_fm_create(unoccupied_orbs(ispin), fm_struct_tmp, name="lumos")
1006 CALL cp_fm_struct_release(fm_struct_tmp)
1007 CALL cp_fm_init_random(unoccupied_orbs(ispin), nlumos)
1008
1009 ! the full_all preconditioner makes not much sense for lumos search
1010 NULLIFY (local_preconditioner)
1011 IF (ASSOCIATED(scf_env%ot_preconditioner)) THEN
1012 local_preconditioner => scf_env%ot_preconditioner(1)%preconditioner
1013 ! this one can for sure not be right (as it has to match a given C0)
1014 IF (local_preconditioner%in_use == ot_precond_full_all) THEN
1015 NULLIFY (local_preconditioner)
1016 END IF
1017 END IF
1018
1019 CALL ot_eigensolver(matrix_h=ks_rmpv(ispin)%matrix, matrix_s=matrix_s(1)%matrix, &
1020 matrix_c_fm=unoccupied_orbs(ispin), &
1021 matrix_orthogonal_space_fm=mo_coeff, &
1022 eps_gradient=scf_control%eps_lumos, &
1023 preconditioner=local_preconditioner, &
1024 iter_max=scf_control%max_iter_lumos, &
1025 size_ortho_space=nmo)
1026
1027 CALL calculate_subspace_eigenvalues(unoccupied_orbs(ispin), ks_rmpv(ispin)%matrix, &
1028 unoccupied_evals(ispin)%array, scr=iounit, &
1029 ionode=iounit > 0)
1030
1031 END DO
1032
1033 END SUBROUTINE make_lumo_tb
1034
1035! **************************************************************************************************
1036!> \brief ...
1037!> \param qs_env ...
1038! **************************************************************************************************
1039 SUBROUTINE rebuild_pw_env(qs_env)
1040
1041 TYPE(qs_environment_type), POINTER :: qs_env
1042
1043 LOGICAL :: skip_load_balance_distributed
1044 TYPE(cell_type), POINTER :: cell
1045 TYPE(dft_control_type), POINTER :: dft_control
1046 TYPE(pw_env_type), POINTER :: new_pw_env
1047 TYPE(qs_ks_env_type), POINTER :: ks_env
1048 TYPE(qs_rho_type), POINTER :: rho
1049 TYPE(task_list_type), POINTER :: task_list
1050
1051 CALL get_qs_env(qs_env, ks_env=ks_env, dft_control=dft_control, pw_env=new_pw_env)
1052 IF (.NOT. ASSOCIATED(new_pw_env)) THEN
1053 CALL pw_env_create(new_pw_env)
1054 CALL set_ks_env(ks_env, pw_env=new_pw_env)
1055 CALL pw_env_release(new_pw_env)
1056 END IF
1057 CALL get_qs_env(qs_env, pw_env=new_pw_env, dft_control=dft_control, cell=cell)
1058
1059 new_pw_env%cell_hmat = cell%hmat
1060 CALL pw_env_rebuild(new_pw_env, qs_env=qs_env)
1061
1062 NULLIFY (task_list)
1063 CALL get_ks_env(ks_env, task_list=task_list)
1064 IF (.NOT. ASSOCIATED(task_list)) THEN
1065 CALL allocate_task_list(task_list)
1066 CALL set_ks_env(ks_env, task_list=task_list)
1067 END IF
1068 skip_load_balance_distributed = dft_control%qs_control%skip_load_balance_distributed
1069 CALL generate_qs_task_list(ks_env, task_list, basis_type="ORB", &
1070 reorder_rs_grid_ranks=.true., &
1071 skip_load_balance_distributed=skip_load_balance_distributed)
1072 CALL get_qs_env(qs_env, rho=rho)
1073 CALL qs_rho_rebuild(rho, qs_env=qs_env, rebuild_ao=.false., rebuild_grids=.true.)
1074
1075 END SUBROUTINE rebuild_pw_env
1076
1077! **************************************************************************************************
1078!> \brief ...
1079!> \param qs_env ...
1080!> \param zcharge ...
1081!> \param cube_section ...
1082! **************************************************************************************************
1083 SUBROUTINE print_e_density(qs_env, zcharge, cube_section)
1084
1085 TYPE(qs_environment_type), POINTER :: qs_env
1086 REAL(kind=dp), DIMENSION(:), INTENT(IN) :: zcharge
1087 TYPE(section_vals_type), POINTER :: cube_section
1088
1089 CHARACTER(LEN=default_path_length) :: filename, mpi_filename, my_pos_cube
1090 INTEGER :: iounit, ispin, unit_nr
1091 LOGICAL :: append_cube, mpi_io
1092 REAL(kind=dp), DIMENSION(:), POINTER :: tot_rho_r
1093 TYPE(cp_logger_type), POINTER :: logger
1094 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: rho_ao
1095 TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: rho_ao_kp
1096 TYPE(dft_control_type), POINTER :: dft_control
1097 TYPE(particle_list_type), POINTER :: particles
1098 TYPE(pw_c1d_gs_type), DIMENSION(:), POINTER :: rho_g
1099 TYPE(pw_env_type), POINTER :: pw_env
1100 TYPE(pw_pool_p_type), DIMENSION(:), POINTER :: pw_pools
1101 TYPE(pw_pool_type), POINTER :: auxbas_pw_pool
1102 TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: rho_r
1103 TYPE(qs_ks_env_type), POINTER :: ks_env
1104 TYPE(qs_rho_type), POINTER :: rho
1105 TYPE(qs_subsys_type), POINTER :: subsys
1106
1107 CALL get_qs_env(qs_env, dft_control=dft_control)
1108
1109 append_cube = section_get_lval(cube_section, "APPEND")
1110 my_pos_cube = "REWIND"
1111 IF (append_cube) my_pos_cube = "APPEND"
1112
1113 logger => cp_get_default_logger()
1114 iounit = cp_logger_get_default_io_unit(logger)
1115
1116 ! we need to construct the density on a realspace grid
1117 CALL get_qs_env(qs_env, ks_env=ks_env, rho=rho)
1118 NULLIFY (rho_r, rho_g, tot_rho_r)
1119 CALL qs_rho_get(rho, rho_ao_kp=rho_ao_kp, &
1120 rho_r=rho_r, rho_g=rho_g, tot_rho_r=tot_rho_r)
1121 DO ispin = 1, dft_control%nspins
1122 rho_ao => rho_ao_kp(ispin, :)
1123 CALL calculate_rho_elec(matrix_p_kp=rho_ao, &
1124 rho=rho_r(ispin), &
1125 rho_gspace=rho_g(ispin), &
1126 total_rho=tot_rho_r(ispin), &
1127 ks_env=ks_env)
1128 END DO
1129 CALL qs_rho_set(rho, rho_r_valid=.true., rho_g_valid=.true.)
1130
1131 CALL get_qs_env(qs_env, subsys=subsys)
1132 CALL qs_subsys_get(subsys, particles=particles)
1133
1134 IF (dft_control%nspins > 1) THEN
1135 IF (iounit > 0) THEN
1136 WRITE (unit=iounit, fmt="(/,T2,A,T51,2F15.6)") &
1137 "Integrated alpha and beta electronic density:", tot_rho_r(1:2)
1138 END IF
1139 CALL get_qs_env(qs_env=qs_env, pw_env=pw_env)
1140 CALL pw_env_get(pw_env=pw_env, auxbas_pw_pool=auxbas_pw_pool, pw_pools=pw_pools)
1141 block
1142 TYPE(pw_r3d_rs_type) :: rho_elec_rspace
1143 CALL auxbas_pw_pool%create_pw(pw=rho_elec_rspace)
1144 CALL pw_copy(rho_r(1), rho_elec_rspace)
1145 CALL pw_axpy(rho_r(2), rho_elec_rspace)
1146 filename = "ELECTRON_DENSITY"
1147 mpi_io = .true.
1148 unit_nr = cp_print_key_unit_nr(logger, cube_section, '', &
1149 extension=".cube", middle_name=trim(filename), &
1150 file_position=my_pos_cube, log_filename=.false., mpi_io=mpi_io, &
1151 fout=mpi_filename)
1152 IF (iounit > 0) THEN
1153 IF (.NOT. mpi_io) THEN
1154 INQUIRE (unit=unit_nr, name=filename)
1155 ELSE
1156 filename = mpi_filename
1157 END IF
1158 WRITE (unit=iounit, fmt="(T2,A,/,T2,A79)") &
1159 "The sum of alpha and beta density is written in cube file format to the file:", adjustr(trim(filename))
1160 END IF
1161 CALL cp_pw_to_cube(rho_elec_rspace, unit_nr, "SUM OF ALPHA AND BETA DENSITY", &
1162 particles=particles, zeff=zcharge, stride=section_get_ivals(cube_section, "STRIDE"), &
1163 mpi_io=mpi_io)
1164 CALL cp_print_key_finished_output(unit_nr, logger, cube_section, '', mpi_io=mpi_io)
1165 CALL pw_copy(rho_r(1), rho_elec_rspace)
1166 CALL pw_axpy(rho_r(2), rho_elec_rspace, alpha=-1.0_dp)
1167 filename = "SPIN_DENSITY"
1168 mpi_io = .true.
1169 unit_nr = cp_print_key_unit_nr(logger, cube_section, '', &
1170 extension=".cube", middle_name=trim(filename), &
1171 file_position=my_pos_cube, log_filename=.false., mpi_io=mpi_io, &
1172 fout=mpi_filename)
1173 IF (iounit > 0) THEN
1174 IF (.NOT. mpi_io) THEN
1175 INQUIRE (unit=unit_nr, name=filename)
1176 ELSE
1177 filename = mpi_filename
1178 END IF
1179 WRITE (unit=iounit, fmt="(T2,A,/,T2,A79)") &
1180 "The spin density is written in cube file format to the file:", adjustr(trim(filename))
1181 END IF
1182 CALL cp_pw_to_cube(rho_elec_rspace, unit_nr, "SPIN DENSITY", &
1183 particles=particles, zeff=zcharge, &
1184 stride=section_get_ivals(cube_section, "STRIDE"), mpi_io=mpi_io)
1185 CALL cp_print_key_finished_output(unit_nr, logger, cube_section, '', mpi_io=mpi_io)
1186 CALL auxbas_pw_pool%give_back_pw(rho_elec_rspace)
1187 END block
1188 ELSE
1189 IF (iounit > 0) THEN
1190 WRITE (unit=iounit, fmt="(/,T2,A,T66,F15.6)") &
1191 "Integrated electronic density:", tot_rho_r(1)
1192 END IF
1193 filename = "ELECTRON_DENSITY"
1194 mpi_io = .true.
1195 unit_nr = cp_print_key_unit_nr(logger, cube_section, '', &
1196 extension=".cube", middle_name=trim(filename), &
1197 file_position=my_pos_cube, log_filename=.false., mpi_io=mpi_io, &
1198 fout=mpi_filename)
1199 IF (iounit > 0) THEN
1200 IF (.NOT. mpi_io) THEN
1201 INQUIRE (unit=unit_nr, name=filename)
1202 ELSE
1203 filename = mpi_filename
1204 END IF
1205 WRITE (unit=iounit, fmt="(T2,A,/,T2,A79)") &
1206 "The electron density is written in cube file format to the file:", adjustr(trim(filename))
1207 END IF
1208 CALL cp_pw_to_cube(rho_r(1), unit_nr, "ELECTRON DENSITY", &
1209 particles=particles, zeff=zcharge, &
1210 stride=section_get_ivals(cube_section, "STRIDE"), mpi_io=mpi_io)
1211 CALL cp_print_key_finished_output(unit_nr, logger, cube_section, '', mpi_io=mpi_io)
1212 END IF ! nspins
1213
1214 END SUBROUTINE print_e_density
1215! **************************************************************************************************
1216!> \brief ...
1217!> \param qs_env ...
1218!> \param zcharge ...
1219!> \param cube_section ...
1220!> \param total_density ...
1221!> \param v_hartree ...
1222!> \param efield ...
1223! **************************************************************************************************
1224 SUBROUTINE print_density_cubes(qs_env, zcharge, cube_section, total_density, v_hartree, efield)
1225
1226 TYPE(qs_environment_type), POINTER :: qs_env
1227 REAL(kind=dp), DIMENSION(:), INTENT(IN) :: zcharge
1228 TYPE(section_vals_type), POINTER :: cube_section
1229 LOGICAL, INTENT(IN), OPTIONAL :: total_density, v_hartree, efield
1230
1231 CHARACTER(len=1), DIMENSION(3), PARAMETER :: cdir = ["x", "y", "z"]
1232
1233 CHARACTER(LEN=default_path_length) :: filename, mpi_filename, my_pos_cube
1234 INTEGER :: id, iounit, ispin, nd(3), unit_nr
1235 LOGICAL :: append_cube, mpi_io, my_efield, &
1236 my_total_density, my_v_hartree
1237 REAL(kind=dp) :: total_rho_core_rspace, udvol
1238 REAL(kind=dp), DIMENSION(:), POINTER :: tot_rho_r
1239 TYPE(cell_type), POINTER :: cell
1240 TYPE(cp_logger_type), POINTER :: logger
1241 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: rho_ao
1242 TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: rho_ao_kp
1243 TYPE(dft_control_type), POINTER :: dft_control
1244 TYPE(particle_list_type), POINTER :: particles
1245 TYPE(pw_c1d_gs_type) :: rho_core
1246 TYPE(pw_c1d_gs_type), DIMENSION(:), POINTER :: rho_g
1247 TYPE(pw_env_type), POINTER :: pw_env
1248 TYPE(pw_poisson_parameter_type) :: poisson_params
1249 TYPE(pw_pool_p_type), DIMENSION(:), POINTER :: pw_pools
1250 TYPE(pw_pool_type), POINTER :: auxbas_pw_pool
1251 TYPE(pw_r3d_rs_type) :: rho_tot_rspace
1252 TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: rho_r
1253 TYPE(qs_ks_env_type), POINTER :: ks_env
1254 TYPE(qs_rho_type), POINTER :: rho
1255 TYPE(qs_subsys_type), POINTER :: subsys
1256
1257 CALL get_qs_env(qs_env, cell=cell, dft_control=dft_control)
1258
1259 append_cube = section_get_lval(cube_section, "APPEND")
1260 my_pos_cube = "REWIND"
1261 IF (append_cube) my_pos_cube = "APPEND"
1262
1263 IF (PRESENT(total_density)) THEN
1264 my_total_density = total_density
1265 ELSE
1266 my_total_density = .false.
1267 END IF
1268 IF (PRESENT(v_hartree)) THEN
1269 my_v_hartree = v_hartree
1270 ELSE
1271 my_v_hartree = .false.
1272 END IF
1273 IF (PRESENT(efield)) THEN
1274 my_efield = efield
1275 ELSE
1276 my_efield = .false.
1277 END IF
1278
1279 logger => cp_get_default_logger()
1280 iounit = cp_logger_get_default_io_unit(logger)
1281
1282 ! we need to construct the density on a realspace grid
1283 CALL get_qs_env(qs_env, ks_env=ks_env, rho=rho)
1284 NULLIFY (rho_r, rho_g, tot_rho_r)
1285 CALL qs_rho_get(rho, rho_ao_kp=rho_ao_kp, &
1286 rho_r=rho_r, rho_g=rho_g, tot_rho_r=tot_rho_r)
1287 DO ispin = 1, dft_control%nspins
1288 rho_ao => rho_ao_kp(ispin, :)
1289 CALL calculate_rho_elec(matrix_p_kp=rho_ao, &
1290 rho=rho_r(ispin), &
1291 rho_gspace=rho_g(ispin), &
1292 total_rho=tot_rho_r(ispin), &
1293 ks_env=ks_env)
1294 END DO
1295 CALL qs_rho_set(rho, rho_r_valid=.true., rho_g_valid=.true.)
1296
1297 CALL get_qs_env(qs_env, subsys=subsys)
1298 CALL qs_subsys_get(subsys, particles=particles)
1299
1300 CALL get_qs_env(qs_env=qs_env, pw_env=pw_env)
1301 CALL pw_env_get(pw_env=pw_env, auxbas_pw_pool=auxbas_pw_pool, pw_pools=pw_pools)
1302 CALL auxbas_pw_pool%create_pw(pw=rho_core)
1303 CALL calculate_rho_core(rho_core, total_rho_core_rspace, qs_env)
1304
1305 IF (iounit > 0) THEN
1306 WRITE (unit=iounit, fmt="(/,T2,A,T66,F15.6)") &
1307 "Integrated electronic density:", sum(tot_rho_r(:))
1308 WRITE (unit=iounit, fmt="(T2,A,T66,F15.6)") &
1309 "Integrated core density:", total_rho_core_rspace
1310 END IF
1311
1312 CALL auxbas_pw_pool%create_pw(pw=rho_tot_rspace)
1313 CALL pw_transfer(rho_core, rho_tot_rspace)
1314 DO ispin = 1, dft_control%nspins
1315 CALL pw_axpy(rho_r(ispin), rho_tot_rspace)
1316 END DO
1317
1318 IF (my_total_density) THEN
1319 filename = "TOTAL_DENSITY"
1320 mpi_io = .true.
1321 unit_nr = cp_print_key_unit_nr(logger, cube_section, '', &
1322 extension=".cube", middle_name=trim(filename), file_position=my_pos_cube, &
1323 log_filename=.false., mpi_io=mpi_io, fout=mpi_filename)
1324 IF (iounit > 0) THEN
1325 IF (.NOT. mpi_io) THEN
1326 INQUIRE (unit=unit_nr, name=filename)
1327 ELSE
1328 filename = mpi_filename
1329 END IF
1330 WRITE (unit=iounit, fmt="(T2,A,/,T2,A79)") &
1331 "The total density is written in cube file format to the file:", adjustr(trim(filename))
1332 END IF
1333 CALL cp_pw_to_cube(rho_tot_rspace, unit_nr, "TOTAL DENSITY", &
1334 particles=particles, zeff=zcharge, &
1335 stride=section_get_ivals(cube_section, "STRIDE"), mpi_io=mpi_io)
1336 CALL cp_print_key_finished_output(unit_nr, logger, cube_section, '', mpi_io=mpi_io)
1337 END IF
1338 IF (my_v_hartree .OR. my_efield) THEN
1339 block
1340 TYPE(pw_c1d_gs_type) :: rho_tot_gspace
1341 CALL auxbas_pw_pool%create_pw(pw=rho_tot_gspace)
1342 CALL pw_transfer(rho_tot_rspace, rho_tot_gspace)
1343 poisson_params%solver = pw_poisson_analytic
1344 poisson_params%periodic = cell%perd
1345 poisson_params%ewald_type = do_ewald_none
1346 block
1347 TYPE(greens_fn_type) :: green_fft
1348 TYPE(pw_grid_type), POINTER :: pwdummy
1349 NULLIFY (pwdummy)
1350 CALL pw_green_create(green_fft, poisson_params, cell%hmat, auxbas_pw_pool, pwdummy, pwdummy)
1351 rho_tot_gspace%array(:) = rho_tot_gspace%array(:)*green_fft%influence_fn%array(:)
1352 CALL pw_green_release(green_fft, auxbas_pw_pool)
1353 END block
1354 IF (my_v_hartree) THEN
1355 block
1356 TYPE(pw_r3d_rs_type) :: vhartree
1357 CALL auxbas_pw_pool%create_pw(pw=vhartree)
1358 CALL pw_transfer(rho_tot_gspace, vhartree)
1359 filename = "V_HARTREE"
1360 mpi_io = .true.
1361 unit_nr = cp_print_key_unit_nr(logger, cube_section, '', &
1362 extension=".cube", middle_name=trim(filename), file_position=my_pos_cube, &
1363 log_filename=.false., mpi_io=mpi_io, fout=mpi_filename)
1364 IF (iounit > 0) THEN
1365 IF (.NOT. mpi_io) THEN
1366 INQUIRE (unit=unit_nr, name=filename)
1367 ELSE
1368 filename = mpi_filename
1369 END IF
1370 WRITE (unit=iounit, fmt="(T2,A,/,T2,A79)") &
1371 "The Hartree potential is written in cube file format to the file:", adjustr(trim(filename))
1372 END IF
1373 CALL cp_pw_to_cube(vhartree, unit_nr, "Hartree Potential", &
1374 particles=particles, zeff=zcharge, &
1375 stride=section_get_ivals(cube_section, "STRIDE"), mpi_io=mpi_io)
1376 CALL cp_print_key_finished_output(unit_nr, logger, cube_section, '', mpi_io=mpi_io)
1377 CALL auxbas_pw_pool%give_back_pw(vhartree)
1378 END block
1379 END IF
1380 IF (my_efield) THEN
1381 block
1382 TYPE(pw_c1d_gs_type) :: vhartree
1383 CALL auxbas_pw_pool%create_pw(pw=vhartree)
1384 udvol = 1.0_dp/rho_tot_rspace%pw_grid%dvol
1385 DO id = 1, 3
1386 CALL pw_transfer(rho_tot_gspace, vhartree)
1387 nd = 0
1388 nd(id) = 1
1389 CALL pw_derive(vhartree, nd)
1390 CALL pw_transfer(vhartree, rho_tot_rspace)
1391 CALL pw_scale(rho_tot_rspace, udvol)
1392
1393 filename = "EFIELD_"//cdir(id)
1394 mpi_io = .true.
1395 unit_nr = cp_print_key_unit_nr(logger, cube_section, '', &
1396 extension=".cube", middle_name=trim(filename), file_position=my_pos_cube, &
1397 log_filename=.false., mpi_io=mpi_io, fout=mpi_filename)
1398 IF (iounit > 0) THEN
1399 IF (.NOT. mpi_io) THEN
1400 INQUIRE (unit=unit_nr, name=filename)
1401 ELSE
1402 filename = mpi_filename
1403 END IF
1404 WRITE (unit=iounit, fmt="(T2,A,/,T2,A79)") &
1405 "The Efield is written in cube file format to the file:", adjustr(trim(filename))
1406 END IF
1407 CALL cp_pw_to_cube(rho_tot_rspace, unit_nr, "EFIELD "//cdir(id), &
1408 particles=particles, zeff=zcharge, &
1409 stride=section_get_ivals(cube_section, "STRIDE"), mpi_io=mpi_io)
1410 CALL cp_print_key_finished_output(unit_nr, logger, cube_section, '', mpi_io=mpi_io)
1411 END DO
1412 CALL auxbas_pw_pool%give_back_pw(vhartree)
1413 END block
1414 END IF
1415 CALL auxbas_pw_pool%give_back_pw(rho_tot_gspace)
1416 END block
1417 END IF
1418
1419 CALL auxbas_pw_pool%give_back_pw(rho_tot_rspace)
1420 CALL auxbas_pw_pool%give_back_pw(rho_core)
1421
1422 END SUBROUTINE print_density_cubes
1423
1424! **************************************************************************************************
1425!> \brief ...
1426!> \param qs_env ...
1427!> \param zcharge ...
1428!> \param elf_section ...
1429! **************************************************************************************************
1430 SUBROUTINE print_elf(qs_env, zcharge, elf_section)
1431
1432 TYPE(qs_environment_type), POINTER :: qs_env
1433 REAL(kind=dp), DIMENSION(:), INTENT(IN) :: zcharge
1434 TYPE(section_vals_type), POINTER :: elf_section
1435
1436 CHARACTER(LEN=default_path_length) :: filename, mpi_filename, my_pos_cube, &
1437 title
1438 INTEGER :: iounit, ispin, unit_nr
1439 LOGICAL :: append_cube, mpi_io
1440 REAL(kind=dp) :: rho_cutoff
1441 REAL(kind=dp), DIMENSION(:), POINTER :: tot_rho_r
1442 TYPE(cp_logger_type), POINTER :: logger
1443 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: rho_ao
1444 TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: rho_ao_kp
1445 TYPE(dft_control_type), POINTER :: dft_control
1446 TYPE(particle_list_type), POINTER :: particles
1447 TYPE(pw_c1d_gs_type), DIMENSION(:), POINTER :: rho_g
1448 TYPE(pw_env_type), POINTER :: pw_env
1449 TYPE(pw_pool_p_type), DIMENSION(:), POINTER :: pw_pools
1450 TYPE(pw_pool_type), POINTER :: auxbas_pw_pool
1451 TYPE(pw_r3d_rs_type), ALLOCATABLE, DIMENSION(:) :: elf_r
1452 TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: rho_r
1453 TYPE(qs_ks_env_type), POINTER :: ks_env
1454 TYPE(qs_rho_type), POINTER :: rho
1455 TYPE(qs_subsys_type), POINTER :: subsys
1456
1457 logger => cp_get_default_logger()
1458 iounit = cp_logger_get_default_io_unit(logger)
1459
1460 ! we need to construct the density on a realspace grid
1461 CALL get_qs_env(qs_env, dft_control=dft_control, ks_env=ks_env, rho=rho)
1462 NULLIFY (rho_r, rho_g, tot_rho_r)
1463 CALL qs_rho_get(rho, rho_ao_kp=rho_ao_kp, &
1464 rho_r=rho_r, rho_g=rho_g, tot_rho_r=tot_rho_r)
1465 DO ispin = 1, dft_control%nspins
1466 rho_ao => rho_ao_kp(ispin, :)
1467 CALL calculate_rho_elec(matrix_p_kp=rho_ao, &
1468 rho=rho_r(ispin), &
1469 rho_gspace=rho_g(ispin), &
1470 total_rho=tot_rho_r(ispin), &
1471 ks_env=ks_env)
1472 END DO
1473 CALL qs_rho_set(rho, rho_r_valid=.true., rho_g_valid=.true.)
1474
1475 CALL get_qs_env(qs_env, subsys=subsys)
1476 CALL qs_subsys_get(subsys, particles=particles)
1477
1478 ALLOCATE (elf_r(dft_control%nspins))
1479 CALL get_qs_env(qs_env=qs_env, pw_env=pw_env)
1480 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool, pw_pools=pw_pools)
1481 DO ispin = 1, dft_control%nspins
1482 CALL auxbas_pw_pool%create_pw(elf_r(ispin))
1483 CALL pw_zero(elf_r(ispin))
1484 END DO
1485
1486 IF (iounit > 0) THEN
1487 WRITE (unit=iounit, fmt="(/,T2,A)") &
1488 "ELF is computed on the real space grid -----"
1489 END IF
1490 rho_cutoff = section_get_rval(elf_section, "density_cutoff")
1491 CALL qs_elf_calc(qs_env, elf_r, rho_cutoff)
1492
1493 ! write ELF into cube file
1494 append_cube = section_get_lval(elf_section, "APPEND")
1495 my_pos_cube = "REWIND"
1496 IF (append_cube) my_pos_cube = "APPEND"
1497 DO ispin = 1, dft_control%nspins
1498 WRITE (filename, '(a5,I1.1)') "ELF_S", ispin
1499 WRITE (title, *) "ELF spin ", ispin
1500 mpi_io = .true.
1501 unit_nr = cp_print_key_unit_nr(logger, elf_section, '', extension=".cube", &
1502 middle_name=trim(filename), file_position=my_pos_cube, &
1503 log_filename=.false., mpi_io=mpi_io, fout=mpi_filename)
1504 IF (iounit > 0) THEN
1505 IF (.NOT. mpi_io) THEN
1506 INQUIRE (unit=unit_nr, name=filename)
1507 ELSE
1508 filename = mpi_filename
1509 END IF
1510 WRITE (unit=iounit, fmt="(T2,A,/,T2,A79)") &
1511 "ELF is written in cube file format to the file:", adjustr(trim(filename))
1512 END IF
1513
1514 CALL cp_pw_to_cube(elf_r(ispin), unit_nr, title, particles=particles, zeff=zcharge, &
1515 stride=section_get_ivals(elf_section, "STRIDE"), mpi_io=mpi_io)
1516 CALL cp_print_key_finished_output(unit_nr, logger, elf_section, '', mpi_io=mpi_io)
1517
1518 CALL auxbas_pw_pool%give_back_pw(elf_r(ispin))
1519 END DO
1520
1521 DEALLOCATE (elf_r)
1522
1523 END SUBROUTINE print_elf
1524! **************************************************************************************************
1525!> \brief ...
1526!> \param qs_env ...
1527!> \param zcharge ...
1528!> \param cube_section ...
1529! **************************************************************************************************
1530 SUBROUTINE print_mo_cubes(qs_env, zcharge, cube_section)
1531
1532 TYPE(qs_environment_type), POINTER :: qs_env
1533 REAL(kind=dp), DIMENSION(:), INTENT(IN) :: zcharge
1534 TYPE(section_vals_type), POINTER :: cube_section
1535
1536 CHARACTER(LEN=default_path_length) :: filename, my_pos_cube, title
1537 INTEGER :: homo, i, ifirst, ilast, iounit, ir, &
1538 ispin, ivector, n_rep, nhomo, nlist, &
1539 nlumo, nmo, shomo, unit_nr
1540 INTEGER, DIMENSION(:), POINTER :: list, list_index
1541 LOGICAL :: append_cube, mpi_io, write_cube
1542 REAL(kind=dp) :: homo_lumo(2, 2)
1543 REAL(kind=dp), DIMENSION(:), POINTER :: mo_eigenvalues
1544 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
1545 TYPE(cell_type), POINTER :: cell
1546 TYPE(cp_fm_type), POINTER :: mo_coeff
1547 TYPE(cp_logger_type), POINTER :: logger
1548 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: ks_rmpv, mo_derivs
1549 TYPE(dft_control_type), POINTER :: dft_control
1550 TYPE(mo_set_type), DIMENSION(:), POINTER :: mos
1551 TYPE(particle_list_type), POINTER :: particles
1552 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
1553 TYPE(pw_c1d_gs_type) :: wf_g
1554 TYPE(pw_env_type), POINTER :: pw_env
1555 TYPE(pw_pool_p_type), DIMENSION(:), POINTER :: pw_pools
1556 TYPE(pw_pool_type), POINTER :: auxbas_pw_pool
1557 TYPE(pw_r3d_rs_type) :: wf_r
1558 TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
1559 TYPE(qs_subsys_type), POINTER :: subsys
1560 TYPE(scf_control_type), POINTER :: scf_control
1561
1562 logger => cp_get_default_logger()
1563 iounit = cp_logger_get_default_io_unit(logger)
1564
1565 CALL get_qs_env(qs_env, mos=mos, matrix_ks=ks_rmpv, scf_control=scf_control)
1566 CALL get_qs_env(qs_env, dft_control=dft_control, mo_derivs=mo_derivs)
1567 CALL make_mo_eig(mos, dft_control%nspins, ks_rmpv, scf_control, mo_derivs)
1568 NULLIFY (mo_eigenvalues)
1569 homo = 0
1570 DO ispin = 1, dft_control%nspins
1571 CALL get_mo_set(mo_set=mos(ispin), eigenvalues=mo_eigenvalues, homo=shomo)
1572 homo_lumo(ispin, 1) = mo_eigenvalues(shomo)
1573 homo = max(homo, shomo)
1574 END DO
1575 write_cube = section_get_lval(cube_section, "WRITE_CUBE")
1576 nlumo = section_get_ival(cube_section, "NLUMO")
1577 nhomo = section_get_ival(cube_section, "NHOMO")
1578 NULLIFY (list_index)
1579 CALL section_vals_val_get(cube_section, "HOMO_LIST", n_rep_val=n_rep)
1580 IF (n_rep > 0) THEN
1581 nlist = 0
1582 DO ir = 1, n_rep
1583 NULLIFY (list)
1584 CALL section_vals_val_get(cube_section, "HOMO_LIST", i_rep_val=ir, i_vals=list)
1585 IF (ASSOCIATED(list)) THEN
1586 CALL reallocate(list_index, 1, nlist + SIZE(list))
1587 DO i = 1, SIZE(list)
1588 list_index(i + nlist) = list(i)
1589 END DO
1590 nlist = nlist + SIZE(list)
1591 END IF
1592 END DO
1593 nhomo = maxval(list_index)
1594 ELSE
1595 IF (nhomo == -1) nhomo = homo
1596 nlist = homo - max(1, homo - nhomo + 1) + 1
1597 ALLOCATE (list_index(nlist))
1598 DO i = 1, nlist
1599 list_index(i) = max(1, homo - nhomo + 1) + i - 1
1600 END DO
1601 END IF
1602
1603 CALL get_qs_env(qs_env=qs_env, pw_env=pw_env)
1604 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool, pw_pools=pw_pools)
1605 CALL auxbas_pw_pool%create_pw(wf_r)
1606 CALL auxbas_pw_pool%create_pw(wf_g)
1607
1608 CALL get_qs_env(qs_env, subsys=subsys)
1609 CALL qs_subsys_get(subsys, particles=particles)
1610
1611 append_cube = section_get_lval(cube_section, "APPEND")
1612 my_pos_cube = "REWIND"
1613 IF (append_cube) THEN
1614 my_pos_cube = "APPEND"
1615 END IF
1616
1617 CALL get_qs_env(qs_env=qs_env, &
1618 atomic_kind_set=atomic_kind_set, &
1619 qs_kind_set=qs_kind_set, &
1620 cell=cell, &
1621 particle_set=particle_set)
1622
1623 IF (nhomo >= 0) THEN
1624 DO ispin = 1, dft_control%nspins
1625 ! Prints the cube files of OCCUPIED ORBITALS
1626 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff, &
1627 eigenvalues=mo_eigenvalues, homo=homo, nmo=nmo)
1628 IF (write_cube) THEN
1629 DO i = 1, nlist
1630 ivector = list_index(i)
1631 IF (ivector > homo) cycle
1632 CALL calculate_wavefunction(mo_coeff, ivector, wf_r, wf_g, atomic_kind_set, qs_kind_set, &
1633 cell, dft_control, particle_set, pw_env)
1634 WRITE (filename, '(a4,I5.5,a1,I1.1)') "WFN_", ivector, "_", ispin
1635 mpi_io = .true.
1636 unit_nr = cp_print_key_unit_nr(logger, cube_section, '', extension=".cube", &
1637 middle_name=trim(filename), file_position=my_pos_cube, &
1638 log_filename=.false., mpi_io=mpi_io)
1639 WRITE (title, *) "WAVEFUNCTION ", ivector, " spin ", ispin, " i.e. HOMO - ", ivector - homo
1640 CALL cp_pw_to_cube(wf_r, unit_nr, title, particles=particles, zeff=zcharge, &
1641 stride=section_get_ivals(cube_section, "STRIDE"), mpi_io=mpi_io)
1642 CALL cp_print_key_finished_output(unit_nr, logger, cube_section, '', mpi_io=mpi_io)
1643 END DO
1644 END IF
1645 END DO
1646 END IF
1647
1648 IF (nlumo /= 0) THEN
1649 DO ispin = 1, dft_control%nspins
1650 ! Prints the cube files of UNOCCUPIED ORBITALS
1651 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff, &
1652 eigenvalues=mo_eigenvalues, homo=homo, nmo=nmo)
1653 IF (write_cube) THEN
1654 ifirst = homo + 1
1655 IF (nlumo == -1) THEN
1656 ilast = nmo
1657 ELSE
1658 ilast = ifirst + nlumo - 1
1659 ilast = min(nmo, ilast)
1660 END IF
1661 DO ivector = ifirst, ilast
1662 CALL calculate_wavefunction(mo_coeff, ivector, wf_r, wf_g, atomic_kind_set, &
1663 qs_kind_set, cell, dft_control, particle_set, pw_env)
1664 WRITE (filename, '(a4,I5.5,a1,I1.1)') "WFN_", ivector, "_", ispin
1665 mpi_io = .true.
1666 unit_nr = cp_print_key_unit_nr(logger, cube_section, '', extension=".cube", &
1667 middle_name=trim(filename), file_position=my_pos_cube, &
1668 log_filename=.false., mpi_io=mpi_io)
1669 WRITE (title, *) "WAVEFUNCTION ", ivector, " spin ", ispin, " i.e. LUMO + ", ivector - ifirst
1670 CALL cp_pw_to_cube(wf_r, unit_nr, title, particles=particles, zeff=zcharge, &
1671 stride=section_get_ivals(cube_section, "STRIDE"), mpi_io=mpi_io)
1672 CALL cp_print_key_finished_output(unit_nr, logger, cube_section, '', mpi_io=mpi_io)
1673 END DO
1674 END IF
1675 END DO
1676 END IF
1677
1678 CALL auxbas_pw_pool%give_back_pw(wf_g)
1679 CALL auxbas_pw_pool%give_back_pw(wf_r)
1680 IF (ASSOCIATED(list_index)) DEALLOCATE (list_index)
1681
1682 END SUBROUTINE print_mo_cubes
1683
1684! **************************************************************************************************
1685
1686END 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, cartesian_basis)
...
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:245
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_create(matrix, matrix_struct, name, use_sp, nrow, ncol, set_zero)
creates a new full matrix with the given structure
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
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, zeff, stride, max_file_size_mb, 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:127
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:124
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, cell, unoccupied_orbs, unoccupied_evals, qs_env, calc_energies)
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)
...
Utilities for broadened DOS and PDOS output.
subroutine, public get_dos_pdos_flags(dos_section, do_dos_output, do_projected_dos, do_pdos, do_pdos_raw)
Resolve projected-DOS requests from a DOS print section.
Calculation and writing of density of states.
Definition qs_dos.F:14
subroutine, public calculate_dos(mos, dft_section, unoccupied_evals, smearing_enabled)
Compute and write density of states.
Definition qs_dos.F:66
subroutine, public calculate_dos_kp(qs_env, dft_section)
Compute and write density of states (kpoints)
Definition qs_dos.F:325
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, mimic, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, xcint_weights, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, rhoz_cneo_set, ecoul_1c, rho0_s_rs, rho0_s_gs, rhoz_cneo_s_rs, rhoz_cneo_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, lri_env, lri_density, exstate_env, ec_env, harris_env, dispersion_env, gcp_env, vee, rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, wanniercentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs, do_rixs, tb_tblite)
Get the QUICKSTEP environment.
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, monovalent, 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, exc_accint, 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, xcint_weights, 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, exc_accint, 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, xcint_weights, 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_kp(qs_env, dft_section, pdos_print_key, write_pdos, write_pdos_raw)
Compute and write broadened projected density of states for k-point calculations.
Definition qs_pdos.F:1040
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, unoccupied_orbs, unoccupied_evals, pdos_print_key, write_pdos, write_pdos_raw)
Compute and write projected density of states.
Definition qs_pdos.F:155
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 write_p_matrix_csr(qs_env, input)
writing the density matrix in csr format into a file
subroutine, public write_hcore_matrix_csr(qs_env, input)
writing the core Hamiltonian 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 rebuild_pw_env(qs_env)
...
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, basis_type, reorder_rs_grid_ranks, skip_load_balance_distributed, pw_env_external, sab_orb_external, ext_kpoints)
...
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:60
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.