LCOV - code coverage report
Current view: top level - src/subsys - force_field_kind_types.F (source / functions) Coverage Total Hit
Test: CP2K Regtests (git:ce05c02) Lines: 98.3 % 59 58
Test Date: 2026-03-11 06:44:16 Functions: 61.1 % 18 11

            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 Define all structure types related to force field kinds
      10              : !> \par History
      11              : !>      10.2014 Moved kind types out of force_field_types.F [Ole Schuett]
      12              : !> \author Ole Schuett
      13              : ! **************************************************************************************************
      14              : MODULE force_field_kind_types
      15              : 
      16              :    USE kinds,                           ONLY: dp
      17              : #include "../base/base_uses.f90"
      18              : 
      19              :    IMPLICIT NONE
      20              : 
      21              :    PRIVATE
      22              : 
      23              :    CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'force_field_kind_types'
      24              : 
      25              :    INTEGER, PARAMETER, PUBLIC               :: do_ff_undef = 0, &
      26              :                                                do_ff_quartic = 1, &
      27              :                                                do_ff_g96 = 2, &
      28              :                                                do_ff_charmm = 3, &
      29              :                                                do_ff_harmonic = 4, &
      30              :                                                do_ff_g87 = 5, &
      31              :                                                do_ff_morse = 6, &
      32              :                                                do_ff_cubic = 7, &
      33              :                                                do_ff_mixed_bend_stretch = 8, &
      34              :                                                do_ff_amber = 9, &
      35              :                                                do_ff_mm2 = 10, &
      36              :                                                do_ff_mm3 = 11, &
      37              :                                                do_ff_mm4 = 12, &
      38              :                                                do_ff_fues = 13, &
      39              :                                                do_ff_legendre = 14, &
      40              :                                                do_ff_opls = 15
      41              : 
      42              : ! *** Define the derived structure types ***
      43              : 
      44              : ! **************************************************************************************************
      45              :    TYPE legendre_data_type
      46              :       INTEGER :: order = 0
      47              :       REAL(KIND=dp), DIMENSION(:), POINTER :: coeffs => NULL()
      48              :    END TYPE legendre_data_type
      49              : 
      50              : ! **************************************************************************************************
      51              :    TYPE bond_kind_type
      52              :       INTEGER                        :: id_type = do_ff_undef
      53              :       REAL(KIND=dp)                :: k(3) = 0.0_dp, r0 = 0.0_dp, cs = 0.0_dp
      54              :       INTEGER                        :: kind_number = 0
      55              :    END TYPE bond_kind_type
      56              : 
      57              : ! **************************************************************************************************
      58              :    TYPE bend_kind_type
      59              :       INTEGER                        :: id_type = do_ff_undef
      60              :       REAL(KIND=dp)                :: k = 0.0_dp, theta0 = 0.0_dp, cb = 0.0_dp
      61              :       REAL(KIND=dp)                :: r012 = 0.0_dp, r032 = 0.0_dp, kbs12 = 0.0_dp, kbs32 = 0.0_dp, kss = 0.0_dp
      62              :       TYPE(legendre_data_type)       :: legendre = legendre_data_type()
      63              :       INTEGER                        :: kind_number = 0
      64              :    END TYPE bend_kind_type
      65              : 
      66              : ! **************************************************************************************************
      67              :    TYPE ub_kind_type
      68              :       INTEGER                        :: id_type = do_ff_undef
      69              :       REAL(KIND=dp)                :: k(3) = 0.0_dp, r0 = 0.0_dp
      70              :       INTEGER                        :: kind_number = 0
      71              :    END TYPE ub_kind_type
      72              : 
      73              : ! **************************************************************************************************
      74              :    TYPE torsion_kind_type
      75              :       INTEGER                        :: id_type = do_ff_undef
      76              :       INTEGER                        :: nmul = 0
      77              :       INTEGER, POINTER               :: m(:) => NULL()
      78              :       REAL(KIND=dp), POINTER       :: k(:) => NULL(), phi0(:) => NULL()
      79              :       INTEGER                        :: kind_number = 0
      80              :    END TYPE torsion_kind_type
      81              : 
      82              : ! **************************************************************************************************
      83              :    TYPE impr_kind_type
      84              :       INTEGER                        :: id_type = do_ff_undef
      85              :       REAL(KIND=dp)                :: k = 0.0_dp, phi0 = 0.0_dp
      86              :       INTEGER                        :: kind_number = 0
      87              :    END TYPE impr_kind_type
      88              : 
      89              : ! **************************************************************************************************
      90              :    TYPE opbend_kind_type
      91              :       INTEGER                        :: id_type = do_ff_undef
      92              :       REAL(KIND=dp)                :: k = 0.0_dp, phi0 = 0.0_dp
      93              :       INTEGER                        :: kind_number = 0
      94              :    END TYPE opbend_kind_type
      95              : 
      96              : ! *** Public subroutines ***
      97              : 
      98              :    PUBLIC :: allocate_bend_kind_set, &
      99              :              allocate_bond_kind_set, &
     100              :              allocate_ub_kind_set, &
     101              :              allocate_torsion_kind_set, &
     102              :              allocate_impr_kind_set, &
     103              :              allocate_opbend_kind_set, &
     104              :              deallocate_bend_kind_set, &
     105              :              deallocate_bond_kind_set, &
     106              :              torsion_kind_dealloc_ref, &
     107              :              impr_kind_dealloc_ref
     108              : 
     109              : ! *** Public data types ***
     110              : 
     111              :    PUBLIC :: bend_kind_type, &
     112              :              bond_kind_type, &
     113              :              impr_kind_type, &
     114              :              torsion_kind_type, &
     115              :              opbend_kind_type, &
     116              :              ub_kind_type, &
     117              :              ub_kind_dealloc_ref, &
     118              :              legendre_data_type
     119              : CONTAINS
     120              : 
     121              : ! **************************************************************************************************
     122              : !> \brief Allocate and initialize a bend kind set.
     123              : !> \param bend_kind_set ...
     124              : !> \param nkind ...
     125              : ! **************************************************************************************************
     126        29707 :    PURE SUBROUTINE allocate_bend_kind_set(bend_kind_set, nkind)
     127              : 
     128              :       TYPE(bend_kind_type), DIMENSION(:), POINTER        :: bend_kind_set
     129              :       INTEGER, INTENT(IN)                                :: nkind
     130              : 
     131              :       INTEGER                                            :: ikind
     132              : 
     133        29707 :       NULLIFY (bend_kind_set)
     134       184417 :       ALLOCATE (bend_kind_set(nkind))
     135       125531 :       DO ikind = 1, nkind
     136       125531 :          bend_kind_set(ikind)%kind_number = ikind
     137              :       END DO
     138        29707 :    END SUBROUTINE allocate_bend_kind_set
     139              : 
     140              : ! **************************************************************************************************
     141              : !> \brief Allocate and initialize a bond kind set.
     142              : !> \param bond_kind_set ...
     143              : !> \param nkind ...
     144              : ! **************************************************************************************************
     145        30235 :    PURE SUBROUTINE allocate_bond_kind_set(bond_kind_set, nkind)
     146              : 
     147              :       TYPE(bond_kind_type), DIMENSION(:), POINTER        :: bond_kind_set
     148              :       INTEGER, INTENT(IN)                                :: nkind
     149              : 
     150              :       INTEGER                                            :: ikind
     151              : 
     152        30235 :       NULLIFY (bond_kind_set)
     153       248175 :       ALLOCATE (bond_kind_set(nkind))
     154        97690 :       DO ikind = 1, nkind
     155        97690 :          bond_kind_set(ikind)%kind_number = ikind
     156              :       END DO
     157        30235 :    END SUBROUTINE allocate_bond_kind_set
     158              : 
     159              : ! **************************************************************************************************
     160              : !> \brief Allocate and initialize a torsion kind set.
     161              : !> \param torsion_kind_set ...
     162              : !> \param nkind ...
     163              : ! **************************************************************************************************
     164         6554 :    PURE SUBROUTINE allocate_torsion_kind_set(torsion_kind_set, nkind)
     165              : 
     166              :       TYPE(torsion_kind_type), DIMENSION(:), POINTER     :: torsion_kind_set
     167              :       INTEGER, INTENT(IN)                                :: nkind
     168              : 
     169              :       INTEGER                                            :: ikind
     170              : 
     171         6554 :       NULLIFY (torsion_kind_set)
     172       114099 :       ALLOCATE (torsion_kind_set(nkind))
     173       101897 :       DO ikind = 1, nkind
     174       101897 :          torsion_kind_set(ikind)%kind_number = ikind
     175              :       END DO
     176         6554 :    END SUBROUTINE allocate_torsion_kind_set
     177              : 
     178              : ! **************************************************************************************************
     179              : !> \brief Allocate and initialize a ub kind set.
     180              : !> \param ub_kind_set ...
     181              : !> \param nkind ...
     182              : ! **************************************************************************************************
     183        58166 :    PURE SUBROUTINE allocate_ub_kind_set(ub_kind_set, nkind)
     184              : 
     185              :       TYPE(ub_kind_type), DIMENSION(:), POINTER          :: ub_kind_set
     186              :       INTEGER, INTENT(IN)                                :: nkind
     187              : 
     188              :       INTEGER                                            :: ikind
     189              : 
     190        58166 :       NULLIFY (ub_kind_set)
     191       424601 :       ALLOCATE (ub_kind_set(nkind))
     192       161306 :       DO ikind = 1, nkind
     193       161306 :          ub_kind_set(ikind)%kind_number = ikind
     194              :       END DO
     195        58166 :    END SUBROUTINE allocate_ub_kind_set
     196              : 
     197              : ! **************************************************************************************************
     198              : !> \brief Allocate and initialize a impr kind set.
     199              : !> \param impr_kind_set ...
     200              : !> \param nkind ...
     201              : ! **************************************************************************************************
     202         2062 :    PURE SUBROUTINE allocate_impr_kind_set(impr_kind_set, nkind)
     203              : 
     204              :       TYPE(impr_kind_type), DIMENSION(:), POINTER        :: impr_kind_set
     205              :       INTEGER, INTENT(IN)                                :: nkind
     206              : 
     207              :       INTEGER                                            :: ikind
     208              : 
     209         2062 :       NULLIFY (impr_kind_set)
     210        10732 :       ALLOCATE (impr_kind_set(nkind))
     211         6894 :       DO ikind = 1, nkind
     212         6894 :          impr_kind_set(ikind)%kind_number = ikind
     213              :       END DO
     214         2062 :    END SUBROUTINE allocate_impr_kind_set
     215              : 
     216              : ! **************************************************************************************************
     217              : !> \brief Allocate and initialize a opbend kind set.
     218              : !> \param opbend_kind_set ...
     219              : !> \param nkind ...
     220              : ! **************************************************************************************************
     221         3342 :    PURE SUBROUTINE allocate_opbend_kind_set(opbend_kind_set, nkind)
     222              : 
     223              :       TYPE(opbend_kind_type), DIMENSION(:), POINTER      :: opbend_kind_set
     224              :       INTEGER, INTENT(IN)                                :: nkind
     225              : 
     226              :       INTEGER                                            :: ikind
     227              : 
     228         3342 :       NULLIFY (opbend_kind_set)
     229        13064 :       ALLOCATE (opbend_kind_set(nkind))
     230         8050 :       DO ikind = 1, nkind
     231         8050 :          opbend_kind_set(ikind)%kind_number = ikind
     232              :       END DO
     233         3342 :    END SUBROUTINE allocate_opbend_kind_set
     234              : 
     235              : ! **************************************************************************************************
     236              : !> \brief Deallocate a bend kind set.
     237              : !> \param bend_kind_set ...
     238              : ! **************************************************************************************************
     239          606 :    PURE SUBROUTINE deallocate_bend_kind_set(bend_kind_set)
     240              : 
     241              :       TYPE(bend_kind_type), DIMENSION(:), POINTER        :: bend_kind_set
     242              : 
     243              :       INTEGER                                            :: i
     244              : 
     245          606 :       IF (.NOT. ASSOCIATED(bend_kind_set)) RETURN
     246         2786 :       DO i = 1, SIZE(bend_kind_set)
     247         2786 :          IF (ASSOCIATED(bend_kind_set(i)%legendre%coeffs)) THEN
     248          254 :             DEALLOCATE (bend_kind_set(i)%legendre%coeffs)
     249              :          END IF
     250              :       END DO
     251          606 :       DEALLOCATE (bend_kind_set)
     252              :    END SUBROUTINE deallocate_bend_kind_set
     253              : 
     254              : ! **************************************************************************************************
     255              : !> \brief Deallocate a bond kind set.
     256              : !> \param bond_kind_set ...
     257              : ! **************************************************************************************************
     258          804 :    PURE SUBROUTINE deallocate_bond_kind_set(bond_kind_set)
     259              : 
     260              :       TYPE(bond_kind_type), DIMENSION(:), POINTER        :: bond_kind_set
     261              : 
     262          804 :       DEALLOCATE (bond_kind_set)
     263              : 
     264          804 :    END SUBROUTINE deallocate_bond_kind_set
     265              : 
     266              : ! **************************************************************************************************
     267              : !> \brief Deallocate a torsion kind element
     268              : !> \param torsion_kind ...
     269              : ! **************************************************************************************************
     270        95343 :    PURE SUBROUTINE torsion_kind_dealloc_ref(torsion_kind)
     271              : 
     272              :       TYPE(torsion_kind_type), INTENT(INOUT)             :: torsion_kind
     273              : 
     274        95343 :       IF (ASSOCIATED(torsion_kind%k)) THEN
     275        82001 :          DEALLOCATE (torsion_kind%k)
     276              :       END IF
     277        95343 :       IF (ASSOCIATED(torsion_kind%m)) THEN
     278        82001 :          DEALLOCATE (torsion_kind%m)
     279              :       END IF
     280        95343 :       IF (ASSOCIATED(torsion_kind%phi0)) THEN
     281        82001 :          DEALLOCATE (torsion_kind%phi0)
     282              :       END IF
     283              : 
     284        95343 :    END SUBROUTINE torsion_kind_dealloc_ref
     285              : 
     286              : ! **************************************************************************************************
     287              : !> \brief Deallocate a ub kind set.
     288              : !> \param ub_kind_set ...
     289              : ! **************************************************************************************************
     290        58166 :    PURE SUBROUTINE ub_kind_dealloc_ref(ub_kind_set)
     291              :       TYPE(ub_kind_type), DIMENSION(:), POINTER          :: ub_kind_set
     292              : 
     293        58166 :       DEALLOCATE (ub_kind_set)
     294              : 
     295        58166 :    END SUBROUTINE ub_kind_dealloc_ref
     296              : 
     297              : ! **************************************************************************************************
     298              : !> \brief Deallocate a impr kind element
     299              : ! **************************************************************************************************
     300         4832 :    PURE SUBROUTINE impr_kind_dealloc_ref()
     301              : 
     302              : !
     303              : ! Questa e' la migliore routine che mente umana abbia concepito! ;-)
     304              : ! Translation to english: This is the best subroutine that humanity can imagine! ;-)
     305              : !
     306              : 
     307         4832 :    END SUBROUTINE impr_kind_dealloc_ref
     308              : 
     309            0 : END MODULE force_field_kind_types
        

Generated by: LCOV version 2.0-1