Cantera 2.6.0

NasaPoly2.cpp
1// This file is part of Cantera. See License.txt in the top-level directory or
2// at https://cantera.org/license.txt for license and copyright information.
3
4#include "cantera/thermo/NasaPoly2.h"
5#include "cantera/base/global.h"
6#include "cantera/base/stringUtils.h"
7#include "cantera/base/AnyMap.h"
8
9 namespace Cantera {
10
11NasaPoly2::NasaPoly2()
12 : m_midT(0)
13{
14}
15
16 void NasaPoly2::setParameters(double Tmid, const vector_fp& low,
17 const vector_fp& high) {
18 m_midT = Tmid;
19 mnp_low.setMaxTemp(Tmid);
20 mnp_high.setMinTemp(Tmid);
21 mnp_low.setParameters(low);
22 mnp_high.setParameters(high);
23}
24
25 void NasaPoly2::getParameters(AnyMap& thermo) const
26{
27 thermo["model"] = "NASA7";
28 SpeciesThermoInterpType::getParameters(thermo);
29 vector_fp Tranges {m_lowT, m_midT, m_highT};
30 thermo["temperature-ranges"].setQuantity(Tranges, "K");
31 thermo["data"] = std::vector<vector_fp>();
32 mnp_low.getParameters(thermo);
33 mnp_high.getParameters(thermo);
34}
35
36 void NasaPoly2::validate(const std::string& name)
37{
38 if (thermo_warnings_suppressed()) {
39 return;
40 }
41
42 double cp_low, h_low, s_low;
43 double cp_high, h_high, s_high;
44 mnp_low.updatePropertiesTemp(m_midT, &cp_low, &h_low, &s_low);
45 mnp_high.updatePropertiesTemp(m_midT, &cp_high, &h_high, &s_high);
46
47 double delta = cp_low - cp_high;
48 if (fabs(delta/(fabs(cp_low)+1.0E-4)) > 0.01) {
49 warn_user("NasaPoly2::validate",
50 "\nFor species {}, discontinuity in cp/R detected at Tmid = {}\n"
51 "\tValue computed using low-temperature polynomial: {}\n"
52 "\tValue computed using high-temperature polynomial: {}\n",
53 name, m_midT, cp_low, cp_high);
54 }
55
56 // enthalpy
57 delta = h_low - h_high;
58 if (fabs(delta/cp_low) > 0.001) {
59 warn_user("NasaPoly2::validate",
60 "\nFor species {}, discontinuity in h/RT detected at Tmid = {}\n"
61 "\tValue computed using low-temperature polynomial: {}\n"
62 "\tValue computed using high-temperature polynomial: {}\n",
63 name, m_midT, h_low, h_high);
64 }
65
66 // entropy
67 delta = s_low - s_high;
68 if (fabs(delta/(fabs(s_low)+cp_low)) > 0.001) {
69 warn_user("NasaPoly2::validate",
70 "\nFor species {}, discontinuity in s/R detected at Tmid = {}\n"
71 "\tValue computed using low-temperature polynomial: {}\n"
72 "\tValue computed using high-temperature polynomial: {}\n",
73 name, m_midT, s_low, s_high);
74 }
75}
76
77}
AnyMap.h
NasaPoly2.h
Header for a single-species standard state object derived from SpeciesThermoInterpType based on the N...
Cantera::AnyMap
A map of string keys to values whose type can vary at runtime.
Definition: AnyMap.h:399
global.h
This file contains definitions for utility functions and text for modules, inputfiles,...
Cantera
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:557
Cantera::thermo_warnings_suppressed
bool thermo_warnings_suppressed()
Returns true if thermo warnings should be suppressed.
Definition: global.cpp:99
Cantera::vector_fp
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
Definition: ct_defs.h:184
Cantera::warn_user
void warn_user(const std::string &method, const std::string &msg, const Args &... args)
Print a user warning raised from method as CanteraWarning.
Definition: global.h:245
stringUtils.h
Contains declarations for string manipulation functions within Cantera.