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