8#include "cantera/oneD/refine.h"
21const map<string, size_t> componentMap = {
34 , m_nsp(phase->thermo()->nSpecies())
35 , m_thermo(phase->thermo().get())
69 for (
size_t k = 0; k <
m_nsp; k++) {
81 for (
size_t ng = 0; ng <
m_points; ng++) {
98 "An appropriate transport model\nshould be set when instantiating the "
99 "Solution ('gas') object.");
101 m_solution->registerChangedCallback(
this, [
this]() {
119 return "axisymmetric-flow";
121 return "unstrained-flow";
133 throw CanteraError(
"Flow1D::_setTransport",
"Unable to set empty transport.");
137 throw CanteraError(
"Flow1D::_setTransport",
"Invalid Transport model 'none'.");
181 for (
size_t j = 1; j <
m_points; j++) {
182 if (
z[j] <=
z[j-1]) {
184 "grid points must be monotonically increasing");
193 span<double> x = xg.subspan(
loc(),
size());
194 for (
size_t j = 0; j <
m_points; j++) {
202 if (model ==
"none") {
204 "Invalid Transport model 'none'.");
218 warn_user(
"Flow1D::setFluxGradientBasis",
219 "Setting fluxGradientBasis only affects "
220 "the mixture-averaged diffusion model.");
226 for (
size_t j = 0; j <
m_points; j++) {
244 auto yy_j_plus1 =
Y(x, j+1);
245 for (
size_t k = 0; k <
m_nsp; k++) {
246 m_ybar[k] = 0.5*(yy_j[k] + yy_j_plus1[k]);
260 "Thermal diffusion (the Soret effect) is enabled, but it "
261 "only ompatible with the mixture-averaged and multicomponent "
262 "transport models.");
265 size_t nz =
m_zfix.size();
267 for (
size_t j = 0; j <
m_points; j++) {
285 for (
size_t j = 0; j <
m_points; j++) {
291 for (
size_t j = 0; j <
m_points - 1; j++) {
304void Flow1D::eval(
size_t jGlobal, span<const double> xGlobal, span<double> rsdGlobal,
305 span<int> diagGlobal,
double rdt)
314 span<const double> x = xGlobal.subspan(
loc(),
size());
315 span<double> rsd = rsdGlobal.subspan(
loc(),
size());
316 span<int> diag = diagGlobal.subspan(
loc(),
size());
319 if (jGlobal ==
npos) {
323 size_t jpt = (jGlobal == 0) ? 0 : jGlobal -
firstPoint();
324 jmin = std::max<size_t>(jpt, 1) - 1;
339 evalUo(x, rsd, diag, rdt, jmin, jmax);
346 size_t j0 = std::max<size_t>(jmin, 1) - 1;
347 size_t j1 = std::min(jmax+1,
m_points-1);
356 auto yLeft =
Y(x, jmin);
357 auto yRight =
Y(x, jmax);
358 m_kExcessLeft = distance(yLeft.begin(), ranges::max_element(yLeft));
359 m_kExcessRight = distance(yRight.begin(), ranges::max_element(yRight));
370 for (
size_t j = j0; j < j1; j++) {
379 for (
size_t k = 0; k <
m_nsp; k++) {
389 for (
size_t j = j0; j < j1; j++) {
403 for (
size_t k=0; k <
m_nsp; k++) {
407 for (
size_t k=0; k <
m_nsp; k++) {
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++) {
433 for (
size_t j = j0; j < j1; j++) {
435 double dz =
z(j+1) -
z(j);
437 for (
size_t k = 0; k <
m_nsp; k++) {
442 for (
size_t k = 0; k <
m_nsp; k++) {
448 for (
size_t k = 0; k <
m_nsp; k++) {
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++) {
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,
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)
533 size_t j0 = std::max<size_t>(jmin, 1);
534 size_t j1 = std::min(jmax,
m_points-2);
536 for (
size_t j = j0; j <= j1; j++) {
546 for (
size_t j = j0; j <= j1; j++) {
562 for (
size_t j = j0; j <= j1; j++) {
570 double rdt,
size_t jmin,
size_t jmax)
573 for (
size_t j = jmin; j <= jmax; j++) {
590 size_t j0 = std::max<size_t>(jmin, 1);
591 size_t j1 = std::min(jmax,
m_points-2);
592 for (
size_t j = j0; j <= j1; j++) {
606 double rdt,
size_t jmin,
size_t jmax)
609 for (
size_t j = jmin; j <= jmax; j++) {
630 size_t j0 = std::max<size_t>(jmin, 1);
631 size_t j1 = std::min(jmax,
m_points-2);
632 for (
size_t j = j0; j <= j1; j++) {
649 double rdt,
size_t jmin,
size_t jmax)
660 size_t j0 = std::max<size_t>(jmin, 1);
661 size_t j1 = std::min(jmax,
m_points-2);
662 for (
size_t j = j0; j <= j1; j++) {
666 for (
size_t k = 0; k <
m_nsp; k++) {
691 double rdt,
size_t jmin,
size_t jmax)
694 for (
size_t j = jmin; j <= jmax; j++) {
714 size_t j0 = std::max<size_t>(jmin, 1);
715 size_t j1 = std::min(jmax,
m_points-2);
716 for (
size_t j = j0; j <= j1; j++) {
731 double rdt,
size_t jmin,
size_t jmax)
735 for (
size_t k = 0; k <
m_nsp; k++) {
738 rho_u(x, jmin) *
Y(x, k, jmin));
746 for (
size_t k = 0; k <
m_nsp; k++) {
749 rho_u(x, jmax)*
Y(x, k, jmax);
756 size_t j0 = std::max<size_t>(jmin, 1);
757 size_t j1 = std::min(jmax,
m_points-2);
758 for (
size_t j = j0; j <= j1; j++) {
759 for (
size_t k = 0; k <
m_nsp; k++) {
760 double convec =
rho_u(x, j)*
dYdz(x, k, j);
761 double diffus = 2*(
m_flux(k, j) -
m_flux(k, j-1)) / (
z(j+1) -
z(j-1));
763 - convec - diffus) /
m_rho[j]
764 - rdt*(
Y(x, k, j) -
Y_prev(k, j));
771 double rdt,
size_t jmin,
size_t jmax)
773 for (
size_t j = jmin; j <= jmax; j++) {
786 writeline(
'-', 79,
false,
true);
787 writelog(
"\n z radiative heat loss");
788 writeline(
'-', 79,
false,
true);
789 for (
size_t j = 0; j <
m_points; j++) {
822 if (componentMap.count(name)) {
823 return componentMap.at(name);
832 if (aliasMap.count(name)) {
837 "Component '{}' not found", name);
842 if (componentMap.count(name)) {
878 state[
"phase"][
"source"] = source.
empty() ?
"<unknown>" : source.
asString();
887 if (energy_flags.size() == 1) {
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 "Domain needs to be installed in a container.");
930 "Domain does not have associated Solution object.");
933 m_solution->thermo()->setMassFractions_NoNorm(
942 "Domain needs to be installed in a container.");
950 "Flow1D::getValues",
"Component '{}' is not used by '{}'.",
954 for (
size_t j = 0; j <
nPoints(); j++) {
963 "Domain needs to be installed in a container.");
971 "Flow1D::setValues",
"Component '{}' is not used by '{}'.",
975 for (
size_t j = 0; j <
nPoints(); j++) {
984 "Domain needs to be installed in a container.");
992 "Flow1D::getResiduals",
"Component '{}' is not used by '{}'.",
996 for (
size_t j = 0; j <
nPoints(); j++) {
1002 span<const double> pos, span<const double> values)
1006 "Domain needs to be installed in a container.");
1008 if (pos.size() !=
values.size()) {
1010 "Flow1D::setProfile",
"Vectors for positions and values must have same "
1011 "size.\nSizes are {} and {}, respectively.", pos.size(),
values.size());
1013 if (pos.front() != 0.0 || pos.back() != 1.0) {
1015 "'pos' vector must span the range [0, 1]. Got a vector spanning "
1016 "[{}, {}] instead.", pos.front(), pos.back());
1021 "Flow1D::setProfile",
"Component '{}' is not used by '{}'.",
1026 double zDelta =
zmax() - z0;
1027 for (
size_t j = 0; j <
nPoints(); j++) {
1028 double frac = (
z(j) - z0)/zDelta;
1030 soln[
index(i,j)] = v;
1038 "Domain needs to be installed in a container.");
1043 "Flow1D::setFlatProfile",
"Component '{}' is not used by '{}'.",
1047 for (
size_t j = 0; j <
nPoints(); j++) {
1056 "Domain needs to be installed in a container before calling toArray.");
1061 arr->addExtra(
"grid",
false);
1064 arr->setComponent(
"grid",
value);
1065 vector<double> data(
nPoints());
1069 for (
size_t j = 0; j <
nPoints(); j++) {
1070 data[j] = soln[
index(i, j)];
1072 if (!arr->hasComponent(name)) {
1076 arr->setComponent(name,
value);
1081 arr->setComponent(
"D",
value);
1084 arr->addExtra(
"radiative-heat-loss",
true);
1086 arr->setComponent(
"radiative-heat-loss",
value);
1099 "Domain needs to be installed in a container before calling fromArray.");
1107 auto phase = arr->thermo();
1110 const auto grid = arr->getComponent(
"grid").as<vector<double>>();
1119 if (arr->hasComponent(name)) {
1120 const vector<double> data = arr->getComponent(name).as<vector<double>>();
1121 for (
size_t j = 0; j <
nPoints(); j++) {
1122 soln[
index(i,j)] = data[j];
1124 }
else if (name ==
"Lambda" && arr->hasComponent(
"lambda")) {
1126 const auto data = arr->getComponent(
"lambda").as<vector<double>>();
1127 for (
size_t j = 0; j <
nPoints(); j++) {
1128 soln[
index(i,j)] = data[j];
1131 warn_user(
"Flow1D::fromArray",
"Saved state does not contain values for "
1132 "component '{}' in domain '{}'.", name,
id());
1142 if (state.
hasKey(
"energy-enabled")) {
1143 const AnyValue& ee = state[
"energy-enabled"];
1151 if (state.
hasKey(
"transport-model")) {
1155 if (state.
hasKey(
"Soret-enabled")) {
1156 m_do_soret = state[
"Soret-enabled"].asBool();
1159 if (state.
hasKey(
"flux-gradient-basis")) {
1161 state[
"flux-gradient-basis"].asInt());
1164 if (state.
hasKey(
"radiation-enabled")) {
1172 if (state.
hasKey(
"refine-criteria")) {
1173 const AnyMap& criteria = state[
"refine-criteria"].as<
AnyMap>();
1178 m_refiner->setCriteria(ratio, slope, curve, prune);
1180 if (criteria.
hasKey(
"grid-min")) {
1181 m_refiner->setGridMin(criteria[
"grid-min"].asDouble());
1183 if (criteria.
hasKey(
"max-points")) {
1184 m_refiner->setMaxPoints(criteria[
"max-points"].asInt());
1188 if (state.
hasKey(
"fixed-point")) {
1189 m_zfixed = state[
"fixed-point"][
"location"].asDouble();
1190 m_tfixed = state[
"fixed-point"][
"temperature"].asDouble();
1194 if (state.
hasKey(
"continuation-method")) {
1195 const AnyMap& cm = state[
"continuation-method"].as<
AnyMap>();
1196 if (cm[
"type"] ==
"two-point") {
1198 m_zLeft = cm[
"left-location"].asDouble();
1199 m_zRight = cm[
"right-location"].asDouble();
1200 m_tLeft = cm[
"left-temperature"].asDouble();
1201 m_tRight = cm[
"right-temperature"].asDouble();
1203 warn_user(
"Flow1D::setMeta",
"Unknown continuation method '{}'.",
1204 cm[
"type"].asString());
1211 bool changed =
false;
1213 for (
size_t i = 0; i <
m_points; i++) {
1253 if (e_left < 0 || e_left > 1) {
1255 "The left boundary emissivity must be between 0.0 and 1.0!");
1256 }
else if (e_right < 0 || e_right > 1) {
1258 "The right boundary emissivity must be between 0.0 and 1.0!");
1267 bool changed =
false;
1269 for (
size_t i = 0; i <
m_points; i++) {
1291 size_t jloc = (
u(x, j) > 0.0 ? j : j + 1);
1292 for(
size_t k = 0; k <
m_nsp; k++) {
1304 throw CanteraError(
"Flow1D::leftControlPointTemperature",
1305 "Invalid operation: left control point location is not set");
1308 throw CanteraError(
"Flow1D::leftControlPointTemperature",
1309 "Invalid operation: two-point control is not enabled.");
1319 throw CanteraError(
"Flow1D::leftControlPointCoordinate",
1320 "Invalid operation: left control point location is not set");
1323 throw CanteraError(
"Flow1D::leftControlPointCoordinate",
1324 "Invalid operation: two-point control is not enabled.");
1334 throw CanteraError(
"Flow1D::setLeftControlPointTemperature",
1335 "Invalid operation: left control point location is not set");
1338 throw CanteraError(
"Flow1D::setLeftControlPointTemperature",
1339 "Invalid operation: two-point control is not enabled.");
1348 throw CanteraError(
"Flow1D::setLeftControlPointCoordinate",
1349 "Invalid operation: two-point control is not enabled.");
1359 throw CanteraError(
"Flow1D::rightControlPointTemperature",
1360 "Invalid operation: right control point location is not set");
1363 throw CanteraError(
"Flow1D::rightControlPointTemperature",
1364 "Invalid operation: two-point control is not enabled.");
1374 throw CanteraError(
"Flow1D::rightControlPointCoordinate",
1375 "Invalid operation: right control point location is not set");
1378 throw CanteraError(
"Flow1D::rightControlPointCoordinate",
1379 "Invalid operation: two-point control is not enabled.");
1389 throw CanteraError(
"Flow1D::setRightControlPointTemperature",
1390 "Invalid operation: right control point location is not set");
1393 throw CanteraError(
"Flow1D::setRightControlPointTemperature",
1394 "Invalid operation: two-point control is not enabled.");
1403 throw CanteraError(
"Flow1D::setRightControlPointCoordinate",
1404 "Invalid operation: two-point control is not enabled.");
1417 "Invalid operation: two-point control can only be used"
1418 "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.
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.
span< double > col(size_t j)
Return a writable span over column j.
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.
size_t m_iloc
Starting location within the solution vector for unknowns that correspond to this domain.
shared_ptr< Solution > m_solution
Composite thermo/kinetics/transport handler.
OneDim * m_container
Parent OneDim simulation containing this and adjacent domains.
size_t nComponents() const
Number of components at each grid point.
size_t size() const
Return the size of the solution vector (the product of m_nv and m_points).
virtual void setMeta(const AnyMap &meta)
Retrieve meta data.
string id() const
Returns the identifying tag for this domain.
double zmin() const
Get the coordinate [m] of the first (leftmost) grid point in this domain.
span< double > grid()
Access the array of grid coordinates [m].
size_t m_nv
Number of solution components.
size_t nPoints() const
Number of grid points in this domain.
bool m_force_full_update
see forceFullUpdate()
shared_ptr< vector< double > > m_state
data pointer shared from OneDim
vector< double > values(const string &component) const
Retrieve component values.
virtual void resize(size_t nv, size_t np)
Resize the domain to have nv components and np grid points.
double z(size_t jlocal) const
Get the coordinate [m] of the point with local index jlocal
double m_press
pressure [Pa]
virtual double value(const string &component) const
Set a single component value at a boundary.
vector< double > m_z
1D spatial grid coordinates
size_t m_points
Number of grid points.
virtual void show(span< const double > x)
Print the solution.
string m_id
Identity tag for the domain.
unique_ptr< Refiner > m_refiner
Refiner object used for placing grid points.
void setBounds(size_t n, double lower, double upper)
Set the upper and lower bounds for a solution component, n.
double zmax() const
Get the coordinate [m] of the last (rightmost) grid point in this domain.
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...
size_t index(size_t n, size_t j) const
Returns the index of the solution vector, which corresponds to component n at grid point j.
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.
void setLeftControlPointTemperature(double temperature)
Sets the temperature of the left control point.
virtual void updateDiffFluxes(span< const double > x, size_t j0, size_t j1)
Update the diffusive mass fluxes.
ThermoPhase * m_thermo
Phase object used for calculating thermodynamic properties.
void setLeftControlPointCoordinate(double z_left)
Sets the coordinate of the left control point.
vector< double > m_zfix
Relative coordinates used to specify a fixed temperature profile.
virtual void evalEnergy(span< const double > x, span< double > rsd, span< int > diag, double rdt, size_t jmin, size_t jmax)
Evaluate the energy equation residual.
double Lambda(span< const double > x, size_t j) const
Get the radial pressure gradient [N/m⁴] at point j from the local state vector x
double density(size_t j) const
Get the density [kg/m³] at point j
void setupGrid(span< const double > z) override
Set up initial grid.
size_t m_kExcessLeft
Index of species with a large mass fraction at the left boundary, for which the mass fraction may be ...
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 fixTemperature(size_t j=npos)
Specify that the the temperature should be held fixed at point j.
vector< double > m_tfix
Fixed temperature values at the relative coordinates specified in m_zfix.
void setRightControlPointCoordinate(double z_right)
Sets the coordinate of the right control point.
void eval(size_t jGlobal, span< const double > xGlobal, span< double > rsdGlobal, span< int > diagGlobal, double rdt) override
Evaluate the residual functions for axisymmetric stagnation flow.
ThermoPhase & phase()
Access the phase object used to compute thermodynamic properties for points in this domain.
double T_prev(size_t j) const
Get the temperature at point j from the previous time step.
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.
bool m_do_soret
true if the Soret diffusion term should be calculated.
Kinetics * m_kin
Kinetics object used for calculating species production rates.
vector< double > m_qdotRadiation
radiative heat loss vector
size_t componentIndex(const string &name, bool checkAlias=true) const override
Index of component with name name.
double Uo(span< const double > x, size_t j) const
Get the oxidizer inlet velocity [m/s] linked to point j from the local state vector 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.
virtual bool doElectricField() const
Retrieve flag indicating whether electric field is solved or not (used by IonFlow specialization)
bool hasComponent(const string &name, bool checkAlias=true) const override
Check whether the Domain contains a component.
double V(span< const double > x, size_t j) const
Get the spread rate (tangential velocity gradient) [1/s] at point j from the local state vector x.
virtual void updateProperties(size_t jg, span< const double > x, size_t jmin, size_t jmax)
Update the properties (thermo, transport, and diffusion flux).
void resize(size_t components, size_t points) override
Change the grid size. Called after grid refinement.
void setValues(const string &component, span< const double > values) override
Specify component values.
bool m_usesLambda
Flag that is true for counterflow configurations that use the pressure eigenvalue in the radial mome...
vector< double > m_fixedtemp
Fixed values of the temperature at each grid point that are used when solving with the energy equatio...
double conduction(span< const double > x, size_t j) const
Compute the conduction term from the energy equation using a central three-point differencing scheme.
virtual void evalLambda(span< const double > x, span< double > rsd, span< int > diag, double rdt, size_t jmin, size_t jmax)
Evaluate the radial pressure gradient equation residual.
vector< double > m_cp
Specific heat capacity at each grid point.
virtual void evalElectricField(span< const double > x, span< double > rsd, span< int > diag, double rdt, size_t jmin, size_t jmax)
Evaluate the electric field equation residual to be zero everywhere.
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.
ThermoBasis m_fluxGradientBasis
Determines whether diffusive fluxes are computed using gradients of mass fraction or mole fraction.
void setFluxGradientBasis(ThermoBasis fluxGradientBasis)
Compute species diffusive fluxes with respect to their mass fraction gradients (fluxGradientBasis = T...
shared_ptr< SolutionArray > toArray(bool normalize=false) override
Save the state of this domain to a SolutionArray.
void solveEnergyEqn(size_t j=npos)
Specify that the energy equation should be solved at point j.
void setGasAtMidpoint(span< 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 evalSpecies(span< const double > x, span< double > rsd, span< int > diag, double rdt, size_t jmin, size_t jmax)
Evaluate the species equations' residuals.
vector< double > m_rho
Density at each grid point.
double rho_u(span< const double > x, size_t j) const
Get the axial mass flux [kg/m²/s] at point j from the local state vector x.
void _setTransport(shared_ptr< Transport > trans) override
Update transport model to existing instance.
vector< bool > m_do_energy
For each point in the domain, true if energy equation is solved or false if temperature is held const...
double m_epsilon_right
Emissivity of the surface to the right of the domain.
vector< double > m_tcon
Thermal conductivity at each grid point [W/m/K].
vector< double > m_diff
Coefficient used in diffusion calculations for each species at each grid point.
double Y_prev(size_t k, size_t j) const
Get the mass fraction of species k at point j from the previous time step.
double Y(span< const double > x, size_t k, size_t j) const
Get the mass fraction of species k at point j from the local state vector x.
vector< double > m_dz
Grid spacing. Element j holds the value of z(j+1) - z(j).
double T(span< const double > x, size_t j) const
Get the temperature at point j from the local state vector x.
Array2D m_flux
Array of size m_nsp by m_points for saving diffusive mass fluxes.
double dTdz(span< const double > x, size_t j) const
Calculates the spatial derivative of temperature T with respect to z at point j using upwind differen...
ThermoBasis fluxGradientBasis() const
Compute species diffusive fluxes with respect to their mass fraction gradients (fluxGradientBasis = T...
vector< double > m_visc
Dynamic viscosity at each grid point [Pa∙s].
double dVdz(span< const double > x, size_t j) const
Calculates the spatial derivative of velocity V with respect to z at point j using upwind differencin...
double m_epsilon_left
Emissivity of the surface to the left of the domain.
Transport * m_trans
Transport object used for calculating transport properties.
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 computeRadiation(span< const 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...
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.
void _setKinetics(shared_ptr< Kinetics > kin) override
Update transport model to existing instance.
double dYdz(span< const double > x, size_t k, size_t j) const
Calculates the spatial derivative of the species mass fraction with respect to z for species k at po...
void getValues(const string &component, span< double > values) const override
Retrieve component values.
void fromArray(const shared_ptr< SolutionArray > &arr) override
Restore the solution for this domain from a SolutionArray.
virtual void updateTransport(span< const 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.
size_t mindex(size_t k, size_t j, size_t m)
Array access mapping for a 3D array stored in a 1D vector.
void updateState(size_t loc) override
Update state at given location to state of associated Solution object.
bool m_do_multicomponent
true if transport fluxes are computed using the multicomponent diffusion coefficients,...
double V_prev(size_t j) const
Get the spread rate [1/s] at point j from the previous time step.
vector< double > m_wt
Molecular weight of each species.
void show(span< const double > x) override
Print the solution.
virtual void evalMomentum(span< const double > x, span< double > rsd, span< int > diag, double rdt, size_t jmin, size_t jmax)
Evaluate the momentum equation residual.
size_t leftExcessSpecies() const
Index of the species on the left boundary with the largest mass fraction.
bool m_isFree
Flag that is true for freely propagating flames anchored by a temperature fixed point.
Array2D m_dhk_dz
Array of size m_nsp by m_points-1 for saving enthalpy fluxes.
vector< double > m_wtm
Mean molecular weight at each grid point.
vector< double > m_multidiff
Vector of size m_nsp × m_nsp × m_points for saving multicomponent diffusion coefficients.
bool m_twoPointControl
Flag for activating two-point flame control.
double m_zfixed
Location of the point where temperature is fixed.
size_t m_nsp
Number of species in the mechanism.
virtual void evalContinuity(span< const double > x, span< double > rsd, span< int > diag, double rdt, size_t jmin, size_t jmax)
Evaluate the continuity equation residual.
double u(span< const double > x, size_t j) const
Get the axial velocity [m/s] at point j from the local state vector x.
void setProfile(const string &component, span< const double > pos, span< const double > values) override
Specify a profile for a component.
void getResiduals(const string &component, span< double > values) const override
Retrieve internal work array values for a component.
double shear(span< const double > x, size_t j) const
Compute the shear term from the momentum equation using a central three-point differencing scheme.
void _finalize(span< const double > x) override
In some cases, a domain may need to set parameters that depend on the initial solution estimate.
double leftControlPointCoordinate() const
Returns the z-coordinate of the left control point.
AnyMap getMeta() const override
Retrieve meta data.
double X(span< const double > x, size_t k, size_t j) const
Get the mole fraction of species k at point j from the local state vector x.
double leftControlPointTemperature() const
Returns the temperature at the left control point.
string componentName(size_t n) const override
Name of component n. May be overloaded.
void updateThermo(span< const double > x, size_t j0, size_t j1)
Update the thermodynamic properties from point j0 to point j1 (inclusive), based on solution x.
bool isStrained() const
Retrieve flag indicating whether flow uses radial momentum.
void resetBadValues(span< double > x) override
When called, this function should reset "bad" values in the state vector such as negative species con...
string transportModel() const
Retrieve transport model.
double rightControlPointCoordinate() const
Returns the z-coordinate of the right control point.
Array2D m_dthermal
Array of size m_nsp by m_points for saving thermal diffusion coefficients.
virtual void evalUo(span< const double > x, span< double > rsd, span< 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 _getInitialSoln(span< double > x) override
Write the initial solution estimate into array x.
bool m_dovisc
Determines whether the viscosity term in the momentum equation is calculated.
Flow1D(shared_ptr< Solution > phase, const string &id="", size_t points=1)
Create a new flow domain.
void setPressure(double p)
Set the pressure.
double m_zRight
Location of the right control point when two-point control is enabled.
virtual void solveElectricField()
Set to solve electric field in a point (used by IonFlow specialization)
virtual void fixElectricField()
Set to fix voltage in a point (used by IonFlow specialization)
size_t m_kExcessRight
Index of species with a large mass fraction at the right boundary, for which the mass fraction may be...
vector< size_t > m_kRadiating
Indices within the ThermoPhase of the radiating species.
void setTransportModel(const string &model) override
Set transport model by name.
void setFlatProfile(const string &component, double value) override
Specify a flat profile for a component.
void setGas(span< const double > x, size_t j)
Set the gas object state to be consistent with the solution at point j.
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.
vector< double > m_ybar
Holds the average of the species mass fractions between grid points j and j+1.
bool m_do_radiation
Determines whether radiative heat loss is calculated.
virtual void grad_hk(span< const double > x, size_t j)
Compute the spatial derivative of species specific molar enthalpies using upwind differencing.
An array index is out of range.
An error indicating that an unimplemented function has been called.
void resize() override
Call to set the size of internal data structures after first defining the system or if the problem si...
const vector< double > & _workVector() const
Access internal work array.
void getMassFractions(span< double > y) const
Get the species mass fractions.
size_t speciesIndex(const string &name, bool raise=true) const
Returns the index of a species named 'name' within the Phase object.
span< const double > molecularWeights() const
Return a const reference to the internal vector of molecular weights.
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.
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(span< const double > y)
Set the mass fractions to the specified values and normalize them.
virtual void setMassFractions_NoNorm(span< const double > y)
Set the mass fractions to the specified values without normalizing.
virtual double pressure() const
Return the thermodynamic pressure (Pa).
string name() const
Return the name of the phase.
static shared_ptr< SolutionArray > create(const shared_ptr< Solution > &sol, int size=0, const AnyMap &meta={})
Instantiate a new SolutionArray reference.
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(span< double > dt)
Return a vector of thermal diffusion coefficients [kg/m/s].
virtual string transportModel() const
Identifies the model represented by this Transport object.
virtual double thermalConductivity()
Get the mixture thermal conductivity [W/m/K].
virtual double viscosity()
Get the dynamic viscosity [Pa·s].
virtual void getMixDiffCoeffsMass(span< double > d)
Returns a vector of mixture averaged diffusion coefficients [m²/s].
virtual void getMixDiffCoeffs(span< double > d)
Return a vector of mixture averaged diffusion coefficients [m²/s].
virtual void getMultiDiffCoeffs(const size_t ld, span< double > d)
Return the multicomponent diffusion coefficients [m²/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, span< const double > xpts, span< const 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 map< string, string > & _componentAliasMap()
Return mapping of component alias names to standardized component names.
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.