38 warn_deprecated(
"PDSS_HKFT::enthalpy_mole2",
"To be removed after Cantera 3.0");
40 return deltaH() + enthTRPR;
60 double pbar =
m_pres * 1.0E-5;
81 double r_e_j = r_e_j_pr_tr + fabs(
m_charge_j) * gval;
83 double d2r_e_jdT2 = fabs(
m_charge_j) * d2gvaldT2;
84 double r_e_j2 = r_e_j * r_e_j;
87 double r_e_H = 3.082 + gval;
88 double r_e_H2 = r_e_H * r_e_H;
89 omega_j = nu * (charge2 / r_e_j -
m_charge_j / r_e_H);
90 domega_jdT = nu * (-(charge2 / r_e_j2 * dr_e_jdT)
92 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
98 double Y = drelepsilondT / (relepsilon * relepsilon);
101 double X = d2relepsilondT2 / (relepsilon* relepsilon) - 2.0 * relepsilon * Y * Y;
102 double Z = -1.0 / relepsilon;
104 double yterm = 2.0 *
m_temp * Y * domega_jdT;
105 double xterm = omega_j *
m_temp * X;
106 double otterm =
m_temp * d2omega_jdT2 * (Z + 1.0);
109 double Cp_calgmol = c1term + c2term + a3term + a4term + yterm + xterm + otterm + rterm;
111 return m_units.
convertTo(Cp_calgmol,
"J/kmol");
118 double a1term =
m_a1 * 1.0E-5;
120 double a3term =
m_a3 * 1.0E-5/ (
m_temp - 228.);
136 double r_e_j = r_e_j_pr_tr + fabs(
m_charge_j) * gval;
137 double r_e_H = 3.082 + gval;
139 omega_j = nu * (charge2 / r_e_j -
m_charge_j / r_e_H);
141 domega_jdP = - nu * (charge2 / (r_e_j * r_e_j) * dr_e_jdP)
142 + nu *
m_charge_j / (r_e_H * r_e_H) * dgvaldP;
147 double Q = drelepsilondP / (relepsilon * relepsilon);
148 double Z = -1.0 / relepsilon;
149 double wterm = - domega_jdP * (Z + 1.0);
150 double qterm = - omega_j * Q;
151 double molVol_calgmolPascal = a1term + a2term + a3term + a4term + wterm + qterm;
154 return m_units.
convertTo(molVol_calgmolPascal,
"J/kmol");
228 m_a1 = units.convert(a[0],
"cal/gmol/bar");
229 m_a2 = units.convert(a[1],
"cal/gmol");
230 m_a3 = units.convert(a[2],
"cal*K/gmol/bar");
231 m_a4 = units.convert(a[3],
"cal*K/gmol");
235 m_c1 = units.convert(c[0],
"cal/gmol/K");
236 m_c2 = units.convert(c[1],
"cal*K/gmol");
274 m_Y_pr_tr = drelepsilondT / (relepsilon * relepsilon);
287 if (fabs(Hcalc -DHjmol) > m_units.
convertTo(100,
"J/kmol")) {
290 throw CanteraError(
"PDSS_HKFT::initThermo",
"For {}, DHjmol is"
291 " not consistent with G and S: {} vs {} J/kmol",
295 "DHjmol for {} is not consistent with G and S: calculated {} "
296 "vs input {} J/kmol; continuing with consistent DHjmol = {}",
315 double r_e_j = r_e_j_pr_tr + fabs(
m_charge_j) * gval;
318 + nu *
m_charge_j / (3.082 + gval) / (3.082 + gval) * dgvaldT;
353 eosNode[
"model"] =
"HKFT";
358 vector<AnyValue> a(4), c(2);
359 a[0].setQuantity(
m_a1,
"cal/gmol/bar");
360 a[1].setQuantity(
m_a2,
"cal/gmol");
361 a[2].setQuantity(
m_a3,
"cal*K/gmol/bar");
362 a[3].setQuantity(
m_a4,
"cal*K/gmol");
363 eosNode[
"a"] = std::move(a);
365 c[0].setQuantity(
m_c1,
"cal/gmol/K");
366 c[1].setQuantity(
m_c2,
"cal*K/gmol");
367 eosNode[
"c"] = std::move(c);
374 warn_deprecated(
"PDSS_HKFT::deltaH",
"To be removed after Cantera 3.0");
375 double pbar =
m_pres * 1.0E-5;
379 double c2term = -
m_c2 * (1.0/(
m_temp - 228.) - 1.0/(298.15 - 228.));
382 double a4term =
m_a4 * a3tmp * log((2600. + pbar)/(2600. +
m_presR_bar));
392 double r_e_j = r_e_j_pr_tr + fabs(
m_charge_j) * gval;
397 + nu *
m_charge_j / (3.082 + gval) / (3.082 + gval) * dgvaldT;
403 double Y = drelepsilondT / (relepsilon * relepsilon);
404 double Z = -1.0 / relepsilon;
406 double yterm =
m_temp * omega_j * Y;
409 double wterm = - omega_j * (Z + 1.0);
412 double otterm =
m_temp * domega_jdT * (Z + 1.0);
415 double deltaH_calgmol = c1term + a1term + a2term + c2term + a3term + a4term
416 + yterm + yrterm + wterm + wrterm + otterm + otrterm;
418 return m_units.
convertTo(deltaH_calgmol,
"J/kmol");
423 double pbar =
m_pres * 1.0E-5;
428 double c2term = -
m_c2 * ((1.0/(
m_temp - 228.) - 1.0/(298.15 - 228.)) * (228. -
m_temp)/228.
440 double r_e_j = r_e_j_pr_tr + fabs(
m_charge_j) * gval;
445 double Z = -1.0 / relepsilon;
446 double wterm = - omega_j * (Z + 1.0);
449 double deltaG_calgmol = sterm + c1term + a1term + a2term + c2term + a3term + a4term + wterm + wrterm + yterm;
451 return m_units.
convertTo(deltaG_calgmol,
"J/kmol");
456 double pbar =
m_pres * 1.0E-5;
459 double c2term = -
m_c2 / 228. * ((1.0/(
m_temp - 228.) - 1.0/(298.15 - 228.))
460 + 1.0 / 228. * log((298.15*(
m_temp-228.)) / (
m_temp*(298.15-228.))));
474 double r_e_j = r_e_j_pr_tr + fabs(
m_charge_j) * gval;
478 + nu *
m_charge_j / (3.082 + gval) / (3.082 + gval) * dgvaldT;
483 double Y = drelepsilondT / (relepsilon * relepsilon);
484 double Z = -1.0 / relepsilon;
485 double wterm = omega_j * Y;
487 double otterm = domega_jdT * (Z + 1.0);
489 double deltaS_calgmol = c1term + c2term + a3term + a4term + wterm + wrterm + otterm + otrterm;
491 return m_units.
convertTo(deltaS_calgmol,
"J/kmol/K");
496 static double ag_coeff[3] = { -2.037662, 5.747000E-3, -6.557892E-6};
498 return ag_coeff[0] + ag_coeff[1] * temp + ag_coeff[2] * temp * temp;
499 }
else if (ifunc == 1) {
500 return ag_coeff[1] + ag_coeff[2] * 2.0 * temp;
505 return ag_coeff[2] * 2.0;
510 static double bg_coeff[3] = { 6.107361, -1.074377E-2, 1.268348E-5};
512 return bg_coeff[0] + bg_coeff[1] * temp + bg_coeff[2] * temp * temp;
513 }
else if (ifunc == 1) {
514 return bg_coeff[1] + bg_coeff[2] * 2.0 * temp;
519 return bg_coeff[2] * 2.0;
522double PDSS_HKFT::f(
const double temp,
const double pres,
const int ifunc)
const
524 static double af_coeff[3] = { 3.666666E1, -0.1504956E-9, 0.5107997E-13};
525 double TC = temp - 273.15;
526 double presBar = pres / 1.0E5;
531 TC = std::min(TC, 355.0);
532 if (presBar > 1000.) {
536 double T1 = (TC-155.0)/300.;
537 double p2 = (1000. - presBar) * (1000. - presBar);
538 double p3 = (1000. - presBar) * p2;
540 double fac2 = af_coeff[1] * p3 + af_coeff[2] * p4;
542 return pow(T1,4.8) + af_coeff[0] * pow(T1, 16.0) * fac2;
543 }
else if (ifunc == 1) {
544 return (4.8 * pow(T1,3.8) + 16.0 * af_coeff[0] * pow(T1, 15.0)) / 300. * fac2;
545 }
else if (ifunc == 2) {
546 return (4.8 * 3.8 * pow(T1,2.8) + 16.0 * 15.0 * af_coeff[0] * pow(T1, 14.0)) / (300. * 300.) * fac2;
547 }
else if (ifunc == 3) {
548 double fac1 = pow(T1,4.8) + af_coeff[0] * pow(T1, 16.0);
549 fac2 = - (3.0 * af_coeff[1] * p2 + 4.0 * af_coeff[2] * p3)/ 1.0E5;
556double PDSS_HKFT::g(
const double temp,
const double pres,
const int ifunc)
const
558 double afunc =
ag(temp, 0);
559 double bfunc =
bg(temp, 0);
564 double gval = afunc * pow((1.0-dens), bfunc);
570 }
else if (ifunc == 1 || ifunc == 2) {
571 double afuncdT =
ag(temp, 1);
572 double bfuncdT =
bg(temp, 1);
575 double fac1 = afuncdT * gval / afunc;
576 double fac2 = bfuncdT * gval * log(1.0 - dens);
577 double fac3 = gval * alpha * bfunc * dens / (1.0 - dens);
579 double dgdt = fac1 + fac2 + fac3;
584 double afuncdT2 =
ag(temp, 2);
585 double bfuncdT2 =
bg(temp, 2);
586 double dfac1dT = dgdt * afuncdT / afunc + afuncdT2 * gval / afunc
587 - afuncdT * afuncdT * gval / (afunc * afunc);
588 double ddensdT = - alpha * dens;
589 double dfac2dT = bfuncdT2 * gval * log(1.0 - dens)
590 + bfuncdT * dgdt * log(1.0 - dens)
591 - bfuncdT * gval /(1.0 - dens) * ddensdT;
593 double dfac3dT = dgdt * alpha * bfunc * dens / (1.0 - dens)
594 + gval * dalphadT * bfunc * dens / (1.0 - dens)
595 + gval * alpha * bfuncdT * dens / (1.0 - dens)
596 + gval * alpha * bfunc * ddensdT / (1.0 - dens)
597 + gval * alpha * bfunc * dens / ((1.0 - dens) * (1.0 - dens)) * ddensdT;
599 return dfac1dT + dfac2dT + dfac3dT;
600 }
else if (ifunc == 3) {
602 return - bfunc * gval * dens * beta / (1.0 - dens);
611 double gval =
g(temp, pres, ifunc);
612 double fval =
f(temp, pres, ifunc);
613 double res = gval - fval;
621 throw CanteraError(
"PDSS_HKFT::LookupGe",
"element " + elemName +
" not found");
626 "element " + elemName +
" does not have a supplied entropy298");
628 return geValue * -298.15;
634 double totalSum = 0.0;
651 double& minTemp_,
double& maxTemp_,
652 double& 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.
bool hasKey(const string &key) const
Returns true if the map contains an item named key.
const UnitSystem & units() const
Return the default units that should be used to convert stored values.
double convert(const string &key, const string &units) const
Convert the item stored by the given key to the units specified in units.
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].
double molarVolume() const override
Return the molar volume at standard state.
static int s_InputInconsistencyErrorExit
Static variable determining error exiting.
double m_Y_pr_tr
y = dZdT = 1/(esp*esp) desp/dT at 298.15 and 1 bar
double m_a4
Input a4 coefficient (cal K gmol-1)
double enthalpy_mole() const override
Return the molar enthalpy in units of J kmol-1.
unique_ptr< WaterProps > m_waterProps
Pointer to the water property calculator.
double deltaS() const
Main routine that actually calculates the entropy difference between the reference state at Tr,...
double f(const double temp, const double pres, const int ifunc=0) const
Difference function f appearing in the formulation.
double deltaH() const
Routine that actually calculates the enthalpy difference between the reference state at Tr,...
size_t m_spindex
Index of this species within the parent phase.
double m_densWaterSS
density of standard-state water. internal temporary variable
double LookupGe(const string &elemName)
Function to look up Element Free Energies.
double gibbs_RT_ref() const override
Return the molar Gibbs free energy divided by RT at reference pressure.
VPStandardStateTP * m_tp
Parent VPStandardStateTP (ThermoPhase) object.
double m_Entrop_tr_pr
Input value of S_j at Tr and Pr (cal gmol-1 K-1)
double m_deltaG_formation_tr_pr
Input value of deltaG of Formation at Tr and Pr (cal gmol-1)
void setDeltaG0(double dg0)
Set Gibbs free energy of formation at Pr, Tr [J/kmol].
void initThermo() override
Initialization routine.
double m_a3
Input a3 coefficient (cal K gmol-1 bar-1)
double gstar(const double temp, const double pres, const int ifunc=0) const
Evaluate the Gstar value appearing in the HKFT formulation.
double m_charge_j
Charge of the ion.
PDSS_HKFT()
Default Constructor.
double entropy_R_ref() const override
Return the molar entropy divided by R at reference pressure.
double deltaG() const
Main routine that actually calculates the Gibbs free energy difference between the reference state at...
double enthalpy_RT_ref() const override
Return the molar enthalpy divided by RT at reference pressure.
void setS0(double s0)
Set entropy of formation at Pr, Tr [J/kmol/K].
double bg(const double temp, const int ifunc=0) const
Internal formula for the calculation of b_g()
void reportParams(size_t &kindex, int &type, double *const c, double &minTemp, double &maxTemp, double &refPressure) const override
This utility function reports back the type of parameterization and all of the parameters for the spe...
void getParameters(AnyMap &eosNode) const override
Store the parameters needed to reconstruct a copy of this PDSS object.
double m_c2
Input c2 coefficient (cal K gmol-1)
double m_presR_bar
Reference pressure is 1 atm in units of bar= 1.0132.
void set_a(double *a)
Set "a" coefficients (array of 4 elements).
double intEnergy_mole() const override
Return the molar internal Energy in units of J kmol-1.
double m_domega_jdT_prtr
small value that is not quite zero
double entropy_mole() const override
Return the molar entropy in units of J kmol-1 K-1.
double m_omega_pr_tr
Input omega_pr_tr coefficient(cal gmol-1)
double enthalpy_mole2() const
Return the molar enthalpy in units of J kmol-1.
double g(const double temp, const double pres, const int ifunc=0) const
function g appearing in the formulation
void setState_TP(double temp, double pres) override
Set the internal temperature and pressure.
double m_Z_pr_tr
Z = -1 / relEpsilon at 298.15 and 1 bar.
void convertDGFormation()
Translate a Gibbs free energy of formation value to a NIST-based Chemical potential.
double cp_mole() const override
Return the molar const pressure heat capacity in units of J kmol-1 K-1.
double m_deltaH_formation_tr_pr
Input value of deltaH of Formation at Tr and Pr (cal gmol-1)
double m_a1
Input a1 coefficient (cal gmol-1 bar-1)
double ag(const double temp, const int ifunc=0) const
Internal formula for the calculation of a_g()
double density() const override
Return the standard state density at standard state.
double gibbs_mole() const override
Return the molar Gibbs free energy in units of J kmol-1.
double m_c1
Input c1 coefficient (cal gmol-1 K-1)
double molarVolume_ref() const override
Return the molar volume at reference pressure.
PDSS_Water * m_waterSS
Water standard state calculator.
double m_Mu0_tr_pr
Value of the Absolute Gibbs Free Energy NIST scale at T_r and P_r.
void set_c(double *c)
Set "c" coefficients (array of 2 elements).
double m_a2
Input a2 coefficient (cal gmol-1)
void setDeltaH0(double dh0)
Set enthalpy of formation at Pr, Tr [J/kmol].
double cp_R_ref() const override
Return the molar heat capacity divided by R at reference pressure.
double cp_R() const override
Return the molar const pressure heat capacity divided by RT.
double entropy_R() const override
Return the standard state entropy divided by RT.
double enthalpy_RT() const override
Return the standard state molar enthalpy divided by RT.
double gibbs_RT() const override
Return the molar Gibbs free energy divided by RT.
Class for the liquid water pressure dependent standard state.
double thermalExpansionCoeff() const override
Return the volumetric thermal expansion coefficient. Units: 1/K.
double isothermalCompressibility() const
Returns the isothermal compressibility. Units: 1/Pa.
double dthermalExpansionCoeffdT() const
Return the derivative of the volumetric thermal expansion coefficient.
void setState_TP(double temp, double pres) override
Set the internal temperature and pressure.
double pref_safe(double temp) const
Returns a reference pressure value that can be safely calculated by the underlying real equation of s...
double density() const override
Return the standard state density at standard state.
virtual void reportParams(size_t &kindex, int &type, double *const c, double &minTemp, double &maxTemp, double &refPressure) const
This utility function reports back the type of parameterization and all of the parameters for the spe...
virtual void setTemperature(double temp)
Set the internal temperature.
virtual void initThermo()
Initialization routine.
double m_temp
Current temperature used by the PDSS object.
double m_pres
State of the system - pressure.
double 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.
virtual void setPressure(double pres)
Sets the pressure in the object.
size_t elementIndex(const string &name) const
Return the index of element named 'name'.
string speciesName(size_t k) const
Name of the species with index k.
double nAtoms(size_t k, size_t m) const
Number of atoms of element m in species k.
size_t nElements() const
Number of elements.
string elementName(size_t m) const
Name of the element with index m.
double charge(size_t k) const
Dimensionless electrical charge of a single molecule of species k The charge is normalized by the the...
double entropyElement298(size_t m) const
Entropy of the element in its standard state at 298 K and 1 bar.
double convertFrom(double value, const string &src) const
Convert value from the specified src units to units appropriate for this unit system (defined by setD...
double convertTo(double value, const string &dest) const
Convert value to the specified dest units from the appropriate units for this unit system (defined by...
void setDefaults(std::initializer_list< string > units)
Set the default units to convert from when explicit units are not provided.
This file contains definitions for utility functions and text for modules, inputfiles and logging,...
const double OneAtm
One atmosphere [Pa].
void warn_user(const string &method, const string &msg, const Args &... args)
Print a user warning raised from method as CanteraWarning.
Namespace for the Cantera kernel.
const size_t npos
index returned by functions to indicate "no position"
void warn_deprecated(const string &source, const AnyBase &node, const string &message)
A deprecation warning for syntax in an input file.
Contains declarations for string manipulation functions within Cantera.