Thermal-FIST 1.6
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, bool dimensionfull = false);
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 double CalculateEntropyDensityDerivativeT();
193
194 virtual void CalculateTemperatureDerivatives();
195
196 // Dummy
197 virtual double CalculateBaryonMatterEntropyDensity() { return 0.; }
198
199 virtual double CalculateMesonMatterEntropyDensity() { return 0.; }
200
201 virtual double ParticleScalarDensity(int part);
202
203 bool IsLastSolutionOK() const { return m_LastBroydenSuccessFlag && m_LastCalculationSuccessFlag; }
204
205 double DensityId(int index) { return m_DensitiesId[index]; }
206
207 // Override functions end
208
209 const std::vector< std::vector<int> >& VDWComponentIndices() const { return m_dMuStarIndices; }
210 virtual double DeltaMu(int i) const { return MuShift(i); }
211 const std::vector< std::vector<double> >& VirialMatrix() const { return m_Virial; }
212 const std::vector< std::vector<double> >& AttractionMatrix() const { return m_Attr; }
213
214 protected:
219 std::vector<double> ComputeNp(const std::vector<double>& dmustar);
220
224 std::vector<double> ComputeNp(const std::vector<double>& dmustar, const std::vector<double>& ns);
225
228
238 virtual std::vector<double> SearchSingleSolution(const std::vector<double> & muStarInit);
239
251 std::vector<double> SearchMultipleSolutions(int iters = 300);
252
261 std::vector<double> SearchFirstSolution(int iters = 50);
262
265 void SolveEquations();
266
275 virtual double MuShift(int id) const;
276
278 std::vector<double> m_DensitiesId;
279
281 std::vector<double> m_scaldens;
282
284 std::vector< std::vector<double> > m_Virial;
285
287 std::vector< std::vector<double> > m_Attr;
288
291 std::vector< std::vector<double> > m_VirialdT;
292
295 std::vector< std::vector<double> > m_AttrdT;
296
300
303
306
309
311 std::vector<double> m_MuStar;
312
313 std::vector<int> m_MapTodMuStar;
314
315 std::vector<int> m_MapFromdMuStar;
316
317 std::vector< std::vector<int> > m_dMuStarIndices;
318
319 std::vector< std::vector<double> > m_chi;
320
321 std::vector<double> m_chiarb;
322 private:
323
324
325 virtual void CalculatePrimordialDensitiesOld();
326
327 virtual void CalculatePrimordialDensitiesNew();
328
329 class BroydenEquationsVDW : public BroydenEquations
330 {
331 public:
332 BroydenEquationsVDW(ThermalModelVDW *model) : BroydenEquations(), m_THM(model) { m_N = model->m_MapFromdMuStar.size(); }
333 std::vector<double> Equations(const std::vector<double> &x);
334 private:
335 ThermalModelVDW *m_THM;
336 };
337
338 class BroydenJacobianVDW : public BroydenJacobian
339 {
340 public:
341 BroydenJacobianVDW(ThermalModelVDW *model) : BroydenJacobian(), m_THM(model) { }
342 std::vector<double> Jacobian(const std::vector<double> &x);
343 private:
344 ThermalModelVDW *m_THM;
345 };
346
347 class BroydenSolutionCriteriumVDW : public Broyden::BroydenSolutionCriterium
348 {
349 public:
350 BroydenSolutionCriteriumVDW(ThermalModelVDW *model, double relative_error = Broyden::TOL) : Broyden::BroydenSolutionCriterium(relative_error), m_THM(model) { }
351 virtual bool IsSolved(const std::vector<double>& x, const std::vector<double>& f, const std::vector<double>& xdelta = std::vector<double>()) const;
352 protected:
353 ThermalModelVDW *m_THM;
354 };
355 };
356
359
364 void SetVDWHRGInteractionParameters(ThermalModelBase *model, double a, double b);
365
370 void SetVDWHRGInteractionParameters(ThermalModelBase *model, const std::vector<std::vector<double>> & a, const std::vector<std::vector<double>> & b);
371} // namespace thermalfist
372
373#endif
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 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 .
virtual bool UseMultipleSolutionsMode() const
Whether to search for multiple solutions of the QvdW equations by considering different initial guess...
std::vector< int > m_MapTodMuStar
void CalculateVDWComponentsMap()
Partitions particles species into sets that have identical VDW parameters.
virtual std::vector< double > CalculateChargeFluctuations(const std::vector< double > &chgs, int order=4, bool dimensionfull=false)
Calculates fluctuations (diagonal susceptibilities) of an arbitrary "conserved" charge.
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)
std::vector< double > SearchFirstSolution(int iters=50)
Try different initial guesses and return the first valid solution found.
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
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...
virtual double CalculateEntropyDensityDerivativeT()
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.