2 inline void mohrCoulomb(
const double&
phi,
const double&
psi,
const double&
c,
const double* stress,
3 double&
f,
double*
df,
double& g,
double*
r,
double* dr)
5 const int nSymTen=6,sXX=0,sYY=1,sZZ=2,sYZ=3,sZY=3,sXZ=4,sZX=4,sXY=5,sYX=5;
6 const int SKEY=0,TARGKEY=1,J3KEY=2;
8 targ,dtarg[nSymTen],ddtarg[nSymTen*nSymTen],
9 J3,dJ3[nSymTen],ddJ3[nSymTen*nSymTen],
11 dg_dtmp[3],ddg_dtmp[3*3],theta;
12 const double& stress_xx(stress[sXX]),
13 stress_yy(stress[sYY]),
14 stress_zz(stress[sZZ]),
15 stress_yz(stress[sYZ]),
16 stress_zx(stress[sZX]),
17 stress_xy(stress[sXY]);
19 s = sqrt(3)*(stress_xx + stress_yy + stress_zz)/3;
33 targ = pow(stress_xx - stress_yy, 2) + pow(stress_yy - stress_zz, 2) + pow(stress_zz - stress_xx, 2) + 6*pow(stress_xy, 2) + 6*pow(stress_yz, 2) + 6*pow(stress_zx, 2);
35 dtarg[sXX] = -2*stress_yy - 2*stress_zz + 4*stress_xx;
37 dtarg[sYY] = -2*stress_xx - 2*stress_zz + 4*stress_yy;
39 dtarg[sZZ] = -2*stress_xx - 2*stress_yy + 4*stress_zz;
41 dtarg[sYZ] = 12*stress_yz;
43 dtarg[sZX] = 12*stress_zx;
45 dtarg[sXY] = 12*stress_xy;
47 ddtarg[sXX+ nSymTen*sXX] = 4;
49 ddtarg[sXX+ nSymTen*sYY] = -2;
51 ddtarg[sXX+ nSymTen*sZZ] = -2;
53 ddtarg[sXX+ nSymTen*sYZ] = 0;
55 ddtarg[sXX+ nSymTen*sZX] = 0;
57 ddtarg[sXX+ nSymTen*sXY] = 0;
59 ddtarg[sYY+ nSymTen*sXX] = -2;
61 ddtarg[sYY+ nSymTen*sYY] = 4;
63 ddtarg[sYY+ nSymTen*sZZ] = -2;
65 ddtarg[sYY+ nSymTen*sYZ] = 0;
67 ddtarg[sYY+ nSymTen*sZX] = 0;
69 ddtarg[sYY+ nSymTen*sXY] = 0;
71 ddtarg[sZZ+ nSymTen*sXX] = -2;
73 ddtarg[sZZ+ nSymTen*sYY] = -2;
75 ddtarg[sZZ+ nSymTen*sZZ] = 4;
77 ddtarg[sZZ+ nSymTen*sYZ] = 0;
79 ddtarg[sZZ+ nSymTen*sZX] = 0;
81 ddtarg[sZZ+ nSymTen*sXY] = 0;
83 ddtarg[sYZ+ nSymTen*sXX] = 0;
85 ddtarg[sYZ+ nSymTen*sYY] = 0;
87 ddtarg[sYZ+ nSymTen*sZZ] = 0;
89 ddtarg[sYZ+ nSymTen*sYZ] = 12;
91 ddtarg[sYZ+ nSymTen*sZX] = 0;
93 ddtarg[sYZ+ nSymTen*sXY] = 0;
95 ddtarg[sZX+ nSymTen*sXX] = 0;
97 ddtarg[sZX+ nSymTen*sYY] = 0;
99 ddtarg[sZX+ nSymTen*sZZ] = 0;
101 ddtarg[sZX+ nSymTen*sYZ] = 0;
103 ddtarg[sZX+ nSymTen*sZX] = 12;
105 ddtarg[sZX+ nSymTen*sXY] = 0;
107 ddtarg[sXY+ nSymTen*sXX] = 0;
109 ddtarg[sXY+ nSymTen*sYY] = 0;
111 ddtarg[sXY+ nSymTen*sZZ] = 0;
113 ddtarg[sXY+ nSymTen*sYZ] = 0;
115 ddtarg[sXY+ nSymTen*sZX] = 0;
117 ddtarg[sXY+ nSymTen*sXY] = 12;
124 J3 = -pow(stress_xy, 2)*(-stress_xx/3 - stress_yy/3 + 2*stress_zz/3) - pow(stress_yz, 2)*(-stress_yy/3 - stress_zz/3 + 2*stress_xx/3) - pow(stress_zx, 2)*(-stress_xx/3 - stress_zz/3 + 2*stress_yy/3) + (-stress_xx/3 - stress_zz/3 + 2*stress_yy/3)*(-stress_yy/3 - stress_zz/3 + 2*stress_xx/3)*(-stress_xx/3 - stress_yy/3 + 2*stress_zz/3) + 2*stress_xy*stress_yz*stress_zx;
126 dJ3[sXX] = -(-stress_xx/3 - stress_zz/3 + 2*stress_yy/3)*(-stress_yy/3 - stress_zz/3 + 2*stress_xx/3)/3 - (-stress_yy/3 - stress_zz/3 + 2*stress_xx/3)*(-stress_xx/3 - stress_yy/3 + 2*stress_zz/3)/3 + 2*(-stress_xx/3 - stress_zz/3 + 2*stress_yy/3)*(-stress_xx/3 - stress_yy/3 + 2*stress_zz/3)/3 - 2*pow(stress_yz, 2)/3 + pow(stress_xy, 2)/3 + pow(stress_zx, 2)/3;
128 dJ3[sYY] = -(-stress_xx/3 - stress_zz/3 + 2*stress_yy/3)*(-stress_yy/3 - stress_zz/3 + 2*stress_xx/3)/3 - (-stress_xx/3 - stress_zz/3 + 2*stress_yy/3)*(-stress_xx/3 - stress_yy/3 + 2*stress_zz/3)/3 + 2*(-stress_yy/3 - stress_zz/3 + 2*stress_xx/3)*(-stress_xx/3 - stress_yy/3 + 2*stress_zz/3)/3 - 2*pow(stress_zx, 2)/3 + pow(stress_xy, 2)/3 + pow(stress_yz, 2)/3;
130 dJ3[sZZ] = -(-stress_xx/3 - stress_zz/3 + 2*stress_yy/3)*(-stress_xx/3 - stress_yy/3 + 2*stress_zz/3)/3 - (-stress_yy/3 - stress_zz/3 + 2*stress_xx/3)*(-stress_xx/3 - stress_yy/3 + 2*stress_zz/3)/3 + 2*(-stress_xx/3 - stress_zz/3 + 2*stress_yy/3)*(-stress_yy/3 - stress_zz/3 + 2*stress_xx/3)/3 - 2*pow(stress_xy, 2)/3 + pow(stress_yz, 2)/3 + pow(stress_zx, 2)/3;
132 dJ3[sYZ] = -2*stress_yz*(-stress_yy/3 - stress_zz/3 + 2*stress_xx/3) + 2*stress_xy*stress_zx;
134 dJ3[sZX] = -2*stress_zx*(-stress_xx/3 - stress_zz/3 + 2*stress_yy/3) + 2*stress_xy*stress_yz;
136 dJ3[sXY] = -2*stress_xy*(-stress_xx/3 - stress_yy/3 + 2*stress_zz/3) + 2*stress_yz*stress_zx;
138 ddJ3[sXX+ nSymTen*sXX] = -2*stress_yy/9 - 2*stress_zz/9 + 4*stress_xx/9;
140 ddJ3[sXX+ nSymTen*sYY] = -2*stress_xx/9 - 2*stress_yy/9 + 4*stress_zz/9;
142 ddJ3[sXX+ nSymTen*sZZ] = -2*stress_xx/9 - 2*stress_zz/9 + 4*stress_yy/9;
144 ddJ3[sXX+ nSymTen*sYZ] = -4*stress_yz/3;
146 ddJ3[sXX+ nSymTen*sZX] = 2*stress_zx/3;
148 ddJ3[sXX+ nSymTen*sXY] = 2*stress_xy/3;
150 ddJ3[sYY+ nSymTen*sXX] = -2*stress_xx/9 - 2*stress_yy/9 + 4*stress_zz/9;
152 ddJ3[sYY+ nSymTen*sYY] = -2*stress_xx/9 - 2*stress_zz/9 + 4*stress_yy/9;
154 ddJ3[sYY+ nSymTen*sZZ] = -2*stress_yy/9 - 2*stress_zz/9 + 4*stress_xx/9;
156 ddJ3[sYY+ nSymTen*sYZ] = 2*stress_yz/3;
158 ddJ3[sYY+ nSymTen*sZX] = -4*stress_zx/3;
160 ddJ3[sYY+ nSymTen*sXY] = 2*stress_xy/3;
162 ddJ3[sZZ+ nSymTen*sXX] = -2*stress_xx/9 - 2*stress_zz/9 + 4*stress_yy/9;
164 ddJ3[sZZ+ nSymTen*sYY] = -2*stress_yy/9 - 2*stress_zz/9 + 4*stress_xx/9;
166 ddJ3[sZZ+ nSymTen*sZZ] = -2*stress_xx/9 - 2*stress_yy/9 + 4*stress_zz/9;
168 ddJ3[sZZ+ nSymTen*sYZ] = 2*stress_yz/3;
170 ddJ3[sZZ+ nSymTen*sZX] = 2*stress_zx/3;
172 ddJ3[sZZ+ nSymTen*sXY] = -4*stress_xy/3;
174 ddJ3[sYZ+ nSymTen*sXX] = -4*stress_yz/3;
176 ddJ3[sYZ+ nSymTen*sYY] = 2*stress_yz/3;
178 ddJ3[sYZ+ nSymTen*sZZ] = 2*stress_yz/3;
180 ddJ3[sYZ+ nSymTen*sYZ] = -4*stress_xx/3 + 2*stress_yy/3 + 2*stress_zz/3;
182 ddJ3[sYZ+ nSymTen*sZX] = 2*stress_xy;
184 ddJ3[sYZ+ nSymTen*sXY] = 2*stress_zx;
186 ddJ3[sZX+ nSymTen*sXX] = 2*stress_zx/3;
188 ddJ3[sZX+ nSymTen*sYY] = -4*stress_zx/3;
190 ddJ3[sZX+ nSymTen*sZZ] = 2*stress_zx/3;
192 ddJ3[sZX+ nSymTen*sYZ] = 2*stress_xy;
194 ddJ3[sZX+ nSymTen*sZX] = -4*stress_yy/3 + 2*stress_xx/3 + 2*stress_zz/3;
196 ddJ3[sZX+ nSymTen*sXY] = 2*stress_yz;
198 ddJ3[sXY+ nSymTen*sXX] = 2*stress_xy/3;
200 ddJ3[sXY+ nSymTen*sYY] = 2*stress_xy/3;
202 ddJ3[sXY+ nSymTen*sZZ] = -4*stress_xy/3;
204 ddJ3[sXY+ nSymTen*sYZ] = 2*stress_zx;
206 ddJ3[sXY+ nSymTen*sZX] = 2*stress_yz;
208 ddJ3[sXY+ nSymTen*sXY] = -4*stress_zz/3 + 2*stress_xx/3 + 2*stress_yy/3;
210 double tmpval = 27*J3*sqrt(2)/pow(targ, 3.0/2.0);
217 theta = -asin(tmpval)/3;
219 f = -
c*cos(
phi) + sqrt(2)*sqrt(targ)*(sqrt(3)*cos(asin(27*J3*sqrt(2)/pow(targ, 3.0/2.0))/3)/3 + sin(
phi)*sin(asin(27*J3*sqrt(2)/pow(targ, 3.0/2.0))/3)/3)/2 +
s*sqrt(3)*sin(
phi)/3;
221 df_dtmp[SKEY] = sqrt(3)*sin(
phi)/3;
223 df_dtmp[TARGKEY] = sqrt(2)*sqrt(targ)*(9*J3*sqrt(6)*sin(asin(27*J3*sqrt(2)/pow(targ, 3.0/2.0))/3)/(2*pow(targ, 5.0/2.0)*sqrt(1 - 1458*pow(J3, 2)/pow(targ, 3))) - 9*J3*sqrt(2)*cos(asin(27*J3*sqrt(2)/pow(targ, 3.0/2.0))/3)*sin(
phi)/(2*pow(targ, 5.0/2.0)*sqrt(1 - 1458*pow(J3, 2)/pow(targ, 3))))/2 + sqrt(2)*(sqrt(3)*cos(asin(27*J3*sqrt(2)/pow(targ, 3.0/2.0))/3)/3 + sin(
phi)*sin(asin(27*J3*sqrt(2)/pow(targ, 3.0/2.0))/3)/3)/(4*sqrt(targ));
225 df_dtmp[J3KEY] = sqrt(2)*sqrt(targ)*(-3*sqrt(6)*sin(asin(27*J3*sqrt(2)/pow(targ, 3.0/2.0))/3)/(pow(targ, 3.0/2.0)*sqrt(1 - 1458*pow(J3, 2)/pow(targ, 3))) + 3*sqrt(2)*cos(asin(27*J3*sqrt(2)/pow(targ, 3.0/2.0))/3)*sin(
phi)/(pow(targ, 3.0/2.0)*sqrt(1 - 1458*pow(J3, 2)/pow(targ, 3))))/2;
227 df[sXX] = df_dtmp[SKEY]*ds[sXX] + df_dtmp[TARGKEY]*dtarg[sXX] + df_dtmp[J3KEY]*dJ3[sXX];
229 df[sYY] = df_dtmp[SKEY]*ds[sYY] + df_dtmp[TARGKEY]*dtarg[sYY] + df_dtmp[J3KEY]*dJ3[sYY];
231 df[sZZ] = df_dtmp[SKEY]*ds[sZZ] + df_dtmp[TARGKEY]*dtarg[sZZ] + df_dtmp[J3KEY]*dJ3[sZZ];
233 df[sYZ] = df_dtmp[SKEY]*ds[sYZ] + df_dtmp[TARGKEY]*dtarg[sYZ] + df_dtmp[J3KEY]*dJ3[sYZ];
235 df[sZX] = df_dtmp[SKEY]*ds[sZX] + df_dtmp[TARGKEY]*dtarg[sZX] + df_dtmp[J3KEY]*dJ3[sZX];
237 df[sXY] = df_dtmp[SKEY]*ds[sXY] + df_dtmp[TARGKEY]*dtarg[sXY] + df_dtmp[J3KEY]*dJ3[sXY];
239 g = -
c*cos(
psi) + sqrt(2)*sqrt(targ)*(sqrt(3)*cos(asin(27*J3*sqrt(2)/pow(targ, 3.0/2.0))/3)/3 + sin(
psi)*sin(asin(27*J3*sqrt(2)/pow(targ, 3.0/2.0))/3)/3)/2 +
s*sqrt(3)*sin(
psi)/3;
241 dg_dtmp[SKEY] = sqrt(3)*sin(
psi)/3;
243 dg_dtmp[TARGKEY] = sqrt(2)*sqrt(targ)*(9*J3*sqrt(6)*sin(asin(27*J3*sqrt(2)/pow(targ, 3.0/2.0))/3)/(2*pow(targ, 5.0/2.0)*sqrt(1 - 1458*pow(J3, 2)/pow(targ, 3))) - 9*J3*sqrt(2)*cos(asin(27*J3*sqrt(2)/pow(targ, 3.0/2.0))/3)*sin(
psi)/(2*pow(targ, 5.0/2.0)*sqrt(1 - 1458*pow(J3, 2)/pow(targ, 3))))/2 + sqrt(2)*(sqrt(3)*cos(asin(27*J3*sqrt(2)/pow(targ, 3.0/2.0))/3)/3 + sin(
psi)*sin(asin(27*J3*sqrt(2)/pow(targ, 3.0/2.0))/3)/3)/(4*sqrt(targ));
245 dg_dtmp[J3KEY] = sqrt(2)*sqrt(targ)*(-3*sqrt(6)*sin(asin(27*J3*sqrt(2)/pow(targ, 3.0/2.0))/3)/(pow(targ, 3.0/2.0)*sqrt(1 - 1458*pow(J3, 2)/pow(targ, 3))) + 3*sqrt(2)*cos(asin(27*J3*sqrt(2)/pow(targ, 3.0/2.0))/3)*sin(
psi)/(pow(targ, 3.0/2.0)*sqrt(1 - 1458*pow(J3, 2)/pow(targ, 3))))/2;
247 r[sXX] = dg_dtmp[SKEY]*ds[sXX] + dg_dtmp[TARGKEY]*dtarg[sXX] + dg_dtmp[J3KEY]*dJ3[sXX];
249 r[sYY] = dg_dtmp[SKEY]*ds[sYY] + dg_dtmp[TARGKEY]*dtarg[sYY] + dg_dtmp[J3KEY]*dJ3[sYY];
251 r[sZZ] = dg_dtmp[SKEY]*ds[sZZ] + dg_dtmp[TARGKEY]*dtarg[sZZ] + dg_dtmp[J3KEY]*dJ3[sZZ];
253 r[sYZ] = dg_dtmp[SKEY]*ds[sYZ] + dg_dtmp[TARGKEY]*dtarg[sYZ] + dg_dtmp[J3KEY]*dJ3[sYZ];
255 r[sZX] = dg_dtmp[SKEY]*ds[sZX] + dg_dtmp[TARGKEY]*dtarg[sZX] + dg_dtmp[J3KEY]*dJ3[sZX];
257 r[sXY] = dg_dtmp[SKEY]*ds[sXY] + dg_dtmp[TARGKEY]*dtarg[sXY] + dg_dtmp[J3KEY]*dJ3[sXY];
259 ddg_dtmp[SKEY+3*SKEY] = 0;
261 ddg_dtmp[SKEY+3*TARGKEY] = 0;
263 ddg_dtmp[SKEY+3*J3KEY] = 0;
265 ddg_dtmp[TARGKEY+3*SKEY] = 0;
267 ddg_dtmp[TARGKEY+3*TARGKEY] = sqrt(2)*sqrt(targ)*(-19683*sqrt(6)*pow(J3, 3)*sin(asin(27*J3*sqrt(2)/pow(targ, 3.0/2.0))/3)/(2*pow(targ, 13.0/2.0)*pow(1 - 1458*pow(J3, 2)/pow(targ, 3), 3.0/2.0)) - 243*sqrt(3)*pow(J3, 2)*cos(asin(27*J3*sqrt(2)/pow(targ, 3.0/2.0))/3)/(2*pow(targ, 5)*(1 - 1458*pow(J3, 2)/pow(targ, 3))) - 243*pow(J3, 2)*sin(
psi)*sin(asin(27*J3*sqrt(2)/pow(targ, 3.0/2.0))/3)/(2*pow(targ, 5)*(1 - 1458*pow(J3, 2)/pow(targ, 3))) - 45*J3*sqrt(6)*sin(asin(27*J3*sqrt(2)/pow(targ, 3.0/2.0))/3)/(4*pow(targ, 7.0/2.0)*sqrt(1 - 1458*pow(J3, 2)/pow(targ, 3))) + 45*J3*sqrt(2)*cos(asin(27*J3*sqrt(2)/pow(targ, 3.0/2.0))/3)*sin(
psi)/(4*pow(targ, 7.0/2.0)*sqrt(1 - 1458*pow(J3, 2)/pow(targ, 3))) + 19683*sqrt(2)*pow(J3, 3)*cos(asin(27*J3*sqrt(2)/pow(targ, 3.0/2.0))/3)*sin(
psi)/(2*pow(targ, 13.0/2.0)*pow(1 - 1458*pow(J3, 2)/pow(targ, 3), 3.0/2.0)))/2 + sqrt(2)*(9*J3*sqrt(6)*sin(asin(27*J3*sqrt(2)/pow(targ, 3.0/2.0))/3)/(2*pow(targ, 5.0/2.0)*sqrt(1 - 1458*pow(J3, 2)/pow(targ, 3))) - 9*J3*sqrt(2)*cos(asin(27*J3*sqrt(2)/pow(targ, 3.0/2.0))/3)*sin(
psi)/(2*pow(targ, 5.0/2.0)*sqrt(1 - 1458*pow(J3, 2)/pow(targ, 3))))/(2*sqrt(targ)) - sqrt(2)*(sqrt(3)*cos(asin(27*J3*sqrt(2)/pow(targ, 3.0/2.0))/3)/3 + sin(
psi)*sin(asin(27*J3*sqrt(2)/pow(targ, 3.0/2.0))/3)/3)/(8*pow(targ, 3.0/2.0));
269 ddg_dtmp[TARGKEY+3*J3KEY] = sqrt(2)*sqrt(targ)*(9*sqrt(6)*sin(asin(27*J3*sqrt(2)/pow(targ, 3.0/2.0))/3)/(2*pow(targ, 5.0/2.0)*sqrt(1 - 1458*pow(J3, 2)/pow(targ, 3))) + 81*J3*sqrt(3)*cos(asin(27*J3*sqrt(2)/pow(targ, 3.0/2.0))/3)/(pow(targ, 4)*(1 - 1458*pow(J3, 2)/pow(targ, 3))) + 81*J3*sin(
psi)*sin(asin(27*J3*sqrt(2)/pow(targ, 3.0/2.0))/3)/(pow(targ, 4)*(1 - 1458*pow(J3, 2)/pow(targ, 3))) + 6561*sqrt(6)*pow(J3, 2)*sin(asin(27*J3*sqrt(2)/pow(targ, 3.0/2.0))/3)/(pow(targ, 11.0/2.0)*pow(1 - 1458*pow(J3, 2)/pow(targ, 3), 3.0/2.0)) - 9*sqrt(2)*cos(asin(27*J3*sqrt(2)/pow(targ, 3.0/2.0))/3)*sin(
psi)/(2*pow(targ, 5.0/2.0)*sqrt(1 - 1458*pow(J3, 2)/pow(targ, 3))) - 6561*sqrt(2)*pow(J3, 2)*cos(asin(27*J3*sqrt(2)/pow(targ, 3.0/2.0))/3)*sin(
psi)/(pow(targ, 11.0/2.0)*pow(1 - 1458*pow(J3, 2)/pow(targ, 3), 3.0/2.0)))/2 + sqrt(2)*(-3*sqrt(6)*sin(asin(27*J3*sqrt(2)/pow(targ, 3.0/2.0))/3)/(pow(targ, 3.0/2.0)*sqrt(1 - 1458*pow(J3, 2)/pow(targ, 3))) + 3*sqrt(2)*cos(asin(27*J3*sqrt(2)/pow(targ, 3.0/2.0))/3)*sin(
psi)/(pow(targ, 3.0/2.0)*sqrt(1 - 1458*pow(J3, 2)/pow(targ, 3))))/(4*sqrt(targ));
271 ddg_dtmp[J3KEY+3*SKEY] = 0;
273 ddg_dtmp[J3KEY+3*TARGKEY] = sqrt(2)*sqrt(targ)*(9*sqrt(6)*sin(asin(27*J3*sqrt(2)/pow(targ, 3.0/2.0))/3)/(2*pow(targ, 5.0/2.0)*sqrt(1 - 1458*pow(J3, 2)/pow(targ, 3))) + 81*J3*sqrt(3)*cos(asin(27*J3*sqrt(2)/pow(targ, 3.0/2.0))/3)/(pow(targ, 4)*(1 - 1458*pow(J3, 2)/pow(targ, 3))) + 81*J3*sin(
psi)*sin(asin(27*J3*sqrt(2)/pow(targ, 3.0/2.0))/3)/(pow(targ, 4)*(1 - 1458*pow(J3, 2)/pow(targ, 3))) + 6561*sqrt(6)*pow(J3, 2)*sin(asin(27*J3*sqrt(2)/pow(targ, 3.0/2.0))/3)/(pow(targ, 11.0/2.0)*pow(1 - 1458*pow(J3, 2)/pow(targ, 3), 3.0/2.0)) - 9*sqrt(2)*cos(asin(27*J3*sqrt(2)/pow(targ, 3.0/2.0))/3)*sin(
psi)/(2*pow(targ, 5.0/2.0)*sqrt(1 - 1458*pow(J3, 2)/pow(targ, 3))) - 6561*sqrt(2)*pow(J3, 2)*cos(asin(27*J3*sqrt(2)/pow(targ, 3.0/2.0))/3)*sin(
psi)/(pow(targ, 11.0/2.0)*pow(1 - 1458*pow(J3, 2)/pow(targ, 3), 3.0/2.0)))/2 + sqrt(2)*(-3*sqrt(6)*sin(asin(27*J3*sqrt(2)/pow(targ, 3.0/2.0))/3)/(pow(targ, 3.0/2.0)*sqrt(1 - 1458*pow(J3, 2)/pow(targ, 3))) + 3*sqrt(2)*cos(asin(27*J3*sqrt(2)/pow(targ, 3.0/2.0))/3)*sin(
psi)/(pow(targ, 3.0/2.0)*sqrt(1 - 1458*pow(J3, 2)/pow(targ, 3))))/(4*sqrt(targ));
275 ddg_dtmp[J3KEY+3*J3KEY] = sqrt(2)*sqrt(targ)*(-54*sqrt(3)*cos(asin(27*J3*sqrt(2)/pow(targ, 3.0/2.0))/3)/(pow(targ, 3)*(1 - 1458*pow(J3, 2)/pow(targ, 3))) - 54*sin(
psi)*sin(asin(27*J3*sqrt(2)/pow(targ, 3.0/2.0))/3)/(pow(targ, 3)*(1 - 1458*pow(J3, 2)/pow(targ, 3))) - 4374*J3*sqrt(6)*sin(asin(27*J3*sqrt(2)/pow(targ, 3.0/2.0))/3)/(pow(targ, 9.0/2.0)*pow(1 - 1458*pow(J3, 2)/pow(targ, 3), 3.0/2.0)) + 4374*J3*sqrt(2)*cos(asin(27*J3*sqrt(2)/pow(targ, 3.0/2.0))/3)*sin(
psi)/(pow(targ, 9.0/2.0)*pow(1 - 1458*pow(J3, 2)/pow(targ, 3), 3.0/2.0)))/2;
277 dr[sXX+ nSymTen*sXX] = dg_dtmp[TARGKEY]*ddtarg[sXX+nSymTen*sXX] + dg_dtmp[J3KEY]*ddJ3[sXX+nSymTen*sXX]\
278 + ddg_dtmp[SKEY + 3*SKEY]*ds[sXX]*ds[sXX] + ddg_dtmp[SKEY + 3*TARGKEY]*dtarg[sXX]*ds[sXX] + ddg_dtmp[SKEY + 3*J3KEY]*dJ3[sXX]*ds[sXX]\
279 + ddg_dtmp[TARGKEY + 3*SKEY]*ds[sXX]*dtarg[sXX] + ddg_dtmp[TARGKEY + 3*TARGKEY]*dtarg[sXX]*dtarg[sXX] + ddg_dtmp[TARGKEY + 3*J3KEY]*dJ3[sXX]*dtarg[sXX]\
280 + ddg_dtmp[J3KEY + 3*SKEY]*ds[sXX]*dJ3[sXX] + ddg_dtmp[J3KEY + 3*TARGKEY]*dtarg[sXX]*dJ3[sXX] + ddg_dtmp[J3KEY + 3*J3KEY]*dJ3[sXX]*dJ3[sXX];
282 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ARGKEY]*ddtarg[sXX+nSymTen*sXY] + dg_dtmp[J3KEY]*ddJ3[sXX+nSymTen*sXY]\
303 + ddg_dtmp[SKEY + 3*SKEY]*ds[sXY]*ds[sXX] + ddg_dtmp[SKEY + 3*TARGKEY]*dtarg[sXY]*ds[sXX] + ddg_dtmp[SKEY + 3*J3KEY]*dJ3[sXY]*ds[sXX]\
304 + ddg_dtmp[TARGKEY + 3*SKEY]*ds[sXY]*dtarg[sXX] + ddg_dtmp[TARGKEY + 3*TARGKEY]*dtarg[sXY]*dtarg[sXX] + ddg_dtmp[TARGKEY + 3*J3KEY]*dJ3[sXY]*dtarg[sXX]\
305 + ddg_dtmp[J3KEY + 3*SKEY]*ds[sXY]*dJ3[sXX] + ddg_dtmp[J3KEY + 3*TARGKEY]*dtarg[sXY]*dJ3[sXX] + ddg_dtmp[J3KEY + 3*J3KEY]*dJ3[sXY]*dJ3[sXX];
307 dr[sYY+ nSymTen*sXX] = dg_dtmp[TARGKEY]*ddtarg[sYY+nSymTen*sXX] + dg_dtmp[J3KEY]*ddJ3[sYY+nSymTen*sXX]\
308 + ddg_dtmp[SKEY + 3*SKEY]*ds[sXX]*ds[sYY] + ddg_dtmp[SKEY + 3*TARGKEY]*dtarg[sXX]*ds[sYY] + ddg_dtmp[SKEY + 3*J3KEY]*dJ3[sXX]*ds[sYY]\
309 + ddg_dtmp[TARGKEY + 3*SKEY]*ds[sXX]*dtarg[sYY] + ddg_dtmp[TARGKEY + 3*TARGKEY]*dtarg[sXX]*dtarg[sYY] + ddg_dtmp[TARGKEY + 3*J3KEY]*dJ3[sXX]*dtarg[sYY]\
310 + ddg_dtmp[J3KEY + 3*SKEY]*ds[sXX]*dJ3[sYY] + ddg_dtmp[J3KEY + 3*TARGKEY]*dtarg[sXX]*dJ3[sYY] + ddg_dtmp[J3KEY + 3*J3KEY]*dJ3[sXX]*dJ3[sYY];
312 dr[sYY+ nSymTen*sYY] = dg_dtmp[TARGKEY]*ddtarg[sYY+nSymTen*sYY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GKEY]*dtarg[sXY]*ds[sXY] + ddg_dtmp[SKEY + 3*J3KEY]*dJ3[sXY]*ds[sXY]\
454 + ddg_dtmp[TARGKEY + 3*SKEY]*ds[sXY]*dtarg[sXY] + ddg_dtmp[TARGKEY + 3*TARGKEY]*dtarg[sXY]*dtarg[sXY] + ddg_dtmp[TARGKEY + 3*J3KEY]*dJ3[sXY]*dtarg[sXY]\
455 + ddg_dtmp[J3KEY + 3*SKEY]*ds[sXY]*dJ3[sXY] + ddg_dtmp[J3KEY + 3*TARGKEY]*dtarg[sXY]*dJ3[sXY] + ddg_dtmp[J3KEY + 3*J3KEY]*dJ3[sXY]*dJ3[sXY];
457 if (fabs(sin(theta)) >= 0.5-1.0e-8){
458 const double sin_theta = copysign(0.5-1.0e-8,sin(theta));
459 const double cos_theta = copysign(cos(asin(0.5-1.0e-8)),cos(theta));
460 df_dtmp[SKEY] = sqrt(3)*sin(
phi)/3;
462 df_dtmp[TARGKEY] = sqrt(2)*(-sin_theta*sin(
phi)/3 + cos_theta*sqrt(3)/3)/(4*sqrt(targ));
466 df[sXX] = df_dtmp[SKEY]*ds[sXX] + df_dtmp[TARGKEY]*dtarg[sXX] + df_dtmp[J3KEY]*dJ3[sXX];
468 df[sYY] = df_dtmp[SKEY]*ds[sYY] + df_dtmp[TARGKEY]*dtarg[sYY] + df_dtmp[J3KEY]*dJ3[sYY];
470 df[sZZ] = df_dtmp[SKEY]*ds[sZZ] + df_dtmp[TARGKEY]*dtarg[sZZ] + df_dtmp[J3KEY]*dJ3[sZZ];
472 df[sYZ] = df_dtmp[SKEY]*ds[sYZ] + df_dtmp[TARGKEY]*dtarg[sYZ] + df_dtmp[J3KEY]*dJ3[sYZ];
474 df[sZX] = df_dtmp[SKEY]*ds[sZX] + df_dtmp[TARGKEY]*dtarg[sZX] + df_dtmp[J3KEY]*dJ3[sZX];
476 df[sXY] = df_dtmp[SKEY]*ds[sXY] + df_dtmp[TARGKEY]*dtarg[sXY] + df_dtmp[J3KEY]*dJ3[sXY];
478 dg_dtmp[SKEY] = sqrt(3)*sin(
psi)/3;
480 dg_dtmp[TARGKEY] = sqrt(2)*(-sin_theta*sin(
psi)/3 + cos_theta*sqrt(3)/3)/(4*sqrt(targ));
484 r[sXX] = dg_dtmp[SKEY]*ds[sXX] + dg_dtmp[TARGKEY]*dtarg[sXX] + dg_dtmp[J3KEY]*dJ3[sXX];
486 r[sYY] = dg_dtmp[SKEY]*ds[sYY] + dg_dtmp[TARGKEY]*dtarg[sYY] + dg_dtmp[J3KEY]*dJ3[sYY];
488 r[sZZ] = dg_dtmp[SKEY]*ds[sZZ] + dg_dtmp[TARGKEY]*dtarg[sZZ] + dg_dtmp[J3KEY]*dJ3[sZZ];
490 r[sYZ] = dg_dtmp[SKEY]*ds[sYZ] + dg_dtmp[TARGKEY]*dtarg[sYZ] + dg_dtmp[J3KEY]*dJ3[sYZ];
492 r[sZX] = dg_dtmp[SKEY]*ds[sZX] + dg_dtmp[TARGKEY]*dtarg[sZX] + dg_dtmp[J3KEY]*dJ3[sZX];
494 r[sXY] = dg_dtmp[SKEY]*ds[sXY] + dg_dtmp[TARGKEY]*dtarg[sXY] + dg_dtmp[J3KEY]*dJ3[sXY];
496 ddg_dtmp[SKEY+3*SKEY] = 0;
498 ddg_dtmp[SKEY+3*TARGKEY] = 0;
500 ddg_dtmp[SKEY+3*J3KEY] = 0;
502 ddg_dtmp[TARGKEY+3*SKEY] = 0;
504 ddg_dtmp[TARGKEY+3*TARGKEY] = -sqrt(2)*(-sin_theta*sin(
psi)/3 + cos_theta*sqrt(3)/3)/(8*pow(targ, 3.0/2.0));
506 ddg_dtmp[TARGKEY+3*J3KEY] = 0;
508 ddg_dtmp[J3KEY+3*SKEY] = 0;
510 ddg_dtmp[J3KEY+3*TARGKEY] = 0;
512 ddg_dtmp[J3KEY+3*J3KEY] = 0;
514 dr[sXX+ nSymTen*sXX] = dg_dtmp[TARGKEY]*ddtarg[sXX+nSymTen*sXX] + dg_dtmp[J3KEY]*ddJ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