Skip to content

Commit

Permalink
Direct unconstrained variable-metric localization of one-electron orb…
Browse files Browse the repository at this point in the history
…itals (#762)

* NLMO reimplemented, compiles and works for 2 test files
* NLMO refactoring to enable virtual localization in the future
* Diagonal BFGS is implemented and tested on Si. Same convergence as SD
* Adds L-BFGS: code compiles, 1st test fails
* L-BFGS minor bug resolved. Energy goes up in 1st tiny L-BFGS line search
* q: remove minus sign
* Compiled and tested refactoring NLMO objct func with virtual and compact implementation
* Modified NLMOs keyword description
* Tested code and added NLMO input file
* Fix NLMO memory leaks, enter correct reference values for NLMO tests
* Fix print bug in NLMO PCG optimizer
* Fix all valgrind errors related to uninitialized variables
* Fix unused dummy argument in almo_scf_lbfgs_types.F
  • Loading branch information
rzk1 committed Feb 11, 2020
1 parent abecc61 commit 0482296
Show file tree
Hide file tree
Showing 16 changed files with 3,056 additions and 288 deletions.
482 changes: 470 additions & 12 deletions src/almo_scf.F

Large diffs are not rendered by default.

77 changes: 53 additions & 24 deletions src/almo_scf_env_methods.F
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ MODULE almo_scf_env_methods
almo_scf_env_type
USE cp_control_types, ONLY: dft_control_type
USE input_constants, ONLY: &
almo_constraint_distance, almo_deloc_none, almo_deloc_scf, almo_deloc_x, &
almo_deloc_x_then_scf, almo_deloc_xalmo_1diag, almo_domain_layout_atomic, &
almo_domain_layout_molecular, almo_frz_crystal, almo_mat_distr_molecular, &
almo_occ_vol_penalty_none, almo_scf_diag, almo_scf_skip, almo_scf_trustr, cg_hager_zhang, &
almo_constraint_distance, almo_deloc_none, almo_deloc_xalmo_1diag, &
almo_domain_layout_atomic, almo_domain_layout_molecular, almo_frz_crystal, &
almo_mat_distr_molecular, almo_scf_diag, almo_scf_skip, almo_scf_trustr, cg_hager_zhang, &
do_bondparm_vdw, molecular_guess, tensor_orthogonal, virt_full, virt_minimal, virt_number, &
xalmo_trial_r0_out
USE input_section_types, ONLY: section_vals_get_subs_vals,&
Expand Down Expand Up @@ -107,8 +106,9 @@ SUBROUTINE almo_scf_init_read_write_input(input, almo_scf_env)

INTEGER :: handle
TYPE(section_vals_type), POINTER :: almo_analysis_section, almo_opt_diis_section, &
almo_opt_pcg_section, almo_scf_section, matrix_iterate_section, penalty_section, &
xalmo_opt_newton_pcg_section, xalmo_opt_pcg_section, xalmo_opt_trustr_section
almo_opt_pcg_section, almo_scf_section, matrix_iterate_section, nlmo_opt_pcg_section, &
penalty_section, xalmo_opt_newton_pcg_section, xalmo_opt_pcg_section, &
xalmo_opt_trustr_section

CALL timeset(routineN, handle)

Expand All @@ -121,12 +121,13 @@ SUBROUTINE almo_scf_init_read_write_input(input, almo_scf_env)
"XALMO_OPTIMIZER_PCG")
xalmo_opt_trustr_section => section_vals_get_subs_vals(almo_scf_section, &
"XALMO_OPTIMIZER_TRUSTR")
nlmo_opt_pcg_section => section_vals_get_subs_vals(almo_scf_section, &
"NLMO_OPTIMIZER_PCG")
almo_analysis_section => section_vals_get_subs_vals(almo_scf_section, "ANALYSIS")
xalmo_opt_newton_pcg_section => section_vals_get_subs_vals(xalmo_opt_pcg_section, &
"XALMO_NEWTON_PCG_SOLVER")
matrix_iterate_section => section_vals_get_subs_vals(almo_scf_section, &
"MATRIX_ITERATE")
penalty_section => section_vals_get_subs_vals(almo_scf_section, "PENALTY")

! read user input
! common ALMO options
Expand Down Expand Up @@ -154,6 +155,8 @@ SUBROUTINE almo_scf_init_read_write_input(input, almo_scf_env)
almo_scf_env%xalmo_extrapolation_order = MAX(0, almo_scf_env%xalmo_extrapolation_order)
CALL section_vals_val_get(almo_scf_section, "RETURN_ORTHOGONALIZED_MOS", &
l_val=almo_scf_env%return_orthogonalized_mos)
CALL section_vals_val_get(almo_scf_section, "CONSTRUCT_NLMOS", &
l_val=almo_scf_env%construct_nlmos)

CALL section_vals_val_get(matrix_iterate_section, "EPS_LANCZOS", &
r_val=almo_scf_env%eps_lanczos)
Expand Down Expand Up @@ -243,6 +246,49 @@ SUBROUTINE almo_scf_init_read_write_input(input, almo_scf_env)
CALL section_vals_val_get(xalmo_opt_pcg_section, "PRECONDITIONER", &
i_val=almo_scf_env%opt_xalmo_pcg%preconditioner)

penalty_section => section_vals_get_subs_vals(nlmo_opt_pcg_section, "PENALTY")
CALL section_vals_val_get(nlmo_opt_pcg_section, "EPS_ERROR", &
r_val=almo_scf_env%opt_nlmo_pcg%eps_error)
CALL section_vals_val_get(nlmo_opt_pcg_section, "MAX_ITER", &
i_val=almo_scf_env%opt_nlmo_pcg%max_iter)
CALL section_vals_val_get(nlmo_opt_pcg_section, "EPS_ERROR_EARLY", &
r_val=almo_scf_env%opt_nlmo_pcg%eps_error_early)
CALL section_vals_val_get(nlmo_opt_pcg_section, "MAX_ITER_EARLY", &
i_val=almo_scf_env%opt_nlmo_pcg%max_iter_early)
CALL section_vals_val_get(nlmo_opt_pcg_section, "MAX_ITER_OUTER_LOOP", &
i_val=almo_scf_env%opt_nlmo_pcg%max_iter_outer_loop)
CALL section_vals_val_get(nlmo_opt_pcg_section, "LIN_SEARCH_EPS_ERROR", &
r_val=almo_scf_env%opt_nlmo_pcg%lin_search_eps_error)
CALL section_vals_val_get(nlmo_opt_pcg_section, "LIN_SEARCH_STEP_SIZE_GUESS", &
r_val=almo_scf_env%opt_nlmo_pcg%lin_search_step_size_guess)
CALL section_vals_val_get(nlmo_opt_pcg_section, "PRECOND_FILTER_THRESHOLD", &
r_val=almo_scf_env%opt_nlmo_pcg%neglect_threshold)
CALL section_vals_val_get(nlmo_opt_pcg_section, "CONJUGATOR", &
i_val=almo_scf_env%opt_nlmo_pcg%conjugator)
CALL section_vals_val_get(nlmo_opt_pcg_section, "PRECONDITIONER", &
i_val=almo_scf_env%opt_nlmo_pcg%preconditioner)
CALL section_vals_val_get(penalty_section, &
"OPERATOR", &
i_val=almo_scf_env%opt_nlmo_pcg%opt_penalty%operator_type)
CALL section_vals_val_get(penalty_section, &
"PENALTY_STRENGTH", &
r_val=almo_scf_env%opt_nlmo_pcg%opt_penalty%penalty_strength)
CALL section_vals_val_get(penalty_section, &
"PENALTY_STRENGTH_DECREASE_FACTOR", &
r_val=almo_scf_env%opt_nlmo_pcg%opt_penalty%penalty_strength_dec_factor)
CALL section_vals_val_get(penalty_section, &
"DETERMINANT_TOLERANCE", &
r_val=almo_scf_env%opt_nlmo_pcg%opt_penalty%determinant_tolerance)
CALL section_vals_val_get(penalty_section, &
"FINAL_DETERMINANT", &
r_val=almo_scf_env%opt_nlmo_pcg%opt_penalty%final_determinant)
CALL section_vals_val_get(penalty_section, &
"COMPACTIFICATION_FILTER_START", &
r_val=almo_scf_env%opt_nlmo_pcg%opt_penalty%compactification_filter_start)
CALL section_vals_val_get(penalty_section, &
"VIRTUAL_NLMOS", &
l_val=almo_scf_env%opt_nlmo_pcg%opt_penalty%virtual_nlmos)

CALL section_vals_val_get(xalmo_opt_newton_pcg_section, "EPS_ERROR", &
r_val=almo_scf_env%opt_xalmo_newton_pcg_solver%eps_error)
CALL section_vals_val_get(xalmo_opt_newton_pcg_section, "MAX_ITER", &
Expand All @@ -252,13 +298,6 @@ SUBROUTINE almo_scf_init_read_write_input(input, almo_scf_env)
CALL section_vals_val_get(xalmo_opt_newton_pcg_section, "PRECONDITIONER", &
i_val=almo_scf_env%opt_xalmo_newton_pcg_solver%preconditioner)

CALL section_vals_val_get(penalty_section, &
"OCCUPIED_VOLUME_PENALTY_COEFF", &
r_val=almo_scf_env%penalty%occ_vol_coeff)
CALL section_vals_val_get(penalty_section, &
"OCCUPIED_VOLUME_PENALTY_METHOD", &
i_val=almo_scf_env%penalty%occ_vol_method)

CALL section_vals_val_get(almo_analysis_section, "_SECTION_PARAMETERS_", &
l_val=almo_scf_env%almo_analysis%do_analysis)
CALL section_vals_val_get(almo_analysis_section, "FROZEN_MO_ENERGY_TERM", &
Expand Down Expand Up @@ -504,16 +543,6 @@ SUBROUTINE almo_scf_init_read_write_input(input, almo_scf_env)

ENDIF ! end analysis settings

! check penalty settings
IF (almo_scf_env%penalty%occ_vol_method .NE. almo_occ_vol_penalty_none) THEN
IF (almo_scf_env%deloc_method .NE. almo_deloc_x .AND. &
almo_scf_env%deloc_method .NE. almo_deloc_scf .AND. &
almo_scf_env%deloc_method .NE. almo_deloc_x_then_scf) THEN
CALL cp_abort(__LOCATION__, &
"Occupied volume penalty seems to work only with completely delocalized orbitals")
ENDIF
ENDIF ! end penalty settings

CALL timestop(handle)

END SUBROUTINE almo_scf_init_read_write_input
Expand Down

1 comment on commit 0482296

@alazzaro
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rzk1
As a result of this commit, Cray compiler complains with this message (see https://www.cp2k.org/static/regtest/trunk/swan-skl28/CRAY-XC40-cce.popt.out):

ftn-7212 crayftn: ERROR COMPUTE_GRADIENT, File = ../../../../../home/users/alazzaro/cp2k/CP2K_AUTO_REGTEST/CRAY-XC40-cce/popt/cp2k/src/almo_scf_optimizer.F, Line = 6138 
  Variable "ielem" is used before it is defined.

Could you fix it?

Please sign in to comment.