Version: SMASH-3.4
hadgas_eos.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (c) 2016-2020,2022,2025-2026
4  * SMASH Team
5  *
6  * GNU General Public License (GPLv3 or later)
7  *
8  */
9 #ifndef SRC_INCLUDE_SMASH_HADGAS_EOS_H_
10 #define SRC_INCLUDE_SMASH_HADGAS_EOS_H_
11 
12 #include <array>
13 #include <string>
14 #include <vector>
15 
16 #include "gsl/gsl_multiroots.h"
17 #include "gsl/gsl_roots.h"
18 #include "gsl/gsl_vector.h"
19 
20 #include "constants.h"
21 #include "particletype.h"
22 
23 namespace smash {
24 
25 // Forward declaration of HadronGasEos - it is used in EosTable
26 class HadronGasEos;
27 
28 /**
29  * A class to hold, compute and access tabulated EoS.
30  */
31 class EosTable {
32  public:
33  /**
34  * Sets up a table p/T/muB/mus/muQ versus (e, nb, nq), where e - energy
35  * density, nb - net baryon density, nq - net charge density, p - pressure, T
36  * - temperature, muB - net baryon chemical potential, muS - net strangeness
37  * potential, muQ - net charge chemical potential. Net strangeness density and
38  * isospin projection density are assumed to be 0 (Note that the corresponding
39  * chemical potential is still non-zero, because muB != 0).
40  *
41  * After calling this constructor the table is allocated, but it is
42  * still empty. To compute values call compile_table.
43  *
44  * \param[in] de step in energy density [GeV/fm^4]
45  * \param[in] dnb step in net baryon density [GeV/fm^3]
46  * \param[in] dq step in net charge density [GeV/Gev^3]
47  * \param[in] n_e number of steps in energy density
48  * \param[in] n_b number of steps in net baryon density
49  * \param[in] n_q number of steps in net charge density
50  *
51  * Entry at (ie, inb, inq) corresponds to energy density and net baryon
52  * density (e, nb, nq) = (ie*de, inb*dnb, inq*dnq) [GeV/fm^4, GeV/fm^3].
53  */
54  EosTable(double de, double dnb, double dq, size_t n_e, size_t n_b,
55  size_t n_q);
56  /// Define the data structure for one element of the table.
57  struct table_element {
58  /// Pressure
59  double p;
60  /// Temperature
61  double T;
62  /// Net baryochemical potential
63  double mub;
64  /// Net strangeness potential
65  double mus;
66  /// Net charge chemical potential
67  double muq;
68  };
69  /**
70  * Computes the actual content of the table (for EosTable description see
71  * documentation of the constructor).
72  *
73  * \param[in] eos equation of state
74  * \param[in] eos_savefile_name name of the file to save tabulated equation
75  * of state
76  */
77  void compile_table(HadronGasEos& eos,
78  const std::string& eos_savefile_name = "hadgas_eos.dat");
79  /**
80  * Obtain interpolated p/T/muB/muS/muQ from the tabulated equation of state
81  * given energy density, net baryon density and net charge density
82  *
83  * \param[in] e energy density
84  * \param[in] nb net baryon density
85  * \param[in] nq net charge density
86  * \param[out] res structure, that contains p/T/muB/muS/muQ
87  */
88  void get(table_element& res, double e, double nb, double nq) const;
89 
90  private:
91  /// proper index in a 1d vector, where the 3d table is stored
92  size_t index(size_t ie, size_t inb, size_t inq) const {
93  return n_q_ * (ie * n_nb_ + inb) + inq;
94  }
95  /// Storage for the tabulated equation of state
96  std::vector<table_element> table_;
97  /// Step in energy density
98  double de_;
99  /// Step in net-baryon density
100  double dnb_;
101  /// Step in net-charge density
102  double dq_;
103  /// Number of steps in energy density
104  size_t n_e_;
105  /// Number of steps in net-baryon density
106  size_t n_nb_;
107  /// Number of steps in net-charge density
108  size_t n_q_;
109 };
110 
111 /**
112  * Class to handle the equation of state (EoS) of the hadron gas, consisting
113  * of all hadrons included in SMASH. This implementation deals with an ideal
114  * Boltzmann gas and allows to compute:
115  * - energy density \f$\epsilon\f$, pressure \f$p\f$, density \f$n\f$,
116  * net baryon density \f$n_B\f$, net strangeness \f$n_S\f$ and net charge
117  * density \f$n_Q\f$ as a function of temperature \f$T\f$, baryon chemical
118  * potential \f$\mu_B\f$, strange chemical potential \f$\mu_S\f$ and charge
119  * chemical potential \f$\mu_Q\f$.
120  * - Temperature and chemical potentials given energy-, net baryon- and
121  * net strangeness density. This requires solving a system of
122  * nonlinear equations.
123  */
125  public:
126  /**
127  * Constructor of HadronGasEos
128  * \param[in] tabulate Whether the equation of state should be tabulated
129  * Tabulation takes time once (typically around 5 minutes), but
130  * makes the further usage of the class much faster. Tabulated
131  * values are saved in a file and loaded at the next run.
132  * \param[in] account_for_widths Whether equation of state should account
133  * for resonance spectral functions. Normally one wants to do it,
134  * if HadronGasEos is used for density calculations,
135  * for example in the box initialization. However, it is not
136  * recommended to account for spectral functions if EoS is
137  * tabulated (tabulate = true), because this makes tabulation
138  * incredibly slow. Therefore, for HadronGasEos to be used
139  * in thermalizer, this option has to be false. Also note that
140  * presently width account is not implemented for energy density
141  * calculation.
142  */
143  HadronGasEos(bool tabulate, bool account_for_widths);
144  ~HadronGasEos();
145 
146  /**
147  * \brief Compute energy density.
148  *
149  * Grand-canonical Boltzmann ideal gas, consisting of all hadrons in SMASH:
150  * \f[ \epsilon = \sum \frac{g_i m_i^2 T^2}{2\pi^2(\hbar c)^3}
151  * exp \left(\frac{\mu_B B_i + \mu_S S_i + \mu_Q Q_i}{T} \right)
152  * \times \left[ 3 K_2\left( \frac{m_i}{T}\right) + \frac{m_i}{T} K_1\left(
153  * \frac{m_i}{T}\right)\right] \f]
154  *
155  * \param[in] T temperature [GeV]
156  * \param[in] mub baryon chemical potential [GeV]
157  * \param[in] mus strangeness chemical potential [GeV]
158  * \param[in] muq charge chemical potential [GeV]
159  * \return energy density e [GeV/fm\f$^3\f$]
160  */
161  static double energy_density(double T, double mub, double mus, double muq);
162 
163  /**
164  * \brief Compute particle number density.
165  *
166  * Grand-canonical Boltzmann ideal gas, consisting of all hadrons in SMASH:
167  * \f[ n = \sum \frac{g_i m_i^2 T}{2\pi^2(\hbar c)^3}
168  * exp \left(\frac{\mu_B B_i + \mu_S S_i + \mu_Q Q_i}{T} \right)
169  * K_2\left( \frac{m_i}{T}\right)
170  * \f]
171  *
172  * \param[in] T temperature [GeV]
173  * \param[in] mub baryon chemical potential [GeV]
174  * \param[in] mus strangeness chemical potential [GeV]
175  * \param[in] muq charge chemical potential [GeV]
176  * \param[in] account_for_resonance_widths if false, pole masses are used;
177  * if true, then integration over spectral function is included
178  * \return particle number density n [fm\f$^{-3}\f$]
179  */
180  static double density(double T, double mub, double mus, double muq,
181  bool account_for_resonance_widths = false);
182 
183  /**
184  * Compute pressure \f$ p = n T \f$.
185  *
186  * \param[in] T temperature [GeV]
187  * \param[in] mub baryon chemical potential [GeV]
188  * \param[in] mus strangeness chemical potential [GeV]
189  * \param[in] muq charge chemical potential [GeV]
190  * \param[in] account_for_resonance_widths if false, pole masses are used;
191  * if true, then integration over spectral function is included
192  * \return pressure p [GeV/fm\f$^{-3}\f$]
193  */
194  static double pressure(double T, double mub, double mus, double muq,
195  bool account_for_resonance_widths = false) {
196  return T * density(T, mub, mus, muq, account_for_resonance_widths);
197  }
198 
199  /**
200  * \brief Compute net baryon density.
201  *
202  * Grand-canonical Boltzmann ideal gas, consisting of all hadrons in SMASH:
203  * \f[ n_B = \sum B_i \frac{g_i m_i^2 T}{2\pi^2(\hbar c)^3}
204  * exp \left(\frac{\mu_B B_i + \mu_S S_i + \mu_Q Q_i}{T} \right)
205  * K_2\left( \frac{m_i}{T}\right)
206  * \f]
207  *
208  * \param[in] T temperature [GeV]
209  * \param[in] mub baryon chemical potential [GeV]
210  * \param[in] mus strangeness chemical potential [GeV]
211  * \param[in] muq charge chemical potential [GeV]
212  * \param[in] account_for_resonance_widths if false, pole masses are used;
213  * if true, then integration over spectral function is included
214  * \return net baryon density \f$n_B\f$ [fm\f$^{-3}\f$]
215  */
216  static double net_baryon_density(double T, double mub, double mus, double muq,
217  bool account_for_resonance_widths = false);
218 
219  /**
220  * \brief Compute net strangeness density.
221  *
222  * Grand-canonical Boltzmann ideal gas, consisting of all hadrons in SMASH:
223  * \f[ n_S = \sum S_i \frac{g_i m_i^2 T}{2\pi^2(\hbar c)^3}
224  * exp \left(\frac{\mu_B B_i + \mu_S S_i + \mu_Q Q_i}{T} \right)
225  * K_2\left( \frac{m_i}{T}\right)
226  * \f]
227  *
228  * \param[in] T temperature [GeV]
229  * \param[in] mub baryon chemical potential [GeV]
230  * \param[in] mus strangeness chemical potential [GeV]
231  * \param[in] muq charge chemical potential [GeV]
232  * \param[in] account_for_resonance_widths if false, pole masses are used;
233  * if true, then integration over spectral function is included
234  * \return net strangeness density density \f$n_S\f$ [fm\f$^{-3}\f$]
235  */
236  static double net_strange_density(double T, double mub, double mus,
237  double muq,
238  bool account_for_resonance_widths = false);
239 
240  /**
241  * \brief Compute net charge density.
242  *
243  * Grand-canonical Boltzmann ideal gas, consisting of all hadrons in SMASH:
244  * \f[ n_Q = \sum Q_i \frac{g_i m_i^2 T}{2\pi^2(\hbar c)^3}
245  * exp \left(\frac{\mu_B B_i + \mu_S S_i + \mu_Q Q_i}{T} \right)
246  * K_2\left( \frac{m_i}{T}\right)
247  * \f]
248  *
249  * \param[in] T temperature [GeV]
250  * \param[in] mub baryon chemical potential [GeV]
251  * \param[in] mus strangeness chemical potential [GeV]
252  * \param[in] muq charge chemical potential [GeV]
253  * \param[in] account_for_resonance_widths if false, pole masses are used;
254  * if true, then integration over spectral function is included
255  * \return net charge density density \f$n_S\f$ [fm\f$^{-3}\f$]
256  */
257  static double net_charge_density(double T, double mub, double mus, double muq,
258  bool account_for_resonance_widths = false);
259 
260  /**
261  * \brief Compute partial density of one hadron sort.
262  *
263  * Grand-canonical Boltzmann ideal gas:
264  * \f[ n = \frac{g m^2 T}{2\pi^2(\hbar c)^3}
265  * exp \left(\frac{\mu_B B + \mu_S S + \mu_Q Q_i}{T} \right)
266  * K_2\left( \frac{m}{T}\right)
267  * \f]
268  *
269  * \param[in] ptype the hadron sort, for which partial density is computed
270  * \param[in] T temperature [GeV]
271  * \param[in] mub baryon chemical potential [GeV]
272  * \param[in] mus strangeness chemical potential [GeV]
273  * \param[in] muq charge chemical potential [GeV]
274  * \param[in] account_for_resonance_widths if false, pole masses are used;
275  * if true, then integration over spectral function is included
276  * \return partial density of the given hadron sort \f$n\f$ [fm\f$^{-3}\f$]
277  */
278  static double partial_density(const ParticleType& ptype, double T, double mub,
279  double mus, double muq,
280  bool account_for_resonance_widths = false);
281  /**
282  * \brief Sample resonance mass in a thermal medium
283  *
284  * Samples mass from the distribution
285  * \f[ dN/dm \sim A(m) m^2 K_2\left( \frac{m}{T}\right) \f]
286  * For stable particles always returns pole mass.
287  * \param[in] ptype the hadron sort, for which mass is sampled
288  * \param[in] beta inverse temperature 1/T [1/GeV]
289  * \return sampled mass
290  */
291  static double sample_mass_thermal(const ParticleType& ptype, double beta);
292  /**
293  * Compute temperature and chemical potentials given energy-,
294  * net baryon-, net strangeness- and net charge density and an
295  * inital approximation.
296  *
297  * \param[in] e energy density [GeV/fm\f$^3\f$]
298  * \param[in] nb net baryon density [fm\f$^{-3}\f$]
299  * \param[in] ns net strangeness density [fm\f$^{-3}\f$]
300  * \param[in] nq net charge density [fm\f$^{-3}\f$]
301  * \param[in] initial_approximation (T [GeV], mub [GeV], mus [GeV])
302  * to use as starting point
303  * \return array of 4 values: temperature, baryon chemical potential,
304  * strange chemical potential and charge chemical potential
305  */
306  std::array<double, 4> solve_eos(double e, double nb, double ns, double nq,
307  std::array<double, 4> initial_approximation);
308 
309  /**
310  * Compute temperature and chemical potentials given energy-,
311  * net baryon-, net strangeness- and net charge density without an
312  * inital approximation.
313  *
314  * \param[in] e energy density [GeV/fm\f$^3\f$]
315  * \param[in] nb net baryon density [fm\f$^{-3}\f$]
316  * \param[in] ns net strangeness density [fm\f$^{-3}\f$]
317  * \param[in] nq net charge density [fm\f$^{-3}\f$]
318  * \return array of 4 values: temperature, baryon chemical potential
319  * and strange chemical potential and charge
320  */
321  std::array<double, 4> solve_eos(double e, double nb, double ns, double nq) {
322  return solve_eos(e, nb, ns, nq, solve_eos_initial_approximation(e, nb, nq));
323  }
324 
325  /**
326  * Compute a reasonable initial approximation for solve_eos.
327  *
328  * \param[in] e energy density [GeV/fm\f$^3\f$]
329  * \param[in] nb net baryon density [fm\f$^{-3}\f$]
330  * \param[in] nq net charge density [fm\f$^{-3}\f$]
331  * \return array of 3 values: temperature, baryon chemical potential
332  * and strange chemical potential
333  */
334  std::array<double, 4> solve_eos_initial_approximation(double e, double nb,
335  double nq);
336 
337  /**
338  * Compute strangeness chemical potential, requiring that net strangeness = 0
339  *
340  * \param[in] T temperature [GeV]
341  * \param[in] mub baryon chemical potential [GeV]
342  * \param[in] muq charge chemical potential [GeV]
343  * \return strangeness chemical potential [GeV]
344  */
345  static double mus_net_strangeness0(double T, double mub, double muq);
346 
347  /// Get the element of eos table
348  void from_table(EosTable::table_element& res, double e, double nb,
349  double nq) const {
350  eos_table_.get(res, e, nb, nq);
351  }
352 
353  /// Check if a particle belongs to the EoS
354  static bool is_eos_particle(const ParticleType& ptype) {
355  return ptype.is_hadron() && !ptype.pdgcode().is_heavy_flavor();
356  }
357 
358  /// Create an EoS table or not?
359  bool is_tabulated() const { return tabulate_; }
360 
361  /// If resonance spectral functions are taken into account
364  }
365 
366  private:
367  /// A structure for passing equation parameters to the gnu library
368  struct rparams {
369  /// energy density
370  double e;
371  /// net baryon density
372  double nb;
373  /// net strange density
374  double ns;
375  /// net charge density
376  double nq;
377  /// use pole masses of resonances, or integrate over spectral functions
379  };
380 
381  /// Another structure for passing energy density to the gnu library
382  struct eparams {
383  /// energy density
384  double edens;
385  };
386 
387  /**
388  * Function used to avoid duplications in density calculations.
389  * \param[in] m_over_T mass to temperature ratio \f$ m/T \f$
390  * \param[in] mu_over_T chemical potential to temperature ratio \f$ \mu/T \f$
391  * \return calculated \f$ (m/T)^2 exp(\mu/T) K_2(m/T) \f$
392  */
393  static double scaled_partial_density_auxiliary(double m_over_T,
394  double mu_over_T);
395  /**
396  * Compute (unnormalized) density of one hadron sort - helper functions
397  * used to reduce code duplication.
398  *
399  * \param[in] ptype the hadron sort, for which partial density is computed
400  * \param[in] beta inverse temperature [1/GeV]
401  * \param[in] mub baryon chemical potential [GeV]
402  * \param[in] mus strangeness chemical potential [GeV]
403  * \param[in] muq charge chemical potential [GeV]
404  * \param[in] account_for_width Take hadron spectral functions into account
405  * or not. When taken into account, they result in a considerable
406  * slow down.
407  * \return partial (unnormalized) density of the given hadron sort
408  * \f$n\f$ [fm\f$^{-3}\f$]
409  */
410  static double scaled_partial_density(const ParticleType& ptype, double beta,
411  double mub, double mus, double muq,
412  bool account_for_width = false);
413 
414  /// Interface EoS equations to be solved to gnu library
415  static int set_eos_solver_equations(const gsl_vector* x, void* params,
416  gsl_vector* f);
417 
418  /// \see set_eos_solver_equations()
419  static double e_equation(double T, void* params);
420 
421  /**
422  * Helpful printout, useful for debugging if gnu equation solving goes crazy
423  *
424  * \param[in] iter current value of iterator
425  * \return debug output string with iter, x and f(x) from solver
426  */
427  std::string print_solver_state(size_t iter) const;
428 
429  /// Constant factor, that appears in front of many thermodyn. expressions
430  static constexpr double prefactor_ =
431  0.5 * M_1_PI * M_1_PI / (hbarc * hbarc * hbarc);
432 
433  /// Precision of equation solving
434  static constexpr double tolerance_ = 1.e-8;
435 
436  /// Number of equations in the system of equations to be solved
437  static constexpr size_t n_equations_ = 4;
438 
439  /// EOS Table to be used
440  EosTable eos_table_ = EosTable(1.e-1, 1.e-1, 1.e-1, 90, 90, 90);
441 
442  /**
443  * Variables used by gnu equation solver. They are stored here to allocate
444  * and deallocate memory for them only once. It is expected that this class
445  * will be used for solving the EoS many times, so multiple allocations and
446  * frees are unwanted.
447  */
448  gsl_vector* x_;
449 
450  /// \see x_
451  gsl_multiroot_fsolver* solver_;
452 
453  /// Create an EoS table or not?
454  const bool tabulate_;
455 
456  /// Use pole masses of resonances or integrate over spectral functions
458 };
459 
460 namespace detail {
461 
462 /**
463  * Perform a trilinear 1st order interpolation
464  *
465  * Assume, we seek the value of a function \f$ f \f$ at position
466  * \f$(x, y, z)\f$. We know the position \f$(x, y, z)\f$ lies within a 3D cube,
467  * for which the values of the function f are known at each corner
468  * \f$(f_1, ..., f_8)\f$. We can now interpolate those values trilinearly to
469  * obtain an estimate of \f$ f \f$ at position \f$(x, y, z)\f$.
470  *
471  * For this interpolation, linear functions are used in each direction \f$x\f$,
472  * \f$y\f$, and \f$z\f$ respectively with \f$ a_x \f$, \f$ a_y \f$, and \f$ a_z
473  * \f$ as the slope parameters, e.g., \f$ f_1 + a_y \cdot (f_3 - f_1) \f$ for an
474  * approximation between the corners \f$ f_1 \f$ and \f$ f_3 \f$. For the
475  * \f$y\f$-direction, the linear functions are based on the cube's corners. The
476  * \f$x\f$-direction then uses the four obtained values from the interpolation
477  * in \f$y\f$-direction and finally the \f$z\f$-direction interpolation is based
478  * on the two values obtained by the combined interpolations in \f$x\f$- and
479  * \f$y\f$-direction. Since the position \f$(x, y, z)\f$ of the wanted value of
480  * function \f$ f \f$ is within the cube, the allowed values for \f$ a_x \f$,
481  * \f$ a_y \f$, and \f$ a_z \f$ are between 0 and 1.
482  *
483  * Positional placement of the cube:
484  * - \f$x\f$-direction: lower left front to lower right front corner
485  * \f$ (f_1 \f$ to \f$ f_2) \f$
486  * - \f$y\f$-direction: lower left front to upper left front corner
487  * \f$ (f_1 \f$ to \f$ f_3) \f$
488  * - \f$z\f$-direction: lower left front to lower left back corner
489  * \f$ (f_1 \f$ to \f$ f_5) \f$
490  *
491  * \note \f$ a_x \f$, \f$ a_y \f$, and \f$ a_z \f$ have to be chosen in a way
492  * that the linear interpolations reflect the position \f$ (x, y, z) \f$,
493  * i.e. \f$ (x, y, z) = (x_1 + a_x \cdot x_2, y_1 + a_y \cdot y_3,
494  * z_1 + a_z \cdot z_5) \f$ with \f$ (x_i, y_i, z_i) \f$ representing the
495  * coordinates of the corner at \f$ f_i \f$.
496  *
497  * \param[in] ax Fraction of the step in x-direction and used as slope parameter
498  * \param[in] ay Fraction of the step in y-direction and used as slope parameter
499  * \param[in] az Fraction of the step in z-direction and used as slope parameter
500  * \param[in] f1 Value at the lower left front corner of the cube
501  * \param[in] f2 Value at the lower right front corner of the cube
502  * \param[in] f3 Value at the upper left front corner of the cube
503  * \param[in] f4 Value at the upper right front corner of the cube
504  * \param[in] f5 Value at the lower left back corner of the cube
505  * \param[in] f6 Value at the lower right back corner of the cube
506  * \param[in] f7 Value at the upper left back corner of the cube
507  * \param[in] f8 Value at the upper right back corner of the cube
508  *
509  * \return Interpolated value
510  */
511 double interpolate_trilinear(double ax, double ay, double az, double f1,
512  double f2, double f3, double f4, double f5,
513  double f6, double f7, double f8);
514 
515 } // namespace detail
516 
517 } // namespace smash
518 
519 #endif // SRC_INCLUDE_SMASH_HADGAS_EOS_H_
A class to hold, compute and access tabulated EoS.
Definition: hadgas_eos.h:31
std::vector< table_element > table_
Storage for the tabulated equation of state.
Definition: hadgas_eos.h:96
void compile_table(HadronGasEos &eos, const std::string &eos_savefile_name="hadgas_eos.dat")
Computes the actual content of the table (for EosTable description see documentation of the construct...
Definition: hadgas_eos.cc:34
size_t index(size_t ie, size_t inb, size_t inq) const
proper index in a 1d vector, where the 3d table is stored
Definition: hadgas_eos.h:92
double dnb_
Step in net-baryon density.
Definition: hadgas_eos.h:100
size_t n_q_
Number of steps in net-charge density.
Definition: hadgas_eos.h:108
double de_
Step in energy density.
Definition: hadgas_eos.h:98
EosTable(double de, double dnb, double dq, size_t n_e, size_t n_b, size_t n_q)
Sets up a table p/T/muB/mus/muQ versus (e, nb, nq), where e - energy density, nb - net baryon density...
Definition: hadgas_eos.cc:28
size_t n_e_
Number of steps in energy density.
Definition: hadgas_eos.h:104
double dq_
Step in net-charge density.
Definition: hadgas_eos.h:102
void get(table_element &res, double e, double nb, double nq) const
Obtain interpolated p/T/muB/muS/muQ from the tabulated equation of state given energy density,...
Definition: hadgas_eos.cc:162
size_t n_nb_
Number of steps in net-baryon density.
Definition: hadgas_eos.h:106
Class to handle the equation of state (EoS) of the hadron gas, consisting of all hadrons included in ...
Definition: hadgas_eos.h:124
gsl_multiroot_fsolver * solver_
Definition: hadgas_eos.h:451
static double net_charge_density(double T, double mub, double mus, double muq, bool account_for_resonance_widths=false)
Compute net charge density.
Definition: hadgas_eos.cc:369
static constexpr double prefactor_
Constant factor, that appears in front of many thermodyn. expressions.
Definition: hadgas_eos.h:430
static double partial_density(const ParticleType &ptype, double T, double mub, double mus, double muq, bool account_for_resonance_widths=false)
Compute partial density of one hadron sort.
Definition: hadgas_eos.cc:273
static double sample_mass_thermal(const ParticleType &ptype, double beta)
Sample resonance mass in a thermal medium.
Definition: hadgas_eos.cc:388
std::array< double, 4 > solve_eos(double e, double nb, double ns, double nq, std::array< double, 4 > initial_approximation)
Compute temperature and chemical potentials given energy-, net baryon-, net strangeness- and net char...
Definition: hadgas_eos.cc:590
std::array< double, 4 > solve_eos(double e, double nb, double ns, double nq)
Compute temperature and chemical potentials given energy-, net baryon-, net strangeness- and net char...
Definition: hadgas_eos.h:321
bool is_tabulated() const
Create an EoS table or not?
Definition: hadgas_eos.h:359
static double scaled_partial_density_auxiliary(double m_over_T, double mu_over_T)
Function used to avoid duplications in density calculations.
Definition: hadgas_eos.cc:226
EosTable eos_table_
EOS Table to be used.
Definition: hadgas_eos.h:440
gsl_vector * x_
Variables used by gnu equation solver.
Definition: hadgas_eos.h:448
void from_table(EosTable::table_element &res, double e, double nb, double nq) const
Get the element of eos table.
Definition: hadgas_eos.h:348
static double mus_net_strangeness0(double T, double mub, double muq)
Compute strangeness chemical potential, requiring that net strangeness = 0.
Definition: hadgas_eos.cc:460
bool account_for_resonance_widths() const
If resonance spectral functions are taken into account.
Definition: hadgas_eos.h:362
static double density(double T, double mub, double mus, double muq, bool account_for_resonance_widths=false)
Compute particle number density.
Definition: hadgas_eos.cc:313
const bool tabulate_
Create an EoS table or not?
Definition: hadgas_eos.h:454
static bool is_eos_particle(const ParticleType &ptype)
Check if a particle belongs to the EoS.
Definition: hadgas_eos.h:354
static int set_eos_solver_equations(const gsl_vector *x, void *params, gsl_vector *f)
Interface EoS equations to be solved to gnu library.
Definition: hadgas_eos.cc:484
std::string print_solver_state(size_t iter) const
Helpful printout, useful for debugging if gnu equation solving goes crazy.
Definition: hadgas_eos.cc:640
static double e_equation(double T, void *params)
Definition: hadgas_eos.cc:505
static double net_baryon_density(double T, double mub, double mus, double muq, bool account_for_resonance_widths=false)
Compute net baryon density.
Definition: hadgas_eos.cc:331
static double energy_density(double T, double mub, double mus, double muq)
Compute energy density.
Definition: hadgas_eos.cc:284
static double net_strange_density(double T, double mub, double mus, double muq, bool account_for_resonance_widths=false)
Compute net strangeness density.
Definition: hadgas_eos.cc:350
const bool account_for_resonance_widths_
Use pole masses of resonances or integrate over spectral functions.
Definition: hadgas_eos.h:457
std::array< double, 4 > solve_eos_initial_approximation(double e, double nb, double nq)
Compute a reasonable initial approximation for solve_eos.
Definition: hadgas_eos.cc:510
static constexpr size_t n_equations_
Number of equations in the system of equations to be solved.
Definition: hadgas_eos.h:437
HadronGasEos(bool tabulate, bool account_for_widths)
Constructor of HadronGasEos.
Definition: hadgas_eos.cc:200
static double pressure(double T, double mub, double mus, double muq, bool account_for_resonance_widths=false)
Compute pressure .
Definition: hadgas_eos.h:194
static constexpr double tolerance_
Precision of equation solving.
Definition: hadgas_eos.h:434
static double scaled_partial_density(const ParticleType &ptype, double beta, double mub, double mus, double muq, bool account_for_width=false)
Compute (unnormalized) density of one hadron sort - helper functions used to reduce code duplication.
Definition: hadgas_eos.cc:240
Particle type contains the static properties of a particle species.
Definition: particletype.h:100
PdgCode pdgcode() const
Definition: particletype.h:159
bool is_hadron() const
Definition: particletype.h:200
bool is_heavy_flavor() const
Definition: pdgcode.h:617
Collection of useful constants that are known at compile time.
double interpolate_trilinear(double ax, double ay, double az, double f1, double f2, double f3, double f4, double f5, double f6, double f7, double f8)
Perform a trilinear 1st order interpolation.
Definition: hadgas_eos.cc:658
T beta(T a, T b)
Draws a random number from a beta-distribution, where probability density of is .
Definition: random.h:373
Definition: action.h:24
constexpr double hbarc
GeV <-> fm conversion factor.
Definition: constants.h:29
Define the data structure for one element of the table.
Definition: hadgas_eos.h:57
double mub
Net baryochemical potential.
Definition: hadgas_eos.h:63
double muq
Net charge chemical potential.
Definition: hadgas_eos.h:67
double T
Temperature.
Definition: hadgas_eos.h:61
double mus
Net strangeness potential.
Definition: hadgas_eos.h:65
Another structure for passing energy density to the gnu library.
Definition: hadgas_eos.h:382
double edens
energy density
Definition: hadgas_eos.h:384
A structure for passing equation parameters to the gnu library.
Definition: hadgas_eos.h:368
double e
energy density
Definition: hadgas_eos.h:370
double ns
net strange density
Definition: hadgas_eos.h:374
double nq
net charge density
Definition: hadgas_eos.h:376
double nb
net baryon density
Definition: hadgas_eos.h:372
bool account_for_width
use pole masses of resonances, or integrate over spectral functions
Definition: hadgas_eos.h:378