Version: SMASH-1.7
hadgas_eos.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (c) 2016-
4  * SMASH Team
5  *
6  * GNU General Public License (GPLv3 or later)
7  *
8  */
9 #ifndef SRC_INCLUDE_HADGAS_EOS_H_
10 #define SRC_INCLUDE_HADGAS_EOS_H_
11 
12 #include <gsl/gsl_multiroots.h>
13 #include <gsl/gsl_roots.h>
14 #include <gsl/gsl_vector.h>
15 
16 #include <array>
17 #include <string>
18 #include <vector>
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 
32 class EosTable {
33  public:
53  EosTable(double de, double dnb, size_t n_e, size_t n_b);
55  struct table_element {
57  double p;
59  double T;
61  double mub;
63  double mus;
64  };
73  void compile_table(HadronGasEos& eos,
74  const std::string& eos_savefile_name = "hadgas_eos.dat");
83  void get(table_element& res, double e, double nb) const;
84 
85  private:
87  size_t index(size_t ie, size_t inb) const { return ie * n_nb_ + inb; }
89  std::vector<table_element> table_;
91  double de_;
93  double dnb_;
95  size_t n_e_;
97  size_t n_nb_;
98 };
99 
113  public:
131  HadronGasEos(bool tabulate, bool account_for_widths);
132  ~HadronGasEos();
133 
149  static double energy_density(double T, double mub, double mus);
150 
167  static double density(double T, double mub, double mus,
168  bool account_for_resonance_widths = false);
169 
180  static double pressure(double T, double mub, double mus,
181  bool account_for_resonance_widths = false) {
182  return T * density(T, mub, mus, account_for_resonance_widths);
183  }
184 
201  static double net_baryon_density(double T, double mub, double mus,
202  bool account_for_resonance_widths = false);
203 
220  static double net_strange_density(double T, double mub, double mus,
221  bool account_for_resonance_widths = false);
222 
240  static double partial_density(const ParticleType& ptype, double T, double mub,
241  double mus,
242  bool account_for_resonance_widths = false);
253  static double sample_mass_thermal(const ParticleType& ptype, double beta);
266  std::array<double, 3> solve_eos(double e, double nb, double ns,
267  std::array<double, 3> initial_approximation);
268 
279  std::array<double, 3> solve_eos(double e, double nb, double ns) {
280  return solve_eos(e, nb, ns, solve_eos_initial_approximation(e, nb));
281  }
282 
291  std::array<double, 3> solve_eos_initial_approximation(double e, double nb);
292 
300  static double mus_net_strangeness0(double T, double mub);
301 
303  void from_table(EosTable::table_element& res, double e, double nb) const {
304  eos_table_.get(res, e, nb);
305  }
306 
308  static bool is_eos_particle(const ParticleType& ptype) {
309  return ptype.is_hadron() && ptype.pdgcode().charmness() == 0;
310  }
311 
313  bool is_tabulated() const { return tabulate_; }
314 
317  return account_for_resonance_widths_;
318  }
319 
320  private:
322  struct rparams {
324  double e;
326  double nb;
328  double ns;
331  };
332 
334  struct eparams {
336  double edens;
337  };
338 
345  static double scaled_partial_density_auxiliary(double m_over_T,
346  double mu_over_T);
361  static double scaled_partial_density(const ParticleType& ptype, double beta,
362  double mub, double mus,
363  bool account_for_width = false);
364 
366  static int set_eos_solver_equations(const gsl_vector* x, void* params,
367  gsl_vector* f);
368 
370  static double e_equation(double T, void* params);
371 
378  std::string print_solver_state(size_t iter) const;
379 
381  static constexpr double prefactor_ =
382  0.5 * M_1_PI * M_1_PI / (hbarc * hbarc * hbarc);
383 
385  static constexpr double tolerance_ = 1.e-8;
386 
388  static constexpr size_t n_equations_ = 3;
389 
391  EosTable eos_table_ = EosTable(1.e-2, 1.e-2, 900, 900);
392 
399  gsl_vector* x_;
400 
402  gsl_multiroot_fsolver* solver_;
403 
405  const bool tabulate_;
406 
409 };
410 
411 } // namespace smash
412 
413 #endif // SRC_INCLUDE_HADGAS_EOS_H_
A class to hold, compute and access tabulated EoS.
Definition: hadgas_eos.h:32
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
double mub
Net baryochemical potential.
Definition: hadgas_eos.h:61
Class to handle the equation of state (EoS) of the hadron gas, consisting of all hadrons included int...
Definition: hadgas_eos.h:112
Collection of useful constants that are known at compile time.
double mus
Net strangeness potential.
Definition: hadgas_eos.h:63
double T
Temperature.
Definition: hadgas_eos.h:59
void from_table(EosTable::table_element &res, double e, double nb) const
Get the element of eos table.
Definition: hadgas_eos.h:303
double dnb_
Step in net-baryon density.
Definition: hadgas_eos.h:93
EosTable(double de, double dnb, size_t n_e, size_t n_b)
Sets up a table p/T/muB/mus versus (e, nb), where e is energy density, nb is net baryon density...
Definition: hadgas_eos.cc:29
static bool is_eos_particle(const ParticleType &ptype)
Check if a particle belongs to the EoS.
Definition: hadgas_eos.h:308
constexpr double hbarc
GeV <-> fm conversion factor.
Definition: constants.h:25
bool is_tabulated() const
Create an EoS table or not?
Definition: hadgas_eos.h:313
double e
energy density
Definition: hadgas_eos.h:324
bool is_hadron() const
Definition: particletype.h:194
size_t n_nb_
Number of steos in net-baryon density.
Definition: hadgas_eos.h:97
int charmness() const
Definition: pdgcode.h:453
size_t n_e_
Number of steps in energy density.
Definition: hadgas_eos.h:95
bool account_for_width
use pole masses of resonances, or integrate over spectral functions
Definition: hadgas_eos.h:330
double edens
energy density
Definition: hadgas_eos.h:336
gsl_multiroot_fsolver * solver_
Definition: hadgas_eos.h:402
const bool account_for_resonance_widths_
Use pole masses of resonances or integrate over spectral functions.
Definition: hadgas_eos.h:408
Particle type contains the static properties of a particle species.
Definition: particletype.h:97
double nb
net baryon density
Definition: hadgas_eos.h:326
A structure for passing equation parameters to the gnu library.
Definition: hadgas_eos.h:322
size_t index(size_t ie, size_t inb) const
proper index in a 1d vector, where the 2d table is stored
Definition: hadgas_eos.h:87
static double pressure(double T, double mub, double mus, bool account_for_resonance_widths=false)
Compute pressure .
Definition: hadgas_eos.h:180
Define the data structure for one element of the table.
Definition: hadgas_eos.h:55
gsl_vector * x_
Variables used by gnu equation solver.
Definition: hadgas_eos.h:399
double ns
net strange density
Definition: hadgas_eos.h:328
PdgCode pdgcode() const
Definition: particletype.h:156
const bool tabulate_
Create an EoS table or not?
Definition: hadgas_eos.h:405
Another structure for passing energy density to the gnu library.
Definition: hadgas_eos.h:334
bool account_for_resonance_widths() const
If resonance spectral functions are taken into account.
Definition: hadgas_eos.h:316
double de_
Step in energy density.
Definition: hadgas_eos.h:91
std::vector< table_element > table_
Storage for the tabulated equation of state.
Definition: hadgas_eos.h:89
std::array< double, 3 > solve_eos(double e, double nb, double ns)
Compute temperature and chemical potentials given energy-, net baryon- and net strangeness density wi...
Definition: hadgas_eos.h:279
T beta(T a, T b)
Draws a random number from a beta-distribution, where probability density of is .
Definition: random.h:329
Definition: action.h:24