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 
37 using namespace std;
38 
39 namespace Nektar
40 {
42 {
43  static EquationOfStateFactory instance;
44  return instance;
45 }
46 
47 EquationOfState::EquationOfState(
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;
54  m_gammaMoneOgasConst = m_gammaMone / m_gasConstant;
55 }
56 
57 EquationOfState::EquationOfState( const NekDouble &gamma,
58  const NekDouble &gasConstant): m_gamma{gamma}, m_gasConstant{gasConstant}{}
59 
61  const NekDouble &e)
62 {
63  return v_GetSoundSpeed(rho, e);
64 }
65 
67 {
68  return v_GetEntropy(rho, e);
69 }
70 
72 {
73  return v_GetDPDrho_e(rho, e);
74 }
75 
77 {
78  return v_GetDPDe_rho(rho, e);
79 }
80 
82  const NekDouble &p)
83 {
84  return v_GetEFromRhoP(rho, p);
85 }
86 
88 {
89  return v_GetRhoFromPT(p, T);
90 }
91 
92 // General implementation for v_GetSoundSpeed: c^2 = xi + kappa * h
93 // where xi = dpdrho - e/rho * dp/de and kappa = dp/de / rho
95  const NekDouble &e)
96 {
97  NekDouble p = GetPressure(rho, e);
98  NekDouble dpde = GetDPDe_rho(rho, e);
99  NekDouble dpdrho = GetDPDrho_e(rho, e);
100 
101  NekDouble enthalpy = e + p / rho;
102 
103  NekDouble chi = dpdrho - e / rho * dpde;
104  NekDouble kappa = dpde / rho;
105 
106  return sqrt(chi + kappa * enthalpy);
107 }
108 
109 }
NekDouble GetEntropy(const NekDouble &rho, const NekDouble &e)
Calculate the entropy.
virtual NekDouble v_GetSoundSpeed(const NekDouble &rho, const NekDouble &e)
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.
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.
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 GetPressure(const NekDouble &rho, const NekDouble &e)=0
Calculate the pressure.
virtual NekDouble v_GetEntropy(const NekDouble &rho, const NekDouble &e)=0
Provides a generic Factory class.
Definition: NekFactory.hpp:105
std::shared_ptr< SessionReader > SessionReaderSharedPtr
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:1
EquationOfStateFactory & GetEquationOfStateFactory()
Declaration of the equation of state factory singleton.
double NekDouble
scalarT< T > sqrt(scalarT< T > in)
Definition: scalar.hpp:267