22 const size_t c_offset_U = 0;
23 const size_t c_offset_V = 1;
24 const size_t c_offset_T = 2;
25 const size_t c_offset_L = 3;
26 const size_t c_offset_E = 4;
27 const size_t c_offset_Y = 5;
51 StFlow(shared_ptr<ThermoPhase> th,
size_t nsp = 1,
size_t points = 1) :
52 StFlow(th.get(), nsp, points) {
58 virtual void setupGrid(
size_t n,
const doublereal* z);
66 Kinetics& kinetics() {
90 m_do_soret = withSoret;
92 bool withSoret()
const {
110 virtual void _finalize(
const doublereal* x);
126 m_do_energy[j] =
false;
131 return m_fixedtemp[j];
169 m_type = cAxisymmetricStagnationFlow;
177 if (m_type == cFreeFlow) {
179 }
else if (m_type == cAxisymmetricStagnationFlow) {
180 return "Axisymmetric Stagnation";
182 throw CanteraError(
"StFlow::flowType",
"Unknown value for 'm_type'");
186 void solveEnergyEqn(
size_t j=
npos);
223 void fixTemperature(
size_t j=
npos);
225 bool doEnergy(
size_t j) {
226 return m_do_energy[j];
230 virtual void resize(
size_t components,
size_t points);
238 "To be removed after Cantera 2.5.");
242 void setGas(
const doublereal* x,
size_t j);
248 doublereal density(
size_t j)
const {
252 virtual bool fixed_mdot() {
255 void setViscosityFlag(
bool dovisc) {
266 virtual void eval(
size_t j, doublereal* x, doublereal* r,
267 integer* mask, doublereal rdt);
276 int* diag,
double rdt);
285 return m_kExcessRight;
289 doublereal wdot(
size_t k,
size_t j)
const {
302 virtual void updateProperties(
size_t jg,
double* x,
size_t jmin,
size_t jmax);
306 virtual void evalResidual(
double* x,
double* rsd,
int* diag,
307 double rdt,
size_t jmin,
size_t jmax);
314 for (
size_t j = j0; j <= j1; j++) {
316 m_rho[j] = m_thermo->
density();
325 doublereal T(
const doublereal* x,
size_t j)
const {
326 return x[index(c_offset_T, j)];
328 doublereal& T(doublereal* x,
size_t j) {
329 return x[index(c_offset_T, j)];
331 doublereal T_prev(
size_t j)
const {
335 doublereal rho_u(
const doublereal* x,
size_t j)
const {
336 return m_rho[j]*x[index(c_offset_U, j)];
339 doublereal u(
const doublereal* x,
size_t j)
const {
340 return x[index(c_offset_U, j)];
343 doublereal V(
const doublereal* x,
size_t j)
const {
344 return x[index(c_offset_V, j)];
346 doublereal V_prev(
size_t j)
const {
350 doublereal lambda(
const doublereal* x,
size_t j)
const {
351 return x[index(c_offset_L, j)];
354 doublereal Y(
const doublereal* x,
size_t k,
size_t j)
const {
355 return x[index(c_offset_Y + k, j)];
358 doublereal& Y(doublereal* x,
size_t k,
size_t j) {
359 return x[index(c_offset_Y + k, j)];
362 doublereal Y_prev(
size_t k,
size_t j)
const {
366 doublereal X(
const doublereal* x,
size_t k,
size_t j)
const {
367 return m_wtm[j]*Y(x,k,j)/m_wt[k];
370 doublereal flux(
size_t k,
size_t j)
const {
378 doublereal dVdz(
const doublereal* x,
size_t j)
const {
379 size_t jloc = (u(x,j) > 0.0 ? j : j + 1);
380 return (V(x,jloc) - V(x,jloc-1))/m_dz[jloc-1];
383 doublereal dYdz(
const doublereal* x,
size_t k,
size_t j)
const {
384 size_t jloc = (u(x,j) > 0.0 ? j : j + 1);
385 return (Y(x,k,jloc) - Y(x,k,jloc-1))/m_dz[jloc-1];
388 doublereal dTdz(
const doublereal* x,
size_t j)
const {
389 size_t jloc = (u(x,j) > 0.0 ? j : j + 1);
390 return (T(x,jloc) - T(x,jloc-1))/m_dz[jloc-1];
394 doublereal shear(
const doublereal* x,
size_t j)
const {
395 doublereal c1 = m_visc[j-1]*(V(x,j) - V(x,j-1));
396 doublereal c2 = m_visc[j]*(V(x,j+1) - V(x,j));
397 return 2.0*(c2/(z(j+1) - z(j)) - c1/(z(j) - z(j-1)))/(z(j+1) - z(j-1));
400 doublereal divHeatFlux(
const doublereal* x,
size_t j)
const {
401 doublereal c1 = m_tcon[j-1]*(T(x,j) - T(x,j-1));
402 doublereal c2 = m_tcon[j]*(T(x,j+1) - T(x,j));
403 return -2.0*(c2/(z(j+1) - z(j)) - c1/(z(j) - z(j-1)))/(z(j+1) - z(j-1));
406 size_t mindex(
size_t k,
size_t j,
size_t m) {
407 return m*m_nsp*m_nsp + m_nsp*j + k;
443 IdealGasPhase* m_thermo;
448 doublereal m_epsilon_left;
449 doublereal m_epsilon_right;
456 std::vector<bool> m_do_energy;
458 std::vector<bool> m_do_species;
459 bool m_do_multicomponent;
476 size_t m_kExcessRight;
Header file for class Cantera::Array2D.
ThermoPhase object for the ideal gas equation of state - workhorse for Cantera (see Thermodynamic Pro...
Base class for kinetics managers and also contains the kineticsmgr module documentation (see Kinetics...
Base class for exceptions thrown by Cantera classes.
Base class for one-dimensional domains.
int domainType()
Domain type flag.
double prevSoln(size_t n, size_t j) const
Value of component n at point j in the previous solution.
Class IdealGasPhase represents low-density gases that obey the ideal gas equation of state.
Public interface for kinetics managers.
virtual void getNetProductionRates(doublereal *wdot)
Species net production rates [kmol/m^3/s or kmol/m^2/s].
doublereal meanMolecularWeight() const
The mean molecular weight. Units: (kg/kmol)
virtual double density() const
Density (kg/m^3).
This class represents 1D flow domains that satisfy the one-dimensional similarity solution for chemic...
virtual void evalResidual(double *x, double *rsd, int *diag, double rdt, size_t jmin, size_t jmax)
Evaluate the residual function.
virtual void evalRightBoundary(double *x, double *res, int *diag, double rdt)
Evaluate all residual components at the right boundary.
virtual void evalContinuity(size_t j, double *x, double *r, int *diag, double rdt)
Evaluate the residual corresponding to the continuity equation at all interior grid points.
size_t m_kExcessLeft
Index of species with a large mass fraction at each boundary, for which the mass fraction may be calc...
double leftEmissivity() const
Return emissivitiy at left boundary.
virtual void showSolution(const doublereal *x)
Print the solution.
void setGasAtMidpoint(const doublereal *x, size_t j)
Set the gas state to be consistent with the solution at the midpoint between j and j + 1.
size_t rightExcessSpecies() const
Index of the species on the right boundary with the largest mass fraction.
doublereal T_fixed(size_t j) const
The fixed temperature value at point j.
doublereal pressure() const
The current pressure [Pa].
StFlow(shared_ptr< ThermoPhase > th, size_t nsp=1, size_t points=1)
Delegating constructor.
StFlow(ThermoPhase *ph=0, size_t nsp=1, size_t points=1)
Create a new flow domain.
void enableSoret(bool withSoret)
Enable thermal diffusion, also known as Soret diffusion.
void setBoundaryEmissivities(double e_left, double e_right)
Set the emissivities for the boundary values.
void enableRadiation(bool doRadiation)
Turn radiation on / off.
std::vector< size_t > m_kRadiating
Indices within the ThermoPhase of the radiating species.
virtual void eval(size_t j, doublereal *x, doublereal *r, integer *mask, doublereal rdt)
double rightEmissivity() const
Return emissivitiy at right boundary.
virtual XML_Node & save(XML_Node &o, const doublereal *const sol)
Save the current solution for this domain into an XML_Node.
double m_tfixed
Temperature at the point used to fix the flame location.
bool radiationEnabled() const
Returns true if the radiation term in the energy equation is enabled.
void setPressure(doublereal p)
Set the pressure.
virtual void restore(const XML_Node &dom, doublereal *soln, int loglevel)
Restore the solution for this domain from an XML_Node.
void getWdot(doublereal *x, size_t j)
Write the net production rates at point j into array m_wdot
void setThermo(IdealGasPhase &th)
Set the thermo manager.
void setFreeFlow()
Set flow configuration for freely-propagating flames, using an internal point with a fixed temperatur...
virtual void _finalize(const doublereal *x)
In some cases, a domain may need to set parameters that depend on the initial solution estimate.
virtual std::string componentName(size_t n) const
Name of the nth component. May be overloaded.
void setGas(const doublereal *x, size_t j)
Set the gas object state to be consistent with the solution at point j.
virtual void updateDiffFluxes(const doublereal *x, size_t j0, size_t j1)
Update the diffusive mass fluxes.
void setFixedTempProfile(vector_fp &zfixed, vector_fp &tfixed)
Sometimes it is desired to carry out the simulation using a specified temperature profile,...
virtual void resize(size_t components, size_t points)
Change the grid size. Called after grid refinement.
virtual void setFixedPoint(int j0, doublereal t0)
size_t leftExcessSpecies() const
Index of the species on the left boundary with the largest mass fraction.
double radiativeHeatLoss(size_t j) const
Return radiative heat loss at grid point j.
double m_zfixed
Location of the point where temperature is fixed.
void updateThermo(const doublereal *x, size_t j0, size_t j1)
Update the thermodynamic properties from point j0 to point j1 (inclusive), based on solution x.
virtual void updateTransport(doublereal *x, size_t j0, size_t j1)
Update the transport properties at grid points in the range from j0 to j1, based on solution x.
vector_fp m_qdotRadiation
radiative heat loss vector
void setKinetics(Kinetics &kin)
Set the kinetics manager. The kinetics manager must.
virtual void resetBadValues(double *xg)
void setTemperature(size_t j, doublereal t)
virtual void _getInitialSoln(double *x)
Write the initial solution estimate into array x.
virtual void updateProperties(size_t jg, double *x, size_t jmin, size_t jmax)
Update the properties (thermo, transport, and diffusion flux).
virtual std::string flowType()
Return the type of flow domain being represented, either "Free Flame" or "Axisymmetric Stagnation".
virtual void setupGrid(size_t n, const doublereal *z)
called to set up initial grid, and after grid refinement
void setTransport(Transport &trans)
set the transport manager
void setAxisymmetricFlow()
Set flow configuration for axisymmetric counterflow or burner-stabilized flames, using specified inle...
virtual size_t componentIndex(const std::string &name) const
index of component with name name.
bool m_do_radiation
flag for the radiative heat loss
Base class for a phase with thermodynamic properties.
doublereal cp_mass() const
Specific heat at constant pressure. Units: J/kg/K.
Base class for transport property managers.
Class XML_Node is a tree-based representation of the contents of an XML file.
const size_t npos
index returned by functions to indicate "no position"
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
Namespace for the Cantera kernel.