191 TYPE(
atom_p_type),
DIMENSION(:, :),
POINTER :: atom_info
193 LOGICAL,
INTENT(IN) :: pptype
194 INTEGER,
INTENT(IN) :: iunit
197 INTEGER :: i, j, k, l, ll, m, n, n10, nl, nr, zval
198 INTEGER,
ALLOCATABLE,
DIMENSION(:, :) :: xtob
199 LOGICAL :: explicit, mult, penalty
200 REAL(kind=
dp) :: al, crad, ear, fopt, pf, rk
201 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: x
202 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: wem
203 REAL(kind=
dp),
DIMENSION(:),
POINTER :: w
207 SELECT CASE (basis%basis_type)
209 cpabort(
"Unknown basis type for atom_fit_basis")
211 IF (basis%geometrical)
THEN
214 x(1) = sqrt(basis%aval)
215 x(2) = sqrt(basis%cval)
217 ll = maxval(basis%nprim(:))
218 ALLOCATE (xtob(ll, 0:
lmat))
220 ll = sum(basis%nprim(:))
225 DO i = 1, basis%nprim(l)
228 IF (abs(basis%am(i, l) - x(k)) < 1.e-6_dp)
THEN
235 x(ll) = basis%am(i, l)
241 DO i = 1, ostate%nvar
242 x(i) = sqrt(log(1._dp + x(i)))
247 ll = maxval(basis%nbas(:))
248 ALLOCATE (xtob(ll, 0:
lmat))
250 ll = sum(basis%nbas(:))
255 DO i = 1, basis%nbas(l)
257 x(ll) = basis%as(i, l)
262 DO i = 1, ostate%nvar
263 x(i) = sqrt(log(1._dp + x(i)))
271 n =
SIZE(atom_info, 1)
272 m =
SIZE(atom_info, 2)
278 DO i = 1, min(
SIZE(w), n)
279 wem(i, :) = w(i)*wem(i, :)
285 DO i = 1, min(
SIZE(w), m)
286 wem(:, i) = w(i)*wem(:, i)
290 DO i = 1,
SIZE(atom_info, 1)
291 DO j = 1,
SIZE(atom_info, 2)
292 atom_info(i, j)%atom%weight = wem(i, j)
303 WRITE (iunit,
'(/," POWELL| Start optimization procedure")')
304 WRITE (iunit,
'(/," POWELL| Total number of parameters in optimization",T71,I10)') ostate%nvar
306 n10 = max(ostate%maxfun/100, 1)
312 IF (ostate%state == 2)
THEN
313 SELECT CASE (basis%basis_type)
315 cpabort(
"Unknown basis type for atom_fit_basis")
317 IF (basis%geometrical)
THEN
320 DO i = 1, basis%nbas(l)
321 ll = i - 1 + basis%start(l)
322 basis%am(i, l) = x(1)*x(1)*(x(2)*x(2))**(ll)
325 basis%aval = x(1)*x(1)
326 basis%cval = x(2)*x(2)
329 DO i = 1, basis%nprim(l)
330 al = x(xtob(i, l))**2
331 basis%am(i, l) = exp(al) - 1._dp
340 DO i = 1, basis%nbas(l)
343 rk = basis%grid%rad(k)
344 ear = exp(-al*basis%grid%rad(k)**2)
345 basis%bf(k, i, l) = rk**l*ear
346 basis%dbf(k, i, l) = (real(l,
dp)*rk**(l - 1) - 2._dp*al*rk**(l + 1))*ear
347 basis%ddbf(k, i, l) = (real(l*(l - 1),
dp)*rk**(l - 2) - &
348 2._dp*al*real(2*l + 1,
dp)*rk**(l) + 4._dp*al**2*rk**(l + 2))*ear
354 DO i = 1, basis%nbas(l)
355 al = x(xtob(i, l))**2
356 basis%as(i, l) = exp(al) - 1._dp
364 DO i = 1, basis%nbas(l)
367 pf = (2._dp*al)**nl*sqrt(2._dp*al/
fac(2*nl))
369 rk = basis%grid%rad(k)
370 ear = rk**(nl - 1)*exp(-al*rk)
371 basis%bf(k, i, l) = pf*ear
372 basis%dbf(k, i, l) = pf*(real(nl - 1,
dp)/rk - al)*ear
373 basis%ddbf(k, i, l) = pf*(real((nl - 2)*(nl - 1),
dp)/rk/rk &
374 - al*real(2*(nl - 1),
dp)/rk + al*al)*ear
379 CALL basis_fit(atom_info, basis, pptype, ostate%f, 0, penalty)
380 fopt = min(fopt, ostate%f)
383 IF (ostate%state == -1)
EXIT
387 IF (ostate%nf == 2 .AND. iunit > 0)
THEN
388 WRITE (iunit,
'(" POWELL| Initial value of function",T61,F20.10)') ostate%f
390 IF (mod(ostate%nf, n10) == 0 .AND. iunit > 0)
THEN
391 WRITE (iunit,
'(" POWELL| Reached",i4,"% of maximal function calls",T61,F20.10)') &
392 int(real(ostate%nf,
dp)/real(ostate%maxfun,
dp)*100._dp), fopt
401 WRITE (iunit,
'(" POWELL| Number of function evaluations",T71,I10)') ostate%nf
402 WRITE (iunit,
'(" POWELL| Final value of function",T61,F20.10)') ostate%fopt
406 SELECT CASE (basis%basis_type)
408 cpabort(
"Unknown basis type for atom_fit_basis")
410 IF (basis%geometrical)
THEN
413 DO i = 1, basis%nbas(l)
414 ll = i - 1 + basis%start(l)
415 basis%am(i, l) = x(1)*x(1)*(x(2)*x(2))**(ll)
418 basis%aval = x(1)*x(1)
419 basis%cval = x(2)*x(2)
422 DO i = 1, basis%nprim(l)
423 al = x(xtob(i, l))**2
424 basis%am(i, l) = exp(al) - 1._dp
433 DO i = 1, basis%nbas(l)
436 rk = basis%grid%rad(k)
437 ear = exp(-al*basis%grid%rad(k)**2)
438 basis%bf(k, i, l) = rk**l*ear
439 basis%dbf(k, i, l) = (real(l,
dp)*rk**(l - 1) - 2._dp*al*rk**(l + 1))*ear
440 basis%ddbf(k, i, l) = (real(l*(l - 1),
dp)*rk**(l - 2) - &
441 2._dp*al*real(2*l + 1,
dp)*rk**(l) + 4._dp*al**2*rk**(l + 2))*ear
447 DO i = 1, basis%nprim(l)
448 al = x(xtob(i, l))**2
449 basis%as(i, l) = exp(al) - 1._dp
457 DO i = 1, basis%nbas(l)
460 pf = (2._dp*al)**nl*sqrt(2._dp*al/
fac(2*nl))
462 rk = basis%grid%rad(k)
463 ear = rk**(nl - 1)*exp(-al*rk)
464 basis%bf(k, i, l) = pf*ear
465 basis%dbf(k, i, l) = pf*(real(nl - 1,
dp)/rk - al)*ear
466 basis%ddbf(k, i, l) = pf*(real((nl - 2)*(nl - 1),
dp)/rk/rk &
467 - al*real(2*(nl - 1),
dp)/rk + al*al)*ear
472 CALL basis_fit(atom_info, basis, pptype, fopt, 0, penalty)
475 print_basis:
DO i = 1,
SIZE(atom_info, 1)
476 DO j = 1,
SIZE(atom_info, 2)
477 IF (pptype .EQV. atom_info(i, j)%atom%pp_calc)
THEN
487 IF (
ALLOCATED(xtob))
THEN
491 SELECT CASE (basis%basis_type)
493 cpabort(
"Unknown basis type for atom_fit_basis")
495 zval = atom_info(1, 1)%atom%z
515 TYPE(
atom_p_type),
DIMENSION(:, :),
POINTER :: atom_info, atom_refs
517 INTEGER,
INTENT(IN) :: iunit
520 LOGICAL,
PARAMETER :: debug = .false.
522 CHARACTER(len=2) :: pc1, pc2, pct
523 INTEGER :: i, i1, i2, iw, j, j1, j2, k, l, m, n, &
524 n10, np, nre, nreinit, ntarget
525 INTEGER,
ALLOCATABLE,
DIMENSION(:, :) :: xtob
526 INTEGER,
DIMENSION(0:lmat) :: ncore
527 LOGICAL :: explicit, noopt_nlcc, preopt_nlcc
528 REAL(kind=
dp) :: afun, charge, de, deig, drho, dx, eig, fopt, oc, pchg, peig, pv, rcm, rcov, &
529 rmax, semicore_level, step_size_scaling, t_ener, t_psir0, t_semi, t_valence, t_virt, &
530 w_ener, w_node, w_psir0, w_semi, w_valence, w_virt, wtot
531 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: x, xi
532 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: wem
533 REAL(kind=
dp),
ALLOCATABLE, &
534 DIMENSION(:, :, :, :, :) :: dener, pval
535 REAL(kind=
dp),
DIMENSION(:),
POINTER :: w
538 TYPE(wfn_init),
DIMENSION(:, :),
POINTER :: wfn_guess
567 n =
SIZE(atom_info, 1)
568 m =
SIZE(atom_info, 2)
571 ALLOCATE (pval(8, 10, 0:
lmat, m, n))
572 ALLOCATE (dener(2, m, m, n, n))
575 ALLOCATE (wfn_guess(n, m))
578 atom => atom_info(i, j)%atom
579 NULLIFY (wfn_guess(i, j)%wfn)
581 i1 =
SIZE(
atom%orbitals%wfn, 1)
582 i2 =
SIZE(
atom%orbitals%wfn, 2)
583 ALLOCATE (wfn_guess(i, j)%wfn(i1, i2, 0:
lmat))
591 DO i = 1, min(
SIZE(w), n)
592 wem(i, :) = w(i)*wem(i, :)
598 DO i = 1, min(
SIZE(w), m)
599 wem(:, i) = w(i)*wem(:, i)
604 CALL open_file(file_name=
"POWELL_RESULT", file_status=
"UNKNOWN", file_action=
"WRITE", unit_number=iw)
607 IF (ppot%gth_pot%nlcc)
THEN
608 CALL opt_nlcc_param(atom_info, atom_refs, ppot%gth_pot, iunit, preopt_nlcc)
611 preopt_nlcc = .false.
616 CALL get_pseudo_param(xi, ostate%nvar, ppot%gth_pot, noopt_nlcc)
617 ALLOCATE (x(ostate%nvar))
618 x(1:ostate%nvar) = xi(1:ostate%nvar)
627 WRITE (iunit,
'(/," POWELL| Start optimization procedure")')
628 WRITE (iunit,
'(/," POWELL| Total number of parameters in optimization",T71,I10)') ostate%nvar
630 n10 = max(ostate%maxfun/100, 1)
632 rcov =
ptable(atom_refs(1, 1)%atom%z)%covalent_radius*
bohr*rcm
636 DO i = 1,
SIZE(atom_info, 1)
637 DO j = 1,
SIZE(atom_info, 2)
638 atom => atom_info(i, j)%atom
640 dener(2, j, j, i, i) = atom_refs(i, j)%atom%energy%etot
641 IF (
atom%state%multiplicity == -1)
THEN
643 atom%weight = wem(i, j)
646 np =
atom%state%maxn_calc(l)
648 CALL atom_orbital_max(rmax, atom_refs(i, j)%atom%orbitals%wfn(:, ncore(l) + k, l), &
649 rcov, l, atom_refs(i, j)%atom%basis)
650 atom%orbitals%rcmax(k, l, 1) = max(rcov, rmax)
652 atom%orbitals%rcmax(k, l, 1), l, atom_refs(i, j)%atom%basis)
653 atom%orbitals%refene(k, l, 1) = atom_refs(i, j)%atom%orbitals%ener(ncore(l) + k, l)
654 atom%orbitals%refchg(k, l, 1) = charge
655 IF (k >
atom%state%maxn_occ(l))
THEN
656 IF (k <=
atom%state%maxn_occ(l) + 1)
THEN
657 atom%orbitals%wrefene(k, l, 1) = w_virt
658 atom%orbitals%wrefchg(k, l, 1) = w_virt/100._dp
659 atom%orbitals%crefene(k, l, 1) = t_virt
660 atom%orbitals%reftype(k, l, 1) =
"U1"
661 ntarget = ntarget + 2
662 wtot = wtot +
atom%weight*(w_virt + w_virt/100._dp)
664 atom%orbitals%wrefene(k, l, 1) = w_virt/100._dp
665 atom%orbitals%wrefchg(k, l, 1) = 0._dp
666 atom%orbitals%crefene(k, l, 1) = t_virt*10._dp
667 atom%orbitals%reftype(k, l, 1) =
"U2"
668 ntarget = ntarget + 1
669 wtot = wtot +
atom%weight*w_virt/100._dp
671 ELSE IF (k <
atom%state%maxn_occ(l))
THEN
672 atom%orbitals%wrefene(k, l, 1) = w_semi
673 atom%orbitals%wrefchg(k, l, 1) = w_semi/100._dp
674 atom%orbitals%crefene(k, l, 1) = t_semi
675 atom%orbitals%reftype(k, l, 1) =
"SC"
676 ntarget = ntarget + 2
677 wtot = wtot +
atom%weight*(w_semi + w_semi/100._dp)
679 IF (abs(
atom%state%occupation(l, k) - real(4*l + 2, kind=
dp)) < 0.01_dp .AND. &
680 abs(
atom%orbitals%refene(k, l, 1)) > semicore_level)
THEN
682 atom%orbitals%wrefene(k, l, 1) = w_semi
683 atom%orbitals%wrefchg(k, l, 1) = w_semi/100._dp
684 atom%orbitals%crefene(k, l, 1) = t_semi
685 atom%orbitals%reftype(k, l, 1) =
"SC"
686 wtot = wtot +
atom%weight*(w_semi + w_semi/100._dp)
688 atom%orbitals%wrefene(k, l, 1) = w_valence
689 atom%orbitals%wrefchg(k, l, 1) = w_valence/100._dp
690 atom%orbitals%crefene(k, l, 1) = t_valence
691 atom%orbitals%reftype(k, l, 1) =
"VA"
692 wtot = wtot +
atom%weight*(w_valence + w_valence/100._dp)
695 atom%orbitals%tpsir0(k, 1) = t_psir0
696 atom%orbitals%wpsir0(k, 1) = w_psir0
697 wtot = wtot +
atom%weight*w_psir0
699 ntarget = ntarget + 2
703 atom%orbitals%refnod(k, l, 1) = real(k - 1, kind=
dp)
705 IF (k == 1 .AND.
atom%state%occupation(l, k) /= 0._dp)
THEN
706 atom%orbitals%wrefnod(k, l, 1) = w_node
707 wtot = wtot +
atom%weight*w_node
713 atom%weight = wem(i, j)
716 np =
atom%state%maxn_calc(l)
718 CALL atom_orbital_max(rmax, atom_refs(i, j)%atom%orbitals%wfna(:, ncore(l) + k, l), &
719 rcov, l, atom_refs(i, j)%atom%basis)
720 atom%orbitals%rcmax(k, l, 1) = max(rcov, rmax)
721 CALL atom_orbital_max(rmax, atom_refs(i, j)%atom%orbitals%wfnb(:, ncore(l) + k, l), &
722 rcov, l, atom_refs(i, j)%atom%basis)
723 atom%orbitals%rcmax(k, l, 2) = max(rcov, rmax)
725 atom%orbitals%rcmax(k, l, 1), l, atom_refs(i, j)%atom%basis)
726 atom%orbitals%refene(k, l, 1) = atom_refs(i, j)%atom%orbitals%enera(ncore(l) + k, l)
727 atom%orbitals%refchg(k, l, 1) = charge
729 atom%orbitals%rcmax(k, l, 1), l, atom_refs(i, j)%atom%basis)
730 atom%orbitals%refene(k, l, 2) = atom_refs(i, j)%atom%orbitals%enerb(ncore(l) + k, l)
731 atom%orbitals%refchg(k, l, 2) = charge
733 IF (k >
atom%state%maxn_occ(l))
THEN
734 IF (k <=
atom%state%maxn_occ(l) + 1)
THEN
735 atom%orbitals%wrefene(k, l, 1:2) = w_virt
736 atom%orbitals%wrefchg(k, l, 1:2) = w_virt/100._dp
737 atom%orbitals%crefene(k, l, 1:2) = t_virt
738 atom%orbitals%reftype(k, l, 1:2) =
"U1"
739 ntarget = ntarget + 4
740 wtot = wtot +
atom%weight*2._dp*(w_virt + w_virt/100._dp)
742 atom%orbitals%wrefene(k, l, 1:2) = w_virt/100._dp
743 atom%orbitals%wrefchg(k, l, 1:2) = 0._dp
744 atom%orbitals%crefene(k, l, 1:2) = t_virt*10.0_dp
745 atom%orbitals%reftype(k, l, 1:2) =
"U2"
746 wtot = wtot +
atom%weight*2._dp*w_virt/100._dp
747 ntarget = ntarget + 2
749 ELSE IF (k <
atom%state%maxn_occ(l))
THEN
750 atom%orbitals%wrefene(k, l, 1:2) = w_semi
751 atom%orbitals%wrefchg(k, l, 1:2) = w_semi/100._dp
752 atom%orbitals%crefene(k, l, 1:2) = t_semi
753 atom%orbitals%reftype(k, l, 1:2) =
"SC"
754 ntarget = ntarget + 4
755 wtot = wtot +
atom%weight*2._dp*(w_semi + w_semi/100._dp)
757 IF (abs(
atom%state%occupation(l, k) - real(2*l + 1, kind=
dp)) < 0.01_dp .AND. &
758 abs(
atom%orbitals%refene(k, l, 1)) > semicore_level)
THEN
759 atom%orbitals%wrefene(k, l, 1:2) = w_semi
760 atom%orbitals%wrefchg(k, l, 1:2) = w_semi/100._dp
761 atom%orbitals%crefene(k, l, 1:2) = t_semi
762 atom%orbitals%reftype(k, l, 1:2) =
"SC"
763 wtot = wtot +
atom%weight*2._dp*(w_semi + w_semi/100._dp)
765 atom%orbitals%wrefene(k, l, 1:2) = w_valence
766 atom%orbitals%wrefchg(k, l, 1:2) = w_valence/100._dp
767 atom%orbitals%crefene(k, l, 1:2) = t_valence
768 atom%orbitals%reftype(k, l, 1:2) =
"VA"
769 wtot = wtot +
atom%weight*2._dp*(w_valence + w_valence/100._dp)
771 ntarget = ntarget + 4
773 atom%orbitals%tpsir0(k, 1:2) = t_psir0
774 atom%orbitals%wpsir0(k, 1:2) = w_psir0
775 wtot = wtot +
atom%weight*2._dp*w_psir0
780 atom%orbitals%refnod(k, l, 1:2) = real(k - 1, kind=
dp)
782 IF (k == 1 .AND.
atom%state%occa(l, k) /= 0._dp)
THEN
783 atom%orbitals%wrefnod(k, l, 1) = w_node
784 wtot = wtot +
atom%weight*w_node
786 IF (k == 1 .AND.
atom%state%occb(l, k) /= 0._dp)
THEN
787 atom%orbitals%wrefnod(k, l, 2) = w_node
788 wtot = wtot +
atom%weight*w_node
798 DO j1 = 1,
SIZE(atom_info, 2)
799 DO j2 = 1,
SIZE(atom_info, 2)
800 DO i1 = 1,
SIZE(atom_info, 1)
801 DO i2 = 1,
SIZE(atom_info, 1)
802 IF ((j1 > j2) .OR. (j1 == j2 .AND. i1 >= i2)) cycle
803 dener(2, j1, j2, i1, i2) = dener(2, j1, j1, i1, i1) - dener(2, j2, j2, i2, i2)
812 ALLOCATE (xi(ostate%nvar))
815 CALL put_pseudo_param(x, ppot%gth_pot, noopt_nlcc)
816 CALL pseudo_fit(atom_info, wfn_guess, ppot, ostate%f, wtot, pval, dener, w_ener, t_ener, .true.)
818 WRITE (iunit,
'(/," POWELL| Initial errors of target values")')
819 afun = ostate%f*wtot + 1.0e-8_dp
820 DO i = 1,
SIZE(atom_info, 1)
821 DO j = 1,
SIZE(atom_info, 2)
822 atom => atom_info(i, j)%atom
825 wfn_guess(i, j)%wfn =
atom%orbitals%wfn
827 WRITE (iunit,
'(/," Reference configuration ",T31,i5,T50," Method number ",T76,i5)') i, j
828 IF (
atom%state%multiplicity == -1)
THEN
830 WRITE (iunit,
'(" L N Occupation Eigenvalue [eV] dE [eV] dCharge ")')
832 np =
atom%state%maxn_calc(l)
835 oc =
atom%state%occupation(l, k)
836 eig =
atom%orbitals%ener(k, l)
837 deig = eig -
atom%orbitals%refene(k, l, 1)
838 peig = pval(1, k, l, j, i)/afun*100._dp
839 IF (pval(5, k, l, j, i) > 0.5_dp)
THEN
842 WRITE (pc1,
"(I2)") nint(peig)
845 atom%orbitals%rcmax(k, l, 1), l,
atom%basis)
846 drho = charge -
atom%orbitals%refchg(k, l, 1)
847 pchg = pval(2, k, l, j, i)/afun*100._dp
848 IF (pval(6, k, l, j, i) > 0.5_dp)
THEN
851 WRITE (pc2,
"(I2)") min(nint(pchg), 99)
853 pct =
atom%orbitals%reftype(k, l, 1)
854 WRITE (iunit,
'(I5,I5,F14.2,F21.10,A3,F11.6,"[",A2,"]",F13.6,"[",A2,"]")') &
855 l, k, oc, eig*
evolt, pct, deig*
evolt, pc1, drho, pc2
861 WRITE (iunit,
'(" L N Spin Occupation Eigenvalue [eV] dE [eV] dCharge ")')
863 np =
atom%state%maxn_calc(l)
866 oc =
atom%state%occa(l, k)
867 eig =
atom%orbitals%enera(k, l)
868 deig = eig -
atom%orbitals%refene(k, l, 1)
869 peig = pval(1, k, l, j, i)/afun*100._dp
870 IF (pval(5, k, l, j, i) > 0.5_dp)
THEN
873 WRITE (pc1,
"(I2)") nint(peig)
876 charge,
atom%orbitals%wfna(:, k, l),
atom%orbitals%rcmax(k, l, 1), l,
atom%basis)
877 drho = charge -
atom%orbitals%refchg(k, l, 1)
878 pchg = pval(2, k, l, j, i)/afun*100._dp
879 IF (pval(6, k, l, j, i) > 0.5_dp)
THEN
882 WRITE (pc2,
"(I2)") min(nint(pchg), 99)
884 pct =
atom%orbitals%reftype(k, l, 1)
885 WRITE (iunit,
'(I5,I5,2X,A5,F11.2,F19.10,A3,F10.6,"[",A2,"]",F12.6,"[",A2,"]")') &
886 l, k,
"alpha", oc, eig*
evolt, pct, deig*
evolt, pc1, drho, pc2
887 oc =
atom%state%occb(l, k)
888 eig =
atom%orbitals%enerb(k, l)
889 deig = eig -
atom%orbitals%refene(k, l, 2)
890 peig = pval(3, k, l, j, i)/afun*100._dp
891 IF (pval(7, k, l, j, i) > 0.5_dp)
THEN
894 WRITE (pc1,
"(I2)") nint(peig)
897 charge,
atom%orbitals%wfnb(:, k, l),
atom%orbitals%rcmax(k, l, 2), l,
atom%basis)
898 drho = charge -
atom%orbitals%refchg(k, l, 2)
899 pchg = pval(4, k, l, j, i)/afun*100._dp
900 IF (pval(8, k, l, j, i) > 0.5_dp)
THEN
903 WRITE (pc2,
"(I2)") min(nint(pchg), 99)
905 pct =
atom%orbitals%reftype(k, l, 2)
906 WRITE (iunit,
'(I5,I5,2X,A5,F11.2,F19.10,A3,F10.6,"[",A2,"]",F12.6,"[",A2,"]")') &
907 l, k,
" beta", oc, eig*
evolt, pct, deig*
evolt, pc1, drho, pc2
918 WRITE (iunit,
'(" Method/Econf 1 "," Method/Econf 2"," Delta Energy "," Error Energy "," Target")')
919 DO j1 = 1,
SIZE(atom_info, 2)
920 DO j2 = 1,
SIZE(atom_info, 2)
921 DO i1 = 1,
SIZE(atom_info, 1)
922 DO i2 = 1,
SIZE(atom_info, 1)
923 IF ((j1 > j2) .OR. (j1 == j2 .AND. i1 >= i2)) cycle
924 IF (abs(dener(1, j1, j1, i1, i1)) < 0.000001_dp) cycle
925 IF (abs(dener(2, j1, j1, i1, i1)) < 0.000001_dp) cycle
926 IF (abs(dener(1, j2, j2, i2, i2)) < 0.000001_dp) cycle
927 IF (abs(dener(2, j2, j2, i2, i2)) < 0.000001_dp) cycle
928 de = dener(2, j1, j2, i1, i2) - dener(1, j1, j2, i1, i2)
929 WRITE (iunit,
'(i6,i6,i10,i6,5X,F16.6,F19.6,F12.6)') &
930 j1, i1, j2, i2, dener(2, j1, j2, i1, i2), de, t_ener
938 WRITE (iunit,
'(" Number of target values reached: ",T69,i5," of ",i3)') &
939 int(sum(pval(5:8, :, :, :, :))), ntarget
944 WRITE (iunit,
'(" POWELL| Start optimization",I4," of total",I4,T60,"rhobeg = ",F12.8)') &
945 nre, nreinit, ostate%rhobeg
951 IF (ostate%state == 2)
THEN
952 CALL put_pseudo_param(x, ppot%gth_pot, noopt_nlcc)
953 CALL pseudo_fit(atom_info, wfn_guess, ppot, ostate%f, wtot, pval, dener, w_ener, t_ener, .false.)
954 fopt = min(fopt, ostate%f)
957 IF (ostate%state == -1)
EXIT
961 IF (ostate%nf == 2 .AND. iunit > 0)
THEN
962 WRITE (iunit,
'(" POWELL| Initial value of function",T61,F20.10)') ostate%f
964 IF (mod(ostate%nf, n10) == 0 .AND. iunit > 0 .AND. ostate%nf > 2)
THEN
965 WRITE (iunit,
'(" POWELL| Reached",i4,"% of maximal function calls",T61,F20.10)') &
966 int(real(ostate%nf,
dp)/real(ostate%maxfun,
dp)*100._dp), fopt
967 CALL put_pseudo_param(ostate%xopt, ppot%gth_pot, noopt_nlcc)
971 IF (fopt < 1.e-12_dp)
EXIT
974 WRITE (iw, *) ostate%nf, ostate%f, x(1:ostate%nvar)
979 dx = sqrt(sum((ostate%xopt(:) - xi(:))**2)/real(ostate%nvar, kind=
dp))
981 WRITE (iunit,
'(" POWELL| RMS average of variables",T69,F12.10)') dx
985 CALL put_pseudo_param(x, ppot%gth_pot, noopt_nlcc)
988 IF ((dx*dx) < ostate%rhoend)
EXIT
989 ostate%rhobeg = step_size_scaling*ostate%rhobeg
994 WRITE (iunit,
'(" POWELL| Number of function evaluations",T71,I10)') ostate%nf
995 WRITE (iunit,
'(" POWELL| Final value of function",T61,F20.10)') ostate%fopt
997 CALL put_pseudo_param(x, ppot%gth_pot, noopt_nlcc)
998 CALL pseudo_fit(atom_info, wfn_guess, ppot, ostate%f, wtot, pval, dener, w_ener, t_ener, .false.)
999 afun = wtot*ostate%f + 1.0e-8_dp
1001 WRITE (iunit,
'(/," POWELL| Final errors of target values")')
1002 DO i = 1,
SIZE(atom_info, 1)
1003 DO j = 1,
SIZE(atom_info, 2)
1004 atom => atom_info(i, j)%atom
1006 WRITE (iunit,
'(/," Reference configuration ",T31,i5,T50," Method number ",T76,i5)') i, j
1007 IF (
atom%state%multiplicity == -1)
THEN
1009 WRITE (iunit,
'(" L N Occupation Eigenvalue [eV] dE [eV] dCharge ")')
1011 np =
atom%state%maxn_calc(l)
1014 oc =
atom%state%occupation(l, k)
1015 eig =
atom%orbitals%ener(k, l)
1016 deig = eig -
atom%orbitals%refene(k, l, 1)
1017 peig = pval(1, k, l, j, i)/afun*100._dp
1018 IF (pval(5, k, l, j, i) > 0.5_dp)
THEN
1021 WRITE (pc1,
"(I2)") nint(peig)
1024 charge,
atom%orbitals%wfn(:, k, l),
atom%orbitals%rcmax(k, l, 1), l,
atom%basis)
1025 drho = charge -
atom%orbitals%refchg(k, l, 1)
1026 pchg = pval(2, k, l, j, i)/afun*100._dp
1027 IF (pval(6, k, l, j, i) > 0.5_dp)
THEN
1030 WRITE (pc2,
"(I2)") min(nint(pchg), 99)
1032 pct =
atom%orbitals%reftype(k, l, 1)
1033 WRITE (iunit,
'(I5,I5,F14.2,F21.10,A3,F11.6,"[",A2,"]",F13.6,"[",A2,"]")') &
1034 l, k, oc, eig*
evolt, pct, deig*
evolt, pc1, drho, pc2
1038 np =
atom%state%maxn_calc(0)
1041 IF (abs(
atom%orbitals%tpsir0(k, 1)) > 1.e-14_dp)
THEN
1042 IF (abs(pv) > abs(
atom%orbitals%tpsir0(k, 1)))
THEN
1045 pv = 10._dp*(abs(pv) - abs(
atom%orbitals%tpsir0(k, 1)))
1047 pchg =
atom%weight*
atom%orbitals%wpsir0(k, 1)*pv*pv/afun
1049 pchg =
atom%weight*
atom%orbitals%wpsir0(k, 1)*pv*pv/afun*100._dp
1051 WRITE (iunit,
'(" s-states"," N=",I5,T40,"Wavefunction at r=0:",T64,F13.6,"[",I2,"]")') &
1056 WRITE (iunit,
'(" L N Spin Occupation Eigenvalue [eV] dE [eV] dCharge ")')
1058 np =
atom%state%maxn_calc(l)
1061 oc =
atom%state%occa(l, k)
1062 eig =
atom%orbitals%enera(k, l)
1063 deig = eig -
atom%orbitals%refene(k, l, 1)
1064 peig = pval(1, k, l, j, i)/afun*100._dp
1065 IF (pval(5, k, l, j, i) > 0.5_dp)
THEN
1068 WRITE (pc1,
"(I2)") nint(peig)
1071 charge,
atom%orbitals%wfna(:, k, l),
atom%orbitals%rcmax(k, l, 1), l,
atom%basis)
1072 drho = charge -
atom%orbitals%refchg(k, l, 1)
1073 pchg = pval(2, k, l, j, i)/afun*100._dp
1074 IF (pval(6, k, l, j, i) > 0.5_dp)
THEN
1077 WRITE (pc2,
"(I2)") min(nint(pchg), 99)
1079 pct =
atom%orbitals%reftype(k, l, 1)
1080 WRITE (iunit,
'(I5,I5,A,F11.2,F20.10,A3,F10.6,"[",A2,"]",F11.6,"[",A2,"]")') &
1081 l, k,
" alpha", oc, eig*
evolt, pct, deig*
evolt, pc1, drho, pc2
1082 oc =
atom%state%occb(l, k)
1083 eig =
atom%orbitals%enerb(k, l)
1084 deig = eig -
atom%orbitals%refene(k, l, 2)
1085 peig = pval(3, k, l, j, i)/afun*100._dp
1086 IF (pval(7, k, l, j, i) > 0.5_dp)
THEN
1089 WRITE (pc1,
"(I2)") nint(peig)
1092 charge,
atom%orbitals%wfnb(:, k, l),
atom%orbitals%rcmax(k, l, 2), l,
atom%basis)
1093 drho = charge -
atom%orbitals%refchg(k, l, 2)
1094 pchg = pval(4, k, l, j, i)/afun*100._dp
1095 IF (pval(8, k, l, j, i) > 0.5_dp)
THEN
1098 WRITE (pc2,
"(I2)") min(nint(pchg), 99)
1100 pct =
atom%orbitals%reftype(k, l, 2)
1101 WRITE (iunit,
'(I5,I5,A,F11.2,F20.10,A3,F10.6,"[",A2,"]",F11.6,"[",A2,"]")') &
1102 l, k,
" beta", oc, eig*
evolt, pct, deig*
evolt, pc1, drho, pc2
1106 np =
atom%state%maxn_calc(0)
1109 IF (abs(
atom%orbitals%tpsir0(k, 1)) > 1.e-14_dp)
THEN
1110 IF (abs(pv) > abs(
atom%orbitals%tpsir0(k, 1)))
THEN
1113 pv = 10._dp*(abs(pv) - abs(
atom%orbitals%tpsir0(k, 1)))
1115 pchg =
atom%weight*
atom%orbitals%wpsir0(k, 1)*pv*pv/afun
1117 pchg =
atom%weight*
atom%orbitals%wpsir0(k, 1)*pv*pv/afun*100._dp
1119 WRITE (iunit,
'(" s-states"," N=",I5,T35,"Alpha Wavefunction at r=0:",T64,F13.6,"[",I2,"]")') &
1123 IF (abs(
atom%orbitals%tpsir0(k, 2)) > 1.e-14_dp)
THEN
1124 IF (abs(pv) > abs(
atom%orbitals%tpsir0(k, 2)))
THEN
1127 pv = 10._dp*(abs(pv) - abs(
atom%orbitals%tpsir0(k, 2)))
1129 pchg =
atom%weight*
atom%orbitals%wpsir0(k, 2)*pv*pv/afun
1131 pchg =
atom%weight*
atom%orbitals%wpsir0(k, 2)*pv*pv/afun*100._dp
1133 WRITE (iunit,
'(" s-states"," N=",I5,T36,"Beta Wavefunction at r=0:",T64,F13.6,"[",I2,"]")') &
1143 WRITE (iunit,
'(" Method/Econf 1 "," Method/Econf 2"," Delta Energy "," Error Energy "," Target")')
1144 DO j1 = 1,
SIZE(atom_info, 2)
1145 DO j2 = 1,
SIZE(atom_info, 2)
1146 DO i1 = 1,
SIZE(atom_info, 1)
1147 DO i2 = 1,
SIZE(atom_info, 1)
1148 IF ((j1 > j2) .OR. (j1 == j2 .AND. i1 >= i2)) cycle
1149 IF (abs(dener(1, j1, j1, i1, i1)) < 0.000001_dp) cycle
1150 IF (abs(dener(2, j1, j1, i1, i1)) < 0.000001_dp) cycle
1151 IF (abs(dener(1, j2, j2, i2, i2)) < 0.000001_dp) cycle
1152 IF (abs(dener(2, j2, j2, i2, i2)) < 0.000001_dp) cycle
1153 de = dener(2, j1, j2, i1, i2) - dener(1, j1, j2, i1, i2)
1154 WRITE (iunit,
'(i6,i6,i10,i6,5X,F16.6,F19.6,F12.6)') j1, i1, j2, i2, dener(2, j1, j2, i1, i2), de, t_ener
1162 WRITE (iunit,
'(/," Number of target values reached: ",T69,i5," of ",i3)') int(sum(pval(5:8, :, :, :, :))), ntarget
1166 DEALLOCATE (x, pval, dener)
1168 DO i = 1,
SIZE(wfn_guess, 1)
1169 DO j = 1,
SIZE(wfn_guess, 2)
1170 IF (
ASSOCIATED(wfn_guess(i, j)%wfn))
THEN
1171 DEALLOCATE (wfn_guess(i, j)%wfn)
1175 DEALLOCATE (wfn_guess)
1177 IF (
ALLOCATED(xtob))
THEN