LCOV - code coverage report
Current view: top level - src/motion - neb_types.F (source / functions) Coverage Total Hit
Test: CP2K Regtests (git:1be8651) Lines: 97.6 % 42 41
Test Date: 2026-11-24 01:22:08 Functions: 40.0 % 5 2

            Line data    Source code
       1              : !--------------------------------------------------------------------------------------------------!
       2              : !   CP2K: A general program to perform molecular dynamics simulations                              !
       3              : !   Copyright 2000-2026 CP2K developers group <https://cp2k.org>                                   !
       4              : !                                                                                                  !
       5              : !   SPDX-License-Identifier: GPL-2.0-or-later                                                      !
       6              : !--------------------------------------------------------------------------------------------------!
       7              : 
       8              : ! **************************************************************************************************
       9              : !> \brief Typo for Nudged Elastic Band Calculation
      10              : !> \note
      11              : !>      Numerical accuracy for parallel runs:
      12              : !>       Each replica starts the SCF run from the one optimized
      13              : !>       in a previous run. It may happen then energies and derivatives
      14              : !>       of a serial run and a parallel run could be slightly different
      15              : !>       'cause of a different starting density matrix.
      16              : !>       Exact results are obtained using:
      17              : !>          EXTRAPOLATION USE_GUESS in QS section (Teo 09.2006)
      18              : !> \author Teodoro Laino 10.2006
      19              : ! **************************************************************************************************
      20              : MODULE neb_types
      21              : 
      22              :    USE force_env_types,                 ONLY: force_env_type
      23              :    USE input_constants,                 ONLY: band_md_opt,&
      24              :                                               do_b_neb,&
      25              :                                               do_band_cartesian,&
      26              :                                               do_band_collective,&
      27              :                                               pot_neb_full
      28              :    USE input_section_types,             ONLY: section_vals_type
      29              :    USE kinds,                           ONLY: default_string_length,&
      30              :                                               dp
      31              :    USE solid_state_coordinates,         ONLY: solid_state_frame_type,&
      32              :                                               ss_cell_dof
      33              : #include "../base/base_uses.f90"
      34              : 
      35              :    IMPLICIT NONE
      36              :    PRIVATE
      37              :    CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'neb_types'
      38              : 
      39              :    PUBLIC :: neb_type, &
      40              :              neb_var_type, &
      41              :              neb_var_create, &
      42              :              neb_var_release
      43              : 
      44              : ! **************************************************************************************************
      45              :    TYPE neb_type
      46              :       ! NEB parameters
      47              :       INTEGER       :: id_type = do_b_neb
      48              :       INTEGER       :: opt_type = band_md_opt
      49              :       INTEGER       :: pot_type = pot_neb_full
      50              :       INTEGER       :: number_of_replica = 0, nsize_xyz = 0, nsize_int = 0
      51              :       INTEGER       :: nsteps_it = 0, istep = 0
      52              :       INTEGER       :: nr_HE_image = 0
      53              :       LOGICAL       :: rotate_frames = .FALSE., align_frames = .FALSE.
      54              :       LOGICAL       :: optimize_end_points = .FALSE.
      55              :       LOGICAL       :: use_colvar = .FALSE.
      56              :       LOGICAL       :: solid_state = .FALSE.
      57              :       LOGICAL       :: reparametrize_frames = .FALSE.
      58              :       INTEGER       :: spline_order = 0
      59              :       REAL(KIND=dp) :: K = 0.0_dp, spring_energy = 0.0_dp, avg_distance = 0.0_dp
      60              :       REAL(KIND=dp) :: smoothing = 0.0_dp
      61              :       REAL(KIND=dp) :: external_pressure = 0.0_dp, cell_weight = 1.0_dp
      62              :       TYPE(solid_state_frame_type) :: solid_frame = solid_state_frame_type()
      63              :       CHARACTER(LEN=default_string_length) :: opt_type_label = ""
      64              :       ! Section used for restart
      65              :       TYPE(force_env_type), POINTER        :: force_env => NULL()
      66              :       TYPE(section_vals_type), POINTER     :: root_section => NULL()
      67              :       TYPE(section_vals_type), POINTER     :: motion_print_section => NULL()
      68              :       TYPE(section_vals_type), POINTER     :: force_env_section => NULL()
      69              :       TYPE(section_vals_type), POINTER     :: neb_section => NULL()
      70              :    END TYPE neb_type
      71              : 
      72              : ! **************************************************************************************************
      73              :    TYPE neb_var_type
      74              :       INTEGER :: in_use = do_band_collective, size_wrk(2) = 0
      75              :       REAL(KIND=dp), DIMENSION(:, :), POINTER  :: xyz => NULL(), int => NULL(), wrk => NULL()
      76              :       REAL(KIND=dp), DIMENSION(:, :, :), POINTER  :: Mmatrix => NULL()
      77              :       REAL(KIND=dp), ALLOCATABLE :: cells(:, :, :)
      78              :    END TYPE neb_var_type
      79              : 
      80              : CONTAINS
      81              : ! **************************************************************************************************
      82              : !> \brief Creates a variable type for BAND calculation
      83              : !> \param neb_var ...
      84              : !> \param neb_env ...
      85              : !> \param full_allocation ...
      86              : !> \date   05.2007
      87              : !> \author Teodoro Laino [tlaino] - University of Zurich
      88              : ! **************************************************************************************************
      89          160 :    SUBROUTINE neb_var_create(neb_var, neb_env, full_allocation)
      90              :       TYPE(neb_var_type), POINTER                        :: neb_var
      91              :       TYPE(neb_type), POINTER                            :: neb_env
      92              :       LOGICAL, INTENT(IN), OPTIONAL                      :: full_allocation
      93              : 
      94              :       INTEGER                                            :: neb_nr_replica
      95              :       LOGICAL                                            :: allocate_all
      96              : 
      97          160 :       CPASSERT(.NOT. ASSOCIATED(neb_var))
      98          160 :       allocate_all = .FALSE.
      99          160 :       IF (PRESENT(full_allocation)) allocate_all = full_allocation
     100          160 :       neb_nr_replica = neb_env%number_of_replica
     101          640 :       ALLOCATE (neb_var)
     102              :       NULLIFY (neb_var%xyz, neb_var%int, neb_var%wrk, neb_var%Mmatrix)
     103          160 :       IF (allocate_all) THEN
     104          256 :          ALLOCATE (neb_var%xyz(neb_env%nsize_xyz, neb_nr_replica))
     105        79252 :          neb_var%xyz = 0.0_dp
     106              :       END IF
     107          160 :       IF (neb_env%use_colvar) THEN
     108           16 :          neb_var%in_use = do_band_collective
     109           16 :          CPASSERT(neb_env%nsize_int > 0)
     110           64 :          ALLOCATE (neb_var%int(neb_env%nsize_int, neb_nr_replica))
     111          176 :          neb_var%int = 0.0_dp
     112           16 :          neb_var%wrk => neb_var%int
     113          144 :       ELSE IF (neb_env%solid_state) THEN
     114            8 :          neb_var%in_use = do_band_cartesian
     115           20 :          IF (.NOT. allocate_all) ALLOCATE (neb_var%xyz(neb_env%nsize_xyz, neb_nr_replica))
     116           32 :          ALLOCATE (neb_var%wrk(neb_env%nsize_xyz + ss_cell_dof, neb_nr_replica))
     117           16 :          IF (allocate_all) ALLOCATE (neb_var%cells(3, 3, neb_nr_replica))
     118          176 :          neb_var%xyz = 0.0_dp
     119          320 :          neb_var%wrk = 0.0_dp
     120              :       ELSE
     121          136 :          neb_var%in_use = do_band_cartesian
     122          136 :          IF (.NOT. allocate_all) THEN
     123          320 :             ALLOCATE (neb_var%xyz(neb_env%nsize_xyz, neb_nr_replica))
     124        85424 :             neb_var%xyz = 0.0_dp
     125              :          END IF
     126          136 :          neb_var%wrk => neb_var%xyz
     127              :       END IF
     128          160 :       neb_var%size_wrk(1) = SIZE(neb_var%wrk, 1)
     129          160 :       neb_var%size_wrk(2) = SIZE(neb_var%wrk, 2)
     130              : 
     131          160 :    END SUBROUTINE neb_var_create
     132              : 
     133              : ! **************************************************************************************************
     134              : !> \brief Releases a variable type for BAND calculation
     135              : !> \param neb_var ...
     136              : !> \date   05.2007
     137              : !> \author Teodoro Laino [tlaino] - University of Zurich
     138              : ! **************************************************************************************************
     139          160 :    SUBROUTINE neb_var_release(neb_var)
     140              :       TYPE(neb_var_type), POINTER                        :: neb_var
     141              : 
     142          160 :       CPASSERT(ASSOCIATED(neb_var))
     143          160 :       IF (ASSOCIATED(neb_var%wrk) .AND. neb_var%in_use == do_band_cartesian) THEN
     144          144 :          IF (.NOT. ASSOCIATED(neb_var%wrk, neb_var%xyz)) DEALLOCATE (neb_var%wrk)
     145              :       END IF
     146          160 :       IF (ASSOCIATED(neb_var%xyz)) THEN
     147          148 :          DEALLOCATE (neb_var%xyz)
     148              :       END IF
     149          160 :       IF (neb_var%in_use == do_band_collective) THEN
     150           16 :          DEALLOCATE (neb_var%int)
     151              :       END IF
     152          160 :       NULLIFY (neb_var%wrk)
     153          160 :       DEALLOCATE (neb_var)
     154              : 
     155          160 :    END SUBROUTINE neb_var_release
     156              : 
     157            0 : END MODULE neb_types
        

Generated by: LCOV version 2.0-1