82#include "./base/base_uses.f90"
88 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_efield_berry'
109 LOGICAL,
INTENT(IN) :: just_energy, calculate_forces
111 CHARACTER(LEN=*),
PARAMETER :: routinen =
'qs_efield_berry_phase'
114 LOGICAL :: s_mstruct_changed
117 CALL timeset(routinen, handle)
119 NULLIFY (dft_control)
120 CALL get_qs_env(qs_env, s_mstruct_changed=s_mstruct_changed, &
121 dft_control=dft_control)
123 IF (dft_control%apply_period_efield)
THEN
125 IF (dft_control%period_efield%start_frame <= qs_env%sim_step .AND. &
126 (dft_control%period_efield%end_frame == -1 .OR. dft_control%period_efield%end_frame >= qs_env%sim_step))
THEN
128 IF (s_mstruct_changed)
CALL qs_efield_integrals(qs_env)
129 IF (dft_control%period_efield%displacement_field)
THEN
130 CALL qs_dispfield_derivatives(qs_env, just_energy, calculate_forces)
132 CALL qs_efield_derivatives(qs_env, just_energy, calculate_forces)
137 CALL timestop(handle)
145 SUBROUTINE qs_efield_integrals(qs_env)
149 CHARACTER(LEN=*),
PARAMETER :: routinen =
'qs_efield_integrals'
152 REAL(
dp),
DIMENSION(3) :: kvec
154 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: cosmat, matrix_s, sinmat
158 CALL timeset(routinen, handle)
159 cpassert(
ASSOCIATED(qs_env))
161 CALL get_qs_env(qs_env=qs_env, dft_control=dft_control)
163 CALL get_qs_env(qs_env=qs_env, efield=efield, cell=cell, matrix_s=matrix_s)
165 ALLOCATE (cosmat(3), sinmat(3))
167 ALLOCATE (cosmat(i)%matrix, sinmat(i)%matrix)
169 CALL dbcsr_copy(cosmat(i)%matrix, matrix_s(1)%matrix,
'COS MAT')
170 CALL dbcsr_copy(sinmat(i)%matrix, matrix_s(1)%matrix,
'SIN MAT')
172 kvec(:) =
twopi*cell%h_inv(i, :)
177 CALL timestop(handle)
179 END SUBROUTINE qs_efield_integrals
187 SUBROUTINE qs_efield_derivatives(qs_env, just_energy, calculate_forces)
189 LOGICAL,
INTENT(IN) :: just_energy, calculate_forces
191 CHARACTER(LEN=*),
PARAMETER :: routinen =
'qs_efield_derivatives'
193 COMPLEX(dp) :: zdet, zdeta, zi(3)
194 INTEGER :: atom_a, atom_b, handle, i, ia, iatom, icol, idir, ikind, irow, iset, ispin, j, &
195 jatom, jkind, jset, ldab, ldsa, ldsb, lsab, n1, n2, nao, natom, ncoa, ncob, nkind, nmo, &
196 nseta, nsetb, sgfa, sgfb
197 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: atom_of_kind
198 INTEGER,
DIMENSION(:),
POINTER :: la_max, la_min, lb_max, lb_min, npgfa, &
200 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgfa, first_sgfb
201 LOGICAL :: found, uniform, use_virial
202 REAL(
dp) :: charge, ci(3), cqi(3), dab, dd, &
203 ener_field, f0, fab, fieldpol(3), &
204 focc, fpolvec(3), hmat(3, 3), occ, &
205 qi(3), strength, ti(3)
206 REAL(
dp),
DIMENSION(3) :: forcea, forceb, kvec, ra, rab, rb, ria
207 REAL(
dp),
DIMENSION(:, :),
POINTER :: cosab, iblock, rblock, sinab, work
208 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: dcosab, dsinab
209 REAL(kind=
dp),
DIMENSION(:),
POINTER :: set_radius_a, set_radius_b
210 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: rpgfa, rpgfb, sphi_a, sphi_b, zeta, zetb
214 TYPE(
cp_cfm_type),
ALLOCATABLE,
DIMENSION(:) :: eigrmat, inv_mat
216 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: mo_coeff_tmp, mo_derivs_tmp
217 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:, :) :: inv_work, op_fm_set, opvec
219 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_s, mo_derivs
221 TYPE(
dbcsr_type),
POINTER :: cosmat, mo_coeff_b, sinmat
229 DIMENSION(:),
POINTER :: nl_iterator
235 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
239 CALL timeset(routinen, handle)
241 NULLIFY (dft_control, cell, particle_set)
242 CALL get_qs_env(qs_env, dft_control=dft_control, cell=cell, &
243 particle_set=particle_set, virial=virial)
244 NULLIFY (qs_kind_set, efield, para_env, sab_orb)
245 CALL get_qs_env(qs_env=qs_env, qs_kind_set=qs_kind_set, &
246 efield=efield, energy=energy, para_env=para_env, sab_orb=sab_orb)
249 use_virial = virial%pv_availability .AND. (.NOT. virial%pv_numer)
250 use_virial = use_virial .AND. calculate_forces
253 cpabort(
"Stress tensor for periodic E-field not implemented")
257 strength = dft_control%period_efield%strength
258 IF (
ALLOCATED(dft_control%period_efield%strength_list))
THEN
259 strength = dft_control%period_efield%strength_list(mod(qs_env%sim_step &
260 - dft_control%period_efield%start_frame,
SIZE(dft_control%period_efield%strength_list)) + 1)
263 fieldpol = dft_control%period_efield%polarisation
264 fieldpol = fieldpol/norm2(fieldpol)
265 fieldpol = -fieldpol*strength
266 hmat = cell%hmat(:, :)/
twopi
268 fpolvec(idir) = fieldpol(1)*hmat(1, idir) + fieldpol(2)*hmat(2, idir) + fieldpol(3)*hmat(3, idir)
272 natom =
SIZE(particle_set)
273 IF (calculate_forces)
THEN
274 CALL get_qs_env(qs_env=qs_env, atomic_kind_set=atomic_kind_set, force=force)
277 zi(:) = cmplx(1._dp, 0._dp,
dp)
280 CALL get_qs_kind(qs_kind_set(ikind), core_charge=charge)
281 ria = particle_set(ia)%r
284 kvec(:) =
twopi*cell%h_inv(idir, :)
285 dd = sum(kvec(:)*ria(:))
286 zdeta = cmplx(cos(dd), sin(dd), kind=
dp)**charge
287 zi(idir) = zi(idir)*zdeta
289 IF (calculate_forces)
THEN
290 IF (para_env%mepos == 0)
THEN
291 iatom = atom_of_kind(ia)
292 forcea(:) = fieldpol(:)*charge
293 force(ikind)%efield(:, iatom) = force(ikind)%efield(:, iatom) + forcea(:)
297 IF (para_env%mepos == 0)
THEN
307 DO ispin = 1, dft_control%nspins
308 CALL get_mo_set(mo_set=mos(ispin), maxocc=occ, uniform_occupation=uniform)
309 IF (.NOT. uniform)
THEN
310 cpabort(
"Berry phase moments for non uniform MOs' occupation numbers not implemented")
315 CALL get_qs_env(qs_env=qs_env, mo_derivs=mo_derivs)
317 ALLOCATE (op_fm_set(2, dft_control%nspins))
318 ALLOCATE (opvec(2, dft_control%nspins))
319 ALLOCATE (eigrmat(dft_control%nspins))
320 ALLOCATE (inv_mat(dft_control%nspins))
321 ALLOCATE (inv_work(2, dft_control%nspins))
322 ALLOCATE (mo_derivs_tmp(
SIZE(mo_derivs)))
323 ALLOCATE (mo_coeff_tmp(
SIZE(mo_derivs)))
326 DO ispin = 1, dft_control%nspins
327 NULLIFY (tmp_fm_struct, mo_coeff)
328 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff, nao=nao, nmo=nmo)
330 ncol_global=nmo, para_env=para_env, context=mo_coeff%matrix_struct%context)
331 CALL cp_fm_create(mo_derivs_tmp(ispin), mo_coeff%matrix_struct)
332 CALL cp_fm_create(mo_coeff_tmp(ispin), mo_coeff%matrix_struct)
334 DO i = 1,
SIZE(op_fm_set, 1)
335 CALL cp_fm_create(opvec(i, ispin), mo_coeff%matrix_struct)
337 CALL cp_fm_create(inv_work(i, ispin), op_fm_set(i, ispin)%matrix_struct)
339 CALL cp_cfm_create(eigrmat(ispin), op_fm_set(1, ispin)%matrix_struct)
340 CALL cp_cfm_create(inv_mat(ispin), op_fm_set(1, ispin)%matrix_struct)
344 IF (calculate_forces)
THEN
346 CALL get_qs_env(qs_env=qs_env, matrix_s=matrix_s)
347 ALLOCATE (tempmat(2, dft_control%nspins))
348 DO ispin = 1, dft_control%nspins
349 ALLOCATE (tempmat(1, ispin)%matrix, tempmat(2, ispin)%matrix)
350 CALL dbcsr_copy(tempmat(1, ispin)%matrix, matrix_s(1)%matrix,
'TEMPMAT')
351 CALL dbcsr_copy(tempmat(2, ispin)%matrix, matrix_s(1)%matrix,
'TEMPMAT')
352 CALL dbcsr_set(tempmat(1, ispin)%matrix, 0.0_dp)
353 CALL dbcsr_set(tempmat(2, ispin)%matrix, 0.0_dp)
357 ALLOCATE (cosab(ldab, ldab), sinab(ldab, ldab), work(ldab, ldab))
358 ALLOCATE (dcosab(ldab, ldab, 3), dsinab(ldab, ldab, 3))
359 lsab = max(ldab, lsab)
361 ALLOCATE (dcost(i, 1)%block(lsab, lsab), dsint(i, 1)%block(lsab, lsab))
362 ALLOCATE (dcost(i, 2)%block(lsab, lsab), dsint(i, 2)%block(lsab, lsab))
371 IF (abs(fpolvec(idir)) > 1.0e-12_dp)
THEN
372 cosmat => efield%cosmat(idir)%matrix
373 sinmat => efield%sinmat(idir)%matrix
376 DO ispin = 1, dft_control%nspins
377 IF (mos(ispin)%use_mo_coeff_b)
THEN
378 CALL get_mo_set(mo_set=mos(ispin), nao=nao, mo_coeff_b=mo_coeff_b, nmo=nmo)
381 CALL get_mo_set(mo_set=mos(ispin), nao=nao, mo_coeff=mo_coeff, nmo=nmo)
382 mo_coeff_tmp(ispin) = mo_coeff
385 CALL parallel_gemm(
"T",
"N", nmo, nmo, nao, 1.0_dp, mo_coeff_tmp(ispin), opvec(1, ispin), 0.0_dp, &
388 CALL parallel_gemm(
"T",
"N", nmo, nmo, nao, 1.0_dp, mo_coeff_tmp(ispin), opvec(2, ispin), 0.0_dp, &
393 DO ispin = 1, dft_control%nspins
397 CALL cp_cfm_solve(eigrmat(ispin), inv_mat(ispin), zdeta)
401 ci(idir) = aimag(log(zdet**occ))
403 IF (.NOT. just_energy)
THEN
406 DO ispin = 1, dft_control%nspins
407 inv_work(1, ispin)%local_data(:, :) = real(inv_mat(ispin)%local_data(:, :),
dp)
408 inv_work(2, ispin)%local_data(:, :) = aimag(inv_mat(ispin)%local_data(:, :))
409 CALL get_mo_set(mo_set=mos(ispin), nao=nao, nmo=nmo)
410 CALL parallel_gemm(
"N",
"N", nao, nmo, nmo, focc, opvec(1, ispin), inv_work(2, ispin), &
411 1.0_dp, mo_derivs_tmp(ispin))
412 CALL parallel_gemm(
"N",
"N", nao, nmo, nmo, -focc, opvec(2, ispin), inv_work(1, ispin), &
413 1.0_dp, mo_derivs_tmp(ispin))
418 IF (calculate_forces)
THEN
419 nkind =
SIZE(qs_kind_set)
420 natom =
SIZE(particle_set)
421 kvec(:) =
twopi*cell%h_inv(idir, :)
425 DO ispin = 1, dft_control%nspins
426 CALL dbcsr_set(tempmat(1, ispin)%matrix, 0.0_dp)
427 CALL dbcsr_set(tempmat(2, ispin)%matrix, 0.0_dp)
428 CALL get_mo_set(mo_set=mos(ispin), nao=nao, nmo=nmo)
429 CALL parallel_gemm(
"N",
"N", nao, nmo, nmo, 1.0_dp, mo_coeff_tmp(ispin), inv_work(1, ispin), 0.0_dp, &
431 CALL parallel_gemm(
"N",
"N", nao, nmo, nmo, 1.0_dp, mo_coeff_tmp(ispin), inv_work(2, ispin), 0.0_dp, &
434 matrix_v=opvec(1, ispin), matrix_g=mo_coeff_tmp(ispin), ncol=nmo)
436 matrix_v=opvec(2, ispin), matrix_g=mo_coeff_tmp(ispin), ncol=nmo)
440 ALLOCATE (basis_set_list(nkind))
442 qs_kind => qs_kind_set(ikind)
443 CALL get_qs_kind(qs_kind=qs_kind, basis_set=basis_set_a)
444 IF (
ASSOCIATED(basis_set_a))
THEN
445 basis_set_list(ikind)%gto_basis_set => basis_set_a
447 NULLIFY (basis_set_list(ikind)%gto_basis_set)
454 iatom=iatom, jatom=jatom, r=rab)
455 basis_set_a => basis_set_list(ikind)%gto_basis_set
456 IF (.NOT.
ASSOCIATED(basis_set_a)) cycle
457 basis_set_b => basis_set_list(jkind)%gto_basis_set
458 IF (.NOT.
ASSOCIATED(basis_set_b)) cycle
460 first_sgfa => basis_set_a%first_sgf
461 la_max => basis_set_a%lmax
462 la_min => basis_set_a%lmin
463 npgfa => basis_set_a%npgf
464 nseta = basis_set_a%nset
465 nsgfa => basis_set_a%nsgf_set
466 rpgfa => basis_set_a%pgf_radius
467 set_radius_a => basis_set_a%set_radius
468 sphi_a => basis_set_a%sphi
469 zeta => basis_set_a%zet
471 first_sgfb => basis_set_b%first_sgf
472 lb_max => basis_set_b%lmax
473 lb_min => basis_set_b%lmin
474 npgfb => basis_set_b%npgf
475 nsetb = basis_set_b%nset
476 nsgfb => basis_set_b%nsgf_set
477 rpgfb => basis_set_b%pgf_radius
478 set_radius_b => basis_set_b%set_radius
479 sphi_b => basis_set_b%sphi
480 zetb => basis_set_b%zet
482 atom_a = atom_of_kind(iatom)
483 atom_b = atom_of_kind(jatom)
485 ldsa =
SIZE(sphi_a, 1)
486 ldsb =
SIZE(sphi_b, 1)
487 ra(:) =
pbc(particle_set(iatom)%r(:), cell)
489 dab = sqrt(rab(1)*rab(1) + rab(2)*rab(2) + rab(3)*rab(3))
491 IF (iatom <= jatom)
THEN
499 IF (iatom == jatom)
THEN
506 dcost(i, 1)%block = 0.0_dp
507 dsint(i, 1)%block = 0.0_dp
508 dcost(i, 2)%block = 0.0_dp
509 dsint(i, 2)%block = 0.0_dp
513 ncoa = npgfa(iset)*
ncoset(la_max(iset))
514 sgfa = first_sgfa(1, iset)
516 IF (set_radius_a(iset) + set_radius_b(jset) < dab) cycle
517 ncob = npgfb(jset)*
ncoset(lb_max(jset))
518 sgfb = first_sgfb(1, jset)
520 CALL cossin(la_max(iset), npgfa(iset), zeta(:, iset), rpgfa(:, iset), la_min(iset), &
521 lb_max(jset), npgfb(jset), zetb(:, jset), rpgfb(:, jset), lb_min(jset), &
522 ra, rb, kvec, cosab, sinab, dcosab, dsinab)
524 CALL contract_all(dcost(i, 1)%block, dsint(i, 1)%block, &
525 ncoa, nsgfa(iset), sgfa, sphi_a, ldsa, &
526 ncob, nsgfb(jset), sgfb, sphi_b, ldsb, &
527 dcosab(:, :, i), dsinab(:, :, i), ldab, work, ldab)
530 CALL cossin(lb_max(jset), npgfb(jset), zetb(:, jset), rpgfb(:, jset), lb_min(jset), &
531 la_max(iset), npgfa(iset), zeta(:, iset), rpgfa(:, iset), la_min(iset), &
532 rb, ra, kvec, cosab, sinab, dcosab, dsinab)
534 dcosab(1:ncoa, 1:ncob, i) = transpose(dcosab(1:ncob, 1:ncoa, i))
535 dsinab(1:ncoa, 1:ncob, i) = transpose(dsinab(1:ncob, 1:ncoa, i))
536 CALL contract_all(dcost(i, 2)%block, dsint(i, 2)%block, &
537 ncoa, nsgfa(iset), sgfa, sphi_a, ldsa, &
538 ncob, nsgfb(jset), sgfb, sphi_b, ldsb, &
539 dcosab(:, :, i), dsinab(:, :, i), ldab, work, ldab)
545 DO ispin = 1, dft_control%nspins
546 NULLIFY (rblock, iblock)
548 row=irow, col=icol, block=rblock, found=found)
551 row=irow, col=icol, block=iblock, found=found)
555 cpassert(
SIZE(iblock, 1) == n1)
556 cpassert(
SIZE(iblock, 2) == n2)
559 IF (iatom <= jatom)
THEN
561 forcea(i) = forcea(i) + sum(rblock(1:n1, 1:n2)*dsint(i, 1)%block(1:n1, 1:n2)) &
562 - sum(iblock(1:n1, 1:n2)*dcost(i, 1)%block(1:n1, 1:n2))
563 forceb(i) = forceb(i) + sum(rblock(1:n1, 1:n2)*dsint(i, 2)%block(1:n1, 1:n2)) &
564 - sum(iblock(1:n1, 1:n2)*dcost(i, 2)%block(1:n1, 1:n2))
568 forcea(i) = forcea(i) + sum(transpose(rblock(1:n1, 1:n2))*dsint(i, 1)%block(1:n2, 1:n1)) &
569 - sum(transpose(iblock(1:n1, 1:n2))*dcost(i, 1)%block(1:n2, 1:n1))
570 forceb(i) = forceb(i) + sum(transpose(rblock(1:n1, 1:n2))*dsint(i, 2)%block(1:n2, 1:n1)) &
571 - sum(transpose(iblock(1:n1, 1:n2))*dcost(i, 2)%block(1:n2, 1:n1))
575 force(ikind)%efield(1:3, atom_a) = force(ikind)%efield(1:3, atom_a) - fab*fpolvec(idir)*forcea(1:3)
576 force(jkind)%efield(1:3, atom_b) = force(jkind)%efield(1:3, atom_b) - fab*fpolvec(idir)*forceb(1:3)
578 f0 = -fab*fpolvec(idir)
585 DEALLOCATE (basis_set_list)
596 cqi(idir) = qi(idir) + ci(idir)
597 IF (cqi(idir) >
pi) cqi(idir) = cqi(idir) -
twopi
598 IF (cqi(idir) < -
pi) cqi(idir) = cqi(idir) +
twopi
600 IF (abs(efield%polarisation(idir) - cqi(idir)) >
pi)
THEN
601 ti(idir) = (efield%polarisation(idir) - cqi(idir))/
pi
603 cqi(idir) = cqi(idir) + sign(1.0_dp, ti(idir))*
twopi
604 IF (abs(efield%polarisation(idir) - cqi(idir)) <
pi)
EXIT
607 ener_field = ener_field + fpolvec(idir)*cqi(idir)
611 IF (calculate_forces)
THEN
613 IF (abs(efield%field_energy - ener_field) >
pi*abs(sum(fpolvec)))
THEN
614 cpwarn(
"Large change of e-field energy detected. Correct for non-smooth energy surface")
616 efield%field_energy = ener_field
617 efield%polarisation(:) = cqi(:)
619 energy%efield = ener_field
621 IF (.NOT. just_energy)
THEN
623 DO ispin = 1, dft_control%nspins
630 ti(j) = ti(j) + hmat(j, i)*cqi(i)
635 virial%pv_virial(i, j) = virial%pv_virial(i, j) - fieldpol(i)*ti(j)
641 DO ispin = 1, dft_control%nspins
645 IF (mos(ispin)%use_mo_coeff_b)
CALL cp_fm_release(mo_coeff_tmp(ispin))
646 DO i = 1,
SIZE(op_fm_set, 1)
652 DEALLOCATE (inv_mat, inv_work, op_fm_set, opvec, eigrmat)
653 DEALLOCATE (mo_coeff_tmp, mo_derivs_tmp)
655 IF (calculate_forces)
THEN
656 DO ikind = 1,
SIZE(atomic_kind_set)
657 CALL para_env%sum(force(ikind)%efield)
659 DEALLOCATE (cosab, sinab, work, dcosab, dsinab)
661 DEALLOCATE (dcost(i, 1)%block, dsint(i, 1)%block)
662 DEALLOCATE (dcost(i, 2)%block, dsint(i, 2)%block)
666 CALL timestop(handle)
668 END SUBROUTINE qs_efield_derivatives
676 SUBROUTINE qs_dispfield_derivatives(qs_env, just_energy, calculate_forces)
678 LOGICAL,
INTENT(IN) :: just_energy, calculate_forces
680 CHARACTER(LEN=*),
PARAMETER :: routinen =
'qs_dispfield_derivatives'
682 COMPLEX(dp) :: zdet, zdeta, zi(3)
683 INTEGER :: handle, i, ia, iatom, icol, idir, ikind, iodeb, irow, iset, ispin, jatom, jkind, &
684 jset, ldab, ldsa, ldsb, lsab, n1, n2, nao, natom, ncoa, ncob, nkind, nmo, nseta, nsetb, &
686 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: atom_of_kind
687 INTEGER,
DIMENSION(:),
POINTER :: la_max, la_min, lb_max, lb_min, npgfa, &
689 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgfa, first_sgfb
690 LOGICAL :: found, uniform, use_virial
691 REAL(
dp) :: charge, ci(3), cqi(3), dab, dd, di(3), ener_field, fab, fieldpol(3), focc, &
692 hmat(3, 3), occ, omega, qi(3), rlog(3), strength, zlog(3)
693 REAL(
dp),
DIMENSION(3) :: dfilter, forcea, forceb, kvec, ra, rab, &
695 REAL(
dp),
DIMENSION(:, :),
POINTER :: cosab, iblock, rblock, sinab, work
696 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: dcosab, dsinab, force_tmp
697 REAL(kind=
dp),
DIMENSION(:),
POINTER :: set_radius_a, set_radius_b
698 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: rpgfa, rpgfb, sphi_a, sphi_b, zeta, zetb
702 TYPE(
cp_cfm_type),
ALLOCATABLE,
DIMENSION(:) :: eigrmat, inv_mat
704 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: mo_coeff_tmp
705 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:, :) :: inv_work, mo_derivs_tmp, op_fm_set, opvec
707 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_s, mo_derivs
709 TYPE(
dbcsr_type),
POINTER :: cosmat, mo_coeff_b, sinmat
717 DIMENSION(:),
POINTER :: nl_iterator
723 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
727 CALL timeset(routinen, handle)
729 NULLIFY (dft_control, cell, particle_set)
730 CALL get_qs_env(qs_env, dft_control=dft_control, cell=cell, &
731 particle_set=particle_set, virial=virial)
732 NULLIFY (qs_kind_set, efield, para_env, sab_orb)
733 CALL get_qs_env(qs_env=qs_env, qs_kind_set=qs_kind_set, &
734 efield=efield, energy=energy, para_env=para_env, sab_orb=sab_orb)
737 use_virial = virial%pv_availability .AND. (.NOT. virial%pv_numer)
738 use_virial = use_virial .AND. calculate_forces
741 cpabort(
"Stress tensor for periodic D-field not implemented")
744 dfilter(1:3) = dft_control%period_efield%d_filter(1:3)
747 strength = dft_control%period_efield%strength
748 IF (
ALLOCATED(dft_control%period_efield%strength_list))
THEN
749 strength = dft_control%period_efield%strength_list(mod(qs_env%sim_step &
750 - dft_control%period_efield%start_frame,
SIZE(dft_control%period_efield%strength_list)) + 1)
753 fieldpol = dft_control%period_efield%polarisation
754 fieldpol = fieldpol/norm2(fieldpol)
755 fieldpol = fieldpol*strength
758 hmat = cell%hmat(:, :)/(
twopi*omega)
761 natom =
SIZE(particle_set)
762 IF (calculate_forces)
THEN
763 CALL get_qs_env(qs_env=qs_env, atomic_kind_set=atomic_kind_set, force=force)
765 ALLOCATE (force_tmp(natom, 3, 3))
768 zi(:) = cmplx(1._dp, 0._dp,
dp)
771 CALL get_qs_kind(qs_kind_set(ikind), core_charge=charge)
772 ria = particle_set(ia)%r
775 kvec(:) =
twopi*cell%h_inv(idir, :)
776 dd = sum(kvec(:)*ria(:))
777 zdeta = cmplx(cos(dd), sin(dd), kind=
dp)**charge
778 zi(idir) = zi(idir)*zdeta
780 IF (calculate_forces)
THEN
781 IF (para_env%mepos == 0)
THEN
783 force_tmp(ia, i, i) = force_tmp(ia, i, i) + charge/omega
788 rlog = aimag(log(zi))
793 DO ispin = 1, dft_control%nspins
794 CALL get_mo_set(mo_set=mos(ispin), maxocc=occ, uniform_occupation=uniform)
795 IF (.NOT. uniform)
THEN
796 cpabort(
"Berry phase moments for non uniform MO occupation numbers not implemented")
802 CALL get_qs_env(qs_env=qs_env, mo_derivs=mo_derivs)
803 ALLOCATE (op_fm_set(2, dft_control%nspins))
804 ALLOCATE (opvec(2, dft_control%nspins))
805 ALLOCATE (eigrmat(dft_control%nspins))
806 ALLOCATE (inv_mat(dft_control%nspins))
807 ALLOCATE (inv_work(2, dft_control%nspins))
808 ALLOCATE (mo_derivs_tmp(3,
SIZE(mo_derivs)))
809 ALLOCATE (mo_coeff_tmp(
SIZE(mo_derivs)))
812 DO ispin = 1, dft_control%nspins
813 NULLIFY (tmp_fm_struct, mo_coeff)
814 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff, nao=nao, nmo=nmo)
816 ncol_global=nmo, para_env=para_env, context=mo_coeff%matrix_struct%context)
817 CALL cp_fm_create(mo_coeff_tmp(ispin), mo_coeff%matrix_struct)
819 CALL cp_fm_create(mo_derivs_tmp(i, ispin), mo_coeff%matrix_struct)
820 CALL cp_fm_set_all(matrix=mo_derivs_tmp(i, ispin), alpha=0.0_dp)
822 DO i = 1,
SIZE(op_fm_set, 1)
823 CALL cp_fm_create(opvec(i, ispin), mo_coeff%matrix_struct)
825 CALL cp_fm_create(inv_work(i, ispin), op_fm_set(i, ispin)%matrix_struct)
827 CALL cp_cfm_create(eigrmat(ispin), op_fm_set(1, ispin)%matrix_struct)
828 CALL cp_cfm_create(inv_mat(ispin), op_fm_set(1, ispin)%matrix_struct)
832 IF (calculate_forces)
THEN
834 CALL get_qs_env(qs_env=qs_env, matrix_s=matrix_s)
835 ALLOCATE (tempmat(2, dft_control%nspins))
836 DO ispin = 1, dft_control%nspins
837 ALLOCATE (tempmat(1, ispin)%matrix, tempmat(2, ispin)%matrix)
838 CALL dbcsr_copy(tempmat(1, ispin)%matrix, matrix_s(1)%matrix,
'TEMPMAT')
839 CALL dbcsr_copy(tempmat(2, ispin)%matrix, matrix_s(1)%matrix,
'TEMPMAT')
840 CALL dbcsr_set(tempmat(1, ispin)%matrix, 0.0_dp)
841 CALL dbcsr_set(tempmat(2, ispin)%matrix, 0.0_dp)
845 ALLOCATE (cosab(ldab, ldab), sinab(ldab, ldab), work(ldab, ldab))
846 ALLOCATE (dcosab(ldab, ldab, 3), dsinab(ldab, ldab, 3))
847 lsab = max(lsab, ldab)
849 ALLOCATE (dcost(i, 1)%block(lsab, lsab), dsint(i, 1)%block(lsab, lsab))
850 ALLOCATE (dcost(i, 2)%block(lsab, lsab), dsint(i, 2)%block(lsab, lsab))
858 cosmat => efield%cosmat(idir)%matrix
859 sinmat => efield%sinmat(idir)%matrix
862 DO ispin = 1, dft_control%nspins
863 IF (mos(ispin)%use_mo_coeff_b)
THEN
864 CALL get_mo_set(mo_set=mos(ispin), nao=nao, mo_coeff_b=mo_coeff_b, nmo=nmo)
867 CALL get_mo_set(mo_set=mos(ispin), nao=nao, mo_coeff=mo_coeff, nmo=nmo)
868 mo_coeff_tmp(ispin) = mo_coeff
871 CALL parallel_gemm(
"T",
"N", nmo, nmo, nao, 1.0_dp, mo_coeff_tmp(ispin), opvec(1, ispin), 0.0_dp, &
874 CALL parallel_gemm(
"T",
"N", nmo, nmo, nao, 1.0_dp, mo_coeff_tmp(ispin), opvec(2, ispin), 0.0_dp, &
879 DO ispin = 1, dft_control%nspins
883 CALL cp_cfm_solve(eigrmat(ispin), inv_mat(ispin), zdeta)
887 zlog(idir) = aimag(log(zi(idir)))
889 IF (.NOT. just_energy)
THEN
891 DO ispin = 1, dft_control%nspins
892 inv_work(1, ispin)%local_data(:, :) = real(inv_mat(ispin)%local_data(:, :),
dp)
893 inv_work(2, ispin)%local_data(:, :) = aimag(inv_mat(ispin)%local_data(:, :))
894 CALL get_mo_set(mo_set=mos(ispin), nao=nao, nmo=nmo)
897 CALL parallel_gemm(
"N",
"N", nao, nmo, nmo, focc, opvec(1, ispin), inv_work(2, ispin), &
898 1.0_dp, mo_derivs_tmp(idir, ispin))
899 CALL parallel_gemm(
"N",
"N", nao, nmo, nmo, -focc, opvec(2, ispin), inv_work(1, ispin), &
900 1.0_dp, mo_derivs_tmp(idir, ispin))
906 IF (calculate_forces)
THEN
907 nkind =
SIZE(qs_kind_set)
908 natom =
SIZE(particle_set)
909 kvec(:) =
twopi*cell%h_inv(idir, :)
913 DO ispin = 1, dft_control%nspins
914 CALL dbcsr_set(tempmat(1, ispin)%matrix, 0.0_dp)
915 CALL dbcsr_set(tempmat(2, ispin)%matrix, 0.0_dp)
916 CALL get_mo_set(mo_set=mos(ispin), nao=nao, nmo=nmo)
917 CALL parallel_gemm(
"N",
"N", nao, nmo, nmo, 1.0_dp, mo_coeff_tmp(ispin), inv_work(1, ispin), 0.0_dp, &
919 CALL parallel_gemm(
"N",
"N", nao, nmo, nmo, 1.0_dp, mo_coeff_tmp(ispin), inv_work(2, ispin), 0.0_dp, &
922 matrix_v=opvec(1, ispin), matrix_g=mo_coeff_tmp(ispin), ncol=nmo)
924 matrix_v=opvec(2, ispin), matrix_g=mo_coeff_tmp(ispin), ncol=nmo)
928 ALLOCATE (basis_set_list(nkind))
930 qs_kind => qs_kind_set(ikind)
931 CALL get_qs_kind(qs_kind=qs_kind, basis_set=basis_set_a)
932 IF (
ASSOCIATED(basis_set_a))
THEN
933 basis_set_list(ikind)%gto_basis_set => basis_set_a
935 NULLIFY (basis_set_list(ikind)%gto_basis_set)
942 iatom=iatom, jatom=jatom, r=rab)
943 basis_set_a => basis_set_list(ikind)%gto_basis_set
944 IF (.NOT.
ASSOCIATED(basis_set_a)) cycle
945 basis_set_b => basis_set_list(jkind)%gto_basis_set
946 IF (.NOT.
ASSOCIATED(basis_set_b)) cycle
948 first_sgfa => basis_set_a%first_sgf
949 la_max => basis_set_a%lmax
950 la_min => basis_set_a%lmin
951 npgfa => basis_set_a%npgf
952 nseta = basis_set_a%nset
953 nsgfa => basis_set_a%nsgf_set
954 rpgfa => basis_set_a%pgf_radius
955 set_radius_a => basis_set_a%set_radius
956 sphi_a => basis_set_a%sphi
957 zeta => basis_set_a%zet
959 first_sgfb => basis_set_b%first_sgf
960 lb_max => basis_set_b%lmax
961 lb_min => basis_set_b%lmin
962 npgfb => basis_set_b%npgf
963 nsetb = basis_set_b%nset
964 nsgfb => basis_set_b%nsgf_set
965 rpgfb => basis_set_b%pgf_radius
966 set_radius_b => basis_set_b%set_radius
967 sphi_b => basis_set_b%sphi
968 zetb => basis_set_b%zet
970 ldsa =
SIZE(sphi_a, 1)
971 ldsb =
SIZE(sphi_b, 1)
972 ra(:) =
pbc(particle_set(iatom)%r(:), cell)
974 dab = sqrt(rab(1)*rab(1) + rab(2)*rab(2) + rab(3)*rab(3))
976 IF (iatom <= jatom)
THEN
984 IF (iatom == jatom)
THEN
991 dcost(i, 1)%block = 0.0_dp
992 dsint(i, 1)%block = 0.0_dp
993 dcost(i, 2)%block = 0.0_dp
994 dsint(i, 2)%block = 0.0_dp
998 ncoa = npgfa(iset)*
ncoset(la_max(iset))
999 sgfa = first_sgfa(1, iset)
1001 IF (set_radius_a(iset) + set_radius_b(jset) < dab) cycle
1002 ncob = npgfb(jset)*
ncoset(lb_max(jset))
1003 sgfb = first_sgfb(1, jset)
1005 CALL cossin(la_max(iset), npgfa(iset), zeta(:, iset), rpgfa(:, iset), la_min(iset), &
1006 lb_max(jset), npgfb(jset), zetb(:, jset), rpgfb(:, jset), lb_min(jset), &
1007 ra, rb, kvec, cosab, sinab, dcosab, dsinab)
1009 CALL contract_all(dcost(i, 1)%block, dsint(i, 1)%block, &
1010 ncoa, nsgfa(iset), sgfa, sphi_a, ldsa, &
1011 ncob, nsgfb(jset), sgfb, sphi_b, ldsb, &
1012 dcosab(:, :, i), dsinab(:, :, i), ldab, work, ldab)
1015 CALL cossin(lb_max(jset), npgfb(jset), zetb(:, jset), rpgfb(:, jset), lb_min(jset), &
1016 la_max(iset), npgfa(iset), zeta(:, iset), rpgfa(:, iset), la_min(iset), &
1017 rb, ra, kvec, cosab, sinab, dcosab, dsinab)
1019 dcosab(1:ncoa, 1:ncob, i) = transpose(dcosab(1:ncob, 1:ncoa, i))
1020 dsinab(1:ncoa, 1:ncob, i) = transpose(dsinab(1:ncob, 1:ncoa, i))
1021 CALL contract_all(dcost(i, 2)%block, dsint(i, 2)%block, &
1022 ncoa, nsgfa(iset), sgfa, sphi_a, ldsa, &
1023 ncob, nsgfb(jset), sgfb, sphi_b, ldsb, &
1024 dcosab(:, :, i), dsinab(:, :, i), ldab, work, ldab)
1030 DO ispin = 1, dft_control%nspins
1031 NULLIFY (rblock, iblock)
1033 row=irow, col=icol, block=rblock, found=found)
1036 row=irow, col=icol, block=iblock, found=found)
1038 n1 =
SIZE(rblock, 1)
1039 n2 =
SIZE(rblock, 2)
1040 cpassert(
SIZE(iblock, 1) == n1)
1041 cpassert(
SIZE(iblock, 2) == n2)
1042 cpassert(lsab >= n1)
1043 cpassert(lsab >= n2)
1044 IF (iatom <= jatom)
THEN
1046 forcea(i) = forcea(i) + sum(rblock(1:n1, 1:n2)*dsint(i, 1)%block(1:n1, 1:n2)) &
1047 - sum(iblock(1:n1, 1:n2)*dcost(i, 1)%block(1:n1, 1:n2))
1048 forceb(i) = forceb(i) + sum(rblock(1:n1, 1:n2)*dsint(i, 2)%block(1:n1, 1:n2)) &
1049 - sum(iblock(1:n1, 1:n2)*dcost(i, 2)%block(1:n1, 1:n2))
1053 forcea(i) = forcea(i) + sum(transpose(rblock(1:n1, 1:n2))*dsint(i, 1)%block(1:n2, 1:n1)) &
1054 - sum(transpose(iblock(1:n1, 1:n2))*dcost(i, 1)%block(1:n2, 1:n1))
1055 forceb(i) = forceb(i) + sum(transpose(rblock(1:n1, 1:n2))*dsint(i, 2)%block(1:n2, 1:n1)) &
1056 - sum(transpose(iblock(1:n1, 1:n2))*dcost(i, 2)%block(1:n2, 1:n1))
1061 force_tmp(iatom, :, i) = force_tmp(iatom, :, i) - fab*hmat(i, idir)*forcea(:)
1062 force_tmp(jatom, :, i) = force_tmp(jatom, :, i) - fab*hmat(i, idir)*forceb(:)
1066 DEALLOCATE (basis_set_list)
1072 cqi(idir) = rlog(idir) + zlog(idir)
1073 IF (cqi(idir) >
pi) cqi(idir) = cqi(idir) -
twopi
1074 IF (cqi(idir) < -
pi) cqi(idir) = cqi(idir) +
twopi
1076 IF (calculate_forces)
THEN
1077 IF (abs(efield%polarisation(idir) - cqi(idir)) >
pi)
THEN
1078 di(idir) = (efield%polarisation(idir) - cqi(idir))/
pi
1080 cqi(idir) = cqi(idir) + sign(1.0_dp, di(idir))*
twopi
1081 IF (abs(efield%polarisation(idir) - cqi(idir)) <
pi)
EXIT
1090 ci(idir) = ci(idir) + hmat(idir, i)*cqi(i)
1095 IF (calculate_forces)
THEN
1096 ener_field = sum(ci)
1098 IF (abs(efield%field_energy - ener_field) >
pi*abs(sum(hmat)))
THEN
1099 cpwarn(
"Large change of e-field energy detected. Correct for non-smooth energy surface")
1101 efield%field_energy = ener_field
1102 efield%polarisation(:) = cqi(:)
1108 ener_field = ener_field + dfilter(i)*(fieldpol(i) - 2._dp*
twopi*ci(i))**2
1110 energy%efield = 0.25_dp*omega/
twopi*ener_field
1113 IF (para_env%is_source())
THEN
1116 WRITE (iodeb,
'(A,T61,F20.10)')
" Polarisation Quantum: ", 2._dp*
twopi*
twopi*hmat(3, 3)
1117 WRITE (iodeb,
'(A,T21,3F20.10)')
" Polarisation: ", 2._dp*
twopi*ci(1:3)
1118 WRITE (iodeb,
'(A,T21,3F20.10)')
" Displacement: ", fieldpol(1:3)
1119 WRITE (iodeb,
'(A,T21,3F20.10)')
" E-Field: ", ((fieldpol(i) - 2._dp*
twopi*ci(i)), i=1, 3)
1120 WRITE (iodeb,
'(A,T61,F20.10)')
" Disp Free Energy:", energy%efield
1124 IF (.NOT. just_energy)
THEN
1126 di(i) = -omega*(fieldpol(i) - 2._dp*
twopi*ci(i))*dfilter(i)
1129 DO ispin = 1, dft_control%nspins
1133 mo_derivs_tmp(idir, ispin))
1136 DO ispin = 1, dft_control%nspins
1141 IF (calculate_forces)
THEN
1145 iatom = atom_of_kind(ia)
1146 force(ikind)%efield(1:3, iatom) = force(ikind)%efield(1:3, iatom) + di(i)*force_tmp(ia, 1:3, i)
1151 DO ispin = 1, dft_control%nspins
1154 IF (mos(ispin)%use_mo_coeff_b)
CALL cp_fm_release(mo_coeff_tmp(ispin))
1158 DO i = 1,
SIZE(op_fm_set, 1)
1164 DEALLOCATE (inv_mat, inv_work, op_fm_set, opvec, eigrmat)
1165 DEALLOCATE (mo_coeff_tmp, mo_derivs_tmp)
1167 IF (calculate_forces)
THEN
1168 DO ikind = 1,
SIZE(atomic_kind_set)
1169 CALL para_env%sum(force(ikind)%efield)
1171 DEALLOCATE (force_tmp)
1172 DEALLOCATE (cosab, sinab, work, dcosab, dsinab)
1174 DEALLOCATE (dcost(i, 1)%block, dsint(i, 1)%block)
1175 DEALLOCATE (dcost(i, 2)%block, dsint(i, 2)%block)
1179 CALL timestop(handle)
1181 END SUBROUTINE qs_dispfield_derivatives
1203 SUBROUTINE contract_all(cos_block, sin_block, &
1204 ncoa, nsgfa, sgfa, sphi_a, ldsa, &
1205 ncob, nsgfb, sgfb, sphi_b, ldsb, &
1206 cosab, sinab, ldab, work, ldwork)
1208 REAL(
dp),
DIMENSION(:, :),
POINTER :: cos_block, sin_block
1209 INTEGER,
INTENT(IN) :: ncoa, nsgfa, sgfa
1210 REAL(
dp),
DIMENSION(:, :),
INTENT(IN) :: sphi_a
1211 INTEGER,
INTENT(IN) :: ldsa, ncob, nsgfb, sgfb
1212 REAL(
dp),
DIMENSION(:, :),
INTENT(IN) :: sphi_b
1213 INTEGER,
INTENT(IN) :: ldsb
1214 REAL(
dp),
DIMENSION(:, :),
INTENT(IN) :: cosab, sinab
1215 INTEGER,
INTENT(IN) :: ldab
1216 REAL(
dp),
DIMENSION(:, :) :: work
1217 INTEGER,
INTENT(IN) :: ldwork
1221 CALL dgemm(
"N",
"N", ncoa, nsgfb, ncob, 1.0_dp, cosab(1, 1), ldab, &
1222 sphi_b(1, sgfb), ldsb, 0.0_dp, work(1, 1), ldwork)
1224 CALL dgemm(
"T",
"N", nsgfa, nsgfb, ncoa, 1.0_dp, sphi_a(1, sgfa), ldsa, &
1225 work(1, 1), ldwork, 1.0_dp, cos_block(sgfa, sgfb),
SIZE(cos_block, 1))
1228 CALL dgemm(
"N",
"N", ncoa, nsgfb, ncob, 1.0_dp, sinab(1, 1), ldab, &
1229 sphi_b(1, sgfb), ldsb, 0.0_dp, work(1, 1), ldwork)
1231 CALL dgemm(
"T",
"N", nsgfa, nsgfb, ncoa, 1.0_dp, sphi_a(1, sgfa), ldsa, &
1232 work(1, 1), ldwork, 1.0_dp, sin_block(sgfa, sgfb),
SIZE(sin_block, 1))
1234 END SUBROUTINE contract_all
static void dgemm(const char transa, const char transb, const int m, const int n, const int k, const double alpha, const double *a, const int lda, const double *b, const int ldb, const double beta, double *c, const int ldc)
Convenient wrapper to hide Fortran nature of dgemm_, swapping a and b.
Calculation of the moment integrals over Cartesian Gaussian-type functions.
subroutine, public cossin(la_max_set, npgfa, zeta, rpgfa, la_min_set, lb_max, npgfb, zetb, rpgfb, lb_min, rac, rbc, kvec, cosab, sinab, dcosab, dsinab)
...
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.
collect pointers to a block of reals
Handles all functions related to the CELL.
Basic linear algebra operations for complex full matrices.
subroutine, public cp_cfm_solve(matrix_a, general_a, determinant)
Solve the system of linear equations A*b=A_general using LU decomposition. Pay attention that both ma...
subroutine, public cp_cfm_scale_and_add_fm(alpha, matrix_a, beta, matrix_b)
Scale and add two BLACS matrices (a = alpha*a + beta*b). where b is a real matrix (adapted from cp_cf...
Represents a complex full matrix distributed on many processors.
subroutine, public cp_cfm_release(matrix)
Releases a full matrix.
subroutine, public cp_cfm_create(matrix, matrix_struct, name, nrow, ncol, set_zero)
Creates a new full matrix with the given structure.
subroutine, public cp_cfm_set_all(matrix, alpha, beta)
Set all elements of the full matrix to alpha. Besides, set all diagonal matrix elements to beta (if g...
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_set(matrix, alpha)
...
DBCSR operations in CP2K.
subroutine, public cp_dbcsr_sm_fm_multiply(matrix, fm_in, fm_out, ncol, alpha, beta)
multiply a dbcsr with a fm matrix
subroutine, public copy_dbcsr_to_fm(matrix, fm)
Copy a DBCSR matrix to a BLACS matrix.
subroutine, public cp_dbcsr_plus_fm_fm_t(sparse_matrix, matrix_v, matrix_g, ncol, alpha, keep_sparsity, symmetry_mode)
performs the multiplication sparse_matrix+dense_mat*dens_mat^T if matrix_g is not explicitly given,...
subroutine, public copy_fm_to_dbcsr(fm, matrix, keep_sparsity)
Copy a BLACS matrix to a dbcsr matrix.
Basic linear algebra operations for full matrices.
subroutine, public cp_fm_scale_and_add(alpha, matrix_a, beta, matrix_b)
calc A <- alpha*A + beta*B optimized for alpha == 1.0 (just add beta*B) and beta == 0....
represent the structure of a full matrix
subroutine, public cp_fm_struct_create(fmstruct, para_env, context, nrow_global, ncol_global, nrow_block, ncol_block, descriptor, first_p_pos, local_leading_dimension, template_fmstruct, square_blocks, force_block)
allocates and initializes a full matrix structure
subroutine, public cp_fm_struct_release(fmstruct)
releases a full matrix structure
represent a full matrix distributed on many processors
subroutine, public cp_fm_set_all(matrix, alpha, beta)
set all elements of a matrix to the same value, and optionally the diagonal to a different one
subroutine, public cp_fm_create(matrix, matrix_struct, name, nrow, ncol, set_zero)
creates a new full matrix with the given structure
Defines the basic variable types.
integer, parameter, public dp
Definition of mathematical constants and functions.
real(kind=dp), parameter, public pi
complex(kind=dp), parameter, public z_one
complex(kind=dp), parameter, public gaussi
real(kind=dp), parameter, public twopi
complex(kind=dp), parameter, public z_zero
Interface to the message passing library MPI.
Provides Cartesian and spherical orbital pointers and indices.
integer, dimension(:), allocatable, public ncoset
basic linear algebra operations for full matrixes
Define the data structure for the particle information.
Calculates the energy contribution and the mo_derivative of a static periodic electric field.
subroutine, public qs_efield_berry_phase(qs_env, just_energy, calculate_forces)
...
subroutine, public get_qs_env(qs_env, atomic_kind_set, qs_kind_set, cell, super_cell, cell_ref, use_ref_cell, kpoints, dft_control, mos, sab_orb, sab_all, qmmm, qmmm_periodic, mimic, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, matrix_vhxc, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, xcint_weights, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, rhoz_cneo_set, ecoul_1c, rho0_s_rs, rho0_s_gs, rhoz_cneo_s_rs, rhoz_cneo_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, lri_env, lri_density, exstate_env, ec_env, harris_env, dispersion_env, gcp_env, vee, rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, wanniercentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs, do_rixs, tb_tblite)
Get the QUICKSTEP environment.
subroutine, public set_qs_env(qs_env, super_cell, mos, qmmm, qmmm_periodic, mimic, ewald_env, ewald_pw, mpools, rho_external, external_vxc, mask, scf_control, rel_control, qs_charges, ks_env, ks_qmmm_env, wf_history, scf_env, active_space, input, oce, rho_atom_set, rho0_atom_set, rho0_mpole, run_rtp, rtp, rhoz_set, rhoz_tot, ecoul_1c, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, efield, rhoz_cneo_set, linres_control, xas_env, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, ls_scf_env, do_transport, transport_env, lri_env, lri_density, exstate_env, ec_env, dispersion_env, harris_env, gcp_env, mp2_env, bs_env, kg_env, force, kpoints, wanniercentres, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs, do_rixs, tb_tblite)
Set the QUICKSTEP environment.
Define the quickstep kind type and their sub types.
subroutine, public get_qs_kind(qs_kind, basis_set, basis_type, ncgf, nsgf, all_potential, tnadd_potential, gth_potential, sgp_potential, upf_potential, cneo_potential, se_parameter, dftb_parameter, xtb_parameter, dftb3_param, zatom, zeff, elec_conf, mao, lmax_dftb, alpha_core_charge, ccore_charge, core_charge, core_charge_radius, paw_proj_set, paw_atom, hard_radius, hard0_radius, max_rad_local, covalent_radius, vdw_radius, gpw_type_forced, harmonics, max_iso_not0, max_s_harm, grid_atom, ngrid_ang, ngrid_rad, lmax_rho0, dft_plus_u_atom, l_of_dft_plus_u, n_of_dft_plus_u, u_minus_j, hund_j, u_of_dft_plus_u, j_of_dft_plus_u, alpha_of_dft_plus_u, beta_of_dft_plus_u, j0_of_dft_plus_u, occupation_of_dft_plus_u, dispersion, bs_occupation, magnetization, no_optimize, addel, laddel, naddel, orbitals, max_scf, eps_scf, smear, u_ramping, u_minus_j_target, eps_u_ramping, proj_shell_charge, lr_atom, do_mtlr, u_j_loop, ao_coef, init_u_ramping_each_scf, reltmat, ghost, monovalent, floating, name, element_symbol, pao_basis_size, pao_model_file, pao_potentials, pao_descriptors, nelec)
Get attributes of an atomic kind.
subroutine, public 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, do_mtlr_present, basis_type, total_zeff_corr, npgf_seg, cneo_potential_present, nkind_q, natom_q)
Get attributes of an atomic kind set.
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.
Calculates the moment integrals <a|r^m|b> and <a|r x d/dr|b>.
subroutine, public build_berry_moment_matrix(qs_env, cosmat, sinmat, kvec, sab_orb_external, basis_type)
...
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)
...
type for berry phase efield matrices. At the moment only used for cosmat and sinmat
subroutine, public set_efield_matrices(efield, sinmat, cosmat, dipmat)
...
subroutine, public init_efield_matrices(efield)
...
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 defining parameters related to the simulation cell.
Represent a complex full matrix.
keeps the information about the structure of a full matrix
stores all the informations relevant to an mpi environment
Provides all information about a quickstep kind.