LCOV - code coverage report
Current view: top level - src/subsys - shell_potential_types.F (source / functions) Hit Total Coverage
Test: CP2K Regtests (git:2fce0f8) Lines: 24 25 96.0 %
Date: 2024-12-21 06:28:57 Functions: 3 5 60.0 %

          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             : !> \author MI (12.01.2007)
      10             : ! **************************************************************************************************
      11             : MODULE shell_potential_types
      12             : 
      13             :    USE kinds,                           ONLY: default_string_length,&
      14             :                                               dp
      15             : #include "../base/base_uses.f90"
      16             : 
      17             :    IMPLICIT NONE
      18             : 
      19             :    PRIVATE
      20             : 
      21             : ! Global parameters (only in this module)
      22             : 
      23             :    CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'shell_potential_types'
      24             : 
      25             : ! **************************************************************************************************
      26             : !> \brief Define the shell type
      27             : ! **************************************************************************************************
      28             :    TYPE shell_kind_type
      29             :       REAL(dp)                               :: charge_core = 0.0_dp, &
      30             :                                                 charge_shell = 0.0_dp
      31             :       REAL(dp)                               :: mass_core = 0.0_dp, &
      32             :                                                 massfrac = 0.0_dp, &
      33             :                                                 mass_shell = 0.0_dp
      34             :       REAL(dp)                               :: k2_spring = 0.0_dp, k4_spring = 0.0_dp
      35             :       REAL(dp)                               :: max_dist = 0.0_dp
      36             :       REAL(dp)                               :: shell_cutoff = 0.0_dp
      37             :    END TYPE shell_kind_type
      38             : 
      39             : ! **************************************************************************************************
      40             :    TYPE shell_p_type
      41             :       CHARACTER(LEN=default_string_length)   :: atm_name = ""
      42             :       TYPE(shell_kind_type), POINTER          :: shell => NULL()
      43             :    END TYPE shell_p_type
      44             : 
      45             : ! Public subroutines
      46             : 
      47             :    PUBLIC :: get_shell, shell_p_create, &
      48             :              shell_p_release
      49             : 
      50             : ! Public data types
      51             : 
      52             :    PUBLIC :: shell_p_type, shell_kind_type
      53             : 
      54             : CONTAINS
      55             : 
      56             : ! **************************************************************************************************
      57             : !> \brief ...
      58             : !> \param shell ...
      59             : !> \param charge ...
      60             : !> \param charge_core ...
      61             : !> \param charge_shell ...
      62             : !> \param mass_core ...
      63             : !> \param mass_shell ...
      64             : !> \param k2_spring ...
      65             : !> \param k4_spring ...
      66             : !> \param max_dist ...
      67             : !> \param shell_cutoff ...
      68             : ! **************************************************************************************************
      69       52394 :    ELEMENTAL SUBROUTINE get_shell(shell, charge, charge_core, charge_shell, mass_core, &
      70             :                                   mass_shell, k2_spring, k4_spring, max_dist, shell_cutoff)
      71             : 
      72             :       TYPE(shell_kind_type), INTENT(IN)                  :: shell
      73             :       REAL(KIND=dp), INTENT(OUT), OPTIONAL               :: charge, charge_core, charge_shell, &
      74             :                                                             mass_core, mass_shell, k2_spring, &
      75             :                                                             k4_spring, max_dist, shell_cutoff
      76             : 
      77       52394 :       IF (PRESENT(charge)) charge = shell%charge_core + shell%charge_shell
      78       52394 :       IF (PRESENT(charge_core)) charge_core = shell%charge_core
      79       52394 :       IF (PRESENT(charge_shell)) charge_shell = shell%charge_shell
      80       52394 :       IF (PRESENT(mass_core)) mass_core = shell%mass_core
      81       52394 :       IF (PRESENT(mass_shell)) mass_shell = shell%mass_shell
      82       52394 :       IF (PRESENT(k2_spring)) k2_spring = shell%k2_spring
      83       52394 :       IF (PRESENT(k4_spring)) k4_spring = shell%k4_spring
      84       52394 :       IF (PRESENT(max_dist)) max_dist = shell%max_dist
      85       52394 :       IF (PRESENT(shell_cutoff)) shell_cutoff = shell%shell_cutoff
      86             : 
      87       52394 :    END SUBROUTINE
      88             : 
      89             : ! **************************************************************************************************
      90             : !> \brief ...
      91             : !> \param shell_list ...
      92             : !> \param ndim ...
      93             : ! **************************************************************************************************
      94         258 :    SUBROUTINE shell_p_create(shell_list, ndim)
      95             : 
      96             :       TYPE(shell_p_type), DIMENSION(:), POINTER          :: shell_list
      97             :       INTEGER, INTENT(IN)                                :: ndim
      98             : 
      99             :       INTEGER                                            :: i
     100             : 
     101         258 :       CPASSERT(.NOT. ASSOCIATED(shell_list))
     102        1226 :       ALLOCATE (shell_list(ndim))
     103             : 
     104         710 :       DO i = 1, ndim
     105         710 :          ALLOCATE (shell_list(i)%shell)
     106             :       END DO
     107             : 
     108         258 :    END SUBROUTINE shell_p_create
     109             : 
     110             : ! **************************************************************************************************
     111             : !> \brief ...
     112             : !> \param shell_list ...
     113             : ! **************************************************************************************************
     114         258 :    SUBROUTINE shell_p_release(shell_list)
     115             :       TYPE(shell_p_type), DIMENSION(:), POINTER          :: shell_list
     116             : 
     117             :       INTEGER                                            :: i
     118             : 
     119         258 :       IF (ASSOCIATED(shell_list)) THEN
     120         710 :          DO i = 1, SIZE(shell_list)
     121         710 :             DEALLOCATE (shell_list(i)%shell)
     122             :          END DO
     123         258 :          DEALLOCATE (shell_list)
     124             :       END IF
     125             : 
     126         258 :       NULLIFY (shell_list)
     127             : 
     128         258 :    END SUBROUTINE shell_p_release
     129             : 
     130           0 : END MODULE shell_potential_types

Generated by: LCOV version 1.15