1!--------------------------------------------------------------------------------------------------! 2! CP2K: A general program to perform molecular dynamics simulations ! 3! Copyright (C) 2000 - 2020 CP2K developers group ! 4!--------------------------------------------------------------------------------------------------! 5 6! ************************************************************************************************** 7!> \brief almo_scf_env methods 8!> \par History 9!> 2016.12 created [Rustam Z Khaliullin] 10!> \author Rustam Z Khaliullin 11! ************************************************************************************************** 12MODULE almo_scf_env_methods 13 14 USE almo_scf_types, ONLY: almo_max_cutoff_multiplier,& 15 almo_scf_env_type 16 USE cp_control_types, ONLY: dft_control_type 17 USE input_constants, ONLY: & 18 almo_constraint_distance, almo_deloc_none, almo_deloc_xalmo_1diag, & 19 almo_domain_layout_atomic, almo_domain_layout_molecular, almo_frz_crystal, & 20 almo_mat_distr_molecular, almo_scf_diag, almo_scf_skip, almo_scf_trustr, cg_hager_zhang, & 21 do_bondparm_vdw, molecular_guess, tensor_orthogonal, virt_full, virt_minimal, virt_number, & 22 xalmo_trial_r0_out 23 USE input_section_types, ONLY: section_vals_get_subs_vals,& 24 section_vals_type,& 25 section_vals_val_get 26 USE kinds, ONLY: dp 27 USE qs_environment_types, ONLY: get_qs_env,& 28 qs_environment_type,& 29 set_qs_env 30#include "./base/base_uses.f90" 31 32 IMPLICIT NONE 33 34 PRIVATE 35 36 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'almo_scf_env_methods' 37 38 PUBLIC :: almo_scf_env_create 39 40CONTAINS 41 42! ************************************************************************************************** 43!> \brief Creation and basic initialization of the almo environment 44!> \param qs_env ... 45!> \par History 46!> 2016.11 created [Rustam Z Khaliullin] 47!> \author Rustam Z Khaliullin 48! ************************************************************************************************** 49 SUBROUTINE almo_scf_env_create(qs_env) 50 TYPE(qs_environment_type), POINTER :: qs_env 51 52 CHARACTER(len=*), PARAMETER :: routineN = 'almo_scf_env_create', & 53 routineP = moduleN//':'//routineN 54 55 INTEGER :: handle, nallocate 56 TYPE(almo_scf_env_type), POINTER :: almo_scf_env 57 TYPE(dft_control_type), POINTER :: dft_control 58 TYPE(section_vals_type), POINTER :: input 59 60 CALL timeset(routineN, handle) 61 62 ALLOCATE (almo_scf_env) 63 64 ! get basic quantities from the qs_env 65 CALL get_qs_env(qs_env, input=input, dft_control=dft_control) 66 67 ! parse the almo_scf section and set appropriate quantities 68 CALL almo_scf_init_read_write_input(input, almo_scf_env) 69 70 ! set up the buffer for the history of matrices 71 almo_scf_env%nspins = dft_control%nspins 72 almo_scf_env%almo_history%nstore = almo_scf_env%almo_extrapolation_order 73 almo_scf_env%almo_history%istore = 0 74 ! do not allocate zero 75 nallocate = MAX(1, almo_scf_env%almo_extrapolation_order) 76 ALLOCATE (almo_scf_env%almo_history%matrix_p_up_down(almo_scf_env%nspins, nallocate)) 77 ALLOCATE (almo_scf_env%almo_history%matrix_t(almo_scf_env%nspins)) 78 almo_scf_env%xalmo_history%nstore = almo_scf_env%xalmo_extrapolation_order 79 almo_scf_env%xalmo_history%istore = 0 80 nallocate = MAX(1, almo_scf_env%xalmo_extrapolation_order) 81 ALLOCATE (almo_scf_env%xalmo_history%matrix_p_up_down(almo_scf_env%nspins, nallocate)) 82 !ALLOCATE (almo_scf_env%xalmo_history%matrix_x(almo_scf_env%nspins, nallocate)) 83 ALLOCATE (almo_scf_env%xalmo_history%matrix_t(almo_scf_env%nspins)) 84 85 ! put almo_scf_env in qs_env 86 CALL set_qs_env(qs_env, almo_scf_env=almo_scf_env) 87 88 CALL timestop(handle) 89 90 END SUBROUTINE almo_scf_env_create 91 92! ************************************************************************************************** 93!> \brief Parses the ALMO input section 94!> \param input ... 95!> \param almo_scf_env ... 96!> \par History 97!> 2011.05 created [Rustam Z Khaliullin] 98!> \author Rustam Z Khaliullin 99! ************************************************************************************************** 100 SUBROUTINE almo_scf_init_read_write_input(input, almo_scf_env) 101 TYPE(section_vals_type), POINTER :: input 102 TYPE(almo_scf_env_type), INTENT(INOUT) :: almo_scf_env 103 104 CHARACTER(len=*), PARAMETER :: routineN = 'almo_scf_init_read_write_input', & 105 routineP = moduleN//':'//routineN 106 107 INTEGER :: handle 108 TYPE(section_vals_type), POINTER :: almo_analysis_section, almo_opt_diis_section, & 109 almo_opt_pcg_section, almo_scf_section, matrix_iterate_section, nlmo_opt_pcg_section, & 110 penalty_section, xalmo_opt_newton_pcg_section, xalmo_opt_pcg_section, & 111 xalmo_opt_trustr_section 112 113 CALL timeset(routineN, handle) 114 115 almo_scf_section => section_vals_get_subs_vals(input, "DFT%ALMO_SCF") 116 almo_opt_diis_section => section_vals_get_subs_vals(almo_scf_section, & 117 "ALMO_OPTIMIZER_DIIS") 118 almo_opt_pcg_section => section_vals_get_subs_vals(almo_scf_section, & 119 "ALMO_OPTIMIZER_PCG") 120 xalmo_opt_pcg_section => section_vals_get_subs_vals(almo_scf_section, & 121 "XALMO_OPTIMIZER_PCG") 122 xalmo_opt_trustr_section => section_vals_get_subs_vals(almo_scf_section, & 123 "XALMO_OPTIMIZER_TRUSTR") 124 nlmo_opt_pcg_section => section_vals_get_subs_vals(almo_scf_section, & 125 "NLMO_OPTIMIZER_PCG") 126 almo_analysis_section => section_vals_get_subs_vals(almo_scf_section, "ANALYSIS") 127 xalmo_opt_newton_pcg_section => section_vals_get_subs_vals(xalmo_opt_pcg_section, & 128 "XALMO_NEWTON_PCG_SOLVER") 129 matrix_iterate_section => section_vals_get_subs_vals(almo_scf_section, & 130 "MATRIX_ITERATE") 131 132 ! read user input 133 ! common ALMO options 134 CALL section_vals_val_get(almo_scf_section, "EPS_FILTER", & 135 r_val=almo_scf_env%eps_filter) 136 CALL section_vals_val_get(almo_scf_section, "ALMO_SCF_GUESS", & 137 i_val=almo_scf_env%almo_scf_guess) 138 CALL section_vals_val_get(almo_scf_section, "ALMO_ALGORITHM", & 139 i_val=almo_scf_env%almo_update_algorithm) 140 CALL section_vals_val_get(almo_scf_section, "XALMO_ALGORITHM", & 141 i_val=almo_scf_env%xalmo_update_algorithm) 142 CALL section_vals_val_get(almo_scf_section, "XALMO_TRIAL_WF", & 143 i_val=almo_scf_env%xalmo_trial_wf) 144 CALL section_vals_val_get(almo_scf_section, "MO_OVERLAP_INV_ALG", & 145 i_val=almo_scf_env%sigma_inv_algorithm) 146 CALL section_vals_val_get(almo_scf_section, "DELOCALIZE_METHOD", & 147 i_val=almo_scf_env%deloc_method) 148 CALL section_vals_val_get(almo_scf_section, "XALMO_R_CUTOFF_FACTOR", & 149 r_val=almo_scf_env%quencher_r0_factor) 150 CALL section_vals_val_get(almo_scf_section, "ALMO_EXTRAPOLATION_ORDER", & 151 i_val=almo_scf_env%almo_extrapolation_order) 152 almo_scf_env%almo_extrapolation_order = MAX(0, almo_scf_env%almo_extrapolation_order) 153 CALL section_vals_val_get(almo_scf_section, "XALMO_EXTRAPOLATION_ORDER", & 154 i_val=almo_scf_env%xalmo_extrapolation_order) 155 almo_scf_env%xalmo_extrapolation_order = MAX(0, almo_scf_env%xalmo_extrapolation_order) 156 CALL section_vals_val_get(almo_scf_section, "RETURN_ORTHOGONALIZED_MOS", & 157 l_val=almo_scf_env%return_orthogonalized_mos) 158 CALL section_vals_val_get(almo_scf_section, "CONSTRUCT_NLMOS", & 159 l_val=almo_scf_env%construct_nlmos) 160 161 CALL section_vals_val_get(matrix_iterate_section, "EPS_LANCZOS", & 162 r_val=almo_scf_env%eps_lanczos) 163 CALL section_vals_val_get(matrix_iterate_section, "ORDER_LANCZOS", & 164 i_val=almo_scf_env%order_lanczos) 165 CALL section_vals_val_get(matrix_iterate_section, "MAX_ITER_LANCZOS", & 166 i_val=almo_scf_env%max_iter_lanczos) 167 CALL section_vals_val_get(matrix_iterate_section, "EPS_TARGET_FACTOR", & 168 r_val=almo_scf_env%matrix_iter_eps_error_factor) 169 170 ! optimizers 171 CALL section_vals_val_get(almo_opt_diis_section, "EPS_ERROR", & 172 r_val=almo_scf_env%opt_block_diag_diis%eps_error) 173 CALL section_vals_val_get(almo_opt_diis_section, "MAX_ITER", & 174 i_val=almo_scf_env%opt_block_diag_diis%max_iter) 175 CALL section_vals_val_get(almo_opt_diis_section, "EPS_ERROR_EARLY", & 176 r_val=almo_scf_env%opt_block_diag_diis%eps_error_early) 177 CALL section_vals_val_get(almo_opt_diis_section, "MAX_ITER_EARLY", & 178 i_val=almo_scf_env%opt_block_diag_diis%max_iter_early) 179 CALL section_vals_val_get(almo_opt_diis_section, "N_DIIS", & 180 i_val=almo_scf_env%opt_block_diag_diis%ndiis) 181 182 CALL section_vals_val_get(almo_opt_pcg_section, "EPS_ERROR", & 183 r_val=almo_scf_env%opt_block_diag_pcg%eps_error) 184 CALL section_vals_val_get(almo_opt_pcg_section, "MAX_ITER", & 185 i_val=almo_scf_env%opt_block_diag_pcg%max_iter) 186 CALL section_vals_val_get(almo_opt_pcg_section, "EPS_ERROR_EARLY", & 187 r_val=almo_scf_env%opt_block_diag_pcg%eps_error_early) 188 CALL section_vals_val_get(almo_opt_pcg_section, "MAX_ITER_EARLY", & 189 i_val=almo_scf_env%opt_block_diag_pcg%max_iter_early) 190 CALL section_vals_val_get(almo_opt_pcg_section, "MAX_ITER_OUTER_LOOP", & 191 i_val=almo_scf_env%opt_block_diag_pcg%max_iter_outer_loop) 192 CALL section_vals_val_get(almo_opt_pcg_section, "LIN_SEARCH_EPS_ERROR", & 193 r_val=almo_scf_env%opt_block_diag_pcg%lin_search_eps_error) 194 CALL section_vals_val_get(almo_opt_pcg_section, "LIN_SEARCH_STEP_SIZE_GUESS", & 195 r_val=almo_scf_env%opt_block_diag_pcg%lin_search_step_size_guess) 196 CALL section_vals_val_get(almo_opt_pcg_section, "CONJUGATOR", & 197 i_val=almo_scf_env%opt_block_diag_pcg%conjugator) 198 CALL section_vals_val_get(almo_opt_pcg_section, "PRECONDITIONER", & 199 i_val=almo_scf_env%opt_block_diag_pcg%preconditioner) 200 201 CALL section_vals_val_get(xalmo_opt_trustr_section, "EPS_ERROR", & 202 r_val=almo_scf_env%opt_xalmo_trustr%eps_error) 203 CALL section_vals_val_get(xalmo_opt_trustr_section, "MAX_ITER", & 204 i_val=almo_scf_env%opt_xalmo_trustr%max_iter) 205 CALL section_vals_val_get(xalmo_opt_trustr_section, "ALGORITHM", & 206 i_val=almo_scf_env%opt_xalmo_trustr%trustr_algorithm) 207 CALL section_vals_val_get(xalmo_opt_trustr_section, "EPS_ERROR_EARLY", & 208 r_val=almo_scf_env%opt_xalmo_trustr%eps_error_early) 209 CALL section_vals_val_get(xalmo_opt_trustr_section, "MAX_ITER_EARLY", & 210 i_val=almo_scf_env%opt_xalmo_trustr%max_iter_early) 211 CALL section_vals_val_get(xalmo_opt_trustr_section, "MAX_ITER_OUTER_LOOP", & 212 i_val=almo_scf_env%opt_xalmo_trustr%max_iter_outer_loop) 213 CALL section_vals_val_get(xalmo_opt_trustr_section, "ETA", & 214 r_val=almo_scf_env%opt_xalmo_trustr%rho_do_not_update) 215 almo_scf_env%opt_xalmo_trustr%rho_do_not_update = & 216 MIN(MAX(almo_scf_env%opt_xalmo_trustr%rho_do_not_update, 0.0_dp), 0.25_dp) 217 CALL section_vals_val_get(xalmo_opt_trustr_section, "MODEL_GRAD_NORM_RATIO", & 218 r_val=almo_scf_env%opt_xalmo_trustr%model_grad_norm_ratio) 219 CALL section_vals_val_get(xalmo_opt_trustr_section, "INITIAL_TRUST_RADIUS", & 220 r_val=almo_scf_env%opt_xalmo_trustr%initial_trust_radius) 221 CALL section_vals_val_get(xalmo_opt_trustr_section, "MAX_TRUST_RADIUS", & 222 r_val=almo_scf_env%opt_xalmo_trustr%max_trust_radius) 223 CALL section_vals_val_get(xalmo_opt_trustr_section, "CONJUGATOR", & 224 i_val=almo_scf_env%opt_xalmo_trustr%conjugator) 225 CALL section_vals_val_get(xalmo_opt_trustr_section, "PRECONDITIONER", & 226 i_val=almo_scf_env%opt_xalmo_trustr%preconditioner) 227 228 CALL section_vals_val_get(xalmo_opt_pcg_section, "EPS_ERROR", & 229 r_val=almo_scf_env%opt_xalmo_pcg%eps_error) 230 CALL section_vals_val_get(xalmo_opt_pcg_section, "MAX_ITER", & 231 i_val=almo_scf_env%opt_xalmo_pcg%max_iter) 232 CALL section_vals_val_get(xalmo_opt_pcg_section, "EPS_ERROR_EARLY", & 233 r_val=almo_scf_env%opt_xalmo_pcg%eps_error_early) 234 CALL section_vals_val_get(xalmo_opt_pcg_section, "MAX_ITER_EARLY", & 235 i_val=almo_scf_env%opt_xalmo_pcg%max_iter_early) 236 CALL section_vals_val_get(xalmo_opt_pcg_section, "MAX_ITER_OUTER_LOOP", & 237 i_val=almo_scf_env%opt_xalmo_pcg%max_iter_outer_loop) 238 CALL section_vals_val_get(xalmo_opt_pcg_section, "LIN_SEARCH_EPS_ERROR", & 239 r_val=almo_scf_env%opt_xalmo_pcg%lin_search_eps_error) 240 CALL section_vals_val_get(xalmo_opt_pcg_section, "LIN_SEARCH_STEP_SIZE_GUESS", & 241 r_val=almo_scf_env%opt_xalmo_pcg%lin_search_step_size_guess) 242 CALL section_vals_val_get(xalmo_opt_pcg_section, "PRECOND_FILTER_THRESHOLD", & 243 r_val=almo_scf_env%opt_xalmo_pcg%neglect_threshold) 244 CALL section_vals_val_get(xalmo_opt_pcg_section, "CONJUGATOR", & 245 i_val=almo_scf_env%opt_xalmo_pcg%conjugator) 246 CALL section_vals_val_get(xalmo_opt_pcg_section, "PRECONDITIONER", & 247 i_val=almo_scf_env%opt_xalmo_pcg%preconditioner) 248 249 penalty_section => section_vals_get_subs_vals(nlmo_opt_pcg_section, "PENALTY") 250 CALL section_vals_val_get(nlmo_opt_pcg_section, "EPS_ERROR", & 251 r_val=almo_scf_env%opt_nlmo_pcg%eps_error) 252 CALL section_vals_val_get(nlmo_opt_pcg_section, "MAX_ITER", & 253 i_val=almo_scf_env%opt_nlmo_pcg%max_iter) 254 CALL section_vals_val_get(nlmo_opt_pcg_section, "EPS_ERROR_EARLY", & 255 r_val=almo_scf_env%opt_nlmo_pcg%eps_error_early) 256 CALL section_vals_val_get(nlmo_opt_pcg_section, "MAX_ITER_EARLY", & 257 i_val=almo_scf_env%opt_nlmo_pcg%max_iter_early) 258 CALL section_vals_val_get(nlmo_opt_pcg_section, "MAX_ITER_OUTER_LOOP", & 259 i_val=almo_scf_env%opt_nlmo_pcg%max_iter_outer_loop) 260 CALL section_vals_val_get(nlmo_opt_pcg_section, "LIN_SEARCH_EPS_ERROR", & 261 r_val=almo_scf_env%opt_nlmo_pcg%lin_search_eps_error) 262 CALL section_vals_val_get(nlmo_opt_pcg_section, "LIN_SEARCH_STEP_SIZE_GUESS", & 263 r_val=almo_scf_env%opt_nlmo_pcg%lin_search_step_size_guess) 264 CALL section_vals_val_get(nlmo_opt_pcg_section, "PRECOND_FILTER_THRESHOLD", & 265 r_val=almo_scf_env%opt_nlmo_pcg%neglect_threshold) 266 CALL section_vals_val_get(nlmo_opt_pcg_section, "CONJUGATOR", & 267 i_val=almo_scf_env%opt_nlmo_pcg%conjugator) 268 CALL section_vals_val_get(nlmo_opt_pcg_section, "PRECONDITIONER", & 269 i_val=almo_scf_env%opt_nlmo_pcg%preconditioner) 270 CALL section_vals_val_get(penalty_section, & 271 "OPERATOR", & 272 i_val=almo_scf_env%opt_nlmo_pcg%opt_penalty%operator_type) 273 CALL section_vals_val_get(penalty_section, & 274 "PENALTY_STRENGTH", & 275 r_val=almo_scf_env%opt_nlmo_pcg%opt_penalty%penalty_strength) 276 CALL section_vals_val_get(penalty_section, & 277 "PENALTY_STRENGTH_DECREASE_FACTOR", & 278 r_val=almo_scf_env%opt_nlmo_pcg%opt_penalty%penalty_strength_dec_factor) 279 CALL section_vals_val_get(penalty_section, & 280 "DETERMINANT_TOLERANCE", & 281 r_val=almo_scf_env%opt_nlmo_pcg%opt_penalty%determinant_tolerance) 282 CALL section_vals_val_get(penalty_section, & 283 "FINAL_DETERMINANT", & 284 r_val=almo_scf_env%opt_nlmo_pcg%opt_penalty%final_determinant) 285 CALL section_vals_val_get(penalty_section, & 286 "COMPACTIFICATION_FILTER_START", & 287 r_val=almo_scf_env%opt_nlmo_pcg%opt_penalty%compactification_filter_start) 288 CALL section_vals_val_get(penalty_section, & 289 "VIRTUAL_NLMOS", & 290 l_val=almo_scf_env%opt_nlmo_pcg%opt_penalty%virtual_nlmos) 291 292 CALL section_vals_val_get(xalmo_opt_newton_pcg_section, "EPS_ERROR", & 293 r_val=almo_scf_env%opt_xalmo_newton_pcg_solver%eps_error) 294 CALL section_vals_val_get(xalmo_opt_newton_pcg_section, "MAX_ITER", & 295 i_val=almo_scf_env%opt_xalmo_newton_pcg_solver%max_iter) 296 CALL section_vals_val_get(xalmo_opt_newton_pcg_section, "MAX_ITER_OUTER_LOOP", & 297 i_val=almo_scf_env%opt_xalmo_newton_pcg_solver%max_iter_outer_loop) 298 CALL section_vals_val_get(xalmo_opt_newton_pcg_section, "PRECONDITIONER", & 299 i_val=almo_scf_env%opt_xalmo_newton_pcg_solver%preconditioner) 300 301 CALL section_vals_val_get(almo_analysis_section, "_SECTION_PARAMETERS_", & 302 l_val=almo_scf_env%almo_analysis%do_analysis) 303 CALL section_vals_val_get(almo_analysis_section, "FROZEN_MO_ENERGY_TERM", & 304 i_val=almo_scf_env%almo_analysis%frozen_mo_energy_term) 305 306 !CALL section_vals_val_get(almo_scf_section,"DOMAIN_LAYOUT_AOS",& 307 ! i_val=almo_scf_env%domain_layout_aos) 308 !CALL section_vals_val_get(almo_scf_section,"DOMAIN_LAYOUT_MOS",& 309 ! i_val=almo_scf_env%domain_layout_mos) 310 !CALL section_vals_val_get(almo_scf_section,"MATRIX_CLUSTERING_AOS",& 311 ! i_val=almo_scf_env%mat_distr_aos) 312 !CALL section_vals_val_get(almo_scf_section,"MATRIX_CLUSTERING_MOS",& 313 ! i_val=almo_scf_env%mat_distr_mos) 314 !CALL section_vals_val_get(almo_scf_section,"CONSTRAINT_TYPE",& 315 ! i_val=almo_scf_env%constraint_type) 316 !CALL section_vals_val_get(almo_scf_section,"MU",& 317 ! r_val=almo_scf_env%mu) 318 !CALL section_vals_val_get(almo_scf_section,"FIXED_MU",& 319 ! l_val=almo_scf_env%fixed_mu) 320 !CALL section_vals_val_get(almo_scf_section,"EPS_USE_PREV_AS_GUESS",& 321 ! r_val=almo_scf_env%eps_prev_guess) 322 !CALL section_vals_val_get(almo_scf_section,"MIXING_FRACTION",& 323 ! r_val=almo_scf_env%mixing_fraction) 324 !CALL section_vals_val_get(almo_scf_section,"DELOC_CAYLEY_TENSOR_TYPE",& 325 ! i_val=almo_scf_env%deloc_cayley_tensor_type) 326 !CALL section_vals_val_get(almo_scf_section,"DELOC_CAYLEY_CONJUGATOR",& 327 ! i_val=almo_scf_env%deloc_cayley_conjugator) 328 !CALL section_vals_val_get(almo_scf_section,"DELOC_CAYLEY_MAX_ITER",& 329 ! i_val=almo_scf_env%deloc_cayley_max_iter) 330 !CALL section_vals_val_get(almo_scf_section,"DELOC_USE_OCC_ORBS",& 331 ! l_val=almo_scf_env%deloc_use_occ_orbs) 332 !CALL section_vals_val_get(almo_scf_section,"DELOC_CAYLEY_USE_VIRT_ORBS",& 333 ! l_val=almo_scf_env%deloc_cayley_use_virt_orbs) 334 !CALL section_vals_val_get(almo_scf_section,"DELOC_CAYLEY_LINEAR",& 335 ! l_val=almo_scf_env%deloc_cayley_linear) 336 !CALL section_vals_val_get(almo_scf_section,"DELOC_CAYLEY_EPS_CONVERGENCE",& 337 ! r_val=almo_scf_env%deloc_cayley_eps_convergence) 338 !CALL section_vals_val_get(almo_scf_section,"DELOC_CAYLEY_OCC_PRECOND",& 339 ! l_val=almo_scf_env%deloc_cayley_occ_precond) 340 !CALL section_vals_val_get(almo_scf_section,"DELOC_CAYLEY_VIR_PRECOND",& 341 ! l_val=almo_scf_env%deloc_cayley_vir_precond) 342 !CALL section_vals_val_get(almo_scf_section,"ALMO_UPDATE_ALGORITHM_BD",& 343 ! i_val=almo_scf_env%almo_update_algorithm) 344 !CALL section_vals_val_get(almo_scf_section,"DELOC_TRUNCATE_VIRTUALS",& 345 ! i_val=almo_scf_env%deloc_truncate_virt) 346 !CALL section_vals_val_get(almo_scf_section,"DELOC_VIRT_PER_DOMAIN",& 347 ! i_val=almo_scf_env%deloc_virt_per_domain) 348 ! 349 !CALL section_vals_val_get(almo_scf_section,"OPT_K_EPS_CONVERGENCE",& 350 ! r_val=almo_scf_env%opt_k_eps_convergence) 351 !CALL section_vals_val_get(almo_scf_section,"OPT_K_MAX_ITER",& 352 ! i_val=almo_scf_env%opt_k_max_iter) 353 !CALL section_vals_val_get(almo_scf_section,"OPT_K_OUTER_MAX_ITER",& 354 ! i_val=almo_scf_env%opt_k_outer_max_iter) 355 !CALL section_vals_val_get(almo_scf_section,"OPT_K_TRIAL_STEP_SIZE",& 356 ! r_val=almo_scf_env%opt_k_trial_step_size) 357 !CALL section_vals_val_get(almo_scf_section,"OPT_K_CONJUGATOR",& 358 ! i_val=almo_scf_env%opt_k_conjugator) 359 !CALL section_vals_val_get(almo_scf_section,"OPT_K_TRIAL_STEP_SIZE_MULTIPLIER",& 360 ! r_val=almo_scf_env%opt_k_trial_step_size_multiplier) 361 !CALL section_vals_val_get(almo_scf_section,"OPT_K_CONJ_ITER_START",& 362 ! i_val=almo_scf_env%opt_k_conj_iter_start) 363 !CALL section_vals_val_get(almo_scf_section,"OPT_K_PREC_ITER_START",& 364 ! i_val=almo_scf_env%opt_k_prec_iter_start) 365 !CALL section_vals_val_get(almo_scf_section,"OPT_K_CONJ_ITER_FREQ_RESET",& 366 ! i_val=almo_scf_env%opt_k_conj_iter_freq) 367 !CALL section_vals_val_get(almo_scf_section,"OPT_K_PREC_ITER_FREQ_UPDATE",& 368 ! i_val=almo_scf_env%opt_k_prec_iter_freq) 369 ! 370 !CALL section_vals_val_get(almo_scf_section,"QUENCHER_RADIUS_TYPE",& 371 ! i_val=almo_scf_env%quencher_radius_type) 372 !CALL section_vals_val_get(almo_scf_section,"QUENCHER_R0_FACTOR",& 373 ! r_val=almo_scf_env%quencher_r0_factor) 374 !CALL section_vals_val_get(almo_scf_section,"QUENCHER_R1_FACTOR",& 375 ! r_val=almo_scf_env%quencher_r1_factor) 376 !!CALL section_vals_val_get(almo_scf_section,"QUENCHER_R0_SHIFT",& 377 !! r_val=almo_scf_env%quencher_r0_shift) 378 !! 379 !!CALL section_vals_val_get(almo_scf_section,"QUENCHER_R1_SHIFT",& 380 !! r_val=almo_scf_env%quencher_r1_shift) 381 !! 382 !!almo_scf_env%quencher_r0_shift = cp_unit_to_cp2k(& 383 !! almo_scf_env%quencher_r0_shift,"angstrom") 384 !!almo_scf_env%quencher_r1_shift = cp_unit_to_cp2k(& 385 !! almo_scf_env%quencher_r1_shift,"angstrom") 386 ! 387 !CALL section_vals_val_get(almo_scf_section,"QUENCHER_AO_OVERLAP_0",& 388 ! r_val=almo_scf_env%quencher_s0) 389 !CALL section_vals_val_get(almo_scf_section,"QUENCHER_AO_OVERLAP_1",& 390 ! r_val=almo_scf_env%quencher_s1) 391 392 !CALL section_vals_val_get(almo_scf_section,"ENVELOPE_AMPLITUDE",& 393 ! r_val=almo_scf_env%envelope_amplitude) 394 395 !! how to read lists 396 !CALL section_vals_val_get(almo_scf_section,"INT_LIST01", & 397 ! n_rep_val=n_rep) 398 !counter_i = 0 399 !DO k = 1,n_rep 400 ! CALL section_vals_val_get(almo_scf_section,"INT_LIST01",& 401 ! i_rep_val=k,i_vals=tmplist) 402 ! DO jj = 1,SIZE(tmplist) 403 ! counter_i=counter_i+1 404 ! almo_scf_env%charge_of_domain(counter_i)=tmplist(jj) 405 ! ENDDO 406 !ENDDO 407 408 almo_scf_env%domain_layout_aos = almo_domain_layout_molecular 409 almo_scf_env%domain_layout_mos = almo_domain_layout_molecular 410 almo_scf_env%mat_distr_aos = almo_mat_distr_molecular 411 almo_scf_env%mat_distr_mos = almo_mat_distr_molecular 412 413 almo_scf_env%constraint_type = almo_constraint_distance 414 almo_scf_env%mu = -0.1_dp 415 almo_scf_env%fixed_mu = .FALSE. 416 almo_scf_env%mixing_fraction = 0.45_dp 417 almo_scf_env%eps_prev_guess = almo_scf_env%eps_filter/1000.0_dp 418 419 almo_scf_env%deloc_cayley_tensor_type = tensor_orthogonal 420 almo_scf_env%deloc_cayley_conjugator = cg_hager_zhang 421 almo_scf_env%deloc_cayley_max_iter = 100 422 almo_scf_env%deloc_use_occ_orbs = .TRUE. 423 almo_scf_env%deloc_cayley_use_virt_orbs = .FALSE. 424 almo_scf_env%deloc_cayley_linear = .FALSE. 425 almo_scf_env%deloc_cayley_eps_convergence = 1.0E-6_dp 426 almo_scf_env%deloc_cayley_occ_precond = .TRUE. 427 almo_scf_env%deloc_cayley_vir_precond = .TRUE. 428 almo_scf_env%deloc_truncate_virt = virt_full 429 almo_scf_env%deloc_virt_per_domain = -1 430 431 almo_scf_env%opt_k_eps_convergence = 1.0E-5_dp 432 almo_scf_env%opt_k_max_iter = 100 433 almo_scf_env%opt_k_outer_max_iter = 1 434 almo_scf_env%opt_k_trial_step_size = 0.05_dp 435 almo_scf_env%opt_k_conjugator = cg_hager_zhang 436 almo_scf_env%opt_k_trial_step_size_multiplier = 1.05_dp 437 almo_scf_env%opt_k_conj_iter_start = 0 438 almo_scf_env%opt_k_prec_iter_start = 0 439 almo_scf_env%opt_k_conj_iter_freq = 10000000 440 almo_scf_env%opt_k_prec_iter_freq = 10000000 441 442 almo_scf_env%quencher_radius_type = do_bondparm_vdw 443 almo_scf_env%quencher_r1_factor = almo_scf_env%quencher_r0_factor 444 !almo_scf_env%quencher_r0_shift=0.0_dp 445 !almo_scf_env%quencher_r1_shift=0.0_dp 446 !almo_scf_env%quencher_r0_shift = cp_unit_to_cp2k(& 447 ! almo_scf_env%quencher_r0_shift,"angstrom") 448 !almo_scf_env%quencher_r1_shift = cp_unit_to_cp2k(& 449 ! almo_scf_env%quencher_r1_shift,"angstrom") 450 451 almo_scf_env%quencher_s0 = 1.0E-4_dp 452 almo_scf_env%quencher_s1 = 1.0E-6_dp 453 454 almo_scf_env%envelope_amplitude = 1.0_dp 455 456 almo_scf_env%logical01 = .FALSE. ! md in eDOF space 457 almo_scf_env%logical02 = .TRUE. ! not used 458 almo_scf_env%logical03 = .TRUE. ! not used 459 almo_scf_env%logical04 = .TRUE. ! use preconditioner 460 almo_scf_env%logical05 = .FALSE. ! optimize theta 461 462 almo_scf_env%real01 = almo_scf_env%eps_filter/10.0_dp ! skip gradients 463 almo_scf_env%real02 = 0.0_dp ! not used 464 almo_scf_env%real03 = 0.0_dp ! not used 465 almo_scf_env%real04 = 0.5_dp ! mixing s-f precond 466 467 almo_scf_env%integer01 = 10 ! start eDOF-md 468 almo_scf_env%integer02 = 4 ! preconditioner type 469 almo_scf_env%integer03 = 0 ! not used 470 almo_scf_env%integer04 = 0 ! fixed number of line searches (no grad) 471 almo_scf_env%integer05 = 0 ! not used 472 473 ! check for conflicts between options 474 IF (almo_scf_env%xalmo_trial_wf .EQ. xalmo_trial_r0_out .AND. & 475 almo_scf_env%xalmo_update_algorithm .EQ. almo_scf_trustr) THEN 476 CPABORT("Trust region algorithm cannot optimize projected XALMOs") 477 ENDIF 478 479 CALL section_vals_val_get(almo_scf_section, "XALMO_ALGORITHM", & 480 i_val=almo_scf_env%xalmo_update_algorithm) 481 CALL section_vals_val_get(almo_scf_section, "XALMO_TRIAL_WF", & 482 i_val=almo_scf_env%xalmo_trial_wf) 483 IF (almo_scf_env%deloc_method .EQ. almo_deloc_xalmo_1diag .AND. & 484 almo_scf_env%xalmo_update_algorithm .NE. almo_scf_diag) THEN 485 CPABORT("1-step delocalization correction requires a different algorithm") 486 ENDIF 487 488 IF (almo_scf_env%xalmo_trial_wf .EQ. xalmo_trial_r0_out .AND. & 489 almo_scf_env%almo_update_algorithm .EQ. almo_scf_skip .AND. & 490 almo_scf_env%almo_scf_guess .NE. molecular_guess) THEN 491 CPABORT("R0 projector requires optimized ALMOs") 492 ENDIF 493 494 IF (almo_scf_env%deloc_method .EQ. almo_deloc_none .AND. & 495 almo_scf_env%almo_update_algorithm .EQ. almo_scf_skip) THEN 496 CPABORT("No optimization requested") 497 ENDIF 498 499 IF (almo_scf_env%deloc_truncate_virt .EQ. virt_number .AND. & 500 almo_scf_env%deloc_virt_per_domain .LE. 0) THEN 501 CPABORT("specify a positive number of virtual orbitals") 502 ENDIF 503 504 IF (almo_scf_env%deloc_truncate_virt .EQ. virt_minimal) THEN 505 CPABORT("VIRT TRUNCATION TO MINIMAL BASIS IS NIY") 506 ENDIF 507 508 IF (almo_scf_env%domain_layout_mos .NE. almo_domain_layout_molecular) THEN 509 CPABORT("use MOLECULAR domains") 510 ENDIF 511 512 IF (almo_scf_env%domain_layout_aos .NE. almo_domain_layout_molecular) THEN 513 CPABORT("use MOLECULAR domains") 514 ENDIF 515 516 IF (almo_scf_env%mat_distr_mos .NE. almo_mat_distr_molecular) THEN 517 CPABORT("use MOLECULAR distr for MOs") 518 ENDIF 519 520 IF (almo_scf_env%mat_distr_aos == almo_mat_distr_molecular .AND. & 521 almo_scf_env%domain_layout_aos == almo_domain_layout_atomic) THEN 522 CPABORT("AO blocks cannot be larger than domains") 523 ENDIF 524 525 IF (almo_scf_env%mat_distr_mos == almo_mat_distr_molecular .AND. & 526 almo_scf_env%domain_layout_mos == almo_domain_layout_atomic) THEN 527 CPABORT("MO blocks cannot be larger than domains") 528 ENDIF 529 530 IF (almo_scf_env%quencher_r1_factor .GT. almo_max_cutoff_multiplier) THEN 531 CALL cp_abort(__LOCATION__, & 532 "XALMO_R_CUTOFF_FACTOR is larger than almo_max_cutoff_multiplier. "// & 533 "Increase the hard-coded almo_max_cutoff_multiplier") 534 ENDIF 535 536 ! check analysis settings 537 IF (almo_scf_env%almo_analysis%do_analysis) THEN 538 539 IF (almo_scf_env%almo_analysis%frozen_mo_energy_term == almo_frz_crystal & 540 .AND. almo_scf_env%almo_scf_guess .NE. molecular_guess) THEN 541 CPABORT("To compute frozen-MO energy term set ALMO_SCF_GUESS MOLECULAR") 542 ENDIF 543 544 ENDIF ! end analysis settings 545 546 CALL timestop(handle) 547 548 END SUBROUTINE almo_scf_init_read_write_input 549 550END MODULE almo_scf_env_methods 551 552