Thermal-FIST 1.5
Package for hadron resonance gas model applications
Loading...
Searching...
No Matches
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
13namespace 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 virtual 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
153
154 virtual void SetChemicalPotentials(const std::vector<double> & chem = std::vector<double>(0));
155
156 virtual void FillVirial(const std::vector<double> & ri = std::vector<double>(0));
157
158 virtual 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 virtual 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; m_VDWComponentMapCalculated = false; }
165
166 virtual 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; m_VDWComponentMapCalculated = false; }
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
183
184 virtual double CalculatePressure();
185
186 virtual double CalculateEnergyDensity();
187
188 virtual double CalculateEntropyDensity();
189
190 virtual double CalculateEnergyDensityDerivativeT();
191
192 virtual void CalculateTemperatureDerivatives();
193
194 // Dummy
195 virtual double CalculateBaryonMatterEntropyDensity() { return 0.; }
196
197 virtual double CalculateMesonMatterEntropyDensity() { return 0.; }
198
199 virtual double ParticleScalarDensity(int part);
200
201 bool IsLastSolutionOK() const { return m_LastBroydenSuccessFlag && m_LastCalculationSuccessFlag; }
202
203 double DensityId(int index) { return m_DensitiesId[index]; }
204
205 // Override functions end
206
207 const std::vector< std::vector<int> >& VDWComponentIndices() const { return m_dMuStarIndices; }
208 virtual double DeltaMu(int i) const { return MuShift(i); }
209 const std::vector< std::vector<double> >& VirialMatrix() const { return m_Virial; }
210 const std::vector< std::vector<double> >& AttractionMatrix() const { return m_Attr; }
211
212 protected:
217 std::vector<double> ComputeNp(const std::vector<double>& dmustar);
218
222 std::vector<double> ComputeNp(const std::vector<double>& dmustar, const std::vector<double>& ns);
223
226
236 virtual std::vector<double> SearchSingleSolution(const std::vector<double> & muStarInit);
237
249 std::vector<double> SearchMultipleSolutions(int iters = 300);
250
253 void SolveEquations();
254
263 virtual double MuShift(int id) const;
264
266 std::vector<double> m_DensitiesId;
267
269 std::vector<double> m_scaldens;
270
272 std::vector< std::vector<double> > m_Virial;
273
275 std::vector< std::vector<double> > m_Attr;
276
279 std::vector< std::vector<double> > m_VirialdT;
280
283 std::vector< std::vector<double> > m_AttrdT;
284
288
291
294
297
299 std::vector<double> m_MuStar;
300
301 std::vector<int> m_MapTodMuStar;
302
303 std::vector<int> m_MapFromdMuStar;
304
305 std::vector< std::vector<int> > m_dMuStarIndices;
306
307 std::vector< std::vector<double> > m_chi;
308
309 std::vector<double> m_chiarb;
310 private:
311
312
313 virtual void CalculatePrimordialDensitiesOld();
314
315 virtual void CalculatePrimordialDensitiesNew();
316
317 class BroydenEquationsVDW : public BroydenEquations
318 {
319 public:
320 BroydenEquationsVDW(ThermalModelVDW *model) : BroydenEquations(), m_THM(model) { m_N = model->m_MapFromdMuStar.size(); }
321 std::vector<double> Equations(const std::vector<double> &x);
322 private:
323 ThermalModelVDW *m_THM;
324 };
325
326 class BroydenJacobianVDW : public BroydenJacobian
327 {
328 public:
329 BroydenJacobianVDW(ThermalModelVDW *model) : BroydenJacobian(), m_THM(model) { }
330 std::vector<double> Jacobian(const std::vector<double> &x);
331 private:
332 ThermalModelVDW *m_THM;
333 };
334
335 class BroydenSolutionCriteriumVDW : public Broyden::BroydenSolutionCriterium
336 {
337 public:
338 BroydenSolutionCriteriumVDW(ThermalModelVDW *model, double relative_error = Broyden::TOL) : Broyden::BroydenSolutionCriterium(relative_error), m_THM(model) { }
339 virtual bool IsSolved(const std::vector<double>& x, const std::vector<double>& f, const std::vector<double>& xdelta = std::vector<double>()) const;
340 protected:
341 ThermalModelVDW *m_THM;
342 };
343 };
344
347
352 void SetVDWHRGInteractionParameters(ThermalModelBase *model, double a, double b);
353
358 void SetVDWHRGInteractionParameters(ThermalModelBase *model, const std::vector<std::vector<double>> & a, const std::vector<std::vector<double>> & b);
359} // namespace thermalfist
360
361#endif
362
map< string, double > params
BroydenSolutionCriterium(double maximum_error=TOL)
Definition Broyden.h:153
Abstract class which defines the system of non-linear equations to be solved by the Broyden's method.
Definition Broyden.h:32
int m_N
The number of equations.
Definition Broyden.h:66
static const double TOL
Default desired solution accuracy.
Definition Broyden.h:183
BroydenJacobian(BroydenEquations *eqs=NULL)
Construct a new BroydenJacobian object.
Definition Broyden.h:89
Abstract base class for an HRG model implementation.
ThermalModelBase(ThermalParticleSystem *TPS, const ThermalModelParameters &params=ThermalModelParameters())
Construct a new ThermalModelBase object.
Class implementing the quantum van der Waals HRG model.
virtual void SetChemicalPotentials(const std::vector< double > &chem=std::vector< double >(0))
Sets the chemical potentials of all particles.
std::vector< double > m_chiarb
virtual double CalculateEnergyDensityDerivativeT()
virtual void WriteInteractionParameters(const std::string &filename)
Write the QvdW interaction parameters to a file.
double VirialCoefficientdT(int i, int j) const
The temperature derivative of the eigenvolume parameter .
virtual void ChangeTPS(ThermalParticleSystem *TPS)
Change the particle list.
bool m_VDWComponentMapCalculated
Whether the mapping to components with the same VDW parameters has been calculated.
virtual std::vector< double > CalculateChargeFluctuations(const std::vector< double > &chgs, int order=4)
Calculates fluctuations (diagonal susceptibilities) of an arbitrary "conserved" charge.
virtual double CalculateMesonMatterEntropyDensity()
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< double > GetMuStar() const
virtual void SetAttraction(int i, int j, double a)
Set the vdW mean field attraction coefficient .
virtual double MuShift(int id) const
The shift in the chemical potential of particle species i due to the QvdW interactions.
void SetTemperatureDependentAB(bool Tdep)
Sets whether temperature depedence of QvdW parameters should be considered.
std::vector< double > m_DensitiesId
Vector of ideal gas densities with shifted chemical potentials.
virtual void ReadInteractionParameters(const std::string &filename)
Reads the QvdW interaction parameters from a file.
double MuStar(int i) const
The shifted chemical potential of particle species i.
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 AttractionCoefficient(int i, int j) const
QvdW mean field attraction coefficient .
void SetVirialdT(int i, int j, double dbdT)
Set the temperature derivative of the eigenvolume parameter .
std::vector< int > m_MapTodMuStar
void CalculateVDWComponentsMap()
Partitions particles species into sets that have identical VDW parameters.
const std::vector< std::vector< int > > & VDWComponentIndices() const
virtual void SetMultipleSolutionsMode(bool search)
Whether to search for multiple solutions of the QvdW equations by considering different initial guess...
void FillChemicalPotentials()
Sets the chemical potentials of all particles.
std::vector< std::vector< double > > m_AttrdT
void CalculateTwoParticleCorrelations()
Computes the fluctuations and correlations of the primordial particle numbers.
virtual void SetVirial(int i, int j, double b)
Set the excluded volume coefficient .
virtual double DeltaMu(int i) const
std::vector< double > ComputeNp(const std::vector< double > &dmustar)
const std::vector< std::vector< double > > & VirialMatrix() const
virtual void FillAttraction(const std::vector< std::vector< double > > &aij=std::vector< std::vector< double > >(0))
double AttractionCoefficientdT(int i, int j) const
The temperature derivative of the QvdW attraction parameter .
const std::vector< std::vector< double > > & AttractionMatrix() const
std::vector< std::vector< int > > m_dMuStarIndices
virtual ~ThermalModelVDW(void)
Destroy the ThermalModelVDW object.
virtual void CalculateTemperatureDerivatives()
Computes the temperature derivatives of densities, shifted chemical potentials, and primordial hadron...
std::vector< int > m_MapFromdMuStar
std::vector< std::vector< double > > m_Virial
bool UseMultipleSolutionsMode() const
Whether to search for multiple solutions of the QvdW equations by considering different initial guess...
std::vector< double > m_MuStar
Vector of the shifted chemical potentials.
void CalculateFluctuations()
Computes the fluctuation observables.
bool TemperatureDependentAB() const
Whether temperature depedence of QvdW parameters is considered.
virtual double ParticleScalarDensity(int part)
void SetAttractiondT(int i, int j, double dadT)
Set the temperature derivative of the QvdW attraction parameter .
std::vector< double > m_scaldens
Vector of scalar densities. Not used.
virtual void CalculatePrimordialDensities()
Calculates the primordial densities of all species.
std::vector< std::vector< double > > m_chi
std::vector< std::vector< double > > m_VirialdT
bool m_SearchMultipleSolutions
Whether multiple solutions are considered.
ThermalModelVDW(ThermalParticleSystem *TPS_, const ThermalModelParameters &params=ThermalModelParameters())
Construct a new ThermalModelVDW object.
bool m_LastBroydenSuccessFlag
Whether Broyden's method was successfull.
double VirialCoefficient(int i, int j) const
Excluded volume coefficient .
virtual double CalculateBaryonMatterEntropyDensity()
virtual 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 SetMuStar(const std::vector< double > &MuStar)
Set the vector of shifted chemical potentials.
std::vector< std::vector< double > > m_Attr
Matrix of the attractive QvdW coefficients .
std::vector< double > SearchMultipleSolutions(int iters=300)
Uses the Broyden method with different initial guesses to look for different possible solutions of th...
Class containing the particle list.
The main namespace where all classes and functions of the Thermal-FIST library reside.
Definition CosmicEoS.h:9
ThermalModelVDW ThermalModelVDWFull
For backward compatibility.
void SetVDWHRGInteractionParameters(ThermalModelBase *model, double a, double b)
Sets vdW interactions for baryon-baryon and antibaryon-antibaryon pairs as in https://arxiv....
Structure containing all thermal parameters of the model.