LCOV - code coverage report
Current view: top level - src - iao_types.F (source / functions) Hit Total Coverage
Test: CP2K Regtests (git:4dc10b3) Lines: 59 63 93.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 Calculate ntrinsic atomic orbitals and analyze wavefunctions
      10             : !> \par History
      11             : !>      03.2023 created [JGH]
      12             : !> \author JGH
      13             : ! **************************************************************************************************
      14             : MODULE iao_types
      15             :    USE cell_types,                      ONLY: cell_type
      16             :    USE input_constants,                 ONLY: do_iaoloc_enone,&
      17             :                                               do_iaoloc_pm2
      18             :    USE input_section_types,             ONLY: section_vals_get,&
      19             :                                               section_vals_get_subs_vals,&
      20             :                                               section_vals_type,&
      21             :                                               section_vals_val_get
      22             :    USE kinds,                           ONLY: dp
      23             : #include "./base/base_uses.f90"
      24             : 
      25             :    IMPLICIT NONE
      26             :    PRIVATE
      27             : 
      28             :    PUBLIC ::  iao_env_type, iao_read_input, iao_set_default
      29             : 
      30             : ! **************************************************************************************************
      31             :    TYPE iao_env_type
      32             :       LOGICAL                                :: do_iao = .FALSE.
      33             :       !
      34             :       REAL(KIND=dp)                          :: eps_svd = 0.0_dp
      35             :       REAL(KIND=dp)                          :: eps_occ = 0.0_dp
      36             :       ! chages
      37             :       LOGICAL                                :: do_charges = .FALSE.
      38             :       ! one-center expansion
      39             :       LOGICAL                                :: do_oce = .FALSE.
      40             :       INTEGER                                :: lmax_oce = 0
      41             :       INTEGER                                :: nbas_oce = 0
      42             :       LOGICAL                                :: append_oce = .FALSE.
      43             :       ! Bond orbitals
      44             :       LOGICAL                                :: do_bondorbitals = .FALSE.
      45             :       ! Wannier centers
      46             :       LOGICAL                                :: do_center = .FALSE.
      47             :       LOGICAL                                :: pos_periodic = .FALSE.
      48             :       INTEGER                                :: loc_operator = 0
      49             :       INTEGER                                :: eloc_function = 0
      50             :       REAL(KIND=dp)                          :: eloc_weight = 0.0_dp
      51             :       ! Molden
      52             :       LOGICAL                                :: molden_iao = .FALSE.
      53             :       LOGICAL                                :: molden_ibo = .FALSE.
      54             :       ! CUBE files
      55             :       LOGICAL                                :: cubes_iao = .FALSE.
      56             :       LOGICAL                                :: cubes_ibo = .FALSE.
      57             :       ! Input sections
      58             :       TYPE(section_vals_type), POINTER       :: iao_cubes_section => NULL(), &
      59             :                                                 iao_molden_section => NULL(), &
      60             :                                                 ibo_cubes_section => NULL(), &
      61             :                                                 ibo_molden_section => NULL(), &
      62             :                                                 ibo_cc_section => NULL()
      63             :    END TYPE iao_env_type
      64             : 
      65             : ! **************************************************************************************************
      66             : 
      67             : CONTAINS
      68             : 
      69             : ! **************************************************************************************************
      70             : !> \brief ...
      71             : !> \param iao_env ...
      72             : ! **************************************************************************************************
      73          62 :    SUBROUTINE iao_set_default(iao_env)
      74             :       TYPE(iao_env_type), INTENT(INOUT)                  :: iao_env
      75             : 
      76             :       !iao
      77          62 :       iao_env%do_iao = .FALSE.
      78          62 :       iao_env%eps_svd = 0.0_dp
      79          62 :       iao_env%eps_occ = 0.0_dp
      80             :       ! charges
      81          62 :       iao_env%do_charges = .FALSE.
      82             :       ! one-center expansion
      83          62 :       iao_env%do_oce = .FALSE.
      84          62 :       iao_env%lmax_oce = 3
      85          62 :       iao_env%nbas_oce = 10
      86          62 :       iao_env%append_oce = .FALSE.
      87             :       ! Bond orbitals
      88          62 :       iao_env%do_bondorbitals = .FALSE.
      89             :       ! Wannier centers
      90          62 :       iao_env%do_center = .FALSE.
      91          62 :       iao_env%pos_periodic = .FALSE.
      92          62 :       iao_env%loc_operator = do_iaoloc_pm2
      93          62 :       iao_env%eloc_function = do_iaoloc_enone
      94          62 :       iao_env%eloc_weight = 0.0_dp
      95             :       ! i/o
      96          62 :       iao_env%molden_iao = .FALSE.
      97          62 :       iao_env%molden_ibo = .FALSE.
      98          62 :       iao_env%cubes_iao = .FALSE.
      99          62 :       iao_env%cubes_ibo = .FALSE.
     100             :       ! Input sections
     101          62 :       NULLIFY (iao_env%iao_cubes_section, iao_env%iao_molden_section)
     102          62 :       NULLIFY (iao_env%ibo_cubes_section, iao_env%ibo_molden_section)
     103          62 :       NULLIFY (iao_env%ibo_cc_section)
     104             : 
     105          62 :    END SUBROUTINE iao_set_default
     106             : 
     107             : ! **************************************************************************************************
     108             : 
     109             : ! **************************************************************************************************
     110             : !> \brief ...
     111             : !> \param iao_env ...
     112             : !> \param iao_section ...
     113             : !> \param cell ...
     114             : ! **************************************************************************************************
     115          64 :    SUBROUTINE iao_read_input(iao_env, iao_section, cell)
     116             :       TYPE(iao_env_type), INTENT(INOUT)                  :: iao_env
     117             :       TYPE(section_vals_type), POINTER                   :: iao_section
     118             :       TYPE(cell_type), OPTIONAL                          :: cell
     119             : 
     120             :       LOGICAL                                            :: explicit, iao_explicit
     121             :       TYPE(section_vals_type), POINTER                   :: subsection
     122             : 
     123          32 :       CALL iao_set_default(iao_env)
     124             : 
     125          32 :       CALL section_vals_get(iao_section, explicit=iao_explicit)
     126          32 :       IF (iao_explicit) THEN
     127           4 :          iao_env%do_iao = .TRUE.
     128             :          ! input options
     129           4 :          CALL section_vals_val_get(iao_section, "EPS_SVD", r_val=iao_env%eps_svd)
     130           4 :          CALL section_vals_val_get(iao_section, "EPS_OCC", r_val=iao_env%eps_occ)
     131           4 :          CALL section_vals_val_get(iao_section, "ATOMIC_CHARGES", l_val=iao_env%do_charges)
     132           4 :          iao_env%iao_molden_section => section_vals_get_subs_vals(iao_section, "IAO_MOLDEN")
     133           4 :          CALL section_vals_get(iao_env%iao_molden_section, explicit=iao_env%molden_iao)
     134           4 :          iao_env%iao_cubes_section => section_vals_get_subs_vals(iao_section, "IAO_CUBES")
     135           4 :          CALL section_vals_get(iao_env%iao_cubes_section, explicit=iao_env%cubes_iao)
     136           4 :          subsection => section_vals_get_subs_vals(iao_section, "ONE_CENTER_EXPANSION")
     137           4 :          CALL section_vals_get(subsection, explicit=iao_env%do_oce)
     138           4 :          IF (iao_env%do_oce) THEN
     139           4 :             subsection => section_vals_get_subs_vals(iao_section, "ONE_CENTER_EXPANSION")
     140           4 :             CALL section_vals_val_get(subsection, "LMAX", i_val=iao_env%lmax_oce)
     141           4 :             CALL section_vals_val_get(subsection, "NBAS", i_val=iao_env%nbas_oce)
     142           4 :             CALL section_vals_val_get(subsection, "APPEND", l_val=iao_env%append_oce)
     143             :          END IF
     144           4 :          subsection => section_vals_get_subs_vals(iao_section, "BOND_ORBITALS")
     145           4 :          CALL section_vals_get(subsection, explicit=iao_env%do_bondorbitals)
     146           4 :          IF (iao_env%do_bondorbitals) THEN
     147           4 :             subsection => section_vals_get_subs_vals(iao_section, "BOND_ORBITALS")
     148           4 :             CALL section_vals_val_get(subsection, "LOCALIZATION_OPERATOR", i_val=iao_env%loc_operator)
     149           4 :             CALL section_vals_val_get(subsection, "ENERGY_LOCALIZATION_FUNCTION", i_val=iao_env%eloc_function)
     150           4 :             CALL section_vals_val_get(subsection, "ENERGY_LOCALIZATION_WEIGHT", r_val=iao_env%eloc_weight)
     151           4 :             iao_env%ibo_molden_section => section_vals_get_subs_vals(subsection, "IBO_MOLDEN")
     152           4 :             CALL section_vals_get(iao_env%ibo_molden_section, explicit=iao_env%molden_ibo)
     153           4 :             iao_env%ibo_cubes_section => section_vals_get_subs_vals(subsection, "IBO_CUBES")
     154           4 :             CALL section_vals_get(iao_env%ibo_cubes_section, explicit=iao_env%cubes_ibo)
     155           4 :             iao_env%ibo_cc_section => section_vals_get_subs_vals(subsection, "CHARGE_CENTER")
     156           4 :             CALL section_vals_get(iao_env%ibo_cc_section, explicit=iao_env%do_center)
     157           4 :             IF (iao_env%do_center) THEN
     158             :                CALL section_vals_val_get(iao_env%ibo_cc_section, "POSITION_OPERATOR_BERRY", &
     159           4 :                                          l_val=iao_env%pos_periodic, explicit=explicit)
     160           4 :                IF (.NOT. explicit) THEN
     161             :                   ! set default according to cell periodicity
     162           0 :                   iao_env%pos_periodic = .TRUE.
     163           0 :                   IF (PRESENT(cell)) THEN
     164           0 :                      IF (ALL(cell%perd == 0)) iao_env%pos_periodic = .FALSE.
     165             :                   END IF
     166             :                END IF
     167             :             END IF
     168             :          END IF
     169             :       END IF
     170             : 
     171          32 :    END SUBROUTINE iao_read_input
     172             : 
     173             : ! **************************************************************************************************
     174             : 
     175           0 : END MODULE iao_types

Generated by: LCOV version 1.15