LCOV - code coverage report
Current view: top level - src - input_cp2k_field.F (source / functions) Hit Total Coverage
Test: CP2K Regtests (git:ccc2433) Lines: 102 102 100.0 %
Date: 2024-04-25 07:09:54 Functions: 6 6 100.0 %

          Line data    Source code
       1             : !--------------------------------------------------------------------------------------------------!
       2             : !   CP2K: A general program to perform molecular dynamics simulations                              !
       3             : !   Copyright 2000-2024 CP2K developers group <https://cp2k.org>                                   !
       4             : !                                                                                                  !
       5             : !   SPDX-License-Identifier: GPL-2.0-or-later                                                      !
       6             : !--------------------------------------------------------------------------------------------------!
       7             : 
       8             : ! **************************************************************************************************
       9             : !> \brief function that build the field section of the input
      10             : !> \par History
      11             : !>      02.2017 moved out of input_cp2k_dft [JHU]
      12             : !> \author fawzi
      13             : ! **************************************************************************************************
      14             : MODULE input_cp2k_field
      15             :    USE bibliography,                    ONLY: Souza2002,&
      16             :                                               Stengel2009,&
      17             :                                               Umari2002
      18             :    USE input_constants,                 ONLY: constant_env,&
      19             :                                               custom_env,&
      20             :                                               gaussian,&
      21             :                                               gaussian_env,&
      22             :                                               ramp_env
      23             :    USE input_keyword_types,             ONLY: keyword_create,&
      24             :                                               keyword_release,&
      25             :                                               keyword_type
      26             :    USE input_section_types,             ONLY: section_add_keyword,&
      27             :                                               section_add_subsection,&
      28             :                                               section_create,&
      29             :                                               section_release,&
      30             :                                               section_type
      31             :    USE input_val_types,                 ONLY: char_t,&
      32             :                                               real_t
      33             :    USE kinds,                           ONLY: dp
      34             :    USE string_utilities,                ONLY: s2a
      35             : #include "./base/base_uses.f90"
      36             : 
      37             :    IMPLICIT NONE
      38             :    PRIVATE
      39             : 
      40             :    CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'input_cp2k_field'
      41             : 
      42             :    PUBLIC :: create_per_efield_section, create_efield_section
      43             : 
      44             : CONTAINS
      45             : 
      46             : ! **************************************************************************************************
      47             : !> \brief creates the section for static periodic fields
      48             : !> \param section ...
      49             : !> \author Florian Schiffmann
      50             : ! **************************************************************************************************
      51       16800 :    SUBROUTINE create_per_efield_section(section)
      52             :       TYPE(section_type), POINTER                        :: section
      53             : 
      54             :       TYPE(keyword_type), POINTER                        :: keyword
      55             : 
      56       16800 :       CPASSERT(.NOT. ASSOCIATED(section))
      57             :       CALL section_create(section, __LOCATION__, name="PERIODIC_EFIELD", &
      58             :                           description="parameters for finite periodic electric field computed using"// &
      59             :                           " the Berry phase approach. IMPORTANT: Can only be used in combination"// &
      60             :                           " with OT. Can not be used in combination with RTP or EMD,"// &
      61             :                           " e.g. RESTART_RTP has to be .FALSE. when restarting the job.", &
      62             :                           citations=(/Souza2002, Umari2002/), &
      63       50400 :                           n_keywords=6, n_subsections=1, repeats=.TRUE.)
      64             : 
      65       16800 :       NULLIFY (keyword)
      66             : 
      67             :       CALL keyword_create(keyword, __LOCATION__, name="INTENSITY", &
      68             :                           description="Intensity of the electric field in a.u", &
      69             :                           usage="INTENSITY  0.001", &
      70       16800 :                           default_r_val=0._dp)
      71       16800 :       CALL section_add_keyword(section, keyword)
      72       16800 :       CALL keyword_release(keyword)
      73             : 
      74             :       CALL keyword_create(keyword, __LOCATION__, name="POLARISATION", &
      75             :                           description="Polarisation vector of electric field", &
      76             :                           usage="POLARISIATION  0.0 0.0 1.0", &
      77             :                           repeats=.FALSE., n_var=3, &
      78       16800 :                           type_of_var=real_t, default_r_vals=(/0.0_dp, 0.0_dp, 1.0_dp/))
      79       16800 :       CALL section_add_keyword(section, keyword)
      80       16800 :       CALL keyword_release(keyword)
      81             : 
      82             :       CALL keyword_create(keyword, __LOCATION__, name="DISPLACEMENT_FIELD", &
      83             :                           description="Use the displacement field formulation.", &
      84             :                           usage="DISPLACEMENT_FIELD T", &
      85             :                           citations=(/Stengel2009/), &
      86             :                           default_l_val=.FALSE., &
      87       33600 :                           lone_keyword_l_val=.TRUE.)
      88       16800 :       CALL section_add_keyword(section, keyword)
      89       16800 :       CALL keyword_release(keyword)
      90             : 
      91             :       CALL keyword_create(keyword, __LOCATION__, name="D_FILTER", &
      92             :                           description="Filter for displacement field (x,y,z-dirction)", &
      93             :                           usage="D_FILTER  1.0 0.0 0.0", &
      94             :                           repeats=.FALSE., n_var=3, &
      95       16800 :                           type_of_var=real_t, default_r_vals=(/1.0_dp, 1.0_dp, 1.0_dp/))
      96       16800 :       CALL section_add_keyword(section, keyword)
      97       16800 :       CALL keyword_release(keyword)
      98             : 
      99       16800 :    END SUBROUTINE create_per_efield_section
     100             : ! **************************************************************************************************
     101             : !> \brief creates the section for time dependent nonperiodic fields
     102             : !> \param section ...
     103             : !> \author Florian Schiffmann
     104             : ! **************************************************************************************************
     105        8408 :    SUBROUTINE create_efield_section(section)
     106             :       TYPE(section_type), POINTER                        :: section
     107             : 
     108             :       TYPE(keyword_type), POINTER                        :: keyword
     109             :       TYPE(section_type), POINTER                        :: subsection
     110             : 
     111        8408 :       CPASSERT(.NOT. ASSOCIATED(section))
     112             :       CALL section_create(section, __LOCATION__, name="EFIELD", &
     113             :                           description="Parameters for finite, time  dependent electric fields. "// &
     114             :                           "For time dependent  propagation in periodic systems, set "// &
     115             :                           "DFT%REAL_TIME_PROPAGATION%VELOCITY_GAUGE to true. "// &
     116             :                           "For static fields use EXTERNAL_POTENTIAL.", &
     117        8408 :                           n_keywords=6, n_subsections=1, repeats=.TRUE.)
     118             : 
     119        8408 :       NULLIFY (keyword, subsection)
     120             : 
     121             :       CALL keyword_create(keyword, __LOCATION__, name="INTENSITY", &
     122             :                           description="Intensity of the electric field. For real-time propagation (RTP) units are "// &
     123             :                           "in W*cm-2 which corresponds "// &
     124             :                           "to a maximal amplitude in a.u. of sqrt(I/(3.50944*10^16)). "// &
     125             :                           "For a constant local field in isolated system calclulations, units are in a.u..", &
     126             :                           usage="INTENSITY  0.001", &
     127        8408 :                           default_r_val=0._dp)
     128        8408 :       CALL section_add_keyword(section, keyword)
     129        8408 :       CALL keyword_release(keyword)
     130             : 
     131             :       CALL keyword_create(keyword, __LOCATION__, name="POLARISATION", &
     132             :                           description="Polarisation vector of electric field", &
     133             :                           usage="POLARISATION  0.0 0.0 1.0", &
     134             :                           repeats=.FALSE., n_var=3, &
     135        8408 :                           type_of_var=real_t, default_r_vals=(/0.0_dp, 0.0_dp, 1.0_dp/))
     136        8408 :       CALL section_add_keyword(section, keyword)
     137        8408 :       CALL keyword_release(keyword)
     138             : 
     139             :       CALL keyword_create(keyword, __LOCATION__, name="WAVELENGTH", &
     140             :                           description="Wavelength of efield field for real-time propagation (RTP) calculations.", &
     141             :                           usage="Wavelength  1.E0", &
     142        8408 :                           default_r_val=0._dp, unit_str="nm")
     143        8408 :       CALL section_add_keyword(section, keyword)
     144        8408 :       CALL keyword_release(keyword)
     145             : 
     146             :       CALL keyword_create(keyword, __LOCATION__, name="PHASE", &
     147             :                           description="Phase offset of the cosine given in multiples of pi. "// &
     148             :                           "Used in real-time propagation (RTP) calculations.", &
     149             :                           usage="Phase  1.E0", &
     150        8408 :                           default_r_val=0._dp)
     151        8408 :       CALL section_add_keyword(section, keyword)
     152        8408 :       CALL keyword_release(keyword)
     153             : 
     154             :       CALL keyword_create(keyword, __LOCATION__, name="ENVELOP", &
     155             :                           description="Shape of the efield pulse used in real-time propagation (RTP) calculations.", &
     156             :                           usage="ENVELOP CONSTANT", &
     157             :                           default_i_val=constant_env, &
     158             :                           enum_c_vals=s2a("CONSTANT", "GAUSSIAN", "RAMP", "CUSTOM"), &
     159             :                           enum_desc=s2a("No envelop function is applied to the strength", &
     160             :                                         "A Gaussian function is used as envelop ", &
     161             :                                         "Linear tune in/out of the field", &
     162             :                                         "A custom field read from a file"), &
     163        8408 :                           enum_i_vals=(/constant_env, gaussian_env, ramp_env, custom_env/))
     164        8408 :       CALL section_add_keyword(section, keyword)
     165        8408 :       CALL keyword_release(keyword)
     166             : 
     167             :       CALL keyword_create(keyword, __LOCATION__, name="VEC_POT_INITIAL", &
     168             :                           description="Initial value of the vector "// &
     169             :                           "potential (for velocity gauge). This input is "// &
     170             :                           "made especially for restarting RTP calculation. "// &
     171             :                           "Unit is atomic unit. "// &
     172             :                           "Note that if several field sections are defined, only the first one will be used.", &
     173             :                           usage="vec_pot_initial  1.0E-2 0.0 0.0", &
     174             :                           repeats=.FALSE., &
     175             :                           n_var=3, type_of_var=real_t, &
     176        8408 :                           default_r_vals=(/0.0_dp, 0.0_dp, 0.0_dp/))
     177        8408 :       CALL section_add_keyword(section, keyword)
     178        8408 :       CALL keyword_release(keyword)
     179             : 
     180        8408 :       CALL create_constant_env_section(subsection)
     181        8408 :       CALL section_add_subsection(section, subsection)
     182        8408 :       CALL section_release(subsection)
     183             : 
     184        8408 :       CALL create_gaussian_env_section(subsection)
     185        8408 :       CALL section_add_subsection(section, subsection)
     186        8408 :       CALL section_release(subsection)
     187             : 
     188        8408 :       CALL create_ramp_env_section(subsection)
     189        8408 :       CALL section_add_subsection(section, subsection)
     190        8408 :       CALL section_release(subsection)
     191             : 
     192        8408 :       CALL create_custom_env_section(subsection)
     193        8408 :       CALL section_add_subsection(section, subsection)
     194        8408 :       CALL section_release(subsection)
     195             : 
     196        8408 :    END SUBROUTINE create_efield_section
     197             : 
     198             : ! **************************************************************************************************
     199             : !> \brief ...
     200             : !> \param section ...
     201             : ! **************************************************************************************************
     202        8408 :    SUBROUTINE create_constant_env_section(section)
     203             :       TYPE(section_type), POINTER                        :: section
     204             : 
     205             :       TYPE(keyword_type), POINTER                        :: keyword
     206             : 
     207        8408 :       CPASSERT(.NOT. ASSOCIATED(section))
     208             :       CALL section_create(section, __LOCATION__, name="CONSTANT_ENV", &
     209             :                           description="parameters for a constant envelop", &
     210        8408 :                           n_keywords=6, n_subsections=1, repeats=.TRUE.)
     211             : 
     212        8408 :       NULLIFY (keyword)
     213             : 
     214             :       CALL keyword_create(keyword, __LOCATION__, name="START_STEP", &
     215             :                           description="First step the field is applied ", &
     216             :                           usage="START_STEP 0", &
     217        8408 :                           default_i_val=0)
     218        8408 :       CALL section_add_keyword(section, keyword)
     219        8408 :       CALL keyword_release(keyword)
     220             : 
     221             :       CALL keyword_create(keyword, __LOCATION__, name="END_STEP", &
     222             :                           description="Last step the field is applied", &
     223             :                           usage="END_STEP 2", &
     224        8408 :                           default_i_val=-1)
     225        8408 :       CALL section_add_keyword(section, keyword)
     226        8408 :       CALL keyword_release(keyword)
     227             : 
     228        8408 :    END SUBROUTINE create_constant_env_section
     229             : 
     230             : ! **************************************************************************************************
     231             : !> \brief ...
     232             : !> \param section ...
     233             : ! **************************************************************************************************
     234        8408 :    SUBROUTINE create_gaussian_env_section(section)
     235             :       TYPE(section_type), POINTER                        :: section
     236             : 
     237             :       TYPE(keyword_type), POINTER                        :: keyword
     238             : 
     239        8408 :       CPASSERT(.NOT. ASSOCIATED(section))
     240             :       CALL section_create(section, __LOCATION__, name="GAUSSIAN_ENV", &
     241             :                           description="parameters for a gaussian envelop", &
     242        8408 :                           n_keywords=6, n_subsections=1, repeats=.TRUE.)
     243             : 
     244        8408 :       NULLIFY (keyword)
     245             : 
     246             :       CALL keyword_create(keyword, __LOCATION__, name="T0", &
     247             :                           description="Center of the gaussian envelop (maximum of the gaussian)", &
     248             :                           usage="T0 2.0E0", &
     249             :                           default_r_val=0.0E0_dp, &
     250        8408 :                           unit_str="fs")
     251        8408 :       CALL section_add_keyword(section, keyword)
     252        8408 :       CALL keyword_release(keyword)
     253             : 
     254             :       CALL keyword_create(keyword, __LOCATION__, name="SIGMA", &
     255             :                           description="Width of the gaussian ", &
     256             :                           usage="SIGMA 2.0E0", &
     257             :                           default_r_val=-1.0E0_dp, &
     258        8408 :                           unit_str="fs")
     259        8408 :       CALL section_add_keyword(section, keyword)
     260        8408 :       CALL keyword_release(keyword)
     261             : 
     262        8408 :    END SUBROUTINE create_gaussian_env_section
     263             : 
     264             : ! **************************************************************************************************
     265             : !> \brief ...
     266             : !> \param section ...
     267             : ! **************************************************************************************************
     268        8408 :    SUBROUTINE create_ramp_env_section(section)
     269             :       TYPE(section_type), POINTER                        :: section
     270             : 
     271             :       TYPE(keyword_type), POINTER                        :: keyword
     272             : 
     273        8408 :       CPASSERT(.NOT. ASSOCIATED(section))
     274             :       CALL section_create(section, __LOCATION__, name="RAMP_ENV", &
     275             :                           description="Parameters for an trapeziodal envelop ", &
     276        8408 :                           n_keywords=6, n_subsections=1, repeats=.TRUE.)
     277             : 
     278        8408 :       NULLIFY (keyword)
     279             : 
     280             :       CALL keyword_create(keyword, __LOCATION__, name="START_STEP_IN", &
     281             :                           description="Step when the electric field starts to be applied ", &
     282             :                           usage="START_STEP_IN 0", &
     283        8408 :                           default_i_val=0)
     284        8408 :       CALL section_add_keyword(section, keyword)
     285        8408 :       CALL keyword_release(keyword)
     286             : 
     287             :       CALL keyword_create(keyword, __LOCATION__, name="END_STEP_IN", &
     288             :                           description="Step when the field reaches the full strength", &
     289             :                           usage="END_STEP_IN 2", &
     290        8408 :                           default_i_val=-1)
     291        8408 :       CALL section_add_keyword(section, keyword)
     292        8408 :       CALL keyword_release(keyword)
     293             : 
     294             :       CALL keyword_create(keyword, __LOCATION__, name="START_STEP_OUT", &
     295             :                           description="Step when the field starts to vanish ", &
     296             :                           usage="START_STEP 0", &
     297        8408 :                           default_i_val=0)
     298        8408 :       CALL section_add_keyword(section, keyword)
     299        8408 :       CALL keyword_release(keyword)
     300             : 
     301             :       CALL keyword_create(keyword, __LOCATION__, name="END_STEP_OUT", &
     302             :                           description="Step when the field disappears", &
     303             :                           usage="END_TIME 2", &
     304        8408 :                           default_i_val=-1)
     305        8408 :       CALL section_add_keyword(section, keyword)
     306        8408 :       CALL keyword_release(keyword)
     307             : 
     308        8408 :    END SUBROUTINE create_ramp_env_section
     309             : 
     310             : ! **************************************************************************************************
     311             : !> \brief ...
     312             : !> \param section ...
     313             : ! **************************************************************************************************
     314        8408 :    SUBROUTINE create_custom_env_section(section)
     315             :       TYPE(section_type), POINTER                        :: section
     316             : 
     317             :       TYPE(keyword_type), POINTER                        :: keyword
     318             : 
     319        8408 :       CPASSERT(.NOT. ASSOCIATED(section))
     320             :       CALL section_create(section, __LOCATION__, name="CUSTOM_ENV", &
     321             :                           description="Parameters for a custom efield", &
     322        8408 :                           n_keywords=2, n_subsections=1, repeats=.TRUE.)
     323             : 
     324        8408 :       NULLIFY (keyword)
     325             : 
     326             :       CALL keyword_create(keyword, __LOCATION__, name="EFIELD_FILE_NAME", &
     327             :                           description="Specify file that contains the electric field [V/m].", &
     328             :                           usage="EFIELD_FILE_NAME filename", &
     329        8408 :                           n_var=1, type_of_var=char_t, default_c_val="")
     330        8408 :       CALL section_add_keyword(section, keyword)
     331        8408 :       CALL keyword_release(keyword)
     332             : 
     333             :       CALL keyword_create(keyword, __LOCATION__, name="TIMESTEP", &
     334             :                           description="The time step between the entries in the list with the electric field.", &
     335             :                           usage="TIME_STEP 1", &
     336             :                           unit_str="fs", &
     337        8408 :                           default_r_val=1.0_dp)
     338        8408 :       CALL section_add_keyword(section, keyword)
     339        8408 :       CALL keyword_release(keyword)
     340             : 
     341        8408 :    END SUBROUTINE create_custom_env_section
     342             : 
     343             : END MODULE input_cp2k_field

Generated by: LCOV version 1.15