antioch-0.4.0
cea_curve_fit.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // Antioch - A Gas Dynamics Thermochemistry Library
5 //
6 // Copyright (C) 2014-2016 Paul T. Bauman, Benjamin S. Kirk,
7 // Sylvain Plessis, Roy H. Stonger
8 //
9 // Copyright (C) 2013 The PECOS Development Team
10 //
11 // This library is free software; you can redistribute it and/or
12 // modify it under the terms of the Version 2.1 GNU Lesser General
13 // Public License as published by the Free Software Foundation.
14 //
15 // This library is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc. 51 Franklin Street, Fifth Floor,
23 // Boston, MA 02110-1301 USA
24 //
25 //-----------------------------------------------------------------------el-
26 
27 #ifndef ANTIOCH_CEA_CURVE_FIT_H
28 #define ANTIOCH_CEA_CURVE_FIT_H
29 
31 
32 namespace Antioch
33 {
42  template<typename CoeffType=double>
43  class CEACurveFit: public NASA9CurveFit<CoeffType>
44  {
45  public:
46 
47  CEACurveFit( const std::vector<CoeffType>& coeffs );
48 
49  CEACurveFit( const std::vector<CoeffType>& coeffs, const std::vector<CoeffType> & temps );
50 
52 
53  private:
54 
55  void remap_coeffs( const std::vector<CoeffType>& coeffs );
56 
57  };
58 
59  template<typename CoeffType>
60  inline
61  CEACurveFit<CoeffType>::CEACurveFit( const std::vector<CoeffType>& coeffs )
62  :NASA9CurveFit<CoeffType>()
63  {
64 
65  if( this->_coefficients.size()%10 != 0 )
66  antioch_error_msg("ERROR: Expected CEA style of input for coefficients! Must be a multiple of 10!");
67 
68  this->_n_coeffs = 9;
69 
70  // If no temp is provided, we assume the standard CEA form.
71  this->init_nasa9_temps( coeffs, 10 );
72 
73  this->remap_coeffs(coeffs);
74 
75  this->check_coeff_size();
77  }
78 
79  template<typename CoeffType>
80  inline
81  CEACurveFit<CoeffType>::CEACurveFit( const std::vector<CoeffType>& coeffs,
82  const std::vector<CoeffType> & temp )
83  :NASA9CurveFit<CoeffType>()
84  {
85  if( this->_coefficients.size()%10 != 0 )
86  antioch_error_msg("ERROR: Expected CEA style of input for coefficients! Must be a multiple of 10!");
87 
88  this->_n_coeffs = 9;
89 
90  this->_temp = temp;
91 
92  this->remap_coeffs(coeffs);
93 
94  this->check_coeff_size();
96  }
97 
98  template<typename CoeffType>
99  inline
100  void CEACurveFit<CoeffType>::remap_coeffs( const std::vector<CoeffType>& coeffs )
101  {
102  this->_coefficients.resize(this->_n_coeffs*(this->_temp.size()-1),0.0);
103 
104  for( unsigned int t = 0; t < this->_temp.size()-1; t++ )
105  {
106  for( unsigned int c = 0; c < 7; c++ )
107  {
108  unsigned int i = 10*t + c;
109  unsigned int j = 9*t + c;
110  this->_coefficients[j] = coeffs[i];
111  }
112 
113  for( unsigned int c = 7; c < 9; c++ )
114  {
115  unsigned int i = 10*t + c;
116  unsigned int j = 9*t + c;
117  this->_coefficients[j] = coeffs[i+1];
118  }
119  }
120  }
121 
122 } // end namespace Antioch
123 
124 #endif // ANTIOCH_CEA_CURVE_FIT_H
void remap_coeffs(const std::vector< CoeffType > &coeffs)
void check_temp_coeff_size_consistency() const
void init_nasa9_temps(const std::vector< CoeffType > &coeffs, unsigned n_coeffs)
std::vector< CoeffType > _temp
The temperatures.
This class stores the NASA polynomial fit to the thermodynamics quantities and .
Definition: ascii_parser.h:68
#define antioch_error_msg(errmsg)
CEACurveFit(const std::vector< CoeffType > &coeffs)
Definition: cea_curve_fit.h:61
The parameters are reduced parameters.
unsigned int _n_coeffs
The number of coefficients in each interval.
std::vector< CoeffType > _coefficients
The coefficient data.

Generated on Thu Jul 7 2016 11:09:46 for antioch-0.4.0 by  doxygen 1.8.8