forked from cp2k/cp2k
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxc_xwpbe.F
5695 lines (5575 loc) · 280 KB
/
xc_xwpbe.F
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
!--------------------------------------------------------------------------------------------------!
! CP2K: A general program to perform molecular dynamics simulations !
! Copyright 2000-2025 CP2K developers group <https://cp2k.org> !
! !
! SPDX-License-Identifier: GPL-2.0-or-later !
!--------------------------------------------------------------------------------------------------!
! **************************************************************************************************
!> \brief Calculates short range exchange part for wPBE functional and averaged
!> PBE exchange-hole functional (omega = 0.0 )
!> \par History
!> Manuel Guidon (05.2007) : initial version
!> \author Manuel Guidon (05.2007)
! **************************************************************************************************
MODULE xc_xwpbe
USE bibliography, ONLY: Heyd2004,&
cite_reference
USE input_section_types, ONLY: section_vals_type,&
section_vals_val_get
USE kinds, ONLY: dp
USE mathconstants, ONLY: pi,&
rootpi
USE mathlib, ONLY: expint
USE xc_derivative_desc, ONLY: deriv_norm_drho,&
deriv_norm_drhoa,&
deriv_norm_drhob,&
deriv_rho,&
deriv_rhoa,&
deriv_rhob
USE xc_derivative_set_types, ONLY: xc_derivative_set_type,&
xc_dset_get_derivative
USE xc_derivative_types, ONLY: xc_derivative_get,&
xc_derivative_type
USE xc_rho_cflags_types, ONLY: xc_rho_cflags_type
USE xc_rho_set_types, ONLY: xc_rho_set_get,&
xc_rho_set_type
#include "../base/base_uses.f90"
IMPLICIT NONE
PRIVATE
! *** Global parameters ***
PUBLIC :: xwpbe_lda_info, xwpbe_lda_eval, xwpbe_lsd_info, &
xwpbe_lsd_eval
REAL(KIND=dp), PARAMETER :: alpha1 = -1.128223946706117_dp, &
alpha2 = 1.452736265762971_dp, &
alpha3 = -1.243162299390327_dp, &
alpha4 = 0.971824836115601_dp, &
alpha5 = -0.568861079687373_dp, &
alpha6 = 0.246880514820192_dp, &
alpha7 = -0.065032363850763_dp, &
alpha8 = 0.008401793031216_dp
REAL(KIND=dp), PARAMETER :: beta = 1.455915450052607_dp, &
beta2 = 2.0_dp
REAL(KIND=dp), PARAMETER :: a1 = 0.00979681_dp, &
a2 = 0.04108340_dp, &
a3 = 0.18744000_dp, &
a4 = 0.00120824_dp, &
a5 = 0.0347188_dp
REAL(KIND=dp), PARAMETER :: A = 1.0161144_dp, &
B = -0.37170836_dp, &
C = -0.077215461_dp, &
DD = 0.57786348_dp, &
E = -0.051955731_dp, &
F1 = 0.47965830_dp, &
F2 = 6.4753871_dp, &
clda = -0.73855876638202240588423_dp
REAL(KIND=dp), PARAMETER :: expcutoff = 700.0_dp, &
exei1 = 4.0364_dp, &
exei2 = 1.15198_dp, &
exei3 = 5.03627_dp, &
exei4 = 4.19160_dp
REAL(KIND=dp), PARAMETER :: smax = 8.572844_dp, &
sconst = 18.79622316_dp, &
scutoff = 8.3_dp
REAL(KIND=dp), PARAMETER :: gcutoff = 0.08_dp, &
g1 = -0.02628417880_dp/E, &
g2 = -0.07117647788_dp/E, &
g3 = 0.08534541323_dp/E, &
g4 = 0.0_dp
REAL(KIND=dp), PARAMETER :: wcutoff = 14.0_dp
REAL(KIND=dp), PARAMETER :: f12 = 0.5_dp, f14 = 0.25_dp, f158 = 15.0_dp/8.0_dp, &
f1516 = 15.0_dp/16.0_dp, f24364 = 243.0_dp/64.0_dp, &
f2716 = 27.0_dp/16.0_dp, f2732 = 27.0_dp/32.0_dp, &
f34 = 0.75_dp, f32 = 1.5_dp, f38 = 0.375_dp, f68 = 0.75_dp, &
f6561512 = 6561.0_dp/512.0_dp, f8132 = 81.0_dp/32.0_dp, &
f8164 = 81.0_dp/64.0_dp, f729128 = 729.0_dp/128.0_dp, &
f52 = 2.5_dp, f94 = 9.0_dp/4.0_dp, f916 = 9.0_dp/16.0_dp, &
f89 = 8.0_dp/9.0_dp, f2187256 = 2187.0_dp/256.0_dp, &
r1 = 1.0_dp, f98 = 9.0_dp/8.0_dp, r15 = 15.0_dp, &
r3 = 3.0_dp, r4 = 4.0_dp, r16 = 16.0_dp, r8 = 8.0_dp, &
r6 = 6.0_dp, r2 = 2.0_dp
CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'xc_xwpbe'
CONTAINS
! **************************************************************************************************
!> \brief return various information on the functional
!> \param reference string with the reference of the actual functional
!> \param shortform string with the shortform of the functional name
!> \param needs the components needed by this functional are set to
!> true (does not set the unneeded components to false)
!> \param max_deriv ...
!> \par History
!> 05.2007 created [Manuel Guidon]
!> \author Manuel Guidon
! **************************************************************************************************
SUBROUTINE xwpbe_lda_info(reference, shortform, needs, max_deriv)
CHARACTER(LEN=*), INTENT(OUT), OPTIONAL :: reference, shortform
TYPE(xc_rho_cflags_type), INTENT(inout), OPTIONAL :: needs
INTEGER, INTENT(out), OPTIONAL :: max_deriv
IF (PRESENT(reference)) THEN
reference = "Jochen Heyd and Gustavo E. Scuseria, J. Chem. Phys., 120, 7274 {LDA version}"
END IF
IF (PRESENT(shortform)) THEN
shortform = "shortrange part of PBE exchange {LDA}"
END IF
IF (PRESENT(needs)) THEN
needs%rho = .TRUE.
needs%norm_drho = .TRUE.
END IF
! deriv > 1 are not correct
! IF (PRESENT(max_deriv)) max_deriv = 2
IF (PRESENT(max_deriv)) max_deriv = 1
END SUBROUTINE xwpbe_lda_info
! **************************************************************************************************
!> \brief evaluates the screened hole averaged PBE exchange functional for lda
!> \param rho_set the density where you want to evaluate the functional
!> \param deriv_set place where to store the functional derivatives (they are
!> added to the derivatives)
!> \param order degree of the derivative that should be evaluated,
!> if positive all the derivatives up to the given degree are evaluated,
!> if negative only the given degree is calculated
!> \param xwpbe_params input parameters (scaling,omega)
!> \par History
!> 05.2007 created [Manuel Guidon]
!> \author Manuel Guidon
!> \note
!> The current version provides code for derivatives up to second order.
!> Using the maple sheet in cp2k/doc it is straightforward to produce routines
!> for higher derivatives.
! **************************************************************************************************
SUBROUTINE xwpbe_lda_eval(rho_set, deriv_set, order, xwpbe_params)
TYPE(xc_rho_set_type), INTENT(IN) :: rho_set
TYPE(xc_derivative_set_type), INTENT(IN) :: deriv_set
INTEGER, INTENT(IN) :: order
TYPE(section_vals_type), POINTER :: xwpbe_params
CHARACTER(len=*), PARAMETER :: routineN = 'xwpbe_lda_eval'
INTEGER :: handle, npoints
INTEGER, DIMENSION(2, 3) :: bo
REAL(kind=dp) :: epsilon_norm_drho, epsilon_rho, omega, &
sx, sx0
REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), &
POINTER :: dummy, e_0, e_ndrho, e_ndrho_ndrho, &
e_ndrho_rho, e_rho, e_rho_rho, &
norm_drho, rho
TYPE(xc_derivative_type), POINTER :: deriv
CALL timeset(routineN, handle)
CALL cite_reference(Heyd2004)
CALL section_vals_val_get(xwpbe_params, "SCALE_X", r_val=sx)
CALL section_vals_val_get(xwpbe_params, "SCALE_X0", r_val=sx0)
CALL section_vals_val_get(xwpbe_params, "OMEGA", r_val=omega)
CALL xc_rho_set_get(rho_set, rho=rho, &
norm_drho=norm_drho, local_bounds=bo, rho_cutoff=epsilon_rho, &
drho_cutoff=epsilon_norm_drho)
npoints = (bo(2, 1) - bo(1, 1) + 1)*(bo(2, 2) - bo(1, 2) + 1)*(bo(2, 3) - bo(1, 3) + 1)
dummy => rho
e_0 => dummy
e_rho => dummy
e_ndrho => dummy
e_rho_rho => dummy
e_ndrho_rho => dummy
e_ndrho_ndrho => dummy
IF (order >= 0) THEN
deriv => xc_dset_get_derivative(deriv_set, [INTEGER::], &
allocate_deriv=.TRUE.)
CALL xc_derivative_get(deriv, deriv_data=e_0)
END IF
IF (order >= 1 .OR. order == -1) THEN
deriv => xc_dset_get_derivative(deriv_set, [deriv_rho], &
allocate_deriv=.TRUE.)
CALL xc_derivative_get(deriv, deriv_data=e_rho)
deriv => xc_dset_get_derivative(deriv_set, [deriv_norm_drho], &
allocate_deriv=.TRUE.)
CALL xc_derivative_get(deriv, deriv_data=e_ndrho)
END IF
IF (order >= 2 .OR. order == -2) THEN
CPABORT("derivatives bigger than 1 do not work correctly")
deriv => xc_dset_get_derivative(deriv_set, [deriv_rho, deriv_rho], &
allocate_deriv=.TRUE.)
CALL xc_derivative_get(deriv, deriv_data=e_rho_rho)
deriv => xc_dset_get_derivative(deriv_set, [deriv_norm_drho, deriv_rho], &
allocate_deriv=.TRUE.)
CALL xc_derivative_get(deriv, deriv_data=e_ndrho_rho)
deriv => xc_dset_get_derivative(deriv_set, &
[deriv_norm_drho, deriv_norm_drho], allocate_deriv=.TRUE.)
CALL xc_derivative_get(deriv, deriv_data=e_ndrho_ndrho)
END IF
IF (order > 1 .OR. order < -1) THEN
CPABORT("derivatives bigger than 1 do not work correctly")
END IF
IF (order > 2 .OR. order < -2) THEN
CPABORT("derivatives bigger than 2 not implemented")
END IF
!$OMP PARALLEL DEFAULT(NONE) &
!$OMP SHARED(npoints, order, rho, norm_drho, e_0, e_rho, e_ndrho) &
!$OMP SHARED(e_rho_rho, e_ndrho_rho, e_ndrho_ndrho, epsilon_rho) &
!$OMP SHARED(sx, sx0, omega)
CALL xwpbe_lda_calc(npoints, order, rho=rho, norm_drho=norm_drho, &
e_0=e_0, e_rho=e_rho, e_ndrho=e_ndrho, e_rho_rho=e_rho_rho, &
e_ndrho_rho=e_ndrho_rho, e_ndrho_ndrho=e_ndrho_ndrho, &
epsilon_rho=epsilon_rho, sx=sx, sx0=sx0, omega=omega)
!$OMP END PARALLEL
CALL timestop(handle)
END SUBROUTINE xwpbe_lda_eval
! **************************************************************************************************
!> \brief evaluates the screened hole averaged PBE exchange functional for lda
!> \param npoints ...
!> \param order degree of the derivative that should be evaluated,
!> if positive all the derivatives up to the given degree are evaluated,
!> if negative only the given degree is calculated
!> \param rho , ndrho: density and norm of the density gradient
!> \param norm_drho ...
!> \param e_0 ...
!> \param e_rho ...
!> \param e_ndrho ...
!> \param e_rho_rho ...
!> \param e_ndrho_rho ...
!> \param e_ndrho_ndrho ...
!> \param epsilon_rho ...
!> \param sx , sx0: scaling factor for omega!=0 and omega=0
!> \param sx0 ...
!> \param omega screening parameter
!> \par History
!> 05.2007 created [Manuel Guidon]
!> \author Manuel Guidon
!> \note
!> In order to avoid numerical instabilities, this routine calls different
!> subroutines. There are 4 routines for the case omega!=0 and 2 routines
!> for omega=0.
! **************************************************************************************************
SUBROUTINE xwpbe_lda_calc(npoints, order, rho, norm_drho, e_0, e_rho, e_ndrho, &
e_rho_rho, e_ndrho_rho, e_ndrho_ndrho, &
epsilon_rho, sx, sx0, omega)
INTEGER, INTENT(in) :: npoints, order
REAL(kind=dp), DIMENSION(1:npoints), INTENT(inout) :: rho, norm_drho, e_0, e_rho, e_ndrho, &
e_rho_rho, e_ndrho_rho, e_ndrho_ndrho
REAL(kind=dp), INTENT(in) :: epsilon_rho, sx, sx0, omega
INTEGER :: ip
REAL(dp) :: my_ndrho, my_rho
REAL(KIND=dp) :: ss, ss2, sscale, t1, t2, t3, t4, t5, t6, &
t7, t8, ww
!$OMP DO
DO ip = 1, npoints
my_rho = MAX(rho(ip), 0.0_dp)
IF (my_rho > epsilon_rho) THEN
my_ndrho = MAX(norm_drho(ip), 0.0_dp)
!Do some precalculation in order to catch the correct branch afterwards
sscale = 1.0_dp
t1 = pi**2
t2 = t1*my_rho
t3 = t2**(0.1e1_dp/0.3e1_dp)
t4 = 0.1e1_dp/t3
t5 = omega*t4
ww = 0.6933612743506347048433524e0_dp*t5
t6 = my_ndrho*t4
t7 = 0.1e1_dp/my_rho
t8 = t7*sscale
ss = 0.3466806371753173524216762e0_dp*t6*t8
IF (ss > scutoff) THEN
ss2 = ss*ss
sscale = (smax*ss2 - sconst)/(ss2*ss)
END IF
IF (sx0 /= 0.0_dp) THEN
!original PBE hole
IF (ss*sscale > gcutoff) THEN
CALL xwpbe_lda_calc_0(e_0(ip), e_rho(ip), e_ndrho(ip), e_rho_rho(ip), &
e_ndrho_rho(ip), e_ndrho_ndrho(ip), my_rho, &
my_ndrho, sscale, sx0, order)
ELSE
CALL xwpbe_lda_calc_01(e_0(ip), e_rho(ip), e_ndrho(ip), e_rho_rho(ip), &
e_ndrho_rho(ip), e_ndrho_ndrho(ip), my_rho, &
my_ndrho, sscale, sx0, order)
END IF
END IF
IF (sx /= 0.0_dp) THEN
IF (ww < wcutoff .AND. ss*sscale > gcutoff) THEN
CALL xwpbe_lda_calc_1(e_0(ip), e_rho(ip), e_ndrho(ip), e_rho_rho(ip), &
e_ndrho_rho(ip), e_ndrho_ndrho(ip), my_rho, &
my_ndrho, omega, sscale, sx, order)
ELSE IF (ww < wcutoff .AND. ss*sscale <= gcutoff) THEN
CALL xwpbe_lda_calc_2(e_0(ip), e_rho(ip), e_ndrho(ip), e_rho_rho(ip), &
e_ndrho_rho(ip), e_ndrho_ndrho(ip), my_rho, &
my_ndrho, omega, sscale, sx, order)
ELSE IF (ww >= wcutoff .AND. ss*sscale > gcutoff) THEN
CALL xwpbe_lda_calc_3(e_0(ip), e_rho(ip), e_ndrho(ip), e_rho_rho(ip), &
e_ndrho_rho(ip), e_ndrho_ndrho(ip), my_rho, &
my_ndrho, omega, sscale, sx, order)
ELSE
CALL xwpbe_lda_calc_4(e_0(ip), e_rho(ip), e_ndrho(ip), e_rho_rho(ip), &
e_ndrho_rho(ip), e_ndrho_ndrho(ip), my_rho, &
my_ndrho, omega, sscale, sx, order)
END IF
END IF
END IF
END DO
!$OMP END DO
END SUBROUTINE xwpbe_lda_calc
! **************************************************************************************************
!> \brief Evaluates the screened hole averaged PBE exchange functional for lda
!> \param e_0 ...
!> \param e_rho ...
!> \param e_ndrho ...
!> \param e_rho_rho ...
!> \param e_ndrho_rho ...
!> \param e_ndrho_ndrho ...
!> \param rho , ndrho: density and norm of the density gradient
!> \param ndrho ...
!> \param sscale scaling factor to enforce Lieb-Oxford bound
!> \param sx0 scaling factor
!> \param order degree of the derivative that should be evaluated,
!> if positive all the derivatives up to the given degree are evaluated,
!> if negative only the given degree is calculated
!> \par History
!> 05.2007 created [Manuel Guidon]
!> \author Manuel Guidon
!> \note
!> This routine evaluates the exact functional for omega=0.
! **************************************************************************************************
SUBROUTINE xwpbe_lda_calc_0(e_0, e_rho, e_ndrho, e_rho_rho, e_ndrho_rho, &
e_ndrho_ndrho, rho, ndrho, sscale, sx0, order)
REAL(KIND=dp), INTENT(INOUT) :: e_0, e_rho, e_ndrho, e_rho_rho, &
e_ndrho_rho, e_ndrho_ndrho
REAL(KIND=dp), INTENT(IN) :: rho, ndrho, sscale, sx0
INTEGER, INTENT(IN) :: order
REAL(KIND=dp) :: d2Qndrhondrho, d2Qrhondrho, d2Qrhorho, dQndrho, dQrho, Q, t1, t10, t100, &
t1003, t1007, t1018, t1023, t1024, t103, t1037, t105, t1055, t1056, t1057, t1059, t106, &
t1060, t1073, t1079, t1082, t109, t11, t110, t1100, t111, t1110, t1114, t1117, t112, &
t114, t1143, t116, t1165, t117, t118, t119, t12, t120, t1202, t121, t1215, t122, t123, &
t1242, t125, t1258, t126, t1263, t127, t1286, t13, t130, t1316, t134, t1347, t135, t1352, &
t1358, t136, t1362, t1365, t1369, t1372, t138, t1382, t1388, t139, t1392, t1395, t14, &
t1412, t142, t143, t145, t1455, t146, t1465, t147, t148, t149, t15
REAL(KIND=dp) :: t150, t1510, t152, t1547, t156, t1561, t158, t159, t16, t160, t163, t164, &
t165, t166, t169, t170, t172, t173, t174, t175, t176, t18, t180, t183, t184, t185, t187, &
t188, t19, t190, t191, t192, t193, t199, t2, t20, t200, t201, t202, t203, t207, t209, &
t21, t215, t218, t219, t22, t220, t222, t223, t224, t225, t227, t228, t231, t233, t236, &
t237, t24, t240, t241, t242, t245, t246, t247, t249, t25, t250, t253, t254, t258, t26, &
t261, t262, t263, t265, t266, t269, t272, t274, t275, t278, t28, t281, t282, t284, t285, &
t287, t288, t29, t290, t291, t294, t297, t3, t300, t301, t303
REAL(KIND=dp) :: t304, t306, t307, t31, t314, t32, t321, t323, t326, t327, t33, t330, t334, &
t335, t336, t337, t338, t339, t34, t340, t342, t343, t344, t345, t347, t355, t356, t357, &
t358, t359, t36, t361, t362, t363, t367, t368, t37, t372, t374, t376, t377, t381, t383, &
t384, t387, t388, t39, t390, t391, t394, t397, t398, t4, t40, t400, t401, t402, t404, &
t405, t406, t408, t409, t410, t411, t412, t413, t414, t415, t416, t417, t418, t42, t423, &
t425, t426, t429, t430, t432, t433, t435, t44, t440, t443, t444, t446, t447, t449, t46, &
t463, t465, t47, t471, t472, t475, t476, t478, t479, t480, t484
REAL(KIND=dp) :: t485, t489, t491, t495, t497, t5, t500, t501, t504, t505, t507, t508, t510, &
t511, t513, t514, t515, t52, t520, t53, t530, t537, t54, t540, t542, t546, t550, t553, &
t557, t56, t566, t569, t570, t577, t579, t58, t59, t6, t61, t616, t620, t621, t627, t628, &
t63, t632, t647, t65, t655, t657, t66, t663, t67, t678, t68, t685, t69, t7, t70, t707, &
t71, t716, t72, t73, t735, t74, t744, t751, t755, t76, t761, t77, t778, t78, t784, t788, &
t79, t791, t8, t80, t81, t819, t824, t83, t84, t854, t856, t857, t86, t867, t872, t875, &
t878, t88, t887, t888, t889, t89, t9, t905, t91, t910, t911
REAL(KIND=dp) :: t92, t923, t924, t93, t930, t933, t94, t95, t952, t956, t968, t97, t975, &
t98, t983
IF (order >= 0) THEN
t1 = ndrho**2
t2 = a1*t1
t3 = r2**2
t4 = 0.1e1_dp/t3
t5 = t2*t4
t6 = pi**2
t7 = r3*t6
t8 = t7*rho
t9 = t8**(0.1e1_dp/0.3e1_dp)
t10 = t9**2
t11 = 0.1e1_dp/t10
t12 = rho**2
t13 = 0.1e1_dp/t12
t14 = t11*t13
t15 = sscale**2
t16 = t14*t15
t18 = t1**2
t19 = a2*t18
t20 = t3**2
t21 = 0.1e1_dp/t20
t22 = t19*t21
t24 = 0.1e1_dp/t9/t8
t25 = t12**2
t26 = 0.1e1_dp/t25
t28 = t15**2
t29 = t24*t26*t28
t31 = t5*t16 + t22*t29
t32 = f94*t31
t33 = a3*t18
t34 = t33*t21
t36 = t18*ndrho
t37 = a4*t36
t39 = 0.1e1_dp/t20/r2
t40 = t37*t39
t42 = 0.1e1_dp/t10/t8
t44 = 0.1e1_dp/t25/rho
t46 = t28*sscale
t47 = t42*t44*t46
t52 = 0.1e1_dp/t20/t3
t53 = a5*t18*t1*t52
t54 = r3**2
t56 = t6**2
t58 = 0.1e1_dp/t54/t56
t59 = t25**2
t61 = t28*t15
t63 = t58/t59*t61
t65 = r1 + t34*t29 + t40*t47 + t53*t63
t66 = 0.1e1_dp/t65
t67 = t66*t1
t68 = t32*t67
t69 = t4*t11
t70 = t13*t15
t71 = 0.1e1_dp/A
t72 = t70*t71
t73 = t69*t72
Q = t68*t73
t74 = rho**(0.1e1_dp/0.3e1_dp)
t76 = t74*rho*f89
t77 = B*f12
t78 = t1*t4
t79 = t78*t11
t80 = t31*t66
t81 = t70*t80
t83 = t79*t81 + DD
t84 = 0.1e1_dp/t83
t86 = F2*t31
t88 = F1 + t86*t66
t89 = t70*t88
t91 = t79*t89 + r1
t92 = f12*t91
t93 = t83**2
t94 = 0.1e1_dp/t93
t95 = C*t94
t97 = f34*pi
t98 = rootpi
t100 = r6*C
t103 = r4*B
t105 = r8*A
t106 = t93*t83
t109 = t98*(r15*E + t100*t91*t83 + t103*t93 + t105*t106)
t110 = 0.1e1_dp/r16
t111 = SQRT(t83)
t112 = t111*t106
t114 = t110/t112
t116 = SQRT(A)
t117 = EXP(Q)
t118 = t116*t117
t119 = f32*ndrho
t120 = 0.1e1_dp/r2
t121 = t119*t120
t122 = 0.1e1_dp/t9
t123 = 0.1e1_dp/rho
t125 = t80*t71
t126 = SQRT(t125)
t127 = sscale*t126
t130 = erfc(t121*t122*t123*t127)
t134 = 0.1e1_dp/f1516
t135 = (t97 + t109*t114 - t97*t118*t130)*t134
t136 = 0.1e1_dp/t98
t138 = 0.1e1_dp/E
t139 = t136*t112*t138
t142 = (-t135*t139 + r1)*E
t143 = 0.1e1_dp/t106
t145 = f12*A
t146 = exei(Q)
t147 = t78*t14
t148 = t15*t31
t149 = t66*t84
t150 = t148*t149
t152 = LOG(t147*t150)
t156 = (t77*t84 + t92*t95 + t142*t143 + t145*(t146 + t152)) &
*Clda
e_0 = e_0 + (-t76*t156)*sx0
END IF
IF (order >= 1 .OR. order == -1) THEN
t158 = t4*t42
t159 = t2*t158
t160 = t70*t7
t163 = t12*rho
t164 = 0.1e1_dp/t163
t165 = t11*t164
t166 = t165*t15
t169 = t54*t56
t170 = t169*t12
t172 = 0.1e1_dp/t9/t170
t173 = t21*t172
t174 = t19*t173
t175 = t26*t28
t176 = t175*t7
t180 = t24*t44*t28
t183 = -0.2e1_dp/0.3e1_dp*t159*t160 - (2._dp*t5*t166) - 0.4e1_dp/ &
0.3e1_dp*t174*t176 - (4._dp*t22*t180)
t184 = f94*t183
t185 = t184*t67
t187 = t65**2
t188 = 0.1e1_dp/t187
t190 = t188*t1*t4
t191 = t32*t190
t192 = t15*t71
t193 = t33*t173
t199 = 0.1e1_dp/t10/t170
t200 = t39*t199
t201 = t37*t200
t202 = t44*t46
t203 = t202*t7
t207 = 0.1e1_dp/t25/t12
t209 = t42*t207*t46
t215 = t58/t59/rho*t61
t218 = -0.4e1_dp/0.3e1_dp*t193*t176 - (4._dp*t34*t180) - 0.5e1_dp &
/0.3e1_dp*t201*t203 - (5._dp*t40*t209) - (8._dp*t53*t215)
t219 = t192*t218
t220 = t14*t219
t222 = t67*t4
t223 = t32*t222
t224 = t42*t13
t225 = t224*t15
t227 = t71*r3*t6
t228 = t225*t227
t231 = t164*t15
t233 = t69*t231*t71
dQrho = t185*t73 - t191*t220 - 0.2e1_dp/0.3e1_dp*t223*t228 - (2._dp &
*t68*t233)
t236 = a1*ndrho
t237 = t236*t4
t240 = t1*ndrho
t241 = a2*t240
t242 = t241*t21
t245 = 2._dp*t237*t16 + 4._dp*t242*t29
t246 = f94*t245
t247 = t246*t67
t249 = a3*t240
t250 = t249*t21
t253 = a4*t18
t254 = t253*t39
t258 = a5*t36*t52
t261 = 4._dp*t250*t29 + 5._dp*t254*t47 + 6._dp*t258*t63
t262 = t192*t261
t263 = t14*t262
t265 = t66*ndrho
t266 = t32*t265
dQndrho = t247*t73 - t191*t263 + 2._dp*t266*t73
t269 = t74*f89
t272 = t78*t224
t274 = t66*r3*t6
t275 = t148*t274
t278 = t231*t80
t281 = t183*t66
t282 = t70*t281
t284 = t188*t218
t285 = t148*t284
t287 = -0.2e1_dp/0.3e1_dp*t272*t275 - (2._dp*t79*t278) + (t79 &
*t282) - t147*t285
t288 = t94*t287
t290 = t15*t88
t291 = t290*t7
t294 = t231*t88
t297 = F2*t183
t300 = t297*t66 - t86*t284
t301 = t70*t300
t303 = -0.2e1_dp/0.3e1_dp*t272*t291 - (2._dp*t79*t294) + (t79 &
*t301)
t304 = f12*t303
t306 = C*t143
t307 = t306*t287
t314 = t83*t287
t321 = t98*(t100*t303*t83 + t100*t91*t287 + 2._dp*t103*t314 &
+ 3._dp*t105*t93*t287)
t323 = t93**2
t326 = t110/t111/t323
t327 = t326*t287
t330 = t97*t116
t334 = rootpi
t335 = 0.1e1_dp/t334
t336 = t117*t335
t337 = f32**2
t338 = t337*t1
t339 = t338*t69
t340 = t70*t125
t342 = EXP(-t339*t340)
t343 = t120*t24
t344 = t119*t343
t345 = t123*sscale
t347 = t126*r3*t6
t355 = t119*t120*t122
t356 = 0.1e1_dp/t126
t357 = t281*t71
t358 = t31*t188
t359 = t71*t218
t361 = t357 - t358*t359
t362 = t356*t361
t363 = t345*t362
t367 = t342*(-t344*t345*t347/0.3e1_dp - t121*t122*t13*t127 &
+ t355*t363/0.2e1_dp)
t368 = t336*t367
t372 = (t321*t114 - 0.7e1_dp/0.2e1_dp*t109*t327 - (t330*dQrho &
*t117*t130) + (2._dp*t330*t368))*t134
t374 = t135*t136
t376 = t111*t93*t138
t377 = t376*t287
t381 = (-t372*t139 - 0.7e1_dp/0.2e1_dp*t374*t377)*E
t383 = 0.1e1_dp/t323
t384 = t383*t287
t387 = dexeirho(Q, dQrho)
t388 = t78*t225
t390 = t84*r3*t6
t391 = t80*t390
t394 = t78*t165
t397 = t15*t183
t398 = t397*t149
t400 = t188*t84
t401 = t400*t218
t402 = t148*t401
t404 = t66*t94
t405 = t404*t287
t406 = t148*t405
t408 = -0.2e1_dp/0.3e1_dp*t388*t391 - (2._dp*t394*t150) + t147 &
*t398 - t147*t402 - t147*t406
t409 = 0.1e1_dp/t1
t410 = t408*t409
t411 = t3*t10
t412 = t410*t411
t413 = 0.1e1_dp/t15
t414 = t12*t413
t415 = 0.1e1_dp/t31
t416 = t415*t65
t417 = t416*t83
t418 = t414*t417
t423 = (-t77*t288 + t304*t95 - 2._dp*t92*t307 + t381*t143 - 3._dp &
*t142*t384 + t145*(t387 + t412*t418))*Clda
e_rho = e_rho + (-0.4e1_dp/0.3e1_dp*t269*t156 - t76*t423)*sx0
t425 = ndrho*t4
t426 = t425*t11
t429 = t245*t66
t430 = t70*t429
t432 = t188*t261
t433 = t148*t432
t435 = 2._dp*t426*t81 + t79*t430 - t147*t433
t440 = F2*t245
t443 = t440*t66 - t86*t432
t444 = t70*t443
t446 = 2._dp*t426*t89 + t79*t444
t447 = f12*t446
t449 = t306*t435
t463 = t98*(t100*t446*t83 + t100*t91*t435 + 2._dp*t103*t83 &
*t435 + 3._dp*t105*t93*t435)
t465 = t326*t435
t471 = f32*t120
t472 = t471*t122
t475 = t429*t71
t476 = t71*t261
t478 = t475 - t358*t476
t479 = t356*t478
t480 = t345*t479
t484 = t342*(t472*t345*t126 + t355*t480/0.2e1_dp)
t485 = t336*t484
t489 = (t463*t114 - 0.7e1_dp/0.2e1_dp*t109*t465 - (t330*dQndrho &
*t117*t130) + (2._dp*t330*t485))*t134
t491 = t376*t435
t495 = (-t489*t139 - 0.7e1_dp/0.2e1_dp*t374*t491)*E
t497 = t383*t435
t500 = dexeindrho(Q, dQndrho)
t501 = t425*t14
t504 = t15*t245
t505 = t504*t149
t507 = t400*t261
t508 = t148*t507
t510 = t404*t435
t511 = t148*t510
t513 = 2._dp*t501*t150 + t147*t505 - t147*t508 - t147*t511
t514 = t513*t409
t515 = t514*t411
t520 = (-t77*t94*t435 + t447*t95 - 2._dp*t92*t449 + t495*t143 &
- 3._dp*t142*t497 + t145*(t500 + t515*t418))*Clda
e_ndrho = e_ndrho + (-t76*t520)*sx0
END IF
IF (order >= 2 .OR. order == -2) THEN
t530 = t11*t26
t537 = t54*r3*t56*t6*t163
t540 = t21/t9/t537
t542 = t175*t169
t546 = t44*t28*t7
t550 = t24*t207*t28
t553 = 0.10e2_dp/0.9e1_dp*t2*t4*t199*t70*t169 + 0.8e1_dp/0.3e1_dp &
*t159*t231*t7 + (6._dp*t5*t530*t15) + 0.28e2_dp/0.9e1_dp* &
t19*t540*t542 + 0.32e2_dp/0.3e1_dp*t174*t546 + (20._dp*t22 &
*t550)
t557 = t184*t190
t566 = 0.1e1_dp/t187/t65
t569 = t32*t566*t1*t4
t570 = t218**2
t577 = t32*t188*t78*t42
t579 = t218*r3*t6
t616 = 0.28e2_dp/0.9e1_dp*t33*t540*t542 + 0.32e2_dp/0.3e1_dp*t193* &
t546 + (20._dp*t34*t550) + 0.40e2_dp/0.9e1_dp*t37*t39/t10/ &
t537*t202*t169 + 0.50e2_dp/0.3e1_dp*t201*t207*t46*t7 + 0.30e2_dp &
*t40*t42/t25/t163*t46 + (72._dp*t53*t58/t59/ &
t12*t61)
t620 = t199*t13
t621 = t620*t15
t627 = t42*t164
t628 = t627*t15
t632 = t26*t15
d2Qrhorho = f94*t553*t67*t73 - (2._dp*t557*t220) - 0.4e1_dp/0.3e1_dp &
*t184*t222*t228 - (4._dp*t185*t233) + (2._dp*t569*t14 &
*t192*t570) + 0.4e1_dp/0.3e1_dp*t577*t72*t579 + (4._dp*t191 &
*t165*t219) - (t191*t14*t192*t616) + 0.10e2_dp/0.9e1_dp &
*t223*t621*t71*t54*t56 + 0.8e1_dp/0.3e1_dp*t223*t628* &
t227 + 0.6e1_dp*t68*t69*t632*t71
t647 = -0.4e1_dp/0.3e1_dp*t236*t158*t160 - (4._dp*t237*t166) &
- 0.16e2_dp/0.3e1_dp*t241*t173*t176 - (16._dp*t242*t180)
t655 = t246*t190
t657 = t359*t261
t663 = t32*t188*ndrho*t4
t678 = -0.16e2_dp/0.3e1_dp*t249*t173*t176 - (16._dp*t250*t180) &
- 0.25e2_dp/0.3e1_dp*t253*t200*t203 - (25._dp*t254*t209) - &
(48._dp*t258*t215)
t685 = t7*t261
d2Qrhondrho = (f94*t647*t67*t73) - t557*t263 + (2._dp*t184* &
t265*t73) - (t655*t220) + (2._dp*t569*t16*t657) - (2._dp &
*t663*t220) - (t191*t14*t192*t678) - 0.2e1_dp/0.3e1_dp &
*t246*t222*t228 + 0.2e1_dp/0.3e1_dp*t577*t72*t685 - 0.4e1_dp &
/0.3e1_dp*t32*(t265)*t4*t228 - (2._dp*t247*t233) + &
(2._dp*t191*t165*t262) - (4._dp*t266*t233)
t707 = 2._dp*a1*t4*t16 + 12._dp*a2*t1*t21*t29
t716 = t261**2
t735 = 12._dp*a3*t1*t21*t29 + 20._dp*a4*t240*t39*t47 + 30._dp* &
a5*t18*t52*t63
d2Qndrhondrho = f94*t707*t67*t73 - 2._dp*t655*t263 + 4._dp*t246*t265* &
t73 + 2._dp*t569*t14*t192*t716 - 4._dp*t663*t263 - t191*t14 &
*t192*t735 + 2._dp*t32*t66*t4*t14*t192
t744 = t74**2
t751 = t287**2
t755 = t78*t620
t761 = t78*t627
t778 = t553*t66
t784 = t566*t570
t788 = t188*t616
t791 = 0.10e2_dp/0.9e1_dp*t755*t148*t66*t54*t56 + 0.8e1_dp/0.3e1_dp &
*t761*t275 - 0.4e1_dp/0.3e1_dp*t272*t397*t274 + 0.4e1_dp/0.3e1_dp &
*t388*t358*t579 + (6._dp*t79*t632*t80) - (4._dp*t79 &
*t231*t281) + (4._dp*t394*t285) + (t79*t70*t778) &
- 0.2e1_dp*t147*t397*t284 + 0.2e1_dp*t147*t148*t784 - t147 &
*t148*t788
t819 = 0.10e2_dp/0.9e1_dp*t755*t290*t169 + 0.8e1_dp/0.3e1_dp*t761* &
t291 - 0.4e1_dp/0.3e1_dp*t272*t15*t300*t7 + (6._dp*t79*t632 &
*t88) - 0.4e1_dp*(t79)*t231*t300 + (t79*t70*(F2 &
*t553*t66 - 2._dp*t297*t284 + 2._dp*t86*t784 - t86*t788))
t824 = C*t383
t854 = t323*t83
t856 = 0.1e1_dp/t111/t854
t857 = t110*t856
t867 = dQrho**2
t872 = t97*t116*dQrho
t875 = t97*t118
t878 = t148*t66
t887 = t69*t13
t888 = t338*t887
t889 = t188*t71
t905 = t13*sscale
t910 = t119*t343*t123
t911 = sscale*t356
t923 = 0.1e1_dp/t126/t125
t924 = t361**2
t930 = t183*t188
t933 = t31*t566
t952 = t372*t136
t956 = t111*t83*t138
t968 = 0.1e1_dp/t854
t975 = d2exeirhorho(Q, dQrho, d2Qrhorho)
t983 = t66*t143
t1003 = t358*t84
t1007 = t80*t94
t1018 = t566*t84
t1023 = t78*t16
t1024 = t94*t218
t1037 = (6._dp*t78*t530*t150) - (4._dp*t394*t398) + (4._dp &
*t394*t402) + (2._dp*t147*t148*t983*t751) - (t147 &
*t148*t404*t791) + (t147*t15*t553*t149) - (2._dp* &
t147*t397*t401) - (2._dp*t147*t397*t405) - 0.4e1_dp/0.3e1_dp &
*t388*t281*t390 + 0.4e1_dp/0.3e1_dp*t388*t1003*t579 + 0.4e1_dp &
/0.3e1_dp*t388*t1007*t7*t287 + 0.10e2_dp/0.9e1_dp*(t78) &
*(t621)*(t80)*(t84)*(t54)*(t56) + (2._dp &
*t147*t148*t1018*t570) + 0.2e1_dp*t1023*t358*t1024 &
*t287 - (t147*t148*t400*t616) + 0.8e1_dp/0.3e1_dp*(t78) &
*(t628)*(t391) + (4._dp*t394*t406)
t1055 = t411*t12
t1056 = t410*t1055
t1057 = t31**2
t1059 = t413/t1057
t1060 = t65*t83
t1073 = (2._dp*t77*t143*t751) - (t77*t94*t791) + (f12 &
*t819*t95) - (4._dp*t304*t307) + (6._dp*t92*t824* &
t751) - (2._dp*t92*t306*t791) + (-((t98*(t100*t819 &
*t83 + 2._dp*t100*t303*t287 + t100*t91*t791 + 2._dp*t103*t751 &
+ 2._dp*t103*t83*t791 + 6._dp*t105*t83*t751 + 3._dp*t105*t93 &
*t791)*t114) - (7._dp*t321*t327) + 0.63e2_dp/0.4e1_dp*(t109) &
*(t857)*(t751) - 0.7e1_dp/0.2e1_dp*(t109)*(t326) &
*(t791) - t330*d2Qrhorho*t117*t130 - t330*t867*t117 &
*t130 + (4._dp*t872*t368) + 0.2e1_dp*t875*t335*(0.2e1_dp/ &
0.3e1_dp*t338*t158*t13*t878*t227 + (2._dp*t339*t231* &
t125) - (t339*t70*t357) + t888*t148*t889*t218)*t367 &
+ 0.2e1_dp*t330*t336*t342*(0.4e1_dp/0.9e1_dp*t119*t120*t172 &
*t345*t126*t54*t56 + 0.2e1_dp/0.3e1_dp*t344*t905*t347 &
- t910*t911*t7*t361/0.3e1_dp + (2._dp*t121*t122*t164* &
t127) - t355*t905*t362 - t355*t345*t923*t924/0.4e1_dp + t355 &
*t345*t356*(t778*t71 - 2._dp*t930*t359 + 2._dp*t933* &
t71*t570 - t358*t71*t616)/0.2e1_dp))*t134*t139 - (7._dp &
*t952*t377) - 0.35e2_dp/0.4e1_dp*(t374)*(t956)*(t751) &
- 0.7e1_dp/0.2e1_dp*(t374)*(t376)*(t791))*E* &
(t143) - (6._dp*t381*t384) + (12._dp*t142*t968*t751) &
- (3._dp*t142*t383*t791) + t145*(t975 + t1037*t409*t411 &
*t418 + 0.2e1_dp/0.3e1_dp*(t410)*(t3)*(t122)* &
(t12)*(t413)*(t415)*(t65)*(t83)*(r3) &
*(t6) + (2._dp*t412*rho*t413*t417) - t1056*t1059 &
*t1060*t183 + (t412)*t414*(t415)*t218*(t83) &
+ (t412)*t414*t416*(t287))
e_rho_rho = e_rho_rho + (-0.4e1_dp/0.9e1_dp/t744*f89*t156 - 0.8e1_dp/0.3e1_dp*t269*t423 &
- t76*t1073*Clda)*sx0
t1079 = t143*t287*t435
t1082 = t425*t224
t1100 = t647*t66
t1110 = t566*t218*t261
t1114 = t188*t678
t1117 = -0.4e1_dp/0.3e1_dp*t1082*t275 - 0.2e1_dp/0.3e1_dp*t272*t504 &
*t274 + 0.2e1_dp/0.3e1_dp*t388*t358*t685 - (4._dp*t426*t278) &
- (2._dp*t79*t231*t429) + (2._dp*t394*t433) + (2._dp &
*t426*t282) + (t79*t70*t1100) - t147*t397*t432 - (2._dp &
*t501*t285) - t147*t504*t284 + 0.2e1_dp*t147*t148*t1110 &
- t147*t148*t1114
t1143 = -0.4e1_dp/0.3e1_dp*t1082*t291 - 0.2e1_dp/0.3e1_dp*t272*t15 &
*t443*t7 - (4._dp*t426*t294) - 0.2e1_dp*t79*t231*t443 + &
(2._dp*t426*t301) + t79*t70*(F2*t647*t66 - t297* &
t432 - t440*t284 + 2._dp*t86*t1110 - t86*t1114)
t1165 = t435*t287
t1202 = t97*t116*dQndrho
t1215 = t335*(-2._dp*t337*ndrho*t69*t340 - t339*t70*t475 &
+ t888*t148*t889*t261)
t1242 = t245*t188
t1258 = (t98*(t100*t1143*t83 + t100*t303*t435 + t100 &
*t446*t287 + t100*t91*t1117 + 2._dp*t103*t1165 + 2._dp*t103* &
t83*t1117 + 6._dp*t105*t314*t435 + 3._dp*t105*t93*t1117)* &
t114) - 0.7e1_dp/0.2e1_dp*t321*t465 - 0.7e1_dp/0.2e1_dp*t463*t327 &
+ 0.63e2_dp/0.4e1_dp*(t109)*(t110)*(t856)*(t287) &
*(t435) - 0.7e1_dp/0.2e1_dp*(t109)*(t326)*(t1117) &
- t330*d2Qrhondrho*t117*t130 - t330*dQrho*dQndrho*t117*t130 &
+ (2._dp*t872*t485) + (2._dp*t1202*t368) + (2._dp*t875 &
*t1215*t367) + 0.2e1_dp*t330*t336*t342*(-t471*t24*t123 &
*t127*t7/0.3e1_dp - t910*t911*t7*t478/0.6e1_dp - t472*t905 &
*t126 - t355*t905*t479/0.2e1_dp + t472*t363/0.2e1_dp - t355 &
*t345*t923*t361*t478/0.4e1_dp + t355*t345*t356*(t1100 &
*t71 - t930*t476 - t1242*t359 + 2._dp*t933*t657 - t358 &
*t71*t678)/0.2e1_dp)
t1263 = t489*t136
t1286 = d2exeirhondrho(Q, dQrho, dQndrho, d2Qrhondrho)
t1316 = -0.4e1_dp/0.3e1_dp*t425*t225*t391 - 0.2e1_dp/0.3e1_dp*t388 &
*t429*t390 + 0.2e1_dp/0.3e1_dp*t388*t1003*t685 + 0.2e1_dp/0.3e1_dp &
*t388*t1007*t7*t435 - 0.4e1_dp*t425*t165*t150 - (2._dp &
*t394*t505) + (2._dp*t394*t508) + (2._dp*t394*t511) + &
(2._dp*t501*t398) + t147*t15*t647*t149 - t147*t397*t507
t1347 = -t147*t397*t510 - 2._dp*t501*t402 - t147*t504*t401 &
+ 2._dp*t1023*t933*t84*t218*t261 + t1023*t358*t1024*t435 &
- t147*t148*t400*t678 - 2._dp*t501*t406 - t147*t504*t405 &
+ t1023*t358*t288*t261 + 2._dp*t1023*t80*t1079 - t147 &
*t148*t404*t1117
t1352 = 0.1e1_dp/t240
t1358 = t1059*t1060*t245
t1362 = t414*t415*t261*t83
t1365 = t414*t416*t435
t1369 = (2._dp*t77*t1079) - (t77*t94*t1117) + f12*t1143 &
*t95 - (2._dp*t304*t449) - (2._dp*t447*t307) + (6._dp &
*t92*C*t384*t435) - (2._dp*t92*t306*t1117) + (-t1258 &
*t134*t139 - 0.7e1_dp/0.2e1_dp*t952*t491 - 0.7e1_dp/0.2e1_dp*t1263 &
*t377 - 0.35e2_dp/0.4e1_dp*t374*t956*t1165 - 0.7e1_dp/0.2e1_dp* &
t374*t376*(t1117))*E*t143 - (3._dp*t381*t497) - (3._dp &
*t495*t384) + (12._dp*t142*t968*t287*t435) - (3._dp &
*t142*t383*t1117) + (t145*(t1286 + (t1316 + t1347)* &
t409*t411*t418 - 2._dp*t408*t1352*t411*t418 - t1056*t1358 &
+ t412*t1362 + t412*t1365))
e_ndrho_rho = e_ndrho_rho + (-0.4e1_dp/0.3e1_dp*t269*t520 - t76*t1369*Clda)*sx0
t1372 = t435**2
t1382 = t707*t66
t1388 = t566*t716
t1392 = t188*t735
t1395 = 2._dp*t887*t878 + 4._dp*t426*t430 - 4._dp*t501*t433 + t79* &
t70*t1382 - 2._dp*t147*t504*t432 + 2._dp*t147*t148*t1388 - &
t147*t148*t1392
t1412 = 2._dp*t69*t89 + 4._dp*t426*t444 + t79*t70*(F2*t707* &
t66 - 2._dp*t440*t432 + 2._dp*t86*t1388 - t86*t1392)
t1455 = dQndrho**2
t1465 = t478**2
t1510 = d2exeindrhondrho(Q, dQndrho, d2Qndrhondrho)
t1547 = 2._dp*t887*t150 + 4._dp*t501*t505 - 4._dp*t501*t508 - 4._dp*t501 &
*t511 + t147*t15*t707*t149 - 2._dp*t147*t504*t507 - 2._dp &
*t147*t504*t510 + 2._dp*t147*t148*t1018*t716 + 2._dp*t1023 &
*t358*t94*t261*t435 - t147*t148*t400*t735 + 2._dp*t147 &
*t148*t983*t1372 - t147*t148*t404*t1395
t1561 = (2._dp*t77*t143*t1372) - (t77*t94*t1395) + (f12 &
*t1412*t95) - (4._dp*t447*t449) + (6._dp*t92*t824 &
*t1372) - (2._dp*t92*t306*t1395) + (-((t98*(t100* &
t1412*t83 + 2._dp*t100*t446*t435 + t100*t91*t1395 + 2._dp*t103 &
*t1372 + 2._dp*t103*t83*t1395 + 6._dp*t105*t83*t1372 + 3._dp* &
t105*t93*t1395)*t114) - (7._dp*t463*t465) + 0.63e2_dp/0.4e1_dp &
*(t109)*(t857)*(t1372) - 0.7e1_dp/0.2e1_dp*(t109) &
*(t326)*(t1395) - t330*d2Qndrhondrho*t117*t130 - t330 &
*t1455*t117*t130 + (4._dp*t1202*t485) + (2._dp*t875* &
t1215*t484) + 0.2e1_dp*t330*t336*t342*(t472*t480 - t355 &
*t345*t923*t1465/0.4e1_dp + t355*t345*t356*(t1382* &
t71 - 2._dp*t1242*t476 + 2._dp*t933*t71*t716 - t358*t71*t735) &
/0.2e1_dp))*t134*t139 - (7._dp*t1263*t491) - 0.35e2_dp/0.4e1_dp &
*(t374)*(t956)*(t1372) - 0.7e1_dp/0.2e1_dp*(t374) &
*(t376)*(t1395))*E*(t143) - (6._dp*t495 &
*t497) + (12._dp*t142*t968*t1372) - (3._dp*t142*t383* &
t1395) + (t145*(t1510 + t1547*t409*t411*t418 - 2._dp*t513 &
*t1352*t411*t418 - t514*t1055*t1358 + t515*t1362 + t515 &
*t1365))
e_ndrho_ndrho = e_ndrho_ndrho + (-t76*t1561*Clda)*sx0
END IF
END SUBROUTINE xwpbe_lda_calc_0
! **************************************************************************************************
!> \brief Evaluates the screened hole averaged PBE exchange functional for lda
!> \param e_0 ...
!> \param e_rho ...
!> \param e_ndrho ...
!> \param e_rho_rho ...
!> \param e_ndrho_rho ...
!> \param e_ndrho_ndrho ...
!> \param rho , ndrho: density and norm of the density gradient
!> \param ndrho ...
!> \param sscale scaling factor to enforce Lieb-Oxford bound
!> \param sx0 scaling factor
!> \param order degree of the derivative that should be evaluated,
!> if positive all the derivatives up to the given degree are evaluated,
!> if negative only the given degree is calculated
!> \par History
!> 05.2007 created [Manuel Guidon]
!> \author Manuel Guidon
!> \note
!> This routine evaluates the functional for omega=0 using a taylor
!> expansion for the parameter G.
! **************************************************************************************************
SUBROUTINE xwpbe_lda_calc_01(e_0, e_rho, e_ndrho, e_rho_rho, e_ndrho_rho, &
e_ndrho_ndrho, rho, ndrho, sscale, sx0, order)
REAL(KIND=dp), INTENT(INOUT) :: e_0, e_rho, e_ndrho, e_rho_rho, &
e_ndrho_rho, e_ndrho_ndrho
REAL(KIND=dp), INTENT(IN) :: rho, ndrho, sscale, sx0
INTEGER, INTENT(IN) :: order
REAL(KIND=dp) :: d2Qndrhondrho, d2Qrhondrho, d2Qrhorho, dQndrho, dQrho, Q, t1, t10, t100, &
t101, t1019, t103, t104, t1051, t1056, t1062, t1066, t1069, t107, t1073, t1076, t1080, &
t109, t1094, t1098, t11, t1101, t111, t112, t113, t114, t115, t1154, t116, t118, t1191, &
t12, t1205, t122, t124, t125, t126, t129, t13, t130, t131, t132, t135, t136, t139, t14, &
t140, t141, t142, t146, t149, t15, t150, t151, t153, t154, t156, t157, t158, t159, t16, &
t165, t166, t167, t168, t169, t173, t175, t18, t181, t184, t185, t186, t188, t189, t19, &
t190, t191, t193, t194, t197, t199, t2, t20, t202, t203, t206, t207
REAL(KIND=dp) :: t208, t21, t211, t212, t213, t215, t216, t219, t22, t220, t224, t227, t228, &
t229, t231, t232, t235, t238, t24, t240, t241, t244, t247, t248, t25, t250, t251, t253, &
t254, t256, t257, t26, t260, t263, t266, t267, t270, t272, t273, t276, t277, t28, t280, &
t283, t288, t29, t293, t294, t297, t299, t3, t300, t301, t304, t305, t307, t308, t31, &