Line data Source code
1 : // *****************************************************************************
2 : /*!
3 : \file src/Physics/EOS.hpp
4 : \copyright 2012-2015 J. Bakosi,
5 : 2016-2018 Los Alamos National Security, LLC.,
6 : 2019-2021 Triad National Security, LLC.,
7 : 2022-2025 J. Bakosi
8 : All rights reserved. See the LICENSE file for details.
9 : \brief Equation of state functions
10 : */
11 : // *****************************************************************************
12 : #pragma once
13 :
14 : #include "InciterConfig.hpp"
15 :
16 : namespace inciter {
17 :
18 : extern ctr::Config g_cfg;
19 :
20 : } // ::inciter
21 :
22 : namespace eos {
23 :
24 : using inciter::g_cfg;
25 :
26 : //! Compute pressure
27 : //! \param[in] re Specific internal energy times density
28 : //! \return Pressure from the ideal gas equation of state
29 : inline double
30 92075258 : pressure( double re ) {
31 92075258 : auto g = g_cfg.get< tag::mat_spec_heat_ratio >();
32 92075258 : return re * (g-1.0);
33 : }
34 :
35 : //! Compute speed of sound from density and pressure
36 : //! \param[in] r Density
37 : //! \param[in] p Pressure
38 : //! \return Speed of sound from the ideal gas equation of state
39 : inline double
40 92947000 : soundspeed( double r, double p ) {
41 92947000 : auto g = g_cfg.get< tag::mat_spec_heat_ratio >();
42 92947000 : return std::sqrt( g * p / r );
43 : }
44 :
45 : //! Compute specific total energy from density, momentum, and pressure
46 : //! \param[in] r Density
47 : //! \param[in] u X-velocity
48 : //! \param[in] v Y-velocity
49 : //! \param[in] w Z-velocity
50 : //! \param[in] p Pressure
51 : //! \return Specific total energy from the ideal gas equation of state
52 : inline double
53 5925972 : totalenergy( double r, double u, double v, double w, double p ) {
54 5925972 : auto g = g_cfg.get< tag::mat_spec_heat_ratio >();
55 5925972 : return p / (g-1.0) + 0.5 * r * (u*u + v*v + w*w);
56 : }
57 :
58 : } // eos::
|