24 #include <Eigen/Dense> 26 using namespace Eigen;
38 m_TAG =
"ThermalModelEVDiagonal";
61 printf(
"**WARNING** %s::FillVirial(const std::vector<double> & ri): size of ri does not match number of hadrons in the list",
m_TAG.c_str());
72 printf(
"**WARNING** %s::FillVirialEV(const std::vector<double> & vi): size of vi does not match number of hadrons in the list",
m_TAG.c_str());
82 ifstream fin(filename.c_str());
85 fin.getline(cc, 2000);
86 string tmp = string(cc);
90 istringstream iss(elems[0]);
93 if (iss >> pdgid >> b) {
104 ofstream fout(filename.c_str());
105 fout <<
"# List of eigenvolume parameters to be used in the Diagonal excluded-volume HRG model" 107 fout <<
"# Only particles with a non-zero eigenvolume parameter are listed here" 109 fout <<
"#" << std::setw(14) <<
"pdg" 110 << std::setw(15) <<
"v_i[fm^3]" 115 fout << std::setw(15) <<
m_v[i];
124 if (i < 0 || i >= static_cast<int>(
m_v.size()))
158 double dMu = -
m_v[i] * P;
166 BroydenEquationsDEV eqs(
this);
167 BroydenJacobianDEV jac(
this);
169 BroydenSolutionCriteriumDEV crit(
this, 1.0E-8);
176 std::vector<double> x(1, x0);
178 x = broydn.
Solve(x, &crit);
182 double PressureNew = mnc * exp(x[0]);
211 double densityid = 0., suppression = 0.;
215 #pragma omp parallel for reduction(+:densityid) reduction(+:suppression) if(useOpenMP) 244 vector<double> tN(NN), tW(NN);
249 for (
int i = 0; i < NN; ++i)
m_PrimCorrel[i].resize(NN);
252 for (
int i = 0; i < NN; ++i)
253 for (
int j = 0; j < NN; ++j) {
265 for (
int i = 0; i < NN; ++i) {
283 for (
size_t i = 0; i <
m_wprim.size(); ++i) {
288 for (
size_t i = 0; i <
m_wprim.size(); ++i) {
297 vector<double> ret(order + 1, 0.);
305 if (order < 2)
return ret;
312 vector<double> MuStar(NN, 0.);
313 for (
int i = 0; i < NN; ++i) {
318 MatrixXd densMatrix(2 * NN, 2 * NN);
319 VectorXd solVector(2 * NN), xVector(2 * NN);
322 for (
int i = 0; i < NN; ++i) {
327 for (
int i = 0; i < NN; ++i)
328 for (
int j = 0; j < NN; ++j) {
329 densMatrix(i, j) =
m_v[j] * DensitiesId[i];
330 if (i == j) densMatrix(i, j) += 1.;
333 for (
int i = 0; i < NN; ++i)
334 for (
int j = 0; j < NN; ++j)
335 densMatrix(i, NN + j) = 0.;
337 for (
int i = 0; i < NN; ++i) {
338 densMatrix(i, NN + i) = 0.;
339 for (
int k = 0; k < NN; ++k) {
345 for (
int i = 0; i < NN; ++i)
346 for (
int j = 0; j < NN; ++j) {
347 densMatrix(NN + i, NN + j) =
m_v[i] * DensitiesId[j];
348 if (i == j) densMatrix(NN + i, NN + j) += 1.;
352 PartialPivLU<MatrixXd> decomp(densMatrix);
355 vector<double> dni(NN, 0.), dmus(NN, 0.);
357 for (
int i = 0; i < NN; ++i) {
359 xVector[NN + i] = chgs[i];
362 solVector = decomp.solve(xVector);
364 for (
int i = 0; i < NN; ++i) {
365 dni[i] = solVector[i];
366 dmus[i] = solVector[NN + i];
369 for (
int i = 0; i < NN; ++i)
370 ret[1] += chgs[i] * dni[i];
374 if (order < 3)
return ret;
376 vector<double> d2ni(NN, 0.), d2mus(NN, 0.);
379 for (
int i = 0; i < NN; ++i)
382 for (
int i = 0; i < NN; ++i) {
386 for (
int j = 0; j < NN; ++j) tmp +=
m_v[j] * dni[j];
395 for (
int i = 0; i < NN; ++i) {
396 xVector[NN + i] = 0.;
401 xVector[NN + i] = tmp;
404 solVector = decomp.solve(xVector);
406 for (
int i = 0; i < NN; ++i) {
407 d2ni[i] = solVector[i];
408 d2mus[i] = solVector[NN + i];
411 for (
int i = 0; i < NN; ++i)
412 ret[2] += chgs[i] * d2ni[i];
417 if (order < 4)
return ret;
420 vector<double> d3ni(NN, 0.), d3mus(NN, 0.);
423 for (
int i = 0; i < NN; ++i)
426 vector<double> dnis(NN, 0.);
427 for (
int i = 0; i < NN; ++i) {
431 vector<double> d2nis(NN, 0.);
432 for (
int i = 0; i < NN; ++i) {
437 for (
int i = 0; i < NN; ++i) {
441 for (
int j = 0; j < NN; ++j) tmp +=
m_v[j] * dni[j];
442 tmp = -3. * tmp * d2nis[i];
446 for (
int j = 0; j < NN; ++j) tmp +=
m_v[j] * d2ni[j];
447 tmp = -3. * tmp * dnis[i];
456 tmp = -(tmps - 1.) * chi4id[i] * pow(
xMath::GeVtoifm(), 3) * dmus[i] * dmus[i] * dmus[i];
459 for (
int i = 0; i < NN; ++i) {
460 xVector[NN + i] = 0.;
463 for (
int j = 0; j < NN; ++j) tmp += -2. *
m_v[i] * d2mus[j] * dnis[j];
464 xVector[NN + i] += tmp;
467 for (
int j = 0; j < NN; ++j) tmp += -
m_v[i] * dmus[j] * d2nis[j];
468 xVector[NN + i] += tmp;
471 solVector = decomp.solve(xVector);
473 for (
int i = 0; i < NN; ++i) {
474 d3ni[i] = solVector[i];
475 d3mus[i] = solVector[NN + i];
478 for (
int i = 0; i < NN; ++i)
479 ret[3] += chgs[i] * d3ni[i];
531 if (
id >= 0. &&
id < static_cast<int>(
m_v.size()))
547 if (i >= 0 && i < static_cast<int>(
m_v.size()))
562 std::vector<double> ThermalModelEVDiagonal::BroydenEquationsDEV::Equations(
const std::vector<double>& x)
564 std::vector<double> ret(1);
565 double pressure = m_mnc * exp(x[0]);
567 ret[0] = pressure - m_THM->Pressure(pressure);
572 std::vector<double> ThermalModelEVDiagonal::BroydenJacobianDEV::Jacobian(
const std::vector<double>& x)
574 double pressure = m_mnc * exp(x[0]);
577 for (
size_t i = 0; i < m_THM->Densities().size(); ++i)
578 ret += m_THM->VirialCoefficient(i, i) * m_THM->DensityId(i, pressure);
582 return std::vector<double>(1, ret);
585 std::vector<double> ThermalModelEVDiagonal::BroydenEquationsDEVOrig::Equations(
const std::vector<double>& x)
587 std::vector<double> ret(1);
588 ret[0] = x[0] - m_THM->Pressure(x[0]);
592 std::vector<double> ThermalModelEVDiagonal::BroydenJacobianDEVOrig::Jacobian(
const std::vector<double>& x)
594 const double &pressure = x[0];
597 for (
size_t i = 0; i < m_THM->Densities().size(); ++i)
598 ret += m_THM->VirialCoefficient(i, i) * m_THM->DensityId(i, pressure);
601 return std::vector<double>(1, ret);
604 bool ThermalModelEVDiagonal::BroydenSolutionCriteriumDEV::IsSolved(
const std::vector<double>& x,
const std::vector<double>& f,
const std::vector<double>& )
const 607 for (
size_t i = 0; i < x.size(); ++i) {
608 maxdiff = std::max(maxdiff, fabs(f[i]) / m_THM->m_Pressure);
610 return (maxdiff < m_MaximumError);
virtual double CalculatePressure()
Implementation of the equation of state functions.
Abstract base class for an HRG model implementation.
virtual void CalculateTwoParticleFluctuationsDecays()
Computes particle number correlations and fluctuations for all final-state particles which are marked...
std::vector< std::string > split(const std::string &s, char delim)
std::vector< double > m_Chem
double CommonSuppressionFactor()
The density suppression factor , common for all species.
Class implementing the Broyden method to solve a system of non-linear equations.
double GeVtoifm()
A constant to transform GeV into fm .
std::vector< double > m_kurttot
std::vector< double > m_wprim
const ThermalParticle & Particle(int id) const
ThermalParticle object corresponding to particle species with a provided 0-based index.
std::vector< double > m_skewprim
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...
bool m_FluctuationsCalculated
int PdgToId(long long pdgid)
Transforms PDG ID to a 0-based particle id number.
long long PdgId() const
Particle's Particle Data Group (PDG) ID number.
Class containing the particle list.
Grand canonical ensemble.
ThermalModelParameters m_Parameters
Structure containing all thermal parameters of the model.
int ComponentsNumber() const
Number of different particle species in the list.
virtual double CalculateEnergyDensity()
virtual void CalculateFluctuations()
Computes the fluctuation observables.
double ScaledVarianceId(int i, double Pressure)
Calculate the ideal gas scaled variance of particle species i number fluctuations for the given press...
virtual void CalculateTwoParticleCorrelations()
Computes the fluctuations and correlations of the primordial particle numbers.
void FillVirial(const std::vector< double > &ri=std::vector< double >(0))
Fills the vector of particle eigenvolume parameters.
double VirialCoefficient(int i, int j) const
Return the eigenvolume parameter of particle species i.
virtual void CalculateSusceptibilityMatrix()
Calculates the conserved charges susceptibility matrix.
Contains some extra mathematical functions used in the code.
ThermalParticleSystem * m_TPS
virtual ~ThermalModelEVDiagonal(void)
Destroy the ThermalModelEVDiagonal object.
virtual void CalculatePrimordialDensities()
Calculates the primordial densities of all species.
int MaxIterations() const
virtual void CalculateProxySusceptibilityMatrix()
Calculates the susceptibility matrix of conserved charges proxies.
virtual std::vector< double > Solve(const std::vector< double > &x0, BroydenSolutionCriterium *solcrit=NULL, int max_iterations=MAX_ITERS)
std::vector< double > m_kurtprim
const std::vector< ThermalParticle > & Particles() const
Returns the vector of all particle species.
std::vector< std::vector< double > > m_TotalCorrel
ThermalModelInteraction m_InteractionModel
virtual void ValidateCalculation()
Checks whether issues have occured during the calculation of particle densities in the CalculateDensi...
virtual void WriteInteractionParameters(const std::string &filename)
Write the set of eigenvolume parameters for all particles to an external file.
Contains some functions do deal with excluded volumes.
std::vector< double > m_densitiesidnoshift
void SetVirial(int i, int j, double b)
Sets the eigenvolume parameter of particle species i.
double MaxDifference() const
virtual double ParticleKurtosis(int)
Kurtosis of primordial particle number fluctuations for species i.
std::vector< double > m_v
virtual double MuShift(int i) const
The shift in the chemical potential of particle species i due to the excluded volume interactions...
double ExcludedVolume(int i) const
The excluded volume parameter of particle species i.
virtual void CalculateDensities()
Calculates the primordial and total (after decays) densities of all species.
virtual void SolvePressure()
Solves the transcdental equation for the pressure.
Diagonal excluded volume model.
std::vector< double > m_densities
std::vector< double > m_densitiesid
virtual double CalculateEntropyDensity()
virtual std::vector< double > CalculateChargeFluctuations(const std::vector< double > &chgs, int order=4)
Calculates fluctuations (diagonal susceptibilities) of an arbitrary "conserved" charge.
virtual void ChangeTPS(ThermalParticleSystem *TPS)
Change the particle list.
std::vector< std::vector< double > > m_PrimCorrel
ThermalModelEnsemble m_Ensemble
virtual void CalculateFeeddown()
Calculates the total densities which include feeddown contributions.
std::vector< double > m_skewtot
virtual void CalculateParticleChargeCorrelationMatrix()
Calculates the matrix of correlators between primordial (and also final) particle numbers and conserv...
double DensityId(int i, double Pressure)
Calculate the ideal gas density of particle species i for the given pressure value.
virtual void ChangeTPS(ThermalParticleSystem *TPS)
Change the particle list.
double PressureId(int i, double Pressure)
Calculate the ideal gas pressure of particle species i for the given pressure value.
virtual double CalculateEigenvolumeFraction()
double vr(double r)
Computes the excluded volume parameter from a given radius parameter value.
bool m_LastCalculationSuccessFlag
double Pressure()
System pressure (GeV fm )
The main namespace where all classes and functions of the Thermal-FIST library reside.
void SetRadius(double rad)
Set the same excluded volume radius parameter for all species.
virtual double ParticleScalarDensity(int part)
The scalar density of the particle species i.
virtual double ParticleSkewness(int)
Skewness of primordial particle number fluctuations for species i.
virtual void ReadInteractionParameters(const std::string &filename)
Read the set of eigenvolume parameters for all particles from an external file.
ThermalParticleSystem * TPS()