36#include "./base/base_uses.f90"
41 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'pao_input'
72 INTEGER :: i, n_rep, ntrainfiles
83 pao%iw_fockev =
cp_print_key_unit_nr(logger, pao_section,
"PRINT%FOCK_EIGENVALUES", extension=
".paolog")
85 pao%iw_mlvar =
cp_print_key_unit_nr(logger, pao_section,
"PRINT%ML_VARIANCE", extension=
".paolog")
86 pao%iw_mldata =
cp_print_key_unit_nr(logger, pao_section,
"PRINT%ML_TRAINING_DATA", extension=
".paolog")
88 IF (pao%iw > 0)
WRITE (pao%iw, *)
""
93 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,T70,E11.1)")
" PAO|",
"EPS_PAO", pao%eps_pao
96 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,T70,E11.1)")
" PAO|",
"MIXING", pao%mixing
99 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,T70,I11)")
" PAO|",
"MAX_PAO", pao%max_pao
102 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,T70,I11)")
" PAO|",
"MAX_CYCLES", pao%max_cycles
104 CALL section_vals_val_get(pao_section,
"IGNORE_CONVERGENCE_FAILURE", l_val=pao%ignore_convergence_failure)
105 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,T70,L11)")
" PAO|",
"IGNORE_CONVERGENCE_FAILURE", pao%ignore_convergence_failure
108 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,T70,A11)")
" PAO|",
"PARAMETERIZATION",
id2str(pao%parameterization)
111 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,T70,L11)")
" PAO|",
"PRECONDITION", pao%precondition
114 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,T70,E11.1)")
" PAO|",
"REGULARIZATION", pao%regularization
115 IF (pao%regularization < 0.0_dp) cpabort(
"PAO: REGULARIZATION < 0")
120 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,T70,E11.1)")
" PAO|",
"EPS_PGF", pao%eps_pgf
121 IF (pao%eps_pgf < 0.0_dp) cpabort(
"PAO: EPS_PGF < 0")
124 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,T70,E11.1)")
" PAO|",
"PENALTY_DISTANCE", pao%penalty_dist
125 IF (pao%penalty_dist < 0.0_dp) cpabort(
"PAO: PENALTY_DISTANCE < 0")
128 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,T70,E11.1)")
" PAO|",
"PENALTY_STRENGTH", pao%penalty_strength
129 IF (pao%penalty_strength < 0.0_dp) cpabort(
"PAO: PENALTY_STRENGTH < 0")
131 CALL section_vals_val_get(pao_section,
"LINPOT_PRECONDITION_DELTA", r_val=pao%linpot_precon_delta)
132 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,T70,E11.1)")
" PAO|",
"LINPOT_PRECONDITION_DELTA", pao%linpot_precon_delta
133 IF (pao%linpot_precon_delta < 0.0_dp) cpabort(
"PAO: LINPOT_PRECONDITION_DELTA < 0")
136 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,T70,E11.1)")
" PAO|",
"LINPOT_INITGUESS_DELT", pao%linpot_init_delta
137 IF (pao%linpot_init_delta < 0.0_dp) cpabort(
"PAO: LINPOT_INITGUESS_DELTA < 0")
139 CALL section_vals_val_get(pao_section,
"LINPOT_REGULARIZATION_DELTA", r_val=pao%linpot_regu_delta)
140 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,T70,E11.1)")
" PAO|",
"LINPOT_REGULARIZATION_DELTA", pao%linpot_regu_delta
141 IF (pao%linpot_regu_delta < 0.0_dp) cpabort(
"PAO: LINPOT_REGULARIZATION_DELTA < 0")
143 CALL section_vals_val_get(pao_section,
"LINPOT_REGULARIZATION_STRENGTH", r_val=pao%linpot_regu_strength)
144 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,T70,E11.1)")
" PAO|",
"LINPOT_REGULARIZATION_STRENGTH", pao%linpot_regu_strength
145 IF (pao%linpot_regu_strength < 0.0_dp) cpabort(
"PAO: LINPOT_REGULARIZATION_STRENGTH < 0")
148 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,T70,A11)")
" PAO|",
"OPTIMIZER",
id2str(pao%optimizer)
151 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,T70,I11)")
" PAO|",
"CG_INIT_STEPS", pao%cg_init_steps
152 IF (pao%cg_init_steps < 1) cpabort(
"PAO: CG_INIT_STEPS < 1")
155 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,T70,E11.1)")
" PAO|",
"CG_RESET_LIMIT", pao%cg_reset_limit
156 IF (pao%cg_reset_limit < 0.0_dp) cpabort(
"PAO: CG_RESET_LIMIT < 0")
159 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,T70,E11.1)")
" PAO|",
"CHECK_UNITARY_TOL", pao%check_unitary_tol
162 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,T70,E11.1)")
" PAO|",
"CHECK_GRADIENT_TOL", pao%check_grad_tol
165 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,T70,I11)")
" PAO|",
"NUM_GRADIENT_ORDER", pao%num_grad_order
168 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,T70,E11.1)")
" PAO|",
"NUM_GRADIENT_EPS", pao%num_grad_eps
169 IF (pao%num_grad_eps < 0.0_dp) cpabort(
"PAO: NUM_GRADIENT_EPS < 0")
172 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,T70,I11)")
" PAO|",
"PRINT%RESTART%WRITE_CYCLES", pao%write_cycles
175 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,A)")
" PAO|",
"RESTART_FILE ", trim(pao%restart_file)
178 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,A)")
" PAO|",
"PREOPT_DM_FILE ", trim(pao%preopt_dm_file)
181 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,T70,A11)")
" PAO|",
"MACHINE_LEARNING%METHOD",
id2str(pao%ml_method)
184 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,T70,A11)")
" PAO|",
"MACHINE_LEARNING%PRIOR",
id2str(pao%ml_prior)
187 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,T70,A11)")
" PAO|",
"MACHINE_LEARNING%DESCRIPTOR",
id2str(pao%ml_descriptor)
190 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,T70,E11.1)")
" PAO|",
"MACHINE_LEARNING%TOLERANCE", pao%ml_tolerance
193 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,T70,E11.1)")
" PAO|",
"MACHINE_LEARNING%GP_NOISE_VAR", pao%gp_noise_var
196 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,T70,E11.1)")
" PAO|",
"MACHINE_LEARNING%GP_SCALE", pao%gp_scale
201 ALLOCATE (pao%ml_training_set(ntrainfiles))
202 DO i = 1, ntrainfiles
204 i_rep_val=i, c_val=pao%ml_training_set(i)%fn)
205 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,T70,A)")
" PAO|",
"MACHINE_LEARNING%TRAINING_SET", &
206 trim(pao%ml_training_set(i)%fn)
209 IF (pao%iw > 0)
WRITE (pao%iw, *)
""
220 CHARACTER(LEN=20) :: s
238 s =
"GAUSSIAN_PROCESS"
254 cpabort(
"PAO: unknown id")
268 TYPE(
section_type),
POINTER :: printkey, subsection, subsubsection
270 NULLIFY (keyword, subsection, subsubsection, printkey)
272 cpassert(.NOT.
ASSOCIATED(section))
273 CALL section_create(section, __location__, name=
"PAO", repeats=.false., &
274 description=
"Polarized Atomic Orbital Method", &
279 description=
"Convergence criteria for PAO optimization.", &
280 default_r_val=1.e-5_dp)
285 description=
"Mixing fraction of new and old optimizied solutions.", &
286 default_r_val=0.5_dp)
291 description=
"Maximum number of PAO basis optimization steps.", &
297 description=
"Maximum number of PAO line search cycles for a given hamiltonian.", &
302 CALL keyword_create(keyword, __location__, name=
"IGNORE_CONVERGENCE_FAILURE", &
303 description=
"If true, only a warning is issued if a PAO "// &
304 "optimization has not converged. By default, a run is aborted "// &
305 "if the required convergence criteria have not been achieved.", &
306 usage=
"IGNORE_CONVERGENCE_FAILURE logical_value", &
307 default_l_val=.false., lone_keyword_l_val=.true.)
312 CALL keyword_create(keyword, __location__, name=
"PARAMETERIZATION", &
313 description=
"Parametrization of the mapping between the primary and the PAO basis.", &
314 enum_c_vals=
s2a(
"ROTINV",
"FOCK",
"GTH",
"EXP",
"EQUIVARIANT"), &
316 enum_desc=
s2a(
"Rotational invariant parametrization (machine learnable)", &
317 "Fock matrix parametrization", &
318 "Parametrization based on GTH pseudo potentials", &
319 "Original matrix exponential parametrization", &
320 "Equivariant parametrization"), &
325 CALL keyword_create(keyword, __location__, name=
"REGULARIZATION", &
326 description=
"Strength of regularization term which ensures parameters remain small.", &
327 default_r_val=0.0_dp)
331 CALL keyword_create(keyword, __location__, name=
"PENALTY_DISTANCE", &
332 description=
"Distance at which approaching eigenvalues are penalized to prevent degeneration.", &
333 default_r_val=0.1_dp)
337 CALL keyword_create(keyword, __location__, name=
"PENALTY_STRENGTH", &
338 description=
"Strength of the penalty term which prevents degenerate eigenvalues.", &
339 default_r_val=0.005_dp)
344 description=
"Apply a preconditioner to the parametrization.", &
345 default_l_val=.false., lone_keyword_l_val=.true.)
350 description=
"Sets precision for potential and descriptor matrix elements. "// &
351 "Overrides DFT/QS/EPS_DEFAULT value.", type_of_var=
real_t)
356 CALL keyword_create(keyword, __location__, name=
"PREOPT_DM_FILE", &
357 description=
"Read pre-optimized density matrix from given file.", &
358 repeats=.false., default_c_val=
"")
364 description=
"Reads given files as restart for PAO basis", &
365 repeats=.false., default_c_val=
"")
369 CALL keyword_create(keyword, __location__, name=
"CHECK_GRADIENT_TOL", &
370 description=
"Tolerance for check of full analytic gradient against the numeric one."// &
371 " Negative values mean don't check at all.", &
372 default_r_val=-1.0_dp)
376 CALL keyword_create(keyword, __location__, name=
"NUM_GRADIENT_EPS", &
377 description=
"Step length used for the numeric derivative when checking the gradient.", &
378 default_r_val=1e-8_dp)
382 CALL keyword_create(keyword, __location__, name=
"NUM_GRADIENT_ORDER", &
383 description=
"Order of the numeric derivative when checking the gradient. "// &
384 "Possible values are 2, 4, and 6.", &
389 CALL keyword_create(keyword, __location__, name=
"CHECK_UNITARY_TOL", &
390 description=
"Check if rotation matrix is unitary."// &
391 " Negative values mean don't check at all.", &
392 default_r_val=-1.0_dp)
397 CALL keyword_create(keyword, __location__, name=
"LINPOT_PRECONDITION_DELTA", &
398 description=
"Eigenvalue threshold used for preconditioning.", &
399 default_r_val=0.0_dp)
403 CALL keyword_create(keyword, __location__, name=
"LINPOT_INITGUESS_DELTA", &
404 description=
"Eigenvalue threshold used for calculating initial guess.", &
405 default_r_val=0.0_dp)
409 CALL keyword_create(keyword, __location__, name=
"LINPOT_REGULARIZATION_DELTA", &
410 description=
"Eigenvalue threshold used for regularization.", &
411 default_r_val=0.0_dp)
415 CALL keyword_create(keyword, __location__, name=
"LINPOT_REGULARIZATION_STRENGTH", &
416 description=
"Strength of regularization on linpot layer.", &
417 default_r_val=0.0_dp)
422 CALL section_create(subsection, __location__, name=
"MACHINE_LEARNING", description=
"Machine learning section")
425 description=
"Machine learning scheme used to predict PAO basis sets.", &
426 enum_c_vals=
s2a(
"GAUSSIAN_PROCESS",
"NEURAL_NETWORK",
"LAZY"), &
428 enum_desc=
s2a(
"Gaussian Process",
"Neural Network",
"Just rely on prior"), &
434 description=
"Prior used for predictions.", &
435 enum_c_vals=
s2a(
"ZERO",
"MEAN"), &
437 enum_desc=
s2a(
"Simply use zero",
"Use average of training-set"), &
443 description=
"Descriptor used as input for machine learning.", &
444 enum_c_vals=
s2a(
"POTENTIAL",
"OVERLAP",
"R12"), &
446 enum_desc=
s2a(
"Eigenvalues of local potential matrix", &
447 "Eigenvalues of local overlap matrix", &
448 "Distance between two atoms (just for testing)"), &
455 description=
"Maximum variance tolerated when making predictions.", &
456 default_r_val=1.0e-2_dp)
461 description=
"Variance of noise used for Gaussian Process machine learning.", &
462 default_r_val=0.1_dp)
467 description=
"Length scale used for Gaussian Process machine learning.", &
468 default_r_val=0.05_dp)
473 CALL section_create(subsubsection, __location__, name=
"TRAINING_SET", &
474 description=
"Lists PAO-restart file used for training")
475 CALL keyword_create(keyword, __location__, name=
"_DEFAULT_KEYWORD_", &
476 description=
"One file name per line.", &
477 repeats=.true., type_of_var=
lchar_t)
488 description=
"Printkey section", &
489 n_keywords=0, n_subsections=1, repeats=.true.)
492 description=
"Normal output by PAO", &
498 description=
"One line summary for each atom", &
504 description=
"Gap of the fock matrix for each atom", &
510 description=
"Eigenvalues of the fock matrix for each atom", &
516 description=
"Variances of machine learning predictions for each atom", &
522 description=
"Dumps training data used for machine learning", &
528 description=
"Output by the optimizer", &
534 description=
"Restart file of PAO basis", &
537 CALL keyword_create(keyword, __location__, name=
"BACKUP_COPIES", &
538 description=
"Specifies the maximum number of backup copies.", &
539 usage=
"BACKUP_COPIES {int}", &
545 description=
"Maximum number of PAO line search cycles until a restart is written.", &
558 description=
"Optimizer used to find PAO basis.", &
559 enum_c_vals=
s2a(
"CG",
"BFGS"), &
561 enum_desc=
s2a(
"Conjugate gradient algorithm", &
562 "Broyden-Fletcher-Goldfarb-Shanno algorithm"), &
567 CALL keyword_create(keyword, __location__, name=
"CG_INIT_STEPS", &
568 description=
"Number of steepest descent steps before starting the"// &
569 " conjugate gradients optimization.", &
574 CALL keyword_create(keyword, __location__, name=
"CG_RESET_LIMIT", &
575 description=
"The CG is reseted if the cosine of the angle between the last "// &
576 "search direction and the new gradient is larger that the limit.", &
577 default_r_val=0.1_dp)
collects all references to literature in CP2K as new algorithms / method are included from literature...
integer, save, public schuett2018
integer, save, public berghold2011
integer, save, public zhu2016
various routines to log and control the output. The idea is that decisions about where to log should ...
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
routines to handle the output, The idea is to remove the decision of wheter to output and what to out...
integer function, public cp_print_key_unit_nr(logger, basis_section, print_key_path, extension, middle_name, local, log_filename, ignore_should_output, file_form, file_position, file_action, file_status, do_backup, on_file, is_new_file, mpi_io, fout)
...
integer, parameter, public low_print_level
integer, parameter, public high_print_level
integer, parameter, public add_last_numeric
subroutine, public cp_print_key_section_create(print_key_section, location, name, description, print_level, each_iter_names, each_iter_values, add_last, filename, common_iter_levels, citations, unit_str)
creates a print_key section
Defines the basic variable types.
integer, parameter, public dp
A generic framework to calculate step lengths for 1D line search.
subroutine, public linesearch_create_section(section)
Declare the line search input section.
Types used by the PAO machinery.
Utilities for string manipulations.
type of a logger, at the moment it contains just a print level starting at which level it should be l...