Thermal-FIST  1.3
Package for hadron resonance gas model applications
ThermalModelEVCanonicalStrangeness.cpp
Go to the documentation of this file.
1 /*
2  * Thermal-FIST package
3  *
4  * Copyright (c) 2014-2019 Volodymyr Vovchenko
5  *
6  * GNU General Public License (GPLv3 or later)
7  */
9 
10 #include <iostream>
11 #include <iomanip>
12 #include <fstream>
13 #include <sstream>
14 
15 #include "HRGBase/xMath.h"
17 
18 using namespace std;
19 
20 namespace thermalfist {
21 
22  ThermalModelEVCanonicalStrangeness::ThermalModelEVCanonicalStrangeness(ThermalParticleSystem *TPS_, const ThermalModelParameters& params) :
24  {
25  m_modelEV = NULL;
26  m_v.resize(m_TPS->Particles().size());
27  m_TAG = "ThermalModelEVCanonicalStrangeness";
28 
29  m_Ensemble = SCE;
31  }
32 
34  {
35  ClearModelEV();
36  }
37 
39  if (m_modelEV == NULL)
41 
42  for (int i = 0; i < m_TPS->ComponentsNumber(); ++i) {
43  m_densitiesGCE[i] = /*m_Suppression **/ m_TPS->Particles()[i].Density(m_Parameters, IdealGasFunctions::ParticleDensity, m_UseWidth, m_Chem[i] - m_v[i] * m_PNS);
44  }
45 
46  m_GCECalculated = true;
47  }
48 
50  if (m_modelEV == NULL)
52 
53  m_energydensitiesGCE.resize(m_densitiesGCE.size());
54  for (int i = 0; i < m_TPS->ComponentsNumber(); ++i) {
55  m_energydensitiesGCE[i] = /*m_Suppression **/ m_TPS->Particles()[i].Density(m_Parameters, IdealGasFunctions::EnergyDensity, m_UseWidth, m_Chem[i] - m_v[i] * m_PNS);
56  }
57  }
58 
60  {
61  if (m_modelEV == NULL)
63 
64  m_pressuresGCE.resize(m_densitiesGCE.size());
65  for (int i = 0; i < m_TPS->ComponentsNumber(); ++i) {
67  }
68  }
69 
70 
73 
74  m_energydensitiesGCE.resize(0);
75  m_pressuresGCE.resize(0);
76 
78 
80 
82 
83  for (int i = 0; i < m_TPS->ComponentsNumber(); ++i) {
84  if (m_StrMap.count(-m_TPS->Particles()[i].Strangeness()))
85  m_densities[i] = m_Suppression * (m_Zsum[m_StrMap[-m_TPS->Particles()[i].Strangeness()]] / m_Zsum[m_StrMap[0]]) * m_densitiesGCE[i];
86  }
87 
88  m_EVS = 0.;
89  for (int i = 0; i < m_TPS->ComponentsNumber(); ++i) {
90  if (m_TPS->Particles()[i].Strangeness() != 0)
91  m_EVS += m_v[i] * m_densities[i] * m_Parameters.SVc;
92  }
93 
94  //printf("%15lf%15lf\n", CalculatePressure(), m_PNS);
95  double tP = CalculatePressure();
96  printf("EV-SCE calculation: The following two parameters must be much smaller than unity. Otherwise we are in trouble...\n");
97  printf("%20s%lf\n%20s%lf\n", "PS/P = ", (tP - m_PNS) / tP, "EVS/(V-EVNS) = ", m_EVS / (m_Parameters.SVc - m_EVNS));
98 
99  m_Calculated = true;
101  //m_LastCalculationSuccessFlag = true;
102  }
103 
104 
105 
107  if (!m_Calculated)
109 
110  if (m_energydensitiesGCE.size() == 0)
112 
113  double ret = 0.;
114  for (int i = 0; i < m_TPS->ComponentsNumber(); ++i)
115  ret += m_Suppression * (m_Zsum[m_StrMap[-m_TPS->Particles()[i].Strangeness()]] / m_Zsum[m_StrMap[0]]) * m_energydensitiesGCE[i];
116  return ret;
117  }
118 
119 
121  double ret = log(m_Zsum[m_StrMap[0]]) / m_Parameters.SVc;
122 
123  if (m_energydensitiesGCE.size() == 0)
125 
126  for (int i = 0; i < m_TPS->ComponentsNumber(); ++i)
127  if (m_TPS->Particles()[i].Strangeness() != 0) {
128  if (m_StrMap.count(-m_TPS->Particles()[i].Strangeness()))
129  ret += m_Suppression * (m_Zsum[m_StrMap[-m_TPS->Particles()[i].Strangeness()]] / m_Zsum[m_StrMap[0]]) * ((m_energydensitiesGCE[i] - (m_Chem[i] - m_v[i] * m_PNS) * m_densitiesGCE[i]) / m_Parameters.T);
130  }
131  else {
133  }
134  return ret;
135  }
136 
137 
139  double ret = 0.;
140  if (m_pressuresGCE.size() == 0)
142  for (int i = 0; i < m_TPS->ComponentsNumber(); ++i)
143  ret += (m_Zsum[m_StrMap[-m_TPS->Particles()[i].Strangeness()]] / m_Zsum[m_StrMap[0]]) * m_pressuresGCE[i];
144  return ret;
145  }
146 
148  {
149  if (id >= 0. && id < static_cast<int>(m_v.size()))
150  return -m_v[id] * m_PNS;
151  else
152  return 0.0;
153  }
154 
155 
157  {
158  ClearModelEV();
159 
161 
162  // "Switch off" all strange particles
163  for (size_t i = 0; i < TPSnew->Particles().size(); ++i) {
164  ThermalParticle &part = TPSnew->Particle(i);
165  if (part.Strangeness() != 0)
166  part.SetDegeneracy(0.);
167  }
168 
169  m_modelEV = new ThermalModelEVDiagonal(TPSnew);
175 
177 
180  m_EVNS = 0.;
181  for (size_t i = 0; i < m_modelEV->Densities().size(); ++i) {
182  m_EVNS += m_v[i] * m_modelEV->Densities()[i] * m_Parameters.SVc;
183  }
184  }
185 
187  {
188  if (m_modelEV != NULL) {
189  ThermalParticleSystem *TPSold = m_modelEV->TPS();
190  if (TPSold != NULL)
191  delete TPSold;
192  delete m_modelEV;
193  m_modelEV = NULL;
194  }
195  }
196 
198  {
199  if (static_cast<int>(m_v.size()) != m_TPS->ComponentsNumber())
200  m_v.resize(m_TPS->Particles().size());
201  for (int i = 0; i < m_TPS->ComponentsNumber(); ++i) {
202  m_v[i] = CuteHRGHelper::vr(rad);
203  }
204  }
205 
206  void ThermalModelEVCanonicalStrangeness::FillVirial(const std::vector<double>& ri)
207  {
208  if (ri.size() != m_TPS->Particles().size()) {
209  printf("**WARNING** %s::FillVirial(const std::vector<double> & ri): size of ri does not match number of hadrons in the list", m_TAG.c_str());
210  return;
211  }
212  m_v.resize(m_TPS->Particles().size());
213  for (int i = 0; i < m_TPS->ComponentsNumber(); ++i)
214  m_v[i] = CuteHRGHelper::vr(ri[i]);
215  }
216 
217  void ThermalModelEVCanonicalStrangeness::FillVirialEV(const std::vector<double>& vi)
218  {
219  if (vi.size() != m_TPS->Particles().size()) {
220  printf("**WARNING** %s::FillVirialEV(const std::vector<double> & vi): size of vi does not match number of hadrons in the list", m_TAG.c_str());
221  return;
222  }
223  m_v = vi;
224  }
225 
227  {
228  m_v = std::vector<double>(m_TPS->Particles().size(), 0.);
229 
230  ifstream fin(filename.c_str());
231  char cc[2000];
232  while (!fin.eof()) {
233  fin.getline(cc, 2000);
234  string tmp = string(cc);
235  vector<string> elems = CuteHRGHelper::split(tmp, '#');
236  if (elems.size() < 1)
237  continue;
238  istringstream iss(elems[0]);
239  int pdgid;
240  double b;
241  if (iss >> pdgid >> b) {
242  int ind = m_TPS->PdgToId(pdgid);
243  if (ind != -1)
244  m_v[ind] = b;
245  }
246  }
247  fin.close();
248  }
249 
251  {
252  ofstream fout(filename.c_str());
253  for (int i = 0; i < m_TPS->ComponentsNumber(); ++i) {
254  fout << std::setw(15) << m_TPS->Particle(i).PdgId();
255  fout << std::setw(15) << m_v[i];
256  fout << std::endl;
257  }
258  fout.close();
259  }
260 
262  {
263  if (i < 0 || i >= static_cast<int>(m_v.size()))
264  return 0.;
265  return m_v[i];
266  }
267 
269  {
270  double tEV = 0.;
271  for (int i = 0; i < m_TPS->ComponentsNumber(); ++i) {
272  tEV += m_v[i] * m_densities[i] / 4.;
273  }
274  return tEV;
275  }
276 
278  {
279  if (i >= 0 && i < static_cast<int>(m_v.size()))
280  m_v[i] = CuteHRGHelper::vr(rad);
281  }
282 
284  return (charge == ConservedCharge::StrangenessCharge);
285  }
286 
287 } // namespace thermalfist
virtual double CalculatePressure()
Implementation of the equation of state functions.
virtual bool IsConservedChargeCanonical(ConservedCharge::Name charge) const
Whether the given conserved charge is treated canonically.
std::vector< std::string > split(const std::string &s, char delim)
std::vector< double > m_Chem
const std::vector< double > & Densities() const
double CommonSuppressionFactor()
The density suppression factor , common for all species.
const ThermalParticle & Particle(int id) const
ThermalParticle object corresponding to particle species with a provided 0-based index.
void FillVirialEV(const std::vector< double > &vi=std::vector< double >(0))
Same as FillVirial() but uses the diagonal excluded-volume coefficients as input instead of radii...
virtual void CalculatePrimordialDensities()
Calculates the primordial densities of all species.
virtual double MuShift(int id) const
The shift in the chemical potential of particle species i due to the excluded volume interactions...
void SetUseWidth(bool useWidth)
Sets whether finite resonance widths are used. Deprecated.
int PdgToId(long long pdgid)
Transforms PDG ID to a 0-based particle id number.
Class implementing the ideal HRG model with exact conservation of strangeness (strangeness-canonical ...
long long PdgId() const
Particle&#39;s Particle Data Group (PDG) ID number.
Class implementing the diagonal excluded-volume model.
Class containing the particle list.
virtual void SetParameters(const ThermalModelParameters &params)
The thermal parameters.
ThermalModelParameters m_Parameters
Structure containing all thermal parameters of the model.
int ComponentsNumber() const
Number of different particle species in the list.
virtual ~ThermalModelEVCanonicalStrangeness(void)
Destroy the ThermalModelEVCanonicalStrangeness object.
virtual void ReadInteractionParameters(const std::string &filename)
Read the set of eigenvolume parameters for all particles from an external file.
Contains some extra mathematical functions used in the code.
virtual void WriteInteractionParameters(const std::string &filename)
Write the set of eigenvolume parameters for all particles to an external file.
ThermalParticleSystem * m_TPS
void FillVirialEV(const std::vector< double > &vi=std::vector< double >(0))
Same as FillVirial() but uses the diagonal excluded-volume coefficients as input instead of radii...
Class containing all information about a particle specie.
const std::vector< ThermalParticle > & Particles() const
Returns the vector of all particle species.
void SetRadius(double rad)
Set the same excluded volume radius parameter for all species.
ThermalModelInteraction m_InteractionModel
virtual void ValidateCalculation()
Checks whether issues have occured during the calculation of particle densities in the CalculateDensi...
virtual void CalculateSums(double Vc)
Calculates the strangeness-canonical partition functions.
Contains some functions do deal with excluded volumes.
Name
Set of all conserved charges considered.
virtual double CalculatePressure()
Implementation of the equation of state functions.
virtual void CalculateDensities()
Calculates the primordial and total (after decays) densities of all species.
Diagonal excluded volume model.
std::vector< double > m_densities
void FillVirial(const std::vector< double > &ri=std::vector< double >(0))
Fills the vector of particle eigenvolume parameters.
virtual void CalculateEnergyDensitiesGCE()
Calculates the grand-canonical energy densities.
void SetDegeneracy(double deg)
Set particle&#39;s internal degeneracy factor.
Strangeness-canonical ensemble.
ThermalModelEnsemble m_Ensemble
int Strangeness() const
Particle&#39;s strangeness.
double vr(double r)
Computes the excluded volume parameter from a given radius parameter value.
The main namespace where all classes and functions of the Thermal-FIST library reside.
virtual void SetChemicalPotentials(const std::vector< double > &chem=std::vector< double >(0))
Sets the chemical potentials of all particles.
ThermalParticleSystem * TPS()
virtual void CalculatePressuresGCE()
Calculates the grand-canonical pressures.
virtual void CalculateDensitiesGCE()
Calculates the particle densities in a grand-canonical ensemble.
void SetVolume(double Volume)
Sets the system volume.