PLUTO  4.4-patch2
Data Structures | Macros | Functions | Variables
mod_defs.h File Reference

Module header file for relativistic MHD (RMHD). More...

Go to the source code of this file.

Data Structures

struct  Map_param
 

Macros

#define RMHD_FAST_EIGENVALUES   NO
 
#define RMHD_REDUCED_ENERGY   YES
 

Functions

int ApproximateFastWaves (double *, double, double, double *)
 
int ConsToPrim (double **, double **, int, int, uint16_t *)
 
void Flux (const State *, int, int)
 
void HLL_Speed (const State *, const State *, double *, double *, int, int)
 
int MaxSignalSpeed (const State *, double *, double *, int, int)
 
void PrimToCons (double **, double **, int, int)
 
void VelocityLimiter (double *, double *, double *)
 
int Magnetosonic (double *vp, double cs2, double h, double *lambda)
 
int RMHD_EnergySolve (Map_param *)
 
int RMHD_PressureFix (Map_param *)
 
void HLL_DIVB_SOURCE (const Sweep *, double **, int, int, Grid *)
 

Variables

Riemann_Solver HLLD_Solver
 

Detailed Description

Set label, indexes and basic prototyping for the relativistic MHD module.

Authors
A. Mignone (migno.nosp@m.ne@t.nosp@m.o.inf.nosp@m.n.it)
C. Zanni (zanni.nosp@m.@oat.nosp@m.o.ina.nosp@m.f.it)
G. Mattia
Date
Dec 02, 2020

Macro Definition Documentation

◆ RMHD_FAST_EIGENVALUES

#define RMHD_FAST_EIGENVALUES   NO

If set to YES, use approximate (and faster) expressions when computing the fast magnetosonic speed, see Sect. 3.3 of Del Zanna, A&A (2006), 473. Solutions of quartic equation is avoided and replace with upper bounds provided by quadratic equation.

◆ RMHD_REDUCED_ENERGY

#define RMHD_REDUCED_ENERGY   YES

By turning RMHD_REDUCED_ENERGY to YES, we let PLUTO evolve the total energy minus the mass density contribution.

Function Documentation

◆ ApproximateFastWaves()

int ApproximateFastWaves ( double *  v,
double  cs2,
double  h,
double *  lambda 
)

Compute an approximate expression for the fast magnetosonic speed using the upper-bound estimated outlined by Leismann et al. (A&A 2005, 436, 503), Eq. [27].

Parameters
[in]van array of primitive variables
[in]cs2the sound speed
[in]hthe specific entropy
[out]lambdaan array containing the fast magnetosonic speeds
Returns
1 if an error occurred.

◆ ConsToPrim()

int ConsToPrim ( double **  ucons,
double **  uprim,
int  beg,
int  end,
uint16_t *  flag 
)

Convert from conservative to primitive variables.

Parameters
[in]uconsarray of conservative variables
[out]uprimarray of primitive variables
[in]begstarting index of computation
[in]endfinal index of computation
[in,out]flagarray of flags tagging, in input, zones where entropy must be used to recover pressure and, on output, zones where conversion was not successful.
Returns
Return 0 if conversion was successful in all zones in the range [ibeg,iend]. Return 1 if one or more zones could not be converted correctly and either pressure, density or energy took non-physical values.

◆ Flux()

void Flux ( const State state,
int  beg,
int  end 
)
Parameters
[in,out]statePointer to a state structure
[in]beginitial index of computation
[in]endfinal index of computation
Returns
This function has no return value.

Compute the component of the flux tensor normal to the direction of integration.

Parameters
[in,out]statePointer to a state structure
[in]beginitial index of computation
[in]endfinal index of computation
Returns
This function has no return value.
Parameters
[in,out]statePointer to a state structure
[in]beginitial index of computation
[in]endfinal index of computation
Returns
This function has no return value.

Compute the component of the flux tensor normal to the direction of integration.

Parameters
[in,out]statePointer to a state structure
[in]beginitial index of computation
[in]endfinal index of computation
Returns
This function has no return value.

◆ HLL_DIVB_SOURCE()

void HLL_DIVB_SOURCE ( const Sweep sweep,
double **  Uhll,
int  beg,
int  end,
Grid grid 
)

Include div.B source term to momentum, induction and energy equation. Used in conjunction with an HLL-type Riemann solver.

LAST_MODIFIED

Setp 18th 2008, by Andrea Mignone (migno.nosp@m.ne@t.nosp@m.o.ast.nosp@m.ro.i.nosp@m.t)

◆ HLL_Speed()

void HLL_Speed ( const State stateL,
const State stateR,
double *  SL,
double *  SR,
int  beg,
int  end 
)

Compute leftmost (SL) and rightmost (SR) speeds for the Riemann fan.

Parameters
[in]stateLpointer to a state structure for the left state
[in]stateRpointer to a state structure for the right state
[out]SLthe (estimated) leftmost speed of the Riemann fan
[out]SRthe (estimated) rightmost speed of the Riemann fan
[in]begstarting index of computation
[in]endfinal index of computation

Switches:

ROE_ESTIMATE (YES/NO), DAVIS_ESTIMATE (YES/NO). TVD_ESTIMATE (YES/NO) JAN_HLL (YES/NO)

These switches set how the wave speed estimates are going to be computed. Only one can be set to 'YES', and the rest of them must be set to 'NO'

ROE_ESTIMATE: b_m = (0, (u_R - c_R, u_L - c_L, u_{roe} - c_{roe})) b_m = (0, (u_R + c_R, u_L + c_L, u_{roe} + c_{roe}))

where u_{roe} and c_{roe} are computed using Roe averages.

DAVIS_ESTIMATE: b_m = (0, (u_R - c_R, u_L - c_L)) b_m = (0, (u_R + c_R, u_L + c_L))

Compute leftmost (SL) and rightmost (SR) speeds for the Riemann fan.

Parameters
[in]stateLpointer to a state structure for the left state
[in]stateRpointer to a state structure for the right state
[out]SLthe (estimated) leftmost speed of the Riemann fan
[out]SRthe (estimated) rightmost speed of the Riemann fan
[in]begstarting index of computation
[in]endfinal index of computation

Switches:

ROE_ESTIMATE (YES/NO), DAVIS_ESTIMATE (YES/NO)

These switches set how the wave speed estimates are going to be computed. Only one can be set to 'YES', and the rest of them must be set to 'NO'

ROE_ESTIMATE: b_m = (0, (u_R - c_R, u_L - c_L, u_{roe} - c_{roe})) b_m = (0, (u_R + c_R, u_L + c_L, u_{roe} + c_{roe}))

where u_{roe} and c_{roe} are computed using Roe averages.

DAVIS_ESTIMATE: b_m = (0, (u_R - c_R, u_L - c_L)) b_m = (0, (u_R + c_R, u_L + c_L))

Compute leftmost (SL) and rightmost (SR) speeds for the Riemann fan.

Parameters
[in]stateLpointer to a state structure for the left state
[in]stateRpointer to a state structure for the right state
[out]SLthe (estimated) leftmost speed of the Riemann fan
[out]SRthe (estimated) rightmost speed of the Riemann fan
[in]begstarting index of computation
[in]endfinal index of computation

◆ Magnetosonic()

int Magnetosonic ( double *  vp,
double  cs2,
double  h,
double *  lambda 
)

Find the four magneto-sonic speeds (fast and slow) for the relativistic MHD equations (RMHD). We follow the notations introduced in Eq. (16) in

Del Zanna, Bucciantini and Londrillo, A&A, 400, 397–413, 2003

and also Eq. (57-58) of Mignone & Bodo, MNRAS, 2006 for the degenerate cases.

The quartic equation is solved analytically and the solver (function 'QuarticSolve') assumes all roots are real (which should be always the case here, since eigenvalues are recovered from primitive variables). The coefficients of the quartic were found through the following MAPLE script:

 *   ------------------------------------------------
restart;

u[0] := gamma;
u[x] := gamma*v[x];
b[0] := gamma*vB;
b[x] := B[x]/gamma + b[0]*v[x];
wt   := w + b^2;

#############################################################
"fdZ will be equation (16) of Del Zanna 2003 times w_{tot}";

e2  := c[s]^2 + b^2*(1 - c[s]^2)/wt;
fdZ := (1-e2)*(u[0]*lambda - u[x])^4 + (1-lambda^2)*
       (c[s]^2*(b[0]*lambda - b[x])^2/wt - e2*(u[0]*lambda - u[x])^2);

########################################################
"print the coefficients of the quartic polynomial fdZ";

coeff(fdZ,lambda,4);
coeff(fdZ,lambda,3);
coeff(fdZ,lambda,2);
coeff(fdZ,lambda,1);
coeff(fdZ,lambda,0);

fdZ := fdZ*wt;  

######################################################
"fMB will be equation (56) of Mignone & Bodo (2006)";

a  := gamma*(lambda-v[x]);
BB := b[x] - lambda*b[0];
fMB := w*(1-c[s]^2)*a^4 - (1-lambda^2)*((b^2+w*c[s]^2)*a^2-c[s]^2*BB^2);

######################################
"check that fdZ = fMB";

simplify(fdZ - fMB);

########################################################
"print the coefficients of the quartic polynomial fMB";

coeff(fMB,lambda,4);
coeff(fMB,lambda,3);
coeff(fMB,lambda,2);
coeff(fMB,lambda,1);
coeff(fMB,lambda,0);


###############################################
"Degenerate case 2: Bx = 0, Eq (58) in MB06";

B[x] := 0;

a2 := w*(c[s]^2 + gamma^2*(1-c[s]^2)) + Q; 
a1 := -2*w*gamma^2*v[x]*(1-c[s]^2);
a0 := w*(-c[s]^2 + gamma^2*v[x]^2*(1-c[s]^2))-Q;

"delc is a good way to evaluate the determinant so that it is > 0";
del  := a1^2 - 4*a2*a0;
delc := 4*(w*c[s]^2 + Q)*(w*(1-c[s]^2)*gamma^2*(1-v[x]^2) + (w*c[s]^2+Q));
simplify(del-delc);

############################################################################
"check the correctness of the coefficients of Eq. (58) in MB06";

Q  := b^2 - c[s]^2*vB^2;
divide(fMB, (lambda-v[x])^2,'fMB2');
simplify(a2 - coeff(fMB2,lambda,2)/gamma^2);
simplify(a1 - coeff(fMB2,lambda,1)/gamma^2);
simplify(a0 - coeff(fMB2,lambda,0)/gamma^2);

◆ MaxSignalSpeed()

int MaxSignalSpeed ( const State state,
double *  cmin,
double *  cmax,
int  beg,
int  end 
)

Compute the maximum and minimum characteristic velocities for the HD equations from the vector of primitive variables state->v.

Parameters
[in]statepointer to a State structure
[out]cmin1-D array containing the leftmost characteristic
[out]cmin1-D array containing the rightmost characteristic
[in]begstarting index of computation
[in]endfinal index of computation

Compute the maximum and minimum characteristic velocities for the MHD equations, cmin= v - cf, cmax = v + cf

Parameters
[in]statepointer to a State structure
[out]cmin1-D array containing the leftmost characteristic
[out]cmin1-D array containing the rightmost characteristic
[in]begstarting index of computation
[in]endfinal index of computation

Return the rightmost (cmax) and leftmost (cmin) wave propagation speed in the Riemann fan

Compute the maximum and minimum propagation speeds for the RHD equations.

Parameters
[in]statepointer to a State structure
[out]cmin1-D array containing the leftmost characteristic
[out]cmin1-D array containing the rightmost characteristic
[in]begstarting index of computation
[in]endfinal index of computation

◆ PrimToCons()

void PrimToCons ( double **  uprim,
double **  ucons,
int  ibeg,
int  iend 
)

Convert primitive variables to conservative variables.

Parameters
[in]uprimarray of primitive variables
[out]uconsarray of conservative variables
[in]begstarting index of computation
[in]endfinal index of computation

Convert primitive variables in conservative variables.

Parameters
[in]uprimarray of primitive variables
[out]uconsarray of conservative variables
[in]begstarting index of computation
[in]endfinal index of computation

Convert a vector of primitive quantities to conservative

◆ RMHD_EnergySolve()

int RMHD_EnergySolve ( Map_param par)

Solve f(W) = 0, where f(W) is Equation (A4) or (A6).

Returns
Error codes:
  • 0 = success
  • 1 = negative energy
  • 2 = negative pressure
  • 3 = inaccurate solution (debug only)
  • 4 = NaN

◆ RMHD_PressureFix()

int RMHD_PressureFix ( Map_param par)
Returns
Error codes are:
  • 0 = success
  • 1 = v^2 > 1
  • 2 = too many iterations

◆ VelocityLimiter()

void VelocityLimiter ( double *  v,
double *  vp,
double *  vm 
)

Check whether the total reconstructed velocity is > 1 If a superluminal value occurs, flatten distribution.

Variable Documentation

◆ HLLD_Solver

void HLLD_Solver

Solve Riemann problem for the isothermal MHD equations using the three-states HLLD Riemann solver of Mignone (2007).

Parameters
[in,out]sweeppointer to Sweep structure
[in]beginitial grid index
[out]endfinal grid index
[out]cmax1D array of maximum characteristic speeds
[in]gridpointer to array of Grid structures.