PLUTO
eos.c
Go to the documentation of this file.
1 /* ///////////////////////////////////////////////////////////////////// */
2 /*!
3  \file
4  \brief Taub-Matthews (TM) EOS for relativistic hydro and MHD.
5 
6  \author A. Mignone (mignone@ph.unito.it)
7  \date April 14, 2014
8 */
9 /* ///////////////////////////////////////////////////////////////////// */
10 #include "pluto.h"
11 
12 /* ********************************************************************* */
13 void SoundSpeed2 (double **v, double *cs2, double *h, int beg, int end,
14  int pos, Grid *grid)
15 /*!
16  * Define the square of the sound speed.
17  *
18  * \param [in] v 1D array of primitive quantities
19  * \param [out] cs2 1D array containing the square of the sound speed
20  * \param [in] h 1D array of enthalpy values
21  * \param [in] beg initial index of computation
22  * \param [in] end final index of computation
23  * \param [in] pos an integer specifying the spatial position
24  * inside the cell (only for spatially-dependent EOS)
25  * \param [in] grid pointer to an array of Grid structures
26  *
27  * \return This function has no return value.
28  *********************************************************************** */
29 {
30  int i;
31  double theta;
32 
33  #if PHYSICS == RHD || PHYSICS == RMHD
34  Enthalpy(v, h, beg, end);
35  for (i = beg; i <= end; i++) {
36  theta = v[i][PRS]/v[i][RHO];
37  #if EOS == IDEAL
38  cs2[i] = g_gamma*theta/h[i];
39  #elif EOS == TAUB
40  cs2[i] = theta/(3.0*h[i])*(5.0*h[i] - 8.0*theta)/(h[i] - theta);
41  #endif
42  }
43  #else
44  print ("! SoundSpeed2: Taub EOS not defined for this physics module.\n");
45  QUIT_PLUTO(1);
46  #endif
47 }
48 
49 /* ********************************************************************* */
50 void Enthalpy (double **v, real *h, int beg, int end)
51 /*!
52  * Compute the enthalpy.
53  *
54  * \param [in] v 1D array of primitive quantities
55  * \param [in] h 1D array of enthalpy values
56  * \param [in] beg initial index of computation
57  * \param [in] end final index of computation
58  *
59  * \return This function has no return value.
60  *********************************************************************** */
61 {
62  int i;
63  double gmmr, theta;
64 
65  #if PHYSICS == RHD || PHYSICS == RMHD
66  for (i = beg; i <= end; i++) {
67  theta = v[i][PRS]/v[i][RHO];
68  #if EOS == IDEAL
69  h[i] = 1.0 + gmmr*theta;
70  #elif EOS == TAUB
71  h[i] = 2.5*theta + sqrt(2.25*theta*theta + 1.0);
72  #endif
73  }
74  #endif
75 }
76 
77 /* ********************************************************************* */
78 void Entropy (double **v, double *s, int beg, int end)
79 /*!
80  * Compute the entropy.
81  *
82  * \param [in] v 1D array of primitive quantities
83  * \param [in] s 1D array of entropy values
84  * \param [in] is initial index of computation
85  * \param [in] ie final index of computation
86  *
87  * \return This function has no return value.
88  *********************************************************************** */
89 {
90  int i;
91  double rho, th;
92 
93  #if PHYSICS == RHD || PHYSICS == RMHD
94  for (i = beg; i <= end; i++) {
95  rho = v[i][RHO];
96  #if EOS == IDEAL
97  s[i] = v[i][PRS]/pow(rho,g_gamma);
98  #elif EOS == TAUB
99  th = v[i][PRS]/rho;
100  s[i] = v[i][PRS]/pow(rho,5./3.)*(1.5*th + sqrt(2.25*th*th + 1.0));
101  #endif
102  }
103  #endif
104 }
double g_gamma
Definition: globals.h:112
double real
Definition: pluto.h:488
#define RHO
Definition: mod_defs.h:19
void Enthalpy(double **v, real *h, int beg, int end)
Definition: eos.c:48
static double gmmr
Definition: two_shock.c:42
void SoundSpeed2(double **v, double *cs2, double *h, int beg, int end, int pos, Grid *grid)
Definition: eos.c:16
void Entropy(double **v, double *s, int beg, int end)
Definition: eos.c:80
Definition: structs.h:78
void print(const char *fmt,...)
Definition: amrPluto.cpp:497
#define s
PLUTO main header file.
int i
Definition: analysis.c:2
#define QUIT_PLUTO(e_code)
Definition: macros.h:125