MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
FvSysEqnDetChem< nDim >::NASACoefficients Struct Reference

Stores all NASA coefficients. NASA coefficients are used to compute the cp and cv values. Additional, modified NASA coefficients are stored, which are used to compute the sensible energy. For now only valid for NASA-7 coefficients, which have low temperature and high temperature regions, each one described by a different polynomial. More...

#include <fvcartesiansyseqndetchem.h>

Public Member Functions

 NASACoefficients (const MInt noSpecies, const FvSysEqnDetChem< nDim > &sysEqn)
 Construct a new FvSysEqnDetChem<nDim>::NASACoefficients::NASACoefficients object. This object stores all the information about the NASA coefficients. More...
 
 ~NASACoefficients ()
 Destroy the FvSysEqnDetChem<nDim>::NASACoefficients::NASACoefficients object. More...
 

Public Attributes

MFloatlowTemp = nullptr
 
MFloathighTemp = nullptr
 
MFloatintegralLowTemp = nullptr
 
MFloatintegralHighTemp = nullptr
 
MFloatlowTempIntegrationConstantsEnergy = nullptr
 
MFloathighTempIntegrationConstantsEnergy = nullptr
 
MFloatlowTempIntegrationConstantsEnthalpy = nullptr
 
MFloathighTempIntegrationConstantsEnthalpy = nullptr
 

Static Public Attributes

static constexpr MFloat referenceTemp = 298.0
 
static constexpr MFloat transitionTemp = 1000.0
 
static constexpr MInt totalNumberCoefficientsPerSpecies = 15
 
static constexpr MInt noNASACoefficients = 7
 
static constexpr MInt noNASACoefficientsCpPolynomial = 5
 

Private Member Functions

void getNASACoefficients (const MInt noSpecies, const FvSysEqnDetChem< nDim > &sysEqn)
 Gets the species 7-NASA Coefficients from the given mechanism file. The NASA Coefficients are then used to compute the temperature-dependant specific heat capacity The integral coefficients are the NASA COEFFICIENTS multiplied by 1/(n + 1) and are used for the integration of the heat capacities to compute the sensible energy. More...
 
void computeSensibleEnergyIntegrationConstants (const FvSysEqnDetChem< nDim > &sysEqn)
 Computes the sensible energy and enthalpy integration constants to reuse later (for low and high temp regions). The constants are a result from definite integration. The low temp constant is computed with the low temp NASA polynomial and reference temperature. The high temperature constant is composed of two different terms: one arises from the integration with the low temperature NASA polynomial from reference temperature to the transition temperature. The other term is the lower bound of the definite integral at the high temeprature region. These constants appear in the computation of the sensible energy and are stored and reused to save computational time. More...
 

Friends

class FvSysEqnDetChem< nDim >
 

Detailed Description

template<MInt nDim>
struct FvSysEqnDetChem< nDim >::NASACoefficients
Template Parameters
nDimNumber of dimensions

Definition at line 304 of file fvcartesiansyseqndetchem.h.

Constructor & Destructor Documentation

◆ NASACoefficients()

template<MInt nDim>
FvSysEqnDetChem< nDim >::NASACoefficients::NASACoefficients ( const MInt  noSpecies,
const FvSysEqnDetChem< nDim > &  sysEqn 
)
Template Parameters
nDimNumber of dimensions
Parameters
noSpeciesNumber of species
sysEqnEquation system

Definition at line 232 of file fvcartesiansyseqndetchem.cpp.

232 {
233 mAlloc(lowTemp, noNASACoefficients * noSpecies, "FvSysEqnDetChem::NASACoefficients::lowTemp", AT_);
234 mAlloc(highTemp, noNASACoefficients * noSpecies, "FvSysEqnDetChem::NASACoefficients::highTemp", AT_);
235
237 "FvSysEqnDetChem::NASACoefficients::integralLowTemp", AT_);
239 "FvSysEqnDetChem::NASACoefficients::integralHighTemp", AT_);
240
242 "FvSysEqnDetChem::NASACoefficients::lowTempIntegrationConstantsEnergy", AT_);
244 "FvSysEqnDetChem::NASACoefficients::highTempIntegrationConstantsEnergy", AT_);
245
247 "FvSysEqnDetChem::NASACoefficients::lowTempIntegrationConstantsEnthalpy", AT_);
249 "FvSysEqnDetChem::NASACoefficients::highTempIntegrationConstantsEnthalpy", AT_);
250
251 this->getNASACoefficients(noSpecies, sysEqn);
253}
void mAlloc(T *&a, const MLong N, const MString &objectName, MString function)
allocates memory for one-dimensional array 'a' of size N
Definition: alloc.h:173
void getNASACoefficients(const MInt noSpecies, const FvSysEqnDetChem< nDim > &sysEqn)
Gets the species 7-NASA Coefficients from the given mechanism file. The NASA Coefficients are then us...
static constexpr MInt noNASACoefficientsCpPolynomial
void computeSensibleEnergyIntegrationConstants(const FvSysEqnDetChem< nDim > &sysEqn)
Computes the sensible energy and enthalpy integration constants to reuse later (for low and high temp...

◆ ~NASACoefficients()

template<MInt nDim>
FvSysEqnDetChem< nDim >::NASACoefficients::~NASACoefficients
Template Parameters
nDimNumber of dimensions

Definition at line 261 of file fvcartesiansyseqndetchem.cpp.

Member Function Documentation

◆ computeSensibleEnergyIntegrationConstants()

template<MInt nDim>
void FvSysEqnDetChem< nDim >::NASACoefficients::computeSensibleEnergyIntegrationConstants ( const FvSysEqnDetChem< nDim > &  sysEqn)
private
Template Parameters
nDimNumber of dimensions
Parameters
sysEqnEquation system

Definition at line 385 of file fvcartesiansyseqndetchem.cpp.

386 {
387 for(MUint s = 0; s < sysEqn.PV->m_noSpecies; s++) {
388 MFloat limitTRefEnergy = F0, limitLowTempRegionEnergy = F0, limitHighTempRegionEnergy = F0;
389 MFloat limitTRefEnthalpy = F0, limitLowTempRegionEnthalpy = F0, limitHighTempRegionEnthalpy = F0;
390
391 MFloat speciesSpecificGasConstant = sysEqn.m_species->specificGasConstant[s];
392 MInt offsetIntegralCoeffs = noNASACoefficientsCpPolynomial * s;
393
394 // Horner's rule for polynomials
395 for(MInt i = 4; (i < 5) && (i >= 0); i--) {
396 limitTRefEnergy = limitTRefEnergy * referenceTemp + integralLowTemp[offsetIntegralCoeffs + i];
397 limitLowTempRegionEnergy = limitLowTempRegionEnergy * transitionTemp + integralLowTemp[offsetIntegralCoeffs + i];
398 limitHighTempRegionEnergy =
399 limitHighTempRegionEnergy * transitionTemp + integralHighTemp[offsetIntegralCoeffs + i];
400
401 limitTRefEnthalpy = limitTRefEnthalpy * referenceTemp + integralLowTemp[offsetIntegralCoeffs + i];
402 limitLowTempRegionEnthalpy =
403 limitLowTempRegionEnthalpy * transitionTemp + integralLowTemp[offsetIntegralCoeffs + i];
404 limitHighTempRegionEnthalpy =
405 limitHighTempRegionEnthalpy * transitionTemp + integralHighTemp[offsetIntegralCoeffs + i];
406 }
407
408 limitTRefEnergy *= speciesSpecificGasConstant;
409 limitLowTempRegionEnergy *= speciesSpecificGasConstant;
410 limitHighTempRegionEnergy *= speciesSpecificGasConstant;
411
412 limitTRefEnthalpy *= speciesSpecificGasConstant * referenceTemp;
413 limitLowTempRegionEnthalpy *= speciesSpecificGasConstant * transitionTemp;
414 limitHighTempRegionEnthalpy *= speciesSpecificGasConstant * transitionTemp;
415
416 limitTRefEnergy = (limitTRefEnergy - speciesSpecificGasConstant) * referenceTemp;
417 limitLowTempRegionEnergy = (limitLowTempRegionEnergy - speciesSpecificGasConstant) * transitionTemp;
418 limitHighTempRegionEnergy = (limitHighTempRegionEnergy - speciesSpecificGasConstant) * transitionTemp;
419
420 // Integration constants as defined are SUBSTRACTED in the corresponding equations
421 lowTempIntegrationConstantsEnergy[s] = limitTRefEnergy;
422 highTempIntegrationConstantsEnergy[s] = limitTRefEnergy - limitLowTempRegionEnergy + limitHighTempRegionEnergy;
423
424 lowTempIntegrationConstantsEnthalpy[s] = limitTRefEnthalpy;
426 limitTRefEnthalpy - limitLowTempRegionEnthalpy + limitHighTempRegionEnthalpy;
427 }
428}
PrimitiveVariables * PV
SpeciesProperties * m_species
int32_t MInt
Definition: maiatypes.h:62
uint32_t MUint
Definition: maiatypes.h:63
double MFloat
Definition: maiatypes.h:52

◆ getNASACoefficients()

template<MInt nDim>
void FvSysEqnDetChem< nDim >::NASACoefficients::getNASACoefficients ( const MInt  noSpecies,
const FvSysEqnDetChem< nDim > &  sysEqn 
)
private
Template Parameters
nDimNumber of dimensions
Parameters
noSpeciesNumber of species
sysEqnEquation system

Definition at line 286 of file fvcartesiansyseqndetchem.cpp.

287 {
288 std::shared_ptr<Cantera::Solution> sol(
289 Cantera::newSolution(sysEqn.m_reactionMechanism, sysEqn.m_phaseName, sysEqn.m_transportModel));
290 std::shared_ptr<Cantera::ThermoPhase> gas(sol->thermo());
291
292 MFloat* totalNASACoefficients = nullptr;
293 mAlloc(totalNASACoefficients, totalNumberCoefficientsPerSpecies * noSpecies,
294 "FvSysEqnDetChem::NASACoefficients::getNASACoefficients::totalNASACoefficients", AT_);
295
296 MFloat* const NASACoeffs = ALIGNED_F(totalNASACoefficients);
297
298 for(MUint s = 0; s < sysEqn.PV->m_noSpecies; s++) {
300 MFloat* const speciesNASACoeffs = ALIGNED_F(NASACoeffs + offset);
301
302 shared_ptr<Cantera::Species> species = gas->species(s);
303 shared_ptr<Cantera::SpeciesThermoInterpType> thermoPhaseInf = species->thermo;
304
305 // Dummy variables for Cantera function
306 size_t n;
307 doublereal tlow, thigh, pref;
308 int type;
309
310 thermoPhaseInf->reportParameters(n, type, tlow, thigh, pref, speciesNASACoeffs);
311 }
312 // Store the NASA coefficients for the low and high temperature regions
313 for(MUint s = 0; s < sysEqn.PV->m_noSpecies; s++) {
314 const MInt offset = totalNumberCoefficientsPerSpecies * s;
315 const MInt offsetRegion = noNASACoefficients * s;
316 for(MInt i = 0; i < totalNumberCoefficientsPerSpecies; i++) {
317 if(i == 0) {
318 continue;
319 } else if((i > 0) && (i < (noNASACoefficients + 1))) {
320 const MInt index = i - 1;
321 highTemp[offsetRegion + index] = totalNASACoefficients[offset + i]; // seems OK
322 } else {
323 const MInt index = i - 1 - noNASACoefficients;
324 lowTemp[offsetRegion + index] = totalNASACoefficients[offset + i]; // seems OK
325 }
326 }
327 }
328 // Compute and store integral coefficients
329 for(MUint s = 0; s < sysEqn.PV->m_noSpecies; s++) {
330 const MInt offsetRegion = noNASACoefficients * s;
331 const MInt offsetIntegral = noNASACoefficientsCpPolynomial * s;
332 for(MInt i = 0; i < 5; i++) {
333 integralLowTemp[offsetIntegral + i] = lowTemp[offsetRegion + i] / (i + 1);
334 integralHighTemp[offsetIntegral + i] = highTemp[offsetRegion + i] / (i + 1);
335 }
336 }
337
338#ifndef NDEBUG
339 for(MUint s = 0; s < sysEqn.PV->m_noSpecies; s++) {
340 std::cout << sysEqn.m_species->speciesName[s] << std::endl;
341
343 MInt offset2 = s * noNASACoefficients;
345
346 for(MInt i = 0; i < totalNumberCoefficientsPerSpecies; i++) {
347 std::cout << totalNASACoefficients[offset + i] << " ";
348 }
349 std::cout << std::endl;
350
351 for(MInt i = 0; i < noNASACoefficients; i++) {
352 std::cout << highTemp[offset2 + i] << " ";
353 }
354 std::cout << std::endl;
355 for(MInt i = 0; i < noNASACoefficientsCpPolynomial; i++) {
356 std::cout << integralHighTemp[offset3 + i] << " ";
357 }
358 std::cout << std::endl;
359 for(MInt i = 0; i < noNASACoefficients; i++) {
360 std::cout << lowTemp[offset2 + i] << " ";
361 }
362 std::cout << std::endl;
363 for(MInt i = 0; i < noNASACoefficientsCpPolynomial; i++) {
364 std::cout << integralLowTemp[offset3 + i] << " ";
365 }
366 std::cout << std::endl;
367 }
368#endif
369
370 mDeallocate(totalNASACoefficients);
371}
IdType index(const FloatType *const x, const IdType level)
Return Hilbert index for given location and level in 2D or 3D.
Definition: hilbert.h:165
static constexpr MInt totalNumberCoefficientsPerSpecies

Friends And Related Function Documentation

◆ FvSysEqnDetChem< nDim >

template<MInt nDim>
friend class FvSysEqnDetChem< nDim >
friend

Definition at line 293 of file fvcartesiansyseqndetchem.h.

Member Data Documentation

◆ highTemp

template<MInt nDim>
MFloat* FvSysEqnDetChem< nDim >::NASACoefficients::highTemp = nullptr

Definition at line 314 of file fvcartesiansyseqndetchem.h.

◆ highTempIntegrationConstantsEnergy

template<MInt nDim>
MFloat* FvSysEqnDetChem< nDim >::NASACoefficients::highTempIntegrationConstantsEnergy = nullptr

Definition at line 320 of file fvcartesiansyseqndetchem.h.

◆ highTempIntegrationConstantsEnthalpy

template<MInt nDim>
MFloat* FvSysEqnDetChem< nDim >::NASACoefficients::highTempIntegrationConstantsEnthalpy = nullptr

Definition at line 323 of file fvcartesiansyseqndetchem.h.

◆ integralHighTemp

template<MInt nDim>
MFloat* FvSysEqnDetChem< nDim >::NASACoefficients::integralHighTemp = nullptr

Definition at line 317 of file fvcartesiansyseqndetchem.h.

◆ integralLowTemp

template<MInt nDim>
MFloat* FvSysEqnDetChem< nDim >::NASACoefficients::integralLowTemp = nullptr

Definition at line 316 of file fvcartesiansyseqndetchem.h.

◆ lowTemp

template<MInt nDim>
MFloat* FvSysEqnDetChem< nDim >::NASACoefficients::lowTemp = nullptr

Definition at line 313 of file fvcartesiansyseqndetchem.h.

◆ lowTempIntegrationConstantsEnergy

template<MInt nDim>
MFloat* FvSysEqnDetChem< nDim >::NASACoefficients::lowTempIntegrationConstantsEnergy = nullptr

Definition at line 319 of file fvcartesiansyseqndetchem.h.

◆ lowTempIntegrationConstantsEnthalpy

template<MInt nDim>
MFloat* FvSysEqnDetChem< nDim >::NASACoefficients::lowTempIntegrationConstantsEnthalpy = nullptr

Definition at line 322 of file fvcartesiansyseqndetchem.h.

◆ noNASACoefficients

template<MInt nDim>
constexpr MInt FvSysEqnDetChem< nDim >::NASACoefficients::noNASACoefficients = 7
staticconstexpr

Definition at line 310 of file fvcartesiansyseqndetchem.h.

◆ noNASACoefficientsCpPolynomial

template<MInt nDim>
constexpr MInt FvSysEqnDetChem< nDim >::NASACoefficients::noNASACoefficientsCpPolynomial = 5
staticconstexpr

Definition at line 311 of file fvcartesiansyseqndetchem.h.

◆ referenceTemp

template<MInt nDim>
constexpr MFloat FvSysEqnDetChem< nDim >::NASACoefficients::referenceTemp = 298.0
staticconstexpr

Definition at line 306 of file fvcartesiansyseqndetchem.h.

◆ totalNumberCoefficientsPerSpecies

template<MInt nDim>
constexpr MInt FvSysEqnDetChem< nDim >::NASACoefficients::totalNumberCoefficientsPerSpecies = 15
staticconstexpr

Definition at line 309 of file fvcartesiansyseqndetchem.h.

◆ transitionTemp

template<MInt nDim>
constexpr MFloat FvSysEqnDetChem< nDim >::NASACoefficients::transitionTemp = 1000.0
staticconstexpr

Definition at line 307 of file fvcartesiansyseqndetchem.h.


The documentation for this struct was generated from the following files: