21 sgp_pseudo, upf_pseudo
39 #include "./base/base_uses.f90"
45 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'atom_electronic_structure'
60 TYPE(atom_type),
POINTER ::
atom
61 INTEGER,
INTENT(IN) :: iw
62 LOGICAL,
INTENT(IN),
OPTIONAL :: noguess
63 LOGICAL,
INTENT(OUT),
OPTIONAL :: converged
65 CHARACTER(len=*),
PARAMETER :: routinen =
'calculate_atom'
67 INTEGER :: handle, method
69 TYPE(section_vals_type),
POINTER :: sub_section
71 CALL timeset(routinen, handle)
74 IF (
ASSOCIATED(
atom%xc_section))
THEN
78 IF (explicit)
CALL cp_abort(__location__,
"ADIABATIC_RESCALING not supported in ATOM code")
82 IF (explicit)
CALL cp_abort(__location__,
"VDW_POTENTIAL not supported in ATOM code")
86 IF (explicit)
CALL cp_abort(__location__,
"XC_POTENTIAL not supported in ATOM code")
90 IF (explicit)
CALL cp_abort(__location__,
"WF_CORRELATION methods not supported in ATOM code")
94 method =
atom%method_type
97 CALL calculate_atom_restricted(
atom, iw, noguess, converged)
99 CALL calculate_atom_unrestricted(
atom, iw, noguess, converged)
106 CALL timestop(handle)
126 SUBROUTINE calculate_atom_restricted(atom, iw, noguess, converged)
127 TYPE(atom_type),
POINTER ::
atom
128 INTEGER,
INTENT(IN) :: iw
129 LOGICAL,
INTENT(IN),
OPTIONAL :: noguess
130 LOGICAL,
INTENT(OUT),
OPTIONAL :: converged
132 CHARACTER(len=*),
PARAMETER :: routinen =
'calculate_atom_restricted'
134 INTEGER :: handle, i, iter, l, max_iter, method, &
136 LOGICAL :: do_hfx, doguess, is_converged, need_vxc, &
137 need_x, need_xc, need_zmp
138 REAL(kind=
dp) :: deps, eps_scf, hf_frac
139 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: ext_density, ext_vxc, tmp_dens
140 TYPE(atom_history_type) :: history
141 TYPE(opgrid_type),
POINTER :: cpot, density
142 TYPE(opmat_type),
POINTER :: fmat, hcore, jmat, kmat, xcmat
143 TYPE(section_vals_type),
POINTER :: xc_section
145 CALL timeset(routinen, handle)
147 IF (
PRESENT(noguess))
THEN
148 doguess = .NOT. noguess
155 method =
atom%method_type
156 max_iter =
atom%optimization%max_iter
157 eps_scf =
atom%optimization%eps_scf
181 need_zmp =
atom%do_zmp
185 ALLOCATE (ext_density(
atom%basis%grid%nr))
191 need_vxc =
atom%read_vxc
197 ALLOCATE (ext_vxc(
atom%basis%grid%nr))
203 reltyp =
atom%relativistic
210 SELECT CASE (
atom%potential%ppot_type)
218 hcore%op =
atom%integrals%kin -
atom%zcore*
atom%integrals%core
220 hcore%op =
atom%integrals%kin +
atom%integrals%tzora -
atom%zcore*
atom%integrals%core
222 hcore%op =
atom%integrals%hdkh
224 CASE (gth_pseudo, upf_pseudo, sgp_pseudo, ecp_pseudo)
225 hcore%op =
atom%integrals%kin +
atom%integrals%core +
atom%integrals%hnl
228 IF (
atom%potential%confinement)
THEN
229 hcore%op = hcore%op +
atom%potential%acon*
atom%integrals%conf
232 NULLIFY (fmat, jmat, kmat, xcmat)
238 NULLIFY (density, cpot)
247 ALLOCATE (tmp_dens(
SIZE(density%op)))
249 density%op = density%op + tmp_dens
250 DEALLOCATE (tmp_dens)
255 fmat%op = hcore%op + jmat%op + xcmat%op
257 atom%basis%nbas,
atom%integrals%nne,
atom%state%maxl_calc)
260 atom%state%maxl_occ,
atom%state%maxn_occ)
263 NULLIFY (history%dmat, history%hmat)
265 is_converged = .false.
273 atom%energy%eband = 0._dp
275 DO i = 1, min(
SIZE(
atom%state%occupation, 2),
SIZE(
atom%orbitals%ener, 1))
276 atom%energy%eband =
atom%energy%eband +
atom%orbitals%ener(i, l)*
atom%state%occupation(l, i)
281 SELECT CASE (
atom%potential%ppot_type)
285 atom%energy%eploc = 0._dp
286 atom%energy%epnl = 0._dp
287 CASE (gth_pseudo, upf_pseudo, sgp_pseudo, ecp_pseudo)
291 atom%energy%epseudo =
atom%energy%eploc +
atom%energy%epnl
297 IF (
atom%potential%confinement)
THEN
300 atom%energy%econfinement = 0._dp
305 SELECT CASE (
atom%coulomb_integral_type)
324 SELECT CASE (
atom%exchange_integral_type)
335 kmat%op = hf_frac*kmat%op
338 atom%energy%eexchange = 0._dp
346 ELSEIF (need_zmp)
THEN
349 ELSEIF (need_vxc)
THEN
354 atom%energy%exc = 0._dp
358 atom%energy%elsd = 0._dp
361 atom%energy%etot =
atom%energy%ecore +
atom%energy%ecoulomb +
atom%energy%eexchange +
atom%energy%exc
367 fmat%op = hcore%op + jmat%op + kmat%op + xcmat%op
371 atom%integrals%uptrans,
atom%basis%nbas,
atom%integrals%nne)
383 IF (deps < eps_scf)
THEN
384 is_converged = .true.
387 IF (iter >= max_iter)
THEN
389 WRITE (iw,
"(A)")
" No convergence within maximum number of iterations "
400 atom%basis%nbas,
atom%integrals%nne,
atom%state%maxl_calc)
402 atom%state%maxl_occ,
atom%state%maxn_occ)
423 IF (need_zmp)
DEALLOCATE (ext_density)
424 IF (need_vxc)
DEALLOCATE (ext_vxc)
426 IF (
PRESENT(converged))
THEN
427 converged = is_converged
430 CALL timestop(handle)
432 END SUBROUTINE calculate_atom_restricted
443 SUBROUTINE calculate_atom_unrestricted(atom, iw, noguess, converged)
444 TYPE(atom_type),
POINTER ::
atom
445 INTEGER,
INTENT(IN) :: iw
446 LOGICAL,
INTENT(IN),
OPTIONAL :: noguess
447 LOGICAL,
INTENT(OUT),
OPTIONAL :: converged
449 CHARACTER(len=*),
PARAMETER :: routinen =
'calculate_atom_unrestricted'
451 INTEGER :: handle, i, iter, k, l, max_iter, method, &
453 LOGICAL :: do_hfx, doguess, is_converged, lsdpot, &
455 REAL(kind=
dp) :: deps, depsa, depsb, eps_scf, hf_frac, &
457 TYPE(atom_history_type) :: historya, historyb
458 TYPE(opgrid_type),
POINTER :: cpot, density, rhoa, rhob
459 TYPE(opmat_type),
POINTER :: fmata, fmatb, hcore, hlsd, jmat, kmata, &
460 kmatb, xcmata, xcmatb
461 TYPE(section_vals_type),
POINTER :: xc_section
463 CALL timeset(routinen, handle)
465 IF (
PRESENT(noguess))
THEN
466 doguess = .NOT. noguess
473 method =
atom%method_type
474 max_iter =
atom%optimization%max_iter
475 eps_scf =
atom%optimization%eps_scf
499 IF (sum(abs(
atom%state%occa) + abs(
atom%state%occb)) == 0.0_dp)
THEN
501 nm = real((2*l + 1), kind=
dp)
503 ne =
atom%state%occupation(l, k)
504 IF (ne == 0._dp)
THEN
506 ELSEIF (ne == 2._dp*nm)
THEN
507 atom%state%occa(l, k) = nm
508 atom%state%occb(l, k) = nm
509 ELSEIF (
atom%state%multiplicity == -2)
THEN
510 atom%state%occa(l, k) = min(ne, nm)
511 atom%state%occb(l, k) = max(0._dp, ne - nm)
513 atom%state%occa(l, k) = 0.5_dp*(ne +
atom%state%multiplicity - 1._dp)
514 atom%state%occb(l, k) = ne -
atom%state%occa(l, k)
520 reltyp =
atom%relativistic
524 NULLIFY (hcore, hlsd)
530 SELECT CASE (
atom%potential%ppot_type)
538 hcore%op =
atom%integrals%kin -
atom%zcore*
atom%integrals%core
540 hcore%op =
atom%integrals%kin +
atom%integrals%tzora -
atom%zcore*
atom%integrals%core
542 hcore%op =
atom%integrals%hdkh
545 hcore%op =
atom%integrals%kin +
atom%integrals%core +
atom%integrals%hnl
546 IF (
atom%potential%gth_pot%lsdpot)
THEN
548 hlsd%op =
atom%integrals%clsd
550 CASE (upf_pseudo, sgp_pseudo, ecp_pseudo)
551 hcore%op =
atom%integrals%kin +
atom%integrals%core +
atom%integrals%hnl
554 IF (
atom%potential%confinement)
THEN
555 hcore%op = hcore%op +
atom%potential%acon*
atom%integrals%conf
558 NULLIFY (fmata, fmatb, jmat, kmata, kmatb, xcmata, xcmatb)
567 NULLIFY (density, rhoa, rhob, cpot)
576 density%op = rhoa%op + rhob%op
580 density%op = 2._dp*rhoa%op
583 fmata%op = hcore%op + hlsd%op + jmat%op + xcmata%op
585 atom%basis%nbas,
atom%integrals%nne,
atom%state%maxl_calc)
587 density%op = 2._dp*rhob%op
590 fmatb%op = hcore%op - hlsd%op + jmat%op + xcmatb%op
592 atom%basis%nbas,
atom%integrals%nne,
atom%state%maxl_calc)
595 atom%state%maxl_occ,
atom%state%maxn_occ)
597 atom%state%maxl_occ,
atom%state%maxn_occ)
598 atom%orbitals%pmat =
atom%orbitals%pmata +
atom%orbitals%pmatb
601 NULLIFY (historya%dmat, historya%hmat)
603 NULLIFY (historyb%dmat, historyb%hmat)
606 is_converged = .false.
614 atom%energy%eband = 0._dp
616 DO i = 1, min(
SIZE(
atom%state%occupation, 2),
SIZE(
atom%orbitals%ener, 1))
617 atom%energy%eband =
atom%energy%eband +
atom%orbitals%enera(i, l)*
atom%state%occa(l, i)
618 atom%energy%eband =
atom%energy%eband +
atom%orbitals%enerb(i, l)*
atom%state%occb(l, i)
623 SELECT CASE (
atom%potential%ppot_type)
627 atom%energy%eploc = 0._dp
628 atom%energy%epnl = 0._dp
629 CASE (gth_pseudo, upf_pseudo, sgp_pseudo, ecp_pseudo)
633 atom%energy%epseudo =
atom%energy%eploc +
atom%energy%epnl
639 IF (
atom%potential%confinement)
THEN
642 atom%energy%econfinement = 0._dp
647 SELECT CASE (
atom%coulomb_integral_type)
667 SELECT CASE (
atom%exchange_integral_type)
682 kmata%op = 2._dp*hf_frac*kmata%op
683 kmatb%op = 2._dp*hf_frac*kmatb%op
687 atom%energy%eexchange = 0._dp
698 atom%energy%exc = 0._dp
704 atom%energy%epseudo =
atom%energy%epseudo +
atom%energy%elsd
705 atom%energy%ecore =
atom%energy%ecore +
atom%energy%elsd
707 atom%energy%elsd = 0._dp
711 atom%energy%etot =
atom%energy%ecore +
atom%energy%ecoulomb +
atom%energy%eexchange +
atom%energy%exc
717 fmata%op = hcore%op + hlsd%op + jmat%op + kmata%op + xcmata%op
718 fmatb%op = hcore%op - hlsd%op + jmat%op + kmatb%op + xcmatb%op
721 CALL err_matrix(xcmata%op, depsa, fmata%op,
atom%orbitals%pmata,
atom%integrals%utrans, &
722 atom%integrals%uptrans,
atom%basis%nbas,
atom%integrals%nne)
723 CALL err_matrix(xcmatb%op, depsb, fmatb%op,
atom%orbitals%pmatb,
atom%integrals%utrans, &
724 atom%integrals%uptrans,
atom%basis%nbas,
atom%integrals%nne)
725 deps = 2._dp*max(depsa, depsb)
733 IF (deps < eps_scf)
THEN
734 is_converged = .true.
737 IF (iter >= max_iter)
THEN
739 WRITE (iw,
"(A)")
" No convergence within maximum number of iterations "
752 atom%basis%nbas,
atom%integrals%nne,
atom%state%maxl_calc)
754 atom%state%maxl_occ,
atom%state%maxn_occ)
756 atom%basis%nbas,
atom%integrals%nne,
atom%state%maxl_calc)
758 atom%state%maxl_occ,
atom%state%maxn_occ)
759 atom%orbitals%pmat =
atom%orbitals%pmata +
atom%orbitals%pmatb
786 IF (
PRESENT(converged))
THEN
787 converged = is_converged
790 CALL timestop(handle)
792 END SUBROUTINE calculate_atom_unrestricted
subroutine, public calculate_atom(atom, iw, noguess, converged)
General routine to perform electronic structure atomic calculations.
Optimizer for the atomic code.
subroutine, public atom_opt_fmat(fmat, history, err)
Construct a Kohn-Sham matrix for the next iteration based on the historic data.
pure subroutine, public atom_history_init(history, optimization, matrix)
Initialise a circular buffer to keep Kohn-Sham and density matrices from previous iteration.
pure subroutine, public atom_history_release(history)
Release circular buffer to keep historic matrices.
pure subroutine, public atom_history_update(history, pmat, fmat, emat, energy, error)
Add matrices from the current iteration into the circular buffer.
Routines that print various information about an atomic kind.
subroutine, public atom_print_energies(atom, iw)
Print energy components.
subroutine, public atom_print_iteration(iter, deps, etot, iw)
Print convergence information.
subroutine, public atom_print_state(state, iw)
Print information about electronic state.
subroutine, public atom_print_zmp_iteration(iter, deps, atom, iw)
Printing of the atomic iterations when ZMP is active.
Define the atom type and its sub types.
subroutine, public release_opmat(opmat)
...
subroutine, public release_opgrid(opgrid)
...
integer, parameter, public lmat
subroutine, public set_atom(atom, basis, state, integrals, orbitals, potential, zcore, pp_calc, do_zmp, doread, read_vxc, method_type, relativistic, coulomb_integral_type, exchange_integral_type, fmat)
...
subroutine, public create_opmat(opmat, n, lmax)
...
subroutine, public setup_hf_section(hf_frac, do_hfx, atom, xc_section, extype)
...
subroutine, public create_opgrid(opgrid, grid)
...
Some basic routines for atomic calculations.
subroutine, public slater_density(density1, density2, zcore, state, grid)
Calculate Slater density on a radial grid.
pure subroutine, public atom_denmat(pmat, wfn, nbas, occ, maxl, maxn)
Calculate a density matrix using atomic orbitals.
subroutine, public atom_read_external_vxc(vxc, atom, iw)
ZMP subroutine to read external v_xc in the atomic code.
pure subroutine, public eeri_contract(kmat, erint, pmat, nsize)
Contract exchange Electron Repulsion Integrals.
subroutine, public exchange_semi_analytic(kmat, state, occ, wfn, basis, hfx_pot)
Calculate the exchange potential semi-analytically.
pure subroutine, public ceri_contract(jmat, erint, pmat, nsize, all_nu)
Contract Coulomb Electron Repulsion Integrals.
subroutine, public coulomb_potential_analytic(cpot, pmat, basis, grid, maxl)
Analytically compute the Coulomb potential on an atomic radial grid.
pure subroutine, public err_matrix(emat, demax, kmat, pmat, umat, upmat, nval, nbs)
Calculate the error matrix for each angular momentum.
subroutine, public atom_density(density, pmat, basis, maxl, typ, rr)
Map the electron density on an atomic radial grid.
pure subroutine, public wigner_slater_functional(rho, vxc)
Calculate the functional derivative of the Wigner (correlation) - Slater (exchange) density functiona...
subroutine, public atom_read_zmp_restart(atom, doguess, iw)
ZMP subroutine to read external restart file.
subroutine, public exchange_numeric(kmat, state, occ, wfn, basis, hfx_pot)
Calculate the exchange potential numerically.
pure real(kind=dp) function, public atom_trace(opmat, pmat)
Compute Trace[opmat * pmat] == Trace[opmat * pmat^T] .
subroutine, public atom_read_external_density(density, atom, iw)
ZMP subroutine to read external density from linear grid of density matrix.
subroutine, public numpot_matrix(imat, cpot, basis, derivatives)
Calculate a potential matrix by integrating the potential on an atomic radial grid.
subroutine, public atom_solve(hmat, umat, orb, ener, nb, nv, maxl)
Solve the generalised eigenproblem for every angular momentum.
subroutine, public coulomb_potential_numeric(cpot, density, grid)
Numerically compute the Coulomb potential on an atomic radial grid.
routines that build the integrals of the Vxc potential calculated for the atomic code
subroutine, public calculate_atom_vxc_lda(xcmat, atom, xc_section)
Calculate atomic exchange-correlation potential in spin-restricted case.
subroutine, public calculate_atom_ext_vxc(vxc, atom, lprint, xcmat)
ZMP subroutine for the scf external density from the external v_xc.
subroutine, public calculate_atom_zmp(ext_density, atom, lprint, xcmat)
ZMP subroutine for the calculation of the effective constraint potential in the atomic code.
subroutine, public calculate_atom_vxc_lsd(xcmata, xcmatb, atom, xc_section)
Calculate atomic exchange-correlation potential in spin-polarized case.
Defines the basic variable types.
integer, parameter, public dp