16 const Float p = (gamma - 1._f) * u * rho;
17 return { p,
sqrt(gamma * p / rho) };
21 return p / ((gamma - 1._f) * rho);
25 return p / ((gamma - 1._f) * u);
33 return p /
pow(rho, gamma);
47 const Float p =
sqr(c0) * rho0 / gamma * (
pow(rho / rho0, gamma) - 1._f);
63 const Float chi = 1._f - rho0 / rho;
65 const Float num = rho0 *
sqr(c0) * chi * (1._f - 0.5_f * Gamma * chi);
66 const Float denom =
sqr(1._f - s * chi);
68 return { num / denom + Gamma * u * rho, c0 };
88 const Float eta = rho / rho0;
89 const Float mu = eta - 1._f;
90 const Float denom = u / (u0 * eta * eta) + 1._f;
94 const Float pc = (a + b / denom) * rho * u + A * mu + B * mu * mu;
95 Float dpdu = a * rho + b * rho /
sqr(denom);
96 Float dpdrho = a * u + b * u * (3._f * denom - 2._f) /
sqr(denom) + A / rho0 + 2._f * B * mu / rho0;
97 const Float csc = dpdrho + dpdu *
pc / (rho * rho);
101 const Float rhoExp = rho0 / rho - 1._f;
102 const Float betaExp =
exp(-
min(beta * rhoExp, 70._f));
104 const Float pe = a * rho * u + (b * rho * u / denom + A * mu * betaExp) * alphaExp;
105 dpdu = a * rho + alphaExp * b * rho /
sqr(denom);
106 dpdrho = a * u + alphaExp * (b * u * (3._f * denom - 2._f) /
sqr(denom)) +
107 alphaExp * (b * u * rho / denom) * rho0 * (2._f * alpha * rhoExp) /
sqr(rho) +
108 alphaExp * A * betaExp * (1._f / rho0 + rho0 * mu /
sqr(rho) * (2._f * alpha * rhoExp + beta));
109 Float cse = dpdrho + dpdu * pe / (rho * rho);
111 cse =
max(cse, 0._f);
115 if (rho <= rho0 && u > ucv) {
118 }
else if (rho <= rho0 && u > uiv && u <= ucv) {
119 p = ((u - uiv) * pe + (ucv - u) *
pc) / (ucv - uiv);
121 cs = ((u - uiv) * cse + (ucv - u) * csc) / (ucv - uiv);
124 cs =
max(cs, 0.25_f * A / rho0);
127 return { p,
sqrt(cs) };
132 const Float eta = rho / rho0;
133 const Float mu = eta - 1._f;
134 const Float x = (p - A * mu - B *
sqr(mu)) / rho;
136 const Float m = u0 *
sqr(eta) * (a + b) - x;
138 const Float u = (-m +
sqrt(
sqr(m) - 4._f * l * n)) / (2._f * l);
141 if (rho <= rho0 && u > uiv) {
143 auto func = [
this, rho, p0 = p](
const Float u) {
152 return root.valueOr(u);
161 auto func = [
this, u, p0 = p](
const Float rho) {
184 const Float mu = rho / rho0 - 1._f;
185 const Float p = c * rho * u + A * mu;
200 const Float p =
sqr(cs) * (rho - rho0);
INLINE bool isReal(const AntisymmetricTensor &t)
#define SPH_ASSERT(x,...)
#define NOT_IMPLEMENTED
Helper macro marking missing implementation.
Definitions of physical constaints (in SI units).
INLINE Optional< Float > getRoot(const Interval &range, const Float eps, const TFunctor &functor)
Returns a root of a R->R function on given range.
double Float
Precision used withing the code. Use Float instead of float or double where precision is important.
constexpr INLINE T max(const T &f1, const T &f2)
NAMESPACE_SPH_BEGIN constexpr INLINE T min(const T &f1, const T &f2)
Minimum & Maximum value.
INLINE Float root(const Float f)
constexpr INLINE T sqr(const T &f) noexcept
Return a squared value.
INLINE T sqrt(const T f)
Return a squared root of a value.
constexpr INLINE Float pow(const Float v)
Power for floats.
#define NAMESPACE_SPH_END
@ DENSITY
Density, always a scalar quantity.
StaticArray< T0 &, sizeof...(TArgs)+1 > tie(T0 &t0, TArgs &... rest)
Creates a static array from a list of l-value references.
Aneos(const BodySettings &settings)
virtual Pair< Float > evaluate(const Float rho, const Float u) const override
Computes pressure and local sound speed from given density rho and specific internal energy u.
Float getTemperature(const Float u) const
virtual Float getDensity(const Float p, const Float u) const override
Inverted function; computes density from pressure p and internal energy u.
Float getSpecificEntropy(const Float rho, const Float p) const
virtual Pair< Float > evaluate(const Float rho, const Float u) const override
Computes pressure and local sound speed from given density rho and specific internal energy u.
IdealGasEos(const Float gamma)
virtual Float getInternalEnergy(const Float rho, const Float p) const override
Inverted function; computes specific internal energy u from given density rho and pressure p.
Object representing a 1D interval of real numbers.
virtual Pair< Float > evaluate(const Float rho, const Float u) const override
Computes pressure and local sound speed from given density rho and specific internal energy u.
MieGruneisenEos(const BodySettings &settings)
virtual Pair< Float > evaluate(const Float rho, const Float u) const override
Computes pressure and local sound speed from given density rho and specific internal energy u.
MurnaghanEos(const BodySettings &settings)
TValue get(const TEnum idx, std::enable_if_t<!std::is_enum< std::decay_t< TValue >>::value, int >=0) const
Returns a value of given type from the settings.
virtual Pair< Float > evaluate(const Float rho, const Float u) const override
Computes pressure and local sound speed from given density rho and specific internal energy u.
SimplifiedTillotsonEos(const BodySettings &settings)
Array with fixed number of allocated elements.
virtual Pair< Float > evaluate(const Float rho, const Float u) const override
Computes pressure and local sound speed from given density rho and specific internal energy u.
TaitEos(const BodySettings &settings)
virtual Float getInternalEnergy(const Float rho, const Float p) const override
Inverted function; computes specific internal energy u from given density rho and pressure p.
virtual Float getDensity(const Float p, const Float u) const override
virtual Pair< Float > evaluate(const Float rho, const Float u) const override
Computes pressure and local sound speed from given density rho and specific internal energy u.
TillotsonEos(const BodySettings &settings)
Generic storage and input/output routines of settings.
BodySettingsId
Settings of a single body / gas phase / ...
@ TILLOTSON_NONLINEAR_B
Coefficient B of the nonlinear compressive term in Tillotson equation.
@ TILLOTSON_ALPHA
Alpha coefficient in expanded phase of Tillotson equation.
@ TILLOTSON_ENERGY_CV
Specific energy of complete vaporization.
@ TILLOTSON_SMALL_B
"Small b" coefficient in Tillotson equation
@ BULK_SOUND_SPEED
Used in Mie-Gruneisen equations of state.
@ TAIT_GAMMA
Exponent of density, representing a compressibility of a fluid. Used in Tait equation of state.
@ TILLOTSON_BETA
Beta coefficient in expanded phase of Tillotson equation.
@ TAIT_SOUND_SPEED
Sound speed used in Tait equation of state.
@ BULK_MODULUS
Bulk modulus of the material.
@ DENSITY
Density at zero pressure.
@ TILLOTSON_ENERGY_IV
Specific energy of incipient vaporization.
@ GRUNEISEN_GAMMA
Gruneisen's gamma paraemter used in Mie-Gruneisen equation of state.
@ TILLOTSON_SMALL_A
"Small a" coefficient in Tillotson equation
@ HUGONIOT_SLOPE
Linear Hugoniot slope coefficient used in Mie-Gruneisen equation of state.
@ TILLOTSON_SUBLIMATION
Specific sublimation energy.
constexpr Float pc
Parsec.
constexpr Float gasConstant