41#include "./base/base_uses.f90"
49 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_outer_scf'
71 POINTER :: cdft_control
74 SELECT CASE (scf_control%outer_scf%type)
80 IF (
PRESENT(cdft_control))
THEN
81 res =
SIZE(cdft_control%target)
106 CHARACTER(LEN=*),
PARAMETER :: routinen =
'outer_loop_gradient'
108 INTEGER :: handle, ihistory, ivar, n
109 LOGICAL :: is_constraint
117 CALL timeset(routinen, handle)
119 CALL get_qs_env(qs_env=qs_env, scf_control=scf_control, &
120 dft_control=dft_control, energy=energy)
121 cpassert(scf_control%outer_scf%have_scf)
123 ihistory = scf_env%outer_scf%iter_count
124 cpassert(ihistory <=
SIZE(scf_env%outer_scf%energy, 1))
126 scf_env%outer_scf%energy(ihistory) = energy%total
128 SELECT CASE (scf_control%outer_scf%type)
131 scf_env%outer_scf%variables(1, ihistory) = scf_env%iter_delta
132 scf_env%outer_scf%gradient(1, ihistory) = scf_env%iter_delta
134 cpassert(dft_control%qs_control%ddapc_restraint)
135 DO n = 1,
SIZE(dft_control%qs_control%ddapc_restraint_control)
136 NULLIFY (ddapc_restraint_control)
137 ddapc_restraint_control => dft_control%qs_control%ddapc_restraint_control(n)
139 IF (is_constraint)
EXIT
141 cpassert(is_constraint)
143 scf_env%outer_scf%variables(:, ihistory) = ddapc_restraint_control%strength
144 scf_env%outer_scf%gradient(:, ihistory) = ddapc_restraint_control%ddapc_order_p - &
145 ddapc_restraint_control%target
147 cpassert(dft_control%qs_control%s2_restraint)
148 s2_restraint_control => dft_control%qs_control%s2_restraint_control
150 cpassert(is_constraint)
152 scf_env%outer_scf%variables(:, ihistory) = s2_restraint_control%strength
153 scf_env%outer_scf%gradient(:, ihistory) = s2_restraint_control%s2_order_p - &
154 s2_restraint_control%target
156 cpassert(dft_control%qs_control%cdft)
157 cdft_control => dft_control%qs_control%cdft_control
158 DO ivar = 1,
SIZE(scf_env%outer_scf%gradient, 1)
159 scf_env%outer_scf%variables(ivar, ihistory) = cdft_control%strength(ivar)
160 scf_env%outer_scf%gradient(ivar, ihistory) = cdft_control%value(ivar) - &
161 cdft_control%target(ivar)
168 cpabort(
"Unknown outer SCF type")
172 CALL timestop(handle)
190 CHARACTER(LEN=*),
PARAMETER :: routinen =
'outer_loop_optimize'
192 INTEGER :: handle, i, ibuf, ihigh, ihistory, ilow, &
193 j, jbuf, nb, nvar, optimizer_type
194 REAL(kind=
dp) :: interval, scale, tmp
195 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: ev
196 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: a, b, f, x
197 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: inv_jacobian
199 CALL timeset(routinen, handle)
201 ihistory = scf_env%outer_scf%iter_count
202 optimizer_type = scf_control%outer_scf%optimizer
203 NULLIFY (inv_jacobian)
206 scf_env%outer_scf%variables(:, ihistory + 1) = scf_env%outer_scf%variables(:, ihistory)
210 SELECT CASE (optimizer_type)
212 cpassert(
SIZE(scf_env%outer_scf%gradient(:, 1)) == 1)
216 interval = huge(interval)
218 DO j = i + 1, ihistory
220 IF (scf_env%outer_scf%count(i) > scf_control%outer_scf%bisect_trust_count) cycle
221 IF (scf_env%outer_scf%count(j) > scf_control%outer_scf%bisect_trust_count) cycle
224 IF (scf_env%outer_scf%gradient(1, i)* &
225 scf_env%outer_scf%gradient(1, j) < 0.0_dp)
THEN
226 tmp = abs(scf_env%outer_scf%variables(1, i) - scf_env%outer_scf%variables(1, j))
227 IF (tmp < interval)
THEN
239 scf_env%outer_scf%count(ilow) = scf_env%outer_scf%count(ilow) + 1
240 scf_env%outer_scf%count(ihigh) = scf_env%outer_scf%count(ihigh) + 1
241 scf_env%outer_scf%variables(:, ihistory + 1) = 0.5_dp*(scf_env%outer_scf%variables(:, ilow) + &
242 scf_env%outer_scf%variables(:, ihigh))
244 scf_env%outer_scf%variables(:, ihistory + 1) = scf_env%outer_scf%variables(:, ihistory)
249 scf_env%outer_scf%variables(:, ihistory + 1) = scf_env%outer_scf%variables(:, ihistory) - &
250 scf_control%outer_scf%step_size*scf_env%outer_scf%gradient(:, ihistory)
252 cpassert(scf_control%outer_scf%diis_buffer_length > 0)
254 nb = min(ihistory, scf_control%outer_scf%diis_buffer_length)
259 ALLOCATE (b(nb + 1, nb + 1), a(nb + 1, nb + 1), ev(nb + 1))
262 ibuf = ihistory - nb + i
263 jbuf = ihistory - nb + j
264 b(i, j) = dot_product(scf_env%outer_scf%gradient(:, ibuf), &
265 scf_env%outer_scf%gradient(:, jbuf))
269 b(nb + 1, :) = -1.0_dp
270 b(:, nb + 1) = -1.0_dp
271 b(nb + 1, nb + 1) = 0.0_dp
276 IF (abs(ev(i)) < 1.0e-12_dp)
THEN
279 a(:, i) = a(:, i)/ev(i)
282 ev(:) = -matmul(a, b(nb + 1, :))
284 scf_env%outer_scf%variables(:, ihistory + 1) = 0.0_dp
286 ibuf = ihistory - nb + i
287 scf_env%outer_scf%variables(:, ihistory + 1) = scf_env%outer_scf%variables(:, ihistory + 1) + &
288 ev(i)*scf_env%outer_scf%variables(:, ibuf)
290 DEALLOCATE (a, b, ev)
293 cpassert(
SIZE(scf_env%outer_scf%gradient, 2) >= 3)
294 cpassert(
SIZE(scf_env%outer_scf%gradient, 1) == 1)
295 nvar =
SIZE(scf_env%outer_scf%gradient, 1)
296 IF (ihistory < 2)
THEN
302 scf_env%outer_scf%variables(1, ihistory + 1) = scf_env%outer_scf%variables(1, ihistory) - &
303 (scf_env%outer_scf%variables(1, ihistory) - &
304 scf_env%outer_scf%variables(1, ihistory - 1))/ &
305 (scf_env%outer_scf%gradient(1, ihistory) - &
306 scf_env%outer_scf%gradient(1, ihistory - 1))* &
307 scf_env%outer_scf%gradient(1, ihistory)
309 IF (.NOT.
ASSOCIATED(scf_env%outer_scf%inv_jacobian))
THEN
314 inv_jacobian => scf_env%outer_scf%inv_jacobian
315 IF (ihistory < 2)
THEN
317 scf_control%outer_scf%cdft_opt_control%broyden_update = .false.
319 IF (scf_control%outer_scf%cdft_opt_control%broyden_update)
THEN
321 IF (
SIZE(scf_env%outer_scf%gradient, 2) < 3)
THEN
322 CALL cp_abort(__location__, &
323 "Keyword EXTRAPOLATION_ORDER in section OUTER_SCF "// &
324 "must be greater than or equal to 3 for Broyden optimizers.")
326 nvar =
SIZE(scf_env%outer_scf%gradient, 1)
327 ALLOCATE (f(nvar, 1), x(nvar, 1))
329 f(i, 1) = scf_env%outer_scf%gradient(i, ihistory) - scf_env%outer_scf%gradient(i, ihistory - 1)
330 x(i, 1) = scf_env%outer_scf%variables(i, ihistory) - scf_env%outer_scf%variables(i, ihistory - 1)
332 SELECT CASE (scf_control%outer_scf%cdft_opt_control%broyden_type)
337 scale = sum(matmul(transpose(x), matmul(inv_jacobian, f)))
339 IF (scale < 1.0e-12_dp) scale = 1.0e-12_dp
340 inv_jacobian = inv_jacobian + scale*matmul((x - matmul(inv_jacobian, f)), &
341 matmul(transpose(x), inv_jacobian))
345 scale = sum(matmul(transpose(f), f))
347 IF (scale < 1.0e-12_dp) scale = 1.0e-12_dp
348 inv_jacobian = inv_jacobian + scale*matmul((x - matmul(inv_jacobian, f)), transpose(inv_jacobian))
350 CALL cp_abort(__location__, &
351 "Unknown Broyden type: "// &
352 cp_to_string(scf_control%outer_scf%cdft_opt_control%broyden_type))
358 scf_env%outer_scf%variables(:, ihistory + 1) = scf_env%outer_scf%variables(:, ihistory) - &
359 scf_control%outer_scf%cdft_opt_control%newton_step* &
360 matmul(inv_jacobian, scf_env%outer_scf%gradient(:, ihistory))
361 scf_control%outer_scf%cdft_opt_control%broyden_update = .true.
363 cpassert(
ASSOCIATED(scf_env%outer_scf%inv_jacobian))
364 inv_jacobian => scf_env%outer_scf%inv_jacobian
365 scf_env%outer_scf%variables(:, ihistory + 1) = scf_env%outer_scf%variables(:, ihistory) - &
366 scf_control%outer_scf%cdft_opt_control%newton_step* &
367 matmul(inv_jacobian, scf_env%outer_scf%gradient(:, ihistory))
369 cpabort(
"Unknown outer SCF optimizer")
375 CALL timestop(handle)
391 CHARACTER(LEN=*),
PARAMETER :: routinen =
'outer_loop_update_qs_env'
393 INTEGER :: handle, ihistory, n
394 LOGICAL :: is_constraint
401 CALL timeset(routinen, handle)
403 CALL get_qs_env(qs_env=qs_env, scf_control=scf_control, dft_control=dft_control)
404 ihistory = scf_env%outer_scf%iter_count
406 SELECT CASE (scf_control%outer_scf%type)
410 DO n = 1,
SIZE(dft_control%qs_control%ddapc_restraint_control)
411 NULLIFY (ddapc_restraint_control)
412 ddapc_restraint_control => dft_control%qs_control%ddapc_restraint_control(n)
414 IF (is_constraint)
EXIT
416 ddapc_restraint_control%strength = scf_env%outer_scf%variables(1, ihistory + 1)
418 s2_restraint_control => dft_control%qs_control%s2_restraint_control
419 s2_restraint_control%strength = scf_env%outer_scf%variables(1, ihistory + 1)
421 cdft_control => dft_control%qs_control%cdft_control
422 cdft_control%strength(:) = scf_env%outer_scf%variables(:, ihistory + 1)
426 cpabort(
"Unknown outer SCF type")
429 CALL timestop(handle)
446 CHARACTER(LEN=*),
PARAMETER :: routinen =
'outer_loop_extrapolate'
448 INTEGER :: handle, ihis, ivec, n, nhistory, &
449 nvariables, nvec, outer_scf_ihistory
450 LOGICAL :: is_constraint
451 REAL(kind=
dp) :: alpha
452 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: extrapolation
453 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: outer_scf_history
458 CALL timeset(routinen, handle)
460 CALL get_qs_env(qs_env, outer_scf_history=outer_scf_history, &
461 outer_scf_ihistory=outer_scf_ihistory, &
462 scf_control=scf_control, dft_control=dft_control)
464 nvariables =
SIZE(outer_scf_history, 1)
465 nhistory =
SIZE(outer_scf_history, 2)
466 ALLOCATE (extrapolation(nvariables))
467 cpassert(nhistory > 0)
470 outer_scf_ihistory = outer_scf_ihistory + 1
471 ivec = 1 +
modulo(outer_scf_ihistory - 1, nhistory)
472 SELECT CASE (scf_control%outer_scf%type)
474 outer_scf_history(1, ivec) = 0.0_dp
476 DO n = 1,
SIZE(dft_control%qs_control%ddapc_restraint_control)
477 NULLIFY (ddapc_restraint_control)
478 ddapc_restraint_control => dft_control%qs_control%ddapc_restraint_control(n)
480 IF (is_constraint)
EXIT
482 outer_scf_history(1, ivec) = &
483 ddapc_restraint_control%strength
485 outer_scf_history(1, ivec) = &
486 dft_control%qs_control%s2_restraint_control%strength
488 outer_scf_history(:, ivec) = &
489 dft_control%qs_control%cdft_control%strength(:)
491 outer_scf_history(1, ivec) = 0.0_dp
493 cpabort(
"Unknown outer SCF type")
495 CALL set_qs_env(qs_env, outer_scf_ihistory=outer_scf_ihistory)
497 nvec = min(nhistory, outer_scf_ihistory)
499 ivec = 1 +
modulo(outer_scf_ihistory - 1, nhistory)
500 extrapolation(:) = alpha*outer_scf_history(:, ivec)
502 alpha = -1.0_dp*alpha*real(nvec - ihis + 1,
dp)/real(ihis,
dp)
503 ivec = 1 +
modulo(outer_scf_ihistory - ihis, nhistory)
504 extrapolation(:) = extrapolation + alpha*outer_scf_history(:, ivec)
508 SELECT CASE (scf_control%outer_scf%type)
512 ddapc_restraint_control%strength = extrapolation(1)
514 dft_control%qs_control%s2_restraint_control%strength = extrapolation(1)
516 dft_control%qs_control%cdft_control%strength(:) = extrapolation(:)
520 cpabort(
"Unknown outer SCF type")
523 DEALLOCATE (extrapolation)
525 CALL timestop(handle)
543 INTEGER,
INTENT(IN) :: dir
545 INTEGER :: nvariables
551 IF (
ASSOCIATED(scf_control%outer_scf%cdft_opt_control))
THEN
552 cpassert(
ASSOCIATED(cdft_control%constraint_control%cdft_opt_control))
554 scf_control%outer_scf%cdft_opt_control)
559 scf_control%outer_scf%have_scf = cdft_control%ot_control%have_scf
560 scf_control%outer_scf%max_scf = cdft_control%ot_control%max_scf
561 scf_control%outer_scf%eps_scf = cdft_control%ot_control%eps_scf
562 scf_control%outer_scf%step_size = cdft_control%ot_control%step_size
563 scf_control%outer_scf%type = cdft_control%ot_control%type
564 scf_control%outer_scf%optimizer = cdft_control%ot_control%optimizer
565 scf_control%outer_scf%diis_buffer_length = cdft_control%ot_control%diis_buffer_length
566 scf_control%outer_scf%bisect_trust_count = cdft_control%ot_control%bisect_trust_count
568 cdft_control%constraint%iter_count = scf_env%outer_scf%iter_count
569 cdft_control%constraint%energy = scf_env%outer_scf%energy
570 cdft_control%constraint%variables = scf_env%outer_scf%variables
571 cdft_control%constraint%gradient = scf_env%outer_scf%gradient
572 cdft_control%constraint%count = scf_env%outer_scf%count
573 cdft_control%constraint%deallocate_jacobian = scf_env%outer_scf%deallocate_jacobian
574 IF (
ASSOCIATED(scf_env%outer_scf%inv_jacobian))
THEN
575 nvariables =
SIZE(scf_env%outer_scf%inv_jacobian, 1)
576 IF (.NOT.
ASSOCIATED(cdft_control%constraint%inv_jacobian))
THEN
577 ALLOCATE (cdft_control%constraint%inv_jacobian(nvariables, nvariables))
579 cdft_control%constraint%inv_jacobian = scf_env%outer_scf%inv_jacobian
582 IF (
ASSOCIATED(scf_env%outer_scf%energy))
THEN
583 DEALLOCATE (scf_env%outer_scf%energy)
585 ALLOCATE (scf_env%outer_scf%energy(scf_control%outer_scf%max_scf + 1))
586 scf_env%outer_scf%energy = 0.0_dp
587 IF (
ASSOCIATED(scf_env%outer_scf%variables))
THEN
588 DEALLOCATE (scf_env%outer_scf%variables)
590 ALLOCATE (scf_env%outer_scf%variables(1, scf_control%outer_scf%max_scf + 1))
591 scf_env%outer_scf%variables = 0.0_dp
592 IF (
ASSOCIATED(scf_env%outer_scf%gradient))
THEN
593 DEALLOCATE (scf_env%outer_scf%gradient)
595 ALLOCATE (scf_env%outer_scf%gradient(1, scf_control%outer_scf%max_scf + 1))
596 scf_env%outer_scf%gradient = 0.0_dp
597 IF (
ASSOCIATED(scf_env%outer_scf%count))
THEN
598 DEALLOCATE (scf_env%outer_scf%count)
600 ALLOCATE (scf_env%outer_scf%count(scf_control%outer_scf%max_scf + 1))
601 scf_env%outer_scf%count = 0
603 scf_env%outer_scf%deallocate_jacobian = .true.
604 IF (
ASSOCIATED(scf_env%outer_scf%inv_jacobian))
THEN
605 DEALLOCATE (scf_env%outer_scf%inv_jacobian)
609 scf_control%outer_scf%have_scf = cdft_control%constraint_control%have_scf
610 scf_control%outer_scf%max_scf = cdft_control%constraint_control%max_scf
611 scf_control%outer_scf%eps_scf = cdft_control%constraint_control%eps_scf
612 scf_control%outer_scf%step_size = cdft_control%constraint_control%step_size
613 scf_control%outer_scf%type = cdft_control%constraint_control%type
614 scf_control%outer_scf%optimizer = cdft_control%constraint_control%optimizer
615 scf_control%outer_scf%diis_buffer_length = cdft_control%constraint_control%diis_buffer_length
616 scf_control%outer_scf%bisect_trust_count = cdft_control%constraint_control%bisect_trust_count
618 cdft_control%constraint_control%cdft_opt_control)
619 nvariables =
SIZE(cdft_control%constraint%variables, 1)
620 IF (
ASSOCIATED(scf_env%outer_scf%energy))
THEN
621 DEALLOCATE (scf_env%outer_scf%energy)
623 ALLOCATE (scf_env%outer_scf%energy(scf_control%outer_scf%max_scf + 1))
624 scf_env%outer_scf%energy = cdft_control%constraint%energy
625 IF (
ASSOCIATED(scf_env%outer_scf%variables))
THEN
626 DEALLOCATE (scf_env%outer_scf%variables)
628 ALLOCATE (scf_env%outer_scf%variables(nvariables, scf_control%outer_scf%max_scf + 1))
629 scf_env%outer_scf%variables = cdft_control%constraint%variables
630 IF (
ASSOCIATED(scf_env%outer_scf%gradient))
THEN
631 DEALLOCATE (scf_env%outer_scf%gradient)
633 ALLOCATE (scf_env%outer_scf%gradient(nvariables, scf_control%outer_scf%max_scf + 1))
634 scf_env%outer_scf%gradient = cdft_control%constraint%gradient
635 IF (
ASSOCIATED(scf_env%outer_scf%count))
THEN
636 DEALLOCATE (scf_env%outer_scf%count)
638 ALLOCATE (scf_env%outer_scf%count(scf_control%outer_scf%max_scf + 1))
639 scf_env%outer_scf%count = cdft_control%constraint%count
640 scf_env%outer_scf%iter_count = cdft_control%constraint%iter_count
641 scf_env%outer_scf%deallocate_jacobian = cdft_control%constraint%deallocate_jacobian
642 IF (
ASSOCIATED(cdft_control%constraint%inv_jacobian))
THEN
643 IF (
ASSOCIATED(scf_env%outer_scf%inv_jacobian))
THEN
644 DEALLOCATE (scf_env%outer_scf%inv_jacobian)
646 ALLOCATE (scf_env%outer_scf%inv_jacobian(nvariables, nvariables))
647 scf_env%outer_scf%inv_jacobian = cdft_control%constraint%inv_jacobian
650 cpabort(
"Switching direction should be either ot2cdft or cdft2ot")
665 CHARACTER(LEN=*),
PARAMETER :: routinen =
'outer_loop_purge_history'
667 INTEGER :: handle, outer_scf_ihistory
668 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: gradient_history, outer_scf_history, &
671 CALL timeset(routinen, handle)
673 CALL get_qs_env(qs_env, outer_scf_history=outer_scf_history, &
674 outer_scf_ihistory=outer_scf_ihistory, &
675 gradient_history=gradient_history, &
676 variable_history=variable_history)
677 cpassert(
SIZE(outer_scf_history, 2) > 0)
678 outer_scf_ihistory = 0
679 outer_scf_history = 0.0_dp
680 gradient_history = 0.0_dp
681 variable_history = 0.0_dp
682 CALL set_qs_env(qs_env, outer_scf_ihistory=outer_scf_ihistory)
684 CALL timestop(handle)
static GRID_HOST_DEVICE int modulo(int a, int m)
Equivalent of Fortran's MODULO, which always return a positive number. https://gcc....
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
various routines to log and control the output. The idea is that decisions about where to log should ...
Defines the basic variable types.
integer, parameter, public dp
Collection of simple mathematical functions and subroutines.
subroutine, public diamat_all(a, eigval, dac)
Diagonalize the symmetric n by n matrix a using the LAPACK library. Only the upper triangle of matrix...
subroutine, public qs_basis_center_gradient(qs_env)
...
real(kind=dp) function, public return_basis_center_gradient_norm(qs_env)
... returns the norm of the gradient vector, taking only floating components into account
subroutine, public qs_update_basis_center_pos(qs_env)
move atoms with kind float according to gradient
Control parameters for optimizers that work with CDFT constraints.
subroutine, public cdft_opt_type_release(cdft_opt_control)
releases the CDFT optimizer control object
subroutine, public cdft_opt_type_copy(new, old)
copies settings between two CDFT optimizer control objects retaining both
Defines CDFT control structures.
subroutine, public get_qs_env(qs_env, atomic_kind_set, qs_kind_set, cell, super_cell, cell_ref, use_ref_cell, kpoints, dft_control, mos, sab_orb, sab_all, qmmm, qmmm_periodic, mimic, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, matrix_vhxc, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, xcint_weights, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, rhoz_cneo_set, ecoul_1c, rho0_s_rs, rho0_s_gs, rhoz_cneo_s_rs, rhoz_cneo_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, lri_env, lri_density, exstate_env, ec_env, harris_env, dispersion_env, gcp_env, vee, rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, wanniercentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs, do_rixs, tb_tblite)
Get the QUICKSTEP environment.
subroutine, public set_qs_env(qs_env, super_cell, mos, qmmm, qmmm_periodic, mimic, ewald_env, ewald_pw, mpools, rho_external, external_vxc, mask, scf_control, rel_control, qs_charges, ks_env, ks_qmmm_env, wf_history, scf_env, active_space, input, oce, rho_atom_set, rho0_atom_set, rho0_mpole, run_rtp, rtp, rhoz_set, rhoz_tot, ecoul_1c, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, efield, rhoz_cneo_set, linres_control, xas_env, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, ls_scf_env, do_transport, transport_env, lri_env, lri_density, exstate_env, ec_env, dispersion_env, harris_env, gcp_env, mp2_env, bs_env, kg_env, force, kpoints, wanniercentres, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs, do_rixs, tb_tblite)
Set the QUICKSTEP environment.
Routines for performing an outer scf loop.
subroutine, public outer_loop_purge_history(qs_env)
purges outer_scf_history zeroing everything except the latest value of the outer_scf variable stored ...
subroutine, public outer_loop_switch(scf_env, scf_control, cdft_control, dir)
switch between two outer_scf envs stored in cdft_control
subroutine, public outer_loop_optimize(scf_env, scf_control)
optimizes the parameters of the outer_scf
subroutine, public outer_loop_extrapolate(qs_env)
uses the outer_scf_history to extrapolate new values for the variables and updates their value in qs_...
subroutine, public outer_loop_update_qs_env(qs_env, scf_env)
propagates the updated variables to wherever they need to be set in qs_env
integer function, public outer_loop_variables_count(scf_control, cdft_control)
returns the number of variables that is employed in the outer loop. with a CDFT constraint this value...
subroutine, public outer_loop_gradient(qs_env, scf_env)
computes the gradient wrt to the outer loop variables
module that contains the definitions of the scf types
parameters that control an scf iteration