LCOV - code coverage report
Current view: top level - src - fist_nonbond_env_types.F (source / functions) Hit Total Coverage
Test: CP2K Regtests (git:4dc10b3) Lines: 197 205 96.1 %
Date: 2024-11-21 06:45:46 Functions: 5 12 41.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             : !> \par History
      10             : !>      none
      11             : !> \author HAF
      12             : ! **************************************************************************************************
      13             : MODULE fist_nonbond_env_types
      14             :    USE atomic_kind_types,               ONLY: atomic_kind_type
      15             :    USE cell_types,                      ONLY: cell_release,&
      16             :                                               cell_type
      17             :    USE deepmd_wrapper,                  ONLY: deepmd_model_release,&
      18             :                                               deepmd_model_type
      19             :    USE fist_neighbor_list_types,        ONLY: fist_neighbor_deallocate,&
      20             :                                               fist_neighbor_type
      21             :    USE kinds,                           ONLY: default_string_length,&
      22             :                                               dp
      23             :    USE pair_potential_types,            ONLY: gal21_type,&
      24             :                                               gal_type,&
      25             :                                               nequip_type,&
      26             :                                               pair_potential_pp_release,&
      27             :                                               pair_potential_pp_type,&
      28             :                                               siepmann_type,&
      29             :                                               tersoff_type
      30             :    USE torch_api,                       ONLY: torch_model_release,&
      31             :                                               torch_model_type
      32             : #include "./base/base_uses.f90"
      33             : 
      34             :    IMPLICIT NONE
      35             :    PRIVATE
      36             : 
      37             :    CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'fist_nonbond_env_types'
      38             :    PUBLIC :: fist_nonbond_env_type, fist_nonbond_env_set, &
      39             :              fist_nonbond_env_get, fist_nonbond_env_create, &
      40             :              fist_nonbond_env_release, pos_type, eam_type, &
      41             :              quip_data_type, nequip_data_type, allegro_data_type, deepmd_data_type
      42             : 
      43             : ! **************************************************************************************************
      44             :    TYPE pos_type
      45             :       REAL(KIND=dp) :: r(3) = 0.0_dp
      46             :    END TYPE
      47             : 
      48             :    TYPE eam_type
      49             :       REAL(KIND=dp) :: f_embed = 0.0_dp
      50             :       REAL(KIND=dp) :: rho = 0.0_dp
      51             :    END TYPE
      52             : 
      53             :    TYPE quip_data_type
      54             :       INTEGER, POINTER        :: use_indices(:) => NULL()
      55             :       REAL(KIND=dp), POINTER  :: force(:, :) => NULL()
      56             :       REAL(KIND=dp)           :: virial(3, 3) = 0.0_dp
      57             :    END TYPE
      58             : 
      59             :    TYPE nequip_data_type
      60             :       INTEGER, POINTER        :: use_indices(:) => NULL()
      61             :       REAL(KIND=dp), POINTER  :: force(:, :) => NULL()
      62             :       REAL(KIND=dp)           :: virial(3, 3) = 0.0_dp
      63             :       TYPE(torch_model_type)  :: model
      64             :    END TYPE
      65             : 
      66             :    TYPE allegro_data_type
      67             :       INTEGER, POINTER        :: use_indices(:) => NULL()
      68             :       REAL(KIND=dp), POINTER  :: force(:, :) => NULL()
      69             :       REAL(KIND=dp)           :: virial(3, 3) = 0.0_dp
      70             :       TYPE(torch_model_type)  :: model
      71             :    END TYPE
      72             : 
      73             :    TYPE deepmd_data_type
      74             :       INTEGER, POINTER        :: use_indices(:) => NULL()
      75             :       REAL(KIND=dp), POINTER  :: force(:, :) => NULL()
      76             :       REAL(KIND=dp)           :: virial(3, 3) = 0.0_dp
      77             :       TYPE(deepmd_model_type) :: model
      78             :    END TYPE
      79             : 
      80             : ! **************************************************************************************************
      81             :    TYPE fist_nonbond_env_type
      82             :       INTEGER                                    :: natom_types = -1
      83             :       INTEGER                                    :: counter = -1
      84             :       INTEGER                                    :: last_update = -1
      85             :       INTEGER                                    :: num_update = -1
      86             :       LOGICAL                                    :: do_nonbonded = .FALSE.
      87             :       LOGICAL                                    :: do_electrostatics = .FALSE.
      88             :       LOGICAL                                    :: shift_cutoff = .FALSE.
      89             :       CHARACTER(len=default_string_length)       :: unit_type = ""
      90             :       REAL(KIND=dp)                              :: lup = 0.0_dp
      91             :       REAL(KIND=dp)                              :: aup = 0.0_dp
      92             :       REAL(KIND=dp)                              :: ei_scale14 = 0.0_dp
      93             :       REAL(KIND=dp)                              :: vdw_scale14 = 0.0_dp
      94             :       REAL(KIND=dp)                              :: long_range_correction = 0.0_dp
      95             :       REAL(KIND=dp), DIMENSION(:, :), POINTER    :: rlist_cut => NULL()
      96             :       REAL(KIND=dp), DIMENSION(:, :), POINTER    :: rlist_lowsq => NULL()
      97             :       REAL(KIND=dp), DIMENSION(:, :), POINTER    :: ij_kind_full_fac => NULL()
      98             :       REAL(KIND=dp), DIMENSION(:), POINTER       :: charges => NULL()
      99             :       TYPE(fist_neighbor_type), POINTER          :: nonbonded => NULL()
     100             :       TYPE(pair_potential_pp_type), POINTER      :: potparm14 => NULL()
     101             :       TYPE(pair_potential_pp_type), POINTER      :: potparm => NULL()
     102             :       TYPE(cell_type), POINTER                   :: cell_last_update => NULL()
     103             :       TYPE(pos_type), DIMENSION(:), POINTER      :: r_last_update => NULL()
     104             :       TYPE(pos_type), DIMENSION(:), POINTER      :: r_last_update_pbc => NULL()
     105             :       TYPE(pos_type), DIMENSION(:), POINTER      :: rshell_last_update_pbc => NULL()
     106             :       TYPE(pos_type), DIMENSION(:), POINTER      :: rcore_last_update_pbc => NULL()
     107             :       TYPE(eam_type), DIMENSION(:), POINTER      :: eam_data => NULL()
     108             :       TYPE(quip_data_type), POINTER              :: quip_data => NULL()
     109             :       TYPE(deepmd_data_type), POINTER            :: deepmd_data => NULL()
     110             :       TYPE(nequip_data_type), POINTER            :: nequip_data => NULL()
     111             :       TYPE(allegro_data_type), POINTER           :: allegro_data => NULL()
     112             :    END TYPE fist_nonbond_env_type
     113             : 
     114             : CONTAINS
     115             : 
     116             : ! **************************************************************************************************
     117             : !> \brief sets a fist_nonbond_env
     118             : !> \param fist_nonbond_env the object to create
     119             : !> \param potparm14 ...
     120             : !> \param potparm ...
     121             : !> \param nonbonded ...
     122             : !> \param rlist_cut ...
     123             : !> \param rlist_lowsq ...
     124             : !> \param aup ...
     125             : !> \param lup ...
     126             : !> \param ei_scale14 ...
     127             : !> \param vdw_scale14 ...
     128             : !> \param shift_cutoff ...
     129             : !> \param do_electrostatics ...
     130             : !> \param r_last_update ...
     131             : !> \param r_last_update_pbc ...
     132             : !> \param rshell_last_update_pbc ...
     133             : !> \param rcore_last_update_pbc ...
     134             : !> \param cell_last_update ...
     135             : !> \param num_update ...
     136             : !> \param last_update ...
     137             : !> \param counter ...
     138             : !> \param natom_types ...
     139             : !> \param long_range_correction ...
     140             : !> \param ij_kind_full_fac ...
     141             : !> \param eam_data ...
     142             : !> \param quip_data ...
     143             : !> \param nequip_data ...
     144             : !> \param allegro_data ...
     145             : !> \param deepmd_data ...
     146             : !> \param charges ...
     147             : !> \par History
     148             : !>      12.2002 created [fawzi]
     149             : !> \author Fawzi Mohamed
     150             : ! **************************************************************************************************
     151      551609 :    SUBROUTINE fist_nonbond_env_get(fist_nonbond_env, potparm14, potparm, &
     152             :                                    nonbonded, rlist_cut, rlist_lowsq, aup, lup, ei_scale14, vdw_scale14, &
     153             :                                    shift_cutoff, do_electrostatics, r_last_update, r_last_update_pbc, rshell_last_update_pbc, &
     154             :                                    rcore_last_update_pbc, cell_last_update, num_update, last_update, &
     155             :                                    counter, natom_types, long_range_correction, ij_kind_full_fac, eam_data, &
     156             :                                    quip_data, nequip_data, allegro_data, deepmd_data, charges)
     157             : 
     158             :       TYPE(fist_nonbond_env_type), INTENT(IN)            :: fist_nonbond_env
     159             :       TYPE(pair_potential_pp_type), OPTIONAL, POINTER    :: potparm14, potparm
     160             :       TYPE(fist_neighbor_type), OPTIONAL, POINTER        :: nonbonded
     161             :       REAL(KIND=dp), DIMENSION(:, :), OPTIONAL, POINTER  :: rlist_cut, rlist_lowsq
     162             :       REAL(KIND=dp), OPTIONAL                            :: aup, lup, ei_scale14, vdw_scale14
     163             :       LOGICAL, INTENT(OUT), OPTIONAL                     :: shift_cutoff, do_electrostatics
     164             :       TYPE(pos_type), DIMENSION(:), OPTIONAL, POINTER    :: r_last_update, r_last_update_pbc, &
     165             :                                                             rshell_last_update_pbc, &
     166             :                                                             rcore_last_update_pbc
     167             :       TYPE(cell_type), OPTIONAL, POINTER                 :: cell_last_update
     168             :       INTEGER, OPTIONAL                                  :: num_update, last_update, counter, &
     169             :                                                             natom_types
     170             :       REAL(KIND=dp), OPTIONAL                            :: long_range_correction
     171             :       REAL(KIND=dp), DIMENSION(:, :), OPTIONAL, POINTER  :: ij_kind_full_fac
     172             :       TYPE(eam_type), DIMENSION(:), OPTIONAL, POINTER    :: eam_data
     173             :       TYPE(quip_data_type), OPTIONAL, POINTER            :: quip_data
     174             :       TYPE(nequip_data_type), OPTIONAL, POINTER          :: nequip_data
     175             :       TYPE(allegro_data_type), OPTIONAL, POINTER         :: allegro_data
     176             :       TYPE(deepmd_data_type), OPTIONAL, POINTER          :: deepmd_data
     177             :       REAL(KIND=dp), DIMENSION(:), OPTIONAL, POINTER     :: charges
     178             : 
     179      551609 :       IF (PRESENT(charges)) charges => fist_nonbond_env%charges
     180      551609 :       IF (PRESENT(potparm14)) potparm14 => fist_nonbond_env%potparm14
     181      551609 :       IF (PRESENT(eam_data)) eam_data => fist_nonbond_env%eam_data
     182      551609 :       IF (PRESENT(quip_data)) quip_data => fist_nonbond_env%quip_data
     183      551609 :       IF (PRESENT(nequip_data)) nequip_data => fist_nonbond_env%nequip_data
     184      551609 :       IF (PRESENT(allegro_data)) allegro_data => fist_nonbond_env%allegro_data
     185      551609 :       IF (PRESENT(deepmd_data)) deepmd_data => fist_nonbond_env%deepmd_data
     186      551609 :       IF (PRESENT(potparm)) potparm => fist_nonbond_env%potparm
     187      551609 :       IF (PRESENT(rlist_cut)) rlist_cut => fist_nonbond_env%rlist_cut
     188      551609 :       IF (PRESENT(rlist_lowsq)) rlist_lowsq => fist_nonbond_env%rlist_lowsq
     189      551609 :       IF (PRESENT(ij_kind_full_fac)) ij_kind_full_fac => fist_nonbond_env%ij_kind_full_fac
     190      551609 :       IF (PRESENT(nonbonded)) nonbonded => fist_nonbond_env%nonbonded
     191      551609 :       IF (PRESENT(r_last_update)) &
     192      247529 :          r_last_update => fist_nonbond_env%r_last_update
     193      551609 :       IF (PRESENT(r_last_update_pbc)) &
     194      399767 :          r_last_update_pbc => fist_nonbond_env%r_last_update_pbc
     195      551609 :       IF (PRESENT(rshell_last_update_pbc)) &
     196      163212 :          rshell_last_update_pbc => fist_nonbond_env%rshell_last_update_pbc
     197      551609 :       IF (PRESENT(rcore_last_update_pbc)) &
     198      163212 :          rcore_last_update_pbc => fist_nonbond_env%rcore_last_update_pbc
     199      551609 :       IF (PRESENT(cell_last_update)) &
     200       82421 :          cell_last_update => fist_nonbond_env%cell_last_update
     201      551609 :       IF (PRESENT(lup)) lup = fist_nonbond_env%lup
     202      551609 :       IF (PRESENT(aup)) aup = fist_nonbond_env%aup
     203      551609 :       IF (PRESENT(ei_scale14)) ei_scale14 = fist_nonbond_env%ei_scale14
     204      551609 :       IF (PRESENT(vdw_scale14)) vdw_scale14 = fist_nonbond_env%vdw_scale14
     205      551609 :       IF (PRESENT(shift_cutoff)) &
     206           0 :          shift_cutoff = fist_nonbond_env%shift_cutoff
     207      551609 :       IF (PRESENT(do_electrostatics)) do_electrostatics = fist_nonbond_env%do_electrostatics
     208      551609 :       IF (PRESENT(natom_types)) natom_types = fist_nonbond_env%natom_types
     209      551609 :       IF (PRESENT(counter)) counter = fist_nonbond_env%counter
     210      551609 :       IF (PRESENT(last_update)) last_update = fist_nonbond_env%last_update
     211      551609 :       IF (PRESENT(num_update)) num_update = fist_nonbond_env%num_update
     212      551609 :       IF (PRESENT(long_range_correction)) &
     213           0 :          long_range_correction = fist_nonbond_env%long_range_correction
     214      551609 :    END SUBROUTINE fist_nonbond_env_get
     215             : 
     216             : ! **************************************************************************************************
     217             : !> \brief sets a fist_nonbond_env
     218             : !> \param fist_nonbond_env the object to create
     219             : !> \param potparm14 ...
     220             : !> \param potparm ...
     221             : !> \param rlist_cut ...
     222             : !> \param rlist_lowsq ...
     223             : !> \param nonbonded ...
     224             : !> \param aup ...
     225             : !> \param lup ...
     226             : !> \param ei_scale14 ...
     227             : !> \param vdw_scale14 ...
     228             : !> \param shift_cutoff ...
     229             : !> \param do_electrostatics ...
     230             : !> \param r_last_update ...
     231             : !> \param r_last_update_pbc ...
     232             : !> \param rshell_last_update_pbc ...
     233             : !> \param rcore_last_update_pbc ...
     234             : !> \param cell_last_update ...
     235             : !> \param num_update ...
     236             : !> \param last_update ...
     237             : !> \param counter ...
     238             : !> \param natom_types ...
     239             : !> \param long_range_correction ...
     240             : !> \param eam_data ...
     241             : !> \param quip_data ...
     242             : !> \param nequip_data ...
     243             : !> \param allegro_data ...
     244             : !> \param deepmd_data ...
     245             : !> \param charges ...
     246             : !> \par History
     247             : !>      12.2002 created [fawzi]
     248             : !> \author Fawzi Mohamed
     249             : ! **************************************************************************************************
     250       96101 :    SUBROUTINE fist_nonbond_env_set(fist_nonbond_env, potparm14, potparm, &
     251             :                                    rlist_cut, rlist_lowsq, nonbonded, aup, lup, ei_scale14, vdw_scale14, &
     252             :                                    shift_cutoff, do_electrostatics, r_last_update, r_last_update_pbc, rshell_last_update_pbc, &
     253             :                                    rcore_last_update_pbc, cell_last_update, num_update, last_update, &
     254             :                                    counter, natom_types, long_range_correction, eam_data, quip_data, &
     255             :                                    nequip_data, allegro_data, deepmd_data, charges)
     256             : 
     257             :       TYPE(fist_nonbond_env_type), INTENT(INOUT)         :: fist_nonbond_env
     258             :       TYPE(pair_potential_pp_type), OPTIONAL, POINTER    :: potparm14, potparm
     259             :       REAL(KIND=dp), DIMENSION(:, :), OPTIONAL, POINTER  :: rlist_cut, rlist_lowsq
     260             :       TYPE(fist_neighbor_type), OPTIONAL, POINTER        :: nonbonded
     261             :       REAL(KIND=dp), OPTIONAL                            :: aup, lup, ei_scale14, vdw_scale14
     262             :       LOGICAL, INTENT(IN), OPTIONAL                      :: shift_cutoff, do_electrostatics
     263             :       TYPE(pos_type), DIMENSION(:), OPTIONAL, POINTER    :: r_last_update, r_last_update_pbc, &
     264             :                                                             rshell_last_update_pbc, &
     265             :                                                             rcore_last_update_pbc
     266             :       TYPE(cell_type), OPTIONAL, POINTER                 :: cell_last_update
     267             :       INTEGER, OPTIONAL                                  :: num_update, last_update, counter, &
     268             :                                                             natom_types
     269             :       REAL(KIND=dp), OPTIONAL                            :: long_range_correction
     270             :       TYPE(eam_type), DIMENSION(:), OPTIONAL, POINTER    :: eam_data
     271             :       TYPE(quip_data_type), OPTIONAL, POINTER            :: quip_data
     272             :       TYPE(nequip_data_type), OPTIONAL, POINTER          :: nequip_data
     273             :       TYPE(allegro_data_type), OPTIONAL, POINTER         :: allegro_data
     274             :       TYPE(deepmd_data_type), OPTIONAL, POINTER          :: deepmd_data
     275             :       REAL(KIND=dp), DIMENSION(:), OPTIONAL, POINTER     :: charges
     276             : 
     277       96101 :       IF (PRESENT(potparm14)) fist_nonbond_env%potparm14 => potparm14
     278       96101 :       IF (PRESENT(eam_data)) fist_nonbond_env%eam_data => eam_data
     279       96101 :       IF (PRESENT(quip_data)) fist_nonbond_env%quip_data => quip_data
     280       96101 :       IF (PRESENT(nequip_data)) fist_nonbond_env%nequip_data => nequip_data
     281       96101 :       IF (PRESENT(allegro_data)) fist_nonbond_env%allegro_data => allegro_data
     282       96101 :       IF (PRESENT(deepmd_data)) fist_nonbond_env%deepmd_data => deepmd_data
     283       96101 :       IF (PRESENT(potparm)) fist_nonbond_env%potparm => potparm
     284       96101 :       IF (PRESENT(rlist_cut)) fist_nonbond_env%rlist_cut => rlist_cut
     285       96101 :       IF (PRESENT(charges)) fist_nonbond_env%charges => charges
     286       96101 :       IF (PRESENT(rlist_lowsq)) fist_nonbond_env%rlist_lowsq => rlist_lowsq
     287       96101 :       IF (PRESENT(nonbonded)) fist_nonbond_env%nonbonded => nonbonded
     288       96101 :       IF (PRESENT(r_last_update)) &
     289       11017 :          fist_nonbond_env%r_last_update => r_last_update
     290       96101 :       IF (PRESENT(r_last_update_pbc)) &
     291       11017 :          fist_nonbond_env%r_last_update_pbc => r_last_update_pbc
     292       96101 :       IF (PRESENT(rshell_last_update_pbc)) &
     293       11017 :          fist_nonbond_env%rshell_last_update_pbc => rshell_last_update_pbc
     294       96101 :       IF (PRESENT(rcore_last_update_pbc)) &
     295       11017 :          fist_nonbond_env%rcore_last_update_pbc => rcore_last_update_pbc
     296       96101 :       IF (PRESENT(cell_last_update)) &
     297       11017 :          fist_nonbond_env%cell_last_update => cell_last_update
     298       96101 :       IF (PRESENT(lup)) fist_nonbond_env%lup = lup
     299       96101 :       IF (PRESENT(aup)) fist_nonbond_env%aup = aup
     300       96101 :       IF (PRESENT(ei_scale14)) fist_nonbond_env%ei_scale14 = ei_scale14
     301       96101 :       IF (PRESENT(vdw_scale14)) fist_nonbond_env%vdw_scale14 = vdw_scale14
     302       96101 :       IF (PRESENT(shift_cutoff)) &
     303           0 :          fist_nonbond_env%shift_cutoff = shift_cutoff
     304       96101 :       IF (PRESENT(do_electrostatics)) fist_nonbond_env%do_electrostatics = do_electrostatics
     305       96101 :       IF (PRESENT(natom_types)) fist_nonbond_env%natom_types = natom_types
     306       96101 :       IF (PRESENT(counter)) fist_nonbond_env%counter = counter
     307       96101 :       IF (PRESENT(last_update)) fist_nonbond_env%last_update = last_update
     308       96101 :       IF (PRESENT(num_update)) fist_nonbond_env%num_update = num_update
     309       96101 :       IF (PRESENT(long_range_correction)) &
     310           0 :          fist_nonbond_env%long_range_correction = long_range_correction
     311       96101 :    END SUBROUTINE fist_nonbond_env_set
     312             : 
     313             : ! **************************************************************************************************
     314             : !> \brief allocates and intitializes a fist_nonbond_env
     315             : !> \param fist_nonbond_env the object to create
     316             : !> \param atomic_kind_set ...
     317             : !> \param potparm14 ...
     318             : !> \param potparm ...
     319             : !> \param do_nonbonded ...
     320             : !> \param do_electrostatics ...
     321             : !> \param verlet_skin ...
     322             : !> \param ewald_rcut ...
     323             : !> \param ei_scale14 ...
     324             : !> \param vdw_scale14 ...
     325             : !> \param shift_cutoff ...
     326             : !> \par History
     327             : !>      12.2002 created [fawzi]
     328             : !> \author Fawzi Mohamed
     329             : ! **************************************************************************************************
     330        2671 :    SUBROUTINE fist_nonbond_env_create(fist_nonbond_env, atomic_kind_set, &
     331             :                                       potparm14, potparm, do_nonbonded, do_electrostatics, verlet_skin, ewald_rcut, &
     332             :                                       ei_scale14, vdw_scale14, shift_cutoff)
     333             :       TYPE(fist_nonbond_env_type), INTENT(OUT)           :: fist_nonbond_env
     334             :       TYPE(atomic_kind_type), DIMENSION(:), POINTER      :: atomic_kind_set
     335             :       TYPE(pair_potential_pp_type), OPTIONAL, POINTER    :: potparm14, potparm
     336             :       LOGICAL, INTENT(IN)                                :: do_nonbonded, do_electrostatics
     337             :       REAL(KIND=dp), INTENT(IN)                          :: verlet_skin, ewald_rcut, ei_scale14, &
     338             :                                                             vdw_scale14
     339             :       LOGICAL, INTENT(IN)                                :: shift_cutoff
     340             : 
     341             :       NULLIFY (fist_nonbond_env%potparm14)
     342             :       NULLIFY (fist_nonbond_env%potparm)
     343             :       NULLIFY (fist_nonbond_env%rlist_cut)
     344             :       NULLIFY (fist_nonbond_env%rlist_lowsq)
     345             :       NULLIFY (fist_nonbond_env%ij_kind_full_fac)
     346             :       NULLIFY (fist_nonbond_env%nonbonded)
     347             :       NULLIFY (fist_nonbond_env%cell_last_update)
     348             :       NULLIFY (fist_nonbond_env%r_last_update)
     349             :       NULLIFY (fist_nonbond_env%r_last_update_pbc)
     350             :       NULLIFY (fist_nonbond_env%rshell_last_update_pbc)
     351             :       NULLIFY (fist_nonbond_env%rcore_last_update_pbc)
     352             :       NULLIFY (fist_nonbond_env%eam_data)
     353             :       NULLIFY (fist_nonbond_env%quip_data)
     354             :       NULLIFY (fist_nonbond_env%nequip_data)
     355             :       NULLIFY (fist_nonbond_env%allegro_data)
     356             :       NULLIFY (fist_nonbond_env%deepmd_data)
     357             :       NULLIFY (fist_nonbond_env%charges)
     358             :       CALL init_fist_nonbond_env(fist_nonbond_env, atomic_kind_set, potparm14, &
     359             :                                  potparm, do_nonbonded, do_electrostatics, verlet_skin, ewald_rcut, ei_scale14, &
     360        2671 :                                  vdw_scale14, shift_cutoff)
     361        2671 :    END SUBROUTINE fist_nonbond_env_create
     362             : 
     363             : ! **************************************************************************************************
     364             : !> \brief Purpose: Initialise the FIST nonbond environment.
     365             : !> \param fist_nonbond_env the object to create
     366             : !> \param atomic_kind_set ...
     367             : !> \param potparm14 ...
     368             : !> \param potparm ...
     369             : !> \param do_nonbonded ...
     370             : !> \param do_electrostatics ...
     371             : !> \param verlet_skin ...
     372             : !> \param ewald_rcut ...
     373             : !> \param ei_scale14 ...
     374             : !> \param vdw_scale14 ...
     375             : !> \param shift_cutoff ...
     376             : ! **************************************************************************************************
     377        2671 :    SUBROUTINE init_fist_nonbond_env(fist_nonbond_env, atomic_kind_set, &
     378             :                                     potparm14, potparm, do_nonbonded, do_electrostatics, verlet_skin, ewald_rcut, ei_scale14, &
     379             :                                     vdw_scale14, shift_cutoff)
     380             : 
     381             :       TYPE(fist_nonbond_env_type), INTENT(INOUT)         :: fist_nonbond_env
     382             :       TYPE(atomic_kind_type), DIMENSION(:), POINTER      :: atomic_kind_set
     383             :       TYPE(pair_potential_pp_type), OPTIONAL, POINTER    :: potparm14, potparm
     384             :       LOGICAL, INTENT(IN)                                :: do_nonbonded, do_electrostatics
     385             :       REAL(KIND=dp), INTENT(IN)                          :: verlet_skin, ewald_rcut, ei_scale14, &
     386             :                                                             vdw_scale14
     387             :       LOGICAL, INTENT(IN)                                :: shift_cutoff
     388             : 
     389             :       INTEGER                                            :: idim, jdim, natom_types
     390             :       LOGICAL                                            :: check, use_potparm, use_potparm14
     391             :       REAL(KIND=dp)                                      :: fac, rcut, rlow
     392             : 
     393        2671 :       use_potparm14 = PRESENT(potparm14)
     394        2671 :       IF (use_potparm14) use_potparm14 = use_potparm14 .OR. ASSOCIATED(potparm14)
     395        2671 :       use_potparm = PRESENT(potparm)
     396        2671 :       IF (use_potparm) use_potparm = use_potparm .OR. ASSOCIATED(potparm)
     397        2671 :       NULLIFY (fist_nonbond_env%nonbonded)
     398        2671 :       NULLIFY (fist_nonbond_env%r_last_update)
     399        2671 :       NULLIFY (fist_nonbond_env%r_last_update_pbc)
     400        2671 :       NULLIFY (fist_nonbond_env%rshell_last_update_pbc)
     401        2671 :       NULLIFY (fist_nonbond_env%rcore_last_update_pbc)
     402        2671 :       NULLIFY (fist_nonbond_env%cell_last_update)
     403        2671 :       NULLIFY (fist_nonbond_env%rlist_cut)
     404        2671 :       NULLIFY (fist_nonbond_env%rlist_lowsq)
     405        2671 :       NULLIFY (fist_nonbond_env%ij_kind_full_fac)
     406        2671 :       fist_nonbond_env%unit_type = "ANGSTROM"
     407        2671 :       fist_nonbond_env%do_nonbonded = do_nonbonded
     408        2671 :       fist_nonbond_env%do_electrostatics = do_electrostatics
     409        2671 :       fist_nonbond_env%lup = 0
     410        2671 :       fist_nonbond_env%aup = 0
     411        2671 :       fist_nonbond_env%ei_scale14 = ei_scale14
     412        2671 :       fist_nonbond_env%vdw_scale14 = vdw_scale14
     413        2671 :       fist_nonbond_env%shift_cutoff = shift_cutoff
     414        2671 :       fist_nonbond_env%counter = 0
     415        2671 :       fist_nonbond_env%last_update = 0
     416        2671 :       fist_nonbond_env%num_update = 0
     417        2671 :       fist_nonbond_env%long_range_correction = 0
     418        2671 :       IF (do_nonbonded) THEN
     419        2655 :          natom_types = 1
     420             :          ! Determine size of kind arrays
     421        2655 :          natom_types = SIZE(atomic_kind_set)
     422        2655 :          IF (use_potparm14) THEN
     423        2623 :             check = (SIZE(potparm14%pot, 1) == natom_types)
     424        2623 :             CPASSERT(check)
     425             :          END IF
     426        2655 :          IF (use_potparm) THEN
     427        2623 :             check = (SIZE(potparm%pot, 1) == natom_types)
     428        2623 :             CPASSERT(check)
     429             :          END IF
     430       10620 :          ALLOCATE (fist_nonbond_env%rlist_cut(natom_types, natom_types))
     431        7965 :          ALLOCATE (fist_nonbond_env%rlist_lowsq(natom_types, natom_types))
     432        7965 :          ALLOCATE (fist_nonbond_env%ij_kind_full_fac(natom_types, natom_types))
     433      518203 :          fist_nonbond_env%ij_kind_full_fac = 1.0_dp
     434       13904 :          DO idim = 1, natom_types
     435      271678 :             DO jdim = idim, natom_types
     436      269023 :                IF ((use_potparm) .OR. (use_potparm14)) THEN
     437      257694 :                   IF (use_potparm) THEN
     438      257694 :                      rcut = SQRT(potparm%pot(idim, jdim)%pot%rcutsq)
     439      257694 :                      fac = potparm%pot(idim, jdim)%pot%spl_f%rscale(1)
     440      257694 :                      rlow = fac/(potparm%pot(idim, jdim)%pot%pair_spline_data(1)%spline_data%xn)
     441             :                   ELSE
     442           0 :                      rcut = SQRT(potparm14%pot(idim, jdim)%pot%rcutsq)
     443           0 :                      fac = potparm14%pot(idim, jdim)%pot%spl_f%rscale(1)
     444           0 :                      rlow = fac/(potparm14%pot(idim, jdim)%pot%pair_spline_data(1)%spline_data%xn)
     445             :                   END IF
     446             :                   ! Warning: rlist_rcut should only be used by the neighbor list
     447             :                   ! algorithm. It is not the cutoff for the evaluation of the
     448             :                   ! interactions because rlist_rcut includes the Verlet skin.
     449      257694 :                   rcut = MAX(rcut, ewald_rcut) + verlet_skin
     450      257694 :                   fist_nonbond_env%rlist_cut(idim, jdim) = rcut
     451      257694 :                   fist_nonbond_env%rlist_cut(jdim, idim) = rcut
     452      257694 :                   rlow = rlow*(1.06_dp)**2 ! 1.06_dp in order to have 1/2 Emax_spline
     453      257694 :                   fist_nonbond_env%rlist_lowsq(idim, jdim) = rlow
     454      257694 :                   fist_nonbond_env%rlist_lowsq(jdim, idim) = rlow
     455             :                   ! In case of manybody potential the neighbor list will be full.
     456             :                   ! This means that for each atom pair (a,b) of the current types,
     457             :                   ! atom a is in the neighbor list of b and b is in the neighbor
     458             :                   ! list of a. ij_kind_full_fac is used to correct for the double
     459             :                   ! counting in the conventional pair potentials cause by this
     460             :                   ! situation.
     461      515278 :                   IF (ANY(potparm%pot(idim, jdim)%pot%type == tersoff_type)) THEN
     462             :                      ! TODO: what if 14 is not of tersoff type while the normal
     463             :                      ! nonbond is? (or the reverse). We'd better impose
     464             :                      ! consistency.
     465         118 :                      fist_nonbond_env%ij_kind_full_fac(idim, jdim) = 0.5_dp
     466             :                      fist_nonbond_env%ij_kind_full_fac(idim, jdim) = 0.5_dp
     467             :                   END IF
     468      515391 :                   IF (ANY(potparm%pot(idim, jdim)%pot%type == siepmann_type)) THEN
     469             :                      ! TODO:see tersoff_type
     470           5 :                      fist_nonbond_env%ij_kind_full_fac(idim, jdim) = 0.5_dp
     471             :                      fist_nonbond_env%ij_kind_full_fac(idim, jdim) = 0.5_dp
     472             :                   END IF
     473      515395 :                   IF (ANY(potparm%pot(idim, jdim)%pot%type == gal_type)) THEN
     474           1 :                      fist_nonbond_env%ij_kind_full_fac(idim, jdim) = 0.5_dp
     475             :                      fist_nonbond_env%ij_kind_full_fac(idim, jdim) = 0.5_dp
     476             :                   END IF
     477      515395 :                   IF (ANY(potparm%pot(idim, jdim)%pot%type == gal21_type)) THEN
     478           1 :                      fist_nonbond_env%ij_kind_full_fac(idim, jdim) = 0.5_dp
     479             :                      fist_nonbond_env%ij_kind_full_fac(idim, jdim) = 0.5_dp
     480             :                   END IF
     481      515384 :                   IF (ANY(potparm%pot(idim, jdim)%pot%type == nequip_type)) THEN
     482          12 :                      fist_nonbond_env%ij_kind_full_fac(idim, jdim) = 0.5_dp
     483             :                      fist_nonbond_env%ij_kind_full_fac(idim, jdim) = 0.5_dp
     484             :                   END IF
     485             :                ELSE
     486             :                   ! In case we don't use potparm for initialization let's account
     487             :                   ! only for the real-space part of the Ewald sum.
     488          80 :                   fist_nonbond_env%rlist_cut(idim, jdim) = ewald_rcut
     489          80 :                   fist_nonbond_env%rlist_cut(jdim, idim) = ewald_rcut
     490          80 :                   fist_nonbond_env%rlist_lowsq(idim, jdim) = 0.0_dp
     491          80 :                   fist_nonbond_env%rlist_lowsq(jdim, idim) = 0.0_dp
     492             :                END IF
     493             :             END DO
     494             :          END DO
     495        2655 :          IF (use_potparm14) fist_nonbond_env%potparm14 => potparm14
     496        2655 :          IF (use_potparm) fist_nonbond_env%potparm => potparm
     497        2655 :          fist_nonbond_env%natom_types = natom_types
     498             :       ELSE
     499          16 :          NULLIFY (fist_nonbond_env%potparm)
     500          16 :          NULLIFY (fist_nonbond_env%potparm14)
     501             :       END IF
     502        2671 :    END SUBROUTINE init_fist_nonbond_env
     503             : 
     504             : ! **************************************************************************************************
     505             : !> \brief releases the given fist_nonbond_env (see doc/ReferenceCounting.html)
     506             : !> \param fist_nonbond_env the object to release
     507             : !> \par History
     508             : !>      12.2002 created [fawzi]
     509             : !> \author Fawzi Mohamed
     510             : ! **************************************************************************************************
     511        2671 :    SUBROUTINE fist_nonbond_env_release(fist_nonbond_env)
     512             :       TYPE(fist_nonbond_env_type), INTENT(INOUT)         :: fist_nonbond_env
     513             : 
     514        2671 :       IF (ASSOCIATED(fist_nonbond_env%nonbonded)) THEN
     515        2501 :          CALL fist_neighbor_deallocate(fist_nonbond_env%nonbonded)
     516             :       END IF
     517             :       ! Release potparm
     518        2671 :       CALL pair_potential_pp_release(fist_nonbond_env%potparm)
     519             :       ! Release potparm14
     520        2671 :       CALL pair_potential_pp_release(fist_nonbond_env%potparm14)
     521        2671 :       IF (ASSOCIATED(fist_nonbond_env%r_last_update)) THEN
     522        2501 :          DEALLOCATE (fist_nonbond_env%r_last_update)
     523             :       END IF
     524        2671 :       IF (ASSOCIATED(fist_nonbond_env%r_last_update_pbc)) THEN
     525        2501 :          DEALLOCATE (fist_nonbond_env%r_last_update_pbc)
     526             :       END IF
     527        2671 :       IF (ASSOCIATED(fist_nonbond_env%charges)) THEN
     528           8 :          DEALLOCATE (fist_nonbond_env%charges)
     529             :       END IF
     530        2671 :       IF (ASSOCIATED(fist_nonbond_env%eam_data)) THEN
     531          12 :          DEALLOCATE (fist_nonbond_env%eam_data)
     532             :       END IF
     533        2671 :       IF (ASSOCIATED(fist_nonbond_env%quip_data)) THEN
     534           2 :          IF (ASSOCIATED(fist_nonbond_env%quip_data%force)) THEN
     535           2 :             DEALLOCATE (fist_nonbond_env%quip_data%force)
     536             :          END IF
     537           2 :          IF (ASSOCIATED(fist_nonbond_env%quip_data%use_indices)) THEN
     538           2 :             DEALLOCATE (fist_nonbond_env%quip_data%use_indices)
     539             :          END IF
     540           2 :          DEALLOCATE (fist_nonbond_env%quip_data)
     541             :       END IF
     542        2671 :       IF (ASSOCIATED(fist_nonbond_env%nequip_data)) THEN
     543           4 :          IF (ASSOCIATED(fist_nonbond_env%nequip_data%force)) THEN
     544           4 :             DEALLOCATE (fist_nonbond_env%nequip_data%force)
     545             :          END IF
     546           4 :          IF (ASSOCIATED(fist_nonbond_env%nequip_data%use_indices)) THEN
     547           4 :             DEALLOCATE (fist_nonbond_env%nequip_data%use_indices)
     548             :          END IF
     549           4 :          CALL torch_model_release(fist_nonbond_env%nequip_data%model)
     550           4 :          DEALLOCATE (fist_nonbond_env%nequip_data)
     551             :       END IF
     552        2671 :       IF (ASSOCIATED(fist_nonbond_env%allegro_data)) THEN
     553           4 :          IF (ASSOCIATED(fist_nonbond_env%allegro_data%force)) THEN
     554           4 :             DEALLOCATE (fist_nonbond_env%allegro_data%force)
     555             :          END IF
     556           4 :          IF (ASSOCIATED(fist_nonbond_env%allegro_data%use_indices)) THEN
     557           4 :             DEALLOCATE (fist_nonbond_env%allegro_data%use_indices)
     558             :          END IF
     559           4 :          CALL torch_model_release(fist_nonbond_env%allegro_data%model)
     560           4 :          DEALLOCATE (fist_nonbond_env%allegro_data)
     561             :       END IF
     562        2671 :       IF (ASSOCIATED(fist_nonbond_env%deepmd_data)) THEN
     563           2 :          IF (ASSOCIATED(fist_nonbond_env%deepmd_data%force)) THEN
     564           2 :             DEALLOCATE (fist_nonbond_env%deepmd_data%force)
     565             :          END IF
     566           2 :          IF (ASSOCIATED(fist_nonbond_env%deepmd_data%use_indices)) THEN
     567           2 :             DEALLOCATE (fist_nonbond_env%deepmd_data%use_indices)
     568             :          END IF
     569           2 :          CALL deepmd_model_release(fist_nonbond_env%deepmd_data%model)
     570           2 :          DEALLOCATE (fist_nonbond_env%deepmd_data)
     571             :       END IF
     572        2671 :       IF (ASSOCIATED(fist_nonbond_env%rshell_last_update_pbc)) THEN
     573         244 :          DEALLOCATE (fist_nonbond_env%rshell_last_update_pbc)
     574             :       END IF
     575        2671 :       IF (ASSOCIATED(fist_nonbond_env%rcore_last_update_pbc)) THEN
     576         244 :          DEALLOCATE (fist_nonbond_env%rcore_last_update_pbc)
     577             :       END IF
     578        2671 :       IF (ASSOCIATED(fist_nonbond_env%cell_last_update)) THEN
     579        2501 :          CALL cell_release(fist_nonbond_env%cell_last_update)
     580             :       END IF
     581        2671 :       IF (ASSOCIATED(fist_nonbond_env%ij_kind_full_fac)) THEN
     582        2655 :          DEALLOCATE (fist_nonbond_env%ij_kind_full_fac)
     583             :       END IF
     584        2671 :       IF (ASSOCIATED(fist_nonbond_env%rlist_cut)) THEN
     585        2655 :          DEALLOCATE (fist_nonbond_env%rlist_cut)
     586             :       END IF
     587        2671 :       IF (ASSOCIATED(fist_nonbond_env%rlist_lowsq)) THEN
     588        2655 :          DEALLOCATE (fist_nonbond_env%rlist_lowsq)
     589             :       END IF
     590        2671 :    END SUBROUTINE fist_nonbond_env_release
     591             : 
     592           0 : END MODULE fist_nonbond_env_types

Generated by: LCOV version 1.15