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 16872 : SUBROUTINE create_per_efield_section(section)
52 : TYPE(section_type), POINTER :: section
53 :
54 : TYPE(keyword_type), POINTER :: keyword
55 :
56 16872 : 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 50616 : n_keywords=6, n_subsections=1, repeats=.TRUE.)
64 :
65 16872 : 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 16872 : default_r_val=0._dp)
71 16872 : CALL section_add_keyword(section, keyword)
72 16872 : 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 16872 : type_of_var=real_t, default_r_vals=(/0.0_dp, 0.0_dp, 1.0_dp/))
79 16872 : CALL section_add_keyword(section, keyword)
80 16872 : 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 33744 : lone_keyword_l_val=.TRUE.)
88 16872 : CALL section_add_keyword(section, keyword)
89 16872 : 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 16872 : type_of_var=real_t, default_r_vals=(/1.0_dp, 1.0_dp, 1.0_dp/))
96 16872 : CALL section_add_keyword(section, keyword)
97 16872 : CALL keyword_release(keyword)
98 :
99 16872 : 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 8444 : 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 8444 : 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 8444 : n_keywords=6, n_subsections=1, repeats=.TRUE.)
118 :
119 8444 : 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 8444 : default_r_val=0._dp)
128 8444 : CALL section_add_keyword(section, keyword)
129 8444 : 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 8444 : type_of_var=real_t, default_r_vals=(/0.0_dp, 0.0_dp, 1.0_dp/))
136 8444 : CALL section_add_keyword(section, keyword)
137 8444 : 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 8444 : default_r_val=0._dp, unit_str="nm")
143 8444 : CALL section_add_keyword(section, keyword)
144 8444 : 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 8444 : default_r_val=0._dp)
151 8444 : CALL section_add_keyword(section, keyword)
152 8444 : 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 8444 : enum_i_vals=(/constant_env, gaussian_env, ramp_env, custom_env/))
164 8444 : CALL section_add_keyword(section, keyword)
165 8444 : 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 8444 : default_r_vals=(/0.0_dp, 0.0_dp, 0.0_dp/))
177 8444 : CALL section_add_keyword(section, keyword)
178 8444 : CALL keyword_release(keyword)
179 :
180 8444 : CALL create_constant_env_section(subsection)
181 8444 : CALL section_add_subsection(section, subsection)
182 8444 : CALL section_release(subsection)
183 :
184 8444 : CALL create_gaussian_env_section(subsection)
185 8444 : CALL section_add_subsection(section, subsection)
186 8444 : CALL section_release(subsection)
187 :
188 8444 : CALL create_ramp_env_section(subsection)
189 8444 : CALL section_add_subsection(section, subsection)
190 8444 : CALL section_release(subsection)
191 :
192 8444 : CALL create_custom_env_section(subsection)
193 8444 : CALL section_add_subsection(section, subsection)
194 8444 : CALL section_release(subsection)
195 :
196 8444 : END SUBROUTINE create_efield_section
197 :
198 : ! **************************************************************************************************
199 : !> \brief ...
200 : !> \param section ...
201 : ! **************************************************************************************************
202 8444 : SUBROUTINE create_constant_env_section(section)
203 : TYPE(section_type), POINTER :: section
204 :
205 : TYPE(keyword_type), POINTER :: keyword
206 :
207 8444 : CPASSERT(.NOT. ASSOCIATED(section))
208 : CALL section_create(section, __LOCATION__, name="CONSTANT_ENV", &
209 : description="parameters for a constant envelop", &
210 8444 : n_keywords=6, n_subsections=1, repeats=.TRUE.)
211 :
212 8444 : 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 8444 : default_i_val=0)
218 8444 : CALL section_add_keyword(section, keyword)
219 8444 : 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 8444 : default_i_val=-1)
225 8444 : CALL section_add_keyword(section, keyword)
226 8444 : CALL keyword_release(keyword)
227 :
228 8444 : END SUBROUTINE create_constant_env_section
229 :
230 : ! **************************************************************************************************
231 : !> \brief ...
232 : !> \param section ...
233 : ! **************************************************************************************************
234 8444 : SUBROUTINE create_gaussian_env_section(section)
235 : TYPE(section_type), POINTER :: section
236 :
237 : TYPE(keyword_type), POINTER :: keyword
238 :
239 8444 : CPASSERT(.NOT. ASSOCIATED(section))
240 : CALL section_create(section, __LOCATION__, name="GAUSSIAN_ENV", &
241 : description="parameters for a gaussian envelop", &
242 8444 : n_keywords=6, n_subsections=1, repeats=.TRUE.)
243 :
244 8444 : 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 8444 : unit_str="fs")
251 8444 : CALL section_add_keyword(section, keyword)
252 8444 : 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 8444 : unit_str="fs")
259 8444 : CALL section_add_keyword(section, keyword)
260 8444 : CALL keyword_release(keyword)
261 :
262 8444 : END SUBROUTINE create_gaussian_env_section
263 :
264 : ! **************************************************************************************************
265 : !> \brief ...
266 : !> \param section ...
267 : ! **************************************************************************************************
268 8444 : SUBROUTINE create_ramp_env_section(section)
269 : TYPE(section_type), POINTER :: section
270 :
271 : TYPE(keyword_type), POINTER :: keyword
272 :
273 8444 : CPASSERT(.NOT. ASSOCIATED(section))
274 : CALL section_create(section, __LOCATION__, name="RAMP_ENV", &
275 : description="Parameters for an trapeziodal envelop ", &
276 8444 : n_keywords=6, n_subsections=1, repeats=.TRUE.)
277 :
278 8444 : 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 8444 : default_i_val=0)
284 8444 : CALL section_add_keyword(section, keyword)
285 8444 : 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 8444 : default_i_val=-1)
291 8444 : CALL section_add_keyword(section, keyword)
292 8444 : 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 8444 : default_i_val=0)
298 8444 : CALL section_add_keyword(section, keyword)
299 8444 : 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 8444 : default_i_val=-1)
305 8444 : CALL section_add_keyword(section, keyword)
306 8444 : CALL keyword_release(keyword)
307 :
308 8444 : END SUBROUTINE create_ramp_env_section
309 :
310 : ! **************************************************************************************************
311 : !> \brief ...
312 : !> \param section ...
313 : ! **************************************************************************************************
314 8444 : SUBROUTINE create_custom_env_section(section)
315 : TYPE(section_type), POINTER :: section
316 :
317 : TYPE(keyword_type), POINTER :: keyword
318 :
319 8444 : CPASSERT(.NOT. ASSOCIATED(section))
320 : CALL section_create(section, __LOCATION__, name="CUSTOM_ENV", &
321 : description="Parameters for a custom efield", &
322 8444 : n_keywords=2, n_subsections=1, repeats=.TRUE.)
323 :
324 8444 : 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 8444 : n_var=1, type_of_var=char_t, default_c_val="")
330 8444 : CALL section_add_keyword(section, keyword)
331 8444 : 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 8444 : default_r_val=1.0_dp)
338 8444 : CALL section_add_keyword(section, keyword)
339 8444 : CALL keyword_release(keyword)
340 :
341 8444 : END SUBROUTINE create_custom_env_section
342 :
343 : END MODULE input_cp2k_field
|