PLUTO
energy_solve.c File Reference

Inversion scheme for RHD using total energy density. More...

#include "pluto.h"
Include dependency graph for energy_solve.c:

Go to the source code of this file.

Macros

#define MAX_ITER   20
 

Functions

int EnergySolve (Map_param *par)
 

Detailed Description

Inversion scheme for RHD using total energy density.

Try to recover gas pressure from conserved variables {D, m, E} using the algorithm outlined in Section 2 of Mignone, Plewa Bodo (2005). Specifically, we solve Eq. (12) using a Newton-Raphson root finder.

References

  • "The Piecewise Parabolic Method for Multidimensional Relativistic Fluid Dynamics"
    Mignone, Plewa & Bodo, ApJS (2005) 160, 199.
Author
A. Mignone (migno.nosp@m.ne@p.nosp@m.h.uni.nosp@m.to.i.nosp@m.t)
Date
June 25, 2015

Definition in file energy_solve.c.

Macro Definition Documentation

#define MAX_ITER   20

Definition at line 21 of file energy_solve.c.

Function Documentation

int EnergySolve ( Map_param par)

Use Newton algorithm to recover pressure p0 from conservative quantities D, m and E

Definition at line 23 of file energy_solve.c.

29 {
30  int iter;
31  double p, D_1, alpha, alpha2, lor2, lor, m, tol=1.e-14;
32  double tau, theta, h, dh_dp, dh_dtau, gmmr;
33  double yp, dyp, dp, scrh;
34  double D, E, m2;
35 
36  D = par->D;
37  E = par->E;
38  m2 = par->m2;
39 
40  #if EOS == IDEAL
41  gmmr = g_gamma/(g_gamma - 1.0);
42  #endif
43  m = sqrt(m2);
44  p = m - E;
45  p = MAX(p, 1.e-18);
46  D_1 = 1.0/D;
47  for (iter = 0; iter < MAX_ITER; iter++) {
48 
49  alpha = E + p;
50  alpha2 = alpha*alpha;
51  lor2 = 1.0 - m2/alpha2;
52 
53  lor2 = MAX(lor2,1.e-9);
54  lor2 = 1.0/lor2;
55  lor = sqrt(lor2);
56 
57  tau = lor*D_1;
58  theta = p*tau;
59 
60  #if EOS == IDEAL
61  h = 1.0 + gmmr*theta;
62  dh_dp = gmmr*tau;
63  dh_dtau = gmmr*p;
64  #elif EOS == TAUB
65  h = 2.5*theta + sqrt(2.25*theta*theta + 1.0);
66  scrh = (5.0*h - 8.0*theta)/(2.0*h - 5.0*theta);
67  dh_dp = tau*scrh;
68  dh_dtau = p*scrh;
69  #endif
70 
71  yp = D*h*lor - E - p;
72  dyp = D*lor*dh_dp - m2*lor2*lor/(alpha2*alpha)*(lor*dh_dtau + D*h) - 1.0;
73  dp = yp/dyp;
74  p -= dp;
75  if (fabs (dp) < tol*p) break;
76  }
77 
78 /* ----------------------------------------------------------
79  check if solution is consistent
80  ---------------------------------------------------------- */
81 
82  if (p != p) {
83  WARNING(
84  print("! EnergySolve: NaN found while recovering pressure, ");
85  )
86  return 1;
87  }
88 
89  if (p < 0.0){
90  WARNING(
91  print("! EnergySolve: negative pressure (%8.2e), ", p);
92  )
93  return 1;
94  }
95 
96  par->rho = par->D/lor;
97  par->W = D*h*lor;
98  par->prs = p;
99  par->lor = lor;
100 
101 /* -- Recompute entropy consistently -- */
102 
103 #if ENTROPY_SWITCH
104  #if EOS == IDEAL
105  par->sigma_c = p*lor/pow(par->rho,g_gamma-1);
106  #elif EOS == TAUB
107  theta = p/rho;
108  par->sigma_c = p*lor/pow(par->rho,2.0/3.0)*(1.5*theta + sqrt(2.25*theta*theta + 1.0);
109  #endif
110 #endif
111 
112  return 0; /* -- success -- */
113 }
static double alpha
Definition: init.c:3
#define MAX(a, b)
Definition: macros.h:101
double g_gamma
Definition: globals.h:112
double m2
Square of total momentum (input).
Definition: mod_defs.h:89
double D
Lab density (input).
Definition: mod_defs.h:86
tuple scrh
Definition: configure.py:200
#define WARNING(a)
Definition: macros.h:217
static double gmmr
Definition: two_shock.c:42
double rho
proper density (output)
Definition: mod_defs.h:91
double W
D*h*lor (output).
Definition: mod_defs.h:92
void print(const char *fmt,...)
Definition: amrPluto.cpp:497
double lor
Lorentz factor (output).
Definition: mod_defs.h:93
double prs
Thermal pressure (output).
Definition: mod_defs.h:94
#define MAX_ITER
Definition: energy_solve.c:21
double sigma_c
Conserved entropy (input).
Definition: mod_defs.h:87
double E
Total energy (input).
Definition: mod_defs.h:88

Here is the caller graph for this function: