LCOV - code coverage report
Current view: top level - src - fp_types.F (source / functions) Hit Total Coverage
Test: CP2K Regtests (git:34ef472) Lines: 57 59 96.6 %
Date: 2024-04-26 08:30:29 Functions: 4 5 80.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             : !> \brief types used in the flexible partitioning scheme
      10             : !> \par History
      11             : !>      04.2006 [Joost VandeVondele]
      12             : !> \author Joost VandeVondele
      13             : ! **************************************************************************************************
      14             : MODULE fp_types
      15             :    USE cp_log_handling,                 ONLY: cp_get_default_logger,&
      16             :                                               cp_logger_type
      17             :    USE cp_output_handling,              ONLY: cp_print_key_finished_output,&
      18             :                                               cp_print_key_unit_nr
      19             :    USE input_section_types,             ONLY: section_vals_get,&
      20             :                                               section_vals_get_subs_vals,&
      21             :                                               section_vals_release,&
      22             :                                               section_vals_retain,&
      23             :                                               section_vals_type,&
      24             :                                               section_vals_val_get
      25             :    USE kinds,                           ONLY: dp
      26             : #include "./base/base_uses.f90"
      27             : 
      28             :    IMPLICIT NONE
      29             :    PRIVATE
      30             : 
      31             :    PUBLIC :: fp_type
      32             :    PUBLIC :: fp_env_create, fp_env_release, fp_env_read, fp_env_write
      33             : 
      34             :    CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'fp_types'
      35             : 
      36             : ! **************************************************************************************************
      37             :    TYPE fp_type
      38             : 
      39             :       ! input related objects
      40             :       LOGICAL                        :: use_fp
      41             : 
      42             :       INTEGER                        :: central_atom
      43             :       INTEGER, DIMENSION(:), POINTER :: inner_atoms, outer_atoms
      44             :       REAL(KIND=dp)                  :: inner_radius, outer_radius
      45             :       REAL(KIND=dp)                  :: strength, smooth_width
      46             :       LOGICAL                        :: bias
      47             :       REAL(KIND=dp)                  :: temperature
      48             :       TYPE(section_vals_type), POINTER   :: print_section
      49             : 
      50             :       ! computed during runs
      51             :       INTEGER                        :: i1, i2, o1, o2
      52             :       REAL(KIND=dp)                  :: ri1, ri2, ro1, ro2
      53             :       REAL(KIND=dp)                  :: weight, comb_weight, bias_weight
      54             :       REAL(KIND=dp)                  :: energy, bias_energy, restraint_energy
      55             :    END TYPE fp_type
      56             : 
      57             : CONTAINS
      58             : 
      59             : ! **************************************************************************************************
      60             : !> \brief create retain release the flexible partitioning environment
      61             : !> \param fp_env ...
      62             : !> \par History
      63             : !>      04.2006 created [Joost VandeVondele]
      64             : ! **************************************************************************************************
      65        8469 :    PURE SUBROUTINE fp_env_create(fp_env)
      66             :       TYPE(fp_type), INTENT(OUT)                         :: fp_env
      67             : 
      68        8469 :       fp_env%use_fp = .FALSE.
      69        8469 :       NULLIFY (fp_env%inner_atoms)
      70        8469 :       NULLIFY (fp_env%outer_atoms)
      71        8469 :       NULLIFY (fp_env%print_section)
      72             : 
      73        8469 :    END SUBROUTINE fp_env_create
      74             : 
      75             : ! **************************************************************************************************
      76             : !> \brief ...
      77             : !> \param fp_env ...
      78             : ! **************************************************************************************************
      79        8469 :    SUBROUTINE fp_env_release(fp_env)
      80             :       TYPE(fp_type), INTENT(INOUT)                       :: fp_env
      81             : 
      82        8469 :       IF (ASSOCIATED(fp_env%inner_atoms)) DEALLOCATE (fp_env%inner_atoms)
      83        8469 :       IF (ASSOCIATED(fp_env%outer_atoms)) DEALLOCATE (fp_env%outer_atoms)
      84        8469 :       IF (ASSOCIATED(fp_env%print_section)) CALL section_vals_release(fp_env%print_section)
      85        8469 :       fp_env%use_fp = .FALSE.
      86             : 
      87        8469 :    END SUBROUTINE fp_env_release
      88             : 
      89             : ! **************************************************************************************************
      90             : !> \brief reads the corresponding input section and stores it in the fp_env
      91             : !> \param fp_env ...
      92             : !> \param fp_section ...
      93             : !> \par History
      94             : !>      04.2006 created [Joost VandeVondele]
      95             : ! **************************************************************************************************
      96        8469 :    SUBROUTINE fp_env_read(fp_env, fp_section)
      97             :       TYPE(fp_type), INTENT(INOUT)                       :: fp_env
      98             :       TYPE(section_vals_type), POINTER                   :: fp_section
      99             : 
     100             :       CHARACTER(len=*), PARAMETER                        :: routineN = 'fp_env_read'
     101             : 
     102             :       INTEGER                                            :: handle
     103        8469 :       INTEGER, DIMENSION(:), POINTER                     :: tmplist
     104             : 
     105        8469 :       CALL timeset(routineN, handle)
     106        8469 :       CALL section_vals_get(fp_section, explicit=fp_env%use_fp)
     107        8469 :       IF (fp_env%use_fp) THEN
     108           2 :          CALL section_vals_val_get(fp_section, "CENTRAL_ATOM", i_val=fp_env%central_atom)
     109             : 
     110           2 :          CALL section_vals_val_get(fp_section, "INNER_ATOMS", i_vals=tmplist)
     111           6 :          ALLOCATE (fp_env%inner_atoms(SIZE(tmplist, 1)))
     112          18 :          fp_env%inner_atoms = tmplist
     113             : 
     114           2 :          CALL section_vals_val_get(fp_section, "OUTER_ATOMS", i_vals=tmplist)
     115           6 :          ALLOCATE (fp_env%outer_atoms(SIZE(tmplist, 1)))
     116          48 :          fp_env%outer_atoms = tmplist
     117             : 
     118           2 :          CALL section_vals_val_get(fp_section, "INNER_RADIUS", r_val=fp_env%inner_radius)
     119           2 :          CALL section_vals_val_get(fp_section, "OUTER_RADIUS", r_val=fp_env%outer_radius)
     120           2 :          CALL section_vals_val_get(fp_section, "STRENGTH", r_val=fp_env%strength)
     121           2 :          CALL section_vals_val_get(fp_section, "SMOOTH_WIDTH", r_val=fp_env%smooth_width)
     122           2 :          CALL section_vals_val_get(fp_section, "BIAS", l_val=fp_env%bias)
     123           2 :          CALL section_vals_val_get(fp_section, "TEMPERATURE", r_val=fp_env%temperature)
     124             : 
     125           2 :          fp_env%print_section => section_vals_get_subs_vals(fp_section, "WEIGHTS")
     126           2 :          CALL section_vals_retain(fp_env%print_section)
     127             :       END IF
     128        8469 :       CALL timestop(handle)
     129             : 
     130        8469 :    END SUBROUTINE fp_env_read
     131             : 
     132             : ! **************************************************************************************************
     133             : !> \brief writes information concerning the fp_env to the output
     134             : !> \param fp_env ...
     135             : !> \param fp_section ...
     136             : !> \par History
     137             : !>      04.2006 created [Joost VandeVondele]
     138             : ! **************************************************************************************************
     139        8469 :    SUBROUTINE fp_env_write(fp_env, fp_section)
     140             :       TYPE(fp_type), INTENT(IN)                          :: fp_env
     141             :       TYPE(section_vals_type), POINTER                   :: fp_section
     142             : 
     143             :       CHARACTER(len=*), PARAMETER                        :: routineN = 'fp_env_write'
     144             : 
     145             :       INTEGER                                            :: handle, output_unit
     146             :       TYPE(cp_logger_type), POINTER                      :: logger
     147             :       TYPE(section_vals_type), POINTER                   :: PRINT
     148             : 
     149        8469 :       CALL timeset(routineN, handle)
     150        8469 :       logger => cp_get_default_logger()
     151             : 
     152        8469 :       IF (fp_env%use_fp) THEN
     153           2 :          PRINT => section_vals_get_subs_vals(fp_section, "CONTROL")
     154           2 :          output_unit = cp_print_key_unit_nr(logger, PRINT, "", extension=".Log")
     155           2 :          IF (output_unit > 0) THEN
     156             :             WRITE (UNIT=output_unit, FMT="(T2,A,T79,A)") &
     157           1 :                "FP| Flexible partitioning is ", "ON"
     158             :             WRITE (UNIT=output_unit, FMT="(T2,A,T71,I10)") &
     159           1 :                "FP| Central atom ", fp_env%central_atom
     160             :             WRITE (UNIT=output_unit, FMT="(T2,A,T71,I10)") &
     161           1 :                "FP| number of inner atoms", SIZE(fp_env%inner_atoms, 1)
     162           9 :             WRITE (UNIT=output_unit, FMT="(1(T2,8I8))") fp_env%inner_atoms
     163             :             WRITE (UNIT=output_unit, FMT="(T2,A,T71,I10)") &
     164           1 :                "FP| number of outer atoms", SIZE(fp_env%outer_atoms, 1)
     165          24 :             WRITE (UNIT=output_unit, FMT="(1(T2,8I8))") fp_env%outer_atoms
     166             :             WRITE (UNIT=output_unit, FMT="(T2,A,T61,F20.10)") &
     167           1 :                "FP| inner radius [a.u.] ", fp_env%inner_radius
     168             :             WRITE (UNIT=output_unit, FMT="(T2,A,T61,F20.10)") &
     169           1 :                "FP| outer radius [a.u.] ", fp_env%outer_radius
     170             :             WRITE (UNIT=output_unit, FMT="(T2,A,T61,F20.10)") &
     171           1 :                "FP| reflecting restraint strength ", fp_env%strength
     172           1 :             IF (fp_env%bias) THEN
     173             :                WRITE (UNIT=output_unit, FMT="(T2,A,T79,A)") &
     174           1 :                   "FP| Flexible partitioning bias is ", "ON"
     175             :                WRITE (UNIT=output_unit, FMT="(T2,A,T61,F20.10)") &
     176           1 :                   "FP| bias temperature [kT a.u.]", fp_env%temperature
     177             :                WRITE (UNIT=output_unit, FMT="(T2,A,T61,F20.10)") &
     178           1 :                   "FP| smooth width [a.u.] ", fp_env%smooth_width
     179             :             ELSE
     180             :                WRITE (UNIT=output_unit, FMT="(T2,A,T78,A)") &
     181           0 :                   "FP| Flexible partitioning bias is", "OFF"
     182             :             END IF
     183             :          END IF
     184           2 :          CALL cp_print_key_finished_output(output_unit, logger, PRINT, "")
     185             :       END IF
     186        8469 :       CALL timestop(handle)
     187             : 
     188        8469 :    END SUBROUTINE fp_env_write
     189             : 
     190           0 : END MODULE fp_types

Generated by: LCOV version 1.15