60#include "./base/base_uses.f90"
66 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'atom_energy'
86 CHARACTER(len=*),
PARAMETER :: routinen =
'atom_energy_opt'
88 CHARACTER(LEN=2) :: elem
89 CHARACTER(LEN=default_string_length) :: filename, xcfstr
90 CHARACTER(LEN=default_string_length), &
91 DIMENSION(:),
POINTER :: tmpstringlist
92 INTEGER :: do_eric, do_erie, handle, i, im, in, iw, k, maxl, mb, method, mo, n_meth, n_rep, &
93 nder, nr_gh, num_gau, num_gto, num_pol, reltyp, shortcut, zcore, zval, zz
94 INTEGER,
DIMENSION(0:lmat) :: maxn
95 INTEGER,
DIMENSION(:),
POINTER :: cn
96 LOGICAL :: dm, do_gh, do_zmp, doread, eri_c, eri_e, &
97 explicit,
graph, had_ae, had_pp, &
98 lcomp, lcond, pp_calc, read_vxc
99 REAL(kind=
dp) :: crad, delta, lambda
100 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: ext_density, ext_vxc
101 REAL(kind=
dp),
DIMENSION(0:lmat, 10) :: pocc
106 TYPE(
atom_p_type),
DIMENSION(:, :),
POINTER :: atom_info
110 TYPE(
section_vals_type),
POINTER :: admm_section, basis_section, external_vxc_section, &
111 method_section, opt_section, potential_section, powell_section, sgp_section, xc_func, &
112 xc_section, zmp_restart_section, zmp_section
114 CALL timeset(routinen, handle)
121 IF (
ptable(i)%symbol == elem)
THEN
126 IF (zz /= 1) zval = zz
129 ALLOCATE (ae_basis, pp_basis)
131 NULLIFY (ae_basis%grid)
133 NULLIFY (pp_basis%grid)
140 IF (iw > 0)
CALL atom_print_info(zval,
"Atomic Energy Calculation", iw)
150 NULLIFY (potential_section)
152 ALLOCATE (ae_pot, p_pot)
170 DO in = 1, min(
SIZE(cn), 4)
171 maxn(in - 1) = cn(in)
174 maxn(in) = min(maxn(in), ae_basis%nbas(in))
175 maxn(in) = min(maxn(in), pp_basis%nbas(in))
192 ALLOCATE (ae_int, pp_int)
194 ALLOCATE (atom_info(n_rep, n_meth))
199 NULLIFY (atom_info(in, im)%atom)
202 atom_info(in, im)%atom%optimization = optimization
204 atom_info(in, im)%atom%z = zval
207 atom_info(in, im)%atom%xc_section => xc_section
215 SELECT CASE (shortcut)
252 atom_info(in, im)%atom%do_zmp = do_zmp
254 atom_info(in, im)%atom%ext_file = filename
256 r_val=atom_info(in, im)%atom%zmpgrid_tol)
258 atom_info(in, im)%atom%lambda = lambda
260 atom_info(in, im)%atom%dm = dm
264 atom_info(in, im)%atom%doread = doread
266 atom_info(in, im)%atom%zmp_restart_file = filename
271 atom_info(in, im)%atom%read_vxc = read_vxc
273 atom_info(in, im)%atom%ext_vxc_file = filename
275 r_val=atom_info(in, im)%atom%zmpvxcgrid_tol)
281 c_vals=tmpstringlist)
289 state%maxl_calc = max(maxl, state%maxl_occ)
290 state%maxl_calc = min(
lmat, state%maxl_calc)
292 DO k = 0, state%maxl_calc
293 state%maxn_calc(k) = max(maxn(k), state%maxn_occ(k))
297 pp_calc = any(index(tmpstringlist(1:),
"CORE") /= 0)
302 zcore = zval - nint(sum(state%core))
303 CALL set_atom(atom_info(in, im)%atom, zcore=zcore, pp_calc=.true.)
306 CALL set_atom(atom_info(in, im)%atom, zcore=zval, pp_calc=.false.)
311 CALL set_atom(atom_info(in, im)%atom, method_type=method, relativistic=reltyp)
331 potential=p_pot, eri_coulomb=eri_c, eri_exchange=eri_e)
335 NULLIFY (pp_int%tzora, pp_int%hdkh)
337 CALL set_atom(atom_info(in, im)%atom, basis=pp_basis, integrals=pp_int, potential=p_pot)
338 state%maxn_calc(:) = min(state%maxn_calc(:), pp_basis%nbas(:))
339 cpassert(all(state%maxn_calc(:) >= state%maxn_occ))
344 eri_coulomb=eri_c, eri_exchange=eri_e)
350 CALL set_atom(atom_info(in, im)%atom, basis=ae_basis, integrals=ae_int, potential=ae_pot)
351 state%maxn_calc(:) = min(state%maxn_calc(:), ae_basis%nbas(:))
352 cpassert(all(state%maxn_calc(:) >= state%maxn_occ))
356 CALL set_atom(atom_info(in, im)%atom, state=state)
358 CALL set_atom(atom_info(in, im)%atom, coulomb_integral_type=do_eric, &
359 exchange_integral_type=do_erie)
360 atom_info(in, im)%atom%hfx_pot%do_gh = do_gh
361 atom_info(in, im)%atom%hfx_pot%nr_gh = nr_gh
364 mo = maxval(state%maxn_calc)
365 mb = maxval(atom_info(in, im)%atom%basis%nbas)
367 CALL set_atom(atom_info(in, im)%atom, orbitals=orbitals)
376 IF (atom_info(in, im)%atom%do_zmp)
THEN
379 ALLOCATE (ext_density(atom_info(in, im)%atom%basis%grid%nr))
383 atom=atom_info(in, im)%atom, &
385 DEALLOCATE (ext_density)
388 IF (atom_info(in, im)%atom%read_vxc)
THEN
389 ALLOCATE (ext_vxc(atom_info(in, im)%atom%basis%grid%nr))
393 atom=atom_info(in, im)%atom, &
408 file_position=
"REWIND")
410 CALL atom_write_upf(atom_info(in, im)%atom, iw, xcfstr)
419 CALL atom_fit_density(atom_info(in, im)%atom, num_gto, 0, iw, powell_section=powell_section)
429 CALL atom_fit_kgpot(atom_info(in, im)%atom, num_gau, num_pol, iw, powell_section=powell_section)
438 CALL atom_response_basis(atom_info(in, im)%atom, delta, nder, iw)
448 iw =
cp_print_key_unit_nr(logger, atom_section,
"PRINT%GEOMETRICAL_RESPONSE_BASIS", extension=
".log")
457 CALL section_vals_val_get(atom_section,
"PRINT%ANALYZE_BASIS%OVERLAP_CONDITION_NUMBER", l_val=lcond)
475 CALL atom_admm(atom_info, admm_section, iw)
480 iw =
cp_print_key_unit_nr(logger, atom_section,
"PRINT%SEPARABLE_GAUSSIAN_PSEUDO", extension=
".log")
509 DEALLOCATE (atom_info)
511 DEALLOCATE (ae_pot, p_pot, ae_basis, pp_basis, ae_int, pp_int)
513 CALL timestop(handle)
527 SUBROUTINE atom_response_basis(atom, delta, nder, iw)
530 REAL(kind=
dp),
INTENT(IN) :: delta
531 INTEGER,
INTENT(IN) :: nder, iw
533 REAL(kind=
dp),
PARAMETER :: error_threshold = 1.0e-12_dp
535 INTEGER :: i, ider, j, k, l, lhomo, m, n, nhomo, &
537 REAL(kind=
dp) :: dene, emax, expzet, fhomo, o, prefac, &
539 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: amat
540 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: rbasis
541 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :, :) :: wfn
542 REAL(kind=
dp),
DIMENSION(:, :, :),
POINTER :: ovlp
545 WRITE (iw,
'(/," ",79("*"),/,T30,A,A/," ",79("*"))')
"RESPONSE BASIS for ",
ptable(
atom%z)%symbol
548 ovlp =>
atom%integrals%ovlp
554 DO l = 0, state%maxl_occ
555 DO i = 1, state%maxn_occ(l)
556 IF (
atom%orbitals%ener(i, l) > emax)
THEN
559 emax =
atom%orbitals%ener(i, l)
560 fhomo = state%occupation(l, i)
565 s1 =
SIZE(
atom%orbitals%wfn, 1)
566 s2 =
SIZE(
atom%orbitals%wfn, 2)
567 ALLOCATE (wfn(s1, s2, 0:
lmat, -nder:nder))
568 s2 = maxval(state%maxn_occ) + nder
569 ALLOCATE (rbasis(s1, s2, 0:
lmat))
572 DO ider = -nder, nder
573 dene = real(ider, kind=
dp)*delta
574 cpassert(fhomo > abs(dene))
575 state%occupation(lhomo, nhomo) = fhomo + dene
577 wfn(:, :, :, ider) =
atom%orbitals%wfn
578 state%occupation(lhomo, nhomo) = fhomo
583 DO l = 0, state%maxl_occ
585 DO i = 1, max(state%maxn_occ(l), 1)
586 rbasis(:, i, l) = wfn(:, i, l, 0)
590 i = max(state%maxn_occ(l), 1)
593 rbasis(:, i + 1, l) = 0.5_dp*(wfn(:, i, l, 1) - wfn(:, i, l, -1))/delta
595 rbasis(:, i + 2, l) = 0.25_dp*(wfn(:, i, l, 2) - 2._dp*wfn(:, i, l, 0) + wfn(:, i, l, -2))/delta**2
597 rbasis(:, i + 3, l) = 0.125_dp*(wfn(:, i, l, 3) - 3._dp*wfn(:, i, l, 1) &
598 + 3._dp*wfn(:, i, l, -1) - wfn(:, i, l, -3))/delta**3
600 cpabort(
"Only 1, 2, 3 are supported as the number of wavefunction derivatives")
605 n = state%maxn_occ(l) + nder
606 m =
atom%basis%nbas(l)
609 o = dot_product(rbasis(1:m, j, l), reshape(matmul(ovlp(1:m, 1:m, l), rbasis(1:m, i:i, l)), [m]))
610 rbasis(1:m, i, l) = rbasis(1:m, i, l) - o*rbasis(1:m, j, l)
612 o = dot_product(rbasis(1:m, i, l), reshape(matmul(ovlp(1:m, 1:m, l), rbasis(1:m, i:i, l)), [m]))
613 rbasis(1:m, i, l) = rbasis(1:m, i, l)/sqrt(o)
617 ALLOCATE (amat(n, n))
618 amat(1:n, 1:n) = matmul(transpose(rbasis(1:m, 1:n, l)), matmul(ovlp(1:m, 1:m, l), rbasis(1:m, 1:n, l)))
620 amat(i, i) = amat(i, i) - 1._dp
622 IF (maxval(abs(amat)) > error_threshold)
THEN
623 WRITE (iw,
'(/,A,G20.10)')
" Orthogonality error ", maxval(abs(amat))
628 WRITE (iw,
'(/,A,T30,I3)')
" Angular momentum :", l
630 WRITE (iw,
'(/,A,I0,A,I0,A)')
" Exponent Coef.(Quickstep Normalization), first ", &
631 n - nder,
" valence ", nder,
" response"
632 expzet = 0.25_dp*real(2*l + 3,
dp)
633 prefac = sqrt(
rootpi/2._dp**(l + 2)*
dfac(2*l + 1))
635 zeta = (2._dp*
atom%basis%am(i, l))**expzet
636 WRITE (iw,
'(4X,F20.10,4X,15ES20.6)')
atom%basis%am(i, l), ((prefac*rbasis(i, k, l)/zeta), k=1, n)
641 DEALLOCATE (wfn, rbasis)
643 WRITE (iw,
'(" ",79("*"))')
645 END SUBROUTINE atom_response_basis
655 SUBROUTINE atom_write_upf(atom, iw, xcfstr)
658 INTEGER,
INTENT(IN) :: iw
659 CHARACTER(LEN=*),
INTENT(IN) :: xcfstr
661 CHARACTER(LEN=default_string_length) :: string
662 INTEGER :: i, ibeta, ii, j, k, kk, l, lmax, n0, &
663 nbeta, nr, nwfc, nwfn
665 REAL(kind=
dp) :: occa, occb, pf, rhoatom, rl, rlp, rmax, &
667 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: beta, corden, dens, ef, locpot, rp
668 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: dij
671 IF (.NOT.
atom%pp_calc)
RETURN
673 pot =>
atom%potential%gth_pot
674 cpassert(.NOT. pot%lsdpot)
677 WRITE (iw,
'(A)')
'<UPF version="2.0.1">'
679 WRITE (iw,
'(T4,A)')
'<PP_INFO>'
680 WRITE (iw,
'(T8,A)')
'Converted from CP2K GTH format'
681 WRITE (iw,
'(T8,A)')
'<PP_INPUTFILE>'
683 WRITE (iw,
'(T8,A)')
'</PP_INPUTFILE>'
684 WRITE (iw,
'(T4,A)')
'</PP_INFO>'
685 WRITE (iw,
'(T4,A)')
'<PP_HEADER'
686 WRITE (iw,
'(T8,A)')
'generated="Generated in analytical, separable form"'
687 WRITE (iw,
'(T8,A)')
'author="Goedecker/Hartwigsen/Hutter/Teter"'
688 WRITE (iw,
'(T8,A)')
'date="Phys.Rev.B58, 3641 (1998); B54, 1703 (1996)"'
689 WRITE (iw,
'(T8,A)')
'comment="This file generated by CP2K ATOM code"'
690 CALL compose(string,
"element", cval=pot%symbol)
691 WRITE (iw,
'(T8,A)') trim(string)
692 WRITE (iw,
'(T8,A)')
'pseudo_type="NC"'
693 WRITE (iw,
'(T8,A)')
'relativistic="no"'
694 WRITE (iw,
'(T8,A)')
'is_ultrasoft="F"'
695 WRITE (iw,
'(T8,A)')
'is_paw="F"'
696 WRITE (iw,
'(T8,A)')
'is_coulomb="F"'
698 WRITE (iw,
'(T8,A)')
'has_so="T"'
700 WRITE (iw,
'(T8,A)')
'has_so="F"'
702 WRITE (iw,
'(T8,A)')
'has_wfc="F"'
703 WRITE (iw,
'(T8,A)')
'has_gipaw="F"'
704 WRITE (iw,
'(T8,A)')
'paw_as_gipaw="F"'
706 WRITE (iw,
'(T8,A)')
'core_correction="T"'
708 WRITE (iw,
'(T8,A)')
'core_correction="F"'
710 WRITE (iw,
'(T8,A)')
'functional="'//trim(adjustl(xcfstr))//
'"'
711 CALL compose(string,
"z_valence", rval=pot%zion)
712 WRITE (iw,
'(T8,A)') trim(string)
713 CALL compose(string,
"total_psenergy", rval=2._dp*
atom%energy%etot)
714 WRITE (iw,
'(T8,A)') trim(string)
715 WRITE (iw,
'(T8,A)')
'wfc_cutoff="0.0E+00"'
716 WRITE (iw,
'(T8,A)')
'rho_cutoff="0.0E+00"'
719 IF (pot%nl(l) > 0) lmax = l
721 CALL compose(string,
"l_max", ival=lmax)
722 WRITE (iw,
'(T8,A)') trim(string)
723 WRITE (iw,
'(T8,A)')
'l_max_rho="0"'
724 WRITE (iw,
'(T8,A)')
'l_local="-3"'
725 nr =
atom%basis%grid%nr
726 CALL compose(string,
"mesh_size", ival=nr)
727 WRITE (iw,
'(T8,A)') trim(string)
728 nwfc = sum(
atom%state%maxn_occ)
729 CALL compose(string,
"number_of_wfc", ival=nwfc)
730 WRITE (iw,
'(T8,A)') trim(string)
732 nbeta = pot%nl(0) + 2*sum(pot%nl(1:))
736 CALL compose(string,
"number_of_proj", ival=nbeta)
737 WRITE (iw,
'(T8,A)') trim(string)//
'/>'
740 up =
atom%basis%grid%rad(1) <
atom%basis%grid%rad(nr)
741 WRITE (iw,
'(T4,A)')
'<PP_MESH'
742 WRITE (iw,
'(T8,A)')
'dx="1.E+00"'
743 CALL compose(string,
"mesh", ival=nr)
744 WRITE (iw,
'(T8,A)') trim(string)
745 WRITE (iw,
'(T8,A)')
'xmin="1.E+00"'
746 rmax = maxval(
atom%basis%grid%rad)
747 CALL compose(string,
"rmax", rval=rmax)
748 WRITE (iw,
'(T8,A)') trim(string)
749 WRITE (iw,
'(T8,A)')
'zmesh="1.E+00">'
750 WRITE (iw,
'(T8,A)')
'<PP_R type="real"'
751 CALL compose(string,
"size", ival=nr)
752 WRITE (iw,
'(T12,A)') trim(string)
753 WRITE (iw,
'(T12,A)')
'columns="4">'
755 WRITE (iw,
'(T12,4ES25.12E3)') (
atom%basis%grid%rad(i), i=1, nr)
757 WRITE (iw,
'(T12,4ES25.12E3)') (
atom%basis%grid%rad(i), i=nr, 1, -1)
759 WRITE (iw,
'(T8,A)')
'</PP_R>'
760 WRITE (iw,
'(T8,A)')
'<PP_RAB type="real"'
761 CALL compose(string,
"size", ival=nr)
762 WRITE (iw,
'(T12,A)') trim(string)
763 WRITE (iw,
'(T12,A)')
'columns="4">'
765 WRITE (iw,
'(T12,4ES25.12E3)') (
atom%basis%grid%wr(i)/
atom%basis%grid%rad2(i), i=1, nr)
767 WRITE (iw,
'(T12,4ES25.12E3)') (
atom%basis%grid%wr(i)/
atom%basis%grid%rad2(i), i=nr, 1, -1)
769 WRITE (iw,
'(T8,A)')
'</PP_RAB>'
770 WRITE (iw,
'(T4,A)')
'</PP_MESH>'
774 WRITE (iw,
'(T4,A)')
'<PP_NLCC type="real"'
775 CALL compose(string,
"size", ival=nr)
776 WRITE (iw,
'(T8,A)') trim(string)
777 WRITE (iw,
'(T8,A)')
'columns="4">'
778 ALLOCATE (corden(nr))
782 WRITE (iw,
'(T8,4ES25.12E3)') (corden(i), i=1, nr)
784 WRITE (iw,
'(T8,4ES25.12E3)') (corden(i), i=nr, 1, -1)
787 WRITE (iw,
'(T4,A)')
'</PP_NLCC>'
791 WRITE (iw,
'(T4,A)')
'<PP_LOCAL type="real"'
792 CALL compose(string,
"size", ival=nr)
793 WRITE (iw,
'(T8,A)') trim(string)
794 WRITE (iw,
'(T8,A)')
'columns="4">'
795 ALLOCATE (locpot(nr))
799 WRITE (iw,
'(T8,4ES25.12E3)') (2.0_dp*locpot(i), i=1, nr)
801 WRITE (iw,
'(T8,4ES25.12E3)') (2.0_dp*locpot(i), i=nr, 1, -1)
804 WRITE (iw,
'(T4,A)')
'</PP_LOCAL>'
807 WRITE (iw,
'(T4,A)')
'<PP_NONLOCAL>'
808 ALLOCATE (rp(nr), ef(nr), beta(nr))
811 IF (pot%nl(l) == 0) cycle
813 rp(:) =
atom%basis%grid%rad
814 ef(:) = exp(-0.5_dp*rp*rp/(rl*rl))
816 pf = rl**(l + 0.5_dp*(4._dp*i - 1._dp))
818 pf = sqrt(2._dp)/(pf*sqrt(
gamma1(j)))
819 beta(:) = pf*rp**(l + 2*i - 2)*ef
823 CALL compose(string,
"<PP_BETA", counter=ibeta)
824 WRITE (iw,
'(T8,A)') trim(string)
825 CALL compose(string,
"angular_momentum", ival=l)
826 WRITE (iw,
'(T12,A)') trim(string)
827 WRITE (iw,
'(T12,A)')
'type="real"'
828 CALL compose(string,
"size", ival=nr)
829 WRITE (iw,
'(T12,A)') trim(string)
830 WRITE (iw,
'(T12,A)')
'columns="4">'
832 WRITE (iw,
'(T12,4ES25.12E3)') (2._dp*beta(j), j=1, nr)
834 WRITE (iw,
'(T12,4ES25.12E3)') (2._dp*beta(j), j=nr, 1, -1)
836 CALL compose(string,
"</PP_BETA", counter=ibeta, isfinal=.true.)
837 WRITE (iw,
'(T8,A)') trim(string)
838 IF (soc .AND. l /= 0)
THEN
840 CALL compose(string,
"<PP_BETA", counter=ibeta)
841 WRITE (iw,
'(T8,A)') trim(string)
842 CALL compose(string,
"angular_momentum", ival=l)
843 WRITE (iw,
'(T12,A)') trim(string)
844 WRITE (iw,
'(T12,A)')
'type="real"'
845 CALL compose(string,
"size", ival=nr)
846 WRITE (iw,
'(T12,A)') trim(string)
847 WRITE (iw,
'(T12,A)')
'columns="4">'
849 WRITE (iw,
'(T12,4ES25.12E3)') (2._dp*beta(j), j=1, nr)
851 WRITE (iw,
'(T12,4ES25.12E3)') (2._dp*beta(j), j=nr, 1, -1)
853 CALL compose(string,
"</PP_BETA", counter=ibeta, isfinal=.true.)
854 WRITE (iw,
'(T8,A)') trim(string)
858 DEALLOCATE (rp, ef, beta)
860 ALLOCATE (dij(nbeta, nbeta))
866 IF (pot%nl(l) == 0) cycle
869 dij(1:n0, 1:n0) = pot%hnl(1:n0, 1:n0, 0)
871 ibeta = n0 + 2*sum(pot%nl(1:l - 1))
876 vnlp = pot%hnl(i, k, l) + 0.5_dp*l*pot%knl(i, k, l)
877 vnlm = pot%hnl(i, k, l) - 0.5_dp*(l + 1)*pot%knl(i, k, l)
878 dij(ibeta + ii, ibeta + kk) = vnlm
879 dij(ibeta + ii + 1, ibeta + kk + 1) = vnlp
886 IF (pot%nl(l) == 0) cycle
887 ibeta = sum(pot%nl(0:l - 1)) + 1
888 i = ibeta + pot%nl(l) - 1
889 dij(ibeta:i, ibeta:i) = pot%hnl(1:pot%nl(l), 1:pot%nl(l), l)
892 WRITE (iw,
'(T8,A)')
'<PP_DIJ type="real"'
893 WRITE (iw,
'(T12,A)')
'columns="4">'
894 WRITE (iw,
'(T12,4ES25.12E3)') ((0.5_dp*dij(i, j), j=1, nbeta), i=1, nbeta)
895 WRITE (iw,
'(T8,A)')
'</PP_DIJ>'
897 WRITE (iw,
'(T4,A)')
'</PP_NONLOCAL>'
901 WRITE (iw,
'(T4,A)')
'<PP_PSWFC>'
905 IF (abs(
atom%state%occupation(l, i)) == 0._dp) cycle
906 occa =
atom%state%occupation(l, i)
908 IF (soc .AND. l /= 0)
THEN
913 CALL compose(string,
"<PP_CHI", counter=nwfn)
914 WRITE (iw,
'(T8,A)') trim(string)
915 CALL compose(string,
"l", ival=l)
916 WRITE (iw,
'(T12,A)') trim(string)
917 CALL compose(string,
"occupation", rval=occa)
918 WRITE (iw,
'(T12,A)') trim(string)
919 CALL compose(string,
"pseudo_energy", rval=2._dp*
atom%orbitals%ener(i, l))
920 WRITE (iw,
'(T12,A)') trim(string)
921 WRITE (iw,
'(T12,A)')
'columns="4">'
923 DO k = 1,
atom%basis%nbas(l)
924 beta(:) = beta(:) +
atom%orbitals%wfn(k, i, l)*
atom%basis%bf(:, k, l)
926 beta(:) = beta*
atom%basis%grid%rad
928 WRITE (iw,
'(T12,4ES25.12E3)') (beta(j), j=1, nr)
930 WRITE (iw,
'(T12,4ES25.12E3)') (beta(j), j=nr, 1, -1)
932 CALL compose(string,
"</PP_CHI", counter=nwfn, isfinal=.true.)
933 WRITE (iw,
'(T8,A)') trim(string)
934 IF (soc .AND. l /= 0)
THEN
936 CALL compose(string,
"<PP_CHI", counter=nwfn)
937 WRITE (iw,
'(T8,A)') trim(string)
938 CALL compose(string,
"l", ival=l)
939 WRITE (iw,
'(T12,A)') trim(string)
940 CALL compose(string,
"occupation", rval=occb)
941 WRITE (iw,
'(T12,A)') trim(string)
942 CALL compose(string,
"pseudo_energy", rval=2._dp*
atom%orbitals%ener(i, l))
943 WRITE (iw,
'(T12,A)') trim(string)
944 WRITE (iw,
'(T12,A)')
'columns="4">'
946 DO k = 1,
atom%basis%nbas(l)
947 beta(:) = beta(:) +
atom%orbitals%wfn(k, i, l)*
atom%basis%bf(:, k, l)
949 beta(:) = beta*
atom%basis%grid%rad
951 WRITE (iw,
'(T12,4ES25.12E3)') (beta(j), j=1, nr)
953 WRITE (iw,
'(T12,4ES25.12E3)') (beta(j), j=nr, 1, -1)
955 CALL compose(string,
"</PP_CHI", counter=nwfn, isfinal=.true.)
956 WRITE (iw,
'(T8,A)') trim(string)
960 WRITE (iw,
'(T4,A)')
'</PP_PSWFC>'
965 WRITE (iw,
'(T4,A)')
'<PP_RHOATOM type="real"'
966 CALL compose(string,
"size", ival=nr)
967 WRITE (iw,
'(T8,A)') trim(string)
968 WRITE (iw,
'(T8,A)')
'columns="4">'
970 "RHO",
atom%basis%grid%rad)
972 WRITE (iw,
'(T8,4ES25.12E3)') (
fourpi*dens(j)*
atom%basis%grid%rad2(j), j=1, nr)
974 WRITE (iw,
'(T8,4ES25.12E3)') (
fourpi*dens(j)*
atom%basis%grid%rad2(j), j=nr, 1, -1)
976 WRITE (iw,
'(T4,A)')
'</PP_RHOATOM>'
979 rhoatom = sum(
fourpi*
atom%basis%grid%wr(:)*dens(:))
980 IF (abs(pot%zion - rhoatom) > 0.01_dp)
THEN
981 CALL cp_warn(__location__,
"Valence charge and electron count differ by more than 0.01")
987 WRITE (iw,
'(T4,A)')
'<PP_SPIN_ORB>'
992 IF (abs(
atom%state%occupation(l, i)) == 0._dp) cycle
993 occa =
atom%state%occupation(l, i)
1000 CALL compose(string,
"<PP_RELWFC", counter=nwfn)
1001 WRITE (iw,
'(T8,A)') trim(string)
1002 CALL compose(string,
"index", ival=nwfn)
1003 WRITE (iw,
'(T12,A)') trim(string)
1006 CALL compose(string,
"nn", ival=nwfn)
1007 WRITE (iw,
'(T12,A)') trim(string)
1008 CALL compose(string,
"lchi", ival=l)
1009 WRITE (iw,
'(T12,A)') trim(string)
1015 CALL compose(string,
"jchi", rval=rlp)
1016 WRITE (iw,
'(T12,A)') trim(string)
1017 CALL compose(string,
"oc", rval=occa)
1018 WRITE (iw,
'(T12,A)') trim(string)
1019 WRITE (iw,
'(T12,A)')
'/>'
1022 CALL compose(string,
"<PP_RELWFC", counter=nwfn)
1023 WRITE (iw,
'(T8,A)') trim(string)
1024 CALL compose(string,
"index", ival=nwfn)
1025 WRITE (iw,
'(T12,A)') trim(string)
1028 CALL compose(string,
"nn", ival=nwfn)
1029 WRITE (iw,
'(T12,A)') trim(string)
1030 CALL compose(string,
"lchi", ival=l)
1031 WRITE (iw,
'(T12,A)') trim(string)
1033 CALL compose(string,
"jchi", rval=rlp)
1034 WRITE (iw,
'(T12,A)') trim(string)
1035 CALL compose(string,
"oc", rval=occa)
1036 WRITE (iw,
'(T12,A)') trim(string)
1037 WRITE (iw,
'(T12,A)')
'/>'
1043 IF (pot%nl(l) == 0) cycle
1046 CALL compose(string,
"<PP_RELBETA", counter=ibeta)
1047 WRITE (iw,
'(T8,A)') trim(string)
1048 CALL compose(string,
"index", ival=ibeta)
1049 WRITE (iw,
'(T12,A)') trim(string)
1050 CALL compose(string,
"lll", ival=l)
1051 WRITE (iw,
'(T12,A)') trim(string)
1057 CALL compose(string,
"jjj", rval=rlp)
1058 WRITE (iw,
'(T12,A)') trim(string)
1059 WRITE (iw,
'(T12,A)')
'/>'
1062 CALL compose(string,
"<PP_RELBETA", counter=ibeta)
1063 WRITE (iw,
'(T8,A)') trim(string)
1064 CALL compose(string,
"index", ival=ibeta)
1065 WRITE (iw,
'(T12,A)') trim(string)
1066 CALL compose(string,
"lll", ival=l)
1067 WRITE (iw,
'(T12,A)') trim(string)
1069 CALL compose(string,
"jjj", rval=rlp)
1070 WRITE (iw,
'(T12,A)') trim(string)
1071 WRITE (iw,
'(T12,A)')
'/>'
1075 WRITE (iw,
'(T4,A)')
'</PP_SPIN_ORB>'
1078 WRITE (iw,
'(A)')
'</UPF>'
1080 END SUBROUTINE atom_write_upf
1094 SUBROUTINE compose(string, tag, counter, rval, ival, cval, isfinal)
1095 CHARACTER(len=*),
INTENT(OUT) :: string
1096 CHARACTER(len=*),
INTENT(IN) :: tag
1097 INTEGER,
INTENT(IN),
OPTIONAL :: counter
1098 REAL(kind=
dp),
INTENT(IN),
OPTIONAL :: rval
1099 INTEGER,
INTENT(IN),
OPTIONAL :: ival
1100 CHARACTER(len=*),
INTENT(IN),
OPTIONAL :: cval
1101 LOGICAL,
INTENT(IN),
OPTIONAL :: isfinal
1103 CHARACTER(LEN=default_string_length) :: str
1106 IF (
PRESENT(counter))
THEN
1107 WRITE (str,
"(I12)") counter
1108 ELSE IF (
PRESENT(rval))
THEN
1109 WRITE (str,
"(G18.8)") rval
1110 ELSE IF (
PRESENT(ival))
THEN
1111 WRITE (str,
"(I12)") ival
1112 ELSE IF (
PRESENT(cval))
THEN
1113 WRITE (str,
"(A)") trim(adjustl(cval))
1115 WRITE (str,
"(A)")
""
1118 IF (
PRESENT(isfinal)) fin = isfinal
1119 IF (
PRESENT(counter))
THEN
1121 WRITE (string,
"(A,A1,A,A1)") trim(adjustl(tag)),
'.', trim(adjustl(str)),
'>'
1123 WRITE (string,
"(A,A1,A)") trim(adjustl(tag)),
'.', trim(adjustl(str))
1127 WRITE (string,
"(A,A2,A,A2)") trim(adjustl(tag)),
'="', trim(adjustl(str)),
'>"'
1129 WRITE (string,
"(A,A2,A,A1)") trim(adjustl(tag)),
'="', trim(adjustl(str)),
'"'
1132 END SUBROUTINE compose
program graph
Program to Map on grid the hills spawned during a metadynamics run.
static GRID_HOST_DEVICE orbital up(const int i, const orbital a)
Increase i'th component of given orbital angular momentum.
subroutine, public atom_admm(atom_info, admm_section, iw)
Analysis of ADMM approximation to exact exchange.
subroutine, public calculate_atom(atom, iw, noguess, converged)
General routine to perform electronic structure atomic calculations.
subroutine, public atom_energy_opt(atom_section)
Compute the atomic energy.
routines that fit parameters for /from atomic calculations
subroutine, public atom_fit_density(atom, num_gto, norder, iunit, agto, powell_section, results)
Fit the atomic electron density using a geometrical Gaussian basis set.
subroutine, public atom_fit_kgpot(atom, num_gau, num_pol, iunit, powell_section, results)
...
subroutine, public atom_grb_construction(atom_info, atom_section, iw)
Construct geometrical response basis set.
Calculate the atomic operator matrices.
subroutine, public atom_ppint_release(integrals)
Release memory allocated for atomic integrals (core electrons).
subroutine, public atom_int_setup(integrals, basis, potential, eri_coulomb, eri_exchange, all_nu)
Set up atomic integrals.
subroutine, public atom_relint_setup(integrals, basis, reltyp, zcore, alpha)
...
subroutine, public atom_relint_release(integrals)
Release memory allocated for atomic integrals (relativistic effects).
subroutine, public atom_ppint_setup(integrals, basis, potential)
...
subroutine, public atom_int_release(integrals)
Release memory allocated for atomic integrals (valence electrons).
Routines that print various information about an atomic kind.
subroutine, public atom_print_orbitals(atom, iw, xmgrace)
Print atomic orbitals.
subroutine, public atom_print_basis(atom_basis, iw, title)
Print atomic basis set.
subroutine, public atom_print_method(atom, iw)
Print information about the electronic structure method in use.
subroutine, public atom_write_pseudo_param(gthpot, iunit, fopt)
Print GTH pseudo-potential parameters.
subroutine, public atom_print_potential(potential, iw)
Print information about the pseudo-potential.
subroutine, public atom_print_info(zval, info, iw)
Print an information string related to the atomic kind.
subroutine, public atom_sgp_construction(atom_info, input_section, iw)
...
Define the atom type and its sub types.
subroutine, public read_atom_opt_section(optimization, opt_section)
...
subroutine, public create_atom_type(atom)
...
subroutine, public release_atom_type(atom)
...
subroutine, public release_atom_potential(potential)
...
subroutine, public init_atom_basis(basis, basis_section, zval, btyp)
Initialize the basis for the atomic code.
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 init_atom_potential(potential, potential_section, zval)
...
subroutine, public release_atom_basis(basis)
...
subroutine, public create_atom_orbs(orbs, mbas, mo)
...
Some basic routines for atomic calculations.
subroutine, public atom_condnumber(basis, crad, iw)
Print condition numbers of the given atomic basis set.
pure subroutine, public atom_local_potential(locpot, gthpot, rr)
...
subroutine, public atom_read_external_vxc(vxc, atom, iw)
ZMP subroutine to read external v_xc in the atomic code.
pure logical function, public atom_consistent_method(method, multiplicity)
Check that the atomic multiplicity is consistent with the electronic structure method.
subroutine, public atom_core_density(corden, potential, typ, rr)
...
pure integer function, dimension(0:lmat), public get_maxn_occ(occupation)
Return the maximum principal quantum number of occupied orbitals.
subroutine, public atom_density(density, pmat, basis, maxl, typ, rr)
Map the electron density on an atomic radial grid.
subroutine, public atom_read_external_density(density, atom, iw)
ZMP subroutine to read external density from linear grid of density matrix.
subroutine, public atom_completeness(basis, zv, iw)
Estimate completeness of the given atomic basis set.
subroutine, public atom_write_zmp_restart(atom)
ZMP subroutine to write external restart file.
subroutine, public atom_set_occupation(ostring, occupation, wfnocc, multiplicity)
Set occupation of atomic orbitals.
pure integer function, public get_maxl_occ(occupation)
Return the maximum orbital quantum number of occupied orbitals.
routines that build the integrals of the Vxc potential calculated for the atomic code
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.
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,...
Defines the basic variable types.
integer, parameter, public dp
integer, parameter, public default_string_length
Definition of mathematical constants and functions.
real(kind=dp), dimension(0:maxfac), parameter, public gamma1
real(kind=dp), dimension(-1:2 *maxfac+1), parameter, public dfac
real(kind=dp), parameter, public rootpi
real(kind=dp), parameter, public fourpi
Periodic Table related data definitions.
type(atom), dimension(0:nelem), public ptable
integer, parameter, public nelem
Definition of physical constants:
real(kind=dp), parameter, public bohr
Routines to facilitate writing XMGRACE files.
Provides all information about a basis set.
Provides all information about a pseudopotential.
Information on optimization procedure.
Holds atomic orbitals and energies.
Provides all information on states and occupation.
Provides all information about an atomic kind.
type of a logger, at the moment it contains just a print level starting at which level it should be l...