LCOV - code coverage report
Current view: top level - src/motion - gopt_param_types.F (source / functions) Hit Total Coverage
Test: CP2K Regtests (git:5417965) Lines: 31 32 96.9 %
Date: 2024-02-24 07:43:42 Functions: 1 3 33.3 %

          Line data    Source code
       1             : !--------------------------------------------------------------------------------------------------!
       2             : !   CP2K: A general program to perform molecular dynamics simulations                              !
       3             : !   Copyright 2000-2024 CP2K developers group <https://cp2k.org>                                   !
       4             : !                                                                                                  !
       5             : !   SPDX-License-Identifier: GPL-2.0-or-later                                                      !
       6             : !--------------------------------------------------------------------------------------------------!
       7             : 
       8             : ! **************************************************************************************************
       9             : !> \brief contains typo and related routines to handle parameters controlling the
      10             : !>      GEO_OPT module
      11             : !> \par History
      12             : !>      none
      13             : ! **************************************************************************************************
      14             : MODULE gopt_param_types
      15             : 
      16             :    USE input_constants,                 ONLY: default_bfgs_method_id,&
      17             :                                               default_cell_method_id,&
      18             :                                               default_cg_method_id,&
      19             :                                               default_lbfgs_method_id,&
      20             :                                               default_minimization_method_id,&
      21             :                                               default_ts_method_id,&
      22             :                                               none_ts_method_id
      23             :    USE input_section_types,             ONLY: section_vals_type,&
      24             :                                               section_vals_val_get
      25             :    USE kinds,                           ONLY: dp
      26             : #include "../base/base_uses.f90"
      27             : 
      28             :    IMPLICIT NONE
      29             :    PRIVATE
      30             : 
      31             :    LOGICAL, PRIVATE, PARAMETER :: debug_this_module = .TRUE.
      32             :    CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'gopt_param_types'
      33             : 
      34             :    PUBLIC :: gopt_param_type
      35             :    PUBLIC :: gopt_param_read
      36             : 
      37             : ! **************************************************************************************************
      38             : !> \brief stores the parameters nedeed for a geometry optimization
      39             : !> \param method_id the optimization method
      40             : !> \param wanted_proj_gradient the wanted accuracy on the projected gradient
      41             : !> \param wanted_rel_f_error ...
      42             : !> \param max_h_rank maximum rank of the hessian approximation
      43             : !> \param max_f_per_iter maximum number of function evaluations per iteration
      44             : !> \param max_iter maximum number of iterations
      45             : !> \par History
      46             : !>      08.2003 created [fawzi]
      47             : !> \author Fawzi Mohamed
      48             : ! **************************************************************************************************
      49             :    TYPE cg_ls_param_type
      50             :       INTEGER         :: brent_max_iter = 0, type_id = default_cell_method_id
      51             :       REAL(KIND=dp) :: brent_tol = 0.0_dp, brack_limit = 0.0_dp, initial_step = 0.0_dp, max_step = 0.0_dp
      52             :       LOGICAL         :: grad_only = .FALSE.
      53             :    END TYPE cg_ls_param_type
      54             : 
      55             : ! **************************************************************************************************
      56             :    TYPE gopt_param_type
      57             :       LOGICAL                  :: Fletcher_Reeves = .FALSE.
      58             :       INTEGER                  :: method_id = default_cell_method_id, type_id = default_cell_method_id
      59             :       INTEGER                  :: ts_method_id = 0, cell_method_id = 0, shellcore_method_id = 0
      60             :       INTEGER                  :: max_f_per_iter = 0, max_iter = 0, max_h_rank = 0
      61             :       INTEGER                  :: max_steep_steps = 0
      62             :       REAL(KIND=dp)          :: restart_limit = 0.0_dp
      63             :       REAL(KIND=dp)          :: wanted_proj_gradient = 0.0_dp, wanted_rel_f_error = 0.0_dp
      64             :       REAL(KIND=dp)          :: max_dr = 0.0_dp, max_force = 0.0_dp, rms_dr = 0.0_dp, rms_force = 0.0_dp
      65             :       REAL(KIND=dp)          :: dimer_angle_tol = 0.0_dp
      66             :       TYPE(cg_ls_param_type)   :: cg_ls = cg_ls_param_type()
      67             :    END TYPE gopt_param_type
      68             : 
      69             : CONTAINS
      70             : 
      71             : ! **************************************************************************************************
      72             : !> \brief reads the parameters of the geopmetry optimizer
      73             : !> \param gopt_param ...
      74             : !> \param gopt_section ...
      75             : !> \param type_id ...
      76             : !> \par History
      77             : !>      08.2003 created [fawzi]
      78             : !> \author Fawzi Mohamed
      79             : ! **************************************************************************************************
      80        2012 :    SUBROUTINE gopt_param_read(gopt_param, gopt_section, type_id)
      81             :       TYPE(gopt_param_type), INTENT(OUT)                 :: gopt_param
      82             :       TYPE(section_vals_type), POINTER                   :: gopt_section
      83             :       INTEGER, INTENT(IN), OPTIONAL                      :: type_id
      84             : 
      85        2012 :       CPASSERT(ASSOCIATED(gopt_section))
      86             : 
      87        2012 :       IF (PRESENT(type_id)) THEN
      88         252 :          gopt_param%type_id = type_id
      89             :       ELSE
      90        1760 :          CALL section_vals_val_get(gopt_section, "TYPE", i_val=gopt_param%type_id)
      91             :       END IF
      92        2012 :       CALL section_vals_val_get(gopt_section, "OPTIMIZER", i_val=gopt_param%method_id)
      93             : 
      94        2012 :       CALL section_vals_val_get(gopt_section, "MAX_ITER", i_val=gopt_param%max_iter)
      95        2012 :       CALL section_vals_val_get(gopt_section, "MAX_DR", r_val=gopt_param%max_dr)
      96        2012 :       CALL section_vals_val_get(gopt_section, "MAX_FORCE", r_val=gopt_param%max_force)
      97        2012 :       CALL section_vals_val_get(gopt_section, "RMS_DR", r_val=gopt_param%rms_dr)
      98        2012 :       CALL section_vals_val_get(gopt_section, "RMS_FORCE", r_val=gopt_param%rms_force)
      99             : 
     100        2396 :       SELECT CASE (gopt_param%method_id)
     101             :       CASE (default_lbfgs_method_id)
     102         384 :          CALL section_vals_val_get(gopt_section, "LBFGS%MAX_H_RANK", i_val=gopt_param%max_h_rank)
     103         384 :          CALL section_vals_val_get(gopt_section, "LBFGS%MAX_F_PER_ITER", i_val=gopt_param%max_f_per_iter)
     104         384 :          CALL section_vals_val_get(gopt_section, "LBFGS%WANTED_PROJ_GRADIENT", r_val=gopt_param%wanted_proj_gradient)
     105         384 :          CALL section_vals_val_get(gopt_section, "LBFGS%WANTED_REL_F_ERROR", r_val=gopt_param%wanted_rel_f_error)
     106             :       CASE (default_bfgs_method_id)
     107             :          ! Do nothing
     108             :       CASE (default_cg_method_id)
     109         368 :          CALL section_vals_val_get(gopt_section, "CG%FLETCHER_REEVES", l_val=gopt_param%Fletcher_Reeves)
     110         368 :          CALL section_vals_val_get(gopt_section, "CG%MAX_STEEP_STEPS", i_val=gopt_param%max_steep_steps)
     111         368 :          CALL section_vals_val_get(gopt_section, "CG%RESTART_LIMIT", r_val=gopt_param%restart_limit)
     112         368 :          CALL section_vals_val_get(gopt_section, "CG%LINE_SEARCH%TYPE", i_val=gopt_param%cg_ls%type_id)
     113             :          CALL section_vals_val_get(gopt_section, "CG%LINE_SEARCH%GOLD%INITIAL_STEP", &
     114         368 :                                    r_val=gopt_param%cg_ls%initial_step)
     115             :          CALL section_vals_val_get(gopt_section, "CG%LINE_SEARCH%GOLD%BRENT_TOL", &
     116         368 :                                    r_val=gopt_param%cg_ls%brent_tol)
     117             :          CALL section_vals_val_get(gopt_section, "CG%LINE_SEARCH%GOLD%BRENT_MAX_ITER", &
     118         368 :                                    i_val=gopt_param%cg_ls%brent_max_iter)
     119             :          CALL section_vals_val_get(gopt_section, "CG%LINE_SEARCH%GOLD%BRACK_LIMIT", &
     120         368 :                                    r_val=gopt_param%cg_ls%brack_limit)
     121             :          CALL section_vals_val_get(gopt_section, "CG%LINE_SEARCH%2PNT%MAX_ALLOWED_STEP", &
     122         368 :                                    r_val=gopt_param%cg_ls%max_step)
     123             :          CALL section_vals_val_get(gopt_section, "CG%LINE_SEARCH%2PNT%LINMIN_GRAD_ONLY", &
     124        2380 :                                    l_val=gopt_param%cg_ls%grad_only)
     125             :       END SELECT
     126             : 
     127        3772 :       SELECT CASE (gopt_param%type_id)
     128             :       CASE (default_minimization_method_id)
     129             :          ! Do Nothing
     130        1760 :          gopt_param%ts_method_id = none_ts_method_id
     131             :       CASE (default_ts_method_id)
     132          22 :          CALL section_vals_val_get(gopt_section, "TRANSITION_STATE%METHOD", i_val=gopt_param%ts_method_id)
     133             :       CASE (default_cell_method_id)
     134        2012 :          CALL section_vals_val_get(gopt_section, "TYPE", i_val=gopt_param%cell_method_id)
     135             :       END SELECT
     136             : 
     137        2012 :    END SUBROUTINE gopt_param_read
     138             : 
     139           0 : END MODULE gopt_param_types

Generated by: LCOV version 1.15