LCOV - code coverage report
Current view: top level - src - qmmm_types.F (source / functions) Hit Total Coverage
Test: CP2K Regtests (git:4dc10b3) Lines: 18 21 85.7 %
Date: 2024-11-21 06:45:46 Functions: 2 3 66.7 %

          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 Basic container type for QM/MM.
      10             : !> \author Ole Schuett
      11             : ! **************************************************************************************************
      12             : MODULE qmmm_types
      13             :    USE cp_subsys_types,                 ONLY: cp_subsys_type
      14             :    USE fist_energy_types,               ONLY: fist_energy_type
      15             :    USE fist_environment_types,          ONLY: fist_env_get,&
      16             :                                               fist_env_release,&
      17             :                                               fist_environment_type
      18             :    USE kinds,                           ONLY: dp
      19             :    USE qmmm_types_low,                  ONLY: qmmm_env_qm_release,&
      20             :                                               qmmm_env_qm_type
      21             :    USE qs_energy_types,                 ONLY: qs_energy_type
      22             :    USE qs_environment_types,            ONLY: get_qs_env,&
      23             :                                               qs_env_release,&
      24             :                                               qs_environment_type
      25             : #include "./base/base_uses.f90"
      26             : 
      27             :    IMPLICIT NONE
      28             :    PRIVATE
      29             : 
      30             :    CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'qmmm_types'
      31             : 
      32             :    PUBLIC :: qmmm_env_type, qmmm_env_release, qmmm_env_get
      33             : 
      34             :    TYPE qmmm_env_type
      35             :       TYPE(qs_environment_type), POINTER                      :: qs_env => Null()
      36             :       TYPE(fist_environment_type), POINTER                    :: fist_env => Null()
      37             :       TYPE(qmmm_env_qm_type), POINTER                         :: qm => Null()
      38             :    END TYPE qmmm_env_type
      39             : 
      40             : CONTAINS
      41             : 
      42             : ! **************************************************************************************************
      43             : !> \brief ...
      44             : !> \param qmmm_env ...
      45             : !> \param subsys ...
      46             : !> \param potential_energy ...
      47             : !> \param kinetic_energy ...
      48             : ! **************************************************************************************************
      49       63288 :    SUBROUTINE qmmm_env_get(qmmm_env, subsys, potential_energy, kinetic_energy)
      50             :       TYPE(qmmm_env_type), INTENT(IN)                    :: qmmm_env
      51             :       TYPE(cp_subsys_type), OPTIONAL, POINTER            :: subsys
      52             :       REAL(KIND=dp), INTENT(OUT), OPTIONAL               :: potential_energy, kinetic_energy
      53             : 
      54             :       TYPE(fist_energy_type), POINTER                    :: thermo
      55             :       TYPE(qs_energy_type), POINTER                      :: qs_energy
      56             : 
      57       63288 :       NULLIFY (qs_energy, thermo)
      58             : 
      59       63288 :       IF (PRESENT(kinetic_energy)) THEN
      60           0 :          CALL fist_env_get(qmmm_env%fist_env, thermo=thermo)
      61           0 :          kinetic_energy = thermo%kin
      62             :       END IF
      63       63288 :       IF (PRESENT(subsys)) THEN
      64       52208 :          CALL fist_env_get(qmmm_env%fist_env, subsys=subsys)
      65             :       END IF
      66       63288 :       IF (PRESENT(potential_energy)) THEN
      67             :          ! get the underlying energies from primary subsys.  This is the only subsys
      68             :          ! for conventional QM/MM, and force-mixing knows to put relevant energy there.
      69        7306 :          CALL fist_env_get(qmmm_env%fist_env, thermo=thermo)
      70        7306 :          CALL get_qs_env(qmmm_env%qs_env, energy=qs_energy)
      71        7306 :          potential_energy = thermo%pot + qs_energy%total
      72             :       END IF
      73       63288 :    END SUBROUTINE qmmm_env_get
      74             : 
      75             : ! **************************************************************************************************
      76             : !> \brief releases the given qmmm_env (see doc/ReferenceCounting.html)
      77             : !> \param qmmm_env the object to release
      78             : !> \author Ole Schuett
      79             : ! **************************************************************************************************
      80         394 :    SUBROUTINE qmmm_env_release(qmmm_env)
      81             :       TYPE(qmmm_env_type), INTENT(INOUT)                 :: qmmm_env
      82             : 
      83         394 :       CALL qs_env_release(qmmm_env%qs_env)
      84         394 :       DEALLOCATE (qmmm_env%qs_env)
      85         394 :       CALL qmmm_env_qm_release(qmmm_env%qm)
      86         394 :       DEALLOCATE (qmmm_env%qm)
      87         394 :       CALL fist_env_release(qmmm_env%fist_env)
      88         394 :       DEALLOCATE (qmmm_env%fist_env)
      89             : 
      90         394 :    END SUBROUTINE qmmm_env_release
      91             : 
      92           0 : END MODULE qmmm_types

Generated by: LCOV version 1.15