46 #include "../base/base_uses.f90"
51 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'cp_lbfgs_geo'
70 SUBROUTINE geoopt_lbfgs(force_env, gopt_param, globenv, geo_section, gopt_env, &
72 TYPE(force_env_type),
POINTER :: force_env
73 TYPE(gopt_param_type),
POINTER :: gopt_param
74 TYPE(global_environment_type),
POINTER :: globenv
75 TYPE(section_vals_type),
POINTER :: geo_section
76 TYPE(gopt_f_type),
POINTER :: gopt_env
77 REAL(kind=
dp),
DIMENSION(:),
POINTER :: x0
79 CHARACTER(len=*),
PARAMETER :: routinen =
'geoopt_lbfgs'
81 INTEGER :: handle, iter_nr, its, output_unit
82 LOGICAL :: converged, should_stop
83 REAL(kind=
dp) :: trust_radius
84 TYPE(cell_type),
POINTER :: cell
85 TYPE(cp_lbfgs_opt_gopt_type),
POINTER :: optimizer
86 TYPE(cp_logger_type),
POINTER :: logger
87 TYPE(cp_subsys_type),
POINTER :: subsys
88 TYPE(mp_para_env_type),
POINTER :: para_env
89 TYPE(section_vals_type),
POINTER :: root_section
90 TYPE(spgr_type),
POINTER :: spgr
92 CALL timeset(routinen, handle)
94 NULLIFY (optimizer, para_env, spgr)
97 root_section => force_env%root_section
98 cpassert(
ASSOCIATED(force_env))
99 cpassert(
ASSOCIATED(gopt_param))
102 CALL force_env_get(force_env, para_env=para_env, cell=cell, subsys=subsys)
111 IF (spgr%keep_space_group)
THEN
119 cpabort(
"BFGS method not yet working with DIMER")
124 x0=x0, wanted_relative_f_delta=gopt_param%wanted_rel_f_error, &
125 wanted_projected_gradient=gopt_param%wanted_proj_gradient, m=gopt_param%max_h_rank, &
126 max_f_per_iter=gopt_param%max_f_per_iter, trust_radius=trust_radius)
127 CALL cp_iterate(logger%iter_info, increment=0, iter_nr_out=iter_nr)
130 DO its = iter_nr + 1, gopt_param%max_iter
131 CALL cp_iterate(logger%iter_info, last=(its == gopt_param%max_iter))
137 force_env=force_env, gopt_param=gopt_param, &
138 converged=converged, spgr=spgr))
EXIT
142 IF (should_stop)
THEN
146 IF (its == gopt_param%max_iter)
EXIT
149 IF ((its == gopt_param%max_iter) .AND. (.NOT. converged))
THEN
154 CALL cp_iterate(logger%iter_info, last=.true., increment=0)
155 CALL gopt_f_io_finalize(gopt_env, force_env, optimizer%x, converged, its, root_section, &
156 optimizer%para_env, optimizer%master, output_unit)
159 DEALLOCATE (optimizer)
161 "PRINT%PROGRAM_RUN_INFO")
163 CALL timestop(handle)
Handles all functions related to the CELL.
Routines to handle the external control of CP2K.
subroutine, public external_control(should_stop, flag, globenv, target_time, start_time, force_check)
External manipulations during a run : when the <PROJECT_NAME>.EXIT_$runtype command is sent the progr...
Main driver for L-BFGS optimizer.
subroutine, public geoopt_lbfgs(force_env, gopt_param, globenv, geo_section, gopt_env, x0)
...
routines that optimize a functional using the limited memory bfgs quasi-newton method....
subroutine, public cp_opt_gopt_create(optimizer, para_env, obj_funct, x0, m, print_every, wanted_relative_f_delta, wanted_projected_gradient, lower_bound, upper_bound, kind_of_bound, master, max_f_per_iter, trust_radius)
initializes the optimizer
logical function, public cp_opt_gopt_next(optimizer, n_iter, f, last_f, projected_gradient, converged, geo_section, force_env, gopt_param, spgr)
goes to the next optimal point (after an optimizer iteration) returns true if converged
subroutine, public cp_opt_gopt_stop(optimizer)
stops the optimization
subroutine, public cp_opt_gopt_release(optimizer)
releases the optimizer (see doc/ReferenceCounting.html)
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)
...
subroutine, public cp_print_key_finished_output(unit_nr, logger, basis_section, print_key_path, local, ignore_should_output, on_file, mpi_io)
should be called after you finish working with a unit obtained with cp_print_key_unit_nr,...
subroutine, public cp_iterate(iteration_info, last, iter_nr, increment, iter_nr_out)
adds one to the actual iteration
types that represent a subsys, i.e. a part of the system
Interface for the force calculations.
recursive subroutine, public force_env_get(force_env, in_use, fist_env, qs_env, meta_env, fp_env, subsys, para_env, potential_energy, additional_potential, kinetic_energy, harmonic_shell, kinetic_shell, cell, sub_force_env, qmmm_env, qmmmx_env, eip_env, pwdft_env, globenv, input, force_env_section, method_name_id, root_section, mixed_env, nnp_env, embed_env)
returns various attributes about the force environment
Define type storing the global information of a run. Keep the amount of stored data small....
contains a functional that calculates the energy and its derivatives for the geometry optimizer
subroutine, public print_geo_opt_header(gopt_env, output_unit, label)
...
recursive subroutine, public gopt_f_io_finalize(gopt_env, force_env, x0, conv, its, root_section, para_env, master, output_unit)
Handles the Output at the end of an optimization run.
subroutine, public print_geo_opt_nc(gopt_env, output_unit)
...
subroutine, public gopt_f_ii(its, output_unit)
Prints iteration step of the optimization procedure on screen.
contains a functional that calculates the energy and its derivatives for the geometry optimizer
contains typo and related routines to handle parameters controlling the GEO_OPT module
Defines the basic variable types.
integer, parameter, public dp
Interface to the message passing library MPI.
Space Group Symmetry Type Module (version 1.0, Ferbruary 12, 2021)
Space Group Symmetry Module (version 1.0, January 16, 2020)
subroutine, public print_spgr(spgr)
routine prints Space Group Information.
subroutine, public spgr_apply_rotations_coord(spgr, coord)
routine applies the rotation matrices to the coordinates.
subroutine, public identify_space_group(subsys, geo_section, gopt_env, iunit)
routine indentifies the space group and finds rotation matrices.