Cantera  2.3.0
boundaries1D.cpp
Go to the documentation of this file.
1 //! @file boundaries1D.cpp
2 
3 // This file is part of Cantera. See License.txt in the top-level directory or
4 // at http://www.cantera.org/license.txt for license and copyright information.
5 
6 #include "cantera/oneD/Inlet1D.h"
7 #include "cantera/oneD/OneDim.h"
8 #include "cantera/base/ctml.h"
9 #include "cantera/oneD/StFlow.h"
10 
11 using namespace std;
12 
13 namespace Cantera
14 {
15 
16 Bdry1D::Bdry1D() : Domain1D(1, 1, 0.0),
17  m_flow_left(0), m_flow_right(0),
18  m_ilr(0), m_left_nv(0), m_right_nv(0),
19  m_left_loc(0), m_right_loc(0),
20  m_left_points(0),
21  m_left_nsp(0), m_right_nsp(0),
22  m_sp_left(0), m_sp_right(0),
23  m_start_left(0), m_start_right(0),
24  m_phase_left(0), m_phase_right(0), m_temp(0.0), m_mdot(0.0)
25 {
26  m_type = cConnectorType;
27 }
28 
29 void Bdry1D::_init(size_t n)
30 {
31  if (m_index == npos) {
32  throw CanteraError("Bdry1D::_init",
33  "install in container before calling init.");
34  }
35 
36  // A boundary object contains only one grid point
37  resize(n,1);
38 
39  m_left_nsp = 0;
40  m_right_nsp = 0;
41 
42  // check for left and right flow objects
43  if (m_index > 0) {
44  Domain1D& r = container().domain(m_index-1);
45  if (r.domainType() == cFlowType) {
46  m_flow_left = (StFlow*)&r;
47  m_left_nv = m_flow_left->nComponents();
48  m_left_points = m_flow_left->nPoints();
49  m_left_loc = container().start(m_index-1);
50  m_left_nsp = m_left_nv - c_offset_Y;
51  m_phase_left = &m_flow_left->phase();
52  } else {
53  throw CanteraError("Bdry1D::_init",
54  "Boundary domains can only be connected on the left to flow "
55  "domains, not type {} domains.", r.domainType());
56  }
57  }
58 
59  // if this is not the last domain, see what is connected on the right
60  if (m_index + 1 < container().nDomains()) {
61  Domain1D& r = container().domain(m_index+1);
62  if (r.domainType() == cFlowType) {
63  m_flow_right = (StFlow*)&r;
64  m_right_nv = m_flow_right->nComponents();
65  m_right_loc = container().start(m_index+1);
66  m_right_nsp = m_right_nv - c_offset_Y;
67  m_phase_right = &m_flow_right->phase();
68  } else {
69  throw CanteraError("Bdry1D::_init",
70  "Boundary domains can only be connected on the right to flow "
71  "domains, not type {} domains.", r.domainType());
72  }
73  }
74 }
75 
76 // ---------------- Inlet1D methods ----------------
77 
78 Inlet1D::Inlet1D()
79  : m_V0(0.0)
80  , m_nsp(0)
81  , m_flow(0)
82 {
83  m_type = cInletType;
84  m_xstr = "";
85 }
86 
87 void Inlet1D::showSolution(const double* x)
88 {
89  writelog(" Mass Flux: {:10.4g} kg/m^2/s \n", m_mdot);
90  writelog(" Temperature: {:10.4g} K \n", m_temp);
91  if (m_flow) {
92  writelog(" Mass Fractions: \n");
93  for (size_t k = 0; k < m_flow->phase().nSpecies(); k++) {
94  if (m_yin[k] != 0.0) {
95  writelog(" {:>16s} {:10.4g} \n",
96  m_flow->phase().speciesName(k), m_yin[k]);
97  }
98  }
99  }
100  writelog("\n");
101 }
102 
103 void Inlet1D::setMoleFractions(const std::string& xin)
104 {
105  m_xstr = xin;
106  if (m_flow) {
107  m_flow->phase().setMoleFractionsByName(xin);
108  m_flow->phase().getMassFractions(m_yin.data());
109  needJacUpdate();
110  }
111 }
112 
113 void Inlet1D::setMoleFractions(const doublereal* xin)
114 {
115  if (m_flow) {
116  m_flow->phase().setMoleFractions(xin);
117  m_flow->phase().getMassFractions(m_yin.data());
118  needJacUpdate();
119  }
120 }
121 
122 void Inlet1D::init()
123 {
124  _init(0);
125 
126  // if a flow domain is present on the left, then this must be a right inlet.
127  // Note that an inlet object can only be a terminal object - it cannot have
128  // flows on both the left and right
129  if (m_flow_left) {
130  m_ilr = RightInlet;
131  m_flow = m_flow_left;
132  } else if (m_flow_right) {
133  m_ilr = LeftInlet;
134  m_flow = m_flow_right;
135  } else {
136  throw CanteraError("Inlet1D::init","no flow!");
137  }
138 
139  // components = u, V, T, lambda, + mass fractions
140  m_nsp = m_flow->nComponents() - c_offset_Y;
141  m_yin.resize(m_nsp, 0.0);
142  if (m_xstr != "") {
143  setMoleFractions(m_xstr);
144  } else {
145  m_yin[0] = 1.0;
146  }
147 }
148 
149 void Inlet1D::eval(size_t jg, doublereal* xg, doublereal* rg,
150  integer* diagg, doublereal rdt)
151 {
152  if (jg != npos && (jg + 2 < firstPoint() || jg > lastPoint() + 2)) {
153  return;
154  }
155 
156  if (m_ilr == LeftInlet) {
157  // Array elements corresponding to the first point of the flow domain
158  double* xb = xg + m_flow->loc();
159  double* rb = rg + m_flow->loc();
160 
161  // The first flow residual is for u. This, however, is not modified by
162  // the inlet, since this is set within the flow domain from the
163  // continuity equation.
164 
165  // spreading rate. The flow domain sets this to V(0),
166  // so for finite spreading rate subtract m_V0.
167  rb[1] -= m_V0;
168 
169  // The third flow residual is for T, where it is set to T(0). Subtract
170  // the local temperature to hold the flow T to the inlet T.
171  rb[2] -= m_temp;
172 
173  if (m_flow->fixed_mdot()) {
174  // The flow domain sets this to -rho*u. Add mdot to specify the mass
175  // flow rate.
176  rb[3] += m_mdot;
177  } else {
178  // if the flow is a freely-propagating flame, mdot is not specified.
179  // Set mdot equal to rho*u, and also set lambda to zero.
180  m_mdot = m_flow->density(0)*xb[0];
181  rb[3] = xb[3];
182  }
183 
184  // add the convective term to the species residual equations
185  for (size_t k = 0; k < m_nsp; k++) {
186  if (k != m_flow_right->leftExcessSpecies()) {
187  rb[c_offset_Y+k] += m_mdot*m_yin[k];
188  }
189  }
190 
191  } else {
192  // right inlet
193  // Array elements corresponding to the flast point in the flow domain
194  double* rb = rg + loc() - m_flow->nComponents();
195  rb[1] -= m_V0;
196  rb[2] -= m_temp; // T
197  rb[0] += m_mdot; // u
198  for (size_t k = 0; k < m_nsp; k++) {
199  if (k != m_flow_left->rightExcessSpecies()) {
200  rb[c_offset_Y+k] += m_mdot * m_yin[k];
201  }
202  }
203  }
204 }
205 
206 XML_Node& Inlet1D::save(XML_Node& o, const doublereal* const soln)
207 {
208  XML_Node& inlt = Domain1D::save(o, soln);
209  inlt.addAttribute("type","inlet");
210  addFloat(inlt, "temperature", m_temp);
211  addFloat(inlt, "mdot", m_mdot);
212  for (size_t k=0; k < m_nsp; k++) {
213  addFloat(inlt, "massFraction", m_yin[k], "",
214  m_flow->phase().speciesName(k));
215  }
216  return inlt;
217 }
218 
219 void Inlet1D::restore(const XML_Node& dom, doublereal* soln, int loglevel)
220 {
221  Domain1D::restore(dom, soln, loglevel);
222  m_mdot = getFloat(dom, "mdot");
223  m_temp = getFloat(dom, "temperature");
224 
225  m_yin.assign(m_nsp, 0.0);
226 
227  for (size_t i = 0; i < dom.nChildren(); i++) {
228  const XML_Node& node = dom.child(i);
229  if (node.name() == "massFraction") {
230  size_t k = m_flow->phase().speciesIndex(node.attrib("type"));
231  if (k != npos) {
232  m_yin[k] = node.fp_value();
233  }
234  }
235  }
236  resize(0, 1);
237 }
238 
239 // ------------- Empty1D -------------
240 
241 void Empty1D::init()
242 {
243  _init(0);
244 }
245 
246 void Empty1D::eval(size_t jg, doublereal* xg, doublereal* rg,
247  integer* diagg, doublereal rdt)
248 {
249 }
250 
251 XML_Node& Empty1D::save(XML_Node& o, const doublereal* const soln)
252 {
253  XML_Node& symm = Domain1D::save(o, soln);
254  symm.addAttribute("type","empty");
255  return symm;
256 }
257 
258 void Empty1D::restore(const XML_Node& dom, doublereal* soln, int loglevel)
259 {
260  Domain1D::restore(dom, soln, loglevel);
261  resize(0, 1);
262 }
263 
264 // -------------- Symm1D --------------
265 
266 void Symm1D::init()
267 {
268  _init(0);
269 }
270 
271 void Symm1D::eval(size_t jg, doublereal* xg, doublereal* rg, integer* diagg,
272  doublereal rdt)
273 {
274  if (jg != npos && (jg + 2< firstPoint() || jg > lastPoint() + 2)) {
275  return;
276  }
277 
278  // start of local part of global arrays
279  doublereal* x = xg + loc();
280  doublereal* r = rg + loc();
281  integer* diag = diagg + loc();
282 
283  if (m_flow_right) {
284  size_t nc = m_flow_right->nComponents();
285  double* xb = x;
286  double* rb = r;
287  int* db = diag;
288  db[1] = 0;
289  db[2] = 0;
290  rb[1] = xb[1] - xb[1 + nc]; // zero dV/dz
291  rb[2] = xb[2] - xb[2 + nc]; // zero dT/dz
292  }
293 
294  if (m_flow_left) {
295  size_t nc = m_flow_left->nComponents();
296  double* xb = x - nc;
297  double* rb = r - nc;
298  int* db = diag - nc;
299  db[1] = 0;
300  db[2] = 0;
301  rb[1] = xb[1] - xb[1 - nc]; // zero dV/dz
302  rb[2] = xb[2] - xb[2 - nc]; // zero dT/dz
303  }
304 }
305 
306 XML_Node& Symm1D::save(XML_Node& o, const doublereal* const soln)
307 {
308  XML_Node& symm = Domain1D::save(o, soln);
309  symm.addAttribute("type","symmetry");
310  return symm;
311 }
312 
313 void Symm1D::restore(const XML_Node& dom, doublereal* soln, int loglevel)
314 {
315  Domain1D::restore(dom, soln, loglevel);
316  resize(0, 1);
317 }
318 
319 // -------- Outlet1D --------
320 
321 OutletRes1D::OutletRes1D()
322  : m_nsp(0)
323  , m_flow(0)
324 {
325  m_type = cOutletResType;
326  m_xstr = "";
327 }
328 
330 {
331  _init(0);
332 
333  if (m_flow_right) {
334  m_flow_right->setViscosityFlag(false);
335  }
336  if (m_flow_left) {
337  m_flow_left->setViscosityFlag(false);
338  }
339 }
340 
341 void Outlet1D::eval(size_t jg, doublereal* xg, doublereal* rg, integer* diagg,
342  doublereal rdt)
343 {
344  if (jg != npos && (jg + 2 < firstPoint() || jg > lastPoint() + 2)) {
345  return;
346  }
347 
348  // start of local part of global arrays
349  doublereal* x = xg + loc();
350  doublereal* r = rg + loc();
351  integer* diag = diagg + loc();
352 
353  if (m_flow_right) {
354  size_t nc = m_flow_right->nComponents();
355  double* xb = x;
356  double* rb = r;
357  rb[0] = xb[3];
358  rb[2] = xb[2] - xb[2 + nc];
359  for (size_t k = c_offset_Y; k < nc; k++) {
360  rb[k] = xb[k] - xb[k + nc];
361  }
362  }
363 
364  if (m_flow_left) {
365  size_t nc = m_flow_left->nComponents();
366  double* xb = x - nc;
367  double* rb = r - nc;
368  int* db = diag - nc;
369 
370  // zero Lambda
371  if (m_flow_left->fixed_mdot()) {
372  rb[0] = xb[3];
373  }
374 
375  rb[2] = xb[2] - xb[2 - nc]; // zero T gradient
376  size_t kSkip = c_offset_Y + m_flow_left->rightExcessSpecies();
377  for (size_t k = c_offset_Y; k < nc; k++) {
378  if (k != kSkip) {
379  rb[k] = xb[k] - xb[k - nc]; // zero mass fraction gradient
380  db[k] = 0;
381  }
382  }
383  }
384 }
385 
386 XML_Node& Outlet1D::save(XML_Node& o, const doublereal* const soln)
387 {
388  XML_Node& outlt = Domain1D::save(o, soln);
389  outlt.addAttribute("type","outlet");
390  return outlt;
391 }
392 
393 void Outlet1D::restore(const XML_Node& dom, doublereal* soln, int loglevel)
394 {
395  Domain1D::restore(dom, soln, loglevel);
396  resize(0, 1);
397 }
398 
399 // -------- OutletRes1D --------
400 
401 void OutletRes1D::setMoleFractions(const std::string& xres)
402 {
403  m_xstr = xres;
404  if (m_flow) {
405  m_flow->phase().setMoleFractionsByName(xres);
406  m_flow->phase().getMassFractions(m_yres.data());
407  needJacUpdate();
408  }
409 }
410 
411 void OutletRes1D::setMoleFractions(const doublereal* xres)
412 {
413  if (m_flow) {
414  m_flow->phase().setMoleFractions(xres);
415  m_flow->phase().getMassFractions(m_yres.data());
416  needJacUpdate();
417  }
418 }
419 
421 {
422  _init(0);
423 
424  if (m_flow_left) {
425  m_flow = m_flow_left;
426  } else if (m_flow_right) {
427  m_flow = m_flow_right;
428  } else {
429  throw CanteraError("OutletRes1D::init","no flow!");
430  }
431 
432  m_nsp = m_flow->nComponents() - c_offset_Y;
433  m_yres.resize(m_nsp, 0.0);
434  if (m_xstr != "") {
435  setMoleFractions(m_xstr);
436  } else {
437  m_yres[0] = 1.0;
438  }
439 }
440 
441 void OutletRes1D::eval(size_t jg, doublereal* xg, doublereal* rg,
442  integer* diagg, doublereal rdt)
443 {
444  if (jg != npos && (jg + 2 < firstPoint() || jg > lastPoint() + 2)) {
445  return;
446  }
447 
448  // start of local part of global arrays
449  doublereal* x = xg + loc();
450  doublereal* r = rg + loc();
451  integer* diag = diagg + loc();
452 
453  if (m_flow_right) {
454  size_t nc = m_flow_right->nComponents();
455  double* xb = x;
456  double* rb = r;
457 
458  // this seems wrong...
459  // zero Lambda
460  rb[0] = xb[3];
461 
462  // zero gradient for T
463  rb[2] = xb[2] - xb[2 + nc];
464 
465  // specified mass fractions
466  for (size_t k = c_offset_Y; k < nc; k++) {
467  rb[k] = xb[k] - m_yres[k-c_offset_Y];
468  }
469  }
470 
471  if (m_flow_left) {
472  size_t nc = m_flow_left->nComponents();
473  double* xb = x - nc;
474  double* rb = r - nc;
475  int* db = diag - nc;
476 
477  if (!m_flow_left->fixed_mdot()) {
478  ;
479  } else {
480  rb[0] = xb[3]; // zero Lambda
481  }
482  rb[2] = xb[2] - m_temp; // zero dT/dz
483  size_t kSkip = m_flow_left->rightExcessSpecies();
484  for (size_t k = c_offset_Y; k < nc; k++) {
485  if (k != kSkip) {
486  rb[k] = xb[k] - m_yres[k-c_offset_Y]; // fixed Y
487  db[k] = 0;
488  }
489  }
490  }
491 }
492 
493 XML_Node& OutletRes1D::save(XML_Node& o, const doublereal* const soln)
494 {
495  XML_Node& outlt = Domain1D::save(o, soln);
496  outlt.addAttribute("type","outletres");
497  addFloat(outlt, "temperature", m_temp, "K");
498  for (size_t k=0; k < m_nsp; k++) {
499  addFloat(outlt, "massFraction", m_yres[k], "",
500  m_flow->phase().speciesName(k));
501  }
502  return outlt;
503 }
504 
505 void OutletRes1D::restore(const XML_Node& dom, doublereal* soln, int loglevel)
506 {
507  Domain1D::restore(dom, soln, loglevel);
508  m_temp = getFloat(dom, "temperature");
509 
510  m_yres.assign(m_nsp, 0.0);
511  for (size_t i = 0; i < dom.nChildren(); i++) {
512  const XML_Node& node = dom.child(i);
513  if (node.name() == "massFraction") {
514  size_t k = m_flow->phase().speciesIndex(node.attrib("type"));
515  if (k != npos) {
516  m_yres[k] = node.fp_value();
517  }
518  }
519  }
520 
521  resize(0, 1);
522 }
523 
524 // -------- Surf1D --------
525 
527 {
528  _init(0);
529 }
530 
531 void Surf1D::eval(size_t jg, doublereal* xg, doublereal* rg,
532  integer* diagg, doublereal rdt)
533 {
534  if (jg != npos && (jg + 2 < firstPoint() || jg > lastPoint() + 2)) {
535  return;
536  }
537 
538  // start of local part of global arrays
539  doublereal* x = xg + loc();
540  doublereal* r = rg + loc();
541 
542  if (m_flow_right) {
543  double* rb = r;
544  double* xb = x;
545  rb[2] = xb[2] - m_temp; // specified T
546  }
547 
548  if (m_flow_left) {
549  size_t nc = m_flow_left->nComponents();
550  double* rb = r - nc;
551  double* xb = x - nc;
552  rb[2] = xb[2] - m_temp; // specified T
553  }
554 }
555 
556 XML_Node& Surf1D::save(XML_Node& o, const doublereal* const soln)
557 {
558  XML_Node& inlt = Domain1D::save(o, soln);
559  inlt.addAttribute("type","surface");
560  addFloat(inlt, "temperature", m_temp);
561  return inlt;
562 }
563 
564 void Surf1D::restore(const XML_Node& dom, doublereal* soln, int loglevel)
565 {
566  Domain1D::restore(dom, soln, loglevel);
567  m_temp = getFloat(dom, "temperature");
568  resize(0, 1);
569 }
570 
571 void Surf1D::showSolution_s(std::ostream& s, const double* x)
572 {
573  s << "------------------- Surface " << domainIndex() << " ------------------- " << std::endl;
574  s << " temperature: " << m_temp << " K" << std::endl;
575 }
576 
577 // -------- ReactingSurf1D --------
578 
579 ReactingSurf1D::ReactingSurf1D()
580  : m_kin(0)
581  , m_surfindex(0)
582  , m_nsp(0)
583 {
584  m_type = cSurfType;
585 }
586 
587 void ReactingSurf1D::setKineticsMgr(InterfaceKinetics* kin)
588 {
589  m_kin = kin;
590  m_surfindex = kin->surfacePhaseIndex();
591  m_sphase = (SurfPhase*)&kin->thermo(m_surfindex);
592  m_nsp = m_sphase->nSpecies();
593  m_enabled = true;
594 }
595 
596 string ReactingSurf1D::componentName(size_t n) const
597 {
598  if (n < m_nsp) {
599  return m_sphase->speciesName(n);
600  } else {
601  return "<unknown>";
602  }
603 }
604 
606 {
607  m_nv = m_nsp;
608  _init(m_nsp);
609  m_fixed_cov.resize(m_nsp, 0.0);
610  m_fixed_cov[0] = 1.0;
611  m_work.resize(m_kin->nTotalSpecies(), 0.0);
612 
613  for (size_t n = 0; n < m_nsp; n++) {
614  setBounds(n, -1.0e-5, 2.0);
615  }
616 }
617 
619  double* x = xg + loc();
620  m_sphase->setCoverages(x);
621  m_sphase->getCoverages(x);
622 }
623 
624 void ReactingSurf1D::eval(size_t jg, doublereal* xg, doublereal* rg,
625  integer* diagg, doublereal rdt)
626 {
627  if (jg != npos && (jg + 2 < firstPoint() || jg > lastPoint() + 2)) {
628  return;
629  }
630 
631  // start of local part of global arrays
632  doublereal* x = xg + loc();
633  doublereal* r = rg + loc();
634  integer* diag = diagg + loc();
635 
636  // set the coverages
637  doublereal sum = 0.0;
638  for (size_t k = 0; k < m_nsp; k++) {
639  m_work[k] = x[k];
640  sum += x[k];
641  }
642  m_sphase->setTemperature(m_temp);
643  m_sphase->setCoveragesNoNorm(m_work.data());
644 
645  // set the left gas state to the adjacent point
646 
647  size_t leftloc = 0, rightloc = 0;
648  size_t pnt = 0;
649 
650  if (m_flow_left) {
651  leftloc = m_flow_left->loc();
652  pnt = m_flow_left->nPoints() - 1;
653  m_flow_left->setGas(xg + leftloc, pnt);
654  }
655 
656  if (m_flow_right) {
657  rightloc = m_flow_right->loc();
658  m_flow_right->setGas(xg + rightloc, 0);
659  }
660 
661  m_kin->getNetProductionRates(m_work.data());
662  doublereal rs0 = 1.0/m_sphase->siteDensity();
663  size_t ioffset = m_kin->kineticsSpeciesIndex(0, m_surfindex);
664 
665  if (m_enabled) {
666  doublereal maxx = -1.0;
667  for (size_t k = 0; k < m_nsp; k++) {
668  r[k] = m_work[k + ioffset] * m_sphase->size(k) * rs0;
669  r[k] -= rdt*(x[k] - prevSoln(k,0));
670  diag[k] = 1;
671  maxx = std::max(x[k], maxx);
672  }
673  r[0] = 1.0 - sum;
674  diag[0] = 0;
675  } else {
676  for (size_t k = 0; k < m_nsp; k++) {
677  r[k] = x[k] - m_fixed_cov[k];
678  diag[k] = 0;
679  }
680  }
681 
682  if (m_flow_right) {
683  double* rb = r + m_nsp;
684  double* xb = x + m_nsp;
685  rb[2] = xb[2] - m_temp; // specified T
686  }
687  if (m_flow_left) {
688  size_t nc = m_flow_left->nComponents();
689  const vector_fp& mwleft = m_phase_left->molecularWeights();
690  double* rb = r - nc;
691  double* xb = x - nc;
692  rb[2] = xb[2] - m_temp; // specified T
693  size_t nSkip = m_flow_left->rightExcessSpecies();
694  for (size_t nl = 0; nl < m_left_nsp; nl++) {
695  if (nl != nSkip) {
696  rb[c_offset_Y+nl] += m_work[nl]*mwleft[nl];
697  }
698  }
699  }
700 }
701 
702 XML_Node& ReactingSurf1D::save(XML_Node& o, const doublereal* const soln)
703 {
704  const doublereal* s = soln + loc();
705  XML_Node& dom = Domain1D::save(o, soln);
706  dom.addAttribute("type","surface");
707  addFloat(dom, "temperature", m_temp, "K");
708  for (size_t k=0; k < m_nsp; k++) {
709  addFloat(dom, "coverage", s[k], "", m_sphase->speciesName(k));
710  }
711  return dom;
712 }
713 
714 void ReactingSurf1D::restore(const XML_Node& dom, doublereal* soln,
715  int loglevel)
716 {
717  Domain1D::restore(dom, soln, loglevel);
718  m_temp = getFloat(dom, "temperature");
719 
720  m_fixed_cov.assign(m_nsp, 0.0);
721  for (size_t i = 0; i < dom.nChildren(); i++) {
722  const XML_Node& node = dom.child(i);
723  if (node.name() == "coverage") {
724  size_t k = m_sphase->speciesIndex(node.attrib("type"));
725  if (k != npos) {
726  m_fixed_cov[k] = soln[k] = node.fp_value();
727  }
728  }
729  }
730  m_sphase->setCoverages(&m_fixed_cov[0]);
731 
732  resize(m_nsp, 1);
733 }
734 
735 void ReactingSurf1D::showSolution(const double* x)
736 {
737  writelog(" Temperature: {:10.4g} K \n", m_temp);
738  writelog(" Coverages: \n");
739  for (size_t k = 0; k < m_nsp; k++) {
740  writelog(" {:>20s} {:10.4g} \n", m_sphase->speciesName(k), x[k]);
741  }
742  writelog("\n");
743 }
744 }
void setCoveragesNoNorm(const doublereal *theta)
Set the surface site fractions to a specified state.
Definition: SurfPhase.cpp:282
const vector_fp & molecularWeights() const
Return a const reference to the internal vector of molecular weights.
Definition: Phase.cpp:513
CTML ("Cantera Markup Language") is the variant of XML that Cantera uses to store data...
std::string name() const
Returns the name of the XML node.
Definition: xml.h:370
void getMassFractions(doublereal *const y) const
Get the species mass fractions.
Definition: Phase.cpp:584
virtual void restore(const XML_Node &dom, doublereal *soln, int loglevel)
Restore the solution for this domain from an XML_Node.
virtual void restore(const XML_Node &dom, doublereal *soln, int loglevel)
Restore the solution for this domain from an XML_Node.
size_t speciesIndex(const std::string &name) const
Returns the index of a species named &#39;name&#39; within the Phase object.
Definition: Phase.cpp:251
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"
Definition: ct_defs.h:165
virtual void restore(const XML_Node &dom, doublereal *soln, int loglevel)
Restore the solution for this domain from an XML_Node.
size_t firstPoint() const
The index of the first (i.e., left-most) grid point belonging to this domain.
Definition: Domain1D.h:411
void writelog(const std::string &fmt, const Args &... args)
Write a formatted message to the screen.
Definition: global.h:179
void setCoverages(const doublereal *theta)
Set the surface site fractions to a specified state.
Definition: SurfPhase.cpp:265
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:97
size_t nSpecies() const
Returns the number of species in the phase.
Definition: Phase.h:262
STL namespace.
virtual void eval(size_t jg, doublereal *xg, doublereal *rg, integer *diagg, doublereal rdt)
Evaluate the residual function at point j.
virtual void restore(const XML_Node &dom, doublereal *soln, int loglevel)
Restore the solution for this domain from an XML_Node.
Definition: Domain1D.cpp:173
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 void init()
virtual XML_Node & save(XML_Node &o, const doublereal *const sol)
Save the current solution for this domain into an XML_Node.
Definition: Domain1D.cpp:160
virtual void getNetProductionRates(doublereal *wdot)
Species net production rates [kmol/m^3/s or kmol/m^2/s].
Definition: Kinetics.cpp:473
virtual XML_Node & save(XML_Node &o, const doublereal *const soln)
Save the current solution for this domain into an XML_Node.
size_t lastPoint() const
The index of the last (i.e., right-most) grid point belonging to this domain.
Definition: Domain1D.h:419
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.
virtual void resize(size_t nv, size_t np)
Definition: Domain1D.cpp:34
virtual void showSolution(const doublereal *x)
Print the solution.
void getCoverages(doublereal *theta) const
Return a vector of surface coverages.
Definition: SurfPhase.cpp:290
virtual XML_Node & save(XML_Node &o, const doublereal *const soln)
Save the current solution for this domain into an XML_Node.
size_t nTotalSpecies() const
The total number of species in all phases participating in the kinetics mechanism.
Definition: Kinetics.h:288
std::string speciesName(size_t k) const
Name of the species with index k.
Definition: Phase.cpp:267
void setMoleFractionsByName(const compositionMap &xMap)
Set the species mole fractions by name.
Definition: Phase.cpp:368
size_t kineticsSpeciesIndex(size_t k, size_t n) const
The location of species k of phase n in species arrays.
Definition: Kinetics.h:310
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:65
virtual void setMoleFractions(const doublereal *const x)
Set the mole fractions to the specified values.
Definition: Phase.cpp:327
virtual XML_Node & save(XML_Node &o, const doublereal *const soln)
Save the current solution for this domain into an XML_Node.
void addAttribute(const std::string &attrib, const std::string &value)
Add or modify an attribute of the current node.
Definition: xml.cpp:474
size_t domainIndex()
The left-to-right location of this domain.
Definition: Domain1D.h:55
double prevSoln(size_t n, size_t j) const
Value of component n at point j in the previous solution.
Definition: Domain1D.h:454
XML_Node & child(const size_t n) const
Return a changeable reference to the n&#39;th child of the current node.
Definition: xml.cpp:546
virtual void init()
void setGas(const doublereal *x, size_t j)
Set the gas object state to be consistent with the solution at point j.
Definition: StFlow.cpp:197
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 ...
Definition: ctml.cpp:33
size_t nComponents() const
Number of components at each grid point.
Definition: Domain1D.h:130
std::string attrib(const std::string &attr) const
Function returns the value of an attribute.
Definition: xml.cpp:500
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
Definition: ct_defs.h:157
virtual void setTemperature(const doublereal temp)
Set the internally stored temperature of the phase (K).
Definition: Phase.h:637
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.
Definition: ctml.cpp:178
doublereal size(size_t k) const
This routine returns the size of species k.
Definition: Phase.h:414
size_t rightExcessSpecies() const
Index of the species on the right boundary with the largest mass fraction.
Definition: StFlow.h:237
virtual std::string componentName(size_t n) const
Name of the nth component. May be overloaded.
void needJacUpdate()
Definition: Domain1D.cpp:104
size_t nPoints() const
Number of grid points in this domain.
Definition: Domain1D.h:152
Namespace for the Cantera kernel.
Definition: application.cpp:29
doublereal fp_value() const
Return the value of an XML node as a single double.
Definition: xml.cpp:454
size_t nChildren(bool discardComments=false) const
Return the number of children.
Definition: xml.cpp:556
virtual void init()
virtual size_t loc(size_t j=0) const
Location of the start of the local solution vector in the global solution vector,.
Definition: Domain1D.h:403
doublereal siteDensity()
Returns the site density.
Definition: SurfPhase.h:327
virtual void resetBadValues(double *xg)