1 /*
2
3
4 !
5 ! Dalton, a molecular electronic structure program
6 ! Copyright (C) by the authors of Dalton.
7 !
8 ! This program is free software; you can redistribute it and/or
9 ! modify it under the terms of the GNU Lesser General Public
10 ! License version 2.1 as published by the Free Software Foundation.
11 !
12 ! This program is distributed in the hope that it will be useful,
13 ! but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 ! Lesser General Public License for more details.
16 !
17 ! If a copy of the GNU LGPL v2.1 was not distributed with this
18 ! code, you can obtain one at https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html.
19 !
20
21 !
22
23 */
24 /*-*-mode: C; c-indentation-style: "bsd"; c-basic-offset: 4; -*-*/
25 /* fun-mpbex.c:
26
27 Automatically generated code implementing MPBEX functional and
28 its derivatives. It is generated by func-codegen.pl being a part of
29 a "Automatic code generation framework for analytical functional
30 derivative evaluation", Pawel Salek, 2005
31
32 This functional is connected by making following changes:
33 1. add "extern Functional mpbexFunctional;" to 'functionals.h'
34 2. add "&mpbexFunctional," to 'functionals.c'
35 3. add "fun-mpbex.c" to 'Makefile.am', 'Makefile.in' or 'Makefile'.
36
37 This functional has been generated from following input:
38 ------ cut here -------
39 xa:sqrt(grada*grada)/rhoa^(4/3);
40 xb:sqrt(gradb*gradb)/rhob^(4/3);
41
42 a:0.157;
43 C1:0.21951;
44 C2:-0.015;
45 R:0.804;
46 d:0.066725;
47 mu:d*%PI^2/3;
48 Sa:xa/(2*(6*%PI^2)^(1/3));
49 Sb:xb/(2*(6*%PI^2)^(1/3));
50
51 G(T):=T^2/(1+a*T^2);
52 F(S):=1+C1*G(S)+C2*G(S)^2;
53 Ea(n):=-3/(4*%PI)*(3*%PI^2)^(1/3)*n^(4/3)*F(Sa);
54 Eb(n):=-3/(4*%PI)*(3*%PI^2)^(1/3)*n^(4/3)*F(Sb);
55
56 K(rhoa,grada,rhob,gradb,gradab):=0.5*(Ea(2*rhoa)+Eb(2*rhob));
57
58
59 ------ cut here -------
60 */
61
62
63 /* strictly conform to XOPEN ANSI C standard */
64 #if !defined(SYS_DEC)
65 /* XOPEN compliance is missing on old Tru64 4.0E Alphas and pow() prototype
66 * is not specified. */
67 #define _XOPEN_SOURCE 500
68 #define _XOPEN_SOURCE_EXTENDED 1
69 #endif
70 #include <math.h>
71 #include <stddef.h>
72 #include "general.h"
73
74 #define __CVERSION__
75
76 #include "functionals.h"
77
78 /* INTERFACE PART */
mpbex_isgga(void)79 static integer mpbex_isgga(void) { return 1; } /* FIXME: detect! */
80 static integer mpbex_read(const char *conf_line);
81 static real mpbex_energy(const FunDensProp* dp);
82 static void mpbex_first(FunFirstFuncDrv *ds, real factor,
83 const FunDensProp* dp);
84 static void mpbex_second(FunSecondFuncDrv *ds, real factor,
85 const FunDensProp* dp);
86 static void mpbex_third(FunThirdFuncDrv *ds, real factor,
87 const FunDensProp* dp);
88 static void mpbex_fourth(FunFourthFuncDrv *ds, real factor,
89 const FunDensProp* dp);
90
91 Functional mPBExFunctional = {
92 "mPBEx", /* name */
93 mpbex_isgga, /* gga-corrected */
94 1,
95 mpbex_read,
96 NULL,
97 mpbex_energy,
98 mpbex_first,
99 mpbex_second,
100 mpbex_third,
101 mpbex_fourth
102 };
103
104 /* IMPLEMENTATION PART */
105 static integer
mpbex_read(const char * conf_line)106 mpbex_read(const char *conf_line)
107 {
108 fun_set_hf_weight(0);
109 return 1;
110 }
111
112 static real
mpbex_energy(const FunDensProp * dp)113 mpbex_energy(const FunDensProp *dp)
114 {
115 real res;
116 real rhoa = dp->rhoa, rhob = dp->rhob;
117 real grada = dp->grada, gradb = dp->gradb, gradab = dp->gradab;
118
119 real t1, t2, t3, t4, t5, t6, t7, t8, t9, t10;
120 real t11, t12, t13;
121
122 t1 = pow(2.0,0.333333333333333);
123 t2 = pow(3.0,0.333333333333333);
124 t3 = 1/pow(3.141592653589793,0.333333333333333);
125 t4 = 1/pow(6.0,0.333333333333333);
126 t5 = 1/pow(3.141592653589793,2.666666666666667);
127 t6 = 1/pow(6.0,0.666666666666667);
128 t7 = 1/pow(3.141592653589793,1.333333333333333);
129 t8 = pow(grada,2.0);
130 t9 = 1/pow(rhoa,2.666666666666667);
131 t10 = 0.03925*t6*t7*t8*t9+1.0;
132 t11 = pow(gradb,2.0);
133 t12 = 1/pow(rhob,2.666666666666667);
134 t13 = 0.03925*t6*t7*t11*t12+1.0;
135
136 /* code */
137 res = 0.5*(-1.5*t1*t2*t3*pow(rhob,1.333333333333333)*
138 (-1.5624999999999998E-4*t4*t5*pow(gradb,4.0)/(pow(t13,2.0)*
139 pow(rhob,5.333333333333333))+0.0548775*t11*t12*t6*t7/t13+1.0)-
140 1.5*t1*t2*t3*pow(rhoa,1.333333333333333)*(-1.5624999999999998E-4*
141 t4*t5*pow(grada,4.0)/(pow(t10,2.0)*pow(rhoa,5.333333333333333))+
142 0.0548775*t6*t7*t8*t9/t10+1.0));
143
144 return res;
145 }
146
147 static void
mpbex_first_helper(real rhoa,real grada,real * res)148 mpbex_first_helper(real rhoa, real grada, real *res)
149 { real t1, t2, t3, t4, t5, t6, t7, t8, t9, t10;
150 real t11, t12, t13, t14, t15, t16, t17;
151
152 t1 = pow(2.0,0.333333333333333);
153 t2 = pow(3.0,0.333333333333333);
154 t3 = 1/pow(3.141592653589793,0.333333333333333);
155 t4 = 1/pow(6.0,0.333333333333333);
156 t5 = 1/pow(3.141592653589793,2.666666666666667);
157 t6 = pow(grada,4.0);
158 t7 = 1/pow(6.0,0.666666666666667);
159 t8 = 1/pow(3.141592653589793,1.333333333333333);
160 t9 = pow(grada,2.0);
161 t10 = 1/pow(rhoa,2.666666666666667);
162 t11 = 0.03925*t7*t8*t9*t10+1.0;
163 t12 = 1/pow(t11,2.0);
164 t13 = 1/pow(rhoa,5.333333333333333);
165 t14 = 1/t11;
166 t15 = 1/pow(3.141592653589793,4.0);
167 t16 = 1/pow(t11,3.0);
168 t17 = pow(rhoa,1.333333333333333);
169
170 /* code */
171 res[0] = 0.5*(-1.5*t1*t17*t2*t3*(-5.451388888888888E-6*
172 t15*t16*pow(grada,6.0)/pow(rhoa,9.0)+0.001790640833333*t12*
173 t4*t5*t6/pow(rhoa,6.333333333333333)-0.14634*t14*t7*t8*t9/
174 pow(rhoa,3.666666666666667))-2.0*t1*(-1.5624999999999998E-4*
175 t4*t5*t6*t12*t13+0.0548775*t7*t8*t9*t14*t10+1.0)*t2*t3*pow(rhoa,
176 0.333333333333333));
177 res[1] = -0.75*t1*t17*t2*t3*(4.088541666666666E-6*t15*
178 t16*pow(grada,5.0)/pow(rhoa,8.0)-0.001342980625*t12*t13*t4*
179 t5*pow(grada,3.0)+0.109755*t7*t8*grada*t14*t10);
180 }
181
182 static void
mpbex_first(FunFirstFuncDrv * ds,real factor,const FunDensProp * dp)183 mpbex_first(FunFirstFuncDrv *ds, real factor, const FunDensProp *dp)
184 {
185 real res[2];
186
187 mpbex_first_helper(dp->rhoa, dp->grada, res);
188 /* Final assignment */
189 ds->df1000 += factor*res[0];
190 ds->df0010 += factor*res[1];
191
192
193 if(fabs(dp->rhoa-dp->rhob)>1e-13 ||
194 fabs(dp->grada-dp->gradb)>1e-13)
195 mpbex_first_helper(dp->rhob, dp->gradb, res);
196 ds->df0100 += factor*res[0];
197 ds->df0001 += factor*res[1];
198
199 }
200
201 static void
mpbex_second_helper(real rhoa,real grada,real * res)202 mpbex_second_helper(real rhoa, real grada, real *res)
203 {
204 real t1, t2, t3, t4, t5, t6, t7, t8, t9, t10;
205 real t11, t12, t13, t14, t15, t16, t17, t18;
206 real t19, t20, t21, t22, t23, t24, t25, t26;
207 real t27, t28, t29, t30;
208
209 t1 = pow(2.0,0.333333333333333);
210 t2 = pow(3.0,0.333333333333333);
211 t3 = 1/pow(3.141592653589793,0.333333333333333);
212 t4 = 1/pow(6.0,0.333333333333333);
213 t5 = 1/pow(3.141592653589793,2.666666666666667);
214 t6 = pow(grada,4.0);
215 t7 = 1/pow(6.0,0.666666666666667);
216 t8 = 1/pow(3.141592653589793,1.333333333333333);
217 t9 = pow(grada,2.0);
218 t10 = 1/pow(rhoa,2.666666666666667);
219 t11 = 0.03925*t7*t8*t9*t10+1.0;
220 t12 = 1/pow(t11,2.0);
221 t13 = 1/pow(rhoa,5.333333333333333);
222 t14 = 1/t11;
223 t15 = -1.5624999999999998E-4*t4*t5*t6*t12*t13+0.0548775*
224 t7*t8*t9*t14*t10+1.0;
225 t16 = pow(rhoa,0.333333333333333);
226 t17 = 1/pow(3.141592653589793,4.0);
227 t18 = pow(grada,6.0);
228 t19 = 1/pow(t11,3.0);
229 t20 = 1/pow(rhoa,9.0);
230 t21 = 1/pow(rhoa,6.333333333333333);
231 t22 = 1/pow(rhoa,3.666666666666667);
232 t23 = -0.14634*t7*t8*t9*t14*t22+0.001790640833333*t4*
233 t5*t6*t12*t21-5.451388888888888E-6*t17*t18*t19*t20;
234 t24 = pow(rhoa,1.333333333333333);
235 t25 = pow(grada,5.0);
236 t26 = 1/pow(rhoa,8.0);
237 t27 = pow(grada,3.0);
238 t28 = 0.109755*t7*t8*grada*t14*t10-0.001342980625*t4*
239 t5*t27*t12*t13+4.088541666666666E-6*t17*t25*t19*t26;
240 t29 = 1/pow(3.141592653589793,5.333333333333333);
241 t30 = 1/pow(t11,4.0);
242
243 /* code */
244 res[0] = 0.5*(-1.5*t1*t2*t23*t24*t3-2.0*t1*t15*t16*t2*
245 t3);
246 res[1] = -0.75*t1*t2*t3*t28*t24;
247 res[2] = 0.5*(-1.5*t1*t2*t24*t3*(-1.7117361111111105E-6*
248 t29*t30*t7*pow(grada,8.0)/pow(rhoa,12.66666666666667)+1.1153596907407406E-4*
249 t17*t18*t19/pow(rhoa,10.0)-0.013893545277778*t12*t4*t5*t6/
250 pow(rhoa,7.333333333333333)+0.53658*t14*t7*t8*t9/pow(rhoa,
251 4.666666666666667))-0.666666666666667*t1*t15*t2*t3/pow(rhoa,
252 0.666666666666667)-4.0*t1*t16*t2*t23*t3);
253 res[3] = 0.5*(-1.5*t1*t2*t24*t3*(1.283802083333333E-6*
254 t29*t30*t7*pow(grada,7.0)/pow(rhoa,11.66666666666667)-0.29268*
255 t7*t8*grada*t14*t22+0.009077178333333*t4*t5*t27*t12*t21-7.956343513888887E-5*
256 t17*t25*t19*t20)-2.0*t1*t16*t2*t28*t3);
257 res[4] = -0.75*t1*t2*t24*t3*(-9.628515624999997E-7*t18*
258 t29*t30*t7/pow(rhoa,10.66666666666667)+5.558403468749999E-5*
259 t17*t6*t19*t26-0.005464903125*t4*t5*t9*t12*t13+0.109755*t7*
260 t8*t14*t10);
261
262 }
263
264 static void
mpbex_second(FunSecondFuncDrv * ds,real factor,const FunDensProp * dp)265 mpbex_second(FunSecondFuncDrv *ds, real factor, const FunDensProp* dp)
266 {
267 real res[5];
268
269 mpbex_second_helper(dp->rhoa, dp->grada, res);
270
271 ds->df1000 += factor*res[0];
272 ds->df0010 += factor*res[1];
273
274 ds->df2000 += factor*res[2];
275 ds->df1010 += factor*res[3];
276 ds->df0020 += factor*res[4];
277
278
279 if(fabs(dp->rhoa-dp->rhob)>1e-13 ||
280 fabs(dp->grada-dp->gradb)>1e-13)
281 mpbex_second_helper(dp->rhob, dp->gradb, res);
282 ds->df0100 += factor*res[0];
283 ds->df0001 += factor*res[1];
284
285 ds->df0200 += factor*res[2];
286 ds->df0101 += factor*res[3];
287 ds->df0002 += factor*res[4];
288
289 }
290
291 static void
mpbex_third_helper(real rhoa,real grada,real * res)292 mpbex_third_helper(real rhoa, real grada, real *res)
293 {
294 real t1, t2, t3, t4, t5, t6, t7, t8, t9, t10;
295 real t11, t12, t13, t14, t15, t16, t17, t18;
296 real t19, t20, t21, t22, t23, t24, t25, t26;
297 real t27, t28, t29, t30, t31, t32, t33, t34;
298 real t35, t36, t37, t38, t39, t40, t41, t42;
299 real t43, t44;
300
301 t1 = pow(2.0,0.333333333333333);
302 t2 = pow(3.0,0.333333333333333);
303 t3 = 1/pow(3.141592653589793,0.333333333333333);
304 t4 = 1/pow(6.0,0.333333333333333);
305 t5 = 1/pow(3.141592653589793,2.666666666666667);
306 t6 = pow(grada,4.0);
307 t7 = 1/pow(6.0,0.666666666666667);
308 t8 = 1/pow(3.141592653589793,1.333333333333333);
309 t9 = pow(grada,2.0);
310 t10 = 1/pow(rhoa,2.666666666666667);
311 t11 = 0.03925*t7*t8*t9*t10+1.0;
312 t12 = 1/pow(t11,2.0);
313 t13 = 1/pow(rhoa,5.333333333333333);
314 t14 = 1/t11;
315 t15 = -1.5624999999999998E-4*t4*t5*t6*t12*t13+0.0548775*
316 t7*t8*t9*t14*t10+1.0;
317 t16 = pow(rhoa,0.333333333333333);
318 t17 = 1/pow(3.141592653589793,4.0);
319 t18 = pow(grada,6.0);
320 t19 = 1/pow(t11,3.0);
321 t20 = 1/pow(rhoa,9.0);
322 t21 = 1/pow(rhoa,6.333333333333333);
323 t22 = 1/pow(rhoa,3.666666666666667);
324 t23 = -0.14634*t7*t8*t9*t14*t22+0.001790640833333*t4*
325 t5*t6*t12*t21-5.451388888888888E-6*t17*t18*t19*t20;
326 t24 = pow(rhoa,1.333333333333333);
327 t25 = pow(grada,5.0);
328 t26 = 1/pow(rhoa,8.0);
329 t27 = pow(grada,3.0);
330 t28 = 0.109755*t7*t8*grada*t14*t10-0.001342980625*t4*
331 t5*t27*t12*t13+4.088541666666666E-6*t17*t25*t19*t26;
332 t29 = 1/pow(rhoa,0.666666666666667);
333 t30 = 1/pow(3.141592653589793,5.333333333333333);
334 t31 = pow(grada,8.0);
335 t32 = 1/pow(t11,4.0);
336 t33 = 1/pow(rhoa,12.66666666666667);
337 t34 = 1/pow(rhoa,10.0);
338 t35 = 1/pow(rhoa,7.333333333333333);
339 t36 = 1/pow(rhoa,4.666666666666667);
340 t37 = 0.53658*t7*t8*t9*t14*t36-0.013893545277778*t4*t5*
341 t6*t12*t35+1.1153596907407406E-4*t17*t18*t19*t34-1.7117361111111105E-6*
342 t7*t30*t31*t32*t33;
343 t38 = pow(grada,7.0);
344 t39 = 1/pow(rhoa,11.66666666666667);
345 t40 = -0.29268*t7*t8*grada*t14*t22+0.009077178333333*
346 t4*t5*t27*t12*t21-7.956343513888887E-5*t17*t25*t19*t20+1.283802083333333E-6*
347 t7*t30*t38*t32*t39;
348 t41 = 1/pow(rhoa,10.66666666666667);
349 t42 = 0.109755*t7*t8*t14*t10-0.005464903125*t4*t5*t9*
350 t12*t13+5.558403468749999E-5*t17*t6*t19*t26-9.628515624999997E-7*
351 t7*t30*t18*t32*t41;
352 t43 = 1/pow(3.141592653589793,6.666666666666667);
353 t44 = 1/pow(t11,5.0);
354
355 /* code */
356 res[0] = 0.5*(-1.5*t1*t2*t23*t24*t3-2.0*t1*t15*t16*t2*
357 t3);
358 res[1] = -0.75*t1*t2*t3*t28*t24;
359 res[2] = 0.5*(-1.5*t1*t2*t24*t3*t37-0.666666666666667*
360 t1*t15*t2*t29*t3-4.0*t1*t16*t2*t23*t3);
361 res[3] = 0.5*(-1.5*t1*t2*t24*t3*t40-2.0*t1*t16*t2*t28*
362 t3);
363 res[4] = -0.75*t1*t2*t3*t42*t24;
364 res[5] = 0.5*(-1.5*t1*t2*t24*t3*(-1.194411419753086E-7*
365 t4*t43*t44*pow(grada,10.0)/pow(rhoa,16.33333333333333)+5.670428502999997E-5*
366 t30*t31*t32*t7/pow(rhoa,13.66666666666667)-0.00160009004821*
367 t17*t18*t19/pow(rhoa,11.0)+0.111246338703704*t12*t4*t5*t6/
368 pow(rhoa,8.333333333333334)-2.50404*t14*t7*t8*t9/pow(rhoa,
369 5.666666666666667))+0.444444444444444*t1*t15*t2*t3/pow(rhoa,
370 1.666666666666667)-6.0*t1*t16*t2*t3*t37-2.0*t1*t2*t23*t29*
371 t3);
372 res[6] = 0.5*(-1.5*t1*t2*t24*t3*(8.958085648148145E-8*
373 t4*t43*t44*pow(grada,9.0)/pow(rhoa,15.33333333333333)+1.07316*
374 t7*t8*grada*t14*t36-0.062594436111111*t4*t5*t27*t12*t35+0.001032763582546*
375 t17*t25*t19*t34-3.996060960583333E-5*t7*t30*t38*t32*t33)-4.0*
376 t1*t16*t2*t3*t40-0.666666666666667*t1*t2*t28*t29*t3);
377 res[7] = 0.5*(-1.5*t1*t2*t24*t3*(-6.718564236111108E-8*
378 t31*t4*t43*t44/pow(rhoa,14.33333333333333)+2.772380355854166E-5*
379 t7*t30*t18*t32*t39-0.29268*t7*t8*t14*t22+0.031060765*t4*t5*
380 t9*t12*t21-6.353366754166664E-4*t17*t6*t19*t20)-2.0*t1*t16*
381 t2*t3*t42);
382 res[8] = -0.75*t1*t2*t24*t3*(5.038923177083331E-8*t38*
383 t4*t43*t44/pow(rhoa,13.33333333333333)-1.8867149543906244E-5*
384 t7*t30*t25*t32*t41+3.653344371874999E-4*t17*t27*t19*t26-0.0123657675*
385 t4*t5*grada*t12*t13);
386
387 }
388
389 static void
mpbex_third(FunThirdFuncDrv * ds,real factor,const FunDensProp * dp)390 mpbex_third(FunThirdFuncDrv *ds, real factor, const FunDensProp* dp)
391 {
392 real res[9];
393
394 mpbex_third_helper(dp->rhoa, dp->grada, res);
395
396 ds->df1000 += factor*res[0];
397 ds->df0010 += factor*res[1];
398
399 ds->df2000 += factor*res[2];
400 ds->df1010 += factor*res[3];
401 ds->df0020 += factor*res[4];
402
403 ds->df3000 += factor*res[5];
404 ds->df2010 += factor*res[6];
405 ds->df1020 += factor*res[7];
406 ds->df0030 += factor*res[8];
407
408
409 if(fabs(dp->rhoa-dp->rhob)>1e-13 ||
410 fabs(dp->grada-dp->gradb)>1e-13)
411 mpbex_third_helper(dp->rhob, dp->gradb, res);
412
413 ds->df0100 += factor*res[0];
414 ds->df0001 += factor*res[1];
415
416 ds->df0200 += factor*res[2];
417 ds->df0101 += factor*res[3];
418 ds->df0002 += factor*res[4];
419
420 ds->df0300 += factor*res[5];
421 ds->df0201 += factor*res[6];
422 ds->df0102 += factor*res[7];
423 ds->df0003 += factor*res[8];
424
425 }
426
427 static void
mpbex_fourth_helper(real rhoa,real grada,real * res)428 mpbex_fourth_helper(real rhoa, real grada, real *res)
429 {
430 real t1, t2, t3, t4, t5, t6, t7, t8, t9, t10;
431 real t11, t12, t13, t14, t15, t16, t17, t18;
432 real t19, t20, t21, t22, t23, t24, t25, t26;
433 real t27, t28, t29, t30, t31, t32, t33, t34;
434 real t35, t36, t37, t38, t39, t40, t41, t42;
435 real t43, t44, t45, t46, t47, t48, t49, t50;
436 real t51, t52, t53, t54, t55, t56, t57, t58;
437 real t59, t60, t61;
438
439 t1 = pow(2.0,0.333333333333333);
440 t2 = pow(3.0,0.333333333333333);
441 t3 = 1/pow(3.141592653589793,0.333333333333333);
442 t4 = 1/pow(6.0,0.333333333333333);
443 t5 = 1/pow(3.141592653589793,2.666666666666667);
444 t6 = pow(grada,4.0);
445 t7 = 1/pow(6.0,0.666666666666667);
446 t8 = 1/pow(3.141592653589793,1.333333333333333);
447 t9 = pow(grada,2.0);
448 t10 = 1/pow(rhoa,2.666666666666667);
449 t11 = 0.03925*t7*t8*t9*t10+1.0;
450 t12 = 1/pow(t11,2.0);
451 t13 = 1/pow(rhoa,5.333333333333333);
452 t14 = 1/t11;
453 t15 = -1.5624999999999998E-4*t4*t5*t6*t12*t13+0.0548775*
454 t7*t8*t9*t14*t10+1.0;
455 t16 = pow(rhoa,0.333333333333333);
456 t17 = 1/pow(3.141592653589793,4.0);
457 t18 = pow(grada,6.0);
458 t19 = 1/pow(t11,3.0);
459 t20 = 1/pow(rhoa,9.0);
460 t21 = 1/pow(rhoa,6.333333333333333);
461 t22 = 1/pow(rhoa,3.666666666666667);
462 t23 = -0.14634*t7*t8*t9*t14*t22+0.001790640833333*t4*
463 t5*t6*t12*t21-5.451388888888888E-6*t17*t18*t19*t20;
464 t24 = pow(rhoa,1.333333333333333);
465 t25 = pow(grada,5.0);
466 t26 = 1/pow(rhoa,8.0);
467 t27 = pow(grada,3.0);
468 t28 = 0.109755*t7*t8*grada*t14*t10-0.001342980625*t4*
469 t5*t27*t12*t13+4.088541666666666E-6*t17*t25*t19*t26;
470 t29 = 1/pow(rhoa,0.666666666666667);
471 t30 = 1/pow(3.141592653589793,5.333333333333333);
472 t31 = pow(grada,8.0);
473 t32 = 1/pow(t11,4.0);
474 t33 = 1/pow(rhoa,12.66666666666667);
475 t34 = 1/pow(rhoa,10.0);
476 t35 = 1/pow(rhoa,7.333333333333333);
477 t36 = 1/pow(rhoa,4.666666666666667);
478 t37 = 0.53658*t7*t8*t9*t14*t36-0.013893545277778*t4*t5*
479 t6*t12*t35+1.1153596907407406E-4*t17*t18*t19*t34-1.7117361111111105E-6*
480 t7*t30*t31*t32*t33;
481 t38 = pow(grada,7.0);
482 t39 = 1/pow(rhoa,11.66666666666667);
483 t40 = -0.29268*t7*t8*grada*t14*t22+0.009077178333333*
484 t4*t5*t27*t12*t21-7.956343513888887E-5*t17*t25*t19*t20+1.283802083333333E-6*
485 t7*t30*t38*t32*t39;
486 t41 = 1/pow(rhoa,10.66666666666667);
487 t42 = 0.109755*t7*t8*t14*t10-0.005464903125*t4*t5*t9*
488 t12*t13+5.558403468749999E-5*t17*t6*t19*t26-9.628515624999997E-7*
489 t7*t30*t18*t32*t41;
490 t43 = 1/pow(rhoa,1.666666666666667);
491 t44 = 1/pow(3.141592653589793,6.666666666666667);
492 t45 = pow(grada,10.0);
493 t46 = 1/pow(t11,5.0);
494 t47 = 1/pow(rhoa,16.33333333333333);
495 t48 = 1/pow(rhoa,13.66666666666667);
496 t49 = 1/pow(rhoa,11.0);
497 t50 = 1/pow(rhoa,8.333333333333334);
498 t51 = 1/pow(rhoa,5.666666666666667);
499 t52 = -2.50404*t7*t8*t9*t14*t51+0.111246338703704*t4*
500 t5*t6*t12*t50-0.00160009004821*t17*t18*t19*t49+5.670428502999997E-5*
501 t7*t30*t31*t32*t48-1.194411419753086E-7*t4*t44*t45*t46*t47;
502 t53 = pow(grada,
503 9.0);
504 t54 = 1/pow(rhoa,15.33333333333333);
505 t55 = 1.07316*t7*t8*grada*t14*t36-0.062594436111111*t4*
506 t5*t27*t12*t35+0.001032763582546*t17*t25*t19*t34-3.996060960583333E-5*
507 t7*t30*t38*t32*t33+8.958085648148145E-8*t4*t44*t53*t46*t54;
508 t56 = 1/
509 pow(rhoa,14.33333333333333);
510 t57 = -0.29268*t7*t8*t14*t22+0.031060765*t4*t5*t9*t12*
511 t21-6.353366754166664E-4*t17*t6*t19*t20+2.772380355854166E-5*
512 t7*t30*t18*t32*t39-6.718564236111108E-8*t4*t44*t31*t46*t56;
513 t58 = 1/
514 pow(rhoa,13.33333333333333);
515 t59 = -0.0123657675*t4*t5*grada*t12*t13+3.653344371874999E-4*
516 t17*t27*t19*t26-1.8867149543906244E-5*t7*t30*t25*t32*t41+5.038923177083331E-8*
517 t4*t44*t38*t46*t58;
518 t60 = 1/pow(3.141592653589793,8.0);
519 t61 = 1/pow(t11,6.0);
520
521 /* code */
522 res[0] = 0.5*(-1.5*t1*t2*t23*t24*t3-2.0*t1*t15*t16*t2*
523 t3);
524 res[1] = -0.75*t1*t2*t3*t28*t24;
525 res[2] = 0.5*(-1.5*t1*t2*t24*t3*t37-0.666666666666667*
526 t1*t15*t2*t29*t3-4.0*t1*t16*t2*t23*t3);
527 res[3] = 0.5*(-1.5*t1*t2*t24*t3*t40-2.0*t1*t16*t2*t28*
528 t3);
529 res[4] = -0.75*t1*t2*t3*t42*t24;
530 res[5] = 0.5*(-1.5*t1*t2*t24*t3*t52+0.444444444444444*
531 t1*t15*t2*t3*t43-6.0*t1*t16*t2*t3*t37-2.0*t1*t2*t23*t29*t3);
532 res[6] = 0.5*(-1.5*t1*t2*t24*t3*t55-4.0*t1*t16*t2*t3*
533 t40-0.666666666666667*t1*t2*t28*t29*t3);
534 res[7] = 0.5*(-1.5*t1*t2*t24*t3*t57-2.0*t1*t16*t2*t3*
535 t42);
536 res[8] = -0.75*t1*t2*t3*t59*t24;
537 res[9] = 0.5*(-1.5*t1*t2*t24*t3*(-1.041792182784636E-8*
538 t60*t61*pow(grada,12.0)/pow(rhoa,20.0)+5.907570985467816E-6*
539 t4*t44*t45*t46/pow(rhoa,17.33333333333333)-0.001277386837215*
540 t30*t31*t32*t7/pow(rhoa,14.66666666666667)+0.021482251680638*
541 t17*t18*t19/pow(rhoa,12.0)-0.970734409197531*t12*t4*t5*t6/
542 pow(rhoa,9.333333333333334)+14.18956*t14*t7*t8*t9/pow(rhoa,
543 6.666666666666667))-8.0*t1*t16*t2*t3*t52+1.777777777777778*
544 t1*t2*t23*t3*t43-4.0*t1*t2*t29*t3*t37-0.740740740740741*t1*
545 t10*t15*t2*t3);
546 res[10] = 0.5*(-1.5*t1*t2*t24*t3*(7.81344137088477E-9*
547 t60*t61*pow(grada,11.0)/pow(rhoa,19.0)-5.00808*t7*t8*grada*
548 t14*t51+0.477746544814815*t4*t5*t27*t12*t50-0.012511486152006*
549 t17*t25*t19*t49+8.304554865934256E-4*t7*t30*t38*t32*t48-4.161935669656417E-6*
550 t4*t44*t53*t46*t47)-6.0*t1*t16*t2*t3*t55+0.444444444444444*
551 t1*t2*t28*t3*t43-2.0*t1*t2*t29*t3*t40);
552 res[11] = 0.5*(-1.5*t1*t2*t24*t3*(-5.860081028163578E-9*
553 t45*t60*t61/pow(rhoa,18.0)+2.89749961103861E-6*t4*t44*t31*
554 t46*t54+1.07316*t7*t8*t14*t36-0.201823818333333*t4*t5*t9*t12*
555 t35+0.006801705657639*t17*t6*t19*t34-5.22940090930486E-4*t7*
556 t30*t18*t32*t33)-4.0*t1*t16*t2*t3*t57-0.666666666666667*t1*
557 t2*t29*t3*t42);
558 res[12] = 0.5*(-1.5*t1*t2*t24*t3*(4.395060771122683E-9*
559 t53*t60*t61/pow(rhoa,17.0)-1.988364191785902E-6*t4*t44*t38*
560 t46*t56+3.159646084118749E-4*t7*t30*t25*t32*t39+0.06595076*
561 t4*t5*grada*t12*t21-0.003354103385833*t17*t27*t19*t20)-2.0*
562 t1*t16*t2*t3*t59);
563 res[13] = -0.75*t1*t2*t24*t3*(-3.296295578342012E-9*t31*
564 t60*t61/pow(rhoa,16.0)+1.3401054485269264E-6*t4*t44*t18*t46*
565 t58-1.8037200767718743E-4*t7*t30*t6*t32*t41+0.001419574227812*
566 t17*t9*t19*t26-0.0123657675*t4*t5*t12*t13);
567
568 }
569
570 static void
mpbex_fourth(FunFourthFuncDrv * ds,real factor,const FunDensProp * dp)571 mpbex_fourth(FunFourthFuncDrv *ds, real factor, const FunDensProp* dp)
572 {
573 real res[14];
574
575 mpbex_fourth_helper(dp->rhoa, dp->grada, res);
576
577 ds->df1000 += factor*res[0];
578 ds->df0010 += factor*res[1];
579
580 ds->df2000 += factor*res[2];
581 ds->df1010 += factor*res[3];
582 ds->df0020 += factor*res[4];
583
584 ds->df3000 += factor*res[5];
585 ds->df2010 += factor*res[6];
586 ds->df1020 += factor*res[7];
587 ds->df0030 += factor*res[8];
588
589 ds->df4000 += factor*res[9];
590 ds->df3010 += factor*res[10];
591 ds->df2020 += factor*res[11];
592 ds->df1030 += factor*res[12];
593 ds->df0040 += factor*res[13];
594
595
596 if(fabs(dp->rhoa-dp->rhob)>1e-13 ||
597 fabs(dp->grada-dp->gradb)>1e-13)
598 mpbex_fourth_helper(dp->rhob, dp->gradb, res);
599
600 ds->df0100 += factor*res[0];
601 ds->df0001 += factor*res[1];
602
603 ds->df0200 += factor*res[2];
604 ds->df0101 += factor*res[3];
605 ds->df0002 += factor*res[4];
606
607 ds->df0300 += factor*res[5];
608 ds->df0201 += factor*res[6];
609 ds->df0102 += factor*res[7];
610 ds->df0003 += factor*res[8];
611
612 ds->df0400 += factor*res[9];
613 ds->df0301 += factor*res[10];
614 ds->df0202 += factor*res[11];
615 ds->df0103 += factor*res[12];
616 ds->df0004 += factor*res[13];
617
618 }
619