65 if (dt >
f->
getDx() / 2. ||
67 cout <<
"too big delta_tau " << dt <<
" " <<
f->
getDx() <<
" "
76 double el, er, pl, pr, nbl, nql, nsl, nbr, nqr, nsr, vxl, vxr, vyl, vyr, vzl,
77 vzr, bl = 0., br = 0., csb, vb, El, Er, dx = 0.;
78 double Ftl = 0., Fxl = 0., Fyl = 0., Fzl = 0., Fbl = 0., Fql = 0., Fsl = 0.,
79 Ftr = 0., Fxr = 0., Fyr = 0., Fzr = 0., Fbr = 0., Fqr = 0., Fsr = 0.;
80 double U1l, U2l, U3l, U4l, Ubl, Uql, Usl, U1r, U2r, U3r, U4r, Ubr, Uqr, Usr;
82 const double dta = mode == 0 ? dt / 2. : dt;
86 left->
getPrimVarRight(
eos,
tau, el, pl, nbl, nql, nsl, vxl, vyl, vzl,
89 right->
getPrimVarLeft(
eos,
tau, er, pr, nbr, nqr, nsr, vxr, vyr, vzr,
91 El = (el + pl) / (1 - vxl * vxl - vyl * vyl - vzl * vzl);
92 Er = (er + pr) / (1 - vxr * vxr - vyr * vyr - vzr * vzr);
96 left->
getPrimVarHRight(
eos,
tau, el, pl, nbl, nql, nsl, vxl, vyl, vzl,
98 right->
getPrimVarHLeft(
eos,
tau, er, pr, nbr, nqr, nsr, vxr, vyr, vzr,
100 El = (el + pl) / (1 - vxl * vxl - vyl * vyl - vzl * vzl);
101 Er = (er + pr) / (1 - vxr * vxr - vyr * vyr - vzr * vzr);
102 tauFactor =
tau + dt / 2.;
115 cout <<
"e>1e10; debug info below:\n";
119 left->
getPrimVarRight(
eos,
tau, el, pl, nbl, nql, nsl, vxl, vyl, vzl,
122 left->
getPrimVarHRight(
eos,
tau, el, pl, nbl, nql, nsl, vxl, vyl, vzl,
129 if (el == 0. && er == 0.)
return;
131 cout <<
"Negative pressure" << endl;
132 left->
getPrimVarRight(
eos,
tau, el, pl, nbl, nql, nsl, vxl, vyl, vzl,
134 right->
getPrimVarLeft(
eos,
tau, er, pr, nbr, nqr, nsr, vxr, vyr, vzr,
139 if (left->
getM(direction) < 1. && right->
getM(direction) < 1.)
return;
141 double gammal = 1. / sqrt(1 - vxl * vxl - vyl * vyl - vzl * vzl);
142 double gammar = 1. / sqrt(1 - vxr * vxr - vyr * vyr - vzr * vzr);
143 U1l = gammal * gammal * (el + pl) * vxl;
144 U2l = gammal * gammal * (el + pl) * vyl;
145 U3l = gammal * gammal * (el + pl) * vzl;
146 U4l = gammal * gammal * (el + pl) - pl;
151 U1r = gammar * gammar * (er + pr) * vxr;
152 U2r = gammar * gammar * (er + pr) * vyr;
153 U3r = gammar * gammar * (er + pr) * vzr;
154 U4r = gammar * gammar * (er + pr) - pr;
159 if (direction ==
X_) {
160 Ftl = U4l * vxl + pl * vxl;
161 Fxl = U1l * vxl + pl;
168 Ftr = U4r * vxr + pr * vxr;
169 Fxr = U1r * vxr + pr;
177 csb = sqrt(
eos->
cs2() + 0.5 * sqrt(El * Er) / pow(sqrt(El) + sqrt(Er), 2) *
179 vb = (sqrt(El) * vxl + sqrt(Er) * vxr) / (sqrt(El) + sqrt(Er));
180 bl =
min(0.,
min((vb - csb) / (1 - vb * csb),
182 br = max(0., max((vb + csb) / (1 + vb * csb),
188 if (el == 0.) bl = -1.;
189 if (er == 0.) br = 1.;
191 if (direction ==
Y_) {
192 Ftl = U4l * vyl + pl * vyl;
194 Fyl = U2l * vyl + pl;
200 Ftr = U4r * vyr + pr * vyr;
202 Fyr = U2r * vyr + pr;
209 csb = sqrt(
eos->
cs2() + 0.5 * sqrt(El * Er) / pow(sqrt(El) + sqrt(Er), 2) *
211 vb = (sqrt(El) * vyl + sqrt(Er) * vyr) / (sqrt(El) + sqrt(Er));
212 bl =
min(0.,
min((vb - csb) / (1 - vb * csb),
214 br = max(0., max((vb + csb) / (1 + vb * csb),
220 if (el == 0.) bl = -1.;
221 if (er == 0.) br = 1.;
223 if (direction ==
Z_) {
225 Ftl = U4l * vzl / tau1 + pl * vzl / tau1;
226 Fxl = U1l * vzl / tau1;
227 Fyl = U2l * vzl / tau1;
228 Fzl = U3l * vzl / tau1 + pl / tau1;
229 Fbl = Ubl * vzl / tau1;
230 Fql = Uql * vzl / tau1;
231 Fsl = Usl * vzl / tau1;
233 Ftr = U4r * vzr / tau1 + pr * vzr / tau1;
234 Fxr = U1r * vzr / tau1;
235 Fyr = U2r * vzr / tau1;
236 Fzr = U3r * vzr / tau1 + pr / tau1;
237 Fbr = Ubr * vzr / tau1;
238 Fqr = Uqr * vzr / tau1;
239 Fsr = Usr * vzr / tau1;
245 csb = sqrt(
eos->
cs2() + 0.5 * sqrt(El * Er) / pow(sqrt(El) + sqrt(Er), 2) *
247 vb = (sqrt(El) * vzl + sqrt(Er) * vzr) / (sqrt(El) + sqrt(Er));
248 bl = 1. /
tau *
min(0.,
min((vb - csb) / (1 - vb * csb),
250 br = 1. /
tau * max(0., max((vb + csb) / (1 + vb * csb),
256 if (el == 0.) bl = -1. /
tau;
257 if (er == 0.) br = 1. /
tau;
260 if (bl == 0. && br == 0.)
return;
263 flux[
T_] = tauFactor * dta / dx *
264 (-bl * br * (U4l - U4r) + br * Ftl - bl * Ftr) / (-bl + br);
265 flux[
X_] = tauFactor * dta / dx *
266 (-bl * br * (U1l - U1r) + br * Fxl - bl * Fxr) / (-bl + br);
267 flux[
Y_] = tauFactor * dta / dx *
268 (-bl * br * (U2l - U2r) + br * Fyl - bl * Fyr) / (-bl + br);
269 flux[
Z_] = tauFactor * dta / dx *
270 (-bl * br * (U3l - U3r) + br * Fzl - bl * Fzr) / (-bl + br);
271 flux[
NB_] = tauFactor * dta / dx *
272 (-bl * br * (Ubl - Ubr) + br * Fbl - bl * Fbr) / (-bl + br);
273 flux[
NQ_] = tauFactor * dta / dx *
274 (-bl * br * (Uql - Uqr) + br * Fql - bl * Fqr) / (-bl + br);
275 flux[
NS_] = tauFactor * dta / dx *
276 (-bl * br * (Usl - Usr) + br * Fsl - bl * Fsr) / (-bl + br);
278 if (flux[
NB_] != flux[
NB_]) {
279 cout <<
"---- error in hlle_flux: f_nb undefined!\n";
280 cout << setw(12) << U4l << setw(12) << U1l << setw(12) << U2l << setw(12)
282 cout << setw(12) << U4r << setw(12) << U1r << setw(12) << U2r << setw(12)
284 cout << setw(12) << Ubl << setw(12) << Uql << setw(12) << Usl << endl;
285 cout << setw(12) << Ubr << setw(12) << Uqr << setw(12) << Usr << endl;
286 cout << setw(12) << Ftl << setw(12) << Fxl << setw(12) << Fyl << setw(12)
288 cout << setw(12) << Ftr << setw(12) << Fxr << setw(12) << Fyr << setw(12)
296 right->
addFlux(flux[T_], flux[X_], flux[Y_], flux[Z_], flux[NB_], flux[NQ_],
301 double p,
double nb,
double nq,
double ns,
double vx,
302 double vy,
double vz,
double S[7]) {
305 S[
T_] = -Q[
T_] * vz * vz - p * (1. + vz *
vz);
333 source(
tau, x,
y,
z, e, p, nb, nq, ns, vx, vy, vz, k);
334 for (
int i = 0;
i < 7;
i++) k[
i] *= _dt;
337 cout <<
"---- error in source_step: k_nb undefined!\n";
338 cout << setw(12) << k[0] << setw(12) << k[1] << setw(12) << k[2] << setw(12)
340 cout << setw(12) << k[4] << setw(12) << k[5] << setw(12) << k[6] << endl;
355 uuu[0] = 1. / sqrt(1. - vx * vx - vy * vy - vz * vz);
356 uuu[1] = uuu[0] *
vx;
357 uuu[2] = uuu[0] *
vy;
358 uuu[3] = uuu[0] *
vz;
361 c->
getPiH() * ( - 1.0 - uuu[3] * uuu[3]);
365 for (
int i = 0;
i < 4;
i++) k[
i] *= dt;
375 double dmu[4][4],
double &du) {
376 const double VMIN = 1
e-2;
377 const double UDIFF = 3.0;
378 double e0, e1,
p, nb, nq,
ns, vx1, vy1, vz1, vx0, vy0, vz0, vxH, vyH, vzH;
379 double ut0, ux0, uy0, uz0, ut1, ux1, uy1, uz1;
382 double Z[4][4][4][4];
384 double gmunu[4][4] = {{1, 0, 0, 0}, {0, -1, 0, 0}, {0, 0, -1, 0},
395 for (
int i = 0;
i < 4;
i++)
396 for (
int j = 0;
j < 4;
j++) {
411 double T, mub, muq, mus;
413 double s =
eos->
s(e1, nb, nq, ns);
414 eos->
eos(e1, nb, nq, ns, T, mub, muq, mus, p);
418 ut0 = 1.0 / sqrt(1.0 - vx0 * vx0 - vy0 * vy0 - vz0 * vz0);
422 ut1 = 1.0 / sqrt(1.0 - vx1 * vx1 - vy1 * vy1 - vz1 * vz1);
426 uuu[0] = 1.0 / sqrt(1.0 - vxH * vxH - vyH * vyH - vzH * vzH);
427 uuu[1] = uuu[0] * vxH;
428 uuu[2] = uuu[0] * vyH;
429 uuu[3] = uuu[0] * vzH;
431 dmu[0][0] = (ut1 * ut1 - ut0 * ut0) / 2. / uuu[0] / dt;
432 dmu[0][1] = (ux1 * ux1 - ux0 * ux0) / 2. / uuu[1] / dt;
433 dmu[0][2] = (uy1 * uy1 - uy0 * uy0) / 2. / uuu[2] / dt;
434 dmu[0][3] = (uz1 * uz1 - uz0 * uz0) / 2. / uuu[3] / dt;
435 if (fabs(0.5 * (ut1 + ut0) / ut1) > UDIFF) dmu[0][0] = (ut1 - ut0) / dt;
436 if (fabs(uuu[1]) < VMIN || fabs(0.5 * (ux1 + ux0) / ux1) > UDIFF)
437 dmu[0][1] = (ux1 - ux0) / dt;
438 if (fabs(uuu[2]) < VMIN || fabs(0.5 * (uy1 + uy0) / uy1) > UDIFF)
439 dmu[0][2] = (uy1 - uy0) / dt;
440 if (fabs(uuu[3]) < VMIN || fabs(0.5 * (uz1 + uz0) / uz1) > UDIFF)
441 dmu[0][3] = (uz1 - uz0) / dt;
442 if (e1 <= 0. || e0 <= 0.) {
443 dmu[0][0] = dmu[0][1] = dmu[0][2] = dmu[0][3] = 0.;
450 if (e1 > 0. && e0 > 0.) {
451 ut0 = 1.0 / sqrt(1.0 - vx0 * vx0 - vy0 * vy0 - vz0 * vz0);
455 ut1 = 1.0 / sqrt(1.0 - vx1 * vx1 - vy1 * vy1 - vz1 * vz1);
459 dmu[1][0] = 0.25 * (ut1 * ut1 - ut0 * ut0) / uuu[0] / dx;
460 dmu[1][1] = 0.25 * (ux1 * ux1 - ux0 * ux0) / uuu[1] / dx;
461 dmu[1][2] = 0.25 * (uy1 * uy1 - uy0 * uy0) / uuu[2] / dx;
462 dmu[1][3] = 0.25 * (uz1 * uz1 - uz0 * uz0) / uuu[3] / dx;
463 if (fabs(0.5 * (ut1 + ut0) / uuu[0]) > UDIFF)
464 dmu[1][0] = 0.5 * (ut1 - ut0) / dx;
465 if (fabs(uuu[1]) < VMIN || fabs(0.5 * (ux1 + ux0) / uuu[1]) > UDIFF)
466 dmu[1][1] = 0.5 * (ux1 - ux0) / dx;
467 if (fabs(uuu[2]) < VMIN || fabs(0.5 * (uy1 + uy0) / uuu[2]) > UDIFF)
468 dmu[1][2] = 0.5 * (uy1 - uy0) / dx;
469 if (fabs(uuu[3]) < VMIN || fabs(0.5 * (uz1 + uz0) / uuu[3]) > UDIFF)
470 dmu[1][3] = 0.5 * (uz1 - uz0) / dx;
472 dmu[1][0] = dmu[1][1] = dmu[1][2] = dmu[1][3] = 0.;
474 if (fabs(dmu[1][3]) > 1
e+10)
475 cout <<
"dmu[1][3]: " << uz1 <<
" " << uz0 <<
" " << uuu[3] << endl;
481 if (e1 > 0. && e0 > 0.) {
482 ut0 = 1.0 / sqrt(1.0 - vx0 * vx0 - vy0 * vy0 - vz0 * vz0);
486 ut1 = 1.0 / sqrt(1.0 - vx1 * vx1 - vy1 * vy1 - vz1 * vz1);
490 dmu[2][0] = 0.25 * (ut1 * ut1 - ut0 * ut0) / uuu[0] /
dy;
491 dmu[2][1] = 0.25 * (ux1 * ux1 - ux0 * ux0) / uuu[1] /
dy;
492 dmu[2][2] = 0.25 * (uy1 * uy1 - uy0 * uy0) / uuu[2] /
dy;
493 dmu[2][3] = 0.25 * (uz1 * uz1 - uz0 * uz0) / uuu[3] /
dy;
494 if (fabs(0.5 * (ut1 + ut0) / uuu[0]) > UDIFF)
495 dmu[2][0] = 0.5 * (ut1 - ut0) /
dy;
496 if (fabs(uuu[1]) < VMIN || fabs(0.5 * (ux1 + ux0) / uuu[1]) > UDIFF)
497 dmu[2][1] = 0.5 * (ux1 - ux0) /
dy;
498 if (fabs(uuu[2]) < VMIN || fabs(0.5 * (uy1 + uy0) / uuu[2]) > UDIFF)
499 dmu[2][2] = 0.5 * (uy1 - uy0) /
dy;
500 if (fabs(uuu[3]) < VMIN || fabs(0.5 * (uz1 + uz0) / uuu[3]) > UDIFF)
501 dmu[2][3] = 0.5 * (uz1 - uz0) /
dy;
503 dmu[2][0] = dmu[2][1] = dmu[2][2] = dmu[2][3] = 0.;
510 if (e1 > 0. && e0 > 0.) {
511 ut0 = 1.0 / sqrt(1.0 - vx0 * vx0 - vy0 * vy0 - vz0 * vz0);
515 ut1 = 1.0 / sqrt(1.0 - vx1 * vx1 - vy1 * vy1 - vz1 * vz1);
519 dmu[3][0] = 0.25 * (ut1 * ut1 - ut0 * ut0) / uuu[0] /
dz / (
tau + 0.5 * dt);
520 dmu[3][1] = 0.25 * (ux1 * ux1 - ux0 * ux0) / uuu[1] /
dz / (
tau + 0.5 * dt);
521 dmu[3][2] = 0.25 * (uy1 * uy1 - uy0 * uy0) / uuu[2] /
dz / (
tau + 0.5 * dt);
522 dmu[3][3] = 0.25 * (uz1 * uz1 - uz0 * uz0) / uuu[3] /
dz / (
tau + 0.5 * dt);
523 if (fabs(0.5 * (ut1 + ut0) / uuu[0]) > UDIFF)
524 dmu[3][0] = 0.5 * (ut1 - ut0) /
dz / (
tau + 0.5 * dt);
525 if (fabs(uuu[1]) < VMIN || fabs(0.5 * (ux1 + ux0) / uuu[1]) > UDIFF)
526 dmu[3][1] = 0.5 * (ux1 - ux0) /
dz / (
tau + 0.5 * dt);
527 if (fabs(uuu[2]) < VMIN || fabs(0.5 * (uy1 + uy0) / uuu[2]) > UDIFF)
528 dmu[3][2] = 0.5 * (uy1 - uy0) /
dz / (
tau + 0.5 * dt);
529 if (fabs(uuu[3]) < VMIN || fabs(0.5 * (uz1 + uz0) / uuu[3]) > UDIFF)
530 dmu[3][3] = 0.5 * (uz1 - uz0) /
dz / (
tau + 0.5 * dt);
532 dmu[3][0] = dmu[3][1] = dmu[3][2] = dmu[3][3] = 0.;
535 dmu[3][0] += uuu[3] / (
tau - 0.5 * dt);
536 dmu[3][3] += uuu[0] / (
tau - 0.5 * dt);
538 for (
int i = 0;
i < 4;
i++)
539 for (
int j = 0;
j < 4;
j++)
540 for (
int k = 0;
k < 4;
k++)
541 for (
int l = 0; l < 4; l++) Z[
i][
j][
k][l] = 0.0;
543 for (
int mu = 0;
mu < 4;
mu++)
544 for (
int nu = 0; nu < 4; nu++)
545 for (
int lam = 0; lam < 4; lam++)
548 Z[
mu][nu][lam][
rho] += 0.5 * (gmunu[
mu][lam] - uuu[
mu] * uuu[lam]);
550 Z[
mu][nu][lam][
rho] += 0.5 * (gmunu[nu][lam] - uuu[nu] * uuu[lam]);
552 Z[
mu][nu][lam][
rho] -= (gmunu[
mu][nu] - uuu[
mu] * uuu[nu]) / 3.0;
555 for (
int i = 0;
i < 4;
i++)
556 for (
int j = 0;
j < 4;
j++) {
558 for (
int k = 0;
k < 4;
k++)
559 for (
int l = 0; l < 4; l++) {
560 pi[
i][
j] += Z[
i][
j][
k][l] * dmu[
k][l] * 2.0 * etaS * s / 5.068;
563 Pi = -zetaS * s * (dmu[0][0] + dmu[1][1] + dmu[2][2] + dmu[3][3]) /
565 du = dmu[0][0] + dmu[1][1] + dmu[2][2] + dmu[3][3];
568 for (
int i = 0;
i < 4;
i++)
569 for (
int j = 0;
j < 4;
j++) {
570 if (pi[
i][
j] != 0. && fabs(1.0 - pi[
j][
i] / pi[
i][
j]) > 1
e-10)
571 cout <<
"non-diag: " << pi[
i][j] <<
" " << pi[j][
i] << endl;
572 if (isinf(pi[
i][j]) || isnan(pi[
i][j])) {
573 cout <<
"hydro:NSquant: inf/nan i " <<
i <<
" j " << j << endl;
580 double e,
p, nb, nq,
ns,
vx,
vy,
vz, piNS[4][4], PiNS;
581 for (
int ix = 0; ix <
f->
getNX(); ix++)
582 for (
int iy = 0; iy <
f->
getNY(); iy++)
583 for (
int iz = 0; iz <
f->
getNZ(); iz++) {
586 if (e <= 0.)
continue;
590 double T, mub, muq, mus;
593 eos->
s(e, nb, nq, ns);
594 eos->
eos(e, nb, nq, ns, T, mub, muq, mus, p);
596 for (
int i = 0;
i < 4;
i++)
597 for (
int j = 0;
j < 4;
j++) piNS[
i][
j] = 0.0;
598 piNS[1][1] = piNS[2][2] = 2.0 / 3.0 * etaS * s /
tau / 5.068;
599 piNS[3][3] = -2.0 * piNS[1][1];
601 for (
int i = 0;
i < 4;
i++)
605 cout <<
"setNS done\n";
609 double e,
p, nb, nq,
ns,
vx,
vy,
vz,
T, mub, muq, mus;
610 double piNS[4][4], PiNS, dmu[4][4], du,
pi[4][4], piH[4][4], Pi, PiH;
611 const double gmumu[4] = {1., -1., -1., -1.};
614 for (
int ix = 0; ix <
f->
getNX(); ix++)
615 for (
int iy = 0; iy <
f->
getNY(); iy++)
616 for (
int iz = 0; iz <
f->
getNZ(); iz++) {
621 for (
int i = 0;
i < 4;
i++)
622 for (
int j = 0;
j <=
i;
j++) {
630 double gamma = 1.0 / sqrt(1.0 - vx * vx - vy * vy - vz * vz);
638 for(
int i=0;
i<4;
i++)
641 c->
addFlux(flux[0], flux[1], flux[2], flux[3], 0., 0., 0.);
643 NSquant(ix, iy, iz, piNS, PiNS, dmu, du);
644 eos->
eos(e, nb, nq, ns, T, mub, muq, mus, p);
650 for (
int i = 0;
i < 4;
i++)
651 for (
int j = 0;
j <=
i;
j++) {
652 #ifdef FORMAL_SOLUTION
654 exp(-dt / 2.0 / gamma / taupi) +
658 dt / 2.0 / gamma / taupi);
661 #ifdef FORMAL_SOLUTION
662 c->
setPiH0((c->
getPi() - PiNS) * exp(-dt / 2.0 / gamma / tauPi) +
666 (c->
getPi() - PiNS) * dt / 2.0 / gamma / tauPi);
669 double tau1 =
tau - dt * 0.75;
670 c->
addpiH0(0, 0, -2. * vz * c->
getpi(0, 3) / tau1 * dt /
672 c->
addpiH0(3, 3, -(2. * vz / tau1 * c->
getpi(0, 3)) * dt / 2.);
674 3, 0, -(vz / tau1 * c->
getpi(0, 0) + vz / tau1 * c->
getpi(3, 3)) *
676 c->
addpiH0(1, 0, -vz / tau1 * c->
getpi(1, 3) * dt / 2.);
677 c->
addpiH0(2, 0, -vz / tau1 * c->
getpi(2, 3) * dt / 2.);
678 c->
addpiH0(3, 1, -(vz / tau1 * c->
getpi(0, 1)) * dt / 2.);
679 c->
addpiH0(3, 2, -(vz / tau1 * c->
getpi(0, 2)) * dt / 2.);
681 for (
int i = 0;
i < 4;
i++)
682 for (
int j = 0;
j <=
i;
j++) {
684 -4. / 3. * c->
getpi(
i,
j) * du / gamma * dt / 2.);
685 for (
int k = 0;
k < 4;
687 for (
int l = 0; l < 4; l++)
689 -c->
getpi(
i,
k) * u[
j] * u[l] * dmu[l][
k] *
690 gmumu[
k] / gamma * dt / 2. -
691 c->
getpi(
j,
k) * u[
i] * u[l] * dmu[l][
k] *
692 gmumu[
k] / gamma * dt / 2.);
694 c->
addPiH0(-4. / 3. * c->
getPi() * du / gamma * dt / 2.);
696 for (
int i = 0;
i < 4;
i++)
697 for (
int j = 0;
j <=
i;
j++) {
698 #ifdef FORMAL_SOLUTION
700 exp(-dt / gamma / taupi) +
707 #ifdef FORMAL_SOLUTION
708 c->
setPi0((c->
getPi() - PiNS) * exp(-dt / gamma / tauPi) + PiNS);
712 tau1 =
tau - dt * 0.5;
714 -2. * vz / tau1 * c->
getpiH0(0, 3) * dt);
717 vz / tau1 * c->
getpiH0(3, 3)) *
724 for (
int i = 0;
i < 4;
i++)
725 for (
int j = 0;
j <=
i;
j++) {
727 for (
int k = 0;
k < 4;
729 for (
int l = 0; l < 4; l++)
731 gmumu[
k] / gamma * dt -
733 dmu[l][
k] * gmumu[
k] / gamma * dt);
740 for (
int ix = 0; ix <
f->
getNX(); ix++)
741 for (
int iy = 0; iy <
f->
getNY(); iy++)
742 for (
int iz = 0; iz <
f->
getNZ(); iz++) {
746 if (e <= 0.)
continue;
747 double xm = -vx * dt /
f->
getDx();
748 double ym = -vy * dt /
f->
getDy();
749 double zm = -vz * dt /
f->
getDz() / (
tau - 0.5 * dt);
750 double xmH = -vx * dt /
f->
getDx() / 2.0;
751 double ymH = -vy * dt /
f->
getDy() / 2.0;
752 double zmH = -vz * dt /
f->
getDz() / (
tau - 0.5 * dt) / 2.0;
753 double wx[2] = {(1. - fabs(xm)), fabs(xm)};
754 double wy[2] = {(1. - fabs(ym)), fabs(ym)};
755 double wz[2] = {(1. - fabs(zm)), fabs(zm)};
756 double wxH[2] = {(1. - fabs(xmH)), fabs(xmH)};
757 double wyH[2] = {(1. - fabs(ymH)), fabs(ymH)};
758 double wzH[2] = {(1. - fabs(zmH)), fabs(zmH)};
759 for (
int i = 0;
i < 4;
i++)
760 for (
int j = 0;
j < 4;
j++) {
761 pi[
i][
j] = piH[
i][
j] = 0.0;
764 for (
int jx = 0; jx < 2; jx++)
765 for (
int jy = 0; jy < 2; jy++)
766 for (
int jz = 0; jz < 2; jz++) {
770 for (
int i = 0;
i < 4;
i++)
771 for (
int j = 0;
j < 4;
j++) {
772 pi[
i][
j] += wx[jx] * wy[jy] * wz[jz] * c1->
getpi0(
i,
j);
773 piH[
i][
j] += wxH[jx] * wyH[jy] * wzH[jz] * c1->
getpiH0(
i,
j);
775 Pi += wx[jx] * wy[jy] * wz[jz] * c1->
getPi0();
776 PiH += wxH[jx] * wyH[jy] * wzH[jz] * c1->
getPiH0();
780 for (
int i = 0;
i < 4;
i++)
781 for (
int j = 0;
j < 4;
j++) {
782 if (pi[
i][
j] != 0. && fabs(1.0 - pi[
j][
i] / pi[
i][
j]) > 1e-10)
783 cout <<
"non-diag: " << pi[
i][
j] <<
" " << pi[
j][
i] << endl;
789 double maxT0 = max((e + p) / (1. - vx * vx - vy * vy - vz * vz) - p,
790 (e + p) * (vx * vx + vy * vy + vz * vz) /
791 (1. - vx * vx - vy * vy - vz * vz) +
795 for (
int i = 0;
i < 4;
i++)
796 for (
int j = 0;
j < 4;
j++)
797 if (fabs(pi[
i][
j]) > maxpi) maxpi = fabs(pi[
i][j]);
798 bool rescaled =
false;
799 if (maxT0 / maxpi < 1.0) {
800 for (
int i = 0;
i < 4;
i++)
801 for (
int j = 0; j < 4; j++) {
802 pi[
i][
j] = 0.1 * pi[
i][
j] * maxT0 / maxpi;
803 piH[
i][
j] = 0.1 * piH[
i][
j] * maxT0 / maxpi;
808 if (Pi != 0.) Pi = 0.1 * Pi / fabs(Pi) *
p;
809 if (PiH != 0.) PiH = 0.1 * PiH / fabs(PiH) *
p;
817 for (
int i = 0;
i < 4;
i++)
818 for (
int j = 0; j <=
i; j++) {
825 double gamma = 1.0 / sqrt(1.0 - vx * vx - vy * vy - vz * vz);
832 for(
int i=0;
i<4;
i++)
835 c->
addFlux(flux[0], flux[1], flux[2], flux[3], 0., 0., 0.);
846 if (left->
getM(direction) < 1. && right->
getM(direction) < 1.)
return;
850 else if (direction ==
Y_)
852 else if (direction ==
Z_)
854 double e,
p, nb, nq,
ns, vxl, vyl, vzl, vxr, vyr, vzr;
860 vxl = 0.5 * (vxl + vxr);
861 vyl = 0.5 * (vyl + vyr);
862 vzl = 0.5 * (vzl + vzr);
863 double v = sqrt(vxl * vxl + vyl * vyl + vzl * vzl);
865 vxl = 0.99 * vxl /
v;
866 vyl = 0.99 * vyl /
v;
867 vzl = 0.99 * vzl /
v;
869 double gamma = 1. / sqrt(1. - v * v);
870 double uuu[4] = {gamma, gamma * vxl, gamma * vyl, gamma * vzl};
871 double gmumu[4] = {1., -1., -1., -1.};
874 else if (direction ==
Y_)
876 else if (direction ==
Z_)
878 for (
int ind1 = 0; ind1 < 4; ind1++) {
879 flux[ind1] = 0.5 * (left->
getpiH(ind1, ind2) + right->
getpiH(ind1, ind2));
881 flux[ind1] += -0.5 * (left->
getPiH() + right->
getPiH()) *
884 0.5 * (left->
getPiH() + right->
getPiH()) * uuu[ind1] * uuu[ind2];
886 for (
int i = 0;
i < 4;
i++) flux[
i] = flux[
i] * (
tau - 0.5*dt) * dt / dxa;
888 right->
addFlux(flux[T_], flux[X_], flux[Y_], flux[Z_], 0., 0., 0.);
896 tau_z = dt / 2. / log(1 + dt / 2. /
tau);
899 for (
int iy = 0; iy <
f->
getNY(); iy++)
900 for (
int iz = 0; iz <
f->
getNZ(); iz++)
901 for (
int ix = 0; ix <
f->
getNX(); ix++) {
907 for (
int iy = 0; iy <
f->
getNY(); iy++)
908 for (
int iz = 0; iz <
f->
getNZ(); iz++)
909 for (
int ix = 0; ix <
f->
getNX() - 1; ix++) {
915 for (
int iz = 0; iz <
f->
getNZ(); iz++)
916 for (
int ix = 0; ix <
f->
getNX(); ix++)
917 for (
int iy = 0; iy <
f->
getNY() - 1; iy++) {
923 for (
int ix = 0; ix <
f->
getNX(); ix++)
924 for (
int iy = 0; iy <
f->
getNY(); iy++)
925 for (
int iz = 0; iz <
f->
getNZ() - 1; iz++) {
931 for (
int iy = 0; iy <
f->
getNY(); iy++)
932 for (
int iz = 0; iz <
f->
getNZ(); iz++)
933 for (
int ix = 0; ix <
f->
getNX(); ix++) {
935 source_step(ix, iy, iz,
PREDICT);
942 tau_z = dt / log(1 + dt /
tau);
944 for (
int iy = 0; iy <
f->
getNY(); iy++)
945 for (
int iz = 0; iz <
f->
getNZ(); iz++)
946 for (
int ix = 0; ix <
f->
getNX() - 1; ix++) {
952 for (
int iz = 0; iz <
f->
getNZ(); iz++)
953 for (
int ix = 0; ix <
f->
getNX(); ix++)
954 for (
int iy = 0; iy <
f->
getNY() - 1; iy++) {
960 for (
int ix = 0; ix <
f->
getNX(); ix++)
961 for (
int iy = 0; iy <
f->
getNY(); iy++)
962 for (
int iz = 0; iz <
f->
getNZ() - 1; iz++) {
968 for (
int iy = 0; iy <
f->
getNY(); iy++)
969 for (
int iz = 0; iz <
f->
getNZ(); iz++)
970 for (
int ix = 0; ix <
f->
getNX(); ix++) {
972 source_step(ix, iy, iz,
CORRECT);
984 for (
int iy = 0; iy <
f->
getNY(); iy++)
985 for (
int iz = 0; iz <
f->
getNZ(); iz++)
986 for (
int ix = 0; ix <
f->
getNX() - 1; ix++) {
991 for (
int iz = 0; iz <
f->
getNZ(); iz++)
992 for (
int ix = 0; ix <
f->
getNX(); ix++)
993 for (
int iy = 0; iy <
f->
getNY() - 1; iy++) {
998 for (
int ix = 0; ix <
f->
getNX(); ix++)
999 for (
int iy = 0; iy <
f->
getNY(); iy++)
1000 for (
int iz = 0; iz <
f->
getNZ() - 1; iz++) {
1004 for (
int iy = 0; iy <
f->
getNY(); iy++)
1005 for (
int iz = 0; iz <
f->
getNZ(); iz++)
1006 for (
int ix = 0; ix <
f->
getNX(); ix++) {
1007 visc_source_step(ix, iy, iz);