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