21 const size_t c_offset_U = 0;
22 const size_t c_offset_V = 1;
23 const size_t c_offset_T = 2;
24 const size_t c_offset_L = 3;
25 const size_t c_offset_Y = 4;
28 const int c_Mixav_Transport = 0;
29 const int c_Multi_Transport = 1;
30 const int c_Soret = 2;
56 virtual void setupGrid(
size_t n,
const doublereal* z);
83 void enableSoret(
bool withSoret);
84 bool withSoret()
const {
102 for (
size_t j = 0; j < m_points; j++) {
108 virtual void _finalize(
const doublereal* x);
124 m_do_energy[j] =
false;
134 m_do_species[k] =
true;
139 return m_fixedtemp[j];
144 doublereal
Y_fixed(
size_t k,
size_t j)
const {
145 warn_deprecated(
"StFlow::Y_fixed",
"To be removed after Cantera 2.2.");
153 virtual size_t componentIndex(
const std::string& name)
const;
171 virtual std::string flowType() {
175 void solveEnergyEqn(
size_t j=
npos) {
176 bool changed =
false;
178 for (
size_t i = 0; i < m_points; i++) {
179 if (!m_do_energy[i]) {
182 m_do_energy[i] =
true;
185 if (!m_do_energy[j]) {
188 m_do_energy[j] =
true;
190 m_refiner->setActive(0,
true);
191 m_refiner->setActive(1,
true);
192 m_refiner->setActive(2,
true);
206 m_do_radiation = doRadiation;
211 return m_do_radiation;
221 if (e_left < 0 || e_left > 1) {
223 "The left boundary emissivity must be between 0.0 and 1.0!");
224 }
else if (e_right < 0 || e_right > 1) {
226 "The right boundary emissivity must be between 0.0 and 1.0!");
228 m_epsilon_left = e_left;
229 m_epsilon_right = e_right;
233 void fixTemperature(
size_t j=
npos) {
234 bool changed =
false;
236 for (
size_t i = 0; i < m_points; i++) {
237 if (m_do_energy[i]) {
240 m_do_energy[i] =
false;
243 if (m_do_energy[j]) {
246 m_do_energy[j] =
false;
248 m_refiner->setActive(0,
false);
249 m_refiner->setActive(1,
false);
250 m_refiner->setActive(2,
false);
259 warn_deprecated(
"StFlow::doSpecies",
"To be removed after Cantera 2.2.");
260 return m_do_species[k];
262 bool doEnergy(
size_t j) {
263 return m_do_energy[j];
269 warn_deprecated(
"StFlow::solveSpecies",
"To be removed after Cantera 2.2.");
271 for (
size_t i = 0; i < m_nsp; i++) {
272 m_do_species[i] =
true;
275 m_do_species[k] =
true;
283 warn_deprecated(
"StFlow::fixSpecies",
"To be removed after Cantera 2.2.");
285 for (
size_t i = 0; i < m_nsp; i++) {
286 m_do_species[i] =
false;
289 m_do_species[k] =
false;
294 void integrateChem(doublereal* x,doublereal dt);
297 void resize(
size_t components,
size_t points);
299 virtual void setFixedPoint(
int j0, doublereal t0) {}
301 void setJac(MultiJac* jac);
304 void setGas(
const doublereal* x,
size_t j);
310 doublereal density(
size_t j)
const {
314 virtual bool fixed_mdot() {
317 void setViscosityFlag(
bool dovisc) {
328 virtual void eval(
size_t j, doublereal* x, doublereal* r,
329 integer* mask, doublereal rdt);
333 integer* diag, doublereal rdt) = 0;
337 virtual void evalContinuity(
size_t j, doublereal* x, doublereal* r,
338 integer* diag, doublereal rdt) = 0;
341 doublereal component(
const doublereal* x,
size_t i,
size_t j)
const {
342 return x[index(i,j)];
345 doublereal conc(
const doublereal* x,
size_t k,
size_t j)
const {
346 return Y(x,k,j)*density(j)/m_wt[k];
349 doublereal cbar(
const doublereal* x,
size_t k,
size_t j)
const {
353 doublereal wdot(
size_t k,
size_t j)
const {
368 for (
size_t j = j0; j <= j1; j++) {
370 m_rho[j] = m_thermo->
density();
380 doublereal cdif2(
const doublereal* x,
size_t n,
size_t j,
381 const doublereal* f)
const {
382 doublereal c1 = (f[j] + f[j-1])*(x[index(n,j)] - x[index(n,j-1)]);
383 doublereal c2 = (f[j+1] + f[j])*(x[index(n,j+1)] - x[index(n,j)]);
384 return (c2/(z(j+1) - z(j)) - c1/(z(j) - z(j-1)))/(z(j+1) - z(j-1));
391 doublereal T(
const doublereal* x,
size_t j)
const {
392 return x[index(c_offset_T, j)];
394 doublereal& T(doublereal* x,
size_t j) {
395 return x[index(c_offset_T, j)];
397 doublereal T_prev(
size_t j)
const {
401 doublereal rho_u(
const doublereal* x,
size_t j)
const {
402 return m_rho[j]*x[index(c_offset_U, j)];
405 doublereal u(
const doublereal* x,
size_t j)
const {
406 return x[index(c_offset_U, j)];
409 doublereal V(
const doublereal* x,
size_t j)
const {
410 return x[index(c_offset_V, j)];
412 doublereal V_prev(
size_t j)
const {
416 doublereal lambda(
const doublereal* x,
size_t j)
const {
417 return x[index(c_offset_L, j)];
420 doublereal Y(
const doublereal* x,
size_t k,
size_t j)
const {
421 return x[index(c_offset_Y + k, j)];
424 doublereal& Y(doublereal* x,
size_t k,
size_t j) {
425 return x[index(c_offset_Y + k, j)];
428 doublereal Y_prev(
size_t k,
size_t j)
const {
432 doublereal X(
const doublereal* x,
size_t k,
size_t j)
const {
433 return m_wtm[j]*Y(x,k,j)/m_wt[k];
436 doublereal flux(
size_t k,
size_t j)
const {
444 doublereal dVdz(
const doublereal* x,
size_t j)
const {
445 size_t jloc = (u(x,j) > 0.0 ? j : j + 1);
446 return (V(x,jloc) - V(x,jloc-1))/m_dz[jloc-1];
449 doublereal dYdz(
const doublereal* x,
size_t k,
size_t j)
const {
450 size_t jloc = (u(x,j) > 0.0 ? j : j + 1);
451 return (Y(x,k,jloc) - Y(x,k,jloc-1))/m_dz[jloc-1];
454 doublereal dTdz(
const doublereal* x,
size_t j)
const {
455 size_t jloc = (u(x,j) > 0.0 ? j : j + 1);
456 return (T(x,jloc) - T(x,jloc-1))/m_dz[jloc-1];
460 doublereal shear(
const doublereal* x,
size_t j)
const {
461 doublereal c1 = m_visc[j-1]*(V(x,j) - V(x,j-1));
462 doublereal c2 = m_visc[j]*(V(x,j+1) - V(x,j));
463 return 2.0*(c2/(z(j+1) - z(j)) - c1/(z(j) - z(j-1)))/(z(j+1) - z(j-1));
466 doublereal divHeatFlux(
const doublereal* x,
size_t j)
const {
467 doublereal c1 = m_tcon[j-1]*(T(x,j) - T(x,j-1));
468 doublereal c2 = m_tcon[j]*(T(x,j+1) - T(x,j));
469 return -2.0*(c2/(z(j+1) - z(j)) - c1/(z(j) - z(j-1)))/(z(j+1) - z(j-1));
472 size_t mindex(
size_t k,
size_t j,
size_t m) {
473 return m*m_nsp*m_nsp + m_nsp*j + k;
509 IdealGasPhase* m_thermo;
516 doublereal m_epsilon_left;
517 doublereal m_epsilon_right;
524 std::vector<bool> m_do_energy;
526 std::vector<bool> m_do_species;
527 int m_transport_option;
565 integer* diag, doublereal rdt);
566 virtual void evalContinuity(
size_t j, doublereal* x, doublereal* r,
567 integer* diag, doublereal rdt);
569 virtual std::string flowType() {
570 return "Axisymmetric Stagnation";
583 integer* diag, doublereal rdt);
584 virtual void evalContinuity(
size_t j, doublereal* x, doublereal* r,
585 integer* diag, doublereal rdt);
587 virtual std::string flowType() {
590 virtual bool fixed_mdot() {
593 virtual void _finalize(
const doublereal* x);
594 virtual void restore(
const XML_Node& dom, doublereal* soln,
int loglevel);
doublereal Y_fixed(size_t k, size_t j) const
The fixed mass fraction value of species k at point j.
virtual doublereal density() const
Density (kg/m^3).
virtual void _finalize(const doublereal *x)
In some cases, a domain may need to set parameters that depend on the initial solution estimate...
void setKinetics(Kinetics &kin)
Set the kinetics manager. The kinetics manager must.
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 evalRightBoundary(doublereal *x, doublereal *res, integer *diag, doublereal rdt)=0
Evaluate all residual components at the right boundary.
This class represents 1D flow domains that satisfy the one-dimensional similarity solution for chemic...
void getMassFractions(doublereal *const y) const
Get the species mass fractions.
virtual void evalRightBoundary(doublereal *x, doublereal *res, integer *diag, doublereal rdt)
Evaluate all residual components at the right boundary.
Class IdealGasPhase represents low-density gases that obey the ideal gas equation of state...
const size_t npos
index returned by functions to indicate "no position"
A class for axisymmetric stagnation flows.
virtual void restore(const XML_Node &dom, doublereal *soln, int loglevel)
Restore the solution for this domain from an XML_Node.
virtual void _finalize(const doublereal *x)
In some cases, a domain may need to set parameters that depend on the initial solution estimate...
virtual void evalContinuity(size_t j, doublereal *x, doublereal *r, integer *diag, doublereal rdt)
Evaluate the residual corresponding to the continuity equation at all interior grid points...
Class XML_Node is a tree-based representation of the contents of an XML file.
virtual XML_Node & save(XML_Node &o, const doublereal *const sol)
Save the current solution for this domain into an XML_Node.
Base class for transport property managers.
void warn_deprecated(const std::string &method, const std::string &extra)
Print a warning indicating that method is deprecated.
void setPressure(doublereal p)
Set the pressure.
virtual void evalContinuity(size_t j, doublereal *x, doublereal *r, integer *diag, doublereal rdt)=0
Evaluate the residual corresponding to the continuity equation at all interior grid points...
A class for freely-propagating premixed flames.
A class for 2D arrays stored in column-major (Fortran-compatible) form.
doublereal m_tfixed
Temperature at the point used to fix the flame location.
virtual void restore(const XML_Node &dom, doublereal *soln, int loglevel)
Restore the solution for this domain from an XML_Node.
virtual void getNetProductionRates(doublereal *wdot)
Species net production rates [kmol/m^3/s or kmol/m^2/s].
Base class for a phase with thermodynamic properties.
Header file for class Cantera::Array2D.
void fixSpecies(size_t k=npos)
Base class for one-dimensional domains.
doublereal T_fixed(size_t j) const
The fixed temperature value at point j.
ThermoPhase object for the ideal gas equation of state - workhorse for Cantera (see Thermodynamic Pro...
virtual void evalRightBoundary(doublereal *x, doublereal *res, integer *diag, doublereal rdt)
Evaluate all residual components at the right boundary.
void setThermo(IdealGasPhase &th)
Set the thermo manager.
void setFixedTempProfile(vector_fp &zfixed, vector_fp &tfixed)
Sometimes it is desired to carry out the simulation using a specified temperature profile...
doublereal cp_mass() const
Specific heat at constant pressure.
Public interface for kinetics managers.
Base class for exceptions thrown by Cantera classes.
Base class for kinetics managers and also contains the kineticsmgr module documentation (see Kinetics...
void setTemperature(size_t j, doublereal t)
std::vector< size_t > m_kRadiating
Indices within the ThermoPhase of the radiating species.
doublereal m_zfixed
Location of the point where temperature is fixed.
void getWdot(doublereal *x, size_t j)
Write the net production rates at point j into array m_wdot
virtual std::string componentName(size_t n) const
Name of the nth component. May be overloaded.
virtual void evalContinuity(size_t j, doublereal *x, doublereal *r, integer *diag, doublereal rdt)
Evaluate the residual corresponding to the continuity equation at all interior grid points...
void setGas(const doublereal *x, size_t j)
Set the gas object state to be consistent with the solution at point j.
virtual void showSolution(const doublereal *x)
Print the solution.
bool radiationEnabled() const
Returns true if the radiation term in the energy equation is enabled.
void solveSpecies(size_t k=npos)
doublereal temperature() const
Temperature (K).
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...
virtual void setupGrid(size_t n, const doublereal *z)
called to set up initial grid, and after grid refinement
void enableRadiation(bool doRadiation)
Turn radiation on / off.
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
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...
void setTransport(Transport &trans, bool withSoret=false)
set the transport manager
doublereal meanMolecularWeight() const
The mean molecular weight. Units: (kg/kmol)
const doublereal GasConstant
Universal Gas Constant. [J/kmol/K].
void updateDiffFluxes(const doublereal *x, size_t j0, size_t j1)
Update the diffusive mass fluxes.
virtual void _getInitialSoln(doublereal *x)
Write the initial solution estimate into array x.
doublereal pressure() const
The current pressure [Pa].
void resize(size_t components, size_t points)
Change the grid size. Called after grid refinement.
void setMassFraction(size_t j, size_t k, doublereal y)
StFlow(IdealGasPhase *ph=0, size_t nsp=1, size_t points=1)
Create a new flow domain.
double prevSoln(size_t n, size_t j) const
Value of component n at point j in the previous solution.
void setBoundaryEmissivities(doublereal e_left, doublereal e_right)
Set the emissivities for the boundary values.
virtual void eval(size_t j, doublereal *x, doublereal *r, integer *mask, doublereal rdt)
virtual XML_Node & save(XML_Node &o, const doublereal *const sol)
Save the current solution for this domain into an XML_Node.