29 for (
int i = 0; i < 6; ++i)
m_chi[i].resize(3);
34 m_TAG =
"ThermalModelRealGas";
71 for (
size_t i = 0; i <
m_MuStar.size(); ++i)
78 for (
size_t i = 0; i <
m_MuStar.size(); ++i)
84 map< vector<int>,
int> MapComp;
86 int NN = m_densities.size();
94 for (
int i = 0; i < NN; ++i) {
95 vector<int> IntParam(0);
97 IntParam.push_back(0);
99 IntParam.push_back(
m_exvolmod->ComponentIndices()[i]);
101 IntParam.push_back(0);
103 IntParam.push_back(
m_mfmod->ComponentIndices()[i]);
105 if (MapComp.count(IntParam) == 0) {
106 MapComp[IntParam] = tind;
133 int NN = m_densities.size();
136 vector<double> dmuscur(NNdmu, 0.);
137 for (
int i = 0; i < NNdmu; ++i)
140 BroydenEquationsRealGasComponents eqs(
this);
141 BroydenJacobianRealGasComponents jac(
this);
143 BroydenSolutionCriteriumRealGas crit(
this);
145 dmuscur = broydn.
Solve(dmuscur, &crit);
153 vector<double> ret(NN);
154 for (
int i = 0; i < NN; ++i)
162 int NN = m_densities.size();
164 vector<double> dmuscur(NN, 0.);
165 for (
int i = 0; i < NN; ++i)
166 dmuscur[i] = muStarInit[i] - m_Chem[i];
168 BroydenEquationsRealGas eqs(
this);
169 BroydenJacobianRealGas jac(
this);
171 BroydenSolutionCriteriumRealGas crit(
this);
173 dmuscur = broydn.
Solve(dmuscur, &crit);
181 vector<double> ret(NN);
182 for (
int i = 0; i < NN; ++i)
183 ret[i] = m_Chem[i] + dmuscur[i];
189 vector<double> csol(m_densities.size(), 0.);
194 double dmu = (muBmax - muBmin) / iters;
195 vector<double> curmust(m_densities.size(), 0.);
197 for (
int isol = 0; isol < iters; ++isol) {
198 double tmu = muBmin + (0.5 + isol) * dmu;
199 for (
size_t j = 0; j < curmust.size(); ++j) {
200 curmust[j] = m_Chem[j] + (tmu - m_Parameters.muB) * m_Chem[j] / m_Parameters.muB;
201 if (m_TPS->Particles()[j].Statistics() == -1 && curmust[j] > m_TPS->Particles()[j].Mass())
202 curmust[j] = 0.98 * m_TPS->Particles()[j].Mass();
208 for (
size_t i = 0; i < sol.size(); ++i)
209 if (sol[i] != sol[i]) fl =
false;
213 for (
int i = 0; i < m_TPS->ComponentsNumber(); ++i)
218 m_mfmod->SetDensities(m_densities);
221 for (
size_t i = 0; i < m_densities.size(); ++i) {
223 for (
size_t j = 0; j < m_densities.size(); ++j) {
224 tfsum += m_densities[j] *
m_exvolmod->df(i, j);
231 for (
size_t i = 0; i < m_densities.size(); ++i)
232 tP +=
m_mfmod->dv(i) * m_densities[i];
234 if (!solved || tP > Psol) {
249 vector<double> muStarInit =
m_MuStar;
251 for (
size_t i = 0; i < muStarInit.size(); ++i) {
252 if (m_TPS->Particles()[i].Statistics() == -1 && muStarInit[i] > m_TPS->Particles()[i].Mass())
253 muStarInit[i] = 0.98 * m_TPS->Particles()[i].Mass();
263 m_FluctuationsCalculated =
false;
265 int NN = m_densities.size();
269 for (
int i = 0; i < m_TPS->ComponentsNumber(); ++i)
274 m_mfmod->SetDensities(m_densities);
285 vector<double> ret(order + 1, 0.);
288 for (
size_t i = 0; i < m_densities.size(); ++i)
289 ret[0] += chgs[i] * m_densities[i];
293 if (order < 2)
return ret;
295 int NN = m_densities.size();
297 const vector<int>& evinds =
m_exvolmod->ComponentIndices();
298 const vector<int>& evindsfrom =
m_exvolmod->ComponentIndicesFrom();
300 int Nmfcomp =
m_mfmod->ComponentsNumber();
301 const vector<int>& mfinds =
m_mfmod->ComponentIndices();
302 const vector<int>& mfindsfrom =
m_mfmod->ComponentIndicesFrom();
304 MatrixXd densMatrix(2 * NN, 2 * NN);
305 VectorXd solVector(2 * NN), xVector(2 * NN);
307 vector<double> chi2id(m_densities.size()), Ps(m_densities.size());
308 for (
int i = 0; i < NN; ++i) {
311 chi2id[i] = m_TPS->Particles()[i].chiDimensionfull(2, m_Parameters, m_UseWidth,
m_MuStar[i]) * pow(
xMath::GeVtoifm(), 3);
314 vector<double> evc_chi2id(Nevcomp, 0.), evc_Ps(Nevcomp, 0.), evc_ns(Nevcomp, 0.);
315 for (
int i = 0; i < NN; ++i) {
316 evc_Ps[evinds[i]] += Ps[i];
318 evc_chi2id[evinds[i]] += chi2id[i];
321 vector<vector<double>> pkd2fkij(Nevcomp, vector<double>(Nevcomp, 0.));
322 for (
int indi = 0; indi < Nevcomp; ++indi) {
324 int i = evindsfrom[indi];
325 for (
int indj = 0; indj < Nevcomp; ++indj) {
327 int j = evindsfrom[indj];
331 for (
int k = 0; k < Nevcomp; ++k) {
332 pkd2fkij[indi][indj] += evc_Ps[k] *
m_exvolmod->d2f(evindsfrom[k], i, j);
337 for (
int i = 0; i < NN; ++i)
338 for (
int j = 0; j < NN; ++j) {
340 if (i == j) densMatrix(i, j) += 1.;
343 for (
int i = 0; i < NN; ++i)
344 for (
int j = 0; j < NN; ++j)
345 densMatrix(i, NN + j) = 0.;
347 for (
int i = 0; i < NN; ++i) {
348 densMatrix(i, NN + i) = -
m_exvolmod->f(i) * chi2id[i];
351 for (
int i = 0; i < NN; ++i)
352 for (
int j = 0; j < NN; ++j) {
353 densMatrix(NN + i, j) =
m_mfmod->d2v(i, j);
356 densMatrix(NN + i, j) += -pkd2fkij[evinds[i]][evinds[j]];
359 for (
int i = 0; i < NN; ++i)
360 for (
int j = 0; j < NN; ++j) {
362 if (i == j) densMatrix(NN + i, NN + j) += 1.;
365 PartialPivLU<MatrixXd> decomp(densMatrix);
368 vector<double> dni(NN, 0.), dmus(NN, 0.);
370 for (
int i = 0; i < NN; ++i) {
372 xVector[NN + i] = chgs[i];
375 solVector = decomp.solve(xVector);
377 for (
int i = 0; i < NN; ++i) {
378 dni[i] = solVector[i];
379 dmus[i] = solVector[NN + i];
382 for (
int i = 0; i < NN; ++i)
383 ret[1] += chgs[i] * dni[i];
387 if (order < 3)
return ret;
389 vector<double> evc_dn(Nevcomp, 0.), evc_dmus(Nevcomp, 0.), evc_nsdmus(Nevcomp, 0.);
390 for (
int i = 0; i < NN; ++i) {
391 evc_dn[evinds[i]] += dni[i];
392 evc_dmus[evinds[i]] += dmus[i];
396 vector<double> mfc_dn(Nmfcomp, 0.);
397 for (
int i = 0; i < NN; ++i) {
398 mfc_dn[mfinds[i]] += dni[i];
402 vector<double> d2ni(NN, 0.), d2mus(NN, 0.);
404 vector<double> chi3id(m_densities.size());
405 for (
int i = 0; i < NN; ++i)
406 chi3id[i] = m_TPS->Particles()[i].chiDimensionfull(3, m_Parameters, m_UseWidth,
m_MuStar[i]) * pow(
xMath::GeVtoifm(), 3);
409 vector<vector<double>> d2fijkdnk(Nevcomp, vector<double>(Nevcomp, 0.));
410 for (
int indi = 0; indi < Nevcomp; ++indi) {
411 int i = evindsfrom[indi];
412 for (
int indj = 0; indj < Nevcomp; ++indj) {
413 int j = evindsfrom[indj];
417 for (
int indk = 0; indk < Nevcomp; ++indk) {
418 int k = evindsfrom[indk];
419 d2fijkdnk[indi][indj] += evc_dn[indk] *
m_exvolmod->d2f(i, j, k);
424 vector<double> dfikdnk(Nevcomp, 0.);
425 for (
int indi = 0; indi < Nevcomp; ++indi) {
426 int i = evindsfrom[indi];
430 for (
int indk = 0; indk < Nevcomp; ++indk) {
431 int k = evindsfrom[indk];
432 dfikdnk[indi] += evc_dn[indk] *
m_exvolmod->df(i, k);
436 vector<vector<double>> d2fkijnskmusk(Nevcomp, vector<double>(Nevcomp, 0.));
437 for (
int indi = 0; indi < Nevcomp; ++indi) {
438 int i = evindsfrom[indi];
439 for (
int indj = 0; indj < Nevcomp; ++indj) {
440 int j = evindsfrom[indj];
444 for (
int indk = 0; indk < Nevcomp; ++indk) {
445 int k = evindsfrom[indk];
446 d2fkijnskmusk[indi][indj] +=
m_exvolmod->d2f(k, i, j) * evc_nsdmus[indk];
451 vector<vector<double>> pkd3fkijmdnm(Nevcomp, vector<double>(Nevcomp, 0.));
452 for (
int indi = 0; indi < Nevcomp; ++indi) {
453 int i = evindsfrom[indi];
454 for (
int indj = 0; indj < Nevcomp; ++indj) {
455 int j = evindsfrom[indj];
461 for (
int indk = 0; indk < Nevcomp; ++indk) {
462 int k = evindsfrom[indk];
463 for (
int indm = 0; indm < Nevcomp; ++indm) {
464 int m = evindsfrom[indm];
465 pkd3fkijmdnm[indi][indj] += evc_Ps[indk] *
m_exvolmod->d3f(k, i, j, m) * evc_dn[indm];
471 vector<vector<double>> d3vijkdnk(Nmfcomp, vector<double>(Nmfcomp, 0.));
472 for (
int indi = 0; indi < Nmfcomp; ++indi) {
473 int i = mfindsfrom[indi];
474 for (
int indj = 0; indj < Nmfcomp; ++indj) {
475 int j = mfindsfrom[indj];
479 for (
int indk = 0; indk < Nmfcomp; ++indk) {
480 int k = mfindsfrom[indk];
481 d3vijkdnk[indi][indj] += mfc_dn[indk] *
m_mfmod->d3v(i, j, k);
486 vector< vector<double> > daij11, daij12, daij21, daij22;
492 for (
int i = 0; i < NN; ++i) {
494 daij11[i].resize(NN);
495 daij12[i].resize(NN);
496 daij21[i].resize(NN);
497 daij22[i].resize(NN);
498 for (
int j = 0; j < NN; ++j) {
502 daij11[i][j] += -d2fijkdnk[evinds[i]][evinds[j]] *
m_DensitiesId[i];
503 daij11[i][j] += -
m_exvolmod->df(i, j) * chi2id[i] * dmus[i];
509 daij12[i][j] += -dfikdnk[evinds[i]] * chi2id[i];
510 daij12[i][j] += -
m_exvolmod->f(i) * chi3id[i] * dmus[i];
515 daij21[i][j] += d3vijkdnk[mfinds[i]][mfinds[j]];
522 daij21[i][j] += -d2fkijnskmusk[evinds[i]][evinds[j]];
523 daij21[i][j] += -pkd3fkijmdnm[evinds[i]][evinds[j]];
526 daij22[i][j] += -
m_exvolmod->df(j, i) * chi2id[j] * dmus[j];
529 daij22[i][j] += -
m_DensitiesId[j] * d2fijkdnk[evinds[j]][evinds[i]];
534 for (
int i = 0; i < NN; ++i) {
537 for (
int j = 0; j < NN; ++j)
538 xVector[i] += -daij11[i][j] * dni[j];
540 for (
int j = 0; j < NN; ++j)
541 xVector[i] += -daij12[i][j] * dmus[j];
543 for (
int i = 0; i < NN; ++i) {
544 xVector[NN + i] = 0.;
546 for (
int j = 0; j < NN; ++j)
547 xVector[NN + i] += -daij21[i][j] * dni[j];
549 for (
int j = 0; j < NN; ++j)
550 xVector[NN + i] += -daij22[i][j] * dmus[j];
553 solVector = decomp.solve(xVector);
555 for (
int i = 0; i < NN; ++i) {
556 d2ni[i] = solVector[i];
557 d2mus[i] = solVector[NN + i];
560 for (
int i = 0; i < NN; ++i)
561 ret[2] += chgs[i] * d2ni[i];
565 if (order < 4)
return ret;
567 vector<double> evc_d2n(Nevcomp, 0.), evc_d2mus(Nevcomp, 0.), evc_nsd2mus(Nevcomp, 0.), evc_chi2iddmus2(Nevcomp, 0.);
568 for (
int i = 0; i < NN; ++i) {
569 evc_d2n[evinds[i]] += d2ni[i];
570 evc_d2mus[evinds[i]] += d2mus[i];
572 evc_chi2iddmus2[evinds[i]] += chi2id[i] * dmus[i] * dmus[i];
575 vector<double> mfc_d2n(Nmfcomp, 0.);
576 for (
int i = 0; i < NN; ++i) {
577 mfc_d2n[mfinds[i]] += d2ni[i];
581 vector<double> d3ni(NN, 0.), d3mus(NN, 0.);
583 vector<double> chi4id(m_densities.size());
584 for (
int i = 0; i < NN; ++i)
585 chi4id[i] = m_TPS->Particles()[i].chiDimensionfull(4, m_Parameters, m_UseWidth,
m_MuStar[i]) * pow(
xMath::GeVtoifm(), 3);
587 vector<vector<double>> d2fijkd2nk(Nevcomp, vector<double>(Nevcomp, 0.));
588 for (
int indi = 0; indi < Nevcomp; ++indi) {
589 int i = evindsfrom[indi];
590 for (
int indj = 0; indj < Nevcomp; ++indj) {
591 int j = evindsfrom[indj];
595 for (
int indk = 0; indk < Nevcomp; ++indk) {
596 int k = evindsfrom[indk];
597 d2fijkd2nk[indi][indj] += evc_d2n[indk] *
m_exvolmod->d2f(i, j, k);
602 vector<vector<double>> d3fijkmdnkdnm(Nevcomp, vector<double>(Nevcomp, 0.));
603 for (
int indi = 0; indi < Nevcomp; ++indi) {
604 int i = evindsfrom[indi];
605 for (
int indj = 0; indj < Nevcomp; ++indj) {
606 int j = evindsfrom[indj];
612 for (
int indk = 0; indk < Nevcomp; ++indk) {
613 int k = evindsfrom[indk];
614 for (
int indm = 0; indm < Nevcomp; ++indm) {
615 int m = evindsfrom[indm];
616 d3fijkmdnkdnm[indi][indj] +=
m_exvolmod->d3f(i, j, k, m) * evc_dn[indk] * evc_dn[indm];
622 vector<double> dfikd2nk(Nevcomp, 0.);
623 for (
int indi = 0; indi < Nevcomp; ++indi) {
624 int i = evindsfrom[indi];
628 for (
int indk = 0; indk < Nevcomp; ++indk) {
629 int k = evindsfrom[indk];
630 dfikd2nk[indi] += evc_d2n[indk] *
m_exvolmod->df(i, k);
634 vector<double> d2fikmdnkdnm(Nevcomp, 0.);
635 for (
int indi = 0; indi < Nevcomp; ++indi) {
636 int i = evindsfrom[indi];
642 for (
int indk = 0; indk < Nevcomp; ++indk) {
643 int k = evindsfrom[indk];
644 for (
int indm = 0; indm < Nevcomp; ++indm) {
645 int m = evindsfrom[indm];
646 d2fikmdnkdnm[indi] +=
m_exvolmod->d2f(i, k, m) * evc_dn[indk] * evc_dn[indm];
651 vector<vector<double>> d2fkijnskd2musk(Nevcomp, vector<double>(Nevcomp, 0.));
652 for (
int indi = 0; indi < Nevcomp; ++indi) {
653 int i = evindsfrom[indi];
654 for (
int indj = 0; indj < Nevcomp; ++indj) {
655 int j = evindsfrom[indj];
659 for (
int indk = 0; indk < Nevcomp; ++indk) {
660 int k = evindsfrom[indk];
661 d2fkijnskd2musk[indi][indj] +=
m_exvolmod->d2f(k, i, j) * evc_nsd2mus[indk];
666 vector<vector<double>> d2fkijc2kdmuskdmusk(Nevcomp, vector<double>(Nevcomp, 0.));
667 for (
int indi = 0; indi < Nevcomp; ++indi) {
668 int i = evindsfrom[indi];
669 for (
int indj = 0; indj < Nevcomp; ++indj) {
670 int j = evindsfrom[indj];
674 for (
int indk = 0; indk < Nevcomp; ++indk) {
675 int k = evindsfrom[indk];
676 d2fkijc2kdmuskdmusk[indi][indj] +=
m_exvolmod->d2f(k, i, j) * evc_chi2iddmus2[indk];
681 vector<vector<double>> nskd3fkijmdmuskdnm(Nevcomp, vector<double>(Nevcomp, 0.));
682 for (
int indi = 0; indi < Nevcomp; ++indi) {
683 int i = evindsfrom[indi];
684 for (
int indj = 0; indj < Nevcomp; ++indj) {
685 int j = evindsfrom[indj];
691 for (
int indk = 0; indk < Nevcomp; ++indk) {
692 int k = evindsfrom[indk];
693 for (
int indm = 0; indm < Nevcomp; ++indm) {
694 int m = evindsfrom[indm];
695 nskd3fkijmdmuskdnm[indi][indj] += evc_nsdmus[indk] *
m_exvolmod->d3f(k, i, j, m) * evc_dn[indm];
701 vector<vector<double>> pkd3fkijmd2nm(Nevcomp, vector<double>(Nevcomp, 0.));
702 for (
int indi = 0; indi < Nevcomp; ++indi) {
703 int i = evindsfrom[indi];
704 for (
int indj = 0; indj < Nevcomp; ++indj) {
705 int j = evindsfrom[indj];
711 for (
int indk = 0; indk < Nevcomp; ++indk) {
712 int k = evindsfrom[indk];
713 for (
int indm = 0; indm < Nevcomp; ++indm) {
714 int m = evindsfrom[indm];
715 pkd3fkijmd2nm[indi][indj] += evc_Ps[indk] *
m_exvolmod->d3f(k, i, j, m) * evc_d2n[indm];
721 vector<vector<double>> pkd4fkijmldnmdnl(Nevcomp, vector<double>(Nevcomp, 0.));
722 for (
int indi = 0; indi < Nevcomp; ++indi) {
723 int i = evindsfrom[indi];
724 for (
int indj = 0; indj < Nevcomp; ++indj) {
725 int j = evindsfrom[indj];
733 for (
int indk = 0; indk < Nevcomp; ++indk) {
734 int k = evindsfrom[indk];
735 for (
int indm = 0; indm < Nevcomp; ++indm) {
736 int m = evindsfrom[indm];
737 for (
int indl = 0; indl < Nevcomp; ++indl) {
738 int l = evindsfrom[indl];
739 pkd4fkijmldnmdnl[indi][indj] += evc_Ps[indk] *
m_exvolmod->d4f(k, i, j, m, l) * evc_dn[indm] * evc_dn[indl];
746 vector<vector<double>> d3vijkd2nk(Nmfcomp, vector<double>(Nmfcomp, 0.));
747 for (
int indi = 0; indi < Nmfcomp; ++indi) {
748 int i = mfindsfrom[indi];
749 for (
int indj = 0; indj < Nmfcomp; ++indj) {
750 int j = mfindsfrom[indj];
754 for (
int indk = 0; indk < Nmfcomp; ++indk) {
755 int k = mfindsfrom[indk];
756 d3vijkd2nk[indi][indj] += mfc_d2n[indk] *
m_mfmod->d3v(i, j, k);
761 vector<vector<double>> d4vijkmdnkdnm(Nmfcomp, vector<double>(Nmfcomp, 0.));
762 for (
int indi = 0; indi < Nmfcomp; ++indi) {
763 int i = mfindsfrom[indi];
764 for (
int indj = 0; indj < Nmfcomp; ++indj) {
765 int j = mfindsfrom[indj];
771 for (
int indk = 0; indk < Nmfcomp; ++indk) {
772 int k = mfindsfrom[indk];
773 for (
int indm = 0; indm < Nmfcomp; ++indm) {
774 int m = mfindsfrom[indm];
775 d4vijkmdnkdnm[indi][indj] += mfc_dn[indk] * mfc_dn[indm] *
m_mfmod->d4v(i, j, k, m);
781 vector< vector<double> > d2aij11, d2aij12, d2aij21, d2aij22;
787 for (
int i = 0; i < NN; ++i) {
789 d2aij11[i].resize(NN);
790 d2aij12[i].resize(NN);
791 d2aij21[i].resize(NN);
792 d2aij22[i].resize(NN);
793 for (
int j = 0; j < NN; ++j) {
795 d2aij11[i][j] += -
m_exvolmod->df(i, j) * chi3id[i] * dmus[i] * dmus[i];
796 d2aij11[i][j] += -
m_exvolmod->df(i, j) * chi2id[i] * d2mus[i];
798 d2aij11[i][j] += -2. * d2fijkdnk[evinds[i]][evinds[j]] * chi2id[i] * dmus[i];
799 d2aij11[i][j] += -d2fijkd2nk[evinds[i]][evinds[j]] *
m_DensitiesId[i];
800 d2aij11[i][j] += -d3fijkmdnkdnm[evinds[i]][evinds[j]] *
m_DensitiesId[i];
813 d2aij12[i][j] += -
m_exvolmod->f(i) * chi3id[i] * d2mus[i];
814 d2aij12[i][j] += -
m_exvolmod->f(i) * chi4id[i] * dmus[i] * dmus[i];
816 d2aij12[i][j] += -2. * dfikdnk[evinds[i]] * chi3id[i] * dmus[i];
817 d2aij12[i][j] += -dfikd2nk[evinds[i]] * chi2id[i];
818 d2aij12[i][j] += -d2fikmdnkdnm[evinds[i]] * chi2id[i];
832 d2aij21[i][j] += -d2fkijnskd2musk[evinds[i]][evinds[j]];
833 d2aij21[i][j] += -d2fkijc2kdmuskdmusk[evinds[i]][evinds[j]];
834 d2aij21[i][j] += -2. * nskd3fkijmdmuskdnm[evinds[i]][evinds[j]];
835 d2aij21[i][j] += -pkd3fkijmd2nm[evinds[i]][evinds[j]];
836 d2aij21[i][j] += -pkd4fkijmldnmdnl[evinds[i]][evinds[j]];
838 d2aij21[i][j] += d3vijkd2nk[mfinds[i]][mfinds[j]];
839 d2aij21[i][j] += d4vijkmdnkdnm[mfinds[i]][mfinds[j]];
863 d2aij22[i][j] += -
m_exvolmod->df(j, i) * chi3id[j] * dmus[j] * dmus[j];
864 d2aij22[i][j] += -
m_exvolmod->df(j, i) * chi2id[j] * d2mus[j];
866 d2aij22[i][j] += -2. * d2fijkdnk[evinds[j]][evinds[i]] * chi2id[j] * dmus[j];
871 d2aij22[i][j] += -d2fijkd2nk[evinds[j]][evinds[i]] *
m_DensitiesId[j];
872 d2aij22[i][j] += -d3fijkmdnkdnm[evinds[j]][evinds[i]] *
m_DensitiesId[j];
886 for (
int i = 0; i < NN; ++i) {
889 for (
int j = 0; j < NN; ++j)
890 xVector[i] += -2. * daij11[i][j] * d2ni[j] - d2aij11[i][j] * dni[j];
892 for (
int j = 0; j < NN; ++j)
893 xVector[i] += -2. * daij12[i][j] * d2mus[j] - d2aij12[i][j] * dmus[j];
895 for (
int i = 0; i < NN; ++i) {
896 xVector[NN + i] = 0.;
898 for (
int j = 0; j < NN; ++j)
899 xVector[NN + i] += -2. * daij21[i][j] * d2ni[j] - d2aij21[i][j] * dni[j];
901 for (
int j = 0; j < NN; ++j)
902 xVector[NN + i] += -2. * daij22[i][j] * d2mus[j] - d2aij22[i][j] * dmus[j];
905 solVector = decomp.solve(xVector);
907 for (
int i = 0; i < NN; ++i) {
908 d3ni[i] = solVector[i];
909 d3mus[i] = solVector[NN + i];
912 for (
int i = 0; i < NN; ++i)
913 ret[3] += chgs[i] * d3ni[i];
921 vector<double> ret(order + 1, 0.);
924 for (
size_t i = 0; i < m_densities.size(); ++i)
925 ret[0] += chgs[i] * m_densities[i];
929 if (order < 2)
return ret;
931 int NN = m_densities.size();
933 MatrixXd densMatrix(2 * NN, 2 * NN);
934 VectorXd solVector(2 * NN), xVector(2 * NN);
936 vector<double> chi2id(m_densities.size()), Ps(m_densities.size());
937 for (
int i = 0; i < NN; ++i) {
940 chi2id[i] = m_TPS->Particles()[i].chiDimensionfull(2, m_Parameters, m_UseWidth,
m_MuStar[i]) * pow(
xMath::GeVtoifm(), 3);
943 for (
int i = 0; i < NN; ++i)
944 for (
int j = 0; j < NN; ++j) {
946 if (i == j) densMatrix(i, j) += 1.;
949 for (
int i = 0; i < NN; ++i)
950 for (
int j = 0; j < NN; ++j)
951 densMatrix(i, NN + j) = 0.;
953 for (
int i = 0; i < NN; ++i) {
954 densMatrix(i, NN + i) = -
m_exvolmod->f(i) * chi2id[i];
957 for (
int i = 0; i < NN; ++i)
958 for (
int j = 0; j < NN; ++j) {
959 densMatrix(NN + i, j) =
m_mfmod->d2v(i, j);
960 for (
int k = 0; k < NN; ++k) {
961 densMatrix(NN + i, j) += -
m_exvolmod->d2f(k, i, j) * Ps[k];
965 for (
int i = 0; i < NN; ++i)
966 for (
int j = 0; j < NN; ++j) {
968 if (i == j) densMatrix(NN + i, NN + j) += 1.;
971 PartialPivLU<MatrixXd> decomp(densMatrix);
974 vector<double> dni(NN, 0.), dmus(NN, 0.);
976 for (
int i = 0; i < NN; ++i) {
978 xVector[NN + i] = chgs[i];
981 solVector = decomp.solve(xVector);
983 for (
int i = 0; i < NN; ++i) {
984 dni[i] = solVector[i];
985 dmus[i] = solVector[NN + i];
988 for (
int i = 0; i < NN; ++i)
989 ret[1] += chgs[i] * dni[i];
993 if (order < 3)
return ret;
996 vector<double> d2ni(NN, 0.), d2mus(NN, 0.);
998 vector<double> chi3id(m_densities.size());
999 for (
int i = 0; i < NN; ++i)
1000 chi3id[i] = m_TPS->Particles()[i].chiDimensionfull(3, m_Parameters, m_UseWidth,
m_MuStar[i]) * pow(
xMath::GeVtoifm(), 3);
1002 vector< vector<double> > daij11, daij12, daij21, daij22;
1008 for (
int i = 0; i < NN; ++i) {
1009 cout <<
"chi3 iter: " << i <<
"\n";
1010 daij11[i].resize(NN);
1011 daij12[i].resize(NN);
1012 daij21[i].resize(NN);
1013 daij22[i].resize(NN);
1014 for (
int j = 0; j < NN; ++j) {
1016 for (
int k = 0; k < NN; ++k)
1018 daij11[i][j] += -
m_exvolmod->df(i, j) * chi2id[i] * dmus[i];
1022 for (
int k = 0; k < NN; ++k)
1023 daij12[i][j] += -
m_exvolmod->df(i, k) * chi2id[i] * dni[k];
1024 daij12[i][j] += -
m_exvolmod->f(i) * chi3id[i] * dmus[i];
1029 for (
int k = 0; k < NN; ++k) {
1030 daij21[i][j] +=
m_mfmod->d3v(i, j, k) * dni[k];
1032 for (
int m = 0; m < NN; ++m)
1033 daij21[i][j] += -Ps[k] *
m_exvolmod->d3f(k, i, j, m) * dni[m];
1037 daij22[i][j] += -
m_exvolmod->df(j, i) * chi2id[j] * dmus[j];
1038 for (
int k = 0; k < NN; ++k)
1044 for (
int i = 0; i < NN; ++i) {
1047 for (
int j = 0; j < NN; ++j)
1048 xVector[i] += -daij11[i][j] * dni[j];
1050 for (
int j = 0; j < NN; ++j)
1051 xVector[i] += -daij12[i][j] * dmus[j];
1053 for (
int i = 0; i < NN; ++i) {
1054 xVector[NN + i] = 0.;
1056 for (
int j = 0; j < NN; ++j)
1057 xVector[NN + i] += -daij21[i][j] * dni[j];
1059 for (
int j = 0; j < NN; ++j)
1060 xVector[NN + i] += -daij22[i][j] * dmus[j];
1063 solVector = decomp.solve(xVector);
1065 for (
int i = 0; i < NN; ++i) {
1066 d2ni[i] = solVector[i];
1067 d2mus[i] = solVector[NN + i];
1070 for (
int i = 0; i < NN; ++i)
1071 ret[2] += chgs[i] * d2ni[i];
1075 if (order < 4)
return ret;
1078 vector<double> d3ni(NN, 0.), d3mus(NN, 0.);
1080 vector<double> chi4id(m_densities.size());
1081 for (
int i = 0; i < NN; ++i)
1082 chi4id[i] = m_TPS->Particles()[i].chiDimensionfull(4, m_Parameters, m_UseWidth,
m_MuStar[i]) * pow(
xMath::GeVtoifm(), 3);
1084 vector< vector<double> > d2aij11, d2aij12, d2aij21, d2aij22;
1090 for (
int i = 0; i < NN; ++i) {
1091 cout <<
"chi4 iter: " << i <<
"\n";
1092 d2aij11[i].resize(NN);
1093 d2aij12[i].resize(NN);
1094 d2aij21[i].resize(NN);
1095 d2aij22[i].resize(NN);
1096 for (
int j = 0; j < NN; ++j) {
1098 d2aij11[i][j] += -
m_exvolmod->df(i, j) * chi3id[i] * dmus[i] * dmus[i];
1099 d2aij11[i][j] += -
m_exvolmod->df(i, j) * chi2id[i] * d2mus[i];
1100 for (
int k = 0; k < NN; ++k) {
1101 d2aij11[i][j] += -
m_exvolmod->d2f(i, j, k) * chi2id[i] * dmus[i] * dni[k];
1103 d2aij11[i][j] += -
m_exvolmod->d2f(i, j, k) * chi2id[i] * dmus[i] * dni[k];
1104 for (
int m = 0; m < NN; ++m) {
1111 d2aij12[i][j] += -
m_exvolmod->f(i) * chi3id[i] * d2mus[i];
1112 d2aij12[i][j] += -
m_exvolmod->f(i) * chi4id[i] * dmus[i] * dmus[i];
1113 for (
int k = 0; k < NN; ++k) {
1114 d2aij12[i][j] += -2. *
m_exvolmod->df(i, k) * chi3id[i] * dmus[i] * dni[k];
1115 d2aij12[i][j] += -
m_exvolmod->df(i, k) * chi2id[i] * d2ni[k];
1116 for (
int m = 0; m < NN; ++m) {
1117 d2aij12[i][j] += -
m_exvolmod->d2f(i, k, m) * chi2id[i] * dni[k] * dni[m];
1123 for (
int k = 0; k < NN; ++k) {
1125 d2aij21[i][j] +=
m_mfmod->d3v(i, j, k) * d2ni[k];
1126 for (
int m = 0; m < NN; ++m)
1127 d2aij21[i][j] +=
m_mfmod->d4v(i, j, k, m) * dni[k] * dni[m];
1130 d2aij21[i][j] += -
m_exvolmod->d2f(k, i, j) * chi2id[k] * dmus[k] * dmus[k];
1131 for (
int m = 0; m < NN; ++m)
1134 for (
int m = 0; m < NN; ++m) {
1137 d2aij21[i][j] += -Ps[k] *
m_exvolmod->d3f(k, i, j, m) * d2ni[m];
1138 for (
int l = 0; l < NN; ++l)
1139 d2aij21[i][j] += -Ps[k] *
m_exvolmod->d4f(k, i, j, m, l) * dni[m] * dni[l];
1145 d2aij22[i][j] += -
m_exvolmod->df(j, i) * chi3id[j] * dmus[j] * dmus[j];
1146 d2aij22[i][j] += -
m_exvolmod->df(j, i) * chi2id[j] * d2mus[j];
1147 for (
int k = 0; k < NN; ++k)
1148 d2aij22[i][j] += -
m_exvolmod->d2f(j, i, k) * chi2id[j] * dmus[j] * dni[k];
1149 for (
int k = 0; k < NN; ++k) {
1151 d2aij22[i][j] += -
m_exvolmod->d2f(j, i, k) * chi2id[j] * dni[k] * dmus[j];
1153 for (
int m = 0; m < NN; ++m) {
1161 for (
int i = 0; i < NN; ++i) {
1164 for (
int j = 0; j < NN; ++j)
1165 xVector[i] += -2. * daij11[i][j] * d2ni[j] - d2aij11[i][j] * dni[j];
1167 for (
int j = 0; j < NN; ++j)
1168 xVector[i] += -2. * daij12[i][j] * d2mus[j] - d2aij12[i][j] * dmus[j];
1170 for (
int i = 0; i < NN; ++i) {
1171 xVector[NN + i] = 0.;
1173 for (
int j = 0; j < NN; ++j)
1174 xVector[NN + i] += -2. * daij21[i][j] * d2ni[j] - d2aij21[i][j] * dni[j];
1176 for (
int j = 0; j < NN; ++j)
1177 xVector[NN + i] += -2. * daij22[i][j] * d2mus[j] - d2aij22[i][j] * dmus[j];
1180 solVector = decomp.solve(xVector);
1182 for (
int i = 0; i < NN; ++i) {
1183 d3ni[i] = solVector[i];
1184 d3mus[i] = solVector[NN + i];
1187 for (
int i = 0; i < NN; ++i)
1188 ret[3] += chgs[i] * d3ni[i];
1198 if (order < 1)
return m_chi;
1200 vector<double> chgs(m_densities.size());
1201 vector<double> chis;
1204 for (
size_t i = 0; i < chgs.size(); ++i)
1205 chgs[i] = m_TPS->Particles()[i].BaryonCharge();
1207 for (
int i = 0; i < order; ++i)
m_chi[i][0] = chis[i];
1210 for (
size_t i = 0; i < chgs.size(); ++i)
1211 chgs[i] = m_TPS->Particles()[i].ElectricCharge();
1213 for (
int i = 0; i < order; ++i)
m_chi[i][1] = chis[i];
1216 for (
size_t i = 0; i < chgs.size(); ++i)
1217 chgs[i] = m_TPS->Particles()[i].Strangeness();
1219 for (
int i = 0; i < order; ++i)
m_chi[i][2] = chis[i];
1222 for (
size_t i = 0; i < chgs.size(); ++i)
1223 chgs[i] = m_TPS->Particles()[i].ArbitraryCharge();
1225 for (
int i = 0; i < order; ++i)
m_chiarb[i] = chis[i];
1232 int NN = m_densities.size();
1233 int Nevcomp =
m_exvolmod->ComponentsNumber();
1234 const vector<int>& evinds =
m_exvolmod->ComponentIndices();
1235 const vector<int>& evindsfrom =
m_exvolmod->ComponentIndicesFrom();
1238 m_PrimCorrel.resize(NN);
1239 for (
int i = 0; i < NN; ++i)
1240 m_PrimCorrel[i].resize(NN);
1241 m_dmusdmu = m_PrimCorrel;
1242 m_TotalCorrel = m_PrimCorrel;
1244 MatrixXd densMatrix(2 * NN, 2 * NN);
1245 VectorXd solVector(2 * NN), xVector(2 * NN);
1247 vector<double> chi2id(m_densities.size()), Ps(m_densities.size());
1248 for (
int i = 0; i < NN; ++i) {
1251 chi2id[i] = m_TPS->Particles()[i].chiDimensionfull(2, m_Parameters, m_UseWidth,
m_MuStar[i]);
1254 vector<double> evc_Ps(Nevcomp, 0.);
1255 for (
int i = 0; i < NN; ++i) {
1256 evc_Ps[evinds[i]] += Ps[i];
1259 for (
int i = 0; i < NN; ++i)
1260 for (
int j = 0; j < NN; ++j) {
1262 if (i == j) densMatrix(i, j) += 1.;
1265 for (
int i = 0; i < NN; ++i)
1266 for (
int j = 0; j < NN; ++j)
1267 densMatrix(i, NN + j) = 0.;
1269 for (
int i = 0; i < NN; ++i) {
1273 for (
int i = 0; i < NN; ++i)
1274 for (
int j = 0; j < NN; ++j) {
1275 densMatrix(NN + i, j) =
m_mfmod->d2v(i, j);
1279 for (
int indk = 0; indk < Nevcomp; ++indk) {
1280 int k = evindsfrom[indk];
1281 densMatrix(NN + i, j) += -
m_exvolmod->d2f(k, i, j) * evc_Ps[indk];
1285 for (
int i = 0; i < NN; ++i)
1286 for (
int j = 0; j < NN; ++j) {
1288 if (i == j) densMatrix(NN + i, NN + j) += 1.;
1291 PartialPivLU<MatrixXd> decomp(densMatrix);
1293 for (
int k = 0; k < NN; ++k) {
1294 vector<double> dni(NN, 0.), dmus(NN, 0.);
1296 for (
int i = 0; i < NN; ++i) {
1298 xVector[NN + i] =
static_cast<int>(i == k);
1301 solVector = decomp.solve(xVector);
1303 for (
int i = 0; i < NN; ++i) {
1304 dni[i] = solVector[i];
1305 dmus[i] = solVector[NN + i];
1306 m_dmusdmu[i][k] = dmus[i];
1309 for (
int j = 0; j < NN; ++j) {
1310 m_PrimCorrel[j][k] = dni[j];
1314 for (
int i = 0; i < NN; ++i) {
1315 m_wprim[i] = m_PrimCorrel[i][i];
1316 if (m_densities[i] > 0.) m_wprim[i] *= m_Parameters.T / m_densities[i];
1317 else m_wprim[i] = 1.;
1323 int N = m_TPS->ComponentsNumber();
1324 int Nevcomp =
m_exvolmod->ComponentsNumber();
1325 const vector<int>& evinds =
m_exvolmod->ComponentIndices();
1326 const vector<int>& evindsfrom =
m_exvolmod->ComponentIndicesFrom();
1327 int Nmfcomp =
m_mfmod->ComponentsNumber();
1328 const vector<int>& mfinds =
m_mfmod->ComponentIndices();
1329 const vector<int>& mfindsfrom =
m_mfmod->ComponentIndicesFrom();
1331 double T = m_Parameters.T;
1333 m_dndT = vector<double>(N, 0.);
1334 m_dmusdT = vector<double>(N, 0.);
1335 m_PrimChi2sdT = vector<vector<double>>(N, vector<double>(N, 0.));
1337 vector<double> nids(N, 0.), dniddTs(N, 0.), chi2ids(N, 0.), dchi2idsdT(N, 0.), chi3ids(N, 0.);
1338 for (
int i = 0; i < N; ++i) {
1341 chi2ids[i] = m_TPS->Particles()[i].chiDimensionfull(2, m_Parameters, m_UseWidth,
m_MuStar[i]) *
xMath::GeVtoifm3();
1345 chi3ids[i] = m_TPS->Particles()[i].chiDimensionfull(3, m_Parameters, m_UseWidth,
m_MuStar[i]) *
xMath::GeVtoifm3();
1348 int NN = m_densities.size();
1350 MatrixXd densMatrix(2 * NN, 2 * NN);
1351 VectorXd solVector(2 * NN), xVector(2 * NN);
1353 vector<double> chi2id(m_densities.size()), Ps(m_densities.size()), sids(m_densities.size());
1354 for (
int i = 0; i < NN; ++i) {
1361 vector<double> evc_Ps(Nevcomp, 0.);
1362 for (
int i = 0; i < NN; ++i) {
1363 evc_Ps[evinds[i]] += Ps[i];
1366 for (
int i = 0; i < NN; ++i)
1367 for (
int j = 0; j < NN; ++j) {
1369 if (i == j) densMatrix(i, j) += 1.;
1372 for (
int i = 0; i < NN; ++i)
1373 for (
int j = 0; j < NN; ++j)
1374 densMatrix(i, NN + j) = 0.;
1376 for (
int i = 0; i < NN; ++i) {
1377 densMatrix(i, NN + i) = -
m_exvolmod->f(i) * chi2ids[i];
1380 for (
int i = 0; i < NN; ++i)
1381 for (
int j = 0; j < NN; ++j) {
1382 densMatrix(NN + i, j) =
m_mfmod->d2v(i, j);
1383 for (
int indk = 0; indk < Nevcomp; ++indk) {
1384 int k = evindsfrom[indk];
1385 densMatrix(NN + i, j) += -
m_exvolmod->d2f(k, i, j) * evc_Ps[indk];
1389 for (
int i = 0; i < NN; ++i)
1390 for (
int j = 0; j < NN; ++j) {
1392 if (i == j) densMatrix(NN + i, NN + j) += 1.;
1395 PartialPivLU<MatrixXd> decomp(densMatrix);
1397 for(
int i = 0; i < NN; ++i) {
1399 xVector[i] = fi * dniddTs[i];
1400 xVector[NN + i] = 0.;
1401 for(
int j = 0; j < NN; ++j) {
1402 xVector[NN + i] +=
m_exvolmod->df(j, i) * sids[j];
1406 solVector = decomp.solve(xVector);
1408 for(
int i=0;i<NN;++i) {
1409 m_dndT[i] = solVector[i];
1410 m_dmusdT[i] = solVector[NN+i];
1414 if (IsSusceptibilitiesCalculated()) {
1415 vector<double> dnevdT(Nevcomp, 0.);
1416 for(
int l = 0; l < NN; ++l) {
1417 dnevdT[evinds[l]] += m_dndT[l];
1420 vector<vector<double>> chikjd2fikldnldT(Nevcomp, vector<double>(N, 0.));
1421 for (
int indi = 0; indi < Nevcomp; ++indi) {
1422 int i = evindsfrom[indi];
1423 for (
int j = 0; j < N; ++j) {
1424 for (
int k = 0; k < N; ++k) {
1425 for(
int indl = 0; indl < Nevcomp; ++indl) {
1426 int l = evindsfrom[indl];
1427 chikjd2fikldnldT[indi][j] += m_PrimCorrel[k][j] *
m_exvolmod->d2f(i, k, l) * dnevdT[indl];
1433 vector<vector<double>> chikjdfik(Nevcomp, vector<double>(N, 0.));
1434 for (
int indi = 0; indi < Nevcomp; ++indi) {
1435 int i = evindsfrom[indi];
1436 for (
int j = 0; j < N; ++j) {
1437 for (
int k = 0; k < N; ++k) {
1438 chikjdfik[indi][j] += m_PrimCorrel[k][j] *
m_exvolmod->df(i, k);
1443 vector<double> dfikdnkdT(Nevcomp, 0.);
1444 for (
int indi = 0; indi < Nevcomp; ++indi) {
1445 int i = evindsfrom[indi];
1446 for (
int k = 0; k < N; ++k) {
1447 dfikdnkdT[indi] +=
m_exvolmod->df(i, k) * m_dndT[k];
1451 vector<vector<double>> chikjd3vikldnldT(Nmfcomp, vector<double>(N, 0.));
1452 vector<double> dnmfdT(Nmfcomp, 0.);
1453 for(
int l = 0; l < NN; ++l) {
1454 dnmfdT[mfinds[l]] += m_dndT[l];
1457 for (
int indi = 0; indi < Nmfcomp; ++indi) {
1458 int i = mfindsfrom[indi];
1459 for (
int j = 0; j < N; ++j) {
1460 for (
int k = 0; k < N; ++k) {
1461 for(
int indl = 0; indl < Nmfcomp; ++indl) {
1462 int l = mfindsfrom[indl];
1463 chikjd3vikldnldT[indi][j] += m_PrimCorrel[k][j] *
m_mfmod->d3v(i, k, l) * dnmfdT[indl];
1469 vector<vector<double>> chikjd3fmikldnldTPsm(Nevcomp, vector<double>(N, 0.));
1471 for (
int indi = 0; indi < Nevcomp; ++indi) {
1472 int i = evindsfrom[indi];
1473 for (
int j = 0; j < N; ++j) {
1474 for (
int k = 0; k < N; ++k) {
1475 for(
int indl = 0; indl < Nevcomp; ++indl) {
1476 int l = evindsfrom[indl];
1477 for(
int indm = 0; indm < Nevcomp; ++indm) {
1478 int m = evindsfrom[indm];
1479 chikjd3fmikldnldTPsm[indi][j] += m_PrimCorrel[k][j] *
m_exvolmod->d3f(m, i, k, l) * dnevdT[indl] * evc_Ps[indm];
1486 vector<double> splusnidsums(Nevcomp, 0.);
1487 for(
int m = 0; m < NN; ++m) {
1488 splusnidsums[evinds[m]] += sids[m] + nids[m] * m_dmusdT[m];
1490 vector<vector<double>> chikjd2fmiketc(Nevcomp, vector<double>(N, 0.));
1491 for (
int indi = 0; indi < Nevcomp; ++indi) {
1492 int i = evindsfrom[indi];
1493 for (
int j = 0; j < N; ++j) {
1494 for (
int k = 0; k < N; ++k) {
1495 for (
int indm = 0; indm < Nevcomp; ++indm) {
1496 int m = evindsfrom[indm];
1497 chikjd2fmiketc[indi][j] += m_PrimCorrel[k][j] *
m_exvolmod->d2f(m, i, k) * splusnidsums[indm];
1503 vector<vector<double>> dmusmukjd2fkildnldTnidk(Nevcomp, vector<double>(N, 0.));
1504 for (
int indi = 0; indi < Nevcomp; ++indi) {
1505 int i = evindsfrom[indi];
1506 for (
int j = 0; j < N; ++j) {
1507 for (
int k = 0; k < N; ++k) {
1508 for(
int indl = 0; indl < Nevcomp; ++indl) {
1509 int l = evindsfrom[indl];
1510 dmusmukjd2fkildnldTnidk[indi][j] += m_dmusdmu[k][j] *
m_exvolmod->d2f(k, i, l) * dnevdT[indl] * nids[k];
1516 vector<vector<double>> dmusdmukjdfkietc(Nevcomp, vector<double>(N, 0.));
1517 for (
int indi = 0; indi < Nevcomp; ++indi) {
1518 int i = evindsfrom[indi];
1519 for (
int j = 0; j < N; ++j) {
1520 for (
int k = 0; k < N; ++k) {
1521 dmusdmukjdfkietc[indi][j] += m_dmusdmu[k][j] *
m_exvolmod->df(k, i) * (dniddTs[k] + chi2ids[k] * m_dmusdT[k]);
1527 for (
int j = 0; j < NN; ++j) {
1528 for (
int i = 0; i < NN; ++i) {
1532 a1 += chikjd2fikldnldT[evinds[i]][j] * nids[i];
1533 a1 += chikjdfik[evinds[i]][j] * (dniddTs[i] + chi2ids[i] * m_dmusdT[i]);
1534 a1 += m_dmusdmu[i][j] * dfikdnkdT[evinds[i]] * chi2ids[i];
1543 a1 += m_dmusdmu[i][j] *
m_exvolmod->f(i) * (dchi2idsdT[i] + chi3ids[i] * m_dmusdT[i]);
1552 a2 += -chikjd3vikldnldT[mfinds[i]][j];
1554 a2 += chikjd3fmikldnldTPsm[evinds[i]][j];
1556 a2 += chikjd2fmiketc[evinds[i]][j];
1558 a2 += dmusmukjd2fkildnldTnidk[evinds[i]][j];
1560 a2 += dmusdmukjdfkietc[evinds[i]][j];
1577 xVector[i + NN] = a2;
1580 solVector = decomp.solve(xVector);
1582 for (
int i = 0; i < NN; ++i) {
1589 m_TemperatureDerivativesCalculated =
true;
1593 m_TemperatureDerivativesCalculated =
true;
1604 for (
size_t i = 0; i < m_wprim.size(); ++i) {
1611 m_FluctuationsCalculated =
true;
1613 if (IsTemperatureDerivativesCalculated()) {
1614 m_TemperatureDerivativesCalculated =
false;
1620 if (!IsTemperatureDerivativesCalculated())
1626 for (
int i = 0; i < m_TPS->ComponentsNumber(); ++i) {
1629 for (
int k = 0; k < m_TPS->ComponentsNumber(); ++k) {
1643 ret += dvi * m_dndT[i];
1647 assert(
m_mfmod->dvdT() == 0.0);
1655 for (
size_t i = 0; i < m_densities.size(); ++i)
1660 for (
size_t i = 0; i < m_densities.size(); ++i) {
1662 ret += -m_Parameters.T * tPid *
m_exvolmod->dfdT(i);
1664 ret += m_Parameters.T *
m_mfmod->dvdT();
1673 for (
size_t i = 0; i < m_densities.size(); ++i)
1677 for (
size_t i = 0; i < m_densities.size(); ++i) {
1679 ret += -m_Parameters.T * tPid *
m_exvolmod->dfdT(i);
1681 ret += m_Parameters.T *
m_mfmod->dvdT();
1690 for (
size_t i = 0; i < m_densities.size(); ++i) {
1692 for (
size_t j = 0; j < m_densities.size(); ++j) {
1693 tfsum += m_densities[j] *
m_exvolmod->df(i, j);
1700 for (
size_t i = 0; i < m_densities.size(); ++i)
1701 ret +=
m_mfmod->dv(i) * m_densities[i];
1720 std::vector<double> ThermalModelRealGas::BroydenEquationsRealGas::Equations(
const std::vector<double>& x)
1722 int NN = m_THM->Densities().size();
1723 vector<double> Ps(NN, 0.);
1724 for (
int i = 0; i < NN; ++i) {
1725 Ps[i] = m_THM->TPS()->Particles()[i].Density(m_THM->
Parameters(),
1732 vector<double> ns(NN, 0.);
1733 for (
int i = 0; i < NN; ++i) {
1734 ns[i] = m_THM->TPS()->Particles()[i].Density(m_THM->
Parameters(),
1741 vector<double> np = m_THM->m_exvolmod->nsol(ns);
1742 m_THM->m_exvolmod->SetDensities(np);
1743 m_THM->m_mfmod->SetDensities(np);
1745 vector<double> ret(
m_N, 0.);
1746 for (
size_t i = 0; i < ret.size(); ++i) {
1748 for (
int j = 0; j < NN; ++j)
1749 ret[i] += -m_THM->m_exvolmod->df(j, i) * Ps[j];
1750 ret[i] += m_THM->m_mfmod->dv(i);
1755 std::vector<double> ThermalModelRealGas::BroydenJacobianRealGas::Jacobian(
const std::vector<double>& x)
1757 int NN = m_THM->m_densities.size();
1759 MatrixXd densMatrix(NN, NN);
1760 VectorXd solVector(NN), xVector(NN);
1762 std::vector<double> ret(NN * NN, 0.);
1764 vector<double> Ps(NN, 0.);
1765 for (
int i = 0; i < NN; ++i)
1766 Ps[i] = m_THM->TPS()->Particles()[i].Density(m_THM->Parameters(),
1769 m_THM->ChemicalPotential(i) + x[i]
1772 vector<double> ns(NN, 0.);
1773 for (
int i = 0; i < NN; ++i)
1774 ns[i] = m_THM->TPS()->Particles()[i].Density(m_THM->Parameters(),
1777 m_THM->ChemicalPotential(i) + x[i]
1780 vector<double> chi2s(NN, 0.);
1781 for (
int i = 0; i < NN; ++i)
1782 chi2s[i] = m_THM->TPS()->Particles()[i].chiDimensionfull(2, m_THM->Parameters(),
1784 m_THM->ChemicalPotential(i) + x[i]
1787 vector<double> np = m_THM->m_exvolmod->nsol(ns);
1788 m_THM->m_exvolmod->SetDensities(np);
1789 m_THM->m_mfmod->SetDensities(np);
1791 for (
int i = 0; i < NN; ++i) {
1792 for (
int j = 0; j < NN; ++j) {
1793 densMatrix(i, j) = 0.;
1795 densMatrix(i, j) += 1.;
1797 densMatrix(i, j) += -m_THM->m_exvolmod->df(i, j) * ns[i];
1801 int Nevcomp = m_THM->m_exvolmod->ComponentsNumber();
1802 const vector<int>& evinds = m_THM->m_exvolmod->ComponentIndices();
1803 const vector<int>& evindsfrom = m_THM->m_exvolmod->ComponentIndicesFrom();
1805 int Nmfcomp = m_THM->m_mfmod->ComponentsNumber();
1806 const vector<int>& mfinds = m_THM->m_mfmod->ComponentIndices();
1807 const vector<int>& mfindsfrom = m_THM->m_mfmod->ComponentIndicesFrom();
1809 vector<double> evc_Ps(Nevcomp, 0.);
1810 for (
int i = 0; i < NN; ++i)
1811 evc_Ps[m_THM->m_exvolmod->ComponentIndices()[i]] += Ps[i];
1813 PartialPivLU<MatrixXd> decomp(densMatrix);
1815 for (
int kp = 0; kp < NN; ++kp) {
1818 for (
int l = 0; l < NN; ++l) {
1821 xVector[l] = chi2s[l] * pow(
xMath::GeVtoifm(), 3) * m_THM->m_exvolmod->f(l);
1825 solVector = decomp.solve(xVector);
1826 for (
int i = 0; i < NN; ++i)
1827 if (solVector[i] > 1.) solVector[i] = 1.;
1830 vector<double> dnjdmukp(NN, 0.);
1831 vector<double> evc_dnjdmukp(Nevcomp, 0.);
1832 vector<double> evc_d2fmul(Nevcomp, 0.);
1833 vector<double> mfc_dnjdmukp(Nmfcomp, 0.);
1834 vector<double> mfc_d2vmul(Nmfcomp, 0.);
1836 for (
int j = 0; j < NN; ++j) {
1837 dnjdmukp[j] = solVector[j];
1838 evc_dnjdmukp[evinds[j]] += solVector[j];
1839 mfc_dnjdmukp[mfinds[j]] += solVector[j];
1841 for (
int nn = 0; nn < Nevcomp; ++nn) {
1842 for (
int in = 0; in < Nevcomp; ++in) {
1843 for (
int inp = 0; inp < Nevcomp; ++inp) {
1844 int n = evindsfrom[in];
1845 int np = evindsfrom[inp];
1846 int k = evindsfrom[nn];
1847 evc_d2fmul[nn] += -evc_Ps[in] * m_THM->m_exvolmod->d2f(n, k, np) * evc_dnjdmukp[inp];
1852 for (
int nn = 0; nn < Nmfcomp; ++nn) {
1853 for (
int in = 0; in < Nmfcomp; ++in) {
1854 int n = mfindsfrom[in];
1855 int k = mfindsfrom[nn];
1856 mfc_d2vmul[nn] += m_THM->m_mfmod->d2v(k, n) * mfc_dnjdmukp[in];
1862 for (
int k = 0; k < NN; ++k) {
1864 ret[k * NN + kp] += 1.;
1865 ret[k * NN + kp] += -m_THM->m_exvolmod->df(kp, k) * ns[kp];
1868 ret[k * NN + kp] += evc_d2fmul[evinds[k]];
1870 ret[k * NN + kp] += mfc_d2vmul[mfinds[k]];
1880 bool ThermalModelRealGas::BroydenSolutionCriteriumRealGas::IsSolved(
const std::vector<double>& x,
const std::vector<double>& f,
const std::vector<double>& xdelta)
const
1882 if (xdelta.size() == x.size()) {
1883 double maxdiff = 0.;
1884 for (
size_t i = 0; i < xdelta.size(); ++i) {
1885 maxdiff = std::max(maxdiff, fabs(xdelta[i]));
1886 maxdiff = std::max(maxdiff, fabs(f[i]));
1888 return (maxdiff < m_MaximumError);
1895 std::vector<double> ThermalModelRealGas::BroydenEquationsRealGasComponents::Equations(
const std::vector<double> &x)
1897 int NN = m_THM->Densities().size();
1898 vector<double> Ps(NN, 0.);
1899 for (
int i = 0; i < NN; ++i) {
1900 Ps[i] = m_THM->TPS()->Particles()[i].Density(m_THM->Parameters(),
1903 m_THM->ChemicalPotential(i) + x[m_THM->m_MapTodMuStar[i]]
1907 vector<double> ns(NN, 0.);
1908 for (
int i = 0; i < NN; ++i) {
1909 ns[i] = m_THM->TPS()->Particles()[i].Density(m_THM->Parameters(),
1912 m_THM->ChemicalPotential(i) + x[m_THM->m_MapTodMuStar[i]]
1916 vector<double> np = m_THM->m_exvolmod->nsol(ns);
1917 m_THM->m_exvolmod->SetDensities(np);
1918 m_THM->m_mfmod->SetDensities(np);
1920 vector<double> ret(m_N, 0.);
1921 for (
size_t i = 0; i < ret.size(); ++i) {
1923 for (
int j = 0; j < NN; ++j)
1924 ret[i] += -m_THM->m_exvolmod->df(j, m_THM->m_MapFromdMuStar[i]) * Ps[j];
1925 ret[i] += m_THM->m_mfmod->dv(m_THM->m_MapFromdMuStar[i]);
1930 std::vector<double> ThermalModelRealGas::BroydenJacobianRealGasComponents::Jacobian(
const std::vector<double> &x)
1932 int NN = m_THM->m_densities.size();
1933 int NNdmu = m_THM->m_MapFromdMuStar.size();
1935 MatrixXd densMatrix(NNdmu, NNdmu);
1936 VectorXd solVector(NNdmu), xVector(NNdmu);
1938 std::vector<double> ret(NNdmu * NNdmu, 0.);
1940 vector<double> Ps(NN, 0.);
1941 for (
int i = 0; i < NN; ++i)
1942 Ps[i] = m_THM->TPS()->Particles()[i].Density(m_THM->Parameters(),
1945 m_THM->ChemicalPotential(i) + x[m_THM->m_MapTodMuStar[i]]
1948 vector<double> ns(NN, 0.);
1949 for (
int i = 0; i < NN; ++i)
1950 ns[i] = m_THM->TPS()->Particles()[i].Density(m_THM->Parameters(),
1953 m_THM->ChemicalPotential(i) + x[m_THM->m_MapTodMuStar[i]]
1956 vector<double> chi2s(NN, 0.);
1957 for (
int i = 0; i < NN; ++i)
1958 chi2s[i] = m_THM->TPS()->Particles()[i].chiDimensionfull(2, m_THM->Parameters(),
1960 m_THM->ChemicalPotential(i) + x[m_THM->m_MapTodMuStar[i]]
1963 vector<double> evc_Ps(NNdmu, 0.);
1964 for (
int i = 0; i < NN; ++i)
1965 evc_Ps[m_THM->m_MapTodMuStar[i]] += Ps[i];
1966 vector<double> ns_comps(NNdmu, 0.);
1967 for (
int i = 0; i < NN; ++i)
1968 ns_comps[m_THM->m_MapTodMuStar[i]] += ns[i];
1969 vector<double> chi2_comps(NNdmu, 0.);
1970 for (
int i = 0; i < NN; ++i)
1971 chi2_comps[m_THM->m_MapTodMuStar[i]] += chi2s[i];
1973 vector<double> np = m_THM->m_exvolmod->nsol(ns);
1974 m_THM->m_exvolmod->SetDensities(np);
1975 m_THM->m_mfmod->SetDensities(np);
1977 for (
int i = 0; i < NNdmu; ++i) {
1978 for (
int j = 0; j < NNdmu; ++j) {
1979 densMatrix(i, j) = 0.;
1981 densMatrix(i, j) += 1.;
1983 densMatrix(i, j) += -m_THM->m_exvolmod->df(m_THM->m_MapFromdMuStar[i], m_THM->m_MapFromdMuStar[j])
1990 PartialPivLU<MatrixXd> decomp(densMatrix);
1992 for (
int kp = 0; kp < NNdmu; ++kp) {
1994 for (
int l = 0; l < NNdmu; ++l) {
1998 * m_THM->m_exvolmod->f(m_THM->m_MapFromdMuStar[l]);
2002 solVector = decomp.solve(xVector);
2003 for (
int i = 0; i < NNdmu; ++i)
2004 if (solVector[i] > 1.) solVector[i] = 1.;
2006 vector<double> dnjdmukp(NNdmu, 0.);
2007 for (
int j = 0; j < NNdmu; ++j) {
2008 dnjdmukp[j] = solVector[j];
2011 vector<double> evc_d2fmul(NNdmu, 0.);
2012 vector<double> mfc_d2vmul(NNdmu, 0.);
2013 for (
int nn = 0; nn < NNdmu; ++nn) {
2014 for (
int in = 0; in < NNdmu; ++in) {
2015 for (
int inp = 0; inp < NNdmu; ++inp) {
2016 int n = m_THM->m_MapFromdMuStar[in];
2017 int np = m_THM->m_MapFromdMuStar[inp];
2018 int k = m_THM->m_MapFromdMuStar[nn];
2019 evc_d2fmul[nn] += -evc_Ps[in] * m_THM->m_exvolmod->d2f(n, k, np) * dnjdmukp[inp];
2024 for (
int nn = 0; nn < NNdmu; ++nn) {
2025 for (
int in = 0; in < NNdmu; ++in) {
2026 int n = m_THM->m_MapFromdMuStar[in];
2027 int k = m_THM->m_MapFromdMuStar[nn];
2028 mfc_d2vmul[nn] += m_THM->m_mfmod->d2v(k, n) * dnjdmukp[in];
2032 for (
int k = 0; k < NNdmu; ++k) {
2034 ret[k * NNdmu + kp] += 1.;
2035 ret[k * NNdmu + kp] += -m_THM->m_exvolmod->df(m_THM->m_MapFromdMuStar[kp], m_THM->m_MapFromdMuStar[k])
2038 ret[k * NNdmu + kp] += evc_d2fmul[k];
2039 ret[k * NNdmu + kp] += mfc_d2vmul[k];
Contains some functions to deal with excluded volumes.
map< string, double > params
virtual bool IsSolved(const std::vector< double > &x, const std::vector< double > &f, const std::vector< double > &xdelta=std::vector< double >()) const
int m_N
The number of equations.
Class implementing the Broyden method to solve a system of non-linear equations.
double MaxDifference() const
virtual std::vector< double > Solve(const std::vector< double > &x0, BroydenSolutionCriterium *solcrit=NULL, int max_iterations=MAX_ITERS)
int MaxIterations() const
Base class for multi-component excluded volume models.
Base class for multi-component mean field models.
virtual void CalculateSusceptibilityMatrix()
Calculates the conserved charges susceptibility matrix.
virtual void CalculateParticleChargeCorrelationMatrix()
Calculates the matrix of correlators between primordial (and also final) particle numbers and conserv...
virtual void FillChemicalPotentials()
Sets the chemical potentials of all particles.
virtual void SetChemicalPotentials(const std::vector< double > &chem=std::vector< double >(0))
Sets the chemical potentials of all particles.
double ChemicalPotential(int i) const
Chemical potential of particle species i.
virtual void ValidateCalculation()
Checks whether issues have occured during the calculation of particle densities in the CalculateDensi...
int ComponentsNumber() const
Number of different particle species in the list.
virtual void CalculateProxySusceptibilityMatrix()
Calculates the susceptibility matrix of conserved charges proxies.
ThermalModelBase(ThermalParticleSystem *TPS, const ThermalModelParameters ¶ms=ThermalModelParameters())
Construct a new ThermalModelBase object.
bool UseWidth() const
Whether finite resonance widths are considered.
virtual void CalculateDensities()
Calculates the primordial and total (after decays) densities of all species.
const ThermalModelParameters & Parameters() const
@ GCE
Grand canonical ensemble.
virtual void CalculateTwoParticleFluctuationsDecays()
Computes particle number correlations and fluctuations for all final-state particles which are marked...
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 ¶ms=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...
bool m_ComponentMapCalculated
Whether the mapping to components with the same VDW parameters has been calculated.
std::vector< int > m_MapTodMuStar
Mapping from particle species to dMuStar indices.
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...
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.
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.
std::vector< double > m_MuStar
Vector of the shifted chemical potentials.
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 double CalculatePressure()
Calculate the pressure of the system.
virtual ~ThermalModelRealGas(void)
Destroy the ThermalModelRealGas object.
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.
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)
Calculate the charge fluctuations of the 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 all information about a particle specie.
double Density(const ThermalModelParameters ¶ms, IdealGasFunctions::Quantity type=IdealGasFunctions::ParticleDensity, bool useWidth=0, double mu=0.) const
Computes a specified ideal gas thermodynamic function.
Class containing the particle list.
constexpr double GeVtoifm()
A constant to transform GeV into fm .
constexpr double GeVtoifm3()
A constant to transform GeV into fm .
constexpr double mnucleon()
Nucleon's mass. Value as in UrQMD.
The main namespace where all classes and functions of the Thermal-FIST library reside.
Structure containing all thermal parameters of the model.
Contains some extra mathematical functions used in the code.