17 USE mctc_env,
ONLY: error_type
18 USE mctc_io,
ONLY: structure_type, new
19 USE mctc_io_symbols,
ONLY: symbol_to_number
20 USE tblite_basis_type,
ONLY: get_cutoff
21 USE tblite_container,
ONLY: container_cache
22 USE tblite_integral_multipole,
ONLY: multipole_cgto, multipole_grad_cgto, maxl, msao
23 USE tblite_scf_info,
ONLY: scf_info, atom_resolved, shell_resolved, &
24 orbital_resolved, not_used
25 USE tblite_scf_potential,
ONLY: potential_type, new_potential
26 USE tblite_wavefunction_type,
ONLY: wavefunction_type, new_wavefunction
27 USE tblite_xtb_calculator,
ONLY: xtb_calculator, new_xtb_calculator
28 USE tblite_xtb_gfn1,
ONLY: new_gfn1_calculator
29 USE tblite_xtb_gfn2,
ONLY: new_gfn2_calculator
30 USE tblite_xtb_h0,
ONLY: get_selfenergy, get_hamiltonian, get_occupation, &
31 get_hamiltonian_gradient, tb_hamiltonian
32 USE tblite_xtb_ipea1,
ONLY: new_ipea1_calculator
86#include "./base/base_uses.f90"
91 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'tblite_interface'
93 INTEGER,
PARAMETER :: dip_n = 3
94 INTEGER,
PARAMETER :: quad_n = 6
95 REAL(KIND=
dp),
PARAMETER :: same_atom = 0.00001_dp
117 CHARACTER(LEN=*),
PARAMETER :: routinen =
'tblite_init_geometry'
121 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
122 INTEGER :: iatom, natom
123 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: xyz
124 INTEGER :: handle, ikind
125 INTEGER,
DIMENSION(3) :: periodic
126 LOGICAL,
DIMENSION(3) :: lperiod
128 CALL timeset(routinen, handle)
131 CALL get_qs_env(qs_env=qs_env, particle_set=particle_set, cell=cell, qs_kind_set=qs_kind_set)
134 natom =
SIZE(particle_set)
135 ALLOCATE (xyz(3, natom))
137 ALLOCATE (tb%el_num(natom))
140 xyz(:, iatom) = particle_set(iatom)%r(:)
141 CALL get_atomic_kind(particle_set(iatom)%atomic_kind, kind_number=ikind)
142 CALL get_qs_kind(qs_kind_set(ikind), zatom=tb%el_num(iatom))
143 IF (tb%el_num(iatom) < 1 .OR. tb%el_num(iatom) > 85)
THEN
144 cpabort(
"only elements 1-85 are supported by tblite")
149 CALL get_cell(cell=cell, periodic=periodic)
150 lperiod(1) = periodic(1) == 1
151 lperiod(2) = periodic(2) == 1
152 lperiod(3) = periodic(3) == 1
155 CALL new(tb%mol, tb%el_num, xyz, lattice=cell%hmat, periodic=lperiod)
159 CALL timestop(handle)
164 cpabort(
"Built without TBLITE")
174 SUBROUTINE tb_update_geometry(qs_env, tb)
181 CHARACTER(LEN=*),
PARAMETER :: routinen =
'tblite_update_geometry'
184 INTEGER :: iatom, natom
185 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: xyz
188 CALL timeset(routinen, handle)
191 CALL get_qs_env(qs_env=qs_env, particle_set=particle_set)
194 natom =
SIZE(particle_set)
195 ALLOCATE (xyz(3, natom))
197 xyz(:, iatom) = particle_set(iatom)%r(:)
199 tb%mol%xyz(:, :) = xyz
203 CALL timestop(handle)
208 cpabort(
"Built without TBLITE")
211 END SUBROUTINE tb_update_geometry
223 INTEGER,
PARAMETER :: nspin = 1
225 TYPE(scf_info) :: info
227 info = tb%calc%variable_info()
228 IF (info%charge > shell_resolved) cpabort(
"tblite: no support for orbital resolved charge")
229 IF (info%dipole > atom_resolved) cpabort(
"tblite: no support for shell resolved dipole moment")
230 IF (info%quadrupole > atom_resolved) &
231 cpabort(
"tblite: no support shell resolved quadrupole moment")
233 CALL new_wavefunction(tb%wfn, tb%mol%nat, tb%calc%bas%nsh, tb%calc%bas%nao, nspin, 0.0_dp)
235 CALL new_potential(tb%pot, tb%mol, tb%calc%bas, tb%wfn%nspin)
238 ALLOCATE (tb%e_hal(tb%mol%nat), tb%e_rep(tb%mol%nat), tb%e_disp(tb%mol%nat))
239 ALLOCATE (tb%e_scd(tb%mol%nat), tb%e_es(tb%mol%nat))
240 ALLOCATE (tb%selfenergy(tb%calc%bas%nsh))
241 IF (
ALLOCATED(tb%calc%ncoord))
ALLOCATE (tb%cn(tb%mol%nat))
245 cpabort(
"Built without TBLITE")
262 TYPE(error_type),
ALLOCATABLE :: error
266 cpabort(
"Unknown xtb type")
268 CALL new_gfn1_calculator(tb%calc, tb%mol, error)
270 CALL new_gfn2_calculator(tb%calc, tb%mol, error)
272 CALL new_ipea1_calculator(tb%calc, tb%mol, error)
278 cpabort(
"Built without TBLITE")
289 SUBROUTINE tb_init_ham(qs_env, tb, para_env)
297 TYPE(container_cache) :: hcache, rcache
302 IF (
ALLOCATED(tb%grad))
THEN
304 CALL tb_zero_force(qs_env)
308 IF (
ALLOCATED(tb%calc%halogen))
THEN
309 CALL tb%calc%halogen%update(tb%mol, hcache)
310 IF (
ALLOCATED(tb%grad))
THEN
312 CALL tb%calc%halogen%get_engrad(tb%mol, hcache, tb%e_hal, &
314 CALL tb_grad2force(qs_env, tb, para_env, 0)
316 CALL tb%calc%halogen%get_engrad(tb%mol, hcache, tb%e_hal)
320 IF (
ALLOCATED(tb%calc%repulsion))
THEN
321 CALL tb%calc%repulsion%update(tb%mol, rcache)
322 IF (
ALLOCATED(tb%grad))
THEN
324 CALL tb%calc%repulsion%get_engrad(tb%mol, rcache, tb%e_rep, &
326 CALL tb_grad2force(qs_env, tb, para_env, 1)
328 CALL tb%calc%repulsion%get_engrad(tb%mol, rcache, tb%e_rep)
332 IF (
ALLOCATED(tb%calc%dispersion))
THEN
333 CALL tb%calc%dispersion%update(tb%mol, tb%dcache)
334 IF (
ALLOCATED(tb%grad))
THEN
336 CALL tb%calc%dispersion%get_engrad(tb%mol, tb%dcache, tb%e_disp, &
338 CALL tb_grad2force(qs_env, tb, para_env, 2)
340 CALL tb%calc%dispersion%get_engrad(tb%mol, tb%dcache, tb%e_disp)
344 CALL new_potential(tb%pot, tb%mol, tb%calc%bas, tb%wfn%nspin)
345 IF (
ALLOCATED(tb%calc%coulomb))
THEN
346 CALL tb%calc%coulomb%update(tb%mol, tb%cache)
349 IF (
ALLOCATED(tb%grad))
THEN
350 IF (
ALLOCATED(tb%calc%ncoord))
THEN
351 CALL tb%calc%ncoord%get_cn(tb%mol, tb%cn, tb%dcndr, tb%dcndL)
353 CALL get_selfenergy(tb%calc%h0, tb%mol%id, tb%calc%bas%ish_at, &
354 & tb%calc%bas%nsh_id, cn=tb%cn, selfenergy=tb%selfenergy, dsedcn=tb%dsedcn)
356 IF (
ALLOCATED(tb%calc%ncoord))
THEN
357 CALL tb%calc%ncoord%get_cn(tb%mol, tb%cn)
359 CALL get_selfenergy(tb%calc%h0, tb%mol%id, tb%calc%bas%ish_at, &
360 & tb%calc%bas%nsh_id, cn=tb%cn, selfenergy=tb%selfenergy, dsedcn=tb%dsedcn)
367 cpabort(
"Built without TBLITE")
370 END SUBROUTINE tb_init_ham
390 NULLIFY (scf_section, logger)
396 energy%repulsive = sum(tb%e_rep)
397 energy%el_stat = sum(tb%e_es)
398 energy%dispersion = sum(tb%e_disp)
399 energy%dispersion_sc = sum(tb%e_scd)
400 energy%xtb_xb_inter = sum(tb%e_hal)
402 energy%total = energy%core + energy%repulsive + energy%el_stat + energy%dispersion &
403 + energy%dispersion_sc + energy%xtb_xb_inter + energy%kTS &
404 + energy%efield + energy%qmmm_el
409 WRITE (unit=iounit, fmt=
"(/,(T9,A,T60,F20.10))") &
410 "Repulsive pair potential energy: ", energy%repulsive, &
411 "Zeroth order Hamiltonian energy: ", energy%core, &
412 "Electrostatic energy: ", energy%el_stat, &
413 "Self-consistent dispersion energy: ", energy%dispersion_sc, &
414 "Non-self consistent dispersion energy: ", energy%dispersion
415 WRITE (unit=iounit, fmt=
"(T9,A,T60,F20.10)") &
416 "Correction for halogen bonding: ", energy%xtb_xb_inter
417 IF (abs(energy%efield) > 1.e-12_dp)
THEN
418 WRITE (unit=iounit, fmt=
"(T9,A,T60,F20.10)") &
419 "Electric field interaction energy: ", energy%efield
421 IF (qs_env%qmmm)
THEN
422 WRITE (unit=iounit, fmt=
"(T9,A,T60,F20.10)") &
423 "QM/MM Electrostatic energy: ", energy%qmmm_el
427 "PRINT%DETAILED_ENERGY")
433 cpabort(
"Built without TBLITE")
450 CHARACTER(len=2),
INTENT(IN) :: element_symbol
452 INTEGER,
DIMENSION(5),
INTENT(out) :: occ
456 CHARACTER(LEN=default_string_length) :: sng
457 INTEGER :: ang, i_type, id_atom, ind_ao, ipgf, ish, &
458 ishell, ityp, maxl, mprim, natorb, &
465 CALL symbol_to_number(i_type, element_symbol)
466 DO id_atom = 1, tb%mol%nat
467 IF (i_type == tb%el_num(id_atom))
EXIT
470 param%symbol = element_symbol
471 param%defined = .true.
472 ityp = tb%mol%id(id_atom)
475 nset = tb%calc%bas%nsh_id(ityp)
479 mprim = max(mprim, tb%calc%bas%cgto(ishell, ityp)%nprim)
486 gto_basis_set%name = element_symbol//
"_STO-"//trim(sng)//
"G"
487 gto_basis_set%nset = nset
491 CALL reallocate(gto_basis_set%nshell, 1, nset)
492 CALL reallocate(gto_basis_set%n, 1, 1, 1, nset)
493 CALL reallocate(gto_basis_set%l, 1, 1, 1, nset)
494 CALL reallocate(gto_basis_set%zet, 1, mprim, 1, nset)
495 CALL reallocate(gto_basis_set%gcc, 1, mprim, 1, 1, 1, nset)
500 ang = tb%calc%bas%cgto(ishell, ityp)%ang
501 natorb = natorb + (2*ang + 1)
502 param%lval(ishell) = ang
503 maxl = max(ang, maxl)
504 gto_basis_set%lmax(ishell) = ang
505 gto_basis_set%lmin(ishell) = ang
506 gto_basis_set%npgf(ishell) = tb%calc%bas%cgto(ishell, ityp)%nprim
507 gto_basis_set%nshell(ishell) = nshell
508 gto_basis_set%n(1, ishell) = ang + 1
509 gto_basis_set%l(1, ishell) = ang
510 DO ipgf = 1, gto_basis_set%npgf(ishell)
511 gto_basis_set%gcc(ipgf, 1, ishell) = tb%calc%bas%cgto(ishell, ityp)%coeff(ipgf)
512 gto_basis_set%zet(ipgf, ishell) = tb%calc%bas%cgto(ishell, ityp)%alpha(ipgf)
514 DO ipgf = 1, (2*ang + 1)
516 param%lao(ind_ao) = ang
517 param%nao(ind_ao) = ishell
525 param%rcut = get_cutoff(tb%calc%bas)
526 param%natorb = natorb
531 DO ish = 1, min(tb%calc%bas%nsh_at(id_atom), 5)
532 occ(ish) = nint(tb%calc%h0%refocc(ish, ityp))
533 param%occupation(ish) = occ(ish)
535 param%zeff = sum(occ)
538 gto_basis_set%norm_type = 3
543 mark_used(gto_basis_set)
544 mark_used(element_symbol)
546 cpabort(
"Built without TBLITE")
559 LOGICAL,
INTENT(IN) :: calculate_forces
563 CHARACTER(LEN=*),
PARAMETER :: routinen =
'build_tblite_matrices'
565 INTEGER :: handle, maxder, nderivatives, nimg, img, nkind, i, ic, iw, &
566 iatom, jatom, ikind, jkind, iset, jset, n1, n2, icol, irow, &
567 ia, ib, sgfa, sgfb, atom_a, atom_b, &
568 ldsab, nseta, nsetb, natorb_a, natorb_b, sgfa0
569 LOGICAL :: found, norml1, norml2, use_arnoldi
570 REAL(kind=
dp) :: dr, rr
571 INTEGER,
DIMENSION(3) :: cell
572 REAL(kind=
dp) :: hij, shpoly
573 REAL(kind=
dp),
DIMENSION(2) :: condnum
574 REAL(kind=
dp),
DIMENSION(3) :: rij
575 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: atom_of_kind
576 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: owork
577 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: oint, sint, hint
578 INTEGER,
DIMENSION(:),
POINTER :: la_max, la_min, lb_max, lb_min
579 INTEGER,
DIMENSION(:),
POINTER :: npgfa, npgfb, nsgfa, nsgfb
580 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgfa, first_sgfb
581 REAL(kind=
dp),
DIMENSION(:),
POINTER :: set_radius_a, set_radius_b
582 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: rpgfa, rpgfb, zeta, zetb, scon_a, scon_b
583 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: sblock, fblock
589 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_h, matrix_s, matrix_p, matrix_w
596 DIMENSION(:),
POINTER :: nl_iterator
600 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
603 TYPE(tb_hamiltonian),
POINTER :: h0
606 CALL timeset(routinen, handle)
608 NULLIFY (ks_env, energy, atomic_kind_set, qs_kind_set)
609 NULLIFY (matrix_h, matrix_s, atprop, dft_control)
610 NULLIFY (sab_orb, rho, tb)
613 ks_env=ks_env, para_env=para_env, &
615 atomic_kind_set=atomic_kind_set, &
616 qs_kind_set=qs_kind_set, &
617 matrix_h_kp=matrix_h, &
618 matrix_s_kp=matrix_s, &
620 dft_control=dft_control, &
622 rho=rho, tb_tblite=tb)
626 CALL tb_update_geometry(qs_env, tb)
628 nkind =
SIZE(atomic_kind_set)
630 IF (calculate_forces)
THEN
632 IF (
ALLOCATED(tb%grad))
DEALLOCATE (tb%grad)
633 ALLOCATE (tb%grad(3, tb%mol%nat))
634 IF (
ALLOCATED(tb%dsedcn))
DEALLOCATE (tb%dsedcn)
635 ALLOCATE (tb%dsedcn(tb%calc%bas%nsh))
636 IF (
ALLOCATED(tb%calc%ncoord))
THEN
637 IF (
ALLOCATED(tb%dcndr))
DEALLOCATE (tb%dcndr)
638 ALLOCATE (tb%dcndr(3, tb%mol%nat, tb%mol%nat))
639 IF (
ALLOCATED(tb%dcndL))
DEALLOCATE (tb%dcndL)
640 ALLOCATE (tb%dcndL(3, 3, tb%mol%nat))
643 maxder =
ncoset(nderivatives)
644 nimg = dft_control%nimages
647 CALL tb_init_ham(qs_env, tb, para_env)
653 IF (calculate_forces)
THEN
654 NULLIFY (force, matrix_w, virial)
656 matrix_w_kp=matrix_w, &
657 virial=virial, force=force)
659 IF (
SIZE(matrix_p, 1) == 2)
THEN
661 CALL dbcsr_add(matrix_p(1, img)%matrix, matrix_p(2, img)%matrix, &
662 alpha_scalar=1.0_dp, beta_scalar=1.0_dp)
663 CALL dbcsr_add(matrix_w(1, img)%matrix, matrix_w(2, img)%matrix, &
664 alpha_scalar=1.0_dp, beta_scalar=1.0_dp)
667 tb%use_virial = virial%pv_availability .AND. (.NOT. virial%pv_numer)
673 ALLOCATE (basis_set_list(nkind))
678 CALL create_sab_matrix(ks_env, matrix_s,
"OVERLAP MATRIX", basis_set_list, basis_set_list, &
685 ALLOCATE (matrix_h(1, img)%matrix)
686 CALL dbcsr_create(matrix_h(1, img)%matrix, template=matrix_s(1, 1)%matrix, &
687 name=
"HAMILTONIAN MATRIX")
693 NULLIFY (nl_iterator)
697 iatom=iatom, jatom=jatom, r=rij, cell=cell)
699 icol = max(iatom, jatom)
700 irow = min(iatom, jatom)
701 IF (icol == jatom)
THEN
713 row=irow, col=icol, block=sblock, found=found)
717 row=irow, col=icol, block=fblock, found=found)
722 basis_set_a => basis_set_list(ikind)%gto_basis_set
723 IF (.NOT.
ASSOCIATED(basis_set_a)) cycle
724 basis_set_b => basis_set_list(jkind)%gto_basis_set
725 IF (.NOT.
ASSOCIATED(basis_set_b)) cycle
726 atom_a = atom_of_kind(icol)
727 atom_b = atom_of_kind(irow)
729 first_sgfa => basis_set_a%first_sgf
730 la_max => basis_set_a%lmax
731 la_min => basis_set_a%lmin
732 npgfa => basis_set_a%npgf
733 nseta = basis_set_a%nset
734 nsgfa => basis_set_a%nsgf_set
735 rpgfa => basis_set_a%pgf_radius
736 set_radius_a => basis_set_a%set_radius
737 scon_a => basis_set_a%scon
738 zeta => basis_set_a%zet
740 first_sgfb => basis_set_b%first_sgf
741 lb_max => basis_set_b%lmax
742 lb_min => basis_set_b%lmin
743 npgfb => basis_set_b%npgf
744 nsetb = basis_set_b%nset
745 nsgfb => basis_set_b%nsgf_set
746 rpgfb => basis_set_b%pgf_radius
747 set_radius_b => basis_set_b%set_radius
748 scon_b => basis_set_b%scon
749 zetb => basis_set_b%zet
752 ALLOCATE (oint(ldsab, ldsab, maxder), owork(ldsab, ldsab))
755 natorb_a = natorb_a + (2*basis_set_a%l(1, iset) + 1)
759 natorb_b = natorb_b + (2*basis_set_b%l(1, iset) + 1)
761 ALLOCATE (sint(natorb_a, natorb_b, maxder))
763 ALLOCATE (hint(natorb_a, natorb_b, maxder))
768 n1 = npgfa(iset)*(
ncoset(la_max(iset)) -
ncoset(la_min(iset) - 1))
769 sgfa = first_sgfa(1, iset)
771 IF (set_radius_a(iset) + set_radius_b(jset) < dr) cycle
772 n2 = npgfb(jset)*(
ncoset(lb_max(jset)) -
ncoset(lb_min(jset) - 1))
773 sgfb = first_sgfb(1, jset)
774 IF (calculate_forces)
THEN
775 CALL overlap_ab(la_max(iset), la_min(iset), npgfa(iset), rpgfa(:, iset), zeta(:, iset), &
776 lb_max(jset), lb_min(jset), npgfb(jset), rpgfb(:, jset), zetb(:, jset), &
777 rij, sab=oint(:, :, 1), dab=oint(:, :, 2:4))
779 CALL overlap_ab(la_max(iset), la_min(iset), npgfa(iset), rpgfa(:, iset), zeta(:, iset), &
780 lb_max(jset), lb_min(jset), npgfb(jset), rpgfb(:, jset), zetb(:, jset), &
781 rij, sab=oint(:, :, 1))
784 CALL contraction(oint(:, :, 1), owork, ca=scon_a(:, sgfa:), na=n1, ma=nsgfa(iset), &
785 cb=scon_b(:, sgfb:), nb=n2, mb=nsgfb(jset), fscale=1.0_dp, trans=.false.)
786 CALL block_add(
"IN", owork, nsgfa(iset), nsgfb(jset), sint(:, :, 1), sgfa, sgfb, trans=.false.)
787 IF (calculate_forces)
THEN
789 CALL contraction(oint(:, :, i), owork, ca=scon_a(:, sgfa:), na=n1, ma=nsgfa(iset), &
790 cb=scon_b(:, sgfb:), nb=n2, mb=nsgfb(jset), fscale=1.0_dp, trans=.false.)
791 CALL block_add(
"IN", owork, nsgfa(iset), nsgfb(jset), sint(:, :, i), sgfa, sgfb, trans=.false.)
798 IF (icol <= irow)
THEN
799 sblock(:, :) = sblock(:, :) + sint(:, :, 1)
801 sblock(:, :) = sblock(:, :) + transpose(sint(:, :, 1))
805 IF (icol == irow .AND. dr < same_atom)
THEN
807 n1 = tb%calc%bas%ish_at(icol)
809 sgfa = first_sgfa(1, iset)
810 hij = tb%selfenergy(n1 + iset)
811 DO ia = sgfa, sgfa + nsgfa(iset) - 1
812 hint(ia, ia, 1) = hij
817 rr = sqrt(dr/(h0%rad(jkind) + h0%rad(ikind)))
818 n1 = tb%calc%bas%ish_at(icol)
821 sgfa = first_sgfa(1, iset)
822 sgfa0 = sgfa0 + tb%calc%bas%cgto(iset, tb%mol%id(icol))%nprim
823 n2 = tb%calc%bas%ish_at(irow)
825 sgfb = first_sgfb(1, jset)
826 shpoly = (1.0_dp + h0%shpoly(iset, ikind)*rr) &
827 *(1.0_dp + h0%shpoly(jset, jkind)*rr)
828 hij = 0.5_dp*(tb%selfenergy(n1 + iset) + tb%selfenergy(n2 + jset)) &
829 *h0%hscale(iset, jset, ikind, jkind)*shpoly
830 DO ia = sgfa, sgfa + nsgfa(iset) - 1
831 DO ib = sgfb, sgfb + nsgfb(jset) - 1
832 hint(ia, ib, 1) = hij*sint(ia, ib, 1)
840 IF (icol <= irow)
THEN
841 fblock(:, :) = fblock(:, :) + hint(:, :, 1)
843 fblock(:, :) = fblock(:, :) + transpose(hint(:, :, 1))
846 DEALLOCATE (oint, owork, sint, hint)
852 DO i = 1,
SIZE(matrix_s, 1)
855 DO i = 1,
SIZE(matrix_h, 1)
861 IF (dft_control%qs_control%xtb_control%tblite_method ==
gfn2xtb) &
867 IF (.NOT. calculate_forces)
THEN
869 "DFT%PRINT%OVERLAP_CONDITION") /= 0)
THEN
873 CALL section_vals_val_get(qs_env%input,
"DFT%PRINT%OVERLAP_CONDITION%DIAGONALIZATION", l_val=norml2)
874 CALL section_vals_val_get(qs_env%input,
"DFT%PRINT%OVERLAP_CONDITION%ARNOLDI", l_val=use_arnoldi)
875 CALL get_qs_env(qs_env=qs_env, blacs_env=blacs_env)
876 CALL overlap_condnum(matrix_s, condnum, iw, norml1, norml2, use_arnoldi, blacs_env)
880 DEALLOCATE (basis_set_list)
882 CALL timestop(handle)
886 mark_used(calculate_forces)
887 cpabort(
"Built without TBLITE")
905 LOGICAL,
INTENT(IN) :: calculate_forces
906 LOGICAL,
INTENT(IN) :: use_rho
910 INTEGER :: iatom, ikind, is, ns, atom_a, ii, im
911 INTEGER :: nimg, nkind, nsgf, natorb, na
912 INTEGER :: n_atom, max_orb, max_shell
913 LOGICAL :: do_dipole, do_quadrupole
914 REAL(kind=
dp) :: norm
915 INTEGER,
DIMENSION(5) :: occ
916 INTEGER,
DIMENSION(25) :: lao
917 INTEGER,
DIMENSION(25) :: nao
918 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: ch_atom, ch_shell, ch_ref, ch_orb
919 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: aocg, ao_dip, ao_quad
922 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_s, matrix_p
927 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
934 do_quadrupole = .false.
937 NULLIFY (particle_set, qs_kind_set, atomic_kind_set)
938 CALL get_qs_env(qs_env=qs_env, scf_env=scf_env, particle_set=particle_set, qs_kind_set=qs_kind_set, &
939 atomic_kind_set=atomic_kind_set, matrix_s_kp=matrix_s, rho=rho, para_env=para_env)
943 IF (
ASSOCIATED(tb%dipbra)) do_dipole = .true.
944 IF (
ASSOCIATED(tb%quadbra)) do_quadrupole = .true.
946 matrix_p => scf_env%p_mix_new
948 n_atom =
SIZE(particle_set)
949 nkind =
SIZE(atomic_kind_set)
950 nimg = dft_control%nimages
952 ALLOCATE (aocg(nsgf, n_atom))
954 IF (do_dipole)
ALLOCATE (ao_dip(n_atom, dip_n))
955 IF (do_quadrupole)
ALLOCATE (ao_quad(n_atom, quad_n))
959 CALL get_qs_kind(qs_kind_set(ikind), xtb_parameter=xtb_kind)
961 max_orb = max(max_orb, natorb)
964 max_shell = max(max_shell, tb%calc%bas%nsh_at(is))
966 ALLOCATE (ch_atom(n_atom, 1), ch_shell(n_atom, max_shell))
967 ALLOCATE (ch_orb(max_orb, n_atom), ch_ref(max_orb, n_atom))
973 CALL ao_charges(matrix_p, matrix_s, aocg, para_env)
974 IF (do_dipole .OR. do_quadrupole)
THEN
975 cpabort(
"missing contraction with density matrix for multiple k-points")
978 NULLIFY (p_matrix, s_matrix)
979 p_matrix => matrix_p(:, 1)
980 s_matrix => matrix_s(1, 1)%matrix
981 CALL ao_charges(p_matrix, s_matrix, aocg, para_env)
984 CALL contract_dens(p_matrix, tb%dipbra(im)%matrix, tb%dipket(im)%matrix, ao_dip(:, im), para_env)
987 IF (do_quadrupole)
THEN
989 CALL contract_dens(p_matrix, tb%quadbra(im)%matrix, tb%quadket(im)%matrix, ao_quad(:, im), para_env)
996 CALL get_qs_kind(qs_kind_set(ikind), xtb_parameter=xtb_kind)
999 atom_a = atomic_kind_set(ikind)%atom_list(iatom)
1002 norm = 2*lao(is) + 1
1003 ch_ref(is, atom_a) = tb%calc%h0%refocc(nao(is), ikind)/norm
1004 ch_orb(is, atom_a) = aocg(is, atom_a) - ch_ref(is, atom_a)
1005 ch_shell(atom_a, ns) = ch_orb(is, atom_a) + ch_shell(atom_a, ns)
1007 ch_atom(atom_a, 1) = sum(ch_orb(:, atom_a))
1013 IF (dft_control%qs_control%do_ls_scf)
THEN
1016 CALL charge_mixing(scf_env%mixing_method, scf_env%mixing_store, &
1017 ch_shell, para_env, scf_env%iter_count)
1024 DO iatom = 1, n_atom
1025 ii = tb%calc%bas%ish_at(iatom)
1026 DO is = 1, tb%calc%bas%nsh_at(iatom)
1027 tb%wfn%qsh(ii + is, 1) = -ch_shell(iatom, is)
1029 tb%wfn%qat(iatom, 1) = -ch_atom(iatom, 1)
1033 DO iatom = 1, n_atom
1035 tb%wfn%dpat(im, iatom, 1) = -ao_dip(iatom, im)
1040 IF (do_quadrupole)
THEN
1041 DO iatom = 1, n_atom
1043 tb%wfn%qpat(im, iatom, 1) = -ao_quad(iatom, im)
1046 DEALLOCATE (ao_quad)
1049 IF (
ALLOCATED(tb%calc%coulomb))
THEN
1050 CALL tb%calc%coulomb%get_potential(tb%mol, tb%cache, tb%wfn, tb%pot)
1051 CALL tb%calc%coulomb%get_energy(tb%mol, tb%cache, tb%wfn, tb%e_es)
1053 IF (
ALLOCATED(tb%calc%dispersion))
THEN
1054 CALL tb%calc%dispersion%get_potential(tb%mol, tb%dcache, tb%wfn, tb%pot)
1055 CALL tb%calc%dispersion%get_energy(tb%mol, tb%dcache, tb%wfn, tb%e_scd)
1058 IF (calculate_forces)
THEN
1059 IF (
ALLOCATED(tb%calc%coulomb))
THEN
1061 CALL tb%calc%coulomb%get_gradient(tb%mol, tb%cache, tb%wfn, tb%grad, tb%sigma)
1062 CALL tb_grad2force(qs_env, tb, para_env, 3)
1065 IF (
ALLOCATED(tb%calc%dispersion))
THEN
1067 CALL tb%calc%dispersion%get_gradient(tb%mol, tb%dcache, tb%wfn, tb%grad, tb%sigma)
1068 CALL tb_grad2force(qs_env, tb, para_env, 2)
1072 DEALLOCATE (ch_atom, ch_shell, ch_orb, ch_ref)
1077 mark_used(dft_control)
1078 mark_used(calculate_forces)
1080 cpabort(
"Built without TBLITE")
1097#if defined(__TBLITE)
1099 INTEGER :: ikind, jkind, iatom, jatom, icol, irow
1100 INTEGER :: ic, is, nimg, ni, nj, i, j
1101 INTEGER :: la, lb, za, zb
1103 INTEGER,
DIMENSION(3) :: cellind
1104 INTEGER,
DIMENSION(25) :: naoa, naob
1105 REAL(kind=
dp),
DIMENSION(3) :: rij
1106 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: kind_of, sum_shell
1107 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: ashift, bshift
1108 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: ksblock, sblock
1109 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
1110 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: dip_ket1, dip_ket2, dip_ket3, &
1111 dip_bra1, dip_bra2, dip_bra3
1112 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: quad_ket1, quad_ket2, quad_ket3, &
1113 quad_ket4, quad_ket5, quad_ket6, &
1114 quad_bra1, quad_bra2, quad_bra3, &
1115 quad_bra4, quad_bra5, quad_bra6
1119 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_s
1120 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: ks_matrix
1123 DIMENSION(:),
POINTER :: nl_iterator
1126 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1129 nimg = dft_control%nimages
1131 NULLIFY (matrix_s, ks_matrix, n_list, qs_kind_set)
1132 CALL get_qs_env(qs_env=qs_env, sab_orb=n_list, matrix_s_kp=matrix_s, matrix_ks_kp=ks_matrix, qs_kind_set=qs_kind_set)
1135 ALLOCATE (sum_shell(tb%mol%nat))
1137 DO j = 1, tb%mol%nat
1139 i = i + tb%calc%bas%nsh_at(j)
1144 CALL get_qs_env(qs_env=qs_env, atomic_kind_set=atomic_kind_set)
1151 ikind = kind_of(irow)
1152 jkind = kind_of(icol)
1155 CALL get_qs_kind(qs_kind_set(ikind), xtb_parameter=xtb_atom_a)
1156 CALL get_qs_kind(qs_kind_set(jkind), xtb_parameter=xtb_atom_b)
1160 ni =
SIZE(sblock, 1)
1161 ALLOCATE (ashift(ni, ni))
1164 la = naoa(i) + sum_shell(irow)
1165 ashift(i, i) = tb%pot%vsh(la, 1)
1168 nj =
SIZE(sblock, 2)
1169 ALLOCATE (bshift(nj, nj))
1172 lb = naob(j) + sum_shell(icol)
1173 bshift(j, j) = tb%pot%vsh(lb, 1)
1176 DO is = 1,
SIZE(ks_matrix, 1)
1179 row=irow, col=icol, block=ksblock, found=found)
1181 ksblock = ksblock - 0.5_dp*(matmul(ashift, sblock) &
1182 + matmul(sblock, bshift))
1183 ksblock = ksblock - 0.5_dp*(tb%pot%vat(irow, 1) &
1184 + tb%pot%vat(icol, 1))*sblock
1186 DEALLOCATE (ashift, bshift)
1190 IF (
ASSOCIATED(tb%dipbra))
THEN
1195 NULLIFY (dip_bra1, dip_bra2, dip_bra3)
1197 row=irow, col=icol, block=dip_bra1, found=found)
1200 row=irow, col=icol, block=dip_bra2, found=found)
1203 row=irow, col=icol, block=dip_bra3, found=found)
1205 NULLIFY (dip_ket1, dip_ket2, dip_ket3)
1207 row=irow, col=icol, block=dip_ket1, found=found)
1210 row=irow, col=icol, block=dip_ket2, found=found)
1213 row=irow, col=icol, block=dip_ket3, found=found)
1216 DO is = 1,
SIZE(ks_matrix, 1)
1219 row=irow, col=icol, block=ksblock, found=found)
1221 ksblock = ksblock - 0.5_dp*(dip_ket1*tb%pot%vdp(1, irow, 1) &
1222 + dip_ket2*tb%pot%vdp(2, irow, 1) &
1223 + dip_ket3*tb%pot%vdp(3, irow, 1) &
1224 + dip_bra1*tb%pot%vdp(1, icol, 1) &
1225 + dip_bra2*tb%pot%vdp(2, icol, 1) &
1226 + dip_bra3*tb%pot%vdp(3, icol, 1))
1232 IF (
ASSOCIATED(tb%quadbra))
THEN
1237 NULLIFY (quad_bra1, quad_bra2, quad_bra3, quad_bra4, quad_bra5, quad_bra6)
1239 row=irow, col=icol, block=quad_bra1, found=found)
1242 row=irow, col=icol, block=quad_bra2, found=found)
1245 row=irow, col=icol, block=quad_bra3, found=found)
1248 row=irow, col=icol, block=quad_bra4, found=found)
1251 row=irow, col=icol, block=quad_bra5, found=found)
1254 row=irow, col=icol, block=quad_bra6, found=found)
1257 NULLIFY (quad_ket1, quad_ket2, quad_ket3, quad_ket4, quad_ket5, quad_ket6)
1259 row=irow, col=icol, block=quad_ket1, found=found)
1262 row=irow, col=icol, block=quad_ket2, found=found)
1265 row=irow, col=icol, block=quad_ket3, found=found)
1268 row=irow, col=icol, block=quad_ket4, found=found)
1271 row=irow, col=icol, block=quad_ket5, found=found)
1274 row=irow, col=icol, block=quad_ket6, found=found)
1277 DO is = 1,
SIZE(ks_matrix, 1)
1280 row=irow, col=icol, block=ksblock, found=found)
1283 ksblock = ksblock - 0.5_dp*(quad_ket1*tb%pot%vqp(1, irow, 1) &
1284 + quad_ket2*tb%pot%vqp(2, irow, 1) &
1285 + quad_ket3*tb%pot%vqp(3, irow, 1) &
1286 + quad_ket4*tb%pot%vqp(4, irow, 1) &
1287 + quad_ket5*tb%pot%vqp(5, irow, 1) &
1288 + quad_ket6*tb%pot%vqp(6, irow, 1) &
1289 + quad_bra1*tb%pot%vqp(1, icol, 1) &
1290 + quad_bra2*tb%pot%vqp(2, icol, 1) &
1291 + quad_bra3*tb%pot%vqp(3, icol, 1) &
1292 + quad_bra4*tb%pot%vqp(4, icol, 1) &
1293 + quad_bra5*tb%pot%vqp(5, icol, 1) &
1294 + quad_bra6*tb%pot%vqp(6, icol, 1))
1301 cpabort(
"GFN methods with k-points not tested")
1303 CALL get_qs_env(qs_env=qs_env, kpoints=kpoints)
1304 NULLIFY (cell_to_index)
1307 NULLIFY (nl_iterator)
1311 iatom=iatom, jatom=jatom, r=rij, cell=cellind)
1313 icol = max(iatom, jatom)
1314 irow = min(iatom, jatom)
1316 IF (icol == jatom)
THEN
1323 ic = cell_to_index(cellind(1), cellind(2), cellind(3))
1328 row=irow, col=icol, block=sblock, found=found)
1332 CALL get_qs_kind(qs_kind_set(ikind), xtb_parameter=xtb_atom_a)
1333 CALL get_qs_kind(qs_kind_set(jkind), xtb_parameter=xtb_atom_b)
1337 ni =
SIZE(sblock, 1)
1338 ALLOCATE (ashift(ni, ni))
1341 la = naoa(i) + sum_shell(irow)
1342 ashift(i, i) = tb%pot%vsh(la, 1)
1345 nj =
SIZE(sblock, 2)
1346 ALLOCATE (bshift(nj, nj))
1349 lb = naob(j) + sum_shell(icol)
1350 bshift(j, j) = tb%pot%vsh(lb, 1)
1353 DO is = 1,
SIZE(ks_matrix, 1)
1356 row=irow, col=icol, block=ksblock, found=found)
1358 ksblock = ksblock - 0.5_dp*(matmul(ashift, sblock) &
1359 + matmul(sblock, bshift))
1360 ksblock = ksblock - 0.5_dp*(tb%pot%vat(irow, 1) &
1361 + tb%pot%vat(icol, 1))*sblock
1366 IF (
ASSOCIATED(tb%dipbra))
THEN
1367 NULLIFY (nl_iterator)
1371 iatom=iatom, jatom=jatom, cell=cellind)
1372 icol = max(iatom, jatom)
1373 irow = min(iatom, jatom)
1375 NULLIFY (dip_bra1, dip_bra2, dip_bra3)
1377 row=irow, col=icol, block=dip_bra1, found=found)
1380 row=irow, col=icol, block=dip_bra2, found=found)
1383 row=irow, col=icol, block=dip_bra3, found=found)
1385 NULLIFY (dip_ket1, dip_ket2, dip_ket3)
1387 row=irow, col=icol, block=dip_ket1, found=found)
1390 row=irow, col=icol, block=dip_ket2, found=found)
1393 row=irow, col=icol, block=dip_ket3, found=found)
1396 DO is = 1,
SIZE(ks_matrix, 1)
1399 row=irow, col=icol, block=ksblock, found=found)
1401 ksblock = ksblock - 0.5_dp*(dip_ket1*tb%pot%vdp(1, irow, 1) &
1402 + dip_ket2*tb%pot%vdp(2, irow, 1) &
1403 + dip_ket3*tb%pot%vdp(3, irow, 1) &
1404 + dip_bra1*tb%pot%vdp(1, icol, 1) &
1405 + dip_bra2*tb%pot%vdp(2, icol, 1) &
1406 + dip_bra3*tb%pot%vdp(3, icol, 1))
1412 IF (
ASSOCIATED(tb%quadbra))
THEN
1413 NULLIFY (nl_iterator)
1417 iatom=iatom, jatom=jatom, cell=cellind)
1418 icol = max(iatom, jatom)
1419 irow = min(iatom, jatom)
1421 NULLIFY (quad_bra1, quad_bra2, quad_bra3, quad_bra4, quad_bra5, quad_bra6)
1423 row=irow, col=icol, block=quad_bra1, found=found)
1426 row=irow, col=icol, block=quad_bra2, found=found)
1429 row=irow, col=icol, block=quad_bra3, found=found)
1432 row=irow, col=icol, block=quad_bra4, found=found)
1435 row=irow, col=icol, block=quad_bra5, found=found)
1438 row=irow, col=icol, block=quad_bra6, found=found)
1441 NULLIFY (quad_ket1, quad_ket2, quad_ket3, quad_ket4, quad_ket5, quad_ket6)
1443 row=irow, col=icol, block=quad_ket1, found=found)
1446 row=irow, col=icol, block=quad_ket2, found=found)
1449 row=irow, col=icol, block=quad_ket3, found=found)
1452 row=irow, col=icol, block=quad_ket4, found=found)
1455 row=irow, col=icol, block=quad_ket5, found=found)
1458 row=irow, col=icol, block=quad_ket6, found=found)
1461 DO is = 1,
SIZE(ks_matrix, 1)
1464 row=irow, col=icol, block=ksblock, found=found)
1467 ksblock = ksblock - 0.5_dp*(quad_ket1*tb%pot%vqp(1, irow, 1) &
1468 + quad_ket2*tb%pot%vqp(2, irow, 1) &
1469 + quad_ket3*tb%pot%vqp(3, irow, 1) &
1470 + quad_ket4*tb%pot%vqp(4, irow, 1) &
1471 + quad_ket5*tb%pot%vqp(5, irow, 1) &
1472 + quad_ket6*tb%pot%vqp(6, irow, 1) &
1473 + quad_bra1*tb%pot%vqp(1, icol, 1) &
1474 + quad_bra2*tb%pot%vqp(2, icol, 1) &
1475 + quad_bra3*tb%pot%vqp(3, icol, 1) &
1476 + quad_bra4*tb%pot%vqp(4, icol, 1) &
1477 + quad_bra5*tb%pot%vqp(5, icol, 1) &
1478 + quad_bra6*tb%pot%vqp(6, icol, 1))
1489 mark_used(dft_control)
1490 cpabort(
"Built without TBLITE")
1505#if defined(__TBLITE)
1507 CHARACTER(LEN=*),
PARAMETER :: routinen =
'tb_get_multipole'
1509 INTEGER :: ikind, jkind, iatom, jatom, icol, irow, iset, jset, ityp, jtyp
1510 INTEGER :: nkind, natom, handle, nimg, i, inda, indb
1511 INTEGER :: atom_a, atom_b, nseta, nsetb, ia, ib, ij
1514 REAL(kind=
dp),
DIMENSION(3) :: rij
1515 INTEGER,
DIMENSION(:),
POINTER :: la_max, lb_max
1516 INTEGER,
DIMENSION(:),
POINTER :: nsgfa, nsgfb
1517 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgfa, first_sgfb
1518 INTEGER,
ALLOCATABLE :: atom_of_kind(:)
1519 REAL(kind=
dp),
ALLOCATABLE :: stmp(:)
1520 REAL(kind=
dp),
ALLOCATABLE :: dtmp(:, :), qtmp(:, :), dtmpj(:, :), qtmpj(:, :)
1521 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: dip_ket1, dip_ket2, dip_ket3, &
1522 dip_bra1, dip_bra2, dip_bra3
1523 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: quad_ket1, quad_ket2, quad_ket3, &
1524 quad_ket4, quad_ket5, quad_ket6, &
1525 quad_bra1, quad_bra2, quad_bra3, &
1526 quad_bra4, quad_bra5, quad_bra6
1529 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_s
1535 DIMENSION(:),
POINTER :: nl_iterator
1537 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1539 CALL timeset(routinen, handle)
1542 NULLIFY (atomic_kind_set, qs_kind_set, sab_orb, particle_set)
1543 NULLIFY (dft_control, matrix_s)
1544 CALL get_qs_env(qs_env=qs_env, atomic_kind_set=atomic_kind_set, &
1545 qs_kind_set=qs_kind_set, &
1547 particle_set=particle_set, &
1548 dft_control=dft_control, &
1549 matrix_s_kp=matrix_s)
1550 natom =
SIZE(particle_set)
1551 nkind =
SIZE(atomic_kind_set)
1552 nimg = dft_control%nimages
1557 ALLOCATE (basis_set_list(nkind))
1560 ALLOCATE (stmp(msao(tb%calc%bas%maxl)**2))
1561 ALLOCATE (dtmp(dip_n, msao(tb%calc%bas%maxl)**2))
1562 ALLOCATE (qtmp(quad_n, msao(tb%calc%bas%maxl)**2))
1563 ALLOCATE (dtmpj(dip_n, msao(tb%calc%bas%maxl)**2))
1564 ALLOCATE (qtmpj(quad_n, msao(tb%calc%bas%maxl)**2))
1572 ALLOCATE (tb%dipbra(i)%matrix)
1573 ALLOCATE (tb%dipket(i)%matrix)
1574 CALL dbcsr_create(tb%dipbra(i)%matrix, template=matrix_s(1, 1)%matrix, &
1575 name=
"DIPOLE BRAMATRIX")
1576 CALL dbcsr_create(tb%dipket(i)%matrix, template=matrix_s(1, 1)%matrix, &
1577 name=
"DIPOLE KETMATRIX")
1582 ALLOCATE (tb%quadbra(i)%matrix)
1583 ALLOCATE (tb%quadket(i)%matrix)
1584 CALL dbcsr_create(tb%quadbra(i)%matrix, template=matrix_s(1, 1)%matrix, &
1585 name=
"QUADRUPOLE BRAMATRIX")
1586 CALL dbcsr_create(tb%quadket(i)%matrix, template=matrix_s(1, 1)%matrix, &
1587 name=
"QUADRUPOLE KETMATRIX")
1593 NULLIFY (nl_iterator)
1597 iatom=iatom, jatom=jatom, r=rij)
1599 r2 = norm2(rij(:))**2
1601 icol = max(iatom, jatom)
1602 irow = min(iatom, jatom)
1604 IF (icol == jatom)
THEN
1611 ityp = tb%mol%id(icol)
1612 jtyp = tb%mol%id(irow)
1614 NULLIFY (dip_bra1, dip_bra2, dip_bra3)
1616 row=irow, col=icol, block=dip_bra1, found=found)
1619 row=irow, col=icol, block=dip_bra2, found=found)
1622 row=irow, col=icol, block=dip_bra3, found=found)
1625 NULLIFY (dip_ket1, dip_ket2, dip_ket3)
1627 row=irow, col=icol, block=dip_ket1, found=found)
1630 row=irow, col=icol, block=dip_ket2, found=found)
1633 row=irow, col=icol, block=dip_ket3, found=found)
1636 NULLIFY (quad_bra1, quad_bra2, quad_bra3, quad_bra4, quad_bra5, quad_bra6)
1638 row=irow, col=icol, block=quad_bra1, found=found)
1641 row=irow, col=icol, block=quad_bra2, found=found)
1644 row=irow, col=icol, block=quad_bra3, found=found)
1647 row=irow, col=icol, block=quad_bra4, found=found)
1650 row=irow, col=icol, block=quad_bra5, found=found)
1653 row=irow, col=icol, block=quad_bra6, found=found)
1656 NULLIFY (quad_ket1, quad_ket2, quad_ket3, quad_ket4, quad_ket5, quad_ket6)
1658 row=irow, col=icol, block=quad_ket1, found=found)
1661 row=irow, col=icol, block=quad_ket2, found=found)
1664 row=irow, col=icol, block=quad_ket3, found=found)
1667 row=irow, col=icol, block=quad_ket4, found=found)
1670 row=irow, col=icol, block=quad_ket5, found=found)
1673 row=irow, col=icol, block=quad_ket6, found=found)
1677 basis_set_a => basis_set_list(ikind)%gto_basis_set
1678 IF (.NOT.
ASSOCIATED(basis_set_a)) cycle
1679 basis_set_b => basis_set_list(jkind)%gto_basis_set
1680 IF (.NOT.
ASSOCIATED(basis_set_b)) cycle
1681 atom_a = atom_of_kind(icol)
1682 atom_b = atom_of_kind(irow)
1684 first_sgfa => basis_set_a%first_sgf
1685 la_max => basis_set_a%lmax
1686 nseta = basis_set_a%nset
1687 nsgfa => basis_set_a%nsgf_set
1689 first_sgfb => basis_set_b%first_sgf
1690 lb_max => basis_set_b%lmax
1691 nsetb = basis_set_b%nset
1692 nsgfb => basis_set_b%nsgf_set
1695 IF (icol == irow)
THEN
1698 CALL multipole_cgto(tb%calc%bas%cgto(jset, ityp), tb%calc%bas%cgto(iset, ityp), &
1699 & r2, -rij, tb%calc%bas%intcut, stmp, dtmp, qtmp)
1701 DO inda = 1, nsgfa(iset)
1702 ia = first_sgfa(1, iset) - first_sgfa(1, 1) + inda
1703 DO indb = 1, nsgfb(jset)
1704 ib = first_sgfb(1, jset) - first_sgfb(1, 1) + indb
1705 ij = indb + nsgfb(jset)*(inda - 1)
1707 dip_ket1(ib, ia) = dtmp(1, ij)
1708 dip_ket2(ib, ia) = dtmp(2, ij)
1709 dip_ket3(ib, ia) = dtmp(3, ij)
1711 quad_ket1(ib, ia) = qtmp(1, ij)
1712 quad_ket2(ib, ia) = qtmp(2, ij)
1713 quad_ket3(ib, ia) = qtmp(3, ij)
1714 quad_ket4(ib, ia) = qtmp(4, ij)
1715 quad_ket5(ib, ia) = qtmp(5, ij)
1716 quad_ket6(ib, ia) = qtmp(6, ij)
1718 dip_bra1(ib, ia) = dtmp(1, ij)
1719 dip_bra2(ib, ia) = dtmp(2, ij)
1720 dip_bra3(ib, ia) = dtmp(3, ij)
1722 quad_bra1(ib, ia) = qtmp(1, ij)
1723 quad_bra2(ib, ia) = qtmp(2, ij)
1724 quad_bra3(ib, ia) = qtmp(3, ij)
1725 quad_bra4(ib, ia) = qtmp(4, ij)
1726 quad_bra5(ib, ia) = qtmp(5, ij)
1727 quad_bra6(ib, ia) = qtmp(6, ij)
1735 CALL multipole_cgto(tb%calc%bas%cgto(jset, jtyp), tb%calc%bas%cgto(iset, ityp), &
1736 & r2, -rij, tb%calc%bas%intcut, stmp, dtmp, qtmp)
1737 CALL multipole_cgto(tb%calc%bas%cgto(iset, ityp), tb%calc%bas%cgto(jset, jtyp), &
1738 & r2, rij, tb%calc%bas%intcut, stmp, dtmpj, qtmpj)
1740 DO inda = 1, nsgfa(iset)
1741 ia = first_sgfa(1, iset) - first_sgfa(1, 1) + inda
1742 DO indb = 1, nsgfb(jset)
1743 ib = first_sgfb(1, jset) - first_sgfb(1, 1) + indb
1745 ij = indb + nsgfb(jset)*(inda - 1)
1747 dip_bra1(ib, ia) = dtmp(1, ij)
1748 dip_bra2(ib, ia) = dtmp(2, ij)
1749 dip_bra3(ib, ia) = dtmp(3, ij)
1751 quad_bra1(ib, ia) = qtmp(1, ij)
1752 quad_bra2(ib, ia) = qtmp(2, ij)
1753 quad_bra3(ib, ia) = qtmp(3, ij)
1754 quad_bra4(ib, ia) = qtmp(4, ij)
1755 quad_bra5(ib, ia) = qtmp(5, ij)
1756 quad_bra6(ib, ia) = qtmp(6, ij)
1758 ij = inda + nsgfa(iset)*(indb - 1)
1760 dip_ket1(ib, ia) = dtmpj(1, ij)
1761 dip_ket2(ib, ia) = dtmpj(2, ij)
1762 dip_ket3(ib, ia) = dtmpj(3, ij)
1764 quad_ket1(ib, ia) = qtmpj(1, ij)
1765 quad_ket2(ib, ia) = qtmpj(2, ij)
1766 quad_ket3(ib, ia) = qtmpj(3, ij)
1767 quad_ket4(ib, ia) = qtmpj(4, ij)
1768 quad_ket5(ib, ia) = qtmpj(5, ij)
1769 quad_ket6(ib, ia) = qtmpj(6, ij)
1787 DEALLOCATE (basis_set_list)
1789 CALL timestop(handle)
1794 cpabort(
"Built without TBLITE")
1810 SUBROUTINE contract_dens(p_matrix, bra_mat, ket_mat, output, para_env)
1812 TYPE(
dbcsr_type),
POINTER :: bra_mat, ket_mat
1813 REAL(kind=
dp),
DIMENSION(:),
INTENT(INOUT) :: output
1816 CHARACTER(len=*),
PARAMETER :: routinen =
'contract_dens'
1818 INTEGER :: handle, i, iblock_col, iblock_row, &
1821 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: bra, ket, p_block
1824 CALL timeset(routinen, handle)
1826 nspin =
SIZE(p_matrix)
1831 NULLIFY (p_block, bra, ket)
1835 row=iblock_row, col=iblock_col, block=p_block, found=found)
1836 IF (.NOT. found) cycle
1838 row=iblock_row, col=iblock_col, block=ket, found=found)
1839 IF (.NOT. found) cpabort(
"missing block")
1841 IF (.NOT. (
ASSOCIATED(bra) .AND.
ASSOCIATED(p_block))) cycle
1842 DO j = 1,
SIZE(p_block, 1)
1843 DO i = 1,
SIZE(p_block, 2)
1844 output(iblock_row) = output(iblock_row) + p_block(j, i)*ket(j, i)
1847 IF (iblock_col /= iblock_row)
THEN
1848 DO j = 1,
SIZE(p_block, 1)
1849 DO i = 1,
SIZE(p_block, 2)
1850 output(iblock_col) = output(iblock_col) + p_block(j, i)*bra(j, i)
1858 CALL para_env%sum(output)
1859 CALL timestop(handle)
1861 END SUBROUTINE contract_dens
1871 SUBROUTINE tb_grad2force(qs_env, tb, para_env, ityp)
1878 CHARACTER(len=*),
PARAMETER :: routinen =
'tb_grad2force'
1880 INTEGER :: atoma, handle, iatom, ikind, natom
1881 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: atom_of_kind, kind_of
1886 CALL timeset(routinen, handle)
1888 NULLIFY (force, atomic_kind_set)
1889 CALL get_qs_env(qs_env=qs_env, force=force, particle_set=particle_set, &
1890 atomic_kind_set=atomic_kind_set)
1892 atom_of_kind=atom_of_kind, kind_of=kind_of)
1894 natom =
SIZE(particle_set)
1898 cpabort(
"unknown force type")
1901 ikind = kind_of(iatom)
1902 atoma = atom_of_kind(iatom)
1903 force(ikind)%all_potential(:, atoma) = &
1904 force(ikind)%all_potential(:, atoma) + tb%grad(:, iatom)/para_env%num_pe
1908 ikind = kind_of(iatom)
1909 atoma = atom_of_kind(iatom)
1910 force(ikind)%repulsive(:, atoma) = &
1911 force(ikind)%repulsive(:, atoma) + tb%grad(:, iatom)/para_env%num_pe
1915 ikind = kind_of(iatom)
1916 atoma = atom_of_kind(iatom)
1917 force(ikind)%dispersion(:, atoma) = &
1918 force(ikind)%dispersion(:, atoma) + tb%grad(:, iatom)/para_env%num_pe
1922 ikind = kind_of(iatom)
1923 atoma = atom_of_kind(iatom)
1924 force(ikind)%rho_elec(:, atoma) = &
1925 force(ikind)%rho_elec(:, atoma) + tb%grad(:, iatom)/para_env%num_pe
1929 ikind = kind_of(iatom)
1930 atoma = atom_of_kind(iatom)
1931 force(ikind)%overlap(:, atoma) = &
1932 force(ikind)%overlap(:, atoma) + tb%grad(:, iatom)/para_env%num_pe
1936 ikind = kind_of(iatom)
1937 atoma = atom_of_kind(iatom)
1938 force(ikind)%efield(:, atoma) = &
1939 force(ikind)%efield(:, atoma) + tb%grad(:, iatom)/para_env%num_pe
1943 CALL timestop(handle)
1945 END SUBROUTINE tb_grad2force
1952 SUBROUTINE tb_zero_force(qs_env)
1956 INTEGER :: iatom, ikind, natom
1957 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: kind_of
1962 NULLIFY (force, atomic_kind_set)
1963 CALL get_qs_env(qs_env=qs_env, force=force, particle_set=particle_set, &
1964 atomic_kind_set=atomic_kind_set)
1968 natom =
SIZE(particle_set)
1971 ikind = kind_of(iatom)
1972 force(ikind)%all_potential = 0.0_dp
1973 force(ikind)%repulsive = 0.0_dp
1974 force(ikind)%dispersion = 0.0_dp
1975 force(ikind)%rho_elec = 0.0_dp
1976 force(ikind)%overlap = 0.0_dp
1977 force(ikind)%efield = 0.0_dp
1980 END SUBROUTINE tb_zero_force
1991 LOGICAL,
INTENT(IN) :: use_rho
1992 INTEGER,
INTENT(IN) :: nimg
1994#if defined(__TBLITE)
1995 INTEGER :: i, iatom, ic, ikind, ind, is, ish, &
1997 INTEGER,
DIMENSION(3) :: cellind
1998 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
2000 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: de
2001 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: pblock
2002 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_p
2006 DIMENSION(:),
POINTER :: nl_iterator
2014 NULLIFY (scf_env, rho, tb, sab_orb, para_env, kpoints)
2015 CALL get_qs_env(qs_env=qs_env, scf_env=scf_env, rho=rho, tb_tblite=tb, &
2016 sab_orb=sab_orb, para_env=para_env, kpoints=kpoints)
2018 NULLIFY (cell_to_index)
2027 matrix_p => scf_env%p_mix_new
2030 ALLOCATE (de(tb%mol%nat))
2034 NULLIFY (nl_iterator)
2038 iatom=iatom, jatom=jatom, cell=cellind)
2040 IF (iatom /= jatom) cycle
2042 IF (ikind /= jkind) cpabort(
"Type wrong")
2044 is = tb%calc%bas%ish_at(iatom)
2049 ic = cell_to_index(cellind(1), cellind(2), cellind(3))
2053 IF (cellind(1) /= 0) cycle
2054 IF (cellind(2) /= 0) cycle
2055 IF (cellind(3) /= 0) cycle
2058 row=iatom, col=jatom, block=pblock, found=found)
2060 IF (.NOT. found) cpabort(
"block not found")
2063 DO ish = 1, tb%calc%bas%nsh_id(ikind)
2064 DO i = 1, msao(tb%calc%bas%cgto(ish, ikind)%ang)
2066 de(iatom) = de(iatom) + tb%dsedcn(is + ish)*pblock(ind, ind)
2071 CALL para_env%sum(de)
2074 CALL tb_add_grad(tb%grad, tb%dcndr, de, tb%mol%nat)
2075 IF (tb%use_virial)
CALL tb_add_sig(tb%sigma, tb%dcndL, de, tb%mol%nat)
2076 CALL tb_grad2force(qs_env, tb, para_env, 4)
2083 cpabort(
"Built without TBLITE")
2097 LOGICAL,
INTENT(IN) :: use_rho
2098 INTEGER,
INTENT(IN) :: nimg
2100#if defined(__TBLITE)
2101 INTEGER :: i, ij, iatom, ic, icol, ikind, ni, nj, nkind, nel, &
2102 sgfi, sgfj, ityp, jatom, jkind, jrow, jtyp, iset, jset, &
2103 nseti, nsetj, ia, ib, inda, indb
2104 INTEGER,
DIMENSION(3) :: cellind
2105 INTEGER,
DIMENSION(:),
POINTER :: nsgfa, nsgfb
2106 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgfa, first_sgfb
2107 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
2109 REAL(kind=
dp) :: r2, dr, itemp, jtemp, rr, hij, shpoly, dshpoly, idhdc, jdhdc, &
2110 scal, hp, i_a_shift, j_a_shift, ishift, jshift
2111 REAL(kind=
dp),
DIMENSION(3) :: rij, dgrad
2112 REAL(kind=
dp),
DIMENSION(3, 3) :: hsigma
2113 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: de, t_ov, idip, jdip, iquad, jquad
2114 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: t_dip, t_quad, t_d_ov
2115 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: t_i_dip, t_i_quad, t_j_dip, t_j_quad
2116 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: pblock, wblock
2119 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_p, matrix_w
2125 DIMENSION(:),
POINTER :: nl_iterator
2128 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
2131 TYPE(tb_hamiltonian),
POINTER :: h0
2135 NULLIFY (scf_env, rho, tb, sab_orb, para_env, kpoints, matrix_w)
2137 atomic_kind_set=atomic_kind_set, &
2142 para_env=para_env, &
2143 qs_kind_set=qs_kind_set, &
2145 matrix_w_kp=matrix_w)
2147 NULLIFY (cell_to_index)
2158 matrix_p => scf_env%p_mix_new
2162 nkind =
SIZE(atomic_kind_set)
2163 ALLOCATE (basis_set_list(nkind))
2166 ALLOCATE (de(tb%mol%nat))
2168 nel = msao(tb%calc%bas%maxl)**2
2169 ALLOCATE (t_ov(nel))
2170 ALLOCATE (t_d_ov(3, nel))
2171 ALLOCATE (t_dip(dip_n, nel))
2172 ALLOCATE (t_i_dip(3, dip_n, nel), t_j_dip(3, dip_n, nel))
2173 ALLOCATE (t_quad(quad_n, nel))
2174 ALLOCATE (t_i_quad(3, quad_n, nel), t_j_quad(3, quad_n, nel))
2176 ALLOCATE (idip(dip_n), jdip(dip_n))
2177 ALLOCATE (iquad(quad_n), jquad(quad_n))
2183 NULLIFY (nl_iterator)
2187 iatom=iatom, jatom=jatom, r=rij, cell=cellind)
2189 icol = max(iatom, jatom)
2190 jrow = min(iatom, jatom)
2192 IF (icol == jatom)
THEN
2199 ityp = tb%mol%id(icol)
2200 jtyp = tb%mol%id(jrow)
2202 r2 = dot_product(rij, rij)
2204 IF (icol == jrow .AND. dr < same_atom) cycle
2205 rr = sqrt(dr/(h0%rad(ikind) + h0%rad(jkind)))
2208 basis_set_a => basis_set_list(ikind)%gto_basis_set
2209 IF (.NOT.
ASSOCIATED(basis_set_a)) cycle
2210 first_sgfa => basis_set_a%first_sgf
2211 nsgfa => basis_set_a%nsgf_set
2212 nseti = basis_set_a%nset
2213 basis_set_b => basis_set_list(jkind)%gto_basis_set
2214 IF (.NOT.
ASSOCIATED(basis_set_b)) cycle
2215 first_sgfb => basis_set_b%first_sgf
2216 nsgfb => basis_set_b%nsgf_set
2217 nsetj = basis_set_b%nset
2222 ic = cell_to_index(cellind(1), cellind(2), cellind(3))
2228 row=jrow, col=icol, block=pblock, found=found)
2229 IF (.NOT. found) cpabort(
"pblock not found")
2233 row=jrow, col=icol, block=wblock, found=found)
2236 i_a_shift = tb%pot%vat(icol, 1)
2237 j_a_shift = tb%pot%vat(jrow, 1)
2238 idip(:) = tb%pot%vdp(:, icol, 1)
2239 jdip(:) = tb%pot%vdp(:, jrow, 1)
2240 iquad(:) = tb%pot%vqp(:, icol, 1)
2241 jquad(:) = tb%pot%vqp(:, jrow, 1)
2243 ni = tb%calc%bas%ish_at(icol)
2245 sgfi = first_sgfa(1, iset)
2246 ishift = i_a_shift + tb%pot%vsh(ni + iset, 1)
2247 nj = tb%calc%bas%ish_at(jrow)
2249 sgfj = first_sgfb(1, jset)
2250 jshift = j_a_shift + tb%pot%vsh(nj + jset, 1)
2253 CALL multipole_grad_cgto(tb%calc%bas%cgto(iset, ityp), tb%calc%bas%cgto(jset, jtyp), &
2254 & r2, rij, tb%calc%bas%intcut, t_ov, t_dip, t_quad, t_d_ov, t_i_dip, t_i_quad, &
2255 & t_j_dip, t_j_quad)
2257 shpoly = (1.0_dp + h0%shpoly(iset, ikind)*rr) &
2258 *(1.0_dp + h0%shpoly(jset, jkind)*rr)
2259 dshpoly = ((1.0_dp + h0%shpoly(iset, ikind)*rr)*h0%shpoly(jset, jkind)*rr &
2260 + (1.0_dp + h0%shpoly(jset, jkind)*rr)*h0%shpoly(iset, ikind)*rr) &
2262 scal = h0%hscale(iset, jset, ikind, jkind)
2263 hij = 0.5_dp*(tb%selfenergy(ni + iset) + tb%selfenergy(nj + jset))*scal
2265 idhdc = tb%dsedcn(ni + iset)*shpoly*scal
2266 jdhdc = tb%dsedcn(nj + jset)*shpoly*scal
2271 DO inda = 1, nsgfa(iset)
2272 ia = first_sgfa(1, iset) - first_sgfa(1, 1) + inda
2273 DO indb = 1, nsgfb(jset)
2274 ib = first_sgfb(1, jset) - first_sgfb(1, 1) + indb
2276 ij = inda + nsgfa(iset)*(indb - 1)
2278 itemp = itemp + idhdc*pblock(ib, ia)*t_ov(ij)
2279 jtemp = jtemp + jdhdc*pblock(ib, ia)*t_ov(ij)
2281 hp = 2*hij*pblock(ib, ia)
2282 dgrad(:) = dgrad(:) &
2283 - (ishift + jshift)*pblock(ib, ia)*t_d_ov(:, ij) &
2284 - 2*wblock(ib, ia)*t_d_ov(:, ij) &
2285 + hp*shpoly*t_d_ov(:, ij) &
2286 + hp*dshpoly*t_ov(ij)*rij &
2287 - pblock(ib, ia)*( &
2288 matmul(t_i_dip(:, :, ij), idip) &
2289 + matmul(t_j_dip(:, :, ij), jdip) &
2290 + matmul(t_i_quad(:, :, ij), iquad) &
2291 + matmul(t_j_quad(:, :, ij), jquad))
2295 de(icol) = de(icol) + itemp
2296 de(jrow) = de(jrow) + jtemp
2297 tb%grad(:, icol) = tb%grad(:, icol) - dgrad
2298 tb%grad(:, jrow) = tb%grad(:, jrow) + dgrad
2299 IF (tb%use_virial)
THEN
2300 IF (icol == jrow)
THEN
2303 hsigma(ia, ib) = hsigma(ia, ib) + 0.25_dp*(rij(ia)*dgrad(ib) + rij(ib)*dgrad(ia))
2309 hsigma(ia, ib) = hsigma(ia, ib) + 0.50_dp*(rij(ia)*dgrad(ib) + rij(ib)*dgrad(ia))
2319 CALL para_env%sum(hsigma)
2320 CALL para_env%sum(de)
2321 CALL para_env%sum(tb%grad)
2323 CALL tb_add_grad(tb%grad, tb%dcndr, de, tb%mol%nat)
2324 CALL tb_grad2force(qs_env, tb, para_env, 4)
2326 tb%sigma = tb%sigma + hsigma
2327 IF (tb%use_virial)
CALL tb_add_sig(tb%sigma, tb%dcndL, de, tb%mol%nat)
2330 DEALLOCATE (basis_set_list)
2331 DEALLOCATE (t_ov, t_d_ov)
2332 DEALLOCATE (t_dip, t_i_dip, t_j_dip)
2333 DEALLOCATE (t_quad, t_i_quad, t_j_quad)
2334 DEALLOCATE (idip, jdip, iquad, jquad)
2336 IF (tb%use_virial)
CALL tb_add_stress(qs_env, tb, para_env)
2342 cpabort(
"Built without TBLITE")
2353 SUBROUTINE tb_add_stress(qs_env, tb, para_env)
2362 NULLIFY (virial, cell)
2363 CALL get_qs_env(qs_env=qs_env, virial=virial, cell=cell)
2365 virial%pv_virial = virial%pv_virial - tb%sigma/para_env%num_pe
2367 END SUBROUTINE tb_add_stress
2376 SUBROUTINE tb_add_grad(grad, deriv, dE, natom)
2378 REAL(kind=
dp),
DIMENSION(:, :) :: grad
2379 REAL(kind=
dp),
DIMENSION(:, :, :) :: deriv
2380 REAL(kind=
dp),
DIMENSION(:) :: de
2387 grad(:, i) = grad(:, i) + deriv(:, i, j)*de(j)
2391 END SUBROUTINE tb_add_grad
2400 SUBROUTINE tb_add_sig(sig, deriv, dE, natom)
2402 REAL(kind=
dp),
DIMENSION(:, :) :: sig
2403 REAL(kind=
dp),
DIMENSION(:, :, :) :: deriv
2404 REAL(kind=
dp),
DIMENSION(:) :: de
2411 sig(:, i) = sig(:, i) + deriv(:, i, j)*de(j)
2415 END SUBROUTINE tb_add_sig
Set of routines to: Contract integrals over primitive Gaussians Decontract (density) matrices Trace m...
Calculation of the overlap integrals over Cartesian Gaussian-type functions.
subroutine, public overlap_ab(la_max, la_min, npgfa, rpgfa, zeta, lb_max, lb_min, npgfb, rpgfb, zetb, rab, sab, dab, ddab)
Calculation of the two-center overlap integrals [a|b] over Cartesian Gaussian-type functions....
Define the atomic kind types and their sub types.
subroutine, public get_atomic_kind_set(atomic_kind_set, atom_of_kind, kind_of, natom_of_kind, maxatom, natom, nshell, fist_potential_present, shell_present, shell_adiabatic, shell_check_distance, damping_present)
Get attributes of an atomic kind set.
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.
Holds information on atomic properties.
subroutine, public process_gto_basis(gto_basis_set, do_ortho, nset, maxl)
...
subroutine, public allocate_gto_basis_set(gto_basis_set)
...
subroutine, public write_gto_basis_set(gto_basis_set, output_unit, header)
Write a Gaussian-type orbital (GTO) basis set data set to the output unit.
Handles all functions related to the CELL.
subroutine, public get_cell(cell, alpha, beta, gamma, deth, orthorhombic, abc, periodic, h, h_inv, symmetry_id, tag)
Get informations about a simulation cell.
methods related to the blacs parallel environment
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
subroutine, public dbcsr_iterator_next_block(iterator, row, column, block, block_number_argument_has_been_removed, row_size, col_size, row_offset, col_offset)
...
logical function, public dbcsr_iterator_blocks_left(iterator)
...
subroutine, public dbcsr_iterator_stop(iterator)
...
subroutine, public dbcsr_get_block_p(matrix, row, col, block, found, row_size, col_size)
...
subroutine, public dbcsr_finalize(matrix)
...
subroutine, public dbcsr_iterator_start(iterator, matrix, shared, dynamic, dynamic_byrows)
...
subroutine, public dbcsr_add(matrix_a, matrix_b, alpha_scalar, beta_scalar)
...
subroutine, public dbcsr_print(matrix, variable_name, unit_nr)
Prints given matrix in matlab format (only present blocks).
Routines that link DBCSR and CP2K concepts together.
subroutine, public cp_dbcsr_alloc_block_from_nbl(matrix, sab_orb, desymmetrize)
allocate the blocks of a dbcsr based on the neighbor list
DBCSR operations in CP2K.
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 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...
Defines the basic variable types.
integer, parameter, public dp
integer, parameter, public default_string_length
Types and basic routines needed for a kpoint calculation.
subroutine, public get_kpoint_info(kpoint, kp_scheme, nkp_grid, kp_shift, symmetry, verbose, full_grid, use_real_wfn, eps_geo, parallel_group_size, kp_range, nkp, xkp, wkp, para_env, blacs_env_all, para_env_kp, para_env_inter_kp, blacs_env, kp_env, kp_aux_env, mpools, iogrp, nkp_groups, kp_dist, cell_to_index, index_to_cell, sab_nl, sab_nl_nosym)
Retrieve information from a kpoint environment.
Utility routines for the memory handling.
Interface to the message passing library MPI.
compute mulliken charges we (currently) define them as c_i = 1/2 [ (PS)_{ii} + (SP)_{ii} ]
Provides Cartesian and spherical orbital pointers and indices.
integer, dimension(:), allocatable, public ncoset
Define the data structure for the particle information.
subroutine, public charge_mixing(mixing_method, mixing_store, charges, para_env, iter_count)
Driver for the charge mixing, calls the proper routine given the requested method.
Calculation of overlap matrix condition numbers.
subroutine, public overlap_condnum(matrixkp_s, condnum, iunit, norml1, norml2, use_arnoldi, blacs_env)
Calculation of the overlap matrix Condition Number.
subroutine, public get_qs_env(qs_env, atomic_kind_set, qs_kind_set, cell, super_cell, cell_ref, use_ref_cell, kpoints, dft_control, mos, sab_orb, sab_all, qmmm, qmmm_periodic, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, rhoz_cneo_set, ecoul_1c, rho0_s_rs, rho0_s_gs, rhoz_cneo_s_rs, rhoz_cneo_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, lri_env, lri_density, exstate_env, ec_env, harris_env, dispersion_env, gcp_env, vee, rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, wanniercentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs, do_rixs, tb_tblite)
Get the QUICKSTEP environment.
Some utility functions for the calculation of integrals.
subroutine, public basis_set_list_setup(basis_set_list, basis_type, qs_kind_set)
Set up an easy accessible list of the basis sets for all kinds.
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 get_qs_kind_set(qs_kind_set, all_potential_present, tnadd_potential_present, gth_potential_present, sgp_potential_present, paw_atom_present, dft_plus_u_atom_present, maxcgf, maxsgf, maxco, maxco_proj, maxgtops, maxlgto, maxlprj, maxnset, maxsgf_set, ncgf, npgf, nset, nsgf, nshell, maxpol, maxlppl, maxlppnl, maxppnl, nelectron, maxder, max_ngrid_rad, max_sph_harm, maxg_iso_not0, lmax_rho0, basis_rcut, basis_type, total_zeff_corr, npgf_seg, cneo_potential_present, nkind_q, natom_q)
Get attributes of an atomic kind set.
subroutine, public set_ks_env(ks_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, complex_ks, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, kinetic, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_ks_im_kp, vppl, rho_core, rho_nlcc, rho_nlcc_g, vee, neighbor_list_id, kpoints, sab_orb, sab_all, sac_ae, sac_ppl, sac_lri, sap_ppnl, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_vdw, sab_scp, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, task_list, task_list_soft, subsys, dft_control, dbcsr_dist, distribution_2d, pw_env, para_env, blacs_env)
...
Define the neighbor list data types and the corresponding functionality.
subroutine, public neighbor_list_iterator_create(iterator_set, nl, search, nthread)
Neighbor list iterator functions.
subroutine, public neighbor_list_iterator_release(iterator_set)
...
integer function, public neighbor_list_iterate(iterator_set, mepos)
...
subroutine, public get_iterator_info(iterator_set, mepos, ikind, jkind, nkind, ilist, nlist, inode, nnode, iatom, jatom, r, cell)
...
Calculation of overlap matrix, its derivatives and forces.
superstucture that hold various representations of the density and keeps track of which ones are vali...
subroutine, public qs_rho_get(rho_struct, rho_ao, rho_ao_im, rho_ao_kp, rho_ao_im_kp, rho_r, drho_r, rho_g, drho_g, tau_r, tau_g, rho_r_valid, drho_r_valid, rho_g_valid, drho_g_valid, tau_r_valid, tau_g_valid, tot_rho_r, tot_rho_g, rho_r_sccs, soft_valid, complex_rho_ao)
returns info about the density described by this object. If some representation is not available an e...
module that contains the definitions of the scf types
Utilities for string manipulations.
subroutine, public integer_to_string(inumber, string)
Converts an integer number to a string. The WRITE statement will return an error message,...
subroutine, public tb_set_calculator(tb, typ)
...
subroutine, public tb_ham_add_coulomb(qs_env, tb, dft_control)
...
subroutine, public tb_init_wf(tb)
initialize wavefunction ...
subroutine, public tb_derive_dh_diag(qs_env, use_rho, nimg)
compute the derivative of the energy
subroutine, public tb_update_charges(qs_env, dft_control, tb, calculate_forces, use_rho)
...
subroutine, public tb_init_geometry(qs_env, tb)
intialize geometry objects ...
subroutine, public build_tblite_matrices(qs_env, calculate_forces)
...
subroutine, public tb_get_energy(qs_env, tb, energy)
...
subroutine, public tb_derive_dh_off(qs_env, use_rho, nimg)
compute the derivative of the energy
subroutine, public tb_get_multipole(qs_env, tb)
...
subroutine, public tb_get_basis(tb, gto_basis_set, element_symbol, param, occ)
...
subroutine, public allocate_tblite_type(tb_tblite)
...
subroutine, public deallocate_tblite_type(tb_tblite)
...
Definition of the xTB parameter types.
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)
...
Provides all information about an atomic kind.
type for the atomic properties
Type defining parameters related to the simulation cell.
represent a blacs multidimensional parallel environment (for the mpi corrispective see cp_paratypes/m...
type of a logger, at the moment it contains just a print level starting at which level it should be l...
Contains information about kpoints.
stores all the informations relevant to an mpi environment
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.