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;
30 if (m_index ==
npos) {
31 throw CanteraError(
"Bdry1D",
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())
114 return "temperature";
128 const doublereal lower[2] = {-1.0e5, 200.0};
129 const doublereal upper[2] = {1.0e5, 1.e5};
143 m_flow = m_flow_left;
144 }
else if (m_flow_right) {
146 m_flow = m_flow_right;
153 m_yin.resize(m_nsp, 0.0);
163 eval(
size_t jg, doublereal* xg, doublereal* rg,
164 integer* diagg, doublereal rdt)
171 doublereal* x = xg +
loc();
172 doublereal* r = rg +
loc();
173 integer* diag = diagg +
loc();
178 r[0] = m_mdot - x[0];
181 r[1] = m_temp - x[1];
190 if (m_ilr == LeftInlet) {
212 for (
size_t k = 1; k < m_nsp; k++) {
213 rb[4+k] += x[0]*m_yin[k];
219 if (!m_flow->fixed_mdot()) {
220 r[0] = m_flow->density(0)*xb[0] - x[0];
233 for (
size_t k = 1; k < m_nsp; k++) {
234 rb[4+k] += x[0]*(m_yin[k]);
244 const doublereal* s = soln +
loc();
245 XML_Node& inlt = o.addChild(
"domain");
256 restore(
const XML_Node& dom, doublereal* soln)
286 const doublereal lower = -1.0;
287 const doublereal upper = 1.0;
291 const doublereal
rtol = 1e-4;
292 const doublereal
atol = 1.e-4;
297 eval(
size_t jg, doublereal* xg, doublereal* rg,
298 integer* diagg, doublereal rdt)
305 doublereal* x = xg +
loc();
306 doublereal* r = rg +
loc();
307 integer* diag = diagg +
loc();
317 XML_Node& symm = o.addChild(
"domain");
325 restore(
const XML_Node& dom, doublereal* soln)
352 const doublereal lower = -1.0;
353 const doublereal upper = 1.0;
357 const doublereal
rtol = 1e-4;
358 const doublereal
atol = 1.e-4;
363 eval(
size_t jg, doublereal* xg, doublereal* rg,
364 integer* diagg, doublereal rdt)
371 doublereal* x = xg +
loc();
372 doublereal* r = rg +
loc();
373 integer* diag = diagg +
loc();
388 rb[1] = xb[1] - xb[1 + nc];
389 rb[2] = xb[2] - xb[2 + nc];
399 rb[1] = xb[1] - xb[1 - nc];
400 rb[2] = xb[2] - xb[2 - nc];
408 XML_Node& symm = o.addChild(
"domain");
416 restore(
const XML_Node& dom, doublereal* soln)
426 string Outlet1D::componentName(
size_t n)
const
430 return "outlet dummy";
442 const doublereal lower = -1.0;
443 const doublereal upper = 1.0;
444 setBounds(1, &lower, 1, &upper);
447 const doublereal rtol = 1e-4;
448 const doublereal atol = 1.e-4;
449 setTolerances(1, &rtol, 1, &atol);
451 m_flow_right->setViscosityFlag(
false);
454 m_flow_left->setViscosityFlag(
false);
460 eval(
size_t jg, doublereal* xg, doublereal* rg,
461 integer* diagg, doublereal rdt)
463 if (jg !=
npos && (jg + 2 < firstPoint() || jg > lastPoint() + 2)) {
468 doublereal* x = xg + loc();
469 doublereal* r = rg + loc();
470 integer* diag = diagg + loc();
479 nc = m_flow_right->nComponents();
484 rb[2] = xb[2] - xb[2 + nc];
485 for (k = 4; k < nc; k++) {
487 rb[k] = xb[k] - xb[k + nc];
493 nc = m_flow_left->nComponents();
500 if (!m_flow_left->fixed_mdot()) {
506 rb[2] = xb[2] - xb[2 - nc];
507 for (k = 5; k < nc; k++) {
508 rb[k] = xb[k] - xb[k - nc];
516 save(XML_Node& o,
const doublereal*
const soln)
518 XML_Node& outlt = o.addChild(
"domain");
519 outlt.addAttribute(
"id",
id());
520 outlt.addAttribute(
"points",1);
521 outlt.addAttribute(
"type",
"outlet");
522 outlt.addAttribute(
"components",
double(nComponents()));
526 restore(
const XML_Node& dom, doublereal* soln)
576 const doublereal lower = -1.0;
577 const doublereal upper = 1.0;
581 const doublereal rtol = 1e-4;
582 const doublereal atol = 1.e-4;
586 m_flow = m_flow_left;
587 }
else if (m_flow_right) {
588 m_flow = m_flow_right;
594 m_yres.resize(m_nsp, 0.0);
604 eval(
size_t jg, doublereal* xg, doublereal* rg,
605 integer* diagg, doublereal rdt)
613 doublereal* x = xg +
loc();
614 doublereal* r = rg +
loc();
615 integer* diag = diagg +
loc();
635 rb[2] = xb[2] - xb[2 + nc];
638 for (k = 4; k < nc; k++) {
639 rb[k] = xb[k] - m_yres[k-4];
650 if (!m_flow_left->fixed_mdot()) {
655 rb[2] = xb[2] - m_temp;
656 for (k = 5; k < nc; k++) {
657 rb[k] = xb[k] - m_yres[k-4];
667 XML_Node& outlt = o.addChild(
"domain");
675 restore(
const XML_Node& dom, doublereal* soln)
693 return "temperature";
705 const doublereal lower = 200.0;
706 const doublereal upper = 1.e5;
710 const doublereal rtol = 1e-4;
711 const doublereal atol = 1.e-4;
717 eval(
size_t jg, doublereal* xg, doublereal* rg,
718 integer* diagg, doublereal rdt)
725 doublereal* x = xg +
loc();
726 doublereal* r = rg +
loc();
727 integer* diag = diagg +
loc();
730 r[0] = x[0] - m_temp;
737 rb[2] = xb[2] - x[0];
744 rb[2] = xb[2] - x[0];
751 const doublereal* s = soln +
loc();
753 XML_Node& inlt = o.addChild(
"domain");
764 restore(
const XML_Node& dom, doublereal* soln)
766 map<string, double> x;
768 soln[0] = x[
"temperature"];
786 return "temperature";
787 }
else if (n < m_nsp + 1) {
799 m_fixed_cov.resize(m_nsp, 0.0);
800 m_fixed_cov[0] = 1.0;
807 for (
size_t n = 0; n < m_nsp; n++) {
808 lower[n+1] = -1.0e-5;
813 for (
size_t n = 0; n < m_nv; n++) {
823 eval(
size_t jg, doublereal* xg, doublereal* rg,
824 integer* diagg, doublereal rdt)
831 doublereal* x = xg +
loc();
832 doublereal* r = rg +
loc();
833 integer* diag = diagg +
loc();
837 r[0] = x[0] - m_temp;
840 doublereal sum = 0.0;
841 for (
size_t k = 0; k < m_nsp; k++) {
852 size_t leftloc = 0, rightloc = 0;
856 leftloc = m_flow_left->
loc();
857 pnt = m_flow_left->
nPoints() - 1;
858 m_flow_left->
setGas(xg + leftloc, pnt);
862 rightloc = m_flow_right->
loc();
863 m_flow_right->
setGas(xg + rightloc, 0);
875 doublereal maxx = -1.0;
876 for (
size_t k = 0; k < m_nsp; k++) {
877 r[k+1] = m_work[k + ioffset] * m_sphase->
size(k) * rs0;
878 r[k+1] -= rdt*(x[k+1] -
prevSoln(k+1,0));
887 for (
size_t k = 0; k < m_nsp; k++) {
888 r[k+1] = x[k+1] - m_fixed_cov[k];
896 rb[2] = xb[2] - x[0];
904 rb[2] = xb[2] - x[0];
905 for (
size_t nl = 1; nl < m_left_nsp; nl++) {
906 rb[4+nl] += m_work[nl]*mwleft[nl];
914 const doublereal* s = soln +
loc();
916 XML_Node& inlt = o.addChild(
"domain");
926 void ReactingSurf1D::
927 restore(
const XML_Node& dom, doublereal* soln)
929 map<string, double> x;
931 soln[0] = x[
"temperature"];