Skip to content

Commit

Permalink
Merge pull request #39 from vlvovch/devel
Browse files Browse the repository at this point in the history
Update to version 1.4
  • Loading branch information
vlvovch authored Aug 25, 2022
2 parents 830bc24 + 2ffde41 commit 3db145d
Show file tree
Hide file tree
Showing 40 changed files with 2,633 additions and 1,414 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ install:
script:
- mkdir build
- cd build
- cmake -DINCLUDE_TESTS=OFF ../
- cmake -DINCLUDE_TESTS=ON ../
- make -j$(nproc)
- cd bin/examples
- ./CalculationTmu
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ project (ThermalFIST)

# The version number.
set (ThermalFIST_VERSION_MAJOR 1)
set (ThermalFIST_VERSION_MINOR 3)
set (ThermalFIST_VERSION_DEVEL 4)
set (ThermalFIST_VERSION_MINOR 4)
set (ThermalFIST_VERSION_DEVEL 0)

# configure a header file to pass some of the CMake settings
# to the source code
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cmake_minimum_required(VERSION 2.8.2)
include(ExternalProject)
ExternalProject_Add(googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG master
GIT_TAG main
SOURCE_DIR "${PROJECT_BINARY_DIR}/googletest-src"
BINARY_DIR "${PROJECT_BINARY_DIR}/googletest-build"
CONFIGURE_COMMAND ""
Expand Down
206 changes: 16 additions & 190 deletions include/HRGEV/ThermalModelEVCrossterms.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/*
* Thermal-FIST package
*
* Copyright (c) 2015-2018 Volodymyr Vovchenko
* Copyright (c) 2022 Volodymyr Vovchenko
*
* GNU General Public License (GPLv3 or later)
*/
#ifndef THERMALMODELEVCROSSTERMS_H
#define THERMALMODELEVCROSSTERMS_H

#include "HRGBase/ThermalModelBase.h"
#include "HRGVDW/ThermalModelVDW.h"

namespace thermalfist {

Expand All @@ -28,12 +28,11 @@ namespace thermalfist {
* Phys. Rev. C **95**, 044904 (2017),
* [http://arxiv.org/pdf/1606.06218.pdf](http://arxiv.org/pdf/1606.06218.pdf)
*
* The system of transcendental equations for
* "partial pressures" of hadrons
* is solved using the Broyden's method.
* This class implements the crossterms excluded-volume model as a partial case of
* the van der Waals HRG model where all the attraction terms are set to zero.
*
*/
class ThermalModelEVCrossterms : public ThermalModelBase
class ThermalModelEVCrossterms : public ThermalModelVDW
{
public:
/**
Expand All @@ -42,207 +41,34 @@ namespace thermalfist {
* \param TPS A pointer to the ThermalParticleSystem object containing the particle list
* \param params ThermalModelParameters object with current thermal parameters
*/
ThermalModelEVCrossterms(ThermalParticleSystem *TPS, const ThermalModelParameters& params = ThermalModelParameters());
ThermalModelEVCrossterms(ThermalParticleSystem *TPS, const ThermalModelParameters& params = ThermalModelParameters()) :
ThermalModelVDW(TPS, params) {
m_TAG = "ThermalModelEVCrossterms";
m_InteractionModel = CrosstermsEV;
}

/**
* \brief Destroy the ThermalModelEVCrossterms object
*
*/
virtual ~ThermalModelEVCrossterms(void);
virtual ~ThermalModelEVCrossterms(void) { }

// Override functions begin

virtual void FillVirial(const std::vector<double> & ri = std::vector<double>(0));

virtual void ReadInteractionParameters(const std::string &filename);

virtual void WriteInteractionParameters(const std::string &filename);

void SetRadius(double rad);

double VirialCoefficient(int i, int j) const;

void SetVirial(int i, int j, double b);

virtual void ChangeTPS(ThermalParticleSystem *TPS);

virtual void CalculatePrimordialDensities();

void CalculateTwoParticleCorrelations();

void CalculateFluctuations();

virtual std::vector<double> CalculateChargeFluctuations(const std::vector<double> &chgs, int order = 4);

virtual double CalculatePressure();
virtual void SetRadius(double rad) { FillVirial(std::vector<double>(m_TPS->Particles().size(), rad)); }

virtual double CalculateEnergyDensity();
virtual void SetAttraction(int i, int j, double a);

virtual double CalculateEntropyDensity();

// Dummy
virtual double CalculateBaryonMatterEntropyDensity() { return 0.; }
virtual double CalculateMesonMatterEntropyDensity() { return 0.; }

// TODO properly with excluded volume
virtual double ParticleScaledVariance(int /*part*/) { return 1.; }

// TODO properly with excluded volume
virtual double ParticleSkewness(int part) { return m_skewprim[part]; }

// TODO properly with excluded volume
virtual double ParticleKurtosis(int part) { return m_kurtprim[part]; }

// TODO properly with excluded volume
virtual double ParticleScalarDensity(int /*part*/) { return 0.; }
/// No need to search for multiple soultions in EV-HRG model
virtual void SetMultipleSolutionsMode(bool search);

// Override functions end


const std::vector< std::vector<int> >& EVComponentIndices() const { return m_EVComponentIndices; }
virtual double DeltaMu(int i) const { return MuShift(i); }
const std::vector< std::vector<double> >& VirialMatrix() const { return m_Virial; }

protected:
/**
* \brief Solves the system of transcdental equations
* for the pressure using the Broyden's method.
*
* Solves \f$ p_i(T,\mu) = p_i^{\rm id} (T, \mu_i - \sum_j \tilde{b_{ij}} p_j). \f$
*
*/
virtual void SolvePressure(bool resetPartials = true); // Using Broyden's method

void SolvePressureIter(); // Using iteration method

virtual void CalculatePrimordialDensitiesNoReset();

virtual void CalculatePrimordialDensitiesIter();

/**
* \brief Solves the transcendental equation of
* the corresponding diagonal EV model.
*
* The diagonal EV model here has \f$v_i = \tilde{b}_{ii}\f$.
*
* The partial pressures of the diagonal model
* will be recorded into m_Ps.
*
*/
virtual void SolveDiagonal();

/**
* \brief The "partial pressure" of hadron species i
* for the given total pressure in the diagonal model.
*
* \param i 0-based particle species index.
* \param P Input pressure (GeV fm\f$^{-3}\f$)
* \return Computed partial pressure (GeV fm\f$^{-3}\f$)
*/
double PartialPressureDiagonal(int i, double P);

/**
* \brief The total pressure
* for the given input pressure in the diagonal model.
*
* \param Input pressure (GeV fm\f$^{-3}\f$)
* \return Computed pressure (GeV fm\f$^{-3}\f$)
*/
double PressureDiagonalTotal(double P);

/**
* \brief Calculate the ideal gas density of
* particle species i for the given values
* of partial pressures.
*
* \param i 0-based particle specie index
* \param Pressure Input vector of partial pressures (GeV fm\f$^{-3}\f$)
* \return Ideal gas density (fm\f$^{-3}\f$)
*/
virtual double DensityId(int i, const std::vector<double>& pstars = std::vector<double>());

/**
* \brief Calculate the ideal gas pressure of
* particle species i for the given values
* of partial pressures.
*
* \param i 0-based particle specie index
* \param Pressure Input vector of partial pressures (GeV fm\f$^{-3}\f$)
* \return Ideal gas pressure (fm\f$^{-3}\f$)
*/
virtual double Pressure(int i, const std::vector<double>& pstars = std::vector<double>());

/**
* \brief Calculate the ideal gas scaled variance of
* particle species i number fluctuations
* for the given values
* of partial pressures.
*
* \param i 0-based particle specie index
* \param Pressure Input vector of partial pressures (GeV fm\f$^{-3}\f$)
* \return Ideal gas scaled variance
*/
double ScaledVarianceId(int ind);

/**
* \brief The shift in the chemical potential
* of particle species i due to the
* excluded volume interactions.
*
* Equal to \f$- \sum_j \tilde{b_{ij}} p_j\f$
*
* \param i 0-based particle specie index
* \return The shift in the chemical potential
*/
virtual double MuShift(int i) const;

std::vector<double> m_densitiesid; /**< Vector of ideal gas densities with shifted chemical potentials */
std::vector<double> m_Ps; /**< Vector of (solved) partial pressures */
std::vector< std::vector<double> > m_Virial; /**< Matrix of virial (excluded-volume) coefficients \f$ \tilde{b}_{ij} \f$ */
double m_Pressure; /**< The (solved) total pressure */
double m_TotalEntropyDensity; /**< The (solved) entropy pressure */


std::vector<int> m_MapToEVComponent;
std::vector<int> m_MapFromEVComponent;
std::vector< std::vector<int> > m_EVComponentIndices;

private:
class BroydenEquationsCRS : public BroydenEquations
{
public:
BroydenEquationsCRS(ThermalModelEVCrossterms *model) : BroydenEquations(), m_THM(model) { m_N = model->Densities().size(); }
std::vector<double> Equations(const std::vector<double> &x);
private:
ThermalModelEVCrossterms *m_THM;
};

class BroydenEquationsCRSDEV : public BroydenEquations
{
public:
BroydenEquationsCRSDEV(ThermalModelEVCrossterms *model) : BroydenEquations(), m_THM(model) { m_N = 1; }
std::vector<double> Equations(const std::vector<double> &x);
private:
ThermalModelEVCrossterms *m_THM;
};

class BroydenJacobianCRS : public BroydenJacobian
{
public:
BroydenJacobianCRS(ThermalModelEVCrossterms *model) : BroydenJacobian(), m_THM(model) { }
std::vector<double> Jacobian(const std::vector<double> &x);
private:
ThermalModelEVCrossterms *m_THM;
};

class BroydenSolutionCriteriumCRS : public Broyden::BroydenSolutionCriterium
{
public:
BroydenSolutionCriteriumCRS(ThermalModelEVCrossterms *model, double relative_error = Broyden::TOL) : Broyden::BroydenSolutionCriterium(relative_error), m_THM(model) { }
virtual bool IsSolved(const std::vector<double>& x, const std::vector<double>& f, const std::vector<double>& xdelta = std::vector<double>()) const;
protected:
ThermalModelEVCrossterms *m_THM;
};
const std::vector< std::vector<int> >& EVComponentIndices() const { return VDWComponentIndices(); }
};

} // namespace thermalfist
Expand Down
Loading

0 comments on commit 3db145d

Please sign in to comment.