36 void PrimToCons (
double **uprim,
double **ucons,
int beg,
int end)
48 double vel2, usq, vB, Bmag2;
61 for (i = beg; i <= end; i++) {
66 EXPAND(vx1 = v[
VX1]; ,
69 vel2 = EXPAND(vx1*vx1, + vx2*vx2, + vx3*vx3);
70 g2 = 1.0/(1.0 -
vel2);
73 vB = EXPAND(vx1*v[
BX1], + vx2*v[
BX2], + vx3*v[
BX3]);
74 Bmag2 = EXPAND(v[BX1]*v[BX1], + v[BX2]*v[BX2], + v[BX3]*v[BX3]);
75 wt = v[
RHO]*h[
i]*g2 + Bmag2;
82 EXPAND (u[
MX1] = wt*vx1 - vB*v[BX1]; ,
83 u[
MX2] = wt*vx2 - vB*v[
BX2]; ,
84 u[
MX3] = wt*vx3 - vB*v[
BX3];)
86 EXPAND (u[BX1] = v[BX1]; ,
92 u[ENG] = v[PRS]*(g2*gmmr - 1.0) + u[
RHO]*g2*vel2/(g + 1.0)
93 + 0.5*(Bmag2*(1.0 +
vel2) - vB*vB);
96 u[ENG] = v[PRS]*(g2*2.5 - 1.0)
97 + u[
RHO]*g2*(2.25*wt*wt +
vel2)/(g*sqrt(1.0 + 2.25*wt*wt) + 1.0)
98 + 0.5*(Bmag2*(1.0 +
vel2) - vB*vB);
101 u[ENG] = v[
RHO]*h[
i]*g2 - v[PRS] + 0.5*(Bmag2*(1.0 +
vel2) - vB*vB);
115 int ConsToPrim (
double **ucons,
double **uprim,
int beg,
int end,
136 int i, nv, err, ifail;
137 int use_entropy, use_energy=1;
138 double *u, *
v,
scrh, w_1;
142 for (i = beg; i <= end; i++) {
155 par.
B2 = EXPAND(u[BX1]*u[BX1], + u[BX2]*u[BX2], + u[BX3]*u[BX3]);
156 par.
S2 = par.
S*par.
S;
163 print(
"! ConsToPrim(): negative density (%8.2e), ", u[
RHO]);
172 print(
"! ConsToPrim(): negative energy (%8.2e), ", u[ENG]);
188 use_energy = !use_entropy;
229 w_1 = 1.0/(par.
W + par.
B2);
231 EXPAND(v[
VX1] = w_1*(u[MX1] + scrh*u[BX1]); ,
237 print (
"! ConsToPrim(): v^2 = %f > 1 (p = %12.6e); ", scrh, par.
prs);
243 EXPAND(v[BX1] = u[BX1]; ,
#define RMHD_REDUCED_ENERGY
By turning RMHD_REDUCED_ENERGY to YES, we let PLUTO evolve the total energy minus the mass density co...
double m2
Square of total momentum (input).
double D
Lab density (input).
double g_smallDensity
Small value for density fix.
int PressureFix(Map_param *)
void Enthalpy(double **v, real *h, int beg, int end)
int EnergySolve(Map_param *par)
double S2
Square of S (input).
#define FLAG_CONS2PRIM_FAIL
#define FLAG_ENTROPY
Update pressure using entropy equation.
int ConsToPrim(double **ucons, double **uprim, int ibeg, int iend, unsigned char *flag)
int EntropySolve(Map_param *par)
double W
D*h*lor (output).
void print(const char *fmt,...)
#define ARRAY_1D(nx, type)
double lor
Lorentz factor (output).
long int NMAX_POINT
Maximum number of points among the three directions, boundaries excluded.
void PrimToCons(double **uprim, double **ucons, int ibeg, int iend)
double prs
Thermal pressure (output).
double sigma_c
Conserved entropy (input).
double B2
Square of magnetic field (input).
#define QUIT_PLUTO(e_code)
double E
Total energy (input).