(git:a660c7f)
Loading...
Searching...
No Matches
force_fields_input.F
Go to the documentation of this file.
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!> \par History
10!> Subroutine input_torsions changed (DG) 05-Dec-2000
11!> Output formats changed (DG) 05-Dec-2000
12!> JGH (26-01-2002) : force field parameters stored in tables, not in
13!> matrices. Input changed to have parameters labeled by the position
14!> and not atom pairs (triples etc)
15!> Teo (11.2005) : Moved all information on force field pair_potential to
16!> a much lighter memory structure
17!> Teo 09.2006 : Split all routines force_field I/O in a separate file
18!> \author CJM
19! **************************************************************************************************
23 USE bibliography, ONLY: clabaut2020,&
27 tosi1964a,&
28 tosi1964b,&
30 cite_reference
31 USE cp_files, ONLY: discover_file
43 USE cp_units, ONLY: cp_unit_to_cp2k
47 do_ff_g87,&
48 do_ff_g96,&
60 USE input_val_types, ONLY: val_get,&
62 USE kinds, ONLY: default_path_length,&
64 dp
65 USE mathconstants, ONLY: pi
66 USE mathlib, ONLY: invert_matrix
69 USE pair_potential_types, ONLY: &
78 USE torch_api, ONLY: torch_allow_tf32,&
80#include "./base/base_uses.f90"
81
82 IMPLICIT NONE
83
84 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'force_fields_input'
85
86 PRIVATE
87 PUBLIC :: read_force_field_section, &
93
94CONTAINS
95
96! **************************************************************************************************
97!> \brief Reads the force_field input section
98!> \param ff_section ...
99!> \param mm_section ...
100!> \param ff_type ...
101!> \param para_env ...
102!> \author teo
103! **************************************************************************************************
104 SUBROUTINE read_force_field_section1(ff_section, mm_section, ff_type, para_env)
105 TYPE(section_vals_type), POINTER :: ff_section, mm_section
106 TYPE(force_field_type), INTENT(INOUT) :: ff_type
107 TYPE(mp_para_env_type), POINTER :: para_env
108
109 CHARACTER(LEN=default_string_length), &
110 DIMENSION(:), POINTER :: atm_names
111 INTEGER :: nace, nb4, nbends, nbm, nbmhft, nbmhftd, nbonds, nchg, ndeepmd, neam, ngal, &
112 ngal21, ngd, ngp, nimpr, nipbv, nlj, nmace, nnequip, nopbend, nshell, nsiepmann, ntab, &
113 ntersoff, ntors, ntot, nubs, nwl
114 LOGICAL :: explicit, unique_spline
115 REAL(KIND=dp) :: min_eps_spline_allowed
116 TYPE(input_info_type), POINTER :: inp_info
117 TYPE(section_vals_type), POINTER :: tmp_section, tmp_section2
118
119 INTEGER::i
120
121 NULLIFY (tmp_section, tmp_section2)
122 inp_info => ff_type%inp_info
123 CALL section_vals_val_get(ff_section, "PARMTYPE", i_val=ff_type%ff_type)
124 CALL section_vals_val_get(ff_section, "EI_SCALE14", r_val=ff_type%ei_scale14)
125 CALL section_vals_val_get(ff_section, "VDW_SCALE14", r_val=ff_type%vdw_scale14)
126 CALL section_vals_val_get(ff_section, "SPLINE%RCUT_NB", r_val=ff_type%rcut_nb)
127 CALL section_vals_val_get(ff_section, "SPLINE%R0_NB", r_val=ff_type%rlow_nb)
128 CALL section_vals_val_get(ff_section, "SPLINE%EPS_SPLINE", r_val=ff_type%eps_spline)
129 CALL section_vals_val_get(ff_section, "SPLINE%EMAX_SPLINE", r_val=ff_type%emax_spline)
130 CALL section_vals_val_get(ff_section, "SPLINE%EMAX_ACCURACY", r_val=ff_type%max_energy)
131 CALL section_vals_val_get(ff_section, "SPLINE%NPOINTS", i_val=ff_type%npoints)
132 CALL section_vals_val_get(ff_section, "IGNORE_MISSING_CRITICAL_PARAMS", l_val=ff_type%ignore_missing_critical)
133 cpassert(ff_type%max_energy <= ff_type%emax_spline)
134 ! Read the parameter file name only if the force field type requires it..
135 SELECT CASE (ff_type%ff_type)
137 CALL section_vals_val_get(ff_section, "PARM_FILE_NAME", c_val=ff_type%ff_file_name)
138
139 IF (trim(ff_type%ff_file_name) == "") THEN
140 cpabort("Force Field Parameter's filename is empty! Please check your input file.")
141 END IF
142
143 CASE (do_ff_undef)
144 ! Do Nothing
145 CASE DEFAULT
146 cpabort("Force field type not implemented")
147 END SELECT
148 ! Numerical Accuracy:
149 ! the factors here should depend on the energy and on the shape of each potential mapped
150 ! with splines. this would make everything un-necessarily complicated. Let's just be safe
151 ! and assume that we cannot achieve an accuracy on the spline 2 orders of magnitude more
152 ! than the smallest representable number (taking into account also the max_energy for the
153 ! spline generation
154 min_eps_spline_allowed = 20.0_dp*max(ff_type%max_energy, 10.0_dp)*epsilon(0.0_dp)
155 IF (ff_type%eps_spline < min_eps_spline_allowed) THEN
156 CALL cp_warn(__location__, &
157 "Requested spline accuracy ("//trim(cp_to_string(ff_type%eps_spline))//" ) "// &
158 "is smaller than the minimum value allowed ("//trim(cp_to_string(min_eps_spline_allowed))// &
159 " ) with the present machine precision ("//trim(cp_to_string(epsilon(0.0_dp)))//" ). "// &
160 "New EPS_SPLINE value ("//trim(cp_to_string(min_eps_spline_allowed))//" ). ")
161 ff_type%eps_spline = min_eps_spline_allowed
162 END IF
163 CALL section_vals_val_get(ff_section, "SHIFT_CUTOFF", l_val=ff_type%shift_cutoff)
164 CALL section_vals_val_get(ff_section, "SPLINE%UNIQUE_SPLINE", l_val=unique_spline)
165 ! Single spline
168
169 CALL section_vals_val_get(ff_section, "MULTIPLE_POTENTIAL", l_val=ff_type%multiple_potential)
170 CALL section_vals_val_get(ff_section, "DO_NONBONDED", l_val=ff_type%do_nonbonded)
171 CALL section_vals_val_get(ff_section, "DO_ELECTROSTATICS", l_val=ff_type%do_electrostatics)
172 tmp_section => section_vals_get_subs_vals(ff_section, "NONBONDED")
173 CALL section_vals_get(tmp_section, explicit=explicit)
174 IF (explicit .AND. ff_type%do_nonbonded) THEN
175 tmp_section2 => section_vals_get_subs_vals(tmp_section, "LENNARD-JONES")
176 CALL section_vals_get(tmp_section2, explicit=explicit, n_repetition=nlj)
177 ntot = 0
178 IF (explicit) THEN
179 CALL pair_potential_reallocate(inp_info%nonbonded, 1, ntot + nlj, lj_charmm=.true.)
180 CALL read_lj_section(inp_info%nonbonded, tmp_section2, ntot)
181 END IF
182
183 tmp_section2 => section_vals_get_subs_vals(tmp_section, "WILLIAMS")
184 CALL section_vals_get(tmp_section2, explicit=explicit, n_repetition=nwl)
185 ntot = nlj
186 IF (explicit) THEN
187 CALL pair_potential_reallocate(inp_info%nonbonded, 1, ntot + nwl, williams=.true.)
188 CALL read_wl_section(inp_info%nonbonded, tmp_section2, ntot)
189 END IF
190
191 tmp_section2 => section_vals_get_subs_vals(tmp_section, "EAM")
192 CALL section_vals_get(tmp_section2, explicit=explicit, n_repetition=neam)
193 ntot = nlj + nwl
194 IF (explicit) THEN
195 CALL pair_potential_reallocate(inp_info%nonbonded, 1, ntot + neam, eam=.true.)
196 CALL read_eam_section(inp_info%nonbonded, tmp_section2, ntot, para_env, mm_section)
197 END IF
198
199 tmp_section2 => section_vals_get_subs_vals(tmp_section, "GOODWIN")
200 CALL section_vals_get(tmp_section2, explicit=explicit, n_repetition=ngd)
201 ntot = nlj + nwl + neam
202 IF (explicit) THEN
203 CALL pair_potential_reallocate(inp_info%nonbonded, 1, ntot + ngd, goodwin=.true.)
204 CALL read_gd_section(inp_info%nonbonded, tmp_section2, ntot)
205 END IF
206
207 tmp_section2 => section_vals_get_subs_vals(tmp_section, "IPBV")
208 CALL section_vals_get(tmp_section2, explicit=explicit, n_repetition=nipbv)
209 ntot = nlj + nwl + neam + ngd
210 IF (explicit) THEN
211 CALL pair_potential_reallocate(inp_info%nonbonded, 1, ntot + nipbv, ipbv=.true.)
212 CALL read_ipbv_section(inp_info%nonbonded, tmp_section2, ntot)
213 END IF
214
215 tmp_section2 => section_vals_get_subs_vals(tmp_section, "BMHFT")
216 CALL section_vals_get(tmp_section2, explicit=explicit, n_repetition=nbmhft)
217 ntot = nlj + nwl + neam + ngd + nipbv
218 IF (explicit) THEN
219 CALL pair_potential_reallocate(inp_info%nonbonded, 1, ntot + nbmhft, bmhft=.true.)
220 CALL read_bmhft_section(inp_info%nonbonded, tmp_section2, ntot)
221 END IF
222
223 tmp_section2 => section_vals_get_subs_vals(tmp_section, "BMHFTD")
224 CALL section_vals_get(tmp_section2, explicit=explicit, n_repetition=nbmhftd)
225 ntot = nlj + nwl + neam + ngd + nipbv + nbmhft
226 IF (explicit) THEN
227 CALL pair_potential_reallocate(inp_info%nonbonded, 1, ntot + nbmhftd, bmhftd=.true.)
228 CALL read_bmhftd_section(inp_info%nonbonded, tmp_section2, ntot)
229 END IF
230
231 tmp_section2 => section_vals_get_subs_vals(tmp_section, "BUCK4RANGES")
232 CALL section_vals_get(tmp_section2, explicit=explicit, n_repetition=nb4)
233 ntot = nlj + nwl + neam + ngd + nipbv + nbmhft + nbmhftd
234 IF (explicit) THEN
235 CALL pair_potential_reallocate(inp_info%nonbonded, 1, ntot + nb4, buck4r=.true.)
236 CALL read_b4_section(inp_info%nonbonded, tmp_section2, ntot)
237 END IF
238
239 tmp_section2 => section_vals_get_subs_vals(tmp_section, "BUCKMORSE")
240 CALL section_vals_get(tmp_section2, explicit=explicit, n_repetition=nbm)
241 ntot = nlj + nwl + neam + ngd + nipbv + nbmhft + nbmhftd + nb4
242 IF (explicit) THEN
243 CALL pair_potential_reallocate(inp_info%nonbonded, 1, ntot + nbm, buckmo=.true.)
244 CALL read_bm_section(inp_info%nonbonded, tmp_section2, ntot)
245 END IF
246
247 tmp_section2 => section_vals_get_subs_vals(tmp_section, "GENPOT")
248 CALL section_vals_get(tmp_section2, explicit=explicit, n_repetition=ngp)
249 ntot = nlj + nwl + neam + ngd + nipbv + nbmhft + nbmhftd + nb4 + nbm
250 IF (explicit) THEN
251 CALL pair_potential_reallocate(inp_info%nonbonded, 1, ntot + ngp, gp=.true.)
252 CALL read_gp_section(inp_info%nonbonded, tmp_section2, ntot)
253 END IF
254 tmp_section2 => section_vals_get_subs_vals(tmp_section, "TERSOFF")
255 CALL section_vals_get(tmp_section2, explicit=explicit, n_repetition=ntersoff)
256 ntot = nlj + nwl + neam + ngd + nipbv + nbmhft + nbmhftd + nb4 + nbm + ngp
257 IF (explicit) THEN
258 CALL pair_potential_reallocate(inp_info%nonbonded, 1, ntot + ntersoff, tersoff=.true.)
259 CALL read_tersoff_section(inp_info%nonbonded, tmp_section2, ntot, tmp_section2)
260 END IF
261
262 tmp_section2 => section_vals_get_subs_vals(tmp_section, "GAL19")
263 CALL section_vals_get(tmp_section2, explicit=explicit, n_repetition=ngal)
264 ntot = nlj + nwl + neam + ngd + nipbv + nbmhft + nbmhftd + nb4 + nbm + ngp + ntersoff
265 IF (explicit) THEN
266 CALL pair_potential_reallocate(inp_info%nonbonded, 1, ntot + ngal, gal=.true.)
267 CALL read_gal_section(inp_info%nonbonded, tmp_section2, ntot, tmp_section2)
268 END IF
269
270 tmp_section2 => section_vals_get_subs_vals(tmp_section, "GAL21")
271 CALL section_vals_get(tmp_section2, explicit=explicit, n_repetition=ngal21)
272 ntot = nlj + nwl + neam + ngd + nipbv + nbmhft + nbmhftd + nb4 + nbm + ngp + ntersoff + ngal
273 IF (explicit) THEN
274 CALL pair_potential_reallocate(inp_info%nonbonded, 1, ntot + ngal21, gal21=.true.)
275 CALL read_gal21_section(inp_info%nonbonded, tmp_section2, ntot, tmp_section2)
276 END IF
277
278 tmp_section2 => section_vals_get_subs_vals(tmp_section, "SIEPMANN")
279 CALL section_vals_get(tmp_section2, explicit=explicit, n_repetition=nsiepmann)
280 ntot = nlj + nwl + neam + ngd + nipbv + nbmhft + nbmhftd + nb4 + nbm + ngp + ntersoff + ngal + ngal21
281 IF (explicit) THEN
282 CALL pair_potential_reallocate(inp_info%nonbonded, 1, ntot + nsiepmann, siepmann=.true.)
283 CALL read_siepmann_section(inp_info%nonbonded, tmp_section2, ntot, tmp_section2)
284 END IF
285
286 tmp_section2 => section_vals_get_subs_vals(tmp_section, "nequip")
287 CALL section_vals_get(tmp_section2, explicit=explicit, n_repetition=nnequip)
288 ntot = nlj + nwl + neam + ngd + nipbv + nbmhft + nbmhftd + nb4 + nbm + ngp + ntersoff + &
289 ngal + ngal21 + nsiepmann
290 IF (explicit) THEN
291 ! avoid repeating the nequip section for each pair
292 CALL section_vals_val_get(tmp_section2, "ATOMS", c_vals=atm_names)
293 nnequip = nnequip - 1 + SIZE(atm_names) + (SIZE(atm_names)*SIZE(atm_names) - SIZE(atm_names))/2
294 CALL pair_potential_reallocate(inp_info%nonbonded, 1, ntot + nnequip, nequip=.true.)
295 CALL read_nequip_section(inp_info%nonbonded, tmp_section2, ntot)
296 END IF
297
298 tmp_section2 => section_vals_get_subs_vals(tmp_section, "TABPOT")
299 CALL section_vals_get(tmp_section2, explicit=explicit, n_repetition=ntab)
300 ntot = nlj + nwl + neam + ngd + nipbv + nbmhft + nbmhftd + nb4 + nbm + ngp + ntersoff + &
301 ngal + ngal21 + nsiepmann + nnequip
302 IF (explicit) THEN
303 CALL pair_potential_reallocate(inp_info%nonbonded, 1, ntot + ntab, tab=.true.)
304 CALL read_tabpot_section(inp_info%nonbonded, tmp_section2, ntot, para_env, mm_section)
305 END IF
306
307 tmp_section2 => section_vals_get_subs_vals(tmp_section, "DEEPMD")
308 CALL section_vals_get(tmp_section2, explicit=explicit, n_repetition=ndeepmd)
309 ntot = nlj + nwl + neam + ngd + nipbv + nbmhft + nbmhftd + nb4 + nbm + ngp + ntersoff + &
310 ngal + ngal21 + nsiepmann + nnequip + ntab
311 IF (explicit) THEN
312 ! avoid repeating the deepmd section for each pair
313 CALL section_vals_val_get(tmp_section2, "ATOMS", c_vals=atm_names)
314 ndeepmd = ndeepmd - 1 + SIZE(atm_names) + (SIZE(atm_names)*SIZE(atm_names) - SIZE(atm_names))/2
315 CALL pair_potential_reallocate(inp_info%nonbonded, 1, ntot + ndeepmd, deepmd=.true.)
316 CALL read_deepmd_section(inp_info%nonbonded, tmp_section2, ntot)
317 END IF
318
319 tmp_section2 => section_vals_get_subs_vals(tmp_section, "ACE")
320 CALL section_vals_get(tmp_section2, explicit=explicit, n_repetition=nace)
321 ntot = nlj + nwl + neam + ngd + nipbv + nbmhft + nbmhftd + nb4 + nbm + ngp + ntersoff + &
322 ngal + ngal21 + nsiepmann + nnequip + ntab + ndeepmd
323 IF (explicit) THEN
324 ! avoid repeating the ace section for each pair
325 CALL section_vals_val_get(tmp_section2, "ATOMS", c_vals=atm_names)
326 nace = nace - 1 + SIZE(atm_names) + (SIZE(atm_names)*SIZE(atm_names) - SIZE(atm_names))/2
327 CALL pair_potential_reallocate(inp_info%nonbonded, 1, ntot + nace, ace=.true.)
328 CALL read_ace_section(inp_info%nonbonded, tmp_section2, ntot)
329 END IF
330
331 tmp_section2 => section_vals_get_subs_vals(tmp_section, "MACE")
332 CALL section_vals_get(tmp_section2, explicit=explicit, n_repetition=nmace)
333 ntot = nlj + nwl + neam + ngd + nipbv + nbmhft + nbmhftd + nb4 + nbm + ngp + ntersoff + &
334 ngal + ngal21 + nsiepmann + nnequip + ntab + ndeepmd + nace
335 IF (explicit) THEN
336 ! avoid repeating the mace section for each pair
337 CALL section_vals_val_get(tmp_section2, "ATOMS", c_vals=atm_names)
338 nmace = nmace - 1 + SIZE(atm_names) + (SIZE(atm_names)*SIZE(atm_names) - SIZE(atm_names))/2
339 ! MACE reuses the nequip_pot_type storage (set%nequip), hence nequip=.TRUE. here
340 CALL pair_potential_reallocate(inp_info%nonbonded, 1, ntot + nmace, nequip=.true.)
341 CALL read_mace_section(inp_info%nonbonded, tmp_section2, ntot)
342 END IF
343
344 END IF
345
346 tmp_section => section_vals_get_subs_vals(ff_section, "NONBONDED14")
347 CALL section_vals_get(tmp_section, explicit=explicit)
348 IF (explicit .AND. ff_type%do_nonbonded) THEN
349 tmp_section2 => section_vals_get_subs_vals(tmp_section, "LENNARD-JONES")
350 CALL section_vals_get(tmp_section2, explicit=explicit, n_repetition=nlj)
351 ntot = 0
352 IF (explicit) THEN
353 CALL pair_potential_reallocate(inp_info%nonbonded14, 1, ntot + nlj, lj_charmm=.true.)
354 CALL read_lj_section(inp_info%nonbonded14, tmp_section2, ntot)
355 END IF
356 tmp_section2 => section_vals_get_subs_vals(tmp_section, "WILLIAMS")
357 CALL section_vals_get(tmp_section2, explicit=explicit, n_repetition=nwl)
358 ntot = nlj
359 IF (explicit) THEN
360 CALL pair_potential_reallocate(inp_info%nonbonded14, 1, ntot + nwl, williams=.true.)
361 CALL read_wl_section(inp_info%nonbonded14, tmp_section2, ntot)
362 END IF
363 tmp_section2 => section_vals_get_subs_vals(tmp_section, "GOODWIN")
364 CALL section_vals_get(tmp_section2, explicit=explicit, n_repetition=ngd)
365 ntot = nlj + nwl
366 IF (explicit) THEN
367 CALL pair_potential_reallocate(inp_info%nonbonded14, 1, ntot + ngd, goodwin=.true.)
368 CALL read_gd_section(inp_info%nonbonded14, tmp_section2, ntot)
369 END IF
370 tmp_section2 => section_vals_get_subs_vals(tmp_section, "GENPOT")
371 CALL section_vals_get(tmp_section2, explicit=explicit, n_repetition=ngp)
372 ntot = nlj + nwl + ngd
373 IF (explicit) THEN
374 CALL pair_potential_reallocate(inp_info%nonbonded14, 1, ntot + ngp, gp=.true.)
375 CALL read_gp_section(inp_info%nonbonded14, tmp_section2, ntot)
376 END IF
377 END IF
378
379 tmp_section => section_vals_get_subs_vals(ff_section, "CHARGE")
380 CALL section_vals_get(tmp_section, explicit=explicit, n_repetition=nchg)
381 IF (explicit) THEN
382 ntot = 0
383 CALL reallocate(inp_info%charge_atm, 1, nchg)
384 CALL reallocate(inp_info%charge, 1, nchg)
385 CALL read_chrg_section(inp_info%charge_atm, inp_info%charge, tmp_section, ntot)
386 END IF
387 tmp_section => section_vals_get_subs_vals(ff_section, "DIPOLE")
388 CALL section_vals_get(tmp_section, explicit=explicit, n_repetition=nchg)
389 IF (explicit) THEN
390 ntot = 0
391 CALL reallocate(inp_info%apol_atm, 1, nchg)
392 CALL reallocate(inp_info%apol, 1, nchg)
393 CALL read_apol_section(inp_info%apol_atm, inp_info%apol, inp_info%damping_list, &
394 tmp_section, ntot)
395 END IF
396 tmp_section => section_vals_get_subs_vals(ff_section, "QUADRUPOLE")
397 CALL section_vals_get(tmp_section, explicit=explicit, n_repetition=nchg)
398 IF (explicit) THEN
399 ntot = 0
400 CALL reallocate(inp_info%cpol_atm, 1, nchg)
401 CALL reallocate(inp_info%cpol, 1, nchg)
402 CALL read_cpol_section(inp_info%cpol_atm, inp_info%cpol, tmp_section, ntot)
403 END IF
404 tmp_section => section_vals_get_subs_vals(ff_section, "SHELL")
405 CALL section_vals_get(tmp_section, explicit=explicit, n_repetition=nshell)
406 IF (explicit) THEN
407 ntot = 0
408 CALL shell_p_create(inp_info%shell_list, nshell)
409 CALL read_shell_section(inp_info%shell_list, tmp_section, ntot)
410 END IF
411
412 tmp_section => section_vals_get_subs_vals(ff_section, "BOND")
413 CALL section_vals_get(tmp_section, explicit=explicit, n_repetition=nbonds)
414 IF (explicit) THEN
415 ntot = 0
416 CALL reallocate(inp_info%bond_kind, 1, nbonds)
417 CALL reallocate(inp_info%bond_a, 1, nbonds)
418 CALL reallocate(inp_info%bond_b, 1, nbonds)
419 CALL reallocate(inp_info%bond_k, 1, 3, 1, nbonds)
420 CALL reallocate(inp_info%bond_r0, 1, nbonds)
421 CALL reallocate(inp_info%bond_cs, 1, nbonds)
422 CALL read_bonds_section(inp_info%bond_kind, inp_info%bond_a, inp_info%bond_b, inp_info%bond_k, &
423 inp_info%bond_r0, inp_info%bond_cs, tmp_section, ntot)
424 END IF
425 tmp_section => section_vals_get_subs_vals(ff_section, "BEND")
426 CALL section_vals_get(tmp_section, explicit=explicit, n_repetition=nbends)
427 IF (explicit) THEN
428 ntot = 0
429 CALL reallocate(inp_info%bend_kind, 1, nbends)
430 CALL reallocate(inp_info%bend_a, 1, nbends)
431 CALL reallocate(inp_info%bend_b, 1, nbends)
432 CALL reallocate(inp_info%bend_c, 1, nbends)
433 CALL reallocate(inp_info%bend_k, 1, nbends)
434 CALL reallocate(inp_info%bend_theta0, 1, nbends)
435 CALL reallocate(inp_info%bend_cb, 1, nbends)
436 CALL reallocate(inp_info%bend_r012, 1, nbends)
437 CALL reallocate(inp_info%bend_r032, 1, nbends)
438 CALL reallocate(inp_info%bend_kbs12, 1, nbends)
439 CALL reallocate(inp_info%bend_kbs32, 1, nbends)
440 CALL reallocate(inp_info%bend_kss, 1, nbends)
441 IF (ASSOCIATED(inp_info%bend_legendre)) THEN
442 DO i = 1, SIZE(inp_info%bend_legendre)
443 IF (ASSOCIATED(inp_info%bend_legendre(i)%coeffs)) THEN
444 DEALLOCATE (inp_info%bend_legendre(i)%coeffs)
445 NULLIFY (inp_info%bend_legendre(i)%coeffs)
446 END IF
447 END DO
448 DEALLOCATE (inp_info%bend_legendre)
449 NULLIFY (inp_info%bend_legendre)
450 END IF
451 ALLOCATE (inp_info%bend_legendre(1:nbends))
452 DO i = 1, SIZE(inp_info%bend_legendre(1:nbends))
453 NULLIFY (inp_info%bend_legendre(i)%coeffs)
454 inp_info%bend_legendre(i)%order = 0
455 END DO
456 CALL read_bends_section(inp_info%bend_kind, inp_info%bend_a, inp_info%bend_b, inp_info%bend_c, &
457 inp_info%bend_k, inp_info%bend_theta0, inp_info%bend_cb, &
458 inp_info%bend_r012, inp_info%bend_r032, inp_info%bend_kbs12, &
459 inp_info%bend_kbs32, inp_info%bend_kss, &
460 inp_info%bend_legendre, tmp_section, ntot)
461 END IF
462 tmp_section => section_vals_get_subs_vals(ff_section, "BEND")
463 CALL section_vals_get(tmp_section, explicit=explicit, n_repetition=nubs)
464 IF (explicit) THEN
465 ntot = 0
466 CALL reallocate(inp_info%ub_kind, 1, nubs)
467 CALL reallocate(inp_info%ub_a, 1, nubs)
468 CALL reallocate(inp_info%ub_b, 1, nubs)
469 CALL reallocate(inp_info%ub_c, 1, nubs)
470 CALL reallocate(inp_info%ub_k, 1, 3, 1, nubs)
471 CALL reallocate(inp_info%ub_r0, 1, nubs)
472 CALL read_ubs_section(inp_info%ub_kind, inp_info%ub_a, inp_info%ub_b, inp_info%ub_c, &
473 inp_info%ub_k, inp_info%ub_r0, tmp_section, ntot)
474 END IF
475 tmp_section => section_vals_get_subs_vals(ff_section, "TORSION")
476 CALL section_vals_get(tmp_section, explicit=explicit, n_repetition=ntors)
477 IF (explicit) THEN
478 ntot = 0
479 CALL reallocate(inp_info%torsion_kind, 1, ntors)
480 CALL reallocate(inp_info%torsion_a, 1, ntors)
481 CALL reallocate(inp_info%torsion_b, 1, ntors)
482 CALL reallocate(inp_info%torsion_c, 1, ntors)
483 CALL reallocate(inp_info%torsion_d, 1, ntors)
484 CALL reallocate(inp_info%torsion_k, 1, ntors)
485 CALL reallocate(inp_info%torsion_m, 1, ntors)
486 CALL reallocate(inp_info%torsion_phi0, 1, ntors)
487 CALL read_torsions_section(inp_info%torsion_kind, inp_info%torsion_a, inp_info%torsion_b, &
488 inp_info%torsion_c, inp_info%torsion_d, inp_info%torsion_k, inp_info%torsion_phi0, &
489 inp_info%torsion_m, tmp_section, ntot)
490 END IF
491
492 tmp_section => section_vals_get_subs_vals(ff_section, "IMPROPER")
493 CALL section_vals_get(tmp_section, explicit=explicit, n_repetition=nimpr)
494 IF (explicit) THEN
495 ntot = 0
496 CALL reallocate(inp_info%impr_kind, 1, nimpr)
497 CALL reallocate(inp_info%impr_a, 1, nimpr)
498 CALL reallocate(inp_info%impr_b, 1, nimpr)
499 CALL reallocate(inp_info%impr_c, 1, nimpr)
500 CALL reallocate(inp_info%impr_d, 1, nimpr)
501 CALL reallocate(inp_info%impr_k, 1, nimpr)
502 CALL reallocate(inp_info%impr_phi0, 1, nimpr)
503 CALL read_improper_section(inp_info%impr_kind, inp_info%impr_a, inp_info%impr_b, &
504 inp_info%impr_c, inp_info%impr_d, inp_info%impr_k, inp_info%impr_phi0, &
505 tmp_section, ntot)
506 END IF
507
508 tmp_section => section_vals_get_subs_vals(ff_section, "OPBEND")
509 CALL section_vals_get(tmp_section, explicit=explicit, n_repetition=nopbend)
510 IF (explicit) THEN
511 ntot = 0
512 CALL reallocate(inp_info%opbend_kind, 1, nopbend)
513 CALL reallocate(inp_info%opbend_a, 1, nopbend)
514 CALL reallocate(inp_info%opbend_b, 1, nopbend)
515 CALL reallocate(inp_info%opbend_c, 1, nopbend)
516 CALL reallocate(inp_info%opbend_d, 1, nopbend)
517 CALL reallocate(inp_info%opbend_k, 1, nopbend)
518 CALL reallocate(inp_info%opbend_phi0, 1, nopbend)
519 CALL read_opbend_section(inp_info%opbend_kind, inp_info%opbend_a, inp_info%opbend_b, &
520 inp_info%opbend_c, inp_info%opbend_d, inp_info%opbend_k, inp_info%opbend_phi0, &
521 tmp_section, ntot)
522 END IF
523
524 END SUBROUTINE read_force_field_section1
525
526! **************************************************************************************************
527!> \brief Set up of the IPBV force fields
528!> \param at1 ...
529!> \param at2 ...
530!> \param ipbv ...
531!> \author teo
532! **************************************************************************************************
533 SUBROUTINE set_ipbv_ff(at1, at2, ipbv)
534 CHARACTER(LEN=*), INTENT(IN) :: at1, at2
535 TYPE(ipbv_pot_type), POINTER :: ipbv
536
537 IF ((at1(1:1) == 'O') .AND. (at2(1:1) == 'O')) THEN
538 ipbv%rcore = 0.9_dp ! a.u.
539 ipbv%m = -1.2226442563398141e+11_dp ! Kelvin/a.u.
540 ipbv%b = 1.1791292385486696e+11_dp ! Hartree
541
542 ! Hartree*a.u.^2
543 ipbv%a(2) = 4.786380682394_dp
544 ipbv%a(3) = -1543.407053545_dp
545 ipbv%a(4) = 88783.31188529_dp
546 ipbv%a(5) = -2361200.155376_dp
547 ipbv%a(6) = 35940504.84679_dp
548 ipbv%a(7) = -339762743.6358_dp
549 ipbv%a(8) = 2043874926.466_dp
550 ipbv%a(9) = -7654856796.383_dp
551 ipbv%a(10) = 16195251405.65_dp
552 ipbv%a(11) = -13140392992.18_dp
553 ipbv%a(12) = -9285572894.245_dp
554 ipbv%a(13) = 8756947519.029_dp
555 ipbv%a(14) = 15793297761.67_dp
556 ipbv%a(15) = 12917180227.21_dp
557 ELSE IF (((at1(1:1) == 'O') .AND. (at2(1:1) == 'H')) .OR. &
558 ((at1(1:1) == 'H') .AND. (at2(1:1) == 'O'))) THEN
559
560 ipbv%rcore = 2.95_dp ! a.u.
561
562 ipbv%m = -0.004025691139759147_dp ! Hartree/a.u.
563 ipbv%b = -2.193731138097428_dp ! Hartree
564 ! Hartree*a.u.^2
565 ipbv%a(2) = -195.7716013277_dp
566 ipbv%a(3) = 15343.78613395_dp
567 ipbv%a(4) = -530864.4586516_dp
568 ipbv%a(5) = 10707934.39058_dp
569 ipbv%a(6) = -140099704.7890_dp
570 ipbv%a(7) = 1250943273.785_dp
571 ipbv%a(8) = -7795458330.676_dp
572 ipbv%a(9) = 33955897217.31_dp
573 ipbv%a(10) = -101135640744.0_dp
574 ipbv%a(11) = 193107995718.7_dp
575 ipbv%a(12) = -193440560940.0_dp
576 ipbv%a(13) = -4224406093.918e0_dp
577 ipbv%a(14) = 217192386506.5e0_dp
578 ipbv%a(15) = -157581228915.5_dp
579 ELSE IF ((at1(1:1) == 'H') .AND. (at2(1:1) == 'H')) THEN
580 ipbv%rcore = 3.165_dp ! a.u.
581 ipbv%m = 0.002639704108787555_dp ! Hartree/a.u.
582 ipbv%b = -0.2735482611857583_dp ! Hartree
583 ! Hartree*a.u.^2
584 ipbv%a(2) = -26.29456010782_dp
585 ipbv%a(3) = 2373.352548248_dp
586 ipbv%a(4) = -93880.43551360_dp
587 ipbv%a(5) = 2154624.884809_dp
588 ipbv%a(6) = -31965151.34955_dp
589 ipbv%a(7) = 322781785.3278_dp
590 ipbv%a(8) = -2271097368.668_dp
591 ipbv%a(9) = 11169163192.90_dp
592 ipbv%a(10) = -37684457778.47_dp
593 ipbv%a(11) = 82562104256.03_dp
594 ipbv%a(12) = -100510435213.4_dp
595 ipbv%a(13) = 24570342714.65e0_dp
596 ipbv%a(14) = 88766181532.94e0_dp
597 ipbv%a(15) = -79705131323.98_dp
598 ELSE
599 cpabort("IPBV only for WATER")
600 END IF
601 END SUBROUTINE set_ipbv_ff
602
603! **************************************************************************************************
604!> \brief Set up of the BMHFT force fields
605!> \param at1 ...
606!> \param at2 ...
607!> \param ft ...
608!> \author teo
609! **************************************************************************************************
610 SUBROUTINE set_bmhft_ff(at1, at2, ft)
611 CHARACTER(LEN=*), INTENT(IN) :: at1, at2
612 TYPE(ft_pot_type), POINTER :: ft
613
614 ft%b = cp_unit_to_cp2k(3.1545_dp, "angstrom^-1")
615 IF ((at1(1:2) == 'NA') .AND. (at2(1:2) == 'NA')) THEN
616 ft%a = cp_unit_to_cp2k(424.097_dp, "eV")
617 ft%c = cp_unit_to_cp2k(1.05_dp, "eV*angstrom^6")
618 ft%d = cp_unit_to_cp2k(0.499_dp, "eV*angstrom^8")
619 ELSE IF (((at1(1:2) == 'NA') .AND. (at2(1:2) == 'CL')) .OR. &
620 ((at1(1:2) == 'CL') .AND. (at2(1:2) == 'NA'))) THEN
621
622 ft%a = cp_unit_to_cp2k(1256.31_dp, "eV")
623 ft%c = cp_unit_to_cp2k(7.00_dp, "eV*angstrom^6")
624 ft%d = cp_unit_to_cp2k(8.676_dp, "eV*angstrom^8")
625 ELSE IF ((at1(1:2) == 'CL') .AND. (at2(1:2) == 'CL')) THEN
626 ft%a = cp_unit_to_cp2k(3488.998_dp, "eV")
627 ft%c = cp_unit_to_cp2k(72.50_dp, "eV*angstrom^6")
628 ft%d = cp_unit_to_cp2k(145.427_dp, "eV*angstrom^8")
629 ELSE
630 cpabort("BMHFT only for NaCl")
631 END IF
632
633 END SUBROUTINE set_bmhft_ff
634
635! **************************************************************************************************
636!> \brief Set up of the BMHFTD force fields
637!> \author Mathieu Salanne 05.2010
638! **************************************************************************************************
639 SUBROUTINE set_bmhftd_ff()
640
641 cpabort("No default parameters present for BMHFTD")
642
643 END SUBROUTINE set_bmhftd_ff
644
645! **************************************************************************************************
646!> \brief Reads the EAM section
647!> \param nonbonded ...
648!> \param section ...
649!> \param start ...
650!> \param para_env ...
651!> \param mm_section ...
652!> \author teo
653! **************************************************************************************************
654 SUBROUTINE read_eam_section(nonbonded, section, start, para_env, mm_section)
655 TYPE(pair_potential_p_type), POINTER :: nonbonded
656 TYPE(section_vals_type), POINTER :: section
657 INTEGER, INTENT(IN) :: start
658 TYPE(mp_para_env_type), POINTER :: para_env
659 TYPE(section_vals_type), POINTER :: mm_section
660
661 CHARACTER(LEN=default_string_length), &
662 DIMENSION(:), POINTER :: atm_names
663 INTEGER :: isec, n_items
664
665 CALL section_vals_get(section, n_repetition=n_items)
666 DO isec = 1, n_items
667 CALL section_vals_val_get(section, "ATOMS", i_rep_section=isec, c_vals=atm_names)
668
669 nonbonded%pot(start + isec)%pot%type = ea_type
670 nonbonded%pot(start + isec)%pot%at1 = atm_names(1)
671 nonbonded%pot(start + isec)%pot%at2 = atm_names(2)
672 CALL uppercase(nonbonded%pot(start + isec)%pot%at1)
673 CALL uppercase(nonbonded%pot(start + isec)%pot%at2)
674 CALL section_vals_val_get(section, "PARM_FILE_NAME", i_rep_section=isec, &
675 c_val=nonbonded%pot(start + isec)%pot%set(1)%eam%eam_file_name)
676 CALL read_eam_data(nonbonded%pot(start + isec)%pot%set(1)%eam, para_env, mm_section)
677 nonbonded%pot(start + isec)%pot%rcutsq = nonbonded%pot(start + isec)%pot%set(1)%eam%acutal**2
678 END DO
679 END SUBROUTINE read_eam_section
680
681! **************************************************************************************
682!> \brief Reads the ACE section
683!> \param nonbonded ...
684!> \param section ...
685!> \param start ...
686! **************************************************************************************************
687 SUBROUTINE read_ace_section(nonbonded, section, start)
688 TYPE(pair_potential_p_type), POINTER :: nonbonded
689 TYPE(section_vals_type), POINTER :: section
690 INTEGER, INTENT(IN) :: start
691
692 CHARACTER(LEN=2), ALLOCATABLE, DIMENSION(:) :: ace_atype_symbol
693 CHARACTER(LEN=default_path_length) :: ace_filename
694 CHARACTER(LEN=default_string_length) :: ace_file_name
695 CHARACTER(LEN=default_string_length), &
696 DIMENSION(:), POINTER :: atm_names
697 INTEGER :: ace_ntype, isec, jsec, n_items
698 REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :) :: rcutall
699 TYPE(ace_model_type) :: model
700
701 n_items = 1
702 isec = 1
703 n_items = isec*n_items
704 CALL section_vals_val_get(section, "ATOMS", c_vals=atm_names)
705
706 ace_ntype = SIZE(atm_names)
707 ALLOCATE (ace_atype_symbol(ace_ntype), rcutall(ace_ntype, ace_ntype))
708 DO isec = 1, ace_ntype
709 ace_atype_symbol(isec) = atm_names(isec) (1:2)
710 END DO
711 CALL section_vals_val_get(section, "POT_FILE_NAME", c_val=ace_file_name)
712
713 ace_filename = discover_file(ace_file_name)
714
715#if defined(__ACE)
716 ! need ace_model_initialize() here somewhere to get rcut
717 CALL ace_model_initialize(ntypec=ace_ntype, symbolc=ace_atype_symbol, &
718 fname=trim(ace_filename), rcutc=rcutall, model=model)
719#else
720 cpabort("CP2K was compiled without ACE library.")
721#endif
722
723 DO isec = 1, SIZE(atm_names)
724 DO jsec = isec, SIZE(atm_names)
725 nonbonded%pot(start + n_items)%pot%type = ace_type
726 nonbonded%pot(start + n_items)%pot%at1 = atm_names(isec)
727 nonbonded%pot(start + n_items)%pot%at2 = atm_names(jsec)
728 CALL uppercase(nonbonded%pot(start + n_items)%pot%at1)
729 CALL uppercase(nonbonded%pot(start + n_items)%pot%at2)
730
731 nonbonded%pot(start + n_items)%pot%set(1)%ace%ace_file_name = ace_filename
732 nonbonded%pot(start + n_items)%pot%set(1)%ace%atom_ace_type = isec
733 nonbonded%pot(start + n_items)%pot%set(1)%ace%model = model
734
735 !using rcutall(isec,jsec) instead of maxval(rcutall) TODO check that
736 !it shouldn't be jsec,isec?
737 nonbonded%pot(start + n_items)%pot%rcutsq = cp_unit_to_cp2k(rcutall(isec, jsec), "angstrom")**2
738
739 n_items = n_items + 1
740 END DO
741 END DO
742 END SUBROUTINE read_ace_section
743
744! **************************************************************************************
745!> \brief Reads the DEEPMD section
746!> \param nonbonded ...
747!> \param section ...
748!> \param start ...
749!> \author teo
750! **************************************************************************************************
751 SUBROUTINE read_deepmd_section(nonbonded, section, start)
752 TYPE(pair_potential_p_type), POINTER :: nonbonded
753 TYPE(section_vals_type), POINTER :: section
754 INTEGER, INTENT(IN) :: start
755
756 CHARACTER(LEN=default_string_length) :: deepmd_file_name
757 CHARACTER(LEN=default_string_length), &
758 DIMENSION(:), POINTER :: atm_names
759 INTEGER :: isec, jsec, n_items
760 INTEGER, DIMENSION(:), POINTER :: atm_deepmd_types
761
762 n_items = 1
763 isec = 1
764 n_items = isec*n_items
765 CALL section_vals_val_get(section, "ATOMS", c_vals=atm_names)
766 CALL section_vals_val_get(section, "ATOMS_DEEPMD_TYPE", i_vals=atm_deepmd_types)
767 CALL section_vals_val_get(section, "POT_FILE_NAME", c_val=deepmd_file_name)
768
769 DO isec = 1, SIZE(atm_names)
770 DO jsec = isec, SIZE(atm_names)
771 nonbonded%pot(start + n_items)%pot%type = deepmd_type
772 nonbonded%pot(start + n_items)%pot%at1 = atm_names(isec)
773 nonbonded%pot(start + n_items)%pot%at2 = atm_names(jsec)
774 CALL uppercase(nonbonded%pot(start + n_items)%pot%at1)
775 CALL uppercase(nonbonded%pot(start + n_items)%pot%at2)
776
777 nonbonded%pot(start + n_items)%pot%set(1)%deepmd%deepmd_file_name = discover_file(deepmd_file_name)
778 nonbonded%pot(start + n_items)%pot%set(1)%deepmd%atom_deepmd_type = atm_deepmd_types(isec)
779 nonbonded%pot(start + n_items)%pot%rcutsq = 0.0_dp
780 n_items = n_items + 1
781 END DO
782 END DO
783 END SUBROUTINE read_deepmd_section
784
785! **************************************************************************************************
786!> \brief Reads the NEQUIP section
787!> \param nonbonded ...
788!> \param section ...
789!> \param start ...
790!> \author Gabriele Tocci
791! **************************************************************************************************
792 SUBROUTINE read_nequip_section(nonbonded, section, start)
793 TYPE(pair_potential_p_type), POINTER :: nonbonded
794 TYPE(section_vals_type), POINTER :: section
795 INTEGER, INTENT(IN) :: start
796
797 CHARACTER(LEN=default_string_length) :: model_type_str, pot_file_name, &
798 unit_energy, unit_forces, unit_length
799 CHARACTER(LEN=default_string_length), &
800 DIMENSION(:), POINTER :: atm_names
801 INTEGER :: chosen_type, isec, jsec, n_items
802 TYPE(nequip_pot_type) :: nequip
803
804 n_items = 1
805 isec = 1
806 n_items = isec*n_items
807 CALL section_vals_val_get(section, "ATOMS", c_vals=atm_names)
808 CALL section_vals_val_get(section, "POT_FILE_NAME", c_val=pot_file_name)
809 CALL section_vals_val_get(section, "UNIT_LENGTH", c_val=unit_length)
810 CALL section_vals_val_get(section, "UNIT_ENERGY", c_val=unit_energy)
811 CALL section_vals_val_get(section, "UNIT_FORCES", c_val=unit_forces)
812 CALL section_vals_val_get(section, "MODEL_TYPE", c_val=model_type_str)
813 CALL uppercase(model_type_str)
814
815 IF (trim(model_type_str) == "ALLEGRO") THEN
816 chosen_type = allegro_type
817 ELSE IF (trim(model_type_str) == "NEQUIP") THEN
818 chosen_type = nequip_type
819 ELSE
820 CALL cp_abort(__location__, &
821 "Unknown MODEL_TYPE: "//trim(model_type_str)//". Use NEQUIP or ALLEGRO.")
822 END IF
823
824 nequip%pot_file_name = discover_file(pot_file_name)
825 nequip%unit_length = unit_length
826 nequip%unit_forces = unit_forces
827 nequip%unit_energy = unit_energy
828 CALL read_nequip_data(nequip)
829 CALL check_cp2k_atom_names_in_torch(atm_names, nequip%type_names_torch)
830
831 DO isec = 1, SIZE(atm_names)
832 DO jsec = isec, SIZE(atm_names)
833 nonbonded%pot(start + n_items)%pot%type = chosen_type
834 nonbonded%pot(start + n_items)%pot%at1 = atm_names(isec)
835 nonbonded%pot(start + n_items)%pot%at2 = atm_names(jsec)
836 CALL uppercase(nonbonded%pot(start + n_items)%pot%at1)
837 CALL uppercase(nonbonded%pot(start + n_items)%pot%at2)
838 nonbonded%pot(start + n_items)%pot%set(1)%nequip = nequip
839 nonbonded%pot(start + n_items)%pot%rcutsq = nequip%rcutsq
840 n_items = n_items + 1
841 END DO
842 END DO
843
844 END SUBROUTINE read_nequip_section
845
846! **************************************************************************************************
847!> \brief Reads the MACE section
848!> \param nonbonded ...
849!> \param section ...
850!> \param start ...
851!> \author Xinyue Sun
852! **************************************************************************************************
853 SUBROUTINE read_mace_section(nonbonded, section, start)
854 TYPE(pair_potential_p_type), POINTER :: nonbonded
855 TYPE(section_vals_type), POINTER :: section
856 INTEGER, INTENT(IN) :: start
857
858 CHARACTER(LEN=default_string_length) :: pot_file_name
859 CHARACTER(LEN=default_string_length), &
860 DIMENSION(:), POINTER :: atm_names
861 INTEGER :: isec, jsec, n_items
862 TYPE(nequip_pot_type) :: mace
863
864 n_items = 1
865 isec = 1
866 n_items = isec*n_items
867 CALL section_vals_val_get(section, "ATOMS", c_vals=atm_names)
868 CALL section_vals_val_get(section, "POT_FILE_NAME", c_val=pot_file_name)
869
870 mace%pot_file_name = discover_file(pot_file_name)
871 ! MACE models use standardized units: Angstrom, eV and eV/Angstrom
872 mace%unit_length = "angstrom"
873 mace%unit_energy = "eV"
874 mace%unit_forces = "eV/Angstrom"
875 ! MACE models are exported to speak the same metadata/tensor dialect as NequIP
876 CALL read_nequip_data(mace)
877 CALL check_cp2k_atom_names_in_torch(atm_names, mace%type_names_torch)
878
879 DO isec = 1, SIZE(atm_names)
880 DO jsec = isec, SIZE(atm_names)
881 nonbonded%pot(start + n_items)%pot%type = mace_type
882 nonbonded%pot(start + n_items)%pot%at1 = atm_names(isec)
883 nonbonded%pot(start + n_items)%pot%at2 = atm_names(jsec)
884 CALL uppercase(nonbonded%pot(start + n_items)%pot%at1)
885 CALL uppercase(nonbonded%pot(start + n_items)%pot%at2)
886 nonbonded%pot(start + n_items)%pot%set(1)%nequip = mace
887 nonbonded%pot(start + n_items)%pot%rcutsq = mace%rcutsq
888 n_items = n_items + 1
889 END DO
890 END DO
891
892 END SUBROUTINE read_mace_section
893
894! **************************************************************************************************
895!> \brief Reads the LJ section
896!> \param nonbonded ...
897!> \param section ...
898!> \param start ...
899!> \author teo
900! **************************************************************************************************
901 SUBROUTINE read_lj_section(nonbonded, section, start)
902 TYPE(pair_potential_p_type), POINTER :: nonbonded
903 TYPE(section_vals_type), POINTER :: section
904 INTEGER, INTENT(IN) :: start
905
906 CHARACTER(LEN=default_string_length), &
907 DIMENSION(:), POINTER :: atm_names
908 INTEGER :: isec, n_items, n_rep
909 REAL(kind=dp) :: epsilon, rcut, sigma
910
911 CALL section_vals_get(section, n_repetition=n_items)
912 DO isec = 1, n_items
913 CALL section_vals_val_get(section, "ATOMS", i_rep_section=isec, c_vals=atm_names)
914 CALL section_vals_val_get(section, "EPSILON", i_rep_section=isec, r_val=epsilon)
915 CALL section_vals_val_get(section, "SIGMA", i_rep_section=isec, r_val=sigma)
916 CALL section_vals_val_get(section, "RCUT", i_rep_section=isec, r_val=rcut)
917
918 nonbonded%pot(start + isec)%pot%type = lj_charmm_type
919 nonbonded%pot(start + isec)%pot%at1 = atm_names(1)
920 nonbonded%pot(start + isec)%pot%at2 = atm_names(2)
921 CALL uppercase(nonbonded%pot(start + isec)%pot%at1)
922 CALL uppercase(nonbonded%pot(start + isec)%pot%at2)
923 nonbonded%pot(start + isec)%pot%set(1)%lj%epsilon = epsilon
924 nonbonded%pot(start + isec)%pot%set(1)%lj%sigma6 = sigma**6
925 nonbonded%pot(start + isec)%pot%set(1)%lj%sigma12 = sigma**12
926 nonbonded%pot(start + isec)%pot%rcutsq = rcut*rcut
927 !
928 CALL section_vals_val_get(section, "RMIN", i_rep_section=isec, n_rep_val=n_rep)
929 IF (n_rep == 1) CALL section_vals_val_get(section, "RMIN", i_rep_section=isec, &
930 r_val=nonbonded%pot(start + isec)%pot%set(1)%rmin)
931 CALL section_vals_val_get(section, "RMAX", i_rep_section=isec, n_rep_val=n_rep)
932 IF (n_rep == 1) CALL section_vals_val_get(section, "RMAX", i_rep_section=isec, &
933 r_val=nonbonded%pot(start + isec)%pot%set(1)%rmax)
934 END DO
935 END SUBROUTINE read_lj_section
936
937! **************************************************************************************************
938!> \brief Reads the WILLIAMS section
939!> \param nonbonded ...
940!> \param section ...
941!> \param start ...
942!> \author teo
943! **************************************************************************************************
944 SUBROUTINE read_wl_section(nonbonded, section, start)
945 TYPE(pair_potential_p_type), POINTER :: nonbonded
946 TYPE(section_vals_type), POINTER :: section
947 INTEGER, INTENT(IN) :: start
948
949 CHARACTER(LEN=default_string_length), &
950 DIMENSION(:), POINTER :: atm_names
951 INTEGER :: isec, n_items, n_rep
952 REAL(kind=dp) :: a, b, c, rcut
953
954 CALL section_vals_get(section, n_repetition=n_items)
955 DO isec = 1, n_items
956 CALL section_vals_val_get(section, "ATOMS", i_rep_section=isec, c_vals=atm_names)
957 CALL section_vals_val_get(section, "A", i_rep_section=isec, r_val=a)
958 CALL section_vals_val_get(section, "B", i_rep_section=isec, r_val=b)
959 CALL section_vals_val_get(section, "C", i_rep_section=isec, r_val=c)
960 CALL section_vals_val_get(section, "RCUT", i_rep_section=isec, r_val=rcut)
961
962 nonbonded%pot(start + isec)%pot%type = wl_type
963 nonbonded%pot(start + isec)%pot%at1 = atm_names(1)
964 nonbonded%pot(start + isec)%pot%at2 = atm_names(2)
965 CALL uppercase(nonbonded%pot(start + isec)%pot%at1)
966 CALL uppercase(nonbonded%pot(start + isec)%pot%at2)
967 nonbonded%pot(start + isec)%pot%set(1)%willis%a = a
968 nonbonded%pot(start + isec)%pot%set(1)%willis%b = b
969 nonbonded%pot(start + isec)%pot%set(1)%willis%c = c
970 nonbonded%pot(start + isec)%pot%rcutsq = rcut*rcut
971 !
972 CALL section_vals_val_get(section, "RMIN", i_rep_section=isec, n_rep_val=n_rep)
973 IF (n_rep == 1) CALL section_vals_val_get(section, "RMIN", i_rep_section=isec, &
974 r_val=nonbonded%pot(start + isec)%pot%set(1)%rmin)
975 CALL section_vals_val_get(section, "RMAX", i_rep_section=isec, n_rep_val=n_rep)
976 IF (n_rep == 1) CALL section_vals_val_get(section, "RMAX", i_rep_section=isec, &
977 r_val=nonbonded%pot(start + isec)%pot%set(1)%rmax)
978 END DO
979 END SUBROUTINE read_wl_section
980
981! **************************************************************************************************
982!> \brief Reads the GOODWIN section
983!> \param nonbonded ...
984!> \param section ...
985!> \param start ...
986!> \author teo
987! **************************************************************************************************
988 SUBROUTINE read_gd_section(nonbonded, section, start)
989 TYPE(pair_potential_p_type), POINTER :: nonbonded
990 TYPE(section_vals_type), POINTER :: section
991 INTEGER, INTENT(IN) :: start
992
993 CHARACTER(LEN=default_string_length), &
994 DIMENSION(:), POINTER :: atm_names
995 INTEGER :: isec, m, mc, n_items, n_rep
996 REAL(kind=dp) :: d, dc, rcut, vr0
997
998 CALL section_vals_get(section, n_repetition=n_items)
999 DO isec = 1, n_items
1000 CALL section_vals_val_get(section, "ATOMS", i_rep_section=isec, c_vals=atm_names)
1001 CALL section_vals_val_get(section, "VR0", i_rep_section=isec, r_val=vr0)
1002 CALL section_vals_val_get(section, "D", i_rep_section=isec, r_val=d)
1003 CALL section_vals_val_get(section, "DC", i_rep_section=isec, r_val=dc)
1004 CALL section_vals_val_get(section, "M", i_rep_section=isec, i_val=m)
1005 CALL section_vals_val_get(section, "MC", i_rep_section=isec, i_val=mc)
1006 CALL section_vals_val_get(section, "RCUT", i_rep_section=isec, r_val=rcut)
1007
1008 nonbonded%pot(start + isec)%pot%type = gw_type
1009 nonbonded%pot(start + isec)%pot%at1 = atm_names(1)
1010 nonbonded%pot(start + isec)%pot%at2 = atm_names(2)
1011 CALL uppercase(nonbonded%pot(start + isec)%pot%at1)
1012 CALL uppercase(nonbonded%pot(start + isec)%pot%at2)
1013 nonbonded%pot(start + isec)%pot%set(1)%goodwin%vr0 = vr0
1014 nonbonded%pot(start + isec)%pot%set(1)%goodwin%d = d
1015 nonbonded%pot(start + isec)%pot%set(1)%goodwin%dc = dc
1016 nonbonded%pot(start + isec)%pot%set(1)%goodwin%m = m
1017 nonbonded%pot(start + isec)%pot%set(1)%goodwin%mc = mc
1018 nonbonded%pot(start + isec)%pot%rcutsq = rcut*rcut
1019 !
1020 CALL section_vals_val_get(section, "RMIN", i_rep_section=isec, n_rep_val=n_rep)
1021 IF (n_rep == 1) CALL section_vals_val_get(section, "RMIN", i_rep_section=isec, &
1022 r_val=nonbonded%pot(start + isec)%pot%set(1)%rmin)
1023 CALL section_vals_val_get(section, "RMAX", i_rep_section=isec, n_rep_val=n_rep)
1024 IF (n_rep == 1) CALL section_vals_val_get(section, "RMAX", i_rep_section=isec, &
1025 r_val=nonbonded%pot(start + isec)%pot%set(1)%rmax)
1026 END DO
1027 END SUBROUTINE read_gd_section
1028
1029! **************************************************************************************************
1030!> \brief Reads the IPBV section
1031!> \param nonbonded ...
1032!> \param section ...
1033!> \param start ...
1034!> \author teo
1035! **************************************************************************************************
1036 SUBROUTINE read_ipbv_section(nonbonded, section, start)
1037 TYPE(pair_potential_p_type), POINTER :: nonbonded
1038 TYPE(section_vals_type), POINTER :: section
1039 INTEGER, INTENT(IN) :: start
1040
1041 CHARACTER(LEN=default_string_length), &
1042 DIMENSION(:), POINTER :: atm_names
1043 INTEGER :: isec, n_items, n_rep
1044 REAL(kind=dp) :: rcut
1045
1046 CALL section_vals_get(section, n_repetition=n_items)
1047 DO isec = 1, n_items
1048 CALL section_vals_val_get(section, "ATOMS", i_rep_section=isec, c_vals=atm_names)
1049 nonbonded%pot(start + isec)%pot%type = ip_type
1050 nonbonded%pot(start + isec)%pot%at1 = atm_names(1)
1051 nonbonded%pot(start + isec)%pot%at2 = atm_names(2)
1052 CALL uppercase(nonbonded%pot(start + isec)%pot%at1)
1053 CALL uppercase(nonbonded%pot(start + isec)%pot%at2)
1054 CALL set_ipbv_ff(nonbonded%pot(start + isec)%pot%at1, nonbonded%pot(start + isec)%pot%at2, &
1055 nonbonded%pot(start + isec)%pot%set(1)%ipbv)
1056 CALL section_vals_val_get(section, "RCUT", i_rep_section=isec, r_val=rcut)
1057 nonbonded%pot(start + isec)%pot%rcutsq = rcut**2
1058 !
1059 CALL section_vals_val_get(section, "RMIN", i_rep_section=isec, n_rep_val=n_rep)
1060 IF (n_rep == 1) CALL section_vals_val_get(section, "RMIN", i_rep_section=isec, &
1061 r_val=nonbonded%pot(start + isec)%pot%set(1)%rmin)
1062 CALL section_vals_val_get(section, "RMAX", i_rep_section=isec, n_rep_val=n_rep)
1063 IF (n_rep == 1) CALL section_vals_val_get(section, "RMAX", i_rep_section=isec, &
1064 r_val=nonbonded%pot(start + isec)%pot%set(1)%rmax)
1065 END DO
1066 END SUBROUTINE read_ipbv_section
1067
1068! **************************************************************************************************
1069!> \brief Reads the BMHFT section
1070!> \param nonbonded ...
1071!> \param section ...
1072!> \param start ...
1073!> \author teo
1074! **************************************************************************************************
1075 SUBROUTINE read_bmhft_section(nonbonded, section, start)
1076 TYPE(pair_potential_p_type), POINTER :: nonbonded
1077 TYPE(section_vals_type), POINTER :: section
1078 INTEGER, INTENT(IN) :: start
1079
1080 CHARACTER(LEN=default_string_length), DIMENSION(2) :: map_atoms
1081 CHARACTER(LEN=default_string_length), &
1082 DIMENSION(:), POINTER :: atm_names
1083 INTEGER :: i, isec, n_items, n_rep
1084 REAL(kind=dp) :: rcut
1085
1086 CALL section_vals_get(section, n_repetition=n_items)
1087 DO isec = 1, n_items
1088 CALL cite_reference(tosi1964a)
1089 CALL cite_reference(tosi1964b)
1090 CALL section_vals_val_get(section, "ATOMS", i_rep_section=isec, c_vals=atm_names)
1091 nonbonded%pot(start + isec)%pot%type = ft_type
1092 nonbonded%pot(start + isec)%pot%at1 = atm_names(1)
1093 nonbonded%pot(start + isec)%pot%at2 = atm_names(2)
1094 CALL uppercase(nonbonded%pot(start + isec)%pot%at1)
1095 CALL uppercase(nonbonded%pot(start + isec)%pot%at2)
1096
1097 CALL section_vals_val_get(section, "A", i_rep_section=isec, n_rep_val=i)
1098 IF (i == 1) THEN
1099 CALL section_vals_val_get(section, "A", i_rep_section=isec, &
1100 r_val=nonbonded%pot(start + isec)%pot%set(1)%ft%a)
1101 CALL section_vals_val_get(section, "B", i_rep_section=isec, &
1102 r_val=nonbonded%pot(start + isec)%pot%set(1)%ft%b)
1103 CALL section_vals_val_get(section, "C", i_rep_section=isec, &
1104 r_val=nonbonded%pot(start + isec)%pot%set(1)%ft%c)
1105 CALL section_vals_val_get(section, "D", i_rep_section=isec, &
1106 r_val=nonbonded%pot(start + isec)%pot%set(1)%ft%d)
1107 ELSE
1108 CALL section_vals_val_get(section, "MAP_ATOMS", i_rep_section=isec, c_vals=atm_names)
1109 map_atoms = atm_names
1110 CALL uppercase(map_atoms(1))
1111 CALL uppercase(map_atoms(2))
1112 CALL set_bmhft_ff(map_atoms(1), map_atoms(2), nonbonded%pot(start + isec)%pot%set(1)%ft)
1113 END IF
1114 CALL section_vals_val_get(section, "RCUT", i_rep_section=isec, r_val=rcut)
1115 nonbonded%pot(start + isec)%pot%rcutsq = rcut**2
1116 !
1117 CALL section_vals_val_get(section, "RMIN", i_rep_section=isec, n_rep_val=n_rep)
1118 IF (n_rep == 1) CALL section_vals_val_get(section, "RMIN", i_rep_section=isec, &
1119 r_val=nonbonded%pot(start + isec)%pot%set(1)%rmin)
1120 CALL section_vals_val_get(section, "RMAX", i_rep_section=isec, n_rep_val=n_rep)
1121 IF (n_rep == 1) CALL section_vals_val_get(section, "RMAX", i_rep_section=isec, &
1122 r_val=nonbonded%pot(start + isec)%pot%set(1)%rmax)
1123 END DO
1124 END SUBROUTINE read_bmhft_section
1125
1126! **************************************************************************************************
1127!> \brief Reads the BMHFTD section
1128!> \param nonbonded ...
1129!> \param section ...
1130!> \param start ...
1131!> \author Mathieu Salanne 05.2010
1132! **************************************************************************************************
1133 SUBROUTINE read_bmhftd_section(nonbonded, section, start)
1134 TYPE(pair_potential_p_type), POINTER :: nonbonded
1135 TYPE(section_vals_type), POINTER :: section
1136 INTEGER, INTENT(IN) :: start
1137
1138 CHARACTER(LEN=default_string_length), DIMENSION(2) :: map_atoms
1139 CHARACTER(LEN=default_string_length), &
1140 DIMENSION(:), POINTER :: atm_names
1141 INTEGER :: i, isec, n_items, n_rep
1142 REAL(kind=dp) :: rcut
1143 REAL(kind=dp), DIMENSION(:), POINTER :: bd_vals
1144
1145 NULLIFY (bd_vals)
1146
1147 CALL section_vals_get(section, n_repetition=n_items)
1148
1149 DO isec = 1, n_items
1150 CALL cite_reference(tosi1964a)
1151 CALL cite_reference(tosi1964b)
1152 CALL section_vals_val_get(section, "ATOMS", i_rep_section=isec, c_vals=atm_names)
1153 nonbonded%pot(start + isec)%pot%type = ftd_type
1154 nonbonded%pot(start + isec)%pot%at1 = atm_names(1)
1155 nonbonded%pot(start + isec)%pot%at2 = atm_names(2)
1156 CALL uppercase(nonbonded%pot(start + isec)%pot%at1)
1157 CALL uppercase(nonbonded%pot(start + isec)%pot%at2)
1158
1159 CALL section_vals_val_get(section, "A", i_rep_section=isec, n_rep_val=i)
1160 IF (i == 1) THEN
1161 CALL section_vals_val_get(section, "A", i_rep_section=isec, &
1162 r_val=nonbonded%pot(start + isec)%pot%set(1)%ftd%a)
1163 CALL section_vals_val_get(section, "B", i_rep_section=isec, &
1164 r_val=nonbonded%pot(start + isec)%pot%set(1)%ftd%b)
1165 CALL section_vals_val_get(section, "C", i_rep_section=isec, &
1166 r_val=nonbonded%pot(start + isec)%pot%set(1)%ftd%c)
1167 CALL section_vals_val_get(section, "D", i_rep_section=isec, &
1168 r_val=nonbonded%pot(start + isec)%pot%set(1)%ftd%d)
1169 CALL section_vals_val_get(section, "BD", i_rep_section=isec, r_vals=bd_vals)
1170 IF (ASSOCIATED(bd_vals)) THEN
1171 SELECT CASE (SIZE(bd_vals))
1172 CASE (0)
1173 cpabort("No values specified for parameter BD in section &BMHFTD")
1174 CASE (1)
1175 nonbonded%pot(start + isec)%pot%set(1)%ftd%bd(1:2) = bd_vals(1)
1176 CASE (2)
1177 nonbonded%pot(start + isec)%pot%set(1)%ftd%bd(1:2) = bd_vals(1:2)
1178 CASE DEFAULT
1179 cpabort("Too many values specified for parameter BD in section &BMHFTD")
1180 END SELECT
1181 ELSE
1182 cpabort("Parameter BD in section &BMHFTD was not specified")
1183 END IF
1184 ELSE
1185 CALL section_vals_val_get(section, "MAP_ATOMS", i_rep_section=isec, c_vals=atm_names)
1186 map_atoms = atm_names
1187 CALL uppercase(map_atoms(1))
1188 CALL uppercase(map_atoms(2))
1189 CALL set_bmhftd_ff()
1190 END IF
1191 CALL section_vals_val_get(section, "RCUT", i_rep_section=isec, r_val=rcut)
1192 nonbonded%pot(start + isec)%pot%rcutsq = rcut**2
1193 !
1194 CALL section_vals_val_get(section, "RMIN", i_rep_section=isec, n_rep_val=n_rep)
1195 IF (n_rep == 1) CALL section_vals_val_get(section, "RMIN", i_rep_section=isec, &
1196 r_val=nonbonded%pot(start + isec)%pot%set(1)%rmin)
1197 CALL section_vals_val_get(section, "RMAX", i_rep_section=isec, n_rep_val=n_rep)
1198 IF (n_rep == 1) CALL section_vals_val_get(section, "RMAX", i_rep_section=isec, &
1199 r_val=nonbonded%pot(start + isec)%pot%set(1)%rmax)
1200 END DO
1201 END SUBROUTINE read_bmhftd_section
1202
1203! **************************************************************************************************
1204!> \brief Reads the Buckingham 4 Ranges potential section
1205!> \param nonbonded ...
1206!> \param section ...
1207!> \param start ...
1208!> \par History
1209!> MK (11.11.2010): Automatic fit of the (default) polynomial coefficients
1210!> \author MI,MK
1211! **************************************************************************************************
1212 SUBROUTINE read_b4_section(nonbonded, section, start)
1213
1214 TYPE(pair_potential_p_type), POINTER :: nonbonded
1215 TYPE(section_vals_type), POINTER :: section
1216 INTEGER, INTENT(IN) :: start
1217
1218 CHARACTER(LEN=default_string_length), &
1219 DIMENSION(:), POINTER :: atm_names
1220 INTEGER :: i, ir, isec, n_items, n_rep, np1, np2
1221 LOGICAL :: explicit_poly1, explicit_poly2
1222 REAL(kind=dp) :: a, b, c, eval_error, r1, r2, r3, rcut
1223 REAL(kind=dp), DIMENSION(10) :: v, x
1224 REAL(kind=dp), DIMENSION(10, 10) :: p, p_inv
1225 REAL(kind=dp), DIMENSION(:), POINTER :: coeff1, coeff2, list
1226
1227 NULLIFY (coeff1)
1228 NULLIFY (coeff2)
1229
1230 CALL section_vals_get(section, n_repetition=n_items)
1231
1232 DO isec = 1, n_items
1233 CALL section_vals_val_get(section, "ATOMS", i_rep_section=isec, c_vals=atm_names)
1234 CALL section_vals_val_get(section, "A", i_rep_section=isec, r_val=a)
1235 CALL section_vals_val_get(section, "B", i_rep_section=isec, r_val=b)
1236 CALL section_vals_val_get(section, "C", i_rep_section=isec, r_val=c)
1237 CALL section_vals_val_get(section, "R1", i_rep_section=isec, r_val=r1)
1238 CALL section_vals_val_get(section, "R2", i_rep_section=isec, r_val=r2)
1239 CALL section_vals_val_get(section, "R3", i_rep_section=isec, r_val=r3)
1240 CALL section_vals_val_get(section, "POLY1", explicit=explicit_poly1, n_rep_val=n_rep)
1241 ! Check if polynomial coefficients were specified for range 2 and 3 explicitly
1242 IF (explicit_poly1) THEN
1243 np1 = 0
1244 DO ir = 1, n_rep
1245 NULLIFY (list)
1246 CALL section_vals_val_get(section, "POLY1", i_rep_val=ir, r_vals=list)
1247 IF (ASSOCIATED(list)) THEN
1248 CALL reallocate(coeff1, 0, np1 + SIZE(list) - 1)
1249 DO i = 1, SIZE(list)
1250 coeff1(i + np1 - 1) = list(i)
1251 END DO
1252 np1 = np1 + SIZE(list)
1253 END IF
1254 END DO
1255 END IF
1256 CALL section_vals_val_get(section, "POLY2", explicit=explicit_poly2, n_rep_val=n_rep)
1257 IF (explicit_poly2) THEN
1258 np2 = 0
1259 DO ir = 1, n_rep
1260 NULLIFY (list)
1261 CALL section_vals_val_get(section, "POLY2", i_rep_val=ir, r_vals=list)
1262 IF (ASSOCIATED(list)) THEN
1263 CALL reallocate(coeff2, 0, np2 + SIZE(list) - 1)
1264 DO i = 1, SIZE(list)
1265 coeff2(i + np2 - 1) = list(i)
1266 END DO
1267 np2 = np2 + SIZE(list)
1268 END IF
1269 END DO
1270 END IF
1271 ! Default is a 5th/3rd-order polynomial fit
1272 IF ((.NOT. explicit_poly1) .OR. (.NOT. explicit_poly2)) THEN
1273 ! Build matrix p and vector v to calculate the polynomial coefficients
1274 ! in the vector x from p*x = v
1275 p(:, :) = 0.0_dp
1276 ! Row 1: Match the 5th-order polynomial and the potential at r1
1277 p(1, 1) = 1.0_dp
1278 DO i = 2, 6
1279 p(1, i) = p(1, i - 1)*r1
1280 END DO
1281 ! Row 2: Match the first derivatives of the 5th-order polynomial and the potential at r1
1282 DO i = 2, 6
1283 p(2, i) = real(i - 1, kind=dp)*p(1, i - 1)
1284 END DO
1285 ! Row 3: Match the second derivatives of the 5th-order polynomial and the potential at r1
1286 DO i = 3, 6
1287 p(3, i) = real(i - 1, kind=dp)*p(2, i - 1)
1288 END DO
1289 ! Row 4: Match the 5th-order and the 3rd-order polynomials at r2
1290 p(4, 1) = 1.0_dp
1291 DO i = 2, 6
1292 p(4, i) = p(4, i - 1)*r2
1293 END DO
1294 p(4, 7) = -1.0_dp
1295 DO i = 8, 10
1296 p(4, i) = p(4, i - 1)*r2
1297 END DO
1298 ! Row 5: Match the first derivatives of the 5th-order and the 3rd-order polynomials at r2
1299 DO i = 2, 6
1300 p(5, i) = real(i - 1, kind=dp)*p(4, i - 1)
1301 END DO
1302 DO i = 8, 10
1303 p(5, i) = real(i - 7, kind=dp)*p(4, i - 1)
1304 END DO
1305 ! Row 6: Match the second derivatives of the 5th-order and the 3rd-order polynomials at r2
1306 DO i = 3, 6
1307 p(6, i) = real(i - 1, kind=dp)*p(5, i - 1)
1308 END DO
1309 DO i = 9, 10
1310 p(6, i) = real(i - 7, kind=dp)*p(5, i - 1)
1311 END DO
1312 ! Row 7: Minimum at r2, ie. the first derivative of the 3rd-order polynomial has to be zero at r2
1313 DO i = 8, 10
1314 p(7, i) = -p(5, i)
1315 END DO
1316 ! Row 8: Match the 3rd-order polynomial and the potential at r3
1317 p(8, 7) = 1.0_dp
1318 DO i = 8, 10
1319 p(8, i) = p(8, i - 1)*r3
1320 END DO
1321 ! Row 9: Match the first derivatives of the 3rd-order polynomial and the potential at r3
1322 DO i = 8, 10
1323 p(9, i) = real(i - 7, kind=dp)*p(8, i - 1)
1324 END DO
1325 ! Row 10: Match the second derivatives of the 3rd-order polynomial and the potential at r3
1326 DO i = 9, 10
1327 p(10, i) = real(i - 7, kind=dp)*p(9, i - 1)
1328 END DO
1329 ! Build the vector v
1330 v(1) = a*exp(-b*r1)
1331 v(2) = -b*v(1)
1332 v(3) = -b*v(2)
1333 v(4:7) = 0.0_dp
1334 v(8) = -c/p(8, 10)**2 ! = -c/r3**6
1335 v(9) = -6.0_dp*v(8)/r3
1336 v(10) = -7.0_dp*v(9)/r3
1337 ! Calculate p_inv the inverse of the matrix p
1338 p_inv(:, :) = 0.0_dp
1339 CALL invert_matrix(p, p_inv, eval_error)
1340
1341 IF (eval_error >= 1.0e-8_dp) THEN
1342 CALL cp_warn(__location__, &
1343 "The polynomial fit for the BUCK4RANGES potential is only accurate to "// &
1344 trim(cp_to_string(eval_error)))
1345 END IF
1346
1347 ! Get the 6 coefficients of the 5th-order polynomial -> x(1:6)
1348 ! and the 4 coefficients of the 3rd-order polynomial -> x(7:10)
1349 x(:) = matmul(p_inv(:, :), v(:))
1350 ELSE
1351 x(:) = 0.0_dp
1352 END IF
1353
1354 CALL section_vals_val_get(section, "RCUT", i_rep_section=isec, r_val=rcut)
1355
1356 nonbonded%pot(start + isec)%pot%type = b4_type
1357 nonbonded%pot(start + isec)%pot%at1 = atm_names(1)
1358 nonbonded%pot(start + isec)%pot%at2 = atm_names(2)
1359 CALL uppercase(nonbonded%pot(start + isec)%pot%at1)
1360 CALL uppercase(nonbonded%pot(start + isec)%pot%at2)
1361 nonbonded%pot(start + isec)%pot%set(1)%buck4r%a = a
1362 nonbonded%pot(start + isec)%pot%set(1)%buck4r%b = b
1363 nonbonded%pot(start + isec)%pot%set(1)%buck4r%c = c
1364 nonbonded%pot(start + isec)%pot%set(1)%buck4r%r1 = r1
1365 nonbonded%pot(start + isec)%pot%set(1)%buck4r%r2 = r2
1366 nonbonded%pot(start + isec)%pot%set(1)%buck4r%r3 = r3
1367 IF ((.NOT. explicit_poly1) .OR. (.NOT. explicit_poly2)) THEN
1368 nonbonded%pot(start + isec)%pot%set(1)%buck4r%npoly1 = 5
1369 nonbonded%pot(start + isec)%pot%set(1)%buck4r%poly1(0:5) = x(1:6)
1370 nonbonded%pot(start + isec)%pot%set(1)%buck4r%npoly2 = 3
1371 nonbonded%pot(start + isec)%pot%set(1)%buck4r%poly2(0:3) = x(7:10)
1372 ELSE
1373 nonbonded%pot(start + isec)%pot%set(1)%buck4r%npoly1 = np1 - 1
1374 cpassert(np1 - 1 <= 10)
1375 nonbonded%pot(start + isec)%pot%set(1)%buck4r%poly1(0:np1 - 1) = coeff1(0:np1 - 1)
1376 nonbonded%pot(start + isec)%pot%set(1)%buck4r%npoly2 = np2 - 1
1377 cpassert(np2 - 1 <= 10)
1378 nonbonded%pot(start + isec)%pot%set(1)%buck4r%poly2(0:np2 - 1) = coeff2(0:np2 - 1)
1379 END IF
1380 nonbonded%pot(start + isec)%pot%rcutsq = rcut*rcut
1381
1382 IF (ASSOCIATED(coeff1)) THEN
1383 DEALLOCATE (coeff1)
1384 END IF
1385 IF (ASSOCIATED(coeff2)) THEN
1386 DEALLOCATE (coeff2)
1387 END IF
1388 CALL section_vals_val_get(section, "RMIN", i_rep_section=isec, n_rep_val=n_rep)
1389 IF (n_rep == 1) CALL section_vals_val_get(section, "RMIN", i_rep_section=isec, &
1390 r_val=nonbonded%pot(start + isec)%pot%set(1)%rmin)
1391 CALL section_vals_val_get(section, "RMAX", i_rep_section=isec, n_rep_val=n_rep)
1392 IF (n_rep == 1) CALL section_vals_val_get(section, "RMAX", i_rep_section=isec, &
1393 r_val=nonbonded%pot(start + isec)%pot%set(1)%rmax)
1394 END DO
1395
1396 END SUBROUTINE read_b4_section
1397
1398! **************************************************************************************************
1399!> \brief Reads the GENPOT - generic potential section
1400!> \param nonbonded ...
1401!> \param section ...
1402!> \param start ...
1403!> \author Teodoro Laino - 10.2006
1404! **************************************************************************************************
1405 SUBROUTINE read_gp_section(nonbonded, section, start)
1406 TYPE(pair_potential_p_type), POINTER :: nonbonded
1407 TYPE(section_vals_type), POINTER :: section
1408 INTEGER, INTENT(IN) :: start
1409
1410 CHARACTER(LEN=default_string_length), &
1411 DIMENSION(:), POINTER :: atm_names
1412 INTEGER :: isec, n_items, n_rep
1413 REAL(kind=dp) :: rcut
1414
1415 CALL section_vals_get(section, n_repetition=n_items)
1416 DO isec = 1, n_items
1417 NULLIFY (atm_names)
1418 CALL section_vals_val_get(section, "ATOMS", i_rep_section=isec, c_vals=atm_names)
1419 CALL section_vals_val_get(section, "RCUT", i_rep_section=isec, r_val=rcut)
1420 nonbonded%pot(start + isec)%pot%type = gp_type
1421 nonbonded%pot(start + isec)%pot%at1 = atm_names(1)
1422 nonbonded%pot(start + isec)%pot%at2 = atm_names(2)
1423 nonbonded%pot(start + isec)%pot%rcutsq = rcut*rcut
1424 CALL uppercase(nonbonded%pot(start + isec)%pot%at1)
1425 CALL uppercase(nonbonded%pot(start + isec)%pot%at2)
1426 ! Parse the genpot info
1427 CALL get_generic_info(section, "FUNCTION", nonbonded%pot(start + isec)%pot%set(1)%gp%potential, &
1428 nonbonded%pot(start + isec)%pot%set(1)%gp%parameters, &
1429 nonbonded%pot(start + isec)%pot%set(1)%gp%values, &
1430 size_variables=1, i_rep_sec=isec)
1431 nonbonded%pot(start + isec)%pot%set(1)%gp%variables = nonbonded%pot(start + isec)%pot%set(1)%gp%parameters(1)
1432 !
1433 CALL section_vals_val_get(section, "RMIN", i_rep_section=isec, n_rep_val=n_rep)
1434 IF (n_rep == 1) CALL section_vals_val_get(section, "RMIN", i_rep_section=isec, &
1435 r_val=nonbonded%pot(start + isec)%pot%set(1)%rmin)
1436 CALL section_vals_val_get(section, "RMAX", i_rep_section=isec, n_rep_val=n_rep)
1437 IF (n_rep == 1) CALL section_vals_val_get(section, "RMAX", i_rep_section=isec, &
1438 r_val=nonbonded%pot(start + isec)%pot%set(1)%rmax)
1439 END DO
1440 END SUBROUTINE read_gp_section
1441
1442! **************************************************************************************************
1443!> \brief Reads the tersoff section
1444!> \param nonbonded ...
1445!> \param section ...
1446!> \param start ...
1447!> \param tersoff_section ...
1448!> \author ikuo
1449! **************************************************************************************************
1450 SUBROUTINE read_tersoff_section(nonbonded, section, start, tersoff_section)
1451 TYPE(pair_potential_p_type), POINTER :: nonbonded
1452 TYPE(section_vals_type), POINTER :: section
1453 INTEGER, INTENT(IN) :: start
1454 TYPE(section_vals_type), POINTER :: tersoff_section
1455
1456 CHARACTER(LEN=default_string_length), &
1457 DIMENSION(:), POINTER :: atm_names
1458 INTEGER :: isec, n_items, n_rep
1459 REAL(kind=dp) :: rcut, rcutsq
1460
1461 CALL section_vals_get(section, n_repetition=n_items)
1462 DO isec = 1, n_items
1463 CALL cite_reference(tersoff1988)
1464 CALL section_vals_val_get(section, "ATOMS", i_rep_section=isec, c_vals=atm_names)
1465
1466 nonbonded%pot(start + isec)%pot%type = tersoff_type
1467 nonbonded%pot(start + isec)%pot%at1 = atm_names(1)
1468 nonbonded%pot(start + isec)%pot%at2 = atm_names(2)
1469 CALL uppercase(nonbonded%pot(start + isec)%pot%at1)
1470 CALL uppercase(nonbonded%pot(start + isec)%pot%at2)
1471
1472 CALL section_vals_val_get(tersoff_section, "A", i_rep_section=isec, &
1473 r_val=nonbonded%pot(start + isec)%pot%set(1)%tersoff%A)
1474 CALL section_vals_val_get(tersoff_section, "B", i_rep_section=isec, &
1475 r_val=nonbonded%pot(start + isec)%pot%set(1)%tersoff%B)
1476 CALL section_vals_val_get(tersoff_section, "lambda1", i_rep_section=isec, &
1477 r_val=nonbonded%pot(start + isec)%pot%set(1)%tersoff%lambda1)
1478 CALL section_vals_val_get(tersoff_section, "lambda2", i_rep_section=isec, &
1479 r_val=nonbonded%pot(start + isec)%pot%set(1)%tersoff%lambda2)
1480 CALL section_vals_val_get(tersoff_section, "alpha", i_rep_section=isec, &
1481 r_val=nonbonded%pot(start + isec)%pot%set(1)%tersoff%alpha)
1482 CALL section_vals_val_get(tersoff_section, "beta", i_rep_section=isec, &
1483 r_val=nonbonded%pot(start + isec)%pot%set(1)%tersoff%beta)
1484 CALL section_vals_val_get(tersoff_section, "n", i_rep_section=isec, &
1485 r_val=nonbonded%pot(start + isec)%pot%set(1)%tersoff%n)
1486 CALL section_vals_val_get(tersoff_section, "c", i_rep_section=isec, &
1487 r_val=nonbonded%pot(start + isec)%pot%set(1)%tersoff%c)
1488 CALL section_vals_val_get(tersoff_section, "d", i_rep_section=isec, &
1489 r_val=nonbonded%pot(start + isec)%pot%set(1)%tersoff%d)
1490 CALL section_vals_val_get(tersoff_section, "h", i_rep_section=isec, &
1491 r_val=nonbonded%pot(start + isec)%pot%set(1)%tersoff%h)
1492 CALL section_vals_val_get(tersoff_section, "lambda3", i_rep_section=isec, &
1493 r_val=nonbonded%pot(start + isec)%pot%set(1)%tersoff%lambda3)
1494 CALL section_vals_val_get(tersoff_section, "bigR", i_rep_section=isec, &
1495 r_val=nonbonded%pot(start + isec)%pot%set(1)%tersoff%bigR)
1496 CALL section_vals_val_get(tersoff_section, "bigD", i_rep_section=isec, &
1497 r_val=nonbonded%pot(start + isec)%pot%set(1)%tersoff%bigD)
1498
1499 rcutsq = (nonbonded%pot(start + isec)%pot%set(1)%tersoff%bigR + &
1500 nonbonded%pot(start + isec)%pot%set(1)%tersoff%bigD)**2
1501 nonbonded%pot(start + isec)%pot%set(1)%tersoff%rcutsq = rcutsq
1502 nonbonded%pot(start + isec)%pot%rcutsq = rcutsq
1503
1504 ! In case it is defined override the standard specification of RCUT
1505 CALL section_vals_val_get(tersoff_section, "RCUT", i_rep_section=isec, n_rep_val=n_rep)
1506 IF (n_rep == 1) THEN
1507 CALL section_vals_val_get(tersoff_section, "RCUT", i_rep_section=isec, r_val=rcut)
1508 nonbonded%pot(start + isec)%pot%rcutsq = rcut**2
1509 END IF
1510 END DO
1511 END SUBROUTINE read_tersoff_section
1512
1513! **************************************************************************************************
1514!> \brief Reads the gal19 section
1515!> \param nonbonded ...
1516!> \param section ...
1517!> \param start ...
1518!> \param gal_section ...
1519!> \author Clabaut Paul
1520! **************************************************************************************************
1521 SUBROUTINE read_gal_section(nonbonded, section, start, gal_section)
1522 TYPE(pair_potential_p_type), POINTER :: nonbonded
1523 TYPE(section_vals_type), POINTER :: section
1524 INTEGER, INTENT(IN) :: start
1525 TYPE(section_vals_type), POINTER :: gal_section
1526
1527 CHARACTER(LEN=default_string_length), &
1528 DIMENSION(:), POINTER :: atm_names
1529 INTEGER :: iatom, isec, n_items, n_rep, nval
1530 LOGICAL :: is_ok
1531 REAL(kind=dp) :: rcut, rval
1532 REAL(kind=dp), DIMENSION(:), POINTER :: rvalues
1533 TYPE(cp_sll_val_type), POINTER :: list
1534 TYPE(section_vals_type), POINTER :: subsection
1535 TYPE(val_type), POINTER :: val
1536
1537 CALL section_vals_get(section, n_repetition=n_items)
1538 DO isec = 1, n_items
1539 CALL cite_reference(clabaut2020)
1540 CALL section_vals_val_get(section, "ATOMS", i_rep_section=isec, c_vals=atm_names)
1541
1542 nonbonded%pot(start + isec)%pot%type = gal_type
1543 nonbonded%pot(start + isec)%pot%at1 = atm_names(1)
1544 nonbonded%pot(start + isec)%pot%at2 = atm_names(2)
1545 CALL uppercase(nonbonded%pot(start + isec)%pot%at1)
1546 CALL uppercase(nonbonded%pot(start + isec)%pot%at2)
1547
1548 CALL section_vals_val_get(section, "METALS", i_rep_section=isec, c_vals=atm_names)
1549 IF (any(len_trim(atm_names(:)) > 2)) THEN
1550 cpwarn("The atom name will be truncated.")
1551 END IF
1552 nonbonded%pot(start + isec)%pot%set(1)%gal%met1 = trim(atm_names(1))
1553 nonbonded%pot(start + isec)%pot%set(1)%gal%met2 = trim(atm_names(2))
1554
1555 CALL section_vals_val_get(gal_section, "epsilon", i_rep_section=isec, &
1556 r_val=nonbonded%pot(start + isec)%pot%set(1)%gal%epsilon)
1557 CALL section_vals_val_get(gal_section, "bxy", i_rep_section=isec, &
1558 r_val=nonbonded%pot(start + isec)%pot%set(1)%gal%bxy)
1559 CALL section_vals_val_get(gal_section, "bz", i_rep_section=isec, &
1560 r_val=nonbonded%pot(start + isec)%pot%set(1)%gal%bz)
1561
1562 CALL section_vals_val_get(gal_section, "r", i_rep_section=isec, r_vals=rvalues)
1563 nonbonded%pot(start + isec)%pot%set(1)%gal%r1 = rvalues(1)
1564 nonbonded%pot(start + isec)%pot%set(1)%gal%r2 = rvalues(2)
1565
1566 CALL section_vals_val_get(gal_section, "a1", i_rep_section=isec, &
1567 r_val=nonbonded%pot(start + isec)%pot%set(1)%gal%a1)
1568 CALL section_vals_val_get(gal_section, "a2", i_rep_section=isec, &
1569 r_val=nonbonded%pot(start + isec)%pot%set(1)%gal%a2)
1570 CALL section_vals_val_get(gal_section, "a3", i_rep_section=isec, &
1571 r_val=nonbonded%pot(start + isec)%pot%set(1)%gal%a3)
1572 CALL section_vals_val_get(gal_section, "a4", i_rep_section=isec, &
1573 r_val=nonbonded%pot(start + isec)%pot%set(1)%gal%a4)
1574 CALL section_vals_val_get(gal_section, "A", i_rep_section=isec, &
1575 r_val=nonbonded%pot(start + isec)%pot%set(1)%gal%a)
1576 CALL section_vals_val_get(gal_section, "B", i_rep_section=isec, &
1577 r_val=nonbonded%pot(start + isec)%pot%set(1)%gal%b)
1578 CALL section_vals_val_get(gal_section, "C", i_rep_section=isec, &
1579 r_val=nonbonded%pot(start + isec)%pot%set(1)%gal%c)
1580 NULLIFY (list)
1581 subsection => section_vals_get_subs_vals(section, "GCN", i_rep_section=isec)
1582 CALL section_vals_val_get(subsection, "_DEFAULT_KEYWORD_", n_rep_val=nval)
1583 ALLOCATE (nonbonded%pot(start + isec)%pot%set(1)%gal%gcn(nval))
1584 CALL section_vals_list_get(subsection, "_DEFAULT_KEYWORD_", list=list)
1585 DO iatom = 1, nval
1586 ! we use only the first default_string_length characters of each line
1587 is_ok = cp_sll_val_next(list, val)
1588 CALL val_get(val, r_val=rval)
1589 ! assign values
1590 nonbonded%pot(start + isec)%pot%set(1)%gal%gcn(iatom) = rval
1591 END DO
1592
1593 CALL section_vals_val_get(gal_section, "Fit_express", i_rep_section=isec, &
1594 l_val=nonbonded%pot(start + isec)%pot%set(1)%gal%express)
1595
1596 ! ! In case it is defined override the standard specification of RCUT
1597 CALL section_vals_val_get(gal_section, "RCUT", i_rep_section=isec, n_rep_val=n_rep)
1598 IF (n_rep == 1) THEN
1599 CALL section_vals_val_get(gal_section, "RCUT", i_rep_section=isec, r_val=rcut)
1600 nonbonded%pot(start + isec)%pot%rcutsq = rcut**2
1601 nonbonded%pot(start + isec)%pot%set(1)%gal%rcutsq = rcut**2
1602 END IF
1603 END DO
1604 END SUBROUTINE read_gal_section
1605
1606! **************************************************************************************************
1607!> \brief Reads the gal21 section
1608!> \param nonbonded ...
1609!> \param section ...
1610!> \param start ...
1611!> \param gal21_section ...
1612!> \author Clabaut Paul
1613! **************************************************************************************************
1614 SUBROUTINE read_gal21_section(nonbonded, section, start, gal21_section)
1615 TYPE(pair_potential_p_type), POINTER :: nonbonded
1616 TYPE(section_vals_type), POINTER :: section
1617 INTEGER, INTENT(IN) :: start
1618 TYPE(section_vals_type), POINTER :: gal21_section
1619
1620 CHARACTER(LEN=default_string_length), &
1621 DIMENSION(:), POINTER :: atm_names
1622 INTEGER :: iatom, isec, n_items, n_rep, nval
1623 LOGICAL :: is_ok
1624 REAL(kind=dp) :: rcut, rval
1625 REAL(kind=dp), DIMENSION(:), POINTER :: rvalues
1626 TYPE(cp_sll_val_type), POINTER :: list
1627 TYPE(section_vals_type), POINTER :: subsection
1628 TYPE(val_type), POINTER :: val
1629
1630 CALL section_vals_get(section, n_repetition=n_items)
1631 DO isec = 1, n_items
1632 CALL cite_reference(clabaut2021)
1633 CALL section_vals_val_get(section, "ATOMS", i_rep_section=isec, c_vals=atm_names)
1634
1635 nonbonded%pot(start + isec)%pot%type = gal21_type
1636 nonbonded%pot(start + isec)%pot%at1 = atm_names(1)
1637 nonbonded%pot(start + isec)%pot%at2 = atm_names(2)
1638 CALL uppercase(nonbonded%pot(start + isec)%pot%at1)
1639 CALL uppercase(nonbonded%pot(start + isec)%pot%at2)
1640
1641 CALL section_vals_val_get(section, "METALS", i_rep_section=isec, c_vals=atm_names)
1642 IF (any(len_trim(atm_names(:)) > 2)) THEN
1643 cpwarn("The atom name will be truncated.")
1644 END IF
1645 nonbonded%pot(start + isec)%pot%set(1)%gal21%met1 = trim(atm_names(1))
1646 nonbonded%pot(start + isec)%pot%set(1)%gal21%met2 = trim(atm_names(2))
1647
1648 CALL section_vals_val_get(gal21_section, "epsilon", i_rep_section=isec, r_vals=rvalues)
1649 nonbonded%pot(start + isec)%pot%set(1)%gal21%epsilon1 = rvalues(1)
1650 nonbonded%pot(start + isec)%pot%set(1)%gal21%epsilon2 = rvalues(2)
1651 nonbonded%pot(start + isec)%pot%set(1)%gal21%epsilon3 = rvalues(3)
1652
1653 CALL section_vals_val_get(gal21_section, "bxy", i_rep_section=isec, r_vals=rvalues)
1654 nonbonded%pot(start + isec)%pot%set(1)%gal21%bxy1 = rvalues(1)
1655 nonbonded%pot(start + isec)%pot%set(1)%gal21%bxy2 = rvalues(2)
1656
1657 CALL section_vals_val_get(gal21_section, "bz", i_rep_section=isec, r_vals=rvalues)
1658 nonbonded%pot(start + isec)%pot%set(1)%gal21%bz1 = rvalues(1)
1659 nonbonded%pot(start + isec)%pot%set(1)%gal21%bz2 = rvalues(2)
1660
1661 CALL section_vals_val_get(gal21_section, "r", i_rep_section=isec, r_vals=rvalues)
1662 nonbonded%pot(start + isec)%pot%set(1)%gal21%r1 = rvalues(1)
1663 nonbonded%pot(start + isec)%pot%set(1)%gal21%r2 = rvalues(2)
1664
1665 CALL section_vals_val_get(gal21_section, "a1", i_rep_section=isec, r_vals=rvalues)
1666 nonbonded%pot(start + isec)%pot%set(1)%gal21%a11 = rvalues(1)
1667 nonbonded%pot(start + isec)%pot%set(1)%gal21%a12 = rvalues(2)
1668 nonbonded%pot(start + isec)%pot%set(1)%gal21%a13 = rvalues(3)
1669
1670 CALL section_vals_val_get(gal21_section, "a2", i_rep_section=isec, r_vals=rvalues)
1671 nonbonded%pot(start + isec)%pot%set(1)%gal21%a21 = rvalues(1)
1672 nonbonded%pot(start + isec)%pot%set(1)%gal21%a22 = rvalues(2)
1673 nonbonded%pot(start + isec)%pot%set(1)%gal21%a23 = rvalues(3)
1674
1675 CALL section_vals_val_get(gal21_section, "a3", i_rep_section=isec, r_vals=rvalues)
1676 nonbonded%pot(start + isec)%pot%set(1)%gal21%a31 = rvalues(1)
1677 nonbonded%pot(start + isec)%pot%set(1)%gal21%a32 = rvalues(2)
1678 nonbonded%pot(start + isec)%pot%set(1)%gal21%a33 = rvalues(3)
1679
1680 CALL section_vals_val_get(gal21_section, "a4", i_rep_section=isec, r_vals=rvalues)
1681 nonbonded%pot(start + isec)%pot%set(1)%gal21%a41 = rvalues(1)
1682 nonbonded%pot(start + isec)%pot%set(1)%gal21%a42 = rvalues(2)
1683 nonbonded%pot(start + isec)%pot%set(1)%gal21%a43 = rvalues(3)
1684
1685 CALL section_vals_val_get(gal21_section, "A", i_rep_section=isec, r_vals=rvalues)
1686 nonbonded%pot(start + isec)%pot%set(1)%gal21%AO1 = rvalues(1)
1687 nonbonded%pot(start + isec)%pot%set(1)%gal21%AO2 = rvalues(2)
1688
1689 CALL section_vals_val_get(gal21_section, "B", i_rep_section=isec, r_vals=rvalues)
1690 nonbonded%pot(start + isec)%pot%set(1)%gal21%BO1 = rvalues(1)
1691 nonbonded%pot(start + isec)%pot%set(1)%gal21%BO2 = rvalues(2)
1692
1693 CALL section_vals_val_get(gal21_section, "C", i_rep_section=isec, &
1694 r_val=nonbonded%pot(start + isec)%pot%set(1)%gal21%c)
1695
1696 CALL section_vals_val_get(gal21_section, "AH", i_rep_section=isec, r_vals=rvalues)
1697 nonbonded%pot(start + isec)%pot%set(1)%gal21%AH1 = rvalues(1)
1698 nonbonded%pot(start + isec)%pot%set(1)%gal21%AH2 = rvalues(2)
1699
1700 CALL section_vals_val_get(gal21_section, "BH", i_rep_section=isec, r_vals=rvalues)
1701 nonbonded%pot(start + isec)%pot%set(1)%gal21%BH1 = rvalues(1)
1702 nonbonded%pot(start + isec)%pot%set(1)%gal21%BH2 = rvalues(2)
1703
1704 NULLIFY (list)
1705 subsection => section_vals_get_subs_vals(section, "GCN", i_rep_section=isec)
1706 CALL section_vals_val_get(subsection, "_DEFAULT_KEYWORD_", n_rep_val=nval)
1707 ALLOCATE (nonbonded%pot(start + isec)%pot%set(1)%gal21%gcn(nval))
1708 CALL section_vals_list_get(subsection, "_DEFAULT_KEYWORD_", list=list)
1709 DO iatom = 1, nval
1710 ! we use only the first default_string_length characters of each line
1711 is_ok = cp_sll_val_next(list, val)
1712 CALL val_get(val, r_val=rval)
1713 ! assign values
1714 nonbonded%pot(start + isec)%pot%set(1)%gal21%gcn(iatom) = rval
1715 END DO
1716
1717 CALL section_vals_val_get(gal21_section, "Fit_express", i_rep_section=isec, &
1718 l_val=nonbonded%pot(start + isec)%pot%set(1)%gal21%express)
1719
1720 ! ! In case it is defined override the standard specification of RCUT
1721 CALL section_vals_val_get(gal21_section, "RCUT", i_rep_section=isec, n_rep_val=n_rep)
1722 IF (n_rep == 1) THEN
1723 CALL section_vals_val_get(gal21_section, "RCUT", i_rep_section=isec, r_val=rcut)
1724 nonbonded%pot(start + isec)%pot%rcutsq = rcut**2
1725 nonbonded%pot(start + isec)%pot%set(1)%gal21%rcutsq = rcut**2
1726 END IF
1727 END DO
1728 END SUBROUTINE read_gal21_section
1729
1730! **************************************************************************************************
1731!> \brief Reads the siepmann section
1732!> \param nonbonded ...
1733!> \param section ...
1734!> \param start ...
1735!> \param siepmann_section ...
1736!> \author Dorothea Golze
1737! **************************************************************************************************
1738 SUBROUTINE read_siepmann_section(nonbonded, section, start, siepmann_section)
1739 TYPE(pair_potential_p_type), POINTER :: nonbonded
1740 TYPE(section_vals_type), POINTER :: section
1741 INTEGER, INTENT(IN) :: start
1742 TYPE(section_vals_type), POINTER :: siepmann_section
1743
1744 CHARACTER(LEN=default_string_length), &
1745 DIMENSION(:), POINTER :: atm_names
1746 INTEGER :: isec, n_items, n_rep
1747 REAL(kind=dp) :: rcut
1748
1749 CALL section_vals_get(section, n_repetition=n_items)
1750 DO isec = 1, n_items
1751 CALL cite_reference(siepmann1995)
1752 CALL section_vals_val_get(section, "ATOMS", i_rep_section=isec, c_vals=atm_names)
1753
1754 nonbonded%pot(start + isec)%pot%type = siepmann_type
1755 nonbonded%pot(start + isec)%pot%at1 = atm_names(1)
1756 nonbonded%pot(start + isec)%pot%at2 = atm_names(2)
1757 CALL uppercase(nonbonded%pot(start + isec)%pot%at1)
1758 CALL uppercase(nonbonded%pot(start + isec)%pot%at2)
1759
1760 CALL section_vals_val_get(siepmann_section, "B", i_rep_section=isec, &
1761 r_val=nonbonded%pot(start + isec)%pot%set(1)%siepmann%B)
1762 CALL section_vals_val_get(siepmann_section, "D", i_rep_section=isec, &
1763 r_val=nonbonded%pot(start + isec)%pot%set(1)%siepmann%D)
1764 CALL section_vals_val_get(siepmann_section, "E", i_rep_section=isec, &
1765 r_val=nonbonded%pot(start + isec)%pot%set(1)%siepmann%E)
1766 CALL section_vals_val_get(siepmann_section, "F", i_rep_section=isec, &
1767 r_val=nonbonded%pot(start + isec)%pot%set(1)%siepmann%F)
1768 CALL section_vals_val_get(siepmann_section, "beta", i_rep_section=isec, &
1769 r_val=nonbonded%pot(start + isec)%pot%set(1)%siepmann%beta)
1770 CALL section_vals_val_get(siepmann_section, "ALLOW_OH_FORMATION", i_rep_section=isec, &
1771 l_val=nonbonded%pot(start + isec)%pot%set(1)%siepmann%allow_oh_formation)
1772 CALL section_vals_val_get(siepmann_section, "ALLOW_H3O_FORMATION", i_rep_section=isec, &
1773 l_val=nonbonded%pot(start + isec)%pot%set(1)%siepmann%allow_h3o_formation)
1774 CALL section_vals_val_get(siepmann_section, "ALLOW_O_FORMATION", i_rep_section=isec, &
1775 l_val=nonbonded%pot(start + isec)%pot%set(1)%siepmann%allow_o_formation)
1776
1777 ! ! In case it is defined override the standard specification of RCUT
1778 CALL section_vals_val_get(siepmann_section, "RCUT", i_rep_section=isec, n_rep_val=n_rep)
1779 IF (n_rep == 1) THEN
1780 CALL section_vals_val_get(siepmann_section, "RCUT", i_rep_section=isec, r_val=rcut)
1781 nonbonded%pot(start + isec)%pot%rcutsq = rcut**2
1782 nonbonded%pot(start + isec)%pot%set(1)%siepmann%rcutsq = rcut**2
1783 END IF
1784 END DO
1785 END SUBROUTINE read_siepmann_section
1786
1787! **************************************************************************************************
1788!> \brief Reads the Buckingham plus Morse potential section
1789!> \param nonbonded ...
1790!> \param section ...
1791!> \param start ...
1792!> \author MI
1793! **************************************************************************************************
1794 SUBROUTINE read_bm_section(nonbonded, section, start)
1795 TYPE(pair_potential_p_type), POINTER :: nonbonded
1796 TYPE(section_vals_type), POINTER :: section
1797 INTEGER, INTENT(IN) :: start
1798
1799 CHARACTER(LEN=default_string_length), &
1800 DIMENSION(:), POINTER :: atm_names
1801 INTEGER :: isec, n_items, n_rep
1802 REAL(kind=dp) :: a1, a2, b1, b2, beta, c, d, f0, r0, rcut
1803
1804 CALL section_vals_get(section, n_repetition=n_items)
1805 DO isec = 1, n_items
1806 CALL cite_reference(yamada2000)
1807 CALL section_vals_val_get(section, "ATOMS", i_rep_section=isec, c_vals=atm_names)
1808 CALL section_vals_val_get(section, "F0", i_rep_section=isec, r_val=f0)
1809 CALL section_vals_val_get(section, "A1", i_rep_section=isec, r_val=a1)
1810 CALL section_vals_val_get(section, "A2", i_rep_section=isec, r_val=a2)
1811 CALL section_vals_val_get(section, "B1", i_rep_section=isec, r_val=b1)
1812 CALL section_vals_val_get(section, "B2", i_rep_section=isec, r_val=b2)
1813 CALL section_vals_val_get(section, "C", i_rep_section=isec, r_val=c)
1814 CALL section_vals_val_get(section, "D", i_rep_section=isec, r_val=d)
1815 CALL section_vals_val_get(section, "R0", i_rep_section=isec, r_val=r0)
1816 CALL section_vals_val_get(section, "Beta", i_rep_section=isec, r_val=beta)
1817 CALL section_vals_val_get(section, "RCUT", i_rep_section=isec, r_val=rcut)
1818
1819 nonbonded%pot(start + isec)%pot%type = bm_type
1820 nonbonded%pot(start + isec)%pot%at1 = atm_names(1)
1821 nonbonded%pot(start + isec)%pot%at2 = atm_names(2)
1822 CALL uppercase(nonbonded%pot(start + isec)%pot%at1)
1823 CALL uppercase(nonbonded%pot(start + isec)%pot%at2)
1824 nonbonded%pot(start + isec)%pot%set(1)%buckmo%f0 = f0
1825 nonbonded%pot(start + isec)%pot%set(1)%buckmo%a1 = a1
1826 nonbonded%pot(start + isec)%pot%set(1)%buckmo%a2 = a2
1827 nonbonded%pot(start + isec)%pot%set(1)%buckmo%b1 = b1
1828 nonbonded%pot(start + isec)%pot%set(1)%buckmo%b2 = b2
1829 nonbonded%pot(start + isec)%pot%set(1)%buckmo%c = c
1830 nonbonded%pot(start + isec)%pot%set(1)%buckmo%d = d
1831 nonbonded%pot(start + isec)%pot%set(1)%buckmo%r0 = r0
1832 nonbonded%pot(start + isec)%pot%set(1)%buckmo%beta = beta
1833 nonbonded%pot(start + isec)%pot%rcutsq = rcut*rcut
1834 !
1835 CALL section_vals_val_get(section, "RMIN", i_rep_section=isec, n_rep_val=n_rep)
1836 IF (n_rep == 1) CALL section_vals_val_get(section, "RMIN", i_rep_section=isec, &
1837 r_val=nonbonded%pot(start + isec)%pot%set(1)%rmin)
1838 CALL section_vals_val_get(section, "RMAX", i_rep_section=isec, n_rep_val=n_rep)
1839 IF (n_rep == 1) CALL section_vals_val_get(section, "RMAX", i_rep_section=isec, &
1840 r_val=nonbonded%pot(start + isec)%pot%set(1)%rmax)
1841 END DO
1842 END SUBROUTINE read_bm_section
1843
1844! **************************************************************************************************
1845!> \brief Reads the TABPOT section
1846!> \param nonbonded ...
1847!> \param section ...
1848!> \param start ...
1849!> \param para_env ...
1850!> \param mm_section ...
1851!> \author Alex Mironenko, Da Teng
1852! **************************************************************************************************
1853 SUBROUTINE read_tabpot_section(nonbonded, section, start, para_env, mm_section)
1854 TYPE(pair_potential_p_type), POINTER :: nonbonded
1855 TYPE(section_vals_type), POINTER :: section
1856 INTEGER, INTENT(IN) :: start
1857 TYPE(mp_para_env_type), POINTER :: para_env
1858 TYPE(section_vals_type), POINTER :: mm_section
1859
1860 CHARACTER(LEN=default_string_length), &
1861 DIMENSION(:), POINTER :: atm_names
1862 INTEGER :: isec, n_items
1863
1864 CALL section_vals_get(section, n_repetition=n_items)
1865 DO isec = 1, n_items
1866 CALL section_vals_val_get(section, "ATOMS", i_rep_section=isec, c_vals=atm_names)
1867 nonbonded%pot(start + isec)%pot%type = tab_type
1868 nonbonded%pot(start + isec)%pot%at1 = atm_names(1)
1869 nonbonded%pot(start + isec)%pot%at2 = atm_names(2)
1870 CALL uppercase(nonbonded%pot(start + isec)%pot%at1)
1871 CALL uppercase(nonbonded%pot(start + isec)%pot%at2)
1872 CALL section_vals_val_get(section, "PARM_FILE_NAME", i_rep_section=isec, &
1873 c_val=nonbonded%pot(start + isec)%pot%set(1)%tab%tabpot_file_name)
1874 CALL read_tabpot_data(nonbonded%pot(start + isec)%pot%set(1)%tab, para_env, mm_section)
1875 nonbonded%pot(start + isec)%pot%set(1)%tab%index = isec
1876 END DO
1877 END SUBROUTINE read_tabpot_section
1878
1879! **************************************************************************************************
1880!> \brief Reads the CHARGE section
1881!> \param charge_atm ...
1882!> \param charge ...
1883!> \param section ...
1884!> \param start ...
1885!> \author teo
1886! **************************************************************************************************
1887 SUBROUTINE read_chrg_section(charge_atm, charge, section, start)
1888 CHARACTER(LEN=default_string_length), &
1889 DIMENSION(:), POINTER :: charge_atm
1890 REAL(kind=dp), DIMENSION(:), POINTER :: charge
1891 TYPE(section_vals_type), POINTER :: section
1892 INTEGER, INTENT(IN) :: start
1893
1894 CHARACTER(LEN=default_string_length) :: atm_name
1895 INTEGER :: isec, n_items
1896
1897 CALL section_vals_get(section, n_repetition=n_items)
1898 DO isec = 1, n_items
1899 CALL section_vals_val_get(section, "ATOM", i_rep_section=isec, c_val=atm_name)
1900 charge_atm(start + isec) = atm_name
1901 CALL uppercase(charge_atm(start + isec))
1902 CALL section_vals_val_get(section, "CHARGE", i_rep_section=isec, r_val=charge(start + isec))
1903 END DO
1904 END SUBROUTINE read_chrg_section
1905
1906! **************************************************************************************************
1907!> \brief Reads the POLARIZABILITY section
1908!> \param apol_atm ...
1909!> \param apol ...
1910!> \param damping_list ...
1911!> \param section ...
1912!> \param start ...
1913!> \author Marcel Baer
1914! **************************************************************************************************
1915 SUBROUTINE read_apol_section(apol_atm, apol, damping_list, section, &
1916 start)
1917 CHARACTER(LEN=default_string_length), &
1918 DIMENSION(:), POINTER :: apol_atm
1919 REAL(kind=dp), DIMENSION(:), POINTER :: apol
1920 TYPE(damping_info_type), DIMENSION(:), POINTER :: damping_list
1921 TYPE(section_vals_type), POINTER :: section
1922 INTEGER, INTENT(IN) :: start
1923
1924 CHARACTER(LEN=default_string_length) :: atm_name
1925 INTEGER :: isec, isec_damp, n_damp, n_items, &
1926 start_damp, tmp_damp
1927 TYPE(section_vals_type), POINTER :: tmp_section
1928
1929 CALL section_vals_get(section, n_repetition=n_items)
1930 NULLIFY (tmp_section)
1931 n_damp = 0
1932! *** Counts number of DIPOLE%DAMPING sections ****
1933 DO isec = 1, n_items
1934 tmp_section => section_vals_get_subs_vals(section, "DAMPING", &
1935 i_rep_section=isec)
1936 CALL section_vals_get(tmp_section, n_repetition=tmp_damp)
1937 n_damp = n_damp + tmp_damp
1938
1939 END DO
1940
1941 IF (n_damp > 0) THEN
1942 ALLOCATE (damping_list(1:n_damp))
1943 END IF
1944
1945! *** Reads DIPOLE sections *****
1946 start_damp = 0
1947 DO isec = 1, n_items
1948 CALL section_vals_val_get(section, "ATOM", i_rep_section=isec, c_val=atm_name)
1949 apol_atm(start + isec) = atm_name
1950 CALL uppercase(apol_atm(start + isec))
1951 CALL section_vals_val_get(section, "APOL", i_rep_section=isec, r_val=apol(start + isec))
1952
1953 tmp_section => section_vals_get_subs_vals(section, "DAMPING", &
1954 i_rep_section=isec)
1955 CALL section_vals_get(tmp_section, n_repetition=tmp_damp)
1956 DO isec_damp = 1, tmp_damp
1957 damping_list(start_damp + isec_damp)%atm_name1 = apol_atm(start + isec)
1958 CALL section_vals_val_get(tmp_section, "ATOM", i_rep_section=isec_damp, &
1959 c_val=atm_name)
1960 damping_list(start_damp + isec_damp)%atm_name2 = atm_name
1961 CALL uppercase(damping_list(start_damp + isec_damp)%atm_name2)
1962 CALL section_vals_val_get(tmp_section, "TYPE", i_rep_section=isec_damp, &
1963 c_val=atm_name)
1964 damping_list(start_damp + isec_damp)%dtype = atm_name
1965 CALL uppercase(damping_list(start_damp + isec_damp)%dtype)
1966
1967 CALL section_vals_val_get(tmp_section, "ORDER", i_rep_section=isec_damp, &
1968 i_val=damping_list(start_damp + isec_damp)%order)
1969 CALL section_vals_val_get(tmp_section, "BIJ", i_rep_section=isec_damp, &
1970 r_val=damping_list(start_damp + isec_damp)%bij)
1971 CALL section_vals_val_get(tmp_section, "CIJ", i_rep_section=isec_damp, &
1972 r_val=damping_list(start_damp + isec_damp)%cij)
1973 END DO
1974 start_damp = start_damp + tmp_damp
1975
1976 END DO
1977
1978 END SUBROUTINE read_apol_section
1979
1980! **************************************************************************************************
1981!> \brief Reads the QUADRUPOLE POLARIZABILITY section
1982!> \param cpol_atm ...
1983!> \param cpol ...
1984!> \param section ...
1985!> \param start ...
1986!> \author Marcel Baer
1987! **************************************************************************************************
1988 SUBROUTINE read_cpol_section(cpol_atm, cpol, section, start)
1989 CHARACTER(LEN=default_string_length), &
1990 DIMENSION(:), POINTER :: cpol_atm
1991 REAL(kind=dp), DIMENSION(:), POINTER :: cpol
1992 TYPE(section_vals_type), POINTER :: section
1993 INTEGER, INTENT(IN) :: start
1994
1995 CHARACTER(LEN=default_string_length) :: atm_name
1996 INTEGER :: isec, n_items
1997
1998 CALL section_vals_get(section, n_repetition=n_items)
1999 DO isec = 1, n_items
2000 CALL section_vals_val_get(section, "ATOM", i_rep_section=isec, c_val=atm_name)
2001 cpol_atm(start + isec) = atm_name
2002 CALL uppercase(cpol_atm(start + isec))
2003 CALL section_vals_val_get(section, "CPOL", i_rep_section=isec, r_val=cpol(start + isec))
2004 END DO
2005 END SUBROUTINE read_cpol_section
2006
2007! **************************************************************************************************
2008!> \brief Reads the SHELL section
2009!> \param shell_list ...
2010!> \param section ...
2011!> \param start ...
2012!> \author Marcella Iannuzzi
2013! **************************************************************************************************
2014 SUBROUTINE read_shell_section(shell_list, section, start)
2015
2016 TYPE(shell_p_type), DIMENSION(:), POINTER :: shell_list
2017 TYPE(section_vals_type), POINTER :: section
2018 INTEGER, INTENT(IN) :: start
2019
2020 CHARACTER(LEN=default_string_length) :: atm_name
2021 INTEGER :: i_rep, n_rep
2022 REAL(dp) :: ccharge, cutoff, k, maxdist, mfrac, &
2023 scharge
2024
2025 CALL section_vals_get(section, n_repetition=n_rep)
2026
2027 DO i_rep = 1, n_rep
2028 CALL section_vals_val_get(section, "_SECTION_PARAMETERS_", &
2029 c_val=atm_name, i_rep_section=i_rep)
2030 CALL uppercase(atm_name)
2031 shell_list(start + i_rep)%atm_name = atm_name
2032 CALL section_vals_val_get(section, "CORE_CHARGE", i_rep_section=i_rep, r_val=ccharge)
2033 shell_list(start + i_rep)%shell%charge_core = ccharge
2034 CALL section_vals_val_get(section, "SHELL_CHARGE", i_rep_section=i_rep, r_val=scharge)
2035 shell_list(start + i_rep)%shell%charge_shell = scharge
2036 CALL section_vals_val_get(section, "MASS_FRACTION", i_rep_section=i_rep, r_val=mfrac)
2037 shell_list(start + i_rep)%shell%massfrac = mfrac
2038 CALL section_vals_val_get(section, "K2_SPRING", i_rep_section=i_rep, r_val=k)
2039 IF (k < 0.0_dp) THEN
2040 CALL cp_abort(__location__, &
2041 "An invalid value was specified for the force constant k2 of the core-shell "// &
2042 "spring potential")
2043 END IF
2044 shell_list(start + i_rep)%shell%k2_spring = k
2045 CALL section_vals_val_get(section, "K4_SPRING", i_rep_section=i_rep, r_val=k)
2046 IF (k < 0.0_dp) THEN
2047 CALL cp_abort(__location__, &
2048 "An invalid value was specified for the force constant k4 of the core-shell "// &
2049 "spring potential")
2050 END IF
2051 shell_list(start + i_rep)%shell%k4_spring = k
2052 CALL section_vals_val_get(section, "MAX_DISTANCE", i_rep_section=i_rep, r_val=maxdist)
2053 shell_list(start + i_rep)%shell%max_dist = maxdist
2054 CALL section_vals_val_get(section, "SHELL_CUTOFF", i_rep_section=i_rep, r_val=cutoff)
2055 shell_list(start + i_rep)%shell%shell_cutoff = cutoff
2056 END DO
2057
2058 END SUBROUTINE read_shell_section
2059
2060! **************************************************************************************************
2061!> \brief Reads the BONDS section
2062!> \param bond_kind ...
2063!> \param bond_a ...
2064!> \param bond_b ...
2065!> \param bond_k ...
2066!> \param bond_r0 ...
2067!> \param bond_cs ...
2068!> \param section ...
2069!> \param start ...
2070!> \author teo
2071! **************************************************************************************************
2072 SUBROUTINE read_bonds_section(bond_kind, bond_a, bond_b, bond_k, bond_r0, bond_cs, section, start)
2073 INTEGER, DIMENSION(:), POINTER :: bond_kind
2074 CHARACTER(LEN=default_string_length), &
2075 DIMENSION(:), POINTER :: bond_a, bond_b
2076 REAL(kind=dp), DIMENSION(:, :), POINTER :: bond_k
2077 REAL(kind=dp), DIMENSION(:), POINTER :: bond_r0, bond_cs
2078 TYPE(section_vals_type), POINTER :: section
2079 INTEGER, INTENT(IN) :: start
2080
2081 CHARACTER(LEN=default_string_length), &
2082 DIMENSION(:), POINTER :: atm_names
2083 INTEGER :: isec, k, n_items
2084 REAL(kind=dp), DIMENSION(:), POINTER :: kvals
2085
2086 NULLIFY (kvals, atm_names)
2087 CALL section_vals_get(section, n_repetition=n_items)
2088 DO isec = 1, n_items
2089 CALL section_vals_val_get(section, "KIND", i_rep_section=isec, i_val=bond_kind(start + isec))
2090 CALL section_vals_val_get(section, "ATOMS", i_rep_section=isec, c_vals=atm_names)
2091 bond_a(start + isec) = atm_names(1)
2092 bond_b(start + isec) = atm_names(2)
2093 CALL uppercase(bond_a(start + isec))
2094 CALL uppercase(bond_b(start + isec))
2095 CALL section_vals_val_get(section, "K", i_rep_section=isec, r_vals=kvals)
2096 cpassert(SIZE(kvals) <= 3)
2097 bond_k(:, start + isec) = 0.0_dp
2098 DO k = 1, SIZE(kvals)
2099 bond_k(k, start + isec) = kvals(k)
2100 END DO
2101 CALL section_vals_val_get(section, "R0", i_rep_section=isec, r_val=bond_r0(start + isec))
2102 CALL section_vals_val_get(section, "CS", i_rep_section=isec, r_val=bond_cs(start + isec))
2103 END DO
2104 END SUBROUTINE read_bonds_section
2105
2106! **************************************************************************************************
2107!> \brief Reads the BENDS section
2108!> \param bend_kind ...
2109!> \param bend_a ...
2110!> \param bend_b ...
2111!> \param bend_c ...
2112!> \param bend_k ...
2113!> \param bend_theta0 ...
2114!> \param bend_cb ...
2115!> \param bend_r012 ...
2116!> \param bend_r032 ...
2117!> \param bend_kbs12 ...
2118!> \param bend_kbs32 ...
2119!> \param bend_kss ...
2120!> \param bend_legendre ...
2121!> \param section ...
2122!> \param start ...
2123!> \author teo
2124! **************************************************************************************************
2125 SUBROUTINE read_bends_section(bend_kind, bend_a, bend_b, bend_c, bend_k, bend_theta0, bend_cb, &
2126 bend_r012, bend_r032, bend_kbs12, bend_kbs32, bend_kss, bend_legendre, &
2127 section, start)
2128 INTEGER, DIMENSION(:), POINTER :: bend_kind
2129 CHARACTER(LEN=default_string_length), &
2130 DIMENSION(:), POINTER :: bend_a, bend_b, bend_c
2131 REAL(kind=dp), DIMENSION(:), POINTER :: bend_k, bend_theta0, bend_cb, bend_r012, &
2132 bend_r032, bend_kbs12, bend_kbs32, &
2133 bend_kss
2134 TYPE(legendre_data_type), DIMENSION(:), POINTER :: bend_legendre
2135 TYPE(section_vals_type), POINTER :: section
2136 INTEGER, INTENT(IN) :: start
2137
2138 CHARACTER(LEN=default_string_length), &
2139 DIMENSION(:), POINTER :: atm_names
2140 INTEGER :: isec, k, n_items, n_rep
2141 REAL(kind=dp), DIMENSION(:), POINTER :: kvals, r_values
2142
2143 NULLIFY (kvals, atm_names)
2144 CALL section_vals_get(section, n_repetition=n_items)
2145 bend_legendre%order = 0
2146 DO isec = 1, n_items
2147 CALL section_vals_val_get(section, "KIND", i_rep_section=isec, i_val=bend_kind(start + isec))
2148 CALL section_vals_val_get(section, "ATOMS", i_rep_section=isec, c_vals=atm_names)
2149 bend_a(start + isec) = atm_names(1)
2150 bend_b(start + isec) = atm_names(2)
2151 bend_c(start + isec) = atm_names(3)
2152 CALL uppercase(bend_a(start + isec))
2153 CALL uppercase(bend_b(start + isec))
2154 CALL uppercase(bend_c(start + isec))
2155 CALL section_vals_val_get(section, "K", i_rep_section=isec, r_vals=kvals)
2156 cpassert(SIZE(kvals) == 1)
2157 bend_k(start + isec) = kvals(1)
2158 CALL section_vals_val_get(section, "THETA0", i_rep_section=isec, r_val=bend_theta0(start + isec))
2159 CALL section_vals_val_get(section, "CB", i_rep_section=isec, r_val=bend_cb(start + isec))
2160 CALL section_vals_val_get(section, "R012", i_rep_section=isec, r_val=bend_r012(start + isec))
2161 CALL section_vals_val_get(section, "R032", i_rep_section=isec, r_val=bend_r032(start + isec))
2162 CALL section_vals_val_get(section, "KBS12", i_rep_section=isec, r_val=bend_kbs12(start + isec))
2163 CALL section_vals_val_get(section, "KBS32", i_rep_section=isec, r_val=bend_kbs32(start + isec))
2164 CALL section_vals_val_get(section, "KSS", i_rep_section=isec, r_val=bend_kss(start + isec))
2165 ! get legendre based data
2166 CALL section_vals_val_get(section, "LEGENDRE", i_rep_section=isec, n_rep_val=n_rep)
2167 DO k = 1, n_rep
2168 CALL section_vals_val_get(section, "LEGENDRE", i_rep_val=k, r_vals=r_values, i_rep_section=isec)
2169 bend_legendre(start + isec)%order = SIZE(r_values)
2170 IF (ASSOCIATED(bend_legendre(start + isec)%coeffs)) THEN
2171 DEALLOCATE (bend_legendre(start + isec)%coeffs)
2172 END IF
2173 ALLOCATE (bend_legendre(start + isec)%coeffs(bend_legendre(start + isec)%order))
2174 bend_legendre(start + isec)%coeffs = r_values
2175 END DO
2176 END DO
2177 END SUBROUTINE read_bends_section
2178
2179! **************************************************************************************************
2180!> \brief ...
2181!> \param ub_kind ...
2182!> \param ub_a ...
2183!> \param ub_b ...
2184!> \param ub_c ...
2185!> \param ub_k ...
2186!> \param ub_r0 ...
2187!> \param section ...
2188!> \param start ...
2189! **************************************************************************************************
2190 SUBROUTINE read_ubs_section(ub_kind, ub_a, ub_b, ub_c, ub_k, ub_r0, section, start)
2191 INTEGER, DIMENSION(:), POINTER :: ub_kind
2192 CHARACTER(LEN=default_string_length), &
2193 DIMENSION(:), POINTER :: ub_a, ub_b, ub_c
2194 REAL(kind=dp), DIMENSION(:, :), POINTER :: ub_k
2195 REAL(kind=dp), DIMENSION(:), POINTER :: ub_r0
2196 TYPE(section_vals_type), POINTER :: section
2197 INTEGER, INTENT(IN) :: start
2198
2199 CHARACTER(LEN=default_string_length), &
2200 DIMENSION(:), POINTER :: atm_names
2201 INTEGER :: isec, k, n_items
2202 LOGICAL :: explicit
2203 REAL(kind=dp), DIMENSION(:), POINTER :: kvals
2204 TYPE(section_vals_type), POINTER :: subsection
2205
2206 NULLIFY (atm_names)
2207 CALL section_vals_get(section, n_repetition=n_items)
2208 DO isec = 1, n_items
2209 subsection => section_vals_get_subs_vals(section, "UB", i_rep_section=isec)
2210 CALL section_vals_get(subsection, explicit=explicit)
2211 IF (explicit) THEN
2212 CALL section_vals_val_get(subsection, "KIND", i_val=ub_kind(start + isec))
2213 CALL section_vals_val_get(section, "ATOMS", i_rep_section=isec, c_vals=atm_names)
2214 ub_a(start + isec) = atm_names(1)
2215 ub_b(start + isec) = atm_names(2)
2216 ub_c(start + isec) = atm_names(3)
2217 CALL uppercase(ub_a(start + isec))
2218 CALL uppercase(ub_b(start + isec))
2219 CALL uppercase(ub_c(start + isec))
2220 CALL section_vals_val_get(subsection, "K", r_vals=kvals)
2221 cpassert(SIZE(kvals) <= 3)
2222 ub_k(:, start + isec) = 0.0_dp
2223 DO k = 1, SIZE(kvals)
2224 ub_k(k, start + isec) = kvals(k)
2225 END DO
2226 CALL section_vals_val_get(subsection, "R0", r_val=ub_r0(start + isec))
2227 END IF
2228 END DO
2229 END SUBROUTINE read_ubs_section
2230
2231! **************************************************************************************************
2232!> \brief Reads the TORSIONS section
2233!> \param torsion_kind ...
2234!> \param torsion_a ...
2235!> \param torsion_b ...
2236!> \param torsion_c ...
2237!> \param torsion_d ...
2238!> \param torsion_k ...
2239!> \param torsion_phi0 ...
2240!> \param torsion_m ...
2241!> \param section ...
2242!> \param start ...
2243!> \author teo
2244! **************************************************************************************************
2245 SUBROUTINE read_torsions_section(torsion_kind, torsion_a, torsion_b, torsion_c, torsion_d, torsion_k, &
2246 torsion_phi0, torsion_m, section, start)
2247 INTEGER, DIMENSION(:), POINTER :: torsion_kind
2248 CHARACTER(LEN=default_string_length), &
2249 DIMENSION(:), POINTER :: torsion_a, torsion_b, torsion_c, &
2250 torsion_d
2251 REAL(kind=dp), DIMENSION(:), POINTER :: torsion_k, torsion_phi0
2252 INTEGER, DIMENSION(:), POINTER :: torsion_m
2253 TYPE(section_vals_type), POINTER :: section
2254 INTEGER, INTENT(IN) :: start
2255
2256 CHARACTER(LEN=default_string_length), &
2257 DIMENSION(:), POINTER :: atm_names
2258 INTEGER :: isec, n_items
2259
2260 NULLIFY (atm_names)
2261 CALL section_vals_get(section, n_repetition=n_items)
2262 DO isec = 1, n_items
2263 CALL section_vals_val_get(section, "KIND", i_rep_section=isec, i_val=torsion_kind(start + isec))
2264 CALL section_vals_val_get(section, "ATOMS", i_rep_section=isec, c_vals=atm_names)
2265 torsion_a(start + isec) = atm_names(1)
2266 torsion_b(start + isec) = atm_names(2)
2267 torsion_c(start + isec) = atm_names(3)
2268 torsion_d(start + isec) = atm_names(4)
2269 CALL uppercase(torsion_a(start + isec))
2270 CALL uppercase(torsion_b(start + isec))
2271 CALL uppercase(torsion_c(start + isec))
2272 CALL uppercase(torsion_d(start + isec))
2273 CALL section_vals_val_get(section, "K", i_rep_section=isec, r_val=torsion_k(start + isec))
2274 CALL section_vals_val_get(section, "PHI0", i_rep_section=isec, r_val=torsion_phi0(start + isec))
2275 CALL section_vals_val_get(section, "M", i_rep_section=isec, i_val=torsion_m(start + isec))
2276 ! Modify parameterisation for OPLS case
2277 IF (torsion_kind(start + isec) == do_ff_opls) THEN
2278 IF (torsion_phi0(start + isec) /= 0.0_dp) THEN
2279 CALL cp_warn(__location__, "PHI0 parameter was non-zero "// &
2280 "for an OPLS-type TORSION. It will be ignored.")
2281 END IF
2282 IF (modulo(torsion_m(start + isec), 2) == 0) THEN
2283 ! For even M, negate the cosine using a Pi phase factor
2284 torsion_phi0(start + isec) = pi
2285 END IF
2286 ! the K parameter appears as K/2 in the OPLS parameterisation
2287 torsion_k(start + isec) = torsion_k(start + isec)*0.5_dp
2288 END IF
2289 END DO
2290 END SUBROUTINE read_torsions_section
2291
2292! **************************************************************************************************
2293!> \brief Reads the IMPROPER section
2294!> \param impr_kind ...
2295!> \param impr_a ...
2296!> \param impr_b ...
2297!> \param impr_c ...
2298!> \param impr_d ...
2299!> \param impr_k ...
2300!> \param impr_phi0 ...
2301!> \param section ...
2302!> \param start ...
2303!> \author louis vanduyfhuys
2304! **************************************************************************************************
2305 SUBROUTINE read_improper_section(impr_kind, impr_a, impr_b, impr_c, impr_d, impr_k, &
2306 impr_phi0, section, start)
2307 INTEGER, DIMENSION(:), POINTER :: impr_kind
2308 CHARACTER(LEN=default_string_length), &
2309 DIMENSION(:), POINTER :: impr_a, impr_b, impr_c, impr_d
2310 REAL(kind=dp), DIMENSION(:), POINTER :: impr_k, impr_phi0
2311 TYPE(section_vals_type), POINTER :: section
2312 INTEGER, INTENT(IN) :: start
2313
2314 CHARACTER(LEN=default_string_length), &
2315 DIMENSION(:), POINTER :: atm_names
2316 INTEGER :: isec, n_items
2317
2318 NULLIFY (atm_names)
2319 CALL section_vals_get(section, n_repetition=n_items)
2320 DO isec = 1, n_items
2321 CALL section_vals_val_get(section, "KIND", i_rep_section=isec, i_val=impr_kind(start + isec))
2322 CALL section_vals_val_get(section, "ATOMS", i_rep_section=isec, c_vals=atm_names)
2323 impr_a(start + isec) = atm_names(1)
2324 impr_b(start + isec) = atm_names(2)
2325 impr_c(start + isec) = atm_names(3)
2326 impr_d(start + isec) = atm_names(4)
2327 CALL uppercase(impr_a(start + isec))
2328 CALL uppercase(impr_b(start + isec))
2329 CALL uppercase(impr_c(start + isec))
2330 CALL uppercase(impr_d(start + isec))
2331 CALL section_vals_val_get(section, "K", i_rep_section=isec, r_val=impr_k(start + isec))
2332 CALL section_vals_val_get(section, "PHI0", i_rep_section=isec, r_val=impr_phi0(start + isec))
2333 END DO
2334 END SUBROUTINE read_improper_section
2335
2336! **************************************************************************************************
2337!> \brief Reads the OPBEND section
2338!> \param opbend_kind ...
2339!> \param opbend_a ...
2340!> \param opbend_b ...
2341!> \param opbend_c ...
2342!> \param opbend_d ...
2343!> \param opbend_k ...
2344!> \param opbend_phi0 ...
2345!> \param section ...
2346!> \param start ...
2347!> \author louis vanduyfhuys
2348! **************************************************************************************************
2349 SUBROUTINE read_opbend_section(opbend_kind, opbend_a, opbend_b, opbend_c, opbend_d, opbend_k, &
2350 opbend_phi0, section, start)
2351 INTEGER, DIMENSION(:), POINTER :: opbend_kind
2352 CHARACTER(LEN=default_string_length), &
2353 DIMENSION(:), POINTER :: opbend_a, opbend_b, opbend_c, opbend_d
2354 REAL(kind=dp), DIMENSION(:), POINTER :: opbend_k, opbend_phi0
2355 TYPE(section_vals_type), POINTER :: section
2356 INTEGER, INTENT(IN) :: start
2357
2358 CHARACTER(LEN=default_string_length), &
2359 DIMENSION(:), POINTER :: atm_names
2360 INTEGER :: isec, n_items
2361
2362 NULLIFY (atm_names)
2363 CALL section_vals_get(section, n_repetition=n_items)
2364 DO isec = 1, n_items
2365 CALL section_vals_val_get(section, "KIND", i_rep_section=isec, i_val=opbend_kind(start + isec))
2366 CALL section_vals_val_get(section, "ATOMS", i_rep_section=isec, c_vals=atm_names)
2367 opbend_a(start + isec) = atm_names(1)
2368 opbend_b(start + isec) = atm_names(2)
2369 opbend_c(start + isec) = atm_names(3)
2370 opbend_d(start + isec) = atm_names(4)
2371 CALL uppercase(opbend_a(start + isec))
2372 CALL uppercase(opbend_b(start + isec))
2373 CALL uppercase(opbend_c(start + isec))
2374 CALL uppercase(opbend_d(start + isec))
2375 CALL section_vals_val_get(section, "K", i_rep_section=isec, r_val=opbend_k(start + isec))
2376 CALL section_vals_val_get(section, "PHI0", i_rep_section=isec, r_val=opbend_phi0(start + isec))
2377 END DO
2378 END SUBROUTINE read_opbend_section
2379
2380! **************************************************************************************************
2381!> \brief Reads the force_field input section
2382!> \param ff_type ...
2383!> \param para_env ...
2384!> \param mm_section ...
2385!> \par History
2386!> JGH (30.11.2001) : moved determination of setup variables to
2387!> molecule_input
2388!> \author CJM
2389! **************************************************************************************************
2390 SUBROUTINE read_force_field_section(ff_type, para_env, mm_section)
2391 TYPE(force_field_type), INTENT(INOUT) :: ff_type
2392 TYPE(mp_para_env_type), POINTER :: para_env
2393 TYPE(section_vals_type), POINTER :: mm_section
2394
2395 TYPE(section_vals_type), POINTER :: ff_section
2396
2397 NULLIFY (ff_section)
2398 ff_section => section_vals_get_subs_vals(mm_section, "FORCEFIELD")
2399 CALL read_force_field_section1(ff_section, mm_section, ff_type, para_env)
2400 END SUBROUTINE read_force_field_section
2401
2402! **************************************************************************************************
2403!> \brief reads EAM potential from library
2404!> \param eam ...
2405!> \param para_env ...
2406!> \param mm_section ...
2407! **************************************************************************************************
2408 SUBROUTINE read_eam_data(eam, para_env, mm_section)
2409 TYPE(eam_pot_type), POINTER :: eam
2410 TYPE(mp_para_env_type), POINTER :: para_env
2411 TYPE(section_vals_type), POINTER :: mm_section
2412
2413 CHARACTER(len=*), PARAMETER :: routinen = 'read_eam_data'
2414
2415 INTEGER :: handle, i, iw
2416 TYPE(cp_logger_type), POINTER :: logger
2417 TYPE(cp_parser_type) :: parser
2418
2419 CALL timeset(routinen, handle)
2420 NULLIFY (logger)
2421 logger => cp_get_default_logger()
2422 iw = cp_print_key_unit_nr(logger, mm_section, "PRINT%FF_INFO", &
2423 extension=".mmLog")
2424 IF (iw > 0) WRITE (iw, *) "Reading EAM data from: ", trim(eam%eam_file_name)
2425 CALL parser_create(parser, trim(eam%eam_file_name), para_env=para_env)
2426
2427 CALL parser_get_next_line(parser, 1)
2428 IF (iw > 0) WRITE (iw, *) "Title: ", parser%input_line
2429
2430 CALL parser_get_next_line(parser, 2)
2431 READ (parser%input_line, *) eam%drar, eam%drhoar, eam%acutal, eam%npoints
2432 eam%drar = cp_unit_to_cp2k(eam%drar, "angstrom")
2433 eam%acutal = cp_unit_to_cp2k(eam%acutal, "angstrom")
2434 ! Relocating arrays with the right size
2435 CALL reallocate(eam%rho, 1, eam%npoints)
2436 CALL reallocate(eam%rhop, 1, eam%npoints)
2437 CALL reallocate(eam%rval, 1, eam%npoints)
2438 CALL reallocate(eam%rhoval, 1, eam%npoints)
2439 CALL reallocate(eam%phi, 1, eam%npoints)
2440 CALL reallocate(eam%phip, 1, eam%npoints)
2441 CALL reallocate(eam%frho, 1, eam%npoints)
2442 CALL reallocate(eam%frhop, 1, eam%npoints)
2443 ! Reading density and derivative of density (with respect to r)
2444 DO i = 1, eam%npoints
2445 CALL parser_get_next_line(parser, 1)
2446 READ (parser%input_line, *) eam%rho(i), eam%rhop(i)
2447 eam%rhop(i) = cp_unit_to_cp2k(eam%rhop(i), "angstrom^-1")
2448 eam%rval(i) = real(i - 1, kind=dp)*eam%drar
2449 eam%rhoval(i) = real(i - 1, kind=dp)*eam%drhoar
2450 END DO
2451 ! Reading pair potential PHI and its derivative (with respect to r)
2452 DO i = 1, eam%npoints
2453 CALL parser_get_next_line(parser, 1)
2454 READ (parser%input_line, *) eam%phi(i), eam%phip(i)
2455 eam%phi(i) = cp_unit_to_cp2k(eam%phi(i), "eV")
2456 eam%phip(i) = cp_unit_to_cp2k(eam%phip(i), "eV*angstrom^-1")
2457 END DO
2458 ! Reading embedded function and its derivative (with respect to density)
2459 DO i = 1, eam%npoints
2460 CALL parser_get_next_line(parser, 1)
2461 READ (parser%input_line, *) eam%frho(i), eam%frhop(i)
2462 eam%frho(i) = cp_unit_to_cp2k(eam%frho(i), "eV")
2463 eam%frhop(i) = cp_unit_to_cp2k(eam%frhop(i), "eV")
2464 END DO
2465
2466 IF (iw > 0) WRITE (iw, *) "Finished EAM data"
2467 CALL parser_release(parser)
2468 CALL cp_print_key_finished_output(iw, logger, mm_section, "PRINT%FF_INFO")
2469 CALL timestop(handle)
2470
2471 END SUBROUTINE read_eam_data
2472
2473! **************************************************************************************************
2474!> \brief reads NequIP potential from .pth file
2475!> \param nequip ...
2476!> \author Gabriele Tocci
2477! **************************************************************************************************
2478 SUBROUTINE read_nequip_data(nequip)
2479 TYPE(nequip_pot_type) :: nequip
2480
2481 CHARACTER(LEN=*), PARAMETER :: routinen = 'read_nequip_data'
2482
2483 CHARACTER(LEN=100), ALLOCATABLE, DIMENSION(:) :: tokenized_string
2484 CHARACTER(LEN=4000) :: cutoff_matrix_str
2485 CHARACTER(LEN=default_path_length) :: allow_tf32_str, cutoff_str, model_dtype, &
2486 num_types_str, types_str
2487 INTEGER :: handle, i, j, k, len_path
2488 LOGICAL :: allow_tf32, found_model_file
2489 REAL(kind=dp) :: cut_val
2490
2491 CALL timeset(routinen, handle)
2492
2493 INQUIRE (file=nequip%pot_file_name, exist=found_model_file)
2494 IF (.NOT. found_model_file) THEN
2495 CALL cp_abort(__location__, &
2496 "Nequip model file <"//trim(nequip%pot_file_name)// &
2497 "> not found.")
2498 END IF
2499
2500 len_path = len_trim(nequip%pot_file_name)
2501 IF (len_path >= 4) THEN
2502 IF (nequip%pot_file_name(len_path - 3:len_path) == ".pt2") THEN
2503 CALL cp_abort(__location__, &
2504 "AOT compiled models (.pt2) are not yet supported in CP2K. " &
2505 //"Please use TorchScript (.pth or .pt) models compiled with nequip-compile.")
2506 END IF
2507 END IF
2508
2509 num_types_str = torch_model_read_metadata(nequip%pot_file_name, "num_types")
2510 READ (num_types_str, *) nequip%num_types
2511 cutoff_str = torch_model_read_metadata(nequip%pot_file_name, "r_max")
2512 types_str = torch_model_read_metadata(nequip%pot_file_name, "type_names")
2513 CALL tokenize_string(trim(types_str), tokenized_string)
2514
2515 IF (SIZE(tokenized_string) /= nequip%num_types) THEN
2516 CALL cp_abort(__location__, &
2517 "NequIP Metadata Error: 'num_types' does not match count of 'type_names'")
2518 END IF
2519
2520 IF (ALLOCATED(nequip%type_names_torch)) THEN
2521 DEALLOCATE (nequip%type_names_torch)
2522 END IF
2523 ALLOCATE (nequip%type_names_torch(SIZE(tokenized_string)))
2524 nequip%type_names_torch(:) = tokenized_string(:)
2525
2526 IF (ALLOCATED(nequip%cutoff_matrix)) DEALLOCATE (nequip%cutoff_matrix)
2527 ALLOCATE (nequip%cutoff_matrix(nequip%num_types, nequip%num_types))
2528
2529 READ (cutoff_str, *) nequip%rcutsq
2530 nequip%rcutsq = cp_unit_to_cp2k(nequip%rcutsq, nequip%unit_length)
2531 nequip%rcutsq = nequip%rcutsq*nequip%rcutsq
2532 nequip%unit_length_val = cp_unit_to_cp2k(nequip%unit_length_val, nequip%unit_length)
2533 nequip%unit_forces_val = cp_unit_to_cp2k(nequip%unit_forces_val, nequip%unit_forces)
2534 nequip%unit_energy_val = cp_unit_to_cp2k(nequip%unit_energy_val, nequip%unit_energy)
2535
2536 cutoff_matrix_str = torch_model_read_metadata(nequip%pot_file_name, "per_edge_type_cutoff")
2537
2538 IF (len_trim(cutoff_matrix_str) > 0) THEN
2539 CALL tokenize_string(trim(cutoff_matrix_str), tokenized_string)
2540
2541 IF (SIZE(tokenized_string) /= nequip%num_types**2) THEN
2542 CALL cp_abort(__location__, "per_edge_type_cutoff size does not match num_types^2")
2543 END IF
2544
2545 k = 0
2546 DO i = 1, nequip%num_types
2547 DO j = 1, nequip%num_types
2548 k = k + 1
2549 READ (tokenized_string(k), *) cut_val
2550 cut_val = cp_unit_to_cp2k(cut_val, nequip%unit_length)
2551 nequip%cutoff_matrix(i, j) = cut_val*cut_val
2552 END DO
2553 END DO
2554 ELSE
2555 ! Fallback: Fill with global r_max squared
2556 nequip%cutoff_matrix(:, :) = nequip%rcutsq
2557 END IF
2558
2559 model_dtype = torch_model_read_metadata(nequip%pot_file_name, "model_dtype")
2560 IF (trim(model_dtype) == "float32") THEN
2561 nequip%mixed_precision = .true.
2562 ELSE IF (trim(model_dtype) == "float64") THEN
2563 nequip%mixed_precision = .false.
2564 END IF
2565
2566 allow_tf32_str = torch_model_read_metadata(nequip%pot_file_name, "allow_tf32")
2567 allow_tf32 = (trim(allow_tf32_str) == "1")
2568 IF (trim(allow_tf32_str) /= "1" .AND. trim(allow_tf32_str) /= "0") THEN
2569 CALL cp_abort(__location__, &
2570 "The value for allow_tf32 <"//trim(allow_tf32_str)// &
2571 "> is not supported. Check the .yaml and .pth files.")
2572 END IF
2573 CALL torch_allow_tf32(allow_tf32)
2574
2575 CALL timestop(handle)
2576 END SUBROUTINE read_nequip_data
2577
2578! **************************************************************************************************
2579!> \brief returns tokenized string of kinds from .pth file
2580!> \param element ...
2581!> \param tokenized_array ...
2582!> \author Maria Bilichenko
2583! **************************************************************************************************
2584 SUBROUTINE tokenize_string(element, tokenized_array)
2585 CHARACTER(LEN=*), INTENT(IN) :: element
2586 CHARACTER(LEN=100), ALLOCATABLE, DIMENSION(:), &
2587 INTENT(OUT) :: tokenized_array
2588
2589 CHARACTER(LEN=1) :: ch
2590 CHARACTER(LEN=100) :: current
2591 INTEGER :: i, l, n
2592
2593 l = len_trim(element)
2594
2595 n = 0
2596 current = ""
2597 DO i = 1, l
2598 ch = element(i:i)
2599
2600 IF ((ch >= 'A' .AND. ch <= 'Z') .OR. (ch >= 'a' .AND. ch <= 'z')) THEN
2601 current(len_trim(current) + 1:len_trim(current) + 1) = ch
2602 ELSE
2603 IF (len_trim(current) > 0) THEN
2604 n = n + 1
2605 current = ""
2606 END IF
2607 END IF
2608 END DO
2609 IF (len_trim(current) > 0) n = n + 1
2610
2611 ALLOCATE (tokenized_array(n))
2612
2613 n = 0
2614 current = ""
2615 DO i = 1, l
2616 ch = element(i:i)
2617 IF ((ch >= 'A' .AND. ch <= 'Z') .OR. (ch >= 'a' .AND. ch <= 'z')) THEN
2618 current(len_trim(current) + 1:len_trim(current) + 1) = ch
2619 ELSE
2620 IF (len_trim(current) > 0) THEN
2621 n = n + 1
2622 tokenized_array(n) = trim(current)
2623 current = ""
2624 END IF
2625 END IF
2626 END DO
2627 IF (len_trim(current) > 0) THEN
2628 n = n + 1
2629 tokenized_array(n) = trim(current)
2630 END IF
2631 END SUBROUTINE tokenize_string
2632
2633! **************************************************************************************************
2634!> \brief checks if all the ATOMS from *.inp file are available in *.pth file
2635!> \param cp2k_inp_atom_types ...
2636!> \param torch_atom_types ...
2637!> \author Maria Bilichenko
2638! **************************************************************************************************
2639 SUBROUTINE check_cp2k_atom_names_in_torch(cp2k_inp_atom_types, torch_atom_types)
2640 CHARACTER(LEN=*), DIMENSION(:), INTENT(IN) :: cp2k_inp_atom_types, torch_atom_types
2641
2642 INTEGER :: i, j
2643 LOGICAL :: found_atom
2644
2645 DO i = 1, SIZE(cp2k_inp_atom_types)
2646 found_atom = .false.
2647 DO j = 1, SIZE(torch_atom_types)
2648 IF (trim(cp2k_inp_atom_types(i)) == trim(torch_atom_types(j))) THEN
2649 found_atom = .true.
2650 EXIT
2651 END IF
2652 END DO
2653 IF (.NOT. found_atom) THEN
2654 CALL cp_abort(__location__, &
2655 "Atom "//trim(cp2k_inp_atom_types(i))// &
2656 " is defined in the CP2K input file but is missing in the torch model file")
2657 END IF
2658 END DO
2659 END SUBROUTINE check_cp2k_atom_names_in_torch
2660
2661! **************************************************************************************************
2662!> \brief reads TABPOT potential from file
2663!> \param tab ...
2664!> \param para_env ...
2665!> \param mm_section ...
2666!> \author Da Teng, Alex Mironenko
2667! **************************************************************************************************
2668 SUBROUTINE read_tabpot_data(tab, para_env, mm_section)
2669 TYPE(tab_pot_type), POINTER :: tab
2670 TYPE(mp_para_env_type), POINTER :: para_env
2671 TYPE(section_vals_type), POINTER :: mm_section
2672
2673 CHARACTER(len=*), PARAMETER :: routinen = 'read_tabpot_data'
2674
2675 CHARACTER :: d1, d2
2676 INTEGER :: d, handle, i, iw
2677 TYPE(cp_logger_type), POINTER :: logger
2678 TYPE(cp_parser_type) :: parser
2679
2680 CALL timeset(routinen, handle)
2681 NULLIFY (logger)
2682 logger => cp_get_default_logger()
2683 iw = cp_print_key_unit_nr(logger, mm_section, "PRINT%FF_INFO", &
2684 extension=".mmLog")
2685 IF (iw > 0) WRITE (iw, *) "Reading TABPOT data from: ", trim(tab%tabpot_file_name)
2686 CALL parser_create(parser, trim(tab%tabpot_file_name), para_env=para_env)
2687 CALL parser_get_next_line(parser, 1)
2688 IF (iw > 0) WRITE (iw, *) "Title: ", parser%input_line
2689 CALL parser_get_next_line(parser, 1)
2690
2691 ! example format: N 1000 R 1.00 20.0
2692 ! Assume the data is evenly spaced
2693 READ (parser%input_line, *) d1, tab%npoints, d2, tab%dr, tab%rcut
2694
2695 ! Relocating arrays with the right size
2696 CALL reallocate(tab%r, 1, tab%npoints)
2697 CALL reallocate(tab%e, 1, tab%npoints)
2698 CALL reallocate(tab%f, 1, tab%npoints)
2699
2700 ! Reading r, e, f
2701 DO i = 1, tab%npoints
2702 CALL parser_get_next_line(parser, 1)
2703 READ (parser%input_line, *) d, tab%r(i), tab%e(i), tab%f(i)
2704 tab%r(i) = cp_unit_to_cp2k(tab%r(i), "angstrom")
2705 tab%e(i) = cp_unit_to_cp2k(tab%e(i), "kcalmol")
2706 tab%f(i) = cp_unit_to_cp2k(tab%f(i), "kcalmol*angstrom^-1")
2707 END DO
2708
2709 tab%dr = tab%r(2) - tab%r(1)
2710 tab%rcut = cp_unit_to_cp2k(tab%rcut, "angstrom")
2711
2712 IF (iw > 0) WRITE (iw, *) "Finished TABPOT data"
2713 CALL parser_release(parser)
2714 CALL cp_print_key_finished_output(iw, logger, mm_section, "PRINT%FF_INFO")
2715 CALL timestop(handle)
2716 END SUBROUTINE read_tabpot_data
2717END MODULE force_fields_input
static GRID_HOST_DEVICE int modulo(int a, int m)
Equivalent of Fortran's MODULO, which always return a positive number. https://gcc....
Interface to ACE C wrapper.
Definition ace_wrapper.F:12
subroutine, public ace_model_initialize(ntypec, symbolc, fname, rcutc, model)
...
collects all references to literature in CP2K as new algorithms / method are included from literature...
integer, save, public tosi1964b
integer, save, public tersoff1988
integer, save, public tosi1964a
integer, save, public siepmann1995
integer, save, public yamada2000
integer, save, public clabaut2021
integer, save, public clabaut2020
Utility routines to open and close files. Tracking of preconnections.
Definition cp_files.F:16
character(len=default_path_length) function, public discover_file(file_name)
Checks various locations for a file name.
Definition cp_files.F:521
logical function, public cp_sll_val_next(iterator, el_att)
returns true if the actual element is valid (i.e. iterator ont at end) moves the iterator to the next...
various routines to log and control the output. The idea is that decisions about where to log should ...
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
routines to handle the output, The idea is to remove the decision of wheter to output and what to out...
integer function, public cp_print_key_unit_nr(logger, basis_section, print_key_path, extension, middle_name, local, log_filename, ignore_should_output, file_form, file_position, file_action, file_status, do_backup, on_file, is_new_file, mpi_io, fout)
...
subroutine, public cp_print_key_finished_output(unit_nr, logger, basis_section, print_key_path, local, ignore_should_output, on_file, mpi_io)
should be called after you finish working with a unit obtained with cp_print_key_unit_nr,...
Utility routines to read data from files. Kept as close as possible to the old parser because.
subroutine, public parser_get_next_line(parser, nline, at_end)
Read the next input line and broadcast the input information. Skip (nline-1) lines and skip also all ...
Utility routines to read data from files. Kept as close as possible to the old parser because.
subroutine, public parser_release(parser)
releases the parser
subroutine, public parser_create(parser, file_name, unit_nr, para_env, end_section_label, separator_chars, comment_char, continuation_char, quote_char, section_char, parse_white_lines, initial_variables, apply_preprocessing)
Start a parser run. Initial variables allow to @SET stuff before opening the file.
unit conversion facility
Definition cp_units.F:30
real(kind=dp) function, public cp_unit_to_cp2k(value, unit_str, defaults, power)
converts to the internal cp2k units to the given unit
Definition cp_units.F:1222
Define all structure types related to force field kinds.
integer, parameter, public do_ff_undef
integer, parameter, public do_ff_charmm
integer, parameter, public do_ff_g87
integer, parameter, public do_ff_g96
integer, parameter, public do_ff_amber
integer, parameter, public do_ff_opls
Define all structures types related to force_fields.
subroutine, public read_gd_section(nonbonded, section, start)
Reads the GOODWIN section.
subroutine, public read_force_field_section(ff_type, para_env, mm_section)
Reads the force_field input section.
subroutine, public read_gp_section(nonbonded, section, start)
Reads the GENPOT - generic potential section.
subroutine, public read_wl_section(nonbonded, section, start)
Reads the WILLIAMS section.
subroutine, public read_chrg_section(charge_atm, charge, section, start)
Reads the CHARGE section.
subroutine, public read_lj_section(nonbonded, section, start)
Reads the LJ section.
subroutine, public get_generic_info(gen_section, func_name, xfunction, parameters, values, var_values, size_variables, i_rep_sec, input_variables)
Reads from the input structure all information for generic functions.
objects that represent the structure of input sections and the data contained in an input section
subroutine, public section_vals_list_get(section_vals, keyword_name, i_rep_section, list)
returns the requested list
recursive type(section_vals_type) function, pointer, public section_vals_get_subs_vals(section_vals, subsection_name, i_rep_section, can_return_null)
returns the values of the requested subsection
subroutine, public section_vals_get(section_vals, ref_count, n_repetition, n_subs_vals_rep, section, explicit)
returns various attributes about the section_vals
subroutine, public section_vals_val_get(section_vals, keyword_name, i_rep_section, i_rep_val, n_rep_val, val, l_val, i_val, r_val, c_val, l_vals, i_vals, r_vals, c_vals, explicit)
returns the requested value
a wrapper for basic fortran types.
subroutine, public val_get(val, has_l, has_i, has_r, has_lc, has_c, l_val, l_vals, i_val, i_vals, r_val, r_vals, c_val, c_vals, len_c, type_of_var, enum)
returns the stored values
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
integer, parameter, public default_string_length
Definition kinds.F:57
integer, parameter, public default_path_length
Definition kinds.F:58
An array-based list which grows on demand. When the internal array is full, a new array of twice the ...
Definition list.F:24
Definition of mathematical constants and functions.
real(kind=dp), parameter, public pi
Collection of simple mathematical functions and subroutines.
Definition mathlib.F:15
Utility routines for the memory handling.
Interface to the message passing library MPI.
subroutine, public pair_potential_reallocate(p, lb1_new, ub1_new, lj, lj_charmm, williams, goodwin, eam, nequip, bmhft, bmhftd, ipbv, buck4r, buckmo, gp, tersoff, siepmann, gal, gal21, tab, deepmd, ace)
Cleans the potential parameter type.
integer, parameter, public lj_charmm_type
integer, parameter, public allegro_type
integer, parameter, public bm_type
integer, parameter, public gal_type
integer, parameter, public nequip_type
integer, parameter, public wl_type
integer, parameter, public ft_type
integer, parameter, public tab_type
integer, parameter, public ftd_type
integer, parameter, public ip_type
integer, parameter, public deepmd_type
integer, parameter, public gp_type
integer, parameter, public siepmann_type
integer, parameter, public ace_type
integer, dimension(2), parameter, public do_potential_single_allocation
integer, parameter, public gw_type
integer, dimension(2), parameter, public no_potential_single_allocation
integer, parameter, public mace_type
integer, parameter, public b4_type
integer, parameter, public gal21_type
integer, dimension(2), public potential_single_allocation
integer, parameter, public ea_type
integer, parameter, public tersoff_type
subroutine, public shell_p_create(shell_list, ndim)
...
Utilities for string manipulations.
elemental subroutine, public uppercase(string)
Convert all lower case characters in a string to upper case.
subroutine, public torch_allow_tf32(allow_tf32)
Set whether to allow the use of TF32. Needed due to changes in defaults from pytorch 1....
Definition torch_api.F:2089
character(:) function, allocatable, public torch_model_read_metadata(filename, key)
Reads metadata entry from given "*.pth" file. (In Torch lingo they are called extra files)
Definition torch_api.F:1958
represent a single linked list that stores pointers to the elements
type of a logger, at the moment it contains just a print level starting at which level it should be l...
a type to have a wrapper that stores any basic fortran type
stores all the informations relevant to an mpi environment