13 Bdry1D::Bdry1D() : Domain1D(1, 1, 0.0),
14 m_flow_left(0), m_flow_right(0),
15 m_ilr(0), m_left_nv(0), m_right_nv(0),
16 m_left_loc(0), m_right_loc(0),
17 m_left_points(0), m_nv(0),
18 m_left_nsp(0), m_right_nsp(0),
19 m_sp_left(0), m_sp_right(0),
20 m_start_left(0), m_start_right(0),
21 m_phase_left(0), m_phase_right(0), m_temp(0.0), m_mdot(0.0)
23 m_type = cConnectorType;
29 if (m_index ==
npos) {
30 throw CanteraError(
"Bdry1D",
31 "install in container before calling init.");
43 if (r.domainType() == cFlowType) {
44 m_flow_left = (StFlow*)&r;
46 m_left_points = m_flow_left->
nPoints();
48 m_left_nsp = m_left_nv - 4;
49 m_phase_left = &m_flow_left->phase();
51 throw CanteraError(
"Bdry1D::init",
52 "Boundary domains can only be "
53 "connected on the left to flow domains, not type "+
int2str(r.domainType())
59 if (m_index + 1 <
container().nDomains()) {
61 if (r.domainType() == cFlowType) {
62 m_flow_right = (StFlow*)&r;
65 m_right_nsp = m_right_nv - 4;
66 m_phase_right = &m_flow_right->phase();
68 throw CanteraError(
"Bdry1D::init",
69 "Boundary domains can only be "
70 "connected on the right to flow domains, not type "+
int2str(r.domainType())
107 return "temperature";
132 m_flow = m_flow_left;
133 }
else if (m_flow_right) {
135 m_flow = m_flow_right;
142 m_yin.resize(m_nsp, 0.0);
151 eval(
size_t jg, doublereal* xg, doublereal* rg,
152 integer* diagg, doublereal rdt)
159 doublereal* x = xg +
loc();
160 doublereal* r = rg +
loc();
161 integer* diag = diagg +
loc();
166 r[0] = m_mdot - x[0];
169 r[1] = m_temp - x[1];
178 if (m_ilr == LeftInlet) {
200 for (
size_t k = 1; k < m_nsp; k++) {
201 rb[4+k] += x[0]*m_yin[k];
207 if (!m_flow->fixed_mdot()) {
208 m_mdot = m_flow->density(0)*xb[0];
209 r[0] = m_mdot - x[0];
222 for (
size_t k = 1; k < m_nsp; k++) {
223 rb[4+k] += x[0]*(m_yin[k]);
231 const doublereal* s = soln +
loc();
237 for (
size_t k=0; k < m_nsp; k++) {
249 soln[1] = m_temp =
ctml::getFloat(dom,
"temperature",
"temperature");
251 m_yin.assign(m_nsp, 0.0);
253 for (
size_t i = 0; i < dom.
nChildren(); i++) {
255 if (node.
name() ==
"massFraction") {
291 eval(
size_t jg, doublereal* xg, doublereal* rg,
292 integer* diagg, doublereal rdt)
299 doublereal* x = xg +
loc();
300 doublereal* r = rg +
loc();
301 integer* diag = diagg +
loc();
350 eval(
size_t jg, doublereal* xg, doublereal* rg,
351 integer* diagg, doublereal rdt)
358 doublereal* x = xg +
loc();
359 doublereal* r = rg +
loc();
360 integer* diag = diagg +
loc();
375 rb[1] = xb[1] - xb[1 + nc];
376 rb[2] = xb[2] - xb[2 + nc];
386 rb[1] = xb[1] - xb[1 - nc];
387 rb[2] = xb[2] - xb[2 - nc];
414 return "outlet dummy";
431 m_flow_right->setViscosityFlag(
false);
434 m_flow_left->setViscosityFlag(
false);
439 eval(
size_t jg, doublereal* xg, doublereal* rg,
440 integer* diagg, doublereal rdt)
447 doublereal* x = xg +
loc();
448 doublereal* r = rg +
loc();
449 integer* diag = diagg +
loc();
463 rb[2] = xb[2] - xb[2 + nc];
464 for (k = 4; k < nc; k++) {
466 rb[k] = xb[k] - xb[k + nc];
479 if (!m_flow_left->fixed_mdot()) {
485 rb[2] = xb[2] - xb[2 - nc];
486 for (k = 5; k < nc; k++) {
487 rb[k] = xb[k] - xb[k - nc];
556 m_flow = m_flow_left;
557 }
else if (m_flow_right) {
558 m_flow = m_flow_right;
564 m_yres.resize(m_nsp, 0.0);
573 eval(
size_t jg, doublereal* xg, doublereal* rg,
574 integer* diagg, doublereal rdt)
582 doublereal* x = xg +
loc();
583 doublereal* r = rg +
loc();
584 integer* diag = diagg +
loc();
604 rb[2] = xb[2] - xb[2 + nc];
607 for (k = 4; k < nc; k++) {
608 rb[k] = xb[k] - m_yres[k-4];
619 if (!m_flow_left->fixed_mdot()) {
624 rb[2] = xb[2] - m_temp;
625 for (k = 5; k < nc; k++) {
626 rb[k] = xb[k] - m_yres[k-4];
638 for (
size_t k=0; k < m_nsp; k++) {
651 m_yres.assign(m_nsp, 0.0);
652 for (
size_t i = 0; i < dom.
nChildren(); i++) {
654 if (node.
name() ==
"massFraction") {
673 return "temperature";
693 eval(
size_t jg, doublereal* xg, doublereal* rg,
694 integer* diagg, doublereal rdt)
701 doublereal* x = xg +
loc();
702 doublereal* r = rg +
loc();
703 integer* diag = diagg +
loc();
706 r[0] = x[0] - m_temp;
713 rb[2] = xb[2] - x[0];
720 rb[2] = xb[2] - x[0];
727 const doublereal* s = soln +
loc();
741 soln[0] = m_temp =
ctml::getFloat(dom,
"temperature",
"temperature");
752 return "temperature";
753 }
else if (n < m_nsp + 1) {
765 m_fixed_cov.resize(m_nsp, 0.0);
766 m_fixed_cov[0] = 1.0;
770 for (
size_t n = 0; n < m_nsp; n++) {
780 eval(
size_t jg, doublereal* xg, doublereal* rg,
781 integer* diagg, doublereal rdt)
788 doublereal* x = xg +
loc();
789 doublereal* r = rg +
loc();
790 integer* diag = diagg +
loc();
794 r[0] = x[0] - m_temp;
797 doublereal sum = 0.0;
798 for (
size_t k = 0; k < m_nsp; k++) {
809 size_t leftloc = 0, rightloc = 0;
813 leftloc = m_flow_left->
loc();
814 pnt = m_flow_left->
nPoints() - 1;
815 m_flow_left->
setGas(xg + leftloc, pnt);
819 rightloc = m_flow_right->
loc();
820 m_flow_right->
setGas(xg + rightloc, 0);
832 doublereal maxx = -1.0;
833 for (
size_t k = 0; k < m_nsp; k++) {
834 r[k+1] = m_work[k + ioffset] * m_sphase->
size(k) * rs0;
835 r[k+1] -= rdt*(x[k+1] -
prevSoln(k+1,0));
844 for (
size_t k = 0; k < m_nsp; k++) {
845 r[k+1] = x[k+1] - m_fixed_cov[k];
853 rb[2] = xb[2] - x[0];
861 rb[2] = xb[2] - x[0];
862 for (
size_t nl = 1; nl < m_left_nsp; nl++) {
863 rb[4+nl] += m_work[nl]*mwleft[nl];
871 const doublereal* s = soln +
loc();
875 for (
size_t k=0; k < m_nsp; k++) {
888 m_fixed_cov.assign(m_nsp, 0.0);
889 for (
size_t i = 0; i < dom.
nChildren(); i++) {
891 if (node.
name() ==
"coverage") {
894 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.
virtual void restore(const XML_Node &dom, doublereal *soln, int loglevel)
Restore the solution for this domain from an XML_Node.
virtual void getNetProductionRates(doublereal *net)
Species net production rates [kmol/m^3/s or kmol/m^2/s].
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.
doublereal getFloat(const Cantera::XML_Node &parent, const std::string &name, const std::string &type)
Get a floating-point value from a child element.
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 restore(const XML_Node &dom, doublereal *soln, int loglevel)
Restore the solution for this domain from an XML_Node.
void setBounds(size_t nl, const doublereal *lower, size_t nu, const doublereal *upper)
Set the lower and upper bounds for each solution component.
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 addFloat(Cantera::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 ...
Base class for exceptions thrown by Cantera classes.
void setMoleFractionsByName(compositionMap &xMap)
Set the species mole fractions by name.
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 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.
#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.