LCOV - code coverage report
Current view: top level - src/motion - pint_transformations.F (source / functions) Coverage Total Hit
Test: CP2K Regtests (git:42dac4a) Lines: 91.2 % 34 31
Test Date: 2025-07-25 12:55:17 Functions: 100.0 % 3 3

            Line data    Source code
       1              : !--------------------------------------------------------------------------------------------------!
       2              : !   CP2K: A general program to perform molecular dynamics simulations                              !
       3              : !   Copyright 2000-2025 CP2K developers group <https://cp2k.org>                                   !
       4              : !                                                                                                  !
       5              : !   SPDX-License-Identifier: GPL-2.0-or-later                                                      !
       6              : !--------------------------------------------------------------------------------------------------!
       7              : 
       8              : MODULE pint_transformations
       9              :    USE input_constants,                 ONLY: transformation_stage
      10              :    USE kinds,                           ONLY: dp
      11              :    USE pint_normalmode,                 ONLY: normalmode_f2uf,&
      12              :                                               normalmode_u2x,&
      13              :                                               normalmode_x2u
      14              :    USE pint_staging,                    ONLY: staging_f2uf,&
      15              :                                               staging_u2x,&
      16              :                                               staging_x2u
      17              :    USE pint_types,                      ONLY: pint_env_type
      18              : #include "../base/base_uses.f90"
      19              : 
      20              :    IMPLICIT NONE
      21              : 
      22              :    PRIVATE
      23              :    LOGICAL, PRIVATE, PARAMETER :: debug_this_module = .TRUE.
      24              :    CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'pint_transformations'
      25              : 
      26              :    PUBLIC :: pint_x2u, &
      27              :              pint_u2x, &
      28              :              pint_f2uf
      29              : 
      30              : CONTAINS
      31              : 
      32              : ! ***************************************************************************
      33              : !> \brief Transforms from the x into the u variables
      34              : !>      (at the moment a staging transformation for the positions)
      35              : !> \param pint_env the path integral environment
      36              : !> \param ux will contain the u variable (defaults to pint_env%ux)
      37              : !> \param x the positions to transform (defaults to pint_env%x)
      38              : !> \par History
      39              : !>      Added normal mode transformation [hforbert]
      40              : !> \author fawzi
      41              : ! **************************************************************************************************
      42           95 :    SUBROUTINE pint_x2u(pint_env, ux, x)
      43              :       TYPE(pint_env_type), INTENT(IN)                    :: pint_env
      44              :       REAL(kind=dp), DIMENSION(:, :), INTENT(out), &
      45              :          OPTIONAL, TARGET                                :: ux
      46              :       REAL(kind=dp), DIMENSION(:, :), INTENT(in), &
      47              :          OPTIONAL, TARGET                                :: x
      48              : 
      49              :       REAL(kind=dp), DIMENSION(:, :), POINTER            :: my_ux, my_x
      50              : 
      51           95 :       my_x => pint_env%x
      52           95 :       my_ux => pint_env%ux
      53           95 :       IF (PRESENT(x)) my_x => x
      54           95 :       IF (PRESENT(ux)) my_ux => ux
      55           95 :       CPASSERT(ASSOCIATED(my_ux))
      56           95 :       CPASSERT(ASSOCIATED(my_x))
      57              : 
      58           95 :       IF (pint_env%transform == transformation_stage) THEN
      59            0 :          CALL staging_x2u(pint_env%staging_env, ux=my_ux, x=my_x)
      60              :       ELSE
      61           95 :          CALL normalmode_x2u(pint_env%normalmode_env, ux=my_ux, x=my_x)
      62              :       END IF
      63           95 :    END SUBROUTINE pint_x2u
      64              : 
      65              : ! ***************************************************************************
      66              : !> \brief transform from the u variable to the x (inverse of x2u)
      67              : !> \param pint_env path integral environment
      68              : !> \param ux the u variable (positions to be backtransformed)
      69              : !> \param x will contain the positions
      70              : !> \par History
      71              : !>      Added normal mode transformation by hforbert
      72              : !> \author fawzi
      73              : ! **************************************************************************************************
      74         2243 :    SUBROUTINE pint_u2x(pint_env, ux, x)
      75              :       TYPE(pint_env_type), INTENT(IN)                    :: pint_env
      76              :       REAL(kind=dp), DIMENSION(:, :), INTENT(in), &
      77              :          OPTIONAL, TARGET                                :: ux
      78              :       REAL(kind=dp), DIMENSION(:, :), INTENT(out), &
      79              :          OPTIONAL, TARGET                                :: x
      80              : 
      81              :       REAL(kind=dp), DIMENSION(:, :), POINTER            :: my_ux, my_x
      82              : 
      83         2243 :       my_x => pint_env%x
      84         2243 :       my_ux => pint_env%ux
      85         2243 :       IF (PRESENT(x)) my_x => x
      86         2243 :       IF (PRESENT(ux)) my_ux => ux
      87         2243 :       CPASSERT(ASSOCIATED(my_ux))
      88         2243 :       CPASSERT(ASSOCIATED(my_x))
      89              : 
      90         2243 :       IF (pint_env%transform == transformation_stage) THEN
      91            0 :          CALL staging_u2x(pint_env%staging_env, ux=my_ux, x=my_x)
      92              :       ELSE
      93         2243 :          CALL normalmode_u2x(pint_env%normalmode_env, ux=my_ux, x=my_x)
      94              :       END IF
      95         2243 :    END SUBROUTINE pint_u2x
      96              : 
      97              : ! ***************************************************************************
      98              : !> \brief transformation x to u for the forces
      99              : !> \param pint_env the path integral environment
     100              : !> \param uf will contain the accelerations for the transformed variables
     101              : !>        afterwards
     102              : !> \param f the forces to transform
     103              : !> \par History
     104              : !>      Added normal mode transformation [hforbert]
     105              : !>      Divide forces by the number of beads, since the replication
     106              : !>        environment (should) give raw forces [hforbert]
     107              : !> \author fawzi
     108              : ! **************************************************************************************************
     109          510 :    SUBROUTINE pint_f2uf(pint_env, uf, f)
     110              :       TYPE(pint_env_type), INTENT(IN)                    :: pint_env
     111              :       REAL(kind=dp), DIMENSION(:, :), INTENT(out), &
     112              :          OPTIONAL, TARGET                                :: uf
     113              :       REAL(kind=dp), DIMENSION(:, :), INTENT(in), &
     114              :          OPTIONAL, TARGET                                :: f
     115              : 
     116              :       REAL(kind=dp), DIMENSION(:, :), POINTER            :: my_f, my_uf
     117              : 
     118          510 :       my_f => pint_env%f
     119          510 :       my_uf => pint_env%uf
     120          510 :       IF (PRESENT(f)) my_f => f
     121          510 :       IF (PRESENT(uf)) my_uf => uf
     122          510 :       CPASSERT(ASSOCIATED(my_uf))
     123          510 :       CPASSERT(ASSOCIATED(my_f))
     124              : 
     125          510 :       IF (pint_env%transform == transformation_stage) THEN
     126            0 :          CALL staging_f2uf(pint_env%staging_env, uf=my_uf, f=my_f)
     127              :       ELSE
     128          510 :          CALL normalmode_f2uf(pint_env%normalmode_env, uf=my_uf, f=my_f)
     129              :       END IF
     130              : 
     131      2026338 :       my_uf = my_uf/pint_env%mass_fict*pint_env%propagator%physpotscale
     132          510 :    END SUBROUTINE pint_f2uf
     133              : 
     134              : END MODULE pint_transformations
        

Generated by: LCOV version 2.0-1