Nektar++
Loading...
Searching...
No Matches
VanDerWaalsEoS.hpp
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: VanDerWaalsEoS.hpp
4//
5// For more information, please see: http://www.nektar.info
6//
7// The MIT License
8//
9// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10// Department of Aeronautics, Imperial College London (UK), and Scientific
11// Computing and Imaging Institute, University of Utah (USA).
12//
13// Permission is hereby granted, free of charge, to any person obtaining a
14// copy of this software and associated documentation files (the "Software"),
15// to deal in the Software without restriction, including without limitation
16// the rights to use, copy, modify, merge, publish, distribute, sublicense,
17// and/or sell copies of the Software, and to permit persons to whom the
18// Software is furnished to do so, subject to the following conditions:
19//
20// The above copyright notice and this permission notice shall be included
21// in all copies or substantial portions of the Software.
22//
23// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29// DEALINGS IN THE SOFTWARE.
30//
31// Description: Ideal gas equation of state
32//
33///////////////////////////////////////////////////////////////////////////////
34
35#pragma once
36
37// definition of standard conversions
39// definition of parameters held in structure
41
42namespace Nektar::detail
43{
44
45/**
46 * @brief Ideal gas equation of state Helper function
47 * p = rho * R * T
48 */
49template <typename TData, typename TScalar>
51 const TData &rho, const TData &e)
52{
53 return (e + TData(EoS.a()) * rho) * (TData(EoS.gamma()) - TData(1.0)) /
54 (TData(1.0) / rho - TData(EoS.b())) -
55 TData(EoS.a()) * rho * rho;
56}
57
58template <typename TData, typename TScalar>
60 const TData &rho, const TData &e)
61{
62 TData result;
63
64 result = (TData(EoS.gamma()) - TData(1.0)) *
65 (e + TData(2.0) * TData(EoS.a()) * rho -
66 TData(EoS.a() * EoS.b()) * rho * rho);
67 result = result / ((TData(1.0) - TData(EoS.b()) * rho) *
68 (TData(1.0) - TData(EoS.b()) * rho));
69 result = result - TData(2.0) * TData(EoS.a()) * rho;
70
71 return result;
72}
73
74template <typename TData, typename TScalar>
76 const TData &rho,
77 [[maybe_unused]] const TData &e)
78{
79 return (TData(EoS.gamma()) - TData(1.0)) /
80 (TData(1.0) / rho - TData(EoS.b()));
81}
82
83template <typename TData, typename TScalar>
85 const TData &rho, const TData &e)
86{
87 using std::sqrt;
88
89 TData p = GetPressure(EoS, rho, e);
90 TData dpde = GetDPDe_rho(EoS, rho, e);
91 TData dpdrho = GetDPDrho_e(EoS, rho, e);
92
93 TData enthalpy = e + p / rho;
94
95 TData chi = dpdrho - e / rho * dpde;
96 TData kappa = dpde / rho;
97
98 return sqrt(chi + kappa * enthalpy);
99}
100
101template <typename TData, typename TScalar>
103 const VanDerWaalsEoS<TScalar> &EoS, [[maybe_unused]] const TData &rhoL,
104 [[maybe_unused]] const TData &pL, [[maybe_unused]] const TData &eL,
105 [[maybe_unused]] const TData &HL, [[maybe_unused]] const TData &srL,
106 [[maybe_unused]] const TData &rhoR, [[maybe_unused]] const TData &pR,
107 [[maybe_unused]] const TData &eR, [[maybe_unused]] const TData &HR,
108 [[maybe_unused]] const TData &srR, const TData &HRoe, const TData &URoe2,
109 [[maybe_unused]] const TData &srLR)
110{
111 using std::sqrt;
112 // Calculate sound speed using ideal gas relation
113 return sqrt((TData(EoS.gamma()) - TData(1.0)) *
114 (HRoe - TData(0.5) * URoe2));
115}
116
117template <typename TData, typename TScalar>
119 const TData &rho, const TData &e)
120{
121 return (e + TData(EoS.a()) * rho) * TData(EoS.gammaMoneOgasConst());
122}
123
124/**
125 * @brief Specific internal energy at a prescribed pressure; the inverse of
126 * GetPressure() in its second argument.
127 *
128 * Needed by a pressure outflow, which prescribes p and extrapolates rho, and
129 * must recover the energy state that goes with the pair. Inverting
130 *
131 * p = (e + a rho)(gamma - 1)/(1/rho - b) - a rho^2
132 *
133 * for e gives the expression below.
134 */
135template <typename TData, typename TScalar>
137 const VanDerWaalsEoS<TScalar> &EoS, const TData &rho, const TData &p)
138{
139 return (p + TData(EoS.a()) * rho * rho) *
140 (TData(1.0) / rho - TData(EoS.b())) /
141 (TData(EoS.gamma()) - TData(1.0)) -
142 TData(EoS.a()) * rho;
143}
144
145/**
146 * @brief Specific internal energy at a prescribed temperature; the inverse of
147 * GetTemperature().
148 *
149 * Needed by an isothermal wall, which prescribes T and must recover the energy
150 * state that goes with it. Unlike the ideal gas the result depends on density
151 * through the cohesion term.
152 */
153template <typename TData, typename TScalar>
155 const VanDerWaalsEoS<TScalar> &EoS, const TData &rho, const TData &T)
156{
157 return T / TData(EoS.gammaMoneOgasConst()) - TData(EoS.a()) * rho;
158}
159
160} // namespace Nektar::detail
#define NEK_HOSTDEVICE_INLINE
Definition Backends.hpp:268
NEK_HOSTDEVICE_INLINE TData GetSoundSpeed(const IdealGasEoS< TScalar > &EoS, const TData &rho, const TData &e)
NEK_HOSTDEVICE_INLINE TData GetTemperature(const IdealGasEoS< TScalar > &EoS, const TData &rho, const TData &e)
NEK_HOSTDEVICE_INLINE TData GetRoeSoundSpeed(const IdealGasEoS< TScalar > &EoS, const TData &rhoL, const TData &pL, const TData &eL, const TData &HL, const TData &srL, const TData &rhoR, const TData &pR, const TData &eR, const TData &HR, const TData &srR, const TData &HRoe, const TData &URoe2, const TData &srLR)
NEK_HOSTDEVICE_INLINE TData GetIntEnergyFromPressure(const IdealGasEoS< TScalar > &EoS, const TData &rho, const TData &p)
Specific internal energy at a prescribed pressure; the inverse of GetPressure() in its second argumen...
NEK_HOSTDEVICE_INLINE TData GetIntEnergyFromTemperature(const IdealGasEoS< TScalar > &EoS, const TData &rho, const TData &T)
Specific internal energy at a prescribed temperature; the inverse of GetTemperature().
NEK_HOSTDEVICE_INLINE TData GetDPDrho_e(const VanDerWaalsEoS< TScalar > &EoS, const TData &rho, const TData &e)
NEK_HOSTDEVICE_INLINE TData GetDPDe_rho(const VanDerWaalsEoS< TScalar > &EoS, const TData &rho, const TData &e)
NEK_HOSTDEVICE_INLINE TData GetPressure(const IdealGasEoS< TScalar > &EoS, const TData &rho, const TData &e)
Ideal gas equation of state Helper function p = rho * R * T.
scalarT< T > sqrt(scalarT< T > in)
Definition scalar.hpp:289
Ideal gas equation of state: p = rho * R * T.