23 ThermalModelBase(TPS_, params), m_BCE(1), m_QCE(1), m_SCE(1), m_CCE(1), m_IntegrationIterationsMultiplier(1)
26 m_TAG =
"ThermalModelCanonical";
78 if (computeFluctuations) {
191 if (ind < static_cast<int>(
m_Corr.size()))
197 if (ind < static_cast<int>(
m_Corr.size()))
220 sprintf(cc,
"**WARNING** ThermalModelCanonical: Inaccurate calculation of total baryon number.\ 238 sprintf(cc,
"**WARNING** ThermalModelCanonical: Inaccurate calculation of total electric charge.\ 256 sprintf(cc,
"**WARNING** ThermalModelCanonical: Inaccurate calculation of total strangeness.\ 274 sprintf(cc,
"**WARNING** ThermalModelCanonical: Inaccurate calculation of total charm.\ 302 printf(
"**ERROR** ThermalModelCanonical::CalculatePartitionFunctions: Partial chemical equilibrium canonical ensemble only supported if particle-antiparticle fugacities are symmetric!\n");
309 bool AllMuZero =
true;
328 printf(
"**ERROR** ThermalModelCanonical: neutral particle cannot have non-zero ce charges\n");
331 if (ind < static_cast<int>(Nsx.size()))
337 if (ind < static_cast<int>(Nsx.size())) {
353 if (ind < static_cast<int>(Nsx.size())) {
369 for (
int i = 0; i < static_cast<int>(Nsx.size()); ++i) {
388 nmaxB = nmaxQ = nmaxS = nmaxC = nmax;
396 for (
size_t i = 0; i <
m_PartialZ.size(); ++i) {
404 int maxB = 2 * nmaxB;
408 for (
int iB = 0; iB < maxB; ++iB) {
410 vector<double> xlegB, wlegB;
413 double aB = iB * dphiB;
414 if (iB >= nmaxB) aB =
xMath::Pi() - (iB + 1) * dphiB;
415 double bB = aB + dphiB;
427 int maxS = 2 * nmaxS;
431 for (
int iS = 0; iS < maxS; ++iS) {
432 vector<double> xlegS, wlegS;
435 double aS = iS * dphiS;
436 if (iS >= nmaxS) aS =
xMath::Pi() - (iS + 1) * dphiS;
437 double bS = aS + dphiS;
452 for (
int iQ = 0; iQ < maxQ; ++iQ) {
453 vector<double> xlegQ, wlegQ;
456 double aQ = iQ * dphiQ;
457 double bQ = aQ + dphiQ;
468 int maxC = 2 * nmaxC;
472 for (
int iC = 0; iC < maxC; ++iC) {
473 vector<double> xlegC, wlegC;
475 double aC = iC * dphiC;
476 if (iC >= nmaxC) aC =
xMath::Pi() - (iC + 1) * dphiC;
477 double bC = aC + dphiC;
487 for (
size_t iBt = 0; iBt < xlegB.size(); ++iBt) {
488 for (
size_t iSt = 0; iSt < xlegS.size(); ++iSt) {
489 for (
size_t iQt = 0; iQt < xlegQ.size(); ++iQt) {
490 for (
size_t iCt = 0; iCt < xlegC.size(); ++iCt) {
492 double wx = 0., wy = 0., mx = 0., my = 0.;
493 for (
size_t i = 0; i <
m_PartialZ.size(); ++i) {
500 cosph[i] = cos(tS*xlegS[iSt] + tQ * xlegQ[iQt] + tC * xlegC[iCt]);
501 sinph[i] = sin(tS*xlegS[iSt] + tQ * xlegQ[iQt] + tC * xlegC[iCt]);
504 wx += Nsx[i] * cosph[i];
505 wy += Nsx[i] * sinph[i];
508 mx += Nsx[i] * (cosph[i] - 1.);
512 cosph[i] = cos(tB*xlegB[iBt] + tS * xlegS[iSt] + tQ * xlegQ[iQt] + tC * xlegC[iCt]);
513 mx += Nsx[i] * (cosph[i] - 1.);
516 sinph[i] = sin(tB*xlegB[iBt] + tS * xlegS[iSt] + tQ * xlegQ[iQt] + tC * xlegC[iCt]);
517 my += Nsy[i] * sinph[i];
526 wmod = sqrt(wx*wx + wy * wy);
527 warg = atan2(wy, wx);
530 for (
size_t iN = 0; iN <
m_PartialZ.size(); ++iN) {
538 m_PartialZ[iN] += wlegB[iBt] * wlegS[iSt] * wlegQ[iQt] * wlegC[iCt] *
539 cos(tBg * xlegB[iBt] + tSg * xlegS[iSt] + tQg * xlegQ[iQt] + tCg * xlegC[iCt] - tBg * warg) *
545 m_PartialZ[iN] += wlegB[iBt] * wlegS[iSt] * wlegQ[iQt] * wlegC[iCt] * cos(tBg*xlegB[iBt] + tSg * xlegS[iSt] + tQg * xlegQ[iQt] + tCg * xlegC[iCt]) * exp(mx);
547 m_PartialZ[iN] += wlegB[iBt] * wlegS[iSt] * wlegQ[iQt] * wlegC[iCt] * exp(mx)
548 * (cos(tBg*xlegB[iBt] + tSg * xlegS[iSt] + tQg * xlegQ[iQt] + tCg * xlegC[iCt]) * cos(my)
549 + sin(tBg*xlegB[iBt] + tSg * xlegS[iSt] + tQg * xlegQ[iQt] + tCg * xlegC[iCt]) * sin(my));
564 for (
size_t iN = 0; iN <
m_PartialZ.size(); ++iN) {
579 for (
size_t iN = 0; iN <
m_PartialZ.size(); ++iN) {
587 double ret1 = 0., ret2 = 0., ret3 = 0.;
599 if (ind < static_cast<int>(
m_Corr.size()) && ind2 < static_cast<int>(
m_Corr.size()))
602 if (ind < static_cast<int>(
m_Corr.size()))
606 double ret1num = 0., ret1zn = 0.;
612 if (ind < static_cast<int>(
m_Corr.size())) {
613 ret1num +=
m_Corr[ind] * n * densityClusterN;
614 ret1zn +=
m_Corr[ind] * densityClusterN;
620 if (ind < static_cast<int>(
m_Corr.size()) && ind2 < static_cast<int>(
m_Corr.size()))
629 ret1 = ret1num / ret1zn;
630 ret2 = ret2 / ret1zn;
633 return ret1 + ret2 + ret3;
639 vector<double> yld(NN, 0);
640 vector<double> ret1num(NN, 0);
641 vector< vector<double> > ret2num(NN, vector<double>(NN, 0.));
643 for (
int i = 0; i < NN; ++i)
646 for (
int i = 0; i < NN; ++i) {
662 if (ind < static_cast<int>(
m_Corr.size()))
668 for (
int i = 0; i < NN; ++i) {
669 for (
int j = 0; j < NN; ++j) {
682 ret2num[i][j] = yld[i] * yld[j];
685 for (
int n1 = 1; n1 <= n1max; ++n1) {
686 for (
int n2 = 1; n2 <= n2max; ++n2) {
696 if (ind < static_cast<int>(
m_Corr.size()))
706 for (
int i = 0; i < NN; ++i)
710 for (
int i = 0; i < NN; ++i) {
711 for (
int j = 0; j < NN; ++j) {
723 for (
int i = 0; i < NN; ++i) {
740 for (
size_t i = 0; i <
m_wprim.size(); ++i) {
762 if (ind < static_cast<int>(
m_Corr.size()))
768 if (ind < static_cast<int>(
m_Corr.size()))
792 if (ind < static_cast<int>(
m_Corr.size()))
799 if (ind < static_cast<int>(
m_Corr.size()))
864 void ThermalModelCanonical::PrepareModelGCE()
885 static_cast<bool>(
m_BCE),
886 static_cast<bool>(
m_QCE),
887 static_cast<bool>(
m_SCE),
888 static_cast<bool>(
m_CCE));
908 void ThermalModelCanonical::CleanModelGCE()
virtual double ParticleScaledVariance(int part)
Scaled variance of primordial particle number fluctuations for species i.
Abstract base class for an HRG model implementation.
std::vector< QuantumNumbers > m_QNvec
A set of QuantumNumbers combinations for which it is necessary to compute the canonical partition fun...
virtual void CalculateTwoParticleFluctuationsDecays()
Computes particle number correlations and fluctuations for all final-state particles which are marked...
std::vector< double > m_Chem
double DensityCluster(int n, const ThermalModelParameters ¶ms, IdealGasFunctions::Quantity type=IdealGasFunctions::ParticleDensity, bool useWidth=0, double mu=0.) const
virtual void ValidateCalculation()
Checks whether issues have occured during the calculation of particle densities in the CalculateDensi...
std::vector< double > m_kurttot
int Charm() const
Particle's charm.
int ClusterExpansionOrder() const
Number of terms in the cluster expansion method.
std::vector< double > m_wprim
double Density(const ThermalModelParameters ¶ms, IdealGasFunctions::Quantity type=IdealGasFunctions::ParticleDensity, bool useWidth=0, double mu=0.) const
Computes a specified ideal gas thermodynamic function.
const ThermalParticle & Particle(int id) const
ThermalParticle object corresponding to particle species with a provided 0-based index.
std::vector< double > m_skewprim
virtual void FixParameters()
Method which actually implements ConstrainChemicalPotentials() (for backward compatibility).
bool m_FluctuationsCalculated
virtual void CalculatePrimordialDensities()
Calculates the primordial densities of all species.
void SetUseWidth(bool useWidth)
Sets whether finite resonance widths are used. Deprecated.
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.
virtual void FixParameters()
Method which actually implements ConstrainChemicalPotentials() (for backward compatibility).
ThermalModelParameters m_Parameters
Structure containing all thermal parameters of the model.
virtual double CalculateStrangenessDensity()
int ComponentsNumber() const
Number of different particle species in the list.
virtual ~ThermalModelCanonical(void)
Destroy the ThermalModelCanonical object.
ThermalModelIdeal * m_modelgce
virtual double CalculateBaryonDensity()
virtual double CalculateCharmDensity()
virtual void CalculateSusceptibilityMatrix()
Calculates the conserved charges susceptibility matrix.
double BesselIexp(int n, double x)
Contains some extra mathematical functions used in the code.
ThermalParticleSystem * m_TPS
std::string m_ValidityLog
double ScaledVariance(const ThermalModelParameters ¶ms, bool useWidth=0, double mu=0.) const
Computes the scaled variance of particle number fluctuations in the ideal gas. Computes the scaled va...
virtual void FillChemicalPotentials()
Sets the chemical potentials of all particles.
virtual void FixParametersNoReset()
Method which actually implements ConstrainChemicalPotentialsNoReset() (for backward compatibility)...
int BaryonCharge() const
Particle's baryon number.
virtual void CalculateQuantumNumbersRange(bool computeFluctuations=false)
Calculates the range of quantum numbers values for which it is necessary to compute the canonical par...
Class containing all information about a particle specie.
virtual void CalculateProxySusceptibilityMatrix()
Calculates the susceptibility matrix of conserved charges proxies.
virtual void FixParametersNoReset()
Method which actually implements ConstrainChemicalPotentialsNoReset() (for backward compatibility)...
virtual double CalculateChargeDensity()
virtual void CalculateFluctuations()
Computes the fluctuation observables.
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 bool SolveChemicalPotentials(double totB=0., double totQ=0., double totS=0., double totC=0., double muBinit=0., double muQinit=0., double muSinit=0., double muCinit=0., bool ConstrMuB=true, bool ConstrMuQ=true, bool ConstrMuS=true, bool ConstrMuC=true)
The procedure which calculates the chemical potentials which reproduce the specified total baryon...
void UseStatistics(bool enable)
Use quantum statistics.
void GetCoefsIntegrateLegendre10(double a, double b, std::vector< double > *x, std::vector< double > *w)
Name
Set of all conserved charges considered.
std::vector< double > m_PartialZ
The computed canonical partition function.
virtual double CalculatePressure()
Implementation of the equation of state functions.
virtual double GetGCEDensity(int i) const
Density of particle species i in the grand-canonical ensemble.
virtual void CalculatePartitionFunctions(double Vc=-1.)
Calculates all necessary canonical partition functions.
IdealGasFunctions::QStatsCalculationType CalculationType() const
Method to evaluate quantum statistics.
virtual void CalculateDensities()
Calculates the primordial and total (after decays) densities of all species.
Struct containing a set of quantum numbers: Baryon number, electric charge, strangeness, and charm.
virtual void CalculateTwoParticleCorrelations()
Computes the fluctuations and correlations of the primordial particle numbers.
std::vector< double > m_densities
std::vector< double > m_Corr
A vector of chemical factors.
virtual void ChangeTPS(ThermalParticleSystem *TPS)
Change the particle list.
std::vector< std::vector< double > > m_PrimCorrel
bool UsePartialChemicalEquilibrium()
Whether partial chemical equilibrium with additional chemical potentials is used. ...
ThermalModelEnsemble m_Ensemble
virtual bool IsConservedChargeCanonical(ConservedCharge::Name charge) const
Whether the given conserved charge is treated canonically.
std::vector< double > m_skewtot
void SetCalculationType(IdealGasFunctions::QStatsCalculationType type)
Sets the CalculationType() method to evaluate quantum statistics.
virtual void CalculateParticleChargeCorrelationMatrix()
Calculates the matrix of correlators between primordial (and also final) particle numbers and conserv...
Class implementing the Ideal HRG model.
int ElectricCharge() const
Particle's electric charge.
int Strangeness() const
Particle's strangeness.
virtual void SetStatistics(bool stats)
virtual bool IsParticleCanonical(const ThermalParticle &part)
Determines whether the specified ThermalParticle is treat canonically or grand-canonically in the pre...
const ThermalModelParameters & Parameters() const
void ChangeTPS(ThermalParticleSystem *TPS)
Change the particle list.
bool m_LastCalculationSuccessFlag
The main namespace where all classes and functions of the Thermal-FIST library reside.
virtual void SetChemicalPotentials(const std::vector< double > &chem=std::vector< double >(0))
Sets the chemical potentials of all particles.
int m_IntegrationIterationsMultiplier
A multiplier to increase the number of iterations during the numerical integration used to calculate ...
virtual double CalculateEnergyDensity()
std::map< QuantumNumbers, int > m_QNMap
Maps QuantumNumbers combinations to a 1-dimensional index.
int Statistics() const
Particle's statistics.
virtual double CalculateEntropyDensity()