Cantera  2.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PDSS_HKFT.cpp
Go to the documentation of this file.
1 /**
2  * @file PDSS_HKFT.cpp
3  * Definitions for the class PDSS_HKFT (pressure dependent standard state)
4  * which handles calculations for a single species in a phase using the
5  * HKFT standard state
6  * (see \ref pdssthermo and class \link Cantera::PDSS_HKFT PDSS_HKFT\endlink).
7  */
8 /*
9  * Copyright (2006) Sandia Corporation. Under the terms of
10  * Contract DE-AC04-94AL85000 with Sandia Corporation, the
11  * U.S. Government retains certain rights in this software.
12  */
13 
14 #include "cantera/base/ctml.h"
19 
20 #include <fstream>
21 
22 using namespace std;
23 
24 namespace Cantera
25 {
26 /*
27  * Set the default to error exit if there is an input file inconsistency
28  */
29 int PDSS_HKFT::s_InputInconsistencyErrorExit = 1;
30 
31 PDSS_HKFT::PDSS_HKFT(VPStandardStateTP* tp, size_t spindex) :
32  PDSS(tp, spindex),
33  m_waterSS(0),
34  m_densWaterSS(-1.0),
35  m_waterProps(0),
36  m_born_coeff_j(-1.0),
37  m_r_e_j(-1.0),
38  m_deltaG_formation_tr_pr(0.0),
39  m_deltaH_formation_tr_pr(0.0),
40  m_Mu0_tr_pr(0.0),
41  m_Entrop_tr_pr(0.0),
42  m_a1(0.0),
43  m_a2(0.0),
44  m_a3(0.0),
45  m_a4(0.0),
46  m_c1(0.0),
47  m_c2(0.0),
48  m_omega_pr_tr(0.0),
49  m_Y_pr_tr(0.0),
50  m_Z_pr_tr(0.0),
51  m_presR_bar(0.0),
52  m_domega_jdT_prtr(0.0),
53  m_charge_j(0.0)
54 {
55  m_pres = OneAtm;
56  m_pdssType = cPDSS_MOLAL_HKFT;
57  m_presR_bar = OneAtm * 1.0E-5;
58  m_presR_bar = 1.0;
59 }
60 
62  const std::string& inputFile, const std::string& id) :
63  PDSS(tp, spindex),
64  m_waterSS(0),
65  m_densWaterSS(-1.0),
66  m_waterProps(0),
67  m_born_coeff_j(-1.0),
68  m_r_e_j(-1.0),
69  m_deltaG_formation_tr_pr(0.0),
70  m_deltaH_formation_tr_pr(0.0),
71  m_Mu0_tr_pr(0.0),
72  m_Entrop_tr_pr(0.0),
73  m_a1(0.0),
74  m_a2(0.0),
75  m_a3(0.0),
76  m_a4(0.0),
77  m_c1(0.0),
78  m_c2(0.0),
79  m_omega_pr_tr(0.0),
80  m_Y_pr_tr(0.0),
81  m_Z_pr_tr(0.0),
82  m_presR_bar(1.0),
83  m_domega_jdT_prtr(0.0),
84  m_charge_j(0.0)
85 {
86  m_pres = OneAtm;
87  m_pdssType = cPDSS_MOLAL_HKFT;
88  m_presR_bar = OneAtm * 1.0E-5;
89  m_presR_bar = 1.0;
90  constructPDSSFile(tp, spindex, inputFile, id);
91 }
92 
93 PDSS_HKFT::PDSS_HKFT(VPStandardStateTP* tp, size_t spindex, const XML_Node& speciesNode,
94  const XML_Node& phaseRoot, bool spInstalled) :
95  PDSS(tp, spindex),
96  m_waterSS(0),
97  m_densWaterSS(-1.0),
98  m_waterProps(0),
99  m_born_coeff_j(-1.0),
100  m_r_e_j(-1.0),
101  m_deltaG_formation_tr_pr(0.0),
102  m_deltaH_formation_tr_pr(0.0),
103  m_Mu0_tr_pr(0.0),
104  m_Entrop_tr_pr(0.0),
105  m_a1(0.0),
106  m_a2(0.0),
107  m_a3(0.0),
108  m_a4(0.0),
109  m_c1(0.0),
110  m_c2(0.0),
111  m_omega_pr_tr(0.0),
112  m_Y_pr_tr(0.0),
113  m_Z_pr_tr(0.0),
114  m_presR_bar(0.0),
115  m_domega_jdT_prtr(0.0),
116  m_charge_j(0.0)
117 {
118  m_pres = OneAtm;
119  m_pdssType = cPDSS_MOLAL_HKFT;
120  m_presR_bar = OneAtm * 1.0E-5;
121  m_presR_bar = 1.0;
122  // We have to read the info from here
123  constructPDSSXML(tp, spindex, speciesNode, phaseRoot, spInstalled);
124 }
125 
127  PDSS(b),
128  m_waterSS(0),
129  m_densWaterSS(-1.0),
130  m_waterProps(0),
131  m_born_coeff_j(-1.0),
132  m_r_e_j(-1.0),
133  m_deltaG_formation_tr_pr(0.0),
134  m_deltaH_formation_tr_pr(0.0),
135  m_Mu0_tr_pr(0.0),
136  m_Entrop_tr_pr(0.0),
137  m_a1(0.0),
138  m_a2(0.0),
139  m_a3(0.0),
140  m_a4(0.0),
141  m_c1(0.0),
142  m_c2(0.0),
143  m_omega_pr_tr(0.0),
144  m_Y_pr_tr(0.0),
145  m_Z_pr_tr(0.0),
146  m_presR_bar(0.0),
147  m_domega_jdT_prtr(0.0),
148  m_charge_j(0.0)
149 {
150  m_pdssType = cPDSS_MOLAL_HKFT;
151  m_presR_bar = OneAtm * 1.0E-5;
152  /*
153  * Use the assignment operator to do the brunt
154  * of the work for the copy constructor.
155  */
156  *this = b;
157 }
158 
160 {
161  if (&b == this) {
162  return *this;
163  }
164  /*
165  * Call the base class operator
166  */
167  PDSS::operator=(b);
168 
169  //! Need to call initAllPtrs AFTER, to get the correct m_waterSS
170  m_waterSS = 0;
172  //! Need to call initAllPtrs AFTER, to get the correct m_waterProps
173  delete m_waterProps;
174  m_waterProps = 0;
176  m_r_e_j = b.m_r_e_j;
181  m_a1 = b.m_a1;
182  m_a2 = b.m_a2;
183  m_a3 = b.m_a3;
184  m_a4 = b.m_a4;
185  m_c1 = b.m_c1;
186  m_c2 = b.m_c2;
188  m_Y_pr_tr = b.m_Y_pr_tr;
189  m_Z_pr_tr = b.m_Z_pr_tr;
193 
194  // Here we just fill these in so that local copies within the VPSS object work.
195  m_waterSS = b.m_waterSS;
197 
198  return *this;
199 }
200 
202 {
203  delete m_waterProps;
204 }
205 
207 {
208  return new PDSS_HKFT(*this);
209 }
210 
211 doublereal PDSS_HKFT::enthalpy_mole() const
212 {
213  // Ok we may change this evaluation method in the future.
214  doublereal h = gibbs_mole() + m_temp * entropy_mole();
215 
216 #ifdef DEBUG_MODE_NOT
217  doublereal h2 = enthalpy_mole2();
218  if (fabs(h - h2) > 1.0E-1) {
219  printf("we are here, h = %g, h2 = %g, k = %d, T = %g, P = %g p0 = %g\n",
220  h, h2, m_spindex, m_temp, m_pres,
221  m_p0);
222  }
223 #endif
224  return h;
225 }
226 
227 #ifdef DEBUG_MODE
228 doublereal PDSS_HKFT::enthalpy_mole2() const
229 {
230  double enthTRPR = m_Mu0_tr_pr + 298.15 * m_Entrop_tr_pr * 1.0E3 * 4.184;
231  return deltaH() + enthTRPR;
232 }
233 #endif
234 
235 doublereal PDSS_HKFT::intEnergy_mole() const
236 {
237  return enthalpy_RT() - molarVolume() * m_pres;
238 }
239 
240 doublereal PDSS_HKFT::entropy_mole() const
241 {
242  return m_Entrop_tr_pr * 1.0E3 * 4.184 + deltaS();
243 }
244 
245 doublereal PDSS_HKFT::gibbs_mole() const
246 {
247  return m_Mu0_tr_pr + deltaG();
248 }
249 
250 doublereal PDSS_HKFT::cp_mole() const
251 {
252  doublereal pbar = m_pres * 1.0E-5;
253  doublereal c1term = m_c1;
254 
255  doublereal c2term = m_c2 / (m_temp - 228.) / (m_temp - 228.);
256 
257  doublereal a3term = -m_a3 / (m_temp - 228.) / (m_temp - 228.) / (m_temp - 228.) * 2.0 * m_temp * (pbar - m_presR_bar);
258 
259  doublereal a4term = -m_a4 / (m_temp - 228.) / (m_temp - 228.) / (m_temp - 228.) * 2.0 * m_temp
260  * log((2600. + pbar)/(2600. + m_presR_bar));
261 
262  doublereal omega_j;
263  doublereal domega_jdT;
264  doublereal d2omega_jdT2;
265  if (m_charge_j == 0.0) {
266  omega_j = m_omega_pr_tr;
267  domega_jdT = 0.0;
268  d2omega_jdT2 = 0.0;
269  } else {
270  doublereal nu = 166027;
271  doublereal r_e_j_pr_tr = m_charge_j * m_charge_j / (m_omega_pr_tr/nu + m_charge_j/3.082);
272 
273  doublereal gval = gstar(m_temp, m_pres, 0);
274 
275  doublereal dgvaldT = gstar(m_temp, m_pres, 1);
276  doublereal d2gvaldT2 = gstar(m_temp, m_pres, 2);
277 
278  doublereal r_e_j = r_e_j_pr_tr + fabs(m_charge_j) * gval;
279  doublereal dr_e_jdT = fabs(m_charge_j) * dgvaldT;
280  doublereal d2r_e_jdT2 = fabs(m_charge_j) * d2gvaldT2;
281 
282  doublereal r_e_j2 = r_e_j * r_e_j;
283 
284  doublereal charge2 = m_charge_j * m_charge_j;
285 
286  doublereal r_e_H = 3.082 + gval;
287  doublereal r_e_H2 = r_e_H * r_e_H;
288 
289  omega_j = nu * (charge2 / r_e_j - m_charge_j / r_e_H);
290 
291  domega_jdT = nu * (-(charge2 / r_e_j2 * dr_e_jdT)
292  +(m_charge_j / r_e_H2 * dgvaldT));
293 
294  d2omega_jdT2 = nu * (2.0*charge2*dr_e_jdT*dr_e_jdT/(r_e_j2*r_e_j) - charge2*d2r_e_jdT2/r_e_j2
295  -2.0*m_charge_j*dgvaldT*dgvaldT/(r_e_H2*r_e_H) + m_charge_j*d2gvaldT2 /r_e_H2);
296  }
297 
298  doublereal relepsilon = m_waterProps->relEpsilon(m_temp, m_pres, 0);
299  doublereal drelepsilondT = m_waterProps->relEpsilon(m_temp, m_pres, 1);
300 
301  doublereal Y = drelepsilondT / (relepsilon * relepsilon);
302 
303  doublereal d2relepsilondT2 = m_waterProps->relEpsilon(m_temp, m_pres, 2);
304 
305 #ifdef DEBUG_MODE_NOT
306  doublereal d1 = m_waterProps->relEpsilon(m_temp, m_pres, 1);
307  doublereal d2 = m_waterProps->relEpsilon(m_temp + 0.0001, m_pres, 1);
308  doublereal d3 = (d2 - d1) / 0.0001;
309  if (fabs(d2relepsilondT2 - d3) > 1.0E-6) {
310  printf("we are here\n");
311  }
312 #endif
313 
314  doublereal X = d2relepsilondT2 / (relepsilon* relepsilon) - 2.0 * relepsilon * Y * Y;
315 
316  doublereal Z = -1.0 / relepsilon;
317 
318  doublereal yterm = 2.0 * m_temp * Y * domega_jdT;
319 
320  doublereal xterm = omega_j * m_temp * X;
321 
322  doublereal otterm = m_temp * d2omega_jdT2 * (Z + 1.0);
323 
324  doublereal rterm = - m_domega_jdT_prtr * (m_Z_pr_tr + 1.0);
325 
326  doublereal Cp_calgmol = c1term + c2term + a3term + a4term + yterm + xterm + otterm + rterm;
327 
328  // Convert to Joules / kmol
329  doublereal Cp = Cp_calgmol * 1.0E3 * 4.184;
330 
331 #ifdef DEBUG_MODE_NOT
332  double e1 = enthalpy_mole();
333  m_temp = m_temp - 0.001;
334  double e2 = enthalpy_mole();
335  m_temp = m_temp + 0.001;
336  double cpd = (e1 - e2) / 0.001;
337  if (fabs(Cp - cpd) > 10.0) {
338  printf("Cp difference : raw: %g, delta: %g, k = %d, T = %g, m_pres = %g\n",
339  Cp, cpd, m_spindex, m_temp, m_pres);
340  }
341 #endif
342  return Cp;
343 }
344 
345 doublereal PDSS_HKFT::molarVolume() const
346 {
347  // Initially do all calculations in (cal/gmol/Pa)
348 
349  doublereal a1term = m_a1 * 1.0E-5;
350 
351  doublereal a2term = m_a2 / (2600.E5 + m_pres);
352 
353  doublereal a3term = m_a3 * 1.0E-5/ (m_temp - 228.);
354 
355  doublereal a4term = m_a4 / (m_temp - 228.) / (2600.E5 + m_pres);
356 
357  doublereal omega_j;
358  doublereal domega_jdP;
359  if (m_charge_j == 0.0) {
360  omega_j = m_omega_pr_tr;
361  domega_jdP = 0.0;
362  } else {
363  doublereal nu = 166027.;
364  doublereal charge2 = m_charge_j * m_charge_j;
365  doublereal r_e_j_pr_tr = charge2 / (m_omega_pr_tr/nu + m_charge_j/3.082);
366 
367  doublereal gval = gstar(m_temp, m_pres, 0);
368  doublereal dgvaldP = gstar(m_temp, m_pres, 3);
369 
370  doublereal r_e_j = r_e_j_pr_tr + fabs(m_charge_j) * gval;
371  doublereal r_e_H = 3.082 + gval;
372 
373  omega_j = nu * (charge2 / r_e_j - m_charge_j / r_e_H);
374 
375  doublereal dr_e_jdP = fabs(m_charge_j) * dgvaldP;
376 
377  domega_jdP = - nu * (charge2 / (r_e_j * r_e_j) * dr_e_jdP)
378  + nu * m_charge_j / (r_e_H * r_e_H) * dgvaldP;
379  }
380 
381  doublereal drelepsilondP = m_waterProps->relEpsilon(m_temp, m_pres, 3);
382 
383  doublereal relepsilon = m_waterProps->relEpsilon(m_temp, m_pres, 0);
384 
385  doublereal Q = drelepsilondP / (relepsilon * relepsilon);
386 
387  doublereal Z = -1.0 / relepsilon;
388 
389  doublereal wterm = - domega_jdP * (Z + 1.0);
390 
391  doublereal qterm = - omega_j * Q;
392 
393  doublereal molVol_calgmolPascal = a1term + a2term + a3term + a4term + wterm + qterm;
394 
395  // Convert to m**3 / kmol from (cal/gmol/Pa)
396  return molVol_calgmolPascal * 4.184 * 1.0E3;
397 }
398 
399 doublereal
401 {
402  return m_mw / molarVolume();
403 }
404 
405 doublereal
407 {
408  doublereal m_psave = m_pres;
410  doublereal ee = gibbs_RT();
411  m_pres = m_psave;
412  return ee;
413 }
414 
415 doublereal
417 {
418  doublereal m_psave = m_pres;
420  doublereal hh = enthalpy_RT();
421  m_pres = m_psave;
422  return hh;
423 }
424 
425 doublereal
427 {
428  doublereal m_psave = m_pres;
430  doublereal ee = entropy_R();
431  m_pres = m_psave;
432  return ee;
433 }
434 
435 doublereal
437 {
438  doublereal m_psave = m_pres;
440  doublereal ee = cp_R();
441  m_pres = m_psave;
442  return ee;
443 }
444 
445 doublereal
447 {
448  doublereal m_psave = m_pres;
450  doublereal ee = molarVolume();
451  m_pres = m_psave;
452  return ee;
453 }
454 
455 void PDSS_HKFT::setState_TP(doublereal temp, doublereal pres)
456 {
457  setTemperature(temp);
458  setPressure(pres);
459 }
460 
462 {
464 
465  m_waterSS = dynamic_cast<PDSS_Water*>(m_tp->providePDSS(0));
466  /*
467  * Section to initialize m_Z_pr_tr and m_Y_pr_tr
468  */
469  m_temp = 273.15 + 25.;
470  m_pres = OneAtm;
471  doublereal relepsilon = m_waterProps->relEpsilon(m_temp, m_pres, 0);
472 
475  m_Z_pr_tr = -1.0 / relepsilon;
476 
477  doublereal drelepsilondT = m_waterProps->relEpsilon(m_temp, m_pres, 1);
478 
479  m_Y_pr_tr = drelepsilondT / (relepsilon * relepsilon);
480 
482 
483  m_presR_bar = OneAtm / 1.0E5;
484  m_presR_bar = 1.0;
487 
488  //! Ok, we have mu. Let's check it against the input value
489  // of DH_F to see that we have some internal consistency
490 
491  doublereal Hcalc = m_Mu0_tr_pr + 298.15 * (m_Entrop_tr_pr * 1.0E3 * 4.184);
492 
493  doublereal DHjmol = m_deltaH_formation_tr_pr * 1.0E3 * 4.184;
494 
495  // If the discrepancy is greater than 100 cal gmol-1, print
496  // an error and exit.
497  if (fabs(Hcalc -DHjmol) > 100.* 1.0E3 * 4.184) {
498  std::string sname = m_tp->speciesName(m_spindex);
500 
501  throw CanteraError(" PDSS_HKFT::initThermo() for " + sname,
502  "DHjmol is not consistent with G and S: " +
503  fp2str(Hcalc/(4.184E3)) + " vs "
504  + fp2str(m_deltaH_formation_tr_pr) + "cal gmol-1");
505  } else {
506  writelog(" PDSS_HKFT::initThermo() WARNING: "
507  "DHjmol for " + sname + " is not consistent with G and S: calculated " +
508  fp2str(Hcalc/(4.184E3)) + " vs input "
509  + fp2str(m_deltaH_formation_tr_pr) + "cal gmol-1");
510  writelog(" : continuing with consistent DHjmol = " + fp2str(Hcalc/(4.184E3)));
511  m_deltaH_formation_tr_pr = Hcalc / (1.0E3 * 4.184);
512  }
513  }
514  doublereal nu = 166027;
515 
516  doublereal r_e_j_pr_tr;
517  if (m_charge_j != 0.0) {
518  r_e_j_pr_tr = m_charge_j * m_charge_j / (m_omega_pr_tr/nu + m_charge_j/3.082);
519  } else {
520  r_e_j_pr_tr = 0.0;
521  }
522 
523  if (m_charge_j == 0.0) {
524  m_domega_jdT_prtr = 0.0;
525  } else {
526  doublereal gval = gstar(m_temp, m_pres, 0);
527 
528  doublereal dgvaldT = gstar(m_temp, m_pres, 1);
529 
530  doublereal r_e_j = r_e_j_pr_tr + fabs(m_charge_j) * gval;
531  doublereal dr_e_jdT = fabs(m_charge_j) * dgvaldT;
532 
533  m_domega_jdT_prtr = - nu * (m_charge_j * m_charge_j / (r_e_j * r_e_j) * dr_e_jdT)
534  + nu * m_charge_j / (3.082 + gval) / (3.082 + gval) * dgvaldT;
535  }
536 }
537 
538 void PDSS_HKFT::initAllPtrs(VPStandardStateTP* vptp_ptr, VPSSMgr* vpssmgr_ptr,
539  SpeciesThermo* spthermo_ptr)
540 {
541  PDSS::initAllPtrs(vptp_ptr, vpssmgr_ptr, spthermo_ptr);
542  m_waterSS = dynamic_cast<PDSS_Water*>(m_tp->providePDSS(0));
543  delete m_waterProps;
545 }
546 
548  const XML_Node& speciesNode,
549  const XML_Node& phaseNode, bool spInstalled)
550 {
551  int hasDGO = 0;
552  int hasSO = 0;
553  int hasDHO = 0;
554 
555  if (!spInstalled) {
556  throw CanteraError("PDSS_HKFT::constructPDSSXML", "spInstalled false not handled");
557  }
558 
559  const XML_Node* tn = speciesNode.findByName("thermo");
560  if (!tn) {
561  throw CanteraError("PDSS_HKFT::constructPDSSXML",
562  "no thermo Node for species " + speciesNode.name());
563  }
564  if (lowercase(tn->attrib("model")) != "hkft") {
565  throw CanteraError("PDSS_HKFT::initThermoXML",
566  "thermo model for species isn't hkft: "
567  + speciesNode.name());
568  }
569  const XML_Node* hh = tn->findByName("HKFT");
570  if (!hh) {
571  throw CanteraError("PDSS_HKFT::constructPDSSXML",
572  "no Thermo::HKFT Node for species " + speciesNode.name());
573  }
574 
575  // go get the attributes
576  m_p0 = OneAtm;
577  std::string p0string = hh->attrib("Pref");
578  if (p0string != "") {
579  m_p0 = strSItoDbl(p0string);
580  }
581 
582  std::string minTstring = hh->attrib("Tmin");
583  if (minTstring != "") {
584  m_minTemp = fpValueCheck(minTstring);
585  }
586 
587  std::string maxTstring = hh->attrib("Tmax");
588  if (maxTstring != "") {
589  m_maxTemp = fpValueCheck(maxTstring);
590  }
591 
592  if (hh->hasChild("DG0_f_Pr_Tr")) {
593  doublereal val = getFloat(*hh, "DG0_f_Pr_Tr");
595  hasDGO = 1;
596  }
597 
598  if (hh->hasChild("DH0_f_Pr_Tr")) {
599  doublereal val = getFloat(*hh, "DH0_f_Pr_Tr");
601  hasDHO = 1;
602  }
603 
604  if (hh->hasChild("S0_Pr_Tr")) {
605  doublereal val = getFloat(*hh, "S0_Pr_Tr");
606  m_Entrop_tr_pr= val;
607  hasSO = 1;
608  }
609 
610  const XML_Node* ss = speciesNode.findByName("standardState");
611  if (!ss) {
612  throw CanteraError("PDSS_HKFT::constructPDSSXML",
613  "no standardState Node for species " + speciesNode.name());
614  }
615  if (lowercase(ss->attrib("model")) != "hkft") {
616  throw CanteraError("PDSS_HKFT::initThermoXML",
617  "standardState model for species isn't hkft: "
618  + speciesNode.name());
619  }
620  if (ss->hasChild("a1")) {
621  m_a1 = getFloat(*ss, "a1");
622  } else {
623  throw CanteraError("PDSS_HKFT::constructPDSSXML", " missing a1 field");
624  }
625  if (ss->hasChild("a2")) {
626  m_a2 = getFloat(*ss, "a2");
627  } else {
628  throw CanteraError("PDSS_HKFT::constructPDSSXML", " missing a2 field");
629  }
630  if (ss->hasChild("a3")) {
631  m_a3 = getFloat(*ss, "a3");
632  } else {
633  throw CanteraError("PDSS_HKFT::constructPDSSXML", " missing a3 field");
634  }
635  if (ss->hasChild("a4")) {
636  m_a4 = getFloat(*ss, "a4");
637  } else {
638  throw CanteraError("PDSS_HKFT::constructPDSSXML", " missing a4 field");
639  }
640 
641  if (ss->hasChild("c1")) {
642  m_c1 = getFloat(*ss, "c1");
643  } else {
644  throw CanteraError("PDSS_HKFT::constructPDSSXML", " missing c1 field");
645  }
646  if (ss->hasChild("c2")) {
647  m_c2 = getFloat(*ss, "c2");
648  } else {
649  throw CanteraError("PDSS_HKFT::constructPDSSXML", " missing c2 field");
650  }
651  if (ss->hasChild("omega_Pr_Tr")) {
652  m_omega_pr_tr = getFloat(*ss, "omega_Pr_Tr");
653  } else {
654  throw CanteraError("PDSS_HKFT::constructPDSSXML", " missing omega_Pr_Tr field");
655  }
656 
657 
658  int isum = hasDGO + hasDHO + hasSO;
659  if (isum < 2) {
660  throw CanteraError("PDSS_HKFT::constructPDSSXML",
661  "Missing 2 or more of DG0_f_Pr_Tr, DH0_f_Pr_Tr, or S0_f_Pr_Tr fields. "
662  "Need to supply at least two of these fields");
663  }
664  // Ok, if we are missing one, then we construct its value from the other two.
665  // This code has been internally verified.
666  if (hasDHO == 0) {
669  doublereal Hcalc = m_Mu0_tr_pr + 298.15 * (m_Entrop_tr_pr * 1.0E3 * 4.184);
670  m_deltaH_formation_tr_pr = Hcalc / (1.0E3 * 4.184);
671  }
672  if (hasDGO == 0) {
673  doublereal DHjmol = m_deltaH_formation_tr_pr * 1.0E3 * 4.184;
674  m_Mu0_tr_pr = DHjmol - 298.15 * (m_Entrop_tr_pr * 1.0E3 * 4.184);
675  m_deltaG_formation_tr_pr = m_Mu0_tr_pr / (1.0E3 * 4.184);
676  double tmp = m_Mu0_tr_pr;
679  double totalSum = m_Mu0_tr_pr - tmp;
680  m_Mu0_tr_pr = tmp;
681  m_deltaG_formation_tr_pr = (m_Mu0_tr_pr - totalSum)/ (1.0E3 * 4.184);
682  }
683  if (hasSO == 0) {
686  doublereal DHjmol = m_deltaH_formation_tr_pr * 1.0E3 * 4.184;
687  m_Entrop_tr_pr = (DHjmol - m_Mu0_tr_pr) / (298.15 * 1.0E3 * 4.184);
688  }
689 
690 }
691 
693  const std::string& inputFile,
694  const std::string& id)
695 {
696  if (inputFile.size() == 0) {
697  throw CanteraError("PDSS_HKFT::initThermo",
698  "input file is null");
699  }
700  std::string path = findInputFile(inputFile);
701  ifstream fin(path.c_str());
702  if (!fin) {
703  throw CanteraError("PDSS_HKFT::initThermo","could not open "
704  +path+" for reading.");
705  }
706  /*
707  * The phase object automatically constructs an XML object.
708  * Use this object to store information.
709  */
710 
711  XML_Node fxml;
712  fxml.build(fin);
713  XML_Node* fxml_phase = findXMLPhase(&fxml, id);
714  if (!fxml_phase) {
715  throw CanteraError("PDSS_HKFT::initThermo",
716  "ERROR: Can not find phase named " +
717  id + " in file named " + inputFile);
718  }
719 
720  XML_Node& speciesList = fxml_phase->child("speciesArray");
721  XML_Node* speciesDB = get_XML_NameID("speciesData", speciesList["datasrc"],
722  &(fxml_phase->root()));
723  const XML_Node* s = speciesDB->findByAttr("name", tp->speciesName(spindex));
724 
725  constructPDSSXML(tp, spindex, *s, *fxml_phase, true);
726 }
727 
728 #ifdef DEBUG_MODE
729 doublereal PDSS_HKFT::deltaH() const
730 {
731  doublereal pbar = m_pres * 1.0E-5;
732 
733  doublereal c1term = m_c1 * (m_temp - 298.15);
734 
735  doublereal a1term = m_a1 * (pbar - m_presR_bar);
736 
737  doublereal a2term = m_a2 * log((2600. + pbar)/(2600. + m_presR_bar));
738 
739  doublereal c2term = -m_c2 * (1.0/(m_temp - 228.) - 1.0/(298.15 - 228.));
740 
741  double a3tmp = (2.0 * m_temp - 228.)/ (m_temp - 228.) /(m_temp - 228.);
742 
743  doublereal a3term = m_a3 * a3tmp * (pbar - m_presR_bar);
744 
745  doublereal a4term = m_a4 * a3tmp * log((2600. + pbar)/(2600. + m_presR_bar));
746 
747  doublereal omega_j;
748  doublereal domega_jdT;
749  if (m_charge_j == 0.0) {
750  omega_j = m_omega_pr_tr;
751  domega_jdT = 0.0;
752  } else {
753  doublereal nu = 166027;
754  doublereal r_e_j_pr_tr = m_charge_j * m_charge_j / (m_omega_pr_tr/nu + m_charge_j/3.082);
755  doublereal gval = gstar(m_temp, m_pres, 0);
756  doublereal r_e_j = r_e_j_pr_tr + fabs(m_charge_j) * gval;
757 
758  doublereal dgvaldT = gstar(m_temp, m_pres, 1);
759  doublereal dr_e_jdT = fabs(m_charge_j) * dgvaldT;
760 
761  omega_j = nu * (m_charge_j * m_charge_j / r_e_j - m_charge_j / (3.082 + gval));
762 
763  domega_jdT = - nu * (m_charge_j * m_charge_j / (r_e_j * r_e_j) * dr_e_jdT)
764  + nu * m_charge_j / (3.082 + gval) / (3.082 + gval) * dgvaldT;
765  }
766 
767  doublereal relepsilon = m_waterProps->relEpsilon(m_temp, m_pres, 0);
768  doublereal drelepsilondT = m_waterProps->relEpsilon(m_temp, m_pres, 1);
769 
770  doublereal Y = drelepsilondT / (relepsilon * relepsilon);
771 
772  doublereal Z = -1.0 / relepsilon;
773 
774  doublereal yterm = m_temp * omega_j * Y;
775  doublereal yrterm = - 298.15 * m_omega_pr_tr * m_Y_pr_tr;
776 
777  doublereal wterm = - omega_j * (Z + 1.0);
778  doublereal wrterm = + m_omega_pr_tr * (m_Z_pr_tr + 1.0);
779 
780  doublereal otterm = m_temp * domega_jdT * (Z + 1.0);
781  doublereal otrterm = - m_temp * m_domega_jdT_prtr * (m_Z_pr_tr + 1.0);
782 
783  doublereal deltaH_calgmol = c1term + a1term + a2term + c2term + a3term + a4term
784  + yterm + yrterm + wterm + wrterm + otterm + otrterm;
785 
786  // Convert to Joules / kmol
787  return deltaH_calgmol * 1.0E3 * 4.184;
788 }
789 #endif
790 //================================================================================================================
791 doublereal PDSS_HKFT::deltaG() const
792 {
793  doublereal pbar = m_pres * 1.0E-5;
794  doublereal sterm = - m_Entrop_tr_pr * (m_temp - 298.15);
795 
796  doublereal c1term = -m_c1 * (m_temp * log(m_temp/298.15) - (m_temp - 298.15));
797  doublereal a1term = m_a1 * (pbar - m_presR_bar);
798 
799  doublereal a2term = m_a2 * log((2600. + pbar)/(2600. + m_presR_bar));
800 
801  doublereal c2term = -m_c2 * ((1.0/(m_temp - 228.) - 1.0/(298.15 - 228.)) * (228. - m_temp)/228.
802  - m_temp / (228.*228.) * log((298.15*(m_temp-228.)) / (m_temp*(298.15-228.))));
803 
804  doublereal a3term = m_a3 / (m_temp - 228.) * (pbar - m_presR_bar);
805 
806  doublereal a4term = m_a4 / (m_temp - 228.) * log((2600. + pbar)/(2600. + m_presR_bar));
807 
808  doublereal omega_j;
809  if (m_charge_j == 0.0) {
810  omega_j = m_omega_pr_tr;
811  } else {
812  doublereal nu = 166027;
813  doublereal r_e_j_pr_tr = m_charge_j * m_charge_j / (m_omega_pr_tr/nu + m_charge_j/3.082);
814  doublereal gval = gstar(m_temp, m_pres, 0);
815  doublereal r_e_j = r_e_j_pr_tr + fabs(m_charge_j) * gval;
816  omega_j = nu * (m_charge_j * m_charge_j / r_e_j - m_charge_j / (3.082 + gval));
817  }
818 
819  doublereal relepsilon = m_waterProps->relEpsilon(m_temp, m_pres, 0);
820 
821  doublereal Z = -1.0 / relepsilon;
822 
823  doublereal wterm = - omega_j * (Z + 1.0);
824 
825  doublereal wrterm = m_omega_pr_tr * (m_Z_pr_tr + 1.0);
826 
827  doublereal yterm = m_omega_pr_tr * m_Y_pr_tr * (m_temp - 298.15);
828 
829  doublereal deltaG_calgmol = sterm + c1term + a1term + a2term + c2term + a3term + a4term + wterm + wrterm + yterm;
830 
831  // Convert to Joules / kmol
832  return deltaG_calgmol * 1.0E3 * 4.184;
833 }
834 
835 doublereal PDSS_HKFT::deltaS() const
836 {
837  doublereal pbar = m_pres * 1.0E-5;
838 
839  doublereal c1term = m_c1 * log(m_temp/298.15);
840 
841  doublereal c2term = -m_c2 / 228. * ((1.0/(m_temp - 228.) - 1.0/(298.15 - 228.))
842  + 1.0 / 228. * log((298.15*(m_temp-228.)) / (m_temp*(298.15-228.))));
843 
844  doublereal a3term = m_a3 / (m_temp - 228.) / (m_temp - 228.) * (pbar - m_presR_bar);
845 
846  doublereal a4term = m_a4 / (m_temp - 228.) / (m_temp - 228.) * log((2600. + pbar)/(2600. + m_presR_bar));
847 
848  doublereal omega_j;
849  doublereal domega_jdT;
850  if (m_charge_j == 0.0) {
851  omega_j = m_omega_pr_tr;
852  domega_jdT = 0.0;
853  } else {
854 
855  doublereal nu = 166027;
856  doublereal r_e_j_pr_tr = m_charge_j * m_charge_j / (m_omega_pr_tr/nu + m_charge_j/3.082);
857 
858  doublereal gval = gstar(m_temp, m_pres, 0);
859 
860  doublereal dgvaldT = gstar(m_temp, m_pres, 1);
861 
862  doublereal r_e_j = r_e_j_pr_tr + fabs(m_charge_j) * gval;
863  doublereal dr_e_jdT = fabs(m_charge_j) * dgvaldT;
864 
865  omega_j = nu * (m_charge_j * m_charge_j / r_e_j - m_charge_j / (3.082 + gval));
866 
867  domega_jdT = - nu * (m_charge_j * m_charge_j / (r_e_j * r_e_j) * dr_e_jdT)
868  + nu * m_charge_j / (3.082 + gval) / (3.082 + gval) * dgvaldT;
869  }
870 
871  doublereal relepsilon = m_waterProps->relEpsilon(m_temp, m_pres, 0);
872  doublereal drelepsilondT = m_waterProps->relEpsilon(m_temp, m_pres, 1);
873 
874  doublereal Y = drelepsilondT / (relepsilon * relepsilon);
875 
876  doublereal Z = -1.0 / relepsilon;
877 
878  doublereal wterm = omega_j * Y;
879 
880  doublereal wrterm = - m_omega_pr_tr * m_Y_pr_tr;
881 
882  doublereal otterm = domega_jdT * (Z + 1.0);
883 
884  doublereal otrterm = - m_domega_jdT_prtr * (m_Z_pr_tr + 1.0);
885 
886  doublereal deltaS_calgmol = c1term + c2term + a3term + a4term + wterm + wrterm + otterm + otrterm;
887 
888  // Convert to Joules / kmol
889  return deltaS_calgmol * 1.0E3 * 4.184;
890 }
891 
892 doublereal PDSS_HKFT::ag(const doublereal temp, const int ifunc) const
893 {
894  static doublereal ag_coeff[3] = { -2.037662, 5.747000E-3, -6.557892E-6};
895  if (ifunc == 0) {
896  return ag_coeff[0] + ag_coeff[1] * temp + ag_coeff[2] * temp * temp;
897  } else if (ifunc == 1) {
898  return ag_coeff[1] + ag_coeff[2] * 2.0 * temp;
899  }
900  if (ifunc != 2) {
901  return 0.0;
902  }
903  return ag_coeff[2] * 2.0;
904 }
905 
906 doublereal PDSS_HKFT::bg(const doublereal temp, const int ifunc) const
907 {
908  static doublereal bg_coeff[3] = { 6.107361, -1.074377E-2, 1.268348E-5};
909  if (ifunc == 0) {
910  return bg_coeff[0] + bg_coeff[1] * temp + bg_coeff[2] * temp * temp;
911  } else if (ifunc == 1) {
912  return bg_coeff[1] + bg_coeff[2] * 2.0 * temp;
913  }
914  if (ifunc != 2) {
915  return 0.0;
916  }
917  return bg_coeff[2] * 2.0;
918 }
919 
920 doublereal PDSS_HKFT::f(const doublereal temp, const doublereal pres, const int ifunc) const
921 {
922  static doublereal af_coeff[3] = { 3.666666E1, -0.1504956E-9, 0.5107997E-13};
923  doublereal TC = temp - 273.15;
924  doublereal presBar = pres / 1.0E5;
925 
926  if (TC < 155.0) {
927  return 0.0;
928  }
929  TC = std::min(TC, 355.0);
930  if (presBar > 1000.) {
931  return 0.0;
932  }
933 
934 
935  doublereal T1 = (TC-155.0)/300.;
936  doublereal p2 = (1000. - presBar) * (1000. - presBar);
937  doublereal p3 = (1000. - presBar) * p2;
938  doublereal p4 = p2 * p2;
939  doublereal fac2 = af_coeff[1] * p3 + af_coeff[2] * p4;
940  if (ifunc == 0) {
941  return pow(T1,4.8) + af_coeff[0] * pow(T1, 16.0) * fac2;
942  } else if (ifunc == 1) {
943  return (4.8 * pow(T1,3.8) + 16.0 * af_coeff[0] * pow(T1, 15.0)) / 300. * fac2;
944  } else if (ifunc == 2) {
945  return (4.8 * 3.8 * pow(T1,2.8) + 16.0 * 15.0 * af_coeff[0] * pow(T1, 14.0)) / (300. * 300.) * fac2;
946  } else if (ifunc == 3) {
947  double fac1 = pow(T1,4.8) + af_coeff[0] * pow(T1, 16.0);
948  fac2 = - (3.0 * af_coeff[1] * p2 + 4.0 * af_coeff[2] * p3)/ 1.0E5;
949  return fac1 * fac2;
950  } else {
951  throw CanteraError("HKFT_PDSS::gg", "unimplemented");
952  }
953 }
954 
955 doublereal PDSS_HKFT::g(const doublereal temp, const doublereal pres, const int ifunc) const
956 {
957  doublereal afunc = ag(temp, 0);
958  doublereal bfunc = bg(temp, 0);
959  m_waterSS->setState_TP(temp, pres);
961  // density in gm cm-3
962  doublereal dens = m_densWaterSS * 1.0E-3;
963  doublereal gval = afunc * pow((1.0-dens), bfunc);
964  if (dens >= 1.0) {
965  return 0.0;
966  }
967  if (ifunc == 0) {
968  return gval;
969 
970  } else if (ifunc == 1 || ifunc == 2) {
971  doublereal afuncdT = ag(temp, 1);
972  doublereal bfuncdT = bg(temp, 1);
973  doublereal alpha = m_waterSS->thermalExpansionCoeff();
974 
975  doublereal fac1 = afuncdT * gval / afunc;
976  doublereal fac2 = bfuncdT * gval * log(1.0 - dens);
977  doublereal fac3 = gval * alpha * bfunc * dens / (1.0 - dens);
978 
979  doublereal dgdt = fac1 + fac2 + fac3;
980  if (ifunc == 1) {
981  return dgdt;
982  }
983 
984  doublereal afuncdT2 = ag(temp, 2);
985  doublereal bfuncdT2 = bg(temp, 2);
986 
987  doublereal dfac1dT = dgdt * afuncdT / afunc + afuncdT2 * gval / afunc
988  - afuncdT * afuncdT * gval / (afunc * afunc);
989 
990  doublereal ddensdT = - alpha * dens;
991  doublereal dfac2dT = bfuncdT2 * gval * log(1.0 - dens)
992  + bfuncdT * dgdt * log(1.0 - dens)
993  - bfuncdT * gval /(1.0 - dens) * ddensdT;
994 
995  doublereal dalphadT = m_waterSS->dthermalExpansionCoeffdT();
996 
997  doublereal dfac3dT = dgdt * alpha * bfunc * dens / (1.0 - dens)
998  + gval * dalphadT * bfunc * dens / (1.0 - dens)
999  + gval * alpha * bfuncdT * dens / (1.0 - dens)
1000  + gval * alpha * bfunc * ddensdT / (1.0 - dens)
1001  + gval * alpha * bfunc * dens / ((1.0 - dens) * (1.0 - dens)) * ddensdT;
1002 
1003  return dfac1dT + dfac2dT + dfac3dT;
1004 
1005  } else if (ifunc == 3) {
1006  doublereal beta = m_waterSS->isothermalCompressibility();
1007 
1008  return - bfunc * gval * dens * beta / (1.0 - dens);
1009  } else {
1010  throw CanteraError("HKFT_PDSS::g", "unimplemented");
1011  }
1012  return 0.0;
1013 }
1014 
1015 doublereal PDSS_HKFT::gstar(const doublereal temp, const doublereal pres, const int ifunc) const
1016 {
1017  doublereal gval = g(temp, pres, ifunc);
1018  doublereal fval = f(temp, pres, ifunc);
1019  double res = gval - fval;
1020 #ifdef DEBUG_MODE_NOT
1021  if (ifunc == 2) {
1022  double gval1 = g(temp, pres, 1);
1023  double fval1 = f(temp, pres, 1);
1024  double gval2 = g(temp + 0.001, pres, 1);
1025  double fval2 = f(temp + 0.001, pres, 1);
1026  double gvalT = (gval2 - gval1) / 0.001;
1027  double fvalT = (fval2 - fval1) / 0.001;
1028  if (fabs(gvalT - gval) > 1.0E-9) {
1029  printf("we are here\n");
1030  }
1031  if (fabs(fvalT - fval) > 1.0E-9) {
1032  printf("we are here\n");
1033  }
1034  }
1035 #endif
1036  return res;
1037 }
1038 
1039 doublereal PDSS_HKFT::LookupGe(const std::string& elemName)
1040 {
1041  size_t iE = m_tp->elementIndex(elemName);
1042  if (iE == npos) {
1043  throw CanteraError("PDSS_HKFT::LookupGe", "element " + elemName + " not found");
1044  }
1045  doublereal geValue = m_tp->entropyElement298(iE);
1046  if (geValue == ENTROPY298_UNKNOWN) {
1047  throw CanteraError("PDSS_HKFT::LookupGe",
1048  "element " + elemName + " does not have a supplied entropy298");
1049  }
1050  return geValue * -298.15;
1051 }
1052 
1054 {
1055  /*
1056  * Ok let's get the element compositions and conversion factors.
1057  */
1058  doublereal totalSum = 0.0;
1059  for (size_t m = 0; m < m_tp->nElements(); m++) {
1060  double na = m_tp->nAtoms(m_spindex, m);
1061  if (na > 0.0) {
1062  totalSum += na * LookupGe(m_tp->elementName(m));
1063  }
1064  }
1065  // Add in the charge
1066  if (m_charge_j != 0.0) {
1067  totalSum -= m_charge_j * LookupGe("H");
1068  }
1069  // Ok, now do the calculation. Convert to joules kmol-1
1070  doublereal dg = m_deltaG_formation_tr_pr * 4.184 * 1.0E3;
1071  //! Store the result into an internal variable.
1072  m_Mu0_tr_pr = dg + totalSum;
1073 }
1074 
1075 void PDSS_HKFT::reportParams(size_t& kindex, int& type,
1076  doublereal* const c,
1077  doublereal& minTemp_,
1078  doublereal& maxTemp_,
1079  doublereal& refPressure_) const
1080 {
1081  // Fill in the first part
1082  PDSS::reportParams(kindex, type, c, minTemp_, maxTemp_,
1083  refPressure_);
1084 
1085  c[0] = m_deltaG_formation_tr_pr;
1086  c[1] = m_deltaH_formation_tr_pr;
1087  c[2] = m_Mu0_tr_pr;
1088  c[3] = m_Entrop_tr_pr;
1089  c[4] = m_a1;
1090  c[5] = m_a2;
1091  c[6] = m_a3;
1092  c[7] = m_a4;
1093  c[8] = m_c1;
1094  c[9] = m_c2;
1095  c[10] = m_omega_pr_tr;
1096 }
1097 
1098 }
doublereal nAtoms(size_t k, size_t m) const
Number of atoms of element m in species k.
Definition: Phase.cpp:243
virtual doublereal enthalpy_mole() const
Return the molar enthalpy in units of J kmol-1.
Definition: PDSS_HKFT.cpp:211
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:704
doublereal m_a4
Input a4 coefficient (cal K gmol-1)
Definition: PDSS_HKFT.h:403
virtual doublereal thermalExpansionCoeff() const
Return the volumetric thermal expansion coefficient. Units: 1/K.
Definition: PDSS_Water.cpp:331
doublereal m_densWaterSS
density of standard-state water
Definition: PDSS_HKFT.h:349
CTML ("Cantera Markup Language") is the variant of XML that Cantera uses to store data...
virtual doublereal density() const
Return the standard state density at standard state.
Definition: PDSS_HKFT.cpp:400
doublereal f(const doublereal temp, const doublereal pres, const int ifunc=0) const
Difference function f appearing in the formulation.
Definition: PDSS_HKFT.cpp:920
XML_Node * findXMLPhase(XML_Node *root, const std::string &idtarget)
Search an XML_Node tree for a named phase XML_Node.
Definition: xml.cpp:1108
virtual void setState_TP(doublereal temp, doublereal pres)
Set the internal temperature and pressure.
Definition: PDSS_HKFT.cpp:455
size_t nElements() const
Number of elements.
Definition: Phase.cpp:167
doublereal bg(const doublereal temp, const int ifunc=0) const
Internal formula for the calculation of b_g()
Definition: PDSS_HKFT.cpp:906
doublereal m_deltaG_formation_tr_pr
Input value of deltaG of Formation at Tr and Pr (cal gmol-1)
Definition: PDSS_HKFT.h:367
doublereal gstar(const doublereal temp, const doublereal pres, const int ifunc=0) const
Evaluate the Gstar value appearing in the HKFT formulation.
Definition: PDSS_HKFT.cpp:1015
const doublereal OneAtm
One atmosphere [Pa].
Definition: ct_defs.h:69
std::string attrib(const std::string &attr) const
Function returns the value of an attribute.
Definition: xml.cpp:527
Virtual base class for the classes that manage the calculation of standard state properties for all t...
Definition: VPSSMgr.h:235
std::string findInputFile(const std::string &name)
Find an input file.
Definition: global.cpp:156
virtual void setPressure(doublereal pres)
Sets the pressure in the object.
Definition: PDSS.cpp:338
const size_t npos
index returned by functions to indicate "no position"
Definition: ct_defs.h:165
doublereal m_Mu0_tr_pr
Value of the Absolute Gibbs Free Energy NIST scale at T_r and P_r.
Definition: PDSS_HKFT.h:385
doublereal enthalpy_mole2() const
Return the molar enthalpy in units of J kmol-1.
Definition: PDSS_HKFT.cpp:228
doublereal deltaG() const
Main routine that actually calculates the Gibbs free energy difference between the reference state at...
Definition: PDSS_HKFT.cpp:791
doublereal m_pres
State of the system - pressure.
Definition: PDSS.h:565
doublereal m_c2
Input c2 coefficient (cal K gmol-1)
Definition: PDSS_HKFT.h:409
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:100
Implementation of a pressure dependent standard state virtual function for a Pure Water Phase (see Sp...
virtual doublereal cp_mole() const
Return the molar const pressure heat capacity in units of J kmol-1 K-1.
Definition: PDSS_HKFT.cpp:250
virtual doublereal dthermalExpansionCoeffdT() const
Return the derivative of the volumetric thermal expansion coefficient. Units: 1/K2.
Definition: PDSS_Water.cpp:336
virtual void initAllPtrs(VPStandardStateTP *vptp_ptr, VPSSMgr *vpssmgr_ptr, SpeciesThermo *spthermo_ptr)
Initialize or Reinitialize all shallow pointers in the object.
Definition: PDSS.cpp:182
virtual ~PDSS_HKFT()
Destructor for the phase.
Definition: PDSS_HKFT.cpp:201
doublereal m_a3
Input a3 coefficient (cal K gmol-1 bar-1)
Definition: PDSS_HKFT.h:400
size_t m_spindex
Species index in the ThermoPhase corresponding to this species.
Definition: PDSS.h:595
std::string lowercase(const std::string &s)
Cast a copy of a string to lower case.
Definition: stringUtils.cpp:73
virtual doublereal density() const
Return the standard state density at standard state.
Definition: PDSS_Water.cpp:378
PDSS_enumType m_pdssType
Enumerated type describing the type of the PDSS object.
Definition: PDSS.h:559
doublereal deltaS() const
Main routine that actually calculates the entropy difference between the reference state at Tr...
Definition: PDSS_HKFT.cpp:835
PDSS_HKFT & operator=(const PDSS_HKFT &b)
Assignment operator.
Definition: PDSS_HKFT.cpp:159
doublereal m_omega_pr_tr
Input omega_pr_tr coefficient(cal gmol-1)
Definition: PDSS_HKFT.h:412
Pure Virtual base class for the species thermo manager classes.
doublereal m_Y_pr_tr
y = dZdT = 1/(esp*esp) desp/dT at 298.15 and 1 bar
Definition: PDSS_HKFT.h:415
XML_Node & child(const size_t n) const
Return a changeable reference to the n'th child of the current node.
Definition: xml.cpp:573
virtual void initAllPtrs(VPStandardStateTP *vptp_ptr, VPSSMgr *vpssmgr_ptr, SpeciesThermo *spthermo_ptr)
Initialize or Reinitialize all shallow pointers in the object.
Definition: PDSS_HKFT.cpp:538
doublereal entropyElement298(size_t m) const
Entropy of the element in its standard state at 298 K and 1 bar.
Definition: Phase.cpp:212
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:742
static int s_InputInconsistencyErrorExit
Static variable determining error exiting.
Definition: PDSS_HKFT.h:434
doublereal pref_safe(doublereal temp) const
Returns a reference pressure value that can be safely calculated by the underlying real equation of s...
Definition: PDSS_Water.cpp:402
doublereal g(const doublereal temp, const doublereal pres, const int ifunc=0) const
function g appearing in the formulation
Definition: PDSS_HKFT.cpp:955
virtual void initThermo()
Initialization routine for all of the shallow pointers.
Definition: PDSS_HKFT.cpp:461
doublereal m_a2
Input a2 coefficient (cal gmol-1)
Definition: PDSS_HKFT.h:397
doublereal m_charge_j
Charge of the ion.
Definition: PDSS_HKFT.h:427
virtual void initThermo()
Initialization routine for all of the shallow pointers.
Definition: PDSS.cpp:173
virtual doublereal entropy_mole() const
Return the molar entropy in units of J kmol-1 K-1.
Definition: PDSS_HKFT.cpp:240
void constructPDSSXML(VPStandardStateTP *vptp_ptr, size_t spindex, const XML_Node &speciesNode, const XML_Node &phaseNode, bool spInstalled)
Initialization of a PDSS object using an XML tree.
Definition: PDSS_HKFT.cpp:547
virtual void setTemperature(doublereal temp)
Set the internal temperature.
Definition: PDSS.cpp:348
The WaterProps class is used to house several approximation routines for properties of water...
Definition: WaterProps.h:96
virtual void setState_TP(doublereal temp, doublereal pres)
Set the internal temperature and pressure.
Definition: PDSS_Water.cpp:389
PDSS_HKFT(VPStandardStateTP *tp, size_t spindex)
Constructor that initializes the object by examining the XML entries from the ThermoPhase object...
Definition: PDSS_HKFT.cpp:31
std::string fp2str(const double x, const std::string &fmt)
Convert a double into a c++ string.
Definition: stringUtils.cpp:28
Class for the liquid water pressure dependent standard state.
Definition: PDSS_Water.h:51
doublereal m_deltaH_formation_tr_pr
Input value of deltaH of Formation at Tr and Pr (cal gmol-1)
Definition: PDSS_HKFT.h:376
std::string name() const
Returns the name of the XML node.
Definition: xml.h:394
virtual doublereal entropy_R_ref() const
Return the molar entropy divided by R at reference pressure.
Definition: PDSS_HKFT.cpp:426
doublereal deltaH() const
Routine that actually calculates the enthalpy difference between the reference state at Tr...
Definition: PDSS_HKFT.cpp:729
doublereal m_Entrop_tr_pr
Input value of S_j at Tr and Pr (cal gmol-1 K-1)
Definition: PDSS_HKFT.h:391
virtual doublereal molarVolume_ref() const
Return the molar volume at reference pressure.
Definition: PDSS_HKFT.cpp:446
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:99
virtual doublereal cp_R() const
Return the molar const pressure heat capacity divided by RT.
Definition: PDSS.cpp:407
WaterProps * m_waterProps
Pointer to the water property calculator.
Definition: PDSS_HKFT.h:352
void convertDGFormation()
Translate a Gibbs free energy of formation value to a NIST-based Chemical potential.
Definition: PDSS_HKFT.cpp:1053
virtual doublereal molarVolume() const
Return the molar volume at standard state.
Definition: PDSS_HKFT.cpp:345
doublereal m_presR_bar
Reference pressure is 1 atm in units of bar= 1.0132.
Definition: PDSS_HKFT.h:421
This is a filter class for ThermoPhase that implements some prepatory steps for efficiently handling ...
bool hasChild(const std::string &ch) const
Tests whether the current node has a child node with a particular name.
Definition: xml.cpp:563
virtual doublereal enthalpy_RT_ref() const
Return the molar enthalpy divided by RT at reference pressure.
Definition: PDSS_HKFT.cpp:416
doublereal m_maxTemp
Maximum temperature.
Definition: PDSS.h:574
doublereal m_domega_jdT_prtr
small value that is not quite zero
Definition: PDSS_HKFT.h:424
virtual doublereal enthalpy_RT() const
Return the standard state molar enthalpy divided by RT.
Definition: PDSS.cpp:392
doublereal m_minTemp
Minimum temperature.
Definition: PDSS.h:571
virtual doublereal gibbs_RT_ref() const
Return the molar Gibbs free energy divided by RT at reference pressure.
Definition: PDSS_HKFT.cpp:406
#define ENTROPY298_UNKNOWN
Number indicating we don't know the entropy of the element in its most stable state at 298...
Definition: Elements.h:84
virtual void reportParams(size_t &kindex, int &type, doublereal *const c, doublereal &minTemp, doublereal &maxTemp, doublereal &refPressure) const
This utility function reports back the type of parameterization and all of the parameters for the spe...
Definition: PDSS_HKFT.cpp:1075
PDSS_Water * m_waterSS
Water standard state calculator.
Definition: PDSS_HKFT.h:343
doublereal ag(const doublereal temp, const int ifunc=0) const
Internal formula for the calculation of a_g()
Definition: PDSS_HKFT.cpp:892
doublereal LookupGe(const std::string &elemName)
Function to look up Element Free Energies.
Definition: PDSS_HKFT.cpp:1039
virtual void reportParams(size_t &kindex, int &type, doublereal *const c, doublereal &minTemp, doublereal &maxTemp, doublereal &refPressure) const
This utility function reports back the type of parameterization and all of the parameters for the spe...
Definition: PDSS.cpp:377
Header file for a derived class of ThermoPhase that handles variable pressure standard state methods ...
doublereal m_Z_pr_tr
Z = -1 / relEpsilon at 298.15 and 1 bar.
Definition: PDSS_HKFT.h:418
Virtual base class for a species with a pressure dependent standard state.
Definition: PDSS.h:193
size_t elementIndex(const std::string &name) const
Return the index of element named 'name'.
Definition: Phase.cpp:192
VPStandardStateTP * m_tp
ThermoPhase which this species belongs to.
Definition: PDSS.h:582
doublereal m_temp
Current temperature used by the PDSS object.
Definition: PDSS.h:562
virtual doublereal isothermalCompressibility() const
Returns the isothermal compressibility. Units: 1/Pa.
Definition: PDSS_Water.cpp:352
PDSS & operator=(const PDSS &b)
Assignment operator.
Definition: PDSS.cpp:104
Contains declarations for string manipulation functions within Cantera.
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:194
std::string elementName(size_t m) const
Name of the element with index m.
Definition: Phase.cpp:186
void writelog(const std::string &msg)
Write a message to the screen.
Definition: global.cpp:33
Class for pressure dependent standard states corresponding to ionic solutes in electrolyte water...
Definition: PDSS_HKFT.h:29
doublereal m_c1
Input c1 coefficient (cal gmol-1 K-1)
Definition: PDSS_HKFT.h:406
virtual PDSS * duplMyselfAsPDSS() const
Duplication routine for objects which inherit from PDSS.
Definition: PDSS_HKFT.cpp:206
virtual doublereal gibbs_mole() const
Return the molar Gibbs free energy in units of J kmol-1.
Definition: PDSS_HKFT.cpp:245
doublereal relEpsilon(doublereal T, doublereal P_pascal, int ifunc=0)
Bradley-Pitzer equation for the dielectric constant of water as a function of temperature and pressur...
Definition: WaterProps.cpp:139
doublereal m_r_e_j
Electrostatic radii.
Definition: PDSS_HKFT.h:358
XML_Node & root() const
Return the root of the current XML_Node tree.
Definition: xml.cpp:1095
doublereal m_born_coeff_j
Born coefficient for the current ion or species.
Definition: PDSS_HKFT.h:355
doublereal strSItoDbl(const std::string &strSI)
Interpret one or two token string as a single double.
doublereal fpValueCheck(const std::string &val)
Translate a string into one doublereal value, with error checking.
void build(std::istream &f)
Main routine to create an tree-like representation of an XML file.
Definition: xml.cpp:764
std::string speciesName(size_t k) const
Name of the species with index k.
Definition: Phase.cpp:272
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:252
virtual doublereal cp_R_ref() const
Return the molar heat capacity divided by R at reference pressure.
Definition: PDSS_HKFT.cpp:436
Declarations for the class PDSS_HKFT (pressure dependent standard state) which handles calculations f...
doublereal m_p0
Reference state pressure of the species.
Definition: PDSS.h:568
doublereal m_a1
Input a1 coefficient (cal gmol-1 bar-1)
Definition: PDSS_HKFT.h:394
virtual doublereal gibbs_RT() const
Return the molar Gibbs free energy divided by RT.
Definition: PDSS.cpp:402
doublereal m_mw
Molecular Weight of the species.
Definition: PDSS.h:590
void constructPDSSFile(VPStandardStateTP *vptp_ptr, size_t spindex, const std::string &inputFile, const std::string &id)
Initialization of a PDSS object using an input XML file.
Definition: PDSS_HKFT.cpp:692
virtual doublereal intEnergy_mole() const
Return the molar internal Energy in units of J kmol-1.
Definition: PDSS_HKFT.cpp:235
doublereal charge(size_t k) const
Dimensionless electrical charge of a single molecule of species k The charge is normalized by the the...
Definition: Phase.h:578
virtual doublereal entropy_R() const
Return the standard state entropy divided by RT.
Definition: PDSS.cpp:397