Thermal-FIST  1.3
Package for hadron resonance gas model applications
IdealGasFunctions.cpp
Go to the documentation of this file.
1 /*
2  * Thermal-FIST package
3  *
4  * Copyright (c) 2017-2019 Volodymyr Vovchenko
5  *
6  * GNU General Public License (GPLv3 or later)
7  */
9 
10 #include <stdio.h>
11 #include <cmath>
12 #include <sstream>
13 #include <stdexcept>
14 #include <cfloat>
15 #include <vector>
16 
17 #include "HRGBase/xMath.h"
19 
20 using namespace std;
21 
22 namespace thermalfist {
23 
24  namespace IdealGasFunctions {
25 
26  bool calculationHadBECIssue = false;
27 
28  double BoltzmannDensity(double T, double mu, double m, double deg) {
29  if (m == 0.)
30  return deg * T * T * T / 2. / xMath::Pi() / xMath::Pi() * 2. * exp(mu/ T) * xMath::GeVtoifm3();
31  return deg * m * m * T / 2. / xMath::Pi() / xMath::Pi() * xMath::BesselKexp(2, m / T) * exp((mu - m) / T) * xMath::GeVtoifm3();
32  }
33 
34  double BoltzmannPressure(double T, double mu, double m, double deg) {
35  return T * BoltzmannDensity(T, mu, m, deg);
36  }
37 
38  double BoltzmannEnergyDensity(double T, double mu, double m, double deg) {
39  if (m == 0.)
40  return 3 * T * BoltzmannDensity(T, mu, m, deg);
41  return (3 * T + m * xMath::BesselK1exp(m / T) / xMath::BesselKexp(2, m / T)) * BoltzmannDensity(T, mu, m, deg);
42  }
43 
44  double BoltzmannEntropyDensity(double T, double mu, double m, double deg) {
45  return (BoltzmannPressure(T, mu, m, deg) + BoltzmannEnergyDensity(T, mu, m, deg) - mu * BoltzmannDensity(T, mu, m, deg)) / T;
46  }
47 
48  double BoltzmannScalarDensity(double T, double mu, double m, double deg) {
49  if (m == 0.)
50  return 0.;
51  return deg * m * m * T / 2. / xMath::Pi() / xMath::Pi() * xMath::BesselKexp(1, m / T) * exp((mu - m) / T) * xMath::GeVtoifm3();
52  }
53 
54  double BoltzmannTdndmu(int /*N*/, double T, double mu, double m, double deg)
55  {
56  return BoltzmannDensity(T, mu, m, deg);
57  }
58 
59  double BoltzmannChiN(int N, double T, double mu, double m, double deg)
60  {
61  return BoltzmannTdndmu(N - 1, T, mu, m, deg) / pow(T, 3) / xMath::GeVtoifm3();
62  }
63 
64  double QuantumClusterExpansionDensity(int statistics, double T, double mu, double m, double deg, int order)
65  {
66  double sign = 1.;
67  bool signchange = true;
68  if (statistics == 1) //Fermi
69  signchange = true;
70  else if (statistics == -1) //Bose
71  signchange = false;
72  else
73  return BoltzmannDensity(T, mu, m, deg);
74 
75  double tfug = exp((mu - m) / T);
76  double cfug = tfug;
77  double moverT = m / T;
78  double ret = 0.;
79  for (int i = 1; i <= order; ++i) {
80  ret += sign * xMath::BesselKexp(2, i*moverT) * cfug / static_cast<double>(i);
81  cfug *= tfug;
82  if (signchange) sign = -sign;
83  }
84  ret *= deg * m * m * T / 2. / xMath::Pi() / xMath::Pi() * xMath::GeVtoifm3();
85  return ret;
86  }
87 
88  double QuantumClusterExpansionPressure(int statistics, double T, double mu, double m, double deg, int order)
89  {
90  double sign = 1.;
91  bool signchange = true;
92  if (statistics == 1) //Fermi
93  signchange = true;
94  else if (statistics == -1) //Bose
95  signchange = false;
96  else
97  return BoltzmannPressure(T, mu, m, deg);
98 
99  double tfug = exp((mu - m) / T);
100  double cfug = tfug;
101  double moverT = m / T;
102  double ret = 0.;
103  for (int i = 1; i <= order; ++i) {
104  ret += sign * xMath::BesselKexp(2, i*moverT) * cfug / static_cast<double>(i) / static_cast<double>(i);
105  cfug *= tfug;
106  if (signchange) sign = -sign;
107  }
108  ret *= deg * m * m * T * T / 2. / xMath::Pi() / xMath::Pi() * xMath::GeVtoifm3();
109  return ret;
110  }
111 
112  double QuantumClusterExpansionEnergyDensity(int statistics, double T, double mu, double m, double deg, int order)
113  {
114  double sign = 1.;
115  bool signchange = true;
116  if (statistics == 1) //Fermi
117  signchange = true;
118  else if (statistics == -1) //Bose
119  signchange = false;
120  else
121  return BoltzmannEnergyDensity(T, mu, m, deg);
122 
123  double tfug = exp((mu - m) / T);
124  double cfug = tfug;
125  double moverT = m / T;
126  double ret = 0.;
127  for (int i = 1; i <= order; ++i) {
128  ret += sign * (xMath::BesselKexp(1, i*moverT) + 3. * xMath::BesselKexp(2, i*moverT) / moverT / static_cast<double>(i)) * cfug / static_cast<double>(i);
129  cfug *= tfug;
130  if (signchange) sign = -sign;
131  }
132  ret *= deg * m * m * m * T / 2. / xMath::Pi() / xMath::Pi() * xMath::GeVtoifm3();
133  return ret;
134  }
135 
136  double QuantumClusterExpansionEntropyDensity(int statistics, double T, double mu, double m, double deg, int order)
137  {
138  return (QuantumClusterExpansionPressure(statistics, T, mu, m, deg, order) + QuantumClusterExpansionEnergyDensity(statistics, T, mu, m, deg, order) - mu * QuantumClusterExpansionDensity(statistics, T, mu, m, deg, order)) / T;
139  }
140 
141  double QuantumClusterExpansionScalarDensity(int statistics, double T, double mu, double m, double deg, int order)
142  {
143  double sign = 1.;
144  bool signchange = true;
145  if (statistics == 1) //Fermi
146  signchange = true;
147  else if (statistics == -1) //Bose
148  signchange = false;
149  else
150  return BoltzmannScalarDensity(T, mu, m, deg);
151 
152  double tfug = exp((mu - m) / T);
153  double cfug = tfug;
154  double moverT = m / T;
155  double ret = 0.;
156  for (int i = 1; i <= order; ++i) {
157  ret += sign * xMath::BesselKexp(1, i*moverT) * cfug / static_cast<double>(i);
158  cfug *= tfug;
159  if (signchange) sign = -sign;
160  }
161  ret *= deg * m * m * T / 2. / xMath::Pi() / xMath::Pi() * xMath::GeVtoifm3();
162  return ret;
163  }
164 
165  double QuantumClusterExpansionTdndmu(int N, int statistics, double T, double mu, double m, double deg, int order)
166  {
167  double sign = 1.;
168  bool signchange = true;
169  if (statistics == 1) //Fermi
170  signchange = true;
171  else if (statistics == -1) //Bose
172  signchange = false;
173  else
174  return BoltzmannTdndmu(N, T, mu, m, deg);
175 
176  double tfug = exp((mu - m) / T);
177  double cfug = tfug;
178  double moverT = m / T;
179  double ret = 0.;
180  for (int i = 1; i <= order; ++i) {
181  ret += sign * xMath::BesselKexp(2, i*moverT) * cfug * pow(static_cast<double>(i), N - 1);
182  cfug *= tfug;
183  if (signchange) sign = -sign;
184  }
185  ret *= deg * m * m * T / 2. / xMath::Pi() / xMath::Pi() * xMath::GeVtoifm3();
186  return ret;
187  }
188 
189  double QuantumClusterExpansionChiN(int N, int statistics, double T, double mu, double m, double deg, int order)
190  {
191  return QuantumClusterExpansionTdndmu(N - 1, statistics, T, mu, m, deg, order) / pow(T, 3) / xMath::GeVtoifm3();
192  }
193 
194 
195  // Gauss-Legendre 32-point quadrature for [0,1] interval
198  // Gauss-Laguerre 32-point quadrature for [0,\infty] interval
201 
202  double QuantumNumericalIntegrationDensity(int statistics, double T, double mu, double m, double deg)
203  {
204  if (statistics == 0) return BoltzmannDensity(T, mu, m, deg);
205  if (statistics == 1 && mu > m) return FermiNumericalIntegrationLargeMuDensity(T, mu, m, deg);
206  if (statistics == -1 && mu > m) {
207  printf("**WARNING** QuantumNumericalIntegrationDensity: Bose-Einstein condensation, mass = %lf, mu = %lf\n", m, mu);
208  calculationHadBECIssue = true;
209  return 0.;
210  }
211 
212  double ret = 0.;
213  double moverT = m / T;
214  double muoverT = mu / T;
215  for (int i = 0; i < 32; i++) {
216  double tx = lagx32[i];
217  ret += lagw32[i] * T * tx * T * tx * T / (exp(sqrt(tx*tx + moverT * moverT) - muoverT) + statistics);
218  }
219 
220  ret *= deg / 2. / xMath::Pi() / xMath::Pi() * xMath::GeVtoifm3();
221 
222  return ret;
223  }
224 
225  double QuantumNumericalIntegrationPressure(int statistics, double T, double mu, double m, double deg)
226  {
227  if (statistics == 0) return BoltzmannPressure(T, mu, m, deg);
228  if (statistics == 1 && mu > m) return FermiNumericalIntegrationLargeMuPressure(T, mu, m, deg);
229  if (statistics == -1 && mu > m) {
230  printf("**WARNING** QuantumNumericalIntegrationPressure: Bose-Einstein condensation\n");
231  calculationHadBECIssue = true;
232  return 0.;
233  }
234 
235  double ret = 0.;
236  double moverT = m / T;
237  double muoverT = mu / T;
238  for (int i = 0; i < 32; i++) {
239  double tx = lagx32[i];
240  double x2 = tx * T * tx * T;
241  double E = sqrt(tx*tx + moverT * moverT);
242  ret += lagw32[i] * T * x2 * x2 / E / T / (exp(E - muoverT) + statistics);
243  }
244 
245  ret *= deg / 6. / xMath::Pi() / xMath::Pi() * xMath::GeVtoifm3();
246 
247  return ret;
248  }
249 
250  double QuantumNumericalIntegrationEnergyDensity(int statistics, double T, double mu, double m, double deg)
251  {
252  if (statistics == 0) return BoltzmannEnergyDensity(T, mu, m, deg);
253  if (statistics == 1 && mu > m) return FermiNumericalIntegrationLargeMuEnergyDensity(T, mu, m, deg);
254  if (statistics == -1 && mu > m) {
255  printf("**WARNING** QuantumNumericalIntegrationEnergyDensity: Bose-Einstein condensation\n");
256  calculationHadBECIssue = true;
257  return 0.;
258  }
259 
260  double ret = 0.;
261  double moverT = m / T;
262  double muoverT = mu / T;
263  for (int i = 0; i < 32; i++) {
264  double tx = lagx32[i];
265  ret += lagw32[i] * T * tx * T * tx * T * sqrt(tx*tx + moverT * moverT) * T / (exp(sqrt(tx*tx + moverT * moverT) - muoverT) + statistics);
266  }
267 
268  ret *= deg / 2. / xMath::Pi() / xMath::Pi() * xMath::GeVtoifm3();
269 
270  return ret;
271  }
272 
273  double QuantumNumericalIntegrationEntropyDensity(int statistics, double T, double mu, double m, double deg)
274  {
275  return (QuantumNumericalIntegrationPressure(statistics, T, mu, m, deg) + QuantumNumericalIntegrationEnergyDensity(statistics, T, mu, m, deg) - mu * QuantumNumericalIntegrationDensity(statistics, T, mu, m, deg)) / T;
276  }
277 
278  double QuantumNumericalIntegrationScalarDensity(int statistics, double T, double mu, double m, double deg)
279  {
280  if (statistics == 0) return BoltzmannScalarDensity(T, mu, m, deg);
281  if (statistics == 1 && mu > m) return FermiNumericalIntegrationLargeMuScalarDensity(T, mu, m, deg);
282  if (statistics == -1 && mu > m) {
283  printf("**WARNING** QuantumNumericalIntegrationScalarDensity: Bose-Einstein condensation\n");
284  calculationHadBECIssue = true;
285  return 0.;
286  }
287 
288  double ret = 0.;
289  double moverT = m / T;
290  double muoverT = mu / T;
291  for (int i = 0; i < 32; i++) {
292  double tx = lagx32[i];
293  ret += lagw32[i] * T * tx * T * tx * T * moverT / sqrt(tx*tx + moverT * moverT) / (exp(sqrt(tx*tx + moverT * moverT) - muoverT) + statistics);
294  }
295 
296  ret *= deg / 2. / xMath::Pi() / xMath::Pi() * xMath::GeVtoifm3();
297 
298  return ret;
299  }
300 
301  double QuantumNumericalIntegrationT1dn1dmu1(int statistics, double T, double mu, double m, double deg)
302  {
303  if (statistics == 0) return BoltzmannTdndmu(1, T, mu, m, deg);
304  if (statistics == 1 && mu > m) return FermiNumericalIntegrationLargeMuT1dn1dmu1(T, mu, m, deg);
305  if (statistics == -1 && mu > m) {
306  printf("**WARNING** QuantumNumericalIntegrationT1dn1dmu1: Bose-Einstein condensation\n");
307  calculationHadBECIssue = true;
308  return 0.;
309  }
310 
311  double ret = 0.;
312  double moverT = m / T;
313  double muoverT = mu / T;
314  for (int i = 0; i < 32; i++) {
315  double tx = lagx32[i];
316  double Eexp = exp(sqrt(tx*tx + moverT * moverT) - muoverT);
317  ret += lagw32[i] * T * tx * T * tx * T * 1. / (1. + statistics / Eexp) / (Eexp + statistics);
318  }
319 
320  ret *= deg / 2. / xMath::Pi() / xMath::Pi() * xMath::GeVtoifm3();
321 
322  return ret;
323  }
324 
325  double QuantumNumericalIntegrationT2dn2dmu2(int statistics, double T, double mu, double m, double deg)
326  {
327  if (statistics == 0) return BoltzmannTdndmu(2, T, mu, m, deg);
328  if (statistics == 1 && mu > m) return FermiNumericalIntegrationLargeMuT2dn2dmu2(T, mu, m, deg);
329  if (statistics == -1 && mu > m) {
330  printf("**WARNING** QuantumNumericalIntegrationT2dn2dmu2: Bose-Einstein condensation\n");
331  calculationHadBECIssue = true;
332  return 0.;
333  }
334 
335  double ret = 0.;
336  double moverT = m / T;
337  double muoverT = mu / T;
338  for (int i = 0; i < 32; i++) {
339  double tx = lagx32[i];
340  double Eexp = exp(sqrt(tx*tx + moverT * moverT) - muoverT);
341  //ret += lagw32[i] * T * tx * T * tx * T * (Eexp*Eexp - statistics * Eexp) / (Eexp + statistics) / (Eexp + statistics) / (Eexp + statistics);
342  ret += lagw32[i] * T * tx * T * tx * T * (1. - statistics / Eexp) / (1. + statistics / Eexp) / (1. + statistics / Eexp) / (Eexp + statistics);
343  }
344 
345  ret *= deg / 2. / xMath::Pi() / xMath::Pi() * xMath::GeVtoifm3();
346 
347  return ret;
348  }
349 
350  double QuantumNumericalIntegrationT3dn3dmu3(int statistics, double T, double mu, double m, double deg)
351  {
352  if (statistics == 0) return BoltzmannTdndmu(3, T, mu, m, deg);
353  if (statistics == 1 && mu > m) return FermiNumericalIntegrationLargeMuT3dn3dmu3(T, mu, m, deg);
354  if (statistics == -1 && mu > m) {
355  printf("**WARNING** QuantumNumericalIntegrationT3dn3dmu3: Bose-Einstein condensation\n");
356  calculationHadBECIssue = true;
357  return 0.;
358  }
359 
360 
361  //printf("\n");
362  double ret = 0.;
363  double moverT = m / T;
364  double muoverT = mu / T;
365  for (int i = 0; i < 32; i++) {
366  double tx = lagx32[i];
367  double Eexp = exp(sqrt(tx*tx + moverT * moverT) - muoverT);
368  //ret += lagw32[i] * T * tx * T * tx * T * (Eexp*Eexp*Eexp - 4.*statistics*Eexp*Eexp + statistics*statistics*Eexp) / (Eexp + statistics) / (Eexp + statistics) / (Eexp + statistics) / (Eexp + statistics);
369  ret += lagw32[i] * T * tx * T * tx * T * (1. - 4.*statistics / Eexp + statistics * statistics / Eexp / Eexp) / (1. + statistics / Eexp) / (1. + statistics / Eexp) / (1. + statistics / Eexp) / (Eexp + statistics);
370  //printf("%E %E ", ret, Eexp);
371  }
372  //printf("\n");
373 
374  ret *= deg / 2. / xMath::Pi() / xMath::Pi() * xMath::GeVtoifm3();
375 
376  return ret;
377  }
378 
379  double QuantumNumericalIntegrationTdndmu(int N, int statistics, double T, double mu, double m, double deg)
380  {
381  if (N < 0 || N>3) {
382  printf("**WARNING** QuantumNumericalIntegrationTdndmu: N must be between 0 and 3!\n");
383  calculationHadBECIssue = true;
384  exit(1);
385  }
386  if (N == 0)
387  return QuantumNumericalIntegrationDensity(statistics, T, mu, m, deg);
388 
389  if (N == 1)
390  return QuantumNumericalIntegrationT1dn1dmu1(statistics, T, mu, m, deg);
391 
392  if (N == 2)
393  return QuantumNumericalIntegrationT2dn2dmu2(statistics, T, mu, m, deg);
394 
395  return QuantumNumericalIntegrationT3dn3dmu3(statistics, T, mu, m, deg);
396  }
397 
398  double QuantumNumericalIntegrationChiN(int N, int statistics, double T, double mu, double m, double deg)
399  {
400  return QuantumNumericalIntegrationTdndmu(N - 1, statistics, T, mu, m, deg) / pow(T, 3) / xMath::GeVtoifm3();
401  }
402 
403  double psi(double x)
404  {
405  if (x == 0.0)
406  return 1.;
407  double x2 = x * x;
408  double tmpsqrt = sqrt(1. + x2);
409  return (1. + x2 / 2.) * tmpsqrt - x2 * x2 / 2. * log((1. + tmpsqrt) / x);
410  }
411 
412  double psi2(double x)
413  {
414  if (x == 0.0)
415  return 2.;
416  double x2 = x * x;
417  double tmpsqrt = sqrt(1. + x2);
418  return 2. * tmpsqrt + 2. * x2 * log((1. + tmpsqrt) / x);
419  }
420 
421  double FermiNumericalIntegrationLargeMuDensity(double T, double mu, double m, double deg)
422  {
423  if (mu <= m)
424  return QuantumNumericalIntegrationDensity(1, T, mu, m, deg);
425 
426  double pf = sqrt(mu*mu - m * m);
427  double ret1 = 0.;
428  for (int i = 0; i < 32; i++) {
429  ret1 += -legw32[i] * pf * legx32[i] * pf * legx32[i] * pf / (exp(-(sqrt(legx32[i] * legx32[i] * pf * pf + m * m) - mu) / T) + 1.);
430  }
431 
432  double moverT = m / T;
433  double muoverT = mu / T;
434  for (int i = 0; i < 32; i++) {
435  double tx = pf / T + lagx32[i];
436  ret1 += lagw32[i] * T * tx * T * tx * T / (exp(sqrt(tx*tx + moverT * moverT) - muoverT) + 1.);
437  }
438 
439  ret1 *= deg / 2. / xMath::Pi() / xMath::Pi() * xMath::GeVtoifm3();
440 
441  double ret2 = 0.;
442  ret2 += deg / 2. / xMath::Pi() / xMath::Pi() * xMath::GeVtoifm3() * pf * pf * pf / 3.;
443 
444  return ret1 + ret2;
445  }
446 
447  double FermiNumericalIntegrationLargeMuPressure(double T, double mu, double m, double deg)
448  {
449  if (mu <= m)
450  return QuantumNumericalIntegrationPressure(1, T, mu, m, deg);
451 
452  double pf = sqrt(mu*mu - m * m);
453  double ret1 = 0.;
454  for (int i = 0; i < 32; i++) {
455  double x2 = legx32[i] * pf * legx32[i] * pf;
456  double E = sqrt(legx32[i] * legx32[i] * pf*pf + m * m);
457  ret1 += -legw32[i] * pf * x2 * x2 / E / (exp(-(E - mu) / T) + 1.);
458  }
459 
460  double moverT = m / T;
461  double muoverT = mu / T;
462  for (int i = 0; i < 32; i++) {
463  double tx = pf / T + lagx32[i];
464  double x2 = tx * T * tx * T;
465  double E = sqrt(tx*tx + moverT * moverT);
466  ret1 += lagw32[i] * T * x2 * x2 / E / T / (exp(E - muoverT) + 1.);
467  }
468 
469  ret1 *= deg / 6. / xMath::Pi() / xMath::Pi() * xMath::GeVtoifm3();
470 
471  double ret2 = 0.;
472  ret2 += mu * pf * pf * pf;
473  ret2 += -3. / 4. * pf * pf * pf * pf * psi(m / pf);
474  ret2 *= deg / 6. / xMath::Pi() / xMath::Pi() * xMath::GeVtoifm3();
475 
476  return ret1 + ret2;
477  }
478 
479  double FermiNumericalIntegrationLargeMuEnergyDensity(double T, double mu, double m, double deg)
480  {
481  if (mu <= m)
482  return QuantumNumericalIntegrationEnergyDensity(1, T, mu, m, deg);
483 
484  double pf = sqrt(mu*mu - m * m);
485  double ret1 = 0.;
486  for (int i = 0; i < 32; i++) {
487  ret1 += -legw32[i] * pf * legx32[i] * pf * legx32[i] * pf * sqrt(legx32[i] * legx32[i] * pf*pf + m * m) / (exp(-(sqrt(legx32[i] * legx32[i] * pf*pf + m * m) - mu) / T) + 1.);
488  }
489 
490  double moverT = m / T;
491  double muoverT = mu / T;
492  for (int i = 0; i < 32; i++) {
493  double tx = pf / T + lagx32[i];
494  ret1 += lagw32[i] * T * tx * T * tx * T * sqrt(tx*tx + moverT * moverT) * T / (exp(sqrt(tx*tx + moverT * moverT) - muoverT) + 1.);
495  }
496 
497  ret1 *= deg / 2. / xMath::Pi() / xMath::Pi() * xMath::GeVtoifm3();
498 
499  double ret2 = 0.;
500  ret2 += deg / 2. / xMath::Pi() / xMath::Pi() * xMath::GeVtoifm3() * pf * pf * pf * pf / 4. * psi(m / pf);
501 
502  return ret1 + ret2;
503  }
504 
505  double FermiNumericalIntegrationLargeMuEntropyDensity(double T, double mu, double m, double deg)
506  {
508  }
509 
510  double FermiNumericalIntegrationLargeMuScalarDensity(double T, double mu, double m, double deg)
511  {
512  if (mu <= m)
513  return QuantumNumericalIntegrationScalarDensity(1, T, mu, m, deg);
514 
515  double pf = sqrt(mu*mu - m * m);
516  double ret1 = 0.;
517  for (int i = 0; i < 32; i++) {
518  ret1 += -legw32[i] * pf * legx32[i] * pf * legx32[i] * pf * m / sqrt(legx32[i] * legx32[i] * pf*pf + m * m) / (exp(-(sqrt(legx32[i] * legx32[i] * pf*pf + m * m) - mu) / T) + 1.);
519  }
520 
521  double moverT = m / T;
522  double muoverT = mu / T;
523  for (int i = 0; i < 32; i++) {
524  double tx = pf / T + lagx32[i];
525  ret1 += lagw32[i] * T * tx * T * tx * T * moverT / sqrt(tx*tx + moverT * moverT) / (exp(sqrt(tx*tx + moverT * moverT) - muoverT) + 1.);
526  }
527 
528  ret1 *= deg / 2. / xMath::Pi() / xMath::Pi() * xMath::GeVtoifm3();
529 
530  double ret2 = 0.;
531  ret2 += deg / 2. / xMath::Pi() / xMath::Pi() * xMath::GeVtoifm3() * m * pf * (mu - pf / 4. * psi2(m / pf));
532 
533  return ret1 + ret2;
534  }
535 
536  double FermiNumericalIntegrationLargeMuT1dn1dmu1(double T, double mu, double m, double deg)
537  {
538  if (mu <= m)
539  return QuantumNumericalIntegrationT1dn1dmu1(1, T, mu, m, deg);
540 
541  double pf = sqrt(mu*mu - m * m);
542  double ret1 = 0.;
543  for (int i = 0; i < 32; i++) {
544  double Eexp = exp(-(sqrt(legx32[i] * legx32[i] * pf*pf + m * m) - mu) / T);
545  ret1 += legw32[i] * pf * legx32[i] * pf * legx32[i] * pf * 1. / (1. + 1./Eexp) / (Eexp + 1.);
546  //ret1 += legw32[i] * pf * legx32[i] * pf * legx32[i] * pf * Eexp / (Eexp + 1.) / (Eexp + 1.);
547  }
548 
549  double moverT = m / T;
550  double muoverT = mu / T;
551  for (int i = 0; i < 32; i++) {
552  double tx = pf / T + lagx32[i];
553  double Eexp = exp(sqrt(tx*tx + moverT * moverT) - muoverT);
554  ret1 += lagw32[i] * T * tx * T * tx * T * 1. / (1. + 1. / Eexp) / (Eexp + 1.);
555  //ret1 += lagw32[i] * T * tx * T * tx * T * Eexp / (Eexp + 1.) / (Eexp + 1.);
556  }
557 
558  ret1 *= deg / 2. / xMath::Pi() / xMath::Pi() * xMath::GeVtoifm3();
559 
560  return ret1;
561  }
562 
563  double FermiNumericalIntegrationLargeMuT2dn2dmu2(double T, double mu, double m, double deg)
564  {
565  if (mu <= m)
566  return QuantumNumericalIntegrationT2dn2dmu2(1, T, mu, m, deg);
567 
568  double pf = sqrt(mu*mu - m * m);
569  double ret1 = 0.;
570  for (int i = 0; i < 32; i++) {
571  double Eexp = exp(-(sqrt(legx32[i] * legx32[i] * pf*pf + m * m) - mu) / T);
572  ret1 += -legw32[i] * pf * legx32[i] * pf * legx32[i] * pf * (1. - 1. / Eexp) / (1. + 1. / Eexp) / (1. + 1. / Eexp) / (Eexp + 1.);
573  //ret1 += -legw32[i] * pf * legx32[i] * pf * legx32[i] * pf * (Eexp*Eexp - Eexp) / (Eexp + 1.) / (Eexp + 1.) / (Eexp + 1.);
574  }
575 
576  double moverT = m / T;
577  double muoverT = mu / T;
578  for (int i = 0; i < 32; i++) {
579  double tx = pf / T + lagx32[i];
580  double Eexp = exp(sqrt(tx*tx + moverT * moverT) - muoverT);
581  ret1 += lagw32[i] * T * tx * T * tx * T * (1. - 1. / Eexp) / (1. + 1. / Eexp) / (1. + 1. / Eexp) / (Eexp + 1.);
582  //ret1 += lagw32[i] * T * tx * T * tx * T * (Eexp*Eexp - Eexp) / (Eexp + 1.) / (Eexp + 1.) / (Eexp + 1.);
583  }
584 
585  ret1 *= deg / 2. / xMath::Pi() / xMath::Pi() * xMath::GeVtoifm3();
586 
587  return ret1;
588  }
589 
590  double FermiNumericalIntegrationLargeMuT3dn3dmu3(double T, double mu, double m, double deg)
591  {
592  if (mu <= m)
593  return QuantumNumericalIntegrationT3dn3dmu3(1, T, mu, m, deg);
594 
595  double pf = sqrt(mu*mu - m * m);
596  double ret1 = 0.;
597  for (int i = 0; i < 32; i++) {
598  double Eexp = exp(-(sqrt(legx32[i] * legx32[i] * pf*pf + m * m) - mu) / T);
599  ret1 += legw32[i] * pf * legx32[i] * pf * legx32[i] * pf * (1. - 4./Eexp + 1./Eexp / Eexp) / (1. + 1. / Eexp) / (1. + 1. / Eexp) / (1. + 1. / Eexp) / (Eexp + 1.);
600  //ret1 += legw32[i] * pf * legx32[i] * pf * legx32[i] * pf * (Eexp*Eexp*Eexp - 4.*Eexp*Eexp + Eexp) / (Eexp + 1.) / (Eexp + 1.) / (Eexp + 1.) / (Eexp + 1.);
601  }
602 
603  double moverT = m / T;
604  double muoverT = mu / T;
605  for (int i = 0; i < 32; i++) {
606  double tx = pf / T + lagx32[i];
607  double Eexp = exp(sqrt(tx*tx + moverT * moverT) - muoverT);
608  ret1 += lagw32[i] * T * tx * T * tx * T * (1. - 4. / Eexp + 1. / Eexp / Eexp) / (1. + 1. / Eexp) / (1. + 1. / Eexp) / (1. + 1. / Eexp) / (Eexp + 1.);
609  //ret1 += lagw32[i] * T * tx * T * tx * T * (Eexp*Eexp*Eexp - 4.*Eexp*Eexp + Eexp) / (Eexp + 1.) / (Eexp + 1.) / (Eexp + 1.) / (Eexp + 1.);
610  }
611 
612  ret1 *= deg / 2. / xMath::Pi() / xMath::Pi() * xMath::GeVtoifm3();
613 
614  return ret1;
615  }
616 
617  double FermiNumericalIntegrationLargeMuTdndmu(int N, double T, double mu, double m, double deg)
618  {
619  if (N < 0 || N>3) {
620  printf("**ERROR** FermiNumericalIntegrationLargeMuTdndmu: N < 0 or N > 3\n");
621  exit(1);
622  }
623  if (N == 0)
624  return FermiNumericalIntegrationLargeMuDensity(T, mu, m, deg);
625 
626  if (N == 1)
627  return FermiNumericalIntegrationLargeMuT1dn1dmu1(T, mu, m, deg);
628 
629  if (N == 2)
630  return FermiNumericalIntegrationLargeMuT2dn2dmu2(T, mu, m, deg);
631 
632  return FermiNumericalIntegrationLargeMuT3dn3dmu3(T, mu, m, deg);
633  }
634 
635  double FermiNumericalIntegrationLargeMuChiN(int N, double T, double mu, double m, double deg)
636  {
637  return FermiNumericalIntegrationLargeMuTdndmu(N - 1, T, mu, m, deg) / pow(T, 3) / xMath::GeVtoifm3();
638  }
639 
640  double IdealGasQuantity(Quantity quantity, QStatsCalculationType calctype, int statistics, double T, double mu, double m, double deg, int order)
641  {
642  if (statistics == 0) {
643  if (quantity == ParticleDensity)
644  return BoltzmannDensity(T, mu, m, deg);
645  if (quantity == Pressure)
646  return BoltzmannPressure(T, mu, m, deg);
647  if (quantity == EnergyDensity)
648  return BoltzmannEnergyDensity(T, mu, m, deg);
649  if (quantity == EntropyDensity)
650  return BoltzmannEntropyDensity(T, mu, m, deg);
651  if (quantity == ScalarDensity)
652  return BoltzmannScalarDensity(T, mu, m, deg);
653  if (quantity == chi2)
654  return BoltzmannChiN(2, T, mu, m, deg);
655  if (quantity == chi3)
656  return BoltzmannChiN(3, T, mu, m, deg);
657  if (quantity == chi4)
658  return BoltzmannChiN(4, T, mu, m, deg);
659  }
660  else {
661  if (calctype == ClusterExpansion) {
662  if (quantity == ParticleDensity)
663  return QuantumClusterExpansionDensity(statistics, T, mu, m, deg, order);
664  if (quantity == Pressure)
665  return QuantumClusterExpansionPressure(statistics, T, mu, m, deg, order);
666  if (quantity == EnergyDensity)
667  return QuantumClusterExpansionEnergyDensity(statistics, T, mu, m, deg, order);
668  if (quantity == EntropyDensity)
669  return QuantumClusterExpansionEntropyDensity(statistics, T, mu, m, deg, order);
670  if (quantity == ScalarDensity)
671  return QuantumClusterExpansionScalarDensity(statistics, T, mu, m, deg, order);
672  if (quantity == chi2)
673  return QuantumClusterExpansionChiN(2, statistics, T, mu, m, deg, order);
674  if (quantity == chi3)
675  return QuantumClusterExpansionChiN(3, statistics, T, mu, m, deg, order);
676  if (quantity == chi4)
677  return QuantumClusterExpansionChiN(4, statistics, T, mu, m, deg, order);
678  }
679  else {
680  if (quantity == ParticleDensity)
681  return QuantumNumericalIntegrationDensity(statistics, T, mu, m, deg);
682  if (quantity == Pressure)
683  return QuantumNumericalIntegrationPressure(statistics, T, mu, m, deg);
684  if (quantity == EnergyDensity)
685  return QuantumNumericalIntegrationEnergyDensity(statistics, T, mu, m, deg);
686  if (quantity == EntropyDensity)
687  return QuantumNumericalIntegrationEntropyDensity(statistics, T, mu, m, deg);
688  if (quantity == ScalarDensity)
689  return QuantumNumericalIntegrationScalarDensity(statistics, T, mu, m, deg);
690  if (quantity == chi2)
691  return QuantumNumericalIntegrationChiN(2, statistics, T, mu, m, deg);
692  if (quantity == chi3)
693  return QuantumNumericalIntegrationChiN(3, statistics, T, mu, m, deg);
694  if (quantity == chi4)
695  return QuantumNumericalIntegrationChiN(4, statistics, T, mu, m, deg);
696  }
697  }
698  printf("**WARNING** IdealGasFunctions::IdealGasQuantity: Unknown quantity\n");
699  return 0.;
700  }
701 
702  } // namespace IdealGasFunctions
703 
704 } // namespace thermalfist
double QuantumClusterExpansionTdndmu(int N, int statistics, double T, double mu, double m, double deg, int order=1)
Computes the chemical potential derivative of density for a quantum ideal gas using cluster expansion...
double FermiNumericalIntegrationLargeMuChiN(int N, double T, double mu, double m, double deg)
Computes the n-th order susceptibility for a Fermi-Dirac ideal gas at mu > m.
double QuantumClusterExpansionPressure(int statistics, double T, double mu, double m, double deg, int order=1)
Computes the pressure of a quantum ideal gas using cluster expansion.
double BesselKexp(int n, double x)
Definition: xMath.cpp:697
double QuantumNumericalIntegrationT3dn3dmu3(int statistics, double T, double mu, double m, double deg)
double QuantumClusterExpansionEnergyDensity(int statistics, double T, double mu, double m, double deg, int order=1)
Computes the energy density of a quantum ideal gas using cluster expansion.
double BoltzmannTdndmu(int N, double T, double mu, double m, double deg)
Computes the chemical potential derivative of density for a Maxwell-Boltzmann gas.
const double coefficients_wlag32[32]
Weights of the 32-point Gauss-Laguerre quadrature.
const double coefficients_xlag32[32]
Nodes of the 32-point Gauss-Laguerre quadrature.
const double coefficients_wleg32_zeroone[32]
Weights of the 32-point Gauss-Legendre quadrature in the interval [0,1].
double FermiNumericalIntegrationLargeMuEntropyDensity(double T, double mu, double m, double deg)
Computes the entropy density of a Fermi-Dirac ideal gas at mu > m.
double GeVtoifm3()
A constant to transform GeV into fm .
Definition: xMath.h:33
double QuantumNumericalIntegrationDensity(int statistics, double T, double mu, double m, double deg)
Computes the particle number density of a quantum ideal gas using 32-point Gauss-Laguerre quadratures...
double Pi()
Pi constant.
Definition: xMath.h:24
double psi2(double x)
Auxiliary function.
double FermiNumericalIntegrationLargeMuT2dn2dmu2(double T, double mu, double m, double deg)
double IdealGasQuantity(Quantity quantity, QStatsCalculationType calctype, int statistics, double T, double mu, double m, double deg, int order=1)
Calculation of a generic ideal gas function.
double QuantumNumericalIntegrationPressure(int statistics, double T, double mu, double m, double deg)
Computes the pressure of a quantum ideal gas using 32-point Gauss-Laguerre quadratures.
double QuantumNumericalIntegrationEnergyDensity(int statistics, double T, double mu, double m, double deg)
Computes the energy density of a quantum ideal gas using 32-point Gauss-Laguerre quadratures.
double FermiNumericalIntegrationLargeMuScalarDensity(double T, double mu, double m, double deg)
Computes the scalar density of a Fermi-Dirac ideal gas at mu > m.
double QuantumNumericalIntegrationEntropyDensity(int statistics, double T, double mu, double m, double deg)
Computes the entropy density of a quantum ideal gas using 32-point Gauss-Laguerre quadratures...
double psi(double x)
Auxiliary function.
double QuantumClusterExpansionEntropyDensity(int statistics, double T, double mu, double m, double deg, int order=1)
Computes the entropy density of a quantum ideal gas using cluster expansion.
Contains some extra mathematical functions used in the code.
double QuantumNumericalIntegrationScalarDensity(int statistics, double T, double mu, double m, double deg)
Computes the scalar density of a quantum ideal gas using 32-point Gauss-Laguerre quadratures.
const double coefficients_xleg32_zeroone[32]
Nodes of the 32-point Gauss-Legendre quadrature in the interval [0,1].
double QuantumNumericalIntegrationTdndmu(int N, int statistics, double T, double mu, double m, double deg)
double FermiNumericalIntegrationLargeMuDensity(double T, double mu, double m, double deg)
Computes the particle number density of a Fermi-Dirac ideal gas at mu > m.
double QuantumNumericalIntegrationChiN(int N, int statistics, double T, double mu, double m, double deg)
Computes the n-th order susceptibility for a quantum ideal gas using 32-point Gauss-Laguerre quadratu...
Quantity
Identifies the thermodynamic function.
double QuantumClusterExpansionChiN(int N, int statistics, double T, double mu, double m, double deg, int order=1)
Computes the n-th order susceptibility for a quantum ideal gas using cluster expansion.
double BoltzmannChiN(int N, double T, double mu, double m, double deg)
Computes the n-th order susceptibility for a Maxwell-Boltzmann gas.
double BoltzmannPressure(double T, double mu, double m, double deg)
Computes the pressure of a Maxwell-Boltzmann gas.
double BoltzmannEnergyDensity(double T, double mu, double m, double deg)
Computes the energy density of a Maxwell-Boltzmann gas.
double BoltzmannDensity(double T, double mu, double m, double deg)
Computes the particle number density of a Maxwell-Boltzmann gas.
double QuantumClusterExpansionScalarDensity(int statistics, double T, double mu, double m, double deg, int order=1)
Computes the scalar density of a quantum ideal gas using cluster expansion.
double FermiNumericalIntegrationLargeMuEnergyDensity(double T, double mu, double m, double deg)
Computes the energy density of a Fermi-Dirac ideal gas at mu > m.
double FermiNumericalIntegrationLargeMuT1dn1dmu1(double T, double mu, double m, double deg)
double BoltzmannEntropyDensity(double T, double mu, double m, double deg)
Computes the entropy density of a Maxwell-Boltzmann gas.
double BoltzmannScalarDensity(double T, double mu, double m, double deg)
Computes the scalar density of a Maxwell-Boltzmann gas.
double FermiNumericalIntegrationLargeMuPressure(double T, double mu, double m, double deg)
Computes the pressure of a Fermi-Dirac ideal gas at mu > m.
double FermiNumericalIntegrationLargeMuTdndmu(int N, double T, double mu, double m, double deg)
bool calculationHadBECIssue
Whether > m Bose-Einstein condensation issue was encountered for a Bose gas.
double QuantumNumericalIntegrationT1dn1dmu1(int statistics, double T, double mu, double m, double deg)
double QuantumClusterExpansionDensity(int statistics, double T, double mu, double m, double deg, int order=1)
Computes the particle number density of a quantum ideal gas using cluster expansion.
QStatsCalculationType
Identifies whether quantum statistics are to be computed using the cluster expansion or numerical int...
double BesselK1exp(double x)
Definition: xMath.cpp:662
double QuantumNumericalIntegrationT2dn2dmu2(int statistics, double T, double mu, double m, double deg)
The main namespace where all classes and functions of the Thermal-FIST library reside.
double FermiNumericalIntegrationLargeMuT3dn3dmu3(double T, double mu, double m, double deg)