Alamo
CpConstant.H
Go to the documentation of this file.
1#ifndef MODEL_GAS_THERMO_CPCONSTANT_H_
2#define MODEL_GAS_THERMO_CPCONSTANT_H_
3
4#include <vector>
5#include <memory>
6#include <cmath>
7#include "IO/ParmParse.H"
9
10namespace Model {
11namespace Gas {
12namespace Thermo {
13
15{
16public:
17 static constexpr const char* name = "cpconstant";
18
19private:
20 int nspecies = 1;
21 std::vector<double> cp_moles;
22 std::vector<double> h0;
23 std::vector<double> s0;
24 std::vector<double> Tref;
25
26public:
28
29
30 static void Parse(CpConstant & value, IO::ParmParse & pp, int a_nspecies)
31 {
32 value.nspecies = a_nspecies;
33
34 // heat capacity in moles (one per species)
36 // molar enthalpy (one per species)
38 // molar entropy (one per species)
40 // reference temperature (one per species)
41 pp.queryarr_required("Tref",value.Tref, Unit::Temperature());
42
43 Util::Assert(INFO, TEST(value.cp_moles.size() == (size_t)value.nspecies));
44 Util::Assert(INFO, TEST(value.h0.size() == (size_t)value.nspecies));
45 Util::Assert(INFO, TEST(value.s0.size() == (size_t)value.nspecies));
46 Util::Assert(INFO, TEST(value.Tref.size() == (size_t)value.nspecies));
47 }
48
49public:
50 double cp_mol(double /*T*/, Set::Patch<const Set::Scalar>& X, int i, int j, int k) const
51 {
52 // Specific heat (constant pressure), J/(kmol-K)
53 double cp = 0.0;
54 for (int n=0; n<nspecies; ++n) cp += X(i,j,k,n) * cp_moles[n];
55 return cp;
56 }
57 double enthalpy_mol(double T, Set::Patch<const Set::Scalar>& X, int i, int j, int k) const
58 {
59 // Specific enthalpy, J/kmol)
60 double h = 0.0;
61 for (int n=0; n<nspecies; ++n) h += X(i,j,k,n) * (cp_moles[n] * (T - Tref[n]) + h0[n]);
62 return h;
63 }
64 double entropy_mol(double T, Set::Patch<const Set::Scalar>& X, int i, int j, int k) const
65 {
66 // specific entropy, J/(kmol-K)
67 double s = 0.0;
68 for (int n=0; n<nspecies; ++n) s += X(i,j,k,n) * (cp_moles[n] * log(T / Tref[n]) + s0[n]);
69 return s;
70 }
71
72}; // class CpConstant
73
74} // namespace Thermo
75} // namespace Gas
76} // namespace Model
77
78#endif
#define X(name)
#define TEST(x)
Definition Util.H:25
#define INFO
Definition Util.H:24
int queryarr_required(std::string name, std::vector< T > &value)
Definition ParmParse.H:643
std::vector< double > Tref
Definition CpConstant.H:24
double enthalpy_mol(double T, Set::Patch< const Set::Scalar > &X, int i, int j, int k) const
Definition CpConstant.H:57
std::vector< double > h0
Definition CpConstant.H:22
static constexpr const char * name
Definition CpConstant.H:17
std::vector< double > s0
Definition CpConstant.H:23
double entropy_mol(double T, Set::Patch< const Set::Scalar > &X, int i, int j, int k) const
Definition CpConstant.H:64
std::vector< double > cp_moles
Definition CpConstant.H:21
static void Parse(CpConstant &value, IO::ParmParse &pp, int a_nspecies)
Definition CpConstant.H:30
double cp_mol(double, Set::Patch< const Set::Scalar > &X, int i, int j, int k) const
Definition CpConstant.H:50
Eigen::Matrix< amrex::Real, AMREX_SPACEDIM, 1 > Vector
Definition Base.H:21
AMREX_FORCE_INLINE void Assert(std::string file, std::string func, int line, std::string smt, bool pass, Args const &... args)
Definition Util.H:58
static Unit Energy()
Definition Unit.H:218
static Unit Amount()
Definition Unit.H:203
static Unit Temperature()
Definition Unit.H:201