Cantera  2.1.2
IdealSolidSolnPhase.cpp
Go to the documentation of this file.
1 /**
2  * @file IdealSolidSolnPhase.cpp Implementation file for an ideal solid
3  * solution model with incompressible thermodynamics (see \ref
4  * thermoprops and \link Cantera::IdealSolidSolnPhase
5  * IdealSolidSolnPhase\endlink).
6  */
7 /*
8  * Copyright 2006 Sandia Corporation. Under the terms of Contract
9  * DE-AC04-94AL85000, with Sandia Corporation, the U.S. Government
10  * retains certain rights in this software.
11  */
12 
15 
16 using namespace std;
17 
18 namespace Cantera
19 {
20 
21 IdealSolidSolnPhase::IdealSolidSolnPhase(int formGC) :
22  ThermoPhase(),
23  m_formGC(formGC),
24  m_Pref(OneAtm),
25  m_Pcurrent(OneAtm),
26  m_tlast(0.0)
27 {
28  if (formGC < 0 || formGC > 2) {
29  throw CanteraError(" IdealSolidSolnPhase Constructor",
30  " Illegal value of formGC");
31  }
32 }
33 
34 IdealSolidSolnPhase::IdealSolidSolnPhase(const std::string& inputFile,
35  const std::string& id_, int formGC) :
36  ThermoPhase(),
37  m_formGC(formGC),
38  m_Pref(OneAtm),
39  m_Pcurrent(OneAtm),
40  m_tlast(0.0)
41 {
42  if (formGC < 0 || formGC > 2) {
43  throw CanteraError(" IdealSolidSolnPhase Constructor",
44  " Illegal value of formGC");
45  }
46  initThermoFile(inputFile, id_);
47 }
48 
49 IdealSolidSolnPhase::IdealSolidSolnPhase(XML_Node& root, const std::string& id_,
50  int formGC) :
51  ThermoPhase(),
52  m_formGC(formGC),
53  m_Pref(OneAtm),
54  m_Pcurrent(OneAtm),
55  m_tlast(0.0)
56 {
57  if (formGC < 0 || formGC > 2) {
58  throw CanteraError(" IdealSolidSolnPhase Constructor",
59  " Illegal value of formGC");
60  }
61  importPhase(*findXMLPhase(&root, id_), this);
62 }
63 
65 {
66  *this = b;
67 }
68 
71 {
72  if (this != &b) {
74 
75  m_formGC = b.m_formGC;
76  m_Pref = b.m_Pref;
79  m_tlast = b.m_tlast;
80  m_h0_RT = b.m_h0_RT;
81  m_cp0_R = b.m_cp0_R;
82  m_g0_RT = b.m_g0_RT;
83  m_s0_R = b.m_s0_R;
85  m_pe = b.m_pe;
86  m_pp = b.m_pp;
87  }
88  return *this;
89 }
90 
92 {
93  return new IdealSolidSolnPhase(*this);
94 }
95 
97 {
98  integer res;
99  switch (m_formGC) {
100  case 0:
101  res = cIdealSolidSolnPhase0;
102  break;
103  case 1:
104  res = cIdealSolidSolnPhase1;
105  break;
106  case 2:
107  res = cIdealSolidSolnPhase2;
108  break;
109  default:
110  throw CanteraError("eosType", "Unknown type");
111  break;
112  }
113  return res;
114 }
115 
116 /********************************************************************
117  * Molar Thermodynamic Properties of the Solution
118  ********************************************************************/
119 
120 doublereal IdealSolidSolnPhase::
122 {
123  const double* eptr = &(enthalpy_RT_ref()[0]);
124  doublereal htp = (GasConstant * temperature() * mean_X(eptr));
125  return htp + (pressure() - m_Pref)/molarDensity();
126 }
127 
129 {
130  const double* eptr = DATA_PTR(enthalpy_RT_ref().begin());
131  doublereal htp = (GasConstant * temperature() *
132  mean_X(eptr));
133  return htp - m_Pref / molarDensity();
134 }
135 
137 {
138  const double* dptr = DATA_PTR(entropy_R_ref());
139  return GasConstant * (mean_X(dptr) - sum_xlogx());
140 }
141 
143 {
144  const double* dptr = DATA_PTR(gibbs_RT_ref());
145  doublereal g = mean_X(dptr);
146  return GasConstant * temperature() * (g + sum_xlogx());
147 }
148 
150 {
151  const double* dptr = DATA_PTR(cp_R_ref());
152  return GasConstant * mean_X(dptr);
153 }
154 
155 /********************************************************************
156  * Mechanical Equation of State
157  ********************************************************************/
158 
160 {
161  /*
162  * Calculate the molarVolume of the solution (m**3 kmol-1)
163  */
164  const doublereal* const dtmp = moleFractdivMMW();
165  double invDens = dot(m_speciesMolarVolume.begin(),
166  m_speciesMolarVolume.end(), dtmp);
167  /*
168  * Set the density in the parent State object directly,
169  * by calling the Phase::setDensity() function.
170  */
171  double dens = 1.0/invDens;
172  Phase::setDensity(dens);
173 }
174 
176 setDensity(const doublereal rho)
177 {
178  /*
179  * Unless the input density is exactly equal to the density
180  * calculated and stored in the State object, we throw an
181  * exception. This is because the density is NOT an
182  * independent variable.
183  */
184  double dens = density();
185  if (rho != dens) {
186  throw CanteraError("IdealSolidSolnPhase::setDensity",
187  "Density is not an independent variable");
188  }
189 }
190 
192 {
193  m_Pcurrent = p;
194  calcDensity();
195 }
196 
197 void IdealSolidSolnPhase::setMolarDensity(const doublereal n)
198 {
199  throw CanteraError("IdealSolidSolnPhase::setMolarDensity",
200  "Density is not an independent variable");
201 }
202 
203 void IdealSolidSolnPhase::setMoleFractions(const doublereal* const x)
204 {
206  calcDensity();
207 }
208 
209 void IdealSolidSolnPhase::setMoleFractions_NoNorm(const doublereal* const x)
210 {
212  calcDensity();
213 }
214 
215 void IdealSolidSolnPhase::setMassFractions(const doublereal* const y)
216 {
218  calcDensity();
219 }
220 
221 void IdealSolidSolnPhase::setMassFractions_NoNorm(const doublereal* const y)
222 {
224  calcDensity();
225 }
226 
227 void IdealSolidSolnPhase::setConcentrations(const doublereal* const c)
228 {
230  calcDensity();
231 }
232 
233 /********************************************************************
234  * Chemical Potentials and Activities
235  ********************************************************************/
236 
238 getActivityConcentrations(doublereal* c) const
239 {
240  const doublereal* const dtmp = moleFractdivMMW();
241  const double mmw = meanMolecularWeight();
242  switch (m_formGC) {
243  case 0:
244  for (size_t k = 0; k < m_kk; k++) {
245  c[k] = dtmp[k] * mmw;
246  }
247  break;
248  case 1:
249  for (size_t k = 0; k < m_kk; k++) {
250  c[k] = dtmp[k] * mmw / m_speciesMolarVolume[k];
251  }
252  break;
253  case 2:
254  double atmp = mmw / m_speciesMolarVolume[m_kk-1];
255  for (size_t k = 0; k < m_kk; k++) {
256  c[k] = dtmp[k] * atmp;
257  }
258  break;
259  }
260 }
261 
262 doublereal IdealSolidSolnPhase::
263 standardConcentration(size_t k) const
264 {
265  switch (m_formGC) {
266  case 0:
267  return 1.0;
268  case 1:
269  return 1.0 / m_speciesMolarVolume[k];
270  case 2:
271  return 1.0/m_speciesMolarVolume[m_kk-1];
272  }
273  return 0.0;
274 }
275 doublereal IdealSolidSolnPhase::
277 {
278  switch (m_formGC) {
279  case 0:
280  return 1.0;
281  case 1:
282  return 1.0 / m_speciesMolarVolume[k];
283  case 2:
284  return 1.0 / m_speciesMolarVolume[m_kk-1];
285  }
286  return 0.0;
287 }
288 
289 doublereal IdealSolidSolnPhase::
290 logStandardConc(size_t k) const
291 {
292  _updateThermo();
293  double res;
294  switch (m_formGC) {
295  case 0:
296  res = 0.0;
297  break;
298  case 1:
299  res = log(1.0/m_speciesMolarVolume[k]);
300  break;
301  case 2:
302  res = log(1.0/m_speciesMolarVolume[m_kk-1]);
303  break;
304  default:
305  throw CanteraError("eosType", "Unknown type");
306  break;
307  }
308  return res;
309 }
310 
312 getUnitsStandardConc(double* uA, int, int sizeUA) const
313 {
314  int eos = eosType();
315  if (eos == cIdealSolidSolnPhase0) {
316  for (int i = 0; i < sizeUA; i++) {
317  uA[i] = 0.0;
318  }
319  } else {
320  for (int i = 0; i < sizeUA; i++) {
321  if (i == 0) {
322  uA[0] = 1.0;
323  }
324  if (i == 1) {
325  uA[1] = -int(nDim());
326  }
327  if (i == 2) {
328  uA[2] = 0.0;
329  }
330  if (i == 3) {
331  uA[3] = 0.0;
332  }
333  if (i == 4) {
334  uA[4] = 0.0;
335  }
336  if (i == 5) {
337  uA[5] = 0.0;
338  }
339  }
340  }
341 }
342 
344 getActivityCoefficients(doublereal* ac) const
345 {
346  for (size_t k = 0; k < m_kk; k++) {
347  ac[k] = 1.0;
348  }
349 }
350 
352 getChemPotentials(doublereal* mu) const
353 {
354  doublereal delta_p = m_Pcurrent - m_Pref;
355  doublereal xx;
356  doublereal RT = temperature() * GasConstant;
357  const vector_fp& g_RT = gibbs_RT_ref();
358  for (size_t k = 0; k < m_kk; k++) {
359  xx = std::max(SmallNumber, moleFraction(k));
360  mu[k] = RT * (g_RT[k] + log(xx))
361  + delta_p * m_speciesMolarVolume[k];
362  }
363 }
364 
366 getChemPotentials_RT(doublereal* mu) const
367 {
368  doublereal RT = temperature() * GasConstant;
369  doublereal delta_pdRT = (m_Pcurrent - m_Pref) / RT;
370  doublereal xx;
371  const vector_fp& g_RT = gibbs_RT_ref();
372  for (size_t k = 0; k < m_kk; k++) {
373  xx = std::max(SmallNumber, moleFraction(k));
374  mu[k] = (g_RT[k] + log(xx))
375  + delta_pdRT * m_speciesMolarVolume[k];
376  }
377 }
378 
379 /********************************************************************
380  * Partial Molar Properties
381  ********************************************************************/
382 
384 {
385  const vector_fp& _h = enthalpy_RT_ref();
386  doublereal rt = GasConstant * temperature();
387  scale(_h.begin(), _h.end(), hbar, rt);
388 }
389 
391 getPartialMolarEntropies(doublereal* sbar) const
392 {
393  const vector_fp& _s = entropy_R_ref();
394  doublereal r = GasConstant;
395  doublereal xx;
396  for (size_t k = 0; k < m_kk; k++) {
397  xx = std::max(SmallNumber, moleFraction(k));
398  sbar[k] = r * (_s[k] - log(xx));
399  }
400 }
401 
403 getPartialMolarCp(doublereal* cpbar) const
404 {
405  getCp_R(cpbar);
406  for (size_t k = 0; k < m_kk; k++) {
407  cpbar[k] *= GasConstant;
408  }
409 }
410 
412 getPartialMolarVolumes(doublereal* vbar) const
413 {
414  getStandardVolumes(vbar);
415 }
416 
417 /*****************************************************************
418  * Properties of the Standard State of the Species in the Solution
419  *****************************************************************/
420 
422 getPureGibbs(doublereal* gpure) const
423 {
424  const vector_fp& gibbsrt = gibbs_RT_ref();
425  doublereal RT = _RT();
426  const doublereal* const gk = DATA_PTR(gibbsrt);
427  doublereal delta_p = (m_Pcurrent - m_Pref);
428  for (size_t k = 0; k < m_kk; k++) {
429  gpure[k] = RT * gk[k] + delta_p * m_speciesMolarVolume[k];
430  }
431 }
432 
434 getGibbs_RT(doublereal* grt) const
435 {
436  const vector_fp& gibbsrt = gibbs_RT_ref();
437  doublereal RT = _RT();
438  const doublereal* const gk = DATA_PTR(gibbsrt);
439  doublereal delta_prt = (m_Pcurrent - m_Pref)/ RT;
440  for (size_t k = 0; k < m_kk; k++) {
441  grt[k] = gk[k] + delta_prt * m_speciesMolarVolume[k];
442  }
443 }
444 
446 getEnthalpy_RT(doublereal* hrt) const
447 {
448  const vector_fp& _h = enthalpy_RT_ref();
449  doublereal delta_prt = ((m_Pcurrent - m_Pref) /
450  (GasConstant * temperature()));
451  for (size_t k = 0; k < m_kk; k++) {
452  hrt[k] = _h[k] + delta_prt * m_speciesMolarVolume[k];
453  }
454 }
455 
456 void IdealSolidSolnPhase::getEntropy_R(doublereal* sr) const
457 {
458  const vector_fp& _s = entropy_R_ref();
459  copy(_s.begin(), _s.end(), sr);
460 }
461 
462 void IdealSolidSolnPhase::getIntEnergy_RT(doublereal* urt) const
463 {
464  const vector_fp& _h = enthalpy_RT_ref();
465  doublereal prefrt = m_Pref / (GasConstant * temperature());
466  for (size_t k = 0; k < m_kk; k++) {
467  urt[k] = _h[k] - prefrt * m_speciesMolarVolume[k];
468  }
469 }
470 
471 void IdealSolidSolnPhase::getCp_R(doublereal* cpr) const
472 {
473  const vector_fp& _cpr = cp_R_ref();
474  copy(_cpr.begin(), _cpr.end(), cpr);
475 }
476 
477 void IdealSolidSolnPhase::getStandardVolumes(doublereal* vol) const
478 {
479  copy(m_speciesMolarVolume.begin(), m_speciesMolarVolume.end(), vol);
480 }
481 
482 /*********************************************************************
483  * Thermodynamic Values for the Species Reference States
484  *********************************************************************/
485 
486 void IdealSolidSolnPhase::getEnthalpy_RT_ref(doublereal* hrt) const
487 {
488  _updateThermo();
489  for (size_t k = 0; k != m_kk; k++) {
490  hrt[k] = m_h0_RT[k];
491  }
492 }
493 
494 void IdealSolidSolnPhase::getGibbs_RT_ref(doublereal* grt) const
495 {
496  _updateThermo();
497  for (size_t k = 0; k != m_kk; k++) {
498  grt[k] = m_g0_RT[k];
499  }
500 }
501 
502 void IdealSolidSolnPhase::getGibbs_ref(doublereal* g) const
503 {
504  _updateThermo();
505  double tmp = GasConstant * temperature();
506  for (size_t k = 0; k != m_kk; k++) {
507  g[k] = tmp * m_g0_RT[k];
508  }
509 }
510 
511 void IdealSolidSolnPhase::getIntEnergy_RT_ref(doublereal* urt) const
512 {
513  const vector_fp& _h = enthalpy_RT_ref();
514  doublereal prefrt = m_Pref / (GasConstant * temperature());
515  for (size_t k = 0; k < m_kk; k++) {
516  urt[k] = _h[k] - prefrt * m_speciesMolarVolume[k];
517  }
518 }
519 
520 void IdealSolidSolnPhase::getEntropy_R_ref(doublereal* er) const
521 {
522  _updateThermo();
523  for (size_t k = 0; k != m_kk; k++) {
524  er[k] = m_s0_R[k];
525  }
526 }
527 
528 void IdealSolidSolnPhase::getCp_R_ref(doublereal* cpr) const
529 {
530  _updateThermo();
531  for (size_t k = 0; k != m_kk; k++) {
532  cpr[k] = m_cp0_R[k];
533  }
534 }
535 
537 {
538  _updateThermo();
539  return m_h0_RT;
540 }
541 
543 {
544  _updateThermo();
545  return m_s0_R;
546 }
547 
548 /*********************************************************************
549  * Utility Functions
550  *********************************************************************/
551 
553 {
554 }
555 
556 void IdealSolidSolnPhase::initThermoXML(XML_Node& phaseNode, const std::string& id_)
557 {
558  string subname = "IdealSolidSolnPhase::initThermoXML";
559  if (id_.size() > 0) {
560  string idp = phaseNode.id();
561  if (idp != id_) {
562  throw CanteraError(subname.c_str(),
563  "phasenode and Id are incompatible");
564  }
565  }
566 
567  /*
568  * Check on the thermo field. Must have:
569  * <thermo model="IdealSolidSolution" />
570  */
571  if (phaseNode.hasChild("thermo")) {
572  XML_Node& thNode = phaseNode.child("thermo");
573  string mStringa = thNode.attrib("model");
574  string mString = lowercase(mStringa);
575  if (mString != "idealsolidsolution") {
576  throw CanteraError(subname.c_str(),
577  "Unknown thermo model: " + mStringa);
578  }
579  } else {
580  throw CanteraError(subname.c_str(),
581  "Unspecified thermo model");
582  }
583 
584  /*
585  * Form of the standard concentrations. Must have one of:
586  *
587  * <standardConc model="unity" />
588  * <standardConc model="molar_volume" />
589  * <standardConc model="solvent_volume" />
590  */
591  if (phaseNode.hasChild("standardConc")) {
592  XML_Node& scNode = phaseNode.child("standardConc");
593  string formStringa = scNode.attrib("model");
594  string formString = lowercase(formStringa);
595  if (formString == "unity") {
596  m_formGC = 0;
597  } else if (formString == "molar_volume") {
598  m_formGC = 1;
599  } else if (formString == "solvent_volume") {
600  m_formGC = 2;
601  } else {
602  throw CanteraError(subname.c_str(),
603  "Unknown standardConc model: " + formStringa);
604  }
605  } else {
606  throw CanteraError(subname.c_str(),
607  "Unspecified standardConc model");
608  }
609 
610  /*
611  * Initialize all of the lengths now that we know how many species
612  * there are in the phase.
613  */
614  initLengths();
615  /*
616  * Now go get the molar volumes
617  */
618  XML_Node& speciesList = phaseNode.child("speciesArray");
619  XML_Node* speciesDB = get_XML_NameID("speciesData", speciesList["datasrc"],
620  &phaseNode.root());
621  const vector<string>&sss = speciesNames();
622 
623  for (size_t k = 0; k < m_kk; k++) {
624  XML_Node* s = speciesDB->findByAttr("name", sss[k]);
625  XML_Node* ss = s->findByName("standardState");
626  m_speciesMolarVolume[k] = ctml::getFloat(*ss, "molarVolume", "toSI");
627  }
628 
629  /*
630  * Call the base initThermo, which handles setting the initial
631  * state.
632  */
633  ThermoPhase::initThermoXML(phaseNode, id_);
634 }
635 
638 {
639  /*
640  * Obtain the reference pressure by calling the ThermoPhase
641  * function refPressure, which in turn calls the
642  * species thermo reference pressure function of the
643  * same name.
644  */
645  m_Pref = refPressure();
646 
647  m_h0_RT.resize(m_kk);
648  m_g0_RT.resize(m_kk);
649  m_expg0_RT.resize(m_kk);
650  m_cp0_R.resize(m_kk);
651  m_s0_R.resize(m_kk);
652  m_pe.resize(m_kk, 0.0);
653  m_pp.resize(m_kk);
654  m_speciesMolarVolume.resize(m_kk);
655 }
656 
658 setToEquilState(const doublereal* lambda_RT)
659 {
660  const vector_fp& grt = gibbs_RT_ref();
661 
662  // set the pressure and composition to be consistent with
663  // the temperature,
664  doublereal pres = 0.0;
665  for (size_t k = 0; k < m_kk; k++) {
666  m_pp[k] = -grt[k];
667  for (size_t m = 0; m < nElements(); m++) {
668  m_pp[k] += nAtoms(k,m)*lambda_RT[m];
669  }
670  m_pp[k] = m_Pref * exp(m_pp[k]);
671  pres += m_pp[k];
672  }
673  doublereal* dptr = DATA_PTR(m_pp);
674  setState_PX(pres, dptr);
675 }
676 
678 speciesMolarVolume(int k) const
679 {
680  return m_speciesMolarVolume[k];
681 }
682 
684 getSpeciesMolarVolumes(doublereal* smv) const
685 {
686  copy(m_speciesMolarVolume.begin(), m_speciesMolarVolume.end(), smv);
687 }
688 
691 {
692  doublereal tnow = temperature();
693  if (m_tlast != tnow) {
694  /*
695  * Update the thermodynamic functions of the reference state.
696  */
698  DATA_PTR(m_s0_R));
699  m_tlast = tnow;
700  doublereal rrt = 1.0 / (GasConstant * tnow);
701  doublereal deltaE;
702  for (size_t k = 0; k < m_kk; k++) {
703  deltaE = rrt * m_pe[k];
704  m_h0_RT[k] += deltaE;
705  m_g0_RT[k] = m_h0_RT[k] - m_s0_R[k];
706  }
707  m_tlast = tnow;
708  }
709 }
710 
711 } // end namespace Cantera
void _updateThermo() const
This function gets called for every call to functions in this class.
void getSpeciesMolarVolumes(doublereal *smv) const
Fill in a return vector containing the species molar volumes.
doublereal nAtoms(size_t k, size_t m) const
Number of atoms of element m in species k.
Definition: Phase.cpp:215
virtual void getPureGibbs(doublereal *gpure) const
Get the Gibbs functions for the pure species at the current T and P of the solution.
XML_Node * findByAttr(const std::string &attr, const std::string &val, int depth=100000) const
This routine carries out a recursive search for an XML node based on an attribute of each XML node...
Definition: xml.cpp:716
virtual doublereal density() const
Density (kg/m^3).
Definition: Phase.h:534
virtual void getPartialMolarEntropies(doublereal *sbar) const
Returns an array of partial molar entropies of the species in the solution.
virtual void getChemPotentials(doublereal *mu) const
Get the species chemical potentials.
virtual void initThermoXML(XML_Node &phaseNode, const std::string &id)
XML_Node * findXMLPhase(XML_Node *root, const std::string &idtarget)
Search an XML_Node tree for a named phase XML_Node.
Definition: xml.cpp:1104
size_t nElements() const
Number of elements.
Definition: Phase.cpp:139
const doublereal OneAtm
One atmosphere [Pa].
Definition: ct_defs.h:71
virtual void getChemPotentials_RT(doublereal *mu) const
Get the array of non-dimensional species solution chemical potentials at the current T and P ...
vector_fp m_pp
Temporary array used in equilibrium calculations.
const vector_fp & entropy_R_ref() const
Returns a reference to the vector of nondimensional enthalpies of the reference state at the current ...
std::string attrib(const std::string &attr) const
Function returns the value of an attribute.
Definition: xml.cpp:534
void getEntropy_R(doublereal *sr) const
Get the nondimensional Entropies for the species standard states at the current T and P of the soluti...
doublereal _RT() const
Return the Gas Constant multiplied by the current temperature.
Definition: ThermoPhase.h:977
ThermoPhase & operator=(const ThermoPhase &right)
Assignment operator.
Definition: ThermoPhase.cpp:57
double speciesMolarVolume(int k) const
Report the molar volume of species k.
virtual void setMoleFractions_NoNorm(const doublereal *const x)
Set the mole fractions, but don't normalize them to one.
virtual doublereal referenceConcentration(int k) const
The reference (ie standard) concentration used to normalize the generalized concentration.
virtual void getIntEnergy_RT(doublereal *urt) const
Returns the vector of nondimensional internal Energies of the standard state at the current temperatu...
void calcDensity()
Calculate the density of the mixture using the partial molar volumes and mole fractions as input...
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:100
virtual void setPressure(doublereal p)
Set the pressure at constant temperature.
doublereal getFloat(const Cantera::XML_Node &parent, const std::string &name, const std::string &type)
Get a floating-point value from a child element.
Definition: ctml.cpp:267
const vector_fp & cp_R_ref() const
Returns a reference to the vector of nondimensional enthalpies of the reference state at the current ...
doublereal molarDensity() const
Molar density (kmol/m^3).
Definition: Phase.cpp:597
std::string lowercase(const std::string &s)
Cast a copy of a string to lower case.
Definition: stringUtils.cpp:58
virtual void setMassFractions(const doublereal *const y)
Set the mass fractions, and normalize them to one.
virtual doublereal intEnergy_mole() const
Molar internal energy of the solution.
vector_fp m_speciesMolarVolume
Vector of molar volumes for each species in the solution.
XML_Node & child(const size_t n) const
Return a changeable reference to the n'th child of the current node.
Definition: xml.cpp:584
virtual void getActivityConcentrations(doublereal *c) const
This method returns the array of generalized concentrations.
virtual void initThermo()
Initialization of an IdealSolidSolnPhase phase: Note this function is pretty much useless because it ...
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:101
virtual void getActivityCoefficients(doublereal *ac) const
Get the array of species activity coefficients.
doublereal mean_X(const doublereal *const Q) const
Evaluate the mole-fraction-weighted mean of an array Q.
Definition: Phase.cpp:623
const XML_Node * findByName(const std::string &nm, int depth=100000) const
This routine carries out a recursive search for an XML node based on the name of the node...
Definition: xml.cpp:754
bool importPhase(XML_Node &phase, ThermoPhase *th, SpeciesThermoFactory *spfactory)
Import a phase information into an empty thermophase object.
int m_formGC
Format for the generalized concentrations.
doublereal m_Pcurrent
m_Pcurrent = The current pressure Since the density isn't a function of pressure, but only of the mol...
virtual int eosType() const
Equation of state flag.
virtual void getStandardVolumes(doublereal *vol) const
Get the molar volumes of each species in their standard states at the current T and P of the solution...
virtual void getGibbs_RT_ref(doublereal *grt) const
Returns the vector of nondimensional enthalpies of the reference state at the current temperature of ...
doublereal sum_xlogx() const
Evaluate .
Definition: Phase.cpp:633
const vector_fp & enthalpy_RT_ref() const
Returns a reference to the vector of nondimensional enthalpies of the reference state at the current ...
void getCp_R(doublereal *cpr) const
Get the nondimensional heat capacity at constant pressure function for the species standard states at...
doublereal m_Pref
Value of the reference pressure for all species in this phase.
virtual void getEnthalpy_RT_ref(doublereal *hrt) const
Returns the vector of nondimensional enthalpies of the reference state at the current temperature of ...
virtual doublereal enthalpy_mole() const
Molar enthalpy of the solution.
Header file for an ideal solid solution model with incompressible thermodynamics (see Thermodynamic P...
const vector_fp & gibbs_RT_ref() const
Returns a reference to the vector of nondimensional enthalpies of the reference state at the current ...
virtual doublereal standardConcentration(size_t k) const
The standard concentration used to normalize the generalized concentration.
virtual void setMoleFractions(const doublereal *const x)
Set the mole fractions.
virtual void getPartialMolarCp(doublereal *cpbar) const
Returns an array of partial molar Heat Capacities at constant pressure of the species in the solution...
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:68
vector_fp m_expg0_RT
Vector containing the species reference exp(-G/RT) functions at T = m_tlast.
doublereal m_tlast
Value of the temperature at which the thermodynamics functions for the reference state of the species...
virtual void setConcentrations(const doublereal *const conc)
Set the concentrations to the specified values within the phase.
Definition: Phase.cpp:577
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...
Definition: Phase.cpp:306
virtual void getCp_R_ref(doublereal *cprt) const
Returns the vector of nondimensional constant pressure heat capacities of the reference state at the ...
bool hasChild(const std::string &ch) const
Tests whether the current node has a child node with a particular name.
Definition: xml.cpp:574
void getEnthalpy_RT(doublereal *hrt) const
Get the array of nondimensional Enthalpy functions for the standard state species at the current T an...
virtual void setToEquilState(const doublereal *lambda_RT)
Set mixture to an equilibrium state consistent with specified element potentials and the temperature...
doublereal dot(InputIter x_begin, InputIter x_end, InputIter2 y_begin)
Function that calculates a templated inner product.
Definition: utilities.h:131
virtual doublereal logStandardConc(size_t k) const
Returns the log of the standard concentration of the kth species.
virtual doublereal refPressure() const
Returns the reference pressure in Pa.
Definition: ThermoPhase.h:159
virtual void setMassFractions_NoNorm(const doublereal *const y)
Set the mass fractions to the specified values without normalizing.
Definition: Phase.cpp:388
const std::vector< std::string > & speciesNames() const
Return a const reference to the vector of species names.
Definition: Phase.cpp:252
doublereal moleFraction(size_t k) const
Return the mole fraction of a single species.
Definition: Phase.cpp:524
vector_fp m_cp0_R
Vector containing the species reference constant pressure heat capacities at T = m_tlast.
virtual void setMolarDensity(const doublereal rho)
Overwritten setMolarDensity() function is necessary because the density is not an independent variabl...
doublereal temperature() const
Temperature (K).
Definition: Phase.h:528
size_t nDim() const
Returns the number of spatial dimensions (1, 2, or 3)
Definition: Phase.h:512
virtual void getEntropy_R_ref(doublereal *er) const
Returns the vector of nondimensional entropies of the reference state at the current temperature of t...
virtual void setConcentrations(const doublereal *const c)
Set the concentration,.
virtual doublereal entropy_mole() const
Molar entropy of the solution.
std::string id() const
Return the id attribute, if present.
Definition: xml.cpp:467
virtual void initThermoXML(XML_Node &phaseNode, const std::string &id)
Import and initialize a ThermoPhase object using an XML tree.
const doublereal SmallNumber
smallest number to compare to zero.
Definition: ct_defs.h:139
virtual void getGibbs_ref(doublereal *g) const
Returns the vector of the gibbs function of the reference state at the current temperature of the sol...
Class IdealSolidSolnPhase represents a condensed phase ideal solution compound.
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:165
void initLengths()
This internal function adjusts the lengths of arrays.
void scale(InputIter begin, InputIter end, OutputIter out, S scale_factor)
Multiply elements of an array by a scale factor.
Definition: utilities.h:154
virtual void setDensity(const doublereal rho)
Overwritten setDensity() function is necessary because the density is not an independent variable...
doublereal meanMolecularWeight() const
The mean molecular weight. Units: (kg/kmol)
Definition: Phase.h:588
const doublereal GasConstant
Universal Gas Constant. [J/kmol/K].
Definition: ct_defs.h:66
virtual void setState_PX(doublereal p, doublereal *x)
Set the pressure (Pa) and mole fractions.
Contains declarations for string manipulation functions within Cantera.
virtual doublereal pressure() const
Pressure.
virtual void getGibbs_RT(doublereal *grt) const
Get the nondimensional gibbs function for the species standard states at the current T and P of the s...
#define DATA_PTR(vec)
Creates a pointer to the start of the raw data for a vector.
Definition: ct_defs.h:36
vector_fp m_h0_RT
Vector containing the species reference enthalpies at T = m_tlast.
virtual void setMassFractions(const doublereal *const y)
Set the mass fractions to the specified values and normalize them.
Definition: Phase.cpp:374
virtual void getPartialMolarEnthalpies(doublereal *hbar) const
Returns an array of partial molar enthalpies for the species in the mixture.
size_t m_kk
Number of species in the phase.
Definition: Phase.h:716
virtual void update(doublereal T, doublereal *cp_R, doublereal *h_RT, doublereal *s_R) const =0
Compute the reference-state properties for all species.
virtual void initThermoFile(const std::string &inputFile, const std::string &id)
vector_fp m_pe
Vector of potential energies for the species.
XML_Node & root() const
Return the root of the current XML_Node tree.
Definition: xml.cpp:1091
IdealSolidSolnPhase & operator=(const IdealSolidSolnPhase &)
Assignment operator.
virtual void getUnitsStandardConc(double *uA, int k=0, int sizeUA=6) const
Returns the units of the standard and general concentrations Note they have the same units...
virtual void setMassFractions_NoNorm(const doublereal *const y)
Set the mass fractions, but don't normalize them to one.
SpeciesThermo * m_spthermo
Pointer to the calculation manager for species reference-state thermodynamic properties.
Definition: ThermoPhase.h:1625
virtual ThermoPhase * duplMyselfAsThermoPhase() const
virtual void getPartialMolarVolumes(doublereal *vbar) const
returns an array of partial molar volumes of the species in the solution.
virtual void getIntEnergy_RT_ref(doublereal *urt) const
Returns the vector of nondimensional internal Energies of the reference state at the current temperat...
const doublereal * moleFractdivMMW() const
Returns a const pointer to the start of the moleFraction/MW array.
Definition: Phase.cpp:540
XML_Node * get_XML_NameID(const std::string &nameTarget, const std::string &file_ID, XML_Node *root)
This routine will locate an XML node in either the input XML tree or in another input file specified ...
Definition: global.cpp:271
IdealSolidSolnPhase(int formCG=0)
Constructor for IdealSolidSolnPhase.
virtual void setDensity(const doublereal density_)
Set the internally stored density (kg/m^3) of the phase Note the density of a phase is an independent...
Definition: Phase.h:549
virtual doublereal gibbs_mole() const
Molar gibbs free energy of the solution.
virtual doublereal cp_mole() const
Molar heat capacity at constant pressure of the solution.
vector_fp m_s0_R
Vector containing the species reference entropies at T = m_tlast.
vector_fp m_g0_RT
Vector containing the species reference Gibbs functions at T = m_tlast.