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