Nektar++
EquationOfState.cpp
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: EquationOfState.cpp
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: Abstract base class for equations of state.
32//
33///////////////////////////////////////////////////////////////////////////////
34
35#include "EquationOfState.h"
36
37using namespace std;
38
39namespace Nektar
40{
42{
43 static EquationOfStateFactory instance;
44 return instance;
45}
46
49{
50 pSession->LoadParameter("Gamma", m_gamma, 1.4);
51 pSession->LoadParameter("GasConstant", m_gasConstant, 287.058);
52
53 m_gammaMone = m_gamma - 1.0;
55}
56
58 const NekDouble &gasConstant)
59 : m_gamma{gamma}, m_gasConstant{gasConstant}
60{
61}
62
64 const NekDouble &e)
65{
66 return v_GetTemperature(rho, e);
67}
68
70{
71 return v_GetTemperature(rho, e);
72}
73
75{
76 return v_GetPressure(rho, e);
77}
78
80{
81 return v_GetPressure(rho, e);
82}
83
85 const NekDouble &e)
86{
87 return v_GetSoundSpeed(rho, e);
88}
89
91{
92 return v_GetEntropy(rho, e);
93}
94
96{
97 return v_GetDPDrho_e(rho, e);
98}
99
101{
102 return v_GetDPDe_rho(rho, e);
103}
104
106 const NekDouble &p)
107{
108 return v_GetEFromRhoP(rho, p);
109}
110
112{
113 return v_GetRhoFromPT(p, T);
114}
115
116// General implementation for v_GetSoundSpeed: c^2 = xi + kappa * h
117// where xi = dpdrho - e/rho * dp/de and kappa = dp/de / rho
119 const NekDouble &e)
120{
121 NekDouble p = GetPressure(rho, e);
122 NekDouble dpde = GetDPDe_rho(rho, e);
123 NekDouble dpdrho = GetDPDrho_e(rho, e);
124
125 NekDouble enthalpy = e + p / rho;
126
127 NekDouble chi = dpdrho - e / rho * dpde;
128 NekDouble kappa = dpde / rho;
129
130 return sqrt(chi + kappa * enthalpy);
131}
132
133} // namespace Nektar
NekDouble GetEntropy(const NekDouble &rho, const NekDouble &e)
Calculate the entropy.
virtual NekDouble v_GetSoundSpeed(const NekDouble &rho, const NekDouble &e)
NekDouble GetPressure(const NekDouble &rho, const NekDouble &e)
Calculate the pressure.
virtual NekDouble v_GetEFromRhoP(const NekDouble &rho, const NekDouble &p)=0
virtual NekDouble v_GetDPDe_rho(const NekDouble &rho, const NekDouble &e)=0
NekDouble GetRhoFromPT(const NekDouble &p, const NekDouble &T)
Obtain the density from P and T.
EquationOfState(const LibUtilities::SessionReaderSharedPtr &pSession)
Constructor.
virtual NekDouble v_GetDPDrho_e(const NekDouble &rho, const NekDouble &e)=0
NekDouble GetDPDrho_e(const NekDouble &rho, const NekDouble &e)
Calculate the partial derivative of P(rho,e) with respect to rho.
NekDouble GetSoundSpeed(const NekDouble &rho, const NekDouble &e)
Calculate the sound speed.
NekDouble GetTemperature(const NekDouble &rho, const NekDouble &e)
Calculate the temperature.
virtual NekDouble v_GetRhoFromPT(const NekDouble &rho, const NekDouble &p)=0
NekDouble GetDPDe_rho(const NekDouble &rho, const NekDouble &e)
Calculate the partial derivative of P(rho,e) with respect to e.
NekDouble GetEFromRhoP(const NekDouble &rho, const NekDouble &p)
Obtain the internal energy from rho and P.
virtual NekDouble v_GetTemperature(const NekDouble &rho, const NekDouble &e)=0
virtual NekDouble v_GetEntropy(const NekDouble &rho, const NekDouble &e)=0
virtual NekDouble v_GetPressure(const NekDouble &rho, const NekDouble &e)=0
Provides a generic Factory class.
Definition: NekFactory.hpp:104
std::shared_ptr< SessionReader > SessionReaderSharedPtr
EquationOfStateFactory & GetEquationOfStateFactory()
Declaration of the equation of state factory singleton.
tinysimd::simd< NekDouble > vec_t
double NekDouble
scalarT< T > sqrt(scalarT< T > in)
Definition: scalar.hpp:294