(git:3d5d2e5)
Loading...
Searching...
No Matches
xc_libxc.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!> \brief calculates a functional from libxc and its derivatives
10!> \note
11!> LibXC:
12!> (Marques, Oliveira, Burnus, CPC 183, 2272 (2012)).
13!>
14!> WARNING: In the subroutine libxc_spin_polarized_calc, it could be that the
15!> ordering for the 1st index of v2lapltau, v2rholapl, v2rhotau,
16!> v2sigmalapl and v2sigmatau is not correct. For the moment it does not
17!> matter since the calculation of the 2nd derivatives for meta-GGA
18!> functionals is not implemented in CP2K.
19!>
20!> \par History
21!> 01.2013 created [F. Tran]
22!> 07.2014 updates to versions 2.1 [JGH]
23!> 08.2015 refactoring [A. Gloess (agloess)]
24!> 01.2018 refactoring [A. Gloess (agloess)]
25!> 10.2018/04.2019 added hyb_mgga [S. Simko, included by F. Stein]
26!> \author F. Tran
27! **************************************************************************************************
28
30 USE bibliography, ONLY: lehtola2018, &
32 cite_reference
40 USE kinds, ONLY: default_string_length, &
41 dp
49#include "../base/base_uses.f90"
50#if defined (__LIBXC)
54 USE iso_c_binding, ONLY: c_int, c_double
55 USE xc_derivative_desc, ONLY: &
60 USE xc_libxc_wrap, ONLY: xc_f03_func_t, &
61 xc_f03_func_init, &
62 xc_f03_func_end, &
63 xc_f03_func_info_t, &
64 xc_f03_functional_get_name, &
65 xc_f03_func_get_info, &
66 xc_f03_func_info_get_family, &
67 xc_f03_func_info_get_kind, &
68 xc_f03_func_info_get_n_ext_params, &
69 xc_f03_func_info_get_name, &
70 xc_f03_available_functional_numbers, &
71 xc_f03_available_functional_names, &
72 xc_f03_maximum_name_length, &
73 xc_f03_number_of_functionals, &
74 xc_f03_func_info_get_ext_params_name, &
75 xc_f03_func_info_get_ext_params_description, &
76 xc_f03_func_info_get_ext_params_default_value, &
77 xc_f03_gga_exc, &
78 xc_f03_gga_exc_vxc, &
79 xc_f03_gga_exc_vxc_fxc, &
80 xc_f03_gga_exc_vxc_fxc_kxc, &
81 xc_f03_gga_fxc, &
82 xc_f03_gga_vxc, &
83 xc_f03_gga_vxc_fxc, &
84 xc_f03_gga_vxc_fxc_kxc, &
85 xc_f03_lda, &
86 xc_f03_lda_exc, &
87 xc_f03_lda_exc_vxc, &
88 xc_f03_lda_exc_vxc_fxc, &
89 xc_f03_lda_fxc, &
90 xc_f03_lda_kxc, &
91 xc_f03_lda_vxc, &
92 xc_f03_mgga, &
93 xc_f03_mgga_exc, &
94 xc_f03_mgga_exc_vxc, &
95 xc_f03_mgga_exc_vxc_fxc, &
96 xc_f03_mgga_exc_vxc_fxc_kxc, &
97 xc_f03_mgga_fxc, &
98 xc_f03_mgga_vxc, &
99 xc_f03_mgga_vxc_fxc, &
100 xc_f03_mgga_vxc_fxc_kxc, &
101 xc_polarized, &
102 xc_unpolarized, &
103 xc_family_lda, &
104 xc_family_gga, &
105 xc_family_mgga, &
106 xc_family_hyb_lda, &
107 xc_family_hyb_gga, &
108 xc_family_hyb_mgga, &
109 libxc_set_backend, &
110 libxc_func_init_wrapper, &
111 libxc_gga_exc_vxc_wrapper, libxc_gga_exc_wrapper, &
112 libxc_lda_exc_vxc_wrapper, libxc_lda_exc_wrapper, &
113 libxc_mgga_exc_vxc_wrapper, libxc_mgga_exc_wrapper, &
114 libxc_mgga_vxc_wrapper, &
115 xc_libxc_wrap_functional_get_number, &
116 xc_libxc_wrap_info_needs_laplace, &
117 xc_libxc_wrap_info_no_exc, &
118 xc_libxc_wrap_is_under_development, &
119 xc_libxc_check_functional, &
120 xc_libxc_get_reference_length, &
121 xc_libxc_wrap_init_safe, &
122 xc_libxc_wrap_library_reference, &
123 xc_libxc_wrap_version, &
124 xc_libxc_wrap_set_thresholds, &
125 xc_libxc_wrap_info_refs, &
126 xc_f03_func_set_ext_params, &
127 xc_exchange, xc_correlation, xc_exchange_correlation, xc_kinetic
128 USE xc_libxc_wrap, ONLY: libxc_is_gpu
129 USE xc_libxc_wrap, ONLY: libxc_worker_type, &
130 libxc_worker_alloc, libxc_worker_free_buffers, &
131 libxc_worker_resize_cuda, libxc_worker_eval, libxc_family_flags
132#endif
133!$ USE OMP_LIB, ONLY: omp_get_max_threads, &
134!$ omp_get_num_threads, &
135!$ omp_get_thread_num
136
137 IMPLICIT NONE
138 PRIVATE
139
140 CHARACTER(LEN=*), PARAMETER, PRIVATE :: moduleN = 'xc_libxc'
141
147
148#if defined (__LIBXC)
149 PUBLIC :: libxc_set_backend
150
151! **************************************************************************************************
152!> \brief All threads' workers for one distinct functional setup, together with
153!> the key that identifies that setup. Each worker (functional object plus
154!> host staging buffers and, on GPU builds, the mirroring device buffers)
155!> is implemented in xc_libxc_wrap; here they are only aggregated.
156! **************************************************************************************************
157 TYPE libxc_worker_set_type
158 INTEGER :: func_id = -1
159 INTEGER :: nspin = -1
160 INTEGER :: family = -1
161 ! highest derivative order the workers' buffers were allocated for
162 INTEGER :: grad_deriv = -1
163 LOGICAL :: has_laplace = .false.
164 LOGICAL :: no_exc = .false.
165 LOGICAL :: has_params = .false.
166 REAL(KIND=dp) :: epsilon_rho = -1.0_dp
167 REAL(KIND=dp) :: epsilon_tau = -1.0_dp
168 REAL(KIND=dp), DIMENSION(:), ALLOCATABLE :: params
169 CHARACTER(LEN=128), DIMENSION(:), ALLOCATABLE :: param_names
170 TYPE(libxc_worker_type), DIMENSION(:), ALLOCATABLE :: worker
171 END TYPE libxc_worker_set_type
172
173 ! Workers are acquired from a serial region only (see libxc_get_workers), so
174 ! the cache itself needs no locking.
175 TYPE(libxc_worker_set_type), DIMENSION(:), ALLOCATABLE, TARGET, PRIVATE, SAVE :: libxc_cache
176
177 ! Stands in for the derivative arrays a given evaluation does not produce.
178 ! Those arguments still have to be associated with something, but they are
179 ! never read or written; pointing them at the density instead would make an
180 ! output argument alias a read-only input. Grown on demand and kept for the
181 ! run rather than allocated per evaluation, and like the cache above it is
182 ! only ever touched from a serial region.
183 REAL(KIND=dp), DIMENSION(:), ALLOCATABLE, TARGET, PRIVATE, SAVE :: libxc_unused
184#endif
185
186 ! Backend initialization bookkeeping
187 LOGICAL, PRIVATE, SAVE :: libxc_initialized = .false.
188
189CONTAINS
190
191! **************************************************************************************************
192!> \brief This function checks whether a functional name belongs to LibXC
193!> \param libxc_params (possible) LibXC input section
194!> \return exists whether the functional exists in LibXC
195! **************************************************************************************************
196 FUNCTION libxc_check_existence_in_libxc(libxc_params) RESULT(exists)
197
198 TYPE(section_vals_type), POINTER, INTENT(IN) :: libxc_params
199 LOGICAL :: exists
200
201#if defined (__LIBXC)
202 ! Initialize once on first call
203 IF (.NOT. libxc_initialized) THEN
204 CALL xc_libxc_wrap_init_safe()
205 libxc_initialized = .true.
206 END IF
207
208 exists = xc_libxc_check_functional(libxc_params%section%name)
209#else
210 mark_used(libxc_params)
211 exists = .false.
212#endif
213
215
216! **************************************************************************************************
217!> \brief This function returns the maximum length of the reference string for a given LibXC functional
218!> \param libxc_params LibXC input section
219!> \param lsd spin polarized calculation
220!> \return maximum length of the string
221! **************************************************************************************************
222 FUNCTION libxc_get_reference_length(libxc_params, lsd) RESULT(length)
223
224 TYPE(section_vals_type), POINTER, INTENT(IN) :: libxc_params
225 LOGICAL, INTENT(IN) :: lsd
226 INTEGER :: length
227
228#if defined (__LIBXC)
229 CHARACTER(LEN=*), PARAMETER :: routinen = 'libxc_get_reference_length'
230
231 CHARACTER(LEN=default_string_length) :: func_name
232 INTEGER :: func_id, handle
233 TYPE(xc_f03_func_t) :: xc_func
234 TYPE(xc_f03_func_info_t) :: xc_info
235
236 CALL timeset(routinen, handle)
237
238 func_name = libxc_params%section%name
239
240 func_id = xc_libxc_wrap_functional_get_number(func_name)
241 IF (lsd) THEN
242 CALL libxc_func_init_wrapper(xc_func, func_id, xc_polarized, force_host=.true.)
243 ELSE
244 CALL libxc_func_init_wrapper(xc_func, func_id, xc_unpolarized, force_host=.true.)
245 END IF
246 xc_info = xc_f03_func_get_info(xc_func)
247
248 length = xc_libxc_get_reference_length(xc_info)
249
250 CALL xc_f03_func_end(xc_func)
251
252 CALL timestop(handle)
253#else
254 mark_used(libxc_params)
255 mark_used(lsd)
256 length = 0
257 cpabort("In order to use LibXC you have to download and install it!")
258#endif
259
260 END FUNCTION libxc_get_reference_length
261
262! **************************************************************************************************
263!> \brief ...
264!> \param section ...
265! **************************************************************************************************
266 SUBROUTINE libxc_add_sections(section)
267
268 TYPE(section_type), POINTER, INTENT(IN) :: section
269
270#if defined (__LIBXC)
271 CHARACTER(LEN=*), PARAMETER :: routinen = 'libxc_add_sections'
272
273 TYPE(section_type), POINTER :: subsection
274 TYPE(keyword_type), POINTER :: keyword
275 INTEGER :: handle, no_func, len_name, ii, &
276 func_id, n_param, iparam
277 REAL(kind=c_double) :: default_val
278 CHARACTER(LEN=128) :: func_name, param_name, param_descr, &
279 description
280 CHARACTER(LEN=2*default_string_length) :: warning
281 INTEGER(KIND=C_INT), DIMENSION(:), ALLOCATABLE :: func_ids
282 TYPE(xc_f03_func_t) :: xc_func
283 TYPE(xc_f03_func_info_t) :: xc_info
284
285 CALL timeset(routinen, handle)
286
287 cpassert(ASSOCIATED(section))
288 NULLIFY (subsection, keyword)
289
290 no_func = xc_f03_number_of_functionals()
291 len_name = xc_f03_maximum_name_length()
292
293 ALLOCATE (func_ids(no_func))
294
295 CALL xc_f03_available_functional_numbers(func_ids)
296
297 DO ii = 1, no_func
298
299 func_id = func_ids(ii)
300 IF (ii > 1) THEN
301 IF (func_id == func_ids(ii - 1)) cycle
302 END IF
303 CALL libxc_func_init_wrapper(xc_func, func_id, xc_unpolarized, force_host=.true.)
304 xc_info = xc_f03_func_get_info(xc_func)
305
306 func_name = xc_f03_functional_get_name(func_id)
307 description = xc_f03_func_info_get_name(xc_info)
308 n_param = xc_f03_func_info_get_n_ext_params(xc_info)
309
310 NULLIFY (subsection)
311 CALL section_create(subsection, __location__, name=trim(func_name), description=trim(description), &
312 n_keywords=2 + n_param, n_subsections=0, repeats=.false.)
313
314 IF (description(1:1) == "_") THEN
315 warning = " This parameter is an internal parameter of the functional. Changing this "// &
316 "parameter effectively changes the functional."
317 ELSE
318 warning = " "
319 END IF
320
321 NULLIFY (keyword)
322 CALL keyword_create(keyword, __location__, name="_SECTION_PARAMETERS_", &
323 description="Activates the functional."//trim(warning), &
324 lone_keyword_l_val=.true., default_l_val=.false.)
325 CALL section_add_keyword(subsection, keyword)
326 CALL keyword_release(keyword)
327
328 CALL keyword_create(keyword, __location__, name="SCALE", description="Scales this functional", &
329 default_r_val=1.0_dp)
330 CALL section_add_keyword(subsection, keyword)
331 CALL keyword_release(keyword)
332
333 DO iparam = 1, n_param
334 param_name = xc_f03_func_info_get_ext_params_name(xc_info, iparam - 1)
335 param_descr = xc_f03_func_info_get_ext_params_description(xc_info, iparam - 1)
336 default_val = xc_f03_func_info_get_ext_params_default_value(xc_info, iparam - 1)
337 NULLIFY (keyword)
338 CALL keyword_create(keyword, __location__, name=trim(param_name), &
339 description=trim(param_descr), default_r_val=default_val)
340 CALL section_add_keyword(subsection, keyword)
341 CALL keyword_release(keyword)
342 END DO
343
344 CALL section_add_subsection(section, subsection)
345 CALL section_release(subsection)
346
347 CALL xc_f03_func_end(xc_func)
348
349 END DO
350
351 DEALLOCATE (func_ids)
352
353 CALL timestop(handle)
354#else
355 mark_used(section)
356
357#endif
358
359 END SUBROUTINE libxc_add_sections
360
361! **************************************************************************************************
362!> \brief info about the functional from libxc
363!> \param libxc_params input parameter (functional name, scaling and parameters)
364!> \param reference string with the reference of the actual functional
365!> \param shortform string with the shortform of the functional name
366!> \param needs the components needed by this functional are set to
367!> true (does not set the unneeded components to false)
368!> \param max_deriv maximum implemented derivative of the xc functional
369!> \param print_warn whether to print warning about development status of a functional
370!> \param func_name_override optional LibXC functional name overriding the section name
371!> \author F. Tran
372! **************************************************************************************************
373 SUBROUTINE libxc_spin_unpolarized_info(libxc_params, reference, shortform, needs, max_deriv, print_warn, &
374 func_name_override)
375
376 TYPE(section_vals_type), POINTER :: libxc_params
377 CHARACTER(LEN=*), INTENT(OUT), OPTIONAL :: reference, shortform
378 TYPE(xc_rho_cflags_type), &
379 INTENT(INOUT), OPTIONAL :: needs
380 INTEGER, INTENT(OUT), OPTIONAL :: max_deriv
381 LOGICAL, INTENT(IN), OPTIONAL :: print_warn
382 CHARACTER(LEN=*), INTENT(IN), OPTIONAL :: func_name_override
383
384#if defined (__LIBXC)
385 CHARACTER(LEN=128) :: s1, s2
386 CHARACTER(LEN=default_string_length) :: func_name
387 INTEGER :: func_id
388 REAL(kind=dp) :: func_scale
389 TYPE(xc_f03_func_t) :: xc_func
390 TYPE(xc_f03_func_info_t) :: xc_info
391
392 IF (PRESENT(func_name_override)) THEN
393 func_name = func_name_override
394 func_scale = 1.0_dp
395 ELSE
396 func_name = libxc_params%section%name
397 CALL section_vals_val_get(libxc_params, "scale", r_val=func_scale)
398 END IF
399
400 CALL cite_reference(marques2012)
401 CALL cite_reference(lehtola2018)
402
403 IF (abs(func_scale - 1.0_dp) < 1.0e-10_dp) func_scale = 1.0_dp
404
405 func_id = xc_libxc_wrap_functional_get_number(func_name)
406 CALL libxc_func_init_wrapper(xc_func, func_id, xc_unpolarized, force_host=.true.)
407 xc_info = xc_f03_func_get_info(xc_func)
408
409 s1 = xc_f03_func_info_get_name(xc_info)
410 SELECT CASE (xc_f03_func_info_get_kind(xc_info))
411 CASE (xc_exchange); WRITE (s2, '(a)') "exchange"
412 CASE (xc_correlation); WRITE (s2, '(a)') "correlation"
413 CASE (xc_exchange_correlation); WRITE (s2, '(a)') "exchange-correlation"
414 CASE (xc_kinetic); WRITE (s2, '(a)') "kinetic"
415 CASE default
416 cpabort(trim(func_name)//": this XC_KIND is currently not supported.")
417 END SELECT
418 IF (PRESENT(shortform)) THEN
419 shortform = trim(s1)//' ('//trim(s2)//')'
420 END IF
421 IF (PRESENT(reference)) THEN
422 CALL xc_libxc_wrap_info_refs(xc_info, xc_unpolarized, func_scale, reference)
423 END IF
424 IF (PRESENT(needs)) THEN
425 SELECT CASE (xc_f03_func_info_get_family(xc_info))
426 CASE (xc_family_lda, xc_family_hyb_lda)
427 needs%rho = .true.
428 CASE (xc_family_gga, xc_family_hyb_gga)
429 needs%rho = .true.
430 needs%norm_drho = .true.
431 CASE (xc_family_mgga, xc_family_hyb_mgga)
432 needs%rho = .true.
433 needs%norm_drho = .true.
434 needs%tau = .true.
435 needs%laplace_rho = xc_libxc_wrap_info_needs_laplace(xc_info)
436 CASE default
437 cpabort(trim(func_name)//": this XC_FAMILY is currently not supported.")
438 END SELECT
439 END IF
440 IF (PRESENT(max_deriv)) THEN
441 SELECT CASE (xc_f03_func_info_get_family(xc_info))
442 CASE (xc_family_lda, xc_family_hyb_lda)
443 max_deriv = 3
444 CASE (xc_family_gga, xc_family_hyb_gga)
445 max_deriv = 2
446 CASE (xc_family_mgga, xc_family_hyb_mgga)
447 max_deriv = 2
448 CASE default
449 cpabort(trim(func_name)//": this XC_FAMILY is currently not supported.")
450 END SELECT
451 END IF
452 IF (PRESENT(print_warn)) THEN
453 IF (print_warn .AND. xc_libxc_wrap_is_under_development(xc_info)) THEN
454 cpwarn(trim(func_name)//" is under development. Use with caution.")
455 END IF
456 END IF
457
458 CALL xc_f03_func_end(xc_func)
459#else
460 mark_used(libxc_params)
461 mark_used(reference)
462 mark_used(shortform)
463 mark_used(needs)
464 mark_used(max_deriv)
465 mark_used(print_warn)
466 mark_used(func_name_override)
467
468 CALL cp_abort(__location__, "Unknown functional! If you are asking "// &
469 "for a functional of the LibXC library, "// &
470 "you have to download and install the library!")
471#endif
472
473 END SUBROUTINE libxc_spin_unpolarized_info
474
475! **************************************************************************************************
476!> \brief info about the functional from libxc
477!> \param libxc_params input parameter (functional name, scaling and parameters)
478!> \param reference string with the reference of the actual functional
479!> \param shortform string with the shortform of the functional name
480!> \param needs the components needed by this functional are set to
481!> true (does not set the unneeded components to false)
482!> \param max_deriv maximum implemented derivative of the xc functional
483!> \param print_warn whether to print warning about development status of a functional
484!> \param func_name_override optional LibXC functional name overriding the section name
485!> \author F. Tran
486! **************************************************************************************************
487 SUBROUTINE libxc_spin_polarized_info(libxc_params, reference, shortform, needs, max_deriv, print_warn, &
488 func_name_override)
489
490 TYPE(section_vals_type), POINTER :: libxc_params
491 CHARACTER(LEN=*), INTENT(OUT), OPTIONAL :: reference, shortform
492 TYPE(xc_rho_cflags_type), &
493 INTENT(INOUT), OPTIONAL :: needs
494 INTEGER, INTENT(OUT), OPTIONAL :: max_deriv
495 LOGICAL, INTENT(IN), OPTIONAL :: print_warn
496 CHARACTER(LEN=*), INTENT(IN), OPTIONAL :: func_name_override
497
498#if defined (__LIBXC)
499 CHARACTER(LEN=128) :: s1, s2
500 CHARACTER(LEN=default_string_length) :: func_name
501 INTEGER :: func_id
502 REAL(kind=dp) :: func_scale
503 TYPE(xc_f03_func_t) :: xc_func
504 TYPE(xc_f03_func_info_t) :: xc_info
505
506 IF (PRESENT(func_name_override)) THEN
507 func_name = func_name_override
508 func_scale = 1.0_dp
509 ELSE
510 func_name = libxc_params%section%name
511 CALL section_vals_val_get(libxc_params, "scale", r_val=func_scale)
512 END IF
513
514 CALL cite_reference(marques2012)
515 CALL cite_reference(lehtola2018)
516
517 IF (abs(func_scale - 1.0_dp) < 1.0e-10_dp) func_scale = 1.0_dp
518
519 func_id = xc_libxc_wrap_functional_get_number(func_name)
520 CALL libxc_func_init_wrapper(xc_func, func_id, xc_polarized, force_host=.true.)
521 xc_info = xc_f03_func_get_info(xc_func)
522
523 s1 = xc_f03_func_info_get_name(xc_info)
524 SELECT CASE (xc_f03_func_info_get_kind(xc_info))
525 CASE (xc_exchange); WRITE (s2, '(a)') "exchange"
526 CASE (xc_correlation); WRITE (s2, '(a)') "correlation"
527 CASE (xc_exchange_correlation); WRITE (s2, '(a)') "exchange-correlation"
528 CASE (xc_kinetic); WRITE (s2, '(a)') "kinetic"
529 CASE default
530 cpabort(trim(func_name)//": this XC_KIND is currently not supported.")
531 END SELECT
532 IF (PRESENT(shortform)) THEN
533 shortform = trim(s1)//' ('//trim(s2)//')'
534 END IF
535 IF (PRESENT(reference)) THEN
536 CALL xc_libxc_wrap_info_refs(xc_info, xc_polarized, func_scale, reference)
537 END IF
538 IF (PRESENT(needs)) THEN
539 SELECT CASE (xc_f03_func_info_get_family(xc_info))
540 CASE (xc_family_lda, xc_family_hyb_lda)
541 needs%rho_spin = .true.
542 CASE (xc_family_gga, xc_family_hyb_gga)
543 needs%rho_spin = .true.
544 needs%norm_drho = .true.
545 needs%norm_drho_spin = .true.
546 CASE (xc_family_mgga, xc_family_hyb_mgga)
547 needs%rho_spin = .true.
548 needs%norm_drho = .true.
549 needs%norm_drho_spin = .true.
550 needs%tau_spin = .true.
551 needs%laplace_rho_spin = xc_libxc_wrap_info_needs_laplace(xc_info)
552 CASE default
553 cpabort(trim(func_name)//": this XC_FAMILY is currently not supported.")
554 END SELECT
555 END IF
556 IF (PRESENT(max_deriv)) THEN
557 SELECT CASE (xc_f03_func_info_get_family(xc_info))
558 CASE (xc_family_lda, xc_family_hyb_lda)
559 max_deriv = 3
560 CASE (xc_family_gga, xc_family_hyb_gga)
561 max_deriv = 2
562 CASE (xc_family_mgga, xc_family_hyb_mgga)
563 max_deriv = 2
564 CASE default
565 cpabort(trim(func_name)//": this XC_FAMILY is currently not supported.")
566 END SELECT
567 END IF
568 IF (PRESENT(print_warn)) THEN
569 IF (print_warn .AND. xc_libxc_wrap_is_under_development(xc_info)) THEN
570 cpwarn(trim(func_name)//" is under development. Use with caution.")
571 END IF
572 END IF
573
574 CALL xc_f03_func_end(xc_func)
575#else
576 mark_used(libxc_params)
577 mark_used(reference)
578 mark_used(shortform)
579 mark_used(needs)
580 mark_used(max_deriv)
581 mark_used(print_warn)
582 mark_used(func_name_override)
583
584 CALL cp_abort(__location__, "Unknown functional! If you are "// &
585 "asking for a functional of the LibXC library, "// &
586 "you have to download and install the library!")
587#endif
588
589 END SUBROUTINE libxc_spin_polarized_info
590
591! **************************************************************************************************
592!> \brief info about the LibXC version
593!> \param version version string reported by the library at run time
594!> \param compiled_version version of the LibXC headers CP2K was compiled against
595!> \author A. Gloess (agloess)
596! **************************************************************************************************
597 SUBROUTINE libxc_version_info(version, compiled_version)
598 CHARACTER(LEN=*), INTENT(OUT) :: version ! the string that is output
599 CHARACTER(LEN=*), INTENT(OUT), OPTIONAL :: compiled_version
600
601#if defined (__LIBXC)
602 CALL xc_libxc_wrap_version(version, compiled_version)
603#else
604 version = "none"
605 IF (PRESENT(compiled_version)) compiled_version = "none"
606 cpabort("In order to use libxc you need to download and install it")
607#endif
608
609 END SUBROUTINE libxc_version_info
610
611! **************************************************************************************************
612!> \brief Returns the citation LibXC asks for the library itself.
613!> \param reference bibliographic reference
614!> \param doi digital object identifier of that reference
615!> \author S. Lehtola
616! **************************************************************************************************
617 SUBROUTINE libxc_library_reference(reference, doi)
618 CHARACTER(LEN=*), INTENT(OUT) :: reference, doi
619
620#if defined (__LIBXC)
621 CALL xc_libxc_wrap_library_reference(reference, doi)
622#else
623 reference = "none"
624 doi = "none"
625 cpabort("In order to use libxc you need to download and install it")
626#endif
627
628 END SUBROUTINE libxc_library_reference
629
630! **************************************************************************************************
631!> \brief Reads the external parameters of a LibXC functional from its input section.
632!> \param libxc_params LibXC input section
633!> \param param_names names of the external parameters, as reported by LibXC
634!> \param params values read from the input
635!> \author S. Lehtola
636! **************************************************************************************************
637#if defined (__LIBXC)
638 SUBROUTINE libxc_read_params(libxc_params, param_names, params)
639 TYPE(section_vals_type), INTENT(IN), POINTER :: libxc_params
640 CHARACTER(LEN=128), DIMENSION(:), INTENT(IN) :: param_names
641 REAL(kind=dp), DIMENSION(:), INTENT(OUT) :: params
642
643 INTEGER :: i
644
645 DO i = 1, SIZE(param_names)
646 CALL section_vals_val_get(libxc_params, trim(param_names(i)), r_val=params(i))
647 END DO
648
649 END SUBROUTINE libxc_read_params
650
651! **************************************************************************************************
652!> \brief Makes sure the placeholder for unproduced derivatives holds npoints values.
653!> \param npoints number of grid points in this evaluation
654!> \author S. Lehtola
655! **************************************************************************************************
656 SUBROUTINE libxc_reserve_unused(npoints)
657 INTEGER, INTENT(IN) :: npoints
658
659 IF (ALLOCATED(libxc_unused)) THEN
660 IF (SIZE(libxc_unused) >= npoints) RETURN
661 DEALLOCATE (libxc_unused)
662 END IF
663 ALLOCATE (libxc_unused(npoints))
664
665 END SUBROUTINE libxc_reserve_unused
666
667! **************************************************************************************************
668!> \brief Returns the cache slot holding the per-thread workers for a functional.
669!> \param func_name LibXC functional name
670!> \param nspin XC_UNPOLARIZED or XC_POLARIZED
671!> \param libxc_params LibXC input section, or null when no parameters are to be set
672!> \param epsilon_rho density cutoff
673!> \param epsilon_tau kinetic energy density cutoff
674!> \param grad_deriv highest derivative order this evaluation needs
675!> \return index into libxc_cache
676!> \author S. Lehtola
677!> \note Must be called from a serial region: it is the only writer of the cache,
678!> and keeping it serial is what makes the cache lock-free. The workers it
679!> returns are then used concurrently, one per thread.
680! **************************************************************************************************
681 FUNCTION libxc_get_workers(func_name, nspin, libxc_params, epsilon_rho, epsilon_tau, &
682 grad_deriv) RESULT(idx)
683 CHARACTER(LEN=*), INTENT(IN) :: func_name
684 INTEGER, INTENT(IN) :: nspin
685 TYPE(section_vals_type), INTENT(IN), POINTER :: libxc_params
686 REAL(kind=dp), INTENT(IN) :: epsilon_rho, epsilon_tau
687 INTEGER, INTENT(IN) :: grad_deriv
688 INTEGER :: idx
689
690 CHARACTER(LEN=*), PARAMETER :: routinen = 'libxc_get_workers'
691
692 INTEGER :: func_id, handle, i, ithread, n_params, &
693 nthreads
694 LOGICAL :: has_params
695 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: params
696 TYPE(libxc_worker_set_type), ALLOCATABLE, &
697 DIMENSION(:) :: tmp_cache
698
699 CALL timeset(routinen, handle)
700
701 func_id = xc_libxc_wrap_functional_get_number(func_name)
702 has_params = ASSOCIATED(libxc_params)
703
704 nthreads = 1
705!$ nthreads = omp_get_max_threads()
706
707 IF (.NOT. ALLOCATED(libxc_cache)) ALLOCATE (libxc_cache(0))
708
709 idx = 0
710 DO i = 1, SIZE(libxc_cache)
711 IF (libxc_cache(i)%func_id == func_id .AND. &
712 libxc_cache(i)%nspin == nspin .AND. &
713 (libxc_cache(i)%has_params .EQV. has_params)) THEN
714 IF (libxc_cache(i)%epsilon_rho == epsilon_rho .AND. &
715 libxc_cache(i)%epsilon_tau == epsilon_tau .AND. &
716 SIZE(libxc_cache(i)%worker) >= nthreads) THEN
717 idx = i
718 EXIT
719 END IF
720 END IF
721 END DO
722
723 ! A set built for a lower derivative order carries buffers that are too
724 ! narrow for this call. Widening them in place keeps one set per functional
725 ! setup: the SCF fills the cache at first order and a later response
726 ! calculation grows that same slot to third order.
727 IF (idx /= 0) THEN
728 IF (libxc_cache(idx)%grad_deriv < grad_deriv) THEN
729 DO ithread = 1, SIZE(libxc_cache(idx)%worker)
730 CALL libxc_worker_free_buffers(libxc_cache(idx)%worker(ithread))
731 CALL libxc_worker_alloc(libxc_cache(idx)%worker(ithread), &
732 libxc_cache(idx)%family, nspin, grad_deriv)
733 END DO
734 libxc_cache(idx)%grad_deriv = grad_deriv
735 END IF
736 END IF
737
738 IF (idx == 0) THEN
739 ! Grow the cache by one slot and build the workers for it.
740 CALL move_alloc(libxc_cache, tmp_cache)
741 ALLOCATE (libxc_cache(SIZE(tmp_cache) + 1))
742 DO i = 1, SIZE(tmp_cache)
743 CALL libxc_move_worker_set(tmp_cache(i), libxc_cache(i))
744 END DO
745 DEALLOCATE (tmp_cache)
746 idx = SIZE(libxc_cache)
747
748 associate(ws => libxc_cache(idx))
749 ws%func_id = func_id
750 ws%nspin = nspin
751 ws%has_params = has_params
752 ws%epsilon_rho = epsilon_rho
753 ws%epsilon_tau = epsilon_tau
754 ws%grad_deriv = grad_deriv
755 ALLOCATE (ws%worker(nthreads))
756
757 DO ithread = 1, nthreads
758 CALL libxc_func_init_wrapper(ws%worker(ithread)%func, func_id, nspin)
759 ws%worker(ithread)%info = xc_f03_func_get_info(ws%worker(ithread)%func)
760 ws%worker(ithread)%is_init = .true.
761 END DO
762
763 ws%family = xc_f03_func_info_get_family(ws%worker(1)%info)
764 ws%has_laplace = xc_libxc_wrap_info_needs_laplace(ws%worker(1)%info)
765 ws%no_exc = xc_libxc_wrap_info_no_exc(ws%worker(1)%info)
766
767 ! Remember the parameter names so that later evaluations can re-read
768 ! the input without another functional object to ask for them.
769 n_params = 0
770 IF (has_params) n_params = xc_f03_func_info_get_n_ext_params(ws%worker(1)%info)
771 ALLOCATE (ws%params(n_params))
772 ALLOCATE (ws%param_names(n_params))
773 DO i = 1, n_params
774 ws%param_names(i) = xc_f03_func_info_get_ext_params_name(ws%worker(1)%info, i - 1)
775 END DO
776 IF (n_params > 0) THEN
777 CALL libxc_read_params(libxc_params, ws%param_names, ws%params)
778 DO ithread = 1, nthreads
779 CALL xc_f03_func_set_ext_params(ws%worker(ithread)%func, ws%params)
780 END DO
781 END IF
782
783 DO ithread = 1, nthreads
784 CALL xc_libxc_wrap_set_thresholds(ws%worker(ithread)%func, ws%worker(ithread)%info, &
785 epsilon_rho, epsilon_tau)
786 CALL libxc_worker_alloc(ws%worker(ithread), ws%family, nspin, grad_deriv)
787 END DO
788 END associate
789 ELSE
790 ! Cached slot: the input section may in principle carry different
791 ! parameter values than the ones the workers were last set up with, so
792 ! re-read them and push them through only when they actually changed.
793 associate(ws => libxc_cache(idx))
794 n_params = SIZE(ws%params)
795 IF (n_params > 0) THEN
796 ALLOCATE (params(n_params))
797 CALL libxc_read_params(libxc_params, ws%param_names, params)
798 IF (any(params /= ws%params)) THEN
799 ws%params(:) = params(:)
800 DO ithread = 1, SIZE(ws%worker)
801 CALL xc_f03_func_set_ext_params(ws%worker(ithread)%func, ws%params)
802 ! re-assert the cutoffs: setting parameters runs the
803 ! functional's own callback, which is free to rebuild the
804 ! component functionals a mixed functional is made of
805 CALL xc_libxc_wrap_set_thresholds(ws%worker(ithread)%func, &
806 ws%worker(ithread)%info, &
807 ws%epsilon_rho, ws%epsilon_tau)
808 END DO
809 END IF
810 DEALLOCATE (params)
811 END IF
812 END associate
813 END IF
814
815 CALL timestop(handle)
816
817 END FUNCTION libxc_get_workers
818
819! **************************************************************************************************
820!> \brief Moves a worker set to a new cache slot without touching LibXC.
821!> \param from source slot, left empty
822!> \param to destination slot
823!> \author S. Lehtola
824!> \note Used when the cache array grows. The LibXC objects are opaque handles, so
825!> they survive being moved; only the Fortran allocatables need transferring.
826! **************************************************************************************************
827 SUBROUTINE libxc_move_worker_set(from, to)
828 TYPE(libxc_worker_set_type), INTENT(INOUT) :: from, to
829
830 to%func_id = from%func_id
831 to%nspin = from%nspin
832 to%family = from%family
833 to%grad_deriv = from%grad_deriv
834 to%has_laplace = from%has_laplace
835 to%no_exc = from%no_exc
836 to%has_params = from%has_params
837 to%epsilon_rho = from%epsilon_rho
838 to%epsilon_tau = from%epsilon_tau
839 IF (ALLOCATED(from%params)) CALL move_alloc(from%params, to%params)
840 IF (ALLOCATED(from%param_names)) CALL move_alloc(from%param_names, to%param_names)
841 IF (ALLOCATED(from%worker)) CALL move_alloc(from%worker, to%worker)
842
843 END SUBROUTINE libxc_move_worker_set
844#endif
845
846! **************************************************************************************************
847!> \brief Destroys all cached LibXC functional objects.
848!> \author S. Lehtola
849!> \note Call once at the end of a run. The workers are deliberately kept alive
850!> across SCF steps and across calculations, so nothing else releases them.
851! **************************************************************************************************
853
854#if defined (__LIBXC)
855 INTEGER :: i, ithread
856
857 IF (.NOT. ALLOCATED(libxc_cache)) RETURN
858
859 DO i = 1, SIZE(libxc_cache)
860 IF (.NOT. ALLOCATED(libxc_cache(i)%worker)) cycle
861 DO ithread = 1, SIZE(libxc_cache(i)%worker)
862 IF (libxc_cache(i)%worker(ithread)%is_init) THEN
863 CALL xc_f03_func_end(libxc_cache(i)%worker(ithread)%func)
864 libxc_cache(i)%worker(ithread)%is_init = .false.
865 END IF
866 ! Free the staging buffers and any device buffers they mirror.
867 CALL libxc_worker_free_buffers(libxc_cache(i)%worker(ithread))
868 END DO
869 END DO
870 DEALLOCATE (libxc_cache)
871 IF (ALLOCATED(libxc_unused)) DEALLOCATE (libxc_unused)
872#endif
873
874 END SUBROUTINE libxc_release_workers
875
876! **************************************************************************************************
877!> \brief evaluates the functional from libxc
878!> \param rho_set the density where you want to evaluate the functional
879!> \param deriv_set place where to store the functional derivatives (they are
880!> added to the derivatives)
881!> \param grad_deriv maximum degree of the derivative that should be evaluated;
882!> all derivatives up to the given degree are evaluated, in a single
883!> LibXC call per block of grid points
884!> \param libxc_params input parameter (functional name, scaling and parameters)
885!> \param func_name_override optional LibXC functional name overriding the section name
886!> \author F. Tran
887! **************************************************************************************************
888 SUBROUTINE libxc_spin_unpolarized_eval(rho_set, deriv_set, grad_deriv, libxc_params, func_name_override)
889
890 TYPE(xc_rho_set_type), INTENT(IN) :: rho_set
891 TYPE(xc_derivative_set_type), INTENT(IN) :: deriv_set
892 INTEGER, INTENT(IN) :: grad_deriv
893 TYPE(section_vals_type), POINTER :: libxc_params
894 CHARACTER(LEN=*), INTENT(IN), OPTIONAL :: func_name_override
895
896#if defined (__LIBXC)
897 CHARACTER(LEN=*), PARAMETER :: routinen = 'libxc_spin_unpolarized_eval'
898
899 CHARACTER(LEN=default_string_length) :: func_name
900 INTEGER :: handle, iw, npoints
901 INTEGER, DIMENSION(2, 3) :: bo
902 LOGICAL :: has_laplace
903 REAL(kind=dp) :: epsilon_rho, epsilon_tau, func_scale
904 TYPE(libxc_worker_set_type), POINTER :: workers
905 TYPE(section_vals_type), POINTER :: no_params
906 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: dummy, e_0, e_laplace_rho, &
907 e_laplace_rho_laplace_rho, e_laplace_rho_tau, e_ndrho, &
908 e_ndrho_laplace_rho, e_ndrho_ndrho, e_ndrho_rho, e_ndrho_tau, e_rho, &
909 e_rho_laplace_rho, e_rho_rho, e_rho_rho_rho, e_rho_tau, e_tau, &
910 e_tau_tau, laplace_rho, norm_drho, rho, tau
911 ! derivatives w.r.t. the reduced gradient gamma = |grad rho|^2
912 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma
913 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rho_gamma
914 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_gamma
915 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_laplace_rho
916 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_tau
917 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rho_rho_gamma
918 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rho_rho_laplace_rho
919 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rho_rho_tau
920 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rho_gamma_gamma
921 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rho_gamma_laplace_rho
922 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rho_gamma_tau
923 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rho_laplace_rho_laplace_rho
924 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rho_laplace_rho_tau
925 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rho_tau_tau
926 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_gamma_gamma
927 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_gamma_laplace_rho
928 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_gamma_tau
929 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_laplace_rho_laplace_rho
930 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_laplace_rho_tau
931 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_tau_tau
932 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_laplace_rho_laplace_rho_laplace_rho
933 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_laplace_rho_laplace_rho_tau
934 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_laplace_rho_tau_tau
935 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_tau_tau_tau
936 TYPE(xc_derivative_type), POINTER :: deriv
937 TYPE(xc_f03_func_info_t) :: xc_info
938
939 CALL timeset(routinen, handle)
940
941 ! Only "everything up to grad_deriv" is supported. Asking for a single
942 ! derivative order in isolation is rejected here rather than further down,
943 ! where it would quietly evaluate nothing at all.
944 IF (grad_deriv > 3) THEN
945 cpabort("derivatives larger than 3 not implemented")
946 END IF
947
948 has_laplace = .false.
949 NULLIFY (dummy)
950 NULLIFY (workers)
951 NULLIFY (rho, norm_drho, laplace_rho, tau)
952
953 IF (PRESENT(func_name_override)) THEN
954 func_name = func_name_override
955 func_scale = 1.0_dp
956 ELSE
957 func_name = libxc_params%section%name
958 CALL section_vals_val_get(libxc_params, "scale", r_val=func_scale)
959 END IF
960
961 IF (abs(func_scale - 1.0_dp) < 1.0e-10_dp) func_scale = 1.0_dp
962
963 CALL xc_rho_set_get(rho_set, can_return_null=.true., &
964 rho=rho, norm_drho=norm_drho, laplace_rho=laplace_rho, &
965 rho_cutoff=epsilon_rho, tau_cutoff=epsilon_tau, &
966 tau=tau, local_bounds=bo)
967
968 npoints = (bo(2, 1) - bo(1, 1) + 1)*(bo(2, 2) - bo(1, 2) + 1)*(bo(2, 3) - bo(1, 3) + 1)
969
970 ! One functional object per thread, kept across calls. The cutoffs are part
971 ! of the worker setup because LibXC does the screening itself.
972 IF (PRESENT(func_name_override)) THEN
973 ! an overriding name carries no input section, so no parameters are set
974 NULLIFY (no_params)
975 iw = libxc_get_workers(func_name, xc_unpolarized, no_params, epsilon_rho, epsilon_tau, &
976 grad_deriv)
977 ELSE
978 iw = libxc_get_workers(func_name, xc_unpolarized, libxc_params, epsilon_rho, epsilon_tau, &
979 grad_deriv)
980 END IF
981 workers => libxc_cache(iw)
982 xc_info = workers%worker(1)%info
983 has_laplace = workers%has_laplace
984
985 ! see libxc_unused: the arguments the requested order does not produce are
986 ! never touched, but they still have to point somewhere
987 CALL libxc_reserve_unused(npoints)
988 dummy(bo(1, 1):bo(2, 1), bo(1, 2):bo(2, 2), bo(1, 3):bo(2, 3)) => libxc_unused(1:npoints)
989
990 ! due to assumed shape array usage in next routine
991 IF (.NOT. ASSOCIATED(norm_drho)) norm_drho => rho
992 IF (.NOT. ASSOCIATED(tau)) tau => rho
993
994 ! only some MGGA functionals really need the Laplacian,
995 ! all others can work with rho (read-only) as dummy
996 IF (.NOT. has_laplace) laplace_rho => rho
997
998 e_0 => dummy
999 e_rho => dummy
1000 e_ndrho => dummy
1001 e_laplace_rho => dummy
1002 e_tau => dummy
1003 e_rho_rho => dummy
1004 e_ndrho_rho => dummy
1005 e_ndrho_ndrho => dummy
1006 e_rho_laplace_rho => dummy
1007 e_rho_tau => dummy
1008 e_ndrho_laplace_rho => dummy
1009 e_ndrho_tau => dummy
1010 e_laplace_rho_laplace_rho => dummy
1011 e_laplace_rho_tau => dummy
1012 e_tau_tau => dummy
1013 e_rho_rho_rho => dummy
1014 e_gamma => dummy
1015 e_rho_gamma => dummy
1016 e_gamma_gamma => dummy
1017 e_gamma_laplace_rho => dummy
1018 e_gamma_tau => dummy
1019 e_rho_rho_gamma => dummy
1020 e_rho_rho_laplace_rho => dummy
1021 e_rho_rho_tau => dummy
1022 e_rho_gamma_gamma => dummy
1023 e_rho_gamma_laplace_rho => dummy
1024 e_rho_gamma_tau => dummy
1025 e_rho_laplace_rho_laplace_rho => dummy
1026 e_rho_laplace_rho_tau => dummy
1027 e_rho_tau_tau => dummy
1028 e_gamma_gamma_gamma => dummy
1029 e_gamma_gamma_laplace_rho => dummy
1030 e_gamma_gamma_tau => dummy
1031 e_gamma_laplace_rho_laplace_rho => dummy
1032 e_gamma_laplace_rho_tau => dummy
1033 e_gamma_tau_tau => dummy
1034 e_laplace_rho_laplace_rho_laplace_rho => dummy
1035 e_laplace_rho_laplace_rho_tau => dummy
1036 e_laplace_rho_tau_tau => dummy
1037 e_tau_tau_tau => dummy
1038
1039 deriv => xc_dset_get_derivative(deriv_set, [INTEGER::], &
1040 allocate_deriv=.true.)
1041 CALL xc_derivative_get(deriv, deriv_data=e_0)
1042 IF (grad_deriv >= 1) THEN
1043 SELECT CASE (xc_f03_func_info_get_family(xc_info))
1044 CASE (xc_family_lda, xc_family_hyb_lda)
1045 deriv => xc_dset_get_derivative(deriv_set, [deriv_rho], &
1046 allocate_deriv=.true.)
1047 CALL xc_derivative_get(deriv, deriv_data=e_rho)
1048 CASE (xc_family_gga, xc_family_hyb_gga)
1049 deriv => xc_dset_get_derivative(deriv_set, [deriv_rho], &
1050 allocate_deriv=.true.)
1051 CALL xc_derivative_get(deriv, deriv_data=e_rho)
1052 deriv => xc_dset_get_derivative(deriv_set, [deriv_norm_drho], &
1053 allocate_deriv=.true.)
1054 CALL xc_derivative_get(deriv, deriv_data=e_ndrho)
1055 deriv => xc_dset_get_derivative(deriv_set, &
1056 [deriv_gamma], &
1057 allocate_deriv=.true.)
1058 CALL xc_derivative_get(deriv, deriv_data=e_gamma)
1059 CASE (xc_family_mgga, xc_family_hyb_mgga)
1060 deriv => xc_dset_get_derivative(deriv_set, [deriv_rho], &
1061 allocate_deriv=.true.)
1062 CALL xc_derivative_get(deriv, deriv_data=e_rho)
1063 deriv => xc_dset_get_derivative(deriv_set, [deriv_norm_drho], &
1064 allocate_deriv=.true.)
1065 CALL xc_derivative_get(deriv, deriv_data=e_ndrho)
1066 deriv => xc_dset_get_derivative(deriv_set, &
1067 [deriv_gamma], &
1068 allocate_deriv=.true.)
1069 CALL xc_derivative_get(deriv, deriv_data=e_gamma)
1070 deriv => xc_dset_get_derivative(deriv_set, [deriv_tau], &
1071 allocate_deriv=.true.)
1072 CALL xc_derivative_get(deriv, deriv_data=e_tau)
1073 IF (has_laplace) THEN
1074 deriv => xc_dset_get_derivative(deriv_set, [deriv_laplace_rho], &
1075 allocate_deriv=.true.)
1076 CALL xc_derivative_get(deriv, deriv_data=e_laplace_rho)
1077 END IF
1078 CASE default
1079 cpabort(trim(func_name)//": this XC_FAMILY is currently not supported.")
1080 END SELECT
1081 END IF
1082 IF (grad_deriv >= 2) THEN
1083 SELECT CASE (xc_f03_func_info_get_family(xc_info))
1084 CASE (xc_family_lda, xc_family_hyb_lda)
1085 deriv => xc_dset_get_derivative(deriv_set, [deriv_rho, deriv_rho], &
1086 allocate_deriv=.true.)
1087 CALL xc_derivative_get(deriv, deriv_data=e_rho_rho)
1088 CASE (xc_family_gga, xc_family_hyb_gga)
1089 deriv => xc_dset_get_derivative(deriv_set, [deriv_rho, deriv_rho], &
1090 allocate_deriv=.true.)
1091 CALL xc_derivative_get(deriv, deriv_data=e_rho_rho)
1092 deriv => xc_dset_get_derivative(deriv_set, [deriv_norm_drho, deriv_rho], &
1093 allocate_deriv=.true.)
1094 CALL xc_derivative_get(deriv, deriv_data=e_ndrho_rho)
1095 deriv => xc_dset_get_derivative(deriv_set, [deriv_norm_drho, deriv_norm_drho], &
1096 allocate_deriv=.true.)
1097 CALL xc_derivative_get(deriv, deriv_data=e_ndrho_ndrho)
1098 deriv => xc_dset_get_derivative(deriv_set, &
1099 [deriv_rho, deriv_gamma], &
1100 allocate_deriv=.true.)
1101 CALL xc_derivative_get(deriv, deriv_data=e_rho_gamma)
1102 deriv => xc_dset_get_derivative(deriv_set, &
1103 [deriv_gamma, deriv_gamma], &
1104 allocate_deriv=.true.)
1105 CALL xc_derivative_get(deriv, deriv_data=e_gamma_gamma)
1106 CASE (xc_family_mgga, xc_family_hyb_mgga)
1107 ! not implemented ...
1108
1109 deriv => xc_dset_get_derivative(deriv_set, [deriv_rho, deriv_rho], &
1110 allocate_deriv=.true.)
1111 CALL xc_derivative_get(deriv, deriv_data=e_rho_rho)
1112 deriv => xc_dset_get_derivative(deriv_set, [deriv_norm_drho, deriv_rho], &
1113 allocate_deriv=.true.)
1114 CALL xc_derivative_get(deriv, deriv_data=e_ndrho_rho)
1115 deriv => xc_dset_get_derivative(deriv_set, [deriv_norm_drho, deriv_norm_drho], &
1116 allocate_deriv=.true.)
1117 CALL xc_derivative_get(deriv, deriv_data=e_ndrho_ndrho)
1118 deriv => xc_dset_get_derivative(deriv_set, &
1119 [deriv_rho, deriv_gamma], &
1120 allocate_deriv=.true.)
1121 CALL xc_derivative_get(deriv, deriv_data=e_rho_gamma)
1122 deriv => xc_dset_get_derivative(deriv_set, &
1123 [deriv_gamma, deriv_gamma], &
1124 allocate_deriv=.true.)
1125 CALL xc_derivative_get(deriv, deriv_data=e_gamma_gamma)
1126 deriv => xc_dset_get_derivative(deriv_set, [deriv_rho, deriv_tau], &
1127 allocate_deriv=.true.)
1128 CALL xc_derivative_get(deriv, deriv_data=e_rho_tau)
1129 deriv => xc_dset_get_derivative(deriv_set, [deriv_norm_drho, deriv_tau], &
1130 allocate_deriv=.true.)
1131 CALL xc_derivative_get(deriv, deriv_data=e_ndrho_tau)
1132 deriv => xc_dset_get_derivative(deriv_set, [deriv_tau, deriv_tau], &
1133 allocate_deriv=.true.)
1134 CALL xc_derivative_get(deriv, deriv_data=e_tau_tau)
1135 deriv => xc_dset_get_derivative(deriv_set, &
1136 [deriv_gamma, deriv_tau], &
1137 allocate_deriv=.true.)
1138 CALL xc_derivative_get(deriv, deriv_data=e_gamma_tau)
1139 IF (has_laplace) THEN
1140 deriv => xc_dset_get_derivative(deriv_set, [deriv_rho, deriv_laplace_rho], &
1141 allocate_deriv=.true.)
1142 CALL xc_derivative_get(deriv, deriv_data=e_rho_laplace_rho)
1143 deriv => xc_dset_get_derivative(deriv_set, [deriv_norm_drho, deriv_laplace_rho], &
1144 allocate_deriv=.true.)
1145 CALL xc_derivative_get(deriv, deriv_data=e_ndrho_laplace_rho)
1146 deriv => xc_dset_get_derivative(deriv_set, [deriv_laplace_rho, deriv_laplace_rho], &
1147 allocate_deriv=.true.)
1148 CALL xc_derivative_get(deriv, deriv_data=e_laplace_rho_laplace_rho)
1149 deriv => xc_dset_get_derivative(deriv_set, [deriv_laplace_rho, deriv_tau], &
1150 allocate_deriv=.true.)
1151 CALL xc_derivative_get(deriv, deriv_data=e_laplace_rho_tau)
1152 END IF
1153 CASE default
1154 cpabort(trim(func_name)//": this XC_FAMILY is currently not supported.")
1155 END SELECT
1156 END IF
1157 IF (grad_deriv >= 3) THEN
1158 SELECT CASE (xc_f03_func_info_get_family(xc_info))
1159 CASE (xc_family_lda, xc_family_hyb_lda)
1160 IF (has_laplace) THEN
1161 deriv => xc_dset_get_derivative(deriv_set, &
1162 [deriv_rho, deriv_rho, deriv_laplace_rho], &
1163 allocate_deriv=.true.)
1164 CALL xc_derivative_get(deriv, deriv_data=e_rho_rho_laplace_rho)
1165 deriv => xc_dset_get_derivative(deriv_set, &
1166 [deriv_rho, deriv_gamma, deriv_laplace_rho], &
1167 allocate_deriv=.true.)
1168 CALL xc_derivative_get(deriv, deriv_data=e_rho_gamma_laplace_rho)
1169 deriv => xc_dset_get_derivative(deriv_set, &
1170 [deriv_rho, deriv_laplace_rho, deriv_laplace_rho], &
1171 allocate_deriv=.true.)
1172 CALL xc_derivative_get(deriv, deriv_data=e_rho_laplace_rho_laplace_rho)
1173 deriv => xc_dset_get_derivative(deriv_set, &
1174 [deriv_rho, deriv_laplace_rho, deriv_tau], &
1175 allocate_deriv=.true.)
1176 CALL xc_derivative_get(deriv, deriv_data=e_rho_laplace_rho_tau)
1177 deriv => xc_dset_get_derivative(deriv_set, &
1178 [deriv_gamma, deriv_gamma, deriv_laplace_rho], &
1179 allocate_deriv=.true.)
1180 CALL xc_derivative_get(deriv, deriv_data=e_gamma_gamma_laplace_rho)
1181 deriv => xc_dset_get_derivative(deriv_set, &
1182 [deriv_gamma, deriv_laplace_rho, deriv_laplace_rho], &
1183 allocate_deriv=.true.)
1184 CALL xc_derivative_get(deriv, deriv_data=e_gamma_laplace_rho_laplace_rho)
1185 deriv => xc_dset_get_derivative(deriv_set, &
1186 [deriv_gamma, deriv_laplace_rho, deriv_tau], &
1187 allocate_deriv=.true.)
1188 CALL xc_derivative_get(deriv, deriv_data=e_gamma_laplace_rho_tau)
1189 deriv => xc_dset_get_derivative(deriv_set, &
1190 [deriv_laplace_rho, deriv_laplace_rho, deriv_laplace_rho], &
1191 allocate_deriv=.true.)
1192 CALL xc_derivative_get(deriv, deriv_data=e_laplace_rho_laplace_rho_laplace_rho)
1193 deriv => xc_dset_get_derivative(deriv_set, &
1194 [deriv_laplace_rho, deriv_laplace_rho, deriv_tau], &
1195 allocate_deriv=.true.)
1196 CALL xc_derivative_get(deriv, deriv_data=e_laplace_rho_laplace_rho_tau)
1197 deriv => xc_dset_get_derivative(deriv_set, &
1198 [deriv_laplace_rho, deriv_tau, deriv_tau], &
1199 allocate_deriv=.true.)
1200 CALL xc_derivative_get(deriv, deriv_data=e_laplace_rho_tau_tau)
1201 END IF
1202 deriv => xc_dset_get_derivative(deriv_set, [deriv_rho, deriv_rho, deriv_rho], &
1203 allocate_deriv=.true.)
1204 CALL xc_derivative_get(deriv, deriv_data=e_rho_rho_rho)
1205 CASE (xc_family_gga, xc_family_hyb_gga)
1206 IF (has_laplace) THEN
1207 deriv => xc_dset_get_derivative(deriv_set, &
1208 [deriv_rho, deriv_rho, deriv_laplace_rho], &
1209 allocate_deriv=.true.)
1210 CALL xc_derivative_get(deriv, deriv_data=e_rho_rho_laplace_rho)
1211 deriv => xc_dset_get_derivative(deriv_set, &
1212 [deriv_rho, deriv_gamma, deriv_laplace_rho], &
1213 allocate_deriv=.true.)
1214 CALL xc_derivative_get(deriv, deriv_data=e_rho_gamma_laplace_rho)
1215 deriv => xc_dset_get_derivative(deriv_set, &
1216 [deriv_rho, deriv_laplace_rho, deriv_laplace_rho], &
1217 allocate_deriv=.true.)
1218 CALL xc_derivative_get(deriv, deriv_data=e_rho_laplace_rho_laplace_rho)
1219 deriv => xc_dset_get_derivative(deriv_set, &
1220 [deriv_rho, deriv_laplace_rho, deriv_tau], &
1221 allocate_deriv=.true.)
1222 CALL xc_derivative_get(deriv, deriv_data=e_rho_laplace_rho_tau)
1223 deriv => xc_dset_get_derivative(deriv_set, &
1224 [deriv_gamma, deriv_gamma, deriv_laplace_rho], &
1225 allocate_deriv=.true.)
1226 CALL xc_derivative_get(deriv, deriv_data=e_gamma_gamma_laplace_rho)
1227 deriv => xc_dset_get_derivative(deriv_set, &
1228 [deriv_gamma, deriv_laplace_rho, deriv_laplace_rho], &
1229 allocate_deriv=.true.)
1230 CALL xc_derivative_get(deriv, deriv_data=e_gamma_laplace_rho_laplace_rho)
1231 deriv => xc_dset_get_derivative(deriv_set, &
1232 [deriv_gamma, deriv_laplace_rho, deriv_tau], &
1233 allocate_deriv=.true.)
1234 CALL xc_derivative_get(deriv, deriv_data=e_gamma_laplace_rho_tau)
1235 deriv => xc_dset_get_derivative(deriv_set, &
1236 [deriv_laplace_rho, deriv_laplace_rho, deriv_laplace_rho], &
1237 allocate_deriv=.true.)
1238 CALL xc_derivative_get(deriv, deriv_data=e_laplace_rho_laplace_rho_laplace_rho)
1239 deriv => xc_dset_get_derivative(deriv_set, &
1240 [deriv_laplace_rho, deriv_laplace_rho, deriv_tau], &
1241 allocate_deriv=.true.)
1242 CALL xc_derivative_get(deriv, deriv_data=e_laplace_rho_laplace_rho_tau)
1243 deriv => xc_dset_get_derivative(deriv_set, &
1244 [deriv_laplace_rho, deriv_tau, deriv_tau], &
1245 allocate_deriv=.true.)
1246 CALL xc_derivative_get(deriv, deriv_data=e_laplace_rho_tau_tau)
1247 END IF
1248 deriv => xc_dset_get_derivative(deriv_set, [deriv_rho, deriv_rho, deriv_rho], &
1249 allocate_deriv=.true.)
1250 CALL xc_derivative_get(deriv, deriv_data=e_rho_rho_rho)
1251 deriv => xc_dset_get_derivative(deriv_set, [deriv_rho, deriv_rho, deriv_gamma], &
1252 allocate_deriv=.true.)
1253 CALL xc_derivative_get(deriv, deriv_data=e_rho_rho_gamma)
1254 deriv => xc_dset_get_derivative(deriv_set, [deriv_rho, deriv_gamma, deriv_gamma], &
1255 allocate_deriv=.true.)
1256 CALL xc_derivative_get(deriv, deriv_data=e_rho_gamma_gamma)
1257 deriv => xc_dset_get_derivative(deriv_set, [deriv_gamma, deriv_gamma, deriv_gamma], &
1258 allocate_deriv=.true.)
1259 CALL xc_derivative_get(deriv, deriv_data=e_gamma_gamma_gamma)
1260 CASE (xc_family_mgga, xc_family_hyb_mgga)
1261 deriv => xc_dset_get_derivative(deriv_set, &
1262 [deriv_rho, deriv_rho, deriv_gamma], &
1263 allocate_deriv=.true.)
1264 CALL xc_derivative_get(deriv, deriv_data=e_rho_rho_gamma)
1265 deriv => xc_dset_get_derivative(deriv_set, &
1266 [deriv_rho, deriv_rho, deriv_tau], &
1267 allocate_deriv=.true.)
1268 CALL xc_derivative_get(deriv, deriv_data=e_rho_rho_tau)
1269 deriv => xc_dset_get_derivative(deriv_set, &
1270 [deriv_rho, deriv_gamma, deriv_gamma], &
1271 allocate_deriv=.true.)
1272 CALL xc_derivative_get(deriv, deriv_data=e_rho_gamma_gamma)
1273 deriv => xc_dset_get_derivative(deriv_set, &
1274 [deriv_rho, deriv_gamma, deriv_tau], &
1275 allocate_deriv=.true.)
1276 CALL xc_derivative_get(deriv, deriv_data=e_rho_gamma_tau)
1277 deriv => xc_dset_get_derivative(deriv_set, &
1278 [deriv_rho, deriv_tau, deriv_tau], &
1279 allocate_deriv=.true.)
1280 CALL xc_derivative_get(deriv, deriv_data=e_rho_tau_tau)
1281 deriv => xc_dset_get_derivative(deriv_set, &
1282 [deriv_gamma, deriv_gamma, deriv_gamma], &
1283 allocate_deriv=.true.)
1284 CALL xc_derivative_get(deriv, deriv_data=e_gamma_gamma_gamma)
1285 deriv => xc_dset_get_derivative(deriv_set, &
1286 [deriv_gamma, deriv_gamma, deriv_tau], &
1287 allocate_deriv=.true.)
1288 CALL xc_derivative_get(deriv, deriv_data=e_gamma_gamma_tau)
1289 deriv => xc_dset_get_derivative(deriv_set, &
1290 [deriv_gamma, deriv_tau, deriv_tau], &
1291 allocate_deriv=.true.)
1292 CALL xc_derivative_get(deriv, deriv_data=e_gamma_tau_tau)
1293 deriv => xc_dset_get_derivative(deriv_set, &
1294 [deriv_tau, deriv_tau, deriv_tau], &
1295 allocate_deriv=.true.)
1296 CALL xc_derivative_get(deriv, deriv_data=e_tau_tau_tau)
1297 IF (has_laplace) THEN
1298 deriv => xc_dset_get_derivative(deriv_set, &
1299 [deriv_rho, deriv_rho, deriv_laplace_rho], &
1300 allocate_deriv=.true.)
1301 CALL xc_derivative_get(deriv, deriv_data=e_rho_rho_laplace_rho)
1302 deriv => xc_dset_get_derivative(deriv_set, &
1303 [deriv_rho, deriv_gamma, deriv_laplace_rho], &
1304 allocate_deriv=.true.)
1305 CALL xc_derivative_get(deriv, deriv_data=e_rho_gamma_laplace_rho)
1306 deriv => xc_dset_get_derivative(deriv_set, &
1307 [deriv_rho, deriv_laplace_rho, deriv_laplace_rho], &
1308 allocate_deriv=.true.)
1309 CALL xc_derivative_get(deriv, deriv_data=e_rho_laplace_rho_laplace_rho)
1310 deriv => xc_dset_get_derivative(deriv_set, &
1311 [deriv_rho, deriv_laplace_rho, deriv_tau], &
1312 allocate_deriv=.true.)
1313 CALL xc_derivative_get(deriv, deriv_data=e_rho_laplace_rho_tau)
1314 deriv => xc_dset_get_derivative(deriv_set, &
1315 [deriv_gamma, deriv_gamma, deriv_laplace_rho], &
1316 allocate_deriv=.true.)
1317 CALL xc_derivative_get(deriv, deriv_data=e_gamma_gamma_laplace_rho)
1318 deriv => xc_dset_get_derivative(deriv_set, &
1319 [deriv_gamma, deriv_laplace_rho, deriv_laplace_rho], &
1320 allocate_deriv=.true.)
1321 CALL xc_derivative_get(deriv, deriv_data=e_gamma_laplace_rho_laplace_rho)
1322 deriv => xc_dset_get_derivative(deriv_set, &
1323 [deriv_gamma, deriv_laplace_rho, deriv_tau], &
1324 allocate_deriv=.true.)
1325 CALL xc_derivative_get(deriv, deriv_data=e_gamma_laplace_rho_tau)
1326 deriv => xc_dset_get_derivative(deriv_set, &
1327 [deriv_laplace_rho, deriv_laplace_rho, deriv_laplace_rho], &
1328 allocate_deriv=.true.)
1329 CALL xc_derivative_get(deriv, deriv_data=e_laplace_rho_laplace_rho_laplace_rho)
1330 deriv => xc_dset_get_derivative(deriv_set, &
1331 [deriv_laplace_rho, deriv_laplace_rho, deriv_tau], &
1332 allocate_deriv=.true.)
1333 CALL xc_derivative_get(deriv, deriv_data=e_laplace_rho_laplace_rho_tau)
1334 deriv => xc_dset_get_derivative(deriv_set, &
1335 [deriv_laplace_rho, deriv_tau, deriv_tau], &
1336 allocate_deriv=.true.)
1337 CALL xc_derivative_get(deriv, deriv_data=e_laplace_rho_tau_tau)
1338 END IF
1339 deriv => xc_dset_get_derivative(deriv_set, [deriv_rho, deriv_rho, deriv_rho], &
1340 allocate_deriv=.true.)
1341 CALL xc_derivative_get(deriv, deriv_data=e_rho_rho_rho)
1342 CASE default
1343 cpabort(trim(func_name)//": this XC_FAMILY is currently not supported.")
1344 END SELECT
1345 END IF
1346
1347!$OMP PARALLEL DEFAULT(NONE), &
1348!$OMP SHARED(rho,norm_drho,laplace_rho,tau,e_0,e_rho,e_ndrho,e_laplace_rho),&
1349!$OMP SHARED(e_tau,e_rho_rho,e_ndrho_rho,e_ndrho_ndrho,e_rho_laplace_rho),&
1350!$OMP SHARED(e_rho_tau,e_ndrho_laplace_rho,e_ndrho_tau,e_laplace_rho_laplace_rho),&
1351!$OMP SHARED(e_laplace_rho_tau,e_tau_tau,e_rho_rho_rho),&
1352!$OMP SHARED(e_gamma),&
1353!$OMP SHARED(e_rho_gamma),&
1354!$OMP SHARED(e_gamma_gamma),&
1355!$OMP SHARED(e_gamma_laplace_rho),&
1356!$OMP SHARED(e_gamma_tau),&
1357!$OMP SHARED(e_rho_rho_gamma),&
1358!$OMP SHARED(e_rho_rho_laplace_rho),&
1359!$OMP SHARED(e_rho_rho_tau),&
1360!$OMP SHARED(e_rho_gamma_gamma),&
1361!$OMP SHARED(e_rho_gamma_laplace_rho),&
1362!$OMP SHARED(e_rho_gamma_tau),&
1363!$OMP SHARED(e_rho_laplace_rho_laplace_rho),&
1364!$OMP SHARED(e_rho_laplace_rho_tau),&
1365!$OMP SHARED(e_rho_tau_tau),&
1366!$OMP SHARED(e_gamma_gamma_gamma),&
1367!$OMP SHARED(e_gamma_gamma_laplace_rho),&
1368!$OMP SHARED(e_gamma_gamma_tau),&
1369!$OMP SHARED(e_gamma_laplace_rho_laplace_rho),&
1370!$OMP SHARED(e_gamma_laplace_rho_tau),&
1371!$OMP SHARED(e_gamma_tau_tau),&
1372!$OMP SHARED(e_laplace_rho_laplace_rho_laplace_rho),&
1373!$OMP SHARED(e_laplace_rho_laplace_rho_tau),&
1374!$OMP SHARED(e_laplace_rho_tau_tau),&
1375!$OMP SHARED(e_tau_tau_tau),&
1376!$OMP SHARED(grad_deriv,npoints),&
1377!$OMP SHARED(func_name,func_scale,workers)
1378
1379 CALL libxc_spin_unpolarized_calc(rho=rho, norm_drho=norm_drho, &
1380 laplace_rho=laplace_rho, tau=tau, &
1381 e_0=e_0, e_rho=e_rho, e_ndrho=e_ndrho, e_laplace_rho=e_laplace_rho, &
1382 e_tau=e_tau, e_rho_rho=e_rho_rho, e_ndrho_rho=e_ndrho_rho, &
1383 e_ndrho_ndrho=e_ndrho_ndrho, e_rho_laplace_rho=e_rho_laplace_rho, &
1384 e_rho_tau=e_rho_tau, e_ndrho_laplace_rho=e_ndrho_laplace_rho, &
1385 e_ndrho_tau=e_ndrho_tau, e_laplace_rho_laplace_rho=e_laplace_rho_laplace_rho, &
1386 e_laplace_rho_tau=e_laplace_rho_tau, e_tau_tau=e_tau_tau, &
1387 e_rho_rho_rho=e_rho_rho_rho, &
1388 e_gamma=e_gamma, &
1389 e_rho_gamma=e_rho_gamma, &
1390 e_gamma_gamma=e_gamma_gamma, &
1391 e_gamma_laplace_rho=e_gamma_laplace_rho, &
1392 e_gamma_tau=e_gamma_tau, &
1393 e_rho_rho_gamma=e_rho_rho_gamma, &
1394 e_rho_rho_laplace_rho=e_rho_rho_laplace_rho, &
1395 e_rho_rho_tau=e_rho_rho_tau, &
1396 e_rho_gamma_gamma=e_rho_gamma_gamma, &
1397 e_rho_gamma_laplace_rho=e_rho_gamma_laplace_rho, &
1398 e_rho_gamma_tau=e_rho_gamma_tau, &
1399 e_rho_laplace_rho_laplace_rho=e_rho_laplace_rho_laplace_rho, &
1400 e_rho_laplace_rho_tau=e_rho_laplace_rho_tau, &
1401 e_rho_tau_tau=e_rho_tau_tau, &
1402 e_gamma_gamma_gamma=e_gamma_gamma_gamma, &
1403 e_gamma_gamma_laplace_rho=e_gamma_gamma_laplace_rho, &
1404 e_gamma_gamma_tau=e_gamma_gamma_tau, &
1405 e_gamma_laplace_rho_laplace_rho=e_gamma_laplace_rho_laplace_rho, &
1406 e_gamma_laplace_rho_tau=e_gamma_laplace_rho_tau, &
1407 e_gamma_tau_tau=e_gamma_tau_tau, &
1408 e_laplace_rho_laplace_rho_laplace_rho=e_laplace_rho_laplace_rho_laplace_rho, &
1409 e_laplace_rho_laplace_rho_tau=e_laplace_rho_laplace_rho_tau, &
1410 e_laplace_rho_tau_tau=e_laplace_rho_tau_tau, &
1411 e_tau_tau_tau=e_tau_tau_tau, &
1412 grad_deriv=grad_deriv, npoints=npoints, &
1413 func_name=func_name, sc=func_scale, workers=workers)
1414
1415!$OMP END PARALLEL
1416
1417 NULLIFY (dummy)
1418 NULLIFY (workers)
1419
1420 CALL timestop(handle)
1421#else
1422 mark_used(rho_set)
1423 mark_used(deriv_set)
1424 mark_used(grad_deriv)
1425 mark_used(libxc_params)
1426 mark_used(func_name_override)
1427 CALL cp_abort(__location__, "Unknown functional! If you are asking "// &
1428 "for a functional of the LibXC library, "// &
1429 "you have to download and install the library!")
1430#endif
1431 END SUBROUTINE libxc_spin_unpolarized_eval
1432
1433! **************************************************************************************************
1434!> \brief evaluates the functional from libxc
1435!> \param rho_set the density where you want to evaluate the functional
1436!> \param deriv_set place where to store the functional derivatives (they are
1437!> added to the derivatives)
1438!> \param grad_deriv degree of the derivative that should be evaluated;
1439!> all derivatives up to the given degree are evaluated, in a single
1440!> LibXC call per block of grid points
1441!> \param libxc_params input parameter (functional name, scaling and parameters)
1442!> \param func_name_override optional LibXC functional name overriding the section name
1443!> \author F. Tran
1444! **************************************************************************************************
1445 SUBROUTINE libxc_spin_polarized_eval(rho_set, deriv_set, grad_deriv, libxc_params, func_name_override)
1446
1447 TYPE(xc_rho_set_type), INTENT(IN) :: rho_set
1448 TYPE(xc_derivative_set_type), INTENT(IN) :: deriv_set
1449 INTEGER, INTENT(IN) :: grad_deriv
1450 TYPE(section_vals_type), POINTER :: libxc_params
1451 CHARACTER(LEN=*), INTENT(IN), OPTIONAL :: func_name_override
1452
1453#if defined (__LIBXC)
1454 CHARACTER(LEN=*), PARAMETER :: routinen = 'libxc_spin_polarized_eval'
1455
1456 CHARACTER(LEN=default_string_length) :: func_name
1457 INTEGER :: handle, iw, npoints
1458 INTEGER, DIMENSION(2, 3) :: bo
1459 LOGICAL :: has_laplace
1460 REAL(kind=dp) :: epsilon_rho, epsilon_tau, func_scale
1461 TYPE(libxc_worker_set_type), POINTER :: workers
1462 TYPE(section_vals_type), POINTER :: no_params
1463 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: dummy, e_0, e_laplace_rhoa, &
1464 e_laplace_rhoa_laplace_rhoa, e_laplace_rhoa_laplace_rhob, &
1465 e_laplace_rhoa_tau_a, e_laplace_rhoa_tau_b, e_laplace_rhob, &
1466 e_laplace_rhob_laplace_rhob, e_laplace_rhob_tau_a, &
1467 e_laplace_rhob_tau_b, e_ndrho, e_ndrho_laplace_rhoa, &
1468 e_ndrho_laplace_rhob, e_ndrho_ndrho, e_ndrho_ndrhoa, e_ndrho_ndrhob, &
1469 e_ndrho_rhoa, e_ndrho_rhob, e_ndrho_tau_a, e_ndrho_tau_b, e_ndrhoa, &
1470 e_ndrhoa_laplace_rhoa, e_ndrhoa_laplace_rhob, e_ndrhoa_ndrhoa, &
1471 e_ndrhoa_ndrhob, e_ndrhoa_rhoa, e_ndrhoa_rhob, e_ndrhoa_tau_a, &
1472 e_ndrhoa_tau_b, e_ndrhob
1473 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_ndrhob_laplace_rhoa, &
1474 e_ndrhob_laplace_rhob, e_ndrhob_ndrhob, e_ndrhob_rhoa, e_ndrhob_rhob, &
1475 e_ndrhob_tau_a, e_ndrhob_tau_b, e_rhoa, e_rhoa_laplace_rhoa, &
1476 e_rhoa_laplace_rhob, e_rhoa_rhoa, e_rhoa_rhoa_rhoa, e_rhoa_rhoa_rhob, &
1477 e_rhoa_rhob, e_rhoa_rhob_rhob, e_rhoa_tau_a, e_rhoa_tau_b, e_rhob, &
1478 e_rhob_laplace_rhoa, e_rhob_laplace_rhob, e_rhob_rhob, &
1479 e_rhob_rhob_rhob, e_rhob_tau_a, e_rhob_tau_b, e_tau_a, e_tau_a_tau_a, &
1480 e_tau_a_tau_b, e_tau_b, e_tau_b_tau_b, laplace_rhoa, laplace_rhob, &
1481 norm_drho, norm_drhoa, norm_drhob, rhoa, rhob, tau_a, tau_b
1482 ! derivatives w.r.t. the reduced gradients gamma_ij = grad rho_i . grad rho_j
1483 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_aa
1484 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_ab
1485 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_bb
1486 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhoa_gamma_aa
1487 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhoa_gamma_ab
1488 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhoa_gamma_bb
1489 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhob_gamma_aa
1490 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhob_gamma_ab
1491 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhob_gamma_bb
1492 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_aa_gamma_aa
1493 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_aa_gamma_ab
1494 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_aa_gamma_bb
1495 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_aa_laplace_rhoa
1496 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_aa_laplace_rhob
1497 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_aa_tau_a
1498 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_aa_tau_b
1499 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_ab_gamma_ab
1500 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_ab_gamma_bb
1501 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_ab_laplace_rhoa
1502 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_ab_laplace_rhob
1503 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_ab_tau_a
1504 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_ab_tau_b
1505 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_bb_gamma_bb
1506 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_bb_laplace_rhoa
1507 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_bb_laplace_rhob
1508 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_bb_tau_a
1509 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_bb_tau_b
1510 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhoa_rhoa_gamma_aa
1511 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhoa_rhoa_gamma_ab
1512 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhoa_rhoa_gamma_bb
1513 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhoa_rhoa_laplace_rhoa
1514 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhoa_rhoa_laplace_rhob
1515 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhoa_rhoa_tau_a
1516 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhoa_rhoa_tau_b
1517 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhoa_rhob_gamma_aa
1518 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhoa_rhob_gamma_ab
1519 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhoa_rhob_gamma_bb
1520 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhoa_rhob_laplace_rhoa
1521 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhoa_rhob_laplace_rhob
1522 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhoa_rhob_tau_a
1523 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhoa_rhob_tau_b
1524 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhoa_gamma_aa_gamma_aa
1525 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhoa_gamma_aa_gamma_ab
1526 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhoa_gamma_aa_gamma_bb
1527 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhoa_gamma_aa_laplace_rhoa
1528 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhoa_gamma_aa_laplace_rhob
1529 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhoa_gamma_aa_tau_a
1530 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhoa_gamma_aa_tau_b
1531 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhoa_gamma_ab_gamma_ab
1532 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhoa_gamma_ab_gamma_bb
1533 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhoa_gamma_ab_laplace_rhoa
1534 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhoa_gamma_ab_laplace_rhob
1535 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhoa_gamma_ab_tau_a
1536 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhoa_gamma_ab_tau_b
1537 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhoa_gamma_bb_gamma_bb
1538 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhoa_gamma_bb_laplace_rhoa
1539 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhoa_gamma_bb_laplace_rhob
1540 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhoa_gamma_bb_tau_a
1541 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhoa_gamma_bb_tau_b
1542 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhoa_laplace_rhoa_laplace_rhoa
1543 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhoa_laplace_rhoa_laplace_rhob
1544 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhoa_laplace_rhoa_tau_a
1545 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhoa_laplace_rhoa_tau_b
1546 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhoa_laplace_rhob_laplace_rhob
1547 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhoa_laplace_rhob_tau_a
1548 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhoa_laplace_rhob_tau_b
1549 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhoa_tau_a_tau_a
1550 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhoa_tau_a_tau_b
1551 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhoa_tau_b_tau_b
1552 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhob_rhob_gamma_aa
1553 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhob_rhob_gamma_ab
1554 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhob_rhob_gamma_bb
1555 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhob_rhob_laplace_rhoa
1556 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhob_rhob_laplace_rhob
1557 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhob_rhob_tau_a
1558 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhob_rhob_tau_b
1559 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhob_gamma_aa_gamma_aa
1560 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhob_gamma_aa_gamma_ab
1561 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhob_gamma_aa_gamma_bb
1562 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhob_gamma_aa_laplace_rhoa
1563 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhob_gamma_aa_laplace_rhob
1564 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhob_gamma_aa_tau_a
1565 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhob_gamma_aa_tau_b
1566 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhob_gamma_ab_gamma_ab
1567 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhob_gamma_ab_gamma_bb
1568 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhob_gamma_ab_laplace_rhoa
1569 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhob_gamma_ab_laplace_rhob
1570 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhob_gamma_ab_tau_a
1571 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhob_gamma_ab_tau_b
1572 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhob_gamma_bb_gamma_bb
1573 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhob_gamma_bb_laplace_rhoa
1574 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhob_gamma_bb_laplace_rhob
1575 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhob_gamma_bb_tau_a
1576 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhob_gamma_bb_tau_b
1577 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhob_laplace_rhoa_laplace_rhoa
1578 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhob_laplace_rhoa_laplace_rhob
1579 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhob_laplace_rhoa_tau_a
1580 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhob_laplace_rhoa_tau_b
1581 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhob_laplace_rhob_laplace_rhob
1582 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhob_laplace_rhob_tau_a
1583 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhob_laplace_rhob_tau_b
1584 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhob_tau_a_tau_a
1585 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhob_tau_a_tau_b
1586 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_rhob_tau_b_tau_b
1587 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_aa_gamma_aa_gamma_aa
1588 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_aa_gamma_aa_gamma_ab
1589 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_aa_gamma_aa_gamma_bb
1590 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_aa_gamma_aa_laplace_rhoa
1591 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_aa_gamma_aa_laplace_rhob
1592 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_aa_gamma_aa_tau_a
1593 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_aa_gamma_aa_tau_b
1594 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_aa_gamma_ab_gamma_ab
1595 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_aa_gamma_ab_gamma_bb
1596 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_aa_gamma_ab_laplace_rhoa
1597 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_aa_gamma_ab_laplace_rhob
1598 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_aa_gamma_ab_tau_a
1599 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_aa_gamma_ab_tau_b
1600 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_aa_gamma_bb_gamma_bb
1601 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_aa_gamma_bb_laplace_rhoa
1602 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_aa_gamma_bb_laplace_rhob
1603 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_aa_gamma_bb_tau_a
1604 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_aa_gamma_bb_tau_b
1605 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_aa_laplace_rhoa_laplace_rhoa
1606 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_aa_laplace_rhoa_laplace_rhob
1607 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_aa_laplace_rhoa_tau_a
1608 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_aa_laplace_rhoa_tau_b
1609 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_aa_laplace_rhob_laplace_rhob
1610 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_aa_laplace_rhob_tau_a
1611 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_aa_laplace_rhob_tau_b
1612 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_aa_tau_a_tau_a
1613 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_aa_tau_a_tau_b
1614 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_aa_tau_b_tau_b
1615 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_ab_gamma_ab_gamma_ab
1616 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_ab_gamma_ab_gamma_bb
1617 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_ab_gamma_ab_laplace_rhoa
1618 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_ab_gamma_ab_laplace_rhob
1619 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_ab_gamma_ab_tau_a
1620 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_ab_gamma_ab_tau_b
1621 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_ab_gamma_bb_gamma_bb
1622 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_ab_gamma_bb_laplace_rhoa
1623 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_ab_gamma_bb_laplace_rhob
1624 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_ab_gamma_bb_tau_a
1625 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_ab_gamma_bb_tau_b
1626 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_ab_laplace_rhoa_laplace_rhoa
1627 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_ab_laplace_rhoa_laplace_rhob
1628 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_ab_laplace_rhoa_tau_a
1629 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_ab_laplace_rhoa_tau_b
1630 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_ab_laplace_rhob_laplace_rhob
1631 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_ab_laplace_rhob_tau_a
1632 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_ab_laplace_rhob_tau_b
1633 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_ab_tau_a_tau_a
1634 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_ab_tau_a_tau_b
1635 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_ab_tau_b_tau_b
1636 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_bb_gamma_bb_gamma_bb
1637 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_bb_gamma_bb_laplace_rhoa
1638 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_bb_gamma_bb_laplace_rhob
1639 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_bb_gamma_bb_tau_a
1640 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_bb_gamma_bb_tau_b
1641 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_bb_laplace_rhoa_laplace_rhoa
1642 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_bb_laplace_rhoa_laplace_rhob
1643 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_bb_laplace_rhoa_tau_a
1644 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_bb_laplace_rhoa_tau_b
1645 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_bb_laplace_rhob_laplace_rhob
1646 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_bb_laplace_rhob_tau_a
1647 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_bb_laplace_rhob_tau_b
1648 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_bb_tau_a_tau_a
1649 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_bb_tau_a_tau_b
1650 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_gamma_bb_tau_b_tau_b
1651 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_laplace_rhoa_laplace_rhoa_laplace_rhoa
1652 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_laplace_rhoa_laplace_rhoa_laplace_rhob
1653 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_laplace_rhoa_laplace_rhoa_tau_a
1654 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_laplace_rhoa_laplace_rhoa_tau_b
1655 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_laplace_rhoa_laplace_rhob_laplace_rhob
1656 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_laplace_rhoa_laplace_rhob_tau_a
1657 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_laplace_rhoa_laplace_rhob_tau_b
1658 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_laplace_rhoa_tau_a_tau_a
1659 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_laplace_rhoa_tau_a_tau_b
1660 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_laplace_rhoa_tau_b_tau_b
1661 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_laplace_rhob_laplace_rhob_laplace_rhob
1662 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_laplace_rhob_laplace_rhob_tau_a
1663 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_laplace_rhob_laplace_rhob_tau_b
1664 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_laplace_rhob_tau_a_tau_a
1665 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_laplace_rhob_tau_a_tau_b
1666 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_laplace_rhob_tau_b_tau_b
1667 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_tau_a_tau_a_tau_a
1668 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_tau_a_tau_a_tau_b
1669 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_tau_a_tau_b_tau_b
1670 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_tau_b_tau_b_tau_b
1671 TYPE(xc_derivative_type), POINTER :: deriv
1672 TYPE(xc_f03_func_info_t) :: xc_info
1673
1674 CALL timeset(routinen, handle)
1675
1676 ! Only "everything up to grad_deriv" is supported. Asking for a single
1677 ! derivative order in isolation is rejected here rather than further down,
1678 ! where it would quietly evaluate nothing at all.
1679 IF (grad_deriv > 3) THEN
1680 cpabort("derivatives larger than 3 not implemented")
1681 END IF
1682
1683 NULLIFY (dummy)
1684 NULLIFY (workers)
1685 NULLIFY (rhoa, rhob, norm_drho, norm_drhoa, norm_drhob, laplace_rhoa, &
1686 laplace_rhob, tau_a, tau_b)
1687
1688 IF (PRESENT(func_name_override)) THEN
1689 func_name = func_name_override
1690 func_scale = 1.0_dp
1691 ELSE
1692 func_name = libxc_params%section%name
1693 CALL section_vals_val_get(libxc_params, "scale", r_val=func_scale)
1694 END IF
1695
1696 IF (abs(func_scale - 1.0_dp) < 1.0e-10_dp) func_scale = 1.0_dp
1697
1698 CALL xc_rho_set_get(rho_set, can_return_null=.true., &
1699 rhoa=rhoa, rhob=rhob, norm_drho=norm_drho, &
1700 norm_drhoa=norm_drhoa, norm_drhob=norm_drhob, &
1701 laplace_rhoa=laplace_rhoa, laplace_rhob=laplace_rhob, &
1702 rho_cutoff=epsilon_rho, tau_cutoff=epsilon_tau, &
1703 tau_a=tau_a, tau_b=tau_b, local_bounds=bo)
1704
1705 npoints = (bo(2, 1) - bo(1, 1) + 1)*(bo(2, 2) - bo(1, 2) + 1)*(bo(2, 3) - bo(1, 3) + 1)
1706
1707 ! One functional object per thread, kept across calls. The cutoffs are part
1708 ! of the worker setup because LibXC does the screening itself.
1709 IF (PRESENT(func_name_override)) THEN
1710 ! an overriding name carries no input section, so no parameters are set
1711 NULLIFY (no_params)
1712 iw = libxc_get_workers(func_name, xc_polarized, no_params, epsilon_rho, epsilon_tau, &
1713 grad_deriv)
1714 ELSE
1715 iw = libxc_get_workers(func_name, xc_polarized, libxc_params, epsilon_rho, epsilon_tau, &
1716 grad_deriv)
1717 END IF
1718 workers => libxc_cache(iw)
1719 xc_info = workers%worker(1)%info
1720 has_laplace = workers%has_laplace
1721
1722 ! see libxc_unused: the arguments the requested order does not produce are
1723 ! never touched, but they still have to point somewhere
1724 CALL libxc_reserve_unused(npoints)
1725 dummy(bo(1, 1):bo(2, 1), bo(1, 2):bo(2, 2), bo(1, 3):bo(2, 3)) => libxc_unused(1:npoints)
1726
1727 ! due to assumed shape array usage in next routine
1728 IF (.NOT. ASSOCIATED(norm_drho)) norm_drho => rhoa
1729 IF (.NOT. ASSOCIATED(norm_drhoa)) norm_drhoa => rhoa
1730 IF (.NOT. ASSOCIATED(norm_drhob)) norm_drhob => rhoa
1731 IF (.NOT. ASSOCIATED(tau_a)) tau_a => rhoa
1732 IF (.NOT. ASSOCIATED(tau_b)) tau_b => rhoa
1733
1734 ! only some MGGA functionals really need the Laplacian,
1735 ! all others can work with rhoa (read-only) as dummy
1736 IF (.NOT. has_laplace) laplace_rhoa => rhoa
1737 IF (.NOT. has_laplace) laplace_rhob => rhoa
1738
1739 e_0 => dummy
1740 e_rhoa => dummy
1741 e_rhob => dummy
1742 e_ndrho => dummy
1743 e_ndrhoa => dummy
1744 e_ndrhob => dummy
1745 e_laplace_rhoa => dummy
1746 e_laplace_rhob => dummy
1747 e_tau_a => dummy
1748 e_tau_b => dummy
1749 e_rhoa_rhoa => dummy
1750 e_rhoa_rhob => dummy
1751 e_rhob_rhob => dummy
1752 e_ndrho_rhoa => dummy
1753 e_ndrho_rhob => dummy
1754 e_ndrhoa_rhoa => dummy
1755 e_ndrhoa_rhob => dummy
1756 e_ndrhob_rhoa => dummy
1757 e_ndrhob_rhob => dummy
1758 e_ndrho_ndrho => dummy
1759 e_ndrho_ndrhoa => dummy
1760 e_ndrho_ndrhob => dummy
1761 e_ndrhoa_ndrhoa => dummy
1762 e_ndrhoa_ndrhob => dummy
1763 e_ndrhob_ndrhob => dummy
1764 e_rhoa_laplace_rhoa => dummy
1765 e_rhoa_laplace_rhob => dummy
1766 e_rhob_laplace_rhoa => dummy
1767 e_rhob_laplace_rhob => dummy
1768 e_rhoa_tau_a => dummy
1769 e_rhoa_tau_b => dummy
1770 e_rhob_tau_a => dummy
1771 e_rhob_tau_b => dummy
1772 e_ndrho_laplace_rhoa => dummy
1773 e_ndrho_laplace_rhob => dummy
1774 e_ndrhoa_laplace_rhoa => dummy
1775 e_ndrhoa_laplace_rhob => dummy
1776 e_ndrhob_laplace_rhoa => dummy
1777 e_ndrhob_laplace_rhob => dummy
1778 e_ndrho_tau_a => dummy
1779 e_ndrho_tau_b => dummy
1780 e_ndrhoa_tau_a => dummy
1781 e_ndrhoa_tau_b => dummy
1782 e_ndrhob_tau_a => dummy
1783 e_ndrhob_tau_b => dummy
1784 e_laplace_rhoa_laplace_rhoa => dummy
1785 e_laplace_rhoa_laplace_rhob => dummy
1786 e_laplace_rhob_laplace_rhob => dummy
1787 e_laplace_rhoa_tau_a => dummy
1788 e_laplace_rhoa_tau_b => dummy
1789 e_laplace_rhob_tau_a => dummy
1790 e_laplace_rhob_tau_b => dummy
1791 e_tau_a_tau_a => dummy
1792 e_tau_a_tau_b => dummy
1793 e_tau_b_tau_b => dummy
1794 e_rhoa_rhoa_rhoa => dummy
1795 e_rhoa_rhoa_rhob => dummy
1796 e_rhoa_rhob_rhob => dummy
1797 e_rhob_rhob_rhob => dummy
1798 e_gamma_aa => dummy
1799 e_gamma_ab => dummy
1800 e_gamma_bb => dummy
1801 e_rhoa_gamma_aa => dummy
1802 e_rhoa_gamma_ab => dummy
1803 e_rhoa_gamma_bb => dummy
1804 e_rhob_gamma_aa => dummy
1805 e_rhob_gamma_ab => dummy
1806 e_rhob_gamma_bb => dummy
1807 e_gamma_aa_gamma_aa => dummy
1808 e_gamma_aa_gamma_ab => dummy
1809 e_gamma_aa_gamma_bb => dummy
1810 e_gamma_aa_laplace_rhoa => dummy
1811 e_gamma_aa_laplace_rhob => dummy
1812 e_gamma_aa_tau_a => dummy
1813 e_gamma_aa_tau_b => dummy
1814 e_gamma_ab_gamma_ab => dummy
1815 e_gamma_ab_gamma_bb => dummy
1816 e_gamma_ab_laplace_rhoa => dummy
1817 e_gamma_ab_laplace_rhob => dummy
1818 e_gamma_ab_tau_a => dummy
1819 e_gamma_ab_tau_b => dummy
1820 e_gamma_bb_gamma_bb => dummy
1821 e_gamma_bb_laplace_rhoa => dummy
1822 e_gamma_bb_laplace_rhob => dummy
1823 e_gamma_bb_tau_a => dummy
1824 e_gamma_bb_tau_b => dummy
1825 e_rhoa_rhoa_gamma_aa => dummy
1826 e_rhoa_rhoa_gamma_ab => dummy
1827 e_rhoa_rhoa_gamma_bb => dummy
1828 e_rhoa_rhoa_laplace_rhoa => dummy
1829 e_rhoa_rhoa_laplace_rhob => dummy
1830 e_rhoa_rhoa_tau_a => dummy
1831 e_rhoa_rhoa_tau_b => dummy
1832 e_rhoa_rhob_gamma_aa => dummy
1833 e_rhoa_rhob_gamma_ab => dummy
1834 e_rhoa_rhob_gamma_bb => dummy
1835 e_rhoa_rhob_laplace_rhoa => dummy
1836 e_rhoa_rhob_laplace_rhob => dummy
1837 e_rhoa_rhob_tau_a => dummy
1838 e_rhoa_rhob_tau_b => dummy
1839 e_rhoa_gamma_aa_gamma_aa => dummy
1840 e_rhoa_gamma_aa_gamma_ab => dummy
1841 e_rhoa_gamma_aa_gamma_bb => dummy
1842 e_rhoa_gamma_aa_laplace_rhoa => dummy
1843 e_rhoa_gamma_aa_laplace_rhob => dummy
1844 e_rhoa_gamma_aa_tau_a => dummy
1845 e_rhoa_gamma_aa_tau_b => dummy
1846 e_rhoa_gamma_ab_gamma_ab => dummy
1847 e_rhoa_gamma_ab_gamma_bb => dummy
1848 e_rhoa_gamma_ab_laplace_rhoa => dummy
1849 e_rhoa_gamma_ab_laplace_rhob => dummy
1850 e_rhoa_gamma_ab_tau_a => dummy
1851 e_rhoa_gamma_ab_tau_b => dummy
1852 e_rhoa_gamma_bb_gamma_bb => dummy
1853 e_rhoa_gamma_bb_laplace_rhoa => dummy
1854 e_rhoa_gamma_bb_laplace_rhob => dummy
1855 e_rhoa_gamma_bb_tau_a => dummy
1856 e_rhoa_gamma_bb_tau_b => dummy
1857 e_rhoa_laplace_rhoa_laplace_rhoa => dummy
1858 e_rhoa_laplace_rhoa_laplace_rhob => dummy
1859 e_rhoa_laplace_rhoa_tau_a => dummy
1860 e_rhoa_laplace_rhoa_tau_b => dummy
1861 e_rhoa_laplace_rhob_laplace_rhob => dummy
1862 e_rhoa_laplace_rhob_tau_a => dummy
1863 e_rhoa_laplace_rhob_tau_b => dummy
1864 e_rhoa_tau_a_tau_a => dummy
1865 e_rhoa_tau_a_tau_b => dummy
1866 e_rhoa_tau_b_tau_b => dummy
1867 e_rhob_rhob_gamma_aa => dummy
1868 e_rhob_rhob_gamma_ab => dummy
1869 e_rhob_rhob_gamma_bb => dummy
1870 e_rhob_rhob_laplace_rhoa => dummy
1871 e_rhob_rhob_laplace_rhob => dummy
1872 e_rhob_rhob_tau_a => dummy
1873 e_rhob_rhob_tau_b => dummy
1874 e_rhob_gamma_aa_gamma_aa => dummy
1875 e_rhob_gamma_aa_gamma_ab => dummy
1876 e_rhob_gamma_aa_gamma_bb => dummy
1877 e_rhob_gamma_aa_laplace_rhoa => dummy
1878 e_rhob_gamma_aa_laplace_rhob => dummy
1879 e_rhob_gamma_aa_tau_a => dummy
1880 e_rhob_gamma_aa_tau_b => dummy
1881 e_rhob_gamma_ab_gamma_ab => dummy
1882 e_rhob_gamma_ab_gamma_bb => dummy
1883 e_rhob_gamma_ab_laplace_rhoa => dummy
1884 e_rhob_gamma_ab_laplace_rhob => dummy
1885 e_rhob_gamma_ab_tau_a => dummy
1886 e_rhob_gamma_ab_tau_b => dummy
1887 e_rhob_gamma_bb_gamma_bb => dummy
1888 e_rhob_gamma_bb_laplace_rhoa => dummy
1889 e_rhob_gamma_bb_laplace_rhob => dummy
1890 e_rhob_gamma_bb_tau_a => dummy
1891 e_rhob_gamma_bb_tau_b => dummy
1892 e_rhob_laplace_rhoa_laplace_rhoa => dummy
1893 e_rhob_laplace_rhoa_laplace_rhob => dummy
1894 e_rhob_laplace_rhoa_tau_a => dummy
1895 e_rhob_laplace_rhoa_tau_b => dummy
1896 e_rhob_laplace_rhob_laplace_rhob => dummy
1897 e_rhob_laplace_rhob_tau_a => dummy
1898 e_rhob_laplace_rhob_tau_b => dummy
1899 e_rhob_tau_a_tau_a => dummy
1900 e_rhob_tau_a_tau_b => dummy
1901 e_rhob_tau_b_tau_b => dummy
1902 e_gamma_aa_gamma_aa_gamma_aa => dummy
1903 e_gamma_aa_gamma_aa_gamma_ab => dummy
1904 e_gamma_aa_gamma_aa_gamma_bb => dummy
1905 e_gamma_aa_gamma_aa_laplace_rhoa => dummy
1906 e_gamma_aa_gamma_aa_laplace_rhob => dummy
1907 e_gamma_aa_gamma_aa_tau_a => dummy
1908 e_gamma_aa_gamma_aa_tau_b => dummy
1909 e_gamma_aa_gamma_ab_gamma_ab => dummy
1910 e_gamma_aa_gamma_ab_gamma_bb => dummy
1911 e_gamma_aa_gamma_ab_laplace_rhoa => dummy
1912 e_gamma_aa_gamma_ab_laplace_rhob => dummy
1913 e_gamma_aa_gamma_ab_tau_a => dummy
1914 e_gamma_aa_gamma_ab_tau_b => dummy
1915 e_gamma_aa_gamma_bb_gamma_bb => dummy
1916 e_gamma_aa_gamma_bb_laplace_rhoa => dummy
1917 e_gamma_aa_gamma_bb_laplace_rhob => dummy
1918 e_gamma_aa_gamma_bb_tau_a => dummy
1919 e_gamma_aa_gamma_bb_tau_b => dummy
1920 e_gamma_aa_laplace_rhoa_laplace_rhoa => dummy
1921 e_gamma_aa_laplace_rhoa_laplace_rhob => dummy
1922 e_gamma_aa_laplace_rhoa_tau_a => dummy
1923 e_gamma_aa_laplace_rhoa_tau_b => dummy
1924 e_gamma_aa_laplace_rhob_laplace_rhob => dummy
1925 e_gamma_aa_laplace_rhob_tau_a => dummy
1926 e_gamma_aa_laplace_rhob_tau_b => dummy
1927 e_gamma_aa_tau_a_tau_a => dummy
1928 e_gamma_aa_tau_a_tau_b => dummy
1929 e_gamma_aa_tau_b_tau_b => dummy
1930 e_gamma_ab_gamma_ab_gamma_ab => dummy
1931 e_gamma_ab_gamma_ab_gamma_bb => dummy
1932 e_gamma_ab_gamma_ab_laplace_rhoa => dummy
1933 e_gamma_ab_gamma_ab_laplace_rhob => dummy
1934 e_gamma_ab_gamma_ab_tau_a => dummy
1935 e_gamma_ab_gamma_ab_tau_b => dummy
1936 e_gamma_ab_gamma_bb_gamma_bb => dummy
1937 e_gamma_ab_gamma_bb_laplace_rhoa => dummy
1938 e_gamma_ab_gamma_bb_laplace_rhob => dummy
1939 e_gamma_ab_gamma_bb_tau_a => dummy
1940 e_gamma_ab_gamma_bb_tau_b => dummy
1941 e_gamma_ab_laplace_rhoa_laplace_rhoa => dummy
1942 e_gamma_ab_laplace_rhoa_laplace_rhob => dummy
1943 e_gamma_ab_laplace_rhoa_tau_a => dummy
1944 e_gamma_ab_laplace_rhoa_tau_b => dummy
1945 e_gamma_ab_laplace_rhob_laplace_rhob => dummy
1946 e_gamma_ab_laplace_rhob_tau_a => dummy
1947 e_gamma_ab_laplace_rhob_tau_b => dummy
1948 e_gamma_ab_tau_a_tau_a => dummy
1949 e_gamma_ab_tau_a_tau_b => dummy
1950 e_gamma_ab_tau_b_tau_b => dummy
1951 e_gamma_bb_gamma_bb_gamma_bb => dummy
1952 e_gamma_bb_gamma_bb_laplace_rhoa => dummy
1953 e_gamma_bb_gamma_bb_laplace_rhob => dummy
1954 e_gamma_bb_gamma_bb_tau_a => dummy
1955 e_gamma_bb_gamma_bb_tau_b => dummy
1956 e_gamma_bb_laplace_rhoa_laplace_rhoa => dummy
1957 e_gamma_bb_laplace_rhoa_laplace_rhob => dummy
1958 e_gamma_bb_laplace_rhoa_tau_a => dummy
1959 e_gamma_bb_laplace_rhoa_tau_b => dummy
1960 e_gamma_bb_laplace_rhob_laplace_rhob => dummy
1961 e_gamma_bb_laplace_rhob_tau_a => dummy
1962 e_gamma_bb_laplace_rhob_tau_b => dummy
1963 e_gamma_bb_tau_a_tau_a => dummy
1964 e_gamma_bb_tau_a_tau_b => dummy
1965 e_gamma_bb_tau_b_tau_b => dummy
1966 e_laplace_rhoa_laplace_rhoa_laplace_rhoa => dummy
1967 e_laplace_rhoa_laplace_rhoa_laplace_rhob => dummy
1968 e_laplace_rhoa_laplace_rhoa_tau_a => dummy
1969 e_laplace_rhoa_laplace_rhoa_tau_b => dummy
1970 e_laplace_rhoa_laplace_rhob_laplace_rhob => dummy
1971 e_laplace_rhoa_laplace_rhob_tau_a => dummy
1972 e_laplace_rhoa_laplace_rhob_tau_b => dummy
1973 e_laplace_rhoa_tau_a_tau_a => dummy
1974 e_laplace_rhoa_tau_a_tau_b => dummy
1975 e_laplace_rhoa_tau_b_tau_b => dummy
1976 e_laplace_rhob_laplace_rhob_laplace_rhob => dummy
1977 e_laplace_rhob_laplace_rhob_tau_a => dummy
1978 e_laplace_rhob_laplace_rhob_tau_b => dummy
1979 e_laplace_rhob_tau_a_tau_a => dummy
1980 e_laplace_rhob_tau_a_tau_b => dummy
1981 e_laplace_rhob_tau_b_tau_b => dummy
1982 e_tau_a_tau_a_tau_a => dummy
1983 e_tau_a_tau_a_tau_b => dummy
1984 e_tau_a_tau_b_tau_b => dummy
1985 e_tau_b_tau_b_tau_b => dummy
1986
1987 deriv => xc_dset_get_derivative(deriv_set, [INTEGER::], &
1988 allocate_deriv=.true.)
1989 CALL xc_derivative_get(deriv, deriv_data=e_0)
1990 IF (grad_deriv >= 1) THEN
1991 SELECT CASE (xc_f03_func_info_get_family(xc_info))
1992 CASE (xc_family_lda, xc_family_hyb_lda)
1993 deriv => xc_dset_get_derivative(deriv_set, [deriv_rhoa], &
1994 allocate_deriv=.true.)
1995 CALL xc_derivative_get(deriv, deriv_data=e_rhoa)
1996 deriv => xc_dset_get_derivative(deriv_set, [deriv_rhob], &
1997 allocate_deriv=.true.)
1998 CALL xc_derivative_get(deriv, deriv_data=e_rhob)
1999 CASE (xc_family_gga, xc_family_hyb_gga)
2000 deriv => xc_dset_get_derivative(deriv_set, [deriv_rhoa], &
2001 allocate_deriv=.true.)
2002 CALL xc_derivative_get(deriv, deriv_data=e_rhoa)
2003 deriv => xc_dset_get_derivative(deriv_set, [deriv_rhob], &
2004 allocate_deriv=.true.)
2005 CALL xc_derivative_get(deriv, deriv_data=e_rhob)
2006 deriv => xc_dset_get_derivative(deriv_set, [deriv_norm_drho], &
2007 allocate_deriv=.true.)
2008 CALL xc_derivative_get(deriv, deriv_data=e_ndrho)
2009 deriv => xc_dset_get_derivative(deriv_set, [deriv_norm_drhoa], &
2010 allocate_deriv=.true.)
2011 CALL xc_derivative_get(deriv, deriv_data=e_ndrhoa)
2012 deriv => xc_dset_get_derivative(deriv_set, [deriv_norm_drhob], &
2013 allocate_deriv=.true.)
2014 CALL xc_derivative_get(deriv, deriv_data=e_ndrhob)
2015 deriv => xc_dset_get_derivative(deriv_set, &
2016 [deriv_gamma_aa], &
2017 allocate_deriv=.true.)
2018 CALL xc_derivative_get(deriv, deriv_data=e_gamma_aa)
2019 deriv => xc_dset_get_derivative(deriv_set, &
2020 [deriv_gamma_ab], &
2021 allocate_deriv=.true.)
2022 CALL xc_derivative_get(deriv, deriv_data=e_gamma_ab)
2023 deriv => xc_dset_get_derivative(deriv_set, &
2024 [deriv_gamma_bb], &
2025 allocate_deriv=.true.)
2026 CALL xc_derivative_get(deriv, deriv_data=e_gamma_bb)
2027 CASE (xc_family_mgga, xc_family_hyb_mgga)
2028 deriv => xc_dset_get_derivative(deriv_set, [deriv_rhoa], &
2029 allocate_deriv=.true.)
2030 CALL xc_derivative_get(deriv, deriv_data=e_rhoa)
2031 deriv => xc_dset_get_derivative(deriv_set, [deriv_rhob], &
2032 allocate_deriv=.true.)
2033 CALL xc_derivative_get(deriv, deriv_data=e_rhob)
2034 deriv => xc_dset_get_derivative(deriv_set, [deriv_norm_drho], &
2035 allocate_deriv=.true.)
2036 CALL xc_derivative_get(deriv, deriv_data=e_ndrho)
2037 deriv => xc_dset_get_derivative(deriv_set, [deriv_norm_drhoa], &
2038 allocate_deriv=.true.)
2039 CALL xc_derivative_get(deriv, deriv_data=e_ndrhoa)
2040 deriv => xc_dset_get_derivative(deriv_set, [deriv_norm_drhob], &
2041 allocate_deriv=.true.)
2042 CALL xc_derivative_get(deriv, deriv_data=e_ndrhob)
2043 deriv => xc_dset_get_derivative(deriv_set, &
2044 [deriv_gamma_aa], &
2045 allocate_deriv=.true.)
2046 CALL xc_derivative_get(deriv, deriv_data=e_gamma_aa)
2047 deriv => xc_dset_get_derivative(deriv_set, &
2048 [deriv_gamma_ab], &
2049 allocate_deriv=.true.)
2050 CALL xc_derivative_get(deriv, deriv_data=e_gamma_ab)
2051 deriv => xc_dset_get_derivative(deriv_set, &
2052 [deriv_gamma_bb], &
2053 allocate_deriv=.true.)
2054 CALL xc_derivative_get(deriv, deriv_data=e_gamma_bb)
2055 deriv => xc_dset_get_derivative(deriv_set, [deriv_tau_a], &
2056 allocate_deriv=.true.)
2057 CALL xc_derivative_get(deriv, deriv_data=e_tau_a)
2058 deriv => xc_dset_get_derivative(deriv_set, [deriv_tau_b], &
2059 allocate_deriv=.true.)
2060 CALL xc_derivative_get(deriv, deriv_data=e_tau_b)
2061 IF (has_laplace) THEN
2062 deriv => xc_dset_get_derivative(deriv_set, [deriv_laplace_rhoa], &
2063 allocate_deriv=.true.)
2064 CALL xc_derivative_get(deriv, deriv_data=e_laplace_rhoa)
2065 deriv => xc_dset_get_derivative(deriv_set, [deriv_laplace_rhob], &
2066 allocate_deriv=.true.)
2067 CALL xc_derivative_get(deriv, deriv_data=e_laplace_rhob)
2068 END IF
2069 CASE default
2070 cpabort(trim(func_name)//": this XC_FAMILY is currently not supported.")
2071 END SELECT
2072 END IF
2073 IF (grad_deriv >= 2) THEN
2074 SELECT CASE (xc_f03_func_info_get_family(xc_info))
2075 CASE (xc_family_lda, xc_family_hyb_lda)
2076 deriv => xc_dset_get_derivative(deriv_set, [deriv_rhoa, deriv_rhoa], &
2077 allocate_deriv=.true.)
2078 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_rhoa)
2079 deriv => xc_dset_get_derivative(deriv_set, [deriv_rhoa, deriv_rhob], &
2080 allocate_deriv=.true.)
2081 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_rhob)
2082 deriv => xc_dset_get_derivative(deriv_set, [deriv_rhob, deriv_rhob], &
2083 allocate_deriv=.true.)
2084 CALL xc_derivative_get(deriv, deriv_data=e_rhob_rhob)
2085 CASE (xc_family_gga, xc_family_hyb_gga)
2086 deriv => xc_dset_get_derivative(deriv_set, [deriv_rhoa, deriv_rhoa], &
2087 allocate_deriv=.true.)
2088 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_rhoa)
2089 deriv => xc_dset_get_derivative(deriv_set, [deriv_rhoa, deriv_rhob], &
2090 allocate_deriv=.true.)
2091 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_rhob)
2092 deriv => xc_dset_get_derivative(deriv_set, [deriv_rhob, deriv_rhob], &
2093 allocate_deriv=.true.)
2094 CALL xc_derivative_get(deriv, deriv_data=e_rhob_rhob)
2095 deriv => xc_dset_get_derivative(deriv_set, [deriv_norm_drho, deriv_rhoa], &
2096 allocate_deriv=.true.)
2097 CALL xc_derivative_get(deriv, deriv_data=e_ndrho_rhoa)
2098 deriv => xc_dset_get_derivative(deriv_set, [deriv_norm_drho, deriv_rhob], &
2099 allocate_deriv=.true.)
2100 CALL xc_derivative_get(deriv, deriv_data=e_ndrho_rhob)
2101 deriv => xc_dset_get_derivative(deriv_set, [deriv_norm_drhoa, deriv_rhoa], &
2102 allocate_deriv=.true.)
2103 CALL xc_derivative_get(deriv, deriv_data=e_ndrhoa_rhoa)
2104 deriv => xc_dset_get_derivative(deriv_set, [deriv_norm_drhoa, deriv_rhob], &
2105 allocate_deriv=.true.)
2106 CALL xc_derivative_get(deriv, deriv_data=e_ndrhoa_rhob)
2107 deriv => xc_dset_get_derivative(deriv_set, [deriv_norm_drhob, deriv_rhoa], &
2108 allocate_deriv=.true.)
2109 CALL xc_derivative_get(deriv, deriv_data=e_ndrhob_rhoa)
2110 deriv => xc_dset_get_derivative(deriv_set, [deriv_norm_drhob, deriv_rhob], &
2111 allocate_deriv=.true.)
2112 CALL xc_derivative_get(deriv, deriv_data=e_ndrhob_rhob)
2113 deriv => xc_dset_get_derivative(deriv_set, [deriv_norm_drho, deriv_norm_drho], &
2114 allocate_deriv=.true.)
2115 CALL xc_derivative_get(deriv, deriv_data=e_ndrho_ndrho)
2116 deriv => xc_dset_get_derivative(deriv_set, [deriv_norm_drho, deriv_norm_drhoa], &
2117 allocate_deriv=.true.)
2118 CALL xc_derivative_get(deriv, deriv_data=e_ndrho_ndrhoa)
2119 deriv => xc_dset_get_derivative(deriv_set, [deriv_norm_drho, deriv_norm_drhob], &
2120 allocate_deriv=.true.)
2121 CALL xc_derivative_get(deriv, deriv_data=e_ndrho_ndrhob)
2122 deriv => xc_dset_get_derivative(deriv_set, [deriv_norm_drhoa, deriv_norm_drhoa], &
2123 allocate_deriv=.true.)
2124 CALL xc_derivative_get(deriv, deriv_data=e_ndrhoa_ndrhoa)
2125 deriv => xc_dset_get_derivative(deriv_set, [deriv_norm_drhoa, deriv_norm_drhob], &
2126 allocate_deriv=.true.)
2127 CALL xc_derivative_get(deriv, deriv_data=e_ndrhoa_ndrhob)
2128 deriv => xc_dset_get_derivative(deriv_set, [deriv_norm_drhob, deriv_norm_drhob], &
2129 allocate_deriv=.true.)
2130 CALL xc_derivative_get(deriv, deriv_data=e_ndrhob_ndrhob)
2131 deriv => xc_dset_get_derivative(deriv_set, &
2132 [deriv_rhoa, deriv_gamma_aa], &
2133 allocate_deriv=.true.)
2134 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_gamma_aa)
2135 deriv => xc_dset_get_derivative(deriv_set, &
2136 [deriv_rhoa, deriv_gamma_ab], &
2137 allocate_deriv=.true.)
2138 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_gamma_ab)
2139 deriv => xc_dset_get_derivative(deriv_set, &
2140 [deriv_rhoa, deriv_gamma_bb], &
2141 allocate_deriv=.true.)
2142 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_gamma_bb)
2143 deriv => xc_dset_get_derivative(deriv_set, &
2144 [deriv_rhob, deriv_gamma_aa], &
2145 allocate_deriv=.true.)
2146 CALL xc_derivative_get(deriv, deriv_data=e_rhob_gamma_aa)
2147 deriv => xc_dset_get_derivative(deriv_set, &
2148 [deriv_rhob, deriv_gamma_ab], &
2149 allocate_deriv=.true.)
2150 CALL xc_derivative_get(deriv, deriv_data=e_rhob_gamma_ab)
2151 deriv => xc_dset_get_derivative(deriv_set, &
2152 [deriv_rhob, deriv_gamma_bb], &
2153 allocate_deriv=.true.)
2154 CALL xc_derivative_get(deriv, deriv_data=e_rhob_gamma_bb)
2155 deriv => xc_dset_get_derivative(deriv_set, &
2156 [deriv_gamma_aa, deriv_gamma_aa], &
2157 allocate_deriv=.true.)
2158 CALL xc_derivative_get(deriv, deriv_data=e_gamma_aa_gamma_aa)
2159 deriv => xc_dset_get_derivative(deriv_set, &
2160 [deriv_gamma_aa, deriv_gamma_ab], &
2161 allocate_deriv=.true.)
2162 CALL xc_derivative_get(deriv, deriv_data=e_gamma_aa_gamma_ab)
2163 deriv => xc_dset_get_derivative(deriv_set, &
2164 [deriv_gamma_aa, deriv_gamma_bb], &
2165 allocate_deriv=.true.)
2166 CALL xc_derivative_get(deriv, deriv_data=e_gamma_aa_gamma_bb)
2167 deriv => xc_dset_get_derivative(deriv_set, &
2168 [deriv_gamma_ab, deriv_gamma_ab], &
2169 allocate_deriv=.true.)
2170 CALL xc_derivative_get(deriv, deriv_data=e_gamma_ab_gamma_ab)
2171 deriv => xc_dset_get_derivative(deriv_set, &
2172 [deriv_gamma_ab, deriv_gamma_bb], &
2173 allocate_deriv=.true.)
2174 CALL xc_derivative_get(deriv, deriv_data=e_gamma_ab_gamma_bb)
2175 deriv => xc_dset_get_derivative(deriv_set, &
2176 [deriv_gamma_bb, deriv_gamma_bb], &
2177 allocate_deriv=.true.)
2178 CALL xc_derivative_get(deriv, deriv_data=e_gamma_bb_gamma_bb)
2179 CASE (xc_family_mgga, xc_family_hyb_mgga)
2180
2181 deriv => xc_dset_get_derivative(deriv_set, [deriv_rhoa, deriv_rhoa], &
2182 allocate_deriv=.true.)
2183 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_rhoa)
2184 deriv => xc_dset_get_derivative(deriv_set, [deriv_rhoa, deriv_rhob], &
2185 allocate_deriv=.true.)
2186 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_rhob)
2187 deriv => xc_dset_get_derivative(deriv_set, [deriv_rhob, deriv_rhob], &
2188 allocate_deriv=.true.)
2189 CALL xc_derivative_get(deriv, deriv_data=e_rhob_rhob)
2190 deriv => xc_dset_get_derivative(deriv_set, [deriv_norm_drho, deriv_rhoa], &
2191 allocate_deriv=.true.)
2192 CALL xc_derivative_get(deriv, deriv_data=e_ndrho_rhoa)
2193 deriv => xc_dset_get_derivative(deriv_set, [deriv_norm_drho, deriv_rhob], &
2194 allocate_deriv=.true.)
2195 CALL xc_derivative_get(deriv, deriv_data=e_ndrho_rhob)
2196 deriv => xc_dset_get_derivative(deriv_set, [deriv_norm_drhoa, deriv_rhoa], &
2197 allocate_deriv=.true.)
2198 CALL xc_derivative_get(deriv, deriv_data=e_ndrhoa_rhoa)
2199 deriv => xc_dset_get_derivative(deriv_set, [deriv_norm_drhoa, deriv_rhob], &
2200 allocate_deriv=.true.)
2201 CALL xc_derivative_get(deriv, deriv_data=e_ndrhoa_rhob)
2202 deriv => xc_dset_get_derivative(deriv_set, [deriv_norm_drhob, deriv_rhoa], &
2203 allocate_deriv=.true.)
2204 CALL xc_derivative_get(deriv, deriv_data=e_ndrhob_rhoa)
2205 deriv => xc_dset_get_derivative(deriv_set, [deriv_norm_drhob, deriv_rhob], &
2206 allocate_deriv=.true.)
2207 CALL xc_derivative_get(deriv, deriv_data=e_ndrhob_rhob)
2208 deriv => xc_dset_get_derivative(deriv_set, [deriv_norm_drho, deriv_norm_drho], &
2209 allocate_deriv=.true.)
2210 CALL xc_derivative_get(deriv, deriv_data=e_ndrho_ndrho)
2211 deriv => xc_dset_get_derivative(deriv_set, [deriv_norm_drho, deriv_norm_drhoa], &
2212 allocate_deriv=.true.)
2213 CALL xc_derivative_get(deriv, deriv_data=e_ndrho_ndrhoa)
2214 deriv => xc_dset_get_derivative(deriv_set, [deriv_norm_drho, deriv_norm_drhob], &
2215 allocate_deriv=.true.)
2216 CALL xc_derivative_get(deriv, deriv_data=e_ndrho_ndrhob)
2217 deriv => xc_dset_get_derivative(deriv_set, [deriv_norm_drhoa, deriv_norm_drhoa], &
2218 allocate_deriv=.true.)
2219 CALL xc_derivative_get(deriv, deriv_data=e_ndrhoa_ndrhoa)
2220 deriv => xc_dset_get_derivative(deriv_set, [deriv_norm_drhoa, deriv_norm_drhob], &
2221 allocate_deriv=.true.)
2222 CALL xc_derivative_get(deriv, deriv_data=e_ndrhoa_ndrhob)
2223 deriv => xc_dset_get_derivative(deriv_set, [deriv_norm_drhob, deriv_norm_drhob], &
2224 allocate_deriv=.true.)
2225 CALL xc_derivative_get(deriv, deriv_data=e_ndrhob_ndrhob)
2226 deriv => xc_dset_get_derivative(deriv_set, &
2227 [deriv_rhoa, deriv_gamma_aa], &
2228 allocate_deriv=.true.)
2229 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_gamma_aa)
2230 deriv => xc_dset_get_derivative(deriv_set, &
2231 [deriv_rhoa, deriv_gamma_ab], &
2232 allocate_deriv=.true.)
2233 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_gamma_ab)
2234 deriv => xc_dset_get_derivative(deriv_set, &
2235 [deriv_rhoa, deriv_gamma_bb], &
2236 allocate_deriv=.true.)
2237 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_gamma_bb)
2238 deriv => xc_dset_get_derivative(deriv_set, &
2239 [deriv_rhob, deriv_gamma_aa], &
2240 allocate_deriv=.true.)
2241 CALL xc_derivative_get(deriv, deriv_data=e_rhob_gamma_aa)
2242 deriv => xc_dset_get_derivative(deriv_set, &
2243 [deriv_rhob, deriv_gamma_ab], &
2244 allocate_deriv=.true.)
2245 CALL xc_derivative_get(deriv, deriv_data=e_rhob_gamma_ab)
2246 deriv => xc_dset_get_derivative(deriv_set, &
2247 [deriv_rhob, deriv_gamma_bb], &
2248 allocate_deriv=.true.)
2249 CALL xc_derivative_get(deriv, deriv_data=e_rhob_gamma_bb)
2250 deriv => xc_dset_get_derivative(deriv_set, &
2251 [deriv_gamma_aa, deriv_gamma_aa], &
2252 allocate_deriv=.true.)
2253 CALL xc_derivative_get(deriv, deriv_data=e_gamma_aa_gamma_aa)
2254 deriv => xc_dset_get_derivative(deriv_set, &
2255 [deriv_gamma_aa, deriv_gamma_ab], &
2256 allocate_deriv=.true.)
2257 CALL xc_derivative_get(deriv, deriv_data=e_gamma_aa_gamma_ab)
2258 deriv => xc_dset_get_derivative(deriv_set, &
2259 [deriv_gamma_aa, deriv_gamma_bb], &
2260 allocate_deriv=.true.)
2261 CALL xc_derivative_get(deriv, deriv_data=e_gamma_aa_gamma_bb)
2262 deriv => xc_dset_get_derivative(deriv_set, &
2263 [deriv_gamma_aa, deriv_tau_a], &
2264 allocate_deriv=.true.)
2265 CALL xc_derivative_get(deriv, deriv_data=e_gamma_aa_tau_a)
2266 deriv => xc_dset_get_derivative(deriv_set, &
2267 [deriv_gamma_aa, deriv_tau_b], &
2268 allocate_deriv=.true.)
2269 CALL xc_derivative_get(deriv, deriv_data=e_gamma_aa_tau_b)
2270 deriv => xc_dset_get_derivative(deriv_set, &
2271 [deriv_gamma_ab, deriv_gamma_ab], &
2272 allocate_deriv=.true.)
2273 CALL xc_derivative_get(deriv, deriv_data=e_gamma_ab_gamma_ab)
2274 deriv => xc_dset_get_derivative(deriv_set, &
2275 [deriv_gamma_ab, deriv_gamma_bb], &
2276 allocate_deriv=.true.)
2277 CALL xc_derivative_get(deriv, deriv_data=e_gamma_ab_gamma_bb)
2278 deriv => xc_dset_get_derivative(deriv_set, &
2279 [deriv_gamma_ab, deriv_tau_a], &
2280 allocate_deriv=.true.)
2281 CALL xc_derivative_get(deriv, deriv_data=e_gamma_ab_tau_a)
2282 deriv => xc_dset_get_derivative(deriv_set, &
2283 [deriv_gamma_ab, deriv_tau_b], &
2284 allocate_deriv=.true.)
2285 CALL xc_derivative_get(deriv, deriv_data=e_gamma_ab_tau_b)
2286 deriv => xc_dset_get_derivative(deriv_set, &
2287 [deriv_gamma_bb, deriv_gamma_bb], &
2288 allocate_deriv=.true.)
2289 CALL xc_derivative_get(deriv, deriv_data=e_gamma_bb_gamma_bb)
2290 deriv => xc_dset_get_derivative(deriv_set, &
2291 [deriv_gamma_bb, deriv_tau_a], &
2292 allocate_deriv=.true.)
2293 CALL xc_derivative_get(deriv, deriv_data=e_gamma_bb_tau_a)
2294 deriv => xc_dset_get_derivative(deriv_set, &
2295 [deriv_gamma_bb, deriv_tau_b], &
2296 allocate_deriv=.true.)
2297 CALL xc_derivative_get(deriv, deriv_data=e_gamma_bb_tau_b)
2298 IF (has_laplace) THEN
2299 deriv => xc_dset_get_derivative(deriv_set, &
2300 [deriv_gamma_aa, deriv_laplace_rhoa], &
2301 allocate_deriv=.true.)
2302 CALL xc_derivative_get(deriv, deriv_data=e_gamma_aa_laplace_rhoa)
2303 deriv => xc_dset_get_derivative(deriv_set, &
2304 [deriv_gamma_aa, deriv_laplace_rhob], &
2305 allocate_deriv=.true.)
2306 CALL xc_derivative_get(deriv, deriv_data=e_gamma_aa_laplace_rhob)
2307 deriv => xc_dset_get_derivative(deriv_set, &
2308 [deriv_gamma_ab, deriv_laplace_rhoa], &
2309 allocate_deriv=.true.)
2310 CALL xc_derivative_get(deriv, deriv_data=e_gamma_ab_laplace_rhoa)
2311 deriv => xc_dset_get_derivative(deriv_set, &
2312 [deriv_gamma_ab, deriv_laplace_rhob], &
2313 allocate_deriv=.true.)
2314 CALL xc_derivative_get(deriv, deriv_data=e_gamma_ab_laplace_rhob)
2315 deriv => xc_dset_get_derivative(deriv_set, &
2316 [deriv_gamma_bb, deriv_laplace_rhoa], &
2317 allocate_deriv=.true.)
2318 CALL xc_derivative_get(deriv, deriv_data=e_gamma_bb_laplace_rhoa)
2319 deriv => xc_dset_get_derivative(deriv_set, &
2320 [deriv_gamma_bb, deriv_laplace_rhob], &
2321 allocate_deriv=.true.)
2322 CALL xc_derivative_get(deriv, deriv_data=e_gamma_bb_laplace_rhob)
2323 END IF
2324 deriv => xc_dset_get_derivative(deriv_set, [deriv_rhoa, deriv_tau_a], &
2325 allocate_deriv=.true.)
2326 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_tau_a)
2327 deriv => xc_dset_get_derivative(deriv_set, [deriv_rhoa, deriv_tau_b], &
2328 allocate_deriv=.true.)
2329 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_tau_b)
2330 deriv => xc_dset_get_derivative(deriv_set, [deriv_rhob, deriv_tau_a], &
2331 allocate_deriv=.true.)
2332 CALL xc_derivative_get(deriv, deriv_data=e_rhob_tau_a)
2333 deriv => xc_dset_get_derivative(deriv_set, [deriv_rhob, deriv_tau_b], &
2334 allocate_deriv=.true.)
2335 CALL xc_derivative_get(deriv, deriv_data=e_rhob_tau_b)
2336 deriv => xc_dset_get_derivative(deriv_set, [deriv_norm_drho, deriv_tau_a], &
2337 allocate_deriv=.true.)
2338 CALL xc_derivative_get(deriv, deriv_data=e_ndrho_tau_a)
2339 deriv => xc_dset_get_derivative(deriv_set, [deriv_norm_drho, deriv_tau_b], &
2340 allocate_deriv=.true.)
2341 CALL xc_derivative_get(deriv, deriv_data=e_ndrho_tau_b)
2342 deriv => xc_dset_get_derivative(deriv_set, [deriv_norm_drhoa, deriv_tau_a], &
2343 allocate_deriv=.true.)
2344 CALL xc_derivative_get(deriv, deriv_data=e_ndrhoa_tau_a)
2345 deriv => xc_dset_get_derivative(deriv_set, [deriv_norm_drhoa, deriv_tau_b], &
2346 allocate_deriv=.true.)
2347 CALL xc_derivative_get(deriv, deriv_data=e_ndrhoa_tau_b)
2348 deriv => xc_dset_get_derivative(deriv_set, [deriv_norm_drhob, deriv_tau_a], &
2349 allocate_deriv=.true.)
2350 CALL xc_derivative_get(deriv, deriv_data=e_ndrhob_tau_a)
2351 deriv => xc_dset_get_derivative(deriv_set, [deriv_norm_drhob, deriv_tau_b], &
2352 allocate_deriv=.true.)
2353 CALL xc_derivative_get(deriv, deriv_data=e_ndrhob_tau_b)
2354 deriv => xc_dset_get_derivative(deriv_set, [deriv_tau_a, deriv_tau_a], &
2355 allocate_deriv=.true.)
2356 CALL xc_derivative_get(deriv, deriv_data=e_tau_a_tau_a)
2357 deriv => xc_dset_get_derivative(deriv_set, [deriv_tau_a, deriv_tau_b], &
2358 allocate_deriv=.true.)
2359 CALL xc_derivative_get(deriv, deriv_data=e_tau_a_tau_b)
2360 deriv => xc_dset_get_derivative(deriv_set, [deriv_tau_b, deriv_tau_b], &
2361 allocate_deriv=.true.)
2362 CALL xc_derivative_get(deriv, deriv_data=e_tau_b_tau_b)
2363 IF (has_laplace) THEN
2364 deriv => xc_dset_get_derivative(deriv_set, [deriv_rhoa, deriv_laplace_rhoa], &
2365 allocate_deriv=.true.)
2366 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_laplace_rhoa)
2367 deriv => xc_dset_get_derivative(deriv_set, [deriv_rhoa, deriv_laplace_rhob], &
2368 allocate_deriv=.true.)
2369 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_laplace_rhob)
2370 deriv => xc_dset_get_derivative(deriv_set, [deriv_rhob, deriv_laplace_rhoa], &
2371 allocate_deriv=.true.)
2372 CALL xc_derivative_get(deriv, deriv_data=e_rhob_laplace_rhoa)
2373 deriv => xc_dset_get_derivative(deriv_set, [deriv_rhob, deriv_laplace_rhob], &
2374 allocate_deriv=.true.)
2375 CALL xc_derivative_get(deriv, deriv_data=e_rhob_laplace_rhob)
2376 deriv => xc_dset_get_derivative(deriv_set, [deriv_norm_drho, deriv_laplace_rhoa], &
2377 allocate_deriv=.true.)
2378 CALL xc_derivative_get(deriv, deriv_data=e_ndrho_laplace_rhoa)
2379 deriv => xc_dset_get_derivative(deriv_set, [deriv_norm_drho, deriv_laplace_rhob], &
2380 allocate_deriv=.true.)
2381 CALL xc_derivative_get(deriv, deriv_data=e_ndrho_laplace_rhob)
2382 deriv => xc_dset_get_derivative(deriv_set, [deriv_norm_drhoa, deriv_laplace_rhoa], &
2383 allocate_deriv=.true.)
2384 CALL xc_derivative_get(deriv, deriv_data=e_ndrhoa_laplace_rhoa)
2385 deriv => xc_dset_get_derivative(deriv_set, [deriv_norm_drhoa, deriv_laplace_rhob], &
2386 allocate_deriv=.true.)
2387 CALL xc_derivative_get(deriv, deriv_data=e_ndrhoa_laplace_rhob)
2388 deriv => xc_dset_get_derivative(deriv_set, [deriv_norm_drhob, deriv_laplace_rhoa], &
2389 allocate_deriv=.true.)
2390 CALL xc_derivative_get(deriv, deriv_data=e_ndrhob_laplace_rhoa)
2391 deriv => xc_dset_get_derivative(deriv_set, [deriv_norm_drhob, deriv_laplace_rhob], &
2392 allocate_deriv=.true.)
2393 CALL xc_derivative_get(deriv, deriv_data=e_ndrhob_laplace_rhob)
2394 deriv => xc_dset_get_derivative(deriv_set, [deriv_laplace_rhoa, deriv_laplace_rhoa], &
2395 allocate_deriv=.true.)
2396 CALL xc_derivative_get(deriv, deriv_data=e_laplace_rhoa_laplace_rhoa)
2397 deriv => xc_dset_get_derivative(deriv_set, [deriv_laplace_rhoa, deriv_laplace_rhob], &
2398 allocate_deriv=.true.)
2399 CALL xc_derivative_get(deriv, deriv_data=e_laplace_rhoa_laplace_rhob)
2400 deriv => xc_dset_get_derivative(deriv_set, [deriv_laplace_rhob, deriv_laplace_rhob], &
2401 allocate_deriv=.true.)
2402 CALL xc_derivative_get(deriv, deriv_data=e_laplace_rhob_laplace_rhob)
2403 deriv => xc_dset_get_derivative(deriv_set, [deriv_laplace_rhoa, deriv_tau_a], &
2404 allocate_deriv=.true.)
2405 CALL xc_derivative_get(deriv, deriv_data=e_laplace_rhoa_tau_a)
2406 deriv => xc_dset_get_derivative(deriv_set, [deriv_laplace_rhoa, deriv_tau_b], &
2407 allocate_deriv=.true.)
2408 CALL xc_derivative_get(deriv, deriv_data=e_laplace_rhoa_tau_b)
2409 deriv => xc_dset_get_derivative(deriv_set, [deriv_laplace_rhob, deriv_tau_a], &
2410 allocate_deriv=.true.)
2411 CALL xc_derivative_get(deriv, deriv_data=e_laplace_rhob_tau_a)
2412 deriv => xc_dset_get_derivative(deriv_set, [deriv_laplace_rhob, deriv_tau_b], &
2413 allocate_deriv=.true.)
2414 CALL xc_derivative_get(deriv, deriv_data=e_laplace_rhob_tau_b)
2415 END IF
2416 CASE default
2417 cpabort(trim(func_name)//": this XC_FAMILY is currently not supported.")
2418 END SELECT
2419 END IF
2420 IF (grad_deriv >= 3) THEN
2421 SELECT CASE (xc_f03_func_info_get_family(xc_info))
2422 CASE (xc_family_lda, xc_family_hyb_lda)
2423 deriv => xc_dset_get_derivative(deriv_set, [deriv_rhoa, deriv_rhoa, deriv_rhoa], &
2424 allocate_deriv=.true.)
2425 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_rhoa_rhoa)
2426 deriv => xc_dset_get_derivative(deriv_set, [deriv_rhoa, deriv_rhoa, deriv_rhob], &
2427 allocate_deriv=.true.)
2428 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_rhoa_rhob)
2429 deriv => xc_dset_get_derivative(deriv_set, [deriv_rhoa, deriv_rhob, deriv_rhob], &
2430 allocate_deriv=.true.)
2431 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_rhob_rhob)
2432 deriv => xc_dset_get_derivative(deriv_set, [deriv_rhob, deriv_rhob, deriv_rhob], &
2433 allocate_deriv=.true.)
2434 CALL xc_derivative_get(deriv, deriv_data=e_rhob_rhob_rhob)
2435 CASE (xc_family_gga, xc_family_hyb_gga)
2436 deriv => xc_dset_get_derivative(deriv_set, &
2437 [deriv_rhoa, deriv_rhoa, deriv_gamma_aa], &
2438 allocate_deriv=.true.)
2439 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_rhoa_gamma_aa)
2440 deriv => xc_dset_get_derivative(deriv_set, &
2441 [deriv_rhoa, deriv_rhoa, deriv_gamma_ab], &
2442 allocate_deriv=.true.)
2443 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_rhoa_gamma_ab)
2444 deriv => xc_dset_get_derivative(deriv_set, &
2445 [deriv_rhoa, deriv_rhoa, deriv_gamma_bb], &
2446 allocate_deriv=.true.)
2447 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_rhoa_gamma_bb)
2448 deriv => xc_dset_get_derivative(deriv_set, &
2449 [deriv_rhoa, deriv_rhob, deriv_gamma_aa], &
2450 allocate_deriv=.true.)
2451 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_rhob_gamma_aa)
2452 deriv => xc_dset_get_derivative(deriv_set, &
2453 [deriv_rhoa, deriv_rhob, deriv_gamma_ab], &
2454 allocate_deriv=.true.)
2455 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_rhob_gamma_ab)
2456 deriv => xc_dset_get_derivative(deriv_set, &
2457 [deriv_rhoa, deriv_rhob, deriv_gamma_bb], &
2458 allocate_deriv=.true.)
2459 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_rhob_gamma_bb)
2460 deriv => xc_dset_get_derivative(deriv_set, &
2461 [deriv_rhoa, deriv_gamma_aa, deriv_gamma_aa], &
2462 allocate_deriv=.true.)
2463 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_gamma_aa_gamma_aa)
2464 deriv => xc_dset_get_derivative(deriv_set, &
2465 [deriv_rhoa, deriv_gamma_aa, deriv_gamma_ab], &
2466 allocate_deriv=.true.)
2467 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_gamma_aa_gamma_ab)
2468 deriv => xc_dset_get_derivative(deriv_set, &
2469 [deriv_rhoa, deriv_gamma_aa, deriv_gamma_bb], &
2470 allocate_deriv=.true.)
2471 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_gamma_aa_gamma_bb)
2472 deriv => xc_dset_get_derivative(deriv_set, &
2473 [deriv_rhoa, deriv_gamma_ab, deriv_gamma_ab], &
2474 allocate_deriv=.true.)
2475 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_gamma_ab_gamma_ab)
2476 deriv => xc_dset_get_derivative(deriv_set, &
2477 [deriv_rhoa, deriv_gamma_ab, deriv_gamma_bb], &
2478 allocate_deriv=.true.)
2479 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_gamma_ab_gamma_bb)
2480 deriv => xc_dset_get_derivative(deriv_set, &
2481 [deriv_rhoa, deriv_gamma_bb, deriv_gamma_bb], &
2482 allocate_deriv=.true.)
2483 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_gamma_bb_gamma_bb)
2484 deriv => xc_dset_get_derivative(deriv_set, &
2485 [deriv_rhob, deriv_rhob, deriv_gamma_aa], &
2486 allocate_deriv=.true.)
2487 CALL xc_derivative_get(deriv, deriv_data=e_rhob_rhob_gamma_aa)
2488 deriv => xc_dset_get_derivative(deriv_set, &
2489 [deriv_rhob, deriv_rhob, deriv_gamma_ab], &
2490 allocate_deriv=.true.)
2491 CALL xc_derivative_get(deriv, deriv_data=e_rhob_rhob_gamma_ab)
2492 deriv => xc_dset_get_derivative(deriv_set, &
2493 [deriv_rhob, deriv_rhob, deriv_gamma_bb], &
2494 allocate_deriv=.true.)
2495 CALL xc_derivative_get(deriv, deriv_data=e_rhob_rhob_gamma_bb)
2496 deriv => xc_dset_get_derivative(deriv_set, &
2497 [deriv_rhob, deriv_gamma_aa, deriv_gamma_aa], &
2498 allocate_deriv=.true.)
2499 CALL xc_derivative_get(deriv, deriv_data=e_rhob_gamma_aa_gamma_aa)
2500 deriv => xc_dset_get_derivative(deriv_set, &
2501 [deriv_rhob, deriv_gamma_aa, deriv_gamma_ab], &
2502 allocate_deriv=.true.)
2503 CALL xc_derivative_get(deriv, deriv_data=e_rhob_gamma_aa_gamma_ab)
2504 deriv => xc_dset_get_derivative(deriv_set, &
2505 [deriv_rhob, deriv_gamma_aa, deriv_gamma_bb], &
2506 allocate_deriv=.true.)
2507 CALL xc_derivative_get(deriv, deriv_data=e_rhob_gamma_aa_gamma_bb)
2508 deriv => xc_dset_get_derivative(deriv_set, &
2509 [deriv_rhob, deriv_gamma_ab, deriv_gamma_ab], &
2510 allocate_deriv=.true.)
2511 CALL xc_derivative_get(deriv, deriv_data=e_rhob_gamma_ab_gamma_ab)
2512 deriv => xc_dset_get_derivative(deriv_set, &
2513 [deriv_rhob, deriv_gamma_ab, deriv_gamma_bb], &
2514 allocate_deriv=.true.)
2515 CALL xc_derivative_get(deriv, deriv_data=e_rhob_gamma_ab_gamma_bb)
2516 deriv => xc_dset_get_derivative(deriv_set, &
2517 [deriv_rhob, deriv_gamma_bb, deriv_gamma_bb], &
2518 allocate_deriv=.true.)
2519 CALL xc_derivative_get(deriv, deriv_data=e_rhob_gamma_bb_gamma_bb)
2520 deriv => xc_dset_get_derivative(deriv_set, &
2521 [deriv_gamma_aa, deriv_gamma_aa, deriv_gamma_aa], &
2522 allocate_deriv=.true.)
2523 CALL xc_derivative_get(deriv, deriv_data=e_gamma_aa_gamma_aa_gamma_aa)
2524 deriv => xc_dset_get_derivative(deriv_set, &
2525 [deriv_gamma_aa, deriv_gamma_aa, deriv_gamma_ab], &
2526 allocate_deriv=.true.)
2527 CALL xc_derivative_get(deriv, deriv_data=e_gamma_aa_gamma_aa_gamma_ab)
2528 deriv => xc_dset_get_derivative(deriv_set, &
2529 [deriv_gamma_aa, deriv_gamma_aa, deriv_gamma_bb], &
2530 allocate_deriv=.true.)
2531 CALL xc_derivative_get(deriv, deriv_data=e_gamma_aa_gamma_aa_gamma_bb)
2532 deriv => xc_dset_get_derivative(deriv_set, &
2533 [deriv_gamma_aa, deriv_gamma_ab, deriv_gamma_ab], &
2534 allocate_deriv=.true.)
2535 CALL xc_derivative_get(deriv, deriv_data=e_gamma_aa_gamma_ab_gamma_ab)
2536 deriv => xc_dset_get_derivative(deriv_set, &
2537 [deriv_gamma_aa, deriv_gamma_ab, deriv_gamma_bb], &
2538 allocate_deriv=.true.)
2539 CALL xc_derivative_get(deriv, deriv_data=e_gamma_aa_gamma_ab_gamma_bb)
2540 deriv => xc_dset_get_derivative(deriv_set, &
2541 [deriv_gamma_aa, deriv_gamma_bb, deriv_gamma_bb], &
2542 allocate_deriv=.true.)
2543 CALL xc_derivative_get(deriv, deriv_data=e_gamma_aa_gamma_bb_gamma_bb)
2544 deriv => xc_dset_get_derivative(deriv_set, &
2545 [deriv_gamma_ab, deriv_gamma_ab, deriv_gamma_ab], &
2546 allocate_deriv=.true.)
2547 CALL xc_derivative_get(deriv, deriv_data=e_gamma_ab_gamma_ab_gamma_ab)
2548 deriv => xc_dset_get_derivative(deriv_set, &
2549 [deriv_gamma_ab, deriv_gamma_ab, deriv_gamma_bb], &
2550 allocate_deriv=.true.)
2551 CALL xc_derivative_get(deriv, deriv_data=e_gamma_ab_gamma_ab_gamma_bb)
2552 deriv => xc_dset_get_derivative(deriv_set, &
2553 [deriv_gamma_ab, deriv_gamma_bb, deriv_gamma_bb], &
2554 allocate_deriv=.true.)
2555 CALL xc_derivative_get(deriv, deriv_data=e_gamma_ab_gamma_bb_gamma_bb)
2556 deriv => xc_dset_get_derivative(deriv_set, &
2557 [deriv_gamma_bb, deriv_gamma_bb, deriv_gamma_bb], &
2558 allocate_deriv=.true.)
2559 CALL xc_derivative_get(deriv, deriv_data=e_gamma_bb_gamma_bb_gamma_bb)
2560 deriv => xc_dset_get_derivative(deriv_set, &
2561 [deriv_rhoa, deriv_rhoa, deriv_rhoa], &
2562 allocate_deriv=.true.)
2563 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_rhoa_rhoa)
2564 deriv => xc_dset_get_derivative(deriv_set, &
2565 [deriv_rhoa, deriv_rhoa, deriv_rhob], &
2566 allocate_deriv=.true.)
2567 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_rhoa_rhob)
2568 deriv => xc_dset_get_derivative(deriv_set, &
2569 [deriv_rhoa, deriv_rhob, deriv_rhob], &
2570 allocate_deriv=.true.)
2571 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_rhob_rhob)
2572 deriv => xc_dset_get_derivative(deriv_set, &
2573 [deriv_rhob, deriv_rhob, deriv_rhob], &
2574 allocate_deriv=.true.)
2575 CALL xc_derivative_get(deriv, deriv_data=e_rhob_rhob_rhob)
2576 CASE (xc_family_mgga, xc_family_hyb_mgga)
2577 deriv => xc_dset_get_derivative(deriv_set, &
2578 [deriv_rhoa, deriv_rhoa, deriv_gamma_aa], &
2579 allocate_deriv=.true.)
2580 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_rhoa_gamma_aa)
2581 deriv => xc_dset_get_derivative(deriv_set, &
2582 [deriv_rhoa, deriv_rhoa, deriv_gamma_ab], &
2583 allocate_deriv=.true.)
2584 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_rhoa_gamma_ab)
2585 deriv => xc_dset_get_derivative(deriv_set, &
2586 [deriv_rhoa, deriv_rhoa, deriv_gamma_bb], &
2587 allocate_deriv=.true.)
2588 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_rhoa_gamma_bb)
2589 deriv => xc_dset_get_derivative(deriv_set, &
2590 [deriv_rhoa, deriv_rhoa, deriv_tau_a], &
2591 allocate_deriv=.true.)
2592 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_rhoa_tau_a)
2593 deriv => xc_dset_get_derivative(deriv_set, &
2594 [deriv_rhoa, deriv_rhoa, deriv_tau_b], &
2595 allocate_deriv=.true.)
2596 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_rhoa_tau_b)
2597 deriv => xc_dset_get_derivative(deriv_set, &
2598 [deriv_rhoa, deriv_rhob, deriv_gamma_aa], &
2599 allocate_deriv=.true.)
2600 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_rhob_gamma_aa)
2601 deriv => xc_dset_get_derivative(deriv_set, &
2602 [deriv_rhoa, deriv_rhob, deriv_gamma_ab], &
2603 allocate_deriv=.true.)
2604 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_rhob_gamma_ab)
2605 deriv => xc_dset_get_derivative(deriv_set, &
2606 [deriv_rhoa, deriv_rhob, deriv_gamma_bb], &
2607 allocate_deriv=.true.)
2608 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_rhob_gamma_bb)
2609 deriv => xc_dset_get_derivative(deriv_set, &
2610 [deriv_rhoa, deriv_rhob, deriv_tau_a], &
2611 allocate_deriv=.true.)
2612 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_rhob_tau_a)
2613 deriv => xc_dset_get_derivative(deriv_set, &
2614 [deriv_rhoa, deriv_rhob, deriv_tau_b], &
2615 allocate_deriv=.true.)
2616 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_rhob_tau_b)
2617 deriv => xc_dset_get_derivative(deriv_set, &
2618 [deriv_rhoa, deriv_gamma_aa, deriv_gamma_aa], &
2619 allocate_deriv=.true.)
2620 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_gamma_aa_gamma_aa)
2621 deriv => xc_dset_get_derivative(deriv_set, &
2622 [deriv_rhoa, deriv_gamma_aa, deriv_gamma_ab], &
2623 allocate_deriv=.true.)
2624 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_gamma_aa_gamma_ab)
2625 deriv => xc_dset_get_derivative(deriv_set, &
2626 [deriv_rhoa, deriv_gamma_aa, deriv_gamma_bb], &
2627 allocate_deriv=.true.)
2628 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_gamma_aa_gamma_bb)
2629 deriv => xc_dset_get_derivative(deriv_set, &
2630 [deriv_rhoa, deriv_gamma_aa, deriv_tau_a], &
2631 allocate_deriv=.true.)
2632 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_gamma_aa_tau_a)
2633 deriv => xc_dset_get_derivative(deriv_set, &
2634 [deriv_rhoa, deriv_gamma_aa, deriv_tau_b], &
2635 allocate_deriv=.true.)
2636 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_gamma_aa_tau_b)
2637 deriv => xc_dset_get_derivative(deriv_set, &
2638 [deriv_rhoa, deriv_gamma_ab, deriv_gamma_ab], &
2639 allocate_deriv=.true.)
2640 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_gamma_ab_gamma_ab)
2641 deriv => xc_dset_get_derivative(deriv_set, &
2642 [deriv_rhoa, deriv_gamma_ab, deriv_gamma_bb], &
2643 allocate_deriv=.true.)
2644 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_gamma_ab_gamma_bb)
2645 deriv => xc_dset_get_derivative(deriv_set, &
2646 [deriv_rhoa, deriv_gamma_ab, deriv_tau_a], &
2647 allocate_deriv=.true.)
2648 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_gamma_ab_tau_a)
2649 deriv => xc_dset_get_derivative(deriv_set, &
2650 [deriv_rhoa, deriv_gamma_ab, deriv_tau_b], &
2651 allocate_deriv=.true.)
2652 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_gamma_ab_tau_b)
2653 deriv => xc_dset_get_derivative(deriv_set, &
2654 [deriv_rhoa, deriv_gamma_bb, deriv_gamma_bb], &
2655 allocate_deriv=.true.)
2656 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_gamma_bb_gamma_bb)
2657 deriv => xc_dset_get_derivative(deriv_set, &
2658 [deriv_rhoa, deriv_gamma_bb, deriv_tau_a], &
2659 allocate_deriv=.true.)
2660 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_gamma_bb_tau_a)
2661 deriv => xc_dset_get_derivative(deriv_set, &
2662 [deriv_rhoa, deriv_gamma_bb, deriv_tau_b], &
2663 allocate_deriv=.true.)
2664 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_gamma_bb_tau_b)
2665 deriv => xc_dset_get_derivative(deriv_set, &
2666 [deriv_rhoa, deriv_tau_a, deriv_tau_a], &
2667 allocate_deriv=.true.)
2668 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_tau_a_tau_a)
2669 deriv => xc_dset_get_derivative(deriv_set, &
2670 [deriv_rhoa, deriv_tau_a, deriv_tau_b], &
2671 allocate_deriv=.true.)
2672 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_tau_a_tau_b)
2673 deriv => xc_dset_get_derivative(deriv_set, &
2674 [deriv_rhoa, deriv_tau_b, deriv_tau_b], &
2675 allocate_deriv=.true.)
2676 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_tau_b_tau_b)
2677 deriv => xc_dset_get_derivative(deriv_set, &
2678 [deriv_rhob, deriv_rhob, deriv_gamma_aa], &
2679 allocate_deriv=.true.)
2680 CALL xc_derivative_get(deriv, deriv_data=e_rhob_rhob_gamma_aa)
2681 deriv => xc_dset_get_derivative(deriv_set, &
2682 [deriv_rhob, deriv_rhob, deriv_gamma_ab], &
2683 allocate_deriv=.true.)
2684 CALL xc_derivative_get(deriv, deriv_data=e_rhob_rhob_gamma_ab)
2685 deriv => xc_dset_get_derivative(deriv_set, &
2686 [deriv_rhob, deriv_rhob, deriv_gamma_bb], &
2687 allocate_deriv=.true.)
2688 CALL xc_derivative_get(deriv, deriv_data=e_rhob_rhob_gamma_bb)
2689 deriv => xc_dset_get_derivative(deriv_set, &
2690 [deriv_rhob, deriv_rhob, deriv_tau_a], &
2691 allocate_deriv=.true.)
2692 CALL xc_derivative_get(deriv, deriv_data=e_rhob_rhob_tau_a)
2693 deriv => xc_dset_get_derivative(deriv_set, &
2694 [deriv_rhob, deriv_rhob, deriv_tau_b], &
2695 allocate_deriv=.true.)
2696 CALL xc_derivative_get(deriv, deriv_data=e_rhob_rhob_tau_b)
2697 deriv => xc_dset_get_derivative(deriv_set, &
2698 [deriv_rhob, deriv_gamma_aa, deriv_gamma_aa], &
2699 allocate_deriv=.true.)
2700 CALL xc_derivative_get(deriv, deriv_data=e_rhob_gamma_aa_gamma_aa)
2701 deriv => xc_dset_get_derivative(deriv_set, &
2702 [deriv_rhob, deriv_gamma_aa, deriv_gamma_ab], &
2703 allocate_deriv=.true.)
2704 CALL xc_derivative_get(deriv, deriv_data=e_rhob_gamma_aa_gamma_ab)
2705 deriv => xc_dset_get_derivative(deriv_set, &
2706 [deriv_rhob, deriv_gamma_aa, deriv_gamma_bb], &
2707 allocate_deriv=.true.)
2708 CALL xc_derivative_get(deriv, deriv_data=e_rhob_gamma_aa_gamma_bb)
2709 deriv => xc_dset_get_derivative(deriv_set, &
2710 [deriv_rhob, deriv_gamma_aa, deriv_tau_a], &
2711 allocate_deriv=.true.)
2712 CALL xc_derivative_get(deriv, deriv_data=e_rhob_gamma_aa_tau_a)
2713 deriv => xc_dset_get_derivative(deriv_set, &
2714 [deriv_rhob, deriv_gamma_aa, deriv_tau_b], &
2715 allocate_deriv=.true.)
2716 CALL xc_derivative_get(deriv, deriv_data=e_rhob_gamma_aa_tau_b)
2717 deriv => xc_dset_get_derivative(deriv_set, &
2718 [deriv_rhob, deriv_gamma_ab, deriv_gamma_ab], &
2719 allocate_deriv=.true.)
2720 CALL xc_derivative_get(deriv, deriv_data=e_rhob_gamma_ab_gamma_ab)
2721 deriv => xc_dset_get_derivative(deriv_set, &
2722 [deriv_rhob, deriv_gamma_ab, deriv_gamma_bb], &
2723 allocate_deriv=.true.)
2724 CALL xc_derivative_get(deriv, deriv_data=e_rhob_gamma_ab_gamma_bb)
2725 deriv => xc_dset_get_derivative(deriv_set, &
2726 [deriv_rhob, deriv_gamma_ab, deriv_tau_a], &
2727 allocate_deriv=.true.)
2728 CALL xc_derivative_get(deriv, deriv_data=e_rhob_gamma_ab_tau_a)
2729 deriv => xc_dset_get_derivative(deriv_set, &
2730 [deriv_rhob, deriv_gamma_ab, deriv_tau_b], &
2731 allocate_deriv=.true.)
2732 CALL xc_derivative_get(deriv, deriv_data=e_rhob_gamma_ab_tau_b)
2733 deriv => xc_dset_get_derivative(deriv_set, &
2734 [deriv_rhob, deriv_gamma_bb, deriv_gamma_bb], &
2735 allocate_deriv=.true.)
2736 CALL xc_derivative_get(deriv, deriv_data=e_rhob_gamma_bb_gamma_bb)
2737 deriv => xc_dset_get_derivative(deriv_set, &
2738 [deriv_rhob, deriv_gamma_bb, deriv_tau_a], &
2739 allocate_deriv=.true.)
2740 CALL xc_derivative_get(deriv, deriv_data=e_rhob_gamma_bb_tau_a)
2741 deriv => xc_dset_get_derivative(deriv_set, &
2742 [deriv_rhob, deriv_gamma_bb, deriv_tau_b], &
2743 allocate_deriv=.true.)
2744 CALL xc_derivative_get(deriv, deriv_data=e_rhob_gamma_bb_tau_b)
2745 deriv => xc_dset_get_derivative(deriv_set, &
2746 [deriv_rhob, deriv_tau_a, deriv_tau_a], &
2747 allocate_deriv=.true.)
2748 CALL xc_derivative_get(deriv, deriv_data=e_rhob_tau_a_tau_a)
2749 deriv => xc_dset_get_derivative(deriv_set, &
2750 [deriv_rhob, deriv_tau_a, deriv_tau_b], &
2751 allocate_deriv=.true.)
2752 CALL xc_derivative_get(deriv, deriv_data=e_rhob_tau_a_tau_b)
2753 deriv => xc_dset_get_derivative(deriv_set, &
2754 [deriv_rhob, deriv_tau_b, deriv_tau_b], &
2755 allocate_deriv=.true.)
2756 CALL xc_derivative_get(deriv, deriv_data=e_rhob_tau_b_tau_b)
2757 deriv => xc_dset_get_derivative(deriv_set, &
2758 [deriv_gamma_aa, deriv_gamma_aa, deriv_gamma_aa], &
2759 allocate_deriv=.true.)
2760 CALL xc_derivative_get(deriv, deriv_data=e_gamma_aa_gamma_aa_gamma_aa)
2761 deriv => xc_dset_get_derivative(deriv_set, &
2762 [deriv_gamma_aa, deriv_gamma_aa, deriv_gamma_ab], &
2763 allocate_deriv=.true.)
2764 CALL xc_derivative_get(deriv, deriv_data=e_gamma_aa_gamma_aa_gamma_ab)
2765 deriv => xc_dset_get_derivative(deriv_set, &
2766 [deriv_gamma_aa, deriv_gamma_aa, deriv_gamma_bb], &
2767 allocate_deriv=.true.)
2768 CALL xc_derivative_get(deriv, deriv_data=e_gamma_aa_gamma_aa_gamma_bb)
2769 deriv => xc_dset_get_derivative(deriv_set, &
2770 [deriv_gamma_aa, deriv_gamma_aa, deriv_tau_a], &
2771 allocate_deriv=.true.)
2772 CALL xc_derivative_get(deriv, deriv_data=e_gamma_aa_gamma_aa_tau_a)
2773 deriv => xc_dset_get_derivative(deriv_set, &
2774 [deriv_gamma_aa, deriv_gamma_aa, deriv_tau_b], &
2775 allocate_deriv=.true.)
2776 CALL xc_derivative_get(deriv, deriv_data=e_gamma_aa_gamma_aa_tau_b)
2777 deriv => xc_dset_get_derivative(deriv_set, &
2778 [deriv_gamma_aa, deriv_gamma_ab, deriv_gamma_ab], &
2779 allocate_deriv=.true.)
2780 CALL xc_derivative_get(deriv, deriv_data=e_gamma_aa_gamma_ab_gamma_ab)
2781 deriv => xc_dset_get_derivative(deriv_set, &
2782 [deriv_gamma_aa, deriv_gamma_ab, deriv_gamma_bb], &
2783 allocate_deriv=.true.)
2784 CALL xc_derivative_get(deriv, deriv_data=e_gamma_aa_gamma_ab_gamma_bb)
2785 deriv => xc_dset_get_derivative(deriv_set, &
2786 [deriv_gamma_aa, deriv_gamma_ab, deriv_tau_a], &
2787 allocate_deriv=.true.)
2788 CALL xc_derivative_get(deriv, deriv_data=e_gamma_aa_gamma_ab_tau_a)
2789 deriv => xc_dset_get_derivative(deriv_set, &
2790 [deriv_gamma_aa, deriv_gamma_ab, deriv_tau_b], &
2791 allocate_deriv=.true.)
2792 CALL xc_derivative_get(deriv, deriv_data=e_gamma_aa_gamma_ab_tau_b)
2793 deriv => xc_dset_get_derivative(deriv_set, &
2794 [deriv_gamma_aa, deriv_gamma_bb, deriv_gamma_bb], &
2795 allocate_deriv=.true.)
2796 CALL xc_derivative_get(deriv, deriv_data=e_gamma_aa_gamma_bb_gamma_bb)
2797 deriv => xc_dset_get_derivative(deriv_set, &
2798 [deriv_gamma_aa, deriv_gamma_bb, deriv_tau_a], &
2799 allocate_deriv=.true.)
2800 CALL xc_derivative_get(deriv, deriv_data=e_gamma_aa_gamma_bb_tau_a)
2801 deriv => xc_dset_get_derivative(deriv_set, &
2802 [deriv_gamma_aa, deriv_gamma_bb, deriv_tau_b], &
2803 allocate_deriv=.true.)
2804 CALL xc_derivative_get(deriv, deriv_data=e_gamma_aa_gamma_bb_tau_b)
2805 deriv => xc_dset_get_derivative(deriv_set, &
2806 [deriv_gamma_aa, deriv_tau_a, deriv_tau_a], &
2807 allocate_deriv=.true.)
2808 CALL xc_derivative_get(deriv, deriv_data=e_gamma_aa_tau_a_tau_a)
2809 deriv => xc_dset_get_derivative(deriv_set, &
2810 [deriv_gamma_aa, deriv_tau_a, deriv_tau_b], &
2811 allocate_deriv=.true.)
2812 CALL xc_derivative_get(deriv, deriv_data=e_gamma_aa_tau_a_tau_b)
2813 deriv => xc_dset_get_derivative(deriv_set, &
2814 [deriv_gamma_aa, deriv_tau_b, deriv_tau_b], &
2815 allocate_deriv=.true.)
2816 CALL xc_derivative_get(deriv, deriv_data=e_gamma_aa_tau_b_tau_b)
2817 deriv => xc_dset_get_derivative(deriv_set, &
2818 [deriv_gamma_ab, deriv_gamma_ab, deriv_gamma_ab], &
2819 allocate_deriv=.true.)
2820 CALL xc_derivative_get(deriv, deriv_data=e_gamma_ab_gamma_ab_gamma_ab)
2821 deriv => xc_dset_get_derivative(deriv_set, &
2822 [deriv_gamma_ab, deriv_gamma_ab, deriv_gamma_bb], &
2823 allocate_deriv=.true.)
2824 CALL xc_derivative_get(deriv, deriv_data=e_gamma_ab_gamma_ab_gamma_bb)
2825 deriv => xc_dset_get_derivative(deriv_set, &
2826 [deriv_gamma_ab, deriv_gamma_ab, deriv_tau_a], &
2827 allocate_deriv=.true.)
2828 CALL xc_derivative_get(deriv, deriv_data=e_gamma_ab_gamma_ab_tau_a)
2829 deriv => xc_dset_get_derivative(deriv_set, &
2830 [deriv_gamma_ab, deriv_gamma_ab, deriv_tau_b], &
2831 allocate_deriv=.true.)
2832 CALL xc_derivative_get(deriv, deriv_data=e_gamma_ab_gamma_ab_tau_b)
2833 deriv => xc_dset_get_derivative(deriv_set, &
2834 [deriv_gamma_ab, deriv_gamma_bb, deriv_gamma_bb], &
2835 allocate_deriv=.true.)
2836 CALL xc_derivative_get(deriv, deriv_data=e_gamma_ab_gamma_bb_gamma_bb)
2837 deriv => xc_dset_get_derivative(deriv_set, &
2838 [deriv_gamma_ab, deriv_gamma_bb, deriv_tau_a], &
2839 allocate_deriv=.true.)
2840 CALL xc_derivative_get(deriv, deriv_data=e_gamma_ab_gamma_bb_tau_a)
2841 deriv => xc_dset_get_derivative(deriv_set, &
2842 [deriv_gamma_ab, deriv_gamma_bb, deriv_tau_b], &
2843 allocate_deriv=.true.)
2844 CALL xc_derivative_get(deriv, deriv_data=e_gamma_ab_gamma_bb_tau_b)
2845 deriv => xc_dset_get_derivative(deriv_set, &
2846 [deriv_gamma_ab, deriv_tau_a, deriv_tau_a], &
2847 allocate_deriv=.true.)
2848 CALL xc_derivative_get(deriv, deriv_data=e_gamma_ab_tau_a_tau_a)
2849 deriv => xc_dset_get_derivative(deriv_set, &
2850 [deriv_gamma_ab, deriv_tau_a, deriv_tau_b], &
2851 allocate_deriv=.true.)
2852 CALL xc_derivative_get(deriv, deriv_data=e_gamma_ab_tau_a_tau_b)
2853 deriv => xc_dset_get_derivative(deriv_set, &
2854 [deriv_gamma_ab, deriv_tau_b, deriv_tau_b], &
2855 allocate_deriv=.true.)
2856 CALL xc_derivative_get(deriv, deriv_data=e_gamma_ab_tau_b_tau_b)
2857 deriv => xc_dset_get_derivative(deriv_set, &
2858 [deriv_gamma_bb, deriv_gamma_bb, deriv_gamma_bb], &
2859 allocate_deriv=.true.)
2860 CALL xc_derivative_get(deriv, deriv_data=e_gamma_bb_gamma_bb_gamma_bb)
2861 deriv => xc_dset_get_derivative(deriv_set, &
2862 [deriv_gamma_bb, deriv_gamma_bb, deriv_tau_a], &
2863 allocate_deriv=.true.)
2864 CALL xc_derivative_get(deriv, deriv_data=e_gamma_bb_gamma_bb_tau_a)
2865 deriv => xc_dset_get_derivative(deriv_set, &
2866 [deriv_gamma_bb, deriv_gamma_bb, deriv_tau_b], &
2867 allocate_deriv=.true.)
2868 CALL xc_derivative_get(deriv, deriv_data=e_gamma_bb_gamma_bb_tau_b)
2869 deriv => xc_dset_get_derivative(deriv_set, &
2870 [deriv_gamma_bb, deriv_tau_a, deriv_tau_a], &
2871 allocate_deriv=.true.)
2872 CALL xc_derivative_get(deriv, deriv_data=e_gamma_bb_tau_a_tau_a)
2873 deriv => xc_dset_get_derivative(deriv_set, &
2874 [deriv_gamma_bb, deriv_tau_a, deriv_tau_b], &
2875 allocate_deriv=.true.)
2876 CALL xc_derivative_get(deriv, deriv_data=e_gamma_bb_tau_a_tau_b)
2877 deriv => xc_dset_get_derivative(deriv_set, &
2878 [deriv_gamma_bb, deriv_tau_b, deriv_tau_b], &
2879 allocate_deriv=.true.)
2880 CALL xc_derivative_get(deriv, deriv_data=e_gamma_bb_tau_b_tau_b)
2881 deriv => xc_dset_get_derivative(deriv_set, &
2882 [deriv_tau_a, deriv_tau_a, deriv_tau_a], &
2883 allocate_deriv=.true.)
2884 CALL xc_derivative_get(deriv, deriv_data=e_tau_a_tau_a_tau_a)
2885 deriv => xc_dset_get_derivative(deriv_set, &
2886 [deriv_tau_a, deriv_tau_a, deriv_tau_b], &
2887 allocate_deriv=.true.)
2888 CALL xc_derivative_get(deriv, deriv_data=e_tau_a_tau_a_tau_b)
2889 deriv => xc_dset_get_derivative(deriv_set, &
2890 [deriv_tau_a, deriv_tau_b, deriv_tau_b], &
2891 allocate_deriv=.true.)
2892 CALL xc_derivative_get(deriv, deriv_data=e_tau_a_tau_b_tau_b)
2893 deriv => xc_dset_get_derivative(deriv_set, &
2894 [deriv_tau_b, deriv_tau_b, deriv_tau_b], &
2895 allocate_deriv=.true.)
2896 CALL xc_derivative_get(deriv, deriv_data=e_tau_b_tau_b_tau_b)
2897 IF (has_laplace) THEN
2898 deriv => xc_dset_get_derivative(deriv_set, &
2899 [deriv_rhoa, deriv_rhoa, deriv_laplace_rhoa], &
2900 allocate_deriv=.true.)
2901 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_rhoa_laplace_rhoa)
2902 deriv => xc_dset_get_derivative(deriv_set, &
2903 [deriv_rhoa, deriv_rhoa, deriv_laplace_rhob], &
2904 allocate_deriv=.true.)
2905 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_rhoa_laplace_rhob)
2906 deriv => xc_dset_get_derivative(deriv_set, &
2907 [deriv_rhoa, deriv_rhob, deriv_laplace_rhoa], &
2908 allocate_deriv=.true.)
2909 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_rhob_laplace_rhoa)
2910 deriv => xc_dset_get_derivative(deriv_set, &
2911 [deriv_rhoa, deriv_rhob, deriv_laplace_rhob], &
2912 allocate_deriv=.true.)
2913 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_rhob_laplace_rhob)
2914 deriv => xc_dset_get_derivative(deriv_set, &
2915 [deriv_rhoa, deriv_gamma_aa, deriv_laplace_rhoa], &
2916 allocate_deriv=.true.)
2917 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_gamma_aa_laplace_rhoa)
2918 deriv => xc_dset_get_derivative(deriv_set, &
2919 [deriv_rhoa, deriv_gamma_aa, deriv_laplace_rhob], &
2920 allocate_deriv=.true.)
2921 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_gamma_aa_laplace_rhob)
2922 deriv => xc_dset_get_derivative(deriv_set, &
2923 [deriv_rhoa, deriv_gamma_ab, deriv_laplace_rhoa], &
2924 allocate_deriv=.true.)
2925 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_gamma_ab_laplace_rhoa)
2926 deriv => xc_dset_get_derivative(deriv_set, &
2927 [deriv_rhoa, deriv_gamma_ab, deriv_laplace_rhob], &
2928 allocate_deriv=.true.)
2929 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_gamma_ab_laplace_rhob)
2930 deriv => xc_dset_get_derivative(deriv_set, &
2931 [deriv_rhoa, deriv_gamma_bb, deriv_laplace_rhoa], &
2932 allocate_deriv=.true.)
2933 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_gamma_bb_laplace_rhoa)
2934 deriv => xc_dset_get_derivative(deriv_set, &
2935 [deriv_rhoa, deriv_gamma_bb, deriv_laplace_rhob], &
2936 allocate_deriv=.true.)
2937 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_gamma_bb_laplace_rhob)
2938 deriv => xc_dset_get_derivative(deriv_set, &
2939 [deriv_rhoa, deriv_laplace_rhoa, deriv_laplace_rhoa], &
2940 allocate_deriv=.true.)
2941 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_laplace_rhoa_laplace_rhoa)
2942 deriv => xc_dset_get_derivative(deriv_set, &
2943 [deriv_rhoa, deriv_laplace_rhoa, deriv_laplace_rhob], &
2944 allocate_deriv=.true.)
2945 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_laplace_rhoa_laplace_rhob)
2946 deriv => xc_dset_get_derivative(deriv_set, &
2947 [deriv_rhoa, deriv_laplace_rhoa, deriv_tau_a], &
2948 allocate_deriv=.true.)
2949 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_laplace_rhoa_tau_a)
2950 deriv => xc_dset_get_derivative(deriv_set, &
2951 [deriv_rhoa, deriv_laplace_rhoa, deriv_tau_b], &
2952 allocate_deriv=.true.)
2953 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_laplace_rhoa_tau_b)
2954 deriv => xc_dset_get_derivative(deriv_set, &
2955 [deriv_rhoa, deriv_laplace_rhob, deriv_laplace_rhob], &
2956 allocate_deriv=.true.)
2957 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_laplace_rhob_laplace_rhob)
2958 deriv => xc_dset_get_derivative(deriv_set, &
2959 [deriv_rhoa, deriv_laplace_rhob, deriv_tau_a], &
2960 allocate_deriv=.true.)
2961 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_laplace_rhob_tau_a)
2962 deriv => xc_dset_get_derivative(deriv_set, &
2963 [deriv_rhoa, deriv_laplace_rhob, deriv_tau_b], &
2964 allocate_deriv=.true.)
2965 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_laplace_rhob_tau_b)
2966 deriv => xc_dset_get_derivative(deriv_set, &
2967 [deriv_rhob, deriv_rhob, deriv_laplace_rhoa], &
2968 allocate_deriv=.true.)
2969 CALL xc_derivative_get(deriv, deriv_data=e_rhob_rhob_laplace_rhoa)
2970 deriv => xc_dset_get_derivative(deriv_set, &
2971 [deriv_rhob, deriv_rhob, deriv_laplace_rhob], &
2972 allocate_deriv=.true.)
2973 CALL xc_derivative_get(deriv, deriv_data=e_rhob_rhob_laplace_rhob)
2974 deriv => xc_dset_get_derivative(deriv_set, &
2975 [deriv_rhob, deriv_gamma_aa, deriv_laplace_rhoa], &
2976 allocate_deriv=.true.)
2977 CALL xc_derivative_get(deriv, deriv_data=e_rhob_gamma_aa_laplace_rhoa)
2978 deriv => xc_dset_get_derivative(deriv_set, &
2979 [deriv_rhob, deriv_gamma_aa, deriv_laplace_rhob], &
2980 allocate_deriv=.true.)
2981 CALL xc_derivative_get(deriv, deriv_data=e_rhob_gamma_aa_laplace_rhob)
2982 deriv => xc_dset_get_derivative(deriv_set, &
2983 [deriv_rhob, deriv_gamma_ab, deriv_laplace_rhoa], &
2984 allocate_deriv=.true.)
2985 CALL xc_derivative_get(deriv, deriv_data=e_rhob_gamma_ab_laplace_rhoa)
2986 deriv => xc_dset_get_derivative(deriv_set, &
2987 [deriv_rhob, deriv_gamma_ab, deriv_laplace_rhob], &
2988 allocate_deriv=.true.)
2989 CALL xc_derivative_get(deriv, deriv_data=e_rhob_gamma_ab_laplace_rhob)
2990 deriv => xc_dset_get_derivative(deriv_set, &
2991 [deriv_rhob, deriv_gamma_bb, deriv_laplace_rhoa], &
2992 allocate_deriv=.true.)
2993 CALL xc_derivative_get(deriv, deriv_data=e_rhob_gamma_bb_laplace_rhoa)
2994 deriv => xc_dset_get_derivative(deriv_set, &
2995 [deriv_rhob, deriv_gamma_bb, deriv_laplace_rhob], &
2996 allocate_deriv=.true.)
2997 CALL xc_derivative_get(deriv, deriv_data=e_rhob_gamma_bb_laplace_rhob)
2998 deriv => xc_dset_get_derivative(deriv_set, &
2999 [deriv_rhob, deriv_laplace_rhoa, deriv_laplace_rhoa], &
3000 allocate_deriv=.true.)
3001 CALL xc_derivative_get(deriv, deriv_data=e_rhob_laplace_rhoa_laplace_rhoa)
3002 deriv => xc_dset_get_derivative(deriv_set, &
3003 [deriv_rhob, deriv_laplace_rhoa, deriv_laplace_rhob], &
3004 allocate_deriv=.true.)
3005 CALL xc_derivative_get(deriv, deriv_data=e_rhob_laplace_rhoa_laplace_rhob)
3006 deriv => xc_dset_get_derivative(deriv_set, &
3007 [deriv_rhob, deriv_laplace_rhoa, deriv_tau_a], &
3008 allocate_deriv=.true.)
3009 CALL xc_derivative_get(deriv, deriv_data=e_rhob_laplace_rhoa_tau_a)
3010 deriv => xc_dset_get_derivative(deriv_set, &
3011 [deriv_rhob, deriv_laplace_rhoa, deriv_tau_b], &
3012 allocate_deriv=.true.)
3013 CALL xc_derivative_get(deriv, deriv_data=e_rhob_laplace_rhoa_tau_b)
3014 deriv => xc_dset_get_derivative(deriv_set, &
3015 [deriv_rhob, deriv_laplace_rhob, deriv_laplace_rhob], &
3016 allocate_deriv=.true.)
3017 CALL xc_derivative_get(deriv, deriv_data=e_rhob_laplace_rhob_laplace_rhob)
3018 deriv => xc_dset_get_derivative(deriv_set, &
3019 [deriv_rhob, deriv_laplace_rhob, deriv_tau_a], &
3020 allocate_deriv=.true.)
3021 CALL xc_derivative_get(deriv, deriv_data=e_rhob_laplace_rhob_tau_a)
3022 deriv => xc_dset_get_derivative(deriv_set, &
3023 [deriv_rhob, deriv_laplace_rhob, deriv_tau_b], &
3024 allocate_deriv=.true.)
3025 CALL xc_derivative_get(deriv, deriv_data=e_rhob_laplace_rhob_tau_b)
3026 deriv => xc_dset_get_derivative(deriv_set, &
3027 [deriv_gamma_aa, deriv_gamma_aa, deriv_laplace_rhoa], &
3028 allocate_deriv=.true.)
3029 CALL xc_derivative_get(deriv, deriv_data=e_gamma_aa_gamma_aa_laplace_rhoa)
3030 deriv => xc_dset_get_derivative(deriv_set, &
3031 [deriv_gamma_aa, deriv_gamma_aa, deriv_laplace_rhob], &
3032 allocate_deriv=.true.)
3033 CALL xc_derivative_get(deriv, deriv_data=e_gamma_aa_gamma_aa_laplace_rhob)
3034 deriv => xc_dset_get_derivative(deriv_set, &
3035 [deriv_gamma_aa, deriv_gamma_ab, deriv_laplace_rhoa], &
3036 allocate_deriv=.true.)
3037 CALL xc_derivative_get(deriv, deriv_data=e_gamma_aa_gamma_ab_laplace_rhoa)
3038 deriv => xc_dset_get_derivative(deriv_set, &
3039 [deriv_gamma_aa, deriv_gamma_ab, deriv_laplace_rhob], &
3040 allocate_deriv=.true.)
3041 CALL xc_derivative_get(deriv, deriv_data=e_gamma_aa_gamma_ab_laplace_rhob)
3042 deriv => xc_dset_get_derivative(deriv_set, &
3043 [deriv_gamma_aa, deriv_gamma_bb, deriv_laplace_rhoa], &
3044 allocate_deriv=.true.)
3045 CALL xc_derivative_get(deriv, deriv_data=e_gamma_aa_gamma_bb_laplace_rhoa)
3046 deriv => xc_dset_get_derivative(deriv_set, &
3047 [deriv_gamma_aa, deriv_gamma_bb, deriv_laplace_rhob], &
3048 allocate_deriv=.true.)
3049 CALL xc_derivative_get(deriv, deriv_data=e_gamma_aa_gamma_bb_laplace_rhob)
3050 deriv => xc_dset_get_derivative(deriv_set, &
3051 [deriv_gamma_aa, deriv_laplace_rhoa, deriv_laplace_rhoa], &
3052 allocate_deriv=.true.)
3053 CALL xc_derivative_get(deriv, deriv_data=e_gamma_aa_laplace_rhoa_laplace_rhoa)
3054 deriv => xc_dset_get_derivative(deriv_set, &
3055 [deriv_gamma_aa, deriv_laplace_rhoa, deriv_laplace_rhob], &
3056 allocate_deriv=.true.)
3057 CALL xc_derivative_get(deriv, deriv_data=e_gamma_aa_laplace_rhoa_laplace_rhob)
3058 deriv => xc_dset_get_derivative(deriv_set, &
3059 [deriv_gamma_aa, deriv_laplace_rhoa, deriv_tau_a], &
3060 allocate_deriv=.true.)
3061 CALL xc_derivative_get(deriv, deriv_data=e_gamma_aa_laplace_rhoa_tau_a)
3062 deriv => xc_dset_get_derivative(deriv_set, &
3063 [deriv_gamma_aa, deriv_laplace_rhoa, deriv_tau_b], &
3064 allocate_deriv=.true.)
3065 CALL xc_derivative_get(deriv, deriv_data=e_gamma_aa_laplace_rhoa_tau_b)
3066 deriv => xc_dset_get_derivative(deriv_set, &
3067 [deriv_gamma_aa, deriv_laplace_rhob, deriv_laplace_rhob], &
3068 allocate_deriv=.true.)
3069 CALL xc_derivative_get(deriv, deriv_data=e_gamma_aa_laplace_rhob_laplace_rhob)
3070 deriv => xc_dset_get_derivative(deriv_set, &
3071 [deriv_gamma_aa, deriv_laplace_rhob, deriv_tau_a], &
3072 allocate_deriv=.true.)
3073 CALL xc_derivative_get(deriv, deriv_data=e_gamma_aa_laplace_rhob_tau_a)
3074 deriv => xc_dset_get_derivative(deriv_set, &
3075 [deriv_gamma_aa, deriv_laplace_rhob, deriv_tau_b], &
3076 allocate_deriv=.true.)
3077 CALL xc_derivative_get(deriv, deriv_data=e_gamma_aa_laplace_rhob_tau_b)
3078 deriv => xc_dset_get_derivative(deriv_set, &
3079 [deriv_gamma_ab, deriv_gamma_ab, deriv_laplace_rhoa], &
3080 allocate_deriv=.true.)
3081 CALL xc_derivative_get(deriv, deriv_data=e_gamma_ab_gamma_ab_laplace_rhoa)
3082 deriv => xc_dset_get_derivative(deriv_set, &
3083 [deriv_gamma_ab, deriv_gamma_ab, deriv_laplace_rhob], &
3084 allocate_deriv=.true.)
3085 CALL xc_derivative_get(deriv, deriv_data=e_gamma_ab_gamma_ab_laplace_rhob)
3086 deriv => xc_dset_get_derivative(deriv_set, &
3087 [deriv_gamma_ab, deriv_gamma_bb, deriv_laplace_rhoa], &
3088 allocate_deriv=.true.)
3089 CALL xc_derivative_get(deriv, deriv_data=e_gamma_ab_gamma_bb_laplace_rhoa)
3090 deriv => xc_dset_get_derivative(deriv_set, &
3091 [deriv_gamma_ab, deriv_gamma_bb, deriv_laplace_rhob], &
3092 allocate_deriv=.true.)
3093 CALL xc_derivative_get(deriv, deriv_data=e_gamma_ab_gamma_bb_laplace_rhob)
3094 deriv => xc_dset_get_derivative(deriv_set, &
3095 [deriv_gamma_ab, deriv_laplace_rhoa, deriv_laplace_rhoa], &
3096 allocate_deriv=.true.)
3097 CALL xc_derivative_get(deriv, deriv_data=e_gamma_ab_laplace_rhoa_laplace_rhoa)
3098 deriv => xc_dset_get_derivative(deriv_set, &
3099 [deriv_gamma_ab, deriv_laplace_rhoa, deriv_laplace_rhob], &
3100 allocate_deriv=.true.)
3101 CALL xc_derivative_get(deriv, deriv_data=e_gamma_ab_laplace_rhoa_laplace_rhob)
3102 deriv => xc_dset_get_derivative(deriv_set, &
3103 [deriv_gamma_ab, deriv_laplace_rhoa, deriv_tau_a], &
3104 allocate_deriv=.true.)
3105 CALL xc_derivative_get(deriv, deriv_data=e_gamma_ab_laplace_rhoa_tau_a)
3106 deriv => xc_dset_get_derivative(deriv_set, &
3107 [deriv_gamma_ab, deriv_laplace_rhoa, deriv_tau_b], &
3108 allocate_deriv=.true.)
3109 CALL xc_derivative_get(deriv, deriv_data=e_gamma_ab_laplace_rhoa_tau_b)
3110 deriv => xc_dset_get_derivative(deriv_set, &
3111 [deriv_gamma_ab, deriv_laplace_rhob, deriv_laplace_rhob], &
3112 allocate_deriv=.true.)
3113 CALL xc_derivative_get(deriv, deriv_data=e_gamma_ab_laplace_rhob_laplace_rhob)
3114 deriv => xc_dset_get_derivative(deriv_set, &
3115 [deriv_gamma_ab, deriv_laplace_rhob, deriv_tau_a], &
3116 allocate_deriv=.true.)
3117 CALL xc_derivative_get(deriv, deriv_data=e_gamma_ab_laplace_rhob_tau_a)
3118 deriv => xc_dset_get_derivative(deriv_set, &
3119 [deriv_gamma_ab, deriv_laplace_rhob, deriv_tau_b], &
3120 allocate_deriv=.true.)
3121 CALL xc_derivative_get(deriv, deriv_data=e_gamma_ab_laplace_rhob_tau_b)
3122 deriv => xc_dset_get_derivative(deriv_set, &
3123 [deriv_gamma_bb, deriv_gamma_bb, deriv_laplace_rhoa], &
3124 allocate_deriv=.true.)
3125 CALL xc_derivative_get(deriv, deriv_data=e_gamma_bb_gamma_bb_laplace_rhoa)
3126 deriv => xc_dset_get_derivative(deriv_set, &
3127 [deriv_gamma_bb, deriv_gamma_bb, deriv_laplace_rhob], &
3128 allocate_deriv=.true.)
3129 CALL xc_derivative_get(deriv, deriv_data=e_gamma_bb_gamma_bb_laplace_rhob)
3130 deriv => xc_dset_get_derivative(deriv_set, &
3131 [deriv_gamma_bb, deriv_laplace_rhoa, deriv_laplace_rhoa], &
3132 allocate_deriv=.true.)
3133 CALL xc_derivative_get(deriv, deriv_data=e_gamma_bb_laplace_rhoa_laplace_rhoa)
3134 deriv => xc_dset_get_derivative(deriv_set, &
3135 [deriv_gamma_bb, deriv_laplace_rhoa, deriv_laplace_rhob], &
3136 allocate_deriv=.true.)
3137 CALL xc_derivative_get(deriv, deriv_data=e_gamma_bb_laplace_rhoa_laplace_rhob)
3138 deriv => xc_dset_get_derivative(deriv_set, &
3139 [deriv_gamma_bb, deriv_laplace_rhoa, deriv_tau_a], &
3140 allocate_deriv=.true.)
3141 CALL xc_derivative_get(deriv, deriv_data=e_gamma_bb_laplace_rhoa_tau_a)
3142 deriv => xc_dset_get_derivative(deriv_set, &
3143 [deriv_gamma_bb, deriv_laplace_rhoa, deriv_tau_b], &
3144 allocate_deriv=.true.)
3145 CALL xc_derivative_get(deriv, deriv_data=e_gamma_bb_laplace_rhoa_tau_b)
3146 deriv => xc_dset_get_derivative(deriv_set, &
3147 [deriv_gamma_bb, deriv_laplace_rhob, deriv_laplace_rhob], &
3148 allocate_deriv=.true.)
3149 CALL xc_derivative_get(deriv, deriv_data=e_gamma_bb_laplace_rhob_laplace_rhob)
3150 deriv => xc_dset_get_derivative(deriv_set, &
3151 [deriv_gamma_bb, deriv_laplace_rhob, deriv_tau_a], &
3152 allocate_deriv=.true.)
3153 CALL xc_derivative_get(deriv, deriv_data=e_gamma_bb_laplace_rhob_tau_a)
3154 deriv => xc_dset_get_derivative(deriv_set, &
3155 [deriv_gamma_bb, deriv_laplace_rhob, deriv_tau_b], &
3156 allocate_deriv=.true.)
3157 CALL xc_derivative_get(deriv, deriv_data=e_gamma_bb_laplace_rhob_tau_b)
3158 deriv => xc_dset_get_derivative(deriv_set, &
3159 [deriv_laplace_rhoa, deriv_laplace_rhoa, deriv_laplace_rhoa], &
3160 allocate_deriv=.true.)
3161 CALL xc_derivative_get(deriv, deriv_data=e_laplace_rhoa_laplace_rhoa_laplace_rhoa)
3162 deriv => xc_dset_get_derivative(deriv_set, &
3163 [deriv_laplace_rhoa, deriv_laplace_rhoa, deriv_laplace_rhob], &
3164 allocate_deriv=.true.)
3165 CALL xc_derivative_get(deriv, deriv_data=e_laplace_rhoa_laplace_rhoa_laplace_rhob)
3166 deriv => xc_dset_get_derivative(deriv_set, &
3167 [deriv_laplace_rhoa, deriv_laplace_rhoa, deriv_tau_a], &
3168 allocate_deriv=.true.)
3169 CALL xc_derivative_get(deriv, deriv_data=e_laplace_rhoa_laplace_rhoa_tau_a)
3170 deriv => xc_dset_get_derivative(deriv_set, &
3171 [deriv_laplace_rhoa, deriv_laplace_rhoa, deriv_tau_b], &
3172 allocate_deriv=.true.)
3173 CALL xc_derivative_get(deriv, deriv_data=e_laplace_rhoa_laplace_rhoa_tau_b)
3174 deriv => xc_dset_get_derivative(deriv_set, &
3175 [deriv_laplace_rhoa, deriv_laplace_rhob, deriv_laplace_rhob], &
3176 allocate_deriv=.true.)
3177 CALL xc_derivative_get(deriv, deriv_data=e_laplace_rhoa_laplace_rhob_laplace_rhob)
3178 deriv => xc_dset_get_derivative(deriv_set, &
3179 [deriv_laplace_rhoa, deriv_laplace_rhob, deriv_tau_a], &
3180 allocate_deriv=.true.)
3181 CALL xc_derivative_get(deriv, deriv_data=e_laplace_rhoa_laplace_rhob_tau_a)
3182 deriv => xc_dset_get_derivative(deriv_set, &
3183 [deriv_laplace_rhoa, deriv_laplace_rhob, deriv_tau_b], &
3184 allocate_deriv=.true.)
3185 CALL xc_derivative_get(deriv, deriv_data=e_laplace_rhoa_laplace_rhob_tau_b)
3186 deriv => xc_dset_get_derivative(deriv_set, &
3187 [deriv_laplace_rhoa, deriv_tau_a, deriv_tau_a], &
3188 allocate_deriv=.true.)
3189 CALL xc_derivative_get(deriv, deriv_data=e_laplace_rhoa_tau_a_tau_a)
3190 deriv => xc_dset_get_derivative(deriv_set, &
3191 [deriv_laplace_rhoa, deriv_tau_a, deriv_tau_b], &
3192 allocate_deriv=.true.)
3193 CALL xc_derivative_get(deriv, deriv_data=e_laplace_rhoa_tau_a_tau_b)
3194 deriv => xc_dset_get_derivative(deriv_set, &
3195 [deriv_laplace_rhoa, deriv_tau_b, deriv_tau_b], &
3196 allocate_deriv=.true.)
3197 CALL xc_derivative_get(deriv, deriv_data=e_laplace_rhoa_tau_b_tau_b)
3198 deriv => xc_dset_get_derivative(deriv_set, &
3199 [deriv_laplace_rhob, deriv_laplace_rhob, deriv_laplace_rhob], &
3200 allocate_deriv=.true.)
3201 CALL xc_derivative_get(deriv, deriv_data=e_laplace_rhob_laplace_rhob_laplace_rhob)
3202 deriv => xc_dset_get_derivative(deriv_set, &
3203 [deriv_laplace_rhob, deriv_laplace_rhob, deriv_tau_a], &
3204 allocate_deriv=.true.)
3205 CALL xc_derivative_get(deriv, deriv_data=e_laplace_rhob_laplace_rhob_tau_a)
3206 deriv => xc_dset_get_derivative(deriv_set, &
3207 [deriv_laplace_rhob, deriv_laplace_rhob, deriv_tau_b], &
3208 allocate_deriv=.true.)
3209 CALL xc_derivative_get(deriv, deriv_data=e_laplace_rhob_laplace_rhob_tau_b)
3210 deriv => xc_dset_get_derivative(deriv_set, &
3211 [deriv_laplace_rhob, deriv_tau_a, deriv_tau_a], &
3212 allocate_deriv=.true.)
3213 CALL xc_derivative_get(deriv, deriv_data=e_laplace_rhob_tau_a_tau_a)
3214 deriv => xc_dset_get_derivative(deriv_set, &
3215 [deriv_laplace_rhob, deriv_tau_a, deriv_tau_b], &
3216 allocate_deriv=.true.)
3217 CALL xc_derivative_get(deriv, deriv_data=e_laplace_rhob_tau_a_tau_b)
3218 deriv => xc_dset_get_derivative(deriv_set, &
3219 [deriv_laplace_rhob, deriv_tau_b, deriv_tau_b], &
3220 allocate_deriv=.true.)
3221 CALL xc_derivative_get(deriv, deriv_data=e_laplace_rhob_tau_b_tau_b)
3222 END IF
3223 deriv => xc_dset_get_derivative(deriv_set, &
3224 [deriv_rhoa, deriv_rhoa, deriv_rhoa], &
3225 allocate_deriv=.true.)
3226 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_rhoa_rhoa)
3227 deriv => xc_dset_get_derivative(deriv_set, &
3228 [deriv_rhoa, deriv_rhoa, deriv_rhob], &
3229 allocate_deriv=.true.)
3230 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_rhoa_rhob)
3231 deriv => xc_dset_get_derivative(deriv_set, &
3232 [deriv_rhoa, deriv_rhob, deriv_rhob], &
3233 allocate_deriv=.true.)
3234 CALL xc_derivative_get(deriv, deriv_data=e_rhoa_rhob_rhob)
3235 deriv => xc_dset_get_derivative(deriv_set, &
3236 [deriv_rhob, deriv_rhob, deriv_rhob], &
3237 allocate_deriv=.true.)
3238 CALL xc_derivative_get(deriv, deriv_data=e_rhob_rhob_rhob)
3239 CASE default
3240 cpabort(trim(func_name)//": this XC_FAMILY is currently not supported.")
3241 END SELECT
3242 END IF
3243
3244!$OMP PARALLEL DEFAULT(NONE), &
3245!$OMP SHARED(rhoa,rhob,norm_drho,norm_drhoa,norm_drhob),&
3246!$OMP SHARED(laplace_rhoa,laplace_rhob,tau_a,tau_b),&
3247!$OMP SHARED(e_0,e_rhoa,e_rhob,e_ndrho,e_ndrhoa,e_ndrhob),&
3248!$OMP SHARED(e_laplace_rhoa,e_laplace_rhob,e_tau_a,e_tau_b),&
3249!$OMP SHARED(e_rhoa_rhoa,e_rhoa_rhob,e_rhob_rhob),&
3250!$OMP SHARED(e_ndrho_rhoa,e_ndrho_rhob),&
3251!$OMP SHARED(e_ndrhoa_rhoa,e_ndrhoa_rhob,e_ndrhob_rhoa,e_ndrhob_rhob),&
3252!$OMP SHARED(e_ndrho_ndrho,e_ndrho_ndrhoa,e_ndrho_ndrhob),&
3253!$OMP SHARED(e_ndrhoa_ndrhoa,e_ndrhoa_ndrhob,e_ndrhob_ndrhob),&
3254!$OMP SHARED(e_rhoa_laplace_rhoa,e_rhoa_laplace_rhob,e_rhob_laplace_rhoa,e_rhob_laplace_rhob),&
3255!$OMP SHARED(e_rhoa_tau_a,e_rhoa_tau_b,e_rhob_tau_a,e_rhob_tau_b),&
3256!$OMP SHARED(e_ndrho_laplace_rhoa,e_ndrho_laplace_rhob),&
3257!$OMP SHARED(e_ndrhoa_laplace_rhoa,e_ndrhoa_laplace_rhob,e_ndrhob_laplace_rhoa,e_ndrhob_laplace_rhob),&
3258!$OMP SHARED(e_ndrho_tau_a,e_ndrho_tau_b),&
3259!$OMP SHARED(e_ndrhoa_tau_a,e_ndrhoa_tau_b,e_ndrhob_tau_a,e_ndrhob_tau_b),&
3260!$OMP SHARED(e_laplace_rhoa_laplace_rhoa,e_laplace_rhoa_laplace_rhob,e_laplace_rhob_laplace_rhob),&
3261!$OMP SHARED(e_laplace_rhoa_tau_a,e_laplace_rhoa_tau_b,e_laplace_rhob_tau_a,e_laplace_rhob_tau_b),&
3262!$OMP SHARED(e_tau_a_tau_a,e_tau_a_tau_b,e_tau_b_tau_b),&
3263!$OMP SHARED(e_rhoa_rhoa_rhoa,e_rhoa_rhoa_rhob,e_rhoa_rhob_rhob,e_rhob_rhob_rhob),&
3264!$OMP SHARED(e_gamma_aa),&
3265!$OMP SHARED(e_gamma_ab),&
3266!$OMP SHARED(e_gamma_bb),&
3267!$OMP SHARED(e_rhoa_gamma_aa),&
3268!$OMP SHARED(e_rhoa_gamma_ab),&
3269!$OMP SHARED(e_rhoa_gamma_bb),&
3270!$OMP SHARED(e_rhob_gamma_aa),&
3271!$OMP SHARED(e_rhob_gamma_ab),&
3272!$OMP SHARED(e_rhob_gamma_bb),&
3273!$OMP SHARED(e_gamma_aa_gamma_aa),&
3274!$OMP SHARED(e_gamma_aa_gamma_ab),&
3275!$OMP SHARED(e_gamma_aa_gamma_bb),&
3276!$OMP SHARED(e_gamma_aa_laplace_rhoa),&
3277!$OMP SHARED(e_gamma_aa_laplace_rhob),&
3278!$OMP SHARED(e_gamma_aa_tau_a),&
3279!$OMP SHARED(e_gamma_aa_tau_b),&
3280!$OMP SHARED(e_gamma_ab_gamma_ab),&
3281!$OMP SHARED(e_gamma_ab_gamma_bb),&
3282!$OMP SHARED(e_gamma_ab_laplace_rhoa),&
3283!$OMP SHARED(e_gamma_ab_laplace_rhob),&
3284!$OMP SHARED(e_gamma_ab_tau_a),&
3285!$OMP SHARED(e_gamma_ab_tau_b),&
3286!$OMP SHARED(e_gamma_bb_gamma_bb),&
3287!$OMP SHARED(e_gamma_bb_laplace_rhoa),&
3288!$OMP SHARED(e_gamma_bb_laplace_rhob),&
3289!$OMP SHARED(e_gamma_bb_tau_a),&
3290!$OMP SHARED(e_gamma_bb_tau_b),&
3291!$OMP SHARED(e_rhoa_rhoa_gamma_aa),&
3292!$OMP SHARED(e_rhoa_rhoa_gamma_ab),&
3293!$OMP SHARED(e_rhoa_rhoa_gamma_bb),&
3294!$OMP SHARED(e_rhoa_rhoa_laplace_rhoa),&
3295!$OMP SHARED(e_rhoa_rhoa_laplace_rhob),&
3296!$OMP SHARED(e_rhoa_rhoa_tau_a),&
3297!$OMP SHARED(e_rhoa_rhoa_tau_b),&
3298!$OMP SHARED(e_rhoa_rhob_gamma_aa),&
3299!$OMP SHARED(e_rhoa_rhob_gamma_ab),&
3300!$OMP SHARED(e_rhoa_rhob_gamma_bb),&
3301!$OMP SHARED(e_rhoa_rhob_laplace_rhoa),&
3302!$OMP SHARED(e_rhoa_rhob_laplace_rhob),&
3303!$OMP SHARED(e_rhoa_rhob_tau_a),&
3304!$OMP SHARED(e_rhoa_rhob_tau_b),&
3305!$OMP SHARED(e_rhoa_gamma_aa_gamma_aa),&
3306!$OMP SHARED(e_rhoa_gamma_aa_gamma_ab),&
3307!$OMP SHARED(e_rhoa_gamma_aa_gamma_bb),&
3308!$OMP SHARED(e_rhoa_gamma_aa_laplace_rhoa),&
3309!$OMP SHARED(e_rhoa_gamma_aa_laplace_rhob),&
3310!$OMP SHARED(e_rhoa_gamma_aa_tau_a),&
3311!$OMP SHARED(e_rhoa_gamma_aa_tau_b),&
3312!$OMP SHARED(e_rhoa_gamma_ab_gamma_ab),&
3313!$OMP SHARED(e_rhoa_gamma_ab_gamma_bb),&
3314!$OMP SHARED(e_rhoa_gamma_ab_laplace_rhoa),&
3315!$OMP SHARED(e_rhoa_gamma_ab_laplace_rhob),&
3316!$OMP SHARED(e_rhoa_gamma_ab_tau_a),&
3317!$OMP SHARED(e_rhoa_gamma_ab_tau_b),&
3318!$OMP SHARED(e_rhoa_gamma_bb_gamma_bb),&
3319!$OMP SHARED(e_rhoa_gamma_bb_laplace_rhoa),&
3320!$OMP SHARED(e_rhoa_gamma_bb_laplace_rhob),&
3321!$OMP SHARED(e_rhoa_gamma_bb_tau_a),&
3322!$OMP SHARED(e_rhoa_gamma_bb_tau_b),&
3323!$OMP SHARED(e_rhoa_laplace_rhoa_laplace_rhoa),&
3324!$OMP SHARED(e_rhoa_laplace_rhoa_laplace_rhob),&
3325!$OMP SHARED(e_rhoa_laplace_rhoa_tau_a),&
3326!$OMP SHARED(e_rhoa_laplace_rhoa_tau_b),&
3327!$OMP SHARED(e_rhoa_laplace_rhob_laplace_rhob),&
3328!$OMP SHARED(e_rhoa_laplace_rhob_tau_a),&
3329!$OMP SHARED(e_rhoa_laplace_rhob_tau_b),&
3330!$OMP SHARED(e_rhoa_tau_a_tau_a),&
3331!$OMP SHARED(e_rhoa_tau_a_tau_b),&
3332!$OMP SHARED(e_rhoa_tau_b_tau_b),&
3333!$OMP SHARED(e_rhob_rhob_gamma_aa),&
3334!$OMP SHARED(e_rhob_rhob_gamma_ab),&
3335!$OMP SHARED(e_rhob_rhob_gamma_bb),&
3336!$OMP SHARED(e_rhob_rhob_laplace_rhoa),&
3337!$OMP SHARED(e_rhob_rhob_laplace_rhob),&
3338!$OMP SHARED(e_rhob_rhob_tau_a),&
3339!$OMP SHARED(e_rhob_rhob_tau_b),&
3340!$OMP SHARED(e_rhob_gamma_aa_gamma_aa),&
3341!$OMP SHARED(e_rhob_gamma_aa_gamma_ab),&
3342!$OMP SHARED(e_rhob_gamma_aa_gamma_bb),&
3343!$OMP SHARED(e_rhob_gamma_aa_laplace_rhoa),&
3344!$OMP SHARED(e_rhob_gamma_aa_laplace_rhob),&
3345!$OMP SHARED(e_rhob_gamma_aa_tau_a),&
3346!$OMP SHARED(e_rhob_gamma_aa_tau_b),&
3347!$OMP SHARED(e_rhob_gamma_ab_gamma_ab),&
3348!$OMP SHARED(e_rhob_gamma_ab_gamma_bb),&
3349!$OMP SHARED(e_rhob_gamma_ab_laplace_rhoa),&
3350!$OMP SHARED(e_rhob_gamma_ab_laplace_rhob),&
3351!$OMP SHARED(e_rhob_gamma_ab_tau_a),&
3352!$OMP SHARED(e_rhob_gamma_ab_tau_b),&
3353!$OMP SHARED(e_rhob_gamma_bb_gamma_bb),&
3354!$OMP SHARED(e_rhob_gamma_bb_laplace_rhoa),&
3355!$OMP SHARED(e_rhob_gamma_bb_laplace_rhob),&
3356!$OMP SHARED(e_rhob_gamma_bb_tau_a),&
3357!$OMP SHARED(e_rhob_gamma_bb_tau_b),&
3358!$OMP SHARED(e_rhob_laplace_rhoa_laplace_rhoa),&
3359!$OMP SHARED(e_rhob_laplace_rhoa_laplace_rhob),&
3360!$OMP SHARED(e_rhob_laplace_rhoa_tau_a),&
3361!$OMP SHARED(e_rhob_laplace_rhoa_tau_b),&
3362!$OMP SHARED(e_rhob_laplace_rhob_laplace_rhob),&
3363!$OMP SHARED(e_rhob_laplace_rhob_tau_a),&
3364!$OMP SHARED(e_rhob_laplace_rhob_tau_b),&
3365!$OMP SHARED(e_rhob_tau_a_tau_a),&
3366!$OMP SHARED(e_rhob_tau_a_tau_b),&
3367!$OMP SHARED(e_rhob_tau_b_tau_b),&
3368!$OMP SHARED(e_gamma_aa_gamma_aa_gamma_aa),&
3369!$OMP SHARED(e_gamma_aa_gamma_aa_gamma_ab),&
3370!$OMP SHARED(e_gamma_aa_gamma_aa_gamma_bb),&
3371!$OMP SHARED(e_gamma_aa_gamma_aa_laplace_rhoa),&
3372!$OMP SHARED(e_gamma_aa_gamma_aa_laplace_rhob),&
3373!$OMP SHARED(e_gamma_aa_gamma_aa_tau_a),&
3374!$OMP SHARED(e_gamma_aa_gamma_aa_tau_b),&
3375!$OMP SHARED(e_gamma_aa_gamma_ab_gamma_ab),&
3376!$OMP SHARED(e_gamma_aa_gamma_ab_gamma_bb),&
3377!$OMP SHARED(e_gamma_aa_gamma_ab_laplace_rhoa),&
3378!$OMP SHARED(e_gamma_aa_gamma_ab_laplace_rhob),&
3379!$OMP SHARED(e_gamma_aa_gamma_ab_tau_a),&
3380!$OMP SHARED(e_gamma_aa_gamma_ab_tau_b),&
3381!$OMP SHARED(e_gamma_aa_gamma_bb_gamma_bb),&
3382!$OMP SHARED(e_gamma_aa_gamma_bb_laplace_rhoa),&
3383!$OMP SHARED(e_gamma_aa_gamma_bb_laplace_rhob),&
3384!$OMP SHARED(e_gamma_aa_gamma_bb_tau_a),&
3385!$OMP SHARED(e_gamma_aa_gamma_bb_tau_b),&
3386!$OMP SHARED(e_gamma_aa_laplace_rhoa_laplace_rhoa),&
3387!$OMP SHARED(e_gamma_aa_laplace_rhoa_laplace_rhob),&
3388!$OMP SHARED(e_gamma_aa_laplace_rhoa_tau_a),&
3389!$OMP SHARED(e_gamma_aa_laplace_rhoa_tau_b),&
3390!$OMP SHARED(e_gamma_aa_laplace_rhob_laplace_rhob),&
3391!$OMP SHARED(e_gamma_aa_laplace_rhob_tau_a),&
3392!$OMP SHARED(e_gamma_aa_laplace_rhob_tau_b),&
3393!$OMP SHARED(e_gamma_aa_tau_a_tau_a),&
3394!$OMP SHARED(e_gamma_aa_tau_a_tau_b),&
3395!$OMP SHARED(e_gamma_aa_tau_b_tau_b),&
3396!$OMP SHARED(e_gamma_ab_gamma_ab_gamma_ab),&
3397!$OMP SHARED(e_gamma_ab_gamma_ab_gamma_bb),&
3398!$OMP SHARED(e_gamma_ab_gamma_ab_laplace_rhoa),&
3399!$OMP SHARED(e_gamma_ab_gamma_ab_laplace_rhob),&
3400!$OMP SHARED(e_gamma_ab_gamma_ab_tau_a),&
3401!$OMP SHARED(e_gamma_ab_gamma_ab_tau_b),&
3402!$OMP SHARED(e_gamma_ab_gamma_bb_gamma_bb),&
3403!$OMP SHARED(e_gamma_ab_gamma_bb_laplace_rhoa),&
3404!$OMP SHARED(e_gamma_ab_gamma_bb_laplace_rhob),&
3405!$OMP SHARED(e_gamma_ab_gamma_bb_tau_a),&
3406!$OMP SHARED(e_gamma_ab_gamma_bb_tau_b),&
3407!$OMP SHARED(e_gamma_ab_laplace_rhoa_laplace_rhoa),&
3408!$OMP SHARED(e_gamma_ab_laplace_rhoa_laplace_rhob),&
3409!$OMP SHARED(e_gamma_ab_laplace_rhoa_tau_a),&
3410!$OMP SHARED(e_gamma_ab_laplace_rhoa_tau_b),&
3411!$OMP SHARED(e_gamma_ab_laplace_rhob_laplace_rhob),&
3412!$OMP SHARED(e_gamma_ab_laplace_rhob_tau_a),&
3413!$OMP SHARED(e_gamma_ab_laplace_rhob_tau_b),&
3414!$OMP SHARED(e_gamma_ab_tau_a_tau_a),&
3415!$OMP SHARED(e_gamma_ab_tau_a_tau_b),&
3416!$OMP SHARED(e_gamma_ab_tau_b_tau_b),&
3417!$OMP SHARED(e_gamma_bb_gamma_bb_gamma_bb),&
3418!$OMP SHARED(e_gamma_bb_gamma_bb_laplace_rhoa),&
3419!$OMP SHARED(e_gamma_bb_gamma_bb_laplace_rhob),&
3420!$OMP SHARED(e_gamma_bb_gamma_bb_tau_a),&
3421!$OMP SHARED(e_gamma_bb_gamma_bb_tau_b),&
3422!$OMP SHARED(e_gamma_bb_laplace_rhoa_laplace_rhoa),&
3423!$OMP SHARED(e_gamma_bb_laplace_rhoa_laplace_rhob),&
3424!$OMP SHARED(e_gamma_bb_laplace_rhoa_tau_a),&
3425!$OMP SHARED(e_gamma_bb_laplace_rhoa_tau_b),&
3426!$OMP SHARED(e_gamma_bb_laplace_rhob_laplace_rhob),&
3427!$OMP SHARED(e_gamma_bb_laplace_rhob_tau_a),&
3428!$OMP SHARED(e_gamma_bb_laplace_rhob_tau_b),&
3429!$OMP SHARED(e_gamma_bb_tau_a_tau_a),&
3430!$OMP SHARED(e_gamma_bb_tau_a_tau_b),&
3431!$OMP SHARED(e_gamma_bb_tau_b_tau_b),&
3432!$OMP SHARED(e_laplace_rhoa_laplace_rhoa_laplace_rhoa),&
3433!$OMP SHARED(e_laplace_rhoa_laplace_rhoa_laplace_rhob),&
3434!$OMP SHARED(e_laplace_rhoa_laplace_rhoa_tau_a),&
3435!$OMP SHARED(e_laplace_rhoa_laplace_rhoa_tau_b),&
3436!$OMP SHARED(e_laplace_rhoa_laplace_rhob_laplace_rhob),&
3437!$OMP SHARED(e_laplace_rhoa_laplace_rhob_tau_a),&
3438!$OMP SHARED(e_laplace_rhoa_laplace_rhob_tau_b),&
3439!$OMP SHARED(e_laplace_rhoa_tau_a_tau_a),&
3440!$OMP SHARED(e_laplace_rhoa_tau_a_tau_b),&
3441!$OMP SHARED(e_laplace_rhoa_tau_b_tau_b),&
3442!$OMP SHARED(e_laplace_rhob_laplace_rhob_laplace_rhob),&
3443!$OMP SHARED(e_laplace_rhob_laplace_rhob_tau_a),&
3444!$OMP SHARED(e_laplace_rhob_laplace_rhob_tau_b),&
3445!$OMP SHARED(e_laplace_rhob_tau_a_tau_a),&
3446!$OMP SHARED(e_laplace_rhob_tau_a_tau_b),&
3447!$OMP SHARED(e_laplace_rhob_tau_b_tau_b),&
3448!$OMP SHARED(e_tau_a_tau_a_tau_a),&
3449!$OMP SHARED(e_tau_a_tau_a_tau_b),&
3450!$OMP SHARED(e_tau_a_tau_b_tau_b),&
3451!$OMP SHARED(e_tau_b_tau_b_tau_b),&
3452!$OMP SHARED(grad_deriv,npoints),&
3453!$OMP SHARED(func_name,func_scale,workers)
3454
3455 CALL libxc_spin_polarized_calc(rhoa=rhoa, rhob=rhob, norm_drho=norm_drho, &
3456 norm_drhoa=norm_drhoa, norm_drhob=norm_drhob, laplace_rhoa=laplace_rhoa, &
3457 laplace_rhob=laplace_rhob, tau_a=tau_a, tau_b=tau_b, &
3458 e_0=e_0, e_rhoa=e_rhoa, e_rhob=e_rhob, e_ndrho=e_ndrho, &
3459 e_ndrhoa=e_ndrhoa, e_ndrhob=e_ndrhob, e_laplace_rhoa=e_laplace_rhoa, &
3460 e_laplace_rhob=e_laplace_rhob, e_tau_a=e_tau_a, e_tau_b=e_tau_b, &
3461 e_rhoa_rhoa=e_rhoa_rhoa, e_rhoa_rhob=e_rhoa_rhob, e_rhob_rhob=e_rhob_rhob, &
3462 e_ndrho_rhoa=e_ndrho_rhoa, e_ndrho_rhob=e_ndrho_rhob, &
3463 e_ndrhoa_rhoa=e_ndrhoa_rhoa, e_ndrhoa_rhob=e_ndrhoa_rhob, &
3464 e_ndrhob_rhoa=e_ndrhob_rhoa, e_ndrhob_rhob=e_ndrhob_rhob, &
3465 e_ndrho_ndrho=e_ndrho_ndrho, e_ndrho_ndrhoa=e_ndrho_ndrhoa, &
3466 e_ndrho_ndrhob=e_ndrho_ndrhob, e_ndrhoa_ndrhoa=e_ndrhoa_ndrhoa, &
3467 e_ndrhoa_ndrhob=e_ndrhoa_ndrhob, e_ndrhob_ndrhob=e_ndrhob_ndrhob, &
3468 e_rhoa_laplace_rhoa=e_rhoa_laplace_rhoa, &
3469 e_rhoa_laplace_rhob=e_rhoa_laplace_rhob, &
3470 e_rhob_laplace_rhoa=e_rhob_laplace_rhoa, &
3471 e_rhob_laplace_rhob=e_rhob_laplace_rhob, &
3472 e_rhoa_tau_a=e_rhoa_tau_a, e_rhoa_tau_b=e_rhoa_tau_b, &
3473 e_rhob_tau_a=e_rhob_tau_a, e_rhob_tau_b=e_rhob_tau_b, &
3474 e_ndrho_laplace_rhoa=e_ndrho_laplace_rhoa, &
3475 e_ndrho_laplace_rhob=e_ndrho_laplace_rhob, &
3476 e_ndrhoa_laplace_rhoa=e_ndrhoa_laplace_rhoa, &
3477 e_ndrhoa_laplace_rhob=e_ndrhoa_laplace_rhob, &
3478 e_ndrhob_laplace_rhoa=e_ndrhob_laplace_rhoa, &
3479 e_ndrhob_laplace_rhob=e_ndrhob_laplace_rhob, &
3480 e_ndrho_tau_a=e_ndrho_tau_a, e_ndrho_tau_b=e_ndrho_tau_b, &
3481 e_ndrhoa_tau_a=e_ndrhoa_tau_a, e_ndrhoa_tau_b=e_ndrhoa_tau_b, &
3482 e_ndrhob_tau_a=e_ndrhob_tau_a, e_ndrhob_tau_b=e_ndrhob_tau_b, &
3483 e_laplace_rhoa_laplace_rhoa=e_laplace_rhoa_laplace_rhoa, &
3484 e_laplace_rhoa_laplace_rhob=e_laplace_rhoa_laplace_rhob, &
3485 e_laplace_rhob_laplace_rhob=e_laplace_rhob_laplace_rhob, &
3486 e_laplace_rhoa_tau_a=e_laplace_rhoa_tau_a, &
3487 e_laplace_rhoa_tau_b=e_laplace_rhoa_tau_b, &
3488 e_laplace_rhob_tau_a=e_laplace_rhob_tau_a, &
3489 e_laplace_rhob_tau_b=e_laplace_rhob_tau_b, &
3490 e_tau_a_tau_a=e_tau_a_tau_a, &
3491 e_tau_a_tau_b=e_tau_a_tau_b, &
3492 e_tau_b_tau_b=e_tau_b_tau_b, &
3493 e_rhoa_rhoa_rhoa=e_rhoa_rhoa_rhoa, &
3494 e_rhoa_rhoa_rhob=e_rhoa_rhoa_rhob, &
3495 e_rhoa_rhob_rhob=e_rhoa_rhob_rhob, &
3496 e_rhob_rhob_rhob=e_rhob_rhob_rhob, &
3497 e_gamma_aa=e_gamma_aa, &
3498 e_gamma_ab=e_gamma_ab, &
3499 e_gamma_bb=e_gamma_bb, &
3500 e_rhoa_gamma_aa=e_rhoa_gamma_aa, &
3501 e_rhoa_gamma_ab=e_rhoa_gamma_ab, &
3502 e_rhoa_gamma_bb=e_rhoa_gamma_bb, &
3503 e_rhob_gamma_aa=e_rhob_gamma_aa, &
3504 e_rhob_gamma_ab=e_rhob_gamma_ab, &
3505 e_rhob_gamma_bb=e_rhob_gamma_bb, &
3506 e_gamma_aa_gamma_aa=e_gamma_aa_gamma_aa, &
3507 e_gamma_aa_gamma_ab=e_gamma_aa_gamma_ab, &
3508 e_gamma_aa_gamma_bb=e_gamma_aa_gamma_bb, &
3509 e_gamma_aa_laplace_rhoa=e_gamma_aa_laplace_rhoa, &
3510 e_gamma_aa_laplace_rhob=e_gamma_aa_laplace_rhob, &
3511 e_gamma_aa_tau_a=e_gamma_aa_tau_a, &
3512 e_gamma_aa_tau_b=e_gamma_aa_tau_b, &
3513 e_gamma_ab_gamma_ab=e_gamma_ab_gamma_ab, &
3514 e_gamma_ab_gamma_bb=e_gamma_ab_gamma_bb, &
3515 e_gamma_ab_laplace_rhoa=e_gamma_ab_laplace_rhoa, &
3516 e_gamma_ab_laplace_rhob=e_gamma_ab_laplace_rhob, &
3517 e_gamma_ab_tau_a=e_gamma_ab_tau_a, &
3518 e_gamma_ab_tau_b=e_gamma_ab_tau_b, &
3519 e_gamma_bb_gamma_bb=e_gamma_bb_gamma_bb, &
3520 e_gamma_bb_laplace_rhoa=e_gamma_bb_laplace_rhoa, &
3521 e_gamma_bb_laplace_rhob=e_gamma_bb_laplace_rhob, &
3522 e_gamma_bb_tau_a=e_gamma_bb_tau_a, &
3523 e_gamma_bb_tau_b=e_gamma_bb_tau_b, &
3524 e_rhoa_rhoa_gamma_aa=e_rhoa_rhoa_gamma_aa, &
3525 e_rhoa_rhoa_gamma_ab=e_rhoa_rhoa_gamma_ab, &
3526 e_rhoa_rhoa_gamma_bb=e_rhoa_rhoa_gamma_bb, &
3527 e_rhoa_rhoa_laplace_rhoa=e_rhoa_rhoa_laplace_rhoa, &
3528 e_rhoa_rhoa_laplace_rhob=e_rhoa_rhoa_laplace_rhob, &
3529 e_rhoa_rhoa_tau_a=e_rhoa_rhoa_tau_a, &
3530 e_rhoa_rhoa_tau_b=e_rhoa_rhoa_tau_b, &
3531 e_rhoa_rhob_gamma_aa=e_rhoa_rhob_gamma_aa, &
3532 e_rhoa_rhob_gamma_ab=e_rhoa_rhob_gamma_ab, &
3533 e_rhoa_rhob_gamma_bb=e_rhoa_rhob_gamma_bb, &
3534 e_rhoa_rhob_laplace_rhoa=e_rhoa_rhob_laplace_rhoa, &
3535 e_rhoa_rhob_laplace_rhob=e_rhoa_rhob_laplace_rhob, &
3536 e_rhoa_rhob_tau_a=e_rhoa_rhob_tau_a, &
3537 e_rhoa_rhob_tau_b=e_rhoa_rhob_tau_b, &
3538 e_rhoa_gamma_aa_gamma_aa=e_rhoa_gamma_aa_gamma_aa, &
3539 e_rhoa_gamma_aa_gamma_ab=e_rhoa_gamma_aa_gamma_ab, &
3540 e_rhoa_gamma_aa_gamma_bb=e_rhoa_gamma_aa_gamma_bb, &
3541 e_rhoa_gamma_aa_laplace_rhoa=e_rhoa_gamma_aa_laplace_rhoa, &
3542 e_rhoa_gamma_aa_laplace_rhob=e_rhoa_gamma_aa_laplace_rhob, &
3543 e_rhoa_gamma_aa_tau_a=e_rhoa_gamma_aa_tau_a, &
3544 e_rhoa_gamma_aa_tau_b=e_rhoa_gamma_aa_tau_b, &
3545 e_rhoa_gamma_ab_gamma_ab=e_rhoa_gamma_ab_gamma_ab, &
3546 e_rhoa_gamma_ab_gamma_bb=e_rhoa_gamma_ab_gamma_bb, &
3547 e_rhoa_gamma_ab_laplace_rhoa=e_rhoa_gamma_ab_laplace_rhoa, &
3548 e_rhoa_gamma_ab_laplace_rhob=e_rhoa_gamma_ab_laplace_rhob, &
3549 e_rhoa_gamma_ab_tau_a=e_rhoa_gamma_ab_tau_a, &
3550 e_rhoa_gamma_ab_tau_b=e_rhoa_gamma_ab_tau_b, &
3551 e_rhoa_gamma_bb_gamma_bb=e_rhoa_gamma_bb_gamma_bb, &
3552 e_rhoa_gamma_bb_laplace_rhoa=e_rhoa_gamma_bb_laplace_rhoa, &
3553 e_rhoa_gamma_bb_laplace_rhob=e_rhoa_gamma_bb_laplace_rhob, &
3554 e_rhoa_gamma_bb_tau_a=e_rhoa_gamma_bb_tau_a, &
3555 e_rhoa_gamma_bb_tau_b=e_rhoa_gamma_bb_tau_b, &
3556 e_rhoa_laplace_rhoa_laplace_rhoa=e_rhoa_laplace_rhoa_laplace_rhoa, &
3557 e_rhoa_laplace_rhoa_laplace_rhob=e_rhoa_laplace_rhoa_laplace_rhob, &
3558 e_rhoa_laplace_rhoa_tau_a=e_rhoa_laplace_rhoa_tau_a, &
3559 e_rhoa_laplace_rhoa_tau_b=e_rhoa_laplace_rhoa_tau_b, &
3560 e_rhoa_laplace_rhob_laplace_rhob=e_rhoa_laplace_rhob_laplace_rhob, &
3561 e_rhoa_laplace_rhob_tau_a=e_rhoa_laplace_rhob_tau_a, &
3562 e_rhoa_laplace_rhob_tau_b=e_rhoa_laplace_rhob_tau_b, &
3563 e_rhoa_tau_a_tau_a=e_rhoa_tau_a_tau_a, &
3564 e_rhoa_tau_a_tau_b=e_rhoa_tau_a_tau_b, &
3565 e_rhoa_tau_b_tau_b=e_rhoa_tau_b_tau_b, &
3566 e_rhob_rhob_gamma_aa=e_rhob_rhob_gamma_aa, &
3567 e_rhob_rhob_gamma_ab=e_rhob_rhob_gamma_ab, &
3568 e_rhob_rhob_gamma_bb=e_rhob_rhob_gamma_bb, &
3569 e_rhob_rhob_laplace_rhoa=e_rhob_rhob_laplace_rhoa, &
3570 e_rhob_rhob_laplace_rhob=e_rhob_rhob_laplace_rhob, &
3571 e_rhob_rhob_tau_a=e_rhob_rhob_tau_a, &
3572 e_rhob_rhob_tau_b=e_rhob_rhob_tau_b, &
3573 e_rhob_gamma_aa_gamma_aa=e_rhob_gamma_aa_gamma_aa, &
3574 e_rhob_gamma_aa_gamma_ab=e_rhob_gamma_aa_gamma_ab, &
3575 e_rhob_gamma_aa_gamma_bb=e_rhob_gamma_aa_gamma_bb, &
3576 e_rhob_gamma_aa_laplace_rhoa=e_rhob_gamma_aa_laplace_rhoa, &
3577 e_rhob_gamma_aa_laplace_rhob=e_rhob_gamma_aa_laplace_rhob, &
3578 e_rhob_gamma_aa_tau_a=e_rhob_gamma_aa_tau_a, &
3579 e_rhob_gamma_aa_tau_b=e_rhob_gamma_aa_tau_b, &
3580 e_rhob_gamma_ab_gamma_ab=e_rhob_gamma_ab_gamma_ab, &
3581 e_rhob_gamma_ab_gamma_bb=e_rhob_gamma_ab_gamma_bb, &
3582 e_rhob_gamma_ab_laplace_rhoa=e_rhob_gamma_ab_laplace_rhoa, &
3583 e_rhob_gamma_ab_laplace_rhob=e_rhob_gamma_ab_laplace_rhob, &
3584 e_rhob_gamma_ab_tau_a=e_rhob_gamma_ab_tau_a, &
3585 e_rhob_gamma_ab_tau_b=e_rhob_gamma_ab_tau_b, &
3586 e_rhob_gamma_bb_gamma_bb=e_rhob_gamma_bb_gamma_bb, &
3587 e_rhob_gamma_bb_laplace_rhoa=e_rhob_gamma_bb_laplace_rhoa, &
3588 e_rhob_gamma_bb_laplace_rhob=e_rhob_gamma_bb_laplace_rhob, &
3589 e_rhob_gamma_bb_tau_a=e_rhob_gamma_bb_tau_a, &
3590 e_rhob_gamma_bb_tau_b=e_rhob_gamma_bb_tau_b, &
3591 e_rhob_laplace_rhoa_laplace_rhoa=e_rhob_laplace_rhoa_laplace_rhoa, &
3592 e_rhob_laplace_rhoa_laplace_rhob=e_rhob_laplace_rhoa_laplace_rhob, &
3593 e_rhob_laplace_rhoa_tau_a=e_rhob_laplace_rhoa_tau_a, &
3594 e_rhob_laplace_rhoa_tau_b=e_rhob_laplace_rhoa_tau_b, &
3595 e_rhob_laplace_rhob_laplace_rhob=e_rhob_laplace_rhob_laplace_rhob, &
3596 e_rhob_laplace_rhob_tau_a=e_rhob_laplace_rhob_tau_a, &
3597 e_rhob_laplace_rhob_tau_b=e_rhob_laplace_rhob_tau_b, &
3598 e_rhob_tau_a_tau_a=e_rhob_tau_a_tau_a, &
3599 e_rhob_tau_a_tau_b=e_rhob_tau_a_tau_b, &
3600 e_rhob_tau_b_tau_b=e_rhob_tau_b_tau_b, &
3601 e_gamma_aa_gamma_aa_gamma_aa=e_gamma_aa_gamma_aa_gamma_aa, &
3602 e_gamma_aa_gamma_aa_gamma_ab=e_gamma_aa_gamma_aa_gamma_ab, &
3603 e_gamma_aa_gamma_aa_gamma_bb=e_gamma_aa_gamma_aa_gamma_bb, &
3604 e_gamma_aa_gamma_aa_laplace_rhoa=e_gamma_aa_gamma_aa_laplace_rhoa, &
3605 e_gamma_aa_gamma_aa_laplace_rhob=e_gamma_aa_gamma_aa_laplace_rhob, &
3606 e_gamma_aa_gamma_aa_tau_a=e_gamma_aa_gamma_aa_tau_a, &
3607 e_gamma_aa_gamma_aa_tau_b=e_gamma_aa_gamma_aa_tau_b, &
3608 e_gamma_aa_gamma_ab_gamma_ab=e_gamma_aa_gamma_ab_gamma_ab, &
3609 e_gamma_aa_gamma_ab_gamma_bb=e_gamma_aa_gamma_ab_gamma_bb, &
3610 e_gamma_aa_gamma_ab_laplace_rhoa=e_gamma_aa_gamma_ab_laplace_rhoa, &
3611 e_gamma_aa_gamma_ab_laplace_rhob=e_gamma_aa_gamma_ab_laplace_rhob, &
3612 e_gamma_aa_gamma_ab_tau_a=e_gamma_aa_gamma_ab_tau_a, &
3613 e_gamma_aa_gamma_ab_tau_b=e_gamma_aa_gamma_ab_tau_b, &
3614 e_gamma_aa_gamma_bb_gamma_bb=e_gamma_aa_gamma_bb_gamma_bb, &
3615 e_gamma_aa_gamma_bb_laplace_rhoa=e_gamma_aa_gamma_bb_laplace_rhoa, &
3616 e_gamma_aa_gamma_bb_laplace_rhob=e_gamma_aa_gamma_bb_laplace_rhob, &
3617 e_gamma_aa_gamma_bb_tau_a=e_gamma_aa_gamma_bb_tau_a, &
3618 e_gamma_aa_gamma_bb_tau_b=e_gamma_aa_gamma_bb_tau_b, &
3619 e_gamma_aa_laplace_rhoa_laplace_rhoa=e_gamma_aa_laplace_rhoa_laplace_rhoa, &
3620 e_gamma_aa_laplace_rhoa_laplace_rhob=e_gamma_aa_laplace_rhoa_laplace_rhob, &
3621 e_gamma_aa_laplace_rhoa_tau_a=e_gamma_aa_laplace_rhoa_tau_a, &
3622 e_gamma_aa_laplace_rhoa_tau_b=e_gamma_aa_laplace_rhoa_tau_b, &
3623 e_gamma_aa_laplace_rhob_laplace_rhob=e_gamma_aa_laplace_rhob_laplace_rhob, &
3624 e_gamma_aa_laplace_rhob_tau_a=e_gamma_aa_laplace_rhob_tau_a, &
3625 e_gamma_aa_laplace_rhob_tau_b=e_gamma_aa_laplace_rhob_tau_b, &
3626 e_gamma_aa_tau_a_tau_a=e_gamma_aa_tau_a_tau_a, &
3627 e_gamma_aa_tau_a_tau_b=e_gamma_aa_tau_a_tau_b, &
3628 e_gamma_aa_tau_b_tau_b=e_gamma_aa_tau_b_tau_b, &
3629 e_gamma_ab_gamma_ab_gamma_ab=e_gamma_ab_gamma_ab_gamma_ab, &
3630 e_gamma_ab_gamma_ab_gamma_bb=e_gamma_ab_gamma_ab_gamma_bb, &
3631 e_gamma_ab_gamma_ab_laplace_rhoa=e_gamma_ab_gamma_ab_laplace_rhoa, &
3632 e_gamma_ab_gamma_ab_laplace_rhob=e_gamma_ab_gamma_ab_laplace_rhob, &
3633 e_gamma_ab_gamma_ab_tau_a=e_gamma_ab_gamma_ab_tau_a, &
3634 e_gamma_ab_gamma_ab_tau_b=e_gamma_ab_gamma_ab_tau_b, &
3635 e_gamma_ab_gamma_bb_gamma_bb=e_gamma_ab_gamma_bb_gamma_bb, &
3636 e_gamma_ab_gamma_bb_laplace_rhoa=e_gamma_ab_gamma_bb_laplace_rhoa, &
3637 e_gamma_ab_gamma_bb_laplace_rhob=e_gamma_ab_gamma_bb_laplace_rhob, &
3638 e_gamma_ab_gamma_bb_tau_a=e_gamma_ab_gamma_bb_tau_a, &
3639 e_gamma_ab_gamma_bb_tau_b=e_gamma_ab_gamma_bb_tau_b, &
3640 e_gamma_ab_laplace_rhoa_laplace_rhoa=e_gamma_ab_laplace_rhoa_laplace_rhoa, &
3641 e_gamma_ab_laplace_rhoa_laplace_rhob=e_gamma_ab_laplace_rhoa_laplace_rhob, &
3642 e_gamma_ab_laplace_rhoa_tau_a=e_gamma_ab_laplace_rhoa_tau_a, &
3643 e_gamma_ab_laplace_rhoa_tau_b=e_gamma_ab_laplace_rhoa_tau_b, &
3644 e_gamma_ab_laplace_rhob_laplace_rhob=e_gamma_ab_laplace_rhob_laplace_rhob, &
3645 e_gamma_ab_laplace_rhob_tau_a=e_gamma_ab_laplace_rhob_tau_a, &
3646 e_gamma_ab_laplace_rhob_tau_b=e_gamma_ab_laplace_rhob_tau_b, &
3647 e_gamma_ab_tau_a_tau_a=e_gamma_ab_tau_a_tau_a, &
3648 e_gamma_ab_tau_a_tau_b=e_gamma_ab_tau_a_tau_b, &
3649 e_gamma_ab_tau_b_tau_b=e_gamma_ab_tau_b_tau_b, &
3650 e_gamma_bb_gamma_bb_gamma_bb=e_gamma_bb_gamma_bb_gamma_bb, &
3651 e_gamma_bb_gamma_bb_laplace_rhoa=e_gamma_bb_gamma_bb_laplace_rhoa, &
3652 e_gamma_bb_gamma_bb_laplace_rhob=e_gamma_bb_gamma_bb_laplace_rhob, &
3653 e_gamma_bb_gamma_bb_tau_a=e_gamma_bb_gamma_bb_tau_a, &
3654 e_gamma_bb_gamma_bb_tau_b=e_gamma_bb_gamma_bb_tau_b, &
3655 e_gamma_bb_laplace_rhoa_laplace_rhoa=e_gamma_bb_laplace_rhoa_laplace_rhoa, &
3656 e_gamma_bb_laplace_rhoa_laplace_rhob=e_gamma_bb_laplace_rhoa_laplace_rhob, &
3657 e_gamma_bb_laplace_rhoa_tau_a=e_gamma_bb_laplace_rhoa_tau_a, &
3658 e_gamma_bb_laplace_rhoa_tau_b=e_gamma_bb_laplace_rhoa_tau_b, &
3659 e_gamma_bb_laplace_rhob_laplace_rhob=e_gamma_bb_laplace_rhob_laplace_rhob, &
3660 e_gamma_bb_laplace_rhob_tau_a=e_gamma_bb_laplace_rhob_tau_a, &
3661 e_gamma_bb_laplace_rhob_tau_b=e_gamma_bb_laplace_rhob_tau_b, &
3662 e_gamma_bb_tau_a_tau_a=e_gamma_bb_tau_a_tau_a, &
3663 e_gamma_bb_tau_a_tau_b=e_gamma_bb_tau_a_tau_b, &
3664 e_gamma_bb_tau_b_tau_b=e_gamma_bb_tau_b_tau_b, &
3665 e_laplace_rhoa_laplace_rhoa_laplace_rhoa=e_laplace_rhoa_laplace_rhoa_laplace_rhoa, &
3666 e_laplace_rhoa_laplace_rhoa_laplace_rhob=e_laplace_rhoa_laplace_rhoa_laplace_rhob, &
3667 e_laplace_rhoa_laplace_rhoa_tau_a=e_laplace_rhoa_laplace_rhoa_tau_a, &
3668 e_laplace_rhoa_laplace_rhoa_tau_b=e_laplace_rhoa_laplace_rhoa_tau_b, &
3669 e_laplace_rhoa_laplace_rhob_laplace_rhob=e_laplace_rhoa_laplace_rhob_laplace_rhob, &
3670 e_laplace_rhoa_laplace_rhob_tau_a=e_laplace_rhoa_laplace_rhob_tau_a, &
3671 e_laplace_rhoa_laplace_rhob_tau_b=e_laplace_rhoa_laplace_rhob_tau_b, &
3672 e_laplace_rhoa_tau_a_tau_a=e_laplace_rhoa_tau_a_tau_a, &
3673 e_laplace_rhoa_tau_a_tau_b=e_laplace_rhoa_tau_a_tau_b, &
3674 e_laplace_rhoa_tau_b_tau_b=e_laplace_rhoa_tau_b_tau_b, &
3675 e_laplace_rhob_laplace_rhob_laplace_rhob=e_laplace_rhob_laplace_rhob_laplace_rhob, &
3676 e_laplace_rhob_laplace_rhob_tau_a=e_laplace_rhob_laplace_rhob_tau_a, &
3677 e_laplace_rhob_laplace_rhob_tau_b=e_laplace_rhob_laplace_rhob_tau_b, &
3678 e_laplace_rhob_tau_a_tau_a=e_laplace_rhob_tau_a_tau_a, &
3679 e_laplace_rhob_tau_a_tau_b=e_laplace_rhob_tau_a_tau_b, &
3680 e_laplace_rhob_tau_b_tau_b=e_laplace_rhob_tau_b_tau_b, &
3681 e_tau_a_tau_a_tau_a=e_tau_a_tau_a_tau_a, &
3682 e_tau_a_tau_a_tau_b=e_tau_a_tau_a_tau_b, &
3683 e_tau_a_tau_b_tau_b=e_tau_a_tau_b_tau_b, &
3684 e_tau_b_tau_b_tau_b=e_tau_b_tau_b_tau_b, &
3685 grad_deriv=grad_deriv, npoints=npoints, &
3686 func_name=func_name, sc=func_scale, workers=workers)
3687
3688!$OMP END PARALLEL
3689
3690 NULLIFY (dummy)
3691 NULLIFY (workers)
3692
3693 CALL timestop(handle)
3694#else
3695 mark_used(rho_set)
3696 mark_used(deriv_set)
3697 mark_used(grad_deriv)
3698 mark_used(libxc_params)
3699 mark_used(func_name_override)
3700
3701 CALL cp_abort(__location__, "Unknown functional! If you are asking "// &
3702 "for a functional of the LibXC library, "// &
3703 "you have to download and install the library!")
3704#endif
3705 END SUBROUTINE libxc_spin_polarized_eval
3706
3707#if defined (__LIBXC)
3708
3709! **************************************************************************************************
3710!> \brief Compact C2 maximum, with a transition width relative to its positive lower argument.
3711!> \param a First argument.
3712!> \param b Positive second argument.
3713!> \param value Projected maximum.
3714!> \param first First derivatives in a and b.
3715!> \param second Second derivatives in a and b.
3716!> \param active Optional indication that the first argument is not on the identity branch.
3717!> \param third Optional third derivatives inside each smooth branch.
3718! **************************************************************************************************
3719 PURE SUBROUTINE libxc_c2_maximum(a, b, value, first, second, active, third)
3720 REAL(dp), INTENT(IN) :: a, b
3721 REAL(dp), INTENT(OUT) :: value, first(2), second(2, 2)
3722 LOGICAL, INTENT(OUT), OPTIONAL :: active
3723 REAL(dp), INTENT(OUT), OPTIONAL :: third(2, 2, 2)
3724
3725 REAL(dp), PARAMETER :: relative_width = 64.0_dp*sqrt(epsilon(0.0_dp))
3726
3727 REAL(dp) :: curvature, curvature_derivative, &
3728 polynomial, ratio, slope, u, width
3729
3730 width = relative_width*b
3731 IF (PRESENT(active)) active = a - b < width
3732 second = 0.0_dp
3733 IF (PRESENT(third)) third = 0.0_dp
3734 IF (a - b >= width) THEN
3735 value = a
3736 first = [1.0_dp, 0.0_dp]
3737 ELSE IF (a - b <= -width) THEN
3738 value = b
3739 first = [0.0_dp, 1.0_dp]
3740 ELSE
3741 u = (a - b)/width
3742 polynomial = (1.0_dp + u)**3*(3.0_dp - u)/16.0_dp
3743 slope = (1.0_dp + u)**2*(2.0_dp - u)/4.0_dp
3744 curvature = 0.75_dp*(1.0_dp - u*u)/width
3745 ratio = a/b
3746 value = b + width*polynomial
3747 first = [slope, 1.0_dp + relative_width*polynomial - ratio*slope]
3748 second(1, 1) = curvature
3749 second(1, 2) = -ratio*curvature
3750 second(2, 1) = second(1, 2)
3751 second(2, 2) = ratio*ratio*curvature
3752 IF (PRESENT(third)) THEN
3753 curvature_derivative = -1.5_dp*u/width**2
3754 third(1, 1, 1) = curvature_derivative
3755 third(1, 1, 2) = -curvature/b - ratio*curvature_derivative
3756 third(1, 2, 1) = third(1, 1, 2)
3757 third(2, 1, 1) = third(1, 1, 2)
3758 third(1, 2, 2) = 2.0_dp*ratio*curvature/b + ratio**2*curvature_derivative
3759 third(2, 1, 2) = third(1, 2, 2)
3760 third(2, 2, 1) = third(1, 2, 2)
3761 third(2, 2, 2) = -3.0_dp*ratio**2*curvature/b - ratio**3*curvature_derivative
3762 END IF
3763 END IF
3764 END SUBROUTINE libxc_c2_maximum
3765
3766! **************************************************************************************************
3767!> \brief C2 kinetic projection and its full derivatives in rho, sigma and raw tau.
3768!> \param rho Density used in the bounded denominator.
3769!> \param sigma Same-spin gradient contraction.
3770!> \param raw_tau Unprojected kinetic density.
3771!> \param epsilon_rho Density cutoff.
3772!> \param epsilon_tau Positive kinetic floor.
3773!> \param first Optional first derivatives.
3774!> \param second Optional second derivatives.
3775!> \param active Optional projection activity, independent of rounding of the value.
3776!> \param third Optional third derivatives inside each smooth branch.
3777!> \return Projected kinetic density.
3778! **************************************************************************************************
3779 FUNCTION libxc_c2_project_tau(rho, sigma, raw_tau, epsilon_rho, epsilon_tau, first, second, active, third) RESULT(value)
3780 REAL(dp), INTENT(IN) :: rho, sigma, raw_tau, epsilon_rho, &
3781 epsilon_tau
3782 REAL(dp), INTENT(OUT), OPTIONAL :: first(3), second(3, 3)
3783 LOGICAL, INTENT(OUT), OPTIONAL :: active
3784 REAL(dp), INTENT(OUT), OPTIONAL :: third(3, 3, 3)
3785 REAL(dp) :: value
3786
3787 INTEGER :: a, b, c, i, j, k
3788 LOGICAL :: projection_active
3789 REAL(dp) :: denominator, final_first(2), final_second(2, 2), final_third(2, 2, 2), &
3790 inner_first(2, 3), inner_second(3, 3), inner_third(3, 3, 3), lower, lower_first(2), &
3791 lower_second(2, 2), lower_third(2, 2, 2), outer(2, 2), tau_w, w_first(2), w_second(2, 2), &
3792 w_third(2, 2, 2)
3793
3794 denominator = max(rho, epsilon_rho, tiny(0.0_dp))
3795 tau_w = sigma/(8.0_dp*denominator)
3796 CALL libxc_c2_maximum(tau_w, max(epsilon_tau, epsilon(0.0_dp)), lower, lower_first, lower_second)
3797 CALL libxc_c2_maximum(raw_tau, lower, value, final_first, final_second, projection_active)
3798 IF (PRESENT(active)) active = projection_active
3799 IF (.NOT. projection_active) THEN
3800 IF (PRESENT(first)) first = [0.0_dp, 0.0_dp, 1.0_dp]
3801 IF (PRESENT(second)) second = 0.0_dp
3802 IF (PRESENT(third)) third = 0.0_dp
3803 RETURN
3804 END IF
3805 IF (.NOT. PRESENT(first) .AND. .NOT. PRESENT(second) .AND. .NOT. PRESENT(third)) RETURN
3806 w_first = [0.0_dp, 1.0_dp/(8.0_dp*denominator)]
3807 w_second = 0.0_dp
3808 IF (rho > epsilon_rho) THEN
3809 w_first(1) = -tau_w/denominator
3810 w_second(1, 1) = 2.0_dp*tau_w/denominator**2
3811 w_second(1, 2) = -w_first(2)/denominator
3812 w_second(2, 1) = w_second(1, 2)
3813 END IF
3814 IF (PRESENT(first)) THEN
3815 first(1:2) = final_first(2)*lower_first(1)*w_first
3816 first(3) = final_first(1)
3817 END IF
3818 IF (PRESENT(second) .OR. PRESENT(third)) THEN
3819 DO j = 1, 2
3820 DO i = 1, 2
3821 outer(i, j) = w_first(i)*w_first(j)
3822 END DO
3823 END DO
3824 END IF
3825 IF (PRESENT(second)) THEN
3826 second = 0.0_dp
3827 second(1:2, 1:2) = final_first(2)*(lower_first(1)*w_second + lower_second(1, 1)*outer) + &
3828 final_second(2, 2)*lower_first(1)**2*outer
3829 second(1:2, 3) = final_second(1, 2)*lower_first(1)*w_first
3830 second(3, 1:2) = second(1:2, 3)
3831 second(3, 3) = final_second(1, 1)
3832 END IF
3833 IF (PRESENT(third)) THEN
3834 CALL libxc_c2_maximum(tau_w, max(epsilon_tau, epsilon(0.0_dp)), lower, &
3835 lower_first, lower_second, third=lower_third)
3836 CALL libxc_c2_maximum(raw_tau, lower, value, final_first, final_second, third=final_third)
3837 w_third = 0.0_dp
3838 IF (rho > epsilon_rho) THEN
3839 w_third(1, 1, 1) = -6.0_dp*tau_w/denominator**3
3840 w_third(1, 1, 2) = 2.0_dp*w_first(2)/denominator**2
3841 w_third(1, 2, 1) = w_third(1, 1, 2)
3842 w_third(2, 1, 1) = w_third(1, 1, 2)
3843 END IF
3844 inner_first = 0.0_dp
3845 inner_first(1, 3) = 1.0_dp
3846 inner_first(2, 1:2) = lower_first(1)*w_first
3847 inner_second = 0.0_dp
3848 inner_second(1:2, 1:2) = lower_first(1)*w_second + lower_second(1, 1)*outer
3849 inner_third = 0.0_dp
3850 DO k = 1, 2
3851 DO j = 1, 2
3852 DO i = 1, 2
3853 inner_third(i, j, k) = lower_first(1)*w_third(i, j, k) + &
3854 lower_second(1, 1)*(w_second(i, j)*w_first(k) + w_second(i, k)*w_first(j) + &
3855 w_second(j, k)*w_first(i)) + &
3856 lower_third(1, 1, 1)*w_first(i)*w_first(j)*w_first(k)
3857 END DO
3858 END DO
3859 END DO
3860 DO k = 1, 3
3861 DO j = 1, 3
3862 DO i = 1, 3
3863 third(i, j, k) = final_first(2)*inner_third(i, j, k)
3864 DO a = 1, 2
3865 third(i, j, k) = third(i, j, k) + final_second(a, 2)* &
3866 (inner_first(a, i)*inner_second(j, k) + inner_first(a, j)*inner_second(i, k) + &
3867 inner_first(a, k)*inner_second(i, j))
3868 DO b = 1, 2
3869 DO c = 1, 2
3870 third(i, j, k) = third(i, j, k) + &
3871 final_third(a, b, c)*inner_first(a, i)*inner_first(b, j)*inner_first(c, k)
3872 END DO
3873 END DO
3874 END DO
3875 END DO
3876 END DO
3877 END DO
3878 END IF
3879 END FUNCTION libxc_c2_project_tau
3880
3881! **************************************************************************************************
3882!> \brief Pull back Libxc meta-GGA derivatives through the kinetic-density projection.
3883!> \param w Functional worker with derivatives in Libxc variables.
3884!> \param point Point within the worker's current block.
3885!> \param raw_tau Kinetic densities before projection.
3886!> \param nspin Number of spin channels.
3887!> \param grad_deriv Requested derivative order.
3888!> \param has_laplace Whether the functional uses the density Laplacian.
3889!> \param epsilon_rho Density cutoff used in the projection denominator.
3890!> \param epsilon_tau Kinetic-density cutoff used as a positive floor.
3891! **************************************************************************************************
3892 SUBROUTINE libxc_mgga_tau_pullback(w, point, raw_tau, nspin, grad_deriv, has_laplace, &
3893 epsilon_rho, epsilon_tau)
3894 TYPE(libxc_worker_type), INTENT(INOUT) :: w
3895 INTEGER, INTENT(IN) :: point, nspin, grad_deriv
3896 REAL(dp), INTENT(IN) :: raw_tau(nspin), epsilon_rho, &
3897 epsilon_tau
3898 LOGICAL, INTENT(IN) :: has_laplace
3899
3900 INTEGER :: channel, i, irho, isigma, itau, nvar
3901 REAL(dp) :: projected, tau_first(3), &
3902 tau_second(3, 3), tau_third(3, 3, 3)
3903 INTEGER :: indices(3), j, k
3904 LOGICAL :: active(2)
3905 REAL(dp) :: gradient(9), hessian(9, 9), jacobian(9, 9), &
3906 curvature(9, 9, 2), pulled_gradient(9), &
3907 pulled_hessian(9, 9), third(9, 9, 9), &
3908 pulled_third(9, 9, 9), scratch(9, 9, 9), &
3909 map_third(9, 9, 9, 2), mixed(9)
3910
3911 IF (grad_deriv < 1) RETURN
3912 cpassert(nspin == 1 .OR. nspin == 2)
3913 nvar = 4
3914 IF (nspin == 2) nvar = 9
3915 gradient = 0.0_dp
3916 hessian = 0.0_dp
3917 jacobian = 0.0_dp
3918 curvature = 0.0_dp
3919 IF (grad_deriv >= 3) map_third = 0.0_dp
3920 DO i = 1, nvar
3921 jacobian(i, i) = 1.0_dp
3922 END DO
3923
3924 ! The transition can change curvature even when its value rounds to raw tau.
3925 active = .false.
3926 DO channel = 1, nspin
3927 irho = channel
3928 isigma = 2
3929 itau = 4
3930 IF (nspin == 2) THEN
3931 isigma = 2*channel + 1
3932 itau = 7 + channel
3933 END IF
3934 projected = libxc_c2_project_tau(w%rho(channel, point), w%sigma(isigma - nspin, point), &
3935 raw_tau(channel), epsilon_rho, epsilon_tau, tau_first, tau_second, active(channel))
3936 IF (.NOT. active(channel)) cycle
3937 IF (grad_deriv >= 3) THEN
3938 projected = libxc_c2_project_tau(w%rho(channel, point), w%sigma(isigma - nspin, point), &
3939 raw_tau(channel), epsilon_rho, epsilon_tau, third=tau_third)
3940 END IF
3941 jacobian(itau, :) = 0.0_dp
3942 indices = [irho, isigma, itau]
3943 DO i = 1, 3
3944 jacobian(itau, indices(i)) = tau_first(i)
3945 DO j = 1, 3
3946 curvature(indices(i), indices(j), channel) = tau_second(i, j)
3947 IF (grad_deriv >= 3) THEN
3948 DO k = 1, 3
3949 map_third(indices(i), indices(j), indices(k), channel) = tau_third(i, j, k)
3950 END DO
3951 END IF
3952 END DO
3953 END DO
3954 END DO
3955 IF (.NOT. any(active(1:nspin))) RETURN
3956 IF (grad_deriv >= 3) THEN
3957 third = 0.0_dp
3958 scratch = 0.0_dp
3959 END IF
3960
3961 IF (nspin == 1) THEN
3962 IF (grad_deriv >= 1) THEN
3963 gradient(1) = w%vrho(1, point)
3964 gradient(2) = w%vsigma(1, point)
3965 IF (has_laplace) THEN
3966 gradient(3) = w%vlapl(1, point)
3967 END IF
3968 gradient(4) = w%vtau(1, point)
3969 END IF
3970 IF (grad_deriv >= 2) THEN
3971 hessian(1, 1) = w%v2rho2(1, point)
3972 hessian(1, 1) = hessian(1, 1)
3973 hessian(1, 2) = w%v2rhosigma(1, point)
3974 hessian(2, 1) = hessian(1, 2)
3975 IF (has_laplace) THEN
3976 hessian(1, 3) = w%v2rholapl(1, point)
3977 END IF
3978 hessian(3, 1) = hessian(1, 3)
3979 hessian(1, 4) = w%v2rhotau(1, point)
3980 hessian(4, 1) = hessian(1, 4)
3981 hessian(2, 2) = w%v2sigma2(1, point)
3982 hessian(2, 2) = hessian(2, 2)
3983 IF (has_laplace) THEN
3984 hessian(2, 3) = w%v2sigmalapl(1, point)
3985 END IF
3986 hessian(3, 2) = hessian(2, 3)
3987 hessian(2, 4) = w%v2sigmatau(1, point)
3988 hessian(4, 2) = hessian(2, 4)
3989 IF (has_laplace) THEN
3990 hessian(3, 3) = w%v2lapl2(1, point)
3991 END IF
3992 hessian(3, 3) = hessian(3, 3)
3993 IF (has_laplace) THEN
3994 hessian(3, 4) = w%v2lapltau(1, point)
3995 END IF
3996 hessian(4, 3) = hessian(3, 4)
3997 hessian(4, 4) = w%v2tau2(1, point)
3998 hessian(4, 4) = hessian(4, 4)
3999 END IF
4000 IF (grad_deriv >= 3) THEN
4001 third(1, 1, 1) = w%v3rho3(1, point)
4002 third(1, 1, 2) = w%v3rho2sigma(1, point)
4003 third(1, 2, 1) = third(1, 1, 2)
4004 third(2, 1, 1) = third(1, 1, 2)
4005 IF (has_laplace) THEN
4006 third(1, 1, 3) = w%v3rho2lapl(1, point)
4007 END IF
4008 third(1, 3, 1) = third(1, 1, 3)
4009 third(3, 1, 1) = third(1, 1, 3)
4010 third(1, 1, 4) = w%v3rho2tau(1, point)
4011 third(1, 4, 1) = third(1, 1, 4)
4012 third(4, 1, 1) = third(1, 1, 4)
4013 third(1, 2, 2) = w%v3rhosigma2(1, point)
4014 third(2, 1, 2) = third(1, 2, 2)
4015 third(2, 2, 1) = third(1, 2, 2)
4016 IF (has_laplace) THEN
4017 third(1, 2, 3) = w%v3rhosigmalapl(1, point)
4018 END IF
4019 third(1, 3, 2) = third(1, 2, 3)
4020 third(2, 1, 3) = third(1, 2, 3)
4021 third(2, 3, 1) = third(1, 2, 3)
4022 third(3, 1, 2) = third(1, 2, 3)
4023 third(3, 2, 1) = third(1, 2, 3)
4024 third(1, 2, 4) = w%v3rhosigmatau(1, point)
4025 third(1, 4, 2) = third(1, 2, 4)
4026 third(2, 1, 4) = third(1, 2, 4)
4027 third(2, 4, 1) = third(1, 2, 4)
4028 third(4, 1, 2) = third(1, 2, 4)
4029 third(4, 2, 1) = third(1, 2, 4)
4030 IF (has_laplace) THEN
4031 third(1, 3, 3) = w%v3rholapl2(1, point)
4032 END IF
4033 third(3, 1, 3) = third(1, 3, 3)
4034 third(3, 3, 1) = third(1, 3, 3)
4035 IF (has_laplace) THEN
4036 third(1, 3, 4) = w%v3rholapltau(1, point)
4037 END IF
4038 third(1, 4, 3) = third(1, 3, 4)
4039 third(3, 1, 4) = third(1, 3, 4)
4040 third(3, 4, 1) = third(1, 3, 4)
4041 third(4, 1, 3) = third(1, 3, 4)
4042 third(4, 3, 1) = third(1, 3, 4)
4043 third(1, 4, 4) = w%v3rhotau2(1, point)
4044 third(4, 1, 4) = third(1, 4, 4)
4045 third(4, 4, 1) = third(1, 4, 4)
4046 third(2, 2, 2) = w%v3sigma3(1, point)
4047 IF (has_laplace) THEN
4048 third(2, 2, 3) = w%v3sigma2lapl(1, point)
4049 END IF
4050 third(2, 3, 2) = third(2, 2, 3)
4051 third(3, 2, 2) = third(2, 2, 3)
4052 third(2, 2, 4) = w%v3sigma2tau(1, point)
4053 third(2, 4, 2) = third(2, 2, 4)
4054 third(4, 2, 2) = third(2, 2, 4)
4055 IF (has_laplace) THEN
4056 third(2, 3, 3) = w%v3sigmalapl2(1, point)
4057 END IF
4058 third(3, 2, 3) = third(2, 3, 3)
4059 third(3, 3, 2) = third(2, 3, 3)
4060 IF (has_laplace) THEN
4061 third(2, 3, 4) = w%v3sigmalapltau(1, point)
4062 END IF
4063 third(2, 4, 3) = third(2, 3, 4)
4064 third(3, 2, 4) = third(2, 3, 4)
4065 third(3, 4, 2) = third(2, 3, 4)
4066 third(4, 2, 3) = third(2, 3, 4)
4067 third(4, 3, 2) = third(2, 3, 4)
4068 third(2, 4, 4) = w%v3sigmatau2(1, point)
4069 third(4, 2, 4) = third(2, 4, 4)
4070 third(4, 4, 2) = third(2, 4, 4)
4071 IF (has_laplace) THEN
4072 third(3, 3, 3) = w%v3lapl3(1, point)
4073 END IF
4074 IF (has_laplace) THEN
4075 third(3, 3, 4) = w%v3lapl2tau(1, point)
4076 END IF
4077 third(3, 4, 3) = third(3, 3, 4)
4078 third(4, 3, 3) = third(3, 3, 4)
4079 IF (has_laplace) THEN
4080 third(3, 4, 4) = w%v3lapltau2(1, point)
4081 END IF
4082 third(4, 3, 4) = third(3, 4, 4)
4083 third(4, 4, 3) = third(3, 4, 4)
4084 third(4, 4, 4) = w%v3tau3(1, point)
4085 END IF
4086 ELSE
4087 IF (grad_deriv >= 1) THEN
4088 gradient(1) = w%vrho(1, point)
4089 gradient(2) = w%vrho(2, point)
4090 gradient(3) = w%vsigma(1, point)
4091 gradient(4) = w%vsigma(2, point)
4092 gradient(5) = w%vsigma(3, point)
4093 IF (has_laplace) THEN
4094 gradient(6) = w%vlapl(1, point)
4095 END IF
4096 IF (has_laplace) THEN
4097 gradient(7) = w%vlapl(2, point)
4098 END IF
4099 gradient(8) = w%vtau(1, point)
4100 gradient(9) = w%vtau(2, point)
4101 END IF
4102 IF (grad_deriv >= 2) THEN
4103 hessian(1, 1) = w%v2rho2(1, point)
4104 hessian(1, 1) = hessian(1, 1)
4105 hessian(1, 2) = w%v2rho2(2, point)
4106 hessian(2, 1) = hessian(1, 2)
4107 hessian(1, 3) = w%v2rhosigma(1, point)
4108 hessian(3, 1) = hessian(1, 3)
4109 hessian(1, 4) = w%v2rhosigma(2, point)
4110 hessian(4, 1) = hessian(1, 4)
4111 hessian(1, 5) = w%v2rhosigma(3, point)
4112 hessian(5, 1) = hessian(1, 5)
4113 IF (has_laplace) THEN
4114 hessian(1, 6) = w%v2rholapl(1, point)
4115 END IF
4116 hessian(6, 1) = hessian(1, 6)
4117 IF (has_laplace) THEN
4118 hessian(1, 7) = w%v2rholapl(2, point)
4119 END IF
4120 hessian(7, 1) = hessian(1, 7)
4121 hessian(1, 8) = w%v2rhotau(1, point)
4122 hessian(8, 1) = hessian(1, 8)
4123 hessian(1, 9) = w%v2rhotau(2, point)
4124 hessian(9, 1) = hessian(1, 9)
4125 hessian(2, 2) = w%v2rho2(3, point)
4126 hessian(2, 2) = hessian(2, 2)
4127 hessian(2, 3) = w%v2rhosigma(4, point)
4128 hessian(3, 2) = hessian(2, 3)
4129 hessian(2, 4) = w%v2rhosigma(5, point)
4130 hessian(4, 2) = hessian(2, 4)
4131 hessian(2, 5) = w%v2rhosigma(6, point)
4132 hessian(5, 2) = hessian(2, 5)
4133 IF (has_laplace) THEN
4134 hessian(2, 6) = w%v2rholapl(3, point)
4135 END IF
4136 hessian(6, 2) = hessian(2, 6)
4137 IF (has_laplace) THEN
4138 hessian(2, 7) = w%v2rholapl(4, point)
4139 END IF
4140 hessian(7, 2) = hessian(2, 7)
4141 hessian(2, 8) = w%v2rhotau(3, point)
4142 hessian(8, 2) = hessian(2, 8)
4143 hessian(2, 9) = w%v2rhotau(4, point)
4144 hessian(9, 2) = hessian(2, 9)
4145 hessian(3, 3) = w%v2sigma2(1, point)
4146 hessian(3, 3) = hessian(3, 3)
4147 hessian(3, 4) = w%v2sigma2(2, point)
4148 hessian(4, 3) = hessian(3, 4)
4149 hessian(3, 5) = w%v2sigma2(3, point)
4150 hessian(5, 3) = hessian(3, 5)
4151 IF (has_laplace) THEN
4152 hessian(3, 6) = w%v2sigmalapl(1, point)
4153 END IF
4154 hessian(6, 3) = hessian(3, 6)
4155 IF (has_laplace) THEN
4156 hessian(3, 7) = w%v2sigmalapl(2, point)
4157 END IF
4158 hessian(7, 3) = hessian(3, 7)
4159 hessian(3, 8) = w%v2sigmatau(1, point)
4160 hessian(8, 3) = hessian(3, 8)
4161 hessian(3, 9) = w%v2sigmatau(2, point)
4162 hessian(9, 3) = hessian(3, 9)
4163 hessian(4, 4) = w%v2sigma2(4, point)
4164 hessian(4, 4) = hessian(4, 4)
4165 hessian(4, 5) = w%v2sigma2(5, point)
4166 hessian(5, 4) = hessian(4, 5)
4167 IF (has_laplace) THEN
4168 hessian(4, 6) = w%v2sigmalapl(3, point)
4169 END IF
4170 hessian(6, 4) = hessian(4, 6)
4171 IF (has_laplace) THEN
4172 hessian(4, 7) = w%v2sigmalapl(4, point)
4173 END IF
4174 hessian(7, 4) = hessian(4, 7)
4175 hessian(4, 8) = w%v2sigmatau(3, point)
4176 hessian(8, 4) = hessian(4, 8)
4177 hessian(4, 9) = w%v2sigmatau(4, point)
4178 hessian(9, 4) = hessian(4, 9)
4179 hessian(5, 5) = w%v2sigma2(6, point)
4180 hessian(5, 5) = hessian(5, 5)
4181 IF (has_laplace) THEN
4182 hessian(5, 6) = w%v2sigmalapl(5, point)
4183 END IF
4184 hessian(6, 5) = hessian(5, 6)
4185 IF (has_laplace) THEN
4186 hessian(5, 7) = w%v2sigmalapl(6, point)
4187 END IF
4188 hessian(7, 5) = hessian(5, 7)
4189 hessian(5, 8) = w%v2sigmatau(5, point)
4190 hessian(8, 5) = hessian(5, 8)
4191 hessian(5, 9) = w%v2sigmatau(6, point)
4192 hessian(9, 5) = hessian(5, 9)
4193 IF (has_laplace) THEN
4194 hessian(6, 6) = w%v2lapl2(1, point)
4195 END IF
4196 hessian(6, 6) = hessian(6, 6)
4197 IF (has_laplace) THEN
4198 hessian(6, 7) = w%v2lapl2(2, point)
4199 END IF
4200 hessian(7, 6) = hessian(6, 7)
4201 IF (has_laplace) THEN
4202 hessian(6, 8) = w%v2lapltau(1, point)
4203 END IF
4204 hessian(8, 6) = hessian(6, 8)
4205 IF (has_laplace) THEN
4206 hessian(6, 9) = w%v2lapltau(2, point)
4207 END IF
4208 hessian(9, 6) = hessian(6, 9)
4209 IF (has_laplace) THEN
4210 hessian(7, 7) = w%v2lapl2(3, point)
4211 END IF
4212 hessian(7, 7) = hessian(7, 7)
4213 IF (has_laplace) THEN
4214 hessian(7, 8) = w%v2lapltau(3, point)
4215 END IF
4216 hessian(8, 7) = hessian(7, 8)
4217 IF (has_laplace) THEN
4218 hessian(7, 9) = w%v2lapltau(4, point)
4219 END IF
4220 hessian(9, 7) = hessian(7, 9)
4221 hessian(8, 8) = w%v2tau2(1, point)
4222 hessian(8, 8) = hessian(8, 8)
4223 hessian(8, 9) = w%v2tau2(2, point)
4224 hessian(9, 8) = hessian(8, 9)
4225 hessian(9, 9) = w%v2tau2(3, point)
4226 hessian(9, 9) = hessian(9, 9)
4227 END IF
4228 IF (grad_deriv >= 3) THEN
4229 third(1, 1, 1) = w%v3rho3(1, point)
4230 third(1, 1, 2) = w%v3rho3(2, point)
4231 third(1, 2, 1) = third(1, 1, 2)
4232 third(2, 1, 1) = third(1, 1, 2)
4233 third(1, 1, 3) = w%v3rho2sigma(1, point)
4234 third(1, 3, 1) = third(1, 1, 3)
4235 third(3, 1, 1) = third(1, 1, 3)
4236 third(1, 1, 4) = w%v3rho2sigma(2, point)
4237 third(1, 4, 1) = third(1, 1, 4)
4238 third(4, 1, 1) = third(1, 1, 4)
4239 third(1, 1, 5) = w%v3rho2sigma(3, point)
4240 third(1, 5, 1) = third(1, 1, 5)
4241 third(5, 1, 1) = third(1, 1, 5)
4242 IF (has_laplace) THEN
4243 third(1, 1, 6) = w%v3rho2lapl(1, point)
4244 END IF
4245 third(1, 6, 1) = third(1, 1, 6)
4246 third(6, 1, 1) = third(1, 1, 6)
4247 IF (has_laplace) THEN
4248 third(1, 1, 7) = w%v3rho2lapl(2, point)
4249 END IF
4250 third(1, 7, 1) = third(1, 1, 7)
4251 third(7, 1, 1) = third(1, 1, 7)
4252 third(1, 1, 8) = w%v3rho2tau(1, point)
4253 third(1, 8, 1) = third(1, 1, 8)
4254 third(8, 1, 1) = third(1, 1, 8)
4255 third(1, 1, 9) = w%v3rho2tau(2, point)
4256 third(1, 9, 1) = third(1, 1, 9)
4257 third(9, 1, 1) = third(1, 1, 9)
4258 third(1, 2, 2) = w%v3rho3(3, point)
4259 third(2, 1, 2) = third(1, 2, 2)
4260 third(2, 2, 1) = third(1, 2, 2)
4261 third(1, 2, 3) = w%v3rho2sigma(4, point)
4262 third(1, 3, 2) = third(1, 2, 3)
4263 third(2, 1, 3) = third(1, 2, 3)
4264 third(2, 3, 1) = third(1, 2, 3)
4265 third(3, 1, 2) = third(1, 2, 3)
4266 third(3, 2, 1) = third(1, 2, 3)
4267 third(1, 2, 4) = w%v3rho2sigma(5, point)
4268 third(1, 4, 2) = third(1, 2, 4)
4269 third(2, 1, 4) = third(1, 2, 4)
4270 third(2, 4, 1) = third(1, 2, 4)
4271 third(4, 1, 2) = third(1, 2, 4)
4272 third(4, 2, 1) = third(1, 2, 4)
4273 third(1, 2, 5) = w%v3rho2sigma(6, point)
4274 third(1, 5, 2) = third(1, 2, 5)
4275 third(2, 1, 5) = third(1, 2, 5)
4276 third(2, 5, 1) = third(1, 2, 5)
4277 third(5, 1, 2) = third(1, 2, 5)
4278 third(5, 2, 1) = third(1, 2, 5)
4279 IF (has_laplace) THEN
4280 third(1, 2, 6) = w%v3rho2lapl(3, point)
4281 END IF
4282 third(1, 6, 2) = third(1, 2, 6)
4283 third(2, 1, 6) = third(1, 2, 6)
4284 third(2, 6, 1) = third(1, 2, 6)
4285 third(6, 1, 2) = third(1, 2, 6)
4286 third(6, 2, 1) = third(1, 2, 6)
4287 IF (has_laplace) THEN
4288 third(1, 2, 7) = w%v3rho2lapl(4, point)
4289 END IF
4290 third(1, 7, 2) = third(1, 2, 7)
4291 third(2, 1, 7) = third(1, 2, 7)
4292 third(2, 7, 1) = third(1, 2, 7)
4293 third(7, 1, 2) = third(1, 2, 7)
4294 third(7, 2, 1) = third(1, 2, 7)
4295 third(1, 2, 8) = w%v3rho2tau(3, point)
4296 third(1, 8, 2) = third(1, 2, 8)
4297 third(2, 1, 8) = third(1, 2, 8)
4298 third(2, 8, 1) = third(1, 2, 8)
4299 third(8, 1, 2) = third(1, 2, 8)
4300 third(8, 2, 1) = third(1, 2, 8)
4301 third(1, 2, 9) = w%v3rho2tau(4, point)
4302 third(1, 9, 2) = third(1, 2, 9)
4303 third(2, 1, 9) = third(1, 2, 9)
4304 third(2, 9, 1) = third(1, 2, 9)
4305 third(9, 1, 2) = third(1, 2, 9)
4306 third(9, 2, 1) = third(1, 2, 9)
4307 third(1, 3, 3) = w%v3rhosigma2(1, point)
4308 third(3, 1, 3) = third(1, 3, 3)
4309 third(3, 3, 1) = third(1, 3, 3)
4310 third(1, 3, 4) = w%v3rhosigma2(2, point)
4311 third(1, 4, 3) = third(1, 3, 4)
4312 third(3, 1, 4) = third(1, 3, 4)
4313 third(3, 4, 1) = third(1, 3, 4)
4314 third(4, 1, 3) = third(1, 3, 4)
4315 third(4, 3, 1) = third(1, 3, 4)
4316 third(1, 3, 5) = w%v3rhosigma2(3, point)
4317 third(1, 5, 3) = third(1, 3, 5)
4318 third(3, 1, 5) = third(1, 3, 5)
4319 third(3, 5, 1) = third(1, 3, 5)
4320 third(5, 1, 3) = third(1, 3, 5)
4321 third(5, 3, 1) = third(1, 3, 5)
4322 IF (has_laplace) THEN
4323 third(1, 3, 6) = w%v3rhosigmalapl(1, point)
4324 END IF
4325 third(1, 6, 3) = third(1, 3, 6)
4326 third(3, 1, 6) = third(1, 3, 6)
4327 third(3, 6, 1) = third(1, 3, 6)
4328 third(6, 1, 3) = third(1, 3, 6)
4329 third(6, 3, 1) = third(1, 3, 6)
4330 IF (has_laplace) THEN
4331 third(1, 3, 7) = w%v3rhosigmalapl(2, point)
4332 END IF
4333 third(1, 7, 3) = third(1, 3, 7)
4334 third(3, 1, 7) = third(1, 3, 7)
4335 third(3, 7, 1) = third(1, 3, 7)
4336 third(7, 1, 3) = third(1, 3, 7)
4337 third(7, 3, 1) = third(1, 3, 7)
4338 third(1, 3, 8) = w%v3rhosigmatau(1, point)
4339 third(1, 8, 3) = third(1, 3, 8)
4340 third(3, 1, 8) = third(1, 3, 8)
4341 third(3, 8, 1) = third(1, 3, 8)
4342 third(8, 1, 3) = third(1, 3, 8)
4343 third(8, 3, 1) = third(1, 3, 8)
4344 third(1, 3, 9) = w%v3rhosigmatau(2, point)
4345 third(1, 9, 3) = third(1, 3, 9)
4346 third(3, 1, 9) = third(1, 3, 9)
4347 third(3, 9, 1) = third(1, 3, 9)
4348 third(9, 1, 3) = third(1, 3, 9)
4349 third(9, 3, 1) = third(1, 3, 9)
4350 third(1, 4, 4) = w%v3rhosigma2(4, point)
4351 third(4, 1, 4) = third(1, 4, 4)
4352 third(4, 4, 1) = third(1, 4, 4)
4353 third(1, 4, 5) = w%v3rhosigma2(5, point)
4354 third(1, 5, 4) = third(1, 4, 5)
4355 third(4, 1, 5) = third(1, 4, 5)
4356 third(4, 5, 1) = third(1, 4, 5)
4357 third(5, 1, 4) = third(1, 4, 5)
4358 third(5, 4, 1) = third(1, 4, 5)
4359 IF (has_laplace) THEN
4360 third(1, 4, 6) = w%v3rhosigmalapl(3, point)
4361 END IF
4362 third(1, 6, 4) = third(1, 4, 6)
4363 third(4, 1, 6) = third(1, 4, 6)
4364 third(4, 6, 1) = third(1, 4, 6)
4365 third(6, 1, 4) = third(1, 4, 6)
4366 third(6, 4, 1) = third(1, 4, 6)
4367 IF (has_laplace) THEN
4368 third(1, 4, 7) = w%v3rhosigmalapl(4, point)
4369 END IF
4370 third(1, 7, 4) = third(1, 4, 7)
4371 third(4, 1, 7) = third(1, 4, 7)
4372 third(4, 7, 1) = third(1, 4, 7)
4373 third(7, 1, 4) = third(1, 4, 7)
4374 third(7, 4, 1) = third(1, 4, 7)
4375 third(1, 4, 8) = w%v3rhosigmatau(3, point)
4376 third(1, 8, 4) = third(1, 4, 8)
4377 third(4, 1, 8) = third(1, 4, 8)
4378 third(4, 8, 1) = third(1, 4, 8)
4379 third(8, 1, 4) = third(1, 4, 8)
4380 third(8, 4, 1) = third(1, 4, 8)
4381 third(1, 4, 9) = w%v3rhosigmatau(4, point)
4382 third(1, 9, 4) = third(1, 4, 9)
4383 third(4, 1, 9) = third(1, 4, 9)
4384 third(4, 9, 1) = third(1, 4, 9)
4385 third(9, 1, 4) = third(1, 4, 9)
4386 third(9, 4, 1) = third(1, 4, 9)
4387 third(1, 5, 5) = w%v3rhosigma2(6, point)
4388 third(5, 1, 5) = third(1, 5, 5)
4389 third(5, 5, 1) = third(1, 5, 5)
4390 IF (has_laplace) THEN
4391 third(1, 5, 6) = w%v3rhosigmalapl(5, point)
4392 END IF
4393 third(1, 6, 5) = third(1, 5, 6)
4394 third(5, 1, 6) = third(1, 5, 6)
4395 third(5, 6, 1) = third(1, 5, 6)
4396 third(6, 1, 5) = third(1, 5, 6)
4397 third(6, 5, 1) = third(1, 5, 6)
4398 IF (has_laplace) THEN
4399 third(1, 5, 7) = w%v3rhosigmalapl(6, point)
4400 END IF
4401 third(1, 7, 5) = third(1, 5, 7)
4402 third(5, 1, 7) = third(1, 5, 7)
4403 third(5, 7, 1) = third(1, 5, 7)
4404 third(7, 1, 5) = third(1, 5, 7)
4405 third(7, 5, 1) = third(1, 5, 7)
4406 third(1, 5, 8) = w%v3rhosigmatau(5, point)
4407 third(1, 8, 5) = third(1, 5, 8)
4408 third(5, 1, 8) = third(1, 5, 8)
4409 third(5, 8, 1) = third(1, 5, 8)
4410 third(8, 1, 5) = third(1, 5, 8)
4411 third(8, 5, 1) = third(1, 5, 8)
4412 third(1, 5, 9) = w%v3rhosigmatau(6, point)
4413 third(1, 9, 5) = third(1, 5, 9)
4414 third(5, 1, 9) = third(1, 5, 9)
4415 third(5, 9, 1) = third(1, 5, 9)
4416 third(9, 1, 5) = third(1, 5, 9)
4417 third(9, 5, 1) = third(1, 5, 9)
4418 IF (has_laplace) THEN
4419 third(1, 6, 6) = w%v3rholapl2(1, point)
4420 END IF
4421 third(6, 1, 6) = third(1, 6, 6)
4422 third(6, 6, 1) = third(1, 6, 6)
4423 IF (has_laplace) THEN
4424 third(1, 6, 7) = w%v3rholapl2(2, point)
4425 END IF
4426 third(1, 7, 6) = third(1, 6, 7)
4427 third(6, 1, 7) = third(1, 6, 7)
4428 third(6, 7, 1) = third(1, 6, 7)
4429 third(7, 1, 6) = third(1, 6, 7)
4430 third(7, 6, 1) = third(1, 6, 7)
4431 IF (has_laplace) THEN
4432 third(1, 6, 8) = w%v3rholapltau(1, point)
4433 END IF
4434 third(1, 8, 6) = third(1, 6, 8)
4435 third(6, 1, 8) = third(1, 6, 8)
4436 third(6, 8, 1) = third(1, 6, 8)
4437 third(8, 1, 6) = third(1, 6, 8)
4438 third(8, 6, 1) = third(1, 6, 8)
4439 IF (has_laplace) THEN
4440 third(1, 6, 9) = w%v3rholapltau(2, point)
4441 END IF
4442 third(1, 9, 6) = third(1, 6, 9)
4443 third(6, 1, 9) = third(1, 6, 9)
4444 third(6, 9, 1) = third(1, 6, 9)
4445 third(9, 1, 6) = third(1, 6, 9)
4446 third(9, 6, 1) = third(1, 6, 9)
4447 IF (has_laplace) THEN
4448 third(1, 7, 7) = w%v3rholapl2(3, point)
4449 END IF
4450 third(7, 1, 7) = third(1, 7, 7)
4451 third(7, 7, 1) = third(1, 7, 7)
4452 IF (has_laplace) THEN
4453 third(1, 7, 8) = w%v3rholapltau(3, point)
4454 END IF
4455 third(1, 8, 7) = third(1, 7, 8)
4456 third(7, 1, 8) = third(1, 7, 8)
4457 third(7, 8, 1) = third(1, 7, 8)
4458 third(8, 1, 7) = third(1, 7, 8)
4459 third(8, 7, 1) = third(1, 7, 8)
4460 IF (has_laplace) THEN
4461 third(1, 7, 9) = w%v3rholapltau(4, point)
4462 END IF
4463 third(1, 9, 7) = third(1, 7, 9)
4464 third(7, 1, 9) = third(1, 7, 9)
4465 third(7, 9, 1) = third(1, 7, 9)
4466 third(9, 1, 7) = third(1, 7, 9)
4467 third(9, 7, 1) = third(1, 7, 9)
4468 third(1, 8, 8) = w%v3rhotau2(1, point)
4469 third(8, 1, 8) = third(1, 8, 8)
4470 third(8, 8, 1) = third(1, 8, 8)
4471 third(1, 8, 9) = w%v3rhotau2(2, point)
4472 third(1, 9, 8) = third(1, 8, 9)
4473 third(8, 1, 9) = third(1, 8, 9)
4474 third(8, 9, 1) = third(1, 8, 9)
4475 third(9, 1, 8) = third(1, 8, 9)
4476 third(9, 8, 1) = third(1, 8, 9)
4477 third(1, 9, 9) = w%v3rhotau2(3, point)
4478 third(9, 1, 9) = third(1, 9, 9)
4479 third(9, 9, 1) = third(1, 9, 9)
4480 third(2, 2, 2) = w%v3rho3(4, point)
4481 third(2, 2, 3) = w%v3rho2sigma(7, point)
4482 third(2, 3, 2) = third(2, 2, 3)
4483 third(3, 2, 2) = third(2, 2, 3)
4484 third(2, 2, 4) = w%v3rho2sigma(8, point)
4485 third(2, 4, 2) = third(2, 2, 4)
4486 third(4, 2, 2) = third(2, 2, 4)
4487 third(2, 2, 5) = w%v3rho2sigma(9, point)
4488 third(2, 5, 2) = third(2, 2, 5)
4489 third(5, 2, 2) = third(2, 2, 5)
4490 IF (has_laplace) THEN
4491 third(2, 2, 6) = w%v3rho2lapl(5, point)
4492 END IF
4493 third(2, 6, 2) = third(2, 2, 6)
4494 third(6, 2, 2) = third(2, 2, 6)
4495 IF (has_laplace) THEN
4496 third(2, 2, 7) = w%v3rho2lapl(6, point)
4497 END IF
4498 third(2, 7, 2) = third(2, 2, 7)
4499 third(7, 2, 2) = third(2, 2, 7)
4500 third(2, 2, 8) = w%v3rho2tau(5, point)
4501 third(2, 8, 2) = third(2, 2, 8)
4502 third(8, 2, 2) = third(2, 2, 8)
4503 third(2, 2, 9) = w%v3rho2tau(6, point)
4504 third(2, 9, 2) = third(2, 2, 9)
4505 third(9, 2, 2) = third(2, 2, 9)
4506 third(2, 3, 3) = w%v3rhosigma2(7, point)
4507 third(3, 2, 3) = third(2, 3, 3)
4508 third(3, 3, 2) = third(2, 3, 3)
4509 third(2, 3, 4) = w%v3rhosigma2(8, point)
4510 third(2, 4, 3) = third(2, 3, 4)
4511 third(3, 2, 4) = third(2, 3, 4)
4512 third(3, 4, 2) = third(2, 3, 4)
4513 third(4, 2, 3) = third(2, 3, 4)
4514 third(4, 3, 2) = third(2, 3, 4)
4515 third(2, 3, 5) = w%v3rhosigma2(9, point)
4516 third(2, 5, 3) = third(2, 3, 5)
4517 third(3, 2, 5) = third(2, 3, 5)
4518 third(3, 5, 2) = third(2, 3, 5)
4519 third(5, 2, 3) = third(2, 3, 5)
4520 third(5, 3, 2) = third(2, 3, 5)
4521 IF (has_laplace) THEN
4522 third(2, 3, 6) = w%v3rhosigmalapl(7, point)
4523 END IF
4524 third(2, 6, 3) = third(2, 3, 6)
4525 third(3, 2, 6) = third(2, 3, 6)
4526 third(3, 6, 2) = third(2, 3, 6)
4527 third(6, 2, 3) = third(2, 3, 6)
4528 third(6, 3, 2) = third(2, 3, 6)
4529 IF (has_laplace) THEN
4530 third(2, 3, 7) = w%v3rhosigmalapl(8, point)
4531 END IF
4532 third(2, 7, 3) = third(2, 3, 7)
4533 third(3, 2, 7) = third(2, 3, 7)
4534 third(3, 7, 2) = third(2, 3, 7)
4535 third(7, 2, 3) = third(2, 3, 7)
4536 third(7, 3, 2) = third(2, 3, 7)
4537 third(2, 3, 8) = w%v3rhosigmatau(7, point)
4538 third(2, 8, 3) = third(2, 3, 8)
4539 third(3, 2, 8) = third(2, 3, 8)
4540 third(3, 8, 2) = third(2, 3, 8)
4541 third(8, 2, 3) = third(2, 3, 8)
4542 third(8, 3, 2) = third(2, 3, 8)
4543 third(2, 3, 9) = w%v3rhosigmatau(8, point)
4544 third(2, 9, 3) = third(2, 3, 9)
4545 third(3, 2, 9) = third(2, 3, 9)
4546 third(3, 9, 2) = third(2, 3, 9)
4547 third(9, 2, 3) = third(2, 3, 9)
4548 third(9, 3, 2) = third(2, 3, 9)
4549 third(2, 4, 4) = w%v3rhosigma2(10, point)
4550 third(4, 2, 4) = third(2, 4, 4)
4551 third(4, 4, 2) = third(2, 4, 4)
4552 third(2, 4, 5) = w%v3rhosigma2(11, point)
4553 third(2, 5, 4) = third(2, 4, 5)
4554 third(4, 2, 5) = third(2, 4, 5)
4555 third(4, 5, 2) = third(2, 4, 5)
4556 third(5, 2, 4) = third(2, 4, 5)
4557 third(5, 4, 2) = third(2, 4, 5)
4558 IF (has_laplace) THEN
4559 third(2, 4, 6) = w%v3rhosigmalapl(9, point)
4560 END IF
4561 third(2, 6, 4) = third(2, 4, 6)
4562 third(4, 2, 6) = third(2, 4, 6)
4563 third(4, 6, 2) = third(2, 4, 6)
4564 third(6, 2, 4) = third(2, 4, 6)
4565 third(6, 4, 2) = third(2, 4, 6)
4566 IF (has_laplace) THEN
4567 third(2, 4, 7) = w%v3rhosigmalapl(10, point)
4568 END IF
4569 third(2, 7, 4) = third(2, 4, 7)
4570 third(4, 2, 7) = third(2, 4, 7)
4571 third(4, 7, 2) = third(2, 4, 7)
4572 third(7, 2, 4) = third(2, 4, 7)
4573 third(7, 4, 2) = third(2, 4, 7)
4574 third(2, 4, 8) = w%v3rhosigmatau(9, point)
4575 third(2, 8, 4) = third(2, 4, 8)
4576 third(4, 2, 8) = third(2, 4, 8)
4577 third(4, 8, 2) = third(2, 4, 8)
4578 third(8, 2, 4) = third(2, 4, 8)
4579 third(8, 4, 2) = third(2, 4, 8)
4580 third(2, 4, 9) = w%v3rhosigmatau(10, point)
4581 third(2, 9, 4) = third(2, 4, 9)
4582 third(4, 2, 9) = third(2, 4, 9)
4583 third(4, 9, 2) = third(2, 4, 9)
4584 third(9, 2, 4) = third(2, 4, 9)
4585 third(9, 4, 2) = third(2, 4, 9)
4586 third(2, 5, 5) = w%v3rhosigma2(12, point)
4587 third(5, 2, 5) = third(2, 5, 5)
4588 third(5, 5, 2) = third(2, 5, 5)
4589 IF (has_laplace) THEN
4590 third(2, 5, 6) = w%v3rhosigmalapl(11, point)
4591 END IF
4592 third(2, 6, 5) = third(2, 5, 6)
4593 third(5, 2, 6) = third(2, 5, 6)
4594 third(5, 6, 2) = third(2, 5, 6)
4595 third(6, 2, 5) = third(2, 5, 6)
4596 third(6, 5, 2) = third(2, 5, 6)
4597 IF (has_laplace) THEN
4598 third(2, 5, 7) = w%v3rhosigmalapl(12, point)
4599 END IF
4600 third(2, 7, 5) = third(2, 5, 7)
4601 third(5, 2, 7) = third(2, 5, 7)
4602 third(5, 7, 2) = third(2, 5, 7)
4603 third(7, 2, 5) = third(2, 5, 7)
4604 third(7, 5, 2) = third(2, 5, 7)
4605 third(2, 5, 8) = w%v3rhosigmatau(11, point)
4606 third(2, 8, 5) = third(2, 5, 8)
4607 third(5, 2, 8) = third(2, 5, 8)
4608 third(5, 8, 2) = third(2, 5, 8)
4609 third(8, 2, 5) = third(2, 5, 8)
4610 third(8, 5, 2) = third(2, 5, 8)
4611 third(2, 5, 9) = w%v3rhosigmatau(12, point)
4612 third(2, 9, 5) = third(2, 5, 9)
4613 third(5, 2, 9) = third(2, 5, 9)
4614 third(5, 9, 2) = third(2, 5, 9)
4615 third(9, 2, 5) = third(2, 5, 9)
4616 third(9, 5, 2) = third(2, 5, 9)
4617 IF (has_laplace) THEN
4618 third(2, 6, 6) = w%v3rholapl2(4, point)
4619 END IF
4620 third(6, 2, 6) = third(2, 6, 6)
4621 third(6, 6, 2) = third(2, 6, 6)
4622 IF (has_laplace) THEN
4623 third(2, 6, 7) = w%v3rholapl2(5, point)
4624 END IF
4625 third(2, 7, 6) = third(2, 6, 7)
4626 third(6, 2, 7) = third(2, 6, 7)
4627 third(6, 7, 2) = third(2, 6, 7)
4628 third(7, 2, 6) = third(2, 6, 7)
4629 third(7, 6, 2) = third(2, 6, 7)
4630 IF (has_laplace) THEN
4631 third(2, 6, 8) = w%v3rholapltau(5, point)
4632 END IF
4633 third(2, 8, 6) = third(2, 6, 8)
4634 third(6, 2, 8) = third(2, 6, 8)
4635 third(6, 8, 2) = third(2, 6, 8)
4636 third(8, 2, 6) = third(2, 6, 8)
4637 third(8, 6, 2) = third(2, 6, 8)
4638 IF (has_laplace) THEN
4639 third(2, 6, 9) = w%v3rholapltau(6, point)
4640 END IF
4641 third(2, 9, 6) = third(2, 6, 9)
4642 third(6, 2, 9) = third(2, 6, 9)
4643 third(6, 9, 2) = third(2, 6, 9)
4644 third(9, 2, 6) = third(2, 6, 9)
4645 third(9, 6, 2) = third(2, 6, 9)
4646 IF (has_laplace) THEN
4647 third(2, 7, 7) = w%v3rholapl2(6, point)
4648 END IF
4649 third(7, 2, 7) = third(2, 7, 7)
4650 third(7, 7, 2) = third(2, 7, 7)
4651 IF (has_laplace) THEN
4652 third(2, 7, 8) = w%v3rholapltau(7, point)
4653 END IF
4654 third(2, 8, 7) = third(2, 7, 8)
4655 third(7, 2, 8) = third(2, 7, 8)
4656 third(7, 8, 2) = third(2, 7, 8)
4657 third(8, 2, 7) = third(2, 7, 8)
4658 third(8, 7, 2) = third(2, 7, 8)
4659 IF (has_laplace) THEN
4660 third(2, 7, 9) = w%v3rholapltau(8, point)
4661 END IF
4662 third(2, 9, 7) = third(2, 7, 9)
4663 third(7, 2, 9) = third(2, 7, 9)
4664 third(7, 9, 2) = third(2, 7, 9)
4665 third(9, 2, 7) = third(2, 7, 9)
4666 third(9, 7, 2) = third(2, 7, 9)
4667 third(2, 8, 8) = w%v3rhotau2(4, point)
4668 third(8, 2, 8) = third(2, 8, 8)
4669 third(8, 8, 2) = third(2, 8, 8)
4670 third(2, 8, 9) = w%v3rhotau2(5, point)
4671 third(2, 9, 8) = third(2, 8, 9)
4672 third(8, 2, 9) = third(2, 8, 9)
4673 third(8, 9, 2) = third(2, 8, 9)
4674 third(9, 2, 8) = third(2, 8, 9)
4675 third(9, 8, 2) = third(2, 8, 9)
4676 third(2, 9, 9) = w%v3rhotau2(6, point)
4677 third(9, 2, 9) = third(2, 9, 9)
4678 third(9, 9, 2) = third(2, 9, 9)
4679 third(3, 3, 3) = w%v3sigma3(1, point)
4680 third(3, 3, 4) = w%v3sigma3(2, point)
4681 third(3, 4, 3) = third(3, 3, 4)
4682 third(4, 3, 3) = third(3, 3, 4)
4683 third(3, 3, 5) = w%v3sigma3(3, point)
4684 third(3, 5, 3) = third(3, 3, 5)
4685 third(5, 3, 3) = third(3, 3, 5)
4686 IF (has_laplace) THEN
4687 third(3, 3, 6) = w%v3sigma2lapl(1, point)
4688 END IF
4689 third(3, 6, 3) = third(3, 3, 6)
4690 third(6, 3, 3) = third(3, 3, 6)
4691 IF (has_laplace) THEN
4692 third(3, 3, 7) = w%v3sigma2lapl(2, point)
4693 END IF
4694 third(3, 7, 3) = third(3, 3, 7)
4695 third(7, 3, 3) = third(3, 3, 7)
4696 third(3, 3, 8) = w%v3sigma2tau(1, point)
4697 third(3, 8, 3) = third(3, 3, 8)
4698 third(8, 3, 3) = third(3, 3, 8)
4699 third(3, 3, 9) = w%v3sigma2tau(2, point)
4700 third(3, 9, 3) = third(3, 3, 9)
4701 third(9, 3, 3) = third(3, 3, 9)
4702 third(3, 4, 4) = w%v3sigma3(4, point)
4703 third(4, 3, 4) = third(3, 4, 4)
4704 third(4, 4, 3) = third(3, 4, 4)
4705 third(3, 4, 5) = w%v3sigma3(5, point)
4706 third(3, 5, 4) = third(3, 4, 5)
4707 third(4, 3, 5) = third(3, 4, 5)
4708 third(4, 5, 3) = third(3, 4, 5)
4709 third(5, 3, 4) = third(3, 4, 5)
4710 third(5, 4, 3) = third(3, 4, 5)
4711 IF (has_laplace) THEN
4712 third(3, 4, 6) = w%v3sigma2lapl(3, point)
4713 END IF
4714 third(3, 6, 4) = third(3, 4, 6)
4715 third(4, 3, 6) = third(3, 4, 6)
4716 third(4, 6, 3) = third(3, 4, 6)
4717 third(6, 3, 4) = third(3, 4, 6)
4718 third(6, 4, 3) = third(3, 4, 6)
4719 IF (has_laplace) THEN
4720 third(3, 4, 7) = w%v3sigma2lapl(4, point)
4721 END IF
4722 third(3, 7, 4) = third(3, 4, 7)
4723 third(4, 3, 7) = third(3, 4, 7)
4724 third(4, 7, 3) = third(3, 4, 7)
4725 third(7, 3, 4) = third(3, 4, 7)
4726 third(7, 4, 3) = third(3, 4, 7)
4727 third(3, 4, 8) = w%v3sigma2tau(3, point)
4728 third(3, 8, 4) = third(3, 4, 8)
4729 third(4, 3, 8) = third(3, 4, 8)
4730 third(4, 8, 3) = third(3, 4, 8)
4731 third(8, 3, 4) = third(3, 4, 8)
4732 third(8, 4, 3) = third(3, 4, 8)
4733 third(3, 4, 9) = w%v3sigma2tau(4, point)
4734 third(3, 9, 4) = third(3, 4, 9)
4735 third(4, 3, 9) = third(3, 4, 9)
4736 third(4, 9, 3) = third(3, 4, 9)
4737 third(9, 3, 4) = third(3, 4, 9)
4738 third(9, 4, 3) = third(3, 4, 9)
4739 third(3, 5, 5) = w%v3sigma3(6, point)
4740 third(5, 3, 5) = third(3, 5, 5)
4741 third(5, 5, 3) = third(3, 5, 5)
4742 IF (has_laplace) THEN
4743 third(3, 5, 6) = w%v3sigma2lapl(5, point)
4744 END IF
4745 third(3, 6, 5) = third(3, 5, 6)
4746 third(5, 3, 6) = third(3, 5, 6)
4747 third(5, 6, 3) = third(3, 5, 6)
4748 third(6, 3, 5) = third(3, 5, 6)
4749 third(6, 5, 3) = third(3, 5, 6)
4750 IF (has_laplace) THEN
4751 third(3, 5, 7) = w%v3sigma2lapl(6, point)
4752 END IF
4753 third(3, 7, 5) = third(3, 5, 7)
4754 third(5, 3, 7) = third(3, 5, 7)
4755 third(5, 7, 3) = third(3, 5, 7)
4756 third(7, 3, 5) = third(3, 5, 7)
4757 third(7, 5, 3) = third(3, 5, 7)
4758 third(3, 5, 8) = w%v3sigma2tau(5, point)
4759 third(3, 8, 5) = third(3, 5, 8)
4760 third(5, 3, 8) = third(3, 5, 8)
4761 third(5, 8, 3) = third(3, 5, 8)
4762 third(8, 3, 5) = third(3, 5, 8)
4763 third(8, 5, 3) = third(3, 5, 8)
4764 third(3, 5, 9) = w%v3sigma2tau(6, point)
4765 third(3, 9, 5) = third(3, 5, 9)
4766 third(5, 3, 9) = third(3, 5, 9)
4767 third(5, 9, 3) = third(3, 5, 9)
4768 third(9, 3, 5) = third(3, 5, 9)
4769 third(9, 5, 3) = third(3, 5, 9)
4770 IF (has_laplace) THEN
4771 third(3, 6, 6) = w%v3sigmalapl2(1, point)
4772 END IF
4773 third(6, 3, 6) = third(3, 6, 6)
4774 third(6, 6, 3) = third(3, 6, 6)
4775 IF (has_laplace) THEN
4776 third(3, 6, 7) = w%v3sigmalapl2(2, point)
4777 END IF
4778 third(3, 7, 6) = third(3, 6, 7)
4779 third(6, 3, 7) = third(3, 6, 7)
4780 third(6, 7, 3) = third(3, 6, 7)
4781 third(7, 3, 6) = third(3, 6, 7)
4782 third(7, 6, 3) = third(3, 6, 7)
4783 IF (has_laplace) THEN
4784 third(3, 6, 8) = w%v3sigmalapltau(1, point)
4785 END IF
4786 third(3, 8, 6) = third(3, 6, 8)
4787 third(6, 3, 8) = third(3, 6, 8)
4788 third(6, 8, 3) = third(3, 6, 8)
4789 third(8, 3, 6) = third(3, 6, 8)
4790 third(8, 6, 3) = third(3, 6, 8)
4791 IF (has_laplace) THEN
4792 third(3, 6, 9) = w%v3sigmalapltau(2, point)
4793 END IF
4794 third(3, 9, 6) = third(3, 6, 9)
4795 third(6, 3, 9) = third(3, 6, 9)
4796 third(6, 9, 3) = third(3, 6, 9)
4797 third(9, 3, 6) = third(3, 6, 9)
4798 third(9, 6, 3) = third(3, 6, 9)
4799 IF (has_laplace) THEN
4800 third(3, 7, 7) = w%v3sigmalapl2(3, point)
4801 END IF
4802 third(7, 3, 7) = third(3, 7, 7)
4803 third(7, 7, 3) = third(3, 7, 7)
4804 IF (has_laplace) THEN
4805 third(3, 7, 8) = w%v3sigmalapltau(3, point)
4806 END IF
4807 third(3, 8, 7) = third(3, 7, 8)
4808 third(7, 3, 8) = third(3, 7, 8)
4809 third(7, 8, 3) = third(3, 7, 8)
4810 third(8, 3, 7) = third(3, 7, 8)
4811 third(8, 7, 3) = third(3, 7, 8)
4812 IF (has_laplace) THEN
4813 third(3, 7, 9) = w%v3sigmalapltau(4, point)
4814 END IF
4815 third(3, 9, 7) = third(3, 7, 9)
4816 third(7, 3, 9) = third(3, 7, 9)
4817 third(7, 9, 3) = third(3, 7, 9)
4818 third(9, 3, 7) = third(3, 7, 9)
4819 third(9, 7, 3) = third(3, 7, 9)
4820 third(3, 8, 8) = w%v3sigmatau2(1, point)
4821 third(8, 3, 8) = third(3, 8, 8)
4822 third(8, 8, 3) = third(3, 8, 8)
4823 third(3, 8, 9) = w%v3sigmatau2(2, point)
4824 third(3, 9, 8) = third(3, 8, 9)
4825 third(8, 3, 9) = third(3, 8, 9)
4826 third(8, 9, 3) = third(3, 8, 9)
4827 third(9, 3, 8) = third(3, 8, 9)
4828 third(9, 8, 3) = third(3, 8, 9)
4829 third(3, 9, 9) = w%v3sigmatau2(3, point)
4830 third(9, 3, 9) = third(3, 9, 9)
4831 third(9, 9, 3) = third(3, 9, 9)
4832 third(4, 4, 4) = w%v3sigma3(7, point)
4833 third(4, 4, 5) = w%v3sigma3(8, point)
4834 third(4, 5, 4) = third(4, 4, 5)
4835 third(5, 4, 4) = third(4, 4, 5)
4836 IF (has_laplace) THEN
4837 third(4, 4, 6) = w%v3sigma2lapl(7, point)
4838 END IF
4839 third(4, 6, 4) = third(4, 4, 6)
4840 third(6, 4, 4) = third(4, 4, 6)
4841 IF (has_laplace) THEN
4842 third(4, 4, 7) = w%v3sigma2lapl(8, point)
4843 END IF
4844 third(4, 7, 4) = third(4, 4, 7)
4845 third(7, 4, 4) = third(4, 4, 7)
4846 third(4, 4, 8) = w%v3sigma2tau(7, point)
4847 third(4, 8, 4) = third(4, 4, 8)
4848 third(8, 4, 4) = third(4, 4, 8)
4849 third(4, 4, 9) = w%v3sigma2tau(8, point)
4850 third(4, 9, 4) = third(4, 4, 9)
4851 third(9, 4, 4) = third(4, 4, 9)
4852 third(4, 5, 5) = w%v3sigma3(9, point)
4853 third(5, 4, 5) = third(4, 5, 5)
4854 third(5, 5, 4) = third(4, 5, 5)
4855 IF (has_laplace) THEN
4856 third(4, 5, 6) = w%v3sigma2lapl(9, point)
4857 END IF
4858 third(4, 6, 5) = third(4, 5, 6)
4859 third(5, 4, 6) = third(4, 5, 6)
4860 third(5, 6, 4) = third(4, 5, 6)
4861 third(6, 4, 5) = third(4, 5, 6)
4862 third(6, 5, 4) = third(4, 5, 6)
4863 IF (has_laplace) THEN
4864 third(4, 5, 7) = w%v3sigma2lapl(10, point)
4865 END IF
4866 third(4, 7, 5) = third(4, 5, 7)
4867 third(5, 4, 7) = third(4, 5, 7)
4868 third(5, 7, 4) = third(4, 5, 7)
4869 third(7, 4, 5) = third(4, 5, 7)
4870 third(7, 5, 4) = third(4, 5, 7)
4871 third(4, 5, 8) = w%v3sigma2tau(9, point)
4872 third(4, 8, 5) = third(4, 5, 8)
4873 third(5, 4, 8) = third(4, 5, 8)
4874 third(5, 8, 4) = third(4, 5, 8)
4875 third(8, 4, 5) = third(4, 5, 8)
4876 third(8, 5, 4) = third(4, 5, 8)
4877 third(4, 5, 9) = w%v3sigma2tau(10, point)
4878 third(4, 9, 5) = third(4, 5, 9)
4879 third(5, 4, 9) = third(4, 5, 9)
4880 third(5, 9, 4) = third(4, 5, 9)
4881 third(9, 4, 5) = third(4, 5, 9)
4882 third(9, 5, 4) = third(4, 5, 9)
4883 IF (has_laplace) THEN
4884 third(4, 6, 6) = w%v3sigmalapl2(4, point)
4885 END IF
4886 third(6, 4, 6) = third(4, 6, 6)
4887 third(6, 6, 4) = third(4, 6, 6)
4888 IF (has_laplace) THEN
4889 third(4, 6, 7) = w%v3sigmalapl2(5, point)
4890 END IF
4891 third(4, 7, 6) = third(4, 6, 7)
4892 third(6, 4, 7) = third(4, 6, 7)
4893 third(6, 7, 4) = third(4, 6, 7)
4894 third(7, 4, 6) = third(4, 6, 7)
4895 third(7, 6, 4) = third(4, 6, 7)
4896 IF (has_laplace) THEN
4897 third(4, 6, 8) = w%v3sigmalapltau(5, point)
4898 END IF
4899 third(4, 8, 6) = third(4, 6, 8)
4900 third(6, 4, 8) = third(4, 6, 8)
4901 third(6, 8, 4) = third(4, 6, 8)
4902 third(8, 4, 6) = third(4, 6, 8)
4903 third(8, 6, 4) = third(4, 6, 8)
4904 IF (has_laplace) THEN
4905 third(4, 6, 9) = w%v3sigmalapltau(6, point)
4906 END IF
4907 third(4, 9, 6) = third(4, 6, 9)
4908 third(6, 4, 9) = third(4, 6, 9)
4909 third(6, 9, 4) = third(4, 6, 9)
4910 third(9, 4, 6) = third(4, 6, 9)
4911 third(9, 6, 4) = third(4, 6, 9)
4912 IF (has_laplace) THEN
4913 third(4, 7, 7) = w%v3sigmalapl2(6, point)
4914 END IF
4915 third(7, 4, 7) = third(4, 7, 7)
4916 third(7, 7, 4) = third(4, 7, 7)
4917 IF (has_laplace) THEN
4918 third(4, 7, 8) = w%v3sigmalapltau(7, point)
4919 END IF
4920 third(4, 8, 7) = third(4, 7, 8)
4921 third(7, 4, 8) = third(4, 7, 8)
4922 third(7, 8, 4) = third(4, 7, 8)
4923 third(8, 4, 7) = third(4, 7, 8)
4924 third(8, 7, 4) = third(4, 7, 8)
4925 IF (has_laplace) THEN
4926 third(4, 7, 9) = w%v3sigmalapltau(8, point)
4927 END IF
4928 third(4, 9, 7) = third(4, 7, 9)
4929 third(7, 4, 9) = third(4, 7, 9)
4930 third(7, 9, 4) = third(4, 7, 9)
4931 third(9, 4, 7) = third(4, 7, 9)
4932 third(9, 7, 4) = third(4, 7, 9)
4933 third(4, 8, 8) = w%v3sigmatau2(4, point)
4934 third(8, 4, 8) = third(4, 8, 8)
4935 third(8, 8, 4) = third(4, 8, 8)
4936 third(4, 8, 9) = w%v3sigmatau2(5, point)
4937 third(4, 9, 8) = third(4, 8, 9)
4938 third(8, 4, 9) = third(4, 8, 9)
4939 third(8, 9, 4) = third(4, 8, 9)
4940 third(9, 4, 8) = third(4, 8, 9)
4941 third(9, 8, 4) = third(4, 8, 9)
4942 third(4, 9, 9) = w%v3sigmatau2(6, point)
4943 third(9, 4, 9) = third(4, 9, 9)
4944 third(9, 9, 4) = third(4, 9, 9)
4945 third(5, 5, 5) = w%v3sigma3(10, point)
4946 IF (has_laplace) THEN
4947 third(5, 5, 6) = w%v3sigma2lapl(11, point)
4948 END IF
4949 third(5, 6, 5) = third(5, 5, 6)
4950 third(6, 5, 5) = third(5, 5, 6)
4951 IF (has_laplace) THEN
4952 third(5, 5, 7) = w%v3sigma2lapl(12, point)
4953 END IF
4954 third(5, 7, 5) = third(5, 5, 7)
4955 third(7, 5, 5) = third(5, 5, 7)
4956 third(5, 5, 8) = w%v3sigma2tau(11, point)
4957 third(5, 8, 5) = third(5, 5, 8)
4958 third(8, 5, 5) = third(5, 5, 8)
4959 third(5, 5, 9) = w%v3sigma2tau(12, point)
4960 third(5, 9, 5) = third(5, 5, 9)
4961 third(9, 5, 5) = third(5, 5, 9)
4962 IF (has_laplace) THEN
4963 third(5, 6, 6) = w%v3sigmalapl2(7, point)
4964 END IF
4965 third(6, 5, 6) = third(5, 6, 6)
4966 third(6, 6, 5) = third(5, 6, 6)
4967 IF (has_laplace) THEN
4968 third(5, 6, 7) = w%v3sigmalapl2(8, point)
4969 END IF
4970 third(5, 7, 6) = third(5, 6, 7)
4971 third(6, 5, 7) = third(5, 6, 7)
4972 third(6, 7, 5) = third(5, 6, 7)
4973 third(7, 5, 6) = third(5, 6, 7)
4974 third(7, 6, 5) = third(5, 6, 7)
4975 IF (has_laplace) THEN
4976 third(5, 6, 8) = w%v3sigmalapltau(9, point)
4977 END IF
4978 third(5, 8, 6) = third(5, 6, 8)
4979 third(6, 5, 8) = third(5, 6, 8)
4980 third(6, 8, 5) = third(5, 6, 8)
4981 third(8, 5, 6) = third(5, 6, 8)
4982 third(8, 6, 5) = third(5, 6, 8)
4983 IF (has_laplace) THEN
4984 third(5, 6, 9) = w%v3sigmalapltau(10, point)
4985 END IF
4986 third(5, 9, 6) = third(5, 6, 9)
4987 third(6, 5, 9) = third(5, 6, 9)
4988 third(6, 9, 5) = third(5, 6, 9)
4989 third(9, 5, 6) = third(5, 6, 9)
4990 third(9, 6, 5) = third(5, 6, 9)
4991 IF (has_laplace) THEN
4992 third(5, 7, 7) = w%v3sigmalapl2(9, point)
4993 END IF
4994 third(7, 5, 7) = third(5, 7, 7)
4995 third(7, 7, 5) = third(5, 7, 7)
4996 IF (has_laplace) THEN
4997 third(5, 7, 8) = w%v3sigmalapltau(11, point)
4998 END IF
4999 third(5, 8, 7) = third(5, 7, 8)
5000 third(7, 5, 8) = third(5, 7, 8)
5001 third(7, 8, 5) = third(5, 7, 8)
5002 third(8, 5, 7) = third(5, 7, 8)
5003 third(8, 7, 5) = third(5, 7, 8)
5004 IF (has_laplace) THEN
5005 third(5, 7, 9) = w%v3sigmalapltau(12, point)
5006 END IF
5007 third(5, 9, 7) = third(5, 7, 9)
5008 third(7, 5, 9) = third(5, 7, 9)
5009 third(7, 9, 5) = third(5, 7, 9)
5010 third(9, 5, 7) = third(5, 7, 9)
5011 third(9, 7, 5) = third(5, 7, 9)
5012 third(5, 8, 8) = w%v3sigmatau2(7, point)
5013 third(8, 5, 8) = third(5, 8, 8)
5014 third(8, 8, 5) = third(5, 8, 8)
5015 third(5, 8, 9) = w%v3sigmatau2(8, point)
5016 third(5, 9, 8) = third(5, 8, 9)
5017 third(8, 5, 9) = third(5, 8, 9)
5018 third(8, 9, 5) = third(5, 8, 9)
5019 third(9, 5, 8) = third(5, 8, 9)
5020 third(9, 8, 5) = third(5, 8, 9)
5021 third(5, 9, 9) = w%v3sigmatau2(9, point)
5022 third(9, 5, 9) = third(5, 9, 9)
5023 third(9, 9, 5) = third(5, 9, 9)
5024 IF (has_laplace) THEN
5025 third(6, 6, 6) = w%v3lapl3(1, point)
5026 END IF
5027 IF (has_laplace) THEN
5028 third(6, 6, 7) = w%v3lapl3(2, point)
5029 END IF
5030 third(6, 7, 6) = third(6, 6, 7)
5031 third(7, 6, 6) = third(6, 6, 7)
5032 IF (has_laplace) THEN
5033 third(6, 6, 8) = w%v3lapl2tau(1, point)
5034 END IF
5035 third(6, 8, 6) = third(6, 6, 8)
5036 third(8, 6, 6) = third(6, 6, 8)
5037 IF (has_laplace) THEN
5038 third(6, 6, 9) = w%v3lapl2tau(2, point)
5039 END IF
5040 third(6, 9, 6) = third(6, 6, 9)
5041 third(9, 6, 6) = third(6, 6, 9)
5042 IF (has_laplace) THEN
5043 third(6, 7, 7) = w%v3lapl3(3, point)
5044 END IF
5045 third(7, 6, 7) = third(6, 7, 7)
5046 third(7, 7, 6) = third(6, 7, 7)
5047 IF (has_laplace) THEN
5048 third(6, 7, 8) = w%v3lapl2tau(3, point)
5049 END IF
5050 third(6, 8, 7) = third(6, 7, 8)
5051 third(7, 6, 8) = third(6, 7, 8)
5052 third(7, 8, 6) = third(6, 7, 8)
5053 third(8, 6, 7) = third(6, 7, 8)
5054 third(8, 7, 6) = third(6, 7, 8)
5055 IF (has_laplace) THEN
5056 third(6, 7, 9) = w%v3lapl2tau(4, point)
5057 END IF
5058 third(6, 9, 7) = third(6, 7, 9)
5059 third(7, 6, 9) = third(6, 7, 9)
5060 third(7, 9, 6) = third(6, 7, 9)
5061 third(9, 6, 7) = third(6, 7, 9)
5062 third(9, 7, 6) = third(6, 7, 9)
5063 IF (has_laplace) THEN
5064 third(6, 8, 8) = w%v3lapltau2(1, point)
5065 END IF
5066 third(8, 6, 8) = third(6, 8, 8)
5067 third(8, 8, 6) = third(6, 8, 8)
5068 IF (has_laplace) THEN
5069 third(6, 8, 9) = w%v3lapltau2(2, point)
5070 END IF
5071 third(6, 9, 8) = third(6, 8, 9)
5072 third(8, 6, 9) = third(6, 8, 9)
5073 third(8, 9, 6) = third(6, 8, 9)
5074 third(9, 6, 8) = third(6, 8, 9)
5075 third(9, 8, 6) = third(6, 8, 9)
5076 IF (has_laplace) THEN
5077 third(6, 9, 9) = w%v3lapltau2(3, point)
5078 END IF
5079 third(9, 6, 9) = third(6, 9, 9)
5080 third(9, 9, 6) = third(6, 9, 9)
5081 IF (has_laplace) THEN
5082 third(7, 7, 7) = w%v3lapl3(4, point)
5083 END IF
5084 IF (has_laplace) THEN
5085 third(7, 7, 8) = w%v3lapl2tau(5, point)
5086 END IF
5087 third(7, 8, 7) = third(7, 7, 8)
5088 third(8, 7, 7) = third(7, 7, 8)
5089 IF (has_laplace) THEN
5090 third(7, 7, 9) = w%v3lapl2tau(6, point)
5091 END IF
5092 third(7, 9, 7) = third(7, 7, 9)
5093 third(9, 7, 7) = third(7, 7, 9)
5094 IF (has_laplace) THEN
5095 third(7, 8, 8) = w%v3lapltau2(4, point)
5096 END IF
5097 third(8, 7, 8) = third(7, 8, 8)
5098 third(8, 8, 7) = third(7, 8, 8)
5099 IF (has_laplace) THEN
5100 third(7, 8, 9) = w%v3lapltau2(5, point)
5101 END IF
5102 third(7, 9, 8) = third(7, 8, 9)
5103 third(8, 7, 9) = third(7, 8, 9)
5104 third(8, 9, 7) = third(7, 8, 9)
5105 third(9, 7, 8) = third(7, 8, 9)
5106 third(9, 8, 7) = third(7, 8, 9)
5107 IF (has_laplace) THEN
5108 third(7, 9, 9) = w%v3lapltau2(6, point)
5109 END IF
5110 third(9, 7, 9) = third(7, 9, 9)
5111 third(9, 9, 7) = third(7, 9, 9)
5112 third(8, 8, 8) = w%v3tau3(1, point)
5113 third(8, 8, 9) = w%v3tau3(2, point)
5114 third(8, 9, 8) = third(8, 8, 9)
5115 third(9, 8, 8) = third(8, 8, 9)
5116 third(8, 9, 9) = w%v3tau3(3, point)
5117 third(9, 8, 9) = third(8, 9, 9)
5118 third(9, 9, 8) = third(8, 9, 9)
5119 third(9, 9, 9) = w%v3tau3(4, point)
5120 END IF
5121 END IF
5122
5123 pulled_gradient(1:nvar) = matmul(transpose(jacobian(1:nvar, 1:nvar)), gradient(1:nvar))
5124 IF (grad_deriv >= 2) THEN
5125 pulled_hessian(1:nvar, 1:nvar) = &
5126 matmul(transpose(jacobian(1:nvar, 1:nvar)), &
5127 matmul(hessian(1:nvar, 1:nvar), jacobian(1:nvar, 1:nvar)))
5128 DO channel = 1, nspin
5129 itau = 4
5130 IF (nspin == 2) itau = 7 + channel
5131 pulled_hessian(1:nvar, 1:nvar) = pulled_hessian(1:nvar, 1:nvar) + &
5132 gradient(itau)*curvature(1:nvar, 1:nvar, channel)
5133 END DO
5134 END IF
5135 IF (grad_deriv >= 3) THEN
5136 ! Contract one tensor index at a time, then add the nonlinear map terms.
5137 DO k = 1, nvar
5138 scratch(1:nvar, 1:nvar, k) = matmul(transpose(jacobian(1:nvar, 1:nvar)), third(1:nvar, 1:nvar, k))
5139 END DO
5140 DO i = 1, nvar
5141 pulled_third(i, 1:nvar, 1:nvar) = &
5142 matmul(transpose(jacobian(1:nvar, 1:nvar)), scratch(i, 1:nvar, 1:nvar))
5143 END DO
5144 DO j = 1, nvar
5145 scratch(1:nvar, j, 1:nvar) = matmul(pulled_third(1:nvar, j, 1:nvar), jacobian(1:nvar, 1:nvar))
5146 END DO
5147 pulled_third = scratch
5148 DO channel = 1, nspin
5149 itau = 4
5150 IF (nspin == 2) itau = 7 + channel
5151 mixed(1:nvar) = matmul(hessian(itau, 1:nvar), jacobian(1:nvar, 1:nvar))
5152 DO k = 1, nvar
5153 DO j = 1, nvar
5154 DO i = 1, nvar
5155 pulled_third(i, j, k) = pulled_third(i, j, k) + &
5156 curvature(i, j, channel)*mixed(k) + curvature(i, k, channel)*mixed(j) + &
5157 curvature(j, k, channel)*mixed(i) + gradient(itau)*map_third(i, j, k, channel)
5158 END DO
5159 END DO
5160 END DO
5161 END DO
5162 END IF
5163 IF (nspin == 1) THEN
5164 IF (grad_deriv >= 1) THEN
5165 w%vrho(1, point) = pulled_gradient(1)
5166 w%vsigma(1, point) = pulled_gradient(2)
5167 IF (has_laplace) THEN
5168 w%vlapl(1, point) = pulled_gradient(3)
5169 END IF
5170 w%vtau(1, point) = pulled_gradient(4)
5171 END IF
5172 IF (grad_deriv >= 2) THEN
5173 w%v2rho2(1, point) = pulled_hessian(1, 1)
5174 w%v2rhosigma(1, point) = pulled_hessian(1, 2)
5175 IF (has_laplace) THEN
5176 w%v2rholapl(1, point) = pulled_hessian(1, 3)
5177 END IF
5178 w%v2rhotau(1, point) = pulled_hessian(1, 4)
5179 w%v2sigma2(1, point) = pulled_hessian(2, 2)
5180 IF (has_laplace) THEN
5181 w%v2sigmalapl(1, point) = pulled_hessian(2, 3)
5182 END IF
5183 w%v2sigmatau(1, point) = pulled_hessian(2, 4)
5184 IF (has_laplace) THEN
5185 w%v2lapl2(1, point) = pulled_hessian(3, 3)
5186 END IF
5187 IF (has_laplace) THEN
5188 w%v2lapltau(1, point) = pulled_hessian(3, 4)
5189 END IF
5190 w%v2tau2(1, point) = pulled_hessian(4, 4)
5191 END IF
5192 IF (grad_deriv >= 3) THEN
5193 w%v3rho3(1, point) = pulled_third(1, 1, 1)
5194 w%v3rho2sigma(1, point) = pulled_third(1, 1, 2)
5195 IF (has_laplace) THEN
5196 w%v3rho2lapl(1, point) = pulled_third(1, 1, 3)
5197 END IF
5198 w%v3rho2tau(1, point) = pulled_third(1, 1, 4)
5199 w%v3rhosigma2(1, point) = pulled_third(1, 2, 2)
5200 IF (has_laplace) THEN
5201 w%v3rhosigmalapl(1, point) = pulled_third(1, 2, 3)
5202 END IF
5203 w%v3rhosigmatau(1, point) = pulled_third(1, 2, 4)
5204 IF (has_laplace) THEN
5205 w%v3rholapl2(1, point) = pulled_third(1, 3, 3)
5206 END IF
5207 IF (has_laplace) THEN
5208 w%v3rholapltau(1, point) = pulled_third(1, 3, 4)
5209 END IF
5210 w%v3rhotau2(1, point) = pulled_third(1, 4, 4)
5211 w%v3sigma3(1, point) = pulled_third(2, 2, 2)
5212 IF (has_laplace) THEN
5213 w%v3sigma2lapl(1, point) = pulled_third(2, 2, 3)
5214 END IF
5215 w%v3sigma2tau(1, point) = pulled_third(2, 2, 4)
5216 IF (has_laplace) THEN
5217 w%v3sigmalapl2(1, point) = pulled_third(2, 3, 3)
5218 END IF
5219 IF (has_laplace) THEN
5220 w%v3sigmalapltau(1, point) = pulled_third(2, 3, 4)
5221 END IF
5222 w%v3sigmatau2(1, point) = pulled_third(2, 4, 4)
5223 IF (has_laplace) THEN
5224 w%v3lapl3(1, point) = pulled_third(3, 3, 3)
5225 END IF
5226 IF (has_laplace) THEN
5227 w%v3lapl2tau(1, point) = pulled_third(3, 3, 4)
5228 END IF
5229 IF (has_laplace) THEN
5230 w%v3lapltau2(1, point) = pulled_third(3, 4, 4)
5231 END IF
5232 w%v3tau3(1, point) = pulled_third(4, 4, 4)
5233 END IF
5234 ELSE
5235 IF (grad_deriv >= 1) THEN
5236 w%vrho(1, point) = pulled_gradient(1)
5237 w%vrho(2, point) = pulled_gradient(2)
5238 w%vsigma(1, point) = pulled_gradient(3)
5239 w%vsigma(2, point) = pulled_gradient(4)
5240 w%vsigma(3, point) = pulled_gradient(5)
5241 IF (has_laplace) THEN
5242 w%vlapl(1, point) = pulled_gradient(6)
5243 END IF
5244 IF (has_laplace) THEN
5245 w%vlapl(2, point) = pulled_gradient(7)
5246 END IF
5247 w%vtau(1, point) = pulled_gradient(8)
5248 w%vtau(2, point) = pulled_gradient(9)
5249 END IF
5250 IF (grad_deriv >= 2) THEN
5251 w%v2rho2(1, point) = pulled_hessian(1, 1)
5252 w%v2rho2(2, point) = pulled_hessian(1, 2)
5253 w%v2rhosigma(1, point) = pulled_hessian(1, 3)
5254 w%v2rhosigma(2, point) = pulled_hessian(1, 4)
5255 w%v2rhosigma(3, point) = pulled_hessian(1, 5)
5256 IF (has_laplace) THEN
5257 w%v2rholapl(1, point) = pulled_hessian(1, 6)
5258 END IF
5259 IF (has_laplace) THEN
5260 w%v2rholapl(2, point) = pulled_hessian(1, 7)
5261 END IF
5262 w%v2rhotau(1, point) = pulled_hessian(1, 8)
5263 w%v2rhotau(2, point) = pulled_hessian(1, 9)
5264 w%v2rho2(3, point) = pulled_hessian(2, 2)
5265 w%v2rhosigma(4, point) = pulled_hessian(2, 3)
5266 w%v2rhosigma(5, point) = pulled_hessian(2, 4)
5267 w%v2rhosigma(6, point) = pulled_hessian(2, 5)
5268 IF (has_laplace) THEN
5269 w%v2rholapl(3, point) = pulled_hessian(2, 6)
5270 END IF
5271 IF (has_laplace) THEN
5272 w%v2rholapl(4, point) = pulled_hessian(2, 7)
5273 END IF
5274 w%v2rhotau(3, point) = pulled_hessian(2, 8)
5275 w%v2rhotau(4, point) = pulled_hessian(2, 9)
5276 w%v2sigma2(1, point) = pulled_hessian(3, 3)
5277 w%v2sigma2(2, point) = pulled_hessian(3, 4)
5278 w%v2sigma2(3, point) = pulled_hessian(3, 5)
5279 IF (has_laplace) THEN
5280 w%v2sigmalapl(1, point) = pulled_hessian(3, 6)
5281 END IF
5282 IF (has_laplace) THEN
5283 w%v2sigmalapl(2, point) = pulled_hessian(3, 7)
5284 END IF
5285 w%v2sigmatau(1, point) = pulled_hessian(3, 8)
5286 w%v2sigmatau(2, point) = pulled_hessian(3, 9)
5287 w%v2sigma2(4, point) = pulled_hessian(4, 4)
5288 w%v2sigma2(5, point) = pulled_hessian(4, 5)
5289 IF (has_laplace) THEN
5290 w%v2sigmalapl(3, point) = pulled_hessian(4, 6)
5291 END IF
5292 IF (has_laplace) THEN
5293 w%v2sigmalapl(4, point) = pulled_hessian(4, 7)
5294 END IF
5295 w%v2sigmatau(3, point) = pulled_hessian(4, 8)
5296 w%v2sigmatau(4, point) = pulled_hessian(4, 9)
5297 w%v2sigma2(6, point) = pulled_hessian(5, 5)
5298 IF (has_laplace) THEN
5299 w%v2sigmalapl(5, point) = pulled_hessian(5, 6)
5300 END IF
5301 IF (has_laplace) THEN
5302 w%v2sigmalapl(6, point) = pulled_hessian(5, 7)
5303 END IF
5304 w%v2sigmatau(5, point) = pulled_hessian(5, 8)
5305 w%v2sigmatau(6, point) = pulled_hessian(5, 9)
5306 IF (has_laplace) THEN
5307 w%v2lapl2(1, point) = pulled_hessian(6, 6)
5308 END IF
5309 IF (has_laplace) THEN
5310 w%v2lapl2(2, point) = pulled_hessian(6, 7)
5311 END IF
5312 IF (has_laplace) THEN
5313 w%v2lapltau(1, point) = pulled_hessian(6, 8)
5314 END IF
5315 IF (has_laplace) THEN
5316 w%v2lapltau(2, point) = pulled_hessian(6, 9)
5317 END IF
5318 IF (has_laplace) THEN
5319 w%v2lapl2(3, point) = pulled_hessian(7, 7)
5320 END IF
5321 IF (has_laplace) THEN
5322 w%v2lapltau(3, point) = pulled_hessian(7, 8)
5323 END IF
5324 IF (has_laplace) THEN
5325 w%v2lapltau(4, point) = pulled_hessian(7, 9)
5326 END IF
5327 w%v2tau2(1, point) = pulled_hessian(8, 8)
5328 w%v2tau2(2, point) = pulled_hessian(8, 9)
5329 w%v2tau2(3, point) = pulled_hessian(9, 9)
5330 END IF
5331 IF (grad_deriv >= 3) THEN
5332 w%v3rho3(1, point) = pulled_third(1, 1, 1)
5333 w%v3rho3(2, point) = pulled_third(1, 1, 2)
5334 w%v3rho2sigma(1, point) = pulled_third(1, 1, 3)
5335 w%v3rho2sigma(2, point) = pulled_third(1, 1, 4)
5336 w%v3rho2sigma(3, point) = pulled_third(1, 1, 5)
5337 IF (has_laplace) THEN
5338 w%v3rho2lapl(1, point) = pulled_third(1, 1, 6)
5339 END IF
5340 IF (has_laplace) THEN
5341 w%v3rho2lapl(2, point) = pulled_third(1, 1, 7)
5342 END IF
5343 w%v3rho2tau(1, point) = pulled_third(1, 1, 8)
5344 w%v3rho2tau(2, point) = pulled_third(1, 1, 9)
5345 w%v3rho3(3, point) = pulled_third(1, 2, 2)
5346 w%v3rho2sigma(4, point) = pulled_third(1, 2, 3)
5347 w%v3rho2sigma(5, point) = pulled_third(1, 2, 4)
5348 w%v3rho2sigma(6, point) = pulled_third(1, 2, 5)
5349 IF (has_laplace) THEN
5350 w%v3rho2lapl(3, point) = pulled_third(1, 2, 6)
5351 END IF
5352 IF (has_laplace) THEN
5353 w%v3rho2lapl(4, point) = pulled_third(1, 2, 7)
5354 END IF
5355 w%v3rho2tau(3, point) = pulled_third(1, 2, 8)
5356 w%v3rho2tau(4, point) = pulled_third(1, 2, 9)
5357 w%v3rhosigma2(1, point) = pulled_third(1, 3, 3)
5358 w%v3rhosigma2(2, point) = pulled_third(1, 3, 4)
5359 w%v3rhosigma2(3, point) = pulled_third(1, 3, 5)
5360 IF (has_laplace) THEN
5361 w%v3rhosigmalapl(1, point) = pulled_third(1, 3, 6)
5362 END IF
5363 IF (has_laplace) THEN
5364 w%v3rhosigmalapl(2, point) = pulled_third(1, 3, 7)
5365 END IF
5366 w%v3rhosigmatau(1, point) = pulled_third(1, 3, 8)
5367 w%v3rhosigmatau(2, point) = pulled_third(1, 3, 9)
5368 w%v3rhosigma2(4, point) = pulled_third(1, 4, 4)
5369 w%v3rhosigma2(5, point) = pulled_third(1, 4, 5)
5370 IF (has_laplace) THEN
5371 w%v3rhosigmalapl(3, point) = pulled_third(1, 4, 6)
5372 END IF
5373 IF (has_laplace) THEN
5374 w%v3rhosigmalapl(4, point) = pulled_third(1, 4, 7)
5375 END IF
5376 w%v3rhosigmatau(3, point) = pulled_third(1, 4, 8)
5377 w%v3rhosigmatau(4, point) = pulled_third(1, 4, 9)
5378 w%v3rhosigma2(6, point) = pulled_third(1, 5, 5)
5379 IF (has_laplace) THEN
5380 w%v3rhosigmalapl(5, point) = pulled_third(1, 5, 6)
5381 END IF
5382 IF (has_laplace) THEN
5383 w%v3rhosigmalapl(6, point) = pulled_third(1, 5, 7)
5384 END IF
5385 w%v3rhosigmatau(5, point) = pulled_third(1, 5, 8)
5386 w%v3rhosigmatau(6, point) = pulled_third(1, 5, 9)
5387 IF (has_laplace) THEN
5388 w%v3rholapl2(1, point) = pulled_third(1, 6, 6)
5389 END IF
5390 IF (has_laplace) THEN
5391 w%v3rholapl2(2, point) = pulled_third(1, 6, 7)
5392 END IF
5393 IF (has_laplace) THEN
5394 w%v3rholapltau(1, point) = pulled_third(1, 6, 8)
5395 END IF
5396 IF (has_laplace) THEN
5397 w%v3rholapltau(2, point) = pulled_third(1, 6, 9)
5398 END IF
5399 IF (has_laplace) THEN
5400 w%v3rholapl2(3, point) = pulled_third(1, 7, 7)
5401 END IF
5402 IF (has_laplace) THEN
5403 w%v3rholapltau(3, point) = pulled_third(1, 7, 8)
5404 END IF
5405 IF (has_laplace) THEN
5406 w%v3rholapltau(4, point) = pulled_third(1, 7, 9)
5407 END IF
5408 w%v3rhotau2(1, point) = pulled_third(1, 8, 8)
5409 w%v3rhotau2(2, point) = pulled_third(1, 8, 9)
5410 w%v3rhotau2(3, point) = pulled_third(1, 9, 9)
5411 w%v3rho3(4, point) = pulled_third(2, 2, 2)
5412 w%v3rho2sigma(7, point) = pulled_third(2, 2, 3)
5413 w%v3rho2sigma(8, point) = pulled_third(2, 2, 4)
5414 w%v3rho2sigma(9, point) = pulled_third(2, 2, 5)
5415 IF (has_laplace) THEN
5416 w%v3rho2lapl(5, point) = pulled_third(2, 2, 6)
5417 END IF
5418 IF (has_laplace) THEN
5419 w%v3rho2lapl(6, point) = pulled_third(2, 2, 7)
5420 END IF
5421 w%v3rho2tau(5, point) = pulled_third(2, 2, 8)
5422 w%v3rho2tau(6, point) = pulled_third(2, 2, 9)
5423 w%v3rhosigma2(7, point) = pulled_third(2, 3, 3)
5424 w%v3rhosigma2(8, point) = pulled_third(2, 3, 4)
5425 w%v3rhosigma2(9, point) = pulled_third(2, 3, 5)
5426 IF (has_laplace) THEN
5427 w%v3rhosigmalapl(7, point) = pulled_third(2, 3, 6)
5428 END IF
5429 IF (has_laplace) THEN
5430 w%v3rhosigmalapl(8, point) = pulled_third(2, 3, 7)
5431 END IF
5432 w%v3rhosigmatau(7, point) = pulled_third(2, 3, 8)
5433 w%v3rhosigmatau(8, point) = pulled_third(2, 3, 9)
5434 w%v3rhosigma2(10, point) = pulled_third(2, 4, 4)
5435 w%v3rhosigma2(11, point) = pulled_third(2, 4, 5)
5436 IF (has_laplace) THEN
5437 w%v3rhosigmalapl(9, point) = pulled_third(2, 4, 6)
5438 END IF
5439 IF (has_laplace) THEN
5440 w%v3rhosigmalapl(10, point) = pulled_third(2, 4, 7)
5441 END IF
5442 w%v3rhosigmatau(9, point) = pulled_third(2, 4, 8)
5443 w%v3rhosigmatau(10, point) = pulled_third(2, 4, 9)
5444 w%v3rhosigma2(12, point) = pulled_third(2, 5, 5)
5445 IF (has_laplace) THEN
5446 w%v3rhosigmalapl(11, point) = pulled_third(2, 5, 6)
5447 END IF
5448 IF (has_laplace) THEN
5449 w%v3rhosigmalapl(12, point) = pulled_third(2, 5, 7)
5450 END IF
5451 w%v3rhosigmatau(11, point) = pulled_third(2, 5, 8)
5452 w%v3rhosigmatau(12, point) = pulled_third(2, 5, 9)
5453 IF (has_laplace) THEN
5454 w%v3rholapl2(4, point) = pulled_third(2, 6, 6)
5455 END IF
5456 IF (has_laplace) THEN
5457 w%v3rholapl2(5, point) = pulled_third(2, 6, 7)
5458 END IF
5459 IF (has_laplace) THEN
5460 w%v3rholapltau(5, point) = pulled_third(2, 6, 8)
5461 END IF
5462 IF (has_laplace) THEN
5463 w%v3rholapltau(6, point) = pulled_third(2, 6, 9)
5464 END IF
5465 IF (has_laplace) THEN
5466 w%v3rholapl2(6, point) = pulled_third(2, 7, 7)
5467 END IF
5468 IF (has_laplace) THEN
5469 w%v3rholapltau(7, point) = pulled_third(2, 7, 8)
5470 END IF
5471 IF (has_laplace) THEN
5472 w%v3rholapltau(8, point) = pulled_third(2, 7, 9)
5473 END IF
5474 w%v3rhotau2(4, point) = pulled_third(2, 8, 8)
5475 w%v3rhotau2(5, point) = pulled_third(2, 8, 9)
5476 w%v3rhotau2(6, point) = pulled_third(2, 9, 9)
5477 w%v3sigma3(1, point) = pulled_third(3, 3, 3)
5478 w%v3sigma3(2, point) = pulled_third(3, 3, 4)
5479 w%v3sigma3(3, point) = pulled_third(3, 3, 5)
5480 IF (has_laplace) THEN
5481 w%v3sigma2lapl(1, point) = pulled_third(3, 3, 6)
5482 END IF
5483 IF (has_laplace) THEN
5484 w%v3sigma2lapl(2, point) = pulled_third(3, 3, 7)
5485 END IF
5486 w%v3sigma2tau(1, point) = pulled_third(3, 3, 8)
5487 w%v3sigma2tau(2, point) = pulled_third(3, 3, 9)
5488 w%v3sigma3(4, point) = pulled_third(3, 4, 4)
5489 w%v3sigma3(5, point) = pulled_third(3, 4, 5)
5490 IF (has_laplace) THEN
5491 w%v3sigma2lapl(3, point) = pulled_third(3, 4, 6)
5492 END IF
5493 IF (has_laplace) THEN
5494 w%v3sigma2lapl(4, point) = pulled_third(3, 4, 7)
5495 END IF
5496 w%v3sigma2tau(3, point) = pulled_third(3, 4, 8)
5497 w%v3sigma2tau(4, point) = pulled_third(3, 4, 9)
5498 w%v3sigma3(6, point) = pulled_third(3, 5, 5)
5499 IF (has_laplace) THEN
5500 w%v3sigma2lapl(5, point) = pulled_third(3, 5, 6)
5501 END IF
5502 IF (has_laplace) THEN
5503 w%v3sigma2lapl(6, point) = pulled_third(3, 5, 7)
5504 END IF
5505 w%v3sigma2tau(5, point) = pulled_third(3, 5, 8)
5506 w%v3sigma2tau(6, point) = pulled_third(3, 5, 9)
5507 IF (has_laplace) THEN
5508 w%v3sigmalapl2(1, point) = pulled_third(3, 6, 6)
5509 END IF
5510 IF (has_laplace) THEN
5511 w%v3sigmalapl2(2, point) = pulled_third(3, 6, 7)
5512 END IF
5513 IF (has_laplace) THEN
5514 w%v3sigmalapltau(1, point) = pulled_third(3, 6, 8)
5515 END IF
5516 IF (has_laplace) THEN
5517 w%v3sigmalapltau(2, point) = pulled_third(3, 6, 9)
5518 END IF
5519 IF (has_laplace) THEN
5520 w%v3sigmalapl2(3, point) = pulled_third(3, 7, 7)
5521 END IF
5522 IF (has_laplace) THEN
5523 w%v3sigmalapltau(3, point) = pulled_third(3, 7, 8)
5524 END IF
5525 IF (has_laplace) THEN
5526 w%v3sigmalapltau(4, point) = pulled_third(3, 7, 9)
5527 END IF
5528 w%v3sigmatau2(1, point) = pulled_third(3, 8, 8)
5529 w%v3sigmatau2(2, point) = pulled_third(3, 8, 9)
5530 w%v3sigmatau2(3, point) = pulled_third(3, 9, 9)
5531 w%v3sigma3(7, point) = pulled_third(4, 4, 4)
5532 w%v3sigma3(8, point) = pulled_third(4, 4, 5)
5533 IF (has_laplace) THEN
5534 w%v3sigma2lapl(7, point) = pulled_third(4, 4, 6)
5535 END IF
5536 IF (has_laplace) THEN
5537 w%v3sigma2lapl(8, point) = pulled_third(4, 4, 7)
5538 END IF
5539 w%v3sigma2tau(7, point) = pulled_third(4, 4, 8)
5540 w%v3sigma2tau(8, point) = pulled_third(4, 4, 9)
5541 w%v3sigma3(9, point) = pulled_third(4, 5, 5)
5542 IF (has_laplace) THEN
5543 w%v3sigma2lapl(9, point) = pulled_third(4, 5, 6)
5544 END IF
5545 IF (has_laplace) THEN
5546 w%v3sigma2lapl(10, point) = pulled_third(4, 5, 7)
5547 END IF
5548 w%v3sigma2tau(9, point) = pulled_third(4, 5, 8)
5549 w%v3sigma2tau(10, point) = pulled_third(4, 5, 9)
5550 IF (has_laplace) THEN
5551 w%v3sigmalapl2(4, point) = pulled_third(4, 6, 6)
5552 END IF
5553 IF (has_laplace) THEN
5554 w%v3sigmalapl2(5, point) = pulled_third(4, 6, 7)
5555 END IF
5556 IF (has_laplace) THEN
5557 w%v3sigmalapltau(5, point) = pulled_third(4, 6, 8)
5558 END IF
5559 IF (has_laplace) THEN
5560 w%v3sigmalapltau(6, point) = pulled_third(4, 6, 9)
5561 END IF
5562 IF (has_laplace) THEN
5563 w%v3sigmalapl2(6, point) = pulled_third(4, 7, 7)
5564 END IF
5565 IF (has_laplace) THEN
5566 w%v3sigmalapltau(7, point) = pulled_third(4, 7, 8)
5567 END IF
5568 IF (has_laplace) THEN
5569 w%v3sigmalapltau(8, point) = pulled_third(4, 7, 9)
5570 END IF
5571 w%v3sigmatau2(4, point) = pulled_third(4, 8, 8)
5572 w%v3sigmatau2(5, point) = pulled_third(4, 8, 9)
5573 w%v3sigmatau2(6, point) = pulled_third(4, 9, 9)
5574 w%v3sigma3(10, point) = pulled_third(5, 5, 5)
5575 IF (has_laplace) THEN
5576 w%v3sigma2lapl(11, point) = pulled_third(5, 5, 6)
5577 END IF
5578 IF (has_laplace) THEN
5579 w%v3sigma2lapl(12, point) = pulled_third(5, 5, 7)
5580 END IF
5581 w%v3sigma2tau(11, point) = pulled_third(5, 5, 8)
5582 w%v3sigma2tau(12, point) = pulled_third(5, 5, 9)
5583 IF (has_laplace) THEN
5584 w%v3sigmalapl2(7, point) = pulled_third(5, 6, 6)
5585 END IF
5586 IF (has_laplace) THEN
5587 w%v3sigmalapl2(8, point) = pulled_third(5, 6, 7)
5588 END IF
5589 IF (has_laplace) THEN
5590 w%v3sigmalapltau(9, point) = pulled_third(5, 6, 8)
5591 END IF
5592 IF (has_laplace) THEN
5593 w%v3sigmalapltau(10, point) = pulled_third(5, 6, 9)
5594 END IF
5595 IF (has_laplace) THEN
5596 w%v3sigmalapl2(9, point) = pulled_third(5, 7, 7)
5597 END IF
5598 IF (has_laplace) THEN
5599 w%v3sigmalapltau(11, point) = pulled_third(5, 7, 8)
5600 END IF
5601 IF (has_laplace) THEN
5602 w%v3sigmalapltau(12, point) = pulled_third(5, 7, 9)
5603 END IF
5604 w%v3sigmatau2(7, point) = pulled_third(5, 8, 8)
5605 w%v3sigmatau2(8, point) = pulled_third(5, 8, 9)
5606 w%v3sigmatau2(9, point) = pulled_third(5, 9, 9)
5607 IF (has_laplace) THEN
5608 w%v3lapl3(1, point) = pulled_third(6, 6, 6)
5609 END IF
5610 IF (has_laplace) THEN
5611 w%v3lapl3(2, point) = pulled_third(6, 6, 7)
5612 END IF
5613 IF (has_laplace) THEN
5614 w%v3lapl2tau(1, point) = pulled_third(6, 6, 8)
5615 END IF
5616 IF (has_laplace) THEN
5617 w%v3lapl2tau(2, point) = pulled_third(6, 6, 9)
5618 END IF
5619 IF (has_laplace) THEN
5620 w%v3lapl3(3, point) = pulled_third(6, 7, 7)
5621 END IF
5622 IF (has_laplace) THEN
5623 w%v3lapl2tau(3, point) = pulled_third(6, 7, 8)
5624 END IF
5625 IF (has_laplace) THEN
5626 w%v3lapl2tau(4, point) = pulled_third(6, 7, 9)
5627 END IF
5628 IF (has_laplace) THEN
5629 w%v3lapltau2(1, point) = pulled_third(6, 8, 8)
5630 END IF
5631 IF (has_laplace) THEN
5632 w%v3lapltau2(2, point) = pulled_third(6, 8, 9)
5633 END IF
5634 IF (has_laplace) THEN
5635 w%v3lapltau2(3, point) = pulled_third(6, 9, 9)
5636 END IF
5637 IF (has_laplace) THEN
5638 w%v3lapl3(4, point) = pulled_third(7, 7, 7)
5639 END IF
5640 IF (has_laplace) THEN
5641 w%v3lapl2tau(5, point) = pulled_third(7, 7, 8)
5642 END IF
5643 IF (has_laplace) THEN
5644 w%v3lapl2tau(6, point) = pulled_third(7, 7, 9)
5645 END IF
5646 IF (has_laplace) THEN
5647 w%v3lapltau2(4, point) = pulled_third(7, 8, 8)
5648 END IF
5649 IF (has_laplace) THEN
5650 w%v3lapltau2(5, point) = pulled_third(7, 8, 9)
5651 END IF
5652 IF (has_laplace) THEN
5653 w%v3lapltau2(6, point) = pulled_third(7, 9, 9)
5654 END IF
5655 w%v3tau3(1, point) = pulled_third(8, 8, 8)
5656 w%v3tau3(2, point) = pulled_third(8, 8, 9)
5657 w%v3tau3(3, point) = pulled_third(8, 9, 9)
5658 w%v3tau3(4, point) = pulled_third(9, 9, 9)
5659 END IF
5660 END IF
5661 END SUBROUTINE libxc_mgga_tau_pullback
5662
5663! **************************************************************************************************
5664!> \brief Differentiate exc times the original density through Libxc's individual spin floors.
5665!> \param w Evaluated worker buffers before the kinetic-density and negative-density pullbacks.
5666!> \param point Grid point in the worker block.
5667!> \param grad_deriv Highest evaluated derivative order.
5668!> \param has_laplace Whether the functional uses the density Laplacian.
5669!> \param epsilon_rho Libxc density cutoff.
5670!> \note Libxc returns derivatives of F at m_s=MAX(rho_s,epsilon_rho), whereas CP2K
5671!> accumulates E=n*exc=(n/m)*F with n=SUM(rho_s) and m=SUM(m_s). This pullback
5672!> leaves that energy unchanged, including its original-density normalization.
5673! **************************************************************************************************
5674 SUBROUTINE libxc_spin_floor_pullback(w, point, grad_deriv, has_laplace, epsilon_rho)
5675 TYPE(libxc_worker_type), INTENT(INOUT) :: w
5676 INTEGER, INTENT(IN) :: point, grad_deriv
5677 LOGICAL, INTENT(IN) :: has_laplace
5678 REAL(dp), INTENT(IN) :: epsilon_rho
5679
5680 INTEGER :: i, j
5681 REAL(dp) :: n, m, ratio, functional, third_ratio
5682 REAL(dp) :: diagonal(9), dn(9), dm(9), first_ratio(9), second_ratio(9, 9), &
5683 gradient(9), hessian(9, 9)
5684
5685 IF (grad_deriv < 1 .OR. all(w%rho(:, point) >= epsilon_rho)) RETURN
5686 n = sum(w%rho(:, point))
5687 IF (n < epsilon_rho) RETURN ! Libxc screened this point to zero.
5688 m = sum(max(w%rho(:, point), epsilon_rho))
5689 ratio = n/m
5690 functional = m*w%exc(point)
5691 diagonal = 1.0_dp
5692 diagonal(1:2) = merge(1.0_dp, 0.0_dp, w%rho(:, point) >= epsilon_rho)
5693 dn = 0.0_dp
5694 dn(1:2) = 1.0_dp
5695 dm = 0.0_dp
5696 dm(1:2) = diagonal(1:2)
5697 first_ratio = (dn - ratio*dm)/m
5698 second_ratio = 0.0_dp
5699 DO i = 1, 2
5700 DO j = 1, 2
5701 second_ratio(i, j) = (-dn(i)*dm(j) - dn(j)*dm(i) + 2.0_dp*ratio*dm(i)*dm(j))/m**2
5702 END DO
5703 END DO
5704 gradient = 0.0_dp
5705 hessian = 0.0_dp
5706 IF (ALLOCATED(w%vrho) ) THEN
5707 gradient(1) = w%vrho(1, point)
5708 END IF
5709 IF (ALLOCATED(w%vrho) ) THEN
5710 gradient(2) = w%vrho(2, point)
5711 END IF
5712 IF (ALLOCATED(w%vsigma) ) THEN
5713 gradient(3) = w%vsigma(1, point)
5714 END IF
5715 IF (ALLOCATED(w%vsigma) ) THEN
5716 gradient(4) = w%vsigma(2, point)
5717 END IF
5718 IF (ALLOCATED(w%vsigma) ) THEN
5719 gradient(5) = w%vsigma(3, point)
5720 END IF
5721 IF (ALLOCATED(w%vlapl) .AND. has_laplace) THEN
5722 gradient(6) = w%vlapl(1, point)
5723 END IF
5724 IF (ALLOCATED(w%vlapl) .AND. has_laplace) THEN
5725 gradient(7) = w%vlapl(2, point)
5726 END IF
5727 IF (ALLOCATED(w%vtau) ) THEN
5728 gradient(8) = w%vtau(1, point)
5729 END IF
5730 IF (ALLOCATED(w%vtau) ) THEN
5731 gradient(9) = w%vtau(2, point)
5732 END IF
5733 IF (grad_deriv >= 2) THEN
5734 IF (ALLOCATED(w%v2rho2) ) THEN
5735 hessian(1, 1) = w%v2rho2(1, point)
5736 END IF
5737 hessian(1, 1) = hessian(1, 1)
5738 IF (ALLOCATED(w%v2rho2) ) THEN
5739 hessian(1, 2) = w%v2rho2(2, point)
5740 END IF
5741 hessian(2, 1) = hessian(1, 2)
5742 IF (ALLOCATED(w%v2rhosigma) ) THEN
5743 hessian(1, 3) = w%v2rhosigma(1, point)
5744 END IF
5745 hessian(3, 1) = hessian(1, 3)
5746 IF (ALLOCATED(w%v2rhosigma) ) THEN
5747 hessian(1, 4) = w%v2rhosigma(2, point)
5748 END IF
5749 hessian(4, 1) = hessian(1, 4)
5750 IF (ALLOCATED(w%v2rhosigma) ) THEN
5751 hessian(1, 5) = w%v2rhosigma(3, point)
5752 END IF
5753 hessian(5, 1) = hessian(1, 5)
5754 IF (ALLOCATED(w%v2rholapl) .AND. has_laplace) THEN
5755 hessian(1, 6) = w%v2rholapl(1, point)
5756 END IF
5757 hessian(6, 1) = hessian(1, 6)
5758 IF (ALLOCATED(w%v2rholapl) .AND. has_laplace) THEN
5759 hessian(1, 7) = w%v2rholapl(2, point)
5760 END IF
5761 hessian(7, 1) = hessian(1, 7)
5762 IF (ALLOCATED(w%v2rhotau) ) THEN
5763 hessian(1, 8) = w%v2rhotau(1, point)
5764 END IF
5765 hessian(8, 1) = hessian(1, 8)
5766 IF (ALLOCATED(w%v2rhotau) ) THEN
5767 hessian(1, 9) = w%v2rhotau(2, point)
5768 END IF
5769 hessian(9, 1) = hessian(1, 9)
5770 IF (ALLOCATED(w%v2rho2) ) THEN
5771 hessian(2, 2) = w%v2rho2(3, point)
5772 END IF
5773 hessian(2, 2) = hessian(2, 2)
5774 IF (ALLOCATED(w%v2rhosigma) ) THEN
5775 hessian(2, 3) = w%v2rhosigma(4, point)
5776 END IF
5777 hessian(3, 2) = hessian(2, 3)
5778 IF (ALLOCATED(w%v2rhosigma) ) THEN
5779 hessian(2, 4) = w%v2rhosigma(5, point)
5780 END IF
5781 hessian(4, 2) = hessian(2, 4)
5782 IF (ALLOCATED(w%v2rhosigma) ) THEN
5783 hessian(2, 5) = w%v2rhosigma(6, point)
5784 END IF
5785 hessian(5, 2) = hessian(2, 5)
5786 IF (ALLOCATED(w%v2rholapl) .AND. has_laplace) THEN
5787 hessian(2, 6) = w%v2rholapl(3, point)
5788 END IF
5789 hessian(6, 2) = hessian(2, 6)
5790 IF (ALLOCATED(w%v2rholapl) .AND. has_laplace) THEN
5791 hessian(2, 7) = w%v2rholapl(4, point)
5792 END IF
5793 hessian(7, 2) = hessian(2, 7)
5794 IF (ALLOCATED(w%v2rhotau) ) THEN
5795 hessian(2, 8) = w%v2rhotau(3, point)
5796 END IF
5797 hessian(8, 2) = hessian(2, 8)
5798 IF (ALLOCATED(w%v2rhotau) ) THEN
5799 hessian(2, 9) = w%v2rhotau(4, point)
5800 END IF
5801 hessian(9, 2) = hessian(2, 9)
5802 IF (ALLOCATED(w%v2sigma2) ) THEN
5803 hessian(3, 3) = w%v2sigma2(1, point)
5804 END IF
5805 hessian(3, 3) = hessian(3, 3)
5806 IF (ALLOCATED(w%v2sigma2) ) THEN
5807 hessian(3, 4) = w%v2sigma2(2, point)
5808 END IF
5809 hessian(4, 3) = hessian(3, 4)
5810 IF (ALLOCATED(w%v2sigma2) ) THEN
5811 hessian(3, 5) = w%v2sigma2(3, point)
5812 END IF
5813 hessian(5, 3) = hessian(3, 5)
5814 IF (ALLOCATED(w%v2sigmalapl) .AND. has_laplace) THEN
5815 hessian(3, 6) = w%v2sigmalapl(1, point)
5816 END IF
5817 hessian(6, 3) = hessian(3, 6)
5818 IF (ALLOCATED(w%v2sigmalapl) .AND. has_laplace) THEN
5819 hessian(3, 7) = w%v2sigmalapl(2, point)
5820 END IF
5821 hessian(7, 3) = hessian(3, 7)
5822 IF (ALLOCATED(w%v2sigmatau) ) THEN
5823 hessian(3, 8) = w%v2sigmatau(1, point)
5824 END IF
5825 hessian(8, 3) = hessian(3, 8)
5826 IF (ALLOCATED(w%v2sigmatau) ) THEN
5827 hessian(3, 9) = w%v2sigmatau(2, point)
5828 END IF
5829 hessian(9, 3) = hessian(3, 9)
5830 IF (ALLOCATED(w%v2sigma2) ) THEN
5831 hessian(4, 4) = w%v2sigma2(4, point)
5832 END IF
5833 hessian(4, 4) = hessian(4, 4)
5834 IF (ALLOCATED(w%v2sigma2) ) THEN
5835 hessian(4, 5) = w%v2sigma2(5, point)
5836 END IF
5837 hessian(5, 4) = hessian(4, 5)
5838 IF (ALLOCATED(w%v2sigmalapl) .AND. has_laplace) THEN
5839 hessian(4, 6) = w%v2sigmalapl(3, point)
5840 END IF
5841 hessian(6, 4) = hessian(4, 6)
5842 IF (ALLOCATED(w%v2sigmalapl) .AND. has_laplace) THEN
5843 hessian(4, 7) = w%v2sigmalapl(4, point)
5844 END IF
5845 hessian(7, 4) = hessian(4, 7)
5846 IF (ALLOCATED(w%v2sigmatau) ) THEN
5847 hessian(4, 8) = w%v2sigmatau(3, point)
5848 END IF
5849 hessian(8, 4) = hessian(4, 8)
5850 IF (ALLOCATED(w%v2sigmatau) ) THEN
5851 hessian(4, 9) = w%v2sigmatau(4, point)
5852 END IF
5853 hessian(9, 4) = hessian(4, 9)
5854 IF (ALLOCATED(w%v2sigma2) ) THEN
5855 hessian(5, 5) = w%v2sigma2(6, point)
5856 END IF
5857 hessian(5, 5) = hessian(5, 5)
5858 IF (ALLOCATED(w%v2sigmalapl) .AND. has_laplace) THEN
5859 hessian(5, 6) = w%v2sigmalapl(5, point)
5860 END IF
5861 hessian(6, 5) = hessian(5, 6)
5862 IF (ALLOCATED(w%v2sigmalapl) .AND. has_laplace) THEN
5863 hessian(5, 7) = w%v2sigmalapl(6, point)
5864 END IF
5865 hessian(7, 5) = hessian(5, 7)
5866 IF (ALLOCATED(w%v2sigmatau) ) THEN
5867 hessian(5, 8) = w%v2sigmatau(5, point)
5868 END IF
5869 hessian(8, 5) = hessian(5, 8)
5870 IF (ALLOCATED(w%v2sigmatau) ) THEN
5871 hessian(5, 9) = w%v2sigmatau(6, point)
5872 END IF
5873 hessian(9, 5) = hessian(5, 9)
5874 IF (ALLOCATED(w%v2lapl2) .AND. has_laplace) THEN
5875 hessian(6, 6) = w%v2lapl2(1, point)
5876 END IF
5877 hessian(6, 6) = hessian(6, 6)
5878 IF (ALLOCATED(w%v2lapl2) .AND. has_laplace) THEN
5879 hessian(6, 7) = w%v2lapl2(2, point)
5880 END IF
5881 hessian(7, 6) = hessian(6, 7)
5882 IF (ALLOCATED(w%v2lapltau) .AND. has_laplace) THEN
5883 hessian(6, 8) = w%v2lapltau(1, point)
5884 END IF
5885 hessian(8, 6) = hessian(6, 8)
5886 IF (ALLOCATED(w%v2lapltau) .AND. has_laplace) THEN
5887 hessian(6, 9) = w%v2lapltau(2, point)
5888 END IF
5889 hessian(9, 6) = hessian(6, 9)
5890 IF (ALLOCATED(w%v2lapl2) .AND. has_laplace) THEN
5891 hessian(7, 7) = w%v2lapl2(3, point)
5892 END IF
5893 hessian(7, 7) = hessian(7, 7)
5894 IF (ALLOCATED(w%v2lapltau) .AND. has_laplace) THEN
5895 hessian(7, 8) = w%v2lapltau(3, point)
5896 END IF
5897 hessian(8, 7) = hessian(7, 8)
5898 IF (ALLOCATED(w%v2lapltau) .AND. has_laplace) THEN
5899 hessian(7, 9) = w%v2lapltau(4, point)
5900 END IF
5901 hessian(9, 7) = hessian(7, 9)
5902 IF (ALLOCATED(w%v2tau2) ) THEN
5903 hessian(8, 8) = w%v2tau2(1, point)
5904 END IF
5905 hessian(8, 8) = hessian(8, 8)
5906 IF (ALLOCATED(w%v2tau2) ) THEN
5907 hessian(8, 9) = w%v2tau2(2, point)
5908 END IF
5909 hessian(9, 8) = hessian(8, 9)
5910 IF (ALLOCATED(w%v2tau2) ) THEN
5911 hessian(9, 9) = w%v2tau2(3, point)
5912 END IF
5913 hessian(9, 9) = hessian(9, 9)
5914 END IF
5915 ! Use unmodified first and second derivatives in every product-rule term.
5916 IF (grad_deriv >= 3) THEN
5917 IF (ALLOCATED(w%v3rho3) ) THEN
5918 third_ratio = (2.0_dp*(dn(1)*dm(1)*dm(1) + &
5919 dn(1)*dm(1)*dm(1) + dn(1)*dm(1)*dm(1)) - &
5920 6.0_dp*ratio*dm(1)*dm(1)*dm(1))/m**3
5921 w%v3rho3(1, point) = ratio*diagonal(1)*diagonal(1)*diagonal(1)* &
5922 w%v3rho3(1, point) + first_ratio(1)*diagonal(1)*diagonal(1)*hessian(1, 1) + &
5923 first_ratio(1)*diagonal(1)*diagonal(1)*hessian(1, 1) + &
5924 first_ratio(1)*diagonal(1)*diagonal(1)*hessian(1, 1) + &
5925 second_ratio(1, 1)*diagonal(1)*gradient(1) + &
5926 second_ratio(1, 1)*diagonal(1)*gradient(1) + &
5927 second_ratio(1, 1)*diagonal(1)*gradient(1) + third_ratio*functional
5928 END IF
5929 IF (ALLOCATED(w%v3rho3) ) THEN
5930 third_ratio = (2.0_dp*(dn(1)*dm(1)*dm(2) + &
5931 dn(1)*dm(1)*dm(2) + dn(2)*dm(1)*dm(1)) - &
5932 6.0_dp*ratio*dm(1)*dm(1)*dm(2))/m**3
5933 w%v3rho3(2, point) = ratio*diagonal(1)*diagonal(1)*diagonal(2)* &
5934 w%v3rho3(2, point) + first_ratio(1)*diagonal(1)*diagonal(2)*hessian(1, 2) + &
5935 first_ratio(1)*diagonal(1)*diagonal(2)*hessian(1, 2) + &
5936 first_ratio(2)*diagonal(1)*diagonal(1)*hessian(1, 1) + &
5937 second_ratio(1, 1)*diagonal(2)*gradient(2) + &
5938 second_ratio(1, 2)*diagonal(1)*gradient(1) + &
5939 second_ratio(1, 2)*diagonal(1)*gradient(1) + third_ratio*functional
5940 END IF
5941 IF (ALLOCATED(w%v3rho2sigma) ) THEN
5942 third_ratio = (2.0_dp*(dn(1)*dm(1)*dm(3) + &
5943 dn(1)*dm(1)*dm(3) + dn(3)*dm(1)*dm(1)) - &
5944 6.0_dp*ratio*dm(1)*dm(1)*dm(3))/m**3
5945 w%v3rho2sigma(1, point) = ratio*diagonal(1)*diagonal(1)*diagonal(3)* &
5946 w%v3rho2sigma(1, point) + first_ratio(1)*diagonal(1)*diagonal(3)*hessian(1, 3) + &
5947 first_ratio(1)*diagonal(1)*diagonal(3)*hessian(1, 3) + &
5948 first_ratio(3)*diagonal(1)*diagonal(1)*hessian(1, 1) + &
5949 second_ratio(1, 1)*diagonal(3)*gradient(3) + &
5950 second_ratio(1, 3)*diagonal(1)*gradient(1) + &
5951 second_ratio(1, 3)*diagonal(1)*gradient(1) + third_ratio*functional
5952 END IF
5953 IF (ALLOCATED(w%v3rho2sigma) ) THEN
5954 third_ratio = (2.0_dp*(dn(1)*dm(1)*dm(4) + &
5955 dn(1)*dm(1)*dm(4) + dn(4)*dm(1)*dm(1)) - &
5956 6.0_dp*ratio*dm(1)*dm(1)*dm(4))/m**3
5957 w%v3rho2sigma(2, point) = ratio*diagonal(1)*diagonal(1)*diagonal(4)* &
5958 w%v3rho2sigma(2, point) + first_ratio(1)*diagonal(1)*diagonal(4)*hessian(1, 4) + &
5959 first_ratio(1)*diagonal(1)*diagonal(4)*hessian(1, 4) + &
5960 first_ratio(4)*diagonal(1)*diagonal(1)*hessian(1, 1) + &
5961 second_ratio(1, 1)*diagonal(4)*gradient(4) + &
5962 second_ratio(1, 4)*diagonal(1)*gradient(1) + &
5963 second_ratio(1, 4)*diagonal(1)*gradient(1) + third_ratio*functional
5964 END IF
5965 IF (ALLOCATED(w%v3rho2sigma) ) THEN
5966 third_ratio = (2.0_dp*(dn(1)*dm(1)*dm(5) + &
5967 dn(1)*dm(1)*dm(5) + dn(5)*dm(1)*dm(1)) - &
5968 6.0_dp*ratio*dm(1)*dm(1)*dm(5))/m**3
5969 w%v3rho2sigma(3, point) = ratio*diagonal(1)*diagonal(1)*diagonal(5)* &
5970 w%v3rho2sigma(3, point) + first_ratio(1)*diagonal(1)*diagonal(5)*hessian(1, 5) + &
5971 first_ratio(1)*diagonal(1)*diagonal(5)*hessian(1, 5) + &
5972 first_ratio(5)*diagonal(1)*diagonal(1)*hessian(1, 1) + &
5973 second_ratio(1, 1)*diagonal(5)*gradient(5) + &
5974 second_ratio(1, 5)*diagonal(1)*gradient(1) + &
5975 second_ratio(1, 5)*diagonal(1)*gradient(1) + third_ratio*functional
5976 END IF
5977 IF (ALLOCATED(w%v3rho2lapl) .AND. has_laplace) THEN
5978 third_ratio = (2.0_dp*(dn(1)*dm(1)*dm(6) + &
5979 dn(1)*dm(1)*dm(6) + dn(6)*dm(1)*dm(1)) - &
5980 6.0_dp*ratio*dm(1)*dm(1)*dm(6))/m**3
5981 w%v3rho2lapl(1, point) = ratio*diagonal(1)*diagonal(1)*diagonal(6)* &
5982 w%v3rho2lapl(1, point) + first_ratio(1)*diagonal(1)*diagonal(6)*hessian(1, 6) + &
5983 first_ratio(1)*diagonal(1)*diagonal(6)*hessian(1, 6) + &
5984 first_ratio(6)*diagonal(1)*diagonal(1)*hessian(1, 1) + &
5985 second_ratio(1, 1)*diagonal(6)*gradient(6) + &
5986 second_ratio(1, 6)*diagonal(1)*gradient(1) + &
5987 second_ratio(1, 6)*diagonal(1)*gradient(1) + third_ratio*functional
5988 END IF
5989 IF (ALLOCATED(w%v3rho2lapl) .AND. has_laplace) THEN
5990 third_ratio = (2.0_dp*(dn(1)*dm(1)*dm(7) + &
5991 dn(1)*dm(1)*dm(7) + dn(7)*dm(1)*dm(1)) - &
5992 6.0_dp*ratio*dm(1)*dm(1)*dm(7))/m**3
5993 w%v3rho2lapl(2, point) = ratio*diagonal(1)*diagonal(1)*diagonal(7)* &
5994 w%v3rho2lapl(2, point) + first_ratio(1)*diagonal(1)*diagonal(7)*hessian(1, 7) + &
5995 first_ratio(1)*diagonal(1)*diagonal(7)*hessian(1, 7) + &
5996 first_ratio(7)*diagonal(1)*diagonal(1)*hessian(1, 1) + &
5997 second_ratio(1, 1)*diagonal(7)*gradient(7) + &
5998 second_ratio(1, 7)*diagonal(1)*gradient(1) + &
5999 second_ratio(1, 7)*diagonal(1)*gradient(1) + third_ratio*functional
6000 END IF
6001 IF (ALLOCATED(w%v3rho2tau) ) THEN
6002 third_ratio = (2.0_dp*(dn(1)*dm(1)*dm(8) + &
6003 dn(1)*dm(1)*dm(8) + dn(8)*dm(1)*dm(1)) - &
6004 6.0_dp*ratio*dm(1)*dm(1)*dm(8))/m**3
6005 w%v3rho2tau(1, point) = ratio*diagonal(1)*diagonal(1)*diagonal(8)* &
6006 w%v3rho2tau(1, point) + first_ratio(1)*diagonal(1)*diagonal(8)*hessian(1, 8) + &
6007 first_ratio(1)*diagonal(1)*diagonal(8)*hessian(1, 8) + &
6008 first_ratio(8)*diagonal(1)*diagonal(1)*hessian(1, 1) + &
6009 second_ratio(1, 1)*diagonal(8)*gradient(8) + &
6010 second_ratio(1, 8)*diagonal(1)*gradient(1) + &
6011 second_ratio(1, 8)*diagonal(1)*gradient(1) + third_ratio*functional
6012 END IF
6013 IF (ALLOCATED(w%v3rho2tau) ) THEN
6014 third_ratio = (2.0_dp*(dn(1)*dm(1)*dm(9) + &
6015 dn(1)*dm(1)*dm(9) + dn(9)*dm(1)*dm(1)) - &
6016 6.0_dp*ratio*dm(1)*dm(1)*dm(9))/m**3
6017 w%v3rho2tau(2, point) = ratio*diagonal(1)*diagonal(1)*diagonal(9)* &
6018 w%v3rho2tau(2, point) + first_ratio(1)*diagonal(1)*diagonal(9)*hessian(1, 9) + &
6019 first_ratio(1)*diagonal(1)*diagonal(9)*hessian(1, 9) + &
6020 first_ratio(9)*diagonal(1)*diagonal(1)*hessian(1, 1) + &
6021 second_ratio(1, 1)*diagonal(9)*gradient(9) + &
6022 second_ratio(1, 9)*diagonal(1)*gradient(1) + &
6023 second_ratio(1, 9)*diagonal(1)*gradient(1) + third_ratio*functional
6024 END IF
6025 IF (ALLOCATED(w%v3rho3) ) THEN
6026 third_ratio = (2.0_dp*(dn(1)*dm(2)*dm(2) + &
6027 dn(2)*dm(1)*dm(2) + dn(2)*dm(1)*dm(2)) - &
6028 6.0_dp*ratio*dm(1)*dm(2)*dm(2))/m**3
6029 w%v3rho3(3, point) = ratio*diagonal(1)*diagonal(2)*diagonal(2)* &
6030 w%v3rho3(3, point) + first_ratio(1)*diagonal(2)*diagonal(2)*hessian(2, 2) + &
6031 first_ratio(2)*diagonal(1)*diagonal(2)*hessian(1, 2) + &
6032 first_ratio(2)*diagonal(1)*diagonal(2)*hessian(1, 2) + &
6033 second_ratio(1, 2)*diagonal(2)*gradient(2) + &
6034 second_ratio(1, 2)*diagonal(2)*gradient(2) + &
6035 second_ratio(2, 2)*diagonal(1)*gradient(1) + third_ratio*functional
6036 END IF
6037 IF (ALLOCATED(w%v3rho2sigma) ) THEN
6038 third_ratio = (2.0_dp*(dn(1)*dm(2)*dm(3) + &
6039 dn(2)*dm(1)*dm(3) + dn(3)*dm(1)*dm(2)) - &
6040 6.0_dp*ratio*dm(1)*dm(2)*dm(3))/m**3
6041 w%v3rho2sigma(4, point) = ratio*diagonal(1)*diagonal(2)*diagonal(3)* &
6042 w%v3rho2sigma(4, point) + first_ratio(1)*diagonal(2)*diagonal(3)*hessian(2, 3) + &
6043 first_ratio(2)*diagonal(1)*diagonal(3)*hessian(1, 3) + &
6044 first_ratio(3)*diagonal(1)*diagonal(2)*hessian(1, 2) + &
6045 second_ratio(1, 2)*diagonal(3)*gradient(3) + &
6046 second_ratio(1, 3)*diagonal(2)*gradient(2) + &
6047 second_ratio(2, 3)*diagonal(1)*gradient(1) + third_ratio*functional
6048 END IF
6049 IF (ALLOCATED(w%v3rho2sigma) ) THEN
6050 third_ratio = (2.0_dp*(dn(1)*dm(2)*dm(4) + &
6051 dn(2)*dm(1)*dm(4) + dn(4)*dm(1)*dm(2)) - &
6052 6.0_dp*ratio*dm(1)*dm(2)*dm(4))/m**3
6053 w%v3rho2sigma(5, point) = ratio*diagonal(1)*diagonal(2)*diagonal(4)* &
6054 w%v3rho2sigma(5, point) + first_ratio(1)*diagonal(2)*diagonal(4)*hessian(2, 4) + &
6055 first_ratio(2)*diagonal(1)*diagonal(4)*hessian(1, 4) + &
6056 first_ratio(4)*diagonal(1)*diagonal(2)*hessian(1, 2) + &
6057 second_ratio(1, 2)*diagonal(4)*gradient(4) + &
6058 second_ratio(1, 4)*diagonal(2)*gradient(2) + &
6059 second_ratio(2, 4)*diagonal(1)*gradient(1) + third_ratio*functional
6060 END IF
6061 IF (ALLOCATED(w%v3rho2sigma) ) THEN
6062 third_ratio = (2.0_dp*(dn(1)*dm(2)*dm(5) + &
6063 dn(2)*dm(1)*dm(5) + dn(5)*dm(1)*dm(2)) - &
6064 6.0_dp*ratio*dm(1)*dm(2)*dm(5))/m**3
6065 w%v3rho2sigma(6, point) = ratio*diagonal(1)*diagonal(2)*diagonal(5)* &
6066 w%v3rho2sigma(6, point) + first_ratio(1)*diagonal(2)*diagonal(5)*hessian(2, 5) + &
6067 first_ratio(2)*diagonal(1)*diagonal(5)*hessian(1, 5) + &
6068 first_ratio(5)*diagonal(1)*diagonal(2)*hessian(1, 2) + &
6069 second_ratio(1, 2)*diagonal(5)*gradient(5) + &
6070 second_ratio(1, 5)*diagonal(2)*gradient(2) + &
6071 second_ratio(2, 5)*diagonal(1)*gradient(1) + third_ratio*functional
6072 END IF
6073 IF (ALLOCATED(w%v3rho2lapl) .AND. has_laplace) THEN
6074 third_ratio = (2.0_dp*(dn(1)*dm(2)*dm(6) + &
6075 dn(2)*dm(1)*dm(6) + dn(6)*dm(1)*dm(2)) - &
6076 6.0_dp*ratio*dm(1)*dm(2)*dm(6))/m**3
6077 w%v3rho2lapl(3, point) = ratio*diagonal(1)*diagonal(2)*diagonal(6)* &
6078 w%v3rho2lapl(3, point) + first_ratio(1)*diagonal(2)*diagonal(6)*hessian(2, 6) + &
6079 first_ratio(2)*diagonal(1)*diagonal(6)*hessian(1, 6) + &
6080 first_ratio(6)*diagonal(1)*diagonal(2)*hessian(1, 2) + &
6081 second_ratio(1, 2)*diagonal(6)*gradient(6) + &
6082 second_ratio(1, 6)*diagonal(2)*gradient(2) + &
6083 second_ratio(2, 6)*diagonal(1)*gradient(1) + third_ratio*functional
6084 END IF
6085 IF (ALLOCATED(w%v3rho2lapl) .AND. has_laplace) THEN
6086 third_ratio = (2.0_dp*(dn(1)*dm(2)*dm(7) + &
6087 dn(2)*dm(1)*dm(7) + dn(7)*dm(1)*dm(2)) - &
6088 6.0_dp*ratio*dm(1)*dm(2)*dm(7))/m**3
6089 w%v3rho2lapl(4, point) = ratio*diagonal(1)*diagonal(2)*diagonal(7)* &
6090 w%v3rho2lapl(4, point) + first_ratio(1)*diagonal(2)*diagonal(7)*hessian(2, 7) + &
6091 first_ratio(2)*diagonal(1)*diagonal(7)*hessian(1, 7) + &
6092 first_ratio(7)*diagonal(1)*diagonal(2)*hessian(1, 2) + &
6093 second_ratio(1, 2)*diagonal(7)*gradient(7) + &
6094 second_ratio(1, 7)*diagonal(2)*gradient(2) + &
6095 second_ratio(2, 7)*diagonal(1)*gradient(1) + third_ratio*functional
6096 END IF
6097 IF (ALLOCATED(w%v3rho2tau) ) THEN
6098 third_ratio = (2.0_dp*(dn(1)*dm(2)*dm(8) + &
6099 dn(2)*dm(1)*dm(8) + dn(8)*dm(1)*dm(2)) - &
6100 6.0_dp*ratio*dm(1)*dm(2)*dm(8))/m**3
6101 w%v3rho2tau(3, point) = ratio*diagonal(1)*diagonal(2)*diagonal(8)* &
6102 w%v3rho2tau(3, point) + first_ratio(1)*diagonal(2)*diagonal(8)*hessian(2, 8) + &
6103 first_ratio(2)*diagonal(1)*diagonal(8)*hessian(1, 8) + &
6104 first_ratio(8)*diagonal(1)*diagonal(2)*hessian(1, 2) + &
6105 second_ratio(1, 2)*diagonal(8)*gradient(8) + &
6106 second_ratio(1, 8)*diagonal(2)*gradient(2) + &
6107 second_ratio(2, 8)*diagonal(1)*gradient(1) + third_ratio*functional
6108 END IF
6109 IF (ALLOCATED(w%v3rho2tau) ) THEN
6110 third_ratio = (2.0_dp*(dn(1)*dm(2)*dm(9) + &
6111 dn(2)*dm(1)*dm(9) + dn(9)*dm(1)*dm(2)) - &
6112 6.0_dp*ratio*dm(1)*dm(2)*dm(9))/m**3
6113 w%v3rho2tau(4, point) = ratio*diagonal(1)*diagonal(2)*diagonal(9)* &
6114 w%v3rho2tau(4, point) + first_ratio(1)*diagonal(2)*diagonal(9)*hessian(2, 9) + &
6115 first_ratio(2)*diagonal(1)*diagonal(9)*hessian(1, 9) + &
6116 first_ratio(9)*diagonal(1)*diagonal(2)*hessian(1, 2) + &
6117 second_ratio(1, 2)*diagonal(9)*gradient(9) + &
6118 second_ratio(1, 9)*diagonal(2)*gradient(2) + &
6119 second_ratio(2, 9)*diagonal(1)*gradient(1) + third_ratio*functional
6120 END IF
6121 IF (ALLOCATED(w%v3rhosigma2) ) THEN
6122 third_ratio = (2.0_dp*(dn(1)*dm(3)*dm(3) + &
6123 dn(3)*dm(1)*dm(3) + dn(3)*dm(1)*dm(3)) - &
6124 6.0_dp*ratio*dm(1)*dm(3)*dm(3))/m**3
6125 w%v3rhosigma2(1, point) = ratio*diagonal(1)*diagonal(3)*diagonal(3)* &
6126 w%v3rhosigma2(1, point) + first_ratio(1)*diagonal(3)*diagonal(3)*hessian(3, 3) + &
6127 first_ratio(3)*diagonal(1)*diagonal(3)*hessian(1, 3) + &
6128 first_ratio(3)*diagonal(1)*diagonal(3)*hessian(1, 3) + &
6129 second_ratio(1, 3)*diagonal(3)*gradient(3) + &
6130 second_ratio(1, 3)*diagonal(3)*gradient(3) + &
6131 second_ratio(3, 3)*diagonal(1)*gradient(1) + third_ratio*functional
6132 END IF
6133 IF (ALLOCATED(w%v3rhosigma2) ) THEN
6134 third_ratio = (2.0_dp*(dn(1)*dm(3)*dm(4) + &
6135 dn(3)*dm(1)*dm(4) + dn(4)*dm(1)*dm(3)) - &
6136 6.0_dp*ratio*dm(1)*dm(3)*dm(4))/m**3
6137 w%v3rhosigma2(2, point) = ratio*diagonal(1)*diagonal(3)*diagonal(4)* &
6138 w%v3rhosigma2(2, point) + first_ratio(1)*diagonal(3)*diagonal(4)*hessian(3, 4) + &
6139 first_ratio(3)*diagonal(1)*diagonal(4)*hessian(1, 4) + &
6140 first_ratio(4)*diagonal(1)*diagonal(3)*hessian(1, 3) + &
6141 second_ratio(1, 3)*diagonal(4)*gradient(4) + &
6142 second_ratio(1, 4)*diagonal(3)*gradient(3) + &
6143 second_ratio(3, 4)*diagonal(1)*gradient(1) + third_ratio*functional
6144 END IF
6145 IF (ALLOCATED(w%v3rhosigma2) ) THEN
6146 third_ratio = (2.0_dp*(dn(1)*dm(3)*dm(5) + &
6147 dn(3)*dm(1)*dm(5) + dn(5)*dm(1)*dm(3)) - &
6148 6.0_dp*ratio*dm(1)*dm(3)*dm(5))/m**3
6149 w%v3rhosigma2(3, point) = ratio*diagonal(1)*diagonal(3)*diagonal(5)* &
6150 w%v3rhosigma2(3, point) + first_ratio(1)*diagonal(3)*diagonal(5)*hessian(3, 5) + &
6151 first_ratio(3)*diagonal(1)*diagonal(5)*hessian(1, 5) + &
6152 first_ratio(5)*diagonal(1)*diagonal(3)*hessian(1, 3) + &
6153 second_ratio(1, 3)*diagonal(5)*gradient(5) + &
6154 second_ratio(1, 5)*diagonal(3)*gradient(3) + &
6155 second_ratio(3, 5)*diagonal(1)*gradient(1) + third_ratio*functional
6156 END IF
6157 IF (ALLOCATED(w%v3rhosigmalapl) .AND. has_laplace) THEN
6158 third_ratio = (2.0_dp*(dn(1)*dm(3)*dm(6) + &
6159 dn(3)*dm(1)*dm(6) + dn(6)*dm(1)*dm(3)) - &
6160 6.0_dp*ratio*dm(1)*dm(3)*dm(6))/m**3
6161 w%v3rhosigmalapl(1, point) = ratio*diagonal(1)*diagonal(3)*diagonal(6)* &
6162 w%v3rhosigmalapl(1, point) + first_ratio(1)*diagonal(3)*diagonal(6)*hessian(3, 6) + &
6163 first_ratio(3)*diagonal(1)*diagonal(6)*hessian(1, 6) + &
6164 first_ratio(6)*diagonal(1)*diagonal(3)*hessian(1, 3) + &
6165 second_ratio(1, 3)*diagonal(6)*gradient(6) + &
6166 second_ratio(1, 6)*diagonal(3)*gradient(3) + &
6167 second_ratio(3, 6)*diagonal(1)*gradient(1) + third_ratio*functional
6168 END IF
6169 IF (ALLOCATED(w%v3rhosigmalapl) .AND. has_laplace) THEN
6170 third_ratio = (2.0_dp*(dn(1)*dm(3)*dm(7) + &
6171 dn(3)*dm(1)*dm(7) + dn(7)*dm(1)*dm(3)) - &
6172 6.0_dp*ratio*dm(1)*dm(3)*dm(7))/m**3
6173 w%v3rhosigmalapl(2, point) = ratio*diagonal(1)*diagonal(3)*diagonal(7)* &
6174 w%v3rhosigmalapl(2, point) + first_ratio(1)*diagonal(3)*diagonal(7)*hessian(3, 7) + &
6175 first_ratio(3)*diagonal(1)*diagonal(7)*hessian(1, 7) + &
6176 first_ratio(7)*diagonal(1)*diagonal(3)*hessian(1, 3) + &
6177 second_ratio(1, 3)*diagonal(7)*gradient(7) + &
6178 second_ratio(1, 7)*diagonal(3)*gradient(3) + &
6179 second_ratio(3, 7)*diagonal(1)*gradient(1) + third_ratio*functional
6180 END IF
6181 IF (ALLOCATED(w%v3rhosigmatau) ) THEN
6182 third_ratio = (2.0_dp*(dn(1)*dm(3)*dm(8) + &
6183 dn(3)*dm(1)*dm(8) + dn(8)*dm(1)*dm(3)) - &
6184 6.0_dp*ratio*dm(1)*dm(3)*dm(8))/m**3
6185 w%v3rhosigmatau(1, point) = ratio*diagonal(1)*diagonal(3)*diagonal(8)* &
6186 w%v3rhosigmatau(1, point) + first_ratio(1)*diagonal(3)*diagonal(8)*hessian(3, 8) + &
6187 first_ratio(3)*diagonal(1)*diagonal(8)*hessian(1, 8) + &
6188 first_ratio(8)*diagonal(1)*diagonal(3)*hessian(1, 3) + &
6189 second_ratio(1, 3)*diagonal(8)*gradient(8) + &
6190 second_ratio(1, 8)*diagonal(3)*gradient(3) + &
6191 second_ratio(3, 8)*diagonal(1)*gradient(1) + third_ratio*functional
6192 END IF
6193 IF (ALLOCATED(w%v3rhosigmatau) ) THEN
6194 third_ratio = (2.0_dp*(dn(1)*dm(3)*dm(9) + &
6195 dn(3)*dm(1)*dm(9) + dn(9)*dm(1)*dm(3)) - &
6196 6.0_dp*ratio*dm(1)*dm(3)*dm(9))/m**3
6197 w%v3rhosigmatau(2, point) = ratio*diagonal(1)*diagonal(3)*diagonal(9)* &
6198 w%v3rhosigmatau(2, point) + first_ratio(1)*diagonal(3)*diagonal(9)*hessian(3, 9) + &
6199 first_ratio(3)*diagonal(1)*diagonal(9)*hessian(1, 9) + &
6200 first_ratio(9)*diagonal(1)*diagonal(3)*hessian(1, 3) + &
6201 second_ratio(1, 3)*diagonal(9)*gradient(9) + &
6202 second_ratio(1, 9)*diagonal(3)*gradient(3) + &
6203 second_ratio(3, 9)*diagonal(1)*gradient(1) + third_ratio*functional
6204 END IF
6205 IF (ALLOCATED(w%v3rhosigma2) ) THEN
6206 third_ratio = (2.0_dp*(dn(1)*dm(4)*dm(4) + &
6207 dn(4)*dm(1)*dm(4) + dn(4)*dm(1)*dm(4)) - &
6208 6.0_dp*ratio*dm(1)*dm(4)*dm(4))/m**3
6209 w%v3rhosigma2(4, point) = ratio*diagonal(1)*diagonal(4)*diagonal(4)* &
6210 w%v3rhosigma2(4, point) + first_ratio(1)*diagonal(4)*diagonal(4)*hessian(4, 4) + &
6211 first_ratio(4)*diagonal(1)*diagonal(4)*hessian(1, 4) + &
6212 first_ratio(4)*diagonal(1)*diagonal(4)*hessian(1, 4) + &
6213 second_ratio(1, 4)*diagonal(4)*gradient(4) + &
6214 second_ratio(1, 4)*diagonal(4)*gradient(4) + &
6215 second_ratio(4, 4)*diagonal(1)*gradient(1) + third_ratio*functional
6216 END IF
6217 IF (ALLOCATED(w%v3rhosigma2) ) THEN
6218 third_ratio = (2.0_dp*(dn(1)*dm(4)*dm(5) + &
6219 dn(4)*dm(1)*dm(5) + dn(5)*dm(1)*dm(4)) - &
6220 6.0_dp*ratio*dm(1)*dm(4)*dm(5))/m**3
6221 w%v3rhosigma2(5, point) = ratio*diagonal(1)*diagonal(4)*diagonal(5)* &
6222 w%v3rhosigma2(5, point) + first_ratio(1)*diagonal(4)*diagonal(5)*hessian(4, 5) + &
6223 first_ratio(4)*diagonal(1)*diagonal(5)*hessian(1, 5) + &
6224 first_ratio(5)*diagonal(1)*diagonal(4)*hessian(1, 4) + &
6225 second_ratio(1, 4)*diagonal(5)*gradient(5) + &
6226 second_ratio(1, 5)*diagonal(4)*gradient(4) + &
6227 second_ratio(4, 5)*diagonal(1)*gradient(1) + third_ratio*functional
6228 END IF
6229 IF (ALLOCATED(w%v3rhosigmalapl) .AND. has_laplace) THEN
6230 third_ratio = (2.0_dp*(dn(1)*dm(4)*dm(6) + &
6231 dn(4)*dm(1)*dm(6) + dn(6)*dm(1)*dm(4)) - &
6232 6.0_dp*ratio*dm(1)*dm(4)*dm(6))/m**3
6233 w%v3rhosigmalapl(3, point) = ratio*diagonal(1)*diagonal(4)*diagonal(6)* &
6234 w%v3rhosigmalapl(3, point) + first_ratio(1)*diagonal(4)*diagonal(6)*hessian(4, 6) + &
6235 first_ratio(4)*diagonal(1)*diagonal(6)*hessian(1, 6) + &
6236 first_ratio(6)*diagonal(1)*diagonal(4)*hessian(1, 4) + &
6237 second_ratio(1, 4)*diagonal(6)*gradient(6) + &
6238 second_ratio(1, 6)*diagonal(4)*gradient(4) + &
6239 second_ratio(4, 6)*diagonal(1)*gradient(1) + third_ratio*functional
6240 END IF
6241 IF (ALLOCATED(w%v3rhosigmalapl) .AND. has_laplace) THEN
6242 third_ratio = (2.0_dp*(dn(1)*dm(4)*dm(7) + &
6243 dn(4)*dm(1)*dm(7) + dn(7)*dm(1)*dm(4)) - &
6244 6.0_dp*ratio*dm(1)*dm(4)*dm(7))/m**3
6245 w%v3rhosigmalapl(4, point) = ratio*diagonal(1)*diagonal(4)*diagonal(7)* &
6246 w%v3rhosigmalapl(4, point) + first_ratio(1)*diagonal(4)*diagonal(7)*hessian(4, 7) + &
6247 first_ratio(4)*diagonal(1)*diagonal(7)*hessian(1, 7) + &
6248 first_ratio(7)*diagonal(1)*diagonal(4)*hessian(1, 4) + &
6249 second_ratio(1, 4)*diagonal(7)*gradient(7) + &
6250 second_ratio(1, 7)*diagonal(4)*gradient(4) + &
6251 second_ratio(4, 7)*diagonal(1)*gradient(1) + third_ratio*functional
6252 END IF
6253 IF (ALLOCATED(w%v3rhosigmatau) ) THEN
6254 third_ratio = (2.0_dp*(dn(1)*dm(4)*dm(8) + &
6255 dn(4)*dm(1)*dm(8) + dn(8)*dm(1)*dm(4)) - &
6256 6.0_dp*ratio*dm(1)*dm(4)*dm(8))/m**3
6257 w%v3rhosigmatau(3, point) = ratio*diagonal(1)*diagonal(4)*diagonal(8)* &
6258 w%v3rhosigmatau(3, point) + first_ratio(1)*diagonal(4)*diagonal(8)*hessian(4, 8) + &
6259 first_ratio(4)*diagonal(1)*diagonal(8)*hessian(1, 8) + &
6260 first_ratio(8)*diagonal(1)*diagonal(4)*hessian(1, 4) + &
6261 second_ratio(1, 4)*diagonal(8)*gradient(8) + &
6262 second_ratio(1, 8)*diagonal(4)*gradient(4) + &
6263 second_ratio(4, 8)*diagonal(1)*gradient(1) + third_ratio*functional
6264 END IF
6265 IF (ALLOCATED(w%v3rhosigmatau) ) THEN
6266 third_ratio = (2.0_dp*(dn(1)*dm(4)*dm(9) + &
6267 dn(4)*dm(1)*dm(9) + dn(9)*dm(1)*dm(4)) - &
6268 6.0_dp*ratio*dm(1)*dm(4)*dm(9))/m**3
6269 w%v3rhosigmatau(4, point) = ratio*diagonal(1)*diagonal(4)*diagonal(9)* &
6270 w%v3rhosigmatau(4, point) + first_ratio(1)*diagonal(4)*diagonal(9)*hessian(4, 9) + &
6271 first_ratio(4)*diagonal(1)*diagonal(9)*hessian(1, 9) + &
6272 first_ratio(9)*diagonal(1)*diagonal(4)*hessian(1, 4) + &
6273 second_ratio(1, 4)*diagonal(9)*gradient(9) + &
6274 second_ratio(1, 9)*diagonal(4)*gradient(4) + &
6275 second_ratio(4, 9)*diagonal(1)*gradient(1) + third_ratio*functional
6276 END IF
6277 IF (ALLOCATED(w%v3rhosigma2) ) THEN
6278 third_ratio = (2.0_dp*(dn(1)*dm(5)*dm(5) + &
6279 dn(5)*dm(1)*dm(5) + dn(5)*dm(1)*dm(5)) - &
6280 6.0_dp*ratio*dm(1)*dm(5)*dm(5))/m**3
6281 w%v3rhosigma2(6, point) = ratio*diagonal(1)*diagonal(5)*diagonal(5)* &
6282 w%v3rhosigma2(6, point) + first_ratio(1)*diagonal(5)*diagonal(5)*hessian(5, 5) + &
6283 first_ratio(5)*diagonal(1)*diagonal(5)*hessian(1, 5) + &
6284 first_ratio(5)*diagonal(1)*diagonal(5)*hessian(1, 5) + &
6285 second_ratio(1, 5)*diagonal(5)*gradient(5) + &
6286 second_ratio(1, 5)*diagonal(5)*gradient(5) + &
6287 second_ratio(5, 5)*diagonal(1)*gradient(1) + third_ratio*functional
6288 END IF
6289 IF (ALLOCATED(w%v3rhosigmalapl) .AND. has_laplace) THEN
6290 third_ratio = (2.0_dp*(dn(1)*dm(5)*dm(6) + &
6291 dn(5)*dm(1)*dm(6) + dn(6)*dm(1)*dm(5)) - &
6292 6.0_dp*ratio*dm(1)*dm(5)*dm(6))/m**3
6293 w%v3rhosigmalapl(5, point) = ratio*diagonal(1)*diagonal(5)*diagonal(6)* &
6294 w%v3rhosigmalapl(5, point) + first_ratio(1)*diagonal(5)*diagonal(6)*hessian(5, 6) + &
6295 first_ratio(5)*diagonal(1)*diagonal(6)*hessian(1, 6) + &
6296 first_ratio(6)*diagonal(1)*diagonal(5)*hessian(1, 5) + &
6297 second_ratio(1, 5)*diagonal(6)*gradient(6) + &
6298 second_ratio(1, 6)*diagonal(5)*gradient(5) + &
6299 second_ratio(5, 6)*diagonal(1)*gradient(1) + third_ratio*functional
6300 END IF
6301 IF (ALLOCATED(w%v3rhosigmalapl) .AND. has_laplace) THEN
6302 third_ratio = (2.0_dp*(dn(1)*dm(5)*dm(7) + &
6303 dn(5)*dm(1)*dm(7) + dn(7)*dm(1)*dm(5)) - &
6304 6.0_dp*ratio*dm(1)*dm(5)*dm(7))/m**3
6305 w%v3rhosigmalapl(6, point) = ratio*diagonal(1)*diagonal(5)*diagonal(7)* &
6306 w%v3rhosigmalapl(6, point) + first_ratio(1)*diagonal(5)*diagonal(7)*hessian(5, 7) + &
6307 first_ratio(5)*diagonal(1)*diagonal(7)*hessian(1, 7) + &
6308 first_ratio(7)*diagonal(1)*diagonal(5)*hessian(1, 5) + &
6309 second_ratio(1, 5)*diagonal(7)*gradient(7) + &
6310 second_ratio(1, 7)*diagonal(5)*gradient(5) + &
6311 second_ratio(5, 7)*diagonal(1)*gradient(1) + third_ratio*functional
6312 END IF
6313 IF (ALLOCATED(w%v3rhosigmatau) ) THEN
6314 third_ratio = (2.0_dp*(dn(1)*dm(5)*dm(8) + &
6315 dn(5)*dm(1)*dm(8) + dn(8)*dm(1)*dm(5)) - &
6316 6.0_dp*ratio*dm(1)*dm(5)*dm(8))/m**3
6317 w%v3rhosigmatau(5, point) = ratio*diagonal(1)*diagonal(5)*diagonal(8)* &
6318 w%v3rhosigmatau(5, point) + first_ratio(1)*diagonal(5)*diagonal(8)*hessian(5, 8) + &
6319 first_ratio(5)*diagonal(1)*diagonal(8)*hessian(1, 8) + &
6320 first_ratio(8)*diagonal(1)*diagonal(5)*hessian(1, 5) + &
6321 second_ratio(1, 5)*diagonal(8)*gradient(8) + &
6322 second_ratio(1, 8)*diagonal(5)*gradient(5) + &
6323 second_ratio(5, 8)*diagonal(1)*gradient(1) + third_ratio*functional
6324 END IF
6325 IF (ALLOCATED(w%v3rhosigmatau) ) THEN
6326 third_ratio = (2.0_dp*(dn(1)*dm(5)*dm(9) + &
6327 dn(5)*dm(1)*dm(9) + dn(9)*dm(1)*dm(5)) - &
6328 6.0_dp*ratio*dm(1)*dm(5)*dm(9))/m**3
6329 w%v3rhosigmatau(6, point) = ratio*diagonal(1)*diagonal(5)*diagonal(9)* &
6330 w%v3rhosigmatau(6, point) + first_ratio(1)*diagonal(5)*diagonal(9)*hessian(5, 9) + &
6331 first_ratio(5)*diagonal(1)*diagonal(9)*hessian(1, 9) + &
6332 first_ratio(9)*diagonal(1)*diagonal(5)*hessian(1, 5) + &
6333 second_ratio(1, 5)*diagonal(9)*gradient(9) + &
6334 second_ratio(1, 9)*diagonal(5)*gradient(5) + &
6335 second_ratio(5, 9)*diagonal(1)*gradient(1) + third_ratio*functional
6336 END IF
6337 IF (ALLOCATED(w%v3rholapl2) .AND. has_laplace) THEN
6338 third_ratio = (2.0_dp*(dn(1)*dm(6)*dm(6) + &
6339 dn(6)*dm(1)*dm(6) + dn(6)*dm(1)*dm(6)) - &
6340 6.0_dp*ratio*dm(1)*dm(6)*dm(6))/m**3
6341 w%v3rholapl2(1, point) = ratio*diagonal(1)*diagonal(6)*diagonal(6)* &
6342 w%v3rholapl2(1, point) + first_ratio(1)*diagonal(6)*diagonal(6)*hessian(6, 6) + &
6343 first_ratio(6)*diagonal(1)*diagonal(6)*hessian(1, 6) + &
6344 first_ratio(6)*diagonal(1)*diagonal(6)*hessian(1, 6) + &
6345 second_ratio(1, 6)*diagonal(6)*gradient(6) + &
6346 second_ratio(1, 6)*diagonal(6)*gradient(6) + &
6347 second_ratio(6, 6)*diagonal(1)*gradient(1) + third_ratio*functional
6348 END IF
6349 IF (ALLOCATED(w%v3rholapl2) .AND. has_laplace) THEN
6350 third_ratio = (2.0_dp*(dn(1)*dm(6)*dm(7) + &
6351 dn(6)*dm(1)*dm(7) + dn(7)*dm(1)*dm(6)) - &
6352 6.0_dp*ratio*dm(1)*dm(6)*dm(7))/m**3
6353 w%v3rholapl2(2, point) = ratio*diagonal(1)*diagonal(6)*diagonal(7)* &
6354 w%v3rholapl2(2, point) + first_ratio(1)*diagonal(6)*diagonal(7)*hessian(6, 7) + &
6355 first_ratio(6)*diagonal(1)*diagonal(7)*hessian(1, 7) + &
6356 first_ratio(7)*diagonal(1)*diagonal(6)*hessian(1, 6) + &
6357 second_ratio(1, 6)*diagonal(7)*gradient(7) + &
6358 second_ratio(1, 7)*diagonal(6)*gradient(6) + &
6359 second_ratio(6, 7)*diagonal(1)*gradient(1) + third_ratio*functional
6360 END IF
6361 IF (ALLOCATED(w%v3rholapltau) .AND. has_laplace) THEN
6362 third_ratio = (2.0_dp*(dn(1)*dm(6)*dm(8) + &
6363 dn(6)*dm(1)*dm(8) + dn(8)*dm(1)*dm(6)) - &
6364 6.0_dp*ratio*dm(1)*dm(6)*dm(8))/m**3
6365 w%v3rholapltau(1, point) = ratio*diagonal(1)*diagonal(6)*diagonal(8)* &
6366 w%v3rholapltau(1, point) + first_ratio(1)*diagonal(6)*diagonal(8)*hessian(6, 8) + &
6367 first_ratio(6)*diagonal(1)*diagonal(8)*hessian(1, 8) + &
6368 first_ratio(8)*diagonal(1)*diagonal(6)*hessian(1, 6) + &
6369 second_ratio(1, 6)*diagonal(8)*gradient(8) + &
6370 second_ratio(1, 8)*diagonal(6)*gradient(6) + &
6371 second_ratio(6, 8)*diagonal(1)*gradient(1) + third_ratio*functional
6372 END IF
6373 IF (ALLOCATED(w%v3rholapltau) .AND. has_laplace) THEN
6374 third_ratio = (2.0_dp*(dn(1)*dm(6)*dm(9) + &
6375 dn(6)*dm(1)*dm(9) + dn(9)*dm(1)*dm(6)) - &
6376 6.0_dp*ratio*dm(1)*dm(6)*dm(9))/m**3
6377 w%v3rholapltau(2, point) = ratio*diagonal(1)*diagonal(6)*diagonal(9)* &
6378 w%v3rholapltau(2, point) + first_ratio(1)*diagonal(6)*diagonal(9)*hessian(6, 9) + &
6379 first_ratio(6)*diagonal(1)*diagonal(9)*hessian(1, 9) + &
6380 first_ratio(9)*diagonal(1)*diagonal(6)*hessian(1, 6) + &
6381 second_ratio(1, 6)*diagonal(9)*gradient(9) + &
6382 second_ratio(1, 9)*diagonal(6)*gradient(6) + &
6383 second_ratio(6, 9)*diagonal(1)*gradient(1) + third_ratio*functional
6384 END IF
6385 IF (ALLOCATED(w%v3rholapl2) .AND. has_laplace) THEN
6386 third_ratio = (2.0_dp*(dn(1)*dm(7)*dm(7) + &
6387 dn(7)*dm(1)*dm(7) + dn(7)*dm(1)*dm(7)) - &
6388 6.0_dp*ratio*dm(1)*dm(7)*dm(7))/m**3
6389 w%v3rholapl2(3, point) = ratio*diagonal(1)*diagonal(7)*diagonal(7)* &
6390 w%v3rholapl2(3, point) + first_ratio(1)*diagonal(7)*diagonal(7)*hessian(7, 7) + &
6391 first_ratio(7)*diagonal(1)*diagonal(7)*hessian(1, 7) + &
6392 first_ratio(7)*diagonal(1)*diagonal(7)*hessian(1, 7) + &
6393 second_ratio(1, 7)*diagonal(7)*gradient(7) + &
6394 second_ratio(1, 7)*diagonal(7)*gradient(7) + &
6395 second_ratio(7, 7)*diagonal(1)*gradient(1) + third_ratio*functional
6396 END IF
6397 IF (ALLOCATED(w%v3rholapltau) .AND. has_laplace) THEN
6398 third_ratio = (2.0_dp*(dn(1)*dm(7)*dm(8) + &
6399 dn(7)*dm(1)*dm(8) + dn(8)*dm(1)*dm(7)) - &
6400 6.0_dp*ratio*dm(1)*dm(7)*dm(8))/m**3
6401 w%v3rholapltau(3, point) = ratio*diagonal(1)*diagonal(7)*diagonal(8)* &
6402 w%v3rholapltau(3, point) + first_ratio(1)*diagonal(7)*diagonal(8)*hessian(7, 8) + &
6403 first_ratio(7)*diagonal(1)*diagonal(8)*hessian(1, 8) + &
6404 first_ratio(8)*diagonal(1)*diagonal(7)*hessian(1, 7) + &
6405 second_ratio(1, 7)*diagonal(8)*gradient(8) + &
6406 second_ratio(1, 8)*diagonal(7)*gradient(7) + &
6407 second_ratio(7, 8)*diagonal(1)*gradient(1) + third_ratio*functional
6408 END IF
6409 IF (ALLOCATED(w%v3rholapltau) .AND. has_laplace) THEN
6410 third_ratio = (2.0_dp*(dn(1)*dm(7)*dm(9) + &
6411 dn(7)*dm(1)*dm(9) + dn(9)*dm(1)*dm(7)) - &
6412 6.0_dp*ratio*dm(1)*dm(7)*dm(9))/m**3
6413 w%v3rholapltau(4, point) = ratio*diagonal(1)*diagonal(7)*diagonal(9)* &
6414 w%v3rholapltau(4, point) + first_ratio(1)*diagonal(7)*diagonal(9)*hessian(7, 9) + &
6415 first_ratio(7)*diagonal(1)*diagonal(9)*hessian(1, 9) + &
6416 first_ratio(9)*diagonal(1)*diagonal(7)*hessian(1, 7) + &
6417 second_ratio(1, 7)*diagonal(9)*gradient(9) + &
6418 second_ratio(1, 9)*diagonal(7)*gradient(7) + &
6419 second_ratio(7, 9)*diagonal(1)*gradient(1) + third_ratio*functional
6420 END IF
6421 IF (ALLOCATED(w%v3rhotau2) ) THEN
6422 third_ratio = (2.0_dp*(dn(1)*dm(8)*dm(8) + &
6423 dn(8)*dm(1)*dm(8) + dn(8)*dm(1)*dm(8)) - &
6424 6.0_dp*ratio*dm(1)*dm(8)*dm(8))/m**3
6425 w%v3rhotau2(1, point) = ratio*diagonal(1)*diagonal(8)*diagonal(8)* &
6426 w%v3rhotau2(1, point) + first_ratio(1)*diagonal(8)*diagonal(8)*hessian(8, 8) + &
6427 first_ratio(8)*diagonal(1)*diagonal(8)*hessian(1, 8) + &
6428 first_ratio(8)*diagonal(1)*diagonal(8)*hessian(1, 8) + &
6429 second_ratio(1, 8)*diagonal(8)*gradient(8) + &
6430 second_ratio(1, 8)*diagonal(8)*gradient(8) + &
6431 second_ratio(8, 8)*diagonal(1)*gradient(1) + third_ratio*functional
6432 END IF
6433 IF (ALLOCATED(w%v3rhotau2) ) THEN
6434 third_ratio = (2.0_dp*(dn(1)*dm(8)*dm(9) + &
6435 dn(8)*dm(1)*dm(9) + dn(9)*dm(1)*dm(8)) - &
6436 6.0_dp*ratio*dm(1)*dm(8)*dm(9))/m**3
6437 w%v3rhotau2(2, point) = ratio*diagonal(1)*diagonal(8)*diagonal(9)* &
6438 w%v3rhotau2(2, point) + first_ratio(1)*diagonal(8)*diagonal(9)*hessian(8, 9) + &
6439 first_ratio(8)*diagonal(1)*diagonal(9)*hessian(1, 9) + &
6440 first_ratio(9)*diagonal(1)*diagonal(8)*hessian(1, 8) + &
6441 second_ratio(1, 8)*diagonal(9)*gradient(9) + &
6442 second_ratio(1, 9)*diagonal(8)*gradient(8) + &
6443 second_ratio(8, 9)*diagonal(1)*gradient(1) + third_ratio*functional
6444 END IF
6445 IF (ALLOCATED(w%v3rhotau2) ) THEN
6446 third_ratio = (2.0_dp*(dn(1)*dm(9)*dm(9) + &
6447 dn(9)*dm(1)*dm(9) + dn(9)*dm(1)*dm(9)) - &
6448 6.0_dp*ratio*dm(1)*dm(9)*dm(9))/m**3
6449 w%v3rhotau2(3, point) = ratio*diagonal(1)*diagonal(9)*diagonal(9)* &
6450 w%v3rhotau2(3, point) + first_ratio(1)*diagonal(9)*diagonal(9)*hessian(9, 9) + &
6451 first_ratio(9)*diagonal(1)*diagonal(9)*hessian(1, 9) + &
6452 first_ratio(9)*diagonal(1)*diagonal(9)*hessian(1, 9) + &
6453 second_ratio(1, 9)*diagonal(9)*gradient(9) + &
6454 second_ratio(1, 9)*diagonal(9)*gradient(9) + &
6455 second_ratio(9, 9)*diagonal(1)*gradient(1) + third_ratio*functional
6456 END IF
6457 IF (ALLOCATED(w%v3rho3) ) THEN
6458 third_ratio = (2.0_dp*(dn(2)*dm(2)*dm(2) + &
6459 dn(2)*dm(2)*dm(2) + dn(2)*dm(2)*dm(2)) - &
6460 6.0_dp*ratio*dm(2)*dm(2)*dm(2))/m**3
6461 w%v3rho3(4, point) = ratio*diagonal(2)*diagonal(2)*diagonal(2)* &
6462 w%v3rho3(4, point) + first_ratio(2)*diagonal(2)*diagonal(2)*hessian(2, 2) + &
6463 first_ratio(2)*diagonal(2)*diagonal(2)*hessian(2, 2) + &
6464 first_ratio(2)*diagonal(2)*diagonal(2)*hessian(2, 2) + &
6465 second_ratio(2, 2)*diagonal(2)*gradient(2) + &
6466 second_ratio(2, 2)*diagonal(2)*gradient(2) + &
6467 second_ratio(2, 2)*diagonal(2)*gradient(2) + third_ratio*functional
6468 END IF
6469 IF (ALLOCATED(w%v3rho2sigma) ) THEN
6470 third_ratio = (2.0_dp*(dn(2)*dm(2)*dm(3) + &
6471 dn(2)*dm(2)*dm(3) + dn(3)*dm(2)*dm(2)) - &
6472 6.0_dp*ratio*dm(2)*dm(2)*dm(3))/m**3
6473 w%v3rho2sigma(7, point) = ratio*diagonal(2)*diagonal(2)*diagonal(3)* &
6474 w%v3rho2sigma(7, point) + first_ratio(2)*diagonal(2)*diagonal(3)*hessian(2, 3) + &
6475 first_ratio(2)*diagonal(2)*diagonal(3)*hessian(2, 3) + &
6476 first_ratio(3)*diagonal(2)*diagonal(2)*hessian(2, 2) + &
6477 second_ratio(2, 2)*diagonal(3)*gradient(3) + &
6478 second_ratio(2, 3)*diagonal(2)*gradient(2) + &
6479 second_ratio(2, 3)*diagonal(2)*gradient(2) + third_ratio*functional
6480 END IF
6481 IF (ALLOCATED(w%v3rho2sigma) ) THEN
6482 third_ratio = (2.0_dp*(dn(2)*dm(2)*dm(4) + &
6483 dn(2)*dm(2)*dm(4) + dn(4)*dm(2)*dm(2)) - &
6484 6.0_dp*ratio*dm(2)*dm(2)*dm(4))/m**3
6485 w%v3rho2sigma(8, point) = ratio*diagonal(2)*diagonal(2)*diagonal(4)* &
6486 w%v3rho2sigma(8, point) + first_ratio(2)*diagonal(2)*diagonal(4)*hessian(2, 4) + &
6487 first_ratio(2)*diagonal(2)*diagonal(4)*hessian(2, 4) + &
6488 first_ratio(4)*diagonal(2)*diagonal(2)*hessian(2, 2) + &
6489 second_ratio(2, 2)*diagonal(4)*gradient(4) + &
6490 second_ratio(2, 4)*diagonal(2)*gradient(2) + &
6491 second_ratio(2, 4)*diagonal(2)*gradient(2) + third_ratio*functional
6492 END IF
6493 IF (ALLOCATED(w%v3rho2sigma) ) THEN
6494 third_ratio = (2.0_dp*(dn(2)*dm(2)*dm(5) + &
6495 dn(2)*dm(2)*dm(5) + dn(5)*dm(2)*dm(2)) - &
6496 6.0_dp*ratio*dm(2)*dm(2)*dm(5))/m**3
6497 w%v3rho2sigma(9, point) = ratio*diagonal(2)*diagonal(2)*diagonal(5)* &
6498 w%v3rho2sigma(9, point) + first_ratio(2)*diagonal(2)*diagonal(5)*hessian(2, 5) + &
6499 first_ratio(2)*diagonal(2)*diagonal(5)*hessian(2, 5) + &
6500 first_ratio(5)*diagonal(2)*diagonal(2)*hessian(2, 2) + &
6501 second_ratio(2, 2)*diagonal(5)*gradient(5) + &
6502 second_ratio(2, 5)*diagonal(2)*gradient(2) + &
6503 second_ratio(2, 5)*diagonal(2)*gradient(2) + third_ratio*functional
6504 END IF
6505 IF (ALLOCATED(w%v3rho2lapl) .AND. has_laplace) THEN
6506 third_ratio = (2.0_dp*(dn(2)*dm(2)*dm(6) + &
6507 dn(2)*dm(2)*dm(6) + dn(6)*dm(2)*dm(2)) - &
6508 6.0_dp*ratio*dm(2)*dm(2)*dm(6))/m**3
6509 w%v3rho2lapl(5, point) = ratio*diagonal(2)*diagonal(2)*diagonal(6)* &
6510 w%v3rho2lapl(5, point) + first_ratio(2)*diagonal(2)*diagonal(6)*hessian(2, 6) + &
6511 first_ratio(2)*diagonal(2)*diagonal(6)*hessian(2, 6) + &
6512 first_ratio(6)*diagonal(2)*diagonal(2)*hessian(2, 2) + &
6513 second_ratio(2, 2)*diagonal(6)*gradient(6) + &
6514 second_ratio(2, 6)*diagonal(2)*gradient(2) + &
6515 second_ratio(2, 6)*diagonal(2)*gradient(2) + third_ratio*functional
6516 END IF
6517 IF (ALLOCATED(w%v3rho2lapl) .AND. has_laplace) THEN
6518 third_ratio = (2.0_dp*(dn(2)*dm(2)*dm(7) + &
6519 dn(2)*dm(2)*dm(7) + dn(7)*dm(2)*dm(2)) - &
6520 6.0_dp*ratio*dm(2)*dm(2)*dm(7))/m**3
6521 w%v3rho2lapl(6, point) = ratio*diagonal(2)*diagonal(2)*diagonal(7)* &
6522 w%v3rho2lapl(6, point) + first_ratio(2)*diagonal(2)*diagonal(7)*hessian(2, 7) + &
6523 first_ratio(2)*diagonal(2)*diagonal(7)*hessian(2, 7) + &
6524 first_ratio(7)*diagonal(2)*diagonal(2)*hessian(2, 2) + &
6525 second_ratio(2, 2)*diagonal(7)*gradient(7) + &
6526 second_ratio(2, 7)*diagonal(2)*gradient(2) + &
6527 second_ratio(2, 7)*diagonal(2)*gradient(2) + third_ratio*functional
6528 END IF
6529 IF (ALLOCATED(w%v3rho2tau) ) THEN
6530 third_ratio = (2.0_dp*(dn(2)*dm(2)*dm(8) + &
6531 dn(2)*dm(2)*dm(8) + dn(8)*dm(2)*dm(2)) - &
6532 6.0_dp*ratio*dm(2)*dm(2)*dm(8))/m**3
6533 w%v3rho2tau(5, point) = ratio*diagonal(2)*diagonal(2)*diagonal(8)* &
6534 w%v3rho2tau(5, point) + first_ratio(2)*diagonal(2)*diagonal(8)*hessian(2, 8) + &
6535 first_ratio(2)*diagonal(2)*diagonal(8)*hessian(2, 8) + &
6536 first_ratio(8)*diagonal(2)*diagonal(2)*hessian(2, 2) + &
6537 second_ratio(2, 2)*diagonal(8)*gradient(8) + &
6538 second_ratio(2, 8)*diagonal(2)*gradient(2) + &
6539 second_ratio(2, 8)*diagonal(2)*gradient(2) + third_ratio*functional
6540 END IF
6541 IF (ALLOCATED(w%v3rho2tau) ) THEN
6542 third_ratio = (2.0_dp*(dn(2)*dm(2)*dm(9) + &
6543 dn(2)*dm(2)*dm(9) + dn(9)*dm(2)*dm(2)) - &
6544 6.0_dp*ratio*dm(2)*dm(2)*dm(9))/m**3
6545 w%v3rho2tau(6, point) = ratio*diagonal(2)*diagonal(2)*diagonal(9)* &
6546 w%v3rho2tau(6, point) + first_ratio(2)*diagonal(2)*diagonal(9)*hessian(2, 9) + &
6547 first_ratio(2)*diagonal(2)*diagonal(9)*hessian(2, 9) + &
6548 first_ratio(9)*diagonal(2)*diagonal(2)*hessian(2, 2) + &
6549 second_ratio(2, 2)*diagonal(9)*gradient(9) + &
6550 second_ratio(2, 9)*diagonal(2)*gradient(2) + &
6551 second_ratio(2, 9)*diagonal(2)*gradient(2) + third_ratio*functional
6552 END IF
6553 IF (ALLOCATED(w%v3rhosigma2) ) THEN
6554 third_ratio = (2.0_dp*(dn(2)*dm(3)*dm(3) + &
6555 dn(3)*dm(2)*dm(3) + dn(3)*dm(2)*dm(3)) - &
6556 6.0_dp*ratio*dm(2)*dm(3)*dm(3))/m**3
6557 w%v3rhosigma2(7, point) = ratio*diagonal(2)*diagonal(3)*diagonal(3)* &
6558 w%v3rhosigma2(7, point) + first_ratio(2)*diagonal(3)*diagonal(3)*hessian(3, 3) + &
6559 first_ratio(3)*diagonal(2)*diagonal(3)*hessian(2, 3) + &
6560 first_ratio(3)*diagonal(2)*diagonal(3)*hessian(2, 3) + &
6561 second_ratio(2, 3)*diagonal(3)*gradient(3) + &
6562 second_ratio(2, 3)*diagonal(3)*gradient(3) + &
6563 second_ratio(3, 3)*diagonal(2)*gradient(2) + third_ratio*functional
6564 END IF
6565 IF (ALLOCATED(w%v3rhosigma2) ) THEN
6566 third_ratio = (2.0_dp*(dn(2)*dm(3)*dm(4) + &
6567 dn(3)*dm(2)*dm(4) + dn(4)*dm(2)*dm(3)) - &
6568 6.0_dp*ratio*dm(2)*dm(3)*dm(4))/m**3
6569 w%v3rhosigma2(8, point) = ratio*diagonal(2)*diagonal(3)*diagonal(4)* &
6570 w%v3rhosigma2(8, point) + first_ratio(2)*diagonal(3)*diagonal(4)*hessian(3, 4) + &
6571 first_ratio(3)*diagonal(2)*diagonal(4)*hessian(2, 4) + &
6572 first_ratio(4)*diagonal(2)*diagonal(3)*hessian(2, 3) + &
6573 second_ratio(2, 3)*diagonal(4)*gradient(4) + &
6574 second_ratio(2, 4)*diagonal(3)*gradient(3) + &
6575 second_ratio(3, 4)*diagonal(2)*gradient(2) + third_ratio*functional
6576 END IF
6577 IF (ALLOCATED(w%v3rhosigma2) ) THEN
6578 third_ratio = (2.0_dp*(dn(2)*dm(3)*dm(5) + &
6579 dn(3)*dm(2)*dm(5) + dn(5)*dm(2)*dm(3)) - &
6580 6.0_dp*ratio*dm(2)*dm(3)*dm(5))/m**3
6581 w%v3rhosigma2(9, point) = ratio*diagonal(2)*diagonal(3)*diagonal(5)* &
6582 w%v3rhosigma2(9, point) + first_ratio(2)*diagonal(3)*diagonal(5)*hessian(3, 5) + &
6583 first_ratio(3)*diagonal(2)*diagonal(5)*hessian(2, 5) + &
6584 first_ratio(5)*diagonal(2)*diagonal(3)*hessian(2, 3) + &
6585 second_ratio(2, 3)*diagonal(5)*gradient(5) + &
6586 second_ratio(2, 5)*diagonal(3)*gradient(3) + &
6587 second_ratio(3, 5)*diagonal(2)*gradient(2) + third_ratio*functional
6588 END IF
6589 IF (ALLOCATED(w%v3rhosigmalapl) .AND. has_laplace) THEN
6590 third_ratio = (2.0_dp*(dn(2)*dm(3)*dm(6) + &
6591 dn(3)*dm(2)*dm(6) + dn(6)*dm(2)*dm(3)) - &
6592 6.0_dp*ratio*dm(2)*dm(3)*dm(6))/m**3
6593 w%v3rhosigmalapl(7, point) = ratio*diagonal(2)*diagonal(3)*diagonal(6)* &
6594 w%v3rhosigmalapl(7, point) + first_ratio(2)*diagonal(3)*diagonal(6)*hessian(3, 6) + &
6595 first_ratio(3)*diagonal(2)*diagonal(6)*hessian(2, 6) + &
6596 first_ratio(6)*diagonal(2)*diagonal(3)*hessian(2, 3) + &
6597 second_ratio(2, 3)*diagonal(6)*gradient(6) + &
6598 second_ratio(2, 6)*diagonal(3)*gradient(3) + &
6599 second_ratio(3, 6)*diagonal(2)*gradient(2) + third_ratio*functional
6600 END IF
6601 IF (ALLOCATED(w%v3rhosigmalapl) .AND. has_laplace) THEN
6602 third_ratio = (2.0_dp*(dn(2)*dm(3)*dm(7) + &
6603 dn(3)*dm(2)*dm(7) + dn(7)*dm(2)*dm(3)) - &
6604 6.0_dp*ratio*dm(2)*dm(3)*dm(7))/m**3
6605 w%v3rhosigmalapl(8, point) = ratio*diagonal(2)*diagonal(3)*diagonal(7)* &
6606 w%v3rhosigmalapl(8, point) + first_ratio(2)*diagonal(3)*diagonal(7)*hessian(3, 7) + &
6607 first_ratio(3)*diagonal(2)*diagonal(7)*hessian(2, 7) + &
6608 first_ratio(7)*diagonal(2)*diagonal(3)*hessian(2, 3) + &
6609 second_ratio(2, 3)*diagonal(7)*gradient(7) + &
6610 second_ratio(2, 7)*diagonal(3)*gradient(3) + &
6611 second_ratio(3, 7)*diagonal(2)*gradient(2) + third_ratio*functional
6612 END IF
6613 IF (ALLOCATED(w%v3rhosigmatau) ) THEN
6614 third_ratio = (2.0_dp*(dn(2)*dm(3)*dm(8) + &
6615 dn(3)*dm(2)*dm(8) + dn(8)*dm(2)*dm(3)) - &
6616 6.0_dp*ratio*dm(2)*dm(3)*dm(8))/m**3
6617 w%v3rhosigmatau(7, point) = ratio*diagonal(2)*diagonal(3)*diagonal(8)* &
6618 w%v3rhosigmatau(7, point) + first_ratio(2)*diagonal(3)*diagonal(8)*hessian(3, 8) + &
6619 first_ratio(3)*diagonal(2)*diagonal(8)*hessian(2, 8) + &
6620 first_ratio(8)*diagonal(2)*diagonal(3)*hessian(2, 3) + &
6621 second_ratio(2, 3)*diagonal(8)*gradient(8) + &
6622 second_ratio(2, 8)*diagonal(3)*gradient(3) + &
6623 second_ratio(3, 8)*diagonal(2)*gradient(2) + third_ratio*functional
6624 END IF
6625 IF (ALLOCATED(w%v3rhosigmatau) ) THEN
6626 third_ratio = (2.0_dp*(dn(2)*dm(3)*dm(9) + &
6627 dn(3)*dm(2)*dm(9) + dn(9)*dm(2)*dm(3)) - &
6628 6.0_dp*ratio*dm(2)*dm(3)*dm(9))/m**3
6629 w%v3rhosigmatau(8, point) = ratio*diagonal(2)*diagonal(3)*diagonal(9)* &
6630 w%v3rhosigmatau(8, point) + first_ratio(2)*diagonal(3)*diagonal(9)*hessian(3, 9) + &
6631 first_ratio(3)*diagonal(2)*diagonal(9)*hessian(2, 9) + &
6632 first_ratio(9)*diagonal(2)*diagonal(3)*hessian(2, 3) + &
6633 second_ratio(2, 3)*diagonal(9)*gradient(9) + &
6634 second_ratio(2, 9)*diagonal(3)*gradient(3) + &
6635 second_ratio(3, 9)*diagonal(2)*gradient(2) + third_ratio*functional
6636 END IF
6637 IF (ALLOCATED(w%v3rhosigma2) ) THEN
6638 third_ratio = (2.0_dp*(dn(2)*dm(4)*dm(4) + &
6639 dn(4)*dm(2)*dm(4) + dn(4)*dm(2)*dm(4)) - &
6640 6.0_dp*ratio*dm(2)*dm(4)*dm(4))/m**3
6641 w%v3rhosigma2(10, point) = ratio*diagonal(2)*diagonal(4)*diagonal(4)* &
6642 w%v3rhosigma2(10, point) + first_ratio(2)*diagonal(4)*diagonal(4)*hessian(4, 4) + &
6643 first_ratio(4)*diagonal(2)*diagonal(4)*hessian(2, 4) + &
6644 first_ratio(4)*diagonal(2)*diagonal(4)*hessian(2, 4) + &
6645 second_ratio(2, 4)*diagonal(4)*gradient(4) + &
6646 second_ratio(2, 4)*diagonal(4)*gradient(4) + &
6647 second_ratio(4, 4)*diagonal(2)*gradient(2) + third_ratio*functional
6648 END IF
6649 IF (ALLOCATED(w%v3rhosigma2) ) THEN
6650 third_ratio = (2.0_dp*(dn(2)*dm(4)*dm(5) + &
6651 dn(4)*dm(2)*dm(5) + dn(5)*dm(2)*dm(4)) - &
6652 6.0_dp*ratio*dm(2)*dm(4)*dm(5))/m**3
6653 w%v3rhosigma2(11, point) = ratio*diagonal(2)*diagonal(4)*diagonal(5)* &
6654 w%v3rhosigma2(11, point) + first_ratio(2)*diagonal(4)*diagonal(5)*hessian(4, 5) + &
6655 first_ratio(4)*diagonal(2)*diagonal(5)*hessian(2, 5) + &
6656 first_ratio(5)*diagonal(2)*diagonal(4)*hessian(2, 4) + &
6657 second_ratio(2, 4)*diagonal(5)*gradient(5) + &
6658 second_ratio(2, 5)*diagonal(4)*gradient(4) + &
6659 second_ratio(4, 5)*diagonal(2)*gradient(2) + third_ratio*functional
6660 END IF
6661 IF (ALLOCATED(w%v3rhosigmalapl) .AND. has_laplace) THEN
6662 third_ratio = (2.0_dp*(dn(2)*dm(4)*dm(6) + &
6663 dn(4)*dm(2)*dm(6) + dn(6)*dm(2)*dm(4)) - &
6664 6.0_dp*ratio*dm(2)*dm(4)*dm(6))/m**3
6665 w%v3rhosigmalapl(9, point) = ratio*diagonal(2)*diagonal(4)*diagonal(6)* &
6666 w%v3rhosigmalapl(9, point) + first_ratio(2)*diagonal(4)*diagonal(6)*hessian(4, 6) + &
6667 first_ratio(4)*diagonal(2)*diagonal(6)*hessian(2, 6) + &
6668 first_ratio(6)*diagonal(2)*diagonal(4)*hessian(2, 4) + &
6669 second_ratio(2, 4)*diagonal(6)*gradient(6) + &
6670 second_ratio(2, 6)*diagonal(4)*gradient(4) + &
6671 second_ratio(4, 6)*diagonal(2)*gradient(2) + third_ratio*functional
6672 END IF
6673 IF (ALLOCATED(w%v3rhosigmalapl) .AND. has_laplace) THEN
6674 third_ratio = (2.0_dp*(dn(2)*dm(4)*dm(7) + &
6675 dn(4)*dm(2)*dm(7) + dn(7)*dm(2)*dm(4)) - &
6676 6.0_dp*ratio*dm(2)*dm(4)*dm(7))/m**3
6677 w%v3rhosigmalapl(10, point) = ratio*diagonal(2)*diagonal(4)*diagonal(7)* &
6678 w%v3rhosigmalapl(10, point) + first_ratio(2)*diagonal(4)*diagonal(7)*hessian(4, 7) + &
6679 first_ratio(4)*diagonal(2)*diagonal(7)*hessian(2, 7) + &
6680 first_ratio(7)*diagonal(2)*diagonal(4)*hessian(2, 4) + &
6681 second_ratio(2, 4)*diagonal(7)*gradient(7) + &
6682 second_ratio(2, 7)*diagonal(4)*gradient(4) + &
6683 second_ratio(4, 7)*diagonal(2)*gradient(2) + third_ratio*functional
6684 END IF
6685 IF (ALLOCATED(w%v3rhosigmatau) ) THEN
6686 third_ratio = (2.0_dp*(dn(2)*dm(4)*dm(8) + &
6687 dn(4)*dm(2)*dm(8) + dn(8)*dm(2)*dm(4)) - &
6688 6.0_dp*ratio*dm(2)*dm(4)*dm(8))/m**3
6689 w%v3rhosigmatau(9, point) = ratio*diagonal(2)*diagonal(4)*diagonal(8)* &
6690 w%v3rhosigmatau(9, point) + first_ratio(2)*diagonal(4)*diagonal(8)*hessian(4, 8) + &
6691 first_ratio(4)*diagonal(2)*diagonal(8)*hessian(2, 8) + &
6692 first_ratio(8)*diagonal(2)*diagonal(4)*hessian(2, 4) + &
6693 second_ratio(2, 4)*diagonal(8)*gradient(8) + &
6694 second_ratio(2, 8)*diagonal(4)*gradient(4) + &
6695 second_ratio(4, 8)*diagonal(2)*gradient(2) + third_ratio*functional
6696 END IF
6697 IF (ALLOCATED(w%v3rhosigmatau) ) THEN
6698 third_ratio = (2.0_dp*(dn(2)*dm(4)*dm(9) + &
6699 dn(4)*dm(2)*dm(9) + dn(9)*dm(2)*dm(4)) - &
6700 6.0_dp*ratio*dm(2)*dm(4)*dm(9))/m**3
6701 w%v3rhosigmatau(10, point) = ratio*diagonal(2)*diagonal(4)*diagonal(9)* &
6702 w%v3rhosigmatau(10, point) + first_ratio(2)*diagonal(4)*diagonal(9)*hessian(4, 9) + &
6703 first_ratio(4)*diagonal(2)*diagonal(9)*hessian(2, 9) + &
6704 first_ratio(9)*diagonal(2)*diagonal(4)*hessian(2, 4) + &
6705 second_ratio(2, 4)*diagonal(9)*gradient(9) + &
6706 second_ratio(2, 9)*diagonal(4)*gradient(4) + &
6707 second_ratio(4, 9)*diagonal(2)*gradient(2) + third_ratio*functional
6708 END IF
6709 IF (ALLOCATED(w%v3rhosigma2) ) THEN
6710 third_ratio = (2.0_dp*(dn(2)*dm(5)*dm(5) + &
6711 dn(5)*dm(2)*dm(5) + dn(5)*dm(2)*dm(5)) - &
6712 6.0_dp*ratio*dm(2)*dm(5)*dm(5))/m**3
6713 w%v3rhosigma2(12, point) = ratio*diagonal(2)*diagonal(5)*diagonal(5)* &
6714 w%v3rhosigma2(12, point) + first_ratio(2)*diagonal(5)*diagonal(5)*hessian(5, 5) + &
6715 first_ratio(5)*diagonal(2)*diagonal(5)*hessian(2, 5) + &
6716 first_ratio(5)*diagonal(2)*diagonal(5)*hessian(2, 5) + &
6717 second_ratio(2, 5)*diagonal(5)*gradient(5) + &
6718 second_ratio(2, 5)*diagonal(5)*gradient(5) + &
6719 second_ratio(5, 5)*diagonal(2)*gradient(2) + third_ratio*functional
6720 END IF
6721 IF (ALLOCATED(w%v3rhosigmalapl) .AND. has_laplace) THEN
6722 third_ratio = (2.0_dp*(dn(2)*dm(5)*dm(6) + &
6723 dn(5)*dm(2)*dm(6) + dn(6)*dm(2)*dm(5)) - &
6724 6.0_dp*ratio*dm(2)*dm(5)*dm(6))/m**3
6725 w%v3rhosigmalapl(11, point) = ratio*diagonal(2)*diagonal(5)*diagonal(6)* &
6726 w%v3rhosigmalapl(11, point) + first_ratio(2)*diagonal(5)*diagonal(6)*hessian(5, 6) + &
6727 first_ratio(5)*diagonal(2)*diagonal(6)*hessian(2, 6) + &
6728 first_ratio(6)*diagonal(2)*diagonal(5)*hessian(2, 5) + &
6729 second_ratio(2, 5)*diagonal(6)*gradient(6) + &
6730 second_ratio(2, 6)*diagonal(5)*gradient(5) + &
6731 second_ratio(5, 6)*diagonal(2)*gradient(2) + third_ratio*functional
6732 END IF
6733 IF (ALLOCATED(w%v3rhosigmalapl) .AND. has_laplace) THEN
6734 third_ratio = (2.0_dp*(dn(2)*dm(5)*dm(7) + &
6735 dn(5)*dm(2)*dm(7) + dn(7)*dm(2)*dm(5)) - &
6736 6.0_dp*ratio*dm(2)*dm(5)*dm(7))/m**3
6737 w%v3rhosigmalapl(12, point) = ratio*diagonal(2)*diagonal(5)*diagonal(7)* &
6738 w%v3rhosigmalapl(12, point) + first_ratio(2)*diagonal(5)*diagonal(7)*hessian(5, 7) + &
6739 first_ratio(5)*diagonal(2)*diagonal(7)*hessian(2, 7) + &
6740 first_ratio(7)*diagonal(2)*diagonal(5)*hessian(2, 5) + &
6741 second_ratio(2, 5)*diagonal(7)*gradient(7) + &
6742 second_ratio(2, 7)*diagonal(5)*gradient(5) + &
6743 second_ratio(5, 7)*diagonal(2)*gradient(2) + third_ratio*functional
6744 END IF
6745 IF (ALLOCATED(w%v3rhosigmatau) ) THEN
6746 third_ratio = (2.0_dp*(dn(2)*dm(5)*dm(8) + &
6747 dn(5)*dm(2)*dm(8) + dn(8)*dm(2)*dm(5)) - &
6748 6.0_dp*ratio*dm(2)*dm(5)*dm(8))/m**3
6749 w%v3rhosigmatau(11, point) = ratio*diagonal(2)*diagonal(5)*diagonal(8)* &
6750 w%v3rhosigmatau(11, point) + first_ratio(2)*diagonal(5)*diagonal(8)*hessian(5, 8) + &
6751 first_ratio(5)*diagonal(2)*diagonal(8)*hessian(2, 8) + &
6752 first_ratio(8)*diagonal(2)*diagonal(5)*hessian(2, 5) + &
6753 second_ratio(2, 5)*diagonal(8)*gradient(8) + &
6754 second_ratio(2, 8)*diagonal(5)*gradient(5) + &
6755 second_ratio(5, 8)*diagonal(2)*gradient(2) + third_ratio*functional
6756 END IF
6757 IF (ALLOCATED(w%v3rhosigmatau) ) THEN
6758 third_ratio = (2.0_dp*(dn(2)*dm(5)*dm(9) + &
6759 dn(5)*dm(2)*dm(9) + dn(9)*dm(2)*dm(5)) - &
6760 6.0_dp*ratio*dm(2)*dm(5)*dm(9))/m**3
6761 w%v3rhosigmatau(12, point) = ratio*diagonal(2)*diagonal(5)*diagonal(9)* &
6762 w%v3rhosigmatau(12, point) + first_ratio(2)*diagonal(5)*diagonal(9)*hessian(5, 9) + &
6763 first_ratio(5)*diagonal(2)*diagonal(9)*hessian(2, 9) + &
6764 first_ratio(9)*diagonal(2)*diagonal(5)*hessian(2, 5) + &
6765 second_ratio(2, 5)*diagonal(9)*gradient(9) + &
6766 second_ratio(2, 9)*diagonal(5)*gradient(5) + &
6767 second_ratio(5, 9)*diagonal(2)*gradient(2) + third_ratio*functional
6768 END IF
6769 IF (ALLOCATED(w%v3rholapl2) .AND. has_laplace) THEN
6770 third_ratio = (2.0_dp*(dn(2)*dm(6)*dm(6) + &
6771 dn(6)*dm(2)*dm(6) + dn(6)*dm(2)*dm(6)) - &
6772 6.0_dp*ratio*dm(2)*dm(6)*dm(6))/m**3
6773 w%v3rholapl2(4, point) = ratio*diagonal(2)*diagonal(6)*diagonal(6)* &
6774 w%v3rholapl2(4, point) + first_ratio(2)*diagonal(6)*diagonal(6)*hessian(6, 6) + &
6775 first_ratio(6)*diagonal(2)*diagonal(6)*hessian(2, 6) + &
6776 first_ratio(6)*diagonal(2)*diagonal(6)*hessian(2, 6) + &
6777 second_ratio(2, 6)*diagonal(6)*gradient(6) + &
6778 second_ratio(2, 6)*diagonal(6)*gradient(6) + &
6779 second_ratio(6, 6)*diagonal(2)*gradient(2) + third_ratio*functional
6780 END IF
6781 IF (ALLOCATED(w%v3rholapl2) .AND. has_laplace) THEN
6782 third_ratio = (2.0_dp*(dn(2)*dm(6)*dm(7) + &
6783 dn(6)*dm(2)*dm(7) + dn(7)*dm(2)*dm(6)) - &
6784 6.0_dp*ratio*dm(2)*dm(6)*dm(7))/m**3
6785 w%v3rholapl2(5, point) = ratio*diagonal(2)*diagonal(6)*diagonal(7)* &
6786 w%v3rholapl2(5, point) + first_ratio(2)*diagonal(6)*diagonal(7)*hessian(6, 7) + &
6787 first_ratio(6)*diagonal(2)*diagonal(7)*hessian(2, 7) + &
6788 first_ratio(7)*diagonal(2)*diagonal(6)*hessian(2, 6) + &
6789 second_ratio(2, 6)*diagonal(7)*gradient(7) + &
6790 second_ratio(2, 7)*diagonal(6)*gradient(6) + &
6791 second_ratio(6, 7)*diagonal(2)*gradient(2) + third_ratio*functional
6792 END IF
6793 IF (ALLOCATED(w%v3rholapltau) .AND. has_laplace) THEN
6794 third_ratio = (2.0_dp*(dn(2)*dm(6)*dm(8) + &
6795 dn(6)*dm(2)*dm(8) + dn(8)*dm(2)*dm(6)) - &
6796 6.0_dp*ratio*dm(2)*dm(6)*dm(8))/m**3
6797 w%v3rholapltau(5, point) = ratio*diagonal(2)*diagonal(6)*diagonal(8)* &
6798 w%v3rholapltau(5, point) + first_ratio(2)*diagonal(6)*diagonal(8)*hessian(6, 8) + &
6799 first_ratio(6)*diagonal(2)*diagonal(8)*hessian(2, 8) + &
6800 first_ratio(8)*diagonal(2)*diagonal(6)*hessian(2, 6) + &
6801 second_ratio(2, 6)*diagonal(8)*gradient(8) + &
6802 second_ratio(2, 8)*diagonal(6)*gradient(6) + &
6803 second_ratio(6, 8)*diagonal(2)*gradient(2) + third_ratio*functional
6804 END IF
6805 IF (ALLOCATED(w%v3rholapltau) .AND. has_laplace) THEN
6806 third_ratio = (2.0_dp*(dn(2)*dm(6)*dm(9) + &
6807 dn(6)*dm(2)*dm(9) + dn(9)*dm(2)*dm(6)) - &
6808 6.0_dp*ratio*dm(2)*dm(6)*dm(9))/m**3
6809 w%v3rholapltau(6, point) = ratio*diagonal(2)*diagonal(6)*diagonal(9)* &
6810 w%v3rholapltau(6, point) + first_ratio(2)*diagonal(6)*diagonal(9)*hessian(6, 9) + &
6811 first_ratio(6)*diagonal(2)*diagonal(9)*hessian(2, 9) + &
6812 first_ratio(9)*diagonal(2)*diagonal(6)*hessian(2, 6) + &
6813 second_ratio(2, 6)*diagonal(9)*gradient(9) + &
6814 second_ratio(2, 9)*diagonal(6)*gradient(6) + &
6815 second_ratio(6, 9)*diagonal(2)*gradient(2) + third_ratio*functional
6816 END IF
6817 IF (ALLOCATED(w%v3rholapl2) .AND. has_laplace) THEN
6818 third_ratio = (2.0_dp*(dn(2)*dm(7)*dm(7) + &
6819 dn(7)*dm(2)*dm(7) + dn(7)*dm(2)*dm(7)) - &
6820 6.0_dp*ratio*dm(2)*dm(7)*dm(7))/m**3
6821 w%v3rholapl2(6, point) = ratio*diagonal(2)*diagonal(7)*diagonal(7)* &
6822 w%v3rholapl2(6, point) + first_ratio(2)*diagonal(7)*diagonal(7)*hessian(7, 7) + &
6823 first_ratio(7)*diagonal(2)*diagonal(7)*hessian(2, 7) + &
6824 first_ratio(7)*diagonal(2)*diagonal(7)*hessian(2, 7) + &
6825 second_ratio(2, 7)*diagonal(7)*gradient(7) + &
6826 second_ratio(2, 7)*diagonal(7)*gradient(7) + &
6827 second_ratio(7, 7)*diagonal(2)*gradient(2) + third_ratio*functional
6828 END IF
6829 IF (ALLOCATED(w%v3rholapltau) .AND. has_laplace) THEN
6830 third_ratio = (2.0_dp*(dn(2)*dm(7)*dm(8) + &
6831 dn(7)*dm(2)*dm(8) + dn(8)*dm(2)*dm(7)) - &
6832 6.0_dp*ratio*dm(2)*dm(7)*dm(8))/m**3
6833 w%v3rholapltau(7, point) = ratio*diagonal(2)*diagonal(7)*diagonal(8)* &
6834 w%v3rholapltau(7, point) + first_ratio(2)*diagonal(7)*diagonal(8)*hessian(7, 8) + &
6835 first_ratio(7)*diagonal(2)*diagonal(8)*hessian(2, 8) + &
6836 first_ratio(8)*diagonal(2)*diagonal(7)*hessian(2, 7) + &
6837 second_ratio(2, 7)*diagonal(8)*gradient(8) + &
6838 second_ratio(2, 8)*diagonal(7)*gradient(7) + &
6839 second_ratio(7, 8)*diagonal(2)*gradient(2) + third_ratio*functional
6840 END IF
6841 IF (ALLOCATED(w%v3rholapltau) .AND. has_laplace) THEN
6842 third_ratio = (2.0_dp*(dn(2)*dm(7)*dm(9) + &
6843 dn(7)*dm(2)*dm(9) + dn(9)*dm(2)*dm(7)) - &
6844 6.0_dp*ratio*dm(2)*dm(7)*dm(9))/m**3
6845 w%v3rholapltau(8, point) = ratio*diagonal(2)*diagonal(7)*diagonal(9)* &
6846 w%v3rholapltau(8, point) + first_ratio(2)*diagonal(7)*diagonal(9)*hessian(7, 9) + &
6847 first_ratio(7)*diagonal(2)*diagonal(9)*hessian(2, 9) + &
6848 first_ratio(9)*diagonal(2)*diagonal(7)*hessian(2, 7) + &
6849 second_ratio(2, 7)*diagonal(9)*gradient(9) + &
6850 second_ratio(2, 9)*diagonal(7)*gradient(7) + &
6851 second_ratio(7, 9)*diagonal(2)*gradient(2) + third_ratio*functional
6852 END IF
6853 IF (ALLOCATED(w%v3rhotau2) ) THEN
6854 third_ratio = (2.0_dp*(dn(2)*dm(8)*dm(8) + &
6855 dn(8)*dm(2)*dm(8) + dn(8)*dm(2)*dm(8)) - &
6856 6.0_dp*ratio*dm(2)*dm(8)*dm(8))/m**3
6857 w%v3rhotau2(4, point) = ratio*diagonal(2)*diagonal(8)*diagonal(8)* &
6858 w%v3rhotau2(4, point) + first_ratio(2)*diagonal(8)*diagonal(8)*hessian(8, 8) + &
6859 first_ratio(8)*diagonal(2)*diagonal(8)*hessian(2, 8) + &
6860 first_ratio(8)*diagonal(2)*diagonal(8)*hessian(2, 8) + &
6861 second_ratio(2, 8)*diagonal(8)*gradient(8) + &
6862 second_ratio(2, 8)*diagonal(8)*gradient(8) + &
6863 second_ratio(8, 8)*diagonal(2)*gradient(2) + third_ratio*functional
6864 END IF
6865 IF (ALLOCATED(w%v3rhotau2) ) THEN
6866 third_ratio = (2.0_dp*(dn(2)*dm(8)*dm(9) + &
6867 dn(8)*dm(2)*dm(9) + dn(9)*dm(2)*dm(8)) - &
6868 6.0_dp*ratio*dm(2)*dm(8)*dm(9))/m**3
6869 w%v3rhotau2(5, point) = ratio*diagonal(2)*diagonal(8)*diagonal(9)* &
6870 w%v3rhotau2(5, point) + first_ratio(2)*diagonal(8)*diagonal(9)*hessian(8, 9) + &
6871 first_ratio(8)*diagonal(2)*diagonal(9)*hessian(2, 9) + &
6872 first_ratio(9)*diagonal(2)*diagonal(8)*hessian(2, 8) + &
6873 second_ratio(2, 8)*diagonal(9)*gradient(9) + &
6874 second_ratio(2, 9)*diagonal(8)*gradient(8) + &
6875 second_ratio(8, 9)*diagonal(2)*gradient(2) + third_ratio*functional
6876 END IF
6877 IF (ALLOCATED(w%v3rhotau2) ) THEN
6878 third_ratio = (2.0_dp*(dn(2)*dm(9)*dm(9) + &
6879 dn(9)*dm(2)*dm(9) + dn(9)*dm(2)*dm(9)) - &
6880 6.0_dp*ratio*dm(2)*dm(9)*dm(9))/m**3
6881 w%v3rhotau2(6, point) = ratio*diagonal(2)*diagonal(9)*diagonal(9)* &
6882 w%v3rhotau2(6, point) + first_ratio(2)*diagonal(9)*diagonal(9)*hessian(9, 9) + &
6883 first_ratio(9)*diagonal(2)*diagonal(9)*hessian(2, 9) + &
6884 first_ratio(9)*diagonal(2)*diagonal(9)*hessian(2, 9) + &
6885 second_ratio(2, 9)*diagonal(9)*gradient(9) + &
6886 second_ratio(2, 9)*diagonal(9)*gradient(9) + &
6887 second_ratio(9, 9)*diagonal(2)*gradient(2) + third_ratio*functional
6888 END IF
6889 IF (ALLOCATED(w%v3sigma3) ) THEN
6890 third_ratio = (2.0_dp*(dn(3)*dm(3)*dm(3) + &
6891 dn(3)*dm(3)*dm(3) + dn(3)*dm(3)*dm(3)) - &
6892 6.0_dp*ratio*dm(3)*dm(3)*dm(3))/m**3
6893 w%v3sigma3(1, point) = ratio*diagonal(3)*diagonal(3)*diagonal(3)* &
6894 w%v3sigma3(1, point) + first_ratio(3)*diagonal(3)*diagonal(3)*hessian(3, 3) + &
6895 first_ratio(3)*diagonal(3)*diagonal(3)*hessian(3, 3) + &
6896 first_ratio(3)*diagonal(3)*diagonal(3)*hessian(3, 3) + &
6897 second_ratio(3, 3)*diagonal(3)*gradient(3) + &
6898 second_ratio(3, 3)*diagonal(3)*gradient(3) + &
6899 second_ratio(3, 3)*diagonal(3)*gradient(3) + third_ratio*functional
6900 END IF
6901 IF (ALLOCATED(w%v3sigma3) ) THEN
6902 third_ratio = (2.0_dp*(dn(3)*dm(3)*dm(4) + &
6903 dn(3)*dm(3)*dm(4) + dn(4)*dm(3)*dm(3)) - &
6904 6.0_dp*ratio*dm(3)*dm(3)*dm(4))/m**3
6905 w%v3sigma3(2, point) = ratio*diagonal(3)*diagonal(3)*diagonal(4)* &
6906 w%v3sigma3(2, point) + first_ratio(3)*diagonal(3)*diagonal(4)*hessian(3, 4) + &
6907 first_ratio(3)*diagonal(3)*diagonal(4)*hessian(3, 4) + &
6908 first_ratio(4)*diagonal(3)*diagonal(3)*hessian(3, 3) + &
6909 second_ratio(3, 3)*diagonal(4)*gradient(4) + &
6910 second_ratio(3, 4)*diagonal(3)*gradient(3) + &
6911 second_ratio(3, 4)*diagonal(3)*gradient(3) + third_ratio*functional
6912 END IF
6913 IF (ALLOCATED(w%v3sigma3) ) THEN
6914 third_ratio = (2.0_dp*(dn(3)*dm(3)*dm(5) + &
6915 dn(3)*dm(3)*dm(5) + dn(5)*dm(3)*dm(3)) - &
6916 6.0_dp*ratio*dm(3)*dm(3)*dm(5))/m**3
6917 w%v3sigma3(3, point) = ratio*diagonal(3)*diagonal(3)*diagonal(5)* &
6918 w%v3sigma3(3, point) + first_ratio(3)*diagonal(3)*diagonal(5)*hessian(3, 5) + &
6919 first_ratio(3)*diagonal(3)*diagonal(5)*hessian(3, 5) + &
6920 first_ratio(5)*diagonal(3)*diagonal(3)*hessian(3, 3) + &
6921 second_ratio(3, 3)*diagonal(5)*gradient(5) + &
6922 second_ratio(3, 5)*diagonal(3)*gradient(3) + &
6923 second_ratio(3, 5)*diagonal(3)*gradient(3) + third_ratio*functional
6924 END IF
6925 IF (ALLOCATED(w%v3sigma2lapl) .AND. has_laplace) THEN
6926 third_ratio = (2.0_dp*(dn(3)*dm(3)*dm(6) + &
6927 dn(3)*dm(3)*dm(6) + dn(6)*dm(3)*dm(3)) - &
6928 6.0_dp*ratio*dm(3)*dm(3)*dm(6))/m**3
6929 w%v3sigma2lapl(1, point) = ratio*diagonal(3)*diagonal(3)*diagonal(6)* &
6930 w%v3sigma2lapl(1, point) + first_ratio(3)*diagonal(3)*diagonal(6)*hessian(3, 6) + &
6931 first_ratio(3)*diagonal(3)*diagonal(6)*hessian(3, 6) + &
6932 first_ratio(6)*diagonal(3)*diagonal(3)*hessian(3, 3) + &
6933 second_ratio(3, 3)*diagonal(6)*gradient(6) + &
6934 second_ratio(3, 6)*diagonal(3)*gradient(3) + &
6935 second_ratio(3, 6)*diagonal(3)*gradient(3) + third_ratio*functional
6936 END IF
6937 IF (ALLOCATED(w%v3sigma2lapl) .AND. has_laplace) THEN
6938 third_ratio = (2.0_dp*(dn(3)*dm(3)*dm(7) + &
6939 dn(3)*dm(3)*dm(7) + dn(7)*dm(3)*dm(3)) - &
6940 6.0_dp*ratio*dm(3)*dm(3)*dm(7))/m**3
6941 w%v3sigma2lapl(2, point) = ratio*diagonal(3)*diagonal(3)*diagonal(7)* &
6942 w%v3sigma2lapl(2, point) + first_ratio(3)*diagonal(3)*diagonal(7)*hessian(3, 7) + &
6943 first_ratio(3)*diagonal(3)*diagonal(7)*hessian(3, 7) + &
6944 first_ratio(7)*diagonal(3)*diagonal(3)*hessian(3, 3) + &
6945 second_ratio(3, 3)*diagonal(7)*gradient(7) + &
6946 second_ratio(3, 7)*diagonal(3)*gradient(3) + &
6947 second_ratio(3, 7)*diagonal(3)*gradient(3) + third_ratio*functional
6948 END IF
6949 IF (ALLOCATED(w%v3sigma2tau) ) THEN
6950 third_ratio = (2.0_dp*(dn(3)*dm(3)*dm(8) + &
6951 dn(3)*dm(3)*dm(8) + dn(8)*dm(3)*dm(3)) - &
6952 6.0_dp*ratio*dm(3)*dm(3)*dm(8))/m**3
6953 w%v3sigma2tau(1, point) = ratio*diagonal(3)*diagonal(3)*diagonal(8)* &
6954 w%v3sigma2tau(1, point) + first_ratio(3)*diagonal(3)*diagonal(8)*hessian(3, 8) + &
6955 first_ratio(3)*diagonal(3)*diagonal(8)*hessian(3, 8) + &
6956 first_ratio(8)*diagonal(3)*diagonal(3)*hessian(3, 3) + &
6957 second_ratio(3, 3)*diagonal(8)*gradient(8) + &
6958 second_ratio(3, 8)*diagonal(3)*gradient(3) + &
6959 second_ratio(3, 8)*diagonal(3)*gradient(3) + third_ratio*functional
6960 END IF
6961 IF (ALLOCATED(w%v3sigma2tau) ) THEN
6962 third_ratio = (2.0_dp*(dn(3)*dm(3)*dm(9) + &
6963 dn(3)*dm(3)*dm(9) + dn(9)*dm(3)*dm(3)) - &
6964 6.0_dp*ratio*dm(3)*dm(3)*dm(9))/m**3
6965 w%v3sigma2tau(2, point) = ratio*diagonal(3)*diagonal(3)*diagonal(9)* &
6966 w%v3sigma2tau(2, point) + first_ratio(3)*diagonal(3)*diagonal(9)*hessian(3, 9) + &
6967 first_ratio(3)*diagonal(3)*diagonal(9)*hessian(3, 9) + &
6968 first_ratio(9)*diagonal(3)*diagonal(3)*hessian(3, 3) + &
6969 second_ratio(3, 3)*diagonal(9)*gradient(9) + &
6970 second_ratio(3, 9)*diagonal(3)*gradient(3) + &
6971 second_ratio(3, 9)*diagonal(3)*gradient(3) + third_ratio*functional
6972 END IF
6973 IF (ALLOCATED(w%v3sigma3) ) THEN
6974 third_ratio = (2.0_dp*(dn(3)*dm(4)*dm(4) + &
6975 dn(4)*dm(3)*dm(4) + dn(4)*dm(3)*dm(4)) - &
6976 6.0_dp*ratio*dm(3)*dm(4)*dm(4))/m**3
6977 w%v3sigma3(4, point) = ratio*diagonal(3)*diagonal(4)*diagonal(4)* &
6978 w%v3sigma3(4, point) + first_ratio(3)*diagonal(4)*diagonal(4)*hessian(4, 4) + &
6979 first_ratio(4)*diagonal(3)*diagonal(4)*hessian(3, 4) + &
6980 first_ratio(4)*diagonal(3)*diagonal(4)*hessian(3, 4) + &
6981 second_ratio(3, 4)*diagonal(4)*gradient(4) + &
6982 second_ratio(3, 4)*diagonal(4)*gradient(4) + &
6983 second_ratio(4, 4)*diagonal(3)*gradient(3) + third_ratio*functional
6984 END IF
6985 IF (ALLOCATED(w%v3sigma3) ) THEN
6986 third_ratio = (2.0_dp*(dn(3)*dm(4)*dm(5) + &
6987 dn(4)*dm(3)*dm(5) + dn(5)*dm(3)*dm(4)) - &
6988 6.0_dp*ratio*dm(3)*dm(4)*dm(5))/m**3
6989 w%v3sigma3(5, point) = ratio*diagonal(3)*diagonal(4)*diagonal(5)* &
6990 w%v3sigma3(5, point) + first_ratio(3)*diagonal(4)*diagonal(5)*hessian(4, 5) + &
6991 first_ratio(4)*diagonal(3)*diagonal(5)*hessian(3, 5) + &
6992 first_ratio(5)*diagonal(3)*diagonal(4)*hessian(3, 4) + &
6993 second_ratio(3, 4)*diagonal(5)*gradient(5) + &
6994 second_ratio(3, 5)*diagonal(4)*gradient(4) + &
6995 second_ratio(4, 5)*diagonal(3)*gradient(3) + third_ratio*functional
6996 END IF
6997 IF (ALLOCATED(w%v3sigma2lapl) .AND. has_laplace) THEN
6998 third_ratio = (2.0_dp*(dn(3)*dm(4)*dm(6) + &
6999 dn(4)*dm(3)*dm(6) + dn(6)*dm(3)*dm(4)) - &
7000 6.0_dp*ratio*dm(3)*dm(4)*dm(6))/m**3
7001 w%v3sigma2lapl(3, point) = ratio*diagonal(3)*diagonal(4)*diagonal(6)* &
7002 w%v3sigma2lapl(3, point) + first_ratio(3)*diagonal(4)*diagonal(6)*hessian(4, 6) + &
7003 first_ratio(4)*diagonal(3)*diagonal(6)*hessian(3, 6) + &
7004 first_ratio(6)*diagonal(3)*diagonal(4)*hessian(3, 4) + &
7005 second_ratio(3, 4)*diagonal(6)*gradient(6) + &
7006 second_ratio(3, 6)*diagonal(4)*gradient(4) + &
7007 second_ratio(4, 6)*diagonal(3)*gradient(3) + third_ratio*functional
7008 END IF
7009 IF (ALLOCATED(w%v3sigma2lapl) .AND. has_laplace) THEN
7010 third_ratio = (2.0_dp*(dn(3)*dm(4)*dm(7) + &
7011 dn(4)*dm(3)*dm(7) + dn(7)*dm(3)*dm(4)) - &
7012 6.0_dp*ratio*dm(3)*dm(4)*dm(7))/m**3
7013 w%v3sigma2lapl(4, point) = ratio*diagonal(3)*diagonal(4)*diagonal(7)* &
7014 w%v3sigma2lapl(4, point) + first_ratio(3)*diagonal(4)*diagonal(7)*hessian(4, 7) + &
7015 first_ratio(4)*diagonal(3)*diagonal(7)*hessian(3, 7) + &
7016 first_ratio(7)*diagonal(3)*diagonal(4)*hessian(3, 4) + &
7017 second_ratio(3, 4)*diagonal(7)*gradient(7) + &
7018 second_ratio(3, 7)*diagonal(4)*gradient(4) + &
7019 second_ratio(4, 7)*diagonal(3)*gradient(3) + third_ratio*functional
7020 END IF
7021 IF (ALLOCATED(w%v3sigma2tau) ) THEN
7022 third_ratio = (2.0_dp*(dn(3)*dm(4)*dm(8) + &
7023 dn(4)*dm(3)*dm(8) + dn(8)*dm(3)*dm(4)) - &
7024 6.0_dp*ratio*dm(3)*dm(4)*dm(8))/m**3
7025 w%v3sigma2tau(3, point) = ratio*diagonal(3)*diagonal(4)*diagonal(8)* &
7026 w%v3sigma2tau(3, point) + first_ratio(3)*diagonal(4)*diagonal(8)*hessian(4, 8) + &
7027 first_ratio(4)*diagonal(3)*diagonal(8)*hessian(3, 8) + &
7028 first_ratio(8)*diagonal(3)*diagonal(4)*hessian(3, 4) + &
7029 second_ratio(3, 4)*diagonal(8)*gradient(8) + &
7030 second_ratio(3, 8)*diagonal(4)*gradient(4) + &
7031 second_ratio(4, 8)*diagonal(3)*gradient(3) + third_ratio*functional
7032 END IF
7033 IF (ALLOCATED(w%v3sigma2tau) ) THEN
7034 third_ratio = (2.0_dp*(dn(3)*dm(4)*dm(9) + &
7035 dn(4)*dm(3)*dm(9) + dn(9)*dm(3)*dm(4)) - &
7036 6.0_dp*ratio*dm(3)*dm(4)*dm(9))/m**3
7037 w%v3sigma2tau(4, point) = ratio*diagonal(3)*diagonal(4)*diagonal(9)* &
7038 w%v3sigma2tau(4, point) + first_ratio(3)*diagonal(4)*diagonal(9)*hessian(4, 9) + &
7039 first_ratio(4)*diagonal(3)*diagonal(9)*hessian(3, 9) + &
7040 first_ratio(9)*diagonal(3)*diagonal(4)*hessian(3, 4) + &
7041 second_ratio(3, 4)*diagonal(9)*gradient(9) + &
7042 second_ratio(3, 9)*diagonal(4)*gradient(4) + &
7043 second_ratio(4, 9)*diagonal(3)*gradient(3) + third_ratio*functional
7044 END IF
7045 IF (ALLOCATED(w%v3sigma3) ) THEN
7046 third_ratio = (2.0_dp*(dn(3)*dm(5)*dm(5) + &
7047 dn(5)*dm(3)*dm(5) + dn(5)*dm(3)*dm(5)) - &
7048 6.0_dp*ratio*dm(3)*dm(5)*dm(5))/m**3
7049 w%v3sigma3(6, point) = ratio*diagonal(3)*diagonal(5)*diagonal(5)* &
7050 w%v3sigma3(6, point) + first_ratio(3)*diagonal(5)*diagonal(5)*hessian(5, 5) + &
7051 first_ratio(5)*diagonal(3)*diagonal(5)*hessian(3, 5) + &
7052 first_ratio(5)*diagonal(3)*diagonal(5)*hessian(3, 5) + &
7053 second_ratio(3, 5)*diagonal(5)*gradient(5) + &
7054 second_ratio(3, 5)*diagonal(5)*gradient(5) + &
7055 second_ratio(5, 5)*diagonal(3)*gradient(3) + third_ratio*functional
7056 END IF
7057 IF (ALLOCATED(w%v3sigma2lapl) .AND. has_laplace) THEN
7058 third_ratio = (2.0_dp*(dn(3)*dm(5)*dm(6) + &
7059 dn(5)*dm(3)*dm(6) + dn(6)*dm(3)*dm(5)) - &
7060 6.0_dp*ratio*dm(3)*dm(5)*dm(6))/m**3
7061 w%v3sigma2lapl(5, point) = ratio*diagonal(3)*diagonal(5)*diagonal(6)* &
7062 w%v3sigma2lapl(5, point) + first_ratio(3)*diagonal(5)*diagonal(6)*hessian(5, 6) + &
7063 first_ratio(5)*diagonal(3)*diagonal(6)*hessian(3, 6) + &
7064 first_ratio(6)*diagonal(3)*diagonal(5)*hessian(3, 5) + &
7065 second_ratio(3, 5)*diagonal(6)*gradient(6) + &
7066 second_ratio(3, 6)*diagonal(5)*gradient(5) + &
7067 second_ratio(5, 6)*diagonal(3)*gradient(3) + third_ratio*functional
7068 END IF
7069 IF (ALLOCATED(w%v3sigma2lapl) .AND. has_laplace) THEN
7070 third_ratio = (2.0_dp*(dn(3)*dm(5)*dm(7) + &
7071 dn(5)*dm(3)*dm(7) + dn(7)*dm(3)*dm(5)) - &
7072 6.0_dp*ratio*dm(3)*dm(5)*dm(7))/m**3
7073 w%v3sigma2lapl(6, point) = ratio*diagonal(3)*diagonal(5)*diagonal(7)* &
7074 w%v3sigma2lapl(6, point) + first_ratio(3)*diagonal(5)*diagonal(7)*hessian(5, 7) + &
7075 first_ratio(5)*diagonal(3)*diagonal(7)*hessian(3, 7) + &
7076 first_ratio(7)*diagonal(3)*diagonal(5)*hessian(3, 5) + &
7077 second_ratio(3, 5)*diagonal(7)*gradient(7) + &
7078 second_ratio(3, 7)*diagonal(5)*gradient(5) + &
7079 second_ratio(5, 7)*diagonal(3)*gradient(3) + third_ratio*functional
7080 END IF
7081 IF (ALLOCATED(w%v3sigma2tau) ) THEN
7082 third_ratio = (2.0_dp*(dn(3)*dm(5)*dm(8) + &
7083 dn(5)*dm(3)*dm(8) + dn(8)*dm(3)*dm(5)) - &
7084 6.0_dp*ratio*dm(3)*dm(5)*dm(8))/m**3
7085 w%v3sigma2tau(5, point) = ratio*diagonal(3)*diagonal(5)*diagonal(8)* &
7086 w%v3sigma2tau(5, point) + first_ratio(3)*diagonal(5)*diagonal(8)*hessian(5, 8) + &
7087 first_ratio(5)*diagonal(3)*diagonal(8)*hessian(3, 8) + &
7088 first_ratio(8)*diagonal(3)*diagonal(5)*hessian(3, 5) + &
7089 second_ratio(3, 5)*diagonal(8)*gradient(8) + &
7090 second_ratio(3, 8)*diagonal(5)*gradient(5) + &
7091 second_ratio(5, 8)*diagonal(3)*gradient(3) + third_ratio*functional
7092 END IF
7093 IF (ALLOCATED(w%v3sigma2tau) ) THEN
7094 third_ratio = (2.0_dp*(dn(3)*dm(5)*dm(9) + &
7095 dn(5)*dm(3)*dm(9) + dn(9)*dm(3)*dm(5)) - &
7096 6.0_dp*ratio*dm(3)*dm(5)*dm(9))/m**3
7097 w%v3sigma2tau(6, point) = ratio*diagonal(3)*diagonal(5)*diagonal(9)* &
7098 w%v3sigma2tau(6, point) + first_ratio(3)*diagonal(5)*diagonal(9)*hessian(5, 9) + &
7099 first_ratio(5)*diagonal(3)*diagonal(9)*hessian(3, 9) + &
7100 first_ratio(9)*diagonal(3)*diagonal(5)*hessian(3, 5) + &
7101 second_ratio(3, 5)*diagonal(9)*gradient(9) + &
7102 second_ratio(3, 9)*diagonal(5)*gradient(5) + &
7103 second_ratio(5, 9)*diagonal(3)*gradient(3) + third_ratio*functional
7104 END IF
7105 IF (ALLOCATED(w%v3sigmalapl2) .AND. has_laplace) THEN
7106 third_ratio = (2.0_dp*(dn(3)*dm(6)*dm(6) + &
7107 dn(6)*dm(3)*dm(6) + dn(6)*dm(3)*dm(6)) - &
7108 6.0_dp*ratio*dm(3)*dm(6)*dm(6))/m**3
7109 w%v3sigmalapl2(1, point) = ratio*diagonal(3)*diagonal(6)*diagonal(6)* &
7110 w%v3sigmalapl2(1, point) + first_ratio(3)*diagonal(6)*diagonal(6)*hessian(6, 6) + &
7111 first_ratio(6)*diagonal(3)*diagonal(6)*hessian(3, 6) + &
7112 first_ratio(6)*diagonal(3)*diagonal(6)*hessian(3, 6) + &
7113 second_ratio(3, 6)*diagonal(6)*gradient(6) + &
7114 second_ratio(3, 6)*diagonal(6)*gradient(6) + &
7115 second_ratio(6, 6)*diagonal(3)*gradient(3) + third_ratio*functional
7116 END IF
7117 IF (ALLOCATED(w%v3sigmalapl2) .AND. has_laplace) THEN
7118 third_ratio = (2.0_dp*(dn(3)*dm(6)*dm(7) + &
7119 dn(6)*dm(3)*dm(7) + dn(7)*dm(3)*dm(6)) - &
7120 6.0_dp*ratio*dm(3)*dm(6)*dm(7))/m**3
7121 w%v3sigmalapl2(2, point) = ratio*diagonal(3)*diagonal(6)*diagonal(7)* &
7122 w%v3sigmalapl2(2, point) + first_ratio(3)*diagonal(6)*diagonal(7)*hessian(6, 7) + &
7123 first_ratio(6)*diagonal(3)*diagonal(7)*hessian(3, 7) + &
7124 first_ratio(7)*diagonal(3)*diagonal(6)*hessian(3, 6) + &
7125 second_ratio(3, 6)*diagonal(7)*gradient(7) + &
7126 second_ratio(3, 7)*diagonal(6)*gradient(6) + &
7127 second_ratio(6, 7)*diagonal(3)*gradient(3) + third_ratio*functional
7128 END IF
7129 IF (ALLOCATED(w%v3sigmalapltau) .AND. has_laplace) THEN
7130 third_ratio = (2.0_dp*(dn(3)*dm(6)*dm(8) + &
7131 dn(6)*dm(3)*dm(8) + dn(8)*dm(3)*dm(6)) - &
7132 6.0_dp*ratio*dm(3)*dm(6)*dm(8))/m**3
7133 w%v3sigmalapltau(1, point) = ratio*diagonal(3)*diagonal(6)*diagonal(8)* &
7134 w%v3sigmalapltau(1, point) + first_ratio(3)*diagonal(6)*diagonal(8)*hessian(6, 8) + &
7135 first_ratio(6)*diagonal(3)*diagonal(8)*hessian(3, 8) + &
7136 first_ratio(8)*diagonal(3)*diagonal(6)*hessian(3, 6) + &
7137 second_ratio(3, 6)*diagonal(8)*gradient(8) + &
7138 second_ratio(3, 8)*diagonal(6)*gradient(6) + &
7139 second_ratio(6, 8)*diagonal(3)*gradient(3) + third_ratio*functional
7140 END IF
7141 IF (ALLOCATED(w%v3sigmalapltau) .AND. has_laplace) THEN
7142 third_ratio = (2.0_dp*(dn(3)*dm(6)*dm(9) + &
7143 dn(6)*dm(3)*dm(9) + dn(9)*dm(3)*dm(6)) - &
7144 6.0_dp*ratio*dm(3)*dm(6)*dm(9))/m**3
7145 w%v3sigmalapltau(2, point) = ratio*diagonal(3)*diagonal(6)*diagonal(9)* &
7146 w%v3sigmalapltau(2, point) + first_ratio(3)*diagonal(6)*diagonal(9)*hessian(6, 9) + &
7147 first_ratio(6)*diagonal(3)*diagonal(9)*hessian(3, 9) + &
7148 first_ratio(9)*diagonal(3)*diagonal(6)*hessian(3, 6) + &
7149 second_ratio(3, 6)*diagonal(9)*gradient(9) + &
7150 second_ratio(3, 9)*diagonal(6)*gradient(6) + &
7151 second_ratio(6, 9)*diagonal(3)*gradient(3) + third_ratio*functional
7152 END IF
7153 IF (ALLOCATED(w%v3sigmalapl2) .AND. has_laplace) THEN
7154 third_ratio = (2.0_dp*(dn(3)*dm(7)*dm(7) + &
7155 dn(7)*dm(3)*dm(7) + dn(7)*dm(3)*dm(7)) - &
7156 6.0_dp*ratio*dm(3)*dm(7)*dm(7))/m**3
7157 w%v3sigmalapl2(3, point) = ratio*diagonal(3)*diagonal(7)*diagonal(7)* &
7158 w%v3sigmalapl2(3, point) + first_ratio(3)*diagonal(7)*diagonal(7)*hessian(7, 7) + &
7159 first_ratio(7)*diagonal(3)*diagonal(7)*hessian(3, 7) + &
7160 first_ratio(7)*diagonal(3)*diagonal(7)*hessian(3, 7) + &
7161 second_ratio(3, 7)*diagonal(7)*gradient(7) + &
7162 second_ratio(3, 7)*diagonal(7)*gradient(7) + &
7163 second_ratio(7, 7)*diagonal(3)*gradient(3) + third_ratio*functional
7164 END IF
7165 IF (ALLOCATED(w%v3sigmalapltau) .AND. has_laplace) THEN
7166 third_ratio = (2.0_dp*(dn(3)*dm(7)*dm(8) + &
7167 dn(7)*dm(3)*dm(8) + dn(8)*dm(3)*dm(7)) - &
7168 6.0_dp*ratio*dm(3)*dm(7)*dm(8))/m**3
7169 w%v3sigmalapltau(3, point) = ratio*diagonal(3)*diagonal(7)*diagonal(8)* &
7170 w%v3sigmalapltau(3, point) + first_ratio(3)*diagonal(7)*diagonal(8)*hessian(7, 8) + &
7171 first_ratio(7)*diagonal(3)*diagonal(8)*hessian(3, 8) + &
7172 first_ratio(8)*diagonal(3)*diagonal(7)*hessian(3, 7) + &
7173 second_ratio(3, 7)*diagonal(8)*gradient(8) + &
7174 second_ratio(3, 8)*diagonal(7)*gradient(7) + &
7175 second_ratio(7, 8)*diagonal(3)*gradient(3) + third_ratio*functional
7176 END IF
7177 IF (ALLOCATED(w%v3sigmalapltau) .AND. has_laplace) THEN
7178 third_ratio = (2.0_dp*(dn(3)*dm(7)*dm(9) + &
7179 dn(7)*dm(3)*dm(9) + dn(9)*dm(3)*dm(7)) - &
7180 6.0_dp*ratio*dm(3)*dm(7)*dm(9))/m**3
7181 w%v3sigmalapltau(4, point) = ratio*diagonal(3)*diagonal(7)*diagonal(9)* &
7182 w%v3sigmalapltau(4, point) + first_ratio(3)*diagonal(7)*diagonal(9)*hessian(7, 9) + &
7183 first_ratio(7)*diagonal(3)*diagonal(9)*hessian(3, 9) + &
7184 first_ratio(9)*diagonal(3)*diagonal(7)*hessian(3, 7) + &
7185 second_ratio(3, 7)*diagonal(9)*gradient(9) + &
7186 second_ratio(3, 9)*diagonal(7)*gradient(7) + &
7187 second_ratio(7, 9)*diagonal(3)*gradient(3) + third_ratio*functional
7188 END IF
7189 IF (ALLOCATED(w%v3sigmatau2) ) THEN
7190 third_ratio = (2.0_dp*(dn(3)*dm(8)*dm(8) + &
7191 dn(8)*dm(3)*dm(8) + dn(8)*dm(3)*dm(8)) - &
7192 6.0_dp*ratio*dm(3)*dm(8)*dm(8))/m**3
7193 w%v3sigmatau2(1, point) = ratio*diagonal(3)*diagonal(8)*diagonal(8)* &
7194 w%v3sigmatau2(1, point) + first_ratio(3)*diagonal(8)*diagonal(8)*hessian(8, 8) + &
7195 first_ratio(8)*diagonal(3)*diagonal(8)*hessian(3, 8) + &
7196 first_ratio(8)*diagonal(3)*diagonal(8)*hessian(3, 8) + &
7197 second_ratio(3, 8)*diagonal(8)*gradient(8) + &
7198 second_ratio(3, 8)*diagonal(8)*gradient(8) + &
7199 second_ratio(8, 8)*diagonal(3)*gradient(3) + third_ratio*functional
7200 END IF
7201 IF (ALLOCATED(w%v3sigmatau2) ) THEN
7202 third_ratio = (2.0_dp*(dn(3)*dm(8)*dm(9) + &
7203 dn(8)*dm(3)*dm(9) + dn(9)*dm(3)*dm(8)) - &
7204 6.0_dp*ratio*dm(3)*dm(8)*dm(9))/m**3
7205 w%v3sigmatau2(2, point) = ratio*diagonal(3)*diagonal(8)*diagonal(9)* &
7206 w%v3sigmatau2(2, point) + first_ratio(3)*diagonal(8)*diagonal(9)*hessian(8, 9) + &
7207 first_ratio(8)*diagonal(3)*diagonal(9)*hessian(3, 9) + &
7208 first_ratio(9)*diagonal(3)*diagonal(8)*hessian(3, 8) + &
7209 second_ratio(3, 8)*diagonal(9)*gradient(9) + &
7210 second_ratio(3, 9)*diagonal(8)*gradient(8) + &
7211 second_ratio(8, 9)*diagonal(3)*gradient(3) + third_ratio*functional
7212 END IF
7213 IF (ALLOCATED(w%v3sigmatau2) ) THEN
7214 third_ratio = (2.0_dp*(dn(3)*dm(9)*dm(9) + &
7215 dn(9)*dm(3)*dm(9) + dn(9)*dm(3)*dm(9)) - &
7216 6.0_dp*ratio*dm(3)*dm(9)*dm(9))/m**3
7217 w%v3sigmatau2(3, point) = ratio*diagonal(3)*diagonal(9)*diagonal(9)* &
7218 w%v3sigmatau2(3, point) + first_ratio(3)*diagonal(9)*diagonal(9)*hessian(9, 9) + &
7219 first_ratio(9)*diagonal(3)*diagonal(9)*hessian(3, 9) + &
7220 first_ratio(9)*diagonal(3)*diagonal(9)*hessian(3, 9) + &
7221 second_ratio(3, 9)*diagonal(9)*gradient(9) + &
7222 second_ratio(3, 9)*diagonal(9)*gradient(9) + &
7223 second_ratio(9, 9)*diagonal(3)*gradient(3) + third_ratio*functional
7224 END IF
7225 IF (ALLOCATED(w%v3sigma3) ) THEN
7226 third_ratio = (2.0_dp*(dn(4)*dm(4)*dm(4) + &
7227 dn(4)*dm(4)*dm(4) + dn(4)*dm(4)*dm(4)) - &
7228 6.0_dp*ratio*dm(4)*dm(4)*dm(4))/m**3
7229 w%v3sigma3(7, point) = ratio*diagonal(4)*diagonal(4)*diagonal(4)* &
7230 w%v3sigma3(7, point) + first_ratio(4)*diagonal(4)*diagonal(4)*hessian(4, 4) + &
7231 first_ratio(4)*diagonal(4)*diagonal(4)*hessian(4, 4) + &
7232 first_ratio(4)*diagonal(4)*diagonal(4)*hessian(4, 4) + &
7233 second_ratio(4, 4)*diagonal(4)*gradient(4) + &
7234 second_ratio(4, 4)*diagonal(4)*gradient(4) + &
7235 second_ratio(4, 4)*diagonal(4)*gradient(4) + third_ratio*functional
7236 END IF
7237 IF (ALLOCATED(w%v3sigma3) ) THEN
7238 third_ratio = (2.0_dp*(dn(4)*dm(4)*dm(5) + &
7239 dn(4)*dm(4)*dm(5) + dn(5)*dm(4)*dm(4)) - &
7240 6.0_dp*ratio*dm(4)*dm(4)*dm(5))/m**3
7241 w%v3sigma3(8, point) = ratio*diagonal(4)*diagonal(4)*diagonal(5)* &
7242 w%v3sigma3(8, point) + first_ratio(4)*diagonal(4)*diagonal(5)*hessian(4, 5) + &
7243 first_ratio(4)*diagonal(4)*diagonal(5)*hessian(4, 5) + &
7244 first_ratio(5)*diagonal(4)*diagonal(4)*hessian(4, 4) + &
7245 second_ratio(4, 4)*diagonal(5)*gradient(5) + &
7246 second_ratio(4, 5)*diagonal(4)*gradient(4) + &
7247 second_ratio(4, 5)*diagonal(4)*gradient(4) + third_ratio*functional
7248 END IF
7249 IF (ALLOCATED(w%v3sigma2lapl) .AND. has_laplace) THEN
7250 third_ratio = (2.0_dp*(dn(4)*dm(4)*dm(6) + &
7251 dn(4)*dm(4)*dm(6) + dn(6)*dm(4)*dm(4)) - &
7252 6.0_dp*ratio*dm(4)*dm(4)*dm(6))/m**3
7253 w%v3sigma2lapl(7, point) = ratio*diagonal(4)*diagonal(4)*diagonal(6)* &
7254 w%v3sigma2lapl(7, point) + first_ratio(4)*diagonal(4)*diagonal(6)*hessian(4, 6) + &
7255 first_ratio(4)*diagonal(4)*diagonal(6)*hessian(4, 6) + &
7256 first_ratio(6)*diagonal(4)*diagonal(4)*hessian(4, 4) + &
7257 second_ratio(4, 4)*diagonal(6)*gradient(6) + &
7258 second_ratio(4, 6)*diagonal(4)*gradient(4) + &
7259 second_ratio(4, 6)*diagonal(4)*gradient(4) + third_ratio*functional
7260 END IF
7261 IF (ALLOCATED(w%v3sigma2lapl) .AND. has_laplace) THEN
7262 third_ratio = (2.0_dp*(dn(4)*dm(4)*dm(7) + &
7263 dn(4)*dm(4)*dm(7) + dn(7)*dm(4)*dm(4)) - &
7264 6.0_dp*ratio*dm(4)*dm(4)*dm(7))/m**3
7265 w%v3sigma2lapl(8, point) = ratio*diagonal(4)*diagonal(4)*diagonal(7)* &
7266 w%v3sigma2lapl(8, point) + first_ratio(4)*diagonal(4)*diagonal(7)*hessian(4, 7) + &
7267 first_ratio(4)*diagonal(4)*diagonal(7)*hessian(4, 7) + &
7268 first_ratio(7)*diagonal(4)*diagonal(4)*hessian(4, 4) + &
7269 second_ratio(4, 4)*diagonal(7)*gradient(7) + &
7270 second_ratio(4, 7)*diagonal(4)*gradient(4) + &
7271 second_ratio(4, 7)*diagonal(4)*gradient(4) + third_ratio*functional
7272 END IF
7273 IF (ALLOCATED(w%v3sigma2tau) ) THEN
7274 third_ratio = (2.0_dp*(dn(4)*dm(4)*dm(8) + &
7275 dn(4)*dm(4)*dm(8) + dn(8)*dm(4)*dm(4)) - &
7276 6.0_dp*ratio*dm(4)*dm(4)*dm(8))/m**3
7277 w%v3sigma2tau(7, point) = ratio*diagonal(4)*diagonal(4)*diagonal(8)* &
7278 w%v3sigma2tau(7, point) + first_ratio(4)*diagonal(4)*diagonal(8)*hessian(4, 8) + &
7279 first_ratio(4)*diagonal(4)*diagonal(8)*hessian(4, 8) + &
7280 first_ratio(8)*diagonal(4)*diagonal(4)*hessian(4, 4) + &
7281 second_ratio(4, 4)*diagonal(8)*gradient(8) + &
7282 second_ratio(4, 8)*diagonal(4)*gradient(4) + &
7283 second_ratio(4, 8)*diagonal(4)*gradient(4) + third_ratio*functional
7284 END IF
7285 IF (ALLOCATED(w%v3sigma2tau) ) THEN
7286 third_ratio = (2.0_dp*(dn(4)*dm(4)*dm(9) + &
7287 dn(4)*dm(4)*dm(9) + dn(9)*dm(4)*dm(4)) - &
7288 6.0_dp*ratio*dm(4)*dm(4)*dm(9))/m**3
7289 w%v3sigma2tau(8, point) = ratio*diagonal(4)*diagonal(4)*diagonal(9)* &
7290 w%v3sigma2tau(8, point) + first_ratio(4)*diagonal(4)*diagonal(9)*hessian(4, 9) + &
7291 first_ratio(4)*diagonal(4)*diagonal(9)*hessian(4, 9) + &
7292 first_ratio(9)*diagonal(4)*diagonal(4)*hessian(4, 4) + &
7293 second_ratio(4, 4)*diagonal(9)*gradient(9) + &
7294 second_ratio(4, 9)*diagonal(4)*gradient(4) + &
7295 second_ratio(4, 9)*diagonal(4)*gradient(4) + third_ratio*functional
7296 END IF
7297 IF (ALLOCATED(w%v3sigma3) ) THEN
7298 third_ratio = (2.0_dp*(dn(4)*dm(5)*dm(5) + &
7299 dn(5)*dm(4)*dm(5) + dn(5)*dm(4)*dm(5)) - &
7300 6.0_dp*ratio*dm(4)*dm(5)*dm(5))/m**3
7301 w%v3sigma3(9, point) = ratio*diagonal(4)*diagonal(5)*diagonal(5)* &
7302 w%v3sigma3(9, point) + first_ratio(4)*diagonal(5)*diagonal(5)*hessian(5, 5) + &
7303 first_ratio(5)*diagonal(4)*diagonal(5)*hessian(4, 5) + &
7304 first_ratio(5)*diagonal(4)*diagonal(5)*hessian(4, 5) + &
7305 second_ratio(4, 5)*diagonal(5)*gradient(5) + &
7306 second_ratio(4, 5)*diagonal(5)*gradient(5) + &
7307 second_ratio(5, 5)*diagonal(4)*gradient(4) + third_ratio*functional
7308 END IF
7309 IF (ALLOCATED(w%v3sigma2lapl) .AND. has_laplace) THEN
7310 third_ratio = (2.0_dp*(dn(4)*dm(5)*dm(6) + &
7311 dn(5)*dm(4)*dm(6) + dn(6)*dm(4)*dm(5)) - &
7312 6.0_dp*ratio*dm(4)*dm(5)*dm(6))/m**3
7313 w%v3sigma2lapl(9, point) = ratio*diagonal(4)*diagonal(5)*diagonal(6)* &
7314 w%v3sigma2lapl(9, point) + first_ratio(4)*diagonal(5)*diagonal(6)*hessian(5, 6) + &
7315 first_ratio(5)*diagonal(4)*diagonal(6)*hessian(4, 6) + &
7316 first_ratio(6)*diagonal(4)*diagonal(5)*hessian(4, 5) + &
7317 second_ratio(4, 5)*diagonal(6)*gradient(6) + &
7318 second_ratio(4, 6)*diagonal(5)*gradient(5) + &
7319 second_ratio(5, 6)*diagonal(4)*gradient(4) + third_ratio*functional
7320 END IF
7321 IF (ALLOCATED(w%v3sigma2lapl) .AND. has_laplace) THEN
7322 third_ratio = (2.0_dp*(dn(4)*dm(5)*dm(7) + &
7323 dn(5)*dm(4)*dm(7) + dn(7)*dm(4)*dm(5)) - &
7324 6.0_dp*ratio*dm(4)*dm(5)*dm(7))/m**3
7325 w%v3sigma2lapl(10, point) = ratio*diagonal(4)*diagonal(5)*diagonal(7)* &
7326 w%v3sigma2lapl(10, point) + first_ratio(4)*diagonal(5)*diagonal(7)*hessian(5, 7) + &
7327 first_ratio(5)*diagonal(4)*diagonal(7)*hessian(4, 7) + &
7328 first_ratio(7)*diagonal(4)*diagonal(5)*hessian(4, 5) + &
7329 second_ratio(4, 5)*diagonal(7)*gradient(7) + &
7330 second_ratio(4, 7)*diagonal(5)*gradient(5) + &
7331 second_ratio(5, 7)*diagonal(4)*gradient(4) + third_ratio*functional
7332 END IF
7333 IF (ALLOCATED(w%v3sigma2tau) ) THEN
7334 third_ratio = (2.0_dp*(dn(4)*dm(5)*dm(8) + &
7335 dn(5)*dm(4)*dm(8) + dn(8)*dm(4)*dm(5)) - &
7336 6.0_dp*ratio*dm(4)*dm(5)*dm(8))/m**3
7337 w%v3sigma2tau(9, point) = ratio*diagonal(4)*diagonal(5)*diagonal(8)* &
7338 w%v3sigma2tau(9, point) + first_ratio(4)*diagonal(5)*diagonal(8)*hessian(5, 8) + &
7339 first_ratio(5)*diagonal(4)*diagonal(8)*hessian(4, 8) + &
7340 first_ratio(8)*diagonal(4)*diagonal(5)*hessian(4, 5) + &
7341 second_ratio(4, 5)*diagonal(8)*gradient(8) + &
7342 second_ratio(4, 8)*diagonal(5)*gradient(5) + &
7343 second_ratio(5, 8)*diagonal(4)*gradient(4) + third_ratio*functional
7344 END IF
7345 IF (ALLOCATED(w%v3sigma2tau) ) THEN
7346 third_ratio = (2.0_dp*(dn(4)*dm(5)*dm(9) + &
7347 dn(5)*dm(4)*dm(9) + dn(9)*dm(4)*dm(5)) - &
7348 6.0_dp*ratio*dm(4)*dm(5)*dm(9))/m**3
7349 w%v3sigma2tau(10, point) = ratio*diagonal(4)*diagonal(5)*diagonal(9)* &
7350 w%v3sigma2tau(10, point) + first_ratio(4)*diagonal(5)*diagonal(9)*hessian(5, 9) + &
7351 first_ratio(5)*diagonal(4)*diagonal(9)*hessian(4, 9) + &
7352 first_ratio(9)*diagonal(4)*diagonal(5)*hessian(4, 5) + &
7353 second_ratio(4, 5)*diagonal(9)*gradient(9) + &
7354 second_ratio(4, 9)*diagonal(5)*gradient(5) + &
7355 second_ratio(5, 9)*diagonal(4)*gradient(4) + third_ratio*functional
7356 END IF
7357 IF (ALLOCATED(w%v3sigmalapl2) .AND. has_laplace) THEN
7358 third_ratio = (2.0_dp*(dn(4)*dm(6)*dm(6) + &
7359 dn(6)*dm(4)*dm(6) + dn(6)*dm(4)*dm(6)) - &
7360 6.0_dp*ratio*dm(4)*dm(6)*dm(6))/m**3
7361 w%v3sigmalapl2(4, point) = ratio*diagonal(4)*diagonal(6)*diagonal(6)* &
7362 w%v3sigmalapl2(4, point) + first_ratio(4)*diagonal(6)*diagonal(6)*hessian(6, 6) + &
7363 first_ratio(6)*diagonal(4)*diagonal(6)*hessian(4, 6) + &
7364 first_ratio(6)*diagonal(4)*diagonal(6)*hessian(4, 6) + &
7365 second_ratio(4, 6)*diagonal(6)*gradient(6) + &
7366 second_ratio(4, 6)*diagonal(6)*gradient(6) + &
7367 second_ratio(6, 6)*diagonal(4)*gradient(4) + third_ratio*functional
7368 END IF
7369 IF (ALLOCATED(w%v3sigmalapl2) .AND. has_laplace) THEN
7370 third_ratio = (2.0_dp*(dn(4)*dm(6)*dm(7) + &
7371 dn(6)*dm(4)*dm(7) + dn(7)*dm(4)*dm(6)) - &
7372 6.0_dp*ratio*dm(4)*dm(6)*dm(7))/m**3
7373 w%v3sigmalapl2(5, point) = ratio*diagonal(4)*diagonal(6)*diagonal(7)* &
7374 w%v3sigmalapl2(5, point) + first_ratio(4)*diagonal(6)*diagonal(7)*hessian(6, 7) + &
7375 first_ratio(6)*diagonal(4)*diagonal(7)*hessian(4, 7) + &
7376 first_ratio(7)*diagonal(4)*diagonal(6)*hessian(4, 6) + &
7377 second_ratio(4, 6)*diagonal(7)*gradient(7) + &
7378 second_ratio(4, 7)*diagonal(6)*gradient(6) + &
7379 second_ratio(6, 7)*diagonal(4)*gradient(4) + third_ratio*functional
7380 END IF
7381 IF (ALLOCATED(w%v3sigmalapltau) .AND. has_laplace) THEN
7382 third_ratio = (2.0_dp*(dn(4)*dm(6)*dm(8) + &
7383 dn(6)*dm(4)*dm(8) + dn(8)*dm(4)*dm(6)) - &
7384 6.0_dp*ratio*dm(4)*dm(6)*dm(8))/m**3
7385 w%v3sigmalapltau(5, point) = ratio*diagonal(4)*diagonal(6)*diagonal(8)* &
7386 w%v3sigmalapltau(5, point) + first_ratio(4)*diagonal(6)*diagonal(8)*hessian(6, 8) + &
7387 first_ratio(6)*diagonal(4)*diagonal(8)*hessian(4, 8) + &
7388 first_ratio(8)*diagonal(4)*diagonal(6)*hessian(4, 6) + &
7389 second_ratio(4, 6)*diagonal(8)*gradient(8) + &
7390 second_ratio(4, 8)*diagonal(6)*gradient(6) + &
7391 second_ratio(6, 8)*diagonal(4)*gradient(4) + third_ratio*functional
7392 END IF
7393 IF (ALLOCATED(w%v3sigmalapltau) .AND. has_laplace) THEN
7394 third_ratio = (2.0_dp*(dn(4)*dm(6)*dm(9) + &
7395 dn(6)*dm(4)*dm(9) + dn(9)*dm(4)*dm(6)) - &
7396 6.0_dp*ratio*dm(4)*dm(6)*dm(9))/m**3
7397 w%v3sigmalapltau(6, point) = ratio*diagonal(4)*diagonal(6)*diagonal(9)* &
7398 w%v3sigmalapltau(6, point) + first_ratio(4)*diagonal(6)*diagonal(9)*hessian(6, 9) + &
7399 first_ratio(6)*diagonal(4)*diagonal(9)*hessian(4, 9) + &
7400 first_ratio(9)*diagonal(4)*diagonal(6)*hessian(4, 6) + &
7401 second_ratio(4, 6)*diagonal(9)*gradient(9) + &
7402 second_ratio(4, 9)*diagonal(6)*gradient(6) + &
7403 second_ratio(6, 9)*diagonal(4)*gradient(4) + third_ratio*functional
7404 END IF
7405 IF (ALLOCATED(w%v3sigmalapl2) .AND. has_laplace) THEN
7406 third_ratio = (2.0_dp*(dn(4)*dm(7)*dm(7) + &
7407 dn(7)*dm(4)*dm(7) + dn(7)*dm(4)*dm(7)) - &
7408 6.0_dp*ratio*dm(4)*dm(7)*dm(7))/m**3
7409 w%v3sigmalapl2(6, point) = ratio*diagonal(4)*diagonal(7)*diagonal(7)* &
7410 w%v3sigmalapl2(6, point) + first_ratio(4)*diagonal(7)*diagonal(7)*hessian(7, 7) + &
7411 first_ratio(7)*diagonal(4)*diagonal(7)*hessian(4, 7) + &
7412 first_ratio(7)*diagonal(4)*diagonal(7)*hessian(4, 7) + &
7413 second_ratio(4, 7)*diagonal(7)*gradient(7) + &
7414 second_ratio(4, 7)*diagonal(7)*gradient(7) + &
7415 second_ratio(7, 7)*diagonal(4)*gradient(4) + third_ratio*functional
7416 END IF
7417 IF (ALLOCATED(w%v3sigmalapltau) .AND. has_laplace) THEN
7418 third_ratio = (2.0_dp*(dn(4)*dm(7)*dm(8) + &
7419 dn(7)*dm(4)*dm(8) + dn(8)*dm(4)*dm(7)) - &
7420 6.0_dp*ratio*dm(4)*dm(7)*dm(8))/m**3
7421 w%v3sigmalapltau(7, point) = ratio*diagonal(4)*diagonal(7)*diagonal(8)* &
7422 w%v3sigmalapltau(7, point) + first_ratio(4)*diagonal(7)*diagonal(8)*hessian(7, 8) + &
7423 first_ratio(7)*diagonal(4)*diagonal(8)*hessian(4, 8) + &
7424 first_ratio(8)*diagonal(4)*diagonal(7)*hessian(4, 7) + &
7425 second_ratio(4, 7)*diagonal(8)*gradient(8) + &
7426 second_ratio(4, 8)*diagonal(7)*gradient(7) + &
7427 second_ratio(7, 8)*diagonal(4)*gradient(4) + third_ratio*functional
7428 END IF
7429 IF (ALLOCATED(w%v3sigmalapltau) .AND. has_laplace) THEN
7430 third_ratio = (2.0_dp*(dn(4)*dm(7)*dm(9) + &
7431 dn(7)*dm(4)*dm(9) + dn(9)*dm(4)*dm(7)) - &
7432 6.0_dp*ratio*dm(4)*dm(7)*dm(9))/m**3
7433 w%v3sigmalapltau(8, point) = ratio*diagonal(4)*diagonal(7)*diagonal(9)* &
7434 w%v3sigmalapltau(8, point) + first_ratio(4)*diagonal(7)*diagonal(9)*hessian(7, 9) + &
7435 first_ratio(7)*diagonal(4)*diagonal(9)*hessian(4, 9) + &
7436 first_ratio(9)*diagonal(4)*diagonal(7)*hessian(4, 7) + &
7437 second_ratio(4, 7)*diagonal(9)*gradient(9) + &
7438 second_ratio(4, 9)*diagonal(7)*gradient(7) + &
7439 second_ratio(7, 9)*diagonal(4)*gradient(4) + third_ratio*functional
7440 END IF
7441 IF (ALLOCATED(w%v3sigmatau2) ) THEN
7442 third_ratio = (2.0_dp*(dn(4)*dm(8)*dm(8) + &
7443 dn(8)*dm(4)*dm(8) + dn(8)*dm(4)*dm(8)) - &
7444 6.0_dp*ratio*dm(4)*dm(8)*dm(8))/m**3
7445 w%v3sigmatau2(4, point) = ratio*diagonal(4)*diagonal(8)*diagonal(8)* &
7446 w%v3sigmatau2(4, point) + first_ratio(4)*diagonal(8)*diagonal(8)*hessian(8, 8) + &
7447 first_ratio(8)*diagonal(4)*diagonal(8)*hessian(4, 8) + &
7448 first_ratio(8)*diagonal(4)*diagonal(8)*hessian(4, 8) + &
7449 second_ratio(4, 8)*diagonal(8)*gradient(8) + &
7450 second_ratio(4, 8)*diagonal(8)*gradient(8) + &
7451 second_ratio(8, 8)*diagonal(4)*gradient(4) + third_ratio*functional
7452 END IF
7453 IF (ALLOCATED(w%v3sigmatau2) ) THEN
7454 third_ratio = (2.0_dp*(dn(4)*dm(8)*dm(9) + &
7455 dn(8)*dm(4)*dm(9) + dn(9)*dm(4)*dm(8)) - &
7456 6.0_dp*ratio*dm(4)*dm(8)*dm(9))/m**3
7457 w%v3sigmatau2(5, point) = ratio*diagonal(4)*diagonal(8)*diagonal(9)* &
7458 w%v3sigmatau2(5, point) + first_ratio(4)*diagonal(8)*diagonal(9)*hessian(8, 9) + &
7459 first_ratio(8)*diagonal(4)*diagonal(9)*hessian(4, 9) + &
7460 first_ratio(9)*diagonal(4)*diagonal(8)*hessian(4, 8) + &
7461 second_ratio(4, 8)*diagonal(9)*gradient(9) + &
7462 second_ratio(4, 9)*diagonal(8)*gradient(8) + &
7463 second_ratio(8, 9)*diagonal(4)*gradient(4) + third_ratio*functional
7464 END IF
7465 IF (ALLOCATED(w%v3sigmatau2) ) THEN
7466 third_ratio = (2.0_dp*(dn(4)*dm(9)*dm(9) + &
7467 dn(9)*dm(4)*dm(9) + dn(9)*dm(4)*dm(9)) - &
7468 6.0_dp*ratio*dm(4)*dm(9)*dm(9))/m**3
7469 w%v3sigmatau2(6, point) = ratio*diagonal(4)*diagonal(9)*diagonal(9)* &
7470 w%v3sigmatau2(6, point) + first_ratio(4)*diagonal(9)*diagonal(9)*hessian(9, 9) + &
7471 first_ratio(9)*diagonal(4)*diagonal(9)*hessian(4, 9) + &
7472 first_ratio(9)*diagonal(4)*diagonal(9)*hessian(4, 9) + &
7473 second_ratio(4, 9)*diagonal(9)*gradient(9) + &
7474 second_ratio(4, 9)*diagonal(9)*gradient(9) + &
7475 second_ratio(9, 9)*diagonal(4)*gradient(4) + third_ratio*functional
7476 END IF
7477 IF (ALLOCATED(w%v3sigma3) ) THEN
7478 third_ratio = (2.0_dp*(dn(5)*dm(5)*dm(5) + &
7479 dn(5)*dm(5)*dm(5) + dn(5)*dm(5)*dm(5)) - &
7480 6.0_dp*ratio*dm(5)*dm(5)*dm(5))/m**3
7481 w%v3sigma3(10, point) = ratio*diagonal(5)*diagonal(5)*diagonal(5)* &
7482 w%v3sigma3(10, point) + first_ratio(5)*diagonal(5)*diagonal(5)*hessian(5, 5) + &
7483 first_ratio(5)*diagonal(5)*diagonal(5)*hessian(5, 5) + &
7484 first_ratio(5)*diagonal(5)*diagonal(5)*hessian(5, 5) + &
7485 second_ratio(5, 5)*diagonal(5)*gradient(5) + &
7486 second_ratio(5, 5)*diagonal(5)*gradient(5) + &
7487 second_ratio(5, 5)*diagonal(5)*gradient(5) + third_ratio*functional
7488 END IF
7489 IF (ALLOCATED(w%v3sigma2lapl) .AND. has_laplace) THEN
7490 third_ratio = (2.0_dp*(dn(5)*dm(5)*dm(6) + &
7491 dn(5)*dm(5)*dm(6) + dn(6)*dm(5)*dm(5)) - &
7492 6.0_dp*ratio*dm(5)*dm(5)*dm(6))/m**3
7493 w%v3sigma2lapl(11, point) = ratio*diagonal(5)*diagonal(5)*diagonal(6)* &
7494 w%v3sigma2lapl(11, point) + first_ratio(5)*diagonal(5)*diagonal(6)*hessian(5, 6) + &
7495 first_ratio(5)*diagonal(5)*diagonal(6)*hessian(5, 6) + &
7496 first_ratio(6)*diagonal(5)*diagonal(5)*hessian(5, 5) + &
7497 second_ratio(5, 5)*diagonal(6)*gradient(6) + &
7498 second_ratio(5, 6)*diagonal(5)*gradient(5) + &
7499 second_ratio(5, 6)*diagonal(5)*gradient(5) + third_ratio*functional
7500 END IF
7501 IF (ALLOCATED(w%v3sigma2lapl) .AND. has_laplace) THEN
7502 third_ratio = (2.0_dp*(dn(5)*dm(5)*dm(7) + &
7503 dn(5)*dm(5)*dm(7) + dn(7)*dm(5)*dm(5)) - &
7504 6.0_dp*ratio*dm(5)*dm(5)*dm(7))/m**3
7505 w%v3sigma2lapl(12, point) = ratio*diagonal(5)*diagonal(5)*diagonal(7)* &
7506 w%v3sigma2lapl(12, point) + first_ratio(5)*diagonal(5)*diagonal(7)*hessian(5, 7) + &
7507 first_ratio(5)*diagonal(5)*diagonal(7)*hessian(5, 7) + &
7508 first_ratio(7)*diagonal(5)*diagonal(5)*hessian(5, 5) + &
7509 second_ratio(5, 5)*diagonal(7)*gradient(7) + &
7510 second_ratio(5, 7)*diagonal(5)*gradient(5) + &
7511 second_ratio(5, 7)*diagonal(5)*gradient(5) + third_ratio*functional
7512 END IF
7513 IF (ALLOCATED(w%v3sigma2tau) ) THEN
7514 third_ratio = (2.0_dp*(dn(5)*dm(5)*dm(8) + &
7515 dn(5)*dm(5)*dm(8) + dn(8)*dm(5)*dm(5)) - &
7516 6.0_dp*ratio*dm(5)*dm(5)*dm(8))/m**3
7517 w%v3sigma2tau(11, point) = ratio*diagonal(5)*diagonal(5)*diagonal(8)* &
7518 w%v3sigma2tau(11, point) + first_ratio(5)*diagonal(5)*diagonal(8)*hessian(5, 8) + &
7519 first_ratio(5)*diagonal(5)*diagonal(8)*hessian(5, 8) + &
7520 first_ratio(8)*diagonal(5)*diagonal(5)*hessian(5, 5) + &
7521 second_ratio(5, 5)*diagonal(8)*gradient(8) + &
7522 second_ratio(5, 8)*diagonal(5)*gradient(5) + &
7523 second_ratio(5, 8)*diagonal(5)*gradient(5) + third_ratio*functional
7524 END IF
7525 IF (ALLOCATED(w%v3sigma2tau) ) THEN
7526 third_ratio = (2.0_dp*(dn(5)*dm(5)*dm(9) + &
7527 dn(5)*dm(5)*dm(9) + dn(9)*dm(5)*dm(5)) - &
7528 6.0_dp*ratio*dm(5)*dm(5)*dm(9))/m**3
7529 w%v3sigma2tau(12, point) = ratio*diagonal(5)*diagonal(5)*diagonal(9)* &
7530 w%v3sigma2tau(12, point) + first_ratio(5)*diagonal(5)*diagonal(9)*hessian(5, 9) + &
7531 first_ratio(5)*diagonal(5)*diagonal(9)*hessian(5, 9) + &
7532 first_ratio(9)*diagonal(5)*diagonal(5)*hessian(5, 5) + &
7533 second_ratio(5, 5)*diagonal(9)*gradient(9) + &
7534 second_ratio(5, 9)*diagonal(5)*gradient(5) + &
7535 second_ratio(5, 9)*diagonal(5)*gradient(5) + third_ratio*functional
7536 END IF
7537 IF (ALLOCATED(w%v3sigmalapl2) .AND. has_laplace) THEN
7538 third_ratio = (2.0_dp*(dn(5)*dm(6)*dm(6) + &
7539 dn(6)*dm(5)*dm(6) + dn(6)*dm(5)*dm(6)) - &
7540 6.0_dp*ratio*dm(5)*dm(6)*dm(6))/m**3
7541 w%v3sigmalapl2(7, point) = ratio*diagonal(5)*diagonal(6)*diagonal(6)* &
7542 w%v3sigmalapl2(7, point) + first_ratio(5)*diagonal(6)*diagonal(6)*hessian(6, 6) + &
7543 first_ratio(6)*diagonal(5)*diagonal(6)*hessian(5, 6) + &
7544 first_ratio(6)*diagonal(5)*diagonal(6)*hessian(5, 6) + &
7545 second_ratio(5, 6)*diagonal(6)*gradient(6) + &
7546 second_ratio(5, 6)*diagonal(6)*gradient(6) + &
7547 second_ratio(6, 6)*diagonal(5)*gradient(5) + third_ratio*functional
7548 END IF
7549 IF (ALLOCATED(w%v3sigmalapl2) .AND. has_laplace) THEN
7550 third_ratio = (2.0_dp*(dn(5)*dm(6)*dm(7) + &
7551 dn(6)*dm(5)*dm(7) + dn(7)*dm(5)*dm(6)) - &
7552 6.0_dp*ratio*dm(5)*dm(6)*dm(7))/m**3
7553 w%v3sigmalapl2(8, point) = ratio*diagonal(5)*diagonal(6)*diagonal(7)* &
7554 w%v3sigmalapl2(8, point) + first_ratio(5)*diagonal(6)*diagonal(7)*hessian(6, 7) + &
7555 first_ratio(6)*diagonal(5)*diagonal(7)*hessian(5, 7) + &
7556 first_ratio(7)*diagonal(5)*diagonal(6)*hessian(5, 6) + &
7557 second_ratio(5, 6)*diagonal(7)*gradient(7) + &
7558 second_ratio(5, 7)*diagonal(6)*gradient(6) + &
7559 second_ratio(6, 7)*diagonal(5)*gradient(5) + third_ratio*functional
7560 END IF
7561 IF (ALLOCATED(w%v3sigmalapltau) .AND. has_laplace) THEN
7562 third_ratio = (2.0_dp*(dn(5)*dm(6)*dm(8) + &
7563 dn(6)*dm(5)*dm(8) + dn(8)*dm(5)*dm(6)) - &
7564 6.0_dp*ratio*dm(5)*dm(6)*dm(8))/m**3
7565 w%v3sigmalapltau(9, point) = ratio*diagonal(5)*diagonal(6)*diagonal(8)* &
7566 w%v3sigmalapltau(9, point) + first_ratio(5)*diagonal(6)*diagonal(8)*hessian(6, 8) + &
7567 first_ratio(6)*diagonal(5)*diagonal(8)*hessian(5, 8) + &
7568 first_ratio(8)*diagonal(5)*diagonal(6)*hessian(5, 6) + &
7569 second_ratio(5, 6)*diagonal(8)*gradient(8) + &
7570 second_ratio(5, 8)*diagonal(6)*gradient(6) + &
7571 second_ratio(6, 8)*diagonal(5)*gradient(5) + third_ratio*functional
7572 END IF
7573 IF (ALLOCATED(w%v3sigmalapltau) .AND. has_laplace) THEN
7574 third_ratio = (2.0_dp*(dn(5)*dm(6)*dm(9) + &
7575 dn(6)*dm(5)*dm(9) + dn(9)*dm(5)*dm(6)) - &
7576 6.0_dp*ratio*dm(5)*dm(6)*dm(9))/m**3
7577 w%v3sigmalapltau(10, point) = ratio*diagonal(5)*diagonal(6)*diagonal(9)* &
7578 w%v3sigmalapltau(10, point) + first_ratio(5)*diagonal(6)*diagonal(9)*hessian(6, 9) + &
7579 first_ratio(6)*diagonal(5)*diagonal(9)*hessian(5, 9) + &
7580 first_ratio(9)*diagonal(5)*diagonal(6)*hessian(5, 6) + &
7581 second_ratio(5, 6)*diagonal(9)*gradient(9) + &
7582 second_ratio(5, 9)*diagonal(6)*gradient(6) + &
7583 second_ratio(6, 9)*diagonal(5)*gradient(5) + third_ratio*functional
7584 END IF
7585 IF (ALLOCATED(w%v3sigmalapl2) .AND. has_laplace) THEN
7586 third_ratio = (2.0_dp*(dn(5)*dm(7)*dm(7) + &
7587 dn(7)*dm(5)*dm(7) + dn(7)*dm(5)*dm(7)) - &
7588 6.0_dp*ratio*dm(5)*dm(7)*dm(7))/m**3
7589 w%v3sigmalapl2(9, point) = ratio*diagonal(5)*diagonal(7)*diagonal(7)* &
7590 w%v3sigmalapl2(9, point) + first_ratio(5)*diagonal(7)*diagonal(7)*hessian(7, 7) + &
7591 first_ratio(7)*diagonal(5)*diagonal(7)*hessian(5, 7) + &
7592 first_ratio(7)*diagonal(5)*diagonal(7)*hessian(5, 7) + &
7593 second_ratio(5, 7)*diagonal(7)*gradient(7) + &
7594 second_ratio(5, 7)*diagonal(7)*gradient(7) + &
7595 second_ratio(7, 7)*diagonal(5)*gradient(5) + third_ratio*functional
7596 END IF
7597 IF (ALLOCATED(w%v3sigmalapltau) .AND. has_laplace) THEN
7598 third_ratio = (2.0_dp*(dn(5)*dm(7)*dm(8) + &
7599 dn(7)*dm(5)*dm(8) + dn(8)*dm(5)*dm(7)) - &
7600 6.0_dp*ratio*dm(5)*dm(7)*dm(8))/m**3
7601 w%v3sigmalapltau(11, point) = ratio*diagonal(5)*diagonal(7)*diagonal(8)* &
7602 w%v3sigmalapltau(11, point) + first_ratio(5)*diagonal(7)*diagonal(8)*hessian(7, 8) + &
7603 first_ratio(7)*diagonal(5)*diagonal(8)*hessian(5, 8) + &
7604 first_ratio(8)*diagonal(5)*diagonal(7)*hessian(5, 7) + &
7605 second_ratio(5, 7)*diagonal(8)*gradient(8) + &
7606 second_ratio(5, 8)*diagonal(7)*gradient(7) + &
7607 second_ratio(7, 8)*diagonal(5)*gradient(5) + third_ratio*functional
7608 END IF
7609 IF (ALLOCATED(w%v3sigmalapltau) .AND. has_laplace) THEN
7610 third_ratio = (2.0_dp*(dn(5)*dm(7)*dm(9) + &
7611 dn(7)*dm(5)*dm(9) + dn(9)*dm(5)*dm(7)) - &
7612 6.0_dp*ratio*dm(5)*dm(7)*dm(9))/m**3
7613 w%v3sigmalapltau(12, point) = ratio*diagonal(5)*diagonal(7)*diagonal(9)* &
7614 w%v3sigmalapltau(12, point) + first_ratio(5)*diagonal(7)*diagonal(9)*hessian(7, 9) + &
7615 first_ratio(7)*diagonal(5)*diagonal(9)*hessian(5, 9) + &
7616 first_ratio(9)*diagonal(5)*diagonal(7)*hessian(5, 7) + &
7617 second_ratio(5, 7)*diagonal(9)*gradient(9) + &
7618 second_ratio(5, 9)*diagonal(7)*gradient(7) + &
7619 second_ratio(7, 9)*diagonal(5)*gradient(5) + third_ratio*functional
7620 END IF
7621 IF (ALLOCATED(w%v3sigmatau2) ) THEN
7622 third_ratio = (2.0_dp*(dn(5)*dm(8)*dm(8) + &
7623 dn(8)*dm(5)*dm(8) + dn(8)*dm(5)*dm(8)) - &
7624 6.0_dp*ratio*dm(5)*dm(8)*dm(8))/m**3
7625 w%v3sigmatau2(7, point) = ratio*diagonal(5)*diagonal(8)*diagonal(8)* &
7626 w%v3sigmatau2(7, point) + first_ratio(5)*diagonal(8)*diagonal(8)*hessian(8, 8) + &
7627 first_ratio(8)*diagonal(5)*diagonal(8)*hessian(5, 8) + &
7628 first_ratio(8)*diagonal(5)*diagonal(8)*hessian(5, 8) + &
7629 second_ratio(5, 8)*diagonal(8)*gradient(8) + &
7630 second_ratio(5, 8)*diagonal(8)*gradient(8) + &
7631 second_ratio(8, 8)*diagonal(5)*gradient(5) + third_ratio*functional
7632 END IF
7633 IF (ALLOCATED(w%v3sigmatau2) ) THEN
7634 third_ratio = (2.0_dp*(dn(5)*dm(8)*dm(9) + &
7635 dn(8)*dm(5)*dm(9) + dn(9)*dm(5)*dm(8)) - &
7636 6.0_dp*ratio*dm(5)*dm(8)*dm(9))/m**3
7637 w%v3sigmatau2(8, point) = ratio*diagonal(5)*diagonal(8)*diagonal(9)* &
7638 w%v3sigmatau2(8, point) + first_ratio(5)*diagonal(8)*diagonal(9)*hessian(8, 9) + &
7639 first_ratio(8)*diagonal(5)*diagonal(9)*hessian(5, 9) + &
7640 first_ratio(9)*diagonal(5)*diagonal(8)*hessian(5, 8) + &
7641 second_ratio(5, 8)*diagonal(9)*gradient(9) + &
7642 second_ratio(5, 9)*diagonal(8)*gradient(8) + &
7643 second_ratio(8, 9)*diagonal(5)*gradient(5) + third_ratio*functional
7644 END IF
7645 IF (ALLOCATED(w%v3sigmatau2) ) THEN
7646 third_ratio = (2.0_dp*(dn(5)*dm(9)*dm(9) + &
7647 dn(9)*dm(5)*dm(9) + dn(9)*dm(5)*dm(9)) - &
7648 6.0_dp*ratio*dm(5)*dm(9)*dm(9))/m**3
7649 w%v3sigmatau2(9, point) = ratio*diagonal(5)*diagonal(9)*diagonal(9)* &
7650 w%v3sigmatau2(9, point) + first_ratio(5)*diagonal(9)*diagonal(9)*hessian(9, 9) + &
7651 first_ratio(9)*diagonal(5)*diagonal(9)*hessian(5, 9) + &
7652 first_ratio(9)*diagonal(5)*diagonal(9)*hessian(5, 9) + &
7653 second_ratio(5, 9)*diagonal(9)*gradient(9) + &
7654 second_ratio(5, 9)*diagonal(9)*gradient(9) + &
7655 second_ratio(9, 9)*diagonal(5)*gradient(5) + third_ratio*functional
7656 END IF
7657 IF (ALLOCATED(w%v3lapl3) .AND. has_laplace) THEN
7658 third_ratio = (2.0_dp*(dn(6)*dm(6)*dm(6) + &
7659 dn(6)*dm(6)*dm(6) + dn(6)*dm(6)*dm(6)) - &
7660 6.0_dp*ratio*dm(6)*dm(6)*dm(6))/m**3
7661 w%v3lapl3(1, point) = ratio*diagonal(6)*diagonal(6)*diagonal(6)* &
7662 w%v3lapl3(1, point) + first_ratio(6)*diagonal(6)*diagonal(6)*hessian(6, 6) + &
7663 first_ratio(6)*diagonal(6)*diagonal(6)*hessian(6, 6) + &
7664 first_ratio(6)*diagonal(6)*diagonal(6)*hessian(6, 6) + &
7665 second_ratio(6, 6)*diagonal(6)*gradient(6) + &
7666 second_ratio(6, 6)*diagonal(6)*gradient(6) + &
7667 second_ratio(6, 6)*diagonal(6)*gradient(6) + third_ratio*functional
7668 END IF
7669 IF (ALLOCATED(w%v3lapl3) .AND. has_laplace) THEN
7670 third_ratio = (2.0_dp*(dn(6)*dm(6)*dm(7) + &
7671 dn(6)*dm(6)*dm(7) + dn(7)*dm(6)*dm(6)) - &
7672 6.0_dp*ratio*dm(6)*dm(6)*dm(7))/m**3
7673 w%v3lapl3(2, point) = ratio*diagonal(6)*diagonal(6)*diagonal(7)* &
7674 w%v3lapl3(2, point) + first_ratio(6)*diagonal(6)*diagonal(7)*hessian(6, 7) + &
7675 first_ratio(6)*diagonal(6)*diagonal(7)*hessian(6, 7) + &
7676 first_ratio(7)*diagonal(6)*diagonal(6)*hessian(6, 6) + &
7677 second_ratio(6, 6)*diagonal(7)*gradient(7) + &
7678 second_ratio(6, 7)*diagonal(6)*gradient(6) + &
7679 second_ratio(6, 7)*diagonal(6)*gradient(6) + third_ratio*functional
7680 END IF
7681 IF (ALLOCATED(w%v3lapl2tau) .AND. has_laplace) THEN
7682 third_ratio = (2.0_dp*(dn(6)*dm(6)*dm(8) + &
7683 dn(6)*dm(6)*dm(8) + dn(8)*dm(6)*dm(6)) - &
7684 6.0_dp*ratio*dm(6)*dm(6)*dm(8))/m**3
7685 w%v3lapl2tau(1, point) = ratio*diagonal(6)*diagonal(6)*diagonal(8)* &
7686 w%v3lapl2tau(1, point) + first_ratio(6)*diagonal(6)*diagonal(8)*hessian(6, 8) + &
7687 first_ratio(6)*diagonal(6)*diagonal(8)*hessian(6, 8) + &
7688 first_ratio(8)*diagonal(6)*diagonal(6)*hessian(6, 6) + &
7689 second_ratio(6, 6)*diagonal(8)*gradient(8) + &
7690 second_ratio(6, 8)*diagonal(6)*gradient(6) + &
7691 second_ratio(6, 8)*diagonal(6)*gradient(6) + third_ratio*functional
7692 END IF
7693 IF (ALLOCATED(w%v3lapl2tau) .AND. has_laplace) THEN
7694 third_ratio = (2.0_dp*(dn(6)*dm(6)*dm(9) + &
7695 dn(6)*dm(6)*dm(9) + dn(9)*dm(6)*dm(6)) - &
7696 6.0_dp*ratio*dm(6)*dm(6)*dm(9))/m**3
7697 w%v3lapl2tau(2, point) = ratio*diagonal(6)*diagonal(6)*diagonal(9)* &
7698 w%v3lapl2tau(2, point) + first_ratio(6)*diagonal(6)*diagonal(9)*hessian(6, 9) + &
7699 first_ratio(6)*diagonal(6)*diagonal(9)*hessian(6, 9) + &
7700 first_ratio(9)*diagonal(6)*diagonal(6)*hessian(6, 6) + &
7701 second_ratio(6, 6)*diagonal(9)*gradient(9) + &
7702 second_ratio(6, 9)*diagonal(6)*gradient(6) + &
7703 second_ratio(6, 9)*diagonal(6)*gradient(6) + third_ratio*functional
7704 END IF
7705 IF (ALLOCATED(w%v3lapl3) .AND. has_laplace) THEN
7706 third_ratio = (2.0_dp*(dn(6)*dm(7)*dm(7) + &
7707 dn(7)*dm(6)*dm(7) + dn(7)*dm(6)*dm(7)) - &
7708 6.0_dp*ratio*dm(6)*dm(7)*dm(7))/m**3
7709 w%v3lapl3(3, point) = ratio*diagonal(6)*diagonal(7)*diagonal(7)* &
7710 w%v3lapl3(3, point) + first_ratio(6)*diagonal(7)*diagonal(7)*hessian(7, 7) + &
7711 first_ratio(7)*diagonal(6)*diagonal(7)*hessian(6, 7) + &
7712 first_ratio(7)*diagonal(6)*diagonal(7)*hessian(6, 7) + &
7713 second_ratio(6, 7)*diagonal(7)*gradient(7) + &
7714 second_ratio(6, 7)*diagonal(7)*gradient(7) + &
7715 second_ratio(7, 7)*diagonal(6)*gradient(6) + third_ratio*functional
7716 END IF
7717 IF (ALLOCATED(w%v3lapl2tau) .AND. has_laplace) THEN
7718 third_ratio = (2.0_dp*(dn(6)*dm(7)*dm(8) + &
7719 dn(7)*dm(6)*dm(8) + dn(8)*dm(6)*dm(7)) - &
7720 6.0_dp*ratio*dm(6)*dm(7)*dm(8))/m**3
7721 w%v3lapl2tau(3, point) = ratio*diagonal(6)*diagonal(7)*diagonal(8)* &
7722 w%v3lapl2tau(3, point) + first_ratio(6)*diagonal(7)*diagonal(8)*hessian(7, 8) + &
7723 first_ratio(7)*diagonal(6)*diagonal(8)*hessian(6, 8) + &
7724 first_ratio(8)*diagonal(6)*diagonal(7)*hessian(6, 7) + &
7725 second_ratio(6, 7)*diagonal(8)*gradient(8) + &
7726 second_ratio(6, 8)*diagonal(7)*gradient(7) + &
7727 second_ratio(7, 8)*diagonal(6)*gradient(6) + third_ratio*functional
7728 END IF
7729 IF (ALLOCATED(w%v3lapl2tau) .AND. has_laplace) THEN
7730 third_ratio = (2.0_dp*(dn(6)*dm(7)*dm(9) + &
7731 dn(7)*dm(6)*dm(9) + dn(9)*dm(6)*dm(7)) - &
7732 6.0_dp*ratio*dm(6)*dm(7)*dm(9))/m**3
7733 w%v3lapl2tau(4, point) = ratio*diagonal(6)*diagonal(7)*diagonal(9)* &
7734 w%v3lapl2tau(4, point) + first_ratio(6)*diagonal(7)*diagonal(9)*hessian(7, 9) + &
7735 first_ratio(7)*diagonal(6)*diagonal(9)*hessian(6, 9) + &
7736 first_ratio(9)*diagonal(6)*diagonal(7)*hessian(6, 7) + &
7737 second_ratio(6, 7)*diagonal(9)*gradient(9) + &
7738 second_ratio(6, 9)*diagonal(7)*gradient(7) + &
7739 second_ratio(7, 9)*diagonal(6)*gradient(6) + third_ratio*functional
7740 END IF
7741 IF (ALLOCATED(w%v3lapltau2) .AND. has_laplace) THEN
7742 third_ratio = (2.0_dp*(dn(6)*dm(8)*dm(8) + &
7743 dn(8)*dm(6)*dm(8) + dn(8)*dm(6)*dm(8)) - &
7744 6.0_dp*ratio*dm(6)*dm(8)*dm(8))/m**3
7745 w%v3lapltau2(1, point) = ratio*diagonal(6)*diagonal(8)*diagonal(8)* &
7746 w%v3lapltau2(1, point) + first_ratio(6)*diagonal(8)*diagonal(8)*hessian(8, 8) + &
7747 first_ratio(8)*diagonal(6)*diagonal(8)*hessian(6, 8) + &
7748 first_ratio(8)*diagonal(6)*diagonal(8)*hessian(6, 8) + &
7749 second_ratio(6, 8)*diagonal(8)*gradient(8) + &
7750 second_ratio(6, 8)*diagonal(8)*gradient(8) + &
7751 second_ratio(8, 8)*diagonal(6)*gradient(6) + third_ratio*functional
7752 END IF
7753 IF (ALLOCATED(w%v3lapltau2) .AND. has_laplace) THEN
7754 third_ratio = (2.0_dp*(dn(6)*dm(8)*dm(9) + &
7755 dn(8)*dm(6)*dm(9) + dn(9)*dm(6)*dm(8)) - &
7756 6.0_dp*ratio*dm(6)*dm(8)*dm(9))/m**3
7757 w%v3lapltau2(2, point) = ratio*diagonal(6)*diagonal(8)*diagonal(9)* &
7758 w%v3lapltau2(2, point) + first_ratio(6)*diagonal(8)*diagonal(9)*hessian(8, 9) + &
7759 first_ratio(8)*diagonal(6)*diagonal(9)*hessian(6, 9) + &
7760 first_ratio(9)*diagonal(6)*diagonal(8)*hessian(6, 8) + &
7761 second_ratio(6, 8)*diagonal(9)*gradient(9) + &
7762 second_ratio(6, 9)*diagonal(8)*gradient(8) + &
7763 second_ratio(8, 9)*diagonal(6)*gradient(6) + third_ratio*functional
7764 END IF
7765 IF (ALLOCATED(w%v3lapltau2) .AND. has_laplace) THEN
7766 third_ratio = (2.0_dp*(dn(6)*dm(9)*dm(9) + &
7767 dn(9)*dm(6)*dm(9) + dn(9)*dm(6)*dm(9)) - &
7768 6.0_dp*ratio*dm(6)*dm(9)*dm(9))/m**3
7769 w%v3lapltau2(3, point) = ratio*diagonal(6)*diagonal(9)*diagonal(9)* &
7770 w%v3lapltau2(3, point) + first_ratio(6)*diagonal(9)*diagonal(9)*hessian(9, 9) + &
7771 first_ratio(9)*diagonal(6)*diagonal(9)*hessian(6, 9) + &
7772 first_ratio(9)*diagonal(6)*diagonal(9)*hessian(6, 9) + &
7773 second_ratio(6, 9)*diagonal(9)*gradient(9) + &
7774 second_ratio(6, 9)*diagonal(9)*gradient(9) + &
7775 second_ratio(9, 9)*diagonal(6)*gradient(6) + third_ratio*functional
7776 END IF
7777 IF (ALLOCATED(w%v3lapl3) .AND. has_laplace) THEN
7778 third_ratio = (2.0_dp*(dn(7)*dm(7)*dm(7) + &
7779 dn(7)*dm(7)*dm(7) + dn(7)*dm(7)*dm(7)) - &
7780 6.0_dp*ratio*dm(7)*dm(7)*dm(7))/m**3
7781 w%v3lapl3(4, point) = ratio*diagonal(7)*diagonal(7)*diagonal(7)* &
7782 w%v3lapl3(4, point) + first_ratio(7)*diagonal(7)*diagonal(7)*hessian(7, 7) + &
7783 first_ratio(7)*diagonal(7)*diagonal(7)*hessian(7, 7) + &
7784 first_ratio(7)*diagonal(7)*diagonal(7)*hessian(7, 7) + &
7785 second_ratio(7, 7)*diagonal(7)*gradient(7) + &
7786 second_ratio(7, 7)*diagonal(7)*gradient(7) + &
7787 second_ratio(7, 7)*diagonal(7)*gradient(7) + third_ratio*functional
7788 END IF
7789 IF (ALLOCATED(w%v3lapl2tau) .AND. has_laplace) THEN
7790 third_ratio = (2.0_dp*(dn(7)*dm(7)*dm(8) + &
7791 dn(7)*dm(7)*dm(8) + dn(8)*dm(7)*dm(7)) - &
7792 6.0_dp*ratio*dm(7)*dm(7)*dm(8))/m**3
7793 w%v3lapl2tau(5, point) = ratio*diagonal(7)*diagonal(7)*diagonal(8)* &
7794 w%v3lapl2tau(5, point) + first_ratio(7)*diagonal(7)*diagonal(8)*hessian(7, 8) + &
7795 first_ratio(7)*diagonal(7)*diagonal(8)*hessian(7, 8) + &
7796 first_ratio(8)*diagonal(7)*diagonal(7)*hessian(7, 7) + &
7797 second_ratio(7, 7)*diagonal(8)*gradient(8) + &
7798 second_ratio(7, 8)*diagonal(7)*gradient(7) + &
7799 second_ratio(7, 8)*diagonal(7)*gradient(7) + third_ratio*functional
7800 END IF
7801 IF (ALLOCATED(w%v3lapl2tau) .AND. has_laplace) THEN
7802 third_ratio = (2.0_dp*(dn(7)*dm(7)*dm(9) + &
7803 dn(7)*dm(7)*dm(9) + dn(9)*dm(7)*dm(7)) - &
7804 6.0_dp*ratio*dm(7)*dm(7)*dm(9))/m**3
7805 w%v3lapl2tau(6, point) = ratio*diagonal(7)*diagonal(7)*diagonal(9)* &
7806 w%v3lapl2tau(6, point) + first_ratio(7)*diagonal(7)*diagonal(9)*hessian(7, 9) + &
7807 first_ratio(7)*diagonal(7)*diagonal(9)*hessian(7, 9) + &
7808 first_ratio(9)*diagonal(7)*diagonal(7)*hessian(7, 7) + &
7809 second_ratio(7, 7)*diagonal(9)*gradient(9) + &
7810 second_ratio(7, 9)*diagonal(7)*gradient(7) + &
7811 second_ratio(7, 9)*diagonal(7)*gradient(7) + third_ratio*functional
7812 END IF
7813 IF (ALLOCATED(w%v3lapltau2) .AND. has_laplace) THEN
7814 third_ratio = (2.0_dp*(dn(7)*dm(8)*dm(8) + &
7815 dn(8)*dm(7)*dm(8) + dn(8)*dm(7)*dm(8)) - &
7816 6.0_dp*ratio*dm(7)*dm(8)*dm(8))/m**3
7817 w%v3lapltau2(4, point) = ratio*diagonal(7)*diagonal(8)*diagonal(8)* &
7818 w%v3lapltau2(4, point) + first_ratio(7)*diagonal(8)*diagonal(8)*hessian(8, 8) + &
7819 first_ratio(8)*diagonal(7)*diagonal(8)*hessian(7, 8) + &
7820 first_ratio(8)*diagonal(7)*diagonal(8)*hessian(7, 8) + &
7821 second_ratio(7, 8)*diagonal(8)*gradient(8) + &
7822 second_ratio(7, 8)*diagonal(8)*gradient(8) + &
7823 second_ratio(8, 8)*diagonal(7)*gradient(7) + third_ratio*functional
7824 END IF
7825 IF (ALLOCATED(w%v3lapltau2) .AND. has_laplace) THEN
7826 third_ratio = (2.0_dp*(dn(7)*dm(8)*dm(9) + &
7827 dn(8)*dm(7)*dm(9) + dn(9)*dm(7)*dm(8)) - &
7828 6.0_dp*ratio*dm(7)*dm(8)*dm(9))/m**3
7829 w%v3lapltau2(5, point) = ratio*diagonal(7)*diagonal(8)*diagonal(9)* &
7830 w%v3lapltau2(5, point) + first_ratio(7)*diagonal(8)*diagonal(9)*hessian(8, 9) + &
7831 first_ratio(8)*diagonal(7)*diagonal(9)*hessian(7, 9) + &
7832 first_ratio(9)*diagonal(7)*diagonal(8)*hessian(7, 8) + &
7833 second_ratio(7, 8)*diagonal(9)*gradient(9) + &
7834 second_ratio(7, 9)*diagonal(8)*gradient(8) + &
7835 second_ratio(8, 9)*diagonal(7)*gradient(7) + third_ratio*functional
7836 END IF
7837 IF (ALLOCATED(w%v3lapltau2) .AND. has_laplace) THEN
7838 third_ratio = (2.0_dp*(dn(7)*dm(9)*dm(9) + &
7839 dn(9)*dm(7)*dm(9) + dn(9)*dm(7)*dm(9)) - &
7840 6.0_dp*ratio*dm(7)*dm(9)*dm(9))/m**3
7841 w%v3lapltau2(6, point) = ratio*diagonal(7)*diagonal(9)*diagonal(9)* &
7842 w%v3lapltau2(6, point) + first_ratio(7)*diagonal(9)*diagonal(9)*hessian(9, 9) + &
7843 first_ratio(9)*diagonal(7)*diagonal(9)*hessian(7, 9) + &
7844 first_ratio(9)*diagonal(7)*diagonal(9)*hessian(7, 9) + &
7845 second_ratio(7, 9)*diagonal(9)*gradient(9) + &
7846 second_ratio(7, 9)*diagonal(9)*gradient(9) + &
7847 second_ratio(9, 9)*diagonal(7)*gradient(7) + third_ratio*functional
7848 END IF
7849 IF (ALLOCATED(w%v3tau3) ) THEN
7850 third_ratio = (2.0_dp*(dn(8)*dm(8)*dm(8) + &
7851 dn(8)*dm(8)*dm(8) + dn(8)*dm(8)*dm(8)) - &
7852 6.0_dp*ratio*dm(8)*dm(8)*dm(8))/m**3
7853 w%v3tau3(1, point) = ratio*diagonal(8)*diagonal(8)*diagonal(8)* &
7854 w%v3tau3(1, point) + first_ratio(8)*diagonal(8)*diagonal(8)*hessian(8, 8) + &
7855 first_ratio(8)*diagonal(8)*diagonal(8)*hessian(8, 8) + &
7856 first_ratio(8)*diagonal(8)*diagonal(8)*hessian(8, 8) + &
7857 second_ratio(8, 8)*diagonal(8)*gradient(8) + &
7858 second_ratio(8, 8)*diagonal(8)*gradient(8) + &
7859 second_ratio(8, 8)*diagonal(8)*gradient(8) + third_ratio*functional
7860 END IF
7861 IF (ALLOCATED(w%v3tau3) ) THEN
7862 third_ratio = (2.0_dp*(dn(8)*dm(8)*dm(9) + &
7863 dn(8)*dm(8)*dm(9) + dn(9)*dm(8)*dm(8)) - &
7864 6.0_dp*ratio*dm(8)*dm(8)*dm(9))/m**3
7865 w%v3tau3(2, point) = ratio*diagonal(8)*diagonal(8)*diagonal(9)* &
7866 w%v3tau3(2, point) + first_ratio(8)*diagonal(8)*diagonal(9)*hessian(8, 9) + &
7867 first_ratio(8)*diagonal(8)*diagonal(9)*hessian(8, 9) + &
7868 first_ratio(9)*diagonal(8)*diagonal(8)*hessian(8, 8) + &
7869 second_ratio(8, 8)*diagonal(9)*gradient(9) + &
7870 second_ratio(8, 9)*diagonal(8)*gradient(8) + &
7871 second_ratio(8, 9)*diagonal(8)*gradient(8) + third_ratio*functional
7872 END IF
7873 IF (ALLOCATED(w%v3tau3) ) THEN
7874 third_ratio = (2.0_dp*(dn(8)*dm(9)*dm(9) + &
7875 dn(9)*dm(8)*dm(9) + dn(9)*dm(8)*dm(9)) - &
7876 6.0_dp*ratio*dm(8)*dm(9)*dm(9))/m**3
7877 w%v3tau3(3, point) = ratio*diagonal(8)*diagonal(9)*diagonal(9)* &
7878 w%v3tau3(3, point) + first_ratio(8)*diagonal(9)*diagonal(9)*hessian(9, 9) + &
7879 first_ratio(9)*diagonal(8)*diagonal(9)*hessian(8, 9) + &
7880 first_ratio(9)*diagonal(8)*diagonal(9)*hessian(8, 9) + &
7881 second_ratio(8, 9)*diagonal(9)*gradient(9) + &
7882 second_ratio(8, 9)*diagonal(9)*gradient(9) + &
7883 second_ratio(9, 9)*diagonal(8)*gradient(8) + third_ratio*functional
7884 END IF
7885 IF (ALLOCATED(w%v3tau3) ) THEN
7886 third_ratio = (2.0_dp*(dn(9)*dm(9)*dm(9) + &
7887 dn(9)*dm(9)*dm(9) + dn(9)*dm(9)*dm(9)) - &
7888 6.0_dp*ratio*dm(9)*dm(9)*dm(9))/m**3
7889 w%v3tau3(4, point) = ratio*diagonal(9)*diagonal(9)*diagonal(9)* &
7890 w%v3tau3(4, point) + first_ratio(9)*diagonal(9)*diagonal(9)*hessian(9, 9) + &
7891 first_ratio(9)*diagonal(9)*diagonal(9)*hessian(9, 9) + &
7892 first_ratio(9)*diagonal(9)*diagonal(9)*hessian(9, 9) + &
7893 second_ratio(9, 9)*diagonal(9)*gradient(9) + &
7894 second_ratio(9, 9)*diagonal(9)*gradient(9) + &
7895 second_ratio(9, 9)*diagonal(9)*gradient(9) + third_ratio*functional
7896 END IF
7897 END IF
7898 IF (grad_deriv >= 2) THEN
7899 IF (ALLOCATED(w%v2rho2) ) w%v2rho2(1, point) = &
7900 ratio*diagonal(1)*diagonal(1)*hessian(1, 1) + &
7901 first_ratio(1)*diagonal(1)*gradient(1) + &
7902 first_ratio(1)*diagonal(1)*gradient(1) + second_ratio(1, 1)*functional
7903
7904 IF (ALLOCATED(w%v2rho2) ) w%v2rho2(2, point) = &
7905 ratio*diagonal(1)*diagonal(2)*hessian(1, 2) + &
7906 first_ratio(1)*diagonal(2)*gradient(2) + &
7907 first_ratio(2)*diagonal(1)*gradient(1) + second_ratio(1, 2)*functional
7908
7909 IF (ALLOCATED(w%v2rhosigma) ) w%v2rhosigma(1, point) = &
7910 ratio*diagonal(1)*diagonal(3)*hessian(1, 3) + &
7911 first_ratio(1)*diagonal(3)*gradient(3) + &
7912 first_ratio(3)*diagonal(1)*gradient(1) + second_ratio(1, 3)*functional
7913
7914 IF (ALLOCATED(w%v2rhosigma) ) w%v2rhosigma(2, point) = &
7915 ratio*diagonal(1)*diagonal(4)*hessian(1, 4) + &
7916 first_ratio(1)*diagonal(4)*gradient(4) + &
7917 first_ratio(4)*diagonal(1)*gradient(1) + second_ratio(1, 4)*functional
7918
7919 IF (ALLOCATED(w%v2rhosigma) ) w%v2rhosigma(3, point) = &
7920 ratio*diagonal(1)*diagonal(5)*hessian(1, 5) + &
7921 first_ratio(1)*diagonal(5)*gradient(5) + &
7922 first_ratio(5)*diagonal(1)*gradient(1) + second_ratio(1, 5)*functional
7923
7924 IF (ALLOCATED(w%v2rholapl) .AND. has_laplace) w%v2rholapl(1, point) = &
7925 ratio*diagonal(1)*diagonal(6)*hessian(1, 6) + &
7926 first_ratio(1)*diagonal(6)*gradient(6) + &
7927 first_ratio(6)*diagonal(1)*gradient(1) + second_ratio(1, 6)*functional
7928
7929 IF (ALLOCATED(w%v2rholapl) .AND. has_laplace) w%v2rholapl(2, point) = &
7930 ratio*diagonal(1)*diagonal(7)*hessian(1, 7) + &
7931 first_ratio(1)*diagonal(7)*gradient(7) + &
7932 first_ratio(7)*diagonal(1)*gradient(1) + second_ratio(1, 7)*functional
7933
7934 IF (ALLOCATED(w%v2rhotau) ) w%v2rhotau(1, point) = &
7935 ratio*diagonal(1)*diagonal(8)*hessian(1, 8) + &
7936 first_ratio(1)*diagonal(8)*gradient(8) + &
7937 first_ratio(8)*diagonal(1)*gradient(1) + second_ratio(1, 8)*functional
7938
7939 IF (ALLOCATED(w%v2rhotau) ) w%v2rhotau(2, point) = &
7940 ratio*diagonal(1)*diagonal(9)*hessian(1, 9) + &
7941 first_ratio(1)*diagonal(9)*gradient(9) + &
7942 first_ratio(9)*diagonal(1)*gradient(1) + second_ratio(1, 9)*functional
7943
7944 IF (ALLOCATED(w%v2rho2) ) w%v2rho2(3, point) = &
7945 ratio*diagonal(2)*diagonal(2)*hessian(2, 2) + &
7946 first_ratio(2)*diagonal(2)*gradient(2) + &
7947 first_ratio(2)*diagonal(2)*gradient(2) + second_ratio(2, 2)*functional
7948
7949 IF (ALLOCATED(w%v2rhosigma) ) w%v2rhosigma(4, point) = &
7950 ratio*diagonal(2)*diagonal(3)*hessian(2, 3) + &
7951 first_ratio(2)*diagonal(3)*gradient(3) + &
7952 first_ratio(3)*diagonal(2)*gradient(2) + second_ratio(2, 3)*functional
7953
7954 IF (ALLOCATED(w%v2rhosigma) ) w%v2rhosigma(5, point) = &
7955 ratio*diagonal(2)*diagonal(4)*hessian(2, 4) + &
7956 first_ratio(2)*diagonal(4)*gradient(4) + &
7957 first_ratio(4)*diagonal(2)*gradient(2) + second_ratio(2, 4)*functional
7958
7959 IF (ALLOCATED(w%v2rhosigma) ) w%v2rhosigma(6, point) = &
7960 ratio*diagonal(2)*diagonal(5)*hessian(2, 5) + &
7961 first_ratio(2)*diagonal(5)*gradient(5) + &
7962 first_ratio(5)*diagonal(2)*gradient(2) + second_ratio(2, 5)*functional
7963
7964 IF (ALLOCATED(w%v2rholapl) .AND. has_laplace) w%v2rholapl(3, point) = &
7965 ratio*diagonal(2)*diagonal(6)*hessian(2, 6) + &
7966 first_ratio(2)*diagonal(6)*gradient(6) + &
7967 first_ratio(6)*diagonal(2)*gradient(2) + second_ratio(2, 6)*functional
7968
7969 IF (ALLOCATED(w%v2rholapl) .AND. has_laplace) w%v2rholapl(4, point) = &
7970 ratio*diagonal(2)*diagonal(7)*hessian(2, 7) + &
7971 first_ratio(2)*diagonal(7)*gradient(7) + &
7972 first_ratio(7)*diagonal(2)*gradient(2) + second_ratio(2, 7)*functional
7973
7974 IF (ALLOCATED(w%v2rhotau) ) w%v2rhotau(3, point) = &
7975 ratio*diagonal(2)*diagonal(8)*hessian(2, 8) + &
7976 first_ratio(2)*diagonal(8)*gradient(8) + &
7977 first_ratio(8)*diagonal(2)*gradient(2) + second_ratio(2, 8)*functional
7978
7979 IF (ALLOCATED(w%v2rhotau) ) w%v2rhotau(4, point) = &
7980 ratio*diagonal(2)*diagonal(9)*hessian(2, 9) + &
7981 first_ratio(2)*diagonal(9)*gradient(9) + &
7982 first_ratio(9)*diagonal(2)*gradient(2) + second_ratio(2, 9)*functional
7983
7984 IF (ALLOCATED(w%v2sigma2) ) w%v2sigma2(1, point) = &
7985 ratio*diagonal(3)*diagonal(3)*hessian(3, 3) + &
7986 first_ratio(3)*diagonal(3)*gradient(3) + &
7987 first_ratio(3)*diagonal(3)*gradient(3) + second_ratio(3, 3)*functional
7988
7989 IF (ALLOCATED(w%v2sigma2) ) w%v2sigma2(2, point) = &
7990 ratio*diagonal(3)*diagonal(4)*hessian(3, 4) + &
7991 first_ratio(3)*diagonal(4)*gradient(4) + &
7992 first_ratio(4)*diagonal(3)*gradient(3) + second_ratio(3, 4)*functional
7993
7994 IF (ALLOCATED(w%v2sigma2) ) w%v2sigma2(3, point) = &
7995 ratio*diagonal(3)*diagonal(5)*hessian(3, 5) + &
7996 first_ratio(3)*diagonal(5)*gradient(5) + &
7997 first_ratio(5)*diagonal(3)*gradient(3) + second_ratio(3, 5)*functional
7998
7999 IF (ALLOCATED(w%v2sigmalapl) .AND. has_laplace) w%v2sigmalapl(1, point) = &
8000 ratio*diagonal(3)*diagonal(6)*hessian(3, 6) + &
8001 first_ratio(3)*diagonal(6)*gradient(6) + &
8002 first_ratio(6)*diagonal(3)*gradient(3) + second_ratio(3, 6)*functional
8003
8004 IF (ALLOCATED(w%v2sigmalapl) .AND. has_laplace) w%v2sigmalapl(2, point) = &
8005 ratio*diagonal(3)*diagonal(7)*hessian(3, 7) + &
8006 first_ratio(3)*diagonal(7)*gradient(7) + &
8007 first_ratio(7)*diagonal(3)*gradient(3) + second_ratio(3, 7)*functional
8008
8009 IF (ALLOCATED(w%v2sigmatau) ) w%v2sigmatau(1, point) = &
8010 ratio*diagonal(3)*diagonal(8)*hessian(3, 8) + &
8011 first_ratio(3)*diagonal(8)*gradient(8) + &
8012 first_ratio(8)*diagonal(3)*gradient(3) + second_ratio(3, 8)*functional
8013
8014 IF (ALLOCATED(w%v2sigmatau) ) w%v2sigmatau(2, point) = &
8015 ratio*diagonal(3)*diagonal(9)*hessian(3, 9) + &
8016 first_ratio(3)*diagonal(9)*gradient(9) + &
8017 first_ratio(9)*diagonal(3)*gradient(3) + second_ratio(3, 9)*functional
8018
8019 IF (ALLOCATED(w%v2sigma2) ) w%v2sigma2(4, point) = &
8020 ratio*diagonal(4)*diagonal(4)*hessian(4, 4) + &
8021 first_ratio(4)*diagonal(4)*gradient(4) + &
8022 first_ratio(4)*diagonal(4)*gradient(4) + second_ratio(4, 4)*functional
8023
8024 IF (ALLOCATED(w%v2sigma2) ) w%v2sigma2(5, point) = &
8025 ratio*diagonal(4)*diagonal(5)*hessian(4, 5) + &
8026 first_ratio(4)*diagonal(5)*gradient(5) + &
8027 first_ratio(5)*diagonal(4)*gradient(4) + second_ratio(4, 5)*functional
8028
8029 IF (ALLOCATED(w%v2sigmalapl) .AND. has_laplace) w%v2sigmalapl(3, point) = &
8030 ratio*diagonal(4)*diagonal(6)*hessian(4, 6) + &
8031 first_ratio(4)*diagonal(6)*gradient(6) + &
8032 first_ratio(6)*diagonal(4)*gradient(4) + second_ratio(4, 6)*functional
8033
8034 IF (ALLOCATED(w%v2sigmalapl) .AND. has_laplace) w%v2sigmalapl(4, point) = &
8035 ratio*diagonal(4)*diagonal(7)*hessian(4, 7) + &
8036 first_ratio(4)*diagonal(7)*gradient(7) + &
8037 first_ratio(7)*diagonal(4)*gradient(4) + second_ratio(4, 7)*functional
8038
8039 IF (ALLOCATED(w%v2sigmatau) ) w%v2sigmatau(3, point) = &
8040 ratio*diagonal(4)*diagonal(8)*hessian(4, 8) + &
8041 first_ratio(4)*diagonal(8)*gradient(8) + &
8042 first_ratio(8)*diagonal(4)*gradient(4) + second_ratio(4, 8)*functional
8043
8044 IF (ALLOCATED(w%v2sigmatau) ) w%v2sigmatau(4, point) = &
8045 ratio*diagonal(4)*diagonal(9)*hessian(4, 9) + &
8046 first_ratio(4)*diagonal(9)*gradient(9) + &
8047 first_ratio(9)*diagonal(4)*gradient(4) + second_ratio(4, 9)*functional
8048
8049 IF (ALLOCATED(w%v2sigma2) ) w%v2sigma2(6, point) = &
8050 ratio*diagonal(5)*diagonal(5)*hessian(5, 5) + &
8051 first_ratio(5)*diagonal(5)*gradient(5) + &
8052 first_ratio(5)*diagonal(5)*gradient(5) + second_ratio(5, 5)*functional
8053
8054 IF (ALLOCATED(w%v2sigmalapl) .AND. has_laplace) w%v2sigmalapl(5, point) = &
8055 ratio*diagonal(5)*diagonal(6)*hessian(5, 6) + &
8056 first_ratio(5)*diagonal(6)*gradient(6) + &
8057 first_ratio(6)*diagonal(5)*gradient(5) + second_ratio(5, 6)*functional
8058
8059 IF (ALLOCATED(w%v2sigmalapl) .AND. has_laplace) w%v2sigmalapl(6, point) = &
8060 ratio*diagonal(5)*diagonal(7)*hessian(5, 7) + &
8061 first_ratio(5)*diagonal(7)*gradient(7) + &
8062 first_ratio(7)*diagonal(5)*gradient(5) + second_ratio(5, 7)*functional
8063
8064 IF (ALLOCATED(w%v2sigmatau) ) w%v2sigmatau(5, point) = &
8065 ratio*diagonal(5)*diagonal(8)*hessian(5, 8) + &
8066 first_ratio(5)*diagonal(8)*gradient(8) + &
8067 first_ratio(8)*diagonal(5)*gradient(5) + second_ratio(5, 8)*functional
8068
8069 IF (ALLOCATED(w%v2sigmatau) ) w%v2sigmatau(6, point) = &
8070 ratio*diagonal(5)*diagonal(9)*hessian(5, 9) + &
8071 first_ratio(5)*diagonal(9)*gradient(9) + &
8072 first_ratio(9)*diagonal(5)*gradient(5) + second_ratio(5, 9)*functional
8073
8074 IF (ALLOCATED(w%v2lapl2) .AND. has_laplace) w%v2lapl2(1, point) = &
8075 ratio*diagonal(6)*diagonal(6)*hessian(6, 6) + &
8076 first_ratio(6)*diagonal(6)*gradient(6) + &
8077 first_ratio(6)*diagonal(6)*gradient(6) + second_ratio(6, 6)*functional
8078
8079 IF (ALLOCATED(w%v2lapl2) .AND. has_laplace) w%v2lapl2(2, point) = &
8080 ratio*diagonal(6)*diagonal(7)*hessian(6, 7) + &
8081 first_ratio(6)*diagonal(7)*gradient(7) + &
8082 first_ratio(7)*diagonal(6)*gradient(6) + second_ratio(6, 7)*functional
8083
8084 IF (ALLOCATED(w%v2lapltau) .AND. has_laplace) w%v2lapltau(1, point) = &
8085 ratio*diagonal(6)*diagonal(8)*hessian(6, 8) + &
8086 first_ratio(6)*diagonal(8)*gradient(8) + &
8087 first_ratio(8)*diagonal(6)*gradient(6) + second_ratio(6, 8)*functional
8088
8089 IF (ALLOCATED(w%v2lapltau) .AND. has_laplace) w%v2lapltau(2, point) = &
8090 ratio*diagonal(6)*diagonal(9)*hessian(6, 9) + &
8091 first_ratio(6)*diagonal(9)*gradient(9) + &
8092 first_ratio(9)*diagonal(6)*gradient(6) + second_ratio(6, 9)*functional
8093
8094 IF (ALLOCATED(w%v2lapl2) .AND. has_laplace) w%v2lapl2(3, point) = &
8095 ratio*diagonal(7)*diagonal(7)*hessian(7, 7) + &
8096 first_ratio(7)*diagonal(7)*gradient(7) + &
8097 first_ratio(7)*diagonal(7)*gradient(7) + second_ratio(7, 7)*functional
8098
8099 IF (ALLOCATED(w%v2lapltau) .AND. has_laplace) w%v2lapltau(3, point) = &
8100 ratio*diagonal(7)*diagonal(8)*hessian(7, 8) + &
8101 first_ratio(7)*diagonal(8)*gradient(8) + &
8102 first_ratio(8)*diagonal(7)*gradient(7) + second_ratio(7, 8)*functional
8103
8104 IF (ALLOCATED(w%v2lapltau) .AND. has_laplace) w%v2lapltau(4, point) = &
8105 ratio*diagonal(7)*diagonal(9)*hessian(7, 9) + &
8106 first_ratio(7)*diagonal(9)*gradient(9) + &
8107 first_ratio(9)*diagonal(7)*gradient(7) + second_ratio(7, 9)*functional
8108
8109 IF (ALLOCATED(w%v2tau2) ) w%v2tau2(1, point) = &
8110 ratio*diagonal(8)*diagonal(8)*hessian(8, 8) + &
8111 first_ratio(8)*diagonal(8)*gradient(8) + &
8112 first_ratio(8)*diagonal(8)*gradient(8) + second_ratio(8, 8)*functional
8113
8114 IF (ALLOCATED(w%v2tau2) ) w%v2tau2(2, point) = &
8115 ratio*diagonal(8)*diagonal(9)*hessian(8, 9) + &
8116 first_ratio(8)*diagonal(9)*gradient(9) + &
8117 first_ratio(9)*diagonal(8)*gradient(8) + second_ratio(8, 9)*functional
8118
8119 IF (ALLOCATED(w%v2tau2) ) w%v2tau2(3, point) = &
8120 ratio*diagonal(9)*diagonal(9)*hessian(9, 9) + &
8121 first_ratio(9)*diagonal(9)*gradient(9) + &
8122 first_ratio(9)*diagonal(9)*gradient(9) + second_ratio(9, 9)*functional
8123
8124 END IF
8125 IF (ALLOCATED(w%vrho) ) w%vrho(1, point) = &
8126 ratio*diagonal(1)*gradient(1) + first_ratio(1)*functional
8127
8128 IF (ALLOCATED(w%vrho) ) w%vrho(2, point) = &
8129 ratio*diagonal(2)*gradient(2) + first_ratio(2)*functional
8130
8131 IF (ALLOCATED(w%vsigma) ) w%vsigma(1, point) = &
8132 ratio*diagonal(3)*gradient(3) + first_ratio(3)*functional
8133
8134 IF (ALLOCATED(w%vsigma) ) w%vsigma(2, point) = &
8135 ratio*diagonal(4)*gradient(4) + first_ratio(4)*functional
8136
8137 IF (ALLOCATED(w%vsigma) ) w%vsigma(3, point) = &
8138 ratio*diagonal(5)*gradient(5) + first_ratio(5)*functional
8139
8140 IF (ALLOCATED(w%vlapl) .AND. has_laplace) w%vlapl(1, point) = &
8141 ratio*diagonal(6)*gradient(6) + first_ratio(6)*functional
8142
8143 IF (ALLOCATED(w%vlapl) .AND. has_laplace) w%vlapl(2, point) = &
8144 ratio*diagonal(7)*gradient(7) + first_ratio(7)*functional
8145
8146 IF (ALLOCATED(w%vtau) ) w%vtau(1, point) = &
8147 ratio*diagonal(8)*gradient(8) + first_ratio(8)*functional
8148
8149 IF (ALLOCATED(w%vtau) ) w%vtau(2, point) = &
8150 ratio*diagonal(9)*gradient(9) + first_ratio(9)*functional
8151
8152 END SUBROUTINE libxc_spin_floor_pullback
8153
8154! **************************************************************************************************
8155!> \brief Pull Libxc derivatives back through the negative spin-density clamp.
8156!> \param w Evaluated worker buffers, updated before functional contributions are accumulated.
8157!> \param point Grid point in the worker block.
8158!> \param raw_rho Original alpha and beta densities before MAX(rho,0).
8159!> \param grad_deriv Highest evaluated derivative order.
8160! **************************************************************************************************
8161 SUBROUTINE libxc_spin_density_pullback(w, point, raw_rho, grad_deriv)
8162 TYPE(libxc_worker_type), INTENT(INOUT) :: w
8163 INTEGER, INTENT(IN) :: point, grad_deriv
8164 REAL(dp), INTENT(IN) :: raw_rho(2)
8165
8166 INTEGER :: channel
8167
8168 IF (grad_deriv < 1 .OR. all(raw_rho >= 0.0_dp)) RETURN
8169 DO channel = 1, 2
8170 IF (raw_rho(channel) >= 0.0_dp) cycle
8171 IF (grad_deriv >= 1) THEN
8172 IF (channel == 1) THEN
8173 IF (ALLOCATED(w%vrho)) w%vrho(1, point) = 0.0_dp
8174 END IF
8175 IF (channel == 2) THEN
8176 IF (ALLOCATED(w%vrho)) w%vrho(2, point) = 0.0_dp
8177 END IF
8178 END IF
8179 IF (grad_deriv >= 2) THEN
8180 IF (channel == 1) THEN
8181 IF (ALLOCATED(w%v2rho2)) w%v2rho2(1, point) = 0.0_dp
8182 END IF
8183 IF (channel == 1 .OR. channel == 2) THEN
8184 IF (ALLOCATED(w%v2rho2)) w%v2rho2(2, point) = 0.0_dp
8185 END IF
8186 IF (channel == 1) THEN
8187 IF (ALLOCATED(w%v2rhosigma)) w%v2rhosigma(1, point) = 0.0_dp
8188 END IF
8189 IF (channel == 1) THEN
8190 IF (ALLOCATED(w%v2rhosigma)) w%v2rhosigma(2, point) = 0.0_dp
8191 END IF
8192 IF (channel == 1) THEN
8193 IF (ALLOCATED(w%v2rhosigma)) w%v2rhosigma(3, point) = 0.0_dp
8194 END IF
8195 IF (channel == 1) THEN
8196 IF (ALLOCATED(w%v2rholapl)) w%v2rholapl(1, point) = 0.0_dp
8197 END IF
8198 IF (channel == 1) THEN
8199 IF (ALLOCATED(w%v2rholapl)) w%v2rholapl(2, point) = 0.0_dp
8200 END IF
8201 IF (channel == 1) THEN
8202 IF (ALLOCATED(w%v2rhotau)) w%v2rhotau(1, point) = 0.0_dp
8203 END IF
8204 IF (channel == 1) THEN
8205 IF (ALLOCATED(w%v2rhotau)) w%v2rhotau(2, point) = 0.0_dp
8206 END IF
8207 IF (channel == 2) THEN
8208 IF (ALLOCATED(w%v2rho2)) w%v2rho2(3, point) = 0.0_dp
8209 END IF
8210 IF (channel == 2) THEN
8211 IF (ALLOCATED(w%v2rhosigma)) w%v2rhosigma(4, point) = 0.0_dp
8212 END IF
8213 IF (channel == 2) THEN
8214 IF (ALLOCATED(w%v2rhosigma)) w%v2rhosigma(5, point) = 0.0_dp
8215 END IF
8216 IF (channel == 2) THEN
8217 IF (ALLOCATED(w%v2rhosigma)) w%v2rhosigma(6, point) = 0.0_dp
8218 END IF
8219 IF (channel == 2) THEN
8220 IF (ALLOCATED(w%v2rholapl)) w%v2rholapl(3, point) = 0.0_dp
8221 END IF
8222 IF (channel == 2) THEN
8223 IF (ALLOCATED(w%v2rholapl)) w%v2rholapl(4, point) = 0.0_dp
8224 END IF
8225 IF (channel == 2) THEN
8226 IF (ALLOCATED(w%v2rhotau)) w%v2rhotau(3, point) = 0.0_dp
8227 END IF
8228 IF (channel == 2) THEN
8229 IF (ALLOCATED(w%v2rhotau)) w%v2rhotau(4, point) = 0.0_dp
8230 END IF
8231 END IF
8232 IF (grad_deriv >= 3) THEN
8233 IF (channel == 1) THEN
8234 IF (ALLOCATED(w%v3rho3)) w%v3rho3(1, point) = 0.0_dp
8235 END IF
8236 IF (channel == 1 .OR. channel == 2) THEN
8237 IF (ALLOCATED(w%v3rho3)) w%v3rho3(2, point) = 0.0_dp
8238 END IF
8239 IF (channel == 1) THEN
8240 IF (ALLOCATED(w%v3rho2sigma)) w%v3rho2sigma(1, point) = 0.0_dp
8241 END IF
8242 IF (channel == 1) THEN
8243 IF (ALLOCATED(w%v3rho2sigma)) w%v3rho2sigma(2, point) = 0.0_dp
8244 END IF
8245 IF (channel == 1) THEN
8246 IF (ALLOCATED(w%v3rho2sigma)) w%v3rho2sigma(3, point) = 0.0_dp
8247 END IF
8248 IF (channel == 1) THEN
8249 IF (ALLOCATED(w%v3rho2lapl)) w%v3rho2lapl(1, point) = 0.0_dp
8250 END IF
8251 IF (channel == 1) THEN
8252 IF (ALLOCATED(w%v3rho2lapl)) w%v3rho2lapl(2, point) = 0.0_dp
8253 END IF
8254 IF (channel == 1) THEN
8255 IF (ALLOCATED(w%v3rho2tau)) w%v3rho2tau(1, point) = 0.0_dp
8256 END IF
8257 IF (channel == 1) THEN
8258 IF (ALLOCATED(w%v3rho2tau)) w%v3rho2tau(2, point) = 0.0_dp
8259 END IF
8260 IF (channel == 1 .OR. channel == 2) THEN
8261 IF (ALLOCATED(w%v3rho3)) w%v3rho3(3, point) = 0.0_dp
8262 END IF
8263 IF (channel == 1 .OR. channel == 2) THEN
8264 IF (ALLOCATED(w%v3rho2sigma)) w%v3rho2sigma(4, point) = 0.0_dp
8265 END IF
8266 IF (channel == 1 .OR. channel == 2) THEN
8267 IF (ALLOCATED(w%v3rho2sigma)) w%v3rho2sigma(5, point) = 0.0_dp
8268 END IF
8269 IF (channel == 1 .OR. channel == 2) THEN
8270 IF (ALLOCATED(w%v3rho2sigma)) w%v3rho2sigma(6, point) = 0.0_dp
8271 END IF
8272 IF (channel == 1 .OR. channel == 2) THEN
8273 IF (ALLOCATED(w%v3rho2lapl)) w%v3rho2lapl(3, point) = 0.0_dp
8274 END IF
8275 IF (channel == 1 .OR. channel == 2) THEN
8276 IF (ALLOCATED(w%v3rho2lapl)) w%v3rho2lapl(4, point) = 0.0_dp
8277 END IF
8278 IF (channel == 1 .OR. channel == 2) THEN
8279 IF (ALLOCATED(w%v3rho2tau)) w%v3rho2tau(3, point) = 0.0_dp
8280 END IF
8281 IF (channel == 1 .OR. channel == 2) THEN
8282 IF (ALLOCATED(w%v3rho2tau)) w%v3rho2tau(4, point) = 0.0_dp
8283 END IF
8284 IF (channel == 1) THEN
8285 IF (ALLOCATED(w%v3rhosigma2)) w%v3rhosigma2(1, point) = 0.0_dp
8286 END IF
8287 IF (channel == 1) THEN
8288 IF (ALLOCATED(w%v3rhosigma2)) w%v3rhosigma2(2, point) = 0.0_dp
8289 END IF
8290 IF (channel == 1) THEN
8291 IF (ALLOCATED(w%v3rhosigma2)) w%v3rhosigma2(3, point) = 0.0_dp
8292 END IF
8293 IF (channel == 1) THEN
8294 IF (ALLOCATED(w%v3rhosigmalapl)) w%v3rhosigmalapl(1, point) = 0.0_dp
8295 END IF
8296 IF (channel == 1) THEN
8297 IF (ALLOCATED(w%v3rhosigmalapl)) w%v3rhosigmalapl(2, point) = 0.0_dp
8298 END IF
8299 IF (channel == 1) THEN
8300 IF (ALLOCATED(w%v3rhosigmatau)) w%v3rhosigmatau(1, point) = 0.0_dp
8301 END IF
8302 IF (channel == 1) THEN
8303 IF (ALLOCATED(w%v3rhosigmatau)) w%v3rhosigmatau(2, point) = 0.0_dp
8304 END IF
8305 IF (channel == 1) THEN
8306 IF (ALLOCATED(w%v3rhosigma2)) w%v3rhosigma2(4, point) = 0.0_dp
8307 END IF
8308 IF (channel == 1) THEN
8309 IF (ALLOCATED(w%v3rhosigma2)) w%v3rhosigma2(5, point) = 0.0_dp
8310 END IF
8311 IF (channel == 1) THEN
8312 IF (ALLOCATED(w%v3rhosigmalapl)) w%v3rhosigmalapl(3, point) = 0.0_dp
8313 END IF
8314 IF (channel == 1) THEN
8315 IF (ALLOCATED(w%v3rhosigmalapl)) w%v3rhosigmalapl(4, point) = 0.0_dp
8316 END IF
8317 IF (channel == 1) THEN
8318 IF (ALLOCATED(w%v3rhosigmatau)) w%v3rhosigmatau(3, point) = 0.0_dp
8319 END IF
8320 IF (channel == 1) THEN
8321 IF (ALLOCATED(w%v3rhosigmatau)) w%v3rhosigmatau(4, point) = 0.0_dp
8322 END IF
8323 IF (channel == 1) THEN
8324 IF (ALLOCATED(w%v3rhosigma2)) w%v3rhosigma2(6, point) = 0.0_dp
8325 END IF
8326 IF (channel == 1) THEN
8327 IF (ALLOCATED(w%v3rhosigmalapl)) w%v3rhosigmalapl(5, point) = 0.0_dp
8328 END IF
8329 IF (channel == 1) THEN
8330 IF (ALLOCATED(w%v3rhosigmalapl)) w%v3rhosigmalapl(6, point) = 0.0_dp
8331 END IF
8332 IF (channel == 1) THEN
8333 IF (ALLOCATED(w%v3rhosigmatau)) w%v3rhosigmatau(5, point) = 0.0_dp
8334 END IF
8335 IF (channel == 1) THEN
8336 IF (ALLOCATED(w%v3rhosigmatau)) w%v3rhosigmatau(6, point) = 0.0_dp
8337 END IF
8338 IF (channel == 1) THEN
8339 IF (ALLOCATED(w%v3rholapl2)) w%v3rholapl2(1, point) = 0.0_dp
8340 END IF
8341 IF (channel == 1) THEN
8342 IF (ALLOCATED(w%v3rholapl2)) w%v3rholapl2(2, point) = 0.0_dp
8343 END IF
8344 IF (channel == 1) THEN
8345 IF (ALLOCATED(w%v3rholapltau)) w%v3rholapltau(1, point) = 0.0_dp
8346 END IF
8347 IF (channel == 1) THEN
8348 IF (ALLOCATED(w%v3rholapltau)) w%v3rholapltau(2, point) = 0.0_dp
8349 END IF
8350 IF (channel == 1) THEN
8351 IF (ALLOCATED(w%v3rholapl2)) w%v3rholapl2(3, point) = 0.0_dp
8352 END IF
8353 IF (channel == 1) THEN
8354 IF (ALLOCATED(w%v3rholapltau)) w%v3rholapltau(3, point) = 0.0_dp
8355 END IF
8356 IF (channel == 1) THEN
8357 IF (ALLOCATED(w%v3rholapltau)) w%v3rholapltau(4, point) = 0.0_dp
8358 END IF
8359 IF (channel == 1) THEN
8360 IF (ALLOCATED(w%v3rhotau2)) w%v3rhotau2(1, point) = 0.0_dp
8361 END IF
8362 IF (channel == 1) THEN
8363 IF (ALLOCATED(w%v3rhotau2)) w%v3rhotau2(2, point) = 0.0_dp
8364 END IF
8365 IF (channel == 1) THEN
8366 IF (ALLOCATED(w%v3rhotau2)) w%v3rhotau2(3, point) = 0.0_dp
8367 END IF
8368 IF (channel == 2) THEN
8369 IF (ALLOCATED(w%v3rho3)) w%v3rho3(4, point) = 0.0_dp
8370 END IF
8371 IF (channel == 2) THEN
8372 IF (ALLOCATED(w%v3rho2sigma)) w%v3rho2sigma(7, point) = 0.0_dp
8373 END IF
8374 IF (channel == 2) THEN
8375 IF (ALLOCATED(w%v3rho2sigma)) w%v3rho2sigma(8, point) = 0.0_dp
8376 END IF
8377 IF (channel == 2) THEN
8378 IF (ALLOCATED(w%v3rho2sigma)) w%v3rho2sigma(9, point) = 0.0_dp
8379 END IF
8380 IF (channel == 2) THEN
8381 IF (ALLOCATED(w%v3rho2lapl)) w%v3rho2lapl(5, point) = 0.0_dp
8382 END IF
8383 IF (channel == 2) THEN
8384 IF (ALLOCATED(w%v3rho2lapl)) w%v3rho2lapl(6, point) = 0.0_dp
8385 END IF
8386 IF (channel == 2) THEN
8387 IF (ALLOCATED(w%v3rho2tau)) w%v3rho2tau(5, point) = 0.0_dp
8388 END IF
8389 IF (channel == 2) THEN
8390 IF (ALLOCATED(w%v3rho2tau)) w%v3rho2tau(6, point) = 0.0_dp
8391 END IF
8392 IF (channel == 2) THEN
8393 IF (ALLOCATED(w%v3rhosigma2)) w%v3rhosigma2(7, point) = 0.0_dp
8394 END IF
8395 IF (channel == 2) THEN
8396 IF (ALLOCATED(w%v3rhosigma2)) w%v3rhosigma2(8, point) = 0.0_dp
8397 END IF
8398 IF (channel == 2) THEN
8399 IF (ALLOCATED(w%v3rhosigma2)) w%v3rhosigma2(9, point) = 0.0_dp
8400 END IF
8401 IF (channel == 2) THEN
8402 IF (ALLOCATED(w%v3rhosigmalapl)) w%v3rhosigmalapl(7, point) = 0.0_dp
8403 END IF
8404 IF (channel == 2) THEN
8405 IF (ALLOCATED(w%v3rhosigmalapl)) w%v3rhosigmalapl(8, point) = 0.0_dp
8406 END IF
8407 IF (channel == 2) THEN
8408 IF (ALLOCATED(w%v3rhosigmatau)) w%v3rhosigmatau(7, point) = 0.0_dp
8409 END IF
8410 IF (channel == 2) THEN
8411 IF (ALLOCATED(w%v3rhosigmatau)) w%v3rhosigmatau(8, point) = 0.0_dp
8412 END IF
8413 IF (channel == 2) THEN
8414 IF (ALLOCATED(w%v3rhosigma2)) w%v3rhosigma2(10, point) = 0.0_dp
8415 END IF
8416 IF (channel == 2) THEN
8417 IF (ALLOCATED(w%v3rhosigma2)) w%v3rhosigma2(11, point) = 0.0_dp
8418 END IF
8419 IF (channel == 2) THEN
8420 IF (ALLOCATED(w%v3rhosigmalapl)) w%v3rhosigmalapl(9, point) = 0.0_dp
8421 END IF
8422 IF (channel == 2) THEN
8423 IF (ALLOCATED(w%v3rhosigmalapl)) w%v3rhosigmalapl(10, point) = 0.0_dp
8424 END IF
8425 IF (channel == 2) THEN
8426 IF (ALLOCATED(w%v3rhosigmatau)) w%v3rhosigmatau(9, point) = 0.0_dp
8427 END IF
8428 IF (channel == 2) THEN
8429 IF (ALLOCATED(w%v3rhosigmatau)) w%v3rhosigmatau(10, point) = 0.0_dp
8430 END IF
8431 IF (channel == 2) THEN
8432 IF (ALLOCATED(w%v3rhosigma2)) w%v3rhosigma2(12, point) = 0.0_dp
8433 END IF
8434 IF (channel == 2) THEN
8435 IF (ALLOCATED(w%v3rhosigmalapl)) w%v3rhosigmalapl(11, point) = 0.0_dp
8436 END IF
8437 IF (channel == 2) THEN
8438 IF (ALLOCATED(w%v3rhosigmalapl)) w%v3rhosigmalapl(12, point) = 0.0_dp
8439 END IF
8440 IF (channel == 2) THEN
8441 IF (ALLOCATED(w%v3rhosigmatau)) w%v3rhosigmatau(11, point) = 0.0_dp
8442 END IF
8443 IF (channel == 2) THEN
8444 IF (ALLOCATED(w%v3rhosigmatau)) w%v3rhosigmatau(12, point) = 0.0_dp
8445 END IF
8446 IF (channel == 2) THEN
8447 IF (ALLOCATED(w%v3rholapl2)) w%v3rholapl2(4, point) = 0.0_dp
8448 END IF
8449 IF (channel == 2) THEN
8450 IF (ALLOCATED(w%v3rholapl2)) w%v3rholapl2(5, point) = 0.0_dp
8451 END IF
8452 IF (channel == 2) THEN
8453 IF (ALLOCATED(w%v3rholapltau)) w%v3rholapltau(5, point) = 0.0_dp
8454 END IF
8455 IF (channel == 2) THEN
8456 IF (ALLOCATED(w%v3rholapltau)) w%v3rholapltau(6, point) = 0.0_dp
8457 END IF
8458 IF (channel == 2) THEN
8459 IF (ALLOCATED(w%v3rholapl2)) w%v3rholapl2(6, point) = 0.0_dp
8460 END IF
8461 IF (channel == 2) THEN
8462 IF (ALLOCATED(w%v3rholapltau)) w%v3rholapltau(7, point) = 0.0_dp
8463 END IF
8464 IF (channel == 2) THEN
8465 IF (ALLOCATED(w%v3rholapltau)) w%v3rholapltau(8, point) = 0.0_dp
8466 END IF
8467 IF (channel == 2) THEN
8468 IF (ALLOCATED(w%v3rhotau2)) w%v3rhotau2(4, point) = 0.0_dp
8469 END IF
8470 IF (channel == 2) THEN
8471 IF (ALLOCATED(w%v3rhotau2)) w%v3rhotau2(5, point) = 0.0_dp
8472 END IF
8473 IF (channel == 2) THEN
8474 IF (ALLOCATED(w%v3rhotau2)) w%v3rhotau2(6, point) = 0.0_dp
8475 END IF
8476 END IF
8477 END DO
8478 END SUBROUTINE libxc_spin_density_pullback
8479#endif
8480
8481! **************************************************************************************************
8482!> \brief libxc exchange-correlation functionals
8483!> \param rho density
8484!> \param norm_drho norm of the gradient of the density
8485!> \param laplace_rho laplacian of the density
8486!> \param tau kinetic-energy density
8487!> \param e_0 energy density
8488!> \param e_rho derivative of the energy density with respect to rho
8489!> \param e_ndrho derivative of the energy density with respect to ndrho
8490!> \param e_laplace_rho derivative of the energy density with respect to laplace_rho
8491!> \param e_tau derivative of the energy density with respect to tau
8492!> \param e_rho_rho derivative of the energy density with respect to rho_rho
8493!> \param e_ndrho_rho derivative of the energy density with respect to ndrho_rho
8494!> \param e_ndrho_ndrho derivative of the energy density with respect to ndrho_ndrho
8495!> \param e_rho_laplace_rho derivative of the energy density with respect to rho_laplace_rho
8496!> \param e_rho_tau derivative of the energy density with respect to rho_tau
8497!> \param e_ndrho_laplace_rho derivative of the energy density with respect to ndrho_laplace_rho
8498!> \param e_ndrho_tau derivative of the energy density with respect to ndrho_tau
8499!> \param e_laplace_rho_laplace_rho derivative of the energy density with respect to laplace_rho_laplace_rho
8500!> \param e_laplace_rho_tau derivative of the energy density with respect to laplace_rho_tau
8501!> \param e_tau_tau derivative of the energy density with respect to tau_tau
8502!> \param e_rho_rho_rho derivative of the energy density with respect to rho_rho_rho
8503!> \param grad_deriv maximum degree of the derivative that should be evaluated;
8504!> all derivatives up to the given degree are evaluated, in a single
8505!> LibXC call per block of grid points
8506!> \param npoints number of points on the grid
8507!> \param func_name name of the functional
8508!> \param sc scaling factor of the functional
8509!> \param workers cached LibXC functional objects and staging buffers, one per thread
8510!> \author F. Tran
8511! **************************************************************************************************
8512#if defined (__LIBXC)
8513 SUBROUTINE libxc_spin_unpolarized_calc(rho, norm_drho, laplace_rho, tau, &
8514 e_0, e_rho, e_ndrho, e_laplace_rho, e_tau, e_rho_rho, e_ndrho_rho, &
8515 e_ndrho_ndrho, e_rho_laplace_rho, e_rho_tau, e_ndrho_laplace_rho, &
8516 e_ndrho_tau, e_laplace_rho_laplace_rho, e_laplace_rho_tau, &
8517 e_tau_tau, e_rho_rho_rho, &
8518 e_gamma, &
8519 e_rho_gamma, &
8520 e_gamma_gamma, &
8521 e_gamma_laplace_rho, &
8522 e_gamma_tau, &
8523 e_rho_rho_gamma, &
8524 e_rho_rho_laplace_rho, &
8525 e_rho_rho_tau, &
8526 e_rho_gamma_gamma, &
8527 e_rho_gamma_laplace_rho, &
8528 e_rho_gamma_tau, &
8529 e_rho_laplace_rho_laplace_rho, &
8530 e_rho_laplace_rho_tau, &
8531 e_rho_tau_tau, &
8532 e_gamma_gamma_gamma, &
8533 e_gamma_gamma_laplace_rho, &
8534 e_gamma_gamma_tau, &
8535 e_gamma_laplace_rho_laplace_rho, &
8536 e_gamma_laplace_rho_tau, &
8537 e_gamma_tau_tau, &
8538 e_laplace_rho_laplace_rho_laplace_rho, &
8539 e_laplace_rho_laplace_rho_tau, &
8540 e_laplace_rho_tau_tau, &
8541 e_tau_tau_tau, &
8542 grad_deriv, npoints, func_name, sc, workers)
8543
8544 REAL(kind=dp), DIMENSION(*), INTENT(IN) :: rho, norm_drho, laplace_rho, tau
8545 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_0, e_rho, e_ndrho, e_laplace_rho, e_tau, &
8546 e_rho_rho, e_ndrho_rho, e_ndrho_ndrho, e_rho_laplace_rho, e_rho_tau, e_ndrho_laplace_rho, &
8547 e_ndrho_tau, e_laplace_rho_laplace_rho, e_laplace_rho_tau, e_tau_tau, e_rho_rho_rho
8548 ! Derivatives with respect to the reduced gradient gamma = |grad rho|^2.
8549 ! These are LibXC's own sigma derivatives, copied through unchanged: unlike
8550 ! the norm_drho ones they need no chain rule and carry no 1/|grad rho|.
8551 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma
8552 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rho_gamma
8553 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_gamma
8554 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_laplace_rho
8555 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_tau
8556 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rho_rho_gamma
8557 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rho_rho_laplace_rho
8558 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rho_rho_tau
8559 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rho_gamma_gamma
8560 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rho_gamma_laplace_rho
8561 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rho_gamma_tau
8562 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rho_laplace_rho_laplace_rho
8563 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rho_laplace_rho_tau
8564 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rho_tau_tau
8565 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_gamma_gamma
8566 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_gamma_laplace_rho
8567 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_gamma_tau
8568 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_laplace_rho_laplace_rho
8569 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_laplace_rho_tau
8570 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_tau_tau
8571 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_laplace_rho_laplace_rho_laplace_rho
8572 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_laplace_rho_laplace_rho_tau
8573 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_laplace_rho_tau_tau
8574 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_tau_tau_tau
8575 INTEGER, INTENT(IN) :: grad_deriv, npoints
8576 CHARACTER(LEN=default_string_length), INTENT(IN) :: func_name
8577 REAL(kind=dp), INTENT(IN) :: sc
8578 TYPE(libxc_worker_set_type), INTENT(INOUT), TARGET :: workers
8579
8580 INTEGER :: bsize, family, i, i0, ib, ii, ithread, &
8581 nb, nblocks, nthreads
8582 LOGICAL :: has_laplace, is_gga, is_mgga, no_exc
8583 REAL(kind=dp) :: eps_rho, eps_tau
8584 TYPE(libxc_worker_type), POINTER :: w
8585
8586 ithread = 0
8587 nthreads = 1
8588!$ ithread = omp_get_thread_num()
8589!$ nthreads = omp_get_num_threads()
8590 cpassert(ithread < SIZE(workers%worker))
8591
8592 ! On the GPU path the whole grid is handed to LibXC in a single call (no
8593 ! block cap), so the per-thread staging and device buffers are grown to
8594 ! npoints on demand; one large kernel and one synchronize beat hundreds of
8595 ! cache-sized launches. The CPU/OpenMP blocking is left untouched: cap the
8596 ! block at what the staging buffers were allocated for, but shrink it when
8597 ! there are too few points to give every thread a block of its own, so small
8598 ! atomic grids are not all evaluated by thread 0.
8599 IF (libxc_is_gpu()) THEN
8600 bsize = npoints
8601 ELSE
8602 bsize = max(1, min(workers%worker(1)%nb, (npoints + nthreads - 1)/nthreads))
8603 END IF
8604 nblocks = (npoints + bsize - 1)/bsize
8605
8606 family = workers%family
8607 CALL libxc_family_flags(family, is_gga, is_mgga, trim(func_name))
8608
8609 ! Below the cutoff LibXC leaves outputs at zero, so no test is needed here.
8610 ! Avoid ifx crashes with ASSOCIATE inside the parallel region.
8611 w => workers%worker(ithread + 1)
8612 has_laplace = workers%has_laplace
8613 no_exc = workers%no_exc
8614 eps_rho = workers%epsilon_rho
8615 eps_tau = workers%epsilon_tau
8616 !$OMP DO
8617 DO ib = 1, nblocks
8618 IF (libxc_is_gpu()) CALL libxc_worker_resize_cuda(w, workers%family, workers%nspin, npoints)
8619 i0 = (ib - 1)*bsize
8620 nb = min(bsize, npoints - i0)
8621
8622 ! stage this block's inputs in LibXC's layout
8623 DO i = 1, nb
8624 w%rho(1, i) = rho(i0 + i)
8625 END DO
8626 IF (is_gga) THEN
8627 DO i = 1, nb
8628 w%sigma(1, i) = norm_drho(i0 + i)**2
8629 END DO
8630 END IF
8631 IF (is_mgga) THEN
8632 DO i = 1, nb
8633 ii = i0 + i
8634 w%lapl(1, i) = laplace_rho(ii)
8635 w%tau(1, i) = tau(ii)
8636 END DO
8637 ! Continue at nonpositive tau without discarding finite density.
8638 ! The projection's Jacobian and curvature are applied after evaluation.
8639 DO i = 1, nb
8640 w%tau(1, i) = libxc_c2_project_tau(w%rho(1, i), w%sigma(1, i), tau(i0 + i), eps_rho, eps_tau)
8641 END DO
8642 END IF
8643
8644 ! one LibXC call for the whole block, on the host or the device
8645 CALL libxc_worker_eval(w, workers%family, workers%nspin, grad_deriv, no_exc, nb)
8646 IF (is_mgga .AND. grad_deriv >= 1) THEN
8647 DO i = 1, nb
8648 CALL libxc_mgga_tau_pullback(w, i, [tau(i0 + i)], 1, grad_deriv, has_laplace, eps_rho, eps_tau)
8649 END DO
8650 END IF
8651
8652 ! accumulate; each derivative is added by exactly one loop
8653 DO i = 1, nb
8654 ii = i0 + i
8655 e_0(ii) = e_0(ii) + sc*w%exc(i)*rho(ii)
8656 END DO
8657 IF (grad_deriv >= 1) THEN
8658 DO i = 1, nb
8659 ii = i0 + i
8660 e_rho(ii) = e_rho(ii) + sc*w%vrho(1, i)
8661 END DO
8662 IF (is_gga) THEN
8663 DO i = 1, nb
8664 ii = i0 + i
8665 e_ndrho(ii) = e_ndrho(ii) + sc*2.0_dp*w%vsigma(1, i)*norm_drho(ii)
8666 END DO
8667 DO i = 1, nb
8668 ii = i0 + i
8669 e_gamma(ii) = e_gamma(ii) + sc*w%vsigma(1, i)
8670 END DO
8671 END IF
8672 IF (is_mgga) THEN
8673 DO i = 1, nb
8674 ii = i0 + i
8675 e_tau(ii) = e_tau(ii) + sc*w%vtau(1, i)
8676 END DO
8677 END IF
8678 IF (is_mgga .AND. has_laplace) THEN
8679 DO i = 1, nb
8680 ii = i0 + i
8681 e_laplace_rho(ii) = e_laplace_rho(ii) + sc*w%vlapl(1, i)
8682 END DO
8683 END IF
8684 END IF
8685 IF (grad_deriv >= 2) THEN
8686 DO i = 1, nb
8687 ii = i0 + i
8688 e_rho_rho(ii) = e_rho_rho(ii) + sc*w%v2rho2(1, i)
8689 END DO
8690 IF (is_gga) THEN
8691 DO i = 1, nb
8692 ii = i0 + i
8693 e_ndrho_rho(ii) = e_ndrho_rho(ii) + sc*2.0_dp*w%v2rhosigma(1, i)*norm_drho(ii)
8694 e_ndrho_ndrho(ii) = e_ndrho_ndrho(ii) + &
8695 sc*2.0_dp*(2.0_dp*w%sigma(1, i)*w%v2sigma2(1, i) + w%vsigma(1, i))
8696 END DO
8697 DO i = 1, nb
8698 ii = i0 + i
8699 e_rho_gamma(ii) = e_rho_gamma(ii) + sc*w%v2rhosigma(1, i)
8700 e_gamma_gamma(ii) = e_gamma_gamma(ii) + sc*w%v2sigma2(1, i)
8701 END DO
8702 END IF
8703 IF (is_mgga) THEN
8704 DO i = 1, nb
8705 ii = i0 + i
8706 e_gamma_laplace_rho(ii) = e_gamma_laplace_rho(ii) + sc*w%v2sigmalapl(1, i)
8707 e_gamma_tau(ii) = e_gamma_tau(ii) + sc*w%v2sigmatau(1, i)
8708 e_rho_tau(ii) = e_rho_tau(ii) + sc*w%v2rhotau(1, i)
8709 e_ndrho_tau(ii) = e_ndrho_tau(ii) + sc*2.0_dp*w%v2sigmatau(1, i)*norm_drho(ii)
8710 e_tau_tau(ii) = e_tau_tau(ii) + sc*w%v2tau2(1, i)
8711 END DO
8712 END IF
8713 IF (is_mgga .AND. has_laplace) THEN
8714 DO i = 1, nb
8715 ii = i0 + i
8716 e_rho_laplace_rho(ii) = e_rho_laplace_rho(ii) + sc*w%v2rholapl(1, i)
8717 e_ndrho_laplace_rho(ii) = e_ndrho_laplace_rho(ii) + &
8718 sc*2.0_dp*w%v2sigmalapl(1, i)*norm_drho(ii)
8719 e_laplace_rho_laplace_rho(ii) = e_laplace_rho_laplace_rho(ii) + sc*w%v2lapl2(1, i)
8720 e_laplace_rho_tau(ii) = e_laplace_rho_tau(ii) + sc*w%v2lapltau(1, i)
8721 END DO
8722 END IF
8723 END IF
8724 IF (grad_deriv >= 3) THEN
8725 DO i = 1, nb
8726 ii = i0 + i
8727 e_rho_rho_rho(ii) = e_rho_rho_rho(ii) + sc*w%v3rho3(1, i)
8728 END DO
8729 IF (is_mgga) THEN
8730 DO i = 1, nb
8731 ii = i0 + i
8732 e_rho_rho_gamma(ii) = e_rho_rho_gamma(ii) + sc*w%v3rho2sigma(1, i)
8733 e_rho_rho_laplace_rho(ii) = e_rho_rho_laplace_rho(ii) + sc*w%v3rho2lapl(1, i)
8734 e_rho_rho_tau(ii) = e_rho_rho_tau(ii) + sc*w%v3rho2tau(1, i)
8735 e_rho_gamma_gamma(ii) = e_rho_gamma_gamma(ii) + sc*w%v3rhosigma2(1, i)
8736 e_rho_gamma_laplace_rho(ii) = e_rho_gamma_laplace_rho(ii) + sc*w%v3rhosigmalapl(1, i)
8737 e_rho_gamma_tau(ii) = e_rho_gamma_tau(ii) + sc*w%v3rhosigmatau(1, i)
8738 e_rho_laplace_rho_laplace_rho(ii) = e_rho_laplace_rho_laplace_rho(ii) + sc*w%v3rholapl2(1, i)
8739 e_rho_laplace_rho_tau(ii) = e_rho_laplace_rho_tau(ii) + sc*w%v3rholapltau(1, i)
8740 e_rho_tau_tau(ii) = e_rho_tau_tau(ii) + sc*w%v3rhotau2(1, i)
8741 e_gamma_gamma_gamma(ii) = e_gamma_gamma_gamma(ii) + sc*w%v3sigma3(1, i)
8742 e_gamma_gamma_laplace_rho(ii) = e_gamma_gamma_laplace_rho(ii) + sc*w%v3sigma2lapl(1, i)
8743 e_gamma_gamma_tau(ii) = e_gamma_gamma_tau(ii) + sc*w%v3sigma2tau(1, i)
8744 e_gamma_laplace_rho_laplace_rho(ii) = e_gamma_laplace_rho_laplace_rho(ii) + sc*w%v3sigmalapl2(1, i)
8745 e_gamma_laplace_rho_tau(ii) = e_gamma_laplace_rho_tau(ii) + sc*w%v3sigmalapltau(1, i)
8746 e_gamma_tau_tau(ii) = e_gamma_tau_tau(ii) + sc*w%v3sigmatau2(1, i)
8747 e_laplace_rho_laplace_rho_laplace_rho(ii) = e_laplace_rho_laplace_rho_laplace_rho(ii) + sc*w%v3lapl3(1, i)
8748 e_laplace_rho_laplace_rho_tau(ii) = e_laplace_rho_laplace_rho_tau(ii) + sc*w%v3lapl2tau(1, i)
8749 e_laplace_rho_tau_tau(ii) = e_laplace_rho_tau_tau(ii) + sc*w%v3lapltau2(1, i)
8750 e_tau_tau_tau(ii) = e_tau_tau_tau(ii) + sc*w%v3tau3(1, i)
8751 END DO
8752 ELSE IF (is_gga) THEN
8753 DO i = 1, nb
8754 ii = i0 + i
8755 e_rho_rho_gamma(ii) = e_rho_rho_gamma(ii) + sc*w%v3rho2sigma(1, i)
8756 e_rho_gamma_gamma(ii) = e_rho_gamma_gamma(ii) + sc*w%v3rhosigma2(1, i)
8757 e_gamma_gamma_gamma(ii) = e_gamma_gamma_gamma(ii) + sc*w%v3sigma3(1, i)
8758 END DO
8759 END IF
8760 END IF
8761 END DO
8762!$OMP END DO
8763
8764END SUBROUTINE libxc_spin_unpolarized_calc
8765#endif
8766
8767! **************************************************************************************************
8768!> \brief libxc exchange-correlation functionals
8769!> \param rhoa alpha density
8770!> \param rhob beta density
8771!> \param norm_drho ...
8772!> \param norm_drhoa norm of the gradient of the alpha density
8773!> \param norm_drhob norm of the gradient of the beta density
8774!> \param laplace_rhoa laplacian of the alpha density
8775!> \param laplace_rhob laplacian of the beta density
8776!> \param tau_a alpha kinetic-energy density
8777!> \param tau_b beta kinetic-energy density
8778!> \param e_0 energy density
8779!> \param e_rhoa derivative of the energy density with respect to rhoa
8780!> \param e_rhob derivative of the energy density with respect to rhob
8781!> \param e_ndrho derivative of the energy density with respect to ndrho
8782!> \param e_ndrhoa derivative of the energy density with respect to ndrhoa
8783!> \param e_ndrhob derivative of the energy density with respect to ndrhob
8784!> \param e_laplace_rhoa derivative of the energy density with respect to laplace_rhoa
8785!> \param e_laplace_rhob derivative of the energy density with respect to laplace_rhob
8786!> \param e_tau_a derivative of the energy density with respect to tau_a
8787!> \param e_tau_b derivative of the energy density with respect to tau_b
8788!> \param e_rhoa_rhoa derivative of the energy density with respect to rhoa_rhoa
8789!> \param e_rhoa_rhob derivative of the energy density with respect to rhoa_rhob
8790!> \param e_rhob_rhob derivative of the energy density with respect to rhob_rhob
8791!> \param e_ndrho_rhoa derivative of the energy density with respect to ndrho_rhoa
8792!> \param e_ndrho_rhob derivative of the energy density with respect to ndrho_rhob
8793!> \param e_ndrhoa_rhoa derivative of the energy density with respect to ndrhoa_rhoa
8794!> \param e_ndrhoa_rhob derivative of the energy density with respect to ndrhoa_rhob
8795!> \param e_ndrhob_rhoa derivative of the energy density with respect to ndrhob_rhoa
8796!> \param e_ndrhob_rhob derivative of the energy density with respect to ndrhob_rhob
8797!> \param e_ndrho_ndrho derivative of the energy density with respect to ndrho_ndrho
8798!> \param e_ndrho_ndrhoa derivative of the energy density with respect to ndrho_ndrhoa
8799!> \param e_ndrho_ndrhob derivative of the energy density with respect to ndrho_ndrhob
8800!> \param e_ndrhoa_ndrhoa derivative of the energy density with respect to ndrhoa_ndrhoa
8801!> \param e_ndrhoa_ndrhob derivative of the energy density with respect to ndrhoa_ndrhob
8802!> \param e_ndrhob_ndrhob derivative of the energy density with respect to ndrhob_ndrhob
8803!> \param e_rhoa_laplace_rhoa derivative of the energy density with respect to rhoa_laplace_rhoa
8804!> \param e_rhoa_laplace_rhob derivative of the energy density with respect to rhoa_laplace_rhob
8805!> \param e_rhob_laplace_rhoa derivative of the energy density with respect to rhob_laplace_rhoa
8806!> \param e_rhob_laplace_rhob derivative of the energy density with respect to rhob_laplace_rhob
8807!> \param e_rhoa_tau_a derivative of the energy density with respect to rhoa_tau_a
8808!> \param e_rhoa_tau_b derivative of the energy density with respect to rhoa_tau_b
8809!> \param e_rhob_tau_a derivative of the energy density with respect to rhob_tau_a
8810!> \param e_rhob_tau_b derivative of the energy density with respect to rhob_tau_b
8811!> \param e_ndrho_laplace_rhoa derivative of the energy density with respect to ndrho_laplace_rhoa
8812!> \param e_ndrho_laplace_rhob derivative of the energy density with respect to ndrho_laplace_rhob
8813!> \param e_ndrhoa_laplace_rhoa derivative of the energy density with respect to ndrhoa_laplace_rhoa
8814!> \param e_ndrhoa_laplace_rhob derivative of the energy density with respect to ndrhoa_laplace_rhob
8815!> \param e_ndrhob_laplace_rhoa derivative of the energy density with respect to ndrhob_laplace_rhoa
8816!> \param e_ndrhob_laplace_rhob derivative of the energy density with respect to ndrhob_laplace_rhob
8817!> \param e_ndrho_tau_a derivative of the energy density with respect to ndrho_tau_a
8818!> \param e_ndrho_tau_b derivative of the energy density with respect to ndrho_tau_b
8819!> \param e_ndrhoa_tau_a derivative of the energy density with respect to ndrhoa_tau_a
8820!> \param e_ndrhoa_tau_b derivative of the energy density with respect to ndrhoa_tau_b
8821!> \param e_ndrhob_tau_a derivative of the energy density with respect to ndrhob_tau_a
8822!> \param e_ndrhob_tau_b derivative of the energy density with respect to ndrhob_tau_b
8823!> \param e_laplace_rhoa_laplace_rhoa derivative of the energy density with respect to laplace_rhoa_laplace_rhoa
8824!> \param e_laplace_rhoa_laplace_rhob derivative of the energy density with respect to laplace_rhoa_laplace_rhob
8825!> \param e_laplace_rhob_laplace_rhob derivative of the energy density with respect to laplace_rhob_laplace_rhob
8826!> \param e_laplace_rhoa_tau_a derivative of the energy density with respect to laplace_rhoa_tau_a
8827!> \param e_laplace_rhoa_tau_b derivative of the energy density with respect to laplace_rhoa_tau_b
8828!> \param e_laplace_rhob_tau_a derivative of the energy density with respect to laplace_rhob_tau_a
8829!> \param e_laplace_rhob_tau_b derivative of the energy density with respect to laplace_rhob_tau_b
8830!> \param e_tau_a_tau_a derivative of the energy density with respect to tau_a_tau_a
8831!> \param e_tau_a_tau_b derivative of the energy density with respect to tau_a_tau_b
8832!> \param e_tau_b_tau_b derivative of the energy density with respect to tau_b_tau_b
8833!> \param e_rhoa_rhoa_rhoa derivative of the energy density with respect to rhoa_rhoa_rhoa
8834!> \param e_rhoa_rhoa_rhob derivative of the energy density with respect to rhoa_rhoa_rhob
8835!> \param e_rhoa_rhob_rhob derivative of the energy density with respect to rhoa_rhob_rhob
8836!> \param e_rhob_rhob_rhob derivative of the energy density with respect to rhob_rhob_rhob
8837!> \param grad_deriv maximum degree of the derivative that should be evaluated;
8838!> all derivatives up to the given degree are evaluated, in a single
8839!> LibXC call per block of grid points
8840!> \param npoints number of points on the grid
8841!> \param func_name name of the functional
8842!> \param sc scaling factor of the functional
8843!> \param workers cached LibXC functional objects and staging buffers, one per thread
8844!> \author F. Tran
8845! **************************************************************************************************
8846#if defined (__LIBXC)
8847SUBROUTINE libxc_spin_polarized_calc(rhoa, rhob, norm_drho, norm_drhoa, &
8848 norm_drhob, laplace_rhoa, laplace_rhob, tau_a, tau_b, &
8849 e_0, e_rhoa, e_rhob, e_ndrho, e_ndrhoa, e_ndrhob, &
8850 e_laplace_rhoa, e_laplace_rhob, e_tau_a, e_tau_b, &
8851 e_rhoa_rhoa, e_rhoa_rhob, e_rhob_rhob, &
8852 e_ndrho_rhoa, e_ndrho_rhob, e_ndrhoa_rhoa, &
8853 e_ndrhoa_rhob, e_ndrhob_rhoa, e_ndrhob_rhob, &
8854 e_ndrho_ndrho, e_ndrho_ndrhoa, e_ndrho_ndrhob, &
8855 e_ndrhoa_ndrhoa, e_ndrhoa_ndrhob, e_ndrhob_ndrhob, &
8856 e_rhoa_laplace_rhoa, e_rhoa_laplace_rhob, &
8857 e_rhob_laplace_rhoa, e_rhob_laplace_rhob, &
8858 e_rhoa_tau_a, e_rhoa_tau_b, e_rhob_tau_a, e_rhob_tau_b, &
8859 e_ndrho_laplace_rhoa, e_ndrho_laplace_rhob, &
8860 e_ndrhoa_laplace_rhoa, e_ndrhoa_laplace_rhob, &
8861 e_ndrhob_laplace_rhoa, e_ndrhob_laplace_rhob, &
8862 e_ndrho_tau_a, e_ndrho_tau_b, &
8863 e_ndrhoa_tau_a, e_ndrhoa_tau_b, &
8864 e_ndrhob_tau_a, e_ndrhob_tau_b, &
8865 e_laplace_rhoa_laplace_rhoa, &
8866 e_laplace_rhoa_laplace_rhob, &
8867 e_laplace_rhob_laplace_rhob, &
8868 e_laplace_rhoa_tau_a, e_laplace_rhoa_tau_b, &
8869 e_laplace_rhob_tau_a, e_laplace_rhob_tau_b, &
8870 e_tau_a_tau_a, e_tau_a_tau_b, e_tau_b_tau_b, &
8871 e_rhoa_rhoa_rhoa, e_rhoa_rhoa_rhob, &
8872 e_rhoa_rhob_rhob, e_rhob_rhob_rhob, &
8873 e_gamma_aa, &
8874 e_gamma_ab, &
8875 e_gamma_bb, &
8876 e_rhoa_gamma_aa, &
8877 e_rhoa_gamma_ab, &
8878 e_rhoa_gamma_bb, &
8879 e_rhob_gamma_aa, &
8880 e_rhob_gamma_ab, &
8881 e_rhob_gamma_bb, &
8882 e_gamma_aa_gamma_aa, &
8883 e_gamma_aa_gamma_ab, &
8884 e_gamma_aa_gamma_bb, &
8885 e_gamma_aa_laplace_rhoa, &
8886 e_gamma_aa_laplace_rhob, &
8887 e_gamma_aa_tau_a, &
8888 e_gamma_aa_tau_b, &
8889 e_gamma_ab_gamma_ab, &
8890 e_gamma_ab_gamma_bb, &
8891 e_gamma_ab_laplace_rhoa, &
8892 e_gamma_ab_laplace_rhob, &
8893 e_gamma_ab_tau_a, &
8894 e_gamma_ab_tau_b, &
8895 e_gamma_bb_gamma_bb, &
8896 e_gamma_bb_laplace_rhoa, &
8897 e_gamma_bb_laplace_rhob, &
8898 e_gamma_bb_tau_a, &
8899 e_gamma_bb_tau_b, &
8900 e_rhoa_rhoa_gamma_aa, &
8901 e_rhoa_rhoa_gamma_ab, &
8902 e_rhoa_rhoa_gamma_bb, &
8903 e_rhoa_rhoa_laplace_rhoa, &
8904 e_rhoa_rhoa_laplace_rhob, &
8905 e_rhoa_rhoa_tau_a, &
8906 e_rhoa_rhoa_tau_b, &
8907 e_rhoa_rhob_gamma_aa, &
8908 e_rhoa_rhob_gamma_ab, &
8909 e_rhoa_rhob_gamma_bb, &
8910 e_rhoa_rhob_laplace_rhoa, &
8911 e_rhoa_rhob_laplace_rhob, &
8912 e_rhoa_rhob_tau_a, &
8913 e_rhoa_rhob_tau_b, &
8914 e_rhoa_gamma_aa_gamma_aa, &
8915 e_rhoa_gamma_aa_gamma_ab, &
8916 e_rhoa_gamma_aa_gamma_bb, &
8917 e_rhoa_gamma_aa_laplace_rhoa, &
8918 e_rhoa_gamma_aa_laplace_rhob, &
8919 e_rhoa_gamma_aa_tau_a, &
8920 e_rhoa_gamma_aa_tau_b, &
8921 e_rhoa_gamma_ab_gamma_ab, &
8922 e_rhoa_gamma_ab_gamma_bb, &
8923 e_rhoa_gamma_ab_laplace_rhoa, &
8924 e_rhoa_gamma_ab_laplace_rhob, &
8925 e_rhoa_gamma_ab_tau_a, &
8926 e_rhoa_gamma_ab_tau_b, &
8927 e_rhoa_gamma_bb_gamma_bb, &
8928 e_rhoa_gamma_bb_laplace_rhoa, &
8929 e_rhoa_gamma_bb_laplace_rhob, &
8930 e_rhoa_gamma_bb_tau_a, &
8931 e_rhoa_gamma_bb_tau_b, &
8932 e_rhoa_laplace_rhoa_laplace_rhoa, &
8933 e_rhoa_laplace_rhoa_laplace_rhob, &
8934 e_rhoa_laplace_rhoa_tau_a, &
8935 e_rhoa_laplace_rhoa_tau_b, &
8936 e_rhoa_laplace_rhob_laplace_rhob, &
8937 e_rhoa_laplace_rhob_tau_a, &
8938 e_rhoa_laplace_rhob_tau_b, &
8939 e_rhoa_tau_a_tau_a, &
8940 e_rhoa_tau_a_tau_b, &
8941 e_rhoa_tau_b_tau_b, &
8942 e_rhob_rhob_gamma_aa, &
8943 e_rhob_rhob_gamma_ab, &
8944 e_rhob_rhob_gamma_bb, &
8945 e_rhob_rhob_laplace_rhoa, &
8946 e_rhob_rhob_laplace_rhob, &
8947 e_rhob_rhob_tau_a, &
8948 e_rhob_rhob_tau_b, &
8949 e_rhob_gamma_aa_gamma_aa, &
8950 e_rhob_gamma_aa_gamma_ab, &
8951 e_rhob_gamma_aa_gamma_bb, &
8952 e_rhob_gamma_aa_laplace_rhoa, &
8953 e_rhob_gamma_aa_laplace_rhob, &
8954 e_rhob_gamma_aa_tau_a, &
8955 e_rhob_gamma_aa_tau_b, &
8956 e_rhob_gamma_ab_gamma_ab, &
8957 e_rhob_gamma_ab_gamma_bb, &
8958 e_rhob_gamma_ab_laplace_rhoa, &
8959 e_rhob_gamma_ab_laplace_rhob, &
8960 e_rhob_gamma_ab_tau_a, &
8961 e_rhob_gamma_ab_tau_b, &
8962 e_rhob_gamma_bb_gamma_bb, &
8963 e_rhob_gamma_bb_laplace_rhoa, &
8964 e_rhob_gamma_bb_laplace_rhob, &
8965 e_rhob_gamma_bb_tau_a, &
8966 e_rhob_gamma_bb_tau_b, &
8967 e_rhob_laplace_rhoa_laplace_rhoa, &
8968 e_rhob_laplace_rhoa_laplace_rhob, &
8969 e_rhob_laplace_rhoa_tau_a, &
8970 e_rhob_laplace_rhoa_tau_b, &
8971 e_rhob_laplace_rhob_laplace_rhob, &
8972 e_rhob_laplace_rhob_tau_a, &
8973 e_rhob_laplace_rhob_tau_b, &
8974 e_rhob_tau_a_tau_a, &
8975 e_rhob_tau_a_tau_b, &
8976 e_rhob_tau_b_tau_b, &
8977 e_gamma_aa_gamma_aa_gamma_aa, &
8978 e_gamma_aa_gamma_aa_gamma_ab, &
8979 e_gamma_aa_gamma_aa_gamma_bb, &
8980 e_gamma_aa_gamma_aa_laplace_rhoa, &
8981 e_gamma_aa_gamma_aa_laplace_rhob, &
8982 e_gamma_aa_gamma_aa_tau_a, &
8983 e_gamma_aa_gamma_aa_tau_b, &
8984 e_gamma_aa_gamma_ab_gamma_ab, &
8985 e_gamma_aa_gamma_ab_gamma_bb, &
8986 e_gamma_aa_gamma_ab_laplace_rhoa, &
8987 e_gamma_aa_gamma_ab_laplace_rhob, &
8988 e_gamma_aa_gamma_ab_tau_a, &
8989 e_gamma_aa_gamma_ab_tau_b, &
8990 e_gamma_aa_gamma_bb_gamma_bb, &
8991 e_gamma_aa_gamma_bb_laplace_rhoa, &
8992 e_gamma_aa_gamma_bb_laplace_rhob, &
8993 e_gamma_aa_gamma_bb_tau_a, &
8994 e_gamma_aa_gamma_bb_tau_b, &
8995 e_gamma_aa_laplace_rhoa_laplace_rhoa, &
8996 e_gamma_aa_laplace_rhoa_laplace_rhob, &
8997 e_gamma_aa_laplace_rhoa_tau_a, &
8998 e_gamma_aa_laplace_rhoa_tau_b, &
8999 e_gamma_aa_laplace_rhob_laplace_rhob, &
9000 e_gamma_aa_laplace_rhob_tau_a, &
9001 e_gamma_aa_laplace_rhob_tau_b, &
9002 e_gamma_aa_tau_a_tau_a, &
9003 e_gamma_aa_tau_a_tau_b, &
9004 e_gamma_aa_tau_b_tau_b, &
9005 e_gamma_ab_gamma_ab_gamma_ab, &
9006 e_gamma_ab_gamma_ab_gamma_bb, &
9007 e_gamma_ab_gamma_ab_laplace_rhoa, &
9008 e_gamma_ab_gamma_ab_laplace_rhob, &
9009 e_gamma_ab_gamma_ab_tau_a, &
9010 e_gamma_ab_gamma_ab_tau_b, &
9011 e_gamma_ab_gamma_bb_gamma_bb, &
9012 e_gamma_ab_gamma_bb_laplace_rhoa, &
9013 e_gamma_ab_gamma_bb_laplace_rhob, &
9014 e_gamma_ab_gamma_bb_tau_a, &
9015 e_gamma_ab_gamma_bb_tau_b, &
9016 e_gamma_ab_laplace_rhoa_laplace_rhoa, &
9017 e_gamma_ab_laplace_rhoa_laplace_rhob, &
9018 e_gamma_ab_laplace_rhoa_tau_a, &
9019 e_gamma_ab_laplace_rhoa_tau_b, &
9020 e_gamma_ab_laplace_rhob_laplace_rhob, &
9021 e_gamma_ab_laplace_rhob_tau_a, &
9022 e_gamma_ab_laplace_rhob_tau_b, &
9023 e_gamma_ab_tau_a_tau_a, &
9024 e_gamma_ab_tau_a_tau_b, &
9025 e_gamma_ab_tau_b_tau_b, &
9026 e_gamma_bb_gamma_bb_gamma_bb, &
9027 e_gamma_bb_gamma_bb_laplace_rhoa, &
9028 e_gamma_bb_gamma_bb_laplace_rhob, &
9029 e_gamma_bb_gamma_bb_tau_a, &
9030 e_gamma_bb_gamma_bb_tau_b, &
9031 e_gamma_bb_laplace_rhoa_laplace_rhoa, &
9032 e_gamma_bb_laplace_rhoa_laplace_rhob, &
9033 e_gamma_bb_laplace_rhoa_tau_a, &
9034 e_gamma_bb_laplace_rhoa_tau_b, &
9035 e_gamma_bb_laplace_rhob_laplace_rhob, &
9036 e_gamma_bb_laplace_rhob_tau_a, &
9037 e_gamma_bb_laplace_rhob_tau_b, &
9038 e_gamma_bb_tau_a_tau_a, &
9039 e_gamma_bb_tau_a_tau_b, &
9040 e_gamma_bb_tau_b_tau_b, &
9041 e_laplace_rhoa_laplace_rhoa_laplace_rhoa, &
9042 e_laplace_rhoa_laplace_rhoa_laplace_rhob, &
9043 e_laplace_rhoa_laplace_rhoa_tau_a, &
9044 e_laplace_rhoa_laplace_rhoa_tau_b, &
9045 e_laplace_rhoa_laplace_rhob_laplace_rhob, &
9046 e_laplace_rhoa_laplace_rhob_tau_a, &
9047 e_laplace_rhoa_laplace_rhob_tau_b, &
9048 e_laplace_rhoa_tau_a_tau_a, &
9049 e_laplace_rhoa_tau_a_tau_b, &
9050 e_laplace_rhoa_tau_b_tau_b, &
9051 e_laplace_rhob_laplace_rhob_laplace_rhob, &
9052 e_laplace_rhob_laplace_rhob_tau_a, &
9053 e_laplace_rhob_laplace_rhob_tau_b, &
9054 e_laplace_rhob_tau_a_tau_a, &
9055 e_laplace_rhob_tau_a_tau_b, &
9056 e_laplace_rhob_tau_b_tau_b, &
9057 e_tau_a_tau_a_tau_a, &
9058 e_tau_a_tau_a_tau_b, &
9059 e_tau_a_tau_b_tau_b, &
9060 e_tau_b_tau_b_tau_b, &
9061 grad_deriv, npoints, func_name, sc, workers)
9062
9063REAL(kind=dp), DIMENSION(*), INTENT(IN) :: rhoa, rhob, norm_drho, norm_drhoa, &
9064 norm_drhob, laplace_rhoa, &
9065 laplace_rhob, tau_a, tau_b
9066REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_0, e_rhoa, e_rhob, e_ndrho, e_ndrhoa, &
9067 e_ndrhob, e_laplace_rhoa, e_laplace_rhob, e_tau_a, e_tau_b, e_rhoa_rhoa, e_rhoa_rhob, &
9068 e_rhob_rhob, e_ndrho_rhoa, e_ndrho_rhob, e_ndrhoa_rhoa, e_ndrhoa_rhob, e_ndrhob_rhoa, &
9069 e_ndrhob_rhob, e_ndrho_ndrho, e_ndrho_ndrhoa, e_ndrho_ndrhob, e_ndrhoa_ndrhoa, &
9070 e_ndrhoa_ndrhob, e_ndrhob_ndrhob, e_rhoa_laplace_rhoa, e_rhoa_laplace_rhob, &
9071 e_rhob_laplace_rhoa, e_rhob_laplace_rhob, e_rhoa_tau_a, e_rhoa_tau_b, e_rhob_tau_a, &
9072 e_rhob_tau_b, e_ndrho_laplace_rhoa, e_ndrho_laplace_rhob, e_ndrhoa_laplace_rhoa
9073REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_ndrhoa_laplace_rhob, e_ndrhob_laplace_rhoa, &
9074 e_ndrhob_laplace_rhob, e_ndrho_tau_a, e_ndrho_tau_b, e_ndrhoa_tau_a, e_ndrhoa_tau_b, &
9075 e_ndrhob_tau_a, e_ndrhob_tau_b, e_laplace_rhoa_laplace_rhoa, e_laplace_rhoa_laplace_rhob, &
9076 e_laplace_rhob_laplace_rhob, e_laplace_rhoa_tau_a, e_laplace_rhoa_tau_b, &
9077 e_laplace_rhob_tau_a, e_laplace_rhob_tau_b, e_tau_a_tau_a, e_tau_a_tau_b, e_tau_b_tau_b, &
9078 e_rhoa_rhoa_rhoa, e_rhoa_rhoa_rhob, e_rhoa_rhob_rhob, e_rhob_rhob_rhob
9079 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_aa
9080 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_ab
9081 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_bb
9082 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhoa_gamma_aa
9083 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhoa_gamma_ab
9084 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhoa_gamma_bb
9085 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhob_gamma_aa
9086 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhob_gamma_ab
9087 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhob_gamma_bb
9088 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_aa_gamma_aa
9089 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_aa_gamma_ab
9090 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_aa_gamma_bb
9091 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_aa_laplace_rhoa
9092 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_aa_laplace_rhob
9093 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_aa_tau_a
9094 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_aa_tau_b
9095 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_ab_gamma_ab
9096 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_ab_gamma_bb
9097 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_ab_laplace_rhoa
9098 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_ab_laplace_rhob
9099 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_ab_tau_a
9100 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_ab_tau_b
9101 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_bb_gamma_bb
9102 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_bb_laplace_rhoa
9103 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_bb_laplace_rhob
9104 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_bb_tau_a
9105 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_bb_tau_b
9106 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhoa_rhoa_gamma_aa
9107 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhoa_rhoa_gamma_ab
9108 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhoa_rhoa_gamma_bb
9109 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhoa_rhoa_laplace_rhoa
9110 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhoa_rhoa_laplace_rhob
9111 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhoa_rhoa_tau_a
9112 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhoa_rhoa_tau_b
9113 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhoa_rhob_gamma_aa
9114 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhoa_rhob_gamma_ab
9115 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhoa_rhob_gamma_bb
9116 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhoa_rhob_laplace_rhoa
9117 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhoa_rhob_laplace_rhob
9118 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhoa_rhob_tau_a
9119 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhoa_rhob_tau_b
9120 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhoa_gamma_aa_gamma_aa
9121 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhoa_gamma_aa_gamma_ab
9122 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhoa_gamma_aa_gamma_bb
9123 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhoa_gamma_aa_laplace_rhoa
9124 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhoa_gamma_aa_laplace_rhob
9125 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhoa_gamma_aa_tau_a
9126 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhoa_gamma_aa_tau_b
9127 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhoa_gamma_ab_gamma_ab
9128 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhoa_gamma_ab_gamma_bb
9129 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhoa_gamma_ab_laplace_rhoa
9130 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhoa_gamma_ab_laplace_rhob
9131 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhoa_gamma_ab_tau_a
9132 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhoa_gamma_ab_tau_b
9133 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhoa_gamma_bb_gamma_bb
9134 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhoa_gamma_bb_laplace_rhoa
9135 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhoa_gamma_bb_laplace_rhob
9136 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhoa_gamma_bb_tau_a
9137 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhoa_gamma_bb_tau_b
9138 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhoa_laplace_rhoa_laplace_rhoa
9139 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhoa_laplace_rhoa_laplace_rhob
9140 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhoa_laplace_rhoa_tau_a
9141 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhoa_laplace_rhoa_tau_b
9142 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhoa_laplace_rhob_laplace_rhob
9143 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhoa_laplace_rhob_tau_a
9144 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhoa_laplace_rhob_tau_b
9145 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhoa_tau_a_tau_a
9146 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhoa_tau_a_tau_b
9147 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhoa_tau_b_tau_b
9148 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhob_rhob_gamma_aa
9149 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhob_rhob_gamma_ab
9150 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhob_rhob_gamma_bb
9151 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhob_rhob_laplace_rhoa
9152 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhob_rhob_laplace_rhob
9153 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhob_rhob_tau_a
9154 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhob_rhob_tau_b
9155 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhob_gamma_aa_gamma_aa
9156 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhob_gamma_aa_gamma_ab
9157 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhob_gamma_aa_gamma_bb
9158 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhob_gamma_aa_laplace_rhoa
9159 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhob_gamma_aa_laplace_rhob
9160 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhob_gamma_aa_tau_a
9161 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhob_gamma_aa_tau_b
9162 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhob_gamma_ab_gamma_ab
9163 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhob_gamma_ab_gamma_bb
9164 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhob_gamma_ab_laplace_rhoa
9165 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhob_gamma_ab_laplace_rhob
9166 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhob_gamma_ab_tau_a
9167 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhob_gamma_ab_tau_b
9168 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhob_gamma_bb_gamma_bb
9169 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhob_gamma_bb_laplace_rhoa
9170 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhob_gamma_bb_laplace_rhob
9171 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhob_gamma_bb_tau_a
9172 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhob_gamma_bb_tau_b
9173 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhob_laplace_rhoa_laplace_rhoa
9174 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhob_laplace_rhoa_laplace_rhob
9175 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhob_laplace_rhoa_tau_a
9176 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhob_laplace_rhoa_tau_b
9177 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhob_laplace_rhob_laplace_rhob
9178 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhob_laplace_rhob_tau_a
9179 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhob_laplace_rhob_tau_b
9180 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhob_tau_a_tau_a
9181 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhob_tau_a_tau_b
9182 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rhob_tau_b_tau_b
9183 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_aa_gamma_aa_gamma_aa
9184 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_aa_gamma_aa_gamma_ab
9185 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_aa_gamma_aa_gamma_bb
9186 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_aa_gamma_aa_laplace_rhoa
9187 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_aa_gamma_aa_laplace_rhob
9188 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_aa_gamma_aa_tau_a
9189 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_aa_gamma_aa_tau_b
9190 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_aa_gamma_ab_gamma_ab
9191 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_aa_gamma_ab_gamma_bb
9192 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_aa_gamma_ab_laplace_rhoa
9193 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_aa_gamma_ab_laplace_rhob
9194 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_aa_gamma_ab_tau_a
9195 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_aa_gamma_ab_tau_b
9196 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_aa_gamma_bb_gamma_bb
9197 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_aa_gamma_bb_laplace_rhoa
9198 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_aa_gamma_bb_laplace_rhob
9199 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_aa_gamma_bb_tau_a
9200 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_aa_gamma_bb_tau_b
9201 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_aa_laplace_rhoa_laplace_rhoa
9202 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_aa_laplace_rhoa_laplace_rhob
9203 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_aa_laplace_rhoa_tau_a
9204 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_aa_laplace_rhoa_tau_b
9205 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_aa_laplace_rhob_laplace_rhob
9206 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_aa_laplace_rhob_tau_a
9207 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_aa_laplace_rhob_tau_b
9208 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_aa_tau_a_tau_a
9209 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_aa_tau_a_tau_b
9210 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_aa_tau_b_tau_b
9211 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_ab_gamma_ab_gamma_ab
9212 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_ab_gamma_ab_gamma_bb
9213 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_ab_gamma_ab_laplace_rhoa
9214 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_ab_gamma_ab_laplace_rhob
9215 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_ab_gamma_ab_tau_a
9216 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_ab_gamma_ab_tau_b
9217 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_ab_gamma_bb_gamma_bb
9218 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_ab_gamma_bb_laplace_rhoa
9219 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_ab_gamma_bb_laplace_rhob
9220 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_ab_gamma_bb_tau_a
9221 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_ab_gamma_bb_tau_b
9222 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_ab_laplace_rhoa_laplace_rhoa
9223 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_ab_laplace_rhoa_laplace_rhob
9224 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_ab_laplace_rhoa_tau_a
9225 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_ab_laplace_rhoa_tau_b
9226 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_ab_laplace_rhob_laplace_rhob
9227 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_ab_laplace_rhob_tau_a
9228 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_ab_laplace_rhob_tau_b
9229 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_ab_tau_a_tau_a
9230 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_ab_tau_a_tau_b
9231 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_ab_tau_b_tau_b
9232 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_bb_gamma_bb_gamma_bb
9233 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_bb_gamma_bb_laplace_rhoa
9234 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_bb_gamma_bb_laplace_rhob
9235 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_bb_gamma_bb_tau_a
9236 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_bb_gamma_bb_tau_b
9237 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_bb_laplace_rhoa_laplace_rhoa
9238 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_bb_laplace_rhoa_laplace_rhob
9239 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_bb_laplace_rhoa_tau_a
9240 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_bb_laplace_rhoa_tau_b
9241 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_bb_laplace_rhob_laplace_rhob
9242 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_bb_laplace_rhob_tau_a
9243 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_bb_laplace_rhob_tau_b
9244 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_bb_tau_a_tau_a
9245 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_bb_tau_a_tau_b
9246 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_gamma_bb_tau_b_tau_b
9247 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_laplace_rhoa_laplace_rhoa_laplace_rhoa
9248 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_laplace_rhoa_laplace_rhoa_laplace_rhob
9249 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_laplace_rhoa_laplace_rhoa_tau_a
9250 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_laplace_rhoa_laplace_rhoa_tau_b
9251 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_laplace_rhoa_laplace_rhob_laplace_rhob
9252 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_laplace_rhoa_laplace_rhob_tau_a
9253 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_laplace_rhoa_laplace_rhob_tau_b
9254 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_laplace_rhoa_tau_a_tau_a
9255 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_laplace_rhoa_tau_a_tau_b
9256 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_laplace_rhoa_tau_b_tau_b
9257 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_laplace_rhob_laplace_rhob_laplace_rhob
9258 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_laplace_rhob_laplace_rhob_tau_a
9259 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_laplace_rhob_laplace_rhob_tau_b
9260 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_laplace_rhob_tau_a_tau_a
9261 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_laplace_rhob_tau_a_tau_b
9262 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_laplace_rhob_tau_b_tau_b
9263 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_tau_a_tau_a_tau_a
9264 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_tau_a_tau_a_tau_b
9265 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_tau_a_tau_b_tau_b
9266 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_tau_b_tau_b_tau_b
9267INTEGER, INTENT(IN) :: grad_deriv, npoints
9268CHARACTER(LEN=default_string_length), INTENT(IN) :: func_name
9269REAL(kind=dp), INTENT(IN) :: sc
9270TYPE(libxc_worker_set_type), INTENT(INOUT), TARGET :: workers
9271
9272INTEGER :: bsize, family, i, i0, ib, ii, ithread, &
9273 nb, nblocks, nthreads
9274LOGICAL :: has_laplace, is_gga, is_mgga, no_exc
9275REAL(kind=dp) :: eps_rho, eps_tau
9276TYPE(libxc_worker_type), POINTER :: w
9277
9278ithread = 0
9279nthreads = 1
9280!$ ithread = omp_get_thread_num()
9281!$ nthreads = omp_get_num_threads()
9282cpassert(ithread < SIZE(workers%worker))
9283
9284! See the spin-unpolarized calc: the device is activated per evaluation.
9285
9286! See the spin-unpolarized calc: on the GPU path the whole grid is evaluated
9287! in a single LibXC call, while the CPU/OpenMP path keeps its per-footprint
9288! block cap (shrunk so every thread gets a block on small grids).
9289IF (libxc_is_gpu()) THEN
9290 bsize = npoints
9291ELSE
9292 bsize = max(1, min(workers%worker(1)%nb, (npoints + nthreads - 1)/nthreads))
9293END IF
9294nblocks = (npoints + bsize - 1)/bsize
9295
9296family = workers%family
9297CALL libxc_family_flags(family, is_gga, is_mgga, trim(func_name))
9298
9299! Density and tau cutoffs are applied by LibXC itself, as in the
9300! spin-unpolarized case.
9301! Avoid ifx crashes with ASSOCIATE inside the parallel region.
9302w => workers%worker(ithread + 1)
9303has_laplace = workers%has_laplace
9304no_exc = workers%no_exc
9305eps_rho = workers%epsilon_rho
9306eps_tau = workers%epsilon_tau
9307!$OMP DO
9308DO ib = 1, nblocks
9309 IF (libxc_is_gpu()) CALL libxc_worker_resize_cuda(w, workers%family, workers%nspin, npoints)
9310 i0 = (ib - 1)*bsize
9311 nb = min(bsize, npoints - i0)
9312
9313 ! stage this block's inputs in LibXC's layout
9314 DO i = 1, nb
9315 ii = i0 + i
9316 w%rho(1, i) = max(rhoa(ii), 0.0_dp)
9317 w%rho(2, i) = max(rhob(ii), 0.0_dp)
9318 END DO
9319 IF (is_gga) THEN
9320 ! CP2K works with gradient norms, LibXC with their contractions.
9321 DO i = 1, nb
9322 ii = i0 + i
9323 w%nda(i) = max(norm_drhoa(ii), epsilon(0.0_dp)*1.e4_dp)
9324 w%ndb(i) = max(norm_drhob(ii), epsilon(0.0_dp)*1.e4_dp)
9325 w%nd(i) = max(norm_drho(ii), epsilon(0.0_dp)*1.e4_dp)
9326 w%sigma(1, i) = w%nda(i)**2
9327 w%sigma(3, i) = w%ndb(i)**2
9328 w%sigma(2, i) = 0.5_dp*(w%nd(i)**2 - w%sigma(1, i) - w%sigma(3, i))
9329 END DO
9330 END IF
9331 IF (is_mgga) THEN
9332 DO i = 1, nb
9333 ii = i0 + i
9334 w%lapl(1, i) = laplace_rhoa(ii)
9335 w%lapl(2, i) = laplace_rhob(ii)
9336 w%tau(1, i) = max(tau_a(ii), 0.0_dp)
9337 w%tau(2, i) = max(tau_b(ii), 0.0_dp)
9338 END DO
9339 ! Apply the same continuous kinetic-density projection per spin channel.
9340 DO i = 1, nb
9341 w%tau(1, i) = libxc_c2_project_tau(w%rho(1, i), w%sigma(1, i), tau_a(i0 + i), eps_rho, eps_tau)
9342 w%tau(2, i) = libxc_c2_project_tau(w%rho(2, i), w%sigma(3, i), tau_b(i0 + i), eps_rho, eps_tau)
9343 END DO
9344 END IF
9345
9346 ! one LibXC call for the whole block, on the host or the device
9347 CALL libxc_worker_eval(w, workers%family, workers%nspin, grad_deriv, no_exc, nb)
9348 IF (grad_deriv >= 1 .AND. .NOT. no_exc) THEN
9349 DO i = 1, nb
9350 CALL libxc_spin_floor_pullback(w, i, grad_deriv, has_laplace, eps_rho)
9351 END DO
9352 END IF
9353 IF (is_mgga .AND. grad_deriv >= 1) THEN
9354 DO i = 1, nb
9355 CALL libxc_mgga_tau_pullback(w, i, [tau_a(i0 + i), tau_b(i0 + i)], 2, &
9356 grad_deriv, has_laplace, eps_rho, eps_tau)
9357 END DO
9358 END IF
9359 IF (grad_deriv >= 1) THEN
9360 DO i = 1, nb
9361 CALL libxc_spin_density_pullback(w, i, [rhoa(i0 + i), rhob(i0 + i)], grad_deriv)
9362 END DO
9363 END IF
9364 ! accumulate; one loop per group of derivatives, selected by the
9365 ! order requested and the family
9366 DO i = 1, nb
9367 ii = i0 + i
9368 e_0(ii) = e_0(ii) + sc*w%exc(i)*(w%rho(1, i) + w%rho(2, i))
9369 END DO
9370 IF (grad_deriv >= 1) THEN
9371 DO i = 1, nb
9372 ii = i0 + i
9373 e_rhoa(ii) = e_rhoa(ii) + sc*w%vrho(1, i)
9374 e_rhob(ii) = e_rhob(ii) + sc*w%vrho(2, i)
9375 END DO
9376 IF (is_gga) THEN
9377 DO i = 1, nb
9378 ii = i0 + i
9379 e_ndrho(ii) = e_ndrho(ii) + sc*w%vsigma(2, i)*w%nd(i)
9380 e_ndrhoa(ii) = e_ndrhoa(ii) + &
9381 sc*(2.0_dp*w%vsigma(1, i) - w%vsigma(2, i))*w%nda(i)
9382 e_ndrhob(ii) = e_ndrhob(ii) + &
9383 sc*(2.0_dp*w%vsigma(3, i) - w%vsigma(2, i))*w%ndb(i)
9384 END DO
9385 END IF
9386 IF (is_mgga) THEN
9387 DO i = 1, nb
9388 ii = i0 + i
9389 e_tau_a(ii) = e_tau_a(ii) + sc*w%vtau(1, i)
9390 e_tau_b(ii) = e_tau_b(ii) + sc*w%vtau(2, i)
9391 END DO
9392 END IF
9393 IF (is_mgga .AND. has_laplace) THEN
9394 DO i = 1, nb
9395 ii = i0 + i
9396 e_laplace_rhoa(ii) = e_laplace_rhoa(ii) + sc*w%vlapl(1, i)
9397 e_laplace_rhob(ii) = e_laplace_rhob(ii) + sc*w%vlapl(2, i)
9398 END DO
9399 END IF
9400 END IF
9401 IF (grad_deriv >= 2) THEN
9402 DO i = 1, nb
9403 ii = i0 + i
9404 e_rhoa_rhoa(ii) = e_rhoa_rhoa(ii) + sc*w%v2rho2(1, i)
9405 e_rhoa_rhob(ii) = e_rhoa_rhob(ii) + sc*w%v2rho2(2, i)
9406 e_rhob_rhob(ii) = e_rhob_rhob(ii) + sc*w%v2rho2(3, i)
9407 END DO
9408 IF (is_gga) THEN
9409 DO i = 1, nb
9410 ii = i0 + i
9411 e_ndrho_rhoa(ii) = e_ndrho_rhoa(ii) + sc*w%v2rhosigma(2, i)*w%nd(i)
9412 e_ndrho_rhob(ii) = e_ndrho_rhob(ii) + sc*w%v2rhosigma(5, i)*w%nd(i)
9413 e_ndrhoa_rhoa(ii) = e_ndrhoa_rhoa(ii) + &
9414 sc*(2.0_dp*w%v2rhosigma(1, i) - w%v2rhosigma(2, i))*w%nda(i)
9415 e_ndrhoa_rhob(ii) = e_ndrhoa_rhob(ii) + &
9416 sc*(2.0_dp*w%v2rhosigma(4, i) - w%v2rhosigma(5, i))*w%nda(i)
9417 e_ndrhob_rhoa(ii) = e_ndrhob_rhoa(ii) + &
9418 sc*(2.0_dp*w%v2rhosigma(3, i) - w%v2rhosigma(2, i))*w%ndb(i)
9419 e_ndrhob_rhob(ii) = e_ndrhob_rhob(ii) + &
9420 sc*(2.0_dp*w%v2rhosigma(6, i) - w%v2rhosigma(5, i))*w%ndb(i)
9421 e_ndrho_ndrho(ii) = e_ndrho_ndrho(ii) + &
9422 sc*(w%vsigma(2, i) + w%nd(i)**2*w%v2sigma2(4, i))
9423 e_ndrho_ndrhoa(ii) = e_ndrho_ndrhoa(ii) + &
9424 sc*(2.0_dp*w%v2sigma2(2, i) - w%v2sigma2(4, i))*w%nd(i)*w%nda(i)
9425 e_ndrho_ndrhob(ii) = e_ndrho_ndrhob(ii) + &
9426 sc*(2.0_dp*w%v2sigma2(5, i) - w%v2sigma2(4, i))*w%nd(i)*w%ndb(i)
9427 e_ndrhoa_ndrhoa(ii) = e_ndrhoa_ndrhoa(ii) + &
9428 sc*(2.0_dp*w%vsigma(1, i) - w%vsigma(2, i) + w%nda(i)**2*( &
9429 4.0_dp*w%v2sigma2(1, i) - 4.0_dp*w%v2sigma2(2, i) + w%v2sigma2(4, i)))
9430 e_ndrhoa_ndrhob(ii) = e_ndrhoa_ndrhob(ii) + &
9431 sc*(4.0_dp*w%v2sigma2(3, i) - 2.0_dp*w%v2sigma2(2, i) - &
9432 2.0_dp*w%v2sigma2(5, i) + w%v2sigma2(4, i))*w%nda(i)*w%ndb(i)
9433 e_ndrhob_ndrhob(ii) = e_ndrhob_ndrhob(ii) + &
9434 sc*(2.0_dp*w%vsigma(3, i) - w%vsigma(2, i) + w%ndb(i)**2*( &
9435 4.0_dp*w%v2sigma2(6, i) - 4.0_dp*w%v2sigma2(5, i) + w%v2sigma2(4, i)))
9436 END DO
9437 END IF
9438 IF (is_mgga) THEN
9439 DO i = 1, nb
9440 ii = i0 + i
9441 e_rhoa_tau_a(ii) = e_rhoa_tau_a(ii) + sc*w%v2rhotau(1, i)
9442 e_rhoa_tau_b(ii) = e_rhoa_tau_b(ii) + sc*w%v2rhotau(2, i)
9443 e_rhob_tau_a(ii) = e_rhob_tau_a(ii) + sc*w%v2rhotau(3, i)
9444 e_rhob_tau_b(ii) = e_rhob_tau_b(ii) + sc*w%v2rhotau(4, i)
9445 e_ndrho_tau_a(ii) = e_ndrho_tau_a(ii) + sc*w%v2sigmatau(3, i)*w%nd(i)
9446 e_ndrho_tau_b(ii) = e_ndrho_tau_b(ii) + sc*w%v2sigmatau(4, i)*w%nd(i)
9447 e_ndrhoa_tau_a(ii) = e_ndrhoa_tau_a(ii) + &
9448 sc*(2.0_dp*w%v2sigmatau(1, i) - w%v2sigmatau(3, i))*w%nda(i)
9449 e_ndrhoa_tau_b(ii) = e_ndrhoa_tau_b(ii) + &
9450 sc*(2.0_dp*w%v2sigmatau(2, i) - w%v2sigmatau(4, i))*w%nda(i)
9451 e_ndrhob_tau_a(ii) = e_ndrhob_tau_a(ii) + &
9452 sc*(2.0_dp*w%v2sigmatau(5, i) - w%v2sigmatau(3, i))*w%ndb(i)
9453 e_ndrhob_tau_b(ii) = e_ndrhob_tau_b(ii) + &
9454 sc*(2.0_dp*w%v2sigmatau(6, i) - w%v2sigmatau(4, i))*w%ndb(i)
9455 e_tau_a_tau_a(ii) = e_tau_a_tau_a(ii) + sc*w%v2tau2(1, i)
9456 e_tau_a_tau_b(ii) = e_tau_a_tau_b(ii) + sc*w%v2tau2(2, i)
9457 e_tau_b_tau_b(ii) = e_tau_b_tau_b(ii) + sc*w%v2tau2(3, i)
9458 END DO
9459 END IF
9460 IF (is_mgga .AND. has_laplace) THEN
9461 DO i = 1, nb
9462 ii = i0 + i
9463 e_rhoa_laplace_rhoa(ii) = e_rhoa_laplace_rhoa(ii) + sc*w%v2rholapl(1, i)
9464 e_rhoa_laplace_rhob(ii) = e_rhoa_laplace_rhob(ii) + sc*w%v2rholapl(2, i)
9465 e_rhob_laplace_rhoa(ii) = e_rhob_laplace_rhoa(ii) + sc*w%v2rholapl(3, i)
9466 e_rhob_laplace_rhob(ii) = e_rhob_laplace_rhob(ii) + sc*w%v2rholapl(4, i)
9467 e_ndrho_laplace_rhoa(ii) = e_ndrho_laplace_rhoa(ii) + sc*w%v2sigmalapl(3, i)*w%nd(i)
9468 e_ndrho_laplace_rhob(ii) = e_ndrho_laplace_rhob(ii) + sc*w%v2sigmalapl(4, i)*w%nd(i)
9469 e_ndrhoa_laplace_rhoa(ii) = e_ndrhoa_laplace_rhoa(ii) + &
9470 sc*(2.0_dp*w%v2sigmalapl(1, i) - w%v2sigmalapl(3, i))*w%nda(i)
9471 e_ndrhoa_laplace_rhob(ii) = e_ndrhoa_laplace_rhob(ii) + &
9472 sc*(2.0_dp*w%v2sigmalapl(2, i) - w%v2sigmalapl(4, i))*w%nda(i)
9473 e_ndrhob_laplace_rhoa(ii) = e_ndrhob_laplace_rhoa(ii) + &
9474 sc*(2.0_dp*w%v2sigmalapl(5, i) - w%v2sigmalapl(3, i))*w%ndb(i)
9475 e_ndrhob_laplace_rhob(ii) = e_ndrhob_laplace_rhob(ii) + &
9476 sc*(2.0_dp*w%v2sigmalapl(6, i) - w%v2sigmalapl(4, i))*w%ndb(i)
9477 e_laplace_rhoa_laplace_rhoa(ii) = e_laplace_rhoa_laplace_rhoa(ii) + sc*w%v2lapl2(1, i)
9478 e_laplace_rhoa_laplace_rhob(ii) = e_laplace_rhoa_laplace_rhob(ii) + sc*w%v2lapl2(2, i)
9479 e_laplace_rhob_laplace_rhob(ii) = e_laplace_rhob_laplace_rhob(ii) + sc*w%v2lapl2(3, i)
9480 e_laplace_rhoa_tau_a(ii) = e_laplace_rhoa_tau_a(ii) + sc*w%v2lapltau(1, i)
9481 e_laplace_rhoa_tau_b(ii) = e_laplace_rhoa_tau_b(ii) + sc*w%v2lapltau(2, i)
9482 e_laplace_rhob_tau_a(ii) = e_laplace_rhob_tau_a(ii) + sc*w%v2lapltau(3, i)
9483 e_laplace_rhob_tau_b(ii) = e_laplace_rhob_tau_b(ii) + sc*w%v2lapltau(4, i)
9484 END DO
9485 END IF
9486 END IF
9487 IF (grad_deriv >= 3) THEN
9488 DO i = 1, nb
9489 ii = i0 + i
9490 e_rhoa_rhoa_rhoa(ii) = e_rhoa_rhoa_rhoa(ii) + sc*w%v3rho3(1, i)
9491 e_rhoa_rhoa_rhob(ii) = e_rhoa_rhoa_rhob(ii) + sc*w%v3rho3(2, i)
9492 e_rhoa_rhob_rhob(ii) = e_rhoa_rhob_rhob(ii) + sc*w%v3rho3(3, i)
9493 e_rhob_rhob_rhob(ii) = e_rhob_rhob_rhob(ii) + sc*w%v3rho3(4, i)
9494 END DO
9495 END IF
9496 IF (grad_deriv >= 1 .AND. is_gga) THEN
9497 DO i = 1, nb
9498 ii = i0 + i
9499 e_gamma_aa(ii) = e_gamma_aa(ii) + sc*w%vsigma(1, i)
9500 e_gamma_ab(ii) = e_gamma_ab(ii) + sc*w%vsigma(2, i)
9501 e_gamma_bb(ii) = e_gamma_bb(ii) + sc*w%vsigma(3, i)
9502 END DO
9503 END IF
9504 IF (grad_deriv >= 2 .AND. is_gga) THEN
9505 DO i = 1, nb
9506 ii = i0 + i
9507 e_rhoa_gamma_aa(ii) = e_rhoa_gamma_aa(ii) + sc*w%v2rhosigma(1, i)
9508 e_rhoa_gamma_ab(ii) = e_rhoa_gamma_ab(ii) + sc*w%v2rhosigma(2, i)
9509 e_rhoa_gamma_bb(ii) = e_rhoa_gamma_bb(ii) + sc*w%v2rhosigma(3, i)
9510 e_rhob_gamma_aa(ii) = e_rhob_gamma_aa(ii) + sc*w%v2rhosigma(4, i)
9511 e_rhob_gamma_ab(ii) = e_rhob_gamma_ab(ii) + sc*w%v2rhosigma(5, i)
9512 e_rhob_gamma_bb(ii) = e_rhob_gamma_bb(ii) + sc*w%v2rhosigma(6, i)
9513 e_gamma_aa_gamma_aa(ii) = e_gamma_aa_gamma_aa(ii) + sc*w%v2sigma2(1, i)
9514 e_gamma_aa_gamma_ab(ii) = e_gamma_aa_gamma_ab(ii) + sc*w%v2sigma2(2, i)
9515 e_gamma_aa_gamma_bb(ii) = e_gamma_aa_gamma_bb(ii) + sc*w%v2sigma2(3, i)
9516 e_gamma_ab_gamma_ab(ii) = e_gamma_ab_gamma_ab(ii) + sc*w%v2sigma2(4, i)
9517 e_gamma_ab_gamma_bb(ii) = e_gamma_ab_gamma_bb(ii) + sc*w%v2sigma2(5, i)
9518 e_gamma_bb_gamma_bb(ii) = e_gamma_bb_gamma_bb(ii) + sc*w%v2sigma2(6, i)
9519 END DO
9520 END IF
9521 IF (grad_deriv >= 2 .AND. is_mgga) THEN
9522 DO i = 1, nb
9523 ii = i0 + i
9524 e_gamma_aa_laplace_rhoa(ii) = e_gamma_aa_laplace_rhoa(ii) + sc*w%v2sigmalapl(1, i)
9525 e_gamma_aa_laplace_rhob(ii) = e_gamma_aa_laplace_rhob(ii) + sc*w%v2sigmalapl(2, i)
9526 e_gamma_aa_tau_a(ii) = e_gamma_aa_tau_a(ii) + sc*w%v2sigmatau(1, i)
9527 e_gamma_aa_tau_b(ii) = e_gamma_aa_tau_b(ii) + sc*w%v2sigmatau(2, i)
9528 e_gamma_ab_laplace_rhoa(ii) = e_gamma_ab_laplace_rhoa(ii) + sc*w%v2sigmalapl(3, i)
9529 e_gamma_ab_laplace_rhob(ii) = e_gamma_ab_laplace_rhob(ii) + sc*w%v2sigmalapl(4, i)
9530 e_gamma_ab_tau_a(ii) = e_gamma_ab_tau_a(ii) + sc*w%v2sigmatau(3, i)
9531 e_gamma_ab_tau_b(ii) = e_gamma_ab_tau_b(ii) + sc*w%v2sigmatau(4, i)
9532 e_gamma_bb_laplace_rhoa(ii) = e_gamma_bb_laplace_rhoa(ii) + sc*w%v2sigmalapl(5, i)
9533 e_gamma_bb_laplace_rhob(ii) = e_gamma_bb_laplace_rhob(ii) + sc*w%v2sigmalapl(6, i)
9534 e_gamma_bb_tau_a(ii) = e_gamma_bb_tau_a(ii) + sc*w%v2sigmatau(5, i)
9535 e_gamma_bb_tau_b(ii) = e_gamma_bb_tau_b(ii) + sc*w%v2sigmatau(6, i)
9536 END DO
9537 END IF
9538 IF (grad_deriv >= 3 .AND. is_mgga) THEN
9539 DO i = 1, nb
9540 ii = i0 + i
9541 e_rhoa_rhoa_gamma_aa(ii) = e_rhoa_rhoa_gamma_aa(ii) + sc*w%v3rho2sigma(1, i)
9542 e_rhoa_rhoa_gamma_ab(ii) = e_rhoa_rhoa_gamma_ab(ii) + sc*w%v3rho2sigma(2, i)
9543 e_rhoa_rhoa_gamma_bb(ii) = e_rhoa_rhoa_gamma_bb(ii) + sc*w%v3rho2sigma(3, i)
9544 e_rhoa_rhoa_laplace_rhoa(ii) = e_rhoa_rhoa_laplace_rhoa(ii) + sc*w%v3rho2lapl(1, i)
9545 e_rhoa_rhoa_laplace_rhob(ii) = e_rhoa_rhoa_laplace_rhob(ii) + sc*w%v3rho2lapl(2, i)
9546 e_rhoa_rhoa_tau_a(ii) = e_rhoa_rhoa_tau_a(ii) + sc*w%v3rho2tau(1, i)
9547 e_rhoa_rhoa_tau_b(ii) = e_rhoa_rhoa_tau_b(ii) + sc*w%v3rho2tau(2, i)
9548 e_rhoa_rhob_gamma_aa(ii) = e_rhoa_rhob_gamma_aa(ii) + sc*w%v3rho2sigma(4, i)
9549 e_rhoa_rhob_gamma_ab(ii) = e_rhoa_rhob_gamma_ab(ii) + sc*w%v3rho2sigma(5, i)
9550 e_rhoa_rhob_gamma_bb(ii) = e_rhoa_rhob_gamma_bb(ii) + sc*w%v3rho2sigma(6, i)
9551 e_rhoa_rhob_laplace_rhoa(ii) = e_rhoa_rhob_laplace_rhoa(ii) + sc*w%v3rho2lapl(3, i)
9552 e_rhoa_rhob_laplace_rhob(ii) = e_rhoa_rhob_laplace_rhob(ii) + sc*w%v3rho2lapl(4, i)
9553 e_rhoa_rhob_tau_a(ii) = e_rhoa_rhob_tau_a(ii) + sc*w%v3rho2tau(3, i)
9554 e_rhoa_rhob_tau_b(ii) = e_rhoa_rhob_tau_b(ii) + sc*w%v3rho2tau(4, i)
9555 e_rhoa_gamma_aa_gamma_aa(ii) = e_rhoa_gamma_aa_gamma_aa(ii) + sc*w%v3rhosigma2(1, i)
9556 e_rhoa_gamma_aa_gamma_ab(ii) = e_rhoa_gamma_aa_gamma_ab(ii) + sc*w%v3rhosigma2(2, i)
9557 e_rhoa_gamma_aa_gamma_bb(ii) = e_rhoa_gamma_aa_gamma_bb(ii) + sc*w%v3rhosigma2(3, i)
9558 e_rhoa_gamma_aa_laplace_rhoa(ii) = e_rhoa_gamma_aa_laplace_rhoa(ii) + sc*w%v3rhosigmalapl(1, i)
9559 e_rhoa_gamma_aa_laplace_rhob(ii) = e_rhoa_gamma_aa_laplace_rhob(ii) + sc*w%v3rhosigmalapl(2, i)
9560 e_rhoa_gamma_aa_tau_a(ii) = e_rhoa_gamma_aa_tau_a(ii) + sc*w%v3rhosigmatau(1, i)
9561 e_rhoa_gamma_aa_tau_b(ii) = e_rhoa_gamma_aa_tau_b(ii) + sc*w%v3rhosigmatau(2, i)
9562 e_rhoa_gamma_ab_gamma_ab(ii) = e_rhoa_gamma_ab_gamma_ab(ii) + sc*w%v3rhosigma2(4, i)
9563 e_rhoa_gamma_ab_gamma_bb(ii) = e_rhoa_gamma_ab_gamma_bb(ii) + sc*w%v3rhosigma2(5, i)
9564 e_rhoa_gamma_ab_laplace_rhoa(ii) = e_rhoa_gamma_ab_laplace_rhoa(ii) + sc*w%v3rhosigmalapl(3, i)
9565 e_rhoa_gamma_ab_laplace_rhob(ii) = e_rhoa_gamma_ab_laplace_rhob(ii) + sc*w%v3rhosigmalapl(4, i)
9566 e_rhoa_gamma_ab_tau_a(ii) = e_rhoa_gamma_ab_tau_a(ii) + sc*w%v3rhosigmatau(3, i)
9567 e_rhoa_gamma_ab_tau_b(ii) = e_rhoa_gamma_ab_tau_b(ii) + sc*w%v3rhosigmatau(4, i)
9568 e_rhoa_gamma_bb_gamma_bb(ii) = e_rhoa_gamma_bb_gamma_bb(ii) + sc*w%v3rhosigma2(6, i)
9569 e_rhoa_gamma_bb_laplace_rhoa(ii) = e_rhoa_gamma_bb_laplace_rhoa(ii) + sc*w%v3rhosigmalapl(5, i)
9570 e_rhoa_gamma_bb_laplace_rhob(ii) = e_rhoa_gamma_bb_laplace_rhob(ii) + sc*w%v3rhosigmalapl(6, i)
9571 e_rhoa_gamma_bb_tau_a(ii) = e_rhoa_gamma_bb_tau_a(ii) + sc*w%v3rhosigmatau(5, i)
9572 e_rhoa_gamma_bb_tau_b(ii) = e_rhoa_gamma_bb_tau_b(ii) + sc*w%v3rhosigmatau(6, i)
9573 e_rhoa_laplace_rhoa_laplace_rhoa(ii) = e_rhoa_laplace_rhoa_laplace_rhoa(ii) + sc*w%v3rholapl2(1, i)
9574 e_rhoa_laplace_rhoa_laplace_rhob(ii) = e_rhoa_laplace_rhoa_laplace_rhob(ii) + sc*w%v3rholapl2(2, i)
9575 e_rhoa_laplace_rhoa_tau_a(ii) = e_rhoa_laplace_rhoa_tau_a(ii) + sc*w%v3rholapltau(1, i)
9576 e_rhoa_laplace_rhoa_tau_b(ii) = e_rhoa_laplace_rhoa_tau_b(ii) + sc*w%v3rholapltau(2, i)
9577 e_rhoa_laplace_rhob_laplace_rhob(ii) = e_rhoa_laplace_rhob_laplace_rhob(ii) + sc*w%v3rholapl2(3, i)
9578 e_rhoa_laplace_rhob_tau_a(ii) = e_rhoa_laplace_rhob_tau_a(ii) + sc*w%v3rholapltau(3, i)
9579 e_rhoa_laplace_rhob_tau_b(ii) = e_rhoa_laplace_rhob_tau_b(ii) + sc*w%v3rholapltau(4, i)
9580 e_rhoa_tau_a_tau_a(ii) = e_rhoa_tau_a_tau_a(ii) + sc*w%v3rhotau2(1, i)
9581 e_rhoa_tau_a_tau_b(ii) = e_rhoa_tau_a_tau_b(ii) + sc*w%v3rhotau2(2, i)
9582 e_rhoa_tau_b_tau_b(ii) = e_rhoa_tau_b_tau_b(ii) + sc*w%v3rhotau2(3, i)
9583 e_rhob_rhob_gamma_aa(ii) = e_rhob_rhob_gamma_aa(ii) + sc*w%v3rho2sigma(7, i)
9584 e_rhob_rhob_gamma_ab(ii) = e_rhob_rhob_gamma_ab(ii) + sc*w%v3rho2sigma(8, i)
9585 e_rhob_rhob_gamma_bb(ii) = e_rhob_rhob_gamma_bb(ii) + sc*w%v3rho2sigma(9, i)
9586 e_rhob_rhob_laplace_rhoa(ii) = e_rhob_rhob_laplace_rhoa(ii) + sc*w%v3rho2lapl(5, i)
9587 e_rhob_rhob_laplace_rhob(ii) = e_rhob_rhob_laplace_rhob(ii) + sc*w%v3rho2lapl(6, i)
9588 e_rhob_rhob_tau_a(ii) = e_rhob_rhob_tau_a(ii) + sc*w%v3rho2tau(5, i)
9589 e_rhob_rhob_tau_b(ii) = e_rhob_rhob_tau_b(ii) + sc*w%v3rho2tau(6, i)
9590 e_rhob_gamma_aa_gamma_aa(ii) = e_rhob_gamma_aa_gamma_aa(ii) + sc*w%v3rhosigma2(7, i)
9591 e_rhob_gamma_aa_gamma_ab(ii) = e_rhob_gamma_aa_gamma_ab(ii) + sc*w%v3rhosigma2(8, i)
9592 e_rhob_gamma_aa_gamma_bb(ii) = e_rhob_gamma_aa_gamma_bb(ii) + sc*w%v3rhosigma2(9, i)
9593 e_rhob_gamma_aa_laplace_rhoa(ii) = e_rhob_gamma_aa_laplace_rhoa(ii) + sc*w%v3rhosigmalapl(7, i)
9594 e_rhob_gamma_aa_laplace_rhob(ii) = e_rhob_gamma_aa_laplace_rhob(ii) + sc*w%v3rhosigmalapl(8, i)
9595 e_rhob_gamma_aa_tau_a(ii) = e_rhob_gamma_aa_tau_a(ii) + sc*w%v3rhosigmatau(7, i)
9596 e_rhob_gamma_aa_tau_b(ii) = e_rhob_gamma_aa_tau_b(ii) + sc*w%v3rhosigmatau(8, i)
9597 e_rhob_gamma_ab_gamma_ab(ii) = e_rhob_gamma_ab_gamma_ab(ii) + sc*w%v3rhosigma2(10, i)
9598 e_rhob_gamma_ab_gamma_bb(ii) = e_rhob_gamma_ab_gamma_bb(ii) + sc*w%v3rhosigma2(11, i)
9599 e_rhob_gamma_ab_laplace_rhoa(ii) = e_rhob_gamma_ab_laplace_rhoa(ii) + sc*w%v3rhosigmalapl(9, i)
9600 e_rhob_gamma_ab_laplace_rhob(ii) = e_rhob_gamma_ab_laplace_rhob(ii) + sc*w%v3rhosigmalapl(10, i)
9601 e_rhob_gamma_ab_tau_a(ii) = e_rhob_gamma_ab_tau_a(ii) + sc*w%v3rhosigmatau(9, i)
9602 e_rhob_gamma_ab_tau_b(ii) = e_rhob_gamma_ab_tau_b(ii) + sc*w%v3rhosigmatau(10, i)
9603 e_rhob_gamma_bb_gamma_bb(ii) = e_rhob_gamma_bb_gamma_bb(ii) + sc*w%v3rhosigma2(12, i)
9604 e_rhob_gamma_bb_laplace_rhoa(ii) = e_rhob_gamma_bb_laplace_rhoa(ii) + sc*w%v3rhosigmalapl(11, i)
9605 e_rhob_gamma_bb_laplace_rhob(ii) = e_rhob_gamma_bb_laplace_rhob(ii) + sc*w%v3rhosigmalapl(12, i)
9606 e_rhob_gamma_bb_tau_a(ii) = e_rhob_gamma_bb_tau_a(ii) + sc*w%v3rhosigmatau(11, i)
9607 e_rhob_gamma_bb_tau_b(ii) = e_rhob_gamma_bb_tau_b(ii) + sc*w%v3rhosigmatau(12, i)
9608 e_rhob_laplace_rhoa_laplace_rhoa(ii) = e_rhob_laplace_rhoa_laplace_rhoa(ii) + sc*w%v3rholapl2(4, i)
9609 e_rhob_laplace_rhoa_laplace_rhob(ii) = e_rhob_laplace_rhoa_laplace_rhob(ii) + sc*w%v3rholapl2(5, i)
9610 e_rhob_laplace_rhoa_tau_a(ii) = e_rhob_laplace_rhoa_tau_a(ii) + sc*w%v3rholapltau(5, i)
9611 e_rhob_laplace_rhoa_tau_b(ii) = e_rhob_laplace_rhoa_tau_b(ii) + sc*w%v3rholapltau(6, i)
9612 e_rhob_laplace_rhob_laplace_rhob(ii) = e_rhob_laplace_rhob_laplace_rhob(ii) + sc*w%v3rholapl2(6, i)
9613 e_rhob_laplace_rhob_tau_a(ii) = e_rhob_laplace_rhob_tau_a(ii) + sc*w%v3rholapltau(7, i)
9614 e_rhob_laplace_rhob_tau_b(ii) = e_rhob_laplace_rhob_tau_b(ii) + sc*w%v3rholapltau(8, i)
9615 e_rhob_tau_a_tau_a(ii) = e_rhob_tau_a_tau_a(ii) + sc*w%v3rhotau2(4, i)
9616 e_rhob_tau_a_tau_b(ii) = e_rhob_tau_a_tau_b(ii) + sc*w%v3rhotau2(5, i)
9617 e_rhob_tau_b_tau_b(ii) = e_rhob_tau_b_tau_b(ii) + sc*w%v3rhotau2(6, i)
9618 e_gamma_aa_gamma_aa_gamma_aa(ii) = e_gamma_aa_gamma_aa_gamma_aa(ii) + sc*w%v3sigma3(1, i)
9619 e_gamma_aa_gamma_aa_gamma_ab(ii) = e_gamma_aa_gamma_aa_gamma_ab(ii) + sc*w%v3sigma3(2, i)
9620 e_gamma_aa_gamma_aa_gamma_bb(ii) = e_gamma_aa_gamma_aa_gamma_bb(ii) + sc*w%v3sigma3(3, i)
9621 e_gamma_aa_gamma_aa_laplace_rhoa(ii) = e_gamma_aa_gamma_aa_laplace_rhoa(ii) + sc*w%v3sigma2lapl(1, i)
9622 e_gamma_aa_gamma_aa_laplace_rhob(ii) = e_gamma_aa_gamma_aa_laplace_rhob(ii) + sc*w%v3sigma2lapl(2, i)
9623 e_gamma_aa_gamma_aa_tau_a(ii) = e_gamma_aa_gamma_aa_tau_a(ii) + sc*w%v3sigma2tau(1, i)
9624 e_gamma_aa_gamma_aa_tau_b(ii) = e_gamma_aa_gamma_aa_tau_b(ii) + sc*w%v3sigma2tau(2, i)
9625 e_gamma_aa_gamma_ab_gamma_ab(ii) = e_gamma_aa_gamma_ab_gamma_ab(ii) + sc*w%v3sigma3(4, i)
9626 e_gamma_aa_gamma_ab_gamma_bb(ii) = e_gamma_aa_gamma_ab_gamma_bb(ii) + sc*w%v3sigma3(5, i)
9627 e_gamma_aa_gamma_ab_laplace_rhoa(ii) = e_gamma_aa_gamma_ab_laplace_rhoa(ii) + sc*w%v3sigma2lapl(3, i)
9628 e_gamma_aa_gamma_ab_laplace_rhob(ii) = e_gamma_aa_gamma_ab_laplace_rhob(ii) + sc*w%v3sigma2lapl(4, i)
9629 e_gamma_aa_gamma_ab_tau_a(ii) = e_gamma_aa_gamma_ab_tau_a(ii) + sc*w%v3sigma2tau(3, i)
9630 e_gamma_aa_gamma_ab_tau_b(ii) = e_gamma_aa_gamma_ab_tau_b(ii) + sc*w%v3sigma2tau(4, i)
9631 e_gamma_aa_gamma_bb_gamma_bb(ii) = e_gamma_aa_gamma_bb_gamma_bb(ii) + sc*w%v3sigma3(6, i)
9632 e_gamma_aa_gamma_bb_laplace_rhoa(ii) = e_gamma_aa_gamma_bb_laplace_rhoa(ii) + sc*w%v3sigma2lapl(5, i)
9633 e_gamma_aa_gamma_bb_laplace_rhob(ii) = e_gamma_aa_gamma_bb_laplace_rhob(ii) + sc*w%v3sigma2lapl(6, i)
9634 e_gamma_aa_gamma_bb_tau_a(ii) = e_gamma_aa_gamma_bb_tau_a(ii) + sc*w%v3sigma2tau(5, i)
9635 e_gamma_aa_gamma_bb_tau_b(ii) = e_gamma_aa_gamma_bb_tau_b(ii) + sc*w%v3sigma2tau(6, i)
9636 e_gamma_aa_laplace_rhoa_laplace_rhoa(ii) = e_gamma_aa_laplace_rhoa_laplace_rhoa(ii) + sc*w%v3sigmalapl2(1, i)
9637 e_gamma_aa_laplace_rhoa_laplace_rhob(ii) = e_gamma_aa_laplace_rhoa_laplace_rhob(ii) + sc*w%v3sigmalapl2(2, i)
9638 e_gamma_aa_laplace_rhoa_tau_a(ii) = e_gamma_aa_laplace_rhoa_tau_a(ii) + sc*w%v3sigmalapltau(1, i)
9639 e_gamma_aa_laplace_rhoa_tau_b(ii) = e_gamma_aa_laplace_rhoa_tau_b(ii) + sc*w%v3sigmalapltau(2, i)
9640 e_gamma_aa_laplace_rhob_laplace_rhob(ii) = e_gamma_aa_laplace_rhob_laplace_rhob(ii) + sc*w%v3sigmalapl2(3, i)
9641 e_gamma_aa_laplace_rhob_tau_a(ii) = e_gamma_aa_laplace_rhob_tau_a(ii) + sc*w%v3sigmalapltau(3, i)
9642 e_gamma_aa_laplace_rhob_tau_b(ii) = e_gamma_aa_laplace_rhob_tau_b(ii) + sc*w%v3sigmalapltau(4, i)
9643 e_gamma_aa_tau_a_tau_a(ii) = e_gamma_aa_tau_a_tau_a(ii) + sc*w%v3sigmatau2(1, i)
9644 e_gamma_aa_tau_a_tau_b(ii) = e_gamma_aa_tau_a_tau_b(ii) + sc*w%v3sigmatau2(2, i)
9645 e_gamma_aa_tau_b_tau_b(ii) = e_gamma_aa_tau_b_tau_b(ii) + sc*w%v3sigmatau2(3, i)
9646 e_gamma_ab_gamma_ab_gamma_ab(ii) = e_gamma_ab_gamma_ab_gamma_ab(ii) + sc*w%v3sigma3(7, i)
9647 e_gamma_ab_gamma_ab_gamma_bb(ii) = e_gamma_ab_gamma_ab_gamma_bb(ii) + sc*w%v3sigma3(8, i)
9648 e_gamma_ab_gamma_ab_laplace_rhoa(ii) = e_gamma_ab_gamma_ab_laplace_rhoa(ii) + sc*w%v3sigma2lapl(7, i)
9649 e_gamma_ab_gamma_ab_laplace_rhob(ii) = e_gamma_ab_gamma_ab_laplace_rhob(ii) + sc*w%v3sigma2lapl(8, i)
9650 e_gamma_ab_gamma_ab_tau_a(ii) = e_gamma_ab_gamma_ab_tau_a(ii) + sc*w%v3sigma2tau(7, i)
9651 e_gamma_ab_gamma_ab_tau_b(ii) = e_gamma_ab_gamma_ab_tau_b(ii) + sc*w%v3sigma2tau(8, i)
9652 e_gamma_ab_gamma_bb_gamma_bb(ii) = e_gamma_ab_gamma_bb_gamma_bb(ii) + sc*w%v3sigma3(9, i)
9653 e_gamma_ab_gamma_bb_laplace_rhoa(ii) = e_gamma_ab_gamma_bb_laplace_rhoa(ii) + sc*w%v3sigma2lapl(9, i)
9654 e_gamma_ab_gamma_bb_laplace_rhob(ii) = e_gamma_ab_gamma_bb_laplace_rhob(ii) + sc*w%v3sigma2lapl(10, i)
9655 e_gamma_ab_gamma_bb_tau_a(ii) = e_gamma_ab_gamma_bb_tau_a(ii) + sc*w%v3sigma2tau(9, i)
9656 e_gamma_ab_gamma_bb_tau_b(ii) = e_gamma_ab_gamma_bb_tau_b(ii) + sc*w%v3sigma2tau(10, i)
9657 e_gamma_ab_laplace_rhoa_laplace_rhoa(ii) = e_gamma_ab_laplace_rhoa_laplace_rhoa(ii) + sc*w%v3sigmalapl2(4, i)
9658 e_gamma_ab_laplace_rhoa_laplace_rhob(ii) = e_gamma_ab_laplace_rhoa_laplace_rhob(ii) + sc*w%v3sigmalapl2(5, i)
9659 e_gamma_ab_laplace_rhoa_tau_a(ii) = e_gamma_ab_laplace_rhoa_tau_a(ii) + sc*w%v3sigmalapltau(5, i)
9660 e_gamma_ab_laplace_rhoa_tau_b(ii) = e_gamma_ab_laplace_rhoa_tau_b(ii) + sc*w%v3sigmalapltau(6, i)
9661 e_gamma_ab_laplace_rhob_laplace_rhob(ii) = e_gamma_ab_laplace_rhob_laplace_rhob(ii) + sc*w%v3sigmalapl2(6, i)
9662 e_gamma_ab_laplace_rhob_tau_a(ii) = e_gamma_ab_laplace_rhob_tau_a(ii) + sc*w%v3sigmalapltau(7, i)
9663 e_gamma_ab_laplace_rhob_tau_b(ii) = e_gamma_ab_laplace_rhob_tau_b(ii) + sc*w%v3sigmalapltau(8, i)
9664 e_gamma_ab_tau_a_tau_a(ii) = e_gamma_ab_tau_a_tau_a(ii) + sc*w%v3sigmatau2(4, i)
9665 e_gamma_ab_tau_a_tau_b(ii) = e_gamma_ab_tau_a_tau_b(ii) + sc*w%v3sigmatau2(5, i)
9666 e_gamma_ab_tau_b_tau_b(ii) = e_gamma_ab_tau_b_tau_b(ii) + sc*w%v3sigmatau2(6, i)
9667 e_gamma_bb_gamma_bb_gamma_bb(ii) = e_gamma_bb_gamma_bb_gamma_bb(ii) + sc*w%v3sigma3(10, i)
9668 e_gamma_bb_gamma_bb_laplace_rhoa(ii) = e_gamma_bb_gamma_bb_laplace_rhoa(ii) + sc*w%v3sigma2lapl(11, i)
9669 e_gamma_bb_gamma_bb_laplace_rhob(ii) = e_gamma_bb_gamma_bb_laplace_rhob(ii) + sc*w%v3sigma2lapl(12, i)
9670 e_gamma_bb_gamma_bb_tau_a(ii) = e_gamma_bb_gamma_bb_tau_a(ii) + sc*w%v3sigma2tau(11, i)
9671 e_gamma_bb_gamma_bb_tau_b(ii) = e_gamma_bb_gamma_bb_tau_b(ii) + sc*w%v3sigma2tau(12, i)
9672 e_gamma_bb_laplace_rhoa_laplace_rhoa(ii) = e_gamma_bb_laplace_rhoa_laplace_rhoa(ii) + sc*w%v3sigmalapl2(7, i)
9673 e_gamma_bb_laplace_rhoa_laplace_rhob(ii) = e_gamma_bb_laplace_rhoa_laplace_rhob(ii) + sc*w%v3sigmalapl2(8, i)
9674 e_gamma_bb_laplace_rhoa_tau_a(ii) = e_gamma_bb_laplace_rhoa_tau_a(ii) + sc*w%v3sigmalapltau(9, i)
9675 e_gamma_bb_laplace_rhoa_tau_b(ii) = e_gamma_bb_laplace_rhoa_tau_b(ii) + sc*w%v3sigmalapltau(10, i)
9676 e_gamma_bb_laplace_rhob_laplace_rhob(ii) = e_gamma_bb_laplace_rhob_laplace_rhob(ii) + sc*w%v3sigmalapl2(9, i)
9677 e_gamma_bb_laplace_rhob_tau_a(ii) = e_gamma_bb_laplace_rhob_tau_a(ii) + sc*w%v3sigmalapltau(11, i)
9678 e_gamma_bb_laplace_rhob_tau_b(ii) = e_gamma_bb_laplace_rhob_tau_b(ii) + sc*w%v3sigmalapltau(12, i)
9679 e_gamma_bb_tau_a_tau_a(ii) = e_gamma_bb_tau_a_tau_a(ii) + sc*w%v3sigmatau2(7, i)
9680 e_gamma_bb_tau_a_tau_b(ii) = e_gamma_bb_tau_a_tau_b(ii) + sc*w%v3sigmatau2(8, i)
9681 e_gamma_bb_tau_b_tau_b(ii) = e_gamma_bb_tau_b_tau_b(ii) + sc*w%v3sigmatau2(9, i)
9682 e_laplace_rhoa_laplace_rhoa_laplace_rhoa(ii) = e_laplace_rhoa_laplace_rhoa_laplace_rhoa(ii) + sc*w%v3lapl3(1, i)
9683 e_laplace_rhoa_laplace_rhoa_laplace_rhob(ii) = e_laplace_rhoa_laplace_rhoa_laplace_rhob(ii) + sc*w%v3lapl3(2, i)
9684 e_laplace_rhoa_laplace_rhoa_tau_a(ii) = e_laplace_rhoa_laplace_rhoa_tau_a(ii) + sc*w%v3lapl2tau(1, i)
9685 e_laplace_rhoa_laplace_rhoa_tau_b(ii) = e_laplace_rhoa_laplace_rhoa_tau_b(ii) + sc*w%v3lapl2tau(2, i)
9686 e_laplace_rhoa_laplace_rhob_laplace_rhob(ii) = e_laplace_rhoa_laplace_rhob_laplace_rhob(ii) + sc*w%v3lapl3(3, i)
9687 e_laplace_rhoa_laplace_rhob_tau_a(ii) = e_laplace_rhoa_laplace_rhob_tau_a(ii) + sc*w%v3lapl2tau(3, i)
9688 e_laplace_rhoa_laplace_rhob_tau_b(ii) = e_laplace_rhoa_laplace_rhob_tau_b(ii) + sc*w%v3lapl2tau(4, i)
9689 e_laplace_rhoa_tau_a_tau_a(ii) = e_laplace_rhoa_tau_a_tau_a(ii) + sc*w%v3lapltau2(1, i)
9690 e_laplace_rhoa_tau_a_tau_b(ii) = e_laplace_rhoa_tau_a_tau_b(ii) + sc*w%v3lapltau2(2, i)
9691 e_laplace_rhoa_tau_b_tau_b(ii) = e_laplace_rhoa_tau_b_tau_b(ii) + sc*w%v3lapltau2(3, i)
9692 e_laplace_rhob_laplace_rhob_laplace_rhob(ii) = e_laplace_rhob_laplace_rhob_laplace_rhob(ii) + sc*w%v3lapl3(4, i)
9693 e_laplace_rhob_laplace_rhob_tau_a(ii) = e_laplace_rhob_laplace_rhob_tau_a(ii) + sc*w%v3lapl2tau(5, i)
9694 e_laplace_rhob_laplace_rhob_tau_b(ii) = e_laplace_rhob_laplace_rhob_tau_b(ii) + sc*w%v3lapl2tau(6, i)
9695 e_laplace_rhob_tau_a_tau_a(ii) = e_laplace_rhob_tau_a_tau_a(ii) + sc*w%v3lapltau2(4, i)
9696 e_laplace_rhob_tau_a_tau_b(ii) = e_laplace_rhob_tau_a_tau_b(ii) + sc*w%v3lapltau2(5, i)
9697 e_laplace_rhob_tau_b_tau_b(ii) = e_laplace_rhob_tau_b_tau_b(ii) + sc*w%v3lapltau2(6, i)
9698 e_tau_a_tau_a_tau_a(ii) = e_tau_a_tau_a_tau_a(ii) + sc*w%v3tau3(1, i)
9699 e_tau_a_tau_a_tau_b(ii) = e_tau_a_tau_a_tau_b(ii) + sc*w%v3tau3(2, i)
9700 e_tau_a_tau_b_tau_b(ii) = e_tau_a_tau_b_tau_b(ii) + sc*w%v3tau3(3, i)
9701 e_tau_b_tau_b_tau_b(ii) = e_tau_b_tau_b_tau_b(ii) + sc*w%v3tau3(4, i)
9702 END DO
9703 END IF
9704 IF (grad_deriv >= 3 .AND. is_gga .AND. .NOT. is_mgga) THEN
9705 DO i = 1, nb
9706 ii = i0 + i
9707 e_rhoa_rhoa_gamma_aa(ii) = e_rhoa_rhoa_gamma_aa(ii) + sc*w%v3rho2sigma(1, i)
9708 e_rhoa_rhoa_gamma_ab(ii) = e_rhoa_rhoa_gamma_ab(ii) + sc*w%v3rho2sigma(2, i)
9709 e_rhoa_rhoa_gamma_bb(ii) = e_rhoa_rhoa_gamma_bb(ii) + sc*w%v3rho2sigma(3, i)
9710 e_rhoa_rhob_gamma_aa(ii) = e_rhoa_rhob_gamma_aa(ii) + sc*w%v3rho2sigma(4, i)
9711 e_rhoa_rhob_gamma_ab(ii) = e_rhoa_rhob_gamma_ab(ii) + sc*w%v3rho2sigma(5, i)
9712 e_rhoa_rhob_gamma_bb(ii) = e_rhoa_rhob_gamma_bb(ii) + sc*w%v3rho2sigma(6, i)
9713 e_rhoa_gamma_aa_gamma_aa(ii) = e_rhoa_gamma_aa_gamma_aa(ii) + sc*w%v3rhosigma2(1, i)
9714 e_rhoa_gamma_aa_gamma_ab(ii) = e_rhoa_gamma_aa_gamma_ab(ii) + sc*w%v3rhosigma2(2, i)
9715 e_rhoa_gamma_aa_gamma_bb(ii) = e_rhoa_gamma_aa_gamma_bb(ii) + sc*w%v3rhosigma2(3, i)
9716 e_rhoa_gamma_ab_gamma_ab(ii) = e_rhoa_gamma_ab_gamma_ab(ii) + sc*w%v3rhosigma2(4, i)
9717 e_rhoa_gamma_ab_gamma_bb(ii) = e_rhoa_gamma_ab_gamma_bb(ii) + sc*w%v3rhosigma2(5, i)
9718 e_rhoa_gamma_bb_gamma_bb(ii) = e_rhoa_gamma_bb_gamma_bb(ii) + sc*w%v3rhosigma2(6, i)
9719 e_rhob_rhob_gamma_aa(ii) = e_rhob_rhob_gamma_aa(ii) + sc*w%v3rho2sigma(7, i)
9720 e_rhob_rhob_gamma_ab(ii) = e_rhob_rhob_gamma_ab(ii) + sc*w%v3rho2sigma(8, i)
9721 e_rhob_rhob_gamma_bb(ii) = e_rhob_rhob_gamma_bb(ii) + sc*w%v3rho2sigma(9, i)
9722 e_rhob_gamma_aa_gamma_aa(ii) = e_rhob_gamma_aa_gamma_aa(ii) + sc*w%v3rhosigma2(7, i)
9723 e_rhob_gamma_aa_gamma_ab(ii) = e_rhob_gamma_aa_gamma_ab(ii) + sc*w%v3rhosigma2(8, i)
9724 e_rhob_gamma_aa_gamma_bb(ii) = e_rhob_gamma_aa_gamma_bb(ii) + sc*w%v3rhosigma2(9, i)
9725 e_rhob_gamma_ab_gamma_ab(ii) = e_rhob_gamma_ab_gamma_ab(ii) + sc*w%v3rhosigma2(10, i)
9726 e_rhob_gamma_ab_gamma_bb(ii) = e_rhob_gamma_ab_gamma_bb(ii) + sc*w%v3rhosigma2(11, i)
9727 e_rhob_gamma_bb_gamma_bb(ii) = e_rhob_gamma_bb_gamma_bb(ii) + sc*w%v3rhosigma2(12, i)
9728 e_gamma_aa_gamma_aa_gamma_aa(ii) = e_gamma_aa_gamma_aa_gamma_aa(ii) + sc*w%v3sigma3(1, i)
9729 e_gamma_aa_gamma_aa_gamma_ab(ii) = e_gamma_aa_gamma_aa_gamma_ab(ii) + sc*w%v3sigma3(2, i)
9730 e_gamma_aa_gamma_aa_gamma_bb(ii) = e_gamma_aa_gamma_aa_gamma_bb(ii) + sc*w%v3sigma3(3, i)
9731 e_gamma_aa_gamma_ab_gamma_ab(ii) = e_gamma_aa_gamma_ab_gamma_ab(ii) + sc*w%v3sigma3(4, i)
9732 e_gamma_aa_gamma_ab_gamma_bb(ii) = e_gamma_aa_gamma_ab_gamma_bb(ii) + sc*w%v3sigma3(5, i)
9733 e_gamma_aa_gamma_bb_gamma_bb(ii) = e_gamma_aa_gamma_bb_gamma_bb(ii) + sc*w%v3sigma3(6, i)
9734 e_gamma_ab_gamma_ab_gamma_ab(ii) = e_gamma_ab_gamma_ab_gamma_ab(ii) + sc*w%v3sigma3(7, i)
9735 e_gamma_ab_gamma_ab_gamma_bb(ii) = e_gamma_ab_gamma_ab_gamma_bb(ii) + sc*w%v3sigma3(8, i)
9736 e_gamma_ab_gamma_bb_gamma_bb(ii) = e_gamma_ab_gamma_bb_gamma_bb(ii) + sc*w%v3sigma3(9, i)
9737 e_gamma_bb_gamma_bb_gamma_bb(ii) = e_gamma_bb_gamma_bb_gamma_bb(ii) + sc*w%v3sigma3(10, i)
9738 END DO
9739 END IF
9740END DO
9741!$OMP END DO
9742
9743END SUBROUTINE libxc_spin_polarized_calc
9744#endif
9745
9746END MODULE xc_libxc
static GRID_HOST_DEVICE int idx(const orbital a)
Return coset index of given orbital angular momentum.
collects all references to literature in CP2K as new algorithms / method are included from literature...
integer, save, public marques2012
integer, save, public lehtola2018
represents keywords in an input
subroutine, public keyword_release(keyword)
releases the given keyword (see doc/ReferenceCounting.html)
subroutine, public keyword_create(keyword, location, name, description, usage, type_of_var, n_var, repeats, variants, default_val, default_l_val, default_r_val, default_lc_val, default_c_val, default_i_val, default_l_vals, default_r_vals, default_c_vals, default_i_vals, lone_keyword_val, lone_keyword_l_val, lone_keyword_r_val, lone_keyword_c_val, lone_keyword_i_val, lone_keyword_l_vals, lone_keyword_r_vals, lone_keyword_c_vals, lone_keyword_i_vals, enum_c_vals, enum_i_vals, enum, enum_strict, enum_desc, unit_str, citations, deprecation_notice, removed)
creates a keyword object
objects that represent the structure of input sections and the data contained in an input section
subroutine, public section_create(section, location, name, description, n_keywords, n_subsections, repeats, citations, deprecation_notice)
creates a list of keywords
subroutine, public section_add_keyword(section, keyword)
adds a keyword to the given section
subroutine, public section_add_subsection(section, subsection)
adds a subsection to the given section
recursive subroutine, public section_release(section)
releases the given keyword list (see doc/ReferenceCounting.html)
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
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
Module with functions to handle derivative descriptors. derivative description are strings have the f...
integer, parameter, public deriv_norm_drho
integer, parameter, public deriv_laplace_rhob
integer, parameter, public deriv_gamma
integer, parameter, public deriv_norm_drhoa
integer, parameter, public deriv_rhob
integer, parameter, public deriv_gamma_aa
integer, parameter, public deriv_rhoa
integer, parameter, public deriv_tau
integer, parameter, public deriv_tau_b
integer, parameter, public deriv_tau_a
integer, parameter, public deriv_laplace_rhoa
integer, parameter, public deriv_rho
integer, parameter, public deriv_gamma_bb
integer, parameter, public deriv_norm_drhob
integer, parameter, public deriv_gamma_ab
integer, parameter, public deriv_laplace_rho
represent a group ofunctional derivatives
type(xc_derivative_type) function, pointer, public xc_dset_get_derivative(derivative_set, description, allocate_deriv)
returns the requested xc_derivative
Provides types for the management of the xc-functionals and their derivatives.
subroutine, public xc_derivative_get(deriv, split_desc, order, deriv_data, accept_null_data)
returns various information on the given derivative
Includes all necessary routines, functions and parameters from libxc. Provides CP2K routines/function...
calculates a functional from libxc and its derivatives
Definition xc_libxc.F:29
subroutine, public libxc_spin_unpolarized_info(libxc_params, reference, shortform, needs, max_deriv, print_warn, func_name_override)
info about the functional from libxc
Definition xc_libxc.F:375
subroutine, public libxc_spin_unpolarized_eval(rho_set, deriv_set, grad_deriv, libxc_params, func_name_override)
evaluates the functional from libxc
Definition xc_libxc.F:889
subroutine, public libxc_spin_polarized_info(libxc_params, reference, shortform, needs, max_deriv, print_warn, func_name_override)
info about the functional from libxc
Definition xc_libxc.F:489
subroutine, public libxc_release_workers()
Reads the external parameters of a LibXC functional from its input section.
Definition xc_libxc.F:853
subroutine, public libxc_spin_polarized_eval(rho_set, deriv_set, grad_deriv, libxc_params, func_name_override)
evaluates the functional from libxc
Definition xc_libxc.F:1446
subroutine, public libxc_version_info(version, compiled_version)
info about the LibXC version
Definition xc_libxc.F:598
subroutine, public libxc_add_sections(section)
...
Definition xc_libxc.F:267
logical function, public libxc_check_existence_in_libxc(libxc_params)
This function checks whether a functional name belongs to LibXC.
Definition xc_libxc.F:197
integer function, public libxc_get_reference_length(libxc_params, lsd)
This function returns the maximum length of the reference string for a given LibXC functional.
Definition xc_libxc.F:223
subroutine, public libxc_library_reference(reference, doi)
Returns the citation LibXC asks for the library itself.
Definition xc_libxc.F:618
contains the structure
contains the structure
subroutine, public xc_rho_set_get(rho_set, can_return_null, rho, drho, norm_drho, rhoa, rhob, norm_drhoa, norm_drhob, rho_1_3, rhoa_1_3, rhob_1_3, laplace_rho, laplace_rhoa, laplace_rhob, drhoa, drhob, rho_cutoff, drho_cutoff, tau_cutoff, tau, tau_a, tau_b, local_bounds)
returns the various attributes of rho_set
represent a keyword in the input
represent a section of the input file
A derivative set contains the different derivatives of a xc-functional in form of a linked list.
represent a derivative of a functional
contains a flag for each component of xc_rho_set, so that you can use it to tell which components you...
represent a density, with all the representation and data needed to perform a functional evaluation