29 , m_deltaG_formation_tr_pr(NAN)
30 , m_deltaH_formation_tr_pr(NAN)
43 , m_domega_jdT_prtr(0.0)
61 return deltaH() + enthTRPR;
81 doublereal pbar =
m_pres * 1.0E-5;
82 doublereal c1term =
m_c1;
89 doublereal domega_jdT;
90 doublereal d2omega_jdT2;
96 doublereal nu = 166027;
102 doublereal r_e_j = r_e_j_pr_tr + fabs(
m_charge_j) * gval;
103 doublereal dr_e_jdT = fabs(
m_charge_j) * dgvaldT;
104 doublereal d2r_e_jdT2 = fabs(
m_charge_j) * d2gvaldT2;
105 doublereal r_e_j2 = r_e_j * r_e_j;
108 doublereal r_e_H = 3.082 + gval;
109 doublereal r_e_H2 = r_e_H * r_e_H;
110 omega_j = nu * (charge2 / r_e_j -
m_charge_j / r_e_H);
111 domega_jdT = nu * (-(charge2 / r_e_j2 * dr_e_jdT)
113 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
119 doublereal Y = drelepsilondT / (relepsilon * relepsilon);
122 doublereal X = d2relepsilondT2 / (relepsilon* relepsilon) - 2.0 * relepsilon * Y * Y;
123 doublereal Z = -1.0 / relepsilon;
125 doublereal yterm = 2.0 *
m_temp * Y * domega_jdT;
126 doublereal xterm = omega_j *
m_temp * X;
127 doublereal otterm =
m_temp * d2omega_jdT2 * (Z + 1.0);
130 doublereal Cp_calgmol = c1term + c2term + a3term + a4term + yterm + xterm + otterm + rterm;
133 doublereal Cp = Cp_calgmol *
toSI(
"cal/gmol");
142 doublereal a1term =
m_a1 * 1.0E-5;
143 doublereal a2term =
m_a2 / (2600.E5 +
m_pres);
144 doublereal a3term =
m_a3 * 1.0E-5/ (
m_temp - 228.);
148 doublereal domega_jdP;
153 doublereal nu = 166027.;
160 doublereal r_e_j = r_e_j_pr_tr + fabs(
m_charge_j) * gval;
161 doublereal r_e_H = 3.082 + gval;
163 omega_j = nu * (charge2 / r_e_j -
m_charge_j / r_e_H);
164 doublereal dr_e_jdP = fabs(
m_charge_j) * dgvaldP;
165 domega_jdP = - nu * (charge2 / (r_e_j * r_e_j) * dr_e_jdP)
166 + nu *
m_charge_j / (r_e_H * r_e_H) * dgvaldP;
171 doublereal Q = drelepsilondP / (relepsilon * relepsilon);
172 doublereal Z = -1.0 / relepsilon;
173 doublereal wterm = - domega_jdP * (Z + 1.0);
174 doublereal qterm = - omega_j * Q;
175 doublereal molVol_calgmolPascal = a1term + a2term + a3term + a4term + wterm + qterm;
178 return molVol_calgmolPascal *
toSI(
"cal/gmol");
188 doublereal m_psave =
m_pres;
197 doublereal m_psave =
m_pres;
206 doublereal m_psave =
m_pres;
215 doublereal m_psave =
m_pres;
217 doublereal ee =
cp_R();
224 doublereal m_psave =
m_pres;
252 m_a1 = units.convert(a[0],
"cal/gmol/bar");
253 m_a2 = units.convert(a[1],
"cal/gmol");
254 m_a3 = units.convert(a[2],
"cal*K/gmol/bar");
255 m_a4 = units.convert(a[3],
"cal*K/gmol");
259 m_c1 = units.convert(c[0],
"cal/gmol/K");
260 m_c2 = units.convert(c[1],
"cal*K/gmol");
298 m_Y_pr_tr = drelepsilondT / (relepsilon * relepsilon);
311 if (fabs(Hcalc -DHjmol) > 100.*
toSI(
"cal/gmol")) {
314 throw CanteraError(
"PDSS_HKFT::initThermo",
"For {}, DHjmol is"
315 " not consistent with G and S: {} vs {} cal gmol-1",
319 "DHjmol for {} is not consistent with G and S: calculated {} "
320 "vs input {} cal gmol-1; continuing with consistent DHjmol = {}",
322 Hcalc/
toSI(
"cal/gmol"));
326 doublereal nu = 166027;
327 doublereal r_e_j_pr_tr;
339 doublereal r_e_j = r_e_j_pr_tr + fabs(
m_charge_j) * gval;
340 doublereal dr_e_jdT = fabs(
m_charge_j) * dgvaldT;
342 + nu *
m_charge_j / (3.082 + gval) / (3.082 + gval) * dgvaldT;
361 m_a3 = a[2] /
toSI(
"cal-K/gmol/bar");
384 "no thermo Node for species '{}'", speciesNode.
name());
388 "thermo model for species '{}' isn't 'hkft'",
394 "no Thermo::HKFT Node for species '{}'", speciesNode.
name());
399 std::string p0string = hh->
attrib(
"Pref");
400 if (p0string !=
"") {
404 std::string minTstring = hh->
attrib(
"Tmin");
405 if (minTstring !=
"") {
409 std::string maxTstring = hh->
attrib(
"Tmax");
410 if (maxTstring !=
"") {
432 "no 'standardState' Node for species '{}'",
437 "standardState model for species '{}' isn't 'hkft'",
449 int isum = hasDGO + hasDHO + hasSO;
452 "Missing 2 or more of DG0_f_Pr_Tr, DH0_f_Pr_Tr, or S0_f_Pr_Tr fields. "
453 "Need to supply at least two of these fields");
460 eosNode[
"model"] =
"HKFT";
465 std::vector<AnyValue> a(4), c(2);
466 a[0].setQuantity(
m_a1,
"cal/gmol/bar");
467 a[1].setQuantity(
m_a2,
"cal/gmol");
468 a[2].setQuantity(
m_a3,
"cal*K/gmol/bar");
469 a[3].setQuantity(
m_a4,
"cal*K/gmol");
470 eosNode[
"a"] = std::move(a);
472 c[0].setQuantity(
m_c1,
"cal/gmol/K");
473 c[1].setQuantity(
m_c2,
"cal*K/gmol");
474 eosNode[
"c"] = std::move(c);
481 doublereal pbar =
m_pres * 1.0E-5;
485 doublereal c2term = -
m_c2 * (1.0/(
m_temp - 228.) - 1.0/(298.15 - 228.));
488 doublereal a4term =
m_a4 * a3tmp * log((2600. + pbar)/(2600. +
m_presR_bar));
490 doublereal domega_jdT;
495 doublereal nu = 166027;
498 doublereal r_e_j = r_e_j_pr_tr + fabs(
m_charge_j) * gval;
500 doublereal dr_e_jdT = fabs(
m_charge_j) * dgvaldT;
503 + nu *
m_charge_j / (3.082 + gval) / (3.082 + gval) * dgvaldT;
509 doublereal Y = drelepsilondT / (relepsilon * relepsilon);
510 doublereal Z = -1.0 / relepsilon;
512 doublereal yterm =
m_temp * omega_j * Y;
515 doublereal wterm = - omega_j * (Z + 1.0);
518 doublereal otterm =
m_temp * domega_jdT * (Z + 1.0);
521 doublereal deltaH_calgmol = c1term + a1term + a2term + c2term + a3term + a4term
522 + yterm + yrterm + wterm + wrterm + otterm + otrterm;
525 return deltaH_calgmol *
toSI(
"cal/gmol");
530 doublereal pbar =
m_pres * 1.0E-5;
535 doublereal c2term = -
m_c2 * ((1.0/(
m_temp - 228.) - 1.0/(298.15 - 228.)) * (228. -
m_temp)/228.
544 doublereal nu = 166027;
547 doublereal r_e_j = r_e_j_pr_tr + fabs(
m_charge_j) * gval;
552 doublereal Z = -1.0 / relepsilon;
553 doublereal wterm = - omega_j * (Z + 1.0);
556 doublereal deltaG_calgmol = sterm + c1term + a1term + a2term + c2term + a3term + a4term + wterm + wrterm + yterm;
559 return deltaG_calgmol *
toSI(
"cal/gmol");
564 doublereal pbar =
m_pres * 1.0E-5;
566 doublereal c1term =
m_c1 * log(
m_temp/298.15);
567 doublereal c2term = -
m_c2 / 228. * ((1.0/(
m_temp - 228.) - 1.0/(298.15 - 228.))
568 + 1.0 / 228. * log((298.15*(
m_temp-228.)) / (
m_temp*(298.15-228.))));
573 doublereal domega_jdT;
578 doublereal nu = 166027;
582 doublereal r_e_j = r_e_j_pr_tr + fabs(
m_charge_j) * gval;
583 doublereal dr_e_jdT = fabs(
m_charge_j) * dgvaldT;
586 + nu *
m_charge_j / (3.082 + gval) / (3.082 + gval) * dgvaldT;
591 doublereal Y = drelepsilondT / (relepsilon * relepsilon);
592 doublereal Z = -1.0 / relepsilon;
593 doublereal wterm = omega_j * Y;
595 doublereal otterm = domega_jdT * (Z + 1.0);
597 doublereal deltaS_calgmol = c1term + c2term + a3term + a4term + wterm + wrterm + otterm + otrterm;
600 return deltaS_calgmol *
toSI(
"cal/gmol");
605 static doublereal ag_coeff[3] = { -2.037662, 5.747000E-3, -6.557892E-6};
607 return ag_coeff[0] + ag_coeff[1] * temp + ag_coeff[2] * temp * temp;
608 }
else if (ifunc == 1) {
609 return ag_coeff[1] + ag_coeff[2] * 2.0 * temp;
614 return ag_coeff[2] * 2.0;
619 static doublereal bg_coeff[3] = { 6.107361, -1.074377E-2, 1.268348E-5};
621 return bg_coeff[0] + bg_coeff[1] * temp + bg_coeff[2] * temp * temp;
622 }
else if (ifunc == 1) {
623 return bg_coeff[1] + bg_coeff[2] * 2.0 * temp;
628 return bg_coeff[2] * 2.0;
631doublereal
PDSS_HKFT::f(
const doublereal temp,
const doublereal pres,
const int ifunc)
const
633 static doublereal af_coeff[3] = { 3.666666E1, -0.1504956E-9, 0.5107997E-13};
634 doublereal TC = temp - 273.15;
635 doublereal presBar = pres / 1.0E5;
640 TC = std::min(TC, 355.0);
641 if (presBar > 1000.) {
645 doublereal T1 = (TC-155.0)/300.;
646 doublereal p2 = (1000. - presBar) * (1000. - presBar);
647 doublereal p3 = (1000. - presBar) * p2;
648 doublereal p4 = p2 * p2;
649 doublereal fac2 = af_coeff[1] * p3 + af_coeff[2] * p4;
651 return pow(T1,4.8) + af_coeff[0] * pow(T1, 16.0) * fac2;
652 }
else if (ifunc == 1) {
653 return (4.8 * pow(T1,3.8) + 16.0 * af_coeff[0] * pow(T1, 15.0)) / 300. * fac2;
654 }
else if (ifunc == 2) {
655 return (4.8 * 3.8 * pow(T1,2.8) + 16.0 * 15.0 * af_coeff[0] * pow(T1, 14.0)) / (300. * 300.) * fac2;
656 }
else if (ifunc == 3) {
657 double fac1 = pow(T1,4.8) + af_coeff[0] * pow(T1, 16.0);
658 fac2 = - (3.0 * af_coeff[1] * p2 + 4.0 * af_coeff[2] * p3)/ 1.0E5;
665doublereal
PDSS_HKFT::g(
const doublereal temp,
const doublereal pres,
const int ifunc)
const
667 doublereal afunc =
ag(temp, 0);
668 doublereal bfunc =
bg(temp, 0);
673 doublereal gval = afunc * pow((1.0-dens), bfunc);
679 }
else if (ifunc == 1 || ifunc == 2) {
680 doublereal afuncdT =
ag(temp, 1);
681 doublereal bfuncdT =
bg(temp, 1);
684 doublereal fac1 = afuncdT * gval / afunc;
685 doublereal fac2 = bfuncdT * gval * log(1.0 - dens);
686 doublereal fac3 = gval * alpha * bfunc * dens / (1.0 - dens);
688 doublereal dgdt = fac1 + fac2 + fac3;
693 doublereal afuncdT2 =
ag(temp, 2);
694 doublereal bfuncdT2 =
bg(temp, 2);
695 doublereal dfac1dT = dgdt * afuncdT / afunc + afuncdT2 * gval / afunc
696 - afuncdT * afuncdT * gval / (afunc * afunc);
697 doublereal ddensdT = - alpha * dens;
698 doublereal dfac2dT = bfuncdT2 * gval * log(1.0 - dens)
699 + bfuncdT * dgdt * log(1.0 - dens)
700 - bfuncdT * gval /(1.0 - dens) * ddensdT;
702 doublereal dfac3dT = dgdt * alpha * bfunc * dens / (1.0 - dens)
703 + gval * dalphadT * bfunc * dens / (1.0 - dens)
704 + gval * alpha * bfuncdT * dens / (1.0 - dens)
705 + gval * alpha * bfunc * ddensdT / (1.0 - dens)
706 + gval * alpha * bfunc * dens / ((1.0 - dens) * (1.0 - dens)) * ddensdT;
708 return dfac1dT + dfac2dT + dfac3dT;
709 }
else if (ifunc == 3) {
711 return - bfunc * gval * dens * beta / (1.0 - dens);
718doublereal
PDSS_HKFT::gstar(
const doublereal temp,
const doublereal pres,
const int ifunc)
const
720 doublereal gval =
g(temp, pres, ifunc);
721 doublereal fval =
f(temp, pres, ifunc);
722 double res = gval - fval;
730 throw CanteraError(
"PDSS_HKFT::LookupGe",
"element " + elemName +
" not found");
735 "element " + elemName +
" does not have a supplied entropy298");
737 return geValue * -298.15;
743 doublereal totalSum = 0.0;
762 doublereal& minTemp_,
763 doublereal& maxTemp_,
764 doublereal& refPressure_)
const
#define ENTROPY298_UNKNOWN
Number indicating we don't know the entropy of the element in its most stable state at 298....
Declarations for the class PDSS_HKFT (pressure dependent standard state) which handles calculations f...
Implementation of a pressure dependent standard state virtual function for a Pure Water Phase (see Sp...
Header file for a derived class of ThermoPhase that handles variable pressure standard state methods ...
A map of string keys to values whose type can vary at runtime.
double convert(const std::string &key, const std::string &units) const
Convert the item stored by the given key to the units specified in units.
const UnitSystem & units() const
Return the default units that should be used to convert stored values.
bool hasKey(const std::string &key) const
Returns true if the map contains an item named key.
A wrapper for a variable whose type is determined at runtime.
Base class for exceptions thrown by Cantera classes.
An error indicating that an unimplemented function has been called.
void setOmega(double omega)
Set omega [J/kmol].
static int s_InputInconsistencyErrorExit
Static variable determining error exiting.
virtual void getParameters(AnyMap &eosNode) const
Store the parameters needed to reconstruct a copy of this PDSS object.
virtual doublereal cp_R_ref() const
Return the molar heat capacity divided by R at reference pressure.
doublereal m_deltaG_formation_tr_pr
Input value of deltaG of Formation at Tr and Pr (cal gmol-1)
size_t m_spindex
Index of this species within the parent phase.
doublereal m_a3
Input a3 coefficient (cal K gmol-1 bar-1)
doublereal m_domega_jdT_prtr
small value that is not quite zero
doublereal m_a4
Input a4 coefficient (cal K gmol-1)
doublereal m_charge_j
Charge of the ion.
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...
doublereal m_c2
Input c2 coefficient (cal K gmol-1)
doublereal m_c1
Input c1 coefficient (cal gmol-1 K-1)
doublereal deltaH() const
Routine that actually calculates the enthalpy difference between the reference state at Tr,...
virtual doublereal cp_mole() const
Return the molar const pressure heat capacity in units of J kmol-1 K-1.
VPStandardStateTP * m_tp
Parent VPStandardStateTP (ThermoPhase) object.
virtual doublereal enthalpy_mole() const
Return the molar enthalpy in units of J kmol-1.
void setDeltaG0(double dg0)
Set Gibbs free energy of formation at Pr, Tr [J/kmol].
virtual void setState_TP(doublereal temp, doublereal pres)
Set the internal temperature and pressure.
doublereal m_omega_pr_tr
Input omega_pr_tr coefficient(cal gmol-1)
doublereal m_a2
Input a2 coefficient (cal gmol-1)
doublereal m_densWaterSS
density of standard-state water. internal temporary variable
doublereal m_Entrop_tr_pr
Input value of S_j at Tr and Pr (cal gmol-1 K-1)
PDSS_HKFT()
Default Constructor.
doublereal bg(const doublereal temp, const int ifunc=0) const
Internal formula for the calculation of b_g()
doublereal g(const doublereal temp, const doublereal pres, const int ifunc=0) const
function g appearing in the formulation
doublereal m_Y_pr_tr
y = dZdT = 1/(esp*esp) desp/dT at 298.15 and 1 bar
void setS0(double s0)
Set entropy of formation at Pr, Tr [J/kmol/K].
doublereal ag(const doublereal temp, const int ifunc=0) const
Internal formula for the calculation of a_g()
doublereal f(const doublereal temp, const doublereal pres, const int ifunc=0) const
Difference function f appearing in the formulation.
virtual doublereal entropy_mole() const
Return the molar entropy in units of J kmol-1 K-1.
doublereal m_a1
Input a1 coefficient (cal gmol-1 bar-1)
doublereal enthalpy_mole2() const
Return the molar enthalpy in units of J kmol-1.
virtual doublereal molarVolume_ref() const
Return the molar volume at reference pressure.
virtual void initThermo()
Initialization routine.
doublereal m_Z_pr_tr
Z = -1 / relEpsilon at 298.15 and 1 bar.
doublereal m_deltaH_formation_tr_pr
Input value of deltaH of Formation at Tr and Pr (cal gmol-1)
void set_a(double *a)
Set "a" coefficients (array of 4 elements).
doublereal LookupGe(const std::string &elemName)
Function to look up Element Free Energies.
virtual doublereal molarVolume() const
Return the molar volume at standard state.
void setParametersFromXML(const XML_Node &speciesNode)
Initialization routine for the PDSS object based on the speciesNode.
virtual doublereal gibbs_mole() const
Return the molar Gibbs free energy in units of J kmol-1.
virtual doublereal enthalpy_RT_ref() const
Return the molar enthalpy divided by RT at reference pressure.
doublereal deltaS() const
Main routine that actually calculates the entropy difference between the reference state at Tr,...
void convertDGFormation()
Translate a Gibbs free energy of formation value to a NIST-based Chemical potential.
doublereal m_Mu0_tr_pr
Value of the Absolute Gibbs Free Energy NIST scale at T_r and P_r.
virtual doublereal density() const
Return the standard state density at standard state.
doublereal m_presR_bar
Reference pressure is 1 atm in units of bar= 1.0132.
doublereal gstar(const doublereal temp, const doublereal pres, const int ifunc=0) const
Evaluate the Gstar value appearing in the HKFT formulation.
virtual doublereal entropy_R_ref() const
Return the molar entropy divided by R at reference pressure.
virtual doublereal gibbs_RT_ref() const
Return the molar Gibbs free energy divided by RT at reference pressure.
PDSS_Water * m_waterSS
Water standard state calculator.
doublereal deltaG() const
Main routine that actually calculates the Gibbs free energy difference between the reference state at...
std::unique_ptr< WaterProps > m_waterProps
Pointer to the water property calculator.
void set_c(double *c)
Set "c" coefficients (array of 2 elements).
virtual doublereal intEnergy_mole() const
Return the molar internal Energy in units of J kmol-1.
void setDeltaH0(double dh0)
Set enthalpy of formation at Pr, Tr [J/kmol].
virtual doublereal entropy_R() const
Return the standard state entropy divided by RT.
virtual doublereal enthalpy_RT() const
Return the standard state molar enthalpy divided by RT.
virtual doublereal gibbs_RT() const
Return the molar Gibbs free energy divided by RT.
virtual doublereal cp_R() const
Return the molar const pressure heat capacity divided by RT.
Class for the liquid water pressure dependent standard state.
doublereal pref_safe(doublereal temp) const
Returns a reference pressure value that can be safely calculated by the underlying real equation of s...
virtual void setState_TP(doublereal temp, doublereal pres)
Set the internal temperature and pressure.
virtual doublereal thermalExpansionCoeff() const
Return the volumetric thermal expansion coefficient. Units: 1/K.
virtual doublereal dthermalExpansionCoeffdT() const
Return the derivative of the volumetric thermal expansion coefficient.
virtual doublereal density() const
Return the standard state density at standard state.
virtual doublereal isothermalCompressibility() const
Returns the isothermal compressibility. Units: 1/Pa.
virtual void initThermo()
Initialization routine.
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...
virtual void setParametersFromXML(const XML_Node &speciesNode)
Initialization routine for the PDSS object based on the speciesNode.
doublereal m_pres
State of the system - pressure.
virtual void setPressure(doublereal pres)
Sets the pressure in the object.
doublereal m_temp
Current temperature used by the PDSS object.
doublereal m_maxTemp
Maximum temperature.
virtual void setTemperature(doublereal temp)
Set the internal temperature.
doublereal m_p0
Reference state pressure of the species.
doublereal m_mw
Molecular Weight of the species.
AnyMap m_input
Input data supplied via setParameters.
virtual void getParameters(AnyMap &eosNode) const
Store the parameters needed to reconstruct a copy of this PDSS object.
doublereal m_minTemp
Minimum temperature.
doublereal entropyElement298(size_t m) const
Entropy of the element in its standard state at 298 K and 1 bar.
doublereal charge(size_t k) const
Dimensionless electrical charge of a single molecule of species k The charge is normalized by the the...
size_t elementIndex(const std::string &name) const
Return the index of element named 'name'.
std::string speciesName(size_t k) const
Name of the species with index k.
doublereal nAtoms(size_t k, size_t m) const
Number of atoms of element m in species k.
size_t nElements() const
Number of elements.
std::string elementName(size_t m) const
Name of the element with index m.
The WaterProps class is used to house several approximation routines for properties of water.
Class XML_Node is a tree-based representation of the contents of an XML file.
std::string attrib(const std::string &attr) const
Function returns the value of an attribute.
std::string name() const
Returns the name of the XML node.
bool hasChild(const std::string &ch) const
Tests whether the current node has a child node with a particular name.
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.
CTML ("Cantera Markup Language") is the variant of XML that Cantera uses to store data.
This file contains definitions for utility functions and text for modules, inputfiles,...
Namespace for the Cantera kernel.
const size_t npos
index returned by functions to indicate "no position"
doublereal getFloat(const XML_Node &parent, const std::string &name, const std::string &type="")
Get a floating-point value from a child element.
const double OneAtm
One atmosphere [Pa].
bool caseInsensitiveEquals(const std::string &input, const std::string &test)
Case insensitive equality predicate.
void warn_user(const std::string &method, const std::string &msg, const Args &... args)
Print a user warning raised from method as CanteraWarning.
doublereal toSI(const std::string &unit)
Return the conversion factor to convert unit std::string 'unit' to SI units.
doublereal fpValueCheck(const std::string &val)
Translate a string into one doublereal value, with error checking.
doublereal strSItoDbl(const std::string &strSI)
Interpret one or two token string as a single double.
Contains declarations for string manipulation functions within Cantera.