24 dbcsr_type, dbcsr_type_antisymmetric, dbcsr_type_symmetric
76#include "./base/base_uses.f90"
80 INTEGER,
DIMENSION(16),
PARAMETER ::
orbptr = (/0, 1, 1, 1, &
81 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3/)
85 CHARACTER(len=*),
PARAMETER,
PRIVATE :: modulen =
'qs_dftb_matrices'
101 LOGICAL,
INTENT(IN) :: calculate_forces
103 CHARACTER(LEN=*),
PARAMETER :: routinen =
'build_dftb_matrices'
105 INTEGER :: after, atom_a, atom_b, handle, i, iatom, ic, icol, ikind, img, irow, iw, jatom, &
106 jkind, l1, l2, la, lb, llm, lmaxi, lmaxj, m, n1, n2, n_urpoly, natorb_a, natorb_b, &
107 nderivatives, ngrd, ngrdcut, nimg, nkind, spdim
108 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: atom_of_kind
109 INTEGER,
DIMENSION(3) :: cell
110 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
111 LOGICAL :: defined, found, omit_headers, use_virial
112 REAL(kind=
dp) :: ddr, dgrd, dr, erep, erepij, f0, foab, &
114 REAL(kind=
dp),
DIMENSION(0:3) :: eta_a, eta_b, skself
115 REAL(kind=
dp),
DIMENSION(10) :: urep
116 REAL(kind=
dp),
DIMENSION(2) :: surr
117 REAL(kind=
dp),
DIMENSION(3) :: drij, force_ab, force_rr, force_w, rij, &
119 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: dfblock, dsblock, fblock, fmatij, &
120 fmatji, pblock, sblock, scoeff, &
121 smatij, smatji, spxr, wblock
126 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_h, matrix_p, matrix_s, matrix_w
131 DIMENSION(:),
POINTER :: nl_iterator
137 POINTER :: dftb_potential
141 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
146 CALL timeset(routinen, handle)
153 DO l1 = 0, max(la, lb)
154 DO l2 = 0, min(l1, la, lb)
157 iptr(l1, l2, m, la, lb) = llm
164 NULLIFY (logger, virial, atprop)
167 NULLIFY (matrix_h, matrix_s, matrix_p, matrix_w, atomic_kind_set, &
168 qs_kind_set, sab_orb, ks_env)
172 atomic_kind_set=atomic_kind_set, &
173 qs_kind_set=qs_kind_set, &
174 matrix_h_kp=matrix_h, &
175 matrix_s_kp=matrix_s, &
177 dft_control=dft_control, &
180 dftb_control => dft_control%qs_control%dftb_control
181 nimg = dft_control%nimages
183 CALL get_qs_env(qs_env=qs_env, sab_orb=sab_orb)
185 IF (dftb_control%self_consistent .AND. calculate_forces) nderivatives = 1
186 CALL setup_matrices2(qs_env, nderivatives, nimg, matrix_s,
"OVERLAP", sab_orb)
187 CALL setup_matrices2(qs_env, 0, nimg, matrix_h,
"CORE HAMILTONIAN", sab_orb)
191 NULLIFY (dftb_potential)
192 CALL get_qs_env(qs_env=qs_env, dftb_potential=dftb_potential)
193 NULLIFY (particle_set)
194 CALL get_qs_env(qs_env=qs_env, particle_set=particle_set)
196 IF (calculate_forces)
THEN
197 NULLIFY (rho, force, matrix_w)
200 matrix_w_kp=matrix_w, &
205 IF (
SIZE(matrix_p, 1) == 2)
THEN
207 CALL dbcsr_add(matrix_p(1, img)%matrix, matrix_p(2, img)%matrix, &
208 alpha_scalar=1.0_dp, beta_scalar=1.0_dp)
209 CALL dbcsr_add(matrix_w(1, img)%matrix, matrix_w(2, img)%matrix, &
210 alpha_scalar=1.0_dp, beta_scalar=1.0_dp)
214 use_virial = virial%pv_availability .AND. (.NOT. virial%pv_numer)
217 IF (atprop%energy)
THEN
221 NULLIFY (cell_to_index)
223 CALL get_ks_env(ks_env=ks_env, kpoints=kpoints)
229 nkind =
SIZE(atomic_kind_set)
234 iatom=iatom, jatom=jatom, r=rij, cell=cell)
235 CALL get_qs_kind(qs_kind_set(ikind), dftb_parameter=dftb_kind_a)
237 defined=defined, lmax=lmaxi, skself=skself, &
238 eta=eta_a, natorb=natorb_a)
239 IF (.NOT. defined .OR. natorb_a < 1) cycle
240 CALL get_qs_kind(qs_kind_set(jkind), dftb_parameter=dftb_kind_b)
242 defined=defined, lmax=lmaxj, eta=eta_b, natorb=natorb_b)
244 IF (.NOT. defined .OR. natorb_b < 1) cycle
247 dftb_param_ij => dftb_potential(ikind, jkind)
248 dftb_param_ji => dftb_potential(jkind, ikind)
250 ngrd = dftb_param_ij%ngrd
251 ngrdcut = dftb_param_ij%ngrdcut
252 dgrd = dftb_param_ij%dgrd
254 cpassert(dftb_param_ij%llm == dftb_param_ji%llm)
255 llm = dftb_param_ij%llm
256 fmatij => dftb_param_ij%fmat
257 smatij => dftb_param_ij%smat
258 fmatji => dftb_param_ji%fmat
259 smatji => dftb_param_ji%smat
261 n_urpoly = dftb_param_ij%n_urpoly
262 urep_cut = dftb_param_ij%urep_cut
263 urep = dftb_param_ij%urep
264 spxr => dftb_param_ij%spxr
265 scoeff => dftb_param_ij%scoeff
266 spdim = dftb_param_ij%spdim
267 s_cut = dftb_param_ij%s_cut
268 srep = dftb_param_ij%srep
269 surr = dftb_param_ij%surr
271 dr = sqrt(sum(rij(:)**2))
272 IF (nint(dr/dgrd) <= ngrdcut)
THEN
277 ic = cell_to_index(cell(1), cell(2), cell(3))
281 icol = max(iatom, jatom)
282 irow = min(iatom, jatom)
283 NULLIFY (sblock, fblock)
285 row=irow, col=icol, block=sblock, found=found)
288 row=irow, col=icol, block=fblock, found=found)
291 IF (calculate_forces)
THEN
294 row=irow, col=icol, block=pblock, found=found)
295 cpassert(
ASSOCIATED(pblock))
298 row=irow, col=icol, block=wblock, found=found)
299 cpassert(
ASSOCIATED(wblock))
300 IF (dftb_control%self_consistent)
THEN
302 NULLIFY (dsblocks(i)%block)
304 row=irow, col=icol, block=dsblocks(i)%block, found=found)
310 IF (iatom == jatom .AND. dr < 0.001_dp)
THEN
313 sblock(i, i) = sblock(i, i) + 1._dp
314 fblock(i, i) = fblock(i, i) + skself(
orbptr(i))
319 llm, lmaxi, lmaxj, irow, iatom)
321 llm, lmaxi, lmaxj, irow, iatom)
322 IF (calculate_forces)
THEN
330 IF (irow == iatom) f0 = -1.0_dp
332 ALLOCATE (dfblock(n1, n2), dsblock(n1, n2))
336 dfblock = 0._dp; dsblock = 0._dp
338 drij(i) = rij(i) - ddr*f0
340 llm, lmaxi, lmaxj, irow, iatom)
342 llm, lmaxi, lmaxj, irow, iatom)
347 drij(i) = rij(i) + ddr*f0
349 llm, lmaxi, lmaxj, irow, iatom)
351 llm, lmaxi, lmaxj, irow, iatom)
353 dfblock = dfblock/(2.0_dp*ddr)
354 dsblock = dsblock/(2.0_dp*ddr)
356 foab = 2.0_dp*sum(dfblock*pblock)
357 fow = -2.0_dp*sum(dsblock*wblock)
359 force_ab(i) = force_ab(i) + foab
360 force_w(i) = force_w(i) + fow
361 IF (dftb_control%self_consistent)
THEN
362 cpassert(
ASSOCIATED(dsblocks(i + 1)%block))
363 dsblocks(i + 1)%block = dsblocks(i + 1)%block + dsblock
367 IF (iatom == jatom) f0 = 0.5_dp*f0
371 DEALLOCATE (dfblock, dsblock)
375 IF (calculate_forces .AND. (iatom /= jatom .OR. dr > 0.001_dp))
THEN
376 atom_a = atom_of_kind(iatom)
377 atom_b = atom_of_kind(jatom)
378 IF (irow == iatom) force_ab = -force_ab
379 IF (irow == iatom) force_w = -force_w
380 force(ikind)%all_potential(:, atom_a) = force(ikind)%all_potential(:, atom_a) - force_ab(:)
381 force(jkind)%all_potential(:, atom_b) = force(jkind)%all_potential(:, atom_b) + force_ab(:)
382 force(ikind)%overlap(:, atom_a) = force(ikind)%overlap(:, atom_a) - force_w(:)
383 force(jkind)%overlap(:, atom_b) = force(jkind)%overlap(:, atom_b) + force_w(:)
389 IF ((dr <= urep_cut .OR. spdim > 0) .AND. dr > 0.001_dp)
THEN
391 CALL urep_egr(rij, dr, erepij, force_rr, &
392 n_urpoly, urep, spdim, s_cut, srep, spxr, scoeff, surr, calculate_forces)
394 IF (atprop%energy)
THEN
395 atprop%atecc(iatom) = atprop%atecc(iatom) + 0.5_dp*erepij
396 atprop%atecc(jatom) = atprop%atecc(jatom) + 0.5_dp*erepij
398 IF (calculate_forces .AND. (iatom /= jatom .OR. dr > 0.001_dp))
THEN
399 atom_a = atom_of_kind(iatom)
400 atom_b = atom_of_kind(jatom)
401 force(ikind)%repulsive(:, atom_a) = &
402 force(ikind)%repulsive(:, atom_a) - force_rr(:)
403 force(jkind)%repulsive(:, atom_b) = &
404 force(jkind)%repulsive(:, atom_b) + force_rr(:)
407 IF (iatom == jatom) f0 = -0.5_dp
416 DO i = 1,
SIZE(matrix_s, 1)
421 DO i = 1,
SIZE(matrix_h, 1)
428 CALL para_env%sum(erep)
429 energy%repulsive = erep
431 CALL section_vals_val_get(qs_env%input,
"DFT%PRINT%AO_MATRICES%OMIT_HEADERS", l_val=omit_headers)
433 qs_env%input,
"DFT%PRINT%AO_MATRICES/CORE_HAMILTONIAN"),
cp_p_file))
THEN
437 after = min(max(after, 1), 16)
440 output_unit=iw, omit_headers=omit_headers)
444 "DFT%PRINT%AO_MATRICES/CORE_HAMILTONIAN")
448 qs_env%input,
"DFT%PRINT%AO_MATRICES/OVERLAP"),
cp_p_file))
THEN
452 after = min(max(after, 1), 16)
455 output_unit=iw, omit_headers=omit_headers)
458 qs_env%input,
"DFT%PRINT%AO_MATRICES/DERIVATIVES"),
cp_p_file))
THEN
459 DO i = 2,
SIZE(matrix_s, 1)
461 output_unit=iw, omit_headers=omit_headers)
467 "DFT%PRINT%AO_MATRICES/OVERLAP")
470 IF (calculate_forces)
THEN
471 IF (
SIZE(matrix_p, 1) == 2)
THEN
473 CALL dbcsr_add(matrix_p(1, img)%matrix, matrix_p(2, img)%matrix, alpha_scalar=1.0_dp, &
479 CALL timestop(handle)
491 LOGICAL,
INTENT(in) :: calculate_forces, just_energy
493 CHARACTER(len=*),
PARAMETER :: routinen =
'build_dftb_ks_matrix'
495 INTEGER :: atom_a, handle, iatom, ikind, img, &
496 ispin, natom, nkind, nspins, &
498 REAL(kind=
dp) :: pc_ener, qmmm_el, zeff
499 REAL(kind=
dp),
DIMENSION(:),
POINTER :: mcharge, occupation_numbers
500 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: charges
503 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_p1, mo_derivs
504 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: ks_matrix, matrix_h, matrix_p, matrix_s
511 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
516 CALL timeset(routinen, handle)
517 NULLIFY (dft_control, logger, scf_section, matrix_p, particle_set, ks_env, &
518 ks_matrix, rho, energy)
520 cpassert(
ASSOCIATED(qs_env))
523 dft_control=dft_control, &
524 atomic_kind_set=atomic_kind_set, &
525 qs_kind_set=qs_kind_set, &
526 matrix_h_kp=matrix_h, &
529 matrix_ks_kp=ks_matrix, &
533 energy%hartree = 0.0_dp
534 energy%qmmm_el = 0.0_dp
537 nspins = dft_control%nspins
538 cpassert(
ASSOCIATED(matrix_h))
539 cpassert(
ASSOCIATED(rho))
540 cpassert(
SIZE(ks_matrix) > 0)
543 DO img = 1,
SIZE(ks_matrix, 2)
545 CALL dbcsr_copy(ks_matrix(ispin, img)%matrix, matrix_h(1, img)%matrix)
549 IF (dft_control%qs_control%dftb_control%self_consistent)
THEN
551 CALL get_qs_env(qs_env=qs_env, particle_set=particle_set, &
552 matrix_s_kp=matrix_s)
554 natom =
SIZE(particle_set)
555 ALLOCATE (charges(natom, nspins))
559 ALLOCATE (mcharge(natom))
560 nkind =
SIZE(atomic_kind_set)
563 CALL get_qs_kind(qs_kind_set(ikind), dftb_parameter=dftb_kind)
566 atom_a = atomic_kind_set(ikind)%atom_list(iatom)
567 mcharge(atom_a) = zeff - sum(charges(atom_a, 1:nspins))
573 calculate_forces, just_energy)
576 calculate_forces, just_energy)
582 IF (qs_env%qmmm)
THEN
583 cpassert(
SIZE(ks_matrix, 2) == 1)
586 CALL dbcsr_add(ks_matrix(ispin, 1)%matrix, qs_env%ks_qmmm_env%matrix_h(1)%matrix, &
590 CALL dbcsr_dot(qs_env%ks_qmmm_env%matrix_h(1)%matrix, &
591 matrix_p1(ispin)%matrix, qmmm_el)
592 energy%qmmm_el = energy%qmmm_el + qmmm_el
594 pc_ener = qs_env%ks_qmmm_env%pc_ener
595 energy%qmmm_el = energy%qmmm_el + pc_ener
598 energy%total = energy%core + energy%hartree + energy%qmmm_el + energy%efield + &
599 energy%repulsive + energy%dispersion + energy%dftb3
601 IF (dft_control%qs_control%dftb_control%self_consistent)
THEN
604 IF (output_unit > 0)
THEN
605 WRITE (unit=output_unit, fmt=
"(/,(T9,A,T60,F20.10))") &
606 "Repulsive pair potential energy: ", energy%repulsive, &
607 "Zeroth order Hamiltonian energy: ", energy%core, &
608 "Charge fluctuation energy: ", energy%hartree, &
609 "London dispersion energy: ", energy%dispersion
610 IF (abs(energy%efield) > 1.e-12_dp)
THEN
611 WRITE (unit=output_unit, fmt=
"(T9,A,T60,F20.10)") &
612 "Electric field interaction energy: ", energy%efield
614 IF (dft_control%qs_control%dftb_control%dftb3_diagonal)
THEN
615 WRITE (unit=output_unit, fmt=
"(T9,A,T60,F20.10)") &
616 "DFTB3 3rd Order Energy Correction ", energy%dftb3
618 IF (qs_env%qmmm)
THEN
619 WRITE (unit=output_unit, fmt=
"(T9,A,T60,F20.10)") &
620 "QM/MM Electrostatic energy: ", energy%qmmm_el
624 "PRINT%DETAILED_ENERGY")
627 IF (qs_env%requires_mo_derivs .AND. .NOT. just_energy)
THEN
628 cpassert(
SIZE(ks_matrix, 2) == 1)
630 TYPE(
mo_set_type),
DIMENSION(:),
POINTER :: mo_array
631 CALL get_qs_env(qs_env, mo_derivs=mo_derivs, mos=mo_array)
632 DO ispin = 1,
SIZE(mo_derivs)
634 mo_coeff_b=mo_coeff, occupation_numbers=occupation_numbers)
635 IF (.NOT. mo_array(ispin)%use_mo_coeff_b)
THEN
638 CALL dbcsr_multiply(
'n',
'n', 1.0_dp, ks_matrix(ispin, 1)%matrix, mo_coeff, &
639 0.0_dp, mo_derivs(ispin)%matrix)
644 CALL timestop(handle)
656 TYPE(qs_environment_type),
POINTER :: qs_env
657 INTEGER,
INTENT(IN) :: nderivative
658 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_s
660 CHARACTER(LEN=*),
PARAMETER :: routinen =
'build_dftb_overlap'
662 INTEGER :: handle, i, iatom, icol, ikind, indder, irow, j, jatom, jkind, l1, l2, la, lb, &
663 llm, lmaxi, lmaxj, m, n1, n2, natom, natorb_a, natorb_b, ngrd, ngrdcut, nkind
664 LOGICAL :: defined, found
665 REAL(kind=dp) :: ddr, dgrd, dr, f0
666 REAL(kind=dp),
DIMENSION(0:3) :: skself
667 REAL(kind=dp),
DIMENSION(3) :: drij, rij
668 REAL(kind=dp),
DIMENSION(:, :),
POINTER :: dsblock, dsblockm, sblock, smatij, smatji
669 REAL(kind=dp),
DIMENSION(:, :, :),
POINTER :: dsblock1
670 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
671 TYPE(block_p_type),
DIMENSION(2:10) :: dsblocks
672 TYPE(cp_logger_type),
POINTER :: logger
673 TYPE(dft_control_type),
POINTER :: dft_control
674 TYPE(dftb_control_type),
POINTER :: dftb_control
675 TYPE(neighbor_list_iterator_p_type), &
676 DIMENSION(:),
POINTER :: nl_iterator
677 TYPE(neighbor_list_set_p_type),
DIMENSION(:), &
679 TYPE(qs_dftb_atom_type),
POINTER :: dftb_kind_a, dftb_kind_b
680 TYPE(qs_dftb_pairpot_type),
DIMENSION(:, :), &
681 POINTER :: dftb_potential
682 TYPE(qs_dftb_pairpot_type),
POINTER :: dftb_param_ij, dftb_param_ji
683 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
685 CALL timeset(routinen, handle)
692 DO l1 = 0, max(la, lb)
693 DO l2 = 0, min(l1, la, lb)
696 iptr(l1, l2, m, la, lb) = llm
704 logger => cp_get_default_logger()
706 NULLIFY (atomic_kind_set, qs_kind_set, sab_orb)
708 CALL get_qs_env(qs_env=qs_env, &
709 atomic_kind_set=atomic_kind_set, qs_kind_set=qs_kind_set, &
710 dft_control=dft_control)
712 dftb_control => dft_control%qs_control%dftb_control
714 NULLIFY (dftb_potential)
715 CALL get_qs_env(qs_env=qs_env, &
716 dftb_potential=dftb_potential)
718 nkind =
SIZE(atomic_kind_set)
721 CALL get_qs_env(qs_env=qs_env, sab_orb=sab_orb)
722 CALL setup_matrices1(qs_env, nderivative, matrix_s,
'OVERLAP', sab_orb)
724 CALL neighbor_list_iterator_create(nl_iterator, sab_orb)
725 DO WHILE (neighbor_list_iterate(nl_iterator) == 0)
726 CALL get_iterator_info(nl_iterator, ikind=ikind, jkind=jkind, &
727 iatom=iatom, jatom=jatom, r=rij)
729 CALL get_atomic_kind(atomic_kind_set(ikind), natom=natom)
730 CALL get_qs_kind(qs_kind_set(ikind), dftb_parameter=dftb_kind_a)
731 CALL get_dftb_atom_param(dftb_kind_a, &
732 defined=defined, lmax=lmaxi, skself=skself, &
735 IF (.NOT. defined .OR. natorb_a < 1) cycle
737 CALL get_qs_kind(qs_kind_set(jkind), dftb_parameter=dftb_kind_b)
738 CALL get_dftb_atom_param(dftb_kind_b, &
739 defined=defined, lmax=lmaxj, natorb=natorb_b)
741 IF (.NOT. defined .OR. natorb_b < 1) cycle
744 dftb_param_ij => dftb_potential(ikind, jkind)
745 dftb_param_ji => dftb_potential(jkind, ikind)
747 ngrd = dftb_param_ij%ngrd
748 ngrdcut = dftb_param_ij%ngrdcut
749 dgrd = dftb_param_ij%dgrd
751 cpassert(dftb_param_ij%llm == dftb_param_ji%llm)
752 llm = dftb_param_ij%llm
753 smatij => dftb_param_ij%smat
754 smatji => dftb_param_ji%smat
756 dr = sqrt(sum(rij(:)**2))
757 IF (nint(dr/dgrd) <= ngrdcut)
THEN
759 icol = max(iatom, jatom); irow = min(iatom, jatom)
762 CALL dbcsr_get_block_p(matrix=matrix_s(1)%matrix, &
763 row=irow, col=icol, block=sblock, found=found)
766 IF (nderivative .GT. 0)
THEN
767 DO i = 2,
SIZE(matrix_s, 1)
768 NULLIFY (dsblocks(i)%block)
769 CALL dbcsr_get_block_p(matrix=matrix_s(i)%matrix, &
770 row=irow, col=icol, block=dsblocks(i)%block, found=found)
774 IF (iatom == jatom .AND. dr < 0.001_dp)
THEN
777 sblock(i, i) = sblock(i, i) + 1._dp
781 CALL compute_block_sk(sblock, smatij, smatji, rij, ngrd, ngrdcut, dgrd, &
782 llm, lmaxi, lmaxj, irow, iatom)
784 IF (nderivative .GE. 1)
THEN
785 n1 =
SIZE(sblock, 1); n2 =
SIZE(sblock, 2)
788 ALLOCATE (dsblock1(n1, n2, 3), dsblock(n1, n2), dsblockm(n1, n2))
791 dsblock = 0._dp; dsblockm = 0.0_dp
793 f0 = 1.0_dp;
IF (irow == iatom) f0 = -1.0_dp
795 drij(i) = rij(i) - ddr*f0
796 CALL compute_block_sk(dsblockm, smatij, smatji, drij, ngrd, ngrdcut, dgrd, &
797 llm, lmaxi, lmaxj, irow, iatom)
799 drij(i) = rij(i) + ddr*f0
800 CALL compute_block_sk(dsblock, smatij, smatji, drij, ngrd, ngrdcut, dgrd, &
801 llm, lmaxi, lmaxj, irow, iatom)
803 dsblock1(:, :, i) = (dsblock + dsblockm)
804 dsblock = dsblock - dsblockm
805 dsblock = dsblock/(2.0_dp*ddr)
807 cpassert(
ASSOCIATED(dsblocks(i + 1)%block))
808 dsblocks(i + 1)%block = dsblocks(i + 1)%block + dsblock
809 IF (nderivative .GT. 1)
THEN
810 indder = indder + 5 - i
811 dsblocks(indder)%block = 0.0_dp
812 dsblocks(indder)%block = dsblocks(indder)%block + &
813 (dsblock1(:, :, i) - 2.0_dp*sblock)/ddr**2
817 IF (nderivative .GT. 1)
THEN
820 dsblock = 0._dp; dsblockm = 0.0_dp
822 f0 = 1.0_dp;
IF (irow == iatom) f0 = -1.0_dp
824 drij(i) = rij(i) - ddr*f0; drij(j) = rij(j) - ddr*f0
825 CALL compute_block_sk(dsblockm, smatij, smatji, drij, ngrd, ngrdcut, dgrd, &
826 llm, lmaxi, lmaxj, irow, iatom)
828 drij(i) = rij(i) + ddr*f0; drij(j) = rij(j) + ddr*f0
829 CALL compute_block_sk(dsblock, smatij, smatji, drij, ngrd, ngrdcut, dgrd, &
830 llm, lmaxi, lmaxj, irow, iatom)
833 dsblocks(indder)%block = 0.0_dp
834 dsblocks(indder)%block = &
835 dsblocks(indder)%block + ( &
836 dsblock + dsblockm - dsblock1(:, :, i) - dsblock1(:, :, j) + 2.0_dp*sblock)/(2.0_dp*ddr**2)
841 DEALLOCATE (dsblock1, dsblock, dsblockm)
846 CALL neighbor_list_iterator_release(nl_iterator)
848 DO i = 1,
SIZE(matrix_s, 1)
849 CALL dbcsr_finalize(matrix_s(i)%matrix)
852 CALL timestop(handle)
864 SUBROUTINE setup_matrices1(qs_env, nderivative, matrices, mnames, sab_nl)
866 TYPE(qs_environment_type),
POINTER :: qs_env
867 INTEGER,
INTENT(IN) :: nderivative
868 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: matrices
869 CHARACTER(LEN=*) :: mnames
870 TYPE(neighbor_list_set_p_type),
DIMENSION(:), &
873 CHARACTER(1) :: symmetry_type
874 CHARACTER(LEN=default_string_length) :: matnames
875 INTEGER :: i, natom, neighbor_list_id, nkind, nmat, &
877 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: first_sgf, last_sgf
878 INTEGER,
DIMENSION(:),
POINTER :: row_blk_sizes
879 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
880 TYPE(dbcsr_distribution_type),
POINTER :: dbcsr_dist
881 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
882 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
884 NULLIFY (particle_set, atomic_kind_set)
886 CALL get_qs_env(qs_env=qs_env, &
887 atomic_kind_set=atomic_kind_set, &
888 qs_kind_set=qs_kind_set, &
889 particle_set=particle_set, &
890 dbcsr_dist=dbcsr_dist, &
891 neighbor_list_id=neighbor_list_id)
893 nkind =
SIZE(atomic_kind_set)
894 natom =
SIZE(particle_set)
896 CALL get_qs_kind_set(qs_kind_set, nsgf=nsgf)
898 ALLOCATE (first_sgf(natom))
899 ALLOCATE (last_sgf(natom))
901 CALL get_particle_set(particle_set, qs_kind_set, &
902 first_sgf=first_sgf, &
906 IF (nderivative == 0) nmat = 1
907 IF (nderivative == 1) nmat = 4
908 IF (nderivative == 2) nmat = 10
911 ALLOCATE (row_blk_sizes(natom))
912 CALL dbcsr_convert_offsets_to_sizes(first_sgf, row_blk_sizes, last_sgf)
914 CALL dbcsr_allocate_matrix_set(matrices, nmat)
919 matnames = trim(mnames)//
" DERIVATIVE MATRIX DFTB"
920 symmetry_type = dbcsr_type_antisymmetric
921 IF (i .GT. 4) symmetry_type = dbcsr_type_symmetric
923 symmetry_type = dbcsr_type_symmetric
924 matnames = trim(mnames)//
" MATRIX DFTB"
926 ALLOCATE (matrices(i)%matrix)
927 CALL dbcsr_create(matrix=matrices(i)%matrix, &
928 name=trim(matnames), &
929 dist=dbcsr_dist, matrix_type=symmetry_type, &
930 row_blk_size=row_blk_sizes, col_blk_size=row_blk_sizes, &
932 CALL cp_dbcsr_alloc_block_from_nbl(matrices(i)%matrix, sab_nl)
935 DEALLOCATE (first_sgf)
936 DEALLOCATE (last_sgf)
938 DEALLOCATE (row_blk_sizes)
940 END SUBROUTINE setup_matrices1
951 SUBROUTINE setup_matrices2(qs_env, nderivative, nimg, matrices, mnames, sab_nl)
953 TYPE(qs_environment_type),
POINTER :: qs_env
954 INTEGER,
INTENT(IN) :: nderivative, nimg
955 TYPE(dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrices
956 CHARACTER(LEN=*) :: mnames
957 TYPE(neighbor_list_set_p_type),
DIMENSION(:), &
960 CHARACTER(1) :: symmetry_type
961 CHARACTER(LEN=default_string_length) :: matnames
962 INTEGER :: i, img, natom, neighbor_list_id, nkind, &
964 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: first_sgf, last_sgf
965 INTEGER,
DIMENSION(:),
POINTER :: row_blk_sizes
966 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
967 TYPE(dbcsr_distribution_type),
POINTER :: dbcsr_dist
968 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
969 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
971 NULLIFY (particle_set, atomic_kind_set)
973 CALL get_qs_env(qs_env=qs_env, &
974 atomic_kind_set=atomic_kind_set, &
975 qs_kind_set=qs_kind_set, &
976 particle_set=particle_set, &
977 dbcsr_dist=dbcsr_dist, &
978 neighbor_list_id=neighbor_list_id)
980 nkind =
SIZE(atomic_kind_set)
981 natom =
SIZE(particle_set)
983 CALL get_qs_kind_set(qs_kind_set, nsgf=nsgf)
985 ALLOCATE (first_sgf(natom))
986 ALLOCATE (last_sgf(natom))
988 CALL get_particle_set(particle_set, qs_kind_set, &
989 first_sgf=first_sgf, &
993 IF (nderivative == 0) nmat = 1
994 IF (nderivative == 1) nmat = 4
995 IF (nderivative == 2) nmat = 10
998 ALLOCATE (row_blk_sizes(natom))
999 CALL dbcsr_convert_offsets_to_sizes(first_sgf, row_blk_sizes, last_sgf)
1001 CALL dbcsr_allocate_matrix_set(matrices, nmat, nimg)
1007 matnames = trim(mnames)//
" DERIVATIVE MATRIX DFTB"
1008 symmetry_type = dbcsr_type_antisymmetric
1009 IF (i .GT. 4) symmetry_type = dbcsr_type_symmetric
1011 symmetry_type = dbcsr_type_symmetric
1012 matnames = trim(mnames)//
" MATRIX DFTB"
1014 ALLOCATE (matrices(i, img)%matrix)
1015 CALL dbcsr_create(matrix=matrices(i, img)%matrix, &
1016 name=trim(matnames), &
1017 dist=dbcsr_dist, matrix_type=symmetry_type, &
1018 row_blk_size=row_blk_sizes, col_blk_size=row_blk_sizes, &
1019 mutable_work=.true.)
1020 CALL cp_dbcsr_alloc_block_from_nbl(matrices(i, img)%matrix, sab_nl)
1024 DEALLOCATE (first_sgf)
1025 DEALLOCATE (last_sgf)
1027 DEALLOCATE (row_blk_sizes)
1029 END SUBROUTINE setup_matrices2
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 atprop_array_init(atarray, natom)
...
collect pointers to a block of reals
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
subroutine, public dbcsr_copy(matrix_b, matrix_a, name, keep_sparsity, keep_imaginary)
...
subroutine, public dbcsr_get_block_p(matrix, row, col, block, found, row_size, col_size)
...
subroutine, public dbcsr_multiply(transa, transb, alpha, matrix_a, matrix_b, beta, matrix_c, first_row, last_row, first_column, last_column, first_k, last_k, retain_sparsity, filter_eps, flop)
...
subroutine, public dbcsr_finalize(matrix)
...
subroutine, public dbcsr_add(matrix_a, matrix_b, alpha_scalar, beta_scalar)
...
subroutine, public dbcsr_dot(matrix_a, matrix_b, trace)
Computes the dot product of two matrices, also known as the trace of their matrix product.
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.
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 routines to log and control the output. The idea is that decisions about where to log should ...
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...
Calculation of electric field contributions in TB.
subroutine, public efield_tb_matrix(qs_env, ks_matrix, rho, mcharge, energy, calculate_forces, just_energy)
...
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.
Interface to the message passing library MPI.
compute mulliken charges we (currently) define them as c_i = 1/2 [ (PS)_{ii} + (SP)_{ii} ]
Define methods related to particle_type.
subroutine, public get_particle_set(particle_set, qs_kind_set, first_sgf, last_sgf, nsgf, nmao, basis)
Get the components of a particle set.
Define the data structure for the particle information.
Calculation of Coulomb contributions in DFTB.
subroutine, public build_dftb_coulomb(qs_env, ks_matrix, rho, mcharge, energy, calculate_forces, just_energy)
...
Calculation of Overlap and Hamiltonian matrices in DFTB.
subroutine, public build_dftb_ks_matrix(qs_env, calculate_forces, just_energy)
...
integer, dimension(16), parameter orbptr
subroutine, public build_dftb_matrices(qs_env, para_env, calculate_forces)
...
subroutine, public build_dftb_overlap(qs_env, nderivative, matrix_s)
...
Definition of the DFTB parameter types.
Working with the DFTB parameter types.
subroutine, public urep_egr(rv, r, erep, derep, n_urpoly, urep, spdim, s_cut, srep, spxr, scoeff, surr, dograd)
...
subroutine, public compute_block_sk(block, smatij, smatji, rij, ngrd, ngrdcut, dgrd, llm, lmaxi, lmaxj, irow, iatom)
...
integer, dimension(0:3, 0:3, 0:3, 0:3, 0:3), public iptr
subroutine, public get_dftb_atom_param(dftb_parameter, name, typ, defined, z, zeff, natorb, lmax, skself, occupation, eta, energy, cutoff, xi, di, rcdisp, dudq)
...
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, 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, ecoul_1c, rho0_s_rs, rho0_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)
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, se_parameter, dftb_parameter, xtb_parameter, dftb3_param, zatom, zeff, elec_conf, mao, lmax_dftb, alpha_core_charge, ccore_charge, core_charge, core_charge_radius, paw_proj_set, paw_atom, hard_radius, hard0_radius, max_rad_local, covalent_radius, vdw_radius, gpw_type_forced, harmonics, max_iso_not0, max_s_harm, grid_atom, ngrid_ang, ngrid_rad, lmax_rho0, dft_plus_u_atom, l_of_dft_plus_u, n_of_dft_plus_u, u_minus_j, u_of_dft_plus_u, j_of_dft_plus_u, alpha_of_dft_plus_u, beta_of_dft_plus_u, j0_of_dft_plus_u, occupation_of_dft_plus_u, dispersion, bs_occupation, magnetization, no_optimize, addel, laddel, naddel, orbitals, max_scf, eps_scf, smear, u_ramping, u_minus_j_target, eps_u_ramping, init_u_ramping_each_scf, reltmat, ghost, floating, name, element_symbol, pao_basis_size, pao_model_file, pao_potentials, pao_descriptors, nelec)
Get attributes of an atomic kind.
subroutine, public 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)
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, task_list, task_list_soft, subsys, dft_control, dbcsr_dist, distribution_2d, pw_env, para_env, blacs_env)
...
subroutine, public get_ks_env(ks_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, complex_ks, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, kinetic, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_ks_im_kp, rho, rho_xc, vppl, rho_core, rho_nlcc, rho_nlcc_g, vee, neighbor_list_id, sab_orb, sab_all, sac_ae, sac_ppl, sac_lri, sap_ppnl, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_vdw, sab_scp, sab_almo, sab_kp, sab_kp_nosym, 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)
...
Definition and initialisation of the mo data type.
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.
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)
...
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...
pure subroutine, public virial_pair_force(pv_virial, f0, force, rab)
Computes the contribution to the stress tensor from two-body pair-wise forces.
Provides all information about an atomic kind.
type for the atomic properties
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.