| Cantera 3.0.0

Loading...
Searching...
No Matches
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
11 void NasaPoly2::setParameters(double Tmid, const vector<double>& low,
12 const vector<double>& high) {
13 m_midT = Tmid;
14 mnp_low.setMaxTemp(Tmid);
15 mnp_high.setMinTemp(Tmid);
16 mnp_low.setParameters(low);
17 mnp_high.setParameters(high);
18}
19
20 void NasaPoly2::getParameters(AnyMap& thermo) const
21{
22 thermo["model"] = "NASA7";
23 SpeciesThermoInterpType::getParameters(thermo);
24 vector<double> Tranges {m_lowT, m_midT, m_highT};
25 thermo["temperature-ranges"].setQuantity(Tranges, "K");
26 thermo["data"] = vector<vector<double>>();
27 mnp_low.getParameters(thermo);
28 mnp_high.getParameters(thermo);
29}
30
31 void NasaPoly2::validate(const string& name)
32{
33 if (thermo_warnings_suppressed()) {
34 return;
35 }
36
37 double cp_low, h_low, s_low;
38 double cp_high, h_high, s_high;
39 mnp_low.updatePropertiesTemp(m_midT, &cp_low, &h_low, &s_low);
40 mnp_high.updatePropertiesTemp(m_midT, &cp_high, &h_high, &s_high);
41
42 double delta = cp_low - cp_high;
43 if (fabs(delta/(fabs(cp_low)+1.0E-4)) > 0.01) {
44 warn_user("NasaPoly2::validate",
45 "\nFor species {}, discontinuity in cp/R detected at Tmid = {}\n"
46 "\tValue computed using low-temperature polynomial: {}\n"
47 "\tValue computed using high-temperature polynomial: {}\n",
48 name, m_midT, cp_low, cp_high);
49 }
50
51 // enthalpy
52 delta = h_low - h_high;
53 if (fabs(delta/cp_low) > 0.001) {
54 warn_user("NasaPoly2::validate",
55 "\nFor species {}, discontinuity in h/RT detected at Tmid = {}\n"
56 "\tValue computed using low-temperature polynomial: {}\n"
57 "\tValue computed using high-temperature polynomial: {}\n",
58 name, m_midT, h_low, h_high);
59 }
60
61 // entropy
62 delta = s_low - s_high;
63 if (fabs(delta/(fabs(s_low)+cp_low)) > 0.001) {
64 warn_user("NasaPoly2::validate",
65 "\nFor species {}, discontinuity in s/R detected at Tmid = {}\n"
66 "\tValue computed using low-temperature polynomial: {}\n"
67 "\tValue computed using high-temperature polynomial: {}\n",
68 name, m_midT, s_low, s_high);
69 }
70}
71
72}
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:427
Cantera::NasaPoly1::setParameters
void setParameters(const vector< double > &coeffs)
Set array of 7 polynomial coefficients.
Definition NasaPoly1.h:68
Cantera::NasaPoly1::getParameters
void getParameters(AnyMap &thermo) const override
Store the parameters of the species thermo object such that an identical species thermo object could ...
Definition NasaPoly1.h:141
Cantera::NasaPoly1::updatePropertiesTemp
void updatePropertiesTemp(const double temp, double *cp_R, double *h_RT, double *s_R) const override
Compute the reference-state property of one species.
Definition NasaPoly1.h:124
Cantera::NasaPoly2::getParameters
void getParameters(AnyMap &thermo) const override
Store the parameters of the species thermo object such that an identical species thermo object could ...
Definition NasaPoly2.cpp:20
Cantera::NasaPoly2::validate
void validate(const string &name) override
Check for problems with the parameterization, and generate warnings or throw and exception if any are...
Definition NasaPoly2.cpp:31
Cantera::NasaPoly2::setParameters
void setParameters(double Tmid, const vector< double > &low, const vector< double > &high)
Definition NasaPoly2.cpp:11
Cantera::NasaPoly2::m_midT
double m_midT
Midrange temperature.
Definition NasaPoly2.h:167
Cantera::NasaPoly2::mnp_low
NasaPoly1 mnp_low
NasaPoly1 object for the low temperature region.
Definition NasaPoly2.h:169
Cantera::NasaPoly2::mnp_high
NasaPoly1 mnp_high
NasaPoly1 object for the high temperature region.
Definition NasaPoly2.h:171
Cantera::SpeciesThermoInterpType::getParameters
virtual void getParameters(AnyMap &thermo) const
Store the parameters of the species thermo object such that an identical species thermo object could ...
Definition SpeciesThermoInterpType.cpp:58
Cantera::SpeciesThermoInterpType::m_lowT
double m_lowT
lowest valid temperature
Definition SpeciesThermoInterpType.h:284
Cantera::SpeciesThermoInterpType::setMinTemp
virtual void setMinTemp(double Tmin)
Set the minimum temperature at which the thermo parameterization is valid.
Definition SpeciesThermoInterpType.h:132
Cantera::SpeciesThermoInterpType::m_highT
double m_highT
Highest valid temperature.
Definition SpeciesThermoInterpType.h:286
Cantera::SpeciesThermoInterpType::setMaxTemp
virtual void setMaxTemp(double Tmax)
Set the maximum temperature at which the thermo parameterization is valid.
Definition SpeciesThermoInterpType.h:143
global.h
This file contains definitions for utility functions and text for modules, inputfiles and logging,...
Cantera::thermo_warnings_suppressed
bool thermo_warnings_suppressed()
Returns true if thermo warnings should be suppressed.
Definition global.cpp:97
Cantera::warn_user
void warn_user(const string &method, const string &msg, const Args &... args)
Print a user warning raised from method as CanteraWarning.
Definition global.h:267
Cantera
Namespace for the Cantera kernel.
Definition AnyMap.cpp:564
stringUtils.h
Contains declarations for string manipulation functions within Cantera.