15 Bdry1D::Bdry1D() : Domain1D(1, 1, 0.0),
16 m_flow_left(0), m_flow_right(0),
17 m_ilr(0), m_left_nv(0), m_right_nv(0),
18 m_left_loc(0), m_right_loc(0),
19 m_left_points(0), m_nv(0),
20 m_left_nsp(0), m_right_nsp(0),
21 m_sp_left(0), m_sp_right(0),
22 m_start_left(0), m_start_right(0),
23 m_phase_left(0), m_phase_right(0), m_temp(0.0), m_mdot(0.0)
25 m_type = cConnectorType;
28 void Bdry1D::_init(
size_t n)
30 if (m_index ==
npos) {
31 throw CanteraError(
"Bdry1D::_init",
32 "install in container before calling init.");
44 if (r.domainType() == cFlowType) {
45 m_flow_left = (StFlow*)&r;
47 m_left_points = m_flow_left->
nPoints();
49 m_left_nsp = m_left_nv - 4;
50 m_phase_left = &m_flow_left->phase();
52 throw CanteraError(
"Bdry1D::_init",
53 "Boundary domains can only be "
54 "connected on the left to flow domains, not type "+
int2str(r.domainType())
60 if (m_index + 1 <
container().nDomains()) {
62 if (r.domainType() == cFlowType) {
63 m_flow_right = (StFlow*)&r;
66 m_right_nsp = m_right_nv - 4;
67 m_phase_right = &m_flow_right->phase();
69 throw CanteraError(
"Bdry1D::_init",
70 "Boundary domains can only be "
71 "connected on the right to flow domains, not type "+
int2str(r.domainType())
105 return "temperature";
116 setBounds(0, -1e5, 1e5);
117 setBounds(1, 200.0, 1e5);
129 m_flow = m_flow_left;
130 }
else if (m_flow_right) {
132 m_flow = m_flow_right;
139 m_yin.resize(m_nsp, 0.0);
148 integer* diagg, doublereal rdt)
155 doublereal* x = xg +
loc();
156 doublereal* r = rg +
loc();
157 integer* diag = diagg +
loc();
162 r[0] = m_mdot - x[0];
165 r[1] = m_temp - x[1];
174 if (m_ilr == LeftInlet) {
196 for (
size_t k = 1; k < m_nsp; k++) {
197 rb[4+k] += x[0]*m_yin[k];
203 if (!m_flow->fixed_mdot()) {
204 m_mdot = m_flow->density(0)*xb[0];
205 r[0] = m_mdot - x[0];
218 for (
size_t k = 1; k < m_nsp; k++) {
219 rb[4+k] += x[0]*(m_yin[k]);
226 const doublereal* s = soln +
loc();
232 for (
size_t k=0; k < m_nsp; k++) {
233 addFloat(inlt,
"massFraction", m_yin[k],
"",
242 soln[0] = m_mdot =
getFloat(dom,
"mdot",
"massflowrate");
243 soln[1] = m_temp =
getFloat(dom,
"temperature",
"temperature");
245 m_yin.assign(m_nsp, 0.0);
247 for (
size_t i = 0; i < dom.
nChildren(); i++) {
249 if (node.
name() ==
"massFraction") {
276 setBounds(0, -1.0, 1.0);
284 integer* diagg, doublereal rdt)
291 doublereal* x = xg +
loc();
292 doublereal* r = rg +
loc();
293 integer* diag = diagg +
loc();
331 setBounds(0, -1.0, 1.0);
338 void Symm1D::eval(
size_t jg, doublereal* xg, doublereal* rg, integer* diagg,
346 doublereal* x = xg +
loc();
347 doublereal* r = rg +
loc();
348 integer* diag = diagg +
loc();
363 rb[1] = xb[1] - xb[1 + nc];
364 rb[2] = xb[2] - xb[2 + nc];
374 rb[1] = xb[1] - xb[1 - nc];
375 rb[2] = xb[2] - xb[2 - nc];
400 return "outlet dummy";
410 setBounds(0, -1.0, 1.0);
416 m_flow_right->setViscosityFlag(
false);
419 m_flow_left->setViscosityFlag(
false);
431 doublereal* x = xg +
loc();
432 doublereal* r = rg +
loc();
433 integer* diag = diagg +
loc();
447 rb[2] = xb[2] - xb[2 + nc];
448 for (k = 4; k < nc; k++) {
449 rb[k] = xb[k] - xb[k + nc];
460 if (m_flow_left->fixed_mdot()) {
464 rb[2] = xb[2] - xb[2 - nc];
465 for (k = 5; k < nc; k++) {
466 rb[k] = xb[k] - xb[k - nc];
523 setBounds(0, -1.0, 1.0);
530 m_flow = m_flow_left;
531 }
else if (m_flow_right) {
532 m_flow = m_flow_right;
538 m_yres.resize(m_nsp, 0.0);
547 integer* diagg, doublereal rdt)
555 doublereal* x = xg +
loc();
556 doublereal* r = rg +
loc();
557 integer* diag = diagg +
loc();
577 rb[2] = xb[2] - xb[2 + nc];
580 for (k = 4; k < nc; k++) {
581 rb[k] = xb[k] - m_yres[k-4];
592 if (!m_flow_left->fixed_mdot()) {
597 rb[2] = xb[2] - m_temp;
598 for (k = 5; k < nc; k++) {
599 rb[k] = xb[k] - m_yres[k-4];
609 addFloat(outlt,
"temperature", m_temp,
"K");
610 for (
size_t k=0; k < m_nsp; k++) {
611 addFloat(outlt,
"massFraction", m_yres[k],
"",
620 m_temp =
getFloat(dom,
"temperature");
622 m_yres.assign(m_nsp, 0.0);
623 for (
size_t i = 0; i < dom.
nChildren(); i++) {
625 if (node.
name() ==
"massFraction") {
644 return "temperature";
655 setBounds(0, 200.0, 1e5);
663 integer* diagg, doublereal rdt)
670 doublereal* x = xg +
loc();
671 doublereal* r = rg +
loc();
672 integer* diag = diagg +
loc();
675 r[0] = x[0] - m_temp;
682 rb[2] = xb[2] - x[0];
689 rb[2] = xb[2] - x[0];
695 const doublereal* s = soln +
loc();
707 soln[0] = m_temp =
getFloat(dom,
"temperature",
"temperature");
718 return "temperature";
719 }
else if (n < m_nsp + 1) {
730 m_fixed_cov.resize(m_nsp, 0.0);
731 m_fixed_cov[0] = 1.0;
734 setBounds(0, 200.0, 1e5);
735 for (
size_t n = 0; n < m_nsp; n++) {
736 setBounds(n+1, -1.0e-5, 2.0);
745 integer* diagg, doublereal rdt)
752 doublereal* x = xg +
loc();
753 doublereal* r = rg +
loc();
754 integer* diag = diagg +
loc();
758 r[0] = x[0] - m_temp;
761 doublereal sum = 0.0;
762 for (
size_t k = 0; k < m_nsp; k++) {
771 size_t leftloc = 0, rightloc = 0;
775 leftloc = m_flow_left->
loc();
776 pnt = m_flow_left->
nPoints() - 1;
777 m_flow_left->
setGas(xg + leftloc, pnt);
781 rightloc = m_flow_right->
loc();
782 m_flow_right->
setGas(xg + rightloc, 0);
790 doublereal maxx = -1.0;
791 for (
size_t k = 0; k < m_nsp; k++) {
792 r[k+1] = m_work[k + ioffset] * m_sphase->
size(k) * rs0;
793 r[k+1] -= rdt*(x[k+1] -
prevSoln(k+1,0));
795 maxx = std::max(x[k+1], maxx);
800 for (
size_t k = 0; k < m_nsp; k++) {
801 r[k+1] = x[k+1] - m_fixed_cov[k];
809 rb[2] = xb[2] - x[0];
817 rb[2] = xb[2] - x[0];
818 for (
size_t nl = 1; nl < m_left_nsp; nl++) {
819 rb[4+nl] += m_work[nl]*mwleft[nl];
826 const doublereal* s = soln +
loc();
829 addFloat(dom,
"temperature", s[0],
"K");
830 for (
size_t k=0; k < m_nsp; k++) {
831 addFloat(dom,
"coverage", s[k+1],
"",
841 soln[0] = m_temp =
getFloat(dom,
"temperature");
843 m_fixed_cov.assign(m_nsp, 0.0);
844 for (
size_t i = 0; i < dom.
nChildren(); i++) {
846 if (node.
name() ==
"coverage") {
849 m_fixed_cov[k] = soln[k+1] = node.
fp_value();
virtual void eval(size_t jg, doublereal *xg, doublereal *rg, integer *diagg, doublereal rdt)
Evaluate the residual function at point j.
virtual std::string componentName(size_t n) const
Name of the nth component. May be overloaded.
virtual std::string componentName(size_t n) const
Name of the nth component. May be overloaded.
std::string int2str(const int n, const std::string &fmt)
Convert an int to a string using a format converter.
virtual std::string componentName(size_t n) const
Name of the nth component. May be overloaded.
size_t nPoints() const
Number of grid points in this domain.
CTML ("Cantera Markup Language") is the variant of XML that Cantera uses to store data...
virtual void restore(const XML_Node &dom, doublereal *soln, int loglevel)
Restore the solution for this domain from an XML_Node.
std::string attrib(const std::string &attr) const
Function returns the value of an attribute.
virtual void restore(const XML_Node &dom, doublereal *soln, int loglevel)
Restore the solution for this domain from an XML_Node.
void getMassFractions(doublereal *const y) const
Get the species mass fractions.
virtual void setMoleFractions(const std::string &xin)
Set the mole fractions by specifying a std::string.
virtual void eval(size_t jg, doublereal *xg, doublereal *rg, integer *diagg, doublereal rdt)
Evaluate the residual function at point j.
const size_t npos
index returned by functions to indicate "no position"
size_t firstPoint() const
The index of the first (i.e., left-most) grid point belonging to this domain.
virtual XML_Node & save(XML_Node &o, const doublereal *const soln)
Save the current solution for this domain into an XML_Node.
virtual void restore(const XML_Node &dom, doublereal *soln, int loglevel)
Restore the solution for this domain from an XML_Node.
virtual size_t loc(size_t j=0) const
Location of the start of the local solution vector in the global solution vector,.
virtual std::string componentName(size_t n) const
Name of the nth component. May be overloaded.
void setCoverages(const doublereal *theta)
Set the surface site fractions to a specified state.
Class XML_Node is a tree-based representation of the contents of an XML file.
doublereal size(size_t k) const
This routine returns the size of species k.
size_t nTotalSpecies() const
The total number of species in all phases participating in the kinetics mechanism.
virtual void eval(size_t jg, doublereal *xg, doublereal *rg, integer *diagg, doublereal rdt)
Evaluate the residual function at point j.
virtual std::string componentName(size_t n) const
Name of the nth component. May be overloaded.
virtual void restore(const XML_Node &dom, doublereal *soln, int loglevel)
Restore the solution for this domain from an XML_Node.
virtual void eval(size_t jg, doublereal *xg, doublereal *rg, integer *diagg, doublereal rdt)
Evaluate the residual function at point j.
virtual XML_Node & save(XML_Node &o, const doublereal *const soln)
Save the current solution for this domain into an XML_Node.
virtual XML_Node & save(XML_Node &o, const doublereal *const soln)
Save the current solution for this domain into an XML_Node.
XML_Node & child(const size_t n) const
Return a changeable reference to the n'th child of the current node.
virtual XML_Node & save(XML_Node &o, const doublereal *const sol)
Save the current solution for this domain into an XML_Node.
virtual void getNetProductionRates(doublereal *wdot)
Species net production rates [kmol/m^3/s or kmol/m^2/s].
virtual void restore(const XML_Node &dom, doublereal *soln, int loglevel)
Restore the solution for this domain from an XML_Node.
size_t nComponents() const
Number of components at each grid point.
virtual XML_Node & save(XML_Node &o, const doublereal *const soln)
Save the current solution for this domain into an XML_Node.
size_t speciesIndex(const std::string &name) const
Returns the index of a species named 'name' within the Phase object.
virtual void eval(size_t jg, doublereal *xg, doublereal *rg, integer *diagg, doublereal rdt)
Evaluate the residual function at point j.
Boundary objects for one-dimensional simulations.
size_t start(size_t i) const
The index of the start of domain i in the solution vector.
size_t lastPoint() const
The index of the last (i.e., right-most) grid point belonging to this domain.
Domain1D & domain(size_t i) const
Return a reference to domain i.
virtual XML_Node & save(XML_Node &o, const doublereal *const soln)
Save the current solution for this domain into an XML_Node.
std::string name() const
Returns the name of the XML node.
virtual std::string componentName(size_t n) const
Name of the nth component. May be overloaded.
void setMoleFractionsByName(const compositionMap &xMap)
Set the species mole fractions by name.
Base class for exceptions thrown by Cantera classes.
virtual void setMoleFractions(const doublereal *const x)
Set the mole fractions to the specified values There is no restriction on the sum of the mole fractio...
virtual void resize(size_t nv, size_t np)
virtual XML_Node & save(XML_Node &o, const doublereal *const soln)
Save the current solution for this domain into an XML_Node.
virtual void setMoleFractions(const std::string &xin)
Set the mole fractions by specifying a std::string.
void addAttribute(const std::string &attrib, const std::string &value)
Add or modify an attribute of the current node.
size_t kineticsSpeciesIndex(size_t k, size_t n) const
The location of species k of phase n in species arrays.
virtual void eval(size_t jg, doublereal *xg, doublereal *rg, integer *diagg, doublereal rdt)
Evaluate the residual function at point j.
void setGas(const doublereal *x, size_t j)
Set the gas object state to be consistent with the solution at point j.
Domain1D(size_t nv=1, size_t points=1, doublereal time=0.0)
Constructor.
const vector_fp & molecularWeights() const
Return a const reference to the internal vector of molecular weights.
void addFloat(XML_Node &node, const std::string &title, const doublereal val, const std::string &units, const std::string &type, const doublereal minval, const doublereal maxval)
This function adds a child node with the name, "float", with a value consisting of a single floating ...
void setSteadyTolerances(doublereal rtol, doublereal atol, size_t n=npos)
Set tolerances for steady-state mode.
virtual void eval(size_t jg, doublereal *xg, doublereal *rg, integer *diagg, doublereal rdt)
Evaluate the residual function at point j.
virtual std::string componentName(size_t n) const
Name of the nth component. May be overloaded.
virtual void setTemperature(const doublereal temp)
Set the internally stored temperature of the phase (K).
virtual void restore(const XML_Node &dom, doublereal *soln, int loglevel)
Restore the solution for this domain from an XML_Node.
doublereal getFloat(const XML_Node &parent, const std::string &name, const std::string &type)
Get a floating-point value from a child element.
#define DATA_PTR(vec)
Creates a pointer to the start of the raw data for a vector.
const OneDim & container() const
The container holding this domain.
virtual void restore(const XML_Node &dom, doublereal *soln, int loglevel)
Restore the solution for this domain from an XML_Node.
doublereal fp_value() const
Return the value of an XML node as a single double.
virtual XML_Node & save(XML_Node &o, const doublereal *const soln)
Save the current solution for this domain into an XML_Node.
double prevSoln(size_t n, size_t j) const
Value of component n at point j in the previous solution.
void setTransientTolerances(doublereal rtol, doublereal atol, size_t n=npos)
Set tolerances for time-stepping mode.
std::string speciesName(size_t k) const
Name of the species with index k.
size_t nChildren(bool discardComments=false) const
Return the number of children.
virtual void restore(const XML_Node &dom, doublereal *soln, int loglevel)
Restore the solution for this domain from an XML_Node.
doublereal siteDensity()
Returns the site density.