LCOV - code coverage report
Current view: top level - src - input_cp2k_fde.F (source / functions) Coverage Total Hit
Test: CP2K Regtests (git:9ccafda) Lines: 100.0 % 47 47
Test Date: 2026-10-15 00:55:44 Functions: 100.0 % 1 1

            Line data    Source code
       1              : !--------------------------------------------------------------------------------------------------!
       2              : !   CP2K: A general program to perform molecular dynamics simulations                              !
       3              : !   Copyright 2000-2026 CP2K developers group <https://cp2k.org>                                   !
       4              : !                                                                                                  !
       5              : !   SPDX-License-Identifier: GPL-2.0-or-later                                                      !
       6              : !--------------------------------------------------------------------------------------------------!
       7              : MODULE input_cp2k_fde
       8              :    USE input_keyword_types,             ONLY: keyword_create,&
       9              :                                               keyword_release,&
      10              :                                               keyword_type
      11              :    USE input_section_types,             ONLY: section_add_keyword,&
      12              :                                               section_create,&
      13              :                                               section_type
      14              :    USE kinds,                           ONLY: dp
      15              : #include "./base/base_uses.f90"
      16              : 
      17              :    IMPLICIT NONE
      18              :    PRIVATE
      19              : 
      20              :    CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'input_cp2k_fde'
      21              : 
      22              :    PUBLIC :: create_fde_section
      23              : 
      24              : CONTAINS
      25              : 
      26              : ! **************************************************************************************************
      27              : !> \brief Create the FDE (frozen-density embedding) input section
      28              : !> \param section ...
      29              : ! **************************************************************************************************
      30         1474 :    SUBROUTINE create_fde_section(section)
      31              :       TYPE(section_type), POINTER                        :: section
      32              : 
      33              :       TYPE(keyword_type), POINTER                        :: keyword
      34              : 
      35         1474 :       CPASSERT(.NOT. ASSOCIATED(section))
      36              :       CALL section_create(section, __LOCATION__, name="FDE", &
      37              :                           description="Parameters for in-DFT frozen-density embedding (FDE). "// &
      38              :                           "CP2K drives a freeze-and-thaw optimization and spawns another "// &
      39              :                           "program to perform another calculation on the subsystem. The two "// &
      40              :                           "codes interact via the embedding potential and densities exchanged "// &
      41              :                           "on the real-space grid. The nonadditive kinetic-energy functional "// &
      42              :                           "is taken from the KG_METHOD section.", &
      43         1474 :                           n_keywords=13, n_subsections=0, repeats=.FALSE.)
      44              : 
      45         1474 :       NULLIFY (keyword)
      46              : 
      47              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
      48              :                           description="Controls the activation of the FDE driver.", &
      49         1474 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
      50         1474 :       CALL section_add_keyword(section, keyword)
      51         1474 :       CALL keyword_release(keyword)
      52              : 
      53              :       CALL keyword_create(keyword, __LOCATION__, name="FREEZE_AND_THAW", &
      54              :                           description="Run the freeze-and-thaw loop, relaxing both the "// &
      55              :                           "environment and the subsystem alternately. If .FALSE., perform "// &
      56              :                           "a one-shot embedding of the subsystem in the fixed environment "// &
      57              :                           "density.", &
      58         1474 :                           usage="FREEZE_AND_THAW T", default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
      59         1474 :       CALL section_add_keyword(section, keyword)
      60         1474 :       CALL keyword_release(keyword)
      61              : 
      62              :       CALL keyword_create(keyword, __LOCATION__, name="MAX_FT_ITER", &
      63              :                           description="Maximum number of freeze-and-thaw iterations.", &
      64         1474 :                           usage="MAX_FT_ITER 20", default_i_val=50)
      65         1474 :       CALL section_add_keyword(section, keyword)
      66         1474 :       CALL keyword_release(keyword)
      67              : 
      68              :       CALL keyword_create(keyword, __LOCATION__, name="EPS_FT_DENSITY", &
      69              :                           description="Convergence threshold on the absolute change of the "// &
      70              :                           "density between freeze-and-thaw iterations.", &
      71         1474 :                           usage="EPS_FT_DENSITY 1.0E-5", default_r_val=1.0e-5_dp)
      72         1474 :       CALL section_add_keyword(section, keyword)
      73         1474 :       CALL keyword_release(keyword)
      74              : 
      75              :       CALL keyword_create(keyword, __LOCATION__, name="EPS_FT_ENERGY", &
      76              :                           description="Convergence threshold on the total energy change "// &
      77              :                           "between freeze-and-thaw iterations.", &
      78         1474 :                           usage="EPS_FT_ENERGY 1.0E-6", default_r_val=1.0e-6_dp)
      79         1474 :       CALL section_add_keyword(section, keyword)
      80         1474 :       CALL keyword_release(keyword)
      81              : 
      82              :       CALL keyword_create(keyword, __LOCATION__, name="DENSITY_MIXING", &
      83              :                           description="Linear mixing factor applied to the subsystem density "// &
      84              :                           "between macro-iterations. 1.0 = no damping.", &
      85         1474 :                           usage="DENSITY_MIXING 0.5", default_r_val=1.0_dp)
      86         1474 :       CALL section_add_keyword(section, keyword)
      87         1474 :       CALL keyword_release(keyword)
      88              : 
      89              :       CALL keyword_create(keyword, __LOCATION__, name="COMMAND", &
      90              :                           description="Shell command used to run the subsystem solver on the "// &
      91              :                           "generated input file. The input file name is passed as the last "// &
      92              :                           "argument.", &
      93         1474 :                           usage="COMMAND pymolcas", default_c_val="pymolcas")
      94         1474 :       CALL section_add_keyword(section, keyword)
      95         1474 :       CALL keyword_release(keyword)
      96              : 
      97              :       CALL keyword_create(keyword, __LOCATION__, name="PROJECT", &
      98              :                           description="Project name for the active-subsystem calculation.", &
      99         1474 :                           usage="PROJECT sub", default_c_val="sub")
     100         1474 :       CALL section_add_keyword(section, keyword)
     101         1474 :       CALL keyword_release(keyword)
     102              : 
     103              :       CALL keyword_create(keyword, __LOCATION__, name="WORKDIR", &
     104              :                           description="Working directory in which the subsystem calculation is "// &
     105              :                           "run and the exchange files are written. Defaults to the current "// &
     106              :                           "working directory.", &
     107         1474 :                           usage="WORKDIR ./sub", default_c_val="")
     108         1474 :       CALL section_add_keyword(section, keyword)
     109         1474 :       CALL keyword_release(keyword)
     110              : 
     111              :       CALL keyword_create(keyword, __LOCATION__, name="MOLCAS_INPUT_TEMPLATE", &
     112              :                           description="Path to the OpenMolcas input template for the subsystem "// &
     113              :                           "(GATEWAY/SEWARD/RASSCF). The driver appends the EMBEDDING block.", &
     114         1474 :                           usage="MOLCAS_INPUT_TEMPLATE sub.template.inp", default_c_val="")
     115         1474 :       CALL section_add_keyword(section, keyword)
     116         1474 :       CALL keyword_release(keyword)
     117              : 
     118              :       CALL keyword_create(keyword, __LOCATION__, name="POT_FILE", &
     119              :                           description="File name (in WORKDIR) for the embedding potential "// &
     120              :                           "written in OpenMolcas format.", &
     121         1474 :                           usage="POT_FILE EMBPOT", default_c_val="EMBPOT")
     122         1474 :       CALL section_add_keyword(section, keyword)
     123         1474 :       CALL keyword_release(keyword)
     124              : 
     125              :       CALL keyword_create(keyword, __LOCATION__, name="GRID_FILE", &
     126              :                           description="File name (in WORKDIR) for the output grid coordinates "// &
     127              :                           "on which the subsystem solver evaluates and returns the density.", &
     128         1474 :                           usage="GRID_FILE EMBGRID", default_c_val="EMBGRID")
     129         1474 :       CALL section_add_keyword(section, keyword)
     130         1474 :       CALL keyword_release(keyword)
     131              : 
     132              :       CALL keyword_create(keyword, __LOCATION__, name="RHO_FILE", &
     133              :                           description="File name (in WORKDIR) with the subsystem density "// &
     134              :                           "returned by the subsystem solver on the output grid.", &
     135         1474 :                           usage="RHO_FILE EMBRHOA", default_c_val="EMBRHOA")
     136         1474 :       CALL section_add_keyword(section, keyword)
     137         1474 :       CALL keyword_release(keyword)
     138              : 
     139              :       CALL keyword_create(keyword, __LOCATION__, name="RESULT_FILE", &
     140              :                           description="File name (in WORKDIR) with the scalar results returned "// &
     141              :                           "by the subsystem solver (embedded energy, Tr(D*v_emb), active "// &
     142              :                           "nuclear repulsion, number of active electrons).", &
     143         1474 :                           usage="RESULT_FILE EMBRES", default_c_val="EMBRES")
     144         1474 :       CALL section_add_keyword(section, keyword)
     145         1474 :       CALL keyword_release(keyword)
     146              : 
     147         1474 :    END SUBROUTINE create_fde_section
     148              : 
     149              : END MODULE input_cp2k_fde
        

Generated by: LCOV version 2.0-1