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
14class CpConstant : public Thermo {
15public:
16 static constexpr const char* name = "cpconstant";
17 const char* model_name() const override { return name; }
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 CpConstant(int a_nspecies, IO::ParmParse& pp, std::string name) : CpConstant()
29 {
30 nspecies = a_nspecies;
31 pp.queryclass(name, *this);
32 }
33
34 ~CpConstant() override = default;
35
36 static void Parse(CpConstant & value, IO::ParmParse & pp)
37 {
38 // heat capacity in moles (one per species)
40 // molar enthalpy (one per species)
42 // molar entropy (one per species)
44 // reference temperature (one per species)
45 pp.queryarr_required("Tref",value.Tref, Unit::Temperature());
46
47 Util::Assert(INFO, TEST(value.cp_moles.size() == (size_t)value.nspecies));
48 Util::Assert(INFO, TEST(value.h0.size() == (size_t)value.nspecies));
49 Util::Assert(INFO, TEST(value.s0.size() == (size_t)value.nspecies));
50 Util::Assert(INFO, TEST(value.Tref.size() == (size_t)value.nspecies));
51 }
52
53public:
54 double cp_mol(double /*T*/, Set::Patch<const Set::Scalar>& X, int i, int j, int k) const override {
55 // Specific heat (constant pressure), J/(kmol-K)
56 double cp = 0.0;
57 for (int n=0; n<nspecies; ++n) cp += X(i,j,k,n) * cp_moles[n];
58 return cp;
59 }
60 double enthalpy_mol(double T, Set::Patch<const Set::Scalar>& X, int i, int j, int k) const override {
61 // Specific enthalpy, J/kmol)
62 double h = 0.0;
63 for (int n=0; n<nspecies; ++n) h += X(i,j,k,n) * (cp_moles[n] * (T - Tref[n]) + h0[n]);
64 return h;
65 }
66 double entropy_mol(double T, Set::Patch<const Set::Scalar>& X, int i, int j, int k) const override {
67 // specific entropy, J/(kmol-K)
68 double s = 0.0;
69 for (int n=0; n<nspecies; ++n) s += X(i,j,k,n) * (cp_moles[n] * log(T / Tref[n]) + s0[n]);
70 return s;
71 }
72
73}; // class CpConstant
74
75} // namespace Thermo
76} // namespace Gas
77} // namespace Model
78
79#endif
#define X(name)
#define TEST(x)
Definition Util.H:25
#define INFO
Definition Util.H:24
void queryclass(std::string name, T *value)
Definition ParmParse.H:960
int queryarr_required(std::string name, std::vector< T > &value)
Definition ParmParse.H:643
static void Parse(CpConstant &value, IO::ParmParse &pp)
Definition CpConstant.H:36
std::vector< double > Tref
Definition CpConstant.H:24
std::vector< double > h0
Definition CpConstant.H:22
double cp_mol(double, Set::Patch< const Set::Scalar > &X, int i, int j, int k) const override
Definition CpConstant.H:54
static constexpr const char * name
Definition CpConstant.H:16
const char * model_name() const override
Definition CpConstant.H:17
CpConstant(int a_nspecies, IO::ParmParse &pp, std::string name)
Definition CpConstant.H:28
std::vector< double > s0
Definition CpConstant.H:23
std::vector< double > cp_moles
Definition CpConstant.H:21
~CpConstant() override=default
double entropy_mol(double T, Set::Patch< const Set::Scalar > &X, int i, int j, int k) const override
Definition CpConstant.H:66
double enthalpy_mol(double T, Set::Patch< const Set::Scalar > &X, int i, int j, int k) const override
Definition CpConstant.H:60
Eigen::Matrix< amrex::Real, AMREX_SPACEDIM, 1 > Vector
Definition Base.H:19
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