36 #include "./base/base_uses.f90"
41 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'pao_input'
69 TYPE(pao_env_type),
POINTER :: pao
70 TYPE(section_vals_type),
POINTER :: input
72 INTEGER :: i, n_rep, ntrainfiles
73 TYPE(cp_logger_type),
POINTER :: logger
74 TYPE(section_vals_type),
POINTER :: pao_section, training_set_section
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
105 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,T70,A11)")
" PAO|",
"PARAMETERIZATION",
id2str(pao%parameterization)
108 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,T70,L11)")
" PAO|",
"PRECONDITION", pao%precondition
111 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,T70,E11.1)")
" PAO|",
"REGULARIZATION", pao%regularization
112 IF (pao%regularization < 0.0_dp) cpabort(
"PAO: REGULARIZATION < 0")
117 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,T70,E11.1)")
" PAO|",
"EPS_PGF", pao%eps_pgf
118 IF (pao%eps_pgf < 0.0_dp) cpabort(
"PAO: EPS_PGF < 0")
121 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,T70,E11.1)")
" PAO|",
"PENALTY_DISTANCE", pao%penalty_dist
122 IF (pao%penalty_dist < 0.0_dp) cpabort(
"PAO: PENALTY_DISTANCE < 0")
125 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,T70,E11.1)")
" PAO|",
"PENALTY_STRENGTH", pao%penalty_strength
126 IF (pao%penalty_strength < 0.0_dp) cpabort(
"PAO: PENALTY_STRENGTH < 0")
128 CALL section_vals_val_get(pao_section,
"LINPOT_PRECONDITION_DELTA", r_val=pao%linpot_precon_delta)
129 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,T70,E11.1)")
" PAO|",
"LINPOT_PRECONDITION_DELTA", pao%linpot_precon_delta
130 IF (pao%linpot_precon_delta < 0.0_dp) cpabort(
"PAO: LINPOT_PRECONDITION_DELTA < 0")
133 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,T70,E11.1)")
" PAO|",
"LINPOT_INITGUESS_DELT", pao%linpot_init_delta
134 IF (pao%linpot_init_delta < 0.0_dp) cpabort(
"PAO: LINPOT_INITGUESS_DELTA < 0")
136 CALL section_vals_val_get(pao_section,
"LINPOT_REGULARIZATION_DELTA", r_val=pao%linpot_regu_delta)
137 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,T70,E11.1)")
" PAO|",
"LINPOT_REGULARIZATION_DELTA", pao%linpot_regu_delta
138 IF (pao%linpot_regu_delta < 0.0_dp) cpabort(
"PAO: LINPOT_REGULARIZATION_DELTA < 0")
140 CALL section_vals_val_get(pao_section,
"LINPOT_REGULARIZATION_STRENGTH", r_val=pao%linpot_regu_strength)
141 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,T70,E11.1)")
" PAO|",
"LINPOT_REGULARIZATION_STRENGTH", pao%linpot_regu_strength
142 IF (pao%linpot_regu_strength < 0.0_dp) cpabort(
"PAO: LINPOT_REGULARIZATION_STRENGTH < 0")
145 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,T70,A11)")
" PAO|",
"OPTIMIZER",
id2str(pao%optimizer)
148 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,T70,I11)")
" PAO|",
"CG_INIT_STEPS", pao%cg_init_steps
149 IF (pao%cg_init_steps < 1) cpabort(
"PAO: CG_INIT_STEPS < 1")
152 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,T70,E11.1)")
" PAO|",
"CG_RESET_LIMIT", pao%cg_reset_limit
153 IF (pao%cg_reset_limit < 0.0_dp) cpabort(
"PAO: CG_RESET_LIMIT < 0")
156 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,T70,E11.1)")
" PAO|",
"CHECK_UNITARY_TOL", pao%check_unitary_tol
159 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,T70,E11.1)")
" PAO|",
"CHECK_GRADIENT_TOL", pao%check_grad_tol
162 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,T70,I11)")
" PAO|",
"NUM_GRADIENT_ORDER", pao%num_grad_order
165 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,T70,E11.1)")
" PAO|",
"NUM_GRADIENT_EPS", pao%num_grad_eps
166 IF (pao%num_grad_eps < 0.0_dp) cpabort(
"PAO: NUM_GRADIENT_EPS < 0")
169 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,T70,I11)")
" PAO|",
"PRINT%RESTART%WRITE_CYCLES", pao%write_cycles
172 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,A)")
" PAO|",
"RESTART_FILE ", trim(pao%restart_file)
175 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,A)")
" PAO|",
"PREOPT_DM_FILE ", trim(pao%preopt_dm_file)
178 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,T70,A11)")
" PAO|",
"MACHINE_LEARNING%METHOD",
id2str(pao%ml_method)
181 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,T70,A11)")
" PAO|",
"MACHINE_LEARNING%PRIOR",
id2str(pao%ml_prior)
184 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,T70,A11)")
" PAO|",
"MACHINE_LEARNING%DESCRIPTOR",
id2str(pao%ml_descriptor)
187 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,T70,E11.1)")
" PAO|",
"MACHINE_LEARNING%TOLERANCE", pao%ml_tolerance
190 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,T70,E11.1)")
" PAO|",
"MACHINE_LEARNING%GP_NOISE_VAR", pao%gp_noise_var
193 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,T70,E11.1)")
" PAO|",
"MACHINE_LEARNING%GP_SCALE", pao%gp_scale
198 ALLOCATE (pao%ml_training_set(ntrainfiles))
199 DO i = 1, ntrainfiles
201 i_rep_val=i, c_val=pao%ml_training_set(i)%fn)
202 IF (pao%iw > 0)
WRITE (pao%iw,
"(A,T40,A,T70,A)")
" PAO|",
"MACHINE_LEARNING%TRAINING_SET", &
203 trim(pao%ml_training_set(i)%fn)
206 IF (pao%iw > 0)
WRITE (pao%iw, *)
""
217 CHARACTER(LEN=11) :: s
235 s =
"GAUSSIAN_PROCESS"
251 cpabort(
"PAO: unknown id")
262 TYPE(section_type),
POINTER :: section
264 TYPE(keyword_type),
POINTER :: keyword
265 TYPE(section_type),
POINTER :: printkey, subsection, subsubsection
267 NULLIFY (keyword, subsection, subsubsection, printkey)
269 cpassert(.NOT.
ASSOCIATED(section))
270 CALL section_create(section, __location__, name=
"PAO", repeats=.false., &
271 description=
"Polarized Atomic Orbital Method", &
276 description=
"Convergence criteria for PAO optimization.", &
277 default_r_val=1.e-5_dp)
282 description=
"Mixing fraction of new and old optimizied solutions.", &
283 default_r_val=0.5_dp)
288 description=
"Maximum number of PAO basis optimization steps.", &
294 description=
"Maximum number of PAO line search cycles for a given hamiltonian.", &
300 CALL keyword_create(keyword, __location__, name=
"PARAMETERIZATION", &
301 description=
"Parametrization of the mapping between the primary and the PAO basis.", &
302 enum_c_vals=s2a(
"ROTINV",
"FOCK",
"GTH",
"EXP",
"EQUIVARIANT"), &
304 enum_desc=s2a(
"Rotational invariant parametrization (machine learnable)", &
305 "Fock matrix parametrization", &
306 "Parametrization based on GTH pseudo potentials", &
307 "Original matrix exponential parametrization", &
308 "Equivariant parametrization"), &
313 CALL keyword_create(keyword, __location__, name=
"REGULARIZATION", &
314 description=
"Strength of regularization term which ensures parameters remain small.", &
315 default_r_val=0.0_dp)
319 CALL keyword_create(keyword, __location__, name=
"PENALTY_DISTANCE", &
320 description=
"Distance at which approaching eigenvalues are penalized to prevent degeneration.", &
321 default_r_val=0.1_dp)
325 CALL keyword_create(keyword, __location__, name=
"PENALTY_STRENGTH", &
326 description=
"Strength of the penalty term which prevents degenerate eigenvalues.", &
327 default_r_val=0.005_dp)
332 description=
"Apply a preconditioner to the parametrization.", &
333 default_l_val=.false., lone_keyword_l_val=.true.)
338 description=
"Sets precision for potential and descriptor matrix elements. "// &
339 "Overrides DFT/QS/EPS_DEFAULT value.", type_of_var=
real_t)
344 CALL keyword_create(keyword, __location__, name=
"PREOPT_DM_FILE", &
345 description=
"Read pre-optimized density matrix from given file.", &
346 repeats=.false., default_c_val=
"")
352 description=
"Reads given files as restart for PAO basis", &
353 repeats=.false., default_c_val=
"")
357 CALL keyword_create(keyword, __location__, name=
"CHECK_GRADIENT_TOL", &
358 description=
"Tolerance for check of full analytic gradient against the numeric one."// &
359 " Negative values mean don't check at all.", &
360 default_r_val=-1.0_dp)
364 CALL keyword_create(keyword, __location__, name=
"NUM_GRADIENT_EPS", &
365 description=
"Step length used for the numeric derivative when checking the gradient.", &
366 default_r_val=1e-8_dp)
370 CALL keyword_create(keyword, __location__, name=
"NUM_GRADIENT_ORDER", &
371 description=
"Order of the numeric derivative when checking the gradient. "// &
372 "Possible values are 2, 4, and 6.", &
377 CALL keyword_create(keyword, __location__, name=
"CHECK_UNITARY_TOL", &
378 description=
"Check if rotation matrix is unitary."// &
379 " Negative values mean don't check at all.", &
380 default_r_val=-1.0_dp)
385 CALL keyword_create(keyword, __location__, name=
"LINPOT_PRECONDITION_DELTA", &
386 description=
"Eigenvalue threshold used for preconditioning.", &
387 default_r_val=0.0_dp)
391 CALL keyword_create(keyword, __location__, name=
"LINPOT_INITGUESS_DELTA", &
392 description=
"Eigenvalue threshold used for calculating initial guess.", &
393 default_r_val=0.0_dp)
397 CALL keyword_create(keyword, __location__, name=
"LINPOT_REGULARIZATION_DELTA", &
398 description=
"Eigenvalue threshold used for regularization.", &
399 default_r_val=0.0_dp)
403 CALL keyword_create(keyword, __location__, name=
"LINPOT_REGULARIZATION_STRENGTH", &
404 description=
"Strength of regularization on linpot layer.", &
405 default_r_val=0.0_dp)
410 CALL section_create(subsection, __location__, name=
"MACHINE_LEARNING", description=
"Machine learning section")
413 description=
"Machine learning scheme used to predict PAO basis sets.", &
414 enum_c_vals=s2a(
"GAUSSIAN_PROCESS",
"NEURAL_NETWORK",
"LAZY"), &
416 enum_desc=s2a(
"Gaussian Process",
"Neural Network",
"Just rely on prior"), &
422 description=
"Prior used for predictions.", &
423 enum_c_vals=s2a(
"ZERO",
"MEAN"), &
425 enum_desc=s2a(
"Simply use zero",
"Use average of training-set"), &
431 description=
"Descriptor used as input for machine learning.", &
432 enum_c_vals=s2a(
"POTENTIAL",
"OVERLAP",
"R12"), &
434 enum_desc=s2a(
"Eigenvalues of local potential matrix", &
435 "Eigenvalues of local overlap matrix", &
436 "Distance between two atoms (just for testing)"), &
443 description=
"Maximum variance tolerated when making predictions.", &
444 default_r_val=1.0e-2_dp)
449 description=
"Variance of noise used for Gaussian Process machine learning.", &
450 default_r_val=0.1_dp)
455 description=
"Length scale used for Gaussian Process machine learning.", &
456 default_r_val=0.05_dp)
461 CALL section_create(subsubsection, __location__, name=
"TRAINING_SET", &
462 description=
"Lists PAO-restart file used for training")
463 CALL keyword_create(keyword, __location__, name=
"_DEFAULT_KEYWORD_", &
464 description=
"One file name per line.", &
465 repeats=.true., type_of_var=
lchar_t)
476 description=
"Printkey section", &
477 n_keywords=0, n_subsections=1, repeats=.true.)
480 description=
"Normal output by PAO", &
486 description=
"One line summary for each atom", &
492 description=
"Gap of the fock matrix for each atom", &
498 description=
"Eigenvalues of the fock matrix for each atom", &
504 description=
"Variances of machine learning predictions for each atom", &
510 description=
"Dumps training data used for machine learning", &
516 description=
"Output by the optimizer", &
522 description=
"Restart file of PAO basis", &
525 CALL keyword_create(keyword, __location__, name=
"BACKUP_COPIES", &
526 description=
"Specifies the maximum number of backup copies.", &
527 usage=
"BACKUP_COPIES {int}", &
533 description=
"Maximum number of PAO line search cycles until a restart is written.", &
546 description=
"Optimizer used to find PAO basis.", &
547 enum_c_vals=s2a(
"CG",
"BFGS"), &
549 enum_desc=s2a(
"Conjugate gradient algorithm", &
550 "Broyden-Fletcher-Goldfarb-Shanno algorithm"), &
555 CALL keyword_create(keyword, __location__, name=
"CG_INIT_STEPS", &
556 description=
"Number of steepest descent steps before starting the"// &
557 " conjugate gradients optimization.", &
562 CALL keyword_create(keyword, __location__, name=
"CG_RESET_LIMIT", &
563 description=
"The CG is reseted if the cosine of the angle between the last "// &
564 "search direction and the new gradient is larger that the limit.", &
565 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.