11 #include <boost/math/tools/roots.hpp> 16 namespace bmt = boost::math::tools;
21 const doublereal RedlichKwongMFTP::omega_a = 4.27480233540E-01;
22 const doublereal RedlichKwongMFTP::omega_b = 8.66403499650E-02;
23 const doublereal RedlichKwongMFTP::omega_vc = 3.33333333333333E-01;
25 RedlichKwongMFTP::RedlichKwongMFTP() :
33 fill_n(Vroot_, 3, 0.0);
44 fill_n(Vroot_, 3, 0.0);
56 fill_n(Vroot_, 3, 0.0);
61 double a0,
double a1,
double b)
66 "Unknown species '{}'.",
species);
73 size_t counter = k +
m_kk * k;
74 a_coeff_vec(0, counter) = a0;
75 a_coeff_vec(1, counter) = a1;
78 for (
size_t j = 0; j <
m_kk; j++) {
82 double a0kj = sqrt(a_coeff_vec(0, j +
m_kk * j) * a0);
83 double a1kj = sqrt(a_coeff_vec(1, j +
m_kk * j) * a1);
84 if (a_coeff_vec(0, j +
m_kk * k) == 0) {
85 a_coeff_vec(0, j +
m_kk * k) = a0kj;
86 a_coeff_vec(1, j +
m_kk * k) = a1kj;
87 a_coeff_vec(0, k +
m_kk * j) = a0kj;
88 a_coeff_vec(1, k +
m_kk * j) = a1kj;
91 a_coeff_vec.
getRow(0, a_vec_Curr_.data());
96 const std::string& species_j,
double a0,
double a1)
101 "Unknown species '{}'.", species_i);
106 "Unknown species '{}'.", species_j);
112 size_t counter1 = ki +
m_kk * kj;
113 size_t counter2 = kj +
m_kk * ki;
114 a_coeff_vec(0, counter1) = a_coeff_vec(0, counter2) = a0;
115 a_coeff_vec(1, counter1) = a_coeff_vec(1, counter2) = a1;
116 a_vec_Curr_[counter1] = a_vec_Curr_[counter2] = a0;
125 doublereal h_nonideal =
hresid();
126 return h_ideal + h_nonideal;
134 doublereal sr_nonideal =
sresid();
135 return sr_ideal + sr_nonideal;
142 doublereal sqt = sqrt(TKelvin);
147 doublereal dadt = da_dt();
148 doublereal fac = TKelvin * dadt - 3.0 *
m_a_current / 2.0;
150 +1.0/(
m_b_current * sqt) * log(vpb/mv) * (-0.5 * dadt));
158 doublereal sqt = sqrt(TKelvin);
162 doublereal dadt = da_dt();
163 doublereal fac = TKelvin * dadt - 3.0 *
m_a_current / 2.0;
164 return (cvref - 1.0/(2.0 *
m_b_current * TKelvin * sqt) * log(vpb/mv)*fac
165 +1.0/(
m_b_current * sqt) * log(vpb/mv)*(-0.5*dadt));
207 for (
size_t k = 0; k <
m_kk; k++) {
225 for (
size_t k = 0; k <
m_kk; k++) {
227 for (
size_t i = 0; i <
m_kk; i++) {
228 size_t counter = k +
m_kk*i;
234 for (
size_t k = 0; k <
m_kk; k++) {
235 ac[k] = (-
RT() * log(pres * mv /
RT())
236 +
RT() * log(mv / vmb)
237 +
RT() * b_vec_Curr_[k] / vmb
243 for (
size_t k = 0; k <
m_kk; k++) {
244 ac[k] = exp(ac[k]/
RT());
253 for (
size_t k = 0; k <
m_kk; k++) {
254 muRT[k] *= 1.0 /
RT();
261 for (
size_t k = 0; k <
m_kk; k++) {
263 mu[k] +=
RT()*(log(xx));
271 for (
size_t k = 0; k <
m_kk; k++) {
273 for (
size_t i = 0; i <
m_kk; i++) {
274 size_t counter = k +
m_kk*i;
281 for (
size_t k = 0; k <
m_kk; k++) {
282 mu[k] += (
RT() * log(pres/refP) -
RT() * log(pres * mv /
RT())
283 +
RT() * log(mv / vmb)
284 +
RT() * b_vec_Curr_[k] / vmb
301 doublereal sqt = sqrt(TKelvin);
304 for (
size_t k = 0; k <
m_kk; k++) {
306 for (
size_t i = 0; i <
m_kk; i++) {
307 size_t counter = k +
m_kk*i;
311 for (
size_t k = 0; k <
m_kk; k++) {
312 dpdni_[k] =
RT()/vmb +
RT() * b_vec_Curr_[k] / (vmb * vmb) - 2.0 *
m_pp[k] / (sqt * mv * vpb)
313 +
m_a_current * b_vec_Curr_[k]/(sqt * mv * vpb * vpb);
315 doublereal dadt = da_dt();
316 doublereal fac = TKelvin * dadt - 3.0 *
m_a_current / 2.0;
318 for (
size_t k = 0; k <
m_kk; k++) {
320 for (
size_t i = 0; i <
m_kk; i++) {
321 size_t counter = k +
m_kk*i;
327 doublereal fac2 = mv + TKelvin *
dpdT_ /
dpdV_;
328 for (
size_t k = 0; k <
m_kk; k++) {
331 + b_vec_Curr_[k] / vpb / (
m_b_current * sqt) * fac);
332 hbar[k] = hbar[k] + hE_v;
333 hbar[k] -= fac2 *
dpdni_[k];
342 doublereal sqt = sqrt(TKelvin);
346 for (
size_t k = 0; k <
m_kk; k++) {
350 for (
size_t k = 0; k <
m_kk; k++) {
352 for (
size_t i = 0; i <
m_kk; i++) {
353 size_t counter = k +
m_kk*i;
357 for (
size_t k = 0; k <
m_kk; k++) {
359 for (
size_t i = 0; i <
m_kk; i++) {
360 size_t counter = k +
m_kk*i;
365 doublereal dadt = da_dt();
366 doublereal fac = dadt -
m_a_current / (2.0 * TKelvin);
369 for (
size_t k = 0; k <
m_kk; k++) {
377 - 1.0 / (
m_b_current * sqt) * b_vec_Curr_[k] / vpb * fac
383 for (
size_t k = 0; k <
m_kk; k++) {
384 sbar[k] -= -m_partialMolarVolumes[k] *
dpdT_;
402 for (
size_t k = 0; k <
m_kk; k++) {
404 for (
size_t i = 0; i <
m_kk; i++) {
405 size_t counter = k +
m_kk*i;
409 for (
size_t k = 0; k <
m_kk; k++) {
411 for (
size_t i = 0; i <
m_kk; i++) {
412 size_t counter = k +
m_kk*i;
421 for (
size_t k = 0; k <
m_kk; k++) {
424 - 2.0 *
m_pp[k] / (sqt * vpb)
429 vbar[k] = num / denom;
438 for (
size_t i = 0; i <
m_kk; i++) {
439 for (
size_t j = 0; j <
m_kk; j++) {
440 size_t counter = i +
m_kk * j;
454 for (
size_t i = 0; i <
m_kk; i++) {
455 for (
size_t j = 0; j <
m_kk; j++) {
456 size_t counter = i +
m_kk * j;
470 for (
size_t i = 0; i <
m_kk; i++) {
471 for (
size_t j = 0; j <
m_kk; j++) {
472 size_t counter = i +
m_kk * j;
486 for (
size_t i = 0; i <
m_kk; i++) {
487 for (
size_t j = 0; j <
m_kk; j++) {
488 size_t counter = i +
m_kk * j;
502 for (
size_t i = 0; i <
m_kk; i++) {
503 for (
size_t j = 0; j <
m_kk; j++) {
504 size_t counter = i +
m_kk * j;
525 doublereal pres = 0.0;
527 for (
size_t k = 0; k <
m_kk; k++) {
528 tmp = -
m_tmpV[k] + mu_RT[k];
531 }
else if (tmp > 500.0) {
534 m_pp[k] = m_p0 * exp(500.) * tmp2;
536 m_pp[k] = m_p0 * exp(tmp);
548 a_vec_Curr_.resize(
m_kk *
m_kk, 0.0);
549 b_vec_Curr_.push_back(0.0);
555 m_partialMolarVolumes.push_back(0.0);
565 std::string model = thermoNode[
"model"];
566 if (model !=
"RedlichKwong" && model !=
"RedlichKwongMFTP") {
568 "Unknown thermo model : " + model);
573 if (thermoNode.
hasChild(
"activityCoefficients")) {
578 for (
size_t i = 0; i < acNode.
nChildren(); i++) {
594 string xname = pureFluidParam.
name();
595 if (xname !=
"pureFluidParameters") {
596 throw CanteraError(
"RedlichKwongMFTP::readXMLPureFluid",
597 "Incorrect name for processing this routine: " + xname);
603 for (
size_t iChild = 0; iChild < pureFluidParam.
nChildren(); iChild++) {
607 if (nodeName ==
"a_coeff") {
610 getFloatArray(xmlChild, vParams,
true,
"Pascal-m6/kmol2",
"a_coeff");
612 if (iModel ==
"constant" && vParams.size() == 1) {
615 }
else if (iModel ==
"linear_a" && vParams.size() == 2) {
619 throw CanteraError(
"RedlichKwongMFTP::readXMLPureFluid",
620 "unknown model or incorrect number of parameters");
623 }
else if (nodeName ==
"b_coeff") {
632 string xname = CrossFluidParam.
name();
633 if (xname !=
"crossFluidParameters") {
634 throw CanteraError(
"RedlichKwongMFTP::readXMLCrossFluid",
635 "Incorrect name for processing this routine: " + xname);
638 string iName = CrossFluidParam.
attrib(
"species1");
639 string jName = CrossFluidParam.
attrib(
"species2");
641 size_t num = CrossFluidParam.
nChildren();
642 for (
size_t iChild = 0; iChild < num; iChild++) {
646 if (nodeName ==
"a_coeff") {
648 getFloatArray(xmlChild, vParams,
true,
"Pascal-m6/kmol2",
"a_coeff");
650 if (iModel ==
"constant" && vParams.size() == 1) {
652 }
else if (iModel ==
"linear_a") {
655 throw CanteraError(
"RedlichKwongMFTP::readXMLCrossFluid",
656 "unknown model ({}) or wrong number of parameters ({})",
657 iModel, vParams.size());
666 std::string model = thermoNode[
"model"];
674 doublereal molarV = mmw / rho;
677 doublereal dadt = da_dt();
679 doublereal sqT = sqrt(T);
690 doublereal molarV = mmw / rho;
693 doublereal dadt = da_dt();
695 doublereal sqT = sqrt(T);
696 doublereal fac = T * dadt - 3.0 *
m_a_current / (2.0);
706 doublereal pres = std::max(
psatEst(TKelvin), presGuess);
708 bool foundLiq =
false;
710 while (m < 100 && !foundLiq) {
711 int nsol =
NicholsSolve(TKelvin, pres, atmp, btmp, Vroot);
712 if (nsol == 1 || nsol == 2) {
738 if (rhoguess == -1.0) {
739 if (phaseRequested != FLUID_GAS) {
740 if (TKelvin > tcrit) {
743 if (phaseRequested == FLUID_GAS || phaseRequested == FLUID_SUPERCRIT) {
745 }
else if (phaseRequested >= FLUID_LIQUID_0) {
747 rhoguess = mmw / lqvol;
757 doublereal volguess = mmw / rhoguess;
760 doublereal molarVolLast = Vroot_[0];
762 if (phaseRequested >= FLUID_LIQUID_0) {
763 molarVolLast = Vroot_[0];
764 }
else if (phaseRequested == FLUID_GAS || phaseRequested == FLUID_SUPERCRIT) {
765 molarVolLast = Vroot_[2];
767 if (volguess > Vroot_[1]) {
768 molarVolLast = Vroot_[2];
770 molarVolLast = Vroot_[0];
773 }
else if (NSolns_ == 1) {
774 if (phaseRequested == FLUID_GAS || phaseRequested == FLUID_SUPERCRIT || phaseRequested == FLUID_UNDEFINED) {
775 molarVolLast = Vroot_[0];
779 }
else if (NSolns_ == -1) {
780 if (phaseRequested >= FLUID_LIQUID_0 || phaseRequested == FLUID_UNDEFINED || phaseRequested == FLUID_SUPERCRIT) {
781 molarVolLast = Vroot_[0];
782 }
else if (TKelvin > tcrit) {
783 molarVolLast = Vroot_[0];
788 molarVolLast = Vroot_[0];
791 return mmw / molarVolLast;
803 auto resid = [
this, T](
double v) {
808 boost::uintmax_t maxiter = 100;
809 std::pair<double, double> vv = bmt::toms748_solve(
810 resid, Vroot[0], Vroot[1], bmt::eps_tolerance<double>(48), maxiter);
813 return mmw / (0.5 * (vv.first + vv.second));
825 auto resid = [
this, T](
double v) {
830 boost::uintmax_t maxiter = 100;
831 std::pair<double, double> vv = bmt::toms748_solve(
832 resid, Vroot[1], Vroot[2], bmt::eps_tolerance<double>(48), maxiter);
835 return mmw / (0.5 * (vv.first + vv.second));
840 doublereal sqt = sqrt(TKelvin);
848 doublereal sqt = sqrt(TKelvin);
854 doublereal dpdv = (-
GasConstant * TKelvin / (vmb * vmb)
866 doublereal sqt = sqrt(TKelvin);
869 doublereal dadt = da_dt();
870 doublereal fac = dadt -
m_a_current/(2.0 * TKelvin);
874 void RedlichKwongMFTP::updateMixingExpressions()
883 for (
size_t i = 0; i <
m_kk; i++) {
884 for (
size_t j = 0; j <
m_kk; j++) {
885 size_t counter = i *
m_kk + j;
886 a_vec_Curr_[counter] = a_coeff_vec(0,counter) + a_coeff_vec(1,counter) * temp;
893 for (
size_t i = 0; i <
m_kk; i++) {
895 for (
size_t j = 0; j <
m_kk; j++) {
906 for (
size_t i = 0; i <
m_kk; i++) {
908 for (
size_t j = 0; j <
m_kk; j++) {
909 size_t counter = i *
m_kk + j;
910 doublereal a_vec_Curr = a_coeff_vec(0,counter) + a_coeff_vec(1,counter) * temp;
915 for (
size_t i = 0; i <
m_kk; i++) {
917 for (
size_t j = 0; j <
m_kk; j++) {
918 size_t counter = i *
m_kk + j;
919 doublereal a_vec_Curr = a_coeff_vec(0,counter);
926 doublereal RedlichKwongMFTP::da_dt()
const 928 doublereal dadT = 0.0;
930 for (
size_t i = 0; i <
m_kk; i++) {
931 for (
size_t j = 0; j <
m_kk; j++) {
932 size_t counter = i *
m_kk + j;
940 void RedlichKwongMFTP::calcCriticalConditions(doublereal a, doublereal b, doublereal a0_coeff, doublereal aT_coeff,
941 doublereal& pc, doublereal& tc, doublereal& vc)
const 960 doublereal sqrttc, f, dfdt, deltatc;
966 for (
int j = 0; j < 10; j++) {
970 deltatc = - f / dfdt;
974 throw CanteraError(
"RedlichKwongMFTP::calcCriticalConditions",
"didn't converge");
983 doublereal Vroot[3])
const 988 if (TKelvin <= 0.0) {
989 throw CanteraError(
"RedlichKwongMFTP::NicholsSolve()",
"neg temperature");
995 doublereal sqt = sqrt(TKelvin);
996 doublereal cn = - (
GasConstant * TKelvin * b / pres - a/(pres * sqt) + b * b);
997 doublereal dn = - (a * b / (pres * sqt));
1001 double tc = pow(tmp, pp);
1005 doublereal xN = - bn /(3 * an);
1009 doublereal delta2 = (bn * bn - 3 * an * cn) / (9 * an * an);
1010 doublereal delta = 0.0;
1013 doublereal ratio1 = 3.0 * an * cn / (bn * bn);
1014 doublereal ratio2 = pres * b / (
GasConstant * TKelvin);
1015 if (fabs(ratio1) < 1.0E-7) {
1017 if (fabs(ratio2) < 1.0E-5 && fabs(ratio3) < 1.0E-5) {
1018 doublereal zz = 1.0;
1019 for (
int i = 0; i < 10; i++) {
1020 doublereal znew = zz / (zz - ratio2) - ratio3 / (zz + ratio1);
1021 doublereal deltaz = znew - zz;
1023 if (fabs(deltaz) < 1.0E-14) {
1034 double h2 = 4. * an * an * delta2 * delta2 * delta2;
1036 delta = sqrt(delta2);
1039 doublereal h = 2.0 * an * delta * delta2;
1040 doublereal yN = 2.0 * bn * bn * bn / (27.0 * an * an) - bn * cn / (3.0 * an) + dn;
1041 doublereal desc = yN * yN - h2;
1043 if (fabs(fabs(h) - fabs(yN)) < 1.0E-10) {
1046 throw CanteraError(
"NicholsSolve()",
"numerical issues");
1053 }
else if (desc == 0.0) {
1056 }
else if (desc > 0.0) {
1062 doublereal tmpD = sqrt(desc);
1063 doublereal tmp1 = (- yN + tmpD) / (2.0 * an);
1064 doublereal sgn1 = 1.0;
1069 doublereal tmp2 = (- yN - tmpD) / (2.0 * an);
1070 doublereal sgn2 = 1.0;
1075 doublereal p1 = pow(tmp1, 1./3.);
1076 doublereal p2 = pow(tmp2, 1./3.);
1077 doublereal alpha = xN + sgn1 * p1 + sgn2 * p2;
1081 tmp = an * Vroot[0] * Vroot[0] * Vroot[0] + bn * Vroot[0] * Vroot[0] + cn * Vroot[0] + dn;
1082 }
else if (desc < 0.0) {
1083 doublereal tmp = - yN/h;
1084 doublereal val = acos(tmp);
1085 doublereal theta = val / 3.0;
1086 doublereal oo = 2. *
Pi / 3.;
1087 doublereal alpha = xN + 2. * delta * cos(theta);
1088 doublereal beta = xN + 2. * delta * cos(theta + oo);
1089 doublereal gamma = xN + 2. * delta * cos(theta + 2.0 * oo);
1094 for (
int i = 0; i < 3; i++) {
1095 tmp = an * Vroot[i] * Vroot[i] * Vroot[i] + bn * Vroot[i] * Vroot[i] + cn * Vroot[i] + dn;
1096 if (fabs(tmp) > 1.0E-4) {
1097 for (
int j = 0; j < 3; j++) {
1098 if (j != i && fabs(Vroot[i] - Vroot[j]) < 1.0E-4 * (fabs(Vroot[i]) + fabs(Vroot[j]))) {
1099 writelog(
"RedlichKwongMFTP::NicholsSolve(T = {}, p = {}):" 1100 " WARNING roots have merged: {}, {}\n",
1101 TKelvin, pres, Vroot[i], Vroot[j]);
1106 }
else if (desc == 0.0) {
1107 if (yN == 0.0 && h == 0.0) {
1114 tmp = pow(yN/(2*an), 1./3.);
1115 if (fabs(tmp - delta) > 1.0E-9) {
1116 throw CanteraError(
"RedlichKwongMFTP::NicholsSolve()",
"unexpected");
1118 Vroot[1] = xN + delta;
1119 Vroot[0] = xN - 2.0*delta;
1121 tmp = pow(yN/(2*an), 1./3.);
1122 if (fabs(tmp - delta) > 1.0E-9) {
1123 throw CanteraError(
"RedlichKwongMFTP::NicholsSolve()",
"unexpected");
1126 Vroot[0] = xN + delta;
1127 Vroot[1] = xN - 2.0*delta;
1130 for (
int i = 0; i < 2; i++) {
1131 tmp = an * Vroot[i] * Vroot[i] * Vroot[i] + bn * Vroot[i] * Vroot[i] + cn * Vroot[i] + dn;
1137 double res, dresdV = 0.0;
1138 for (
int i = 0; i < nSolnValues; i++) {
1139 for (
int n = 0; n < 20; n++) {
1140 res = an * Vroot[i] * Vroot[i] * Vroot[i] + bn * Vroot[i] * Vroot[i] + cn * Vroot[i] + dn;
1141 if (fabs(res) < 1.0E-14) {
1144 dresdV = 3.0 * an * Vroot[i] * Vroot[i] + 2.0 * bn * Vroot[i] + cn;
1145 double del = - res / dresdV;
1147 if (fabs(del) / (fabs(Vroot[i]) + fabs(del)) < 1.0E-14) {
1150 double res2 = an * Vroot[i] * Vroot[i] * Vroot[i] + bn * Vroot[i] * Vroot[i] + cn * Vroot[i] + dn;
1151 if (fabs(res2) < fabs(res)) {
1155 Vroot[i] += 0.1 * del;
1158 if ((fabs(res) > 1.0E-14) && (fabs(res) > 1.0E-14 * fabs(dresdV) * fabs(Vroot[i]))) {
1159 writelog(
"RedlichKwongMFTP::NicholsSolve(T = {}, p = {}): " 1160 "WARNING root didn't converge V = {}", TKelvin, pres, Vroot[i]);
1165 if (nSolnValues == 1) {
1167 if (Vroot[0] < vc) {
1171 if (Vroot[0] < xN) {
1176 if (nSolnValues == 2 && delta > 0.0) {
void setSpeciesCoeffs(const std::string &species, double a0, double a1, double b)
Set the pure fluid interaction parameters for a species.
doublereal molarVolume() const
Molar volume (m^3/kmol).
virtual doublereal dpdVCalc(doublereal TKelvin, doublereal molarVol, doublereal &presCalc) const
Calculate the pressure and the pressure derivative given the temperature and the molar volume...
virtual void getEnthalpy_RT_ref(doublereal *hrt) const
doublereal m_b_current
Value of b in the equation of state.
virtual void getPartialMolarIntEnergies(doublereal *ubar) const
Return an array of partial molar internal energies for the species in the mixture.
doublereal dpdV_
The derivative of the pressure wrt the volume.
CTML ("Cantera Markup Language") is the variant of XML that Cantera uses to store data...
std::string name() const
Returns the name of the XML node.
virtual void getGibbs_RT_ref(doublereal *grt) const
Returns the vector of nondimensional Gibbs Free Energies of the reference state at the current temper...
doublereal temperature() const
Temperature (K).
void resize(size_t n, size_t m, doublereal v=0.0)
Resize the array, and fill the new entries with 'v'.
vector_fp m_tmpV
Temporary storage - length = m_kk.
virtual doublereal densSpinodalLiquid() const
Return the value of the density at the liquid spinodal point (on the liquid side) for the current tem...
size_t getFloatArray(const XML_Node &node, vector_fp &v, const bool convert, const std::string &unitsString, const std::string &nodeName)
This function reads the current node or a child node of the current node with the default name...
size_t speciesIndex(const std::string &name) const
Returns the index of a species named 'name' within the Phase object.
virtual doublereal psatEst(doublereal TKelvin) const
Estimate for the saturation pressure.
virtual void compositionChanged()
Apply changes to the state which are needed after the composition changes.
doublereal moleFraction(size_t k) const
Return the mole fraction of a single species.
void pressureDerivatives() const
Calculate dpdV and dpdT at the current conditions.
const size_t npos
index returned by functions to indicate "no position"
virtual doublereal hresid() const
Calculate the deviation terms for the total enthalpy of the mixture from the ideal gas mixture...
RedlichKwongMFTP()
Base constructor.
doublereal z() const
Calculate the value of z.
doublereal sum_xlogx() const
Evaluate .
Headers for the factory class that can create known ThermoPhase objects (see Thermodynamic Properties...
void writelog(const std::string &fmt, const Args &... args)
Write a formatted message to the screen.
virtual doublereal critVolume() const
Critical volume (m3/kmol).
virtual doublereal densityCalc(doublereal TKelvin, doublereal pressure, int phase, doublereal rhoguess)
Calculates the density given the temperature and the pressure and a guess at the density.
Class XML_Node is a tree-based representation of the contents of an XML file.
virtual void getActivityCoefficients(doublereal *ac) const
Get the array of non-dimensional activity coefficients at the current solution temperature, pressure, and solution concentration.
virtual doublereal density() const
Density (kg/m^3).
void readXMLPureFluid(XML_Node &pureFluidParam)
Read the pure species RedlichKwong input parameters.
virtual doublereal cp_mole() const
Molar heat capacity at constant pressure. Units: J/kmol/K.
virtual void getPartialMolarVolumes(doublereal *vbar) const
Return an array of partial molar volumes for the species in the mixture.
int NicholsSolve(double TKelvin, double pres, doublereal a, doublereal b, doublereal Vroot[3]) const
Solve the cubic equation of state.
virtual doublereal sresid() const
Calculate the deviation terms for the total entropy of the mixture from the ideal gas mixture...
doublereal mean_X(const doublereal *const Q) const
Evaluate the mole-fraction-weighted mean of an array Q.
virtual doublereal critTemperature() const
Critical temperature (K).
virtual void initThermoXML(XML_Node &phaseNode, const std::string &id)
Import and initialize a ThermoPhase object using an XML tree.
doublereal RT() const
Return the Gas Constant multiplied by the current temperature.
virtual bool addSpecies(shared_ptr< Species > spec)
virtual void setToEquilState(const doublereal *lambda_RT)
This method is used by the ChemEquil equilibrium solver.
vector_fp m_s0_R
Temporary storage for dimensionless reference state entropies.
virtual void getGibbs_ref(doublereal *g) const
Returns the vector of the Gibbs function of the reference state at the current temperature of the sol...
virtual doublereal critDensity() const
Critical density (kg/m3).
virtual doublereal cv_mole() const
Molar heat capacity at constant volume. Units: J/kmol/K.
static const doublereal omega_b
Omega constant for b.
int m_formTempParam
Form of the temperature parameterization.
void calculateAB(doublereal temp, doublereal &aCalc, doublereal &bCalc) const
Calculate the a and the b parameters given the temperature.
doublereal dpdT_
The derivative of the pressure wrt the temperature.
doublereal m_a_current
Value of a in the equation of state.
shared_ptr< Species > species(const std::string &name) const
Return the Species object for the named species.
virtual void _updateReferenceStateThermo() const
Updates the reference state thermodynamic functions at the current T of the solution.
doublereal getFloatCurrent(const XML_Node &node, const std::string &type)
Get a floating-point value from the current XML element.
vector_fp m_pp
Temporary storage - length = m_kk.
virtual void setParametersFromXML(const XML_Node &thermoNode)
Set equation of state parameter values from XML entries.
virtual doublereal critPressure() const
Critical pressure (Pa).
const doublereal * moleFractdivMMW() const
Returns a const pointer to the start of the moleFraction/MW array.
bool caseInsensitiveEquals(const std::string &input, const std::string &test)
Case insensitive equality predicate.
Base class for exceptions thrown by Cantera classes.
void setBinaryCoeffs(const std::string &species_i, const std::string &species_j, double a0, double a1)
Set values for the interaction parameter between two species.
virtual doublereal liquidVolEst(doublereal TKelvin, doublereal &pres) const
Estimate for the molar volume of the liquid.
virtual void getChemPotentials_RT(doublereal *mu) const
Get the array of non-dimensional species chemical potentials.
virtual void setTemperature(const doublereal temp)
Set the temperature of the phase.
void readXMLCrossFluid(XML_Node &pureFluidParam)
Read the cross species RedlichKwong input parameters.
virtual void calcDensity()
Calculate the density of the mixture using the partial molar volumes and mole fractions as input...
virtual doublereal enthalpy_mole() const
Molar enthalpy. Units: J/kmol.
void importPhase(XML_Node &phase, ThermoPhase *th)
Import a phase information into an empty ThermoPhase object.
virtual doublereal critCompressibility() const
Critical compressibility (unitless).
doublereal dot(InputIter x_begin, InputIter x_end, InputIter2 y_begin)
Function that calculates a templated inner product.
static const doublereal omega_a
Omega constant for a -> value of a in terms of critical properties.
virtual doublereal standardConcentration(size_t k=0) const
Returns the standard concentration , which is used to normalize the generalized concentration.
bool hasChild(const std::string &ch) const
Tests whether the current node has a child node with a particular name.
virtual void getPartialMolarEntropies(doublereal *sbar) const
Returns an array of partial molar entropies of the species in the solution.
XML_Node & child(const size_t n) const
Return a changeable reference to the n'th child of the current node.
void writelogendl()
Write an end of line character to the screen and flush output.
virtual doublereal pressureCalc(doublereal TKelvin, doublereal molarVol) const
Calculate the pressure given the temperature and the molar volume.
virtual void initThermoXML(XML_Node &phaseNode, const std::string &id)
Import and initialize a ThermoPhase object using an XML tree.
const doublereal SmallNumber
smallest number to compare to zero.
std::string attrib(const std::string &attr) const
Function returns the value of an attribute.
virtual doublereal pressure() const
Return the thermodynamic pressure (Pa).
virtual void getEntropy_R_ref(doublereal *er) const
Returns the vector of nondimensional entropies of the reference state at the current temperature of t...
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
doublereal meanMolecularWeight() const
The mean molecular weight. Units: (kg/kmol)
virtual bool addSpecies(shared_ptr< Species > spec)
virtual void setTemperature(const doublereal temp)
Set the internally stored temperature of the phase (K).
void scale(InputIter begin, InputIter end, OutputIter out, S scale_factor)
Multiply elements of an array by a scale factor.
virtual void compositionChanged()
Apply changes to the state which are needed after the composition changes.
virtual doublereal refPressure() const
Returns the reference pressure in Pa.
virtual void setParametersFromXML(const XML_Node &eosdata)
Set equation of state parameter values from XML entries.
const doublereal GasConstant
Universal Gas Constant. [J/kmol/K].
virtual void setState_PX(doublereal p, doublereal *x)
Set the pressure (Pa) and mole fractions.
virtual doublereal densSpinodalGas() const
Return the value of the density at the gas spinodal point (on the gas side) for the current temperatu...
Contains declarations for string manipulation functions within Cantera.
virtual void getChemPotentials(doublereal *mu) const
Get the species chemical potentials. Units: J/kmol.
static const doublereal omega_vc
Omega constant for the critical molar volume.
vector_fp moleFractions_
Storage for the current values of the mole fractions of the species.
virtual void getStandardVolumes(doublereal *vol) const
Get the molar volumes of each species in their standard states at the current T and P of the solution...
void getRow(size_t n, doublereal *const rw)
Get the nth row and return it in a vector.
size_t m_kk
Number of species in the phase.
virtual void getPartialMolarEnthalpies(doublereal *hbar) const
Returns an array of partial molar enthalpies for the species in the mixture.
virtual void getCp_R(doublereal *cpr) const
Get the nondimensional Heat Capacities at constant pressure for the standard state of the species at ...
virtual void initThermoFile(const std::string &inputFile, const std::string &id)
std::string toLowerCopy(const std::string &input)
Convert to lower case.
virtual doublereal entropy_mole() const
Molar entropy. Units: J/kmol/K.
Namespace for the Cantera kernel.
virtual void getPartialMolarCp(doublereal *cpbar) const
Return an array of partial molar heat capacities for the species in the mixture.
vector_fp dpdni_
Vector of derivatives of pressure wrt mole number.
size_t nChildren(bool discardComments=false) const
Return the number of children.
void updateAB()
Update the a and b parameters.
virtual void getIntEnergy_RT(doublereal *urt) const
Returns the vector of nondimensional internal Energies of the standard state at the current temperatu...
virtual void setDensity(const doublereal density_)
Set the internally stored density (kg/m^3) of the phase.
vector_fp m_h0_RT
Temporary storage for dimensionless reference state enthalpies.
vector_fp m_cp0_R
Temporary storage for dimensionless reference state heat capacities.
virtual void getActivityConcentrations(doublereal *c) const
This method returns an array of generalized concentrations.