CP2K 2.4 (Revision 12889)

input_cp2k_force_eval.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_force_eval
00013   USE cp_output_handling,              ONLY: cp_print_key_section_create
00014   USE cp_units,                        ONLY: cp_unit_to_cp2k
00015   USE f77_blas
00016   USE input_constants
00017   USE input_cp2k_dft,                  ONLY: create_bsse_section,&
00018                                              create_dft_section,&
00019                                              create_ep_section
00020   USE input_cp2k_eip,                  ONLY: create_eip_section
00021   USE input_cp2k_mixed,                ONLY: create_mix_section
00022   USE input_cp2k_mm,                   ONLY: create_mm_section
00023   USE input_cp2k_properties_dft,       ONLY: create_properties_section
00024   USE input_cp2k_qmmm,                 ONLY: create_qmmm_section
00025   USE input_cp2k_subsys,               ONLY: create_subsys_section
00026   USE input_keyword_types,             ONLY: keyword_create,&
00027                                              keyword_release,&
00028                                              keyword_type
00029   USE input_section_types,             ONLY: section_add_keyword,&
00030                                              section_add_subsection,&
00031                                              section_create,&
00032                                              section_release,&
00033                                              section_type
00034   USE input_val_types,                 ONLY: char_t,&
00035                                              integer_t,&
00036                                              lchar_t,&
00037                                              real_t
00038   USE kinds,                           ONLY: dp
00039   USE string_utilities,                ONLY: s2a
00040 #include "cp_common_uses.h"
00041 
00042   IMPLICIT NONE
00043   PRIVATE
00044 
00045   LOGICAL, PRIVATE, PARAMETER :: debug_this_module=.TRUE.
00046   CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'input_cp2k_force_eval'
00047 
00048   PUBLIC :: create_force_eval_section
00049 
00050 CONTAINS
00051 
00052 ! *****************************************************************************
00059   SUBROUTINE create_force_eval_section(section,error)
00060     TYPE(section_type), POINTER              :: section
00061     TYPE(cp_error_type), INTENT(inout)       :: error
00062 
00063     CHARACTER(len=*), PARAMETER :: routineN = 'create_force_eval_section', 
00064       routineP = moduleN//':'//routineN
00065 
00066     LOGICAL                                  :: failure
00067     TYPE(keyword_type), POINTER              :: keyword
00068     TYPE(section_type), POINTER              :: subsection
00069 
00070     failure=.FALSE.
00071 
00072     CPPrecondition(.NOT.ASSOCIATED(section),cp_failure_level,routineP,error,failure)
00073     CALL section_create(section,name="force_eval",&
00074          description="parameters needed to calculate energy and forces and"//&
00075          " describe the system you want to analyze.",&
00076          n_keywords=1, n_subsections=9, repeats=.TRUE., required=.TRUE.,&
00077          error=error)
00078 
00079     NULLIFY(subsection)
00080     NULLIFY(keyword)
00081     CALL keyword_create(keyword, name="METHOD",&
00082          description="Which method should be used to compute forces",&
00083          usage="METHOD <STRING>",&
00084          enum_c_vals=s2a("QS",&
00085                          "FIST",&
00086                          "QMMM",&
00087                          "EIP",&
00088                          "QUICKSTEP",&
00089                          "EP",&
00090                          "MIXED"),&
00091          enum_desc=s2a("Electronic structure methods (DFT, ...)",&
00092                        "Molecular Mechanics",&
00093                        "Hybrid quantum classical",&
00094                        "Empirical Interatomic Potential",&
00095                        "Electronic structure methods (DFT, ...)",&
00096                        "Non-orthogonal perturbation",&
00097                        "Use a combination of two of the above"),&
00098          enum_i_vals=(/do_qs, do_fist, do_qmmm, do_eip, do_qs, do_ep, do_mixed/),&
00099          default_i_val=do_qs, error=error)
00100     CALL section_add_keyword(section,keyword,error=error)
00101     CALL keyword_release(keyword,error=error)
00102 
00103     CALL keyword_create(keyword, name="stress_tensor",&
00104          description="Controls the calculation of the stress tensor. The combinations defined below"//&
00105          " are not implemented for all methods.",&
00106          usage="stress_tensor (NONE|ANALYTICAL|NUMERICAL|DIAGONAL_ANA|DIAGONAL_NUM)", &
00107          default_i_val=do_stress_none,&
00108          enum_c_vals=s2a("NONE","ANALYTICAL","NUMERICAL","DIAGONAL_ANALYTICAL","DIAGONAL_NUMERICAL"),&
00109          enum_i_vals=(/do_stress_none,do_stress_analytical,do_stress_numerical,&
00110                        do_stress_diagonal_anal,do_stress_diagonal_numer/),&
00111          enum_desc=s2a("Do not compute stress tensor",&
00112                        "Compute the stress tensor analytical (if available).",&
00113                        "Compute the stress tensor numerically.",&
00114                        "Compute the diagonal part only of the stress tensor analytical (if available).",&
00115                        "Compute the diagonal part only of the stress tensor numerically"),&
00116          error=error)
00117     CALL section_add_keyword(section,keyword,error=error)
00118     CALL keyword_release(keyword,error=error)
00119 
00120     CALL create_ext_pot_section(subsection, error)
00121     CALL section_add_subsection(section, subsection, error=error)
00122     CALL section_release(subsection,error=error)
00123 
00124     CALL create_rescale_force_section(subsection,error)
00125     CALL section_add_subsection(section, subsection, error=error)
00126     CALL section_release(subsection,error=error)
00127 
00128     CALL create_mix_section(subsection,error)
00129     CALL section_add_subsection(section, subsection, error=error)
00130     CALL section_release(subsection,error=error)
00131 
00132     CALL create_dft_section(subsection,error)
00133     CALL section_add_subsection(section, subsection, error=error)
00134     CALL section_release(subsection,error=error)
00135 
00136     CALL create_mm_section(subsection,error)
00137     CALL section_add_subsection(section, subsection, error=error)
00138     CALL section_release(subsection,error=error)
00139 
00140     CALL create_qmmm_section(subsection,error)
00141     CALL section_add_subsection(section, subsection, error=error)
00142     CALL section_release(subsection,error=error)
00143 
00144     CALL create_ep_section(subsection,error)
00145     CALL section_add_subsection(section, subsection, error=error)
00146     CALL section_release(subsection,error=error)
00147 
00148     CALL create_eip_section(subsection, error)
00149     CALL section_add_subsection(section, subsection, error=error)
00150     CALL section_release(subsection, error=error)
00151 
00152     CALL create_bsse_section(subsection,error)
00153     CALL section_add_subsection(section, subsection, error=error)
00154     CALL section_release(subsection,error=error)
00155 
00156     CALL create_subsys_section(subsection,error)
00157     CALL section_add_subsection(section, subsection, error=error)
00158     CALL section_release(subsection,error=error)
00159 
00160     CALL create_properties_section(subsection,error)
00161     CALL section_add_subsection(section, subsection, error=error)
00162     CALL section_release(subsection,error=error)
00163 
00164     CALL create_f_env_print_section(subsection,error)
00165     CALL section_add_subsection(section, subsection, error=error)
00166     CALL section_release(subsection,error=error)
00167 
00168   END SUBROUTINE create_force_eval_section
00169 
00170 ! *****************************************************************************
00175   SUBROUTINE create_ext_pot_section(section,error)
00176     TYPE(section_type), POINTER              :: section
00177     TYPE(cp_error_type), INTENT(inout)       :: error
00178 
00179     CHARACTER(len=*), PARAMETER :: routineN = 'create_ext_pot_section', 
00180       routineP = moduleN//':'//routineN
00181 
00182     LOGICAL                                  :: failure
00183     TYPE(keyword_type), POINTER              :: keyword
00184 
00185     failure=.FALSE.
00186 
00187     CPPrecondition(.NOT.ASSOCIATED(section),cp_failure_level,routineP,error,failure)
00188     IF (.NOT. failure) THEN
00189        CALL section_create(section,name="EXTERNAL_POTENTIAL",&
00190             description="Section controlling the presence of an external potential dependent "//&
00191             " on the atomic positions (X,Y,Z)",&
00192             n_keywords=7, n_subsections=0, repeats=.TRUE., required=.TRUE.,&
00193             error=error)
00194        NULLIFY(keyword)
00195 
00196        CALL keyword_create(keyword, name="ATOMS_LIST",&
00197             description="Specifies the atoms on which the external potential will act",&
00198             usage="ATOMS_LIST {INT} {INT} ..",required=.FALSE.,repeats=.TRUE.,&
00199             n_var=-1, type_of_var=integer_t, error=error)
00200        CALL section_add_keyword(section,keyword,error=error)
00201        CALL keyword_release(keyword,error=error)
00202 
00203        CALL keyword_create(keyword, name="FUNCTION",&
00204             description="Specifies the functional form in mathematical notation. Variables must be the atomic "//&
00205             "coordinates (X,Y,Z).",usage="FUNCTION  X^2+Y^2+Z^2+LOG(ABS(X+Y))", required=.TRUE.,&
00206             type_of_var=lchar_t, n_var=1, error=error)
00207        CALL section_add_keyword(section,keyword,error=error)
00208        CALL keyword_release(keyword,error=error)
00209 
00210        CALL keyword_create(keyword, name="PARAMETERS",&
00211             description="Defines the parameters of the functional form",&
00212             usage="PARAMETERS a b D", required=.TRUE., type_of_var=char_t,&
00213             n_var=-1, repeats=.TRUE., error=error)
00214        CALL section_add_keyword(section,keyword,error=error)
00215        CALL keyword_release(keyword,error=error)
00216 
00217        CALL keyword_create(keyword, name="VALUES",&
00218             description="Defines the values of  parameter of the functional form",&
00219             usage="VALUES ", required=.TRUE., type_of_var=real_t,&
00220             n_var=-1, repeats=.TRUE., unit_str="internal_cp2k", error=error)
00221        CALL section_add_keyword(section,keyword,error=error)
00222        CALL keyword_release(keyword,error=error)
00223 
00224        CALL keyword_create(keyword, name="UNITS",&
00225             description="Optionally, allows to define valid CP2K unit strings for each parameter value. "//&
00226                         "It is assumed that the corresponding parameter value is specified in this unit.",&
00227             usage="UNITS angstrom eV*angstrom^-1 angstrom^1 K", required=.FALSE., type_of_var=char_t,&
00228             n_var=-1, repeats=.TRUE., error=error)
00229        CALL section_add_keyword(section,keyword,error=error)
00230        CALL keyword_release(keyword,error=error)
00231 
00232        CALL keyword_create(keyword, name="DX",&
00233             description="Parameter used for computing the derivative with the Ridders method.",&
00234             usage="DX <REAL>", default_r_val=0.1_dp, unit_str="bohr", error=error)
00235        CALL section_add_keyword(section,keyword,error=error)
00236        CALL keyword_release(keyword,error=error)
00237 
00238        CALL keyword_create(keyword, name="ERROR_LIMIT",&
00239             description="Checks that the error in computing the derivative is not larger than "//&
00240             "the value set. In case prints a warning message.",&
00241             usage="ERROR_LIMIT <REAL>", default_r_val=1.0E-12_dp, error=error)
00242        CALL section_add_keyword(section,keyword,error=error)
00243        CALL keyword_release(keyword,error=error)
00244 
00245 
00246     END IF
00247   END SUBROUTINE create_ext_pot_section
00248 
00249 ! *****************************************************************************
00256   SUBROUTINE create_rescale_force_section(section,error)
00257     TYPE(section_type), POINTER              :: section
00258     TYPE(cp_error_type), INTENT(inout)       :: error
00259 
00260     CHARACTER(len=*), PARAMETER :: routineN = 'create_rescale_force_section', 
00261       routineP = moduleN//':'//routineN
00262 
00263     LOGICAL                                  :: failure
00264     TYPE(keyword_type), POINTER              :: keyword
00265 
00266     failure=.FALSE.
00267 
00268     CPPrecondition(.NOT.ASSOCIATED(section),cp_failure_level,routineP,error,failure)
00269     IF (.NOT. failure) THEN
00270        CALL section_create(section,name="RESCALE_FORCES",&
00271             description="Section controlling the rescaling of forces. Useful when"//&
00272             " starting from quite bad geometries with unphysically large forces.",&
00273             n_keywords=1, n_subsections=0, repeats=.FALSE., required=.TRUE.,&
00274             error=error)
00275        NULLIFY(keyword)
00276 
00277        CALL keyword_create(keyword, name="MAX_FORCE",&
00278             description="Specify the Maximum Values of the force. If the force"//&
00279             " of one atom exceed this value it's rescaled to the MAX_FORCE"//&
00280             " value.",&
00281             default_r_val=cp_unit_to_cp2k(value=50.0_dp,&
00282                                           unit_str="kcalmol*angstrom^-1",&
00283                                           error=error),&
00284              unit_str="hartree*bohr^-1",&
00285              error=error)
00286        CALL section_add_keyword(section,keyword,error=error)
00287        CALL keyword_release(keyword,error=error)
00288 
00289     END IF
00290   END SUBROUTINE create_rescale_force_section
00291 
00292 ! *****************************************************************************
00297   SUBROUTINE create_f_env_print_section(section,error)
00298     TYPE(section_type), POINTER              :: section
00299     TYPE(cp_error_type), INTENT(inout)       :: error
00300 
00301     CHARACTER(len=*), PARAMETER :: routineN = 'create_f_env_print_section', 
00302       routineP = moduleN//':'//routineN
00303 
00304     LOGICAL                                  :: failure
00305     TYPE(keyword_type), POINTER              :: keyword
00306     TYPE(section_type), POINTER              :: print_key
00307 
00308     failure=.FALSE.
00309 
00310     NULLIFY (keyword)
00311     NULLIFY (print_key)
00312 
00313     CPPrecondition(.NOT.ASSOCIATED(section),cp_failure_level,routineP,error,failure)
00314 
00315     IF (.NOT. failure) THEN
00316        CALL section_create(section,name="PRINT",&
00317             description="Properties that you want to output and that are common to all methods",&
00318             n_keywords=0, n_subsections=5, repeats=.FALSE., required=.TRUE.,&
00319             error=error)
00320 
00321        CALL cp_print_key_section_create(print_key,"PROGRAM_RUN_INFO",&
00322             description="Controls the printing of basic information generated by force_eval", &
00323             print_level=low_print_level,add_last=add_last_numeric,filename="__STD_OUT__",&
00324             error=error)
00325        CALL section_add_subsection(section,print_key,error=error)
00326        CALL section_release(print_key,error=error)
00327 
00328        CALL cp_print_key_section_create(print_key,"FORCES",&
00329             description="Controls the printing of the forces after each force evaluation",&
00330             print_level=high_print_level, filename="__STD_OUT__",error=error)
00331        CALL keyword_create(keyword=keyword,&
00332                            name="NDIGITS",&
00333                            description="Specifies the number of digits used "//&
00334                                        "for the printing of the forces",&
00335                            usage="NDIGITS 6",&
00336                            default_i_val=8,&
00337                            required=.FALSE.,&
00338                            repeats=.FALSE.,&
00339                            error=error)
00340        CALL section_add_keyword(print_key,keyword,error=error)
00341        CALL keyword_release(keyword,error=error)
00342        CALL section_add_subsection(section,print_key,error=error)
00343        CALL section_release(print_key,error=error)
00344 
00345        CALL cp_print_key_section_create(print_key,"GRID_INFORMATION",&
00346             description="Controls the printing of information regarding the PW and RS grid structures.",&
00347             print_level=medium_print_level,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,"TOTAL_NUMBERS",&
00353             description="Controls the printing of the total number of atoms, kinds,...",&
00354             print_level=medium_print_level, filename="__STD_OUT__",error=error)
00355        CALL section_add_subsection(section,print_key,error=error)
00356        CALL section_release(print_key,error=error)
00357 
00358        CALL cp_print_key_section_create(print_key,"DISTRIBUTION",&
00359             description="Controls the printing of the distribution of molecules, atoms, ...",&
00360             print_level=medium_print_level, filename="__STD_OUT__",error=error)
00361        CALL section_add_subsection(section,print_key,error=error)
00362        CALL section_release(print_key,error=error)
00363 
00364        CALL cp_print_key_section_create(print_key,"DISTRIBUTION2D",&
00365             description="Controls the printing of the distribution of matrix blocks,...",&
00366             print_level=high_print_level, filename="__STD_OUT__",error=error)
00367        CALL section_add_subsection(section,print_key,error=error)
00368        CALL section_release(print_key,error=error)
00369 
00370        CALL cp_print_key_section_create(print_key,"DISTRIBUTION1D",&
00371             description="Each node prints out its distribution info ...",&
00372             print_level=high_print_level, filename="__STD_OUT__",error=error)
00373        CALL section_add_subsection(section,print_key,error=error)
00374        CALL section_release(print_key,error=error)
00375 
00376        CALL cp_print_key_section_create(print_key,"STRESS_TENSOR",&
00377             description="Controls the printing of the stress tensor",&
00378             print_level=medium_print_level, filename="__STD_OUT__",error=error)
00379        CALL keyword_create(keyword=keyword,&
00380                            name="NDIGITS",&
00381                            description="Specifies the number of digits used "//&
00382                                        "for the printing of the stress tensor",&
00383                            usage="NDIGITS 6",&
00384                            default_i_val=8,&
00385                            required=.FALSE.,&
00386                            repeats=.FALSE.,&
00387                            error=error)
00388        CALL section_add_keyword(print_key,keyword,error=error)
00389        CALL keyword_release(keyword,error=error)
00390        CALL section_add_subsection(section,print_key,error=error)
00391        CALL section_release(print_key,error=error)
00392 
00393     END IF
00394 
00395   END SUBROUTINE create_f_env_print_section
00396 
00397 END MODULE input_cp2k_force_eval