LCOV - code coverage report
Current view: top level - src - input_cp2k_qmmm.F (source / functions) Coverage Total Hit
Test: CP2K Regtests (git:cccd2f3) Lines: 100.0 % 472 472
Test Date: 2026-05-06 07:07:47 Functions: 100.0 % 13 13

            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              : 
       8              : ! **************************************************************************************************
       9              : !> \brief creates the qmmm section of the input
      10              : !> \note
      11              : !>      moved out of input_cp2k
      12              : !> \par History
      13              : !>      10.2005 split out of input_cp2k
      14              : !> \author teo & fawzi
      15              : ! **************************************************************************************************
      16              : MODULE input_cp2k_qmmm
      17              :    USE bibliography,                    ONLY: Bernstein2009,&
      18              :                                               Bernstein2012,&
      19              :                                               Golze2013,&
      20              :                                               Laino2005,&
      21              :                                               Laino2006
      22              :    USE cell_types,                      ONLY: use_perd_none
      23              :    USE cp_eri_mme_interface,            ONLY: create_eri_mme_section
      24              :    USE cp_output_handling,              ONLY: add_last_numeric,&
      25              :                                               cp_print_key_section_create,&
      26              :                                               debug_print_level,&
      27              :                                               high_print_level,&
      28              :                                               low_print_level,&
      29              :                                               medium_print_level,&
      30              :                                               silent_print_level
      31              :    USE cp_spline_utils,                 ONLY: spline3_nopbc_interp
      32              :    USE cp_units,                        ONLY: cp_unit_to_cp2k
      33              :    USE input_constants,                 ONLY: &
      34              :         alpha_imomm_default, charge_scale_factor, do_eri_gpw, do_eri_mme, &
      35              :         do_fm_mom_conserv_buffer, do_fm_mom_conserv_core, do_fm_mom_conserv_equal_a, &
      36              :         do_fm_mom_conserv_equal_f, do_fm_mom_conserv_none, do_fm_mom_conserv_qm, &
      37              :         do_multipole_section_off, do_multipole_section_on, do_par_atom, do_par_grid, &
      38              :         do_qmmm_center_every_step, do_qmmm_center_max_minus_min, do_qmmm_center_never, &
      39              :         do_qmmm_center_pbc_aware, do_qmmm_center_setup_only, do_qmmm_coulomb, do_qmmm_gauss, &
      40              :         do_qmmm_image_calcmatrix, do_qmmm_image_iter, do_qmmm_link_gho, do_qmmm_link_imomm, &
      41              :         do_qmmm_link_pseudo, do_qmmm_none, do_qmmm_pcharge, do_qmmm_swave, do_qmmm_wall_none, &
      42              :         do_qmmm_wall_quadratic, do_qmmm_wall_reflective, gaussian, radius_qmmm_default
      43              :    USE input_cp2k_mm,                   ONLY: create_GENPOT_section,&
      44              :                                               create_Goodwin_section,&
      45              :                                               create_LJ_section,&
      46              :                                               create_NONBONDED14_section,&
      47              :                                               create_Williams_section
      48              :    USE input_cp2k_poisson,              ONLY: create_gspace_interp_section,&
      49              :                                               create_poisson_section
      50              :    USE input_cp2k_subsys,               ONLY: create_cell_section
      51              :    USE input_keyword_types,             ONLY: keyword_create,&
      52              :                                               keyword_release,&
      53              :                                               keyword_type
      54              :    USE input_section_types,             ONLY: section_add_keyword,&
      55              :                                               section_add_subsection,&
      56              :                                               section_create,&
      57              :                                               section_release,&
      58              :                                               section_type
      59              :    USE input_val_types,                 ONLY: char_t,&
      60              :                                               integer_t,&
      61              :                                               lchar_t,&
      62              :                                               logical_t,&
      63              :                                               real_t
      64              :    USE kinds,                           ONLY: dp
      65              :    USE pw_spline_utils,                 ONLY: no_precond,&
      66              :                                               precond_spl3_1,&
      67              :                                               precond_spl3_2,&
      68              :                                               precond_spl3_3,&
      69              :                                               precond_spl3_aint,&
      70              :                                               precond_spl3_aint2
      71              :    USE string_utilities,                ONLY: s2a
      72              : #include "./base/base_uses.f90"
      73              : 
      74              :    IMPLICIT NONE
      75              :    PRIVATE
      76              : 
      77              :    LOGICAL, PRIVATE, PARAMETER :: debug_this_module = .TRUE.
      78              :    CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'input_cp2k_qmmm'
      79              : 
      80              :    PUBLIC :: create_qmmm_section
      81              : 
      82              : !***
      83              : CONTAINS
      84              : 
      85              : ! **************************************************************************************************
      86              : !> \brief Creates the QM/MM section
      87              : !> \param section the section to create
      88              : !> \author teo
      89              : ! **************************************************************************************************
      90         9823 :    SUBROUTINE create_qmmm_section(section)
      91              :       TYPE(section_type), POINTER                        :: section
      92              : 
      93              :       TYPE(keyword_type), POINTER                        :: keyword
      94              :       TYPE(section_type), POINTER                        :: subsection
      95              : 
      96         9823 :       CPASSERT(.NOT. ASSOCIATED(section))
      97              :       CALL section_create(section, __LOCATION__, name="qmmm", &
      98              :                           description="Controls QM/MM calculations, including mechanical, electrostatic, "// &
      99              :                           "Gaussian-expanded, and periodic embedding options.", &
     100              :                           n_keywords=6, n_subsections=3, repeats=.FALSE., &
     101        29469 :                           citations=[Laino2005, Laino2006])
     102              : 
     103         9823 :       NULLIFY (keyword, subsection)
     104              :       CALL keyword_create(keyword, __LOCATION__, name="E_COUPL", &
     105              :                           variants=s2a("QMMM_COUPLING", "ECOUPL"), &
     106              :                           description="Selects the QM-MM coupling model used for the electrostatic interaction.", &
     107              :                           usage="E_COUPL GAUSS", &
     108              :                           enum_c_vals=s2a("NONE", "COULOMB", "GAUSS", "S-WAVE", "POINT_CHARGE"), &
     109              :                           enum_i_vals=[do_qmmm_none, do_qmmm_coulomb, do_qmmm_gauss, do_qmmm_swave, do_qmmm_pcharge], &
     110              :                           enum_desc=s2a("Mechanical coupling (i.e. classical point charge based)", &
     111              :                                         "Using analytical 1/r potential (Coulomb) - not available for GPW/GAPW", &
     112              :                                         "Using fast Gaussian expansion of the electrostatic potential (Erf(r/rc)/r) "// &
     113              :                                         "- not available for DFTB.", &
     114              :                                         "Using fast Gaussian expansion of the s-wave electrostatic potential", &
     115              :                                         "Using quantum mechanics derived point charges interacting with MM charges"), &
     116         9823 :                           default_i_val=do_qmmm_none)
     117         9823 :       CALL section_add_keyword(section, keyword)
     118         9823 :       CALL keyword_release(keyword)
     119              : 
     120              :       CALL keyword_create(keyword, __LOCATION__, name="MM_POTENTIAL_FILE_NAME", &
     121              :                           description="Name of the file containing the potential expansion in gaussians. See the "// &
     122              :                           "USE_GEEP_LIB keyword.", &
     123              :                           usage="MM_POTENTIAL_FILE_NAME {filename}", &
     124         9823 :                           default_lc_val="MM_POTENTIAL")
     125         9823 :       CALL section_add_keyword(section, keyword)
     126         9823 :       CALL keyword_release(keyword)
     127              : 
     128              :       CALL keyword_create(keyword, __LOCATION__, name="use_geep_lib", &
     129              :                           description=" This keyword enables the use of the internal GEEP library to generate the "// &
     130              :                           "gaussian expansion of the MM potential. Using this keyword there's no need to provide "// &
     131              :                           "the MM_POTENTIAL_FILENAME. It expects a number from 2 to 15 (the number of gaussian functions"// &
     132              :                           " to be used in the expansion.", &
     133              :                           usage="use_geep_lib INTEGER", &
     134         9823 :                           default_i_val=0)
     135         9823 :       CALL section_add_keyword(section, keyword)
     136         9823 :       CALL keyword_release(keyword)
     137              : 
     138              :       CALL keyword_create(keyword, __LOCATION__, name="nocompatibility", &
     139              :                           description="This keyword disables the compatibility of QM/MM "// &
     140              :                           "potential between CPMD and CP2K implementations. The compatibility"// &
     141              :                           " is achieved using an MM potential of the form: Erf[x/rc]/x + (1/rc -2/(pi^1/2*rc))*Exp[-(x/rc)^2]. "// &
     142              :                           "This keyword has effect only selecting GAUSS E_COUPLING type.", &
     143              :                           usage="nocompatibility LOGICAL", &
     144         9823 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     145         9823 :       CALL section_add_keyword(section, keyword)
     146         9823 :       CALL keyword_release(keyword)
     147              : 
     148              :       CALL keyword_create(keyword, __LOCATION__, name="eps_mm_rspace", &
     149              :                           description="Set the threshold for the collocation of the GEEP gaussian functions. "// &
     150              :                           "this keyword affects only the GAUSS E_COUPLING.", &
     151              :                           usage="eps_mm_rspace real", &
     152         9823 :                           default_r_val=1.0E-10_dp)
     153         9823 :       CALL section_add_keyword(section, keyword)
     154         9823 :       CALL keyword_release(keyword)
     155              : 
     156              :       CALL keyword_create(keyword, __LOCATION__, name="SPHERICAL_CUTOFF", &
     157              :                           description="Set the spherical cutoff for the QMMM electrostatic interaction. "// &
     158              :                           "This acts like a charge multiplicative factor dependent on cutoff. For MM atoms "// &
     159              :                           "farther than the SPHERICAL_CUTOFF(1) their charge is zero. The switch is performed "// &
     160              :                           "with a smooth function: 0.5*(1-TANH((r-[SPH_CUT(1)-20*SPH_CUT(2)])/(SPH_CUT(2)))). "// &
     161              :                           "Two values are required: the first one is the distance cutoff. The second one controls "// &
     162              :                           "the stiffness of the smoothing.", &
     163              :                           usage="SPHERICAL_CUTOFF  <REAL>", default_r_vals=[-1.0_dp, 0.0_dp], n_var=2, &
     164         9823 :                           unit_str="angstrom")
     165         9823 :       CALL section_add_keyword(section, keyword)
     166         9823 :       CALL keyword_release(keyword)
     167              : 
     168              :       CALL keyword_create(keyword, __LOCATION__, name="parallel_scheme", &
     169              :                           description="Chooses the parallel_scheme for the long range Potential ", &
     170              :                           usage="parallel_scheme (ATOM|GRID)", &
     171              :                           enum_c_vals=s2a("ATOM", "GRID"), &
     172              :                           enum_desc=s2a("parallelizes on atoms. grids replicated. "// &
     173              :                                         "Replication of the grids can be quite expensive memory wise if running on a system "// &
     174              :                                         "with limited memory per core. The grid option may be preferred in this case.", &
     175              :                                         "parallelizes on grid slices. atoms replicated."), &
     176              :                           enum_i_vals=[do_par_atom, do_par_grid], &
     177         9823 :                           default_i_val=do_par_atom)
     178         9823 :       CALL section_add_keyword(section, keyword)
     179         9823 :       CALL keyword_release(keyword)
     180              : 
     181              :       ! Centering keywords
     182              :       CALL keyword_create(keyword, __LOCATION__, name="CENTER", &
     183              :                           description="This keyword sets when the QM system is automatically "// &
     184              :                           "centered.  Default is EVERY_STEP.", &
     185              :                           usage="center (EVERY_STEP|SETUP_ONLY|NEVER)", &
     186              :                           enum_c_vals=s2a("EVERY_STEP", "SETUP_ONLY", "NEVER"), &
     187              :                           enum_desc=s2a("Re-center every step", &
     188              :                                         "Center at first step only", &
     189              :                                         "Never center"), &
     190              :                           enum_i_vals=[do_qmmm_center_every_step, do_qmmm_center_setup_only, do_qmmm_center_never], &
     191         9823 :                           default_i_val=do_qmmm_center_every_step)
     192         9823 :       CALL section_add_keyword(section, keyword)
     193         9823 :       CALL keyword_release(keyword)
     194              : 
     195              :       CALL keyword_create(keyword, __LOCATION__, name="CENTER_TYPE", &
     196              :                           description="This keyword specifies how to do the QM system centering.", &
     197              :                           usage="center_type (MAX_MINUS_MIN|PBC_AWARE_MAX_MINUS_MIN)", &
     198              :                           enum_c_vals=s2a("MAX_MINUS_MIN", "PBC_AWARE_MAX_MINUS_MIN"), &
     199              :                           enum_desc=s2a("Center of box defined by maximum coordinate minus minimum coordinate", &
     200              :                                         "PBC-aware centering (useful for &QMMM&FORCE_MIXING)"), &
     201              :                           enum_i_vals=[do_qmmm_center_max_minus_min, do_qmmm_center_pbc_aware], &
     202         9823 :                           default_i_val=do_qmmm_center_max_minus_min)
     203         9823 :       CALL section_add_keyword(section, keyword)
     204         9823 :       CALL keyword_release(keyword)
     205              : 
     206              :       CALL keyword_create(keyword, __LOCATION__, name="CENTER_GRID", &
     207              :                           description="This keyword specifies whether the QM system is centered in units of the grid spacing.", &
     208              :                           usage="CENTER_GRID LOGICAL", &
     209         9823 :                           default_l_val=.FALSE.)
     210         9823 :       CALL section_add_keyword(section, keyword)
     211         9823 :       CALL keyword_release(keyword)
     212              : 
     213              :       CALL keyword_create(keyword, __LOCATION__, name="initial_translation_vector", &
     214              :                           description="This keyword specify the initial translation vector to be applied to the system.", &
     215              :                           usage="initial_translation_vector <REAL> <REAL> <REAL>", &
     216         9823 :                           n_var=3, default_r_vals=[0.0_dp, 0.0_dp, 0.0_dp])
     217         9823 :       CALL section_add_keyword(section, keyword)
     218         9823 :       CALL keyword_release(keyword)
     219              : 
     220              :       CALL keyword_create( &
     221              :          keyword, __LOCATION__, name="DELTA_CHARGE", &
     222              :          description="Additional net charge relative to that specified in DFT section.  Used automatically by force mixing", &
     223              :          usage="DELTA_CHARGE q", default_i_val=0, &
     224         9823 :          n_var=1, type_of_var=integer_t, repeats=.FALSE.)
     225         9823 :       CALL section_add_keyword(section, keyword)
     226         9823 :       CALL keyword_release(keyword)
     227              : 
     228              :       ! NB: remember to create these
     229         9823 :       CALL create_qmmm_force_mixing_section(subsection)
     230         9823 :       CALL section_add_subsection(section, subsection)
     231         9823 :       CALL section_release(subsection)
     232              : 
     233         9823 :       CALL create_qmmm_qm_kinds(subsection)
     234         9823 :       CALL section_add_subsection(section, subsection)
     235         9823 :       CALL section_release(subsection)
     236              : 
     237         9823 :       CALL create_qmmm_mm_kinds(subsection)
     238         9823 :       CALL section_add_subsection(section, subsection)
     239         9823 :       CALL section_release(subsection)
     240              : 
     241         9823 :       CALL create_cell_section(subsection, periodic=use_perd_none)
     242         9823 :       CALL section_add_subsection(section, subsection)
     243         9823 :       CALL section_release(subsection)
     244              : 
     245         9823 :       CALL create_qmmm_periodic_section(subsection)
     246         9823 :       CALL section_add_subsection(section, subsection)
     247         9823 :       CALL section_release(subsection)
     248              : 
     249         9823 :       CALL create_qmmm_link_section(subsection)
     250         9823 :       CALL section_add_subsection(section, subsection)
     251         9823 :       CALL section_release(subsection)
     252              : 
     253         9823 :       CALL create_qmmm_interp_section(subsection)
     254         9823 :       CALL section_add_subsection(section, subsection)
     255         9823 :       CALL section_release(subsection)
     256              : 
     257         9823 :       CALL create_qmmm_forcefield_section(subsection)
     258         9823 :       CALL section_add_subsection(section, subsection)
     259         9823 :       CALL section_release(subsection)
     260              : 
     261         9823 :       CALL create_qmmm_walls_section(subsection)
     262         9823 :       CALL section_add_subsection(section, subsection)
     263         9823 :       CALL section_release(subsection)
     264              : 
     265         9823 :       CALL create_qmmm_image_charge_section(subsection)
     266         9823 :       CALL section_add_subsection(section, subsection)
     267         9823 :       CALL section_release(subsection)
     268              : 
     269         9823 :       CALL create_print_qmmm_section(subsection)
     270         9823 :       CALL section_add_subsection(section, subsection)
     271         9823 :       CALL section_release(subsection)
     272              : 
     273         9823 :    END SUBROUTINE create_qmmm_section
     274              : 
     275              : ! **************************************************************************************************
     276              : !> \brief Input section to create MM kinds sections
     277              : !> \param section ...
     278              : !> \author tlaino
     279              : ! **************************************************************************************************
     280         9823 :    SUBROUTINE create_qmmm_mm_kinds(section)
     281              :       TYPE(section_type), POINTER                        :: section
     282              : 
     283              :       TYPE(keyword_type), POINTER                        :: keyword
     284              : 
     285         9823 :       NULLIFY (keyword)
     286         9823 :       CPASSERT(.NOT. ASSOCIATED(section))
     287              :       CALL section_create(section, __LOCATION__, name="MM_KIND", &
     288              :                           description="Information about the MM kind in the QM/MM scheme", &
     289         9823 :                           n_keywords=2, n_subsections=0, repeats=.TRUE.)
     290              : 
     291              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
     292         9823 :                           description="The MM  kind", usage="O", n_var=1, type_of_var=char_t)
     293         9823 :       CALL section_add_keyword(section, keyword)
     294         9823 :       CALL keyword_release(keyword)
     295              : 
     296              :       CALL keyword_create(keyword, __LOCATION__, name="RADIUS", &
     297              :                           description="Specifies the radius of the atomic kinds", &
     298              :                           usage="RADIUS real", n_var=1, type_of_var=real_t, unit_str="angstrom", &
     299         9823 :                           default_r_val=cp_unit_to_cp2k(RADIUS_QMMM_DEFAULT, "angstrom"))
     300         9823 :       CALL section_add_keyword(section, keyword)
     301         9823 :       CALL keyword_release(keyword)
     302              : 
     303              :       CALL keyword_create(keyword, __LOCATION__, name="CORR_RADIUS", &
     304              :                           description="Specifies the correction radius of the atomic kinds"// &
     305              :                           " The correction radius is connected to the use of the compatibility keyword.", &
     306         9823 :                           usage="CORR_RADIUS real", n_var=1, type_of_var=real_t, unit_str="angstrom")
     307         9823 :       CALL section_add_keyword(section, keyword)
     308         9823 :       CALL keyword_release(keyword)
     309              : 
     310         9823 :    END SUBROUTINE create_qmmm_mm_kinds
     311              : 
     312              : ! **************************************************************************************************
     313              : !> \brief Input section to create FORCE_MIXING sections
     314              : !> \param section ...
     315              : !> \author noam
     316              : ! **************************************************************************************************
     317         9823 :    SUBROUTINE create_qmmm_force_mixing_section(section)
     318              :       TYPE(section_type), POINTER                        :: section
     319              : 
     320              :       TYPE(keyword_type), POINTER                        :: keyword
     321              :       TYPE(section_type), POINTER                        :: link_subsection, print_key, &
     322              :                                                             qm_kinds_subsection, subsection
     323              : 
     324         9823 :       NULLIFY (keyword)
     325         9823 :       CPASSERT(.NOT. ASSOCIATED(section))
     326              :       CALL section_create(section, __LOCATION__, name="FORCE_MIXING", &
     327              :                           description="This section enables and defines parameters for force-mixing based QM/MM,"// &
     328              :                           " which actually does two conventional QM/MM calculations, on a small"// &
     329              :                           " and a large QM region, and combines the MM forces from one and QM"// &
     330              :                           " forces from the other to create a complete set of forces.  Energy is"// &
     331              :                           " not conserved (although the QM/MM energy from the large QM region calculation is reported)"// &
     332              :                           " so a proper thermostat (i.e. massive, and able to handle dissipation, such as"// &
     333              :                           " Adaptive Langevin (AD_LANGEVIN)) must be used. For some propagation algorithms"// &
     334              :                           " (NVT and REFTRAJ MD ensembles) algorithm is adaptive,"// &
     335              :                           " including molecules hysteretically based on their instantaneous distance from the core region."// &
     336              :                           " Information on core/QM/buffer labels can be written in PDB file using"// &
     337              :                           " MOTION&PRINT&FORCE_MIXING_LABELS.  Will fail if calculation requires a"// &
     338              :                           " meaningfull stress, or an energy that is consistent with the forces."// &
     339              :                           " For GEO_OPT this means"// &
     340              :                           " only MOTION&GEO_OPT&TYPE CG, MOTION&GEO_OPT&CG&LINE_SEARCH&TYPE 2PNT, and"// &
     341              :                           " MOTION&GEO_OPT&CG&LINE_SEARCH&2PNT&LINMIN_GRAD_ONLY T", &
     342              :                           n_keywords=5, n_subsections=3, repeats=.FALSE., &
     343        29469 :                           citations=[Bernstein2009, Bernstein2012])
     344              : 
     345              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
     346              :                           description="Enables force-mixing", &
     347         9823 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     348         9823 :       CALL section_add_keyword(section, keyword)
     349         9823 :       CALL keyword_release(keyword)
     350              : 
     351              :       CALL keyword_create(keyword, __LOCATION__, name="MOMENTUM_CONSERVATION_TYPE", &
     352              :                           description="How to apply force to get momentum conservation", &
     353              :                           usage="MOMENTUM_CONSERVATION_TYPE <type>", &
     354              :                           enum_c_vals=s2a("NONE", "EQUAL_F", "EQUAL_A"), &
     355              :                           enum_i_vals=[do_fm_mom_conserv_none, do_fm_mom_conserv_equal_f, do_fm_mom_conserv_equal_a], &
     356              :                           enum_desc=s2a("No momentum conservation", &
     357              :                                         "Equal force on each atom", &
     358              :                                         "Equal acceleration on each atom"), &
     359         9823 :                           default_i_val=do_fm_mom_conserv_equal_a)
     360         9823 :       CALL section_add_keyword(section, keyword)
     361         9823 :       CALL keyword_release(keyword)
     362              : 
     363              :       CALL keyword_create(keyword, __LOCATION__, name="MOMENTUM_CONSERVATION_REGION", &
     364              :                           description="Region to apply correction force to for momentum conservation", &
     365              :                           usage="MOMENTUM_CONSERVATION_REGION <label>", &
     366              :                           enum_c_vals=s2a("CORE", "QM", "BUFFER"), &
     367              :                           enum_i_vals=[do_fm_mom_conserv_core, do_fm_mom_conserv_QM, do_fm_mom_conserv_buffer], &
     368              :                           enum_desc=s2a("Apply to QM core region", &
     369              :                                         "Apply to full QM (dynamics) region", &
     370              :                                         "Apply to QM+buffer regions"), &
     371         9823 :                           default_i_val=do_fm_mom_conserv_QM)
     372         9823 :       CALL section_add_keyword(section, keyword)
     373         9823 :       CALL keyword_release(keyword)
     374              : 
     375              :       CALL keyword_create(keyword, __LOCATION__, name="R_CORE", &
     376              :                           description="Specify the inner and outer radii of core QM region."// &
     377              :                           " All molecules with any atoms within this distance (hysteretically) of any atoms"// &
     378              :                           " specified as QM in enclosing QM/MM section  will be core QM atoms in the force-mixing calculation.", &
     379              :                           usage="R_CORE <real> <real>", n_var=2, type_of_var=real_t, &
     380              :                           default_r_vals=[cp_unit_to_cp2k(0.0_dp, "angstrom"), &
     381              :                                           cp_unit_to_cp2k(0.0_dp, "angstrom")], &
     382        29469 :                           unit_str="angstrom")
     383         9823 :       CALL section_add_keyword(section, keyword)
     384         9823 :       CALL keyword_release(keyword)
     385              : 
     386              :       CALL keyword_create(keyword, __LOCATION__, name="R_QM", &
     387              :                           description="Specify the inner and outer radii of QM dynamics region."// &
     388              :                           " All molecules with atoms within this distance (hysteretically) of any atoms in"// &
     389              :                           " core will follow QM dynamics in the force-mixing calculation.", &
     390              :                           usage="R_QM <real> <real>", n_var=2, type_of_var=real_t, &
     391              :                           default_r_vals=[cp_unit_to_cp2k(0.5_dp, "angstrom"), &
     392              :                                           cp_unit_to_cp2k(1.0_dp, "angstrom")], &
     393        29469 :                           unit_str="angstrom")
     394         9823 :       CALL section_add_keyword(section, keyword)
     395         9823 :       CALL keyword_release(keyword)
     396              : 
     397              :       CALL keyword_create(keyword, __LOCATION__, name="QM_EXTENDED_SEED_IS_ONLY_CORE_LIST", &
     398              :                           description="Makes the extended QM zone be defined hysterestically"// &
     399              :                           " by distance from QM core list (i.e. atoms specified explicitly by"// &
     400              :                           " user) instead of from full QM core region (specified by user + hysteretic"// &
     401              :                           " selection + unbreakable bonds)", &
     402              :                           usage="QM_EXTENDED_SEED_IS_ONLY_CORE_LIST <logical>", n_var=1, type_of_var=logical_t, &
     403         9823 :                           default_l_val=.FALSE., repeats=.FALSE.)
     404         9823 :       CALL section_add_keyword(section, keyword)
     405         9823 :       CALL keyword_release(keyword)
     406              : 
     407              :       CALL keyword_create(keyword, __LOCATION__, name="R_BUF", &
     408              :                           description="Specify the inner and outer radii of buffer region."// &
     409              :                           " All atoms within this distance (hysteretically) of any QM atoms"// &
     410              :                           " will be buffer atoms in the force-mixing calculation.", &
     411              :                           usage="R_BUF <real> <real>", n_var=2, type_of_var=real_t, &
     412              :                           default_r_vals=[cp_unit_to_cp2k(0.5_dp, "angstrom"), &
     413              :                                           cp_unit_to_cp2k(1.0_dp, "angstrom")], &
     414        29469 :                           unit_str="angstrom")
     415         9823 :       CALL section_add_keyword(section, keyword)
     416         9823 :       CALL keyword_release(keyword)
     417              : 
     418              :       CALL keyword_create(keyword, __LOCATION__, name="QM_KIND_ELEMENT_MAPPING", &
     419              :                           description="Mapping from elements to QM_KINDs for adaptively included atoms.", &
     420              :                           usage="QM_KIND_ELEMENT_MAPPING {El} {QM_KIND}", &
     421         9823 :                           n_var=2, type_of_var=char_t, repeats=.TRUE.)
     422         9823 :       CALL section_add_keyword(section, keyword)
     423         9823 :       CALL keyword_release(keyword)
     424              : 
     425              :       CALL keyword_create(keyword, __LOCATION__, name="MAX_N_QM", &
     426              :                           description="Maximum number of QM atoms, for detection of runaway adaptive selection.", &
     427              :                           usage="MAX_N_QM int", default_i_val=300, &
     428         9823 :                           n_var=1, type_of_var=integer_t, repeats=.FALSE.)
     429         9823 :       CALL section_add_keyword(section, keyword)
     430         9823 :       CALL keyword_release(keyword)
     431              : 
     432              :       CALL keyword_create(keyword, __LOCATION__, name="ADAPTIVE_EXCLUDE_MOLECULES", &
     433              :                           description="List of molecule names to exclude from adaptive regions (e.g. big things like proteins)", &
     434              :                           usage="ADAPTIVE_EXCLUDE_MOLECULES molec1 molec2 ...", &
     435         9823 :                           n_var=-1, type_of_var=char_t, repeats=.FALSE.)
     436         9823 :       CALL section_add_keyword(section, keyword)
     437         9823 :       CALL keyword_release(keyword)
     438              : 
     439              :       CALL keyword_create(keyword, __LOCATION__, name="EXTENDED_DELTA_CHARGE", &
     440              :                           description="Additional net charge in extended region relative to core (core charge is"// &
     441              :                           " specified in DFT section, as usual for a convetional QM/MM calculation)", &
     442              :                           usage="EXTENDED_DELTA_CHARGE q", default_i_val=0, &
     443         9823 :                           n_var=1, type_of_var=integer_t, repeats=.FALSE.)
     444         9823 :       CALL section_add_keyword(section, keyword)
     445         9823 :       CALL keyword_release(keyword)
     446              : 
     447              :       ! QM_NON_ADAPTIVE subsection
     448         9823 :       NULLIFY (subsection)
     449              :       CALL section_create(subsection, __LOCATION__, name="QM_NON_ADAPTIVE", &
     450              :                           description="List of atoms always in QM region, non-adaptively", &
     451         9823 :                           n_keywords=0, n_subsections=1, repeats=.TRUE.)
     452              : 
     453         9823 :       NULLIFY (qm_kinds_subsection)
     454         9823 :       CALL create_qmmm_qm_kinds(qm_kinds_subsection)
     455         9823 :       CALL section_add_subsection(subsection, qm_kinds_subsection)
     456         9823 :       CALL section_release(qm_kinds_subsection)
     457              : 
     458         9823 :       CALL section_add_subsection(section, subsection)
     459         9823 :       CALL section_release(subsection)
     460              : 
     461              :       ! BUFFER_NON_ADAPTIVE subsection
     462         9823 :       NULLIFY (subsection)
     463              :       CALL section_create(subsection, __LOCATION__, name="BUFFER_NON_ADAPTIVE", &
     464              :                           description="List of atoms always in buffer region, non-adaptively, and any needed LINK sections", &
     465         9823 :                           n_keywords=0, n_subsections=1, repeats=.TRUE.)
     466              : 
     467         9823 :       NULLIFY (qm_kinds_subsection)
     468         9823 :       CALL create_qmmm_qm_kinds(qm_kinds_subsection)
     469         9823 :       CALL section_add_subsection(subsection, qm_kinds_subsection)
     470         9823 :       CALL section_release(qm_kinds_subsection)
     471         9823 :       NULLIFY (link_subsection)
     472         9823 :       CALL create_qmmm_link_section(link_subsection)
     473         9823 :       CALL section_add_subsection(subsection, link_subsection)
     474         9823 :       CALL section_release(link_subsection)
     475              : 
     476         9823 :       CALL section_add_subsection(section, subsection)
     477         9823 :       CALL section_release(subsection)
     478              : 
     479              :       ![NB] also need a list?
     480              :       ![NB] maybe not list+links , but some sort of link template
     481              :       ![NB] also, breakable bonds?
     482              :       ! BUFFER_LINKS subsection
     483         9823 :       NULLIFY (subsection)
     484              :       CALL section_create( &
     485              :          subsection, __LOCATION__, name="BUFFER_LINKS", &
     486              :          description="Information about possible links for automatic covalent bond breaking for the buffer QM/MM calculation. "// &
     487              :          "Ignored - need to implement buffer selection by atom and walking of connectivity data.", &
     488         9823 :          n_keywords=0, n_subsections=1, repeats=.TRUE.)
     489              : 
     490         9823 :       NULLIFY (link_subsection)
     491         9823 :       CALL create_qmmm_link_section(link_subsection)
     492         9823 :       CALL section_add_subsection(subsection, link_subsection)
     493         9823 :       CALL section_release(link_subsection)
     494              : 
     495         9823 :       CALL section_add_subsection(section, subsection)
     496         9823 :       CALL section_release(subsection)
     497              : 
     498              :       ! RESTART_INFO subsection
     499         9823 :       NULLIFY (subsection)
     500              :       CALL section_create(subsection, __LOCATION__, name="RESTART_INFO", &
     501              :                           description="This section provides information about old force-mixing indices and labels, "// &
     502              :                           "for restarts.", &
     503         9823 :                           n_keywords=2, n_subsections=0, repeats=.FALSE.)
     504              : 
     505              :       CALL keyword_create(keyword, __LOCATION__, name="INDICES", &
     506              :                           description="Indices of atoms in previous step QM regions.", &
     507              :                           usage="INDICES 1 2 ...", &
     508         9823 :                           n_var=-1, type_of_var=integer_t, repeats=.TRUE.)
     509         9823 :       CALL section_add_keyword(subsection, keyword)
     510         9823 :       CALL keyword_release(keyword)
     511              : 
     512              :       CALL keyword_create(keyword, __LOCATION__, name="LABELS", &
     513              :                           description="Labels of atoms in previous step QM regions.", &
     514              :                           usage="LABELS 1 1 ...", &
     515         9823 :                           n_var=-1, type_of_var=integer_t, repeats=.TRUE.)
     516         9823 :       CALL section_add_keyword(subsection, keyword)
     517         9823 :       CALL keyword_release(keyword)
     518              : 
     519         9823 :       CALL section_add_subsection(section, subsection)
     520         9823 :       CALL section_release(subsection)
     521              : 
     522              :       ! PRINT subsection, with keys for neighbor list
     523              :       CALL section_create(subsection, __LOCATION__, name="print", &
     524              :                           description="Section of possible print options in FORCE_MIXING.", &
     525         9823 :                           n_keywords=0, n_subsections=2, repeats=.FALSE.)
     526         9823 :       NULLIFY (print_key)
     527              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "SUBCELL", &
     528              :                                        description="Activates the printing of the subcells used for the "// &
     529              :                                        "generation of neighbor lists.", unit_str="angstrom", &
     530         9823 :                                        print_level=high_print_level, filename="__STD_OUT__")
     531         9823 :       CALL section_add_subsection(subsection, print_key)
     532         9823 :       CALL section_release(print_key)
     533              : 
     534              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "NEIGHBOR_LISTS", &
     535              :                                        description="Activates the printing of the neighbor lists used"// &
     536              :                                        " for the hysteretic region calculations.", &
     537         9823 :                                        print_level=high_print_level, filename="", unit_str="angstrom")
     538         9823 :       CALL section_add_subsection(subsection, print_key)
     539         9823 :       CALL section_release(print_key)
     540              : 
     541         9823 :       CALL section_add_subsection(section, subsection)
     542         9823 :       CALL section_release(subsection)
     543              : 
     544         9823 :    END SUBROUTINE create_qmmm_force_mixing_section
     545              : 
     546              : ! **************************************************************************************************
     547              : !> \brief Input section to create QM kinds sections
     548              : !> \param section ...
     549              : !> \author tlaino
     550              : ! **************************************************************************************************
     551        29469 :    SUBROUTINE create_qmmm_qm_kinds(section)
     552              :       TYPE(section_type), POINTER                        :: section
     553              : 
     554              :       TYPE(keyword_type), POINTER                        :: keyword
     555              : 
     556        29469 :       NULLIFY (keyword)
     557        29469 :       CPASSERT(.NOT. ASSOCIATED(section))
     558              :       CALL section_create(section, __LOCATION__, name="QM_KIND", &
     559              :                           description="Information about the QM kind in the QM/MM scheme", &
     560        29469 :                           n_keywords=3, n_subsections=0, repeats=.TRUE.)
     561              : 
     562              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
     563        29469 :                           description="The QM kind", usage="O", n_var=1, type_of_var=char_t)
     564        29469 :       CALL section_add_keyword(section, keyword)
     565        29469 :       CALL keyword_release(keyword)
     566              : 
     567              :       CALL keyword_create(keyword, __LOCATION__, name="MM_INDEX", &
     568              :                           description="The indexes of the MM atoms that have this kind. This keyword can be"// &
     569              :                           " repeated several times (useful if you have to specify many indexes).", &
     570              :                           usage="MM_INDEX 1 2", &
     571        29469 :                           n_var=-1, type_of_var=integer_t, repeats=.TRUE.)
     572        29469 :       CALL section_add_keyword(section, keyword)
     573        29469 :       CALL keyword_release(keyword)
     574              : 
     575        29469 :    END SUBROUTINE create_qmmm_qm_kinds
     576              : 
     577              : ! **************************************************************************************************
     578              : !> \brief Input section to set QM/MM periodic boundary conditions
     579              : !> \param section ...
     580              : !> \author tlaino
     581              : ! **************************************************************************************************
     582         9823 :    SUBROUTINE create_qmmm_walls_section(section)
     583              :       TYPE(section_type), POINTER                        :: section
     584              : 
     585              :       TYPE(keyword_type), POINTER                        :: keyword
     586              : 
     587         9823 :       NULLIFY (keyword)
     588         9823 :       CPASSERT(.NOT. ASSOCIATED(section))
     589              :       CALL section_create(section, __LOCATION__, name="WALLS", &
     590              :                           description="Enables Walls for the QM box. This can be used to avoid that QM"// &
     591              :                           " atoms move out of the QM box.", &
     592         9823 :                           n_keywords=0, n_subsections=0, repeats=.FALSE.)
     593              : 
     594              :       CALL keyword_create(keyword, __LOCATION__, name="WALL_SKIN", &
     595              :                           description="Specify the value of the skin of the Wall in each dimension. "// &
     596              :                           "The wall's effect is felt when atoms fall within the skin of the Wall.", &
     597              :                           usage="WALL_SKIN <real> <real> <real>", n_var=3, type_of_var=real_t, &
     598              :                           default_r_vals=[cp_unit_to_cp2k(0.5_dp, "angstrom"), &
     599              :                                           cp_unit_to_cp2k(0.5_dp, "angstrom"), &
     600              :                                           cp_unit_to_cp2k(0.5_dp, "angstrom")], &
     601        39292 :                           unit_str="angstrom")
     602         9823 :       CALL section_add_keyword(section, keyword)
     603         9823 :       CALL keyword_release(keyword)
     604              : 
     605              :       CALL keyword_create(keyword, __LOCATION__, name="TYPE", &
     606              :                           description="Specifies the type of wall", &
     607              :                           usage="TYPE REFLECTIVE", &
     608              :                           enum_c_vals=s2a("NONE", "REFLECTIVE", "QUADRATIC"), &
     609              :                           enum_i_vals=[do_qmmm_wall_none, do_qmmm_wall_reflective, do_qmmm_wall_quadratic], &
     610              :                           enum_desc=s2a("No Wall around QM box", &
     611              :                                         "Reflective Wall around QM box", &
     612              :                                         "Quadratic Wall around QM box"), &
     613         9823 :                           default_i_val=do_qmmm_wall_reflective)
     614         9823 :       CALL section_add_keyword(section, keyword)
     615         9823 :       CALL keyword_release(keyword)
     616              : 
     617              :       CALL keyword_create(keyword, __LOCATION__, name="K", &
     618              :                           description="Specify the value of the the force constant for the quadratic wall", &
     619              :                           usage="K <real>", unit_str='internal_cp2k', &
     620         9823 :                           type_of_var=real_t)
     621         9823 :       CALL section_add_keyword(section, keyword)
     622         9823 :       CALL keyword_release(keyword)
     623              : 
     624         9823 :    END SUBROUTINE create_qmmm_walls_section
     625              : 
     626              : ! ****************************************************************************
     627              : !> \brief Input section for QM/MM image charge calculations
     628              : !> \param section ...
     629              : !> \author Dorothea Golze
     630              : ! **************************************************************************************************
     631         9823 :    SUBROUTINE create_qmmm_image_charge_section(section)
     632              :       TYPE(section_type), POINTER                        :: section
     633              : 
     634              :       TYPE(keyword_type), POINTER                        :: keyword
     635              :       TYPE(section_type), POINTER                        :: subsection
     636              : 
     637         9823 :       NULLIFY (keyword, subsection)
     638         9823 :       CPASSERT(.NOT. ASSOCIATED(section))
     639              :       CALL section_create(section, __LOCATION__, name="IMAGE_CHARGE", &
     640              :                           description="Inclusion of polarization effects within the image charge "// &
     641              :                           "approach for systems where QM molecules are physisorbed on e.g. metal "// &
     642              :                           "surfaces described by MM. This correction introduces only a very small overhead. "// &
     643              :                           "QM box size has to be equal to MM box size.", &
     644              :                           n_keywords=3, n_subsections=1, repeats=.FALSE., &
     645        19646 :                           citations=[Golze2013])
     646              : 
     647              :       CALL keyword_create(keyword, __LOCATION__, name="MM_ATOM_LIST", &
     648              :                           description="List of MM atoms carrying an induced Gaussian charge. "// &
     649              :                           "If this keyword is not given, all MM atoms will carry an image charge.", &
     650              :                           usage="MM_ATOM_LIST 1 2 3 or 1..3 ", n_var=-1, type_of_var=integer_t, &
     651         9823 :                           repeats=.TRUE.)
     652         9823 :       CALL section_add_keyword(section, keyword)
     653         9823 :       CALL keyword_release(keyword)
     654              : 
     655              :       CALL keyword_create(keyword, __LOCATION__, name="WIDTH", &
     656              :                           description="Specifies the value of the width of the (induced) Gaussian "// &
     657              :                           "charge distribution carried by each MM atom.", &
     658              :                           usage="WIDTH <real> ", n_var=1, type_of_var=real_t, &
     659              :                           default_r_val=cp_unit_to_cp2k(value=3.0_dp, unit_str="angstrom^-2"), &
     660         9823 :                           unit_str="angstrom^-2")
     661         9823 :       CALL section_add_keyword(section, keyword)
     662         9823 :       CALL keyword_release(keyword)
     663              : 
     664              :       CALL keyword_create(keyword, __LOCATION__, name="EXT_POTENTIAL", &
     665              :                           description="External potential applied to the metal electrode ", &
     666              :                           usage="EXT_POTENTIAL <real> ", n_var=1, type_of_var=real_t, &
     667              :                           default_r_val=0.0_dp, &
     668         9823 :                           unit_str="volt")
     669         9823 :       CALL section_add_keyword(section, keyword)
     670         9823 :       CALL keyword_release(keyword)
     671              : 
     672              :       CALL keyword_create(keyword, __LOCATION__, name="DETERM_COEFF", &
     673              :                           description="Specifies how the coefficients are determined.", &
     674              :                           usage="DETERM_COEFF ITERATIVE", &
     675              :                           enum_c_vals=s2a("CALC_MATRIX", "ITERATIVE"), &
     676              :                           enum_i_vals=[do_qmmm_image_calcmatrix, do_qmmm_image_iter], &
     677              :                           enum_desc=s2a("Calculates image matrix and solves linear set of equations", &
     678              :                                         "Uses an iterative scheme to calculate the coefficients"), &
     679         9823 :                           default_i_val=do_qmmm_image_calcmatrix)
     680         9823 :       CALL section_add_keyword(section, keyword)
     681         9823 :       CALL keyword_release(keyword)
     682              : 
     683              :       CALL keyword_create(keyword, __LOCATION__, name="RESTART_IMAGE_MATRIX", &
     684              :                           description="Restart the image matrix. Useful when "// &
     685              :                           "calculating coefficients iteratively (the image matrix "// &
     686              :                           "is used as preconditioner in that case)", &
     687              :                           usage="RESTART_IMAGE_MATRIX", default_l_val=.FALSE., &
     688         9823 :                           lone_keyword_l_val=.TRUE.)
     689         9823 :       CALL section_add_keyword(section, keyword)
     690         9823 :       CALL keyword_release(keyword)
     691              : 
     692              :       CALL keyword_create(keyword, __LOCATION__, name="IMAGE_RESTART_FILE_NAME", &
     693              :                           description="File name where to read the image matrix used "// &
     694              :                           "as preconditioner in the iterative scheme", &
     695              :                           usage="IMAGE_RESTART_FILE_NAME <FILENAME>", &
     696         9823 :                           type_of_var=lchar_t)
     697         9823 :       CALL section_add_keyword(section, keyword)
     698         9823 :       CALL keyword_release(keyword)
     699              : 
     700              :       CALL keyword_create(keyword, __LOCATION__, name="IMAGE_MATRIX_METHOD", &
     701              :                           description="Method for calculating the image matrix.", &
     702              :                           usage="IMAGE_MATRIX_METHOD MME", &
     703              :                           enum_c_vals=s2a("GPW", "MME"), &
     704              :                           enum_i_vals=[do_eri_gpw, do_eri_mme], &
     705              :                           enum_desc=s2a("Uses Gaussian Plane Wave method [Golze2013]", &
     706              :                                         "Uses MiniMax-Ewald method (ERI_MME subsection)"), &
     707         9823 :                           default_i_val=do_eri_mme)
     708         9823 :       CALL section_add_keyword(section, keyword)
     709         9823 :       CALL keyword_release(keyword)
     710              : 
     711              :       ! for qmmm image charges we can afford taking the most accurate minimax approximation
     712         9823 :       CALL create_eri_mme_section(subsection, default_n_minimax=53)
     713         9823 :       CALL section_add_subsection(section, subsection)
     714         9823 :       CALL section_release(subsection)
     715              : 
     716         9823 :    END SUBROUTINE create_qmmm_image_charge_section
     717              : 
     718              : ! **************************************************************************************************
     719              : !> \brief Input section to set QM/MM periodic boundary conditions
     720              : !> \param section ...
     721              : !> \author tlaino
     722              : ! **************************************************************************************************
     723         9823 :    SUBROUTINE create_qmmm_periodic_section(section)
     724              :       TYPE(section_type), POINTER                        :: section
     725              : 
     726              :       TYPE(keyword_type), POINTER                        :: keyword
     727              :       TYPE(section_type), POINTER                        :: subsection
     728              : 
     729         9823 :       NULLIFY (keyword, subsection)
     730         9823 :       CPASSERT(.NOT. ASSOCIATED(section))
     731              :       CALL section_create(section, __LOCATION__, name="PERIODIC", &
     732              :                           description="Specify parameters for QM/MM periodic boundary conditions calculations", &
     733              :                           n_keywords=0, n_subsections=0, repeats=.FALSE., &
     734        19646 :                           citations=[Laino2006])
     735              : 
     736              :       CALL keyword_create( &
     737              :          keyword, __LOCATION__, name="GMAX", &
     738              :          description="Specifies the maximum value of G in the reciprocal space over which perform the Ewald sum.", &
     739         9823 :          usage="GMAX <real>", n_var=1, default_r_val=1.0_dp)
     740         9823 :       CALL section_add_keyword(section, keyword)
     741         9823 :       CALL keyword_release(keyword)
     742              : 
     743              :       CALL keyword_create(keyword, __LOCATION__, name="REPLICA", &
     744              :                           description="Specifies the number of replica to take into consideration for the real part of the "// &
     745              :                           "calculation. Default is letting the qmmm module decide how many replica you really need.", &
     746         9823 :                           usage="REPLICA <integer>", n_var=1, default_i_val=-1)
     747         9823 :       CALL section_add_keyword(section, keyword)
     748         9823 :       CALL keyword_release(keyword)
     749              : 
     750              :       CALL keyword_create(keyword, __LOCATION__, name="NGRIDS", &
     751              :                           description="Specifies the number of grid points used for the Interpolation of the G-space term", &
     752         9823 :                           usage="NGRIDS <integer> <integer> <integer> ", n_var=3, default_i_vals=[50, 50, 50])
     753         9823 :       CALL section_add_keyword(section, keyword)
     754         9823 :       CALL keyword_release(keyword)
     755              : 
     756         9823 :       CALL create_multipole_qmmm_section(subsection)
     757         9823 :       CALL section_add_subsection(section, subsection)
     758         9823 :       CALL section_release(subsection)
     759              : 
     760         9823 :       CALL create_gspace_interp_section(subsection)
     761         9823 :       CALL section_add_subsection(section, subsection)
     762         9823 :       CALL section_release(subsection)
     763              : 
     764         9823 :       CALL create_poisson_section(subsection)
     765         9823 :       CALL section_add_subsection(section, subsection)
     766         9823 :       CALL section_release(subsection)
     767              : 
     768              :       CALL cp_print_key_section_create(subsection, __LOCATION__, "check_spline", &
     769              :                                        description="Controls the checking of the G-space term Spline Interpolation.", &
     770         9823 :                                        print_level=medium_print_level, filename="GSpace-SplInterp")
     771         9823 :       CALL section_add_subsection(section, subsection)
     772         9823 :       CALL section_release(subsection)
     773              : 
     774         9823 :    END SUBROUTINE create_qmmm_periodic_section
     775              : 
     776              : ! **************************************************************************************************
     777              : !> \brief Section to set-up parameters for decoupling using the Bloechl scheme
     778              : !> \param section the section to create
     779              : !> \par History
     780              : !>      Dorothea Golze [04.2014] copied from input_cp2k_poisson.F and
     781              : !>      enabled switch-on/off
     782              : !> \author teo
     783              : ! **************************************************************************************************
     784         9823 :    SUBROUTINE create_multipole_qmmm_section(section)
     785              :       TYPE(section_type), POINTER                        :: section
     786              : 
     787              :       TYPE(keyword_type), POINTER                        :: keyword
     788              :       TYPE(section_type), POINTER                        :: subsection
     789              : 
     790         9823 :       CPASSERT(.NOT. ASSOCIATED(section))
     791              : 
     792              :       CALL section_create(section, __LOCATION__, name="MULTIPOLE", &
     793              :                           description="This section is used to set up the decoupling of QM periodic images with "// &
     794              :                           "the use of density derived atomic point charges. Switched on by default even if not "// &
     795              :                           "explicitly given. Can be switched off if e.g. QM and MM box are of the same size.", &
     796         9823 :                           n_keywords=1, n_subsections=0, repeats=.FALSE.)
     797              : 
     798         9823 :       NULLIFY (keyword, subsection)
     799              :       CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
     800              :                           description="Defines the usage of the multipole section", &
     801              :                           usage="ON", &
     802              :                           enum_c_vals=s2a("ON", "OFF"), &
     803              :                           enum_i_vals=[do_multipole_section_on, do_multipole_section_off], &
     804              :                           enum_desc=s2a("switch on MULTIPOLE section", &
     805              :                                         "switch off MULTIPOLE section"), &
     806         9823 :                           default_i_val=do_multipole_section_on, lone_keyword_i_val=do_multipole_section_on)
     807         9823 :       CALL section_add_keyword(section, keyword)
     808         9823 :       CALL keyword_release(keyword)
     809              : 
     810              :       CALL keyword_create(keyword, __LOCATION__, name="RCUT", &
     811              :                           description="Real space cutoff for the Ewald sum.", &
     812              :                           usage="RCUT {real}", n_var=1, type_of_var=real_t, &
     813         9823 :                           unit_str="angstrom")
     814         9823 :       CALL section_add_keyword(section, keyword)
     815         9823 :       CALL keyword_release(keyword)
     816              : 
     817              :       CALL keyword_create(keyword, __LOCATION__, name="EWALD_PRECISION", &
     818              :                           description="Precision achieved in the Ewald sum.", &
     819              :                           usage="EWALD_PRECISION {real}", n_var=1, type_of_var=real_t, &
     820         9823 :                           unit_str="hartree", default_r_val=1.0E-6_dp)
     821         9823 :       CALL section_add_keyword(section, keyword)
     822         9823 :       CALL keyword_release(keyword)
     823              : 
     824              :       CALL keyword_create(keyword, __LOCATION__, name="ANALYTICAL_GTERM", &
     825              :                           description="Evaluates the Gterm in the Ewald Scheme analytically instead of using Splines.", &
     826              :                           usage="ANALYTICAL_GTERM <LOGICAL>", &
     827         9823 :                           default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     828         9823 :       CALL section_add_keyword(section, keyword)
     829         9823 :       CALL keyword_release(keyword)
     830              : 
     831              :       CALL keyword_create(keyword, __LOCATION__, name="NGRIDS", &
     832              :                           description="Specifies the number of grid points used for the Interpolation of the G-space term", &
     833         9823 :                           usage="NGRIDS <integer> <integer> <integer> ", n_var=3, default_i_vals=[50, 50, 50])
     834         9823 :       CALL section_add_keyword(section, keyword)
     835         9823 :       CALL keyword_release(keyword)
     836              : 
     837         9823 :       CALL create_gspace_interp_section(subsection)
     838         9823 :       CALL section_add_subsection(section, subsection)
     839         9823 :       CALL section_release(subsection)
     840              : 
     841              :       CALL cp_print_key_section_create(subsection, __LOCATION__, "check_spline", &
     842              :                                        description="Controls the checking of the G-space term Spline Interpolation.", &
     843         9823 :                                        print_level=medium_print_level, filename="GSpace-SplInterp")
     844         9823 :       CALL section_add_subsection(section, subsection)
     845         9823 :       CALL section_release(subsection)
     846              : 
     847              :       CALL cp_print_key_section_create(subsection, __LOCATION__, "program_run_info", &
     848              :                                        description="Controls the printing of basic information during the run", &
     849         9823 :                                        print_level=low_print_level, add_last=add_last_numeric, filename="__STD_OUT__")
     850         9823 :       CALL section_add_subsection(section, subsection)
     851         9823 :       CALL section_release(subsection)
     852              : 
     853         9823 :    END SUBROUTINE create_multipole_qmmm_section
     854              : 
     855              : ! **************************************************************************************************
     856              : !> \brief creates the qm/mm forcefield section to override to the FF specification
     857              : !>      given in the FIST input
     858              : !> \param section ...
     859              : !> \author tlaino
     860              : ! **************************************************************************************************
     861         9823 :    SUBROUTINE create_qmmm_forcefield_section(section)
     862              :       TYPE(section_type), POINTER                        :: section
     863              : 
     864              :       TYPE(keyword_type), POINTER                        :: keyword
     865              :       TYPE(section_type), POINTER                        :: subsection
     866              : 
     867         9823 :       NULLIFY (subsection, keyword)
     868         9823 :       CPASSERT(.NOT. ASSOCIATED(section))
     869              :       CALL section_create(section, __LOCATION__, name="FORCEFIELD", &
     870              :                           description="Specify information on the QM/MM forcefield", &
     871         9823 :                           n_keywords=0, n_subsections=2, repeats=.TRUE.)
     872              : 
     873              :       CALL keyword_create(keyword, __LOCATION__, name="MULTIPLE_POTENTIAL", &
     874              :                           description="Enables the possibility to define NONBONDED and NONBONDED14 as a"// &
     875              :                           " sum of different kinds of potential. Useful for piecewise defined potentials.", &
     876         9823 :                           usage="MULTIPLE_POTENTIAL T", default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
     877         9823 :       CALL section_add_keyword(section, keyword)
     878         9823 :       CALL keyword_release(keyword)
     879              : 
     880         9823 :       CALL create_qmmm_ff_nb_section(subsection)
     881         9823 :       CALL section_add_subsection(section, subsection)
     882         9823 :       CALL section_release(subsection)
     883              : 
     884         9823 :       CALL create_NONBONDED14_section(subsection)
     885         9823 :       CALL section_add_subsection(section, subsection)
     886         9823 :       CALL section_release(subsection)
     887              : 
     888         9823 :    END SUBROUTINE create_qmmm_forcefield_section
     889              : 
     890              : ! **************************************************************************************************
     891              : !> \brief creates the qm/mm forcefield section to override to the FF specification
     892              : !>      given in the FIST input - NONBONDED PART
     893              : !> \param section ...
     894              : !> \author tlaino
     895              : ! **************************************************************************************************
     896         9823 :    SUBROUTINE create_qmmm_ff_nb_section(section)
     897              :       TYPE(section_type), POINTER                        :: section
     898              : 
     899              :       TYPE(section_type), POINTER                        :: subsection
     900              : 
     901         9823 :       NULLIFY (subsection)
     902         9823 :       CPASSERT(.NOT. ASSOCIATED(section))
     903              :       CALL section_create(section, __LOCATION__, name="NONBONDED", &
     904              :                           description="Specify information on the QM/MM non-bonded forcefield", &
     905         9823 :                           n_keywords=0, n_subsections=2, repeats=.TRUE.)
     906              : 
     907         9823 :       CALL create_LJ_section(subsection)
     908         9823 :       CALL section_add_subsection(section, subsection)
     909         9823 :       CALL section_release(subsection)
     910              : 
     911         9823 :       CALL create_Williams_section(subsection)
     912         9823 :       CALL section_add_subsection(section, subsection)
     913         9823 :       CALL section_release(subsection)
     914              : 
     915         9823 :       CALL create_Goodwin_section(subsection)
     916         9823 :       CALL section_add_subsection(section, subsection)
     917         9823 :       CALL section_release(subsection)
     918              : 
     919         9823 :       CALL create_GENPOT_section(subsection)
     920         9823 :       CALL section_add_subsection(section, subsection)
     921         9823 :       CALL section_release(subsection)
     922              : 
     923         9823 :    END SUBROUTINE create_qmmm_ff_nb_section
     924              : 
     925              : ! **************************************************************************************************
     926              : !> \brief creates the qm/mm link section
     927              : !> \param section ...
     928              : !> \author tlaino
     929              : ! **************************************************************************************************
     930        29469 :    SUBROUTINE create_qmmm_link_section(section)
     931              :       TYPE(section_type), POINTER                        :: section
     932              : 
     933              :       TYPE(keyword_type), POINTER                        :: keyword
     934              :       TYPE(section_type), POINTER                        :: subsection
     935              : 
     936        29469 :       NULLIFY (keyword, subsection)
     937        29469 :       CPASSERT(.NOT. ASSOCIATED(section))
     938              :       CALL section_create(section, __LOCATION__, name="LINK", &
     939              :                           description="Specify information on the QM/MM link treatment", &
     940        29469 :                           n_keywords=7, n_subsections=2, repeats=.TRUE.)
     941              : 
     942              :       CALL keyword_create(keyword, __LOCATION__, name="QM_INDEX", &
     943              :                           variants=["QM"], &
     944              :                           description="Specifies the index of the QM atom involved in the QM/MM link", &
     945        58938 :                           usage="QM_INDEX integer", n_var=1, type_of_var=integer_t)
     946        29469 :       CALL section_add_keyword(section, keyword)
     947        29469 :       CALL keyword_release(keyword)
     948              : 
     949              :       CALL keyword_create(keyword, __LOCATION__, name="QM_KIND", &
     950              :                           description="Specifies the element of the QM capping atom involved in the QM/MM link", &
     951              :                           usage="QM_KIND char", n_var=1, type_of_var=char_t, &
     952        29469 :                           default_c_val="H")
     953        29469 :       CALL section_add_keyword(section, keyword)
     954        29469 :       CALL keyword_release(keyword)
     955              : 
     956              :       CALL keyword_create(keyword, __LOCATION__, name="MM_INDEX", &
     957              :                           variants=["MM"], &
     958              :                           description="Specifies the index of the MM atom involved in the QM/MM link, Default hydrogen.", &
     959        58938 :                           usage="MM_INDEX integer", n_var=1, type_of_var=integer_t)
     960        29469 :       CALL section_add_keyword(section, keyword)
     961        29469 :       CALL keyword_release(keyword)
     962              : 
     963              :       CALL keyword_create(keyword, __LOCATION__, name="RADIUS", &
     964              :                           description="Overwrite the specification of the radius only for the MM atom involved in the link. "// &
     965              :                           "Default is to use the same radius as for the specified type.", &
     966        29469 :                           usage="RADIUS real", n_var=1, type_of_var=real_t, unit_str="angstrom")
     967        29469 :       CALL section_add_keyword(section, keyword)
     968        29469 :       CALL keyword_release(keyword)
     969              : 
     970              :       CALL keyword_create( &
     971              :          keyword, __LOCATION__, name="CORR_RADIUS", &
     972              :          description="Overwrite the specification of the correction radius only for the MM atom involved in the link. "// &
     973              :          "Default is to use the same correction radius as for the specified type.", &
     974        29469 :          usage="CORR_RADIUS real", n_var=1, type_of_var=real_t, unit_str="angstrom")
     975        29469 :       CALL section_add_keyword(section, keyword)
     976        29469 :       CALL keyword_release(keyword)
     977              : 
     978              :       CALL keyword_create(keyword, __LOCATION__, name="LINK_TYPE", &
     979              :                           variants=["LINK ", "TYPE ", "LTYPE"], &
     980              :                           description="Specifies the method to use to treat the defined QM/MM link", &
     981              :                           usage="LINK_TYPE char", &
     982              :                           enum_c_vals=s2a("IMOMM", "GHO", "PSEUDO"), &
     983              :                           enum_i_vals=[do_qmmm_link_imomm, do_qmmm_link_gho, do_qmmm_link_pseudo], &
     984              :                           enum_desc=s2a("Use Integrated Molecular Orbital Molecular Mechanics method", &
     985              :                                         "Use Generalized Hybrid Orbital method", &
     986              :                                         "Use a monovalent pseudo-potential"), &
     987       117876 :                           default_i_val=do_qmmm_link_imomm)
     988        29469 :       CALL section_add_keyword(section, keyword)
     989        29469 :       CALL keyword_release(keyword)
     990              : 
     991              :       CALL keyword_create(keyword, __LOCATION__, name="ALPHA_IMOMM", &
     992              :                           variants=s2a("ALPHA"), &
     993              :                           description="Specifies the scaling factor to be used for projecting the forces "// &
     994              :                           "on the capping hydrogen in the IMOMM QM/MM link scheme to the MM atom of the link. "// &
     995              :                           "A good guess can be derived from the bond distances of the forcefield: "// &
     996              :                           "alpha = r_eq(QM-MM) / r_eq(QM-H).", &
     997              :                           usage="ALPHA_IMOMM real", n_var=1, type_of_var=real_t, &
     998        29469 :                           default_r_val=ALPHA_IMOMM_DEFAULT)
     999        29469 :       CALL section_add_keyword(section, keyword)
    1000        29469 :       CALL keyword_release(keyword)
    1001              : 
    1002              :       CALL keyword_create(keyword, __LOCATION__, name="QMMM_SCALE_FACTOR", &
    1003              :                           variants=["QMMM_CHARGE_SCALE ", &
    1004              :                                     "QMMM_CHARGE_FACTOR", &
    1005              :                                     "QMMM_SCALE_CHARGE "], &
    1006              :                           description="Specifies the scaling factor for the MM charge involved in the link QM/MM."// &
    1007              :                           " This keyword affects only the QM/MM potential, it doesn't affect the electrostatic in"// &
    1008              :                           " the classical part of the code."// &
    1009              :                           " Default 1.0 i.e. no charge rescaling of the MM atom of the QM/MM link bond.", &
    1010              :                           usage="QMMM_SCALE_FACTOR real", n_var=1, type_of_var=real_t, &
    1011       117876 :                           default_r_val=CHARGE_SCALE_FACTOR)
    1012        29469 :       CALL section_add_keyword(section, keyword)
    1013        29469 :       CALL keyword_release(keyword)
    1014              : 
    1015              :       CALL keyword_create(keyword, __LOCATION__, name="FIST_SCALE_FACTOR", &
    1016              :                           variants=["FIST_CHARGE_SCALE ", &
    1017              :                                     "FIST_CHARGE_FACTOR", &
    1018              :                                     "FIST_SCALE_CHARGE "], &
    1019              :                           description="Specifies the scaling factor for the MM charge involved in the link QM/MM."// &
    1020              :                           " This keyword modifies the MM charge in FIST. The modified charge will be used then also"// &
    1021              :                           " for the generation of the QM/MM potential. "// &
    1022              :                           "Default 1.0 i.e. no charge rescaling of the MM atom of the QM/MM link bond.", &
    1023              :                           usage="FIST_SCALE_FACTOR real", n_var=1, type_of_var=real_t, &
    1024       117876 :                           default_r_val=CHARGE_SCALE_FACTOR)
    1025        29469 :       CALL section_add_keyword(section, keyword)
    1026        29469 :       CALL keyword_release(keyword)
    1027              : 
    1028              :       CALL section_create(subsection, __LOCATION__, name="MOVE_MM_CHARGE", &
    1029              :                           description="Specify information to move a classical charge before the"// &
    1030              :                           " QM/MM energies and forces evaluation", &
    1031        29469 :                           n_keywords=4, n_subsections=0, repeats=.TRUE.)
    1032              : 
    1033              :       CALL keyword_create(keyword, __LOCATION__, name="ATOM_INDEX_1", &
    1034              :                           variants=["MM1"], &
    1035              :                           description="Specifies the index of the MM atom involved in the QM/MM link to be moved", &
    1036        58938 :                           usage="ATOM_INDEX_1 integer", n_var=1, type_of_var=integer_t)
    1037        29469 :       CALL section_add_keyword(subsection, keyword)
    1038        29469 :       CALL keyword_release(keyword)
    1039              : 
    1040              :       CALL keyword_create(keyword, __LOCATION__, name="ATOM_INDEX_2", &
    1041              :                           variants=["MM2"], &
    1042              :                           description="Specifies the index of the second atom defining the direction along which"// &
    1043              :                           " the atom will be moved", &
    1044        58938 :                           usage="ATOM_INDEX_2 integer", n_var=1, type_of_var=integer_t)
    1045        29469 :       CALL section_add_keyword(subsection, keyword)
    1046        29469 :       CALL keyword_release(keyword)
    1047              : 
    1048              :       CALL keyword_create(keyword, __LOCATION__, name="ALPHA", &
    1049              :                           description="Specifies the scaling factor that defines the movement along the defined direction", &
    1050        29469 :                           usage="ALPHA real", n_var=1, type_of_var=real_t)
    1051        29469 :       CALL section_add_keyword(subsection, keyword)
    1052        29469 :       CALL keyword_release(keyword)
    1053              : 
    1054              :       CALL keyword_create(keyword, __LOCATION__, name="RADIUS", &
    1055              :                           description="Specifies the radius used for the QM/MM electrostatic coupling after movement", &
    1056        29469 :                           usage="RADIUS real", n_var=1, type_of_var=real_t, unit_str="angstrom", default_r_val=0.0_dp)
    1057        29469 :       CALL section_add_keyword(subsection, keyword)
    1058        29469 :       CALL keyword_release(keyword)
    1059              : 
    1060              :       CALL keyword_create(keyword, __LOCATION__, name="CORR_RADIUS", &
    1061              :                           description="Specifies the correction radius used for the QM/MM electrostatic coupling after movement", &
    1062        29469 :                           usage="CORR_RADIUS real", n_var=1, type_of_var=real_t, unit_str="angstrom", default_r_val=0.0_dp)
    1063        29469 :       CALL section_add_keyword(subsection, keyword)
    1064        29469 :       CALL keyword_release(keyword)
    1065              : 
    1066        29469 :       CALL section_add_subsection(section, subsection)
    1067        29469 :       CALL section_release(subsection)
    1068              : 
    1069              :       CALL section_create(subsection, __LOCATION__, name="ADD_MM_CHARGE", &
    1070              :                           description="Specify information to add a classical charge before the"// &
    1071              :                           " QM/MM energies and forces evaluation", &
    1072        29469 :                           n_keywords=5, n_subsections=0, repeats=.TRUE.)
    1073              : 
    1074              :       CALL keyword_create(keyword, __LOCATION__, name="ATOM_INDEX_1", &
    1075              :                           variants=["MM1"], &
    1076              :                           description="Specifies the index of the first atom defining the direction along which"// &
    1077              :                           " the atom will be added", &
    1078        58938 :                           usage="ATOM_INDEX_1 integer", n_var=1, type_of_var=integer_t)
    1079        29469 :       CALL section_add_keyword(subsection, keyword)
    1080        29469 :       CALL keyword_release(keyword)
    1081              : 
    1082              :       CALL keyword_create(keyword, __LOCATION__, name="ATOM_INDEX_2", &
    1083              :                           variants=["MM2"], &
    1084              :                           description="Specifies the index of the second atom defining the direction along which"// &
    1085              :                           " the atom will be added", &
    1086        58938 :                           usage="ATOM_INDEX_2 integer", n_var=1, type_of_var=integer_t)
    1087        29469 :       CALL section_add_keyword(subsection, keyword)
    1088        29469 :       CALL keyword_release(keyword)
    1089              : 
    1090              :       CALL keyword_create(keyword, __LOCATION__, name="ALPHA", &
    1091              :                           description="Specifies the scaling factor that defines the movement along the defined direction", &
    1092        29469 :                           usage="ALPHA real", n_var=1, type_of_var=real_t)
    1093        29469 :       CALL section_add_keyword(subsection, keyword)
    1094        29469 :       CALL keyword_release(keyword)
    1095              : 
    1096              :       CALL keyword_create(keyword, __LOCATION__, name="RADIUS", &
    1097              :                           description="Specifies the radius used for the QM/MM electrostatic coupling for the added source", &
    1098              :                           usage="RADIUS real", n_var=1, unit_str="angstrom", &
    1099        29469 :                           default_r_val=cp_unit_to_cp2k(RADIUS_QMMM_DEFAULT, "angstrom"))
    1100        29469 :       CALL section_add_keyword(subsection, keyword)
    1101        29469 :       CALL keyword_release(keyword)
    1102              : 
    1103              :       CALL keyword_create( &
    1104              :          keyword, __LOCATION__, name="CORR_RADIUS", &
    1105              :          description="Specifies the correction radius used for the QM/MM electrostatic coupling for the added source", &
    1106              :          usage="CORR_RADIUS real", n_var=1, unit_str="angstrom", &
    1107        29469 :          default_r_val=cp_unit_to_cp2k(RADIUS_QMMM_DEFAULT, "angstrom"))
    1108        29469 :       CALL section_add_keyword(subsection, keyword)
    1109        29469 :       CALL keyword_release(keyword)
    1110              : 
    1111              :       CALL keyword_create(keyword, __LOCATION__, name="CHARGE", &
    1112              :                           description="Specifies the charge for the added source of QM/MM potential", &
    1113        29469 :                           usage="CHARGE real", default_r_val=0.0_dp, n_var=1, type_of_var=real_t)
    1114        29469 :       CALL section_add_keyword(subsection, keyword)
    1115        29469 :       CALL keyword_release(keyword)
    1116              : 
    1117        29469 :       CALL section_add_subsection(section, subsection)
    1118        29469 :       CALL section_release(subsection)
    1119        29469 :    END SUBROUTINE create_qmmm_link_section
    1120              : 
    1121              : ! **************************************************************************************************
    1122              : !> \brief creates the interpolation section
    1123              : !> \param section ...
    1124              : !> \author tlaino
    1125              : ! **************************************************************************************************
    1126         9823 :    SUBROUTINE create_qmmm_interp_section(section)
    1127              :       TYPE(section_type), POINTER                        :: section
    1128              : 
    1129              :       TYPE(keyword_type), POINTER                        :: keyword
    1130              :       TYPE(section_type), POINTER                        :: print_key
    1131              : 
    1132         9823 :       CPASSERT(.NOT. ASSOCIATED(section))
    1133              :       CALL section_create(section, __LOCATION__, name="interpolator", &
    1134              :                           description="kind of interpolation used between the multigrids", &
    1135         9823 :                           n_keywords=5, n_subsections=0, repeats=.FALSE.)
    1136              : 
    1137         9823 :       NULLIFY (keyword, print_key)
    1138              : 
    1139              :       CALL keyword_create(keyword, __LOCATION__, name="kind", &
    1140              :                           description="the interpolator to use", &
    1141              :                           usage="kind spline3", &
    1142              :                           default_i_val=spline3_nopbc_interp, &
    1143              :                           enum_c_vals=s2a("spline3_nopbc"), &
    1144         9823 :                           enum_i_vals=[spline3_nopbc_interp])
    1145         9823 :       CALL section_add_keyword(section, keyword)
    1146         9823 :       CALL keyword_release(keyword)
    1147              : 
    1148              :       CALL keyword_create(keyword, __LOCATION__, name="safe_computation", &
    1149              :                           description="if a non unrolled calculation is to be performed in parallel", &
    1150              :                           usage="safe_computation OFF", &
    1151              :                           default_l_val=.FALSE., &
    1152         9823 :                           lone_keyword_l_val=.TRUE.)
    1153         9823 :       CALL section_add_keyword(section, keyword)
    1154         9823 :       CALL keyword_release(keyword)
    1155              : 
    1156              :       CALL keyword_create(keyword, __LOCATION__, name="aint_precond", &
    1157              :                           description="the approximate inverse to use to get the starting point"// &
    1158              :                           " for the linear solver of the spline3 methods", &
    1159              :                           usage="aint_precond copy", &
    1160              :                           default_i_val=precond_spl3_aint, &
    1161              :                           enum_c_vals=s2a("copy", "spl3_nopbc_aint1", "spl3_nopbc_precond1", &
    1162              :                                           "spl3_nopbc_aint2", "spl3_nopbc_precond2", "spl3_nopbc_precond3"), &
    1163              :                           enum_i_vals=[no_precond, precond_spl3_aint, precond_spl3_1, &
    1164         9823 :                                        precond_spl3_aint2, precond_spl3_2, precond_spl3_3])
    1165         9823 :       CALL section_add_keyword(section, keyword)
    1166         9823 :       CALL keyword_release(keyword)
    1167              : 
    1168              :       CALL keyword_create(keyword, __LOCATION__, name="precond", &
    1169              :                           description="The preconditioner used"// &
    1170              :                           " for the linear solver of the spline3 methods", &
    1171              :                           usage="precond copy", &
    1172              :                           default_i_val=precond_spl3_3, &
    1173              :                           enum_c_vals=s2a("copy", "spl3_nopbc_aint1", "spl3_nopbc_precond1", &
    1174              :                                           "spl3_nopbc_aint2", "spl3_nopbc_precond2", "spl3_nopbc_precond3"), &
    1175              :                           enum_i_vals=[no_precond, precond_spl3_aint, precond_spl3_1, &
    1176         9823 :                                        precond_spl3_aint2, precond_spl3_2, precond_spl3_3])
    1177         9823 :       CALL section_add_keyword(section, keyword)
    1178         9823 :       CALL keyword_release(keyword)
    1179              : 
    1180              :       CALL keyword_create(keyword, __LOCATION__, name="eps_x", &
    1181              :                           description="accuracy on the solution for spline3 the interpolators", &
    1182         9823 :                           usage="eps_x 1.e-15", default_r_val=1.e-10_dp)
    1183         9823 :       CALL section_add_keyword(section, keyword)
    1184         9823 :       CALL keyword_release(keyword)
    1185              : 
    1186              :       CALL keyword_create(keyword, __LOCATION__, name="eps_r", &
    1187              :                           description="accuracy on the residual for spline3 the interpolators", &
    1188         9823 :                           usage="eps_r 1.e-15", default_r_val=1.e-10_dp)
    1189         9823 :       CALL section_add_keyword(section, keyword)
    1190         9823 :       CALL keyword_release(keyword)
    1191              : 
    1192              :       CALL keyword_create(keyword, __LOCATION__, name="max_iter", &
    1193              :                           variants=['maxiter'], &
    1194              :                           description="the maximum number of iterations", &
    1195        19646 :                           usage="max_iter 200", default_i_val=100)
    1196         9823 :       CALL section_add_keyword(section, keyword)
    1197         9823 :       CALL keyword_release(keyword)
    1198              : 
    1199         9823 :       NULLIFY (print_key)
    1200              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "conv_info", &
    1201              :                                        description="if convergence information about the linear solver"// &
    1202              :                                        " of the spline methods should be printed", &
    1203              :                                        print_level=medium_print_level, each_iter_names=s2a("SPLINE_FIND_COEFFS"), &
    1204              :                                        each_iter_values=[10], filename="__STD_OUT__", &
    1205         9823 :                                        add_last=add_last_numeric)
    1206         9823 :       CALL section_add_subsection(section, print_key)
    1207         9823 :       CALL section_release(print_key)
    1208              : 
    1209              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "spl_coeffs", &
    1210              :                                        description="outputs a cube with the coefficients calculated for "// &
    1211              :                                        "the spline interpolation", &
    1212         9823 :                                        print_level=debug_print_level)
    1213         9823 :       CALL section_add_subsection(section, print_key)
    1214         9823 :       CALL section_release(print_key)
    1215         9823 :    END SUBROUTINE create_qmmm_interp_section
    1216              : 
    1217              : ! **************************************************************************************************
    1218              : !> \brief Create the print qmmm section
    1219              : !> \param section the section to create
    1220              : !> \author teo
    1221              : ! **************************************************************************************************
    1222         9823 :    SUBROUTINE create_print_qmmm_section(section)
    1223              :       TYPE(section_type), POINTER                        :: section
    1224              : 
    1225              :       TYPE(keyword_type), POINTER                        :: keyword
    1226              :       TYPE(section_type), POINTER                        :: print_key
    1227              : 
    1228         9823 :       CPASSERT(.NOT. ASSOCIATED(section))
    1229         9823 :       NULLIFY (keyword, print_key)
    1230              :       CALL section_create(section, __LOCATION__, name="print", &
    1231              :                           description="Section of possible print options specific of the QMMM code.", &
    1232         9823 :                           n_keywords=0, n_subsections=1, repeats=.FALSE.)
    1233              : 
    1234         9823 :       NULLIFY (print_key)
    1235              : 
    1236              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "DIPOLE", &
    1237              :                                        description="Controls the printing of the DIPOLE in a QM/MM calculations."// &
    1238              :                                        " It requires that the DIPOLE calculations is"// &
    1239              :                                        " requested both for the QS  and for the MM  part.", &
    1240         9823 :                                        print_level=high_print_level, filename="__STD_OUT__")
    1241         9823 :       CALL section_add_subsection(section, print_key)
    1242         9823 :       CALL section_release(print_key)
    1243              : 
    1244              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "PGF", &
    1245              :                                        description="Controls the printing of the gaussian expansion basis set of the"// &
    1246              :                                        " electrostatic potential", &
    1247         9823 :                                        print_level=high_print_level, filename="__STD_OUT__")
    1248         9823 :       CALL section_add_subsection(section, print_key)
    1249         9823 :       CALL section_release(print_key)
    1250              : 
    1251              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "POTENTIAL", &
    1252              :                                        description="Controls the printing of the QMMM  potential", &
    1253              :                                        print_level=high_print_level, filename="MM_ELPOT_QMMM", &
    1254         9823 :                                        common_iter_levels=1)
    1255              : 
    1256              :       CALL keyword_create(keyword, __LOCATION__, name="stride", &
    1257              :                           description="The stride (X,Y,Z) used to write the cube file "// &
    1258              :                           "(larger values result in smaller cube files). You can provide 3 numbers (for X,Y,Z) or"// &
    1259              :                           " 1 number valid for all components.", &
    1260         9823 :                           usage="STRIDE 2 2 2", n_var=-1, default_i_vals=[2, 2, 2], type_of_var=integer_t)
    1261         9823 :       CALL section_add_keyword(print_key, keyword)
    1262         9823 :       CALL keyword_release(keyword)
    1263              : 
    1264         9823 :       CALL section_add_subsection(section, print_key)
    1265         9823 :       CALL section_release(print_key)
    1266              : 
    1267              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "MM_POTENTIAL", &
    1268              :                                        description="Controls the printing of the MM unidimensional potential on file", &
    1269              :                                        print_level=high_print_level, filename="MM_ELPOT", &
    1270         9823 :                                        common_iter_levels=1)
    1271         9823 :       CALL section_add_subsection(section, print_key)
    1272         9823 :       CALL section_release(print_key)
    1273              : 
    1274              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "QMMM_MATRIX", &
    1275              :                                        description="Controls the printing of the QMMM 1 electron Hamiltonian Matrix"// &
    1276              :                                        " for methods like semiempirical and DFTB", &
    1277              :                                        print_level=high_print_level, filename="__STD_OUT__", &
    1278         9823 :                                        common_iter_levels=1)
    1279         9823 :       CALL section_add_subsection(section, print_key)
    1280         9823 :       CALL section_release(print_key)
    1281              : 
    1282              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "PROGRAM_BANNER", &
    1283              :                                        description="Controls the printing of the banner of the MM program", &
    1284         9823 :                                        print_level=silent_print_level, filename="__STD_OUT__")
    1285         9823 :       CALL section_add_subsection(section, print_key)
    1286         9823 :       CALL section_release(print_key)
    1287              : 
    1288              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "PROGRAM_RUN_INFO", &
    1289              :                                        description="Controls the printing of information regarding the run.", &
    1290         9823 :                                        print_level=medium_print_level, filename="__STD_OUT__")
    1291         9823 :       CALL section_add_subsection(section, print_key)
    1292         9823 :       CALL section_release(print_key)
    1293              : 
    1294              :       CALL cp_print_key_section_create( &
    1295              :          print_key, __LOCATION__, "PERIODIC_INFO", &
    1296              :          description="Controls the printing of information regarding the periodic boundary condition.", &
    1297         9823 :          print_level=medium_print_level, filename="__STD_OUT__")
    1298         9823 :       CALL section_add_subsection(section, print_key)
    1299         9823 :       CALL section_release(print_key)
    1300              : 
    1301              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "GRID_INFORMATION", &
    1302              :                                        description="Controls the printing of information regarding the PW grid structures"// &
    1303              :                                        " for PERIODIC QM/MM calculations.", &
    1304         9823 :                                        print_level=medium_print_level, filename="__STD_OUT__")
    1305         9823 :       CALL section_add_subsection(section, print_key)
    1306         9823 :       CALL section_release(print_key)
    1307              : 
    1308              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "derivatives", &
    1309              :                                        description="Print all derivatives after QM/MM calculation", &
    1310         9823 :                                        print_level=high_print_level, filename="__STD_OUT__")
    1311         9823 :       CALL section_add_subsection(section, print_key)
    1312         9823 :       CALL section_release(print_key)
    1313              : 
    1314              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "qmmm_charges", &
    1315              :                                        description="Print all charges generating the QM/MM potential", &
    1316         9823 :                                        print_level=medium_print_level, filename="__STD_OUT__")
    1317         9823 :       CALL section_add_subsection(section, print_key)
    1318         9823 :       CALL section_release(print_key)
    1319              : 
    1320              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "qmmm_link_info", &
    1321              :                                        description="Print all information on QM/MM links", &
    1322         9823 :                                        print_level=medium_print_level, filename="__STD_OUT__")
    1323         9823 :       CALL section_add_subsection(section, print_key)
    1324         9823 :       CALL section_release(print_key)
    1325              : 
    1326              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "qs_derivatives", &
    1327              :                                        description="Print QM derivatives after QS calculation", &
    1328         9823 :                                        print_level=medium_print_level, filename="__STD_OUT__")
    1329         9823 :       CALL section_add_subsection(section, print_key)
    1330         9823 :       CALL section_release(print_key)
    1331              : 
    1332              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "image_charge_info", &
    1333              :                                        description="Prints image charge coefficients and detailed energy info", &
    1334         9823 :                                        print_level=high_print_level, filename="__STD_OUT__")
    1335         9823 :       CALL section_add_subsection(section, print_key)
    1336         9823 :       CALL section_release(print_key)
    1337              : 
    1338              :       CALL cp_print_key_section_create(print_key, __LOCATION__, "image_charge_restart", &
    1339              :                                        description="Controls the printing of the restart file for "// &
    1340              :                                        "the image matrix when using the iterative scheme", &
    1341              :                                        print_level=low_print_level, add_last=add_last_numeric, filename="RESTART", &
    1342         9823 :                                        common_iter_levels=3)
    1343         9823 :       CALL section_add_subsection(section, print_key)
    1344         9823 :       CALL section_release(print_key)
    1345              : 
    1346         9823 :    END SUBROUTINE create_print_qmmm_section
    1347              : 
    1348              : END MODULE input_cp2k_qmmm
        

Generated by: LCOV version 2.0-1