12 #include <boost/math/tools/roots.hpp> 15 namespace bmt = boost::math::tools;
20 const doublereal RedlichKwongMFTP::omega_a = 4.27480233540E-01;
21 const doublereal RedlichKwongMFTP::omega_b = 8.66403499650E-02;
22 const doublereal RedlichKwongMFTP::omega_vc = 3.33333333333333E-01;
24 RedlichKwongMFTP::RedlichKwongMFTP() :
25 m_standardMixingRules(0),
30 Vroot_{0.0, 0.0, 0.0},
37 m_standardMixingRules(0),
42 Vroot_{0.0, 0.0, 0.0},
46 initThermoFile(infile, id_);
50 m_standardMixingRules(0),
55 Vroot_{0.0, 0.0, 0.0},
63 m_standardMixingRules(0),
74 RedlichKwongMFTP& RedlichKwongMFTP::operator=(
const RedlichKwongMFTP& b)
79 MixtureFugacityTP::operator=(b);
86 a_vec_Curr_ = b.a_vec_Curr_;
87 b_vec_Curr_ = b.b_vec_Curr_;
88 a_coeff_vec = b.a_coeff_vec;
90 m_pc_Species = b.m_pc_Species;
91 m_tc_Species = b.m_tc_Species;
92 m_vc_Species = b.m_vc_Species;
94 Vroot_[0] = b.Vroot_[0];
95 Vroot_[1] = b.Vroot_[1];
96 Vroot_[2] = b.Vroot_[2];
99 m_partialMolarVolumes = b.m_partialMolarVolumes;
115 "To be removed after Cantera 2.3.");
116 return cRedlichKwongMFTP;
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));
177 throw CanteraError(
" RedlichKwongMFTP::pressure()",
"setState broken down, maybe");
211 for (
size_t k = 0; k <
m_kk; k++) {
229 for (
size_t k = 0; k <
m_kk; k++) {
231 for (
size_t i = 0; i <
m_kk; i++) {
232 size_t counter = k +
m_kk*i;
238 for (
size_t k = 0; k <
m_kk; k++) {
239 ac[k] = (-
RT() * log(pres * mv /
RT())
240 +
RT() * log(mv / vmb)
241 +
RT() * b_vec_Curr_[k] / vmb
247 for (
size_t k = 0; k <
m_kk; k++) {
248 ac[k] = exp(ac[k]/
RT());
257 for (
size_t k = 0; k <
m_kk; k++) {
258 muRT[k] *= 1.0 /
RT();
265 for (
size_t k = 0; k <
m_kk; k++) {
267 mu[k] +=
RT()*(log(xx));
275 for (
size_t k = 0; k <
m_kk; k++) {
277 for (
size_t i = 0; i <
m_kk; i++) {
278 size_t counter = k +
m_kk*i;
285 for (
size_t k = 0; k <
m_kk; k++) {
286 mu[k] += (
RT() * log(pres/refP) -
RT() * log(pres * mv /
RT())
287 +
RT() * log(mv / vmb)
288 +
RT() * b_vec_Curr_[k] / vmb
305 doublereal sqt = sqrt(TKelvin);
308 for (
size_t k = 0; k <
m_kk; k++) {
310 for (
size_t i = 0; i <
m_kk; i++) {
311 size_t counter = k +
m_kk*i;
315 for (
size_t k = 0; k <
m_kk; k++) {
316 dpdni_[k] =
RT()/vmb +
RT() * b_vec_Curr_[k] / (vmb * vmb) - 2.0 *
m_pp[k] / (sqt * mv * vpb)
317 +
m_a_current * b_vec_Curr_[k]/(sqt * mv * vpb * vpb);
319 doublereal dadt = da_dt();
320 doublereal fac = TKelvin * dadt - 3.0 *
m_a_current / 2.0;
322 for (
size_t k = 0; k <
m_kk; k++) {
324 for (
size_t i = 0; i <
m_kk; i++) {
325 size_t counter = k +
m_kk*i;
331 doublereal fac2 = mv + TKelvin *
dpdT_ /
dpdV_;
332 for (
size_t k = 0; k <
m_kk; k++) {
335 + b_vec_Curr_[k] / vpb / (
m_b_current * sqt) * fac);
336 hbar[k] = hbar[k] + hE_v;
337 hbar[k] -= fac2 *
dpdni_[k];
346 doublereal sqt = sqrt(TKelvin);
350 for (
size_t k = 0; k <
m_kk; k++) {
354 for (
size_t k = 0; k <
m_kk; k++) {
356 for (
size_t i = 0; i <
m_kk; i++) {
357 size_t counter = k +
m_kk*i;
361 for (
size_t k = 0; k <
m_kk; k++) {
363 for (
size_t i = 0; i <
m_kk; i++) {
364 size_t counter = k +
m_kk*i;
369 doublereal dadt = da_dt();
370 doublereal fac = dadt -
m_a_current / (2.0 * TKelvin);
373 for (
size_t k = 0; k <
m_kk; k++) {
381 - 1.0 / (
m_b_current * sqt) * b_vec_Curr_[k] / vpb * fac
387 for (
size_t k = 0; k <
m_kk; k++) {
388 sbar[k] -= -m_partialMolarVolumes[k] *
dpdT_;
406 for (
size_t k = 0; k <
m_kk; k++) {
408 for (
size_t i = 0; i <
m_kk; i++) {
409 size_t counter = k +
m_kk*i;
413 for (
size_t k = 0; k <
m_kk; k++) {
415 for (
size_t i = 0; i <
m_kk; i++) {
416 size_t counter = k +
m_kk*i;
425 for (
size_t k = 0; k <
m_kk; k++) {
428 - 2.0 *
m_pp[k] / (sqt * vpb)
433 vbar[k] = num / denom;
442 for (
size_t i = 0; i <
m_kk; i++) {
443 for (
size_t j = 0; j <
m_kk; j++) {
444 size_t counter = i +
m_kk * j;
458 for (
size_t i = 0; i <
m_kk; i++) {
459 for (
size_t j = 0; j <
m_kk; j++) {
460 size_t counter = i +
m_kk * j;
474 for (
size_t i = 0; i <
m_kk; i++) {
475 for (
size_t j = 0; j <
m_kk; j++) {
476 size_t counter = i +
m_kk * j;
490 for (
size_t i = 0; i <
m_kk; i++) {
491 for (
size_t j = 0; j <
m_kk; j++) {
492 size_t counter = i +
m_kk * j;
506 for (
size_t i = 0; i <
m_kk; i++) {
507 for (
size_t j = 0; j <
m_kk; j++) {
508 size_t counter = i +
m_kk * j;
529 doublereal pres = 0.0;
531 for (
size_t k = 0; k <
m_kk; k++) {
532 tmp = -
m_tmpV[k] + mu_RT[k];
535 }
else if (tmp > 500.0) {
538 m_pp[k] = m_p0 * exp(500.) * tmp2;
540 m_pp[k] = m_p0 * exp(tmp);
552 a_vec_Curr_.resize(
m_kk *
m_kk, 0.0);
553 b_vec_Curr_.push_back(0.0);
557 m_pc_Species.push_back(0.0);
558 m_tc_Species.push_back(0.0);
559 m_vc_Species.push_back(0.0);
563 m_partialMolarVolumes.push_back(0.0);
577 std::string model = thermoNode[
"model"];
578 if (model ==
"RedlichKwong") {
580 }
else if (model ==
"RedlichKwongMFTP") {
584 "Unknown thermo model : " + model);
590 if (thermoNode.
hasChild(
"activityCoefficients")) {
597 for (
size_t i = 0; i < nC; i++) {
599 if (ba::iequals(xmlACChild.
name(),
"purefluidparameters")) {
609 for (
size_t i = 0; i < nC; i++) {
611 if (ba::iequals(xmlACChild.
name(),
"crossfluidparameters")) {
618 for (
size_t i = 0; i <
m_kk; i++) {
619 double a0coeff = a_coeff_vec(0, i*
m_kk + i);
620 double aTcoeff = a_coeff_vec(1, i*
m_kk + i);
621 double ai = a0coeff + aTcoeff * 500.;
622 double bi = b_vec_Curr_[i];
623 calcCriticalConditions(ai, bi, a0coeff, aTcoeff, m_pc_Species[i], m_tc_Species[i], m_vc_Species[i]);
632 string xname = pureFluidParam.
name();
633 if (xname !=
"pureFluidParameters") {
634 throw CanteraError(
"RedlichKwongMFTP::readXMLPureFluid",
635 "Incorrect name for processing this routine: " + xname);
640 string iName = pureFluidParam.
attrib(
"species");
642 throw CanteraError(
"RedlichKwongMFTP::readXMLPureFluid",
"no species attribute");
645 if (iSpecies ==
npos) {
648 size_t counter = iSpecies +
m_kk * iSpecies;
649 size_t nParamsExpected, nParamsFound;
651 for (
size_t iChild = 0; iChild < num; iChild++) {
653 string nodeName = ba::to_lower_copy(xmlChild.
name());
655 if (nodeName ==
"a_coeff") {
656 string iModel = ba::to_lower_copy(xmlChild.
attrib(
"model"));
657 if (iModel ==
"constant") {
659 }
else if (iModel ==
"linear_a") {
665 throw CanteraError(
"RedlichKwongMFTP::readXMLPureFluid",
"unknown model");
668 getFloatArray(xmlChild, vParams,
true,
"Pascal-m6/kmol2",
"a_coeff");
669 nParamsFound = vParams.size();
670 if (nParamsFound != nParamsExpected) {
671 throw CanteraError(
"RedlichKwongMFTP::readXMLPureFluid(for a_coeff" + iName +
")",
672 "wrong number of params found");
675 for (
size_t i = 0; i < nParamsFound; i++) {
676 a_coeff_vec(i, counter) = vParams[i];
678 }
else if (nodeName ==
"b_coeff") {
679 getFloatArray(xmlChild, vParams,
true,
"m3/kmol",
"b_coeff");
680 nParamsFound = vParams.size();
681 if (nParamsFound != 1) {
682 throw CanteraError(
"RedlichKwongMFTP::readXMLPureFluid(for b_coeff" + iName +
")",
683 "wrong number of params found");
685 b_vec_Curr_[iSpecies] = vParams[0];
693 for (
size_t i = 0; i <
m_kk; i++) {
694 size_t icounter = i +
m_kk * i;
695 for (
size_t j = 0; j <
m_kk; j++) {
697 size_t counter = i +
m_kk * j;
698 size_t jcounter = j +
m_kk * j;
699 for (
int n = 0; n < nParam; n++) {
700 a_coeff_vec(n, counter) = sqrt(a_coeff_vec(n, icounter) * a_coeff_vec(n, jcounter));
710 string xname = CrossFluidParam.
name();
711 if (xname !=
"crossFluidParameters") {
712 throw CanteraError(
"RedlichKwongMFTP::readXMLCrossFluid",
713 "Incorrect name for processing this routine: " + xname);
718 string iName = CrossFluidParam.
attrib(
"species1");
720 throw CanteraError(
"RedlichKwongMFTP::readXMLCrossFluid",
"no species1 attribute");
723 if (iSpecies ==
npos) {
726 string jName = CrossFluidParam.
attrib(
"species2");
728 throw CanteraError(
"RedlichKwongMFTP::readXMLCrossFluid",
"no species2 attribute");
731 if (jSpecies ==
npos) {
735 size_t counter = iSpecies +
m_kk * jSpecies;
736 size_t counter0 = jSpecies +
m_kk * iSpecies;
737 size_t nParamsExpected, nParamsFound;
738 size_t num = CrossFluidParam.
nChildren();
739 for (
size_t iChild = 0; iChild < num; iChild++) {
741 string nodeName = ba::to_lower_copy(xmlChild.
name());
743 if (nodeName ==
"a_coeff") {
744 string iModel = ba::to_lower_copy(xmlChild.
attrib(
"model"));
745 if (iModel ==
"constant") {
747 }
else if (iModel ==
"linear_a") {
753 throw CanteraError(
"RedlichKwongMFTP::readXMLCrossFluid",
"unknown model");
756 getFloatArray(xmlChild, vParams,
true,
"Pascal-m6/kmol2",
"a_coeff");
757 nParamsFound = vParams.size();
758 if (nParamsFound != nParamsExpected) {
759 throw CanteraError(
"RedlichKwongMFTP::readXMLCrossFluid(for a_coeff" + iName +
")",
760 "wrong number of params found");
763 for (
size_t i = 0; i < nParamsFound; i++) {
764 a_coeff_vec(i, counter) = vParams[i];
765 a_coeff_vec(i, counter0) = vParams[i];
774 std::string model = thermoNode[
"model"];
782 doublereal molarV = mmw / rho;
785 doublereal dadt = da_dt();
787 doublereal sqT = sqrt(T);
798 doublereal molarV = mmw / rho;
801 doublereal dadt = da_dt();
803 doublereal sqT = sqrt(T);
804 doublereal fac = T * dadt - 3.0 *
m_a_current / (2.0);
814 doublereal pres = std::max(
psatEst(TKelvin), presGuess);
816 bool foundLiq =
false;
818 while (m < 100 && !foundLiq) {
819 int nsol =
NicholsSolve(TKelvin, pres, atmp, btmp, Vroot);
820 if (nsol == 1 || nsol == 2) {
846 if (rhoguess == -1.0) {
847 if (phaseRequested != FLUID_GAS) {
848 if (TKelvin > tcrit) {
851 if (phaseRequested == FLUID_GAS || phaseRequested == FLUID_SUPERCRIT) {
853 }
else if (phaseRequested >= FLUID_LIQUID_0) {
855 rhoguess = mmw / lqvol;
865 doublereal volguess = mmw / rhoguess;
868 doublereal molarVolLast = Vroot_[0];
870 if (phaseRequested >= FLUID_LIQUID_0) {
871 molarVolLast = Vroot_[0];
872 }
else if (phaseRequested == FLUID_GAS || phaseRequested == FLUID_SUPERCRIT) {
873 molarVolLast = Vroot_[2];
875 if (volguess > Vroot_[1]) {
876 molarVolLast = Vroot_[2];
878 molarVolLast = Vroot_[0];
881 }
else if (NSolns_ == 1) {
882 if (phaseRequested == FLUID_GAS || phaseRequested == FLUID_SUPERCRIT || phaseRequested == FLUID_UNDEFINED) {
883 molarVolLast = Vroot_[0];
887 }
else if (NSolns_ == -1) {
888 if (phaseRequested >= FLUID_LIQUID_0 || phaseRequested == FLUID_UNDEFINED || phaseRequested == FLUID_SUPERCRIT) {
889 molarVolLast = Vroot_[0];
890 }
else if (TKelvin > tcrit) {
891 molarVolLast = Vroot_[0];
896 molarVolLast = Vroot_[0];
899 return mmw / molarVolLast;
911 auto resid = [
this, T](
double v) {
916 boost::uintmax_t maxiter = 100;
917 std::pair<double, double> vv = bmt::toms748_solve(
918 resid, Vroot[0], Vroot[1], bmt::eps_tolerance<double>(48), maxiter);
921 return mmw / (0.5 * (vv.first + vv.second));
933 auto resid = [
this, T](
double v) {
938 boost::uintmax_t maxiter = 100;
939 std::pair<double, double> vv = bmt::toms748_solve(
940 resid, Vroot[1], Vroot[2], bmt::eps_tolerance<double>(48), maxiter);
943 return mmw / (0.5 * (vv.first + vv.second));
948 doublereal sqt = sqrt(TKelvin);
956 doublereal sqt = sqrt(TKelvin);
962 doublereal dpdv = (-
GasConstant * TKelvin / (vmb * vmb)
974 doublereal sqt = sqrt(TKelvin);
977 doublereal dadt = da_dt();
978 doublereal fac = dadt -
m_a_current/(2.0 * TKelvin);
982 void RedlichKwongMFTP::updateMixingExpressions()
991 for (
size_t i = 0; i <
m_kk; i++) {
992 for (
size_t j = 0; j <
m_kk; j++) {
993 size_t counter = i *
m_kk + j;
994 a_vec_Curr_[counter] = a_coeff_vec(0,counter) + a_coeff_vec(1,counter) * temp;
1001 for (
size_t i = 0; i <
m_kk; i++) {
1003 for (
size_t j = 0; j <
m_kk; j++) {
1014 for (
size_t i = 0; i <
m_kk; i++) {
1016 for (
size_t j = 0; j <
m_kk; j++) {
1017 size_t counter = i *
m_kk + j;
1018 doublereal a_vec_Curr = a_coeff_vec(0,counter) + a_coeff_vec(1,counter) * temp;
1023 for (
size_t i = 0; i <
m_kk; i++) {
1025 for (
size_t j = 0; j <
m_kk; j++) {
1026 size_t counter = i *
m_kk + j;
1027 doublereal a_vec_Curr = a_coeff_vec(0,counter);
1034 doublereal RedlichKwongMFTP::da_dt()
const 1036 doublereal dadT = 0.0;
1038 for (
size_t i = 0; i <
m_kk; i++) {
1039 for (
size_t j = 0; j <
m_kk; j++) {
1040 size_t counter = i *
m_kk + j;
1048 void RedlichKwongMFTP::calcCriticalConditions(doublereal a, doublereal b, doublereal a0_coeff, doublereal aT_coeff,
1049 doublereal& pc, doublereal& tc, doublereal& vc)
const 1068 doublereal sqrttc, f, dfdt, deltatc;
1074 for (
int j = 0; j < 10; j++) {
1078 deltatc = - f / dfdt;
1081 if (deltatc > 0.1) {
1082 throw CanteraError(
"RedlichKwongMFTP::calcCriticalConditions",
"didn't converge");
1091 doublereal Vroot[3])
const 1096 if (TKelvin <= 0.0) {
1097 throw CanteraError(
"RedlichKwongMFTP::NicholsSolve()",
"neg temperature");
1101 doublereal an = 1.0;
1103 doublereal sqt = sqrt(TKelvin);
1104 doublereal cn = - (
GasConstant * TKelvin * b / pres - a/(pres * sqt) + b * b);
1105 doublereal dn = - (a * b / (pres * sqt));
1109 double tc = pow(tmp, pp);
1113 doublereal xN = - bn /(3 * an);
1117 doublereal delta2 = (bn * bn - 3 * an * cn) / (9 * an * an);
1118 doublereal delta = 0.0;
1121 doublereal ratio1 = 3.0 * an * cn / (bn * bn);
1122 doublereal ratio2 = pres * b / (
GasConstant * TKelvin);
1123 if (fabs(ratio1) < 1.0E-7) {
1125 if (fabs(ratio2) < 1.0E-5 && fabs(ratio3) < 1.0E-5) {
1126 doublereal zz = 1.0;
1127 for (
int i = 0; i < 10; i++) {
1128 doublereal znew = zz / (zz - ratio2) - ratio3 / (zz + ratio1);
1129 doublereal deltaz = znew - zz;
1131 if (fabs(deltaz) < 1.0E-14) {
1142 double h2 = 4. * an * an * delta2 * delta2 * delta2;
1144 delta = sqrt(delta2);
1147 doublereal h = 2.0 * an * delta * delta2;
1148 doublereal yN = 2.0 * bn * bn * bn / (27.0 * an * an) - bn * cn / (3.0 * an) + dn;
1149 doublereal desc = yN * yN - h2;
1151 if (fabs(fabs(h) - fabs(yN)) < 1.0E-10) {
1154 throw CanteraError(
"NicholsSolve()",
"numerical issues");
1161 }
else if (desc == 0.0) {
1164 }
else if (desc > 0.0) {
1170 doublereal tmpD = sqrt(desc);
1171 doublereal tmp1 = (- yN + tmpD) / (2.0 * an);
1172 doublereal sgn1 = 1.0;
1177 doublereal tmp2 = (- yN - tmpD) / (2.0 * an);
1178 doublereal sgn2 = 1.0;
1183 doublereal p1 = pow(tmp1, 1./3.);
1184 doublereal p2 = pow(tmp2, 1./3.);
1185 doublereal alpha = xN + sgn1 * p1 + sgn2 * p2;
1189 tmp = an * Vroot[0] * Vroot[0] * Vroot[0] + bn * Vroot[0] * Vroot[0] + cn * Vroot[0] + dn;
1190 }
else if (desc < 0.0) {
1191 doublereal tmp = - yN/h;
1192 doublereal val = acos(tmp);
1193 doublereal theta = val / 3.0;
1194 doublereal oo = 2. *
Pi / 3.;
1195 doublereal alpha = xN + 2. * delta * cos(theta);
1196 doublereal beta = xN + 2. * delta * cos(theta + oo);
1197 doublereal gamma = xN + 2. * delta * cos(theta + 2.0 * oo);
1202 for (
int i = 0; i < 3; i++) {
1203 tmp = an * Vroot[i] * Vroot[i] * Vroot[i] + bn * Vroot[i] * Vroot[i] + cn * Vroot[i] + dn;
1204 if (fabs(tmp) > 1.0E-4) {
1205 for (
int j = 0; j < 3; j++) {
1206 if (j != i && fabs(Vroot[i] - Vroot[j]) < 1.0E-4 * (fabs(Vroot[i]) + fabs(Vroot[j]))) {
1207 writelog(
"RedlichKwongMFTP::NicholsSolve(T = {}, p = {}):" 1208 " WARNING roots have merged: {}, {}\n",
1209 TKelvin, pres, Vroot[i], Vroot[j]);
1214 }
else if (desc == 0.0) {
1215 if (yN == 0.0 && h == 0.0) {
1222 tmp = pow(yN/(2*an), 1./3.);
1223 if (fabs(tmp - delta) > 1.0E-9) {
1224 throw CanteraError(
"RedlichKwongMFTP::NicholsSolve()",
"unexpected");
1226 Vroot[1] = xN + delta;
1227 Vroot[0] = xN - 2.0*delta;
1229 tmp = pow(yN/(2*an), 1./3.);
1230 if (fabs(tmp - delta) > 1.0E-9) {
1231 throw CanteraError(
"RedlichKwongMFTP::NicholsSolve()",
"unexpected");
1234 Vroot[0] = xN + delta;
1235 Vroot[1] = xN - 2.0*delta;
1238 for (
int i = 0; i < 2; i++) {
1239 tmp = an * Vroot[i] * Vroot[i] * Vroot[i] + bn * Vroot[i] * Vroot[i] + cn * Vroot[i] + dn;
1245 double res, dresdV = 0.0;
1246 for (
int i = 0; i < nSolnValues; i++) {
1247 for (
int n = 0; n < 20; n++) {
1248 res = an * Vroot[i] * Vroot[i] * Vroot[i] + bn * Vroot[i] * Vroot[i] + cn * Vroot[i] + dn;
1249 if (fabs(res) < 1.0E-14) {
1252 dresdV = 3.0 * an * Vroot[i] * Vroot[i] + 2.0 * bn * Vroot[i] + cn;
1253 double del = - res / dresdV;
1255 if (fabs(del) / (fabs(Vroot[i]) + fabs(del)) < 1.0E-14) {
1258 double res2 = an * Vroot[i] * Vroot[i] * Vroot[i] + bn * Vroot[i] * Vroot[i] + cn * Vroot[i] + dn;
1259 if (fabs(res2) < fabs(res)) {
1263 Vroot[i] += 0.1 * del;
1266 if ((fabs(res) > 1.0E-14) && (fabs(res) > 1.0E-14 * fabs(dresdV) * fabs(Vroot[i]))) {
1267 writelog(
"RedlichKwongMFTP::NicholsSolve(T = {}, p = {}): " 1268 "WARNING root didn't converge V = {}", TKelvin, pres, Vroot[i]);
1273 if (nSolnValues == 1) {
1275 if (Vroot[0] < vc) {
1279 if (Vroot[0] < xN) {
1284 if (nSolnValues == 2 && delta > 0.0) {
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...
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 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 ThermoPhase * duplMyselfAsThermoPhase() const
Duplication routine for objects which inherit from ThermoPhase.
virtual void getActivityCoefficients(doublereal *ac) const
Get the array of non-dimensional activity coefficients at the current solution temperature, pressure, and solution concentration.
void warn_deprecated(const std::string &method, const std::string &extra)
Print a warning indicating that method is deprecated.
virtual doublereal density() const
Density (kg/m^3).
void readXMLPureFluid(XML_Node &pureFluidParam)
Read the pure species RedlichKwong input parameters.
virtual doublereal refPressure(size_t k=npos) const
The reference-state pressure for species k.
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.
Base class for a phase with thermodynamic properties.
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.
doublereal m_Pcurrent
Current value of the pressure.
int m_standardMixingRules
boolean indicating whether standard mixing rules are applied
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.
virtual void _updateReferenceStateThermo() const
Updates the reference state thermodynamic functions at the current T of the solution.
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.
Base class for exceptions thrown by Cantera classes.
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.
MultiSpeciesThermo * m_spthermo
Pointer to the calculation manager for species reference-state thermodynamic properties.
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...
size_t m_kk
Number of species in the phase.
void applyStandardMixingRules()
Apply mixing rules for a coefficients.
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 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.
virtual int eosType() const
Equation of state type flag.
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.