Thermal-FIST 1.6
Package for hadron resonance gas model applications
Loading...
Searching...
No Matches
ThermalModelRealGas.h
Go to the documentation of this file.
1#ifndef THERMALMODELREALGAS_H
2#define THERMALMODELREALGAS_H
3
7
8namespace thermalfist {
9
25 {
26 public:
34
39 virtual ~ThermalModelRealGas(void);
40
47
54
61
68
69 //void SetExcludedVolumeModelCopy(const ExcludedVolumeModelMultiBase& exvolmod) { *m_exvolmod = exvolmod; }
70 //void SetMeanFieldModelCopy(const MeanFieldModelMultiBase& mfmod) { *m_mfmod = mfmod; }
71
82 virtual void SetMultipleSolutionsMode(bool search) { m_SearchMultipleSolutions = search; }
83
91 virtual bool UseMultipleSolutionsMode() const { return m_SearchMultipleSolutions; }
92
99 double MuStar(int i) const { return m_MuStar[i]; }
100
106 std::vector<double> GetMuStar() const { return m_MuStar; }
107
113 void SetMuStar(const std::vector<double>& MuStar) { m_MuStar = MuStar; }
114
115 // Override functions begin
116
121
128 virtual void SetChemicalPotentials(const std::vector<double>& chem = std::vector<double>(0));
129
133 virtual void CalculatePrimordialDensities();
134
142 virtual std::vector<double> CalculateChargeFluctuations(const std::vector<double>& chgs, int order = 4, bool dimensionfull = false);
143
151 virtual std::vector<double> CalculateChargeFluctuationsOld(const std::vector<double>& chgs, int order = 4);
152
159 virtual std::vector< std::vector<double> > CalculateFluctuations(int order);
160
165
170
176 virtual double CalculatePressure();
177
183 virtual double CalculateEnergyDensity();
184
190 virtual double CalculateEntropyDensity();
191
197 virtual double CalculateEnergyDensityDerivativeT();
198
204 virtual double CalculateEntropyDensityDerivativeT();
205
209 virtual void CalculateTemperatureDerivatives();
210
211 // Dummy
217 virtual double CalculateBaryonMatterEntropyDensity() { return 0.; }
218
224 virtual double CalculateMesonMatterEntropyDensity() { return 0.; }
225
232 virtual double ParticleScalarDensity(int part);
233
239 bool IsLastSolutionOK() const { return m_LastBroydenSuccessFlag && m_LastCalculationSuccessFlag; }
240
247 double DensityId(int index) { return m_DensitiesId[index]; }
248
249 // Override functions end
250
256 const std::vector< std::vector<int> >& ComponentIndices() const { return m_dMuStarIndices; }
257
264 virtual double DeltaMu(int i) const { return MuShift(i); }
265
269 std::vector< std::vector<double> > m_chi;
270
274 std::vector<double> m_chiarb;
275 double ChiArb(int charge);
276
277 protected:
278
285
295 virtual std::vector<double> SearchSingleSolution(const std::vector<double>& muStarInit);
296
306 virtual std::vector<double> SearchSingleSolutionUsingComponents(const std::vector<double>& muStarInit);
307
317 virtual std::vector<double> SearchSingleSolutionDirect(const std::vector<double>& muStarInit);
318
330 std::vector<double> SearchMultipleSolutions(int iters = 300);
331
340 std::vector<double> SearchFirstSolution(int iters = 50);
341
344 void SolveEquations();
345
354 virtual double MuShift(int id) const;
355
357 std::vector<double> m_DensitiesId;
358
360 std::vector<double> m_scaldens;
361
364
367
370
372 std::vector<double> m_MuStar;
373
375 std::vector<int> m_MapTodMuStar;
376
378 std::vector<int> m_MapFromdMuStar;
379
381 std::vector< std::vector<int> > m_dMuStarIndices;
382
383
386
389
392
395 private:
401 class BroydenEquationsRealGas : public BroydenEquations
402 {
403 public:
409 BroydenEquationsRealGas(ThermalModelRealGas* model) : BroydenEquations(), m_THM(model) { m_N = model->ComponentsNumber(); }
410
417 std::vector<double> Equations(const std::vector<double>& x);
418 private:
420 ThermalModelRealGas* m_THM;
421 };
422
428 class BroydenJacobianRealGas : public BroydenJacobian
429 {
430 public:
436 BroydenJacobianRealGas(ThermalModelRealGas* model) : BroydenJacobian(), m_THM(model) { }
437
444 std::vector<double> Jacobian(const std::vector<double>& x);
445 private:
447 ThermalModelRealGas* m_THM;
448 };
449
455 class BroydenSolutionCriteriumRealGas : public Broyden::BroydenSolutionCriterium
456 {
457 public:
464 BroydenSolutionCriteriumRealGas(ThermalModelRealGas* model, double relative_error = Broyden::TOL) : Broyden::BroydenSolutionCriterium(relative_error), m_THM(model) { }
465
474 virtual bool IsSolved(const std::vector<double>& x, const std::vector<double>& f, const std::vector<double>& xdelta = std::vector<double>()) const;
475 protected:
477 ThermalModelRealGas* m_THM;
478 };
479
485 class BroydenEquationsRealGasComponents : public BroydenEquations
486 {
487 public:
493 BroydenEquationsRealGasComponents(ThermalModelRealGas* model) : BroydenEquations(), m_THM(model) { m_N = model->m_MapFromdMuStar.size(); }
494
501 std::vector<double> Equations(const std::vector<double>& x);
502 private:
504 ThermalModelRealGas* m_THM;
505 };
506
512 class BroydenJacobianRealGasComponents : public BroydenJacobian
513 {
514 public:
520 BroydenJacobianRealGasComponents(ThermalModelRealGas* model) : BroydenJacobian(), m_THM(model) { }
521
528 std::vector<double> Jacobian(const std::vector<double>& x);
529 private:
531 ThermalModelRealGas* m_THM;
532 };
533
534 };
535
536} // namespace thermalfist
537
538#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
BroydenEquations()=default
Default constructor. Does nothing.
static const double TOL
Default desired solution accuracy.
Definition Broyden.h:183
Class which implements calculation of the Jacobian needed for the Broyden's method.
Definition Broyden.h:77
BroydenJacobian(BroydenEquations *eqs=NULL)
Construct a new BroydenJacobian object.
Definition Broyden.h:89
Base class for multi-component excluded volume models.
Base class for multi-component mean field models.
int ComponentsNumber() const
Number of different particle species in the list.
ThermalModelBase(ThermalParticleSystem *TPS, const ThermalModelParameters &params=ThermalModelParameters())
Construct a new ThermalModelBase object.
Class implementing the quantum real gas HRG model.
void SetExcludedVolumeModel(ExcludedVolumeModelMultiBase *exvolmod)
Set the excluded volume model for the real gas HRG model.
void CalculateFluctuations()
Calculate the fluctuations.
void CalculateComponentsMap()
Partitions particles species into sets that have identical pair interactions.
std::vector< std::vector< int > > m_dMuStarIndices
Vector of component indices for each particle species.
ThermalModelRealGas(ThermalParticleSystem *TPS_, const ThermalModelParameters &params=ThermalModelParameters())
Construct a new ThermalModelRealGas object.
virtual std::vector< double > SearchSingleSolutionUsingComponents(const std::vector< double > &muStarInit)
Uses the Broyden method with a provided initial guess to determine the shifted chemical potentials by...
virtual double CalculateMesonMatterEntropyDensity()
Calculate the meson matter entropy density of the system.
bool m_ComponentMapCalculated
Whether the mapping to components with the same VDW parameters has been calculated.
ExcludedVolumeModelMultiBase * ExcludedVolumeModel() const
Get the excluded volume model used in the real gas HRG model.
std::vector< int > m_MapTodMuStar
Mapping from particle species to dMuStar indices.
virtual double CalculateBaryonMatterEntropyDensity()
Calculate the baryon matter entropy density of the system.
void SetMeanFieldModel(MeanFieldModelMultiBase *mfmod)
Set the mean field model for the real gas HRG model.
MeanFieldModelMultiBase * MeanFieldModel() const
Get the mean field model used in the real gas HRG model.
std::vector< double > SearchMultipleSolutions(int iters=300)
Uses the Broyden method with different initial guesses to look for different possible solutions of th...
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...
void SetMuStar(const std::vector< double > &MuStar)
Set the vector of shifted chemical potentials for all particle species.
double DensityId(int index)
Get the ideal gas density of a particle species.
virtual std::vector< double > SearchSingleSolutionDirect(const std::vector< double > &muStarInit)
Uses the Broyden method with a provided initial guess to determine the shifted chemical potentials by...
virtual double CalculateEnergyDensity()
Calculate the energy density of the system.
std::vector< double > m_chiarb
Vector of computed susceptibilities for a specified arbitraty charge.
ExcludedVolumeModelMultiBase * m_exvolmod
Excluded volume model used in the real gas HRG model.
virtual std::vector< double > CalculateChargeFluctuationsOld(const std::vector< double > &chgs, int order=4)
Calculate the charge fluctuations of the particle species (old method).
std::vector< int > m_MapFromdMuStar
Mapping from dMuStar indices to particle species.
std::vector< double > SearchFirstSolution(int iters=50)
Try different initial guesses and return the first valid solution found.
virtual void CalculateTemperatureDerivatives()
Calculate the temperature derivatives of the system.
void CalculateTwoParticleCorrelations()
Calculate the two-particle correlations of the particle species.
virtual void CalculatePrimordialDensities()
Calculate the primordial densities of the particle species.
virtual double MuShift(int id) const
The shift in the chemical potential of particle species i due to the QvdW interactions.
virtual double CalculateEntropyDensity()
Calculate the entropy density of the system.
virtual void SetChemicalPotentials(const std::vector< double > &chem=std::vector< double >(0))
Set the chemical potentials of the particle species.
const std::vector< std::vector< int > > & ComponentIndices() const
Get the component indices of the particle species.
std::vector< double > m_MuStar
Vector of the shifted chemical potentials.
virtual double CalculateEntropyDensityDerivativeT()
Calculate the derivative of the entropy density with respect to temperature.
bool m_LastBroydenSuccessFlag
Whether Broyden's method was successfull.
virtual double CalculateEnergyDensityDerivativeT()
Calculate the derivative of the energy density with respect to temperature.
std::vector< double > m_DensitiesId
Vector of ideal gas densities with shifted chemical potentials.
virtual void SetMultipleSolutionsMode(bool search)
Whether to search for multiple solutions of the real gas model equations by considering different ini...
virtual double CalculatePressure()
Calculate the pressure of the system.
virtual ~ThermalModelRealGas(void)
Destroy the ThermalModelRealGas object.
virtual bool UseMultipleSolutionsMode() const
Whether to search for multiple solutions of the real gas model equations by considering different ini...
ExcludedVolumeModelMultiBase * m_exvolmodideal
Excluded volume model object in the ideal gas limit.
void FillChemicalPotentials()
Fill the chemical potentials of the particle species.
std::vector< double > m_scaldens
Vector of scalar densities. Not used.
bool IsLastSolutionOK() const
Check if the last solution was successful.
std::vector< double > GetMuStar() const
Get the vector of shifted chemical potentials for all particle species.
MeanFieldModelMultiBase * m_mfmod
Mean field model used in the real gas HRG model.
MeanFieldModelMultiBase * m_mfmodideal
Mean field model object in the ideal gas limit.
std::vector< std::vector< double > > m_chi
Vector of computed susceptibilities values.
virtual std::vector< double > CalculateChargeFluctuations(const std::vector< double > &chgs, int order=4, bool dimensionfull=false)
Calculate the charge fluctuations of the particle species.
virtual double DeltaMu(int i) const
Get the delta mu (chemical potential shift due to interactions) of a particle species.
double MuStar(int i) const
Get the shifted chemical potential of a particle species.
virtual double ParticleScalarDensity(int part)
Calculate the scalar density of a particle species.
bool m_SearchMultipleSolutions
Whether multiple solutions are considered.
Class containing the particle list.
The main namespace where all classes and functions of the Thermal-FIST library reside.
Definition CosmicEoS.h:9
Structure containing all thermal parameters of the model.