20 REAL(kind=
dp),
PARAMETER :: tolerance = 1.0e-14_dp
24 REAL(kind=
dp) :: damping, measured, predicted, quality, ratio, &
29 error stop
"Broyden retained a non-descent history"
32 error stop
"Broyden discarded a descent history"
35 error stop
"CG retained unresolved free-energy history"
38 error stop
"CG discarded resolved free-energy history"
41 error stop
"L-BFGS restarted at the gradient-growth threshold"
44 error stop
"L-BFGS missed excessive gradient growth"
47 error stop
"L-BFGS restarted at the step-collapse threshold"
50 error stop
"L-BFGS retained a collapsed step"
55 error stop
"Well-conditioned L-BFGS curvature was damped"
58 sy = real(i, kind=
dp)*0.1_dp
60 yy = 1.0_dp + 2.0_dp*damping*sy + damping**2
61 IF (.NOT. (damping > 0.0_dp .AND. sy + damping > 0.5_dp*sqrt(yy)))
THEN
62 error stop
"L-BFGS damping failed the relative-curvature bound"
68 IF (.NOT. (accepted .AND. abs(scale - 1.5_dp) <= tolerance .AND. weight == 1.0_dp))
THEN
69 error stop
"L-BFGS response secant changed the H0 direction norm"
72 sy = weight*scale*0.01_dp + (1.0_dp - weight)*2.0_dp
73 IF (.NOT. (accepted .AND. abs(sy - 0.4_dp) <= tolerance .AND. weight > 0.0_dp .AND. weight < 1.0_dp))
THEN
74 error stop
"L-BFGS response secant failed the Powell curvature bound"
77 IF (accepted .OR. weight /= 0.0_dp) error stop
"Rejected response secant changed H0"
81 10.0_dp, 9.6_dp, 1.0_dp, 0.8_dp, 1.0_dp, 1.0_dp, 0.5_dp, 0.1_dp, &
82 predicted, measured, quality, ratio, accepted)
83 IF (.NOT. (accepted .AND. abs(predicted - 0.375_dp) <= tolerance .AND. &
84 abs(measured - 0.4_dp) <= tolerance .AND. abs(quality - 0.4_dp/0.375_dp) <= tolerance .AND. &
85 abs(ratio - 0.8_dp) <= tolerance)) error stop
"Useful Mermin response was rejected"
87 10.0_dp, 9.6_dp, 1.0_dp, 1.5_dp, 1.0_dp, 1.0_dp, 0.5_dp, 0.1_dp, &
88 predicted, measured, quality, ratio, accepted)
89 IF (accepted) error stop
"Residual-growing Mermin response was accepted"
Defines the basic variable types.
integer, parameter, public dp
pure subroutine, public lbfgs_response_secant_parameters(g_dot_response, response_norm_sq, g_dot_h0_g, h0_g_norm_sq, response_scale, response_weight, valid)
Normalize and damp an occupation-response secant against the conventional H0 direction.
pure subroutine, public ot_mermin_response_assess(reference_energy, current_energy, reference_residual, current_residual, predicted_slope, predicted_curvature, position, default_step, predicted_drop, measured_drop, quality, residual_ratio, good)
Assess a finite-response candidate at its accepted Mermin endpoint.
pure elemental logical function, public broyden_history_restart_required(non_descent, forget_history, do_ener)
Decide whether a non-descent Broyden step invalidates its secant history.
pure real(kind=dp) function, public lbfgs_curvature_damping_shift(sy, ss, yy, curvature_tol)
Returns the smallest shift y <- y + shift*s that meets relative L-BFGS curvature.
pure logical function, public lbfgs_history_restart_required(current_gradient_norm_sq, previous_gradient_norm_sq)
Decides whether an L-BFGS history must be discarded after excessive gradient growth.
pure elemental logical function, public cg_history_restart_required(occupation_preconditioned, current_energy, reference_energy)
Decide whether an unresolved accepted energy change invalidates CG conjugacy.
pure logical function, public lbfgs_step_restart_required(accepted_step, reference_step)
Decides whether L-BFGS must recover from a collapsed accepted line-search step.
program qs_ot_minimizer_unittest