Thermal-FIST 1.5
Package for hadron resonance gas model applications
Loading...
Searching...
No Matches
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#include <cassert>
15
16#include "HRGBase/xMath.h"
18
19using namespace std;
20
21namespace thermalfist {
22
25 {
26 m_modelEV = NULL;
27 m_v.resize(m_TPS->Particles().size());
28 m_TAG = "ThermalModelEVCanonicalStrangeness";
29
30 m_Ensemble = SCE;
31 m_InteractionModel = DiagonalEV;
32 }
33
38
40 if (m_modelEV == NULL)
42
43 for (int i = 0; i < m_TPS->ComponentsNumber(); ++i) {
44 m_densitiesGCE[i] = /*m_Suppression **/ m_TPS->Particles()[i].Density(m_Parameters, IdealGasFunctions::ParticleDensity, m_UseWidth, m_Chem[i] - m_v[i] * m_PNS);
45 }
46
47 m_GCECalculated = true;
48 }
49
51 if (m_modelEV == NULL)
53
55 for (int i = 0; i < m_TPS->ComponentsNumber(); ++i) {
56 m_energydensitiesGCE[i] = /*m_Suppression **/ m_TPS->Particles()[i].Density(m_Parameters, IdealGasFunctions::EnergyDensity, m_UseWidth, m_Chem[i] - m_v[i] * m_PNS);
57 }
58 }
59
61 {
62 if (m_modelEV == NULL)
64
65 m_pressuresGCE.resize(m_densitiesGCE.size());
66 for (int i = 0; i < m_TPS->ComponentsNumber(); ++i) {
67 m_pressuresGCE[i] = m_TPS->Particles()[i].Density(m_Parameters, IdealGasFunctions::Pressure, m_UseWidth, m_Chem[i] - m_v[i] * m_PNS);
68 }
69 }
70
71
73 assert(m_IGFExtraConfig.MagneticField.B == 0.); // No magnetic field supported currently
74
75 m_FluctuationsCalculated = false;
76
77 m_energydensitiesGCE.resize(0);
78 m_pressuresGCE.resize(0);
79
81
83
84 CalculateSums(m_Parameters.SVc - m_EVNS);
85
86 for (int i = 0; i < m_TPS->ComponentsNumber(); ++i) {
87 if (m_StrMap.count(-m_TPS->Particles()[i].Strangeness()))
88 m_densities[i] = m_Suppression * (m_Zsum[m_StrMap[-m_TPS->Particles()[i].Strangeness()]] / m_Zsum[m_StrMap[0]]) * m_densitiesGCE[i];
89 }
90
91 m_EVS = 0.;
92 for (int i = 0; i < m_TPS->ComponentsNumber(); ++i) {
93 if (m_TPS->Particles()[i].Strangeness() != 0)
94 m_EVS += m_v[i] * m_densities[i] * m_Parameters.SVc;
95 }
96
97 //printf("%15lf%15lf\n", CalculatePressure(), m_PNS);
98 double tP = CalculatePressure();
99 printf("EV-SCE calculation: The following two parameters must be much smaller than unity. Otherwise we are in trouble...\n");
100 printf("%20s%lf\n%20s%lf\n", "PS/P = ", (tP - m_PNS) / tP, "EVS/(V-EVNS) = ", m_EVS / (m_Parameters.SVc - m_EVNS));
101
102 m_Calculated = true;
104 //m_LastCalculationSuccessFlag = true;
105 }
106
107
108
110 if (!m_Calculated)
112
113 if (m_energydensitiesGCE.size() == 0)
115
116 double ret = 0.;
117 for (int i = 0; i < m_TPS->ComponentsNumber(); ++i)
118 ret += m_Suppression * (m_Zsum[m_StrMap[-m_TPS->Particles()[i].Strangeness()]] / m_Zsum[m_StrMap[0]]) * m_energydensitiesGCE[i];
119 return ret;
120 }
121
122
124 double ret = log(m_Zsum[m_StrMap[0]]) / m_Parameters.SVc;
125
126 if (m_energydensitiesGCE.size() == 0)
128
129 for (int i = 0; i < m_TPS->ComponentsNumber(); ++i)
130 if (m_TPS->Particles()[i].Strangeness() != 0) {
131 if (m_StrMap.count(-m_TPS->Particles()[i].Strangeness()))
132 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);
133 }
134 else {
135 ret += m_Suppression * m_TPS->Particles()[i].Density(m_Parameters, IdealGasFunctions::EntropyDensity, m_UseWidth, m_Chem[i] - m_v[i] * m_PNS);
136 }
137 return ret;
138 }
139
140
142 double ret = 0.;
143 if (m_pressuresGCE.size() == 0)
145 for (int i = 0; i < m_TPS->ComponentsNumber(); ++i)
146 ret += (m_Zsum[m_StrMap[-m_TPS->Particles()[i].Strangeness()]] / m_Zsum[m_StrMap[0]]) * m_pressuresGCE[i];
147 return ret;
148 }
149
151 {
152 if (id >= 0. && id < static_cast<int>(m_v.size()))
153 return -m_v[id] * m_PNS;
154 else
155 return 0.0;
156 }
157
158
160 {
161 ClearModelEV();
162
163 ThermalParticleSystem *TPSnew = new ThermalParticleSystem(*m_TPS);
164
165 // "Switch off" all strange particles
166 for (size_t i = 0; i < TPSnew->Particles().size(); ++i) {
167 ThermalParticle &part = TPSnew->Particle(i);
168 if (part.Strangeness() != 0)
169 part.SetDegeneracy(0.);
170 }
171
172 m_modelEV = new ThermalModelEVDiagonal(TPSnew);
173 m_modelEV->FillVirialEV(m_v);
174 m_modelEV->SetUseWidth(m_UseWidth);
175 m_modelEV->SetParameters(m_Parameters);
176 m_modelEV->SetVolume(m_Parameters.SVc);
177 m_modelEV->SetChemicalPotentials(m_Chem);
178
179 m_modelEV->CalculateDensities();
180
181 m_PNS = m_modelEV->CalculatePressure();
182 m_Suppression = m_modelEV->CommonSuppressionFactor();
183 m_EVNS = 0.;
184 for (size_t i = 0; i < m_modelEV->Densities().size(); ++i) {
185 m_EVNS += m_v[i] * m_modelEV->Densities()[i] * m_Parameters.SVc;
186 }
187 }
188
190 {
191 if (m_modelEV != NULL) {
192 ThermalParticleSystem *TPSold = m_modelEV->TPS();
193 if (TPSold != NULL)
194 delete TPSold;
195 delete m_modelEV;
196 m_modelEV = NULL;
197 }
198 }
199
201 {
202 if (static_cast<int>(m_v.size()) != m_TPS->ComponentsNumber())
203 m_v.resize(m_TPS->Particles().size());
204 for (int i = 0; i < m_TPS->ComponentsNumber(); ++i) {
205 m_v[i] = CuteHRGHelper::vr(rad);
206 }
207 }
208
209 void ThermalModelEVCanonicalStrangeness::FillVirial(const std::vector<double>& ri)
210 {
211 if (ri.size() != m_TPS->Particles().size()) {
212 throw std::invalid_argument(m_TAG + "::FillVirial(const std::vector<double> & ri): size of ri does not match number of hadrons in the list");
213 }
214 m_v.resize(m_TPS->Particles().size());
215 for (int i = 0; i < m_TPS->ComponentsNumber(); ++i)
216 m_v[i] = CuteHRGHelper::vr(ri[i]);
217 }
218
219 void ThermalModelEVCanonicalStrangeness::FillVirialEV(const std::vector<double>& vi)
220 {
221 if (vi.size() != m_TPS->Particles().size()) {
222 throw std::invalid_argument(m_TAG + "::FillVirialEV(const std::vector<double> & vi): size of vi does not match number of hadrons in the list");
223 }
224 m_v = vi;
225 }
226
228 {
229 m_v = std::vector<double>(m_TPS->Particles().size(), 0.);
230
231 ifstream fin(filename.c_str());
232 char cc[2000];
233 while (!fin.eof()) {
234 fin.getline(cc, 2000);
235 string tmp = string(cc);
236 vector<string> elems = CuteHRGHelper::split(tmp, '#');
237 if (elems.size() < 1)
238 continue;
239 istringstream iss(elems[0]);
240 int pdgid;
241 double b;
242 if (iss >> pdgid >> b) {
243 int ind = m_TPS->PdgToId(pdgid);
244 if (ind != -1)
245 m_v[ind] = b;
246 }
247 }
248 fin.close();
249 }
250
252 {
253 ofstream fout(filename.c_str());
254 for (int i = 0; i < m_TPS->ComponentsNumber(); ++i) {
255 fout << std::setw(15) << m_TPS->Particle(i).PdgId();
256 fout << std::setw(15) << m_v[i];
257 fout << std::endl;
258 }
259 fout.close();
260 }
261
263 {
264 if (i < 0 || i >= static_cast<int>(m_v.size()))
265 return 0.;
266 return m_v[i];
267 }
268
270 {
271 double tEV = 0.;
272 for (int i = 0; i < m_TPS->ComponentsNumber(); ++i) {
273 tEV += m_v[i] * m_densities[i] / 4.;
274 }
275 return tEV;
276 }
277
279 {
280 if (i >= 0 && i < static_cast<int>(m_v.size()))
281 m_v[i] = CuteHRGHelper::vr(rad);
282 }
283
287
288} // namespace thermalfist
Contains some functions to deal with excluded volumes.
map< string, double > params
@ DiagonalEV
Diagonal excluded volume model.
virtual void ValidateCalculation()
Checks whether issues have occured during the calculation of particle densities in the CalculateDensi...
virtual void CalculateDensities()
Calculates the primordial and total (after decays) densities of all species.
@ SCE
Strangeness-canonical ensemble.
ThermalModelCanonicalStrangeness(ThermalParticleSystem *TPS, const ThermalModelParameters &params=ThermalModelParameters())
Construct a new ThermalModelCanonicalStrangeness object.
virtual void CalculateSums(double Vc)
Calculates the strangeness-canonical partition functions.
void SetRadius(double rad)
Set the same excluded volume radius parameter for all species.
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.
void FillVirial(const std::vector< double > &ri=std::vector< double >(0))
Fills the vector of particle eigenvolume parameters.
virtual void CalculatePrimordialDensities()
Calculates the primordial densities of all species.
virtual void CalculateDensitiesGCE()
Calculates the particle densities in a grand-canonical ensemble.
virtual void CalculatePressuresGCE()
Calculates the grand-canonical pressures.
virtual void ReadInteractionParameters(const std::string &filename)
Read the set of eigenvolume parameters for all particles from an external file.
virtual bool IsConservedChargeCanonical(ConservedCharge::Name charge) const
ThermalModelEVCanonicalStrangeness(ThermalParticleSystem *TPS, const ThermalModelParameters &params=ThermalModelParameters())
Construct a new Thermal ModelEVCanonicalStrangeness object.
virtual void WriteInteractionParameters(const std::string &filename)
Write the set of eigenvolume parameters for all particles to an external file.
virtual double MuShift(int id) const
The shift in the chemical potential of particle species i due to the excluded volume interactions.
virtual ~ThermalModelEVCanonicalStrangeness(void)
Destroy the ThermalModelEVCanonicalStrangeness object.
virtual void CalculateEnergyDensitiesGCE()
Calculates the grand-canonical energy densities.
Class implementing the diagonal excluded-volume model.
Class containing all information about a particle specie.
int Strangeness() const
Particle's strangeness.
void SetDegeneracy(double deg)
Set particle's internal degeneracy factor.
Class containing the particle list.
const std::vector< ThermalParticle > & Particles() const
Returns the vector of all particle species.
const ThermalParticle & Particle(int id) const
ThermalParticle object corresponding to particle species with a provided 0-based index.
double vr(double r)
Computes the excluded volume parameter from a given radius parameter value.
std::vector< std::string > split(const std::string &s, char delim)
The main namespace where all classes and functions of the Thermal-FIST library reside.
Definition CosmicEoS.h:9
Name
Set of all conserved charges considered.
Structure containing all thermal parameters of the model.
Contains some extra mathematical functions used in the code.