Thermal-FIST  1.3
Package for hadron resonance gas model applications
ThermalModelVDW.h
Go to the documentation of this file.
1 /*
2  * Thermal-FIST package
3  *
4  * Copyright (c) 2016-2019 Volodymyr Vovchenko
5  *
6  * GNU General Public License (GPLv3 or later)
7  */
8 #ifndef THERMALMODELVDW_H
9 #define THERMALMODELVDW_H
10 
12 
13 namespace thermalfist {
14 
37  {
38  public:
46 
51  virtual ~ThermalModelVDW(void);
52 
59  void FillVirialEV(const std::vector< std::vector<double> > & bij = std::vector< std::vector<double> >(0));
60 
69  void SetVirialdT(int i, int j, double dbdT) { if (i >= 0 && i < static_cast<int>(m_VirialdT.size()) && j >= 0 && j < static_cast<int>(m_VirialdT[i].size())) m_VirialdT[i][j] = dbdT; }
70 
79  void SetAttractiondT(int i, int j, double dadT) { if (i >= 0 && i < static_cast<int>(m_AttrdT.size()) && j >= 0 && j < static_cast<int>(m_AttrdT[i].size())) m_AttrdT[i][j] = dadT; }
80 
89  double VirialCoefficientdT(int i, int j) const;
90 
99  double AttractionCoefficientdT(int i, int j) const;
100 
108 
117 
118 
129  void SetMultipleSolutionsMode(bool search) { m_SearchMultipleSolutions = search; }
130 
139 
141  double MuStar(int i) const { return m_MuStar[i]; }
142 
145  std::vector<double> GetMuStar() const { return m_MuStar; }
146 
148  void SetMuStar(const std::vector<double> & MuStar) { m_MuStar = MuStar; }
149 
150  // Override functions begin
151 
152  void FillChemicalPotentials();
153 
154  virtual void SetChemicalPotentials(const std::vector<double> & chem = std::vector<double>(0));
155 
156  void FillVirial(const std::vector<double> & ri = std::vector<double>(0));
157 
158  void FillAttraction(const std::vector< std::vector<double> > & aij = std::vector< std::vector<double> >(0));
159 
160  virtual void ReadInteractionParameters(const std::string &filename);
161 
162  virtual void WriteInteractionParameters(const std::string &filename);
163 
164  void SetVirial(int i, int j, double b) { if (i >= 0 && i < static_cast<int>(m_Virial.size()) && j >= 0 && j < static_cast<int>(m_Virial[i].size())) m_Virial[i][j] = b; }
165 
166  void SetAttraction(int i, int j, double a) { if (i >= 0 && i < static_cast<int>(m_Attr.size()) && j >= 0 && j < static_cast<int>(m_Attr[i].size())) m_Attr[i][j] = a; }
167 
168  double VirialCoefficient(int i, int j) const;
169 
170  double AttractionCoefficient(int i, int j) const;
171 
172  virtual void ChangeTPS(ThermalParticleSystem *TPS);
173 
174  virtual void CalculatePrimordialDensities();
175 
176  virtual std::vector<double> CalculateChargeFluctuations(const std::vector<double> &chgs, int order = 4);
177 
178  virtual std::vector< std::vector<double> > CalculateFluctuations(int order);
179 
181 
182  void CalculateFluctuations();
183 
184  virtual double CalculatePressure();
185 
186  virtual double CalculateEnergyDensity();
187 
188  virtual double CalculateEntropyDensity();
189 
190  // Dummy
191  virtual double CalculateBaryonMatterEntropyDensity() { return 0.; }
192 
193  virtual double CalculateMesonMatterEntropyDensity() { return 0.; }
194 
195  virtual double ParticleScalarDensity(int part);
196 
198 
199  double DensityId(int index) { return m_DensitiesId[index]; }
200 
201  // Override functions end
202 
203  protected:
208  std::vector<double> ComputeNp(const std::vector<double>& dmustar);
209 
213  std::vector<double> ComputeNp(const std::vector<double>& dmustar, const std::vector<double>& ns);
214 
224  virtual std::vector<double> SearchSingleSolution(const std::vector<double> & muStarInit);
225 
237  std::vector<double> SearchMultipleSolutions(int iters = 300);
238 
241  void SolveEquations();
242 
251  virtual double MuShift(int id) const;
252 
254  std::vector<double> m_DensitiesId;
255 
257  std::vector<double> m_scaldens;
258 
260  std::vector< std::vector<double> > m_Virial;
261 
263  std::vector< std::vector<double> > m_Attr;
264 
267  std::vector< std::vector<double> > m_VirialdT;
268 
271  std::vector< std::vector<double> > m_AttrdT;
272 
276 
279 
282 
284  std::vector<double> m_MuStar;
285 
286  std::vector<int> m_MapTodMuStar;
287 
288  std::vector<int> m_MapFromdMuStar;
289 
290  std::vector< std::vector<int> > m_dMuStarIndices;
291 
292  private:
293  std::vector< std::vector<double> > m_chi;
294 
295  std::vector<double> m_chiarb;
296 
297 
298  virtual void CalculatePrimordialDensitiesOld();
299 
300  virtual void CalculatePrimordialDensitiesNew();
301 
302  class BroydenEquationsVDW : public BroydenEquations
303  {
304  public:
305  BroydenEquationsVDW(ThermalModelVDW *model) : BroydenEquations(), m_THM(model) { m_N = model->m_MapFromdMuStar.size(); }
306  std::vector<double> Equations(const std::vector<double> &x);
307  private:
308  ThermalModelVDW *m_THM;
309  };
310 
311  class BroydenJacobianVDW : public BroydenJacobian
312  {
313  public:
314  BroydenJacobianVDW(ThermalModelVDW *model) : BroydenJacobian(), m_THM(model) { }
315  std::vector<double> Jacobian(const std::vector<double> &x);
316  private:
317  ThermalModelVDW *m_THM;
318  };
319 
320  class BroydenSolutionCriteriumVDW : public Broyden::BroydenSolutionCriterium
321  {
322  public:
323  BroydenSolutionCriteriumVDW(ThermalModelVDW *model, double relative_error = Broyden::TOL) : Broyden::BroydenSolutionCriterium(relative_error), m_THM(model) { }
324  virtual bool IsSolved(const std::vector<double>& x, const std::vector<double>& f, const std::vector<double>& xdelta = std::vector<double>()) const;
325  protected:
326  ThermalModelVDW *m_THM;
327  };
328  };
329 
332 
333 } // namespace thermalfist
334 
335 #endif
336 
Abstract base class for an HRG model implementation.
std::vector< int > m_MapTodMuStar
static const double TOL
Default desired solution accuracy.
Definition: Broyden.h:183
void CalculateFluctuations()
Computes the fluctuation observables.
virtual void ChangeTPS(ThermalParticleSystem *TPS)
Change the particle list.
Class implementing the Broyden method to solve a system of non-linear equations.
Definition: Broyden.h:131
virtual void SetChemicalPotentials(const std::vector< double > &chem=std::vector< double >(0))
Sets the chemical potentials of all particles.
std::vector< double > SearchMultipleSolutions(int iters=300)
Uses the Broyden method with different initial guesses to look for different possible solutions of th...
std::vector< double > m_scaldens
Vector of scalar densities. Not used.
void FillChemicalPotentials()
Sets the chemical potentials of all particles.
virtual double CalculateMesonMatterEntropyDensity()
The fraction of entropy carried by mesons (Ideal GCE only)
void SetVirial(int i, int j, double b)
Set the excluded volume coefficient .
void FillVirialEV(const std::vector< std::vector< double > > &bij=std::vector< std::vector< double > >(0))
Same as FillVirial() but uses the matrix of excluded-volume coefficients as input instead of radii...
double VirialCoefficient(int i, int j) const
Excluded volume coefficient .
virtual void ReadInteractionParameters(const std::string &filename)
Reads the QvdW interaction parameters from a file.
Class containing the particle list.
virtual std::vector< double > SearchSingleSolution(const std::vector< double > &muStarInit)
Uses the Broyden method with a provided initial guess to determine the shifted chemical potentials by...
std::vector< std::vector< int > > m_dMuStarIndices
Structure containing all thermal parameters of the model.
double AttractionCoefficient(int i, int j) const
QvdW mean field attraction coefficient .
double VirialCoefficientdT(int i, int j) const
The temperature derivative of the eigenvolume parameter .
std::vector< std::vector< double > > m_Attr
Matrix of the attractive QvdW coefficients .
Abstract class which defines the system of non-linear equations to be solved by the Broyden&#39;s method...
Definition: Broyden.h:31
virtual double MuShift(int id) const
The shift in the chemical potential of particle species i due to the QvdW interactions.
virtual ~ThermalModelVDW(void)
Destroy the ThermalModelVDW object.
std::vector< std::vector< double > > m_VirialdT
Class implementing the quantum van der Waals HRG model.
void FillVirial(const std::vector< double > &ri=std::vector< double >(0))
Fills the excluded volume coefficients based on the provided radii parameters for all species...
void SetTemperatureDependentAB(bool Tdep)
Sets whether temperature depedence of QvdW parameters should be considered.
std::vector< int > m_MapFromdMuStar
ThermalModelVDW(ThermalParticleSystem *TPS_, const ThermalModelParameters &params=ThermalModelParameters())
Construct a new ThermalModelVDW object.
Sub-class where it is determined whether the required accuracy is achieved in the Broyden&#39;s method...
Definition: Broyden.h:144
std::vector< double > ComputeNp(const std::vector< double > &dmustar)
double MuStar(int i) const
The shifted chemical potential of particle species i.
void SetVirialdT(int i, int j, double dbdT)
Set the temperature derivative of the eigenvolume parameter .
virtual double CalculateEnergyDensity()
virtual double CalculateEntropyDensity()
double AttractionCoefficientdT(int i, int j) const
The temperature derivative of the QvdW attraction parameter .
std::vector< std::vector< double > > m_AttrdT
bool TemperatureDependentAB() const
Whether temperature depedence of QvdW parameters is considered.
virtual void CalculatePrimordialDensities()
Calculates the primordial densities of all species.
virtual double CalculatePressure()
Implementation of the equation of state functions.
Class which implements calculation of the Jacobian needed for the Broyden&#39;s method.
Definition: Broyden.h:76
std::vector< std::vector< double > > m_Virial
virtual std::vector< double > CalculateChargeFluctuations(const std::vector< double > &chgs, int order=4)
Calculates fluctuations (diagonal susceptibilities) of an arbitrary "conserved" charge.
ThermalModelVDW ThermalModelVDWFull
For backward compatibility.
bool m_LastBroydenSuccessFlag
Whether Broyden&#39;s method was successfull.
void SetAttractiondT(int i, int j, double dadT)
Set the temperature derivative of the QvdW attraction parameter .
virtual double ParticleScalarDensity(int part)
The scalar density of the particle species i.
void CalculateTwoParticleCorrelations()
Computes the fluctuations and correlations of the primordial particle numbers.
std::vector< double > m_MuStar
Vector of the shifted chemical potentials.
virtual double CalculateBaryonMatterEntropyDensity()
The fraction of entropy carried by baryons (Ideal GCE only)
bool m_SearchMultipleSolutions
Whether multiple solutions are considered.
The main namespace where all classes and functions of the Thermal-FIST library reside.
void SetMultipleSolutionsMode(bool search)
Whether to search for multiple solutions of the QvdW equations by considering different initial guess...
virtual void WriteInteractionParameters(const std::string &filename)
Write the QvdW interaction parameters to a file.
std::vector< double > m_DensitiesId
Vector of ideal gas densities with shifted chemical potentials.
void SetAttraction(int i, int j, double a)
Set the vdW mean field attraction coefficient .
void SetMuStar(const std::vector< double > &MuStar)
Set the vector of shifted chemical potentials.
bool UseMultipleSolutionsMode() const
Whether to search for multiple solutions of the QvdW equations by considering different initial guess...
ThermalParticleSystem * TPS()
std::vector< double > GetMuStar() const
void FillAttraction(const std::vector< std::vector< double > > &aij=std::vector< std::vector< double > >(0))