7#include "cantera/oneD/refine.h"
30 m_do_multicomponent(false),
31 m_do_radiation(false),
37 if (ph->
type() ==
"IdealGas") {
41 "Unsupported phase type: need 'IdealGasPhase'");
62 m_nv = c_offset_Y + m_nsp;
65 m_do_species.resize(m_nsp,
true);
68 m_do_energy.resize(m_points,
false);
70 m_diff.resize(m_nsp*m_points);
71 m_multidiff.resize(m_nsp*m_nsp*m_points);
72 m_flux.
resize(m_nsp,m_points);
73 m_wdot.
resize(m_nsp,m_points, 0.0);
78 setBounds(0, -1e20, 1e20);
79 setBounds(1, -1e20, 1e20);
80 setBounds(2, 200.0, 2*m_thermo->
maxTemp());
81 setBounds(3, -1e20, 1e20);
82 setBounds(c_offset_E, -1e20, 1e20);
85 for (
size_t k = 0; k < m_nsp; k++) {
86 setBounds(c_offset_Y+k, -1.0e-7, 1.0e5);
90 m_refiner->setActive(c_offset_U,
false);
91 m_refiner->setActive(c_offset_V,
false);
92 m_refiner->setActive(c_offset_T,
false);
93 m_refiner->setActive(c_offset_L,
false);
96 for (
size_t ng = 0; ng < m_points; ng++) {
97 gr.push_back(1.0*ng/m_points);
110 m_rho.resize(m_points, 0.0);
111 m_wtm.resize(m_points, 0.0);
112 m_cp.resize(m_points, 0.0);
113 m_visc.resize(m_points, 0.0);
114 m_tcon.resize(m_points, 0.0);
116 m_diff.resize(m_nsp*m_points);
117 if (m_do_multicomponent) {
118 m_multidiff.resize(m_nsp*m_nsp*m_points);
119 m_dthermal.
resize(m_nsp, m_points, 0.0);
121 m_flux.
resize(m_nsp,m_points);
122 m_wdot.
resize(m_nsp,m_points, 0.0);
123 m_do_energy.resize(m_points,
false);
125 m_fixedtemp.resize(m_points);
127 m_dz.resize(m_points-1);
128 m_z.resize(m_points);
136 for (
size_t j = 1; j < m_points; j++) {
137 if (z[j] <= z[j-1]) {
139 "grid points must be monotonically increasing");
142 m_dz[j-1] = m_z[j] - m_z[j-1];
148 double* x = xg +
loc();
149 for (
size_t j = 0; j < m_points; j++) {
150 double* Y = x + m_nv*j + c_offset_Y;
161 m_diff.resize(m_nsp*m_points);
162 if (m_do_multicomponent) {
163 m_multidiff.resize(m_nsp*m_nsp*m_points);
164 m_dthermal.
resize(m_nsp, m_points, 0.0);
170 for (
size_t j = 0; j < m_points; j++) {
179 const doublereal* yy = x + m_nv*j + c_offset_Y;
187 const doublereal* yyj = x + m_nv*j + c_offset_Y;
188 const doublereal* yyjp = x + m_nv*(j+1) + c_offset_Y;
189 for (
size_t k = 0; k < m_nsp; k++) {
190 m_ybar[k] = 0.5*(yyj[k] + yyjp[k]);
198 if (!m_do_multicomponent && m_do_soret) {
200 "Thermal diffusion (the Soret effect) is enabled, and requires "
201 "using a multicomponent transport model.");
204 size_t nz = m_zfix.size();
205 bool e = m_do_energy[0];
206 for (
size_t j = 0; j < m_points; j++) {
208 m_fixedtemp[j] = T(x, j);
210 double zz = (z(j) - z(0))/(z(m_points - 1) - z(0));
224 for (
size_t j = 0; j < m_points; j++) {
230 for (
size_t j = 0; j < m_points - 1; j++) {
244 doublereal* rg, integer* diagg, doublereal rdt)
253 doublereal* x = xg +
loc();
254 doublereal* rsd = rg +
loc();
255 integer* diag = diagg +
loc();
262 size_t jpt = (jg == 0) ? 0 : jg -
firstPoint();
263 jmin = std::max<size_t>(jpt, 1) - 1;
264 jmax = std::min(jpt+1,m_points-1);
274 size_t j0 = std::max<size_t>(jmin, 1) - 1;
275 size_t j1 = std::min(jmax+1,m_points-1);
278 if (jg ==
npos || m_force_full_update) {
284 double* Yleft = x + index(c_offset_Y, jmin);
285 m_kExcessLeft = distance(Yleft, max_element(Yleft, Yleft + m_nsp));
286 double* Yright = x + index(c_offset_Y, jmax);
287 m_kExcessRight = distance(Yright, max_element(Yright, Yright + m_nsp));
296 double rdt,
size_t jmin,
size_t jmax)
321 doublereal k_P_ref = 1.0*
OneAtm;
324 const doublereal c_H2O[6] = {-0.23093, -1.12390, 9.41530, -2.99880,
325 0.51382, -1.86840e-5};
326 const doublereal c_CO2[6] = {18.741, -121.310, 273.500, -194.050,
330 double boundary_Rad_left = m_epsilon_left *
StefanBoltz * pow(T(x, 0), 4);
331 double boundary_Rad_right = m_epsilon_right *
StefanBoltz * pow(T(x, m_points - 1), 4);
334 for (
size_t j = jmin; j < jmax; j++) {
336 double radiative_heat_loss = 0;
343 for (
size_t n = 0; n <= 5; n++) {
344 k_P_H2O += c_H2O[n] * pow(1000 / T(x, j), (
double) n);
352 for (
size_t n = 0; n <= 5; n++) {
353 k_P_CO2 += c_CO2[n] * pow(1000 / T(x, j), (
double) n);
360 radiative_heat_loss = 2 * k_P *(2 *
StefanBoltz * pow(T(x, j), 4)
361 - boundary_Rad_left - boundary_Rad_right);
368 for (
size_t j = jmin; j <= jmax; j++) {
379 rsd[index(c_offset_U,0)] =
380 -(rho_u(x,1) - rho_u(x,0))/m_dz[0]
381 -(density(1)*V(x,1) + density(0)*V(x,0));
387 rsd[index(c_offset_V,0)] = V(x,0);
389 rsd[index(c_offset_T,0)] = T(x,0);
391 rsd[index(c_offset_T,0)] = T(x,0) -
T_fixed(0);
393 rsd[index(c_offset_L,0)] = -rho_u(x,0);
398 for (
size_t k = 0; k < m_nsp; k++) {
400 rsd[index(c_offset_Y + k, 0)] =
401 -(m_flux(k,0) + rho_u(x,0)* Y(x,k,0));
406 rsd[index(c_offset_E, 0)] = x[index(c_offset_E, j)];
407 }
else if (j == m_points - 1) {
410 rsd[index(c_offset_E, j)] = x[index(c_offset_E, j)];
414 rsd[index(c_offset_E, j)] = x[index(c_offset_E, j)];
422 rsd[index(c_offset_V,j)]
423 = (shear(x,j) - lambda(x,j) - rho_u(x,j)*dVdz(x,j)
424 - m_rho[j]*V(x,j)*V(x,j))/m_rho[j]
425 - rdt*(V(x,j) - V_prev(j));
426 diag[index(c_offset_V, j)] = 1;
435 for (
size_t k = 0; k < m_nsp; k++) {
436 double convec = rho_u(x,j)*dYdz(x,k,j);
437 double diffus = 2.0*(m_flux(k,j) - m_flux(k,j-1))
439 rsd[index(c_offset_Y + k, j)]
440 = (m_wt[k]*(wdot(k,j))
441 - convec - diffus)/m_rho[j]
442 - rdt*(Y(x,k,j) - Y_prev(k,j));
443 diag[index(c_offset_Y + k, j)] = 1;
454 if (m_do_energy[j]) {
462 for (
size_t k = 0; k < m_nsp; k++) {
463 double flxk = 0.5*(m_flux(k,j-1) + m_flux(k,j));
464 sum += wdot(k,j)*h_RT[k];
465 sum2 += flxk*cp_R[k]/m_wt[k];
468 double dtdzj = dTdz(x,j);
471 rsd[index(c_offset_T, j)] = - m_cp[j]*rho_u(x,j)*dtdzj
472 - divHeatFlux(x,j) - sum - sum2;
473 rsd[index(c_offset_T, j)] /= (m_rho[j]*m_cp[j]);
474 rsd[index(c_offset_T, j)] -= rdt*(T(x,j) - T_prev(j));
475 rsd[index(c_offset_T, j)] -= (
m_qdotRadiation[j] / (m_rho[j] * m_cp[j]));
476 diag[index(c_offset_T, j)] = 1;
479 rsd[index(c_offset_T, j)] = T(x,j) -
T_fixed(j);
480 diag[index(c_offset_T, j)] = 0;
483 rsd[index(c_offset_L, j)] = lambda(x,j) - lambda(x,j-1);
484 diag[index(c_offset_L, j)] = 0;
491 if (m_do_multicomponent) {
492 for (
size_t j = j0; j < j1; j++) {
495 doublereal rho = m_thermo->
density();
496 m_visc[j] = (m_dovisc ? m_trans->
viscosity() : 0.0);
500 for (
size_t k = 0; k < m_nsp; k++) {
501 m_diff[k+j*m_nsp] = m_wt[k] * rho / (wtm*wtm);
510 for (
size_t j = j0; j < j1; j++) {
512 m_visc[j] = (m_dovisc ? m_trans->
viscosity() : 0.0);
521 writelog(
" Pressure: {:10.4g} Pa\n", m_press);
526 writeline(
'-', 79,
false,
true);
527 writelog(
"\n z radiative heat loss");
528 writeline(
'-', 79,
false,
true);
529 for (
size_t j = 0; j < m_points; j++) {
538 if (m_do_multicomponent) {
539 for (
size_t j = j0; j < j1; j++) {
540 double dz = z(j+1) - z(j);
541 for (
size_t k = 0; k < m_nsp; k++) {
542 doublereal sum = 0.0;
543 for (
size_t m = 0; m < m_nsp; m++) {
544 sum += m_wt[m] * m_multidiff[mindex(k,m,j)] * (X(x,m,j+1)-X(x,m,j));
546 m_flux(k,j) = sum * m_diff[k+j*m_nsp] / dz;
550 for (
size_t j = j0; j < j1; j++) {
552 double wtm = m_wtm[j];
553 double rho = density(j);
554 double dz = z(j+1) - z(j);
555 for (
size_t k = 0; k < m_nsp; k++) {
556 m_flux(k,j) = m_wt[k]*(rho*m_diff[k+m_nsp*j]/wtm);
557 m_flux(k,j) *= (X(x,k,j) - X(x,k,j+1))/dz;
561 for (
size_t k = 0; k < m_nsp; k++) {
562 m_flux(k,j) += sum*Y(x,k,j);
568 for (
size_t m = j0; m < j1; m++) {
569 double gradlogT = 2.0 * (T(x,m+1) - T(x,m)) /
570 ((T(x,m+1) + T(x,m)) * (z(m+1) - z(m)));
571 for (
size_t k = 0; k < m_nsp; k++) {
572 m_flux(k,m) -= m_dthermal(k,m)*gradlogT;
584 return "spread_rate";
592 if (n >= c_offset_Y && n < (c_offset_Y + m_nsp)) {
602 if (name==
"velocity") {
604 }
else if (name==
"spread_rate") {
606 }
else if (name==
"T") {
608 }
else if (name==
"lambda") {
610 }
else if (name ==
"eField") {
613 for (
size_t n=c_offset_Y; n<m_nsp+c_offset_Y; n++) {
619 "no component named " + name);
627 return m_type != cFreeFlow;
629 return m_type != cFreeFlow;
640 vector<string> ignored;
645 for (
size_t istr = 0; istr < str.size(); istr++) {
650 double pp =
getFloat(dom,
"pressure",
"pressure");
655 bool readgrid =
false, wrote_header =
false;
656 for (
size_t n = 0; n < d.size(); n++) {
658 string nm = fa[
"title"];
663 writelog(
"Grid contains {} points.\n", np);
671 "domain contains no grid points.");
674 debuglog(
"Importing datasets:\n", loglevel >= 2);
675 for (
size_t n = 0; n < d.size(); n++) {
677 string nm = fa[
"title"];
680 debuglog(
"axial velocity ", loglevel >= 2);
681 if (x.size() != np) {
683 "axial velocity array size error");
685 for (
size_t j = 0; j < np; j++) {
686 soln[index(c_offset_U,j)] = x[j];
688 }
else if (nm ==
"z") {
690 }
else if (nm ==
"V") {
691 debuglog(
"radial velocity ", loglevel >= 2);
692 if (x.size() != np) {
694 "radial velocity array size error");
696 for (
size_t j = 0; j < np; j++) {
697 soln[index(c_offset_V,j)] = x[j];
699 }
else if (nm ==
"T") {
700 debuglog(
"temperature ", loglevel >= 2);
701 if (x.size() != np) {
703 "temperature array size error");
705 for (
size_t j = 0; j < np; j++) {
706 soln[index(c_offset_T,j)] = x[j];
713 for (
size_t jj = 0; jj < np; jj++) {
714 zz[jj] = (grid(jj) - zmin())/(zmax() - zmin());
717 }
else if (nm ==
"L") {
719 if (x.size() != np) {
721 "lambda array size error");
723 for (
size_t j = 0; j < np; j++) {
724 soln[index(c_offset_L,j)] = x[j];
728 if (x.size() == np) {
731 for (
size_t j = 0; j < np; j++) {
732 soln[index(k+c_offset_Y,j)] = x[j];
736 ignored.push_back(nm);
740 if (loglevel >=2 && !ignored.empty()) {
743 size_t nn = ignored.size();
744 for (
size_t n = 0; n < nn; n++) {
750 for (
size_t ks = 0; ks < nsp; ks++) {
751 if (did_species[ks] == 0) {
753 writelog(
"Missing data for species:\n");
761 if (dom.
hasChild(
"energy_enabled")) {
764 for (
size_t i = 0; i < x.size(); i++) {
765 m_do_energy[i] = (x[i] != 0);
767 }
else if (!x.empty()) {
768 throw CanteraError(
"StFlow::restore",
"energy_enabled is length {}"
769 "but should be length {}", x.size(),
nPoints());
773 if (dom.
hasChild(
"species_enabled")) {
775 if (x.size() == m_nsp) {
776 for (
size_t i = 0; i < x.size(); i++) {
777 m_do_species[i] = (x[i] != 0);
779 }
else if (!x.empty()) {
783 warn_user(
"StFlow::restore",
"species_enabled is "
784 "length {} but should be length {}. Enabling all species "
785 "equations by default.", x.size(), m_nsp);
787 m_do_species.assign(m_nsp,
true);
791 if (dom.
hasChild(
"refine_criteria")) {
810 XML_Node& gv = flow.addChild(
"grid_data");
811 addFloat(flow,
"pressure", m_press,
"Pa",
"pressure");
817 soln.
getRow(c_offset_U, x.data());
820 soln.
getRow(c_offset_V, x.data());
823 soln.
getRow(c_offset_T, x.data());
826 soln.
getRow(c_offset_L, x.data());
829 for (
size_t k = 0; k < m_nsp; k++) {
830 soln.
getRow(c_offset_Y+k, x.data());
832 x.size(),x.data(),
"",
"massFraction");
839 for (
size_t i = 0; i <
nPoints(); i++) {
840 values[i] = m_do_energy[i];
844 values.resize(m_nsp);
845 for (
size_t i = 0; i < m_nsp; i++) {
846 values[i] = m_do_species[i];
850 XML_Node& ref = flow.addChild(
"refine_criteria");
867 state[
"pressure"] = m_press;
869 state[
"phase"][
"name"] = m_thermo->
name();
871 state[
"phase"][
"source"] = source.
empty() ?
"<unknown>" : source.
asString();
876 state[
"emissivity-left"] = m_epsilon_left;
877 state[
"emissivity-right"] = m_epsilon_right;
880 std::set<bool> energy_flags(m_do_energy.begin(), m_do_energy.end());
881 if (energy_flags.size() == 1) {
882 state[
"energy-enabled"] = m_do_energy[0];
884 state[
"energy-enabled"] = m_do_energy;
887 state[
"Soret-enabled"] = m_do_soret;
889 std::set<bool> species_flags(m_do_species.begin(), m_do_species.end());
890 if (species_flags.size() == 1) {
891 state[
"species-enabled"] = m_do_species[0];
893 for (
size_t k = 0; k < m_nsp; k++) {
894 state[
"species-enabled"][m_thermo->
speciesName(k)] = m_do_species[k];
898 state[
"refine-criteria"][
"ratio"] = m_refiner->maxRatio();
899 state[
"refine-criteria"][
"slope"] = m_refiner->maxDelta();
900 state[
"refine-criteria"][
"curve"] = m_refiner->maxSlope();
901 state[
"refine-criteria"][
"prune"] = m_refiner->prune();
902 state[
"refine-criteria"][
"grid-min"] = m_refiner->gridMin();
903 state[
"refine-criteria"][
"max-points"] =
904 static_cast<long int>(m_refiner->maxPoints());
907 state[
"fixed-point"][
"location"] =
m_zfixed;
908 state[
"fixed-point"][
"temperature"] =
m_tfixed;
915 for (
size_t j = 0; j <
nPoints(); j++) {
916 data[j] = soln[index(i,j)];
928 m_press = state[
"pressure"].asDouble();
938 for (
size_t j = 0; j <
nPoints(); j++) {
939 soln[index(i,j)] = data[j];
941 }
else if (loglevel) {
942 warn_user(
"StFlow::restore",
"Saved state does not contain values for "
943 "component '{}' in domain '{}'.", name,
id());
947 if (state.
hasKey(
"energy-enabled")) {
948 const AnyValue& ee = state[
"energy-enabled"];
956 if (state.
hasKey(
"Soret-enabled")) {
957 m_do_soret = state[
"Soret-enabled"].asBool();
960 if (state.
hasKey(
"species-enabled")) {
961 const AnyValue& se = state[
"species-enabled"];
969 if (state.
hasKey(
"radiation-enabled")) {
972 m_epsilon_left = state[
"emissivity-left"].asDouble();
973 m_epsilon_right = state[
"emissivity-right"].asDouble();
977 if (state.
hasKey(
"refine-criteria")) {
978 const AnyMap& criteria = state[
"refine-criteria"].as<
AnyMap>();
979 double ratio = criteria.
getDouble(
"ratio", m_refiner->maxRatio());
980 double slope = criteria.
getDouble(
"slope", m_refiner->maxDelta());
981 double curve = criteria.
getDouble(
"curve", m_refiner->maxSlope());
982 double prune = criteria.
getDouble(
"prune", m_refiner->prune());
983 m_refiner->setCriteria(ratio, slope, curve, prune);
985 if (criteria.
hasKey(
"grid-min")) {
986 m_refiner->setGridMin(criteria[
"grid-min"].asDouble());
988 if (criteria.
hasKey(
"max-points")) {
989 m_refiner->setMaxPoints(criteria[
"max-points"].asInt());
993 if (state.
hasKey(
"fixed-point")) {
994 m_zfixed = state[
"fixed-point"][
"location"].asDouble();
995 m_tfixed = state[
"fixed-point"][
"temperature"].asDouble();
999void StFlow::solveEnergyEqn(
size_t j)
1001 bool changed =
false;
1003 for (
size_t i = 0; i < m_points; i++) {
1004 if (!m_do_energy[i]) {
1007 m_do_energy[i] =
true;
1010 if (!m_do_energy[j]) {
1013 m_do_energy[j] =
true;
1015 m_refiner->setActive(c_offset_U,
true);
1016 m_refiner->setActive(c_offset_V,
true);
1017 m_refiner->setActive(c_offset_T,
true);
1025 if (e_left < 0 || e_left > 1) {
1027 "The left boundary emissivity must be between 0.0 and 1.0!");
1028 }
else if (e_right < 0 || e_right > 1) {
1030 "The right boundary emissivity must be between 0.0 and 1.0!");
1032 m_epsilon_left = e_left;
1033 m_epsilon_right = e_right;
1037void StFlow::fixTemperature(
size_t j)
1039 bool changed =
false;
1041 for (
size_t i = 0; i < m_points; i++) {
1042 if (m_do_energy[i]) {
1045 m_do_energy[i] =
false;
1048 if (m_do_energy[j]) {
1051 m_do_energy[j] =
false;
1053 m_refiner->setActive(c_offset_U,
false);
1054 m_refiner->setActive(c_offset_V,
false);
1055 m_refiner->setActive(c_offset_T,
false);
1063 size_t j = m_points - 1;
1069 rsd[index(c_offset_V,j)] = V(x,j);
1070 doublereal sum = 0.0;
1071 rsd[index(c_offset_L, j)] = lambda(x,j) - lambda(x,j-1);
1072 diag[index(c_offset_L, j)] = 0;
1073 for (
size_t k = 0; k < m_nsp; k++) {
1075 rsd[index(k+c_offset_Y,j)] = m_flux(k,j-1) + rho_u(x,j)*Y(x,k,j);
1079 if (
domainType() == cAxisymmetricStagnationFlow) {
1080 rsd[index(c_offset_U,j)] = rho_u(x,j);
1081 if (m_do_energy[j]) {
1082 rsd[index(c_offset_T,j)] = T(x,j);
1084 rsd[index(c_offset_T, j)] = T(x,j) -
T_fixed(j);
1087 rsd[index(c_offset_U,j)] = rho_u(x,j) - rho_u(x,j-1);
1088 rsd[index(c_offset_T,j)] = T(x,j) - T(x,j-1);
1095 diag[index(c_offset_U, j)] = 0;
1101 if (
domainType() == cAxisymmetricStagnationFlow) {
1105 rsd[index(c_offset_U,j)] =
1106 -(rho_u(x,j+1) - rho_u(x,j))/m_dz[j]
1107 -(density(j+1)*V(x,j+1) + density(j)*V(x,j));
1110 rsd[index(c_offset_U,j)] =
1111 - (rho_u(x,j) - rho_u(x,j-1))/m_dz[j-1]
1112 - (density(j-1)*V(x,j-1) + density(j)*V(x,j));
1114 if (m_do_energy[j]) {
1115 rsd[index(c_offset_U,j)] = (T(x,j) -
m_tfixed);
1117 rsd[index(c_offset_U,j)] = (rho_u(x,j)
1121 rsd[index(c_offset_U,j)] =
1122 - (rho_u(x,j+1) - rho_u(x,j))/m_dz[j]
1123 - (density(j+1)*V(x,j+1) + density(j)*V(x,j));
Headers for the Transport object, which is the virtual base class for all transport property evaluato...
const AnyValue & getMetadata(const std::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 std::string &key, double default_) const
If key exists, return it as a double, otherwise return default_.
bool hasKey(const std::string &key) const
Returns true if the map contains an item named key.
A wrapper for a variable whose type is determined at runtime.
const std::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.
const std::vector< T > & asVector(size_t nMin=npos, size_t nMax=npos) const
Return the held value, if it is a vector of type T.
bool isScalar() const
Returns true if the held value is a scalar type (such as double, long int, string,...
A class for 2D arrays stored in column-major (Fortran-compatible) form.
doublereal * ptrColumn(size_t j)
Return a pointer to the top of column j, columns are contiguous in memory.
size_t nColumns() const
Number of columns.
void getRow(size_t n, double *const rw)
Get the nth row and return it in a vector.
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.
size_t nComponents() const
Number of components at each grid point.
virtual AnyMap serialize(const double *soln) const
Save the state of this domain as an AnyMap.
virtual void showSolution(const doublereal *x)
Print the solution.
size_t nPoints() const
Number of grid points in this domain.
virtual XML_Node & save(XML_Node &o, const doublereal *const sol)
Save the current solution for this domain into an XML_Node.
virtual void resize(size_t nv, size_t np)
Refiner & refiner()
Return a reference to the grid refiner.
virtual void restore(const XML_Node &dom, doublereal *soln, int loglevel)
Restore the solution for this domain from an XML_Node.
int domainType()
Domain type flag.
size_t firstPoint() const
The index of the first (that is, left-most) grid point belonging to this domain.
virtual size_t loc(size_t j=0) const
Location of the start of the local solution vector in the global solution vector,.
Class IdealGasPhase represents low-density gases that obey the ideal gas equation of state.
const vector_fp & cp_R_ref() const
Returns a reference to the dimensionless reference state Heat Capacity vector.
const vector_fp & enthalpy_RT_ref() const
Returns a reference to the dimensionless reference state enthalpy vector.
virtual void setPressure(doublereal p)
Set the pressure at constant temperature and composition.
std::string name() const
Return the name of the phase.
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.
const vector_fp & molecularWeights() const
Return a const reference to the internal vector of molecular weights.
std::string speciesName(size_t k) const
Name of the species with index k.
doublereal meanMolecularWeight() const
The mean molecular weight. Units: (kg/kmol)
virtual double density() const
Density (kg/m^3).
doublereal temperature() const
Temperature (K).
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.
size_t speciesIndex(const std::string &name) const
Returns the index of a species named 'name' within the Phase object.
void getMassFractions(double *const y) const
Get the species mass fractions.
void setCriteria(doublereal ratio=10.0, doublereal slope=0.8, doublereal curve=0.8, doublereal prune=-0.1)
Set grid refinement criteria.
void setGridMin(double gridmin)
Set the minimum allowable spacing between adjacent grid points [m].
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...
virtual AnyMap serialize(const double *soln) const
Save the state of this domain as an AnyMap.
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.
StFlow(ThermoPhase *ph=0, size_t nsp=1, size_t points=1)
Create a new flow domain.
void setBoundaryEmissivities(double e_left, double e_right)
Set the emissivities for the boundary values.
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)
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.
virtual bool componentActive(size_t n) const
Returns true if the specified component is an active part of the solver state.
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
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.
size_t leftExcessSpecies() const
Index of the species on the left boundary with the largest mass fraction.
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
virtual void resetBadValues(double *xg)
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() const
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
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.
virtual doublereal maxTemp(size_t k=npos) const
Maximum temperature for which the thermodynamic data for the species are valid.
virtual std::string type() const
String indicating the thermodynamic model implemented.
const AnyMap & input() const
Access input data associated with the phase description.
Base class for transport property managers.
virtual void getThermalDiffCoeffs(doublereal *const dt)
Return a vector of Thermal diffusion coefficients [kg/m/sec].
virtual doublereal viscosity()
virtual std::string transportType() const
Identifies the Transport object type.
virtual void getMultiDiffCoeffs(const size_t ld, doublereal *const d)
Return the Multicomponent diffusion coefficients. Units: [m^2/s].
virtual doublereal thermalConductivity()
Returns the mixture thermal conductivity in W/m/K.
virtual void getMixDiffCoeffs(doublereal *const d)
Returns a vector of mixture averaged diffusion coefficients.
Class XML_Node is a tree-based representation of the contents of an XML file.
bool hasChild(const std::string &ch) const
Tests whether the current node has a child node with a particular name.
void addAttribute(const std::string &attrib, const std::string &value)
Add or modify an attribute of the current node.
std::vector< XML_Node * > getChildren(const std::string &name) const
Get a vector of pointers to XML_Node containing all of the children of the current node which match t...
std::string value() const
Return the value of an XML node as a string.
XML_Node & child(const size_t n) const
Return a changeable reference to the n'th child of the current node.
CTML ("Cantera Markup Language") is the variant of XML that Cantera uses to store data.
Header for a file containing miscellaneous numerical functions.
This file contains definitions for utility functions and text for modules, inputfiles,...
void writelog(const std::string &fmt, const Args &... args)
Write a formatted message to the screen.
Namespace for the Cantera kernel.
const size_t npos
index returned by functions to indicate "no position"
doublereal linearInterp(doublereal x, const vector_fp &xpts, const vector_fp &fpts)
Linearly interpolate a function defined on a discrete grid.
const double Undef
Fairly random number to be used to initialize variables against to see if they are subsequently defin...
doublereal getFloat(const XML_Node &parent, const std::string &name, const std::string &type="")
Get a floating-point value from a child element.
bool getOptionalFloat(const XML_Node &parent, const std::string &name, doublereal &fltRtn, const std::string &type="")
Get an optional floating-point value from a child element.
const double OneAtm
One atmosphere [Pa].
void addFloat(XML_Node &node, const std::string &titleString, const doublereal value, const std::string &unitsString="", const std::string &typeString="", const doublereal minval=Undef, const doublereal maxval=Undef)
This function adds a child node with the name, "float", with a value consisting of a single floating ...
void debuglog(const std::string &msg, int loglevel)
Write a message to the log only if loglevel > 0.
std::vector< int > vector_int
Vector of ints.
const double StefanBoltz
Stefan-Boltzmann constant [W/m2/K4].
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
const double GasConstant
Universal Gas Constant [J/kmol/K].
size_t getFloatArray(const XML_Node &node, vector_fp &v, const bool convert=true, const std::string &unitsString="", const std::string &nodeName="floatArray")
This function reads the current node or a child node of the current node with the default name,...
void warn_user(const std::string &method, const std::string &msg, const Args &... args)
Print a user warning raised from method as CanteraWarning.
void addFloatArray(XML_Node &node, const std::string &titleString, const size_t n, const doublereal *const values, const std::string &unitsString="", const std::string &typeString="", const doublereal minval=Undef, const doublereal maxval=Undef)
This function adds a child node with the name, "floatArray", with a value consisting of a comma separ...
void addNamedFloatArray(XML_Node &parentNode, const std::string &name, const size_t n, const doublereal *const vals, const std::string units="", const std::string type="", const doublereal minval=Undef, const doublereal maxval=Undef)
This function adds a child node with the name given by the first parameter with a value consisting of...