Version: SMASH-1.8
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 
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_
smash::HadronGasEos
Class to handle the equation of state (EoS) of the hadron gas, consisting of all hadrons included int...
Definition: hadgas_eos.h:112
smash
Definition: action.h:24
smash::EosTable::table_element::T
double T
Temperature.
Definition: hadgas_eos.h:59
smash::HadronGasEos::solve_eos
std::array< double, 3 > solve_eos(double e, double nb, double ns, std::array< double, 3 > initial_approximation)
Compute temperature and chemical potentials given energy-, net baryon-, net strangeness density and a...
Definition: hadgas_eos.cc:506
smash::HadronGasEos::from_table
void from_table(EosTable::table_element &res, double e, double nb) const
Get the element of eos table.
Definition: hadgas_eos.h:303
smash::HadronGasEos::eos_table_
EosTable eos_table_
EOS Table to be used.
Definition: hadgas_eos.h:391
smash::HadronGasEos::density
static double density(double T, double mub, double mus, bool account_for_resonance_widths=false)
Compute particle number density.
Definition: hadgas_eos.cc:272
smash::HadronGasEos::partial_density
static double partial_density(const ParticleType &ptype, double T, double mub, double mus, bool account_for_resonance_widths=false)
Compute partial density of one hadron sort.
Definition: hadgas_eos.cc:234
smash::HadronGasEos::solve_eos
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
smash::HadronGasEos::solver_
gsl_multiroot_fsolver * solver_
Definition: hadgas_eos.h:402
smash::HadronGasEos::net_strange_density
static double net_strange_density(double T, double mub, double mus, bool account_for_resonance_widths=false)
Compute net strangeness density.
Definition: hadgas_eos.cc:307
smash::HadronGasEos::eparams
Another structure for passing energy density to the gnu library.
Definition: hadgas_eos.h:334
smash::HadronGasEos::scaled_partial_density_auxiliary
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:188
smash::EosTable::index
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
smash::HadronGasEos::rparams::account_for_width
bool account_for_width
use pole masses of resonances, or integrate over spectral functions
Definition: hadgas_eos.h:330
smash::HadronGasEos::solve_eos_initial_approximation
std::array< double, 3 > solve_eos_initial_approximation(double e, double nb)
Compute a reasonable initial approximation for solve_eos.
Definition: hadgas_eos.cc:443
smash::HadronGasEos::tolerance_
static constexpr double tolerance_
Precision of equation solving.
Definition: hadgas_eos.h:385
smash::EosTable::n_e_
size_t n_e_
Number of steps in energy density.
Definition: hadgas_eos.h:95
smash::HadronGasEos::e_equation
static double e_equation(double T, void *params)
Definition: hadgas_eos.cc:438
smash::EosTable::dnb_
double dnb_
Step in net-baryon density.
Definition: hadgas_eos.h:93
smash::EosTable::table_element::p
double p
Pressure.
Definition: hadgas_eos.h:57
smash::HadronGasEos::prefactor_
static constexpr double prefactor_
Constant factor, that appears in front of many thermodyn. expressions.
Definition: hadgas_eos.h:381
smash::HadronGasEos::account_for_resonance_widths_
const bool account_for_resonance_widths_
Use pole masses of resonances or integrate over spectral functions.
Definition: hadgas_eos.h:408
smash::HadronGasEos::HadronGasEos
HadronGasEos(bool tabulate, bool account_for_widths)
Constructor of HadronGasEos.
Definition: hadgas_eos.cc:162
smash::ParticleType::pdgcode
PdgCode pdgcode() const
Definition: particletype.h:156
smash::EosTable::table_element::mub
double mub
Net baryochemical potential.
Definition: hadgas_eos.h:61
smash::hbarc
constexpr double hbarc
GeV <-> fm conversion factor.
Definition: constants.h:25
smash::EosTable::EosTable
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:30
smash::random::beta
T beta(T a, T b)
Draws a random number from a beta-distribution, where probability density of is .
Definition: random.h:329
smash::HadronGasEos::print_solver_state
std::string print_solver_state(size_t iter) const
Helpful printout, useful for debugging if gnu equation solving goes crazy.
Definition: hadgas_eos.cc:553
smash::HadronGasEos::is_tabulated
bool is_tabulated() const
Create an EoS table or not?
Definition: hadgas_eos.h:313
smash::EosTable::n_nb_
size_t n_nb_
Number of steos in net-baryon density.
Definition: hadgas_eos.h:97
smash::HadronGasEos::rparams::ns
double ns
net strange density
Definition: hadgas_eos.h:328
smash::HadronGasEos::x_
gsl_vector * x_
Variables used by gnu equation solver.
Definition: hadgas_eos.h:399
smash::HadronGasEos::sample_mass_thermal
static double sample_mass_thermal(const ParticleType &ptype, double beta)
Sample resonance mass in a thermal medium.
Definition: hadgas_eos.cc:325
smash::HadronGasEos::account_for_resonance_widths
bool account_for_resonance_widths() const
If resonance spectral functions are taken into account.
Definition: hadgas_eos.h:316
smash::HadronGasEos::rparams::e
double e
energy density
Definition: hadgas_eos.h:324
smash::ParticleType::is_hadron
bool is_hadron() const
Definition: particletype.h:194
smash::HadronGasEos::scaled_partial_density
static double scaled_partial_density(const ParticleType &ptype, double beta, double mub, double mus, bool account_for_width=false)
Compute (unnormalized) density of one hadron sort - helper functions used to reduce code duplication.
Definition: hadgas_eos.cc:202
smash::ParticleType
Definition: particletype.h:97
smash::HadronGasEos::net_baryon_density
static double net_baryon_density(double T, double mub, double mus, bool account_for_resonance_widths=false)
Compute net baryon density.
Definition: hadgas_eos.cc:289
smash::HadronGasEos::tabulate_
const bool tabulate_
Create an EoS table or not?
Definition: hadgas_eos.h:405
smash::EosTable::get
void get(table_element &res, double e, double nb) const
Obtain interpolated p/T/muB/muS from the tabulated equation of state given energy density and net bar...
Definition: hadgas_eos.cc:137
particletype.h
smash::EosTable::table_element::mus
double mus
Net strangeness potential.
Definition: hadgas_eos.h:63
smash::HadronGasEos::~HadronGasEos
~HadronGasEos()
Definition: hadgas_eos.cc:183
smash::HadronGasEos::mus_net_strangeness0
static double mus_net_strangeness0(double T, double mub)
Compute strangeness chemical potential, requiring that net strangeness = 0.
Definition: hadgas_eos.cc:396
smash::EosTable::table_element
Define the data structure for one element of the table.
Definition: hadgas_eos.h:55
smash::HadronGasEos::set_eos_solver_equations
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:420
smash::HadronGasEos::rparams::nb
double nb
net baryon density
Definition: hadgas_eos.h:326
smash::PdgCode::charmness
int charmness() const
Definition: pdgcode.h:450
smash::HadronGasEos::n_equations_
static constexpr size_t n_equations_
Number of equations in the system of equations to be solved.
Definition: hadgas_eos.h:388
smash::HadronGasEos::is_eos_particle
static bool is_eos_particle(const ParticleType &ptype)
Check if a particle belongs to the EoS.
Definition: hadgas_eos.h:308
constants.h
smash::EosTable::de_
double de_
Step in energy density.
Definition: hadgas_eos.h:91
smash::EosTable
A class to hold, compute and access tabulated EoS.
Definition: hadgas_eos.h:32
smash::EosTable::table_
std::vector< table_element > table_
Storage for the tabulated equation of state.
Definition: hadgas_eos.h:89
smash::HadronGasEos::eparams::edens
double edens
energy density
Definition: hadgas_eos.h:336
smash::HadronGasEos::pressure
static double pressure(double T, double mub, double mus, bool account_for_resonance_widths=false)
Compute pressure .
Definition: hadgas_eos.h:180
smash::HadronGasEos::rparams
A structure for passing equation parameters to the gnu library.
Definition: hadgas_eos.h:322
smash::EosTable::compile_table
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:35
smash::HadronGasEos::energy_density
static double energy_density(double T, double mub, double mus)
Compute energy density.
Definition: hadgas_eos.cc:244