Line data Source code
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"
8 : #include "Model/Gas/Thermo/Thermo.H"
9 :
10 : namespace Model {
11 : namespace Gas {
12 : namespace Thermo {
13 :
14 : class CpConstant
15 : {
16 : public:
17 : static constexpr const char* name = "cpconstant";
18 :
19 : private:
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 :
26 : public:
27 16 : CpConstant() {} ;
28 :
29 :
30 8 : static void Parse(CpConstant & value, IO::ParmParse & pp, int a_nspecies)
31 : {
32 8 : value.nspecies = a_nspecies;
33 :
34 : // heat capacity in moles (one per species)
35 16 : pp.queryarr_required("cp_moles",value.cp_moles,Unit::Energy()/Unit::Amount()/Unit::Temperature());
36 : // molar enthalpy (one per species)
37 16 : pp.queryarr_required("h0",value.h0,Unit::Energy()/Unit::Amount());
38 : // molar entropy (one per species)
39 16 : pp.queryarr_required("s0",value.s0, Unit::Energy()/Unit::Amount()/Unit::Temperature());
40 : // reference temperature (one per species)
41 16 : pp.queryarr_required("Tref",value.Tref, Unit::Temperature());
42 :
43 56 : Util::Assert(INFO, TEST(value.cp_moles.size() == (size_t)value.nspecies));
44 56 : Util::Assert(INFO, TEST(value.h0.size() == (size_t)value.nspecies));
45 56 : Util::Assert(INFO, TEST(value.s0.size() == (size_t)value.nspecies));
46 56 : Util::Assert(INFO, TEST(value.Tref.size() == (size_t)value.nspecies));
47 8 : }
48 :
49 : public:
50 463376096 : 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 463376096 : double cp = 0.0;
54 926752192 : for (int n=0; n<nspecies; ++n) cp += X(i,j,k,n) * cp_moles[n];
55 463376096 : return cp;
56 : }
57 0 : 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 0 : double h = 0.0;
61 0 : for (int n=0; n<nspecies; ++n) h += X(i,j,k,n) * (cp_moles[n] * (T - Tref[n]) + h0[n]);
62 0 : return h;
63 : }
64 0 : 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 0 : double s = 0.0;
68 0 : for (int n=0; n<nspecies; ++n) s += X(i,j,k,n) * (cp_moles[n] * log(T / Tref[n]) + s0[n]);
69 0 : return s;
70 : }
71 :
72 : }; // class CpConstant
73 :
74 : } // namespace Thermo
75 : } // namespace Gas
76 : } // namespace Model
77 :
78 : #endif
|