The Self-consistency cycle
Definition of scf_t
type scf_t
private
integer, public :: max_iter !< maximum number of SCF iterations
real(real64), public :: lmm_r
! several convergence criteria
logical :: conv_eigen_error
logical :: check_conv
integer :: mix_field
logical :: lcao_restricted
logical :: calc_force
logical, public :: calc_stress
logical :: calc_dipole
logical :: calc_partial_charges
type(mix_t) :: smix
type(mixfield_t), pointer :: mixfield
type(eigensolver_t) :: eigens
integer :: mixdim1
logical :: forced_finish !< remember if 'touch stop' was triggered earlier.
type(lda_u_mixer_t) :: lda_u_mix
type(vtau_mixer_t) :: vtau_mix
type(berry_t) :: berry
integer :: matvec !< number matrix-vector products
type(restart_t), public :: restart_load, restart_dump
type(criterion_list_t), public :: criterion_list
real(real64) :: energy_in, energy_diff, abs_dens_diff, evsum_in, evsum_out, evsum_diff
! Variables needed to store information accross scf_start, scf_run, and scf_finish
logical :: converged_current, converged_last
integer :: verbosity_
type(lcao_t) :: lcao !< Linear combination of atomic orbitals
real(real64), allocatable :: rhoout(:,:), rhoin(:,:)
real(real64), allocatable :: vhxc_old(:,:)
class(wfs_elec_t), allocatable :: psioutb(:, :)
logical :: output_forces, calc_current, output_during_scf, finish
end type scf_t
Definition of scf_run()
subroutine scf_run(scf, namespace, space, mc, gr, ions, ext_partners, st, ks, hm, outp, &
verbosity, iters_done, restart_dump)
type(scf_t), intent(inout) :: scf !< self consistent cycle
type(namespace_t), intent(in) :: namespace
type(electron_space_t), intent(in) :: space
type(multicomm_t), intent(in) :: mc
type(grid_t), intent(inout) :: gr !< grid
type(ions_t), intent(inout) :: ions !< geometry
type(partner_list_t), intent(in) :: ext_partners
type(states_elec_t), intent(inout) :: st !< States
type(v_ks_t), intent(inout) :: ks !< Kohn-Sham
type(hamiltonian_elec_t), intent(inout) :: hm !< Hamiltonian
type(output_t), optional, intent(in) :: outp
integer, optional, intent(in) :: verbosity
integer, optional, intent(out) :: iters_done
type(restart_t), optional, intent(in) :: restart_dump
integer :: iter
logical :: completed
PUSH_SUB(scf_run)
call scf_start(scf, namespace, space, gr, ions, st, ks, hm, outp, verbosity)
! SCF cycle
do iter = 1, scf%max_iter
call scf_iter(scf, namespace, space, mc, gr, ions, ext_partners, st, ks, hm, iter, outp, &
verbosity, iters_done, restart_dump)
completed = scf_iter_finish(scf, namespace, space, gr, ions, st, ks, hm, iter, outp, verbosity, iters_done)
if(scf%forced_finish .or. completed) then
exit
end if
end do
call scf_finish(scf, namespace, space, mc, gr, ions, ext_partners, st, ks, hm, iter, outp, &
verbosity, iters_done, restart_dump)
POP_SUB(scf_run)
end subroutine scf_run