8#include "cantera/oneD/refine.h"
48 m_do_species.resize(
m_nsp,
true);
70 for (
size_t k = 0; k <
m_nsp; k++) {
82 for (
size_t ng = 0; ng <
m_points; ng++) {
94 :
Flow1D(th.get(), nsp, points)
102 :
Flow1D(sol->thermo().get(), sol->thermo()->nSpecies(), points)
110 "An appropriate transport model\nshould be set when instantiating the "
111 "Solution ('gas') object.");
113 m_solution->registerChangedCallback(
this, [
this]() {
131 return "axisymmetric-flow";
133 return "unstrained-flow";
145 throw CanteraError(
"Flow1D::setTransport",
"Unable to set empty transport.");
147 m_trans = trans.get();
149 throw CanteraError(
"Flow1D::setTransport",
"Invalid Transport model 'none'.");
151 m_do_multicomponent = (m_trans->
transportModel() ==
"multicomponent" ||
155 if (m_do_multicomponent) {
172 if (m_do_multicomponent) {
193 for (
size_t j = 1; j <
m_points; j++) {
194 if (z[j] <= z[j-1]) {
196 "grid points must be monotonically increasing");
199 m_dz[j-1] = m_z[j] - m_z[j-1];
205 double* x = xg +
loc();
206 for (
size_t j = 0; j <
m_points; j++) {
226 warn_user(
"Flow1D::setFluxGradientBasis",
227 "Setting fluxGradientBasis only affects "
228 "the mixture-averaged diffusion model.");
234 for (
size_t j = 0; j <
m_points; j++) {
253 const double* yyjp = x + m_nv*(j+1) +
c_offset_Y;
254 for (
size_t k = 0; k <
m_nsp; k++) {
255 m_ybar[k] = 0.5*(yyj[k] + yyjp[k]);
263 if (!m_do_multicomponent && m_do_soret) {
265 "Thermal diffusion (the Soret effect) is enabled, and requires "
266 "using a multicomponent transport model.");
269 size_t nz = m_zfix.size();
270 bool e = m_do_energy[0];
271 for (
size_t j = 0; j <
m_points; j++) {
273 m_fixedtemp[j] = T(x, j);
275 double zz = (z(j) - z(0))/(z(
m_points - 1) - z(0));
289 for (
size_t j = 0; j <
m_points; j++) {
295 for (
size_t j = 0; j <
m_points - 1; j++) {
309 integer* diagGlobal,
double rdt)
318 double* x = xGlobal +
loc();
319 double* rsd = rsdGlobal +
loc();
320 integer* diag = diagGlobal +
loc();
323 if (jGlobal ==
npos) {
327 size_t jpt = (jGlobal == 0) ? 0 : jGlobal -
firstPoint();
328 jmin = std::max<size_t>(jpt, 1) - 1;
343 evalUo(x, rsd, diag, rdt, jmin, jmax);
350 size_t j0 = std::max<size_t>(jmin, 1) - 1;
351 size_t j1 = std::min(jmax+1,
m_points-1);
354 if (jg ==
npos || m_force_full_update) {
363 m_kExcessRight = distance(Yright, max_element(Yright, Yright +
m_nsp));
373 if (m_do_multicomponent) {
374 for (
size_t j = j0; j < j1; j++) {
377 double rho = m_thermo->
density();
378 m_visc[j] = (m_dovisc ? m_trans->
viscosity() : 0.0);
382 for (
size_t k = 0; k <
m_nsp; k++) {
392 for (
size_t j = j0; j < j1; j++) {
394 m_visc[j] = (m_dovisc ? m_trans->
viscosity() : 0.0);
396 if (m_fluxGradientBasis == ThermoBasis::molar) {
402 double rho = m_thermo->
density();
404 if (m_fluxGradientBasis == ThermoBasis::molar) {
406 for (
size_t k=0; k <
m_nsp; k++) {
410 for (
size_t k=0; k <
m_nsp; k++) {
421 if (m_do_multicomponent) {
422 for (
size_t j = j0; j < j1; j++) {
423 double dz = z(j+1) - z(j);
424 for (
size_t k = 0; k <
m_nsp; k++) {
426 for (
size_t m = 0; m <
m_nsp; m++) {
427 sum += m_wt[m] * m_multidiff[mindex(k,m,j)] * (X(x,m,j+1)-X(x,m,j));
433 for (
size_t j = j0; j < j1; j++) {
435 double dz = z(j+1) - z(j);
436 if (m_fluxGradientBasis == ThermoBasis::molar) {
437 for (
size_t k = 0; k <
m_nsp; k++) {
438 m_flux(k,j) =
m_diff[k+
m_nsp*j] * (X(x,k,j) - X(x,k,j+1))/dz;
442 for (
size_t k = 0; k <
m_nsp; k++) {
443 m_flux(k,j) =
m_diff[k+
m_nsp*j] * (Y(x,k,j) - Y(x,k,j+1))/dz;
448 for (
size_t k = 0; k <
m_nsp; k++) {
449 m_flux(k,j) += sum*Y(x,k,j);
455 for (
size_t m = j0; m < j1; m++) {
456 double gradlogT = 2.0 * (T(x,m+1) - T(x,m)) /
457 ((T(x,m+1) + T(x,m)) * (z(m+1) - z(m)));
458 for (
size_t k = 0; k <
m_nsp; k++) {
459 m_flux(k,m) -= m_dthermal(k,m)*gradlogT;
469 double k_P_ref = 1.0*
OneAtm;
472 const double c_H2O[6] = {-0.23093, -1.12390, 9.41530, -2.99880,
473 0.51382, -1.86840e-5};
474 const double c_CO2[6] = {18.741, -121.310, 273.500, -194.050,
478 double boundary_Rad_left = m_epsilon_left *
StefanBoltz * pow(T(x, 0), 4);
481 for (
size_t j = jmin; j < jmax; j++) {
487 for (
size_t n = 0; n <= 5; n++) {
488 k_P_H2O += c_H2O[n] * pow(1000 / T(x, j), (
double) n);
496 for (
size_t n = 0; n <= 5; n++) {
497 k_P_CO2 += c_CO2[n] * pow(1000 / T(x, j), (
double) n);
504 double radiative_heat_loss = 2 * k_P *(2 *
StefanBoltz * pow(T(x, j), 4)
505 - boundary_Rad_left - boundary_Rad_right);
513 double rdt,
size_t jmin,
size_t jmax)
517 rsd[index(
c_offset_U,jmin)] = -(rho_u(x,jmin + 1) - rho_u(x,jmin))/m_dz[jmin]
518 -(density(jmin + 1)*V(x,jmin + 1)
519 + density(jmin)*V(x,jmin));
526 rsd[index(
c_offset_U, jmax)] = rho_u(x, jmax);
528 rsd[index(
c_offset_U, jmax)] = rho_u(x, jmax) - rho_u(x, jmax - 1);
534 size_t j0 = std::max<size_t>(jmin, 1);
535 size_t j1 = std::min(jmax,
m_points - 2);
537 for (
size_t j = j0; j <= j1; j++) {
542 rsd[index(
c_offset_U,j)] = -(rho_u(x,j+1) - rho_u(x,j))/m_dz[j]
543 -(density(j+1)*V(x,j+1) + density(j)*V(x,j));
547 }
else if (m_isFree) {
548 for (
size_t j = j0; j <= j1; j++) {
551 rsd[index(
c_offset_U,j)] = -(rho_u(x,j) - rho_u(x,j-1))/m_dz[j-1];
553 if (m_do_energy[j]) {
559 rsd[index(
c_offset_U,j)] = -(rho_u(x,j+1) - rho_u(x,j))/m_dz[j];
564 for (
size_t j = j0; j <= j1; j++) {
565 rsd[index(
c_offset_U, j)] = rho_u(x, j) - rho_u(x, j - 1);
572 double rdt,
size_t jmin,
size_t jmax)
575 for (
size_t j = jmin; j <= jmax; j++) {
592 size_t j0 = std::max<size_t>(jmin, 1);
593 size_t j1 = std::min(jmax,
m_points - 2);
594 for (
size_t j = j0; j <= j1; j++) {
595 rsd[index(
c_offset_V,j)] = (shear(x, j) - lambda(x, j)
596 - rho_u(x, j) * dVdz(x, j)
598 - rdt * (V(x, j) - V_prev(j));
604 double rdt,
size_t jmin,
size_t jmax)
607 for (
size_t j = jmin; j <= jmax; j++) {
616 rsd[index(
c_offset_L, jmin)] = lambda(x,jmin+1) - lambda(x,jmin);
618 rsd[index(
c_offset_L, jmin)] = -rho_u(x, jmin);
623 rsd[index(
c_offset_L, jmax)] = lambda(x, jmax) - lambda(x, jmax-1);
628 size_t j0 = std::max<size_t>(jmin, 1);
629 size_t j1 = std::min(jmax,
m_points - 2);
630 for (
size_t j = j0; j <= j1; j++) {
634 }
else if (grid(j) >
m_zLeft) {
635 rsd[index(
c_offset_L, j)] = lambda(x,j) - lambda(x,j-1);
636 }
else if (grid(j) <
m_zLeft) {
637 rsd[index(
c_offset_L, j)] = lambda(x,j+1) - lambda(x,j);
640 rsd[index(
c_offset_L, j)] = lambda(x,j) - lambda(x,j-1);
647 double rdt,
size_t jmin,
size_t jmax)
658 size_t j0 = std::max<size_t>(jmin, 1);
659 size_t j1 = std::min(jmax,
m_points - 2);
660 for (
size_t j = j0; j <= j1; j++) {
661 if (m_do_energy[j]) {
664 for (
size_t k = 0; k <
m_nsp; k++) {
665 double flxk = 0.5*(m_flux(k,j-1) + m_flux(k,j));
667 sum += flxk *
m_dhk_dz(k,j) / m_wt[k];
671 - divHeatFlux(x,j) - sum;
673 rsd[index(
c_offset_T, j)] -= rdt*(T(x,j) - T_prev(j));
685 double rdt,
size_t jmin,
size_t jmax)
688 for (
size_t j = jmin; j <= jmax; j++) {
708 size_t j0 = std::max<size_t>(jmin, 1);
709 size_t j1 = std::min(jmax,
m_points - 2);
710 for (
size_t j = j0; j <= j1; j++) {
727 double rdt,
size_t jmin,
size_t jmax)
731 for (
size_t k = 0; k <
m_nsp; k++) {
733 rsd[index(
c_offset_Y + k, jmin)] = -(m_flux(k,jmin) +
734 rho_u(x,jmin) * Y(x,k,jmin));
741 for (
size_t k = 0; k <
m_nsp; k++) {
743 rsd[index(k+
c_offset_Y,jmax)] = m_flux(k,jmax-1) +
744 rho_u(x,jmax)*Y(x,k,jmax);
751 size_t j0 = std::max<size_t>(jmin, 1);
752 size_t j1 = std::min(jmax,
m_points - 2);
753 for (
size_t j = j0; j <= j1; j++) {
754 for (
size_t k = 0; k <
m_nsp; k++) {
755 double convec = rho_u(x,j)*dYdz(x,k,j);
756 double diffus = 2.0*(m_flux(k,j) - m_flux(k,j-1)) / (z(j+1) - z(j-1));
758 - convec - diffus)/
m_rho[j]
759 - rdt*(Y(x,k,j) - Y_prev(k,j));
766 double rdt,
size_t jmin,
size_t jmax)
768 for (
size_t j = jmin; j <= jmax; j++) {
777 "Overloaded by StFlow; to be removed after Cantera 3.1");
782 writelog(
" Pressure: {:10.4g} Pa\n", m_press);
787 writeline(
'-', 79,
false,
true);
788 writelog(
"\n z radiative heat loss");
789 writeline(
'-', 79,
false,
true);
790 for (
size_t j = 0; j <
m_points; j++) {
803 return "spread_rate";
823 if (name==
"velocity") {
825 }
else if (name==
"spread_rate") {
827 }
else if (name==
"T") {
829 }
else if (name==
"lambda") {
831 }
else if (name ==
"eField") {
833 }
else if (name ==
"Uo") {
842 "no component named " + name);
867 state[
"phase"][
"name"] = m_thermo->
name();
869 state[
"phase"][
"source"] = source.
empty() ?
"<unknown>" : source.
asString();
873 state[
"emissivity-left"] = m_epsilon_left;
874 state[
"emissivity-right"] = m_epsilon_right;
877 set<bool> energy_flags(m_do_energy.begin(), m_do_energy.end());
878 if (energy_flags.size() == 1) {
879 state[
"energy-enabled"] = m_do_energy[0];
881 state[
"energy-enabled"] = m_do_energy;
884 state[
"Soret-enabled"] = m_do_soret;
886 state[
"flux-gradient-basis"] =
static_cast<long int>(m_fluxGradientBasis);
888 set<bool> species_flags(m_do_species.begin(), m_do_species.end());
889 if (species_flags.size() == 1) {
890 state[
"species-enabled"] = m_do_species[0];
892 for (
size_t k = 0; k <
m_nsp; k++) {
893 state[
"species-enabled"][m_thermo->
speciesName(k)] = m_do_species[k];
897 state[
"refine-criteria"][
"ratio"] = m_refiner->maxRatio();
898 state[
"refine-criteria"][
"slope"] = m_refiner->maxDelta();
899 state[
"refine-criteria"][
"curve"] = m_refiner->maxSlope();
900 state[
"refine-criteria"][
"prune"] = m_refiner->prune();
901 state[
"refine-criteria"][
"grid-min"] = m_refiner->gridMin();
902 state[
"refine-criteria"][
"max-points"] =
903 static_cast<long int>(m_refiner->maxPoints());
906 state[
"fixed-point"][
"location"] =
m_zfixed;
907 state[
"fixed-point"][
"temperature"] =
m_tfixed;
912 state[
"continuation-method"][
"type"] =
"two-point";
913 state[
"continuation-method"][
"left-location"] =
m_zLeft;
914 state[
"continuation-method"][
"right-location"] =
m_zRight;
915 state[
"continuation-method"][
"left-temperature"] =
m_tLeft;
916 state[
"continuation-method"][
"right-temperature"] =
m_tRight;
926 arr->addExtra(
"grid",
false);
929 arr->setComponent(
"grid", value);
930 vector<double> data(
nPoints());
934 for (
size_t j = 0; j <
nPoints(); j++) {
935 data[j] = soln[index(i, j)];
937 if (!arr->hasComponent(name)) {
941 arr->setComponent(name, value);
945 arr->setComponent(
"D", value);
948 arr->addExtra(
"radiative-heat-loss",
true);
950 arr->setComponent(
"radiative-heat-loss", value);
960 auto phase = arr.
thermo();
972 const vector<double> data = arr.
getComponent(name).
as<vector<double>>();
973 for (
size_t j = 0; j <
nPoints(); j++) {
974 soln[index(i,j)] = data[j];
977 warn_user(
"Flow1D::fromArray",
"Saved state does not contain values for "
978 "component '{}' in domain '{}'.", name,
id());
988 if (state.
hasKey(
"energy-enabled")) {
989 const AnyValue& ee = state[
"energy-enabled"];
999 if (state.
hasKey(
"Soret-enabled")) {
1000 m_do_soret = state[
"Soret-enabled"].asBool();
1003 if (state.
hasKey(
"flux-gradient-basis")) {
1005 state[
"flux-gradient-basis"].asInt());
1008 if (state.
hasKey(
"species-enabled")) {
1009 const AnyValue& se = state[
"species-enabled"];
1017 if (state.
hasKey(
"radiation-enabled")) {
1020 m_epsilon_left = state[
"emissivity-left"].asDouble();
1021 m_epsilon_right = state[
"emissivity-right"].asDouble();
1025 if (state.
hasKey(
"refine-criteria")) {
1026 const AnyMap& criteria = state[
"refine-criteria"].as<
AnyMap>();
1027 double ratio = criteria.
getDouble(
"ratio", m_refiner->maxRatio());
1028 double slope = criteria.
getDouble(
"slope", m_refiner->maxDelta());
1029 double curve = criteria.
getDouble(
"curve", m_refiner->maxSlope());
1030 double prune = criteria.
getDouble(
"prune", m_refiner->prune());
1031 m_refiner->setCriteria(ratio, slope, curve, prune);
1033 if (criteria.
hasKey(
"grid-min")) {
1034 m_refiner->setGridMin(criteria[
"grid-min"].asDouble());
1036 if (criteria.
hasKey(
"max-points")) {
1037 m_refiner->setMaxPoints(criteria[
"max-points"].asInt());
1041 if (state.
hasKey(
"fixed-point")) {
1042 m_zfixed = state[
"fixed-point"][
"location"].asDouble();
1043 m_tfixed = state[
"fixed-point"][
"temperature"].asDouble();
1047 if (state.
hasKey(
"continuation-method")) {
1048 const AnyMap& cm = state[
"continuation-method"].as<
AnyMap>();
1049 if (cm[
"type"] ==
"two-point") {
1051 m_zLeft = cm[
"left-location"].asDouble();
1052 m_zRight = cm[
"right-location"].asDouble();
1053 m_tLeft = cm[
"left-temperature"].asDouble();
1054 m_tRight = cm[
"right-temperature"].asDouble();
1056 warn_user(
"Flow1D::setMeta",
"Unknown continuation method '{}'.",
1057 cm[
"type"].asString());
1062void Flow1D::solveEnergyEqn(
size_t j)
1064 bool changed =
false;
1066 for (
size_t i = 0; i <
m_points; i++) {
1067 if (!m_do_energy[i]) {
1070 m_do_energy[i] =
true;
1073 if (!m_do_energy[j]) {
1076 m_do_energy[j] =
true;
1089 "Not used by '{}' objects.",
type());
1095 "Not used by '{}' objects.",
type());
1101 "Not used by '{}' objects.",
type());
1107 "Not used by '{}' objects.",
type());
1113 "Not used by '{}' objects.",
type());
1118 if (e_left < 0 || e_left > 1) {
1120 "The left boundary emissivity must be between 0.0 and 1.0!");
1121 }
else if (e_right < 0 || e_right > 1) {
1123 "The right boundary emissivity must be between 0.0 and 1.0!");
1125 m_epsilon_left = e_left;
1126 m_epsilon_right = e_right;
1130void Flow1D::fixTemperature(
size_t j)
1132 bool changed =
false;
1134 for (
size_t i = 0; i <
m_points; i++) {
1135 if (m_do_energy[i]) {
1138 m_do_energy[i] =
false;
1141 if (m_do_energy[j]) {
1144 m_do_energy[j] =
false;
1156 for(
size_t k = 0; k <
m_nsp; k++) {
1157 if (u(x, j) > 0.0) {
1173 throw CanteraError(
"Flow1D::leftControlPointTemperature",
1174 "Invalid operation: left control point location is not set");
1177 throw CanteraError(
"Flow1D::leftControlPointTemperature",
1178 "Invalid operation: two-point control is not enabled.");
1188 throw CanteraError(
"Flow1D::leftControlPointCoordinate",
1189 "Invalid operation: left control point location is not set");
1192 throw CanteraError(
"Flow1D::leftControlPointCoordinate",
1193 "Invalid operation: two-point control is not enabled.");
1203 throw CanteraError(
"Flow1D::setLeftControlPointTemperature",
1204 "Invalid operation: left control point location is not set");
1207 throw CanteraError(
"Flow1D::setLeftControlPointTemperature",
1208 "Invalid operation: two-point control is not enabled.");
1217 throw CanteraError(
"Flow1D::setLeftControlPointCoordinate",
1218 "Invalid operation: two-point control is not enabled.");
1228 throw CanteraError(
"Flow1D::rightControlPointTemperature",
1229 "Invalid operation: right control point location is not set");
1232 throw CanteraError(
"Flow1D::rightControlPointTemperature",
1233 "Invalid operation: two-point control is not enabled.");
1243 throw CanteraError(
"Flow1D::rightControlPointCoordinate",
1244 "Invalid operation: right control point location is not set");
1247 throw CanteraError(
"Flow1D::rightControlPointCoordinate",
1248 "Invalid operation: two-point control is not enabled.");
1258 throw CanteraError(
"Flow1D::setRightControlPointTemperature",
1259 "Invalid operation: right control point location is not set");
1262 throw CanteraError(
"Flow1D::setRightControlPointTemperature",
1263 "Invalid operation: two-point control is not enabled.");
1272 throw CanteraError(
"Flow1D::setRightControlPointCoordinate",
1273 "Invalid operation: two-point control is not enabled.");
1283 "Invalid operation: two-point control can only be used"
1284 "with axisymmetric flames.");
Header file defining class TransportFactory (see TransportFactory)
Headers for the Transport object, which is the virtual base class for all transport property evaluato...
const AnyValue & getMetadata(const string &key) const
Get a value from the metadata applicable to the AnyMap tree containing this node.
A map of string keys to values whose type can vary at runtime.
double getDouble(const string &key, double default_) const
If key exists, return it as a double, otherwise return default_.
bool hasKey(const string &key) const
Returns true if the map contains an item named key.
const string & getString(const string &key, const string &default_) const
If key exists, return it as a string, otherwise return default_.
A wrapper for a variable whose type is determined at runtime.
const string & asString() const
Return the held value, if it is a string.
bool & asBool()
Return the held value, if it is a bool.
bool empty() const
Return boolean indicating whether AnyValue is empty.
bool isScalar() const
Returns true if the held value is a scalar type (such as double, long int, string,...
const vector< T > & asVector(size_t nMin=npos, size_t nMax=npos) const
Return the held value, if it is a vector of type T.
const T & as() const
Get the value of this key as the specified type.
double * ptrColumn(size_t j)
Return a pointer to the top of column j, columns are contiguous in memory.
virtual void resize(size_t n, size_t m, double v=0.0)
Resize the array, and fill the new entries with 'v'.
Base class for exceptions thrown by Cantera classes.
Base class for one-dimensional domains.
size_t lastPoint() const
The index of the last (that is, right-most) grid point belonging to this domain.
shared_ptr< Solution > m_solution
Composite thermo/kinetics/transport handler.
size_t nComponents() const
Number of components at each grid point.
virtual void setMeta(const AnyMap &meta)
Retrieve meta data.
size_t nPoints() const
Number of grid points in this domain.
virtual void resize(size_t nv, size_t np)
Resize the domain to have nv components and np grid points.
void setSolution(shared_ptr< Solution > sol)
Set the solution manager.
size_t m_points
Number of grid points.
string m_id
Identity tag for the domain.
string type() const
String indicating the domain implemented.
size_t firstPoint() const
The index of the first (that is, left-most) grid point belonging to this domain.
void needJacUpdate()
Set this if something has changed in the governing equations (for example, the value of a constant ha...
virtual size_t loc(size_t j=0) const
Location of the start of the local solution vector in the global solution vector,.
virtual AnyMap getMeta() const
Retrieve meta data.
virtual void show(std::ostream &s, const double *x)
Print the solution.
This class represents 1D flow domains that satisfy the one-dimensional similarity solution for chemic...
void setLeftControlPointTemperature(double temperature)
Sets the temperature of the left control point.
void eval(size_t jGlobal, double *xGlobal, double *rsdGlobal, integer *diagGlobal, double rdt) override
Evaluate the residual functions for axisymmetric stagnation flow.
void setLeftControlPointCoordinate(double z_left)
Sets the coordinate of the left control point.
size_t m_kExcessLeft
Index of species with a large mass fraction at each boundary, for which the mass fraction may be calc...
void setMeta(const AnyMap &state) override
Retrieve meta data.
double m_zLeft
Location of the left control point when two-point control is enabled.
void setTransportModel(const string &trans)
Set the transport model.
void setRightControlPointCoordinate(double z_right)
Sets the coordinate of the right control point.
void setTransport(shared_ptr< Transport > trans) override
Set transport model to existing instance.
void setKinetics(shared_ptr< Kinetics > kin) override
Set the kinetics manager.
void resetBadValues(double *xg) override
When called, this function should reset "bad" values in the state vector such as negative species con...
bool twoPointControlEnabled() const
Returns the status of the two-point control.
size_t rightExcessSpecies() const
Index of the species on the right boundary with the largest mass fraction.
vector< double > m_qdotRadiation
radiative heat loss vector
virtual void evalMomentum(double *x, double *rsd, int *diag, double rdt, size_t jmin, size_t jmax)
Evaluate the momentum equation residual.
void updateThermo(const double *x, size_t j0, size_t j1)
Update the thermodynamic properties from point j0 to point j1 (inclusive), based on solution x.
double m_tLeft
Temperature of the left control point when two-point control is enabled.
void setRightControlPointTemperature(double temperature)
Sets the temperature of the right control point.
void resize(size_t components, size_t points) override
Change the grid size. Called after grid refinement.
virtual void evalContinuity(double *x, double *rsd, int *diag, double rdt, size_t jmin, size_t jmax)
Evaluate the continuity equation residual.
vector< double > m_cp
Vector of size m_nsp to cache specific heat capacities.
void enableTwoPointControl(bool twoPointControl)
Sets the status of the two-point control.
double m_tRight
Temperature of the right control point when two-point control is enabled.
void setBoundaryEmissivities(double e_left, double e_right)
Set the emissivities for the boundary values.
void setFluxGradientBasis(ThermoBasis fluxGradientBasis)
Compute species diffusive fluxes with respect to their mass fraction gradients (fluxGradientBasis = T...
virtual void evalEnergy(double *x, double *rsd, int *diag, double rdt, size_t jmin, size_t jmax)
Evaluate the energy equation residual.
vector< double > m_rho
Vector of size m_nsp to cache densities.
Flow1D(ThermoPhase *ph=0, size_t nsp=1, size_t points=1)
Create a new flow domain.
vector< double > m_diff
Array of size m_nsp by m_points for saving density times diffusion coefficient times species molar ma...
shared_ptr< SolutionArray > asArray(const double *soln) const override
Save the state of this domain as a SolutionArray.
size_t componentIndex(const string &name) const override
index of component with name name.
void setGas(const double *x, size_t j)
Set the gas object state to be consistent with the solution at point j.
ThermoBasis fluxGradientBasis() const
Compute species diffusive fluxes with respect to their mass fraction gradients (fluxGradientBasis = T...
double Uo(const double *x, size_t j) const
Solution component for oxidizer velocity,.
double m_tfixed
Temperature at the point used to fix the flame location.
virtual bool componentActive(size_t n) const
Returns true if the specified component is an active part of the solver state.
Array2D m_wdot
Array of size m_nsp by m_points for saving species production rates.
Array2D m_hk
Array of size m_nsp by m_points for saving molar enthalpies.
virtual bool doElectricField(size_t j) const
Retrieve flag indicating whether electric field is solved or not (used by IonFlow specialization)
virtual void evalSpecies(double *x, double *rsd, int *diag, double rdt, size_t jmin, size_t jmax)
Evaluate the species equations' residuals.
void setupGrid(size_t n, const double *z) override
called to set up initial grid, and after grid refinement
size_t leftExcessSpecies() const
Index of the species on the left boundary with the largest mass fraction.
Array2D m_dhk_dz
Array of size m_nsp by m_points-1 for saving enthalpy fluxes.
virtual void evalElectricField(double *x, double *rsd, int *diag, double rdt, size_t jmin, size_t jmax)
Evaluate the electric field equation residual to be zero everywhere.
vector< double > m_wtm
Vector of size m_nsp to cache mean molecular weights.
bool m_twoPointControl
Flag for activating two-point flame control.
double m_zfixed
Location of the point where temperature is fixed.
void _finalize(const double *x) override
In some cases, a domain may need to set parameters that depend on the initial solution estimate.
virtual size_t getSolvingStage() const
Get the solving stage (used by IonFlow specialization)
size_t m_nsp
Number of species in the mechanism.
virtual void evalLambda(double *x, double *rsd, int *diag, double rdt, size_t jmin, size_t jmax)
Evaluate the lambda equation residual.
void fromArray(SolutionArray &arr, double *soln) override
Restore the solution for this domain from a SolutionArray.
double leftControlPointCoordinate() const
Returns the z-coordinate of the left control point.
AnyMap getMeta() const override
Retrieve meta data.
virtual void updateDiffFluxes(const double *x, size_t j0, size_t j1)
Update the diffusive mass fluxes.
double leftControlPointTemperature() const
Returns the temperature at the left control point.
string componentName(size_t n) const override
Name of the nth component. May be overloaded.
void setGasAtMidpoint(const double *x, size_t j)
Set the gas state to be consistent with the solution at the midpoint between j and j + 1.
virtual void grad_hk(const double *x, size_t j)
Get the gradient of species specific molar enthalpies.
bool isStrained() const
Retrieve flag indicating whether flow uses radial momentum.
string transportModel() const
Retrieve transport model.
double rightControlPointCoordinate() const
Returns the z-coordinate of the right control point.
void computeRadiation(double *x, size_t jmin, size_t jmax)
Computes the radiative heat loss vector over points jmin to jmax and stores the data in the qdotRadia...
virtual void updateProperties(size_t jg, double *x, size_t jmin, size_t jmax)
Update the properties (thermo, transport, and diffusion flux).
virtual void evalUo(double *x, double *rsd, int *diag, double rdt, size_t jmin, size_t jmax)
Evaluate the oxidizer axial velocity equation residual.
string domainType() const override
Domain type flag.
void show(const double *x) override
Print the solution.
virtual void setSolvingStage(const size_t stage)
Solving stage mode for handling ionized species (used by IonFlow specialization)
void setPressure(double p)
Set the pressure.
virtual void fixElectricField(size_t j=npos)
Set to fix voltage in a point (used by IonFlow specialization)
virtual void updateTransport(double *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.
double m_zRight
Location of the right control point when two-point control is enabled.
virtual void solveElectricField(size_t j=npos)
Set to solve electric field in a point (used by IonFlow specialization)
void _getInitialSoln(double *x) override
Write the initial solution estimate into array x.
vector< size_t > m_kRadiating
Indices within the ThermoPhase of the radiating species.
double rightControlPointTemperature() const
Returns the temperature at the right control point.
double T_fixed(size_t j) const
The fixed temperature value at point j.
bool m_do_radiation
flag for the radiative heat loss
An error indicating that an unimplemented function has been called.
size_t nSpecies() const
Returns the number of species in the phase.
virtual void setMassFractions_NoNorm(const double *const y)
Set the mass fractions to the specified values without normalizing.
double temperature() const
Temperature (K).
virtual void setPressure(double p)
Set the internally stored pressure (Pa) at constant temperature and composition.
double meanMolecularWeight() const
The mean molecular weight. Units: (kg/kmol)
string speciesName(size_t k) const
Name of the species with index k.
const vector< double > & molecularWeights() const
Return a const reference to the internal vector of molecular weights.
size_t speciesIndex(const string &name) const
Returns the index of a species named 'name' within the Phase object.
virtual double density() const
Density (kg/m^3).
virtual void setTemperature(double temp)
Set the internally stored temperature of the phase (K).
virtual void setMassFractions(const double *const y)
Set the mass fractions to the specified values and normalize them.
void getMassFractions(double *const y) const
Get the species mass fractions.
virtual double pressure() const
Return the thermodynamic pressure (Pa).
string name() const
Return the name of the phase.
A container class holding arrays of state information.
void setLoc(int loc, bool restore=true)
Update the buffered location used to access SolutionArray entries.
AnyValue getComponent(const string &name) const
Retrieve a component of the SolutionArray by name.
bool hasComponent(const string &name) const
Check whether SolutionArray contains a component.
AnyMap & meta()
SolutionArray meta data.
shared_ptr< ThermoPhase > thermo()
Retrieve associated ThermoPhase object.
static shared_ptr< SolutionArray > create(const shared_ptr< Solution > &sol, int size=0, const AnyMap &meta={})
Instantiate a new SolutionArray reference.
static shared_ptr< Solution > create()
Create an empty Solution object.
Base class for a phase with thermodynamic properties.
virtual double maxTemp(size_t k=npos) const
Maximum temperature for which the thermodynamic data for the species are valid.
const AnyMap & input() const
Access input data associated with the phase description.
virtual void getThermalDiffCoeffs(double *const dt)
Return a vector of Thermal diffusion coefficients [kg/m/sec].
virtual string transportModel() const
Identifies the model represented by this Transport object.
virtual void getMixDiffCoeffs(double *const d)
Returns a vector of mixture averaged diffusion coefficients.
virtual double thermalConductivity()
Returns the mixture thermal conductivity in W/m/K.
virtual void getMixDiffCoeffsMass(double *const d)
Returns a vector of mixture averaged diffusion coefficients.
virtual double viscosity()
The viscosity in Pa-s.
virtual void getMultiDiffCoeffs(const size_t ld, double *const d)
Return the Multicomponent diffusion coefficients. Units: [m^2/s].
Header for a file containing miscellaneous numerical functions.
This file contains definitions for utility functions and text for modules, inputfiles and logging,...
void writelog(const string &fmt, const Args &... args)
Write a formatted message to the screen.
double linearInterp(double x, const vector< double > &xpts, const vector< double > &fpts)
Linearly interpolate a function defined on a discrete grid.
const double OneAtm
One atmosphere [Pa].
const double StefanBoltz
Stefan-Boltzmann constant [W/m2/K4].
void warn_user(const string &method, const string &msg, const Args &... args)
Print a user warning raised from method as CanteraWarning.
Namespace for the Cantera kernel.
const size_t npos
index returned by functions to indicate "no position"
const double Undef
Fairly random number to be used to initialize variables against to see if they are subsequently defin...
@ c_offset_U
axial velocity [m/s]
@ c_offset_E
electric field
@ c_offset_Y
mass fractions
@ c_offset_Uo
oxidizer axial velocity [m/s]
@ c_offset_T
temperature [kelvin]
ThermoBasis
Differentiate between mole fractions and mass fractions for input mixture composition.