Thermal-FIST  1.3
Package for hadron resonance gas model applications
cpc1-HRG-TDep.cpp
Go to the documentation of this file.
1 #include <string.h>
2 #include <fstream>
3 #include <iostream>
4 #include <iomanip>
5 #include <ctime>
6 #include <cstdio>
7 
8 #include "HRGBase.h"
9 #include "HRGEV.h"
10 #include "HRGFit.h"
11 #include "HRGVDW.h"
12 
13 #include "ThermalFISTConfig.h"
14 
15 using namespace std;
16 
17 #ifdef ThermalFIST_USENAMESPACE
18 using namespace thermalfist;
19 #endif
20 
21 
22 // Temperature dependence of HRG thermodynamics at \mu = 0
23 // Three variants of the HRG model:
24 // 1. Ideal HRG: <config> = 0
25 // 2. EV-HRG with constant radius parameter r = 0.3 fm for all hadrons (as in 1412.5478): <config> = 1
26 // 3. QvdW-HRG with a and b for baryons only, fixed to nuclear ground state (as in 1609.03975): <config> = 2
27 // Usage: cpc1HRGTDep <config>
28 int main(int argc, char *argv[])
29 {
30  // Particle list file
31  // Here we will use the list from THERMUS-2.3, for comparing the results with THERMUS-2.3
32  string listname = string(ThermalFIST_INPUT_FOLDER) + "/list/thermus23/list.dat";
33 
34  // Alternative: use the default PDG2014 list
35  //string listname = string(ThermalFIST_INPUT_FOLDER) + "/list/PDG2014/list.dat";
36 
37  // Create the hadron list instance and read the list from file
38  ThermalParticleSystem TPS(listname);
39 
40  // Which variant of the HRG model to use
41  int config = 0;
42 
43  // Read config from command line
44  if (argc > 1)
45  config = atoi(argv[1]);
46 
47 
48  string modeltype; // For output
49 
50 
51  // Pointer to the thermal model instance used in calculations
52  ThermalModelBase *model;
53 
54 
55 
56  if (config == 0) // Ideal HRG
57  {
58  model = new ThermalModelIdeal(&TPS);
59 
60  printf("#Calculating thermodynamics at \\mu = 0 in Id-HRG model\n");
61 
62  modeltype = "Id-HRG";
63  }
64  else if (config == 1) // EV-HRG, r = 0.3 fm, to reproduce 1412.5478
65  {
66  model = new ThermalModelEVDiagonal(&TPS);
67  // Set r = 0.3 fm for each hadron in the list
68  double rad = 0.3;
69  for (int i = 0; i < model->TPS()->ComponentsNumber(); ++i)
70  model->SetRadius(i, rad);
71 
72  printf("#Calculating thermodynamics at \\mu = 0 in EV-HRG model with r = %lf fm\n", rad);
73 
74  modeltype = "EV-HRG";
75  }
76  else if (config == 2) // QvdW-HRG, to reproduce 1609.03975
77  {
78  model = new ThermalModelVDWFull(&TPS);
79 
80  // vdW parameters, for baryon-baryon, antibaryon-antibaryon ONLY, otherwise zero
81  double a = 0.329; // In GeV*fm3
82  double b = 3.42; // In fm3
83 
84  // Iterate over all pairs of hadron species and set a and b
85  for (int i = 0; i < model->TPS()->ComponentsNumber(); ++i) {
86  for (int j = 0; j < model->TPS()->ComponentsNumber(); ++j) {
87  int B1 = model->TPS()->Particle(i).BaryonCharge(); // Baryon number of 1st species
88  int B2 = model->TPS()->Particle(j).BaryonCharge(); // Baryon number of 2nd species
89 
90  if ((B1 > 0 && B2 > 0) || (B1 < 0 && B2 < 0)) // baryon-baryon or antibaryon-antibaryon
91  {
92  model->SetAttraction(i, j, a); // Set QvdW repulsion
93  model->SetVirial(i, j, b); // Set QvdW attraction
94  }
95  else // no vdW interactions for meson-meson, meson-baryon or baryon-anitbaryon pairs
96  {
97  model->SetAttraction(i, j, 0.);
98  model->SetVirial(i, j, 0.);
99  }
100  }
101  }
102 
103  printf("#Calculating thermodynamics at \\mu = 0 in QvdW-HRG model\n");
104 
105  modeltype = "QvdW-HRG";
106  }
107  else // Ideal HRG by default
108  {
109  model = new ThermalModelIdeal(&TPS);
110 
111  modeltype = "Id-HRG";
112  }
113 
114  // Use quantum statistics
115  model->SetStatistics(true);
116  //model->SetStatistics(false);
117 
118  // Use mass integration over Breit-Wigner shapes in +-2Gamma interval, as in THERMUS
119  model->SetUseWidth(ThermalParticle::BWTwoGamma);
120  //model->SetUseWidth(ThermalParticle::ZeroWidth);
121 
122  // Set chemical potentials to zero
123  model->SetBaryonChemicalPotential(0.0);
124  model->SetElectricChemicalPotential(0.0);
126  model->SetCharmChemicalPotential(0.0);
127  model->FillChemicalPotentials();
128 
129 
130  // Prepare output
131  char tmpc[1000];
132  sprintf(tmpc, "cpc1.%s.TDep.out", modeltype.c_str());
133  FILE *fout = fopen(tmpc, "w");
134 
135  // Output to screen
136  printf("%15s%15s%15s%15s%15s%15s%15s\n",
137  "T[MeV]", // Temperature
138  "p/T^4", // Scaled pressure
139  "e/T^4", // Scaled energy density
140  "s/T^3", // Scaled entropy density
141  "chi2B", // Baryon number susceptibility
142  "chi4B", // 4th order baryon cumulant
143  "chi2B-chi4B" // Difference of 2nd and 4th order baryon susceptibilities
144  );
145 
146  // Output to file
147  fprintf(fout, "%15s%15s%15s%15s%15s%15s%15s\n",
148  "T[MeV]", // Temperature
149  "p/T^4", // Scaled pressure
150  "e/T^4", // Scaled energy density
151  "s/T^3", // Scaled entropy density
152  "chi2B", // Baryon number susceptibility
153  "chi4B", // 4th order baryon cumulant
154  "chi2B-chi4B" // Difference of 2nd and 4th order baryon susceptibilities
155  );
156 
157 
158  double wt1 = get_wall_time(); // Timing
159 
160  int iters = 0; // Number of data points
161 
162  // Temperature interval, in GeV
163  double Tmin = 0.020;
164  double Tmax = 0.2001;
165  double dT = 0.001;
166 
167  for (double T = Tmin; T <= Tmax; T += dT) {
168  model->SetTemperature(T);
169 
170  // Calculates densities, solves all necessary transcendental equations, if necessary
171  model->CalculateDensities();
172 
173  // Output temperature, scale to get the unit of MeV
174  printf("%15lf", T * 1000.);
175  fprintf(fout, "%15lf", T * 1000.);
176 
177  // Pressure, in [GeV/fm3]
178  double p = model->CalculatePressure();
179  // Scaled pressure, pow(xMath::GeVtoifm(), 3) needed to make it dimensionless
180  double pT4 = p / pow(T, 4) / pow(xMath::GeVtoifm(), 3);
181  printf("%15lf", pT4);
182  fprintf(fout, "%15lf", pT4);
183 
184  // Energy density
185  double e = model->CalculateEnergyDensity();
186  double eT4 = e / pow(T, 4) / pow(xMath::GeVtoifm(), 3);
187  printf("%15lf", eT4);
188  fprintf(fout, "%15lf", eT4);
189 
190  // Entropy density
191  double s = model->CalculateEntropyDensity();
192  double sT3 = s / pow(T, 3) / pow(xMath::GeVtoifm(), 3);
193  printf("%15lf", sT3);
194  fprintf(fout, "%15lf", sT3);
195 
196 
197  // Baryon number fluctuations
198 
199  // Vector containing baryon charge of each species
200  vector<double> baryon_charges;
201  for (int i = 0; i < model->TPS()->ComponentsNumber(); ++i) {
202  baryon_charges.push_back(static_cast<double>(model->TPS()->Particle(i).BaryonCharge()));
203  }
204 
205  // Calculate baryon number cumulants up to 4th order
206  vector<double> chiB = model->CalculateChargeFluctuations(baryon_charges, 4);
207 
208  if (chiB.size() >= 4) {
209  // chi2B
210  printf("%15E", chiB[1]);
211  fprintf(fout, "%15E", chiB[1]);
212 
213  // chi4B
214  printf("%15E", chiB[3]);
215  fprintf(fout, "%15E", chiB[3]);
216 
217  // chi2B - chi4B
218  printf("%15E", chiB[1] - chiB[3]);
219  fprintf(fout, "%15E", chiB[1] - chiB[3]);
220  }
221 
222  printf("\n");
223  fprintf(fout, "\n");
224 
225  iters++;
226 
227  }
228 
229  fclose(fout);
230 
231  delete model;
232 
233 
234  double wt2 = get_wall_time();
235 
236  printf("%30s %lf s\n", "Running time:", (wt2 - wt1));
237  printf("%30s %lf s\n", "Time per single calculation:", (wt2 - wt1) / iters);
238 
239  return 0;
240 }
241 
Abstract base class for an HRG model implementation.
virtual void SetStrangenessChemicalPotential(double muS)
Set the strangeness chemical potential.
double GeVtoifm()
A constant to transform GeV into fm .
Definition: xMath.h:27
virtual void SetElectricChemicalPotential(double muQ)
Set the electric chemical potential.
virtual void SetBaryonChemicalPotential(double muB)
Set the baryon chemical potential.
const ThermalParticle & Particle(int id) const
ThermalParticle object corresponding to particle species with a provided 0-based index.
virtual void SetStatistics(bool stats)
void SetUseWidth(bool useWidth)
Sets whether finite resonance widths are used. Deprecated.
Class implementing the diagonal excluded-volume model.
Class containing the particle list.
virtual void SetRadius(double)
Set the same excluded volume radius parameter for all species.
int ComponentsNumber() const
Number of different particle species in the list.
virtual void SetTemperature(double T)
Set the temperature.
virtual void SetVirial(int, int, double)
Set the excluded volume coefficient .
virtual void FillChemicalPotentials()
Sets the chemical potentials of all particles.
int BaryonCharge() const
Particle&#39;s baryon number.
double get_wall_time()
Definition: Utility.cpp:187
virtual double CalculateEnergyDensity()=0
virtual void SetCharmChemicalPotential(double muC)
Set the charm chemical potential.
int main(int argc, char *argv[])
virtual double CalculateEntropyDensity()=0
virtual void CalculateDensities()
Calculates the primordial and total (after decays) densities of all species.
virtual double CalculatePressure()=0
Implementation of the equation of state functions.
virtual std::vector< double > CalculateChargeFluctuations(const std::vector< double > &chgs, int order=4)
Calculates fluctuations (diagonal susceptibilities) of an arbitrary "conserved" charge.
virtual void SetAttraction(int, int, double)
Set the vdW mean field attraction coefficient .
Class implementing the Ideal HRG model.
ThermalModelVDW ThermalModelVDWFull
For backward compatibility.
The main namespace where all classes and functions of the Thermal-FIST library reside.
ThermalParticleSystem * TPS()