Cantera  2.3.0
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 // This file is part of Cantera. See License.txt in the top-level directory or
10 // at http://www.cantera.org/license.txt for license and copyright information.
11 
12 #include "cantera/base/ctml.h"
17 
18 using namespace std;
19 
20 namespace Cantera
21 {
22 // Set the default to error exit if there is an input file inconsistency
23 int PDSS_HKFT::s_InputInconsistencyErrorExit = 1;
24 
25 PDSS_HKFT::PDSS_HKFT(VPStandardStateTP* tp, size_t spindex) :
26  PDSS(tp, spindex),
27  m_waterSS(0),
28  m_densWaterSS(-1.0),
29  m_born_coeff_j(-1.0),
30  m_r_e_j(-1.0),
31  m_deltaG_formation_tr_pr(0.0),
32  m_deltaH_formation_tr_pr(0.0),
33  m_Mu0_tr_pr(0.0),
34  m_Entrop_tr_pr(0.0),
35  m_a1(0.0),
36  m_a2(0.0),
37  m_a3(0.0),
38  m_a4(0.0),
39  m_c1(0.0),
40  m_c2(0.0),
41  m_omega_pr_tr(0.0),
42  m_Y_pr_tr(0.0),
43  m_Z_pr_tr(0.0),
44  m_presR_bar(0.0),
45  m_domega_jdT_prtr(0.0),
46  m_charge_j(0.0)
47 {
48  m_pres = OneAtm;
49  m_pdssType = cPDSS_MOLAL_HKFT;
50  m_presR_bar = OneAtm * 1.0E-5;
51  m_presR_bar = 1.0;
52 }
53 
55  const std::string& inputFile, const std::string& id) :
56  PDSS(tp, spindex),
57  m_waterSS(0),
58  m_densWaterSS(-1.0),
59  m_born_coeff_j(-1.0),
60  m_r_e_j(-1.0),
61  m_deltaG_formation_tr_pr(0.0),
62  m_deltaH_formation_tr_pr(0.0),
63  m_Mu0_tr_pr(0.0),
64  m_Entrop_tr_pr(0.0),
65  m_a1(0.0),
66  m_a2(0.0),
67  m_a3(0.0),
68  m_a4(0.0),
69  m_c1(0.0),
70  m_c2(0.0),
71  m_omega_pr_tr(0.0),
72  m_Y_pr_tr(0.0),
73  m_Z_pr_tr(0.0),
74  m_presR_bar(1.0),
75  m_domega_jdT_prtr(0.0),
76  m_charge_j(0.0)
77 {
78  warn_deprecated("PDSS_HKFT constructor from XML input file",
79  "To be removed after Cantera 2.3.");
80  m_pres = OneAtm;
81  m_pdssType = cPDSS_MOLAL_HKFT;
82  m_presR_bar = OneAtm * 1.0E-5;
83  m_presR_bar = 1.0;
84  constructPDSSFile(tp, spindex, inputFile, id);
85 }
86 
87 PDSS_HKFT::PDSS_HKFT(VPStandardStateTP* tp, size_t spindex, const XML_Node& speciesNode,
88  const XML_Node& phaseRoot, bool spInstalled) :
89  PDSS(tp, spindex),
90  m_waterSS(0),
91  m_densWaterSS(-1.0),
92  m_born_coeff_j(-1.0),
93  m_r_e_j(-1.0),
94  m_deltaG_formation_tr_pr(0.0),
95  m_deltaH_formation_tr_pr(0.0),
96  m_Mu0_tr_pr(0.0),
97  m_Entrop_tr_pr(0.0),
98  m_a1(0.0),
99  m_a2(0.0),
100  m_a3(0.0),
101  m_a4(0.0),
102  m_c1(0.0),
103  m_c2(0.0),
104  m_omega_pr_tr(0.0),
105  m_Y_pr_tr(0.0),
106  m_Z_pr_tr(0.0),
107  m_presR_bar(0.0),
108  m_domega_jdT_prtr(0.0),
109  m_charge_j(0.0)
110 {
111  m_pres = OneAtm;
112  m_pdssType = cPDSS_MOLAL_HKFT;
113  m_presR_bar = OneAtm * 1.0E-5;
114  m_presR_bar = 1.0;
115  // We have to read the info from here
116  constructPDSSXML(tp, spindex, speciesNode, phaseRoot, spInstalled);
117 }
118 
120  PDSS(b),
121  m_waterSS(0),
122  m_densWaterSS(-1.0),
123  m_born_coeff_j(-1.0),
124  m_r_e_j(-1.0),
125  m_deltaG_formation_tr_pr(0.0),
126  m_deltaH_formation_tr_pr(0.0),
127  m_Mu0_tr_pr(0.0),
128  m_Entrop_tr_pr(0.0),
129  m_a1(0.0),
130  m_a2(0.0),
131  m_a3(0.0),
132  m_a4(0.0),
133  m_c1(0.0),
134  m_c2(0.0),
135  m_omega_pr_tr(0.0),
136  m_Y_pr_tr(0.0),
137  m_Z_pr_tr(0.0),
138  m_presR_bar(0.0),
139  m_domega_jdT_prtr(0.0),
140  m_charge_j(0.0)
141 {
142  m_pdssType = cPDSS_MOLAL_HKFT;
143  m_presR_bar = OneAtm * 1.0E-5;
144 
145  // Use the assignment operator to do the brunt of the work for the copy
146  // constructor.
147  *this = b;
148 }
149 
150 PDSS_HKFT& PDSS_HKFT::operator=(const PDSS_HKFT& b)
151 {
152  if (&b == this) {
153  return *this;
154  }
155  // Call the base class operator
156  PDSS::operator=(b);
157 
158  // Need to call initAllPtrs AFTER, to get the correct m_waterSS
159  m_waterSS = 0;
160  m_densWaterSS = b.m_densWaterSS;
161  // Need to call initAllPtrs AFTER, to get the correct m_waterProps
162  m_born_coeff_j = b.m_born_coeff_j;
163  m_r_e_j = b.m_r_e_j;
164  m_deltaG_formation_tr_pr = b.m_deltaG_formation_tr_pr;
165  m_deltaH_formation_tr_pr = b.m_deltaH_formation_tr_pr;
166  m_Mu0_tr_pr = b.m_Mu0_tr_pr;
167  m_Entrop_tr_pr = b.m_Entrop_tr_pr;
168  m_a1 = b.m_a1;
169  m_a2 = b.m_a2;
170  m_a3 = b.m_a3;
171  m_a4 = b.m_a4;
172  m_c1 = b.m_c1;
173  m_c2 = b.m_c2;
174  m_omega_pr_tr = b.m_omega_pr_tr;
175  m_Y_pr_tr = b.m_Y_pr_tr;
176  m_Z_pr_tr = b.m_Z_pr_tr;
177  m_presR_bar = b.m_presR_bar;
178  m_domega_jdT_prtr = b.m_domega_jdT_prtr;
179  m_charge_j = b.m_charge_j;
180 
181  // Here we just fill these in so that local copies within the VPSS object work.
182  m_waterSS = b.m_waterSS;
183  m_waterProps.reset(new WaterProps(m_waterSS));
184 
185  return *this;
186 }
187 
188 PDSS_HKFT::~PDSS_HKFT()
189 {
190 }
191 
193 {
194  return new PDSS_HKFT(*this);
195 }
196 
197 doublereal PDSS_HKFT::enthalpy_mole() const
198 {
199  // Ok we may change this evaluation method in the future.
200  doublereal h = gibbs_mole() + m_temp * entropy_mole();
201  return h;
202 }
203 
204 doublereal PDSS_HKFT::enthalpy_mole2() const
205 {
206  double enthTRPR = m_Mu0_tr_pr + 298.15 * m_Entrop_tr_pr * toSI("cal/gmol");
207  return deltaH() + enthTRPR;
208 }
209 
210 doublereal PDSS_HKFT::intEnergy_mole() const
211 {
212  return enthalpy_RT() - molarVolume() * m_pres;
213 }
214 
215 doublereal PDSS_HKFT::entropy_mole() const
216 {
217  return m_Entrop_tr_pr * toSI("cal/gmol") + deltaS();
218 }
219 
220 doublereal PDSS_HKFT::gibbs_mole() const
221 {
222  return m_Mu0_tr_pr + deltaG();
223 }
224 
225 doublereal PDSS_HKFT::cp_mole() const
226 {
227  doublereal pbar = m_pres * 1.0E-5;
228  doublereal c1term = m_c1;
229  doublereal c2term = m_c2 / (m_temp - 228.) / (m_temp - 228.);
230  doublereal a3term = -m_a3 / (m_temp - 228.) / (m_temp - 228.) / (m_temp - 228.) * 2.0 * m_temp * (pbar - m_presR_bar);
231  doublereal a4term = -m_a4 / (m_temp - 228.) / (m_temp - 228.) / (m_temp - 228.) * 2.0 * m_temp
232  * log((2600. + pbar)/(2600. + m_presR_bar));
233 
234  doublereal omega_j;
235  doublereal domega_jdT;
236  doublereal d2omega_jdT2;
237  if (m_charge_j == 0.0) {
238  omega_j = m_omega_pr_tr;
239  domega_jdT = 0.0;
240  d2omega_jdT2 = 0.0;
241  } else {
242  doublereal nu = 166027;
243  doublereal r_e_j_pr_tr = m_charge_j * m_charge_j / (m_omega_pr_tr/nu + m_charge_j/3.082);
244  doublereal gval = gstar(m_temp, m_pres, 0);
245  doublereal dgvaldT = gstar(m_temp, m_pres, 1);
246  doublereal d2gvaldT2 = gstar(m_temp, m_pres, 2);
247 
248  doublereal r_e_j = r_e_j_pr_tr + fabs(m_charge_j) * gval;
249  doublereal dr_e_jdT = fabs(m_charge_j) * dgvaldT;
250  doublereal d2r_e_jdT2 = fabs(m_charge_j) * d2gvaldT2;
251  doublereal r_e_j2 = r_e_j * r_e_j;
252 
253  doublereal charge2 = m_charge_j * m_charge_j;
254  doublereal r_e_H = 3.082 + gval;
255  doublereal r_e_H2 = r_e_H * r_e_H;
256  omega_j = nu * (charge2 / r_e_j - m_charge_j / r_e_H);
257  domega_jdT = nu * (-(charge2 / r_e_j2 * dr_e_jdT)
258  +(m_charge_j / r_e_H2 * dgvaldT));
259  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
260  -2.0*m_charge_j*dgvaldT*dgvaldT/(r_e_H2*r_e_H) + m_charge_j*d2gvaldT2 /r_e_H2);
261  }
262 
263  doublereal relepsilon = m_waterProps->relEpsilon(m_temp, m_pres, 0);
264  doublereal drelepsilondT = m_waterProps->relEpsilon(m_temp, m_pres, 1);
265  doublereal Y = drelepsilondT / (relepsilon * relepsilon);
266  doublereal d2relepsilondT2 = m_waterProps->relEpsilon(m_temp, m_pres, 2);
267 
268  doublereal X = d2relepsilondT2 / (relepsilon* relepsilon) - 2.0 * relepsilon * Y * Y;
269  doublereal Z = -1.0 / relepsilon;
270 
271  doublereal yterm = 2.0 * m_temp * Y * domega_jdT;
272  doublereal xterm = omega_j * m_temp * X;
273  doublereal otterm = m_temp * d2omega_jdT2 * (Z + 1.0);
274  doublereal rterm = - m_domega_jdT_prtr * (m_Z_pr_tr + 1.0);
275 
276  doublereal Cp_calgmol = c1term + c2term + a3term + a4term + yterm + xterm + otterm + rterm;
277 
278  // Convert to Joules / kmol
279  doublereal Cp = Cp_calgmol * toSI("cal/gmol");
280 
281  return Cp;
282 }
283 
284 doublereal PDSS_HKFT::molarVolume() const
285 {
286  // Initially do all calculations in (cal/gmol/Pa)
287 
288  doublereal a1term = m_a1 * 1.0E-5;
289  doublereal a2term = m_a2 / (2600.E5 + m_pres);
290  doublereal a3term = m_a3 * 1.0E-5/ (m_temp - 228.);
291  doublereal a4term = m_a4 / (m_temp - 228.) / (2600.E5 + m_pres);
292 
293  doublereal omega_j;
294  doublereal domega_jdP;
295  if (m_charge_j == 0.0) {
296  omega_j = m_omega_pr_tr;
297  domega_jdP = 0.0;
298  } else {
299  doublereal nu = 166027.;
300  doublereal charge2 = m_charge_j * m_charge_j;
301  doublereal r_e_j_pr_tr = charge2 / (m_omega_pr_tr/nu + m_charge_j/3.082);
302 
303  doublereal gval = gstar(m_temp, m_pres, 0);
304  doublereal dgvaldP = gstar(m_temp, m_pres, 3);
305 
306  doublereal r_e_j = r_e_j_pr_tr + fabs(m_charge_j) * gval;
307  doublereal r_e_H = 3.082 + gval;
308 
309  omega_j = nu * (charge2 / r_e_j - m_charge_j / r_e_H);
310  doublereal dr_e_jdP = fabs(m_charge_j) * dgvaldP;
311  domega_jdP = - nu * (charge2 / (r_e_j * r_e_j) * dr_e_jdP)
312  + nu * m_charge_j / (r_e_H * r_e_H) * dgvaldP;
313  }
314 
315  doublereal drelepsilondP = m_waterProps->relEpsilon(m_temp, m_pres, 3);
316  doublereal relepsilon = m_waterProps->relEpsilon(m_temp, m_pres, 0);
317  doublereal Q = drelepsilondP / (relepsilon * relepsilon);
318  doublereal Z = -1.0 / relepsilon;
319  doublereal wterm = - domega_jdP * (Z + 1.0);
320  doublereal qterm = - omega_j * Q;
321  doublereal molVol_calgmolPascal = a1term + a2term + a3term + a4term + wterm + qterm;
322 
323  // Convert to m**3 / kmol from (cal/gmol/Pa)
324  return molVol_calgmolPascal * toSI("cal/gmol");
325 }
326 
327 doublereal PDSS_HKFT::density() const
328 {
329  return m_mw / molarVolume();
330 }
331 
332 doublereal PDSS_HKFT::gibbs_RT_ref() const
333 {
334  doublereal m_psave = m_pres;
336  doublereal ee = gibbs_RT();
337  m_pres = m_psave;
338  return ee;
339 }
340 
341 doublereal PDSS_HKFT::enthalpy_RT_ref() const
342 {
343  doublereal m_psave = m_pres;
345  doublereal hh = enthalpy_RT();
346  m_pres = m_psave;
347  return hh;
348 }
349 
350 doublereal PDSS_HKFT::entropy_R_ref() const
351 {
352  doublereal m_psave = m_pres;
354  doublereal ee = entropy_R();
355  m_pres = m_psave;
356  return ee;
357 }
358 
359 doublereal PDSS_HKFT::cp_R_ref() const
360 {
361  doublereal m_psave = m_pres;
363  doublereal ee = cp_R();
364  m_pres = m_psave;
365  return ee;
366 }
367 
368 doublereal PDSS_HKFT::molarVolume_ref() const
369 {
370  doublereal m_psave = m_pres;
372  doublereal ee = molarVolume();
373  m_pres = m_psave;
374  return ee;
375 }
376 
377 void PDSS_HKFT::setState_TP(doublereal temp, doublereal pres)
378 {
379  setTemperature(temp);
380  setPressure(pres);
381 }
382 
384 {
386 
387  m_waterSS = &dynamic_cast<PDSS_Water&>(*m_tp->providePDSS(0));
388 
389  // Section to initialize m_Z_pr_tr and m_Y_pr_tr
390  m_temp = 273.15 + 25.;
391  m_pres = OneAtm;
392  doublereal relepsilon = m_waterProps->relEpsilon(m_temp, m_pres, 0);
395  m_Z_pr_tr = -1.0 / relepsilon;
396  doublereal drelepsilondT = m_waterProps->relEpsilon(m_temp, m_pres, 1);
397  m_Y_pr_tr = drelepsilondT / (relepsilon * relepsilon);
398  m_waterProps.reset(new WaterProps(m_waterSS));
399  m_presR_bar = OneAtm / 1.0E5;
400  m_presR_bar = 1.0;
403 
404  // Ok, we have mu. Let's check it against the input value
405  // of DH_F to see that we have some internal consistency
406  doublereal Hcalc = m_Mu0_tr_pr + 298.15 * (m_Entrop_tr_pr * toSI("cal/gmol"));
407  doublereal DHjmol = m_deltaH_formation_tr_pr * toSI("cal/gmol");
408 
409  // If the discrepancy is greater than 100 cal gmol-1, print
410  // an error and exit.
411  if (fabs(Hcalc -DHjmol) > 100.* toSI("cal/gmol")) {
412  std::string sname = m_tp->speciesName(m_spindex);
414  throw CanteraError("PDSS_HKFT::initThermo()", "For {}, DHjmol is"
415  " not consistent with G and S: {} vs {} cal gmol-1",
416  sname, Hcalc/toSI("cal/gmol"), m_deltaH_formation_tr_pr);
417  } else {
418  writelog("PDSS_HKFT::initThermo() WARNING: DHjmol for {} is not"
419  " consistent with G and S: calculated {} vs input {} cal gmol-1",
420  sname, Hcalc/toSI("cal/gmol"), m_deltaH_formation_tr_pr);
421  writelog(" : continuing with consistent DHjmol = {}", Hcalc/toSI("cal/gmol"));
422  m_deltaH_formation_tr_pr = Hcalc / toSI("cal/gmol");
423  }
424  }
425  doublereal nu = 166027;
426  doublereal r_e_j_pr_tr;
427  if (m_charge_j != 0.0) {
428  r_e_j_pr_tr = m_charge_j * m_charge_j / (m_omega_pr_tr/nu + m_charge_j/3.082);
429  } else {
430  r_e_j_pr_tr = 0.0;
431  }
432 
433  if (m_charge_j == 0.0) {
434  m_domega_jdT_prtr = 0.0;
435  } else {
436  doublereal gval = gstar(m_temp, m_pres, 0);
437  doublereal dgvaldT = gstar(m_temp, m_pres, 1);
438  doublereal r_e_j = r_e_j_pr_tr + fabs(m_charge_j) * gval;
439  doublereal dr_e_jdT = fabs(m_charge_j) * dgvaldT;
440  m_domega_jdT_prtr = - nu * (m_charge_j * m_charge_j / (r_e_j * r_e_j) * dr_e_jdT)
441  + nu * m_charge_j / (3.082 + gval) / (3.082 + gval) * dgvaldT;
442  }
443 }
444 
445 void PDSS_HKFT::initAllPtrs(VPStandardStateTP* vptp_ptr, VPSSMgr* vpssmgr_ptr,
446  MultiSpeciesThermo* spthermo_ptr)
447 {
448  PDSS::initAllPtrs(vptp_ptr, vpssmgr_ptr, spthermo_ptr);
449  m_waterSS = &dynamic_cast<PDSS_Water&>(*m_tp->providePDSS(0));
450  m_waterProps.reset(new WaterProps(m_waterSS));
451 }
452 
454  const XML_Node& speciesNode,
455  const XML_Node& phaseNode, bool spInstalled)
456 {
457  int hasDGO = 0;
458  int hasSO = 0;
459  int hasDHO = 0;
460 
461  if (!spInstalled) {
462  throw CanteraError("PDSS_HKFT::constructPDSSXML", "spInstalled false not handled");
463  }
464 
465  const XML_Node* tn = speciesNode.findByName("thermo");
466  if (!tn) {
467  throw CanteraError("PDSS_HKFT::constructPDSSXML",
468  "no thermo Node for species " + speciesNode.name());
469  }
470  if (!ba::iequals(tn->attrib("model"), "hkft")) {
471  throw CanteraError("PDSS_HKFT::initThermoXML",
472  "thermo model for species isn't hkft: "
473  + speciesNode.name());
474  }
475  const XML_Node* hh = tn->findByName("HKFT");
476  if (!hh) {
477  throw CanteraError("PDSS_HKFT::constructPDSSXML",
478  "no Thermo::HKFT Node for species " + speciesNode.name());
479  }
480 
481  // go get the attributes
482  m_p0 = OneAtm;
483  std::string p0string = hh->attrib("Pref");
484  if (p0string != "") {
485  m_p0 = strSItoDbl(p0string);
486  }
487 
488  std::string minTstring = hh->attrib("Tmin");
489  if (minTstring != "") {
490  m_minTemp = fpValueCheck(minTstring);
491  }
492 
493  std::string maxTstring = hh->attrib("Tmax");
494  if (maxTstring != "") {
495  m_maxTemp = fpValueCheck(maxTstring);
496  }
497 
498  if (hh->hasChild("DG0_f_Pr_Tr")) {
499  doublereal val = getFloat(*hh, "DG0_f_Pr_Tr");
501  hasDGO = 1;
502  }
503 
504  if (hh->hasChild("DH0_f_Pr_Tr")) {
505  doublereal val = getFloat(*hh, "DH0_f_Pr_Tr");
507  hasDHO = 1;
508  }
509 
510  if (hh->hasChild("S0_Pr_Tr")) {
511  doublereal val = getFloat(*hh, "S0_Pr_Tr");
512  m_Entrop_tr_pr= val;
513  hasSO = 1;
514  }
515 
516  const XML_Node* ss = speciesNode.findByName("standardState");
517  if (!ss) {
518  throw CanteraError("PDSS_HKFT::constructPDSSXML",
519  "no standardState Node for species " + speciesNode.name());
520  }
521  if (!ba::iequals(ss->attrib("model"), "hkft")) {
522  throw CanteraError("PDSS_HKFT::initThermoXML",
523  "standardState model for species isn't hkft: "
524  + speciesNode.name());
525  }
526  if (ss->hasChild("a1")) {
527  m_a1 = getFloat(*ss, "a1");
528  } else {
529  throw CanteraError("PDSS_HKFT::constructPDSSXML", " missing a1 field");
530  }
531  if (ss->hasChild("a2")) {
532  m_a2 = getFloat(*ss, "a2");
533  } else {
534  throw CanteraError("PDSS_HKFT::constructPDSSXML", " missing a2 field");
535  }
536  if (ss->hasChild("a3")) {
537  m_a3 = getFloat(*ss, "a3");
538  } else {
539  throw CanteraError("PDSS_HKFT::constructPDSSXML", " missing a3 field");
540  }
541  if (ss->hasChild("a4")) {
542  m_a4 = getFloat(*ss, "a4");
543  } else {
544  throw CanteraError("PDSS_HKFT::constructPDSSXML", " missing a4 field");
545  }
546 
547  if (ss->hasChild("c1")) {
548  m_c1 = getFloat(*ss, "c1");
549  } else {
550  throw CanteraError("PDSS_HKFT::constructPDSSXML", " missing c1 field");
551  }
552  if (ss->hasChild("c2")) {
553  m_c2 = getFloat(*ss, "c2");
554  } else {
555  throw CanteraError("PDSS_HKFT::constructPDSSXML", " missing c2 field");
556  }
557  if (ss->hasChild("omega_Pr_Tr")) {
558  m_omega_pr_tr = getFloat(*ss, "omega_Pr_Tr");
559  } else {
560  throw CanteraError("PDSS_HKFT::constructPDSSXML", " missing omega_Pr_Tr field");
561  }
562 
563  int isum = hasDGO + hasDHO + hasSO;
564  if (isum < 2) {
565  throw CanteraError("PDSS_HKFT::constructPDSSXML",
566  "Missing 2 or more of DG0_f_Pr_Tr, DH0_f_Pr_Tr, or S0_f_Pr_Tr fields. "
567  "Need to supply at least two of these fields");
568  }
569  // Ok, if we are missing one, then we construct its value from the other two.
570  // This code has been internally verified.
571  if (hasDHO == 0) {
574  doublereal Hcalc = m_Mu0_tr_pr + 298.15 * (m_Entrop_tr_pr * toSI("cal/gmol"));
575  m_deltaH_formation_tr_pr = Hcalc / toSI("cal/gmol");
576  }
577  if (hasDGO == 0) {
578  doublereal DHjmol = m_deltaH_formation_tr_pr * toSI("cal/gmol");
579  m_Mu0_tr_pr = DHjmol - 298.15 * (m_Entrop_tr_pr * toSI("cal/gmol"));
580  m_deltaG_formation_tr_pr = m_Mu0_tr_pr / toSI("cal/gmol");
581  double tmp = m_Mu0_tr_pr;
584  double totalSum = m_Mu0_tr_pr - tmp;
585  m_Mu0_tr_pr = tmp;
586  m_deltaG_formation_tr_pr = (m_Mu0_tr_pr - totalSum)/ toSI("cal/gmol");
587  }
588  if (hasSO == 0) {
591  doublereal DHjmol = m_deltaH_formation_tr_pr * toSI("cal/gmol");
592  m_Entrop_tr_pr = (DHjmol - m_Mu0_tr_pr) / (298.15 * toSI("cal/gmol"));
593  }
594 }
595 
597  const std::string& inputFile,
598  const std::string& id)
599 {
600  warn_deprecated("PDSS_HKFT::constructPDSSFile",
601  "To be removed after Cantera 2.3.");
602  if (inputFile.size() == 0) {
603  throw CanteraError("PDSS_HKFT::initThermo",
604  "input file is null");
605  }
606 
607  // The phase object automatically constructs an XML object. Use this object
608  // to store information.
609  XML_Node fxml;
610  fxml.build(findInputFile(inputFile));
611  XML_Node* fxml_phase = findXMLPhase(&fxml, id);
612  if (!fxml_phase) {
613  throw CanteraError("PDSS_HKFT::initThermo",
614  "ERROR: Can not find phase named " +
615  id + " in file named " + inputFile);
616  }
617 
618  XML_Node& speciesList = fxml_phase->child("speciesArray");
619  XML_Node* speciesDB = get_XML_NameID("speciesData", speciesList["datasrc"],
620  &fxml_phase->root());
621  const XML_Node* s = speciesDB->findByAttr("name", tp->speciesName(spindex));
622  constructPDSSXML(tp, spindex, *s, *fxml_phase, true);
623 }
624 
625 doublereal PDSS_HKFT::deltaH() const
626 {
627  doublereal pbar = m_pres * 1.0E-5;
628  doublereal c1term = m_c1 * (m_temp - 298.15);
629  doublereal a1term = m_a1 * (pbar - m_presR_bar);
630  doublereal a2term = m_a2 * log((2600. + pbar)/(2600. + m_presR_bar));
631  doublereal c2term = -m_c2 * (1.0/(m_temp - 228.) - 1.0/(298.15 - 228.));
632  double a3tmp = (2.0 * m_temp - 228.)/ (m_temp - 228.) /(m_temp - 228.);
633  doublereal a3term = m_a3 * a3tmp * (pbar - m_presR_bar);
634  doublereal a4term = m_a4 * a3tmp * log((2600. + pbar)/(2600. + m_presR_bar));
635  doublereal omega_j;
636  doublereal domega_jdT;
637  if (m_charge_j == 0.0) {
638  omega_j = m_omega_pr_tr;
639  domega_jdT = 0.0;
640  } else {
641  doublereal nu = 166027;
642  doublereal r_e_j_pr_tr = m_charge_j * m_charge_j / (m_omega_pr_tr/nu + m_charge_j/3.082);
643  doublereal gval = gstar(m_temp, m_pres, 0);
644  doublereal r_e_j = r_e_j_pr_tr + fabs(m_charge_j) * gval;
645  doublereal dgvaldT = gstar(m_temp, m_pres, 1);
646  doublereal dr_e_jdT = fabs(m_charge_j) * dgvaldT;
647  omega_j = nu * (m_charge_j * m_charge_j / r_e_j - m_charge_j / (3.082 + gval));
648  domega_jdT = - nu * (m_charge_j * m_charge_j / (r_e_j * r_e_j) * dr_e_jdT)
649  + nu * m_charge_j / (3.082 + gval) / (3.082 + gval) * dgvaldT;
650  }
651 
652  doublereal relepsilon = m_waterProps->relEpsilon(m_temp, m_pres, 0);
653  doublereal drelepsilondT = m_waterProps->relEpsilon(m_temp, m_pres, 1);
654 
655  doublereal Y = drelepsilondT / (relepsilon * relepsilon);
656  doublereal Z = -1.0 / relepsilon;
657 
658  doublereal yterm = m_temp * omega_j * Y;
659  doublereal yrterm = - 298.15 * m_omega_pr_tr * m_Y_pr_tr;
660 
661  doublereal wterm = - omega_j * (Z + 1.0);
662  doublereal wrterm = + m_omega_pr_tr * (m_Z_pr_tr + 1.0);
663 
664  doublereal otterm = m_temp * domega_jdT * (Z + 1.0);
665  doublereal otrterm = - m_temp * m_domega_jdT_prtr * (m_Z_pr_tr + 1.0);
666 
667  doublereal deltaH_calgmol = c1term + a1term + a2term + c2term + a3term + a4term
668  + yterm + yrterm + wterm + wrterm + otterm + otrterm;
669 
670  // Convert to Joules / kmol
671  return deltaH_calgmol * toSI("cal/gmol");
672 }
673 
674 doublereal PDSS_HKFT::deltaG() const
675 {
676  doublereal pbar = m_pres * 1.0E-5;
677  doublereal sterm = - m_Entrop_tr_pr * (m_temp - 298.15);
678  doublereal c1term = -m_c1 * (m_temp * log(m_temp/298.15) - (m_temp - 298.15));
679  doublereal a1term = m_a1 * (pbar - m_presR_bar);
680  doublereal a2term = m_a2 * log((2600. + pbar)/(2600. + m_presR_bar));
681  doublereal c2term = -m_c2 * ((1.0/(m_temp - 228.) - 1.0/(298.15 - 228.)) * (228. - m_temp)/228.
682  - m_temp / (228.*228.) * log((298.15*(m_temp-228.)) / (m_temp*(298.15-228.))));
683  doublereal a3term = m_a3 / (m_temp - 228.) * (pbar - m_presR_bar);
684  doublereal a4term = m_a4 / (m_temp - 228.) * log((2600. + pbar)/(2600. + m_presR_bar));
685 
686  doublereal omega_j;
687  if (m_charge_j == 0.0) {
688  omega_j = m_omega_pr_tr;
689  } else {
690  doublereal nu = 166027;
691  doublereal r_e_j_pr_tr = m_charge_j * m_charge_j / (m_omega_pr_tr/nu + m_charge_j/3.082);
692  doublereal gval = gstar(m_temp, m_pres, 0);
693  doublereal r_e_j = r_e_j_pr_tr + fabs(m_charge_j) * gval;
694  omega_j = nu * (m_charge_j * m_charge_j / r_e_j - m_charge_j / (3.082 + gval));
695  }
696 
697  doublereal relepsilon = m_waterProps->relEpsilon(m_temp, m_pres, 0);
698  doublereal Z = -1.0 / relepsilon;
699  doublereal wterm = - omega_j * (Z + 1.0);
700  doublereal wrterm = m_omega_pr_tr * (m_Z_pr_tr + 1.0);
701  doublereal yterm = m_omega_pr_tr * m_Y_pr_tr * (m_temp - 298.15);
702  doublereal deltaG_calgmol = sterm + c1term + a1term + a2term + c2term + a3term + a4term + wterm + wrterm + yterm;
703 
704  // Convert to Joules / kmol
705  return deltaG_calgmol * toSI("cal/gmol");
706 }
707 
708 doublereal PDSS_HKFT::deltaS() const
709 {
710  doublereal pbar = m_pres * 1.0E-5;
711 
712  doublereal c1term = m_c1 * log(m_temp/298.15);
713  doublereal c2term = -m_c2 / 228. * ((1.0/(m_temp - 228.) - 1.0/(298.15 - 228.))
714  + 1.0 / 228. * log((298.15*(m_temp-228.)) / (m_temp*(298.15-228.))));
715  doublereal a3term = m_a3 / (m_temp - 228.) / (m_temp - 228.) * (pbar - m_presR_bar);
716  doublereal a4term = m_a4 / (m_temp - 228.) / (m_temp - 228.) * log((2600. + pbar)/(2600. + m_presR_bar));
717 
718  doublereal omega_j;
719  doublereal domega_jdT;
720  if (m_charge_j == 0.0) {
721  omega_j = m_omega_pr_tr;
722  domega_jdT = 0.0;
723  } else {
724  doublereal nu = 166027;
725  doublereal r_e_j_pr_tr = m_charge_j * m_charge_j / (m_omega_pr_tr/nu + m_charge_j/3.082);
726  doublereal gval = gstar(m_temp, m_pres, 0);
727  doublereal dgvaldT = gstar(m_temp, m_pres, 1);
728  doublereal r_e_j = r_e_j_pr_tr + fabs(m_charge_j) * gval;
729  doublereal dr_e_jdT = fabs(m_charge_j) * dgvaldT;
730  omega_j = nu * (m_charge_j * m_charge_j / r_e_j - m_charge_j / (3.082 + gval));
731  domega_jdT = - nu * (m_charge_j * m_charge_j / (r_e_j * r_e_j) * dr_e_jdT)
732  + nu * m_charge_j / (3.082 + gval) / (3.082 + gval) * dgvaldT;
733  }
734 
735  doublereal relepsilon = m_waterProps->relEpsilon(m_temp, m_pres, 0);
736  doublereal drelepsilondT = m_waterProps->relEpsilon(m_temp, m_pres, 1);
737  doublereal Y = drelepsilondT / (relepsilon * relepsilon);
738  doublereal Z = -1.0 / relepsilon;
739  doublereal wterm = omega_j * Y;
740  doublereal wrterm = - m_omega_pr_tr * m_Y_pr_tr;
741  doublereal otterm = domega_jdT * (Z + 1.0);
742  doublereal otrterm = - m_domega_jdT_prtr * (m_Z_pr_tr + 1.0);
743  doublereal deltaS_calgmol = c1term + c2term + a3term + a4term + wterm + wrterm + otterm + otrterm;
744 
745  // Convert to Joules / kmol
746  return deltaS_calgmol * toSI("cal/gmol");
747 }
748 
749 doublereal PDSS_HKFT::ag(const doublereal temp, const int ifunc) const
750 {
751  static doublereal ag_coeff[3] = { -2.037662, 5.747000E-3, -6.557892E-6};
752  if (ifunc == 0) {
753  return ag_coeff[0] + ag_coeff[1] * temp + ag_coeff[2] * temp * temp;
754  } else if (ifunc == 1) {
755  return ag_coeff[1] + ag_coeff[2] * 2.0 * temp;
756  }
757  if (ifunc != 2) {
758  return 0.0;
759  }
760  return ag_coeff[2] * 2.0;
761 }
762 
763 doublereal PDSS_HKFT::bg(const doublereal temp, const int ifunc) const
764 {
765  static doublereal bg_coeff[3] = { 6.107361, -1.074377E-2, 1.268348E-5};
766  if (ifunc == 0) {
767  return bg_coeff[0] + bg_coeff[1] * temp + bg_coeff[2] * temp * temp;
768  } else if (ifunc == 1) {
769  return bg_coeff[1] + bg_coeff[2] * 2.0 * temp;
770  }
771  if (ifunc != 2) {
772  return 0.0;
773  }
774  return bg_coeff[2] * 2.0;
775 }
776 
777 doublereal PDSS_HKFT::f(const doublereal temp, const doublereal pres, const int ifunc) const
778 {
779  static doublereal af_coeff[3] = { 3.666666E1, -0.1504956E-9, 0.5107997E-13};
780  doublereal TC = temp - 273.15;
781  doublereal presBar = pres / 1.0E5;
782 
783  if (TC < 155.0) {
784  return 0.0;
785  }
786  TC = std::min(TC, 355.0);
787  if (presBar > 1000.) {
788  return 0.0;
789  }
790 
791  doublereal T1 = (TC-155.0)/300.;
792  doublereal p2 = (1000. - presBar) * (1000. - presBar);
793  doublereal p3 = (1000. - presBar) * p2;
794  doublereal p4 = p2 * p2;
795  doublereal fac2 = af_coeff[1] * p3 + af_coeff[2] * p4;
796  if (ifunc == 0) {
797  return pow(T1,4.8) + af_coeff[0] * pow(T1, 16.0) * fac2;
798  } else if (ifunc == 1) {
799  return (4.8 * pow(T1,3.8) + 16.0 * af_coeff[0] * pow(T1, 15.0)) / 300. * fac2;
800  } else if (ifunc == 2) {
801  return (4.8 * 3.8 * pow(T1,2.8) + 16.0 * 15.0 * af_coeff[0] * pow(T1, 14.0)) / (300. * 300.) * fac2;
802  } else if (ifunc == 3) {
803  double fac1 = pow(T1,4.8) + af_coeff[0] * pow(T1, 16.0);
804  fac2 = - (3.0 * af_coeff[1] * p2 + 4.0 * af_coeff[2] * p3)/ 1.0E5;
805  return fac1 * fac2;
806  } else {
807  throw CanteraError("HKFT_PDSS::gg", "unimplemented");
808  }
809 }
810 
811 doublereal PDSS_HKFT::g(const doublereal temp, const doublereal pres, const int ifunc) const
812 {
813  doublereal afunc = ag(temp, 0);
814  doublereal bfunc = bg(temp, 0);
815  m_waterSS->setState_TP(temp, pres);
817  // density in gm cm-3
818  doublereal dens = m_densWaterSS * 1.0E-3;
819  doublereal gval = afunc * pow((1.0-dens), bfunc);
820  if (dens >= 1.0) {
821  return 0.0;
822  }
823  if (ifunc == 0) {
824  return gval;
825  } else if (ifunc == 1 || ifunc == 2) {
826  doublereal afuncdT = ag(temp, 1);
827  doublereal bfuncdT = bg(temp, 1);
828  doublereal alpha = m_waterSS->thermalExpansionCoeff();
829 
830  doublereal fac1 = afuncdT * gval / afunc;
831  doublereal fac2 = bfuncdT * gval * log(1.0 - dens);
832  doublereal fac3 = gval * alpha * bfunc * dens / (1.0 - dens);
833 
834  doublereal dgdt = fac1 + fac2 + fac3;
835  if (ifunc == 1) {
836  return dgdt;
837  }
838 
839  doublereal afuncdT2 = ag(temp, 2);
840  doublereal bfuncdT2 = bg(temp, 2);
841  doublereal dfac1dT = dgdt * afuncdT / afunc + afuncdT2 * gval / afunc
842  - afuncdT * afuncdT * gval / (afunc * afunc);
843  doublereal ddensdT = - alpha * dens;
844  doublereal dfac2dT = bfuncdT2 * gval * log(1.0 - dens)
845  + bfuncdT * dgdt * log(1.0 - dens)
846  - bfuncdT * gval /(1.0 - dens) * ddensdT;
847  doublereal dalphadT = m_waterSS->dthermalExpansionCoeffdT();
848  doublereal dfac3dT = dgdt * alpha * bfunc * dens / (1.0 - dens)
849  + gval * dalphadT * bfunc * dens / (1.0 - dens)
850  + gval * alpha * bfuncdT * dens / (1.0 - dens)
851  + gval * alpha * bfunc * ddensdT / (1.0 - dens)
852  + gval * alpha * bfunc * dens / ((1.0 - dens) * (1.0 - dens)) * ddensdT;
853 
854  return dfac1dT + dfac2dT + dfac3dT;
855  } else if (ifunc == 3) {
856  doublereal beta = m_waterSS->isothermalCompressibility();
857  return - bfunc * gval * dens * beta / (1.0 - dens);
858  } else {
859  throw CanteraError("HKFT_PDSS::g", "unimplemented");
860  }
861  return 0.0;
862 }
863 
864 doublereal PDSS_HKFT::gstar(const doublereal temp, const doublereal pres, const int ifunc) const
865 {
866  doublereal gval = g(temp, pres, ifunc);
867  doublereal fval = f(temp, pres, ifunc);
868  double res = gval - fval;
869  return res;
870 }
871 
872 doublereal PDSS_HKFT::LookupGe(const std::string& elemName)
873 {
874  size_t iE = m_tp->elementIndex(elemName);
875  if (iE == npos) {
876  throw CanteraError("PDSS_HKFT::LookupGe", "element " + elemName + " not found");
877  }
878  doublereal geValue = m_tp->entropyElement298(iE);
879  if (geValue == ENTROPY298_UNKNOWN) {
880  throw CanteraError("PDSS_HKFT::LookupGe",
881  "element " + elemName + " does not have a supplied entropy298");
882  }
883  return geValue * -298.15;
884 }
885 
887 {
888  // Ok let's get the element compositions and conversion factors.
889  doublereal totalSum = 0.0;
890  for (size_t m = 0; m < m_tp->nElements(); m++) {
891  double na = m_tp->nAtoms(m_spindex, m);
892  if (na > 0.0) {
893  totalSum += na * LookupGe(m_tp->elementName(m));
894  }
895  }
896  // Add in the charge
897  if (m_charge_j != 0.0) {
898  totalSum -= m_charge_j * LookupGe("H");
899  }
900  // Ok, now do the calculation. Convert to joules kmol-1
901  doublereal dg = m_deltaG_formation_tr_pr * toSI("cal/gmol");
902  //! Store the result into an internal variable.
903  m_Mu0_tr_pr = dg + totalSum;
904 }
905 
906 void PDSS_HKFT::reportParams(size_t& kindex, int& type,
907  doublereal* const c,
908  doublereal& minTemp_,
909  doublereal& maxTemp_,
910  doublereal& refPressure_) const
911 {
912  // Fill in the first part
913  PDSS::reportParams(kindex, type, c, minTemp_, maxTemp_,
914  refPressure_);
915 
918  c[2] = m_Mu0_tr_pr;
919  c[3] = m_Entrop_tr_pr;
920  c[4] = m_a1;
921  c[5] = m_a2;
922  c[6] = m_a3;
923  c[7] = m_a4;
924  c[8] = m_c1;
925  c[9] = m_c2;
926  c[10] = m_omega_pr_tr;
927 }
928 
929 }
doublereal m_a4
Input a4 coefficient (cal K gmol-1)
Definition: PDSS_HKFT.h:377
size_t nElements() const
Number of elements.
Definition: Phase.cpp:161
doublereal m_densWaterSS
density of standard-state water. internal temporary variable
Definition: PDSS_HKFT.h:323
CTML ("Cantera Markup Language") is the variant of XML that Cantera uses to store data...
doublereal deltaH() const
Routine that actually calculates the enthalpy difference between the reference state at Tr...
Definition: PDSS_HKFT.cpp:625
virtual doublereal gibbs_RT() const
Return the molar Gibbs free energy divided by RT.
Definition: PDSS.cpp:405
std::string name() const
Returns the name of the XML node.
Definition: xml.h:370
virtual doublereal enthalpy_mole() const
Return the molar enthalpy in units of J kmol-1.
Definition: PDSS_HKFT.cpp:197
XML_Node * findXMLPhase(XML_Node *root, const std::string &idtarget)
Search an XML_Node tree for a named phase XML_Node.
Definition: xml.cpp:1038
virtual void setState_TP(doublereal temp, doublereal pres)
Set the internal temperature and pressure.
Definition: PDSS_HKFT.cpp:377
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:695
doublereal m_deltaG_formation_tr_pr
Input value of deltaG of Formation at Tr and Pr (cal gmol-1)
Definition: PDSS_HKFT.h:341
const doublereal OneAtm
One atmosphere [Pa].
Definition: ct_defs.h:69
virtual doublereal gibbs_RT_ref() const
Return the molar Gibbs free energy divided by RT at reference pressure.
Definition: PDSS_HKFT.cpp:332
doublereal bg(const doublereal temp, const int ifunc=0) const
Internal formula for the calculation of b_g()
Definition: PDSS_HKFT.cpp:763
doublereal deltaS() const
Main routine that actually calculates the entropy difference between the reference state at Tr...
Definition: PDSS_HKFT.cpp:708
virtual doublereal entropy_mole() const
Return the molar entropy in units of J kmol-1 K-1.
Definition: PDSS_HKFT.cpp:215
Virtual base class for the classes that manage the calculation of standard state properties for all t...
Definition: VPSSMgr.h:228
std::string findInputFile(const std::string &name)
Find an input file.
Definition: global.cpp:155
doublereal toSI(const std::string &unit)
Return the conversion factor to convert unit std::string &#39;unit&#39; to SI units.
Definition: global.cpp:160
virtual doublereal intEnergy_mole() const
Return the molar internal Energy in units of J kmol-1.
Definition: PDSS_HKFT.cpp:210
virtual void setPressure(doublereal pres)
Sets the pressure in the object.
Definition: PDSS.cpp:341
const size_t npos
index returned by functions to indicate "no position"
Definition: ct_defs.h:165
size_t elementIndex(const std::string &name) const
Return the index of element named &#39;name&#39;.
Definition: Phase.cpp:186
doublereal g(const doublereal temp, const doublereal pres, const int ifunc=0) const
function g appearing in the formulation
Definition: PDSS_HKFT.cpp:811
doublereal m_Mu0_tr_pr
Value of the Absolute Gibbs Free Energy NIST scale at T_r and P_r.
Definition: PDSS_HKFT.h:359
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:906
doublereal m_pres
State of the system - pressure.
Definition: PDSS.h:544
void writelog(const std::string &fmt, const Args &... args)
Write a formatted message to the screen.
Definition: global.h:179
doublereal m_c2
Input c2 coefficient (cal K gmol-1)
Definition: PDSS_HKFT.h:383
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:97
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:864
Implementation of a pressure dependent standard state virtual function for a Pure Water Phase (see Sp...
void warn_deprecated(const std::string &method, const std::string &extra)
Print a warning indicating that method is deprecated.
Definition: global.cpp:54
STL namespace.
virtual doublereal cp_R_ref() const
Return the molar heat capacity divided by R at reference pressure.
Definition: PDSS_HKFT.cpp:359
doublereal m_a3
Input a3 coefficient (cal K gmol-1 bar-1)
Definition: PDSS_HKFT.h:374
virtual doublereal cp_R() const
Return the molar const pressure heat capacity divided by RT.
Definition: PDSS.cpp:410
size_t m_spindex
Species index in the ThermoPhase corresponding to this species.
Definition: PDSS.h:570
virtual doublereal molarVolume() const
Return the molar volume at standard state.
Definition: PDSS_HKFT.cpp:284
PDSS_enumType m_pdssType
Enumerated type describing the type of the PDSS object.
Definition: PDSS.h:538
doublereal m_omega_pr_tr
Input omega_pr_tr coefficient(cal gmol-1)
Definition: PDSS_HKFT.h:386
doublereal m_Y_pr_tr
y = dZdT = 1/(esp*esp) desp/dT at 298.15 and 1 bar
Definition: PDSS_HKFT.h:389
virtual doublereal entropy_R() const
Return the standard state entropy divided by RT.
Definition: PDSS.cpp:400
virtual doublereal isothermalCompressibility() const
Returns the isothermal compressibility. Units: 1/Pa.
Definition: PDSS_Water.cpp:327
virtual void initAllPtrs(VPStandardStateTP *vptp_ptr, VPSSMgr *vpssmgr_ptr, MultiSpeciesThermo *spthermo_ptr)
Initialize or Reinitialize all shallow pointers in the object.
Definition: PDSS.cpp:184
static int s_InputInconsistencyErrorExit
Static variable determining error exiting.
Definition: PDSS_HKFT.h:408
virtual void initThermo()
Initialization routine for all of the shallow pointers.
Definition: PDSS_HKFT.cpp:383
doublereal enthalpy_mole2() const
Return the molar enthalpy in units of J kmol-1.
Definition: PDSS_HKFT.cpp:204
doublereal m_a2
Input a2 coefficient (cal gmol-1)
Definition: PDSS_HKFT.h:371
doublereal m_charge_j
Charge of the ion.
Definition: PDSS_HKFT.h:401
virtual void initThermo()
Initialization routine for all of the shallow pointers.
Definition: PDSS.cpp:175
std::unique_ptr< WaterProps > m_waterProps
Pointer to the water property calculator.
Definition: PDSS_HKFT.h:326
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:453
virtual void setTemperature(doublereal temp)
Set the internal temperature.
Definition: PDSS.cpp:351
virtual doublereal thermalExpansionCoeff() const
Return the volumetric thermal expansion coefficient. Units: 1/K.
Definition: PDSS_Water.cpp:306
The WaterProps class is used to house several approximation routines for properties of water...
Definition: WaterProps.h:93
virtual void initAllPtrs(VPStandardStateTP *vptp_ptr, VPSSMgr *vpssmgr_ptr, MultiSpeciesThermo *spthermo_ptr)
Initialize or Reinitialize all shallow pointers in the object.
Definition: PDSS_HKFT.cpp:445
virtual void setState_TP(doublereal temp, doublereal pres)
Set the internal temperature and pressure.
Definition: PDSS_Water.cpp:364
doublereal deltaG() const
Main routine that actually calculates the Gibbs free energy difference between the reference state at...
Definition: PDSS_HKFT.cpp:674
std::string speciesName(size_t k) const
Name of the species with index k.
Definition: Phase.cpp:267
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:25
Class for the liquid water pressure dependent standard state.
Definition: PDSS_Water.h:49
doublereal m_deltaH_formation_tr_pr
Input value of deltaH of Formation at Tr and Pr (cal gmol-1)
Definition: PDSS_HKFT.h:350
doublereal entropyElement298(size_t m) const
Entropy of the element in its standard state at 298 K and 1 bar.
Definition: Phase.cpp:206
doublereal m_Entrop_tr_pr
Input value of S_j at Tr and Pr (cal gmol-1 K-1)
Definition: PDSS_HKFT.h:365
virtual doublereal density() const
Return the standard state density at standard state.
Definition: PDSS_HKFT.cpp:327
virtual doublereal entropy_R_ref() const
Return the molar entropy divided by R at reference pressure.
Definition: PDSS_HKFT.cpp:350
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:65
doublereal f(const doublereal temp, const doublereal pres, const int ifunc=0) const
Difference function f appearing in the formulation.
Definition: PDSS_HKFT.cpp:777
void convertDGFormation()
Translate a Gibbs free energy of formation value to a NIST-based Chemical potential.
Definition: PDSS_HKFT.cpp:886
void build(const std::string &filename)
Populate the XML tree from an input file.
Definition: xml.cpp:716
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:377
doublereal m_presR_bar
Reference pressure is 1 atm in units of bar= 1.0132.
Definition: PDSS_HKFT.h:395
This is a filter class for ThermoPhase that implements some prepatory steps for efficiently handling ...
virtual doublereal molarVolume_ref() const
Return the molar volume at reference pressure.
Definition: PDSS_HKFT.cpp:368
virtual doublereal dthermalExpansionCoeffdT() const
Return the derivative of the volumetric thermal expansion coefficient.
Definition: PDSS_Water.cpp:311
doublereal m_maxTemp
Maximum temperature.
Definition: PDSS.h:553
virtual PDSS * duplMyselfAsPDSS() const
Duplication routine for objects which inherit from PDSS.
Definition: PDSS_HKFT.cpp:192
doublereal m_domega_jdT_prtr
small value that is not quite zero
Definition: PDSS_HKFT.h:398
doublereal m_minTemp
Minimum temperature.
Definition: PDSS.h:550
#define ENTROPY298_UNKNOWN
Number indicating we don&#39;t know the entropy of the element in its most stable state at 298...
Definition: Elements.h:87
bool hasChild(const std::string &ch) const
Tests whether the current node has a child node with a particular name.
Definition: xml.cpp:536
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
PDSS_Water * m_waterSS
Water standard state calculator.
Definition: PDSS_HKFT.h:320
XML_Node & root() const
Return the root of the current XML_Node tree.
Definition: xml.cpp:1025
doublereal LookupGe(const std::string &elemName)
Function to look up Element Free Energies.
Definition: PDSS_HKFT.cpp:872
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:380
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:392
std::string attrib(const std::string &attr) const
Function returns the value of an attribute.
Definition: xml.cpp:500
Virtual base class for a species with a pressure dependent standard state.
Definition: PDSS.h:176
VPStandardStateTP * m_tp
ThermoPhase which this species belongs to.
Definition: PDSS.h:561
doublereal m_temp
Current temperature used by the PDSS object.
Definition: PDSS.h:541
PDSS & operator=(const PDSS &b)
Definition: PDSS.cpp:103
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:178
virtual doublereal gibbs_mole() const
Return the molar Gibbs free energy in units of J kmol-1.
Definition: PDSS_HKFT.cpp:220
Class for pressure dependent standard states corresponding to ionic solutes in electrolyte water...
Definition: PDSS_HKFT.h:27
virtual doublereal density() const
Return the standard state density at standard state.
Definition: PDSS_Water.cpp:353
doublereal ag(const doublereal temp, const int ifunc=0) const
Internal formula for the calculation of a_g()
Definition: PDSS_HKFT.cpp:749
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:661
A species thermodynamic property manager for a phase.
doublereal m_c1
Input c1 coefficient (cal gmol-1 K-1)
Definition: PDSS_HKFT.h:380
doublereal m_r_e_j
Electrostatic radii.
Definition: PDSS_HKFT.h:332
Namespace for the Cantera kernel.
Definition: application.cpp:29
doublereal m_born_coeff_j
Born coefficient for the current ion or species.
Definition: PDSS_HKFT.h:329
doublereal nAtoms(size_t k, size_t m) const
Number of atoms of element m in species k.
Definition: Phase.cpp:237
doublereal strSItoDbl(const std::string &strSI)
Interpret one or two token string as a single double.
virtual doublereal enthalpy_RT_ref() const
Return the molar enthalpy divided by RT at reference pressure.
Definition: PDSS_HKFT.cpp:341
virtual doublereal enthalpy_RT() const
Return the standard state molar enthalpy divided by RT.
Definition: PDSS.cpp:395
doublereal fpValueCheck(const std::string &val)
Translate a string into one doublereal value, with error checking.
virtual doublereal cp_mole() const
Return the molar const pressure heat capacity in units of J kmol-1 K-1.
Definition: PDSS_HKFT.cpp:225
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
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:577
std::string elementName(size_t m) const
Name of the element with index m.
Definition: Phase.cpp:180
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:547
doublereal m_a1
Input a1 coefficient (cal gmol-1 bar-1)
Definition: PDSS_HKFT.h:368
doublereal m_mw
Molecular Weight of the species.
Definition: PDSS.h:567
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:596