CP2K 2.4 (Revision 12889)

input_cp2k_mixed.f90

Go to the documentation of this file.
00001 !-----------------------------------------------------------------------------!
00002 !   CP2K: A general program to perform molecular dynamics simulations         !
00003 !   Copyright (C) 2000 - 2013  CP2K developers group                          !
00004 !-----------------------------------------------------------------------------!
00005 
00006 ! *****************************************************************************
00012 MODULE input_cp2k_mixed
00013   USE cp_output_handling,              ONLY: cp_print_key_section_create
00014   USE f77_blas
00015   USE input_constants
00016   USE input_keyword_types,             ONLY: keyword_create,&
00017                                              keyword_release,&
00018                                              keyword_type
00019   USE input_section_types,             ONLY: section_add_keyword,&
00020                                              section_add_subsection,&
00021                                              section_create,&
00022                                              section_release,&
00023                                              section_type
00024   USE input_val_types,                 ONLY: char_t,&
00025                                              integer_t,&
00026                                              lchar_t,&
00027                                              real_t
00028   USE kinds,                           ONLY: dp
00029   USE string_utilities,                ONLY: s2a
00030 #include "cp_common_uses.h"
00031 
00032   IMPLICIT NONE
00033   PRIVATE
00034 
00035   LOGICAL, PRIVATE, PARAMETER :: debug_this_module=.TRUE.
00036   CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'input_cp2k_mixed'
00037 
00038   PUBLIC :: create_mix_section
00039 
00040 CONTAINS
00041 
00042 ! *****************************************************************************
00049   SUBROUTINE create_mix_section(section,error)
00050     TYPE(section_type), POINTER              :: section
00051     TYPE(cp_error_type), INTENT(inout)       :: error
00052 
00053     CHARACTER(len=*), PARAMETER :: routineN = 'create_mix_section', 
00054       routineP = moduleN//':'//routineN
00055 
00056     LOGICAL                                  :: failure
00057     TYPE(keyword_type), POINTER              :: keyword
00058     TYPE(section_type), POINTER              :: sub2section, sub3section, 
00059                                                 subsection
00060 
00061     failure=.FALSE.
00062 
00063     CPPrecondition(.NOT.ASSOCIATED(section),cp_failure_level,routineP,error,failure)
00064     IF (.NOT. failure) THEN
00065        CALL section_create(section,name="MIXED",&
00066             description="This section contains all information to run with a hamiltonian "//&
00067                         "defined by a mixing of force_evals",&
00068             n_keywords=1, n_subsections=0, repeats=.FALSE., required=.TRUE.,&
00069             error=error)
00070        NULLIFY(keyword, subsection)
00071 
00072        CALL keyword_create(keyword, name="MIXING_TYPE",&
00073             description="The type of mixing to be employed",&
00074             usage="MIXING_TYPE LINEAR_COMBINATION",&
00075             default_i_val=mix_linear_combination,&
00076             enum_c_vals=s2a("LINEAR_COMBINATION", &
00077                             "MINIMUM",&
00078                             "COUPLED",&
00079                             "RESTRAINT",&
00080                             "GENMIX"),&
00081             enum_desc=s2a("Linear combination of force envs (support only 2 force_evals)", &
00082                           "Use the force env with the minimum energy (support only 2 force_evals)",&
00083                           "Consider the force envs as a two state system with a given"//&
00084                           " coupling matrix element (support only 2 force_evals)",&
00085                           "Use the difference between the energy of the force envs as a"//&
00086                           " restraint on the first (support only 2 force_evals)",&
00087                           "Defines a user-driven generica coupling (support for an unlimited number of force_eval)"),&
00088             enum_i_vals=(/mix_linear_combination,mix_minimum,mix_coupled,mix_restrained,mix_generic/),&
00089             error=error)
00090        CALL section_add_keyword(section,keyword,error=error)
00091        CALL keyword_release(keyword,error=error)
00092 
00093        CALL keyword_create(keyword, name="GROUP_PARTITION",&
00094             description="gives the exact number of processors for each group."//&
00095             " If not specified processors allocated will be equally distributed for"//&
00096             " the specified subforce_eval, trying to build a number of groups equal to the"//&
00097             " number of subforce_eval specified.",&
00098             usage="group_partition  2 2 4 2 4 ", type_of_var=integer_t, n_var=-1, error=error)
00099        CALL section_add_keyword(section,keyword,error=error)
00100        CALL keyword_release(keyword,error=error)
00101 
00102        CALL keyword_create(keyword, name="NGROUPS",variants=(/"NGROUP"/),&
00103             description="Gives the wanted number of groups. If not specified the number"//&
00104             " of groups is set to the number of subforce_eval defined.",&
00105             usage="ngroups 4", type_of_var=integer_t, error=error)
00106        CALL section_add_keyword(section,keyword,error=error)
00107        CALL keyword_release(keyword,error=error)
00108 
00109        ! Double force_eval
00110        CALL section_create(subsection,name="LINEAR",&
00111             description="Linear combination between two force_eval:  F= lambda F1 + (1-lambda) F2",&
00112             n_keywords=1, n_subsections=0, repeats=.FALSE., required=.TRUE.,&
00113             error=error)
00114        CALL keyword_create(keyword, name="LAMBDA",&
00115             description="Specify the mixing parameter lambda in the formula:",&
00116             usage="lambda <REAL>", type_of_var=real_t,&
00117             required=.TRUE.,error=error)
00118        CALL section_add_keyword(subsection,keyword,error=error)
00119        CALL keyword_release(keyword,error=error)
00120        CALL section_add_subsection(section,subsection,error=error)
00121        CALL section_release(subsection,error=error)
00122 
00123        CALL section_create(subsection,name="COUPLING",&
00124             description="Coupling between two force_eval: E=(E1+E2 - sqrt((E1-E2)**2+4*H12**2))/2",&
00125             n_keywords=1, n_subsections=0, repeats=.FALSE., required=.TRUE.,&
00126             error=error)
00127        CALL keyword_create(keyword, name="COUPLING_PARAMETER",&
00128             description="Coupling parameter H12 used in the coupling",&
00129             usage="COUPLING_PARAMETER <REAL>", type_of_var=real_t,&
00130             required=.TRUE.,error=error)
00131        CALL section_add_keyword(subsection,keyword,error=error)
00132        CALL keyword_release(keyword,error=error)
00133        CALL section_add_subsection(section,subsection,error=error)
00134        CALL section_release(subsection,error=error)
00135 
00136        CALL section_create(subsection,name="RESTRAINT",&
00137             description="Restraint between two force_eval: E = E1 + k*(E1-E2-t)**2",&
00138             n_keywords=1, n_subsections=0, repeats=.FALSE., required=.TRUE.,&
00139             error=error)
00140        CALL keyword_create(keyword, name="RESTRAINT_TARGET",&
00141             description="Target value of the restraint (t) ",&
00142             usage="RESTRAINT_TARGET <REAL>", type_of_var=real_t,&
00143             required=.TRUE.,error=error)
00144        CALL section_add_keyword(subsection,keyword,error=error)
00145        CALL keyword_release(keyword,error=error)
00146 
00147        CALL keyword_create(keyword, name="RESTRAINT_STRENGTH",&
00148             description="Strength of the restraint (k) in "//&
00149             "k*(E1-E2-t)**2" ,&
00150             usage="RESTRAINT_STRENGTH <REAL>", type_of_var=real_t,&
00151             required=.TRUE.,error=error)
00152        CALL section_add_keyword(subsection,keyword,error=error)
00153        CALL keyword_release(keyword,error=error)
00154        CALL section_add_subsection(section,subsection,error=error)
00155        CALL section_release(subsection,error=error)
00156 
00157        ! Multiple force_eval
00158        CALL section_create(subsection,name="GENERIC",&
00159             description="User driven coupling between two or more force_eval.",&
00160             n_keywords=1, n_subsections=0, repeats=.FALSE., required=.TRUE.,&
00161             error=error)
00162        CALL keyword_create(keyword, name="MIXING_FUNCTION",&
00163             description="Specifies the mixing functional form in mathematical notation.",&
00164             usage="MIXING_FUNCTION (E1+E2-LOG(E1/E2))", required=.TRUE., type_of_var=lchar_t,&
00165             n_var=1, error=error)
00166        CALL section_add_keyword(subsection,keyword,error=error)
00167        CALL keyword_release(keyword,error=error)
00168 
00169        CALL keyword_create(keyword, name="VARIABLES",&
00170             description="Defines the variables of the functional form. To allow an efficient"//&
00171             " mapping the order of the energy variables will be considered identical to the"//&
00172             " order of the force_eval in the force_eval_order list.",&
00173             usage="VARIABLES x", required=.TRUE., type_of_var=char_t,&
00174             n_var=-1, error=error)
00175        CALL section_add_keyword(subsection,keyword,error=error)
00176        CALL keyword_release(keyword,error=error)
00177 
00178        CALL keyword_create(keyword, name="PARAMETERS",&
00179             description="Defines the parameters of the functional form",&
00180             usage="PARAMETERS a b D", required=.TRUE., type_of_var=char_t,&
00181             n_var=-1, repeats=.TRUE., error=error)
00182        CALL section_add_keyword(subsection,keyword,error=error)
00183        CALL keyword_release(keyword,error=error)
00184 
00185        CALL keyword_create(keyword, name="VALUES",&
00186             description="Defines the values of parameter of the functional form",&
00187             usage="VALUES ", required=.TRUE., type_of_var=real_t,&
00188             n_var=-1, repeats=.TRUE., unit_str="internal_cp2k", error=error)
00189        CALL section_add_keyword(subsection,keyword,error=error)
00190        CALL keyword_release(keyword,error=error)
00191 
00192        CALL keyword_create(keyword, name="UNITS",&
00193             description="Optionally, allows to define valid CP2K unit strings for each parameter value. "//&
00194                         "It is assumed that the corresponding parameter value is specified in this unit.",&
00195             usage="UNITS angstrom eV*angstrom^-1 angstrom^1 K", required=.FALSE., type_of_var=char_t,&
00196             n_var=-1, repeats=.TRUE., error=error)
00197        CALL section_add_keyword(subsection,keyword,error=error)
00198        CALL keyword_release(keyword,error=error)
00199 
00200        CALL keyword_create(keyword, name="DX",&
00201             description="Parameter used for computing the derivative with the Ridders method.",&
00202             usage="DX <REAL>", default_r_val=0.1_dp, unit_str="bohr", error=error)
00203        CALL section_add_keyword(subsection,keyword,error=error)
00204        CALL keyword_release(keyword,error=error)
00205 
00206        CALL keyword_create(keyword, name="ERROR_LIMIT",&
00207             description="Checks that the error in computing the derivative is not larger than "//&
00208             "the value set. In case prints a warning message.",&
00209             usage="ERROR_LIMIT <REAL>", default_r_val=1.0E-12_dp, error=error)
00210        CALL section_add_keyword(subsection,keyword,error=error)
00211        CALL keyword_release(keyword,error=error)
00212        CALL section_add_subsection(section,subsection,error=error)
00213        CALL section_release(subsection,error=error)
00214 
00215        ! Mapping of atoms
00216        NULLIFY(sub2section, sub3section)
00217        CALL section_create(subsection,name="MAPPING",&
00218             description="Defines the mapping of atoms for the different force_eval with the mixed force_eval."//&
00219             " The default is to have a mapping 1-1 between atom index (i.e. all force_eval share the same"//&
00220             " geometrical structure). The mapping is based on defining fragments and the mapping the "//&
00221             " fragments between the several force_eval and the mixed force_eval",&
00222             n_keywords=1, n_subsections=0, repeats=.TRUE., required=.TRUE.,&
00223             error=error)
00224 
00225        ! Mixed force_eval
00226        CALL section_create(sub2section,name="FORCE_EVAL_MIXED",&
00227             description="Defines the fragments for the mixed force_eval (reference)",&
00228             n_keywords=1, n_subsections=0, repeats=.TRUE., required=.TRUE.,&
00229             error=error)
00230 
00231        CALL section_create(sub3section,name="FRAGMENT",&
00232             description="Fragment definition",&
00233             n_keywords=1, n_subsections=0, repeats=.TRUE., required=.TRUE.,&
00234             error=error)
00235 
00236        CALL keyword_create(keyword, name="_SECTION_PARAMETERS_",&
00237             description="Defines the index of the fragment defined",&
00238             usage="<INTEGER>",  type_of_var=integer_t, n_var=1, required=.TRUE.,error=error)
00239        CALL section_add_keyword(sub3section,keyword,error=error)
00240        CALL keyword_release(keyword,error=error)
00241 
00242        CALL keyword_create(keyword, name="_DEFAULT_KEYWORD_",&
00243             description="Starting and ending atomic index defining one fragment must be provided",&
00244             usage="<INTEGER> <INTEGER>", type_of_var=integer_t, n_var=2, repeats=.TRUE.,&
00245             required=.TRUE.,error=error)
00246        CALL section_add_keyword(sub3section,keyword,error=error)
00247        CALL keyword_release(keyword,error=error)
00248 
00249        CALL section_add_subsection(sub2section,sub3section,error=error)
00250        CALL section_release(sub3section,error=error)
00251        CALL section_add_subsection(subsection,sub2section,error=error)
00252        CALL section_release(sub2section,error=error)
00253 
00254        ! All other force_eval
00255        CALL section_create(sub2section,name="FORCE_EVAL",&
00256             description="Defines the fragments and the mapping for each force_eval (an integer index (ID) "//&
00257             "needs to be provided as parameter)",&
00258             n_keywords=1, n_subsections=0, repeats=.TRUE., required=.TRUE.,&
00259             error=error)
00260 
00261        CALL keyword_create(keyword, name="DEFINE_FRAGMENTS",&
00262             description="Specify the fragments definition of the force_eval through the fragments of the"//&
00263             " force_eval_mixed. This avoids the pedantic definition of the fragments for the force_eval,"//&
00264             " assuming the order of the fragments for the specified force_eval is the same as the sequence "//&
00265             " of integers provided. Easier to USE should be preferred to the specification of the single fragments.",&
00266             usage="DEFINE_FRAGMENTS <INTEGER> .. <INTEGER>", type_of_var=integer_t, n_var=-1,&
00267             error=error)
00268        CALL section_add_keyword(sub2section,keyword,error=error)
00269        CALL keyword_release(keyword,error=error)
00270 
00271        CALL keyword_create(keyword, name="_SECTION_PARAMETERS_",&
00272             description="Defines the index of the force_eval for which fragments and mappings are provided",&
00273             usage="<INTEGER>",  type_of_var=integer_t, n_var=1, required=.TRUE.,error=error)
00274        CALL section_add_keyword(sub2section,keyword,error=error)
00275        CALL keyword_release(keyword,error=error)
00276 
00277        CALL section_create(sub3section,name="FRAGMENT",&
00278             description="Fragment definition",&
00279             n_keywords=1, n_subsections=0, repeats=.TRUE., required=.TRUE.,&
00280             error=error)
00281 
00282        CALL keyword_create(keyword, name="_SECTION_PARAMETERS_",&
00283             description="Defines the index of the fragment defined",&
00284             usage="<INTEGER>",  type_of_var=integer_t, n_var=1, required=.FALSE.,error=error)
00285        CALL section_add_keyword(sub3section,keyword,error=error)
00286        CALL keyword_release(keyword,error=error)
00287 
00288        CALL keyword_create(keyword, name="_DEFAULT_KEYWORD_",&
00289             description="Starting and ending atomic index defining one fragment must be provided",&
00290             usage="<INTEGER> <INTEGER>", type_of_var=integer_t, n_var=2, repeats=.FALSE.,&
00291             required=.TRUE.,error=error)
00292        CALL section_add_keyword(sub3section,keyword,error=error)
00293        CALL keyword_release(keyword,error=error)
00294 
00295        CALL keyword_create(keyword, name="MAP",&
00296             description="Provides the index of the fragment of the MIXED force_eval mapped on the"//&
00297             " locally defined fragment.",&
00298             usage="MAP <INTEGER>", type_of_var=integer_t, n_var=1, repeats=.FALSE.,&
00299             required=.TRUE.,error=error)
00300        CALL section_add_keyword(sub3section,keyword,error=error)
00301        CALL keyword_release(keyword,error=error)
00302 
00303        CALL section_add_subsection(sub2section,sub3section,error=error)
00304        CALL section_release(sub3section,error=error)
00305        CALL section_add_subsection(subsection,sub2section,error=error)
00306        CALL section_release(sub2section,error=error)
00307 
00308        CALL section_add_subsection(section,subsection,error=error)
00309        CALL section_release(subsection,error=error)
00310 
00311        CALL create_print_mix_section(subsection, error=error)
00312        CALL section_add_subsection(section,subsection,error=error)
00313        CALL section_release(subsection,error=error)
00314     END IF
00315   END SUBROUTINE create_mix_section
00316 
00317 ! *****************************************************************************
00324   SUBROUTINE create_print_mix_section(section,error)
00325     TYPE(section_type), POINTER              :: section
00326     TYPE(cp_error_type), INTENT(inout)       :: error
00327 
00328     CHARACTER(len=*), PARAMETER :: routineN = 'create_print_mix_section', 
00329       routineP = moduleN//':'//routineN
00330 
00331     LOGICAL                                  :: failure
00332     TYPE(section_type), POINTER              :: print_key
00333 
00334     failure=.FALSE.
00335     CPPrecondition(.NOT.ASSOCIATED(section),cp_failure_level,routineP,error,failure)
00336     IF (.NOT. failure) THEN
00337        CALL section_create(section,name="print",&
00338             description="Section of possible print options in MIXED env.",&
00339             n_keywords=0, n_subsections=1, repeats=.FALSE., required=.TRUE.,&
00340             error=error)
00341 
00342        NULLIFY(print_key)
00343 
00344        CALL cp_print_key_section_create(print_key,"PROGRAM_RUN_INFO",&
00345             description="Controls the printing of information during the evaluation of "//&
00346             "the mixed environment. ",&
00347             print_level=low_print_level,add_last=add_last_numeric,filename="__STD_OUT__",&
00348             error=error)
00349        CALL section_add_subsection(section,print_key,error=error)
00350        CALL section_release(print_key,error=error)
00351 
00352        CALL cp_print_key_section_create(print_key,"DIPOLE",&
00353             description="Controls the printing of dipole information. "//&
00354             "Requires the DIPOLE calculation be active for all subforce_eval.", &
00355             print_level=medium_print_level,filename="__STD_OUT__",&
00356             error=error)
00357        CALL section_add_subsection(section,print_key,error=error)
00358        CALL section_release(print_key,error=error)
00359     END IF
00360   END SUBROUTINE create_print_mix_section
00361 
00362 END MODULE input_cp2k_mixed