Reference

Generic Interface

class eos_thermal : private EOS_Toolkit::detail::eos_thermal_base

Interface for generic thermal EOS.

Public Types

using range = interval<real_t>

Synonym for interval.

Public Functions

eos_thermal() = default

Default constructor.

Creates uninitialized EOS. Any attemt to use resulting object throws an exception. One can use it after copying another EOS to it.

inline explicit eos_thermal(spimpl_t eosp)

Constructor from pointer to implementation.

This is intended for EOS implementors. Users should use the functions provided by a given implementation to obtain the EOS.

Parameters

eosp – Shared pointer to implementation

eos_thermal(const eos_thermal&) = default

Copy constructor.

eos_thermal &operator=(const eos_thermal&) = default

Assignment operator.

eos_thermal(eos_thermal&&) = default

Move constructor.

eos_thermal &operator=(eos_thermal&&) = default

Move assignment operator.

~eos_thermal() = default

Destructor.

The EOS implementation will be destructed when no other copy of the EOS is using it (“last person turns off the light”).

auto at_rho_eps_ye(real_t rho, real_t eps, real_t ye) const -> state

Specify a matter state based on density, specific energy, and electron fraction.

Parameters
  • rho – Mass density \( \rho \)

  • eps – Specific internal energy \( \epsilon \)

  • ye – Electron fraction \( Y_e \)

Throws

std::runtime_error – if called for unitialized object

Returns

Object representing matter state

auto at_rho_temp_ye(real_t rho, real_t temp, real_t ye) const -> state

Specify a matter state based on density, temperature, and electron fraction.

Parameters
  • rho – Mass density \( \rho \)

  • temp – Temperature \( T \)

  • ye – Electron fraction \( Y_e \)

Throws
  • std::runtime_error – if EOS does not support temperature

  • std::runtime_error – if called for unitialized object

Returns

Object representing matter state

auto range_rho() const -> const range&
Throws

std::runtime_error – if called for unitialized object

Returns

validity range for density

auto range_ye() const -> const range&
Throws

std::runtime_error – if called for unitialized object

Returns

validity range for electron fraction

auto range_eps(real_t rho, real_t ye) const -> range
Parameters
  • rho – Mass density \( \rho \)

  • ye – Electron fraction \( Y_e \)

Throws

std::runtime_error – if called for unitialized object

Returns

validity range for specific energy.

auto range_temp(real_t rho, real_t ye) const -> range
Parameters
  • rho – Mass density \( \rho \)

  • ye – Electron fraction \( Y_e \)

Throws

std::runtime_error – if called for unitialized object

Returns

validity range for temperature

auto minimal_h() const -> real_t
Throws

std::runtime_error – if called for unitialized object

Returns

global lower bound for relativistic enthalpy.

auto is_rho_valid(real_t rho) const -> bool
Parameters

rho – Mass density \( \rho \)

Throws

std::runtime_error – if called for unitialized object

Returns

if density is in valid range

auto is_ye_valid(real_t ye) const -> bool
Parameters

ye – Electron fraction \( Y_e \)

Throws

std::runtime_error – if called for unitialized object

Returns

if electron fraction is in valid range

auto is_rho_ye_valid(real_t rho, real_t ye) const -> bool
Parameters
  • rho – Mass density \( \rho \)

  • ye – Electron fraction \( Y_e \)

Throws

std::runtime_error – if called for unitialized object

Returns

if density and electron fraction are in valid range

auto is_rho_eps_ye_valid(real_t rho, real_t eps, real_t ye) const -> bool
Parameters
  • rho – Mass density \( \rho \)

  • eps – Specific internal energy \( \epsilon \)

  • ye – Electron fraction \( Y_e \)

Throws

std::runtime_error – if called for unitialized object

Returns

if density, specfic energy, and electron fraction are valid.

auto is_rho_temp_ye_valid(real_t rho, real_t temp, real_t ye) const -> bool
Parameters
  • rho – Mass density \( \rho \)

  • temp – temperature \( T \)

  • ye – Electron fraction \( Y_e \)

Throws

std::runtime_error – if called for unitialized object

Returns

if density, temperature, and electron fraction are valid.

auto press_at_rho_eps_ye(real_t rho, real_t eps, real_t ye) const -> real_t

Compute pressure based on density, specific energy, and electron fraction.

Parameters
  • rho – Mass density \( \rho \)

  • eps – Specific internal energy \( \epsilon \)

  • ye – Electron fraction \( Y_e \)

Throws

std::runtime_error – if called for unitialized object

Returns

Pressure \( P \) if state is valid, else NAN

Post

Guarantees \( P\ge 0 \)

auto csnd_at_rho_eps_ye(real_t rho, real_t eps, real_t ye) const -> real_t

Compute soundspeed based on density, specific energy, and electron fraction.

Parameters
  • rho – Mass density \( \rho \)

  • eps – Specific internal energy \( \epsilon \)

  • ye – Electron fraction \( Y_e \)

Throws

std::runtime_error – if called for unitialized object

Returns

Speed of sound \( c_s \) if state is valid, else NAN

Post

Guarantees \( 0\le c_s < 1 \)

auto temp_at_rho_eps_ye(real_t rho, real_t eps, real_t ye) const -> real_t

Compute temperature based on density, specific energy, and electron fraction.

Parameters
  • rho – Mass density \( \rho \)

  • eps – Specific internal energy \( \epsilon \)

  • ye – Electron fraction \( Y_e \)

Throws
  • std::runtime_error – if temperature not available for EOS

  • std::runtime_error – if called for unitialized object

Returns

Temperature \( T \) if state is valid, else NAN

Post

Guarantees \( T\ge 0 \)

auto sentr_at_rho_eps_ye(real_t rho, real_t eps, real_t ye) const -> real_t

Compute specific entropy based on density, specific energy, and electron fraction.

Parameters
  • rho – Mass density \( \rho \)

  • eps – Specific internal energy \( \epsilon \)

  • ye – Electron fraction \( Y_e \)

Throws
  • std::runtime_error – if entropy not available for EOS

  • std::runtime_error – if called for unitialized object

Returns

Specific entropy \( s \) if state is valid, else NAN

auto dpress_drho_at_rho_eps_ye(real_t rho, real_t eps, real_t ye) const -> real_t

Compute partial derivative of pressure with respect to mass density, \( \frac{\partial P}{\partial \rho} \), based on density, specific energy, and electron fraction.

Parameters
  • rho – Mass density \( \rho \)

  • eps – Specific internal energy \( \epsilon \)

  • ye – Electron fraction \( Y_e \)

Throws

std::runtime_error – if called for unitialized object

Returns

Pressure derivative if state is valid, else NAN

auto dpress_deps_at_rho_eps_ye(real_t rho, real_t eps, real_t ye) const -> real_t

Compute partial derivative of pressure with respect to specific energy, \( \frac{\partial P}{\partial \epsilon} \), based on density, specific energy, and electron fraction.

Parameters
  • rho – Mass density \( \rho \)

  • eps – Specific internal energy \( \epsilon \)

  • ye – Electron fraction \( Y_e \)

Throws

std::runtime_error – if called for unitialized object

Returns

Pressure derivative if state is valid, else NAN

auto press_at_rho_temp_ye(real_t rho, real_t temp, real_t ye) const -> real_t

Compute pressure based on density, temperature, and electron fraction.

Parameters
  • rho – Mass density \( \rho \)

  • temp – Temperature \( T \)

  • ye – Electron fraction \( Y_e \)

Throws
  • std::runtime_error – if temperature not available for EOS

  • std::runtime_error – if called for unitialized object

Returns

Pressure \( P \) if state is valid, else NAN

Post

Guarantees \( P\ge 0 \)

auto csnd_at_rho_temp_ye(real_t rho, real_t temp, real_t ye) const -> real_t

Compute soundspeed based on density, temperature, and electron fraction.

Parameters
  • rho – Mass density \( \rho \)

  • temp – Temperature \( T \)

  • ye – Electron fraction \( Y_e \)

Throws
  • std::runtime_error – if temperature not available for EOS

  • std::runtime_error – if called for unitialized object

Returns

Speed of sound \( c_s \) if state is valid, else NAN

Post

Guarantees \( 0\le c_s < 1 \)

auto eps_at_rho_temp_ye(real_t rho, real_t temp, real_t ye) const -> real_t

Compute specific energy based on density, temperature, and electron fraction.

Parameters
  • rho – Mass density \( \rho \)

  • temp – Temperature \( T \)

  • ye – Electron fraction \( Y_e \)

Throws
  • std::runtime_error – if temperature not available for EOS

  • std::runtime_error – if called for unitialized object

Returns

\( \epsilon \) if state is valid, else NAN

Post

Guarantees \( \epsilon \ge -1 \)

auto sentr_at_rho_temp_ye(real_t rho, real_t temp, real_t ye) const -> real_t

Compute specific entropy based on density, temperature, and electron fraction.

Parameters
  • rho – Mass density \( \rho \)

  • temp – Temperature \( T \)

  • ye – Electron fraction \( Y_e \)

Throws
  • std::runtime_error – if temperature not available for EOS

  • std::runtime_error – if entropy not available for EOS

  • std::runtime_error – if called for unitialized object

Returns

Specific entropy \( s \) if state is valid, else NAN

auto dpress_drho_at_rho_temp_ye(real_t rho, real_t temp, real_t ye) const -> real_t

Compute partial derivative of pressure with respect to mass density, \( \frac{\partial P}{\partial \rho} \), based on density, temperature, and electron fraction.

Parameters
  • rho – Mass density \( \rho \)

  • temp – Temperature \( T \)

  • ye – Electron fraction \( Y_e \)

Throws
  • std::runtime_error – if temperature not available for EOS

  • std::runtime_error – if called for unitialized object

Returns

Pressure derivative if state is valid, else NAN

auto dpress_deps_at_rho_temp_ye(real_t rho, real_t temp, real_t ye) const -> real_t

Compute partial derivative of pressure with respect to specific energy, \( \frac{\partial P}{\partial \epsilon} \), based on density, temperature, and electron fraction.

Parameters
  • rho – Mass density \( \rho \)

  • temp – Temperature \( T \)

  • ye – Electron fraction \( Y_e \)

Throws
  • std::runtime_error – if temperature not available for EOS

  • std::runtime_error – if called for unitialized object

Returns

Pressure derivative if state is valid, else NAN

void save(datasink s) const

Save EOS to a datastore.

Allows saving the EOS to a datastore. This is intended mainly for internal use by the EOS file functionality.

auto units_to_SI() const -> const units&

Return the EOS units.

This returns the conversion factors to express the units used by the EOS into SI units. The units are specified by the user when creating the EOS and stored for bookkeeping.

auto descr_str() const -> std::string

Short description string.

Returns

Short auto-generated EOS type-specific description string

class state : public EOS_Toolkit::detail::eos_thermal_base::state_base

Class representing the matter state for the eos_thermal interface.

Public Functions

inline explicit operator bool() const

Conversion operator to bool.

Returns

If state is valid.

auto press() const -> real_t
Throws

std::runtime_error – if state is invalid

Returns

Pressure \( P \)

Post

Guarantees \( P\ge 0 \)

auto csnd() const -> real_t
Throws

std::runtime_error – if state is invalid

Returns

Speed of sound \( c_s \)

Post

Guarantees \( 0\le c_s < 1 \)

auto temp() const -> real_t
Throws
  • std::runtime_error – if state is invalid

  • std::runtime_error – if temperature not available for EOS

Returns

Temperature \( T\ge 0 \)

Post

Guarantees \( T\ge 0 \)

auto sentr() const -> real_t
Throws
  • std::runtime_error – if state is invalid

  • std::runtime_error – if entropy not available for EOS

Returns

Specific entropy \( s \)

auto eps() const -> real_t
Throws

std::runtime_error – if state is invalid

Returns

Specific internal energy \( \epsilon \)

Post

Guarantees \( \epsilon \ge -1 \)

auto dpress_drho() const -> real_t
Throws

std::runtime_error – if state is invalid

Returns

partial derivative of pressure with respect to mass density \( \frac{\partial P}{\partial \rho} \)

auto dpress_deps() const -> real_t
Throws

std::runtime_error – if state is invalid

Returns

partial derivative of pressure with respect to specific energy \( \frac{\partial P}{\partial \epsilon} \)

Loading and Saving EOS

eos_thermal EOS_Toolkit::load_eos_thermal(std::string fname, const units &u = units::geom_solar())

Load thermal EOS from hdf5 file.

Parameters
  • fname – Filename of EOS file

  • Unit – system the returned EOS should use. The unit system needs to be geometric, i.e. \( G=c=1 \). Default is to fix the mass unit to \( 1 M_\odot \).

Returns

Generic interface to the EOS

void EOS_Toolkit::save_eos_thermal(std::string fname, eos_thermal eos, std::string info = "")

Save thermal EOS to hdf5 file.

Parameters
  • fname – Filename of EOS file

  • eos – EOS object to save

  • info – Free-form description text (optional)

Creating Specific EOS

eos_thermal EOS_Toolkit::make_eos_hybrid(eos_barotr eos_c, real_t gamma_th, real_t eps_max, real_t rho_max)

Create Hybrid EOS.

The parameters are w.r.t EOS units. The EOS units are taken from the cold EOS and stored for bookkeeping.

The electron fraction is an unused dummy parameter for this EOS, with allowed range \([0,1]\).

Parameters
  • eos_c – The cold (barotropic) EOS

  • gamma_th – The adiabatic exponent \( \Gamma_\mathrm{th} \) for the thermal part

  • eps_max – Maximum allowed specific internal energy \( \epsilon \)

  • rho_max – Maximum allowed mass density \( \rho \)

Returns

eos_thermal object representing the hybrid EOS

eos_thermal EOS_Toolkit::make_eos_idealgas(real_t n, real_t max_eps, real_t max_rho, units eos_units = units::geom_solar())

Create a classical ideal gas EOS.

The parameters are w.r.t EOS units. The EOS units given in the last parameter are stored for bookkeeping.

The electron fraction is an unused dummy parameter for this EOS, with allowed range \([0,1]\).

Parameters
  • n – Adiabatic index

  • max_eps – Maximum allowed specific internal energy \( \epsilon \)

  • max_rho – Maximum allowed mass density \( \rho \)

  • eos_units – Unit system of the EOS. Assumed geometric.

Returns

eos_thermal object representing the ideal gas EOS