33#include "./base/base_uses.f90"
39 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'almo_scf_env_methods'
55 CHARACTER(len=*),
PARAMETER :: routinen =
'almo_scf_env_create'
57 INTEGER :: handle, nallocate
62 CALL timeset(routinen, handle)
64 ALLOCATE (almo_scf_env)
67 CALL get_qs_env(qs_env, input=input, dft_control=dft_control)
70 CALL almo_scf_init_read_write_input(input, almo_scf_env)
73 almo_scf_env%nspins = dft_control%nspins
74 almo_scf_env%almo_history%nstore = almo_scf_env%almo_extrapolation_order
75 almo_scf_env%almo_history%istore = 0
77 nallocate = max(1, almo_scf_env%almo_extrapolation_order)
78 ALLOCATE (almo_scf_env%almo_history%matrix_p_up_down(almo_scf_env%nspins, nallocate))
79 ALLOCATE (almo_scf_env%almo_history%matrix_t(almo_scf_env%nspins))
80 almo_scf_env%xalmo_history%nstore = almo_scf_env%xalmo_extrapolation_order
81 almo_scf_env%xalmo_history%istore = 0
82 nallocate = max(1, almo_scf_env%xalmo_extrapolation_order)
83 ALLOCATE (almo_scf_env%xalmo_history%matrix_p_up_down(almo_scf_env%nspins, nallocate))
85 ALLOCATE (almo_scf_env%xalmo_history%matrix_t(almo_scf_env%nspins))
88 CALL set_qs_env(qs_env, almo_scf_env=almo_scf_env)
103 SUBROUTINE almo_scf_init_read_write_input(input, almo_scf_env)
107 CHARACTER(len=*),
PARAMETER :: routinen =
'almo_scf_init_read_write_input'
109 INTEGER :: handle, i, ndomain
111 TYPE(
section_vals_type),
POINTER :: almo_analysis_section, almo_opt_diis_section, &
112 almo_opt_pcg_section, almo_opt_trustr_section, almo_scf_section, fragment_section, &
113 matrix_iterate_section, nlmo_opt_pcg_section, penalty_section, &
114 xalmo_opt_newton_pcg_section, xalmo_opt_pcg_section, xalmo_opt_trustr_section
116 CALL timeset(routinen, handle)
120 "ALMO_OPTIMIZER_DIIS")
122 "ALMO_OPTIMIZER_PCG")
124 "ALMO_OPTIMIZER_TRUSTR")
126 "XALMO_OPTIMIZER_PCG")
128 "XALMO_OPTIMIZER_TRUSTR")
130 "NLMO_OPTIMIZER_PCG")
133 "XALMO_NEWTON_PCG_SOLVER")
140 r_val=almo_scf_env%eps_filter)
142 i_val=almo_scf_env%almo_scf_guess)
144 i_val=almo_scf_env%almo_update_algorithm)
146 i_val=almo_scf_env%xalmo_update_algorithm)
148 i_val=almo_scf_env%xalmo_trial_wf)
150 i_val=almo_scf_env%sigma_inv_algorithm)
152 i_val=almo_scf_env%deloc_method)
154 r_val=almo_scf_env%quencher_r0_factor)
156 i_val=almo_scf_env%almo_extrapolation_order)
157 almo_scf_env%almo_extrapolation_order = max(0, almo_scf_env%almo_extrapolation_order)
159 i_val=almo_scf_env%xalmo_extrapolation_order)
160 almo_scf_env%xalmo_extrapolation_order = max(0, almo_scf_env%xalmo_extrapolation_order)
162 l_val=almo_scf_env%return_orthogonalized_mos)
164 l_val=almo_scf_env%construct_nlmos)
167 r_val=almo_scf_env%eps_lanczos)
169 i_val=almo_scf_env%order_lanczos)
171 i_val=almo_scf_env%max_iter_lanczos)
173 r_val=almo_scf_env%matrix_iter_eps_error_factor)
177 r_val=almo_scf_env%opt_block_diag_diis%eps_error)
179 i_val=almo_scf_env%opt_block_diag_diis%max_iter)
181 r_val=almo_scf_env%opt_block_diag_diis%eps_error_early)
183 i_val=almo_scf_env%opt_block_diag_diis%max_iter_early)
185 i_val=almo_scf_env%opt_block_diag_diis%ndiis)
188 r_val=almo_scf_env%opt_block_diag_pcg%eps_error)
190 i_val=almo_scf_env%opt_block_diag_pcg%max_iter)
192 r_val=almo_scf_env%opt_block_diag_pcg%eps_error_early)
194 i_val=almo_scf_env%opt_block_diag_pcg%max_iter_early)
196 i_val=almo_scf_env%opt_block_diag_pcg%max_iter_outer_loop)
198 r_val=almo_scf_env%opt_block_diag_pcg%lin_search_eps_error)
200 r_val=almo_scf_env%opt_block_diag_pcg%lin_search_step_size_guess)
202 r_val=almo_scf_env%opt_block_diag_pcg%neglect_threshold)
204 i_val=almo_scf_env%opt_block_diag_pcg%conjugator)
206 i_val=almo_scf_env%opt_block_diag_pcg%preconditioner)
209 r_val=almo_scf_env%opt_block_diag_trustr%eps_error)
211 i_val=almo_scf_env%opt_block_diag_trustr%max_iter)
213 i_val=almo_scf_env%opt_block_diag_trustr%trustr_algorithm)
215 r_val=almo_scf_env%opt_block_diag_trustr%eps_error_early)
217 i_val=almo_scf_env%opt_block_diag_trustr%max_iter_early)
219 i_val=almo_scf_env%opt_block_diag_trustr%max_iter_outer_loop)
221 r_val=almo_scf_env%opt_block_diag_trustr%rho_do_not_update)
222 almo_scf_env%opt_block_diag_trustr%rho_do_not_update = &
223 min(max(almo_scf_env%opt_block_diag_trustr%rho_do_not_update, 0.0_dp), 0.25_dp)
225 r_val=almo_scf_env%opt_block_diag_trustr%model_grad_norm_ratio)
227 r_val=almo_scf_env%opt_block_diag_trustr%initial_trust_radius)
229 r_val=almo_scf_env%opt_block_diag_trustr%max_trust_radius)
231 i_val=almo_scf_env%opt_block_diag_trustr%conjugator)
233 i_val=almo_scf_env%opt_block_diag_trustr%preconditioner)
236 r_val=almo_scf_env%opt_xalmo_trustr%eps_error)
238 i_val=almo_scf_env%opt_xalmo_trustr%max_iter)
240 i_val=almo_scf_env%opt_xalmo_trustr%trustr_algorithm)
242 r_val=almo_scf_env%opt_xalmo_trustr%eps_error_early)
244 i_val=almo_scf_env%opt_xalmo_trustr%max_iter_early)
246 i_val=almo_scf_env%opt_xalmo_trustr%max_iter_outer_loop)
248 r_val=almo_scf_env%opt_xalmo_trustr%rho_do_not_update)
249 almo_scf_env%opt_xalmo_trustr%rho_do_not_update = &
250 min(max(almo_scf_env%opt_xalmo_trustr%rho_do_not_update, 0.0_dp), 0.25_dp)
252 r_val=almo_scf_env%opt_xalmo_trustr%model_grad_norm_ratio)
254 r_val=almo_scf_env%opt_xalmo_trustr%initial_trust_radius)
256 r_val=almo_scf_env%opt_xalmo_trustr%max_trust_radius)
258 i_val=almo_scf_env%opt_xalmo_trustr%conjugator)
260 i_val=almo_scf_env%opt_xalmo_trustr%preconditioner)
263 r_val=almo_scf_env%opt_xalmo_pcg%eps_error)
265 i_val=almo_scf_env%opt_xalmo_pcg%max_iter)
267 r_val=almo_scf_env%opt_xalmo_pcg%eps_error_early)
269 i_val=almo_scf_env%opt_xalmo_pcg%max_iter_early)
271 i_val=almo_scf_env%opt_xalmo_pcg%max_iter_outer_loop)
273 r_val=almo_scf_env%opt_xalmo_pcg%lin_search_eps_error)
275 r_val=almo_scf_env%opt_xalmo_pcg%lin_search_step_size_guess)
277 r_val=almo_scf_env%opt_xalmo_pcg%neglect_threshold)
279 i_val=almo_scf_env%opt_xalmo_pcg%conjugator)
281 i_val=almo_scf_env%opt_xalmo_pcg%preconditioner)
285 r_val=almo_scf_env%opt_nlmo_pcg%eps_error)
287 i_val=almo_scf_env%opt_nlmo_pcg%max_iter)
289 r_val=almo_scf_env%opt_nlmo_pcg%eps_error_early)
291 i_val=almo_scf_env%opt_nlmo_pcg%max_iter_early)
293 i_val=almo_scf_env%opt_nlmo_pcg%max_iter_outer_loop)
295 r_val=almo_scf_env%opt_nlmo_pcg%lin_search_eps_error)
297 r_val=almo_scf_env%opt_nlmo_pcg%lin_search_step_size_guess)
299 r_val=almo_scf_env%opt_nlmo_pcg%neglect_threshold)
301 i_val=almo_scf_env%opt_nlmo_pcg%conjugator)
303 i_val=almo_scf_env%opt_nlmo_pcg%preconditioner)
306 i_val=almo_scf_env%opt_nlmo_pcg%opt_penalty%operator_type)
308 "PENALTY_STRENGTH", &
309 r_val=almo_scf_env%opt_nlmo_pcg%opt_penalty%penalty_strength)
311 "PENALTY_STRENGTH_DECREASE_FACTOR", &
312 r_val=almo_scf_env%opt_nlmo_pcg%opt_penalty%penalty_strength_dec_factor)
314 "DETERMINANT_TOLERANCE", &
315 r_val=almo_scf_env%opt_nlmo_pcg%opt_penalty%determinant_tolerance)
317 "FINAL_DETERMINANT", &
318 r_val=almo_scf_env%opt_nlmo_pcg%opt_penalty%final_determinant)
320 "COMPACTIFICATION_FILTER_START", &
321 r_val=almo_scf_env%opt_nlmo_pcg%opt_penalty%compactification_filter_start)
324 l_val=almo_scf_env%opt_nlmo_pcg%opt_penalty%virtual_nlmos)
327 r_val=almo_scf_env%opt_xalmo_newton_pcg_solver%eps_error)
329 i_val=almo_scf_env%opt_xalmo_newton_pcg_solver%max_iter)
331 i_val=almo_scf_env%opt_xalmo_newton_pcg_solver%max_iter_outer_loop)
333 i_val=almo_scf_env%opt_xalmo_newton_pcg_solver%preconditioner)
336 l_val=almo_scf_env%almo_analysis%do_analysis)
338 i_val=almo_scf_env%almo_analysis%frozen_mo_energy_term)
343 explicit=explicit, n_repetition=ndomain)
346 ALLOCATE (almo_scf_env%charge_of_domain(ndomain))
347 ALLOCATE (almo_scf_env%multiplicity_of_domain(ndomain))
348 ALLOCATE (almo_scf_env%activate(1))
349 almo_scf_env%multiplicity_of_domain = 0
350 almo_scf_env%charge_of_domain = 0
351 almo_scf_env%activate = 1
355 i_rep_section=i, i_val=almo_scf_env%fragment%charge)
356 almo_scf_env%charge_of_domain(i) = almo_scf_env%fragment%charge
359 i_rep_section=i, i_val=almo_scf_env%fragment%multiplicity)
360 almo_scf_env%multiplicity_of_domain(i) = almo_scf_env%fragment%multiplicity
363 ALLOCATE (almo_scf_env%activate(1))
364 almo_scf_env%activate = 0
373 almo_scf_env%mu = -0.1_dp
374 almo_scf_env%fixed_mu = .false.
375 almo_scf_env%mixing_fraction = 0.45_dp
376 almo_scf_env%eps_prev_guess = almo_scf_env%eps_filter/1000.0_dp
380 almo_scf_env%deloc_cayley_max_iter = 100
381 almo_scf_env%deloc_use_occ_orbs = .true.
382 almo_scf_env%deloc_cayley_use_virt_orbs = .false.
383 almo_scf_env%deloc_cayley_linear = .false.
384 almo_scf_env%deloc_cayley_eps_convergence = 1.0e-6_dp
385 almo_scf_env%deloc_cayley_occ_precond = .true.
386 almo_scf_env%deloc_cayley_vir_precond = .true.
387 almo_scf_env%deloc_truncate_virt =
virt_full
388 almo_scf_env%deloc_virt_per_domain = -1
390 almo_scf_env%opt_k_eps_convergence = 1.0e-5_dp
391 almo_scf_env%opt_k_max_iter = 100
392 almo_scf_env%opt_k_outer_max_iter = 1
393 almo_scf_env%opt_k_trial_step_size = 0.05_dp
395 almo_scf_env%opt_k_trial_step_size_multiplier = 1.05_dp
396 almo_scf_env%opt_k_conj_iter_start = 0
397 almo_scf_env%opt_k_prec_iter_start = 0
398 almo_scf_env%opt_k_conj_iter_freq = 10000000
399 almo_scf_env%opt_k_prec_iter_freq = 10000000
402 almo_scf_env%quencher_r1_factor = almo_scf_env%quencher_r0_factor
410 almo_scf_env%quencher_s0 = 1.0e-4_dp
411 almo_scf_env%quencher_s1 = 1.0e-6_dp
413 almo_scf_env%envelope_amplitude = 1.0_dp
415 almo_scf_env%logical01 = .false.
416 almo_scf_env%logical02 = .true.
417 almo_scf_env%logical03 = .true.
418 almo_scf_env%logical04 = .true.
419 almo_scf_env%logical05 = .false.
421 almo_scf_env%real01 = almo_scf_env%eps_filter/10.0_dp
422 almo_scf_env%real02 = 0.0_dp
423 almo_scf_env%real03 = 0.0_dp
424 almo_scf_env%real04 = 0.5_dp
426 almo_scf_env%integer01 = 10
427 almo_scf_env%integer02 = 4
428 almo_scf_env%integer03 = 0
429 almo_scf_env%integer04 = 0
430 almo_scf_env%integer05 = 0
435 cpabort(
"Trust region algorithm cannot optimize projected XALMOs")
439 i_val=almo_scf_env%xalmo_update_algorithm)
441 i_val=almo_scf_env%xalmo_trial_wf)
444 cpabort(
"1-step delocalization correction requires a different algorithm")
450 cpabort(
"R0 projector requires optimized ALMOs")
455 cpabort(
"No optimization requested")
458 IF (almo_scf_env%deloc_truncate_virt ==
virt_number .AND. &
459 almo_scf_env%deloc_virt_per_domain <= 0)
THEN
460 cpabort(
"specify a positive number of virtual orbitals")
463 IF (almo_scf_env%deloc_truncate_virt ==
virt_minimal)
THEN
464 cpabort(
"VIRT TRUNCATION TO MINIMAL BASIS IS NIY")
468 cpabort(
"use MOLECULAR domains")
472 cpabort(
"use MOLECULAR domains")
476 cpabort(
"use MOLECULAR distr for MOs")
481 cpabort(
"AO blocks cannot be larger than domains")
486 cpabort(
"MO blocks cannot be larger than domains")
490 CALL cp_abort(__location__, &
491 "XALMO_R_CUTOFF_FACTOR is larger than almo_max_cutoff_multiplier. "// &
492 "Increase the hard-coded almo_max_cutoff_multiplier")
496 IF (almo_scf_env%almo_analysis%do_analysis)
THEN
500 cpabort(
"To compute frozen-MO energy term set ALMO_SCF_GUESS MOLECULAR")
505 CALL timestop(handle)
507 END SUBROUTINE almo_scf_init_read_write_input
subroutine, public almo_scf_env_create(qs_env)
Creation and basic initialization of the almo environment.
Types for all ALMO-based methods.
real(kind=dp), parameter, public almo_max_cutoff_multiplier
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
Defines the basic variable types.
integer, parameter, public dp
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.