24 use,
intrinsic :: iso_fortran_env
34 integer,
public,
parameter :: &
51 integer,
public :: max_iter
53 real(real64),
public :: conv_rel_dens
54 real(real64),
public :: conv_abs_dens
55 real(real64) :: conv_threshold_use
56 real(real64) :: dynamic_tol_factor
57 real(real64) :: current_tol
58 real(real64) :: initial_tol
59 real(real64),
public :: final_tol
60 integer :: iter_window
66 subroutine scf_tol_init(this, namespace, qtot, def_maximumiter, tol_scheme)
67 type(scf_tol_t),
intent(out) :: this
68 type(namespace_t),
intent(in) :: namespace
69 real(real64),
intent(in) :: qtot
70 integer,
optional,
intent(in) :: def_maximumiter
71 integer,
optional,
intent(in) :: tol_scheme
73 integer :: def_maximumiter_
84 def_maximumiter_ = 200
85 if (
present(def_maximumiter)) def_maximumiter_ = def_maximumiter
87 call parse_variable(namespace,
'LRMaximumIter', def_maximumiter_, this%max_iter)
100 call parse_variable(namespace,
'LRConvAbsDens', 1e-5_real64, this%conv_abs_dens)
116 if (this%conv_abs_dens <=
m_zero)
then
117 this%conv_threshold_use = this%conv_rel_dens * qtot
118 else if (this%conv_rel_dens <=
m_zero)
then
119 this%conv_threshold_use = this%conv_abs_dens
121 this%conv_threshold_use = min(this%conv_abs_dens, this%conv_rel_dens * qtot)
124 if (this%conv_abs_dens <=
m_zero .and. this%conv_rel_dens <=
m_zero)
then
125 message(1) =
"Input: Not all convergence criteria can be <= 0"
126 message(2) =
"Please set one of the following to a nonzero value:"
151 if (
present(tol_scheme))
then
152 this%scheme = tol_scheme
169 call parse_variable(namespace,
'LRTolInitTol', 1e-2_real64, this%initial_tol)
170 this%current_tol = this%initial_tol
180 call parse_variable(namespace,
'LRTolFinalTol', 1e-6_real64, this%final_tol)
193 call parse_variable(namespace,
'LRTolAdaptiveFactor', 0.1_real64, this%dynamic_tol_factor)
205 call parse_variable(namespace,
'LRTolIterWindow', 10, this%iter_window)
214 real(real64) function
scf_tol_step(this, iter, scf_res) result(r)
216 integer,
intent(in) :: iter
217 real(real64),
intent(in) :: scf_res
219 real(real64) :: logi, logf
223 if (iter == 0) this%current_tol =
m_huge
225 select case (this%scheme)
233 r = this%dynamic_tol_factor * (this%final_tol/this%conv_threshold_use)*scf_res
237 r = this%initial_tol + (this%final_tol - this%initial_tol) * &
238 real(iter, real64) /
real(this%iter_window, real64)
241 logi =
log(this%initial_tol)
242 logf =
log(this%final_tol)
243 r = logi + (logf - logi) * &
244 real(iter, real64) /
real(this%iter_window, real64)
249 r = max(r, this%final_tol)
251 r = min(r, this%current_tol)
264 this%current_tol = m_zero
275 this%current_tol = m_zero
292 type(namespace_t),
intent(in) :: namespace
293 character(len=*),
intent(in) :: old_prefix
294 character(len=*),
intent(in) :: new_prefix
298 call messages_obsolete_variable(namespace, trim(old_prefix)//
'LRMaximumIter', trim(new_prefix)//
'LRMaximumIter')
299 call messages_obsolete_variable(namespace, trim(old_prefix)//
'LRConvAbsDens', trim(new_prefix)//
'LRConvAbsDens')
300 call messages_obsolete_variable(namespace, trim(old_prefix)//
'LRTolScheme', trim(new_prefix)//
'LRTolScheme')
301 call messages_obsolete_variable(namespace, trim(old_prefix)//
'LRTolInitTol', trim(new_prefix)//
'LRTolInitTol')
302 call messages_obsolete_variable(namespace, trim(old_prefix)//
'LRTolFinalTol', trim(new_prefix)//
'LRTolFinalTol')
303 call messages_obsolete_variable(namespace, trim(old_prefix)//
'LRTolAdaptiveFactor', trim(new_prefix)//
'LRTolAdaptiveFactor')
304 call messages_obsolete_variable(namespace, trim(old_prefix)//
'LRTolIterWindow', trim(new_prefix)//
'LRTolIterWindow')
double log(double __x) __attribute__((__nothrow__
double exp(double __x) __attribute__((__nothrow__
real(real64), parameter, public m_huge
real(real64), parameter, public m_zero
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
subroutine, public messages_fatal(no_lines, only_root_writes, namespace)
subroutine, public messages_input_error(namespace, var, details, row, column)
real(real64) function, public scf_tol_step(this, iter, scf_res)
integer, parameter, public scf_tol_adaptive
subroutine, public scf_tol_init(this, namespace, qtot, def_maximumiter, tol_scheme)
subroutine, public scf_tol_end(this)
real(real64) function, public scf_tol_final(this)
integer, parameter, public scf_tol_exp
integer, parameter, public scf_tol_linear
subroutine, public scf_tol_obsolete_variables(namespace, old_prefix, new_prefix)
subroutine, public scf_tol_stop(this)