12#include <boost/math/tools/roots.hpp>
17namespace bmt = boost::math::tools;
34 fill_n(Vroot_, 3, 0.0);
46 fill_n(Vroot_, 3, 0.0);
51 double a0,
double a1,
double b)
56 "Unknown species '{}'.",
species);
63 size_t counter = k +
m_kk * k;
64 a_coeff_vec(0, counter) = a0;
65 a_coeff_vec(1, counter) = a1;
68 for (
size_t j = 0; j <
m_kk; j++) {
74 if (isnan(a_coeff_vec(0, j +
m_kk * j))) {
77 }
else if (isnan(a_coeff_vec(0, j +
m_kk * k))) {
80 double a0kj = sqrt(a_coeff_vec(0, j +
m_kk * j) * a0);
81 double a1kj = sqrt(a_coeff_vec(1, j +
m_kk * j) * a1);
82 a_coeff_vec(0, j +
m_kk * k) = a0kj;
83 a_coeff_vec(1, j +
m_kk * k) = a1kj;
84 a_coeff_vec(0, k +
m_kk * j) = a0kj;
85 a_coeff_vec(1, k +
m_kk * j) = a1kj;
88 a_coeff_vec.
getRow(0, a_vec_Curr_.data());
93 const std::string& species_j,
double a0,
double a1)
98 "Unknown species '{}'.", species_i);
103 "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 sqt = sqrt(TKelvin);
130 doublereal dadt = da_dt();
131 doublereal fac = TKelvin * dadt - 3.0 *
m_a_current / 2.0;
133 +1.0/(
m_b_current * sqt) * log(vpb/mv) * (-0.5 * dadt));
141 doublereal sqt = sqrt(TKelvin);
145 doublereal dadt = da_dt();
146 doublereal fac = TKelvin * dadt - 3.0 *
m_a_current / 2.0;
147 return (cvref - 1.0/(2.0 *
m_b_current * TKelvin * sqt) * log(vpb/mv)*fac
148 +1.0/(
m_b_current * sqt) * log(vpb/mv)*(-0.5*dadt));
175 for (
size_t k = 0; k <
m_kk; k++) {
177 for (
size_t i = 0; i <
m_kk; i++) {
178 size_t counter = k +
m_kk*i;
184 for (
size_t k = 0; k <
m_kk; k++) {
185 ac[k] = (-
RT() * log(pres * mv /
RT())
186 +
RT() * log(mv / vmb)
187 +
RT() * b_vec_Curr_[k] / vmb
193 for (
size_t k = 0; k <
m_kk; k++) {
194 ac[k] = exp(ac[k]/
RT());
203 for (
size_t k = 0; k <
m_kk; k++) {
204 muRT[k] *= 1.0 /
RT();
211 for (
size_t k = 0; k <
m_kk; k++) {
213 mu[k] +=
RT()*(log(xx));
221 for (
size_t k = 0; k <
m_kk; k++) {
223 for (
size_t i = 0; i <
m_kk; i++) {
224 size_t counter = k +
m_kk*i;
231 for (
size_t k = 0; k <
m_kk; k++) {
232 mu[k] += (
RT() * log(pres/refP) -
RT() * log(pres * mv /
RT())
233 +
RT() * log(mv / vmb)
234 +
RT() * b_vec_Curr_[k] / vmb
251 doublereal sqt = sqrt(TKelvin);
254 for (
size_t k = 0; k <
m_kk; k++) {
256 for (
size_t i = 0; i <
m_kk; i++) {
257 size_t counter = k +
m_kk*i;
261 for (
size_t k = 0; k <
m_kk; k++) {
262 dpdni_[k] =
RT()/vmb +
RT() * b_vec_Curr_[k] / (vmb * vmb) - 2.0 *
m_pp[k] / (sqt * mv * vpb)
263 +
m_a_current * b_vec_Curr_[k]/(sqt * mv * vpb * vpb);
265 doublereal dadt = da_dt();
266 doublereal fac = TKelvin * dadt - 3.0 *
m_a_current / 2.0;
268 for (
size_t k = 0; k <
m_kk; k++) {
270 for (
size_t i = 0; i <
m_kk; i++) {
271 size_t counter = k +
m_kk*i;
277 doublereal fac2 = mv + TKelvin *
dpdT_ /
dpdV_;
278 for (
size_t k = 0; k <
m_kk; k++) {
281 + b_vec_Curr_[k] / vpb / (
m_b_current * sqt) * fac);
282 hbar[k] = hbar[k] + hE_v;
283 hbar[k] -= fac2 *
dpdni_[k];
292 doublereal sqt = sqrt(TKelvin);
296 for (
size_t k = 0; k <
m_kk; k++) {
300 for (
size_t k = 0; k <
m_kk; k++) {
302 for (
size_t i = 0; i <
m_kk; i++) {
303 size_t counter = k +
m_kk*i;
307 for (
size_t k = 0; k <
m_kk; k++) {
309 for (
size_t i = 0; i <
m_kk; i++) {
310 size_t counter = k +
m_kk*i;
315 doublereal dadt = da_dt();
316 doublereal fac = dadt -
m_a_current / (2.0 * TKelvin);
319 for (
size_t k = 0; k <
m_kk; k++) {
327 - 1.0 / (
m_b_current * sqt) * b_vec_Curr_[k] / vpb * fac
333 for (
size_t k = 0; k <
m_kk; k++) {
334 sbar[k] -= -m_partialMolarVolumes[k] *
dpdT_;
344 for (
size_t k = 0; k <
nSpecies(); k++) {
345 ubar[k] -= p * m_partialMolarVolumes[k];
351 for (
size_t k = 0; k <
m_kk; k++) {
353 for (
size_t i = 0; i <
m_kk; i++) {
354 size_t counter = k +
m_kk*i;
358 for (
size_t k = 0; k <
m_kk; k++) {
360 for (
size_t i = 0; i <
m_kk; i++) {
361 size_t counter = k +
m_kk*i;
370 for (
size_t k = 0; k <
m_kk; k++) {
373 - 2.0 *
m_pp[k] / (sqt * vpb)
378 vbar[k] = num / denom;
386 a_vec_Curr_.resize(
m_kk *
m_kk, 0.0);
390 b_vec_Curr_.push_back(NAN);
395 m_partialMolarVolumes.push_back(0.0);
405 std::string model = thermoNode[
"model"];
406 if (model !=
"RedlichKwong" && model !=
"RedlichKwongMFTP") {
408 "Unknown thermo model : " + model);
414 a_coeff_vec.
data().assign(a_coeff_vec.
data().size(), NAN);
418 if (thermoNode.
hasChild(
"activityCoefficients")) {
425 for (
size_t i = 0; i < acNode.
nChildren(); i++) {
441 for (
size_t i = 0; i <
m_kk; i++) {
448 size_t counter = iSpecies +
m_kk * iSpecies;
451 if (isnan(a_coeff_vec(0, counter))) {
453 vector<double> coeffArray;
462 if (!isnan(coeffArray[0])) {
478 std::unordered_map<std::string, AnyMap*> dbSpecies;
480 for (
auto& item : m_species) {
481 auto& data = item.second->input;
483 if (!isnan(a_coeff_vec(0, k +
m_kk * k))) {
486 bool foundCoeffs =
false;
488 if (data.hasKey(
"equation-of-state") &&
489 data[
"equation-of-state"].hasMapWhere(
"model",
"Redlich-Kwong"))
493 auto eos = data[
"equation-of-state"].getMapWhere(
494 "model",
"Redlich-Kwong");
496 if (eos.hasKey(
"a") && eos.hasKey(
"b")) {
497 double a0 = 0, a1 = 0;
498 if (eos[
"a"].isScalar()) {
499 a0 = eos.convert(
"a",
"Pa*m^6/kmol^2*K^0.5");
501 auto avec = eos[
"a"].asVector<
AnyValue>(2);
502 a0 = eos.units().convert(avec[0],
"Pa*m^6/kmol^2*K^0.5");
503 a1 = eos.units().convert(avec[1],
"Pa*m^6/kmol^2/K^0.5");
505 double b = eos.convert(
"b",
"m^3/kmol");
511 if (eos.hasKey(
"binary-a")) {
514 for (
auto& item2 : binary_a) {
515 double a0 = 0, a1 = 0;
516 if (item2.second.isScalar()) {
517 a0 = units.
convert(item2.second,
"Pa*m^6/kmol^2*K^0.5");
519 auto avec = item2.second.asVector<
AnyValue>(2);
520 a0 = units.convert(avec[0],
"Pa*m^6/kmol^2*K^0.5");
521 a1 = units.convert(avec[1],
"Pa*m^6/kmol^2/K^0.5");
533 double Tc = NAN, Pc = NAN;
534 if (data.hasKey(
"critical-parameters")) {
537 auto& critProps = data[
"critical-parameters"].as<
AnyMap>();
538 Tc = critProps.
convert(
"critical-temperature",
"K");
539 Pc = critProps.convert(
"critical-pressure",
"Pa");
543 if (critPropsDb.
empty()) {
545 dbSpecies = critPropsDb[
"species"].asMap(
"name");
549 auto ucName = boost::algorithm::to_upper_copy(item.first);
550 if (dbSpecies.count(ucName)) {
551 auto& spec = *dbSpecies.at(ucName);
552 auto& critProps = spec[
"critical-parameters"].as<
AnyMap>();
553 Tc = critProps.
convert(
"critical-temperature",
"K");
554 Pc = critProps.convert(
"critical-pressure",
"Pa");
572 AnyMap& speciesNode)
const
578 auto& eosNode = speciesNode[
"equation-of-state"].getMapWhere(
579 "model",
"Redlich-Kwong",
true);
581 size_t counter = k +
m_kk * k;
582 if (a_coeff_vec(1, counter) != 0.0) {
583 vector<AnyValue> coeffs(2);
584 coeffs[0].setQuantity(a_coeff_vec(0, counter),
"Pa*m^6/kmol^2*K^0.5");
585 coeffs[1].setQuantity(a_coeff_vec(1, counter),
"Pa*m^6/kmol^2/K^0.5");
586 eosNode[
"a"] = std::move(coeffs);
588 eosNode[
"a"].setQuantity(a_coeff_vec(0, counter),
589 "Pa*m^6/kmol^2*K^0.5");
591 eosNode[
"b"].setQuantity(b_vec_Curr_[k],
"m^3/kmol");
593 auto& critProps = speciesNode[
"critical-parameters"];
594 double a = a_coeff_vec(0, k +
m_kk * k);
595 double b = b_vec_Curr_[k];
598 critProps[
"critical-temperature"].setQuantity(Tc,
"K");
599 critProps[
"critical-pressure"].setQuantity(Pc,
"Pa");
603 auto& eosNode = speciesNode[
"equation-of-state"].getMapWhere(
604 "model",
"Redlich-Kwong",
true);
607 if (item.second.second == 0) {
608 bin_a[item.first].setQuantity(item.second.first,
"Pa*m^6/kmol^2*K^0.5");
610 vector<AnyValue> coeffs(2);
611 coeffs[0].setQuantity(item.second.first,
"Pa*m^6/kmol^2*K^0.5");
612 coeffs[1].setQuantity(item.second.second,
"Pa*m^6/kmol^2/K^0.5");
613 bin_a[item.first] = std::move(coeffs);
616 eosNode[
"binary-a"] = std::move(bin_a);
622 warn_deprecated(
"RedlichKwongMFTP::getCoeff",
"To be removed after Cantera 2.6. "
623 "Use of critical-properties.yaml is integrated into initThermo() "
624 "for YAML input files.");
627 const auto&
species = data[
"species"].asMap(
"name");
630 auto ucName = boost::algorithm::to_upper_copy(iName);
632 auto& critProps =
species.at(ucName)->at(
"critical-parameters").as<
AnyMap>();
633 double Tc = critProps.
convert(
"critical-temperature",
"K");
634 double Pc = critProps.convert(
"critical-pressure",
"Pa");
646 string xname = pureFluidParam.
name();
647 if (xname !=
"pureFluidParameters") {
648 throw CanteraError(
"RedlichKwongMFTP::readXMLPureFluid",
649 "Incorrect name for processing this routine: " + xname);
655 for (
size_t iChild = 0; iChild < pureFluidParam.
nChildren(); iChild++) {
659 if (nodeName ==
"a_coeff") {
662 getFloatArray(xmlChild, vParams,
true,
"Pascal-m6/kmol2",
"a_coeff");
664 if (iModel ==
"constant" && vParams.size() == 1) {
667 }
else if (iModel ==
"linear_a" && vParams.size() == 2) {
671 throw CanteraError(
"RedlichKwongMFTP::readXMLPureFluid",
672 "unknown model or incorrect number of parameters");
675 }
else if (nodeName ==
"b_coeff") {
685 string xname = CrossFluidParam.
name();
686 if (xname !=
"crossFluidParameters") {
687 throw CanteraError(
"RedlichKwongMFTP::readXMLCrossFluid",
688 "Incorrect name for processing this routine: " + xname);
691 string iName = CrossFluidParam.
attrib(
"species1");
692 string jName = CrossFluidParam.
attrib(
"species2");
694 size_t num = CrossFluidParam.
nChildren();
695 for (
size_t iChild = 0; iChild < num; iChild++) {
699 if (nodeName ==
"a_coeff") {
701 getFloatArray(xmlChild, vParams,
true,
"Pascal-m6/kmol2",
"a_coeff");
703 if (iModel ==
"constant" && vParams.size() == 1) {
705 }
else if (iModel ==
"linear_a") {
708 throw CanteraError(
"RedlichKwongMFTP::readXMLCrossFluid",
709 "unknown model ({}) or wrong number of parameters ({})",
710 iModel, vParams.size());
719 std::string model = thermoNode[
"model"];
727 doublereal molarV = mmw / rho;
730 doublereal dadt = da_dt();
732 doublereal sqT = sqrt(T);
743 doublereal molarV = mmw / rho;
746 doublereal dadt = da_dt();
748 doublereal sqT = sqrt(T);
749 doublereal fac = T * dadt - 3.0 *
m_a_current / (2.0);
759 doublereal pres = std::max(
psatEst(TKelvin), presGuess);
761 bool foundLiq =
false;
763 while (m < 100 && !foundLiq) {
764 int nsol =
solveCubic(TKelvin, pres, atmp, btmp, Vroot);
765 if (nsol == 1 || nsol == 2) {
791 if (rhoguess == -1.0) {
792 if (phaseRequested >= FLUID_LIQUID_0) {
794 rhoguess = mmw / lqvol;
802 doublereal volguess = mmw / rhoguess;
805 doublereal molarVolLast = Vroot_[0];
807 if (phaseRequested >= FLUID_LIQUID_0) {
808 molarVolLast = Vroot_[0];
809 }
else if (phaseRequested == FLUID_GAS || phaseRequested == FLUID_SUPERCRIT) {
810 molarVolLast = Vroot_[2];
812 if (volguess > Vroot_[1]) {
813 molarVolLast = Vroot_[2];
815 molarVolLast = Vroot_[0];
818 }
else if (NSolns_ == 1) {
819 if (phaseRequested == FLUID_GAS || phaseRequested == FLUID_SUPERCRIT || phaseRequested == FLUID_UNDEFINED) {
820 molarVolLast = Vroot_[0];
824 }
else if (NSolns_ == -1) {
825 if (phaseRequested >= FLUID_LIQUID_0 || phaseRequested == FLUID_UNDEFINED || phaseRequested == FLUID_SUPERCRIT) {
826 molarVolLast = Vroot_[0];
827 }
else if (TKelvin > tcrit) {
828 molarVolLast = Vroot_[0];
833 molarVolLast = Vroot_[0];
836 return mmw / molarVolLast;
848 auto resid = [
this, T](
double v) {
853 boost::uintmax_t maxiter = 100;
854 std::pair<double, double> vv = bmt::toms748_solve(
855 resid, Vroot[0], Vroot[1], bmt::eps_tolerance<double>(48), maxiter);
858 return mmw / (0.5 * (vv.first + vv.second));
870 auto resid = [
this, T](
double v) {
875 boost::uintmax_t maxiter = 100;
876 std::pair<double, double> vv = bmt::toms748_solve(
877 resid, Vroot[1], Vroot[2], bmt::eps_tolerance<double>(48), maxiter);
880 return mmw / (0.5 * (vv.first + vv.second));
885 doublereal sqt = sqrt(TKelvin);
891 doublereal dpdv = (-
GasConstant * TKelvin / (vmb * vmb)
903 doublereal sqt = sqrt(TKelvin);
906 doublereal dadt = da_dt();
907 doublereal fac = dadt -
m_a_current/(2.0 * TKelvin);
915 for (
size_t i = 0; i <
m_kk; i++) {
916 for (
size_t j = 0; j <
m_kk; j++) {
917 size_t counter = i *
m_kk + j;
918 a_vec_Curr_[counter] = a_coeff_vec(0,counter) + a_coeff_vec(1,counter) * temp;
925 for (
size_t i = 0; i <
m_kk; i++) {
927 for (
size_t j = 0; j <
m_kk; j++) {
933 fmt::memory_buffer b;
934 for (
size_t k = 0; k <
m_kk; k++) {
935 if (isnan(b_vec_Curr_[k])) {
943 throw CanteraError(
"RedlichKwongMFTP::updateMixingExpressions",
944 "Missing Redlich-Kwong coefficients for species: {}", to_string(b));
953 for (
size_t i = 0; i <
m_kk; i++) {
955 for (
size_t j = 0; j <
m_kk; j++) {
956 size_t counter = i *
m_kk + j;
957 doublereal a_vec_Curr = a_coeff_vec(0,counter) + a_coeff_vec(1,counter) * temp;
962 for (
size_t i = 0; i <
m_kk; i++) {
964 for (
size_t j = 0; j <
m_kk; j++) {
965 size_t counter = i *
m_kk + j;
966 doublereal a_vec_Curr = a_coeff_vec(0,counter);
973doublereal RedlichKwongMFTP::da_dt()
const
975 doublereal dadT = 0.0;
977 for (
size_t i = 0; i <
m_kk; i++) {
978 for (
size_t j = 0; j <
m_kk; j++) {
979 size_t counter = i *
m_kk + j;
987void RedlichKwongMFTP::calcCriticalConditions(doublereal& pc, doublereal& tc, doublereal& vc)
const
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;
1017 doublereal sqrttc, f, dfdt, deltatc;
1023 for (
int j = 0; j < 10; j++) {
1027 deltatc = - f / dfdt;
1030 if (deltatc > 0.1) {
1031 throw CanteraError(
"RedlichKwongMFTP::calcCriticalConditions",
1044 doublereal an = 1.0;
1046 doublereal sqt = sqrt(T);
1047 doublereal cn = - (
GasConstant * T * b / pres - a/(pres * sqt) + b * b);
1048 doublereal dn = - (a * b / (pres * sqt));
1052 double tc = pow(tmp, pp);
1056 int nSolnValues =
MixtureFugacityTP::solveCubic(T, pres, a, b, a, Vroot, an, bn, cn, dn, tc, vc);
Declaration for class Cantera::Species.
Headers for the factory class that can create known ThermoPhase objects (see Thermodynamic Properties...
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 empty() const
Return boolean indicating whether AnyMap is empty.
static AnyMap fromYamlFile(const std::string &name, const std::string &parent_name="")
Create an AnyMap from a YAML file.
A wrapper for a variable whose type is determined at runtime.
void getRow(size_t n, double *const rw)
Get the nth row and return it in a vector.
vector_fp & data()
Return a reference to the data vector.
void resize(size_t n, size_t m, double v=0.0)
Resize the array, and fill the new entries with 'v'.
Base class for exceptions thrown by Cantera classes.
vector_fp m_cp0_R
Temporary storage for dimensionless reference state heat capacities.
virtual bool addSpecies(shared_ptr< Species > spec)
doublereal z() const
Calculate the value of z.
virtual void _updateReferenceStateThermo() const
Updates the reference state thermodynamic functions at the current T of the solution.
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...
int solveCubic(double T, double pres, double a, double b, double aAlpha, double Vroot[3], double an, double bn, double cn, double dn, double tc, double vc) const
Solve the cubic equation of state.
virtual doublereal psatEst(doublereal TKelvin) const
Estimate for the saturation pressure.
virtual void getEntropy_R_ref(doublereal *er) const
Returns the vector of nondimensional entropies of the reference state at the current temperature of t...
virtual double critDensity() const
Critical density (kg/m3).
virtual void setTemperature(const doublereal temp)
Set the temperature of the phase.
vector_fp moleFractions_
Storage for the current values of the mole fractions of the species.
virtual double critTemperature() const
Critical temperature (K).
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...
vector_fp m_tmpV
Temporary storage - length = m_kk.
virtual double critPressure() const
Critical pressure (Pa).
virtual void getEnthalpy_RT_ref(doublereal *hrt) const
doublereal mean_X(const doublereal *const Q) const
Evaluate the mole-fraction-weighted mean of an array Q.
void checkSpeciesIndex(size_t k) const
Check that the specified species index is in range.
std::string name() const
Return the name of the phase.
size_t nSpecies() const
Returns the number of species in the phase.
size_t m_kk
Number of species in the phase.
std::string speciesName(size_t k) const
Name of the species with index k.
doublereal meanMolecularWeight() const
The mean molecular weight. Units: (kg/kmol)
double moleFraction(size_t k) const
Return the mole fraction of a single species.
virtual double density() const
Density (kg/m^3).
doublereal temperature() const
Temperature (K).
size_t speciesIndex(const std::string &name) const
Returns the index of a species named 'name' within the Phase object.
double molarVolume() const
Molar volume (m^3/kmol).
shared_ptr< Species > species(const std::string &name) const
Return the Species object for the named species.
virtual bool addSpecies(shared_ptr< Species > spec)
virtual void getActivityCoefficients(doublereal *ac) const
Get the array of non-dimensional activity coefficients at the current solution temperature,...
static const doublereal omega_b
Omega constant for b.
int m_formTempParam
Form of the temperature parameterization.
virtual doublereal hresid() const
Calculate the deviation terms for the total enthalpy of the mixture from the ideal gas mixture.
doublereal m_b_current
Value of b in the equation of state.
doublereal dpdT_
The derivative of the pressure wrt the temperature.
virtual doublereal pressure() const
Return the thermodynamic pressure (Pa).
std::map< std::string, std::map< std::string, std::pair< double, double > > > m_binaryParameters
Explicitly-specified binary interaction parameters.
virtual void getPartialMolarIntEnergies(doublereal *ubar) const
Return an array of partial molar internal energies for the species in the mixture.
virtual doublereal cp_mole() const
Molar heat capacity at constant pressure. Units: J/kmol/K.
virtual std::vector< double > getCoeff(const std::string &iName)
Retrieve a and b coefficients by looking up tabulated critical parameters.
virtual void getPartialMolarEnthalpies(doublereal *hbar) const
Returns an array of partial molar enthalpies for the species in the mixture.
virtual void getPartialMolarEntropies(doublereal *sbar) const
Returns an array of partial molar entropies of the species in the solution.
virtual void initThermoXML(XML_Node &phaseNode, const std::string &id)
Import and initialize a ThermoPhase object using an XML tree.
void readXMLCrossFluid(XML_Node &pureFluidParam)
Read the cross species RedlichKwong input parameters.
virtual void getPartialMolarVolumes(doublereal *vbar) const
Return an array of partial molar volumes for the species in the mixture.
vector_fp m_pp
Temporary storage - length = m_kk.
RedlichKwongMFTP(const std::string &infile="", const std::string &id="")
Construct a RedlichKwongMFTP object from an input file.
virtual doublereal cv_mole() const
Molar heat capacity at constant volume. Units: J/kmol/K.
void readXMLPureFluid(XML_Node &pureFluidParam)
Read the pure species RedlichKwong input parameters.
virtual doublereal dpdVCalc(doublereal TKelvin, doublereal molarVol, doublereal &presCalc) const
Calculate the pressure and the pressure derivative given the temperature and the molar volume.
std::vector< CoeffSource > m_coeffSource
For each species, specifies the source of the a and b coefficients.
virtual doublereal sresid() const
Calculate the deviation terms for the total entropy of the mixture from the ideal gas mixture.
virtual void updateMixingExpressions()
Update the a and b parameters.
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.
void pressureDerivatives() const
Calculate dpdV and dpdT at the current conditions.
static const doublereal omega_vc
Omega constant for the critical molar volume.
virtual doublereal liquidVolEst(doublereal TKelvin, doublereal &pres) const
Estimate for the molar volume of the liquid.
virtual void initThermo()
Initialize the ThermoPhase object after all species have been set up.
virtual doublereal densityCalc(doublereal T, doublereal pressure, int phase, doublereal rhoguess)
Calculates the density given the temperature and the pressure and a guess at the density.
doublereal m_a_current
Value of a in the equation of state.
virtual doublereal densSpinodalGas() const
Return the value of the density at the gas spinodal point (on the gas side) for the current temperatu...
void setSpeciesCoeffs(const std::string &species, double a0, double a1, double b)
Set the pure fluid interaction parameters for a species.
virtual void getSpeciesParameters(const std::string &name, AnyMap &speciesNode) const
Get phase-specific parameters of a Species object such that an identical one could be reconstructed a...
void calculateAB(doublereal temp, doublereal &aCalc, doublereal &bCalc) const
Calculate the a and the b parameters given the temperature.
virtual void getChemPotentials_RT(doublereal *mu) const
Get the array of non-dimensional species chemical potentials.
doublereal dpdV_
The derivative of the pressure wrt the volume.
virtual doublereal densSpinodalLiquid() const
Return the value of the density at the liquid spinodal point (on the liquid side) for the current tem...
virtual void getChemPotentials(doublereal *mu) const
Get the species chemical potentials. Units: J/kmol.
static const doublereal omega_a
Omega constant for a -> value of a in terms of critical properties.
vector_fp dpdni_
Vector of derivatives of pressure wrt mole number.
virtual void setParametersFromXML(const XML_Node &thermoNode)
Set equation of state parameter values from XML entries.
int solveCubic(double T, double pres, double a, double b, double Vroot[3]) const
Prepare variables and call the function to solve the cubic equation of state.
virtual doublereal standardConcentration(size_t k=0) const
Returns the standard concentration , which is used to normalize the generalized concentration.
doublereal RT() const
Return the Gas Constant multiplied by the current temperature.
void initThermoFile(const std::string &inputFile, const std::string &id)
virtual void initThermoXML(XML_Node &phaseNode, const std::string &id)
Import and initialize a ThermoPhase object using an XML tree.
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.
virtual void getSpeciesParameters(const std::string &name, AnyMap &speciesNode) const
Get phase-specific parameters of a Species object such that an identical one could be reconstructed a...
double convert(double value, const std::string &src, const std::string &dest) const
Convert value from the units of src to the units of dest.
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.
size_t nChildren(bool discardComments=false) const
Return the number of children.
XML_Node & child(const size_t n) const
Return a changeable reference to the n'th child of the current node.
CTML ("Cantera Markup Language") is the variant of XML that Cantera uses to store data.
void importPhase(XML_Node &phase, ThermoPhase *th)
Import a phase information into an empty ThermoPhase object.
Namespace for the Cantera kernel.
const size_t npos
index returned by functions to indicate "no position"
doublereal getFloatCurrent(const XML_Node &currXML, const std::string &type="")
Get a floating-point value from the current XML element.
bool caseInsensitiveEquals(const std::string &input, const std::string &test)
Case insensitive equality predicate.
void warn_deprecated(const std::string &source, const AnyBase &node, const std::string &message)
A deprecation warning for syntax in an input file.
const double SmallNumber
smallest number to compare to zero.
std::string toLowerCopy(const std::string &input)
Convert to lower case.
void scale(InputIter begin, InputIter end, OutputIter out, S scale_factor)
Multiply elements of an array by a scale factor.
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
const double GasConstant
Universal Gas Constant [J/kmol/K].
size_t getFloatArray(const XML_Node &node, vector_fp &v, const bool convert=true, const std::string &unitsString="", const std::string &nodeName="floatArray")
This function reads the current node or a child node of the current node with the default name,...
Contains declarations for string manipulation functions within Cantera.