30 using namespace Cantera;
35 vcs_MultiPhaseEquil::vcs_MultiPhaseEquil() :
68 vcs_MultiPhaseEquil::~vcs_MultiPhaseEquil()
80 int printLvl, doublereal err,
81 int maxsteps,
int loglevel)
87 if ((XY != TV) && (XY != HV) && (XY != UV) && (XY != SV)) {
88 throw CanteraError(
"vcs_MultiPhaseEquil::equilibrate_TV",
89 "Wrong XY flag:" +
int2str(XY));
99 int strt = estimateEquil;
106 doublereal Vnow, Verr;
107 int printLvlSub = std::max(0, printLvl - 1);
108 for (
int n = 0; n < maxiter; n++) {
114 iSuccess =
equilibrate_TP(strt, printLvlSub, err, maxsteps, loglevel);
119 printLvlSub, err, maxsteps, loglevel);
124 printLvlSub, err, maxsteps, loglevel);
129 printLvlSub, err, maxsteps, loglevel);
149 Verr = fabs((Vtarget - Vnow)/Vtarget);
162 dVdP = (V2 - V1) / (P2 - P1);
167 Pnew = Pnow + (Vtarget - Vnow) / dVdP;
168 if (Pnew < 0.2 * Pnow) {
171 if (Pnew > 3.0 * Pnow) {
179 Pnew = Pnow + 0.5*(Vtarget - Vnow)/dVdP;
180 if (Pnew < 0.5* Pnow) {
183 if (Pnew > 1.7 * Pnow) {
191 "No convergence for V");
199 int XY,
double Tlow,
double Thigh,
201 int printLvl, doublereal err,
202 int maxsteps,
int loglevel)
206 if (XY != HP && XY != UP) {
207 throw CanteraError(
"vcs_MultiPhaseEquil::equilibrate_HP",
210 int strt = estimateEquil;
217 if (Thigh <= 0.0 || Thigh > 1.0E6) {
223 doublereal cpb = 1.0, dT, dTa, dTmax, Tnew;
225 doublereal Hlow =
Undef;
226 doublereal Hhigh =
Undef;
227 doublereal Herr, HConvErr;
229 int printLvlSub = std::max(printLvl - 1, 0);
231 for (
int n = 0; n < maxiter; n++) {
240 iSuccess =
equilibrate_TP(strt, printLvlSub, err, maxsteps, loglevel);
249 double Tmoles = pmoles[0];
250 double HperMole = Hnow/Tmoles;
252 plogf(
"T = %g, Hnow = %g ,Tmoles = %g, HperMole = %g",
253 Tnow, Hnow, Tmoles, HperMole);
262 if (Hnow < Htarget) {
277 cpb = (Hhigh - Hlow)/(Thigh - Tlow);
278 dT = (Htarget - Hnow)/cpb;
280 dTmax = 0.5*fabs(Thigh - Tlow);
285 Tnew = sqrt(Tlow*Thigh);
294 double acpb = std::max(fabs(cpb), 1.0E-6);
295 double denom = std::max(fabs(Htarget), acpb);
296 Herr = Htarget - Hnow;
297 HConvErr = fabs((Herr)/denom);
306 plogf(
" equilibrate_HP: It = %d, Tcurr = %g Hcurr = %g, Htarget = %g\n",
307 n, Tnow, Hnow, Htarget);
308 plogf(
" H rel error = %g, cp = %g, HConvErr = %g\n",
309 Herr, cpb, HConvErr);
312 if (HConvErr < err) {
317 plogf(
" equilibrate_HP: CONVERGENCE: Hfinal = %g Tfinal = %g, Its = %d \n",
319 plogf(
" H rel error = %g, cp = %g, HConvErr = %g\n",
320 Herr, cpb, HConvErr);
331 if (!estimateEquil) {
333 "try estimating composition at the start");
336 Tnew = 0.5*(Tnow + Thigh);
337 if (fabs(Tnew - Tnow) < 1.0) {
342 "trying T = "+
fp2str(Tnow));
351 "No convergence for T");
358 double Tlow,
double Thigh,
360 int printLvl, doublereal err,
361 int maxsteps,
int loglevel)
364 int strt = estimateEquil;
371 if (Thigh <= 0.0 || Thigh > 1.0E6) {
377 doublereal cpb = 1.0, dT, dTa, dTmax, Tnew;
379 doublereal Slow =
Undef;
380 doublereal Shigh =
Undef;
381 doublereal Serr, SConvErr;
389 int printLvlSub = std::max(printLvl - 1, 0);
391 for (
int n = 0; n < maxiter; n++) {
399 int iSuccess =
equilibrate_TP(strt, printLvlSub, err, maxsteps, loglevel);
404 double Tmoles = pmoles[0];
405 double SperMole = Snow/Tmoles;
406 plogf(
"T = %g, Snow = %g ,Tmoles = %g, SperMole = %g\n",
407 Tnow, Snow, Tmoles, SperMole);
413 if (Snow < Starget) {
418 if (Slow > Starget) {
437 cpb = (Shigh - Slow)/(Thigh - Tlow);
438 dT = (Starget - Snow)/cpb;
441 dTmax = 0.5*fabs(Thigh - Tlow);
442 if (Tnew > Thigh || Tnew < Tlow) {
443 dTmax = 1.5*fabs(Thigh - Tlow);
445 dTmax = std::min(dTmax, 300.);
450 Tnew = sqrt(Tlow*Thigh);
454 double acpb = std::max(fabs(cpb), 1.0E-6);
455 double denom = std::max(fabs(Starget), acpb);
456 Serr = Starget - Snow;
457 SConvErr = fabs((Serr)/denom);
466 plogf(
" equilibrate_SP: It = %d, Tcurr = %g Scurr = %g, Starget = %g\n",
467 n, Tnow, Snow, Starget);
468 plogf(
" S rel error = %g, cp = %g, SConvErr = %g\n",
469 Serr, cpb, SConvErr);
472 if (SConvErr < err) {
477 plogf(
" equilibrate_SP: CONVERGENCE: Sfinal = %g Tfinal = %g, Its = %d \n",
479 plogf(
" S rel error = %g, cp = %g, HConvErr = %g\n",
480 Serr, cpb, SConvErr);
491 if (!estimateEquil) {
493 "try estimating composition at the start");
496 Tnew = 0.5*(Tnow + Thigh);
497 if (fabs(Tnew - Tnow) < 1.0) {
502 "trying T = "+
fp2str(Tnow));
511 "No convergence for T");
515 int printLvl, doublereal err,
516 int maxsteps,
int loglevel)
521 iSuccess =
equilibrate_TP(estimateEquil, printLvl, err, maxsteps, loglevel);
522 }
else if (XY == HP || XY == UP) {
531 estimateEquil, printLvl, err, maxsteps, loglevel);
532 }
else if (XY == SP) {
537 estimateEquil, printLvl, err, maxsteps, loglevel);
539 }
else if (XY == TV) {
542 estimateEquil, printLvl, err, maxsteps, loglevel);
543 }
else if (XY == HV) {
546 estimateEquil, printLvl, err, maxsteps, loglevel);
547 }
else if (XY == UV) {
550 estimateEquil, printLvl, err, maxsteps, loglevel);
551 }
else if (XY == SV) {
554 printLvl, err, maxsteps, loglevel);
557 "Unsupported Option");
563 int printLvl, doublereal err,
564 int maxsteps,
int loglevel)
566 int maxit = maxsteps;
602 "Temperature less than zero on input");
607 "Pressure less than zero on input");
610 beginLogGroup(
"vcs_MultiPhaseEquil::equilibrate_TP", loglevel);
648 double phaseMole = 0.0;
650 for (
size_t k = 0; k < tref.
nSpecies(); k++, kGlob++) {
659 plogf(
"\n Results from vcs:\n");
661 plogf(
"\nVCS FAILED TO CONVERGE!\n");
667 plogf(
"----------------------------------------"
668 "---------------------\n");
669 plogf(
" Name Mole_Number");
675 plogf(
" Mole_Fraction Chem_Potential");
677 plogf(
" (kcal/mol)\n");
679 plogf(
" (Dimensionless)\n");
681 plogf(
" (kJ/mol)\n");
683 plogf(
" (Kelvin)\n");
685 plogf(
" (J/kmol)\n");
687 plogf(
"--------------------------------------------------"
700 plogf(
" -1.000e+300\n");
709 plogf(
"------------------------------------------"
710 "-------------------\n");
713 plogf(
"Total time = %12.6e seconds\n", te);
731 FILE* FP = fopen(reportFile.c_str(),
"w");
733 plogf(
"Failure to open file\n");
742 std::vector<double> VolPM;
743 std::vector<double> activity;
744 std::vector<double> ac;
745 std::vector<double> mu;
746 std::vector<double> mu0;
747 std::vector<double> molalities;
751 for (
size_t iphase = 0; iphase < nphase; iphase++) {
755 VolPM.resize(nSpecies, 0.0);
760 double VolPhaseVolumes = 0.0;
761 for (k = 0; k < nSpecies; k++) {
762 VolPhaseVolumes += VolPM[k] * mf[istart + k];
764 VolPhaseVolumes *= TMolesPhase;
765 vol += VolPhaseVolumes;
768 fprintf(FP,
"--------------------- VCS_MULTIPHASE_EQUIL FINAL REPORT"
769 " -----------------------------\n");
770 fprintf(FP,
"Temperature = %11.5g kelvin\n", Temp);
771 fprintf(FP,
"Pressure = %11.5g Pascal\n", pres);
772 fprintf(FP,
"Total Volume = %11.5g m**3\n", vol);
776 for (
size_t iphase = 0; iphase < nphase; iphase++) {
780 string phaseName = tref.
name();
785 activity.resize(nSpecies, 0.0);
786 ac.resize(nSpecies, 0.0);
788 mu0.resize(nSpecies, 0.0);
789 mu.resize(nSpecies, 0.0);
790 VolPM.resize(nSpecies, 0.0);
791 molalities.resize(nSpecies, 0.0);
800 double VolPhaseVolumes = 0.0;
801 for (k = 0; k < nSpecies; k++) {
802 VolPhaseVolumes += VolPM[k] * mf[istart + k];
804 VolPhaseVolumes *= TMolesPhase;
805 vol += VolPhaseVolumes;
808 if (actConvention == 1) {
814 fprintf(FP,
" Name, Phase, PhaseMoles, Mole_Fract, "
815 "Molalities, ActCoeff, Activity,"
816 "ChemPot_SS0, ChemPot, mole_num, PMVol, Phase_Volume\n");
818 fprintf(FP,
" , , (kmol), , "
820 " (J/kmol), (J/kmol), (kmol), (m**3/kmol), (m**3)\n");
822 for (k = 0; k < nSpecies; k++) {
824 fprintf(FP,
"%12s, %11s, %11.3e, %11.3e, %11.3e, %11.3e, %11.3e,"
825 "%11.3e, %11.3e, %11.3e, %11.3e, %11.3e\n",
827 phaseName.c_str(), TMolesPhase,
828 mf[istart + k], molalities[k], ac[k], activity[k],
829 mu0[k]*1.0E-6, mu[k]*1.0E-6,
830 mf[istart + k] * TMolesPhase,
831 VolPM[k], VolPhaseVolumes);
836 fprintf(FP,
" Name, Phase, PhaseMoles, Mole_Fract, "
837 "Molalities, ActCoeff, Activity,"
838 " ChemPotSS0, ChemPot, mole_num, PMVol, Phase_Volume\n");
840 fprintf(FP,
" , , (kmol), , "
842 " (J/kmol), (J/kmol), (kmol), (m**3/kmol), (m**3)\n");
844 for (k = 0; k < nSpecies; k++) {
847 for (k = 0; k < nSpecies; k++) {
849 fprintf(FP,
"%12s, %11s, %11.3e, %11.3e, %11.3e, %11.3e, %11.3e, "
850 "%11.3e, %11.3e,% 11.3e, %11.3e, %11.3e\n",
852 phaseName.c_str(), TMolesPhase,
853 mf[istart + k], molalities[k], ac[k],
854 activity[k], mu0[k]*1.0E-6, mu[k]*1.0E-6,
855 mf[istart + k] * TMolesPhase,
856 VolPM[k], VolPhaseVolumes);
865 for (k = 0; k < nSpecies; k++) {
867 fprintf(FP,
"ERROR: incompatibility!\n");
869 plogf(
"ERROR: incompatibility!\n");
886 for (
int i = 0; i < num; i++) {
903 size_t totNumPhases = mphase->
nPhases();
904 size_t totNumSpecies = mphase->
nSpecies();
910 vprob->
NPhase = totNumPhases;
918 vprob->Title =
"MultiPhase Object";
929 for (
size_t iphase = 0; iphase < totNumPhases; iphase++) {
934 tPhase = &(mphase->
phase(iphase));
951 size_t nSpPhase = tPhase->
nSpecies();
955 string phaseName = tPhase->
name();
968 VolPhase->
resize(iphase, nSpPhase, nelem, phaseName.c_str(), 0.0);
994 case cIncompressible:
998 throw CanteraError(
"VCSnonideal",
"cSurf not handled yet.");
999 case cStoichSubstance:
1004 plogf(
"cPureFluid not recognized yet by VCSnonideal\n");
1008 throw CanteraError(
"VCSnonideal",
"cEdge not handled yet.");
1009 case cIdealSolidSolnPhase0:
1010 case cIdealSolidSolnPhase1:
1011 case cIdealSolidSolnPhase2:
1016 plogf(
"Unknown Cantera EOS to VCSnonideal: %d\n", eos);
1020 plogf(
"vcs functions asked for, but unimplemented\n");
1045 vector<double> muPhase(tPhase->
nSpecies(),0.0);
1047 double tMoles = 0.0;
1051 for (
size_t k = 0; k < nSpPhase; k++) {
1073 vprob->
SpName[kT] = stmp;
1085 tMoles += vprob->
w[kT];
1117 sProp->NumElements = vprob->
ne;
1119 sProp->SpeciesThermo = ts_ptr;
1122 for (
size_t e = 0; e < vprob->
ne; e++) {
1125 sProp->Charge = tPhase->
charge(k);
1126 sProp->SurfaceSpecies =
false;
1150 double minTemp, maxTemp, refPressure;
1151 sp.
reportParams(k, spType, c, minTemp, maxTemp, refPressure);
1168 plogf(
"vcs_Cantera_convert: Species Type %d not known \n",
1174 plogf(
"Cantera calls not being used -> exiting\n");
1188 std::vector<double> phaseTermCoeff(nSpPhase, 0.0);
1203 for (
size_t k = 0; k < nSpPhase; k++) {
1205 vprob->
mf[kTa] = vprob->
w[kTa] / tMoles;
1212 for (
size_t k = 0; k < nSpPhase; k++) {
1214 vprob->
mf[kTa]= 1.0 / (double) nSpPhase;
1224 for (
size_t k = 0; k < nSpPhase; k++) {
1226 ts_ptr = sProp->SpeciesThermo;
1238 vprob->
gai.resize(vprob->
ne, 0.0);
1249 plogf(
" Cantera_to_vprob: START OF PROBLEM STATEMENT ");
1254 plogf(
" Phase IDs of species\n");
1255 plogf(
" species phaseID phaseName ");
1256 plogf(
" Initial_Estimated_kMols\n");
1257 for (
size_t i = 0; i < vprob->
nspecies; i++) {
1258 size_t iphase = vprob->
PhaseID[i];
1261 plogf(
"%16s %5d %16s", vprob->
SpName[i].c_str(), iphase,
1264 plogf(
" Volts = %-10.5g\n", vprob->
w[i]);
1266 plogf(
" %-10.5g\n", vprob->
w[i]);
1276 plogf(
" Information about phases\n");
1277 plogf(
" PhaseName PhaseNum SingSpec GasPhase EqnState NumSpec");
1278 plogf(
" TMolesInert Tmoles(kmol)\n");
1280 for (
size_t iphase = 0; iphase < vprob->
NPhase; iphase++) {
1283 plogf(
"%16s %5d %5d %8d %16s %8d %16e ", VolPhase->
PhaseName.c_str(),
1294 plogf(
" Cantera_to_vprob: END OF PROBLEM STATEMENT ");
1307 size_t totNumPhases = mphase->
nPhases();
1309 std::vector<double> tmpMoles;
1320 for (
size_t iphase = 0; iphase < totNumPhases; iphase++) {
1321 tPhase = &(mphase->
phase(iphase));
1330 vector<double> muPhase(tPhase->
nSpecies(),0.0);
1335 size_t nSpPhase = tPhase->
nSpecies();
1337 tmpMoles.resize(nSpPhase);
1338 for (
size_t k = 0; k < nSpPhase; k++) {
1356 if ((nSpPhase == 1) && (volPhase->
phiVarIndex() == 0)) {
1382 plogf(
" Cantera_to_vprob: START OF PROBLEM STATEMENT ");
1387 plogf(
" Phase IDs of species\n");
1388 plogf(
" species phaseID phaseName ");
1389 plogf(
" Initial_Estimated_kMols\n");
1390 for (
size_t i = 0; i < vprob->
nspecies; i++) {
1391 size_t iphase = vprob->
PhaseID[i];
1394 plogf(
"%16s %5d %16s", vprob->
SpName[i].c_str(), iphase,
1397 plogf(
" Volts = %-10.5g\n", vprob->
w[i]);
1399 plogf(
" %-10.5g\n", vprob->
w[i]);
1409 plogf(
" Information about phases\n");
1410 plogf(
" PhaseName PhaseNum SingSpec GasPhase EqnState NumSpec");
1411 plogf(
" TMolesInert Tmoles(kmol)\n");
1413 for (
size_t iphase = 0; iphase < vprob->
NPhase; iphase++) {
1416 plogf(
"%16s %5d %5d %8d %16s %8d %16e ", VolPhase->
PhaseName.c_str(),
1427 plogf(
" Cantera_to_vprob: END OF PROBLEM STATEMENT ");
1440 nu.resize(nsp, 0.0);
1441 for (
size_t i = 0; i < nsp; i++) {
1448 if (rxn > nsp - nc) {
1451 size_t j = indSpecies[rxn + nc];
1453 for (
size_t kc = 0; kc < nc; kc++) {
1455 nu[j] = scMatrix[rxn][kc];
1507 plogf(
"problems\n");
1517 throw CanteraError(
"vcs_MultiPhaseEquil::determine_PhaseStability",
1518 "Temperature less than zero on input");
1522 throw CanteraError(
"vcs_MultiPhaseEquil::determine_PhaseStability",
1523 "Pressure less than zero on input");
1526 beginLogGroup(
"vcs_MultiPhaseEquil::determine_PhaseStability", loglevel);
1564 plogf(
"\n Results from vcs_PS:\n");
1571 plogf(
"Phase %d named %s is stable, function value = %g > 0\n", iph, sss.c_str(), funcStab);
1573 plogf(
"Phase %d named %s is not stable + function value = %g < 0\n", iph, sss.c_str(), funcStab);
1576 plogf(
"----------------------------------------"
1577 "---------------------\n");
1578 plogf(
" Name Mole_Number");
1584 plogf(
" Mole_Fraction Chem_Potential");
1586 plogf(
" (kcal/mol)\n");
1588 plogf(
" (Dimensionless)\n");
1590 plogf(
" (kJ/mol)\n");
1592 plogf(
" (Kelvin)\n");
1594 plogf(
" (J/kmol)\n");
1596 plogf(
"-------------------------------------------------------------\n");
1611 plogf(
"------------------------------------------"
1612 "-------------------\n");
1615 plogf(
"Total time = %12.6e seconds\n", te);
1619 endLogGroup(
"vcs_MultiPhaseEquil::determine_PhaseStability");
std::vector< VCS_SPECIES_THERMO * > SpeciesThermo
Vector of pointers to thermo structures which identify the model and parameters for evaluating the th...
int speciesUnknownType(const size_t k) const
Returns the type of the species unknown.
#define VCS_PHASE_EXIST_NO
Phase doesn't currently exist in the mixture.
std::vector< double > WtSpecies
Molecular weight of species.
doublereal molecularWeight(size_t k) const
Molecular weight of species k.
vcs_SpeciesProperties * speciesProperty(const size_t kindex)
Retrieve the kth Species structure for the species belonging to this phase.
ThermoPhase object for the ideal molal equation of state (see Thermodynamic Properties and class Idea...
std::string int2str(const int n, const std::string &fmt)
Convert an int to a string using a format converter.
size_t VP_ID_
Original ID of the phase in the problem.
double vcsUtil_gasConstant(int mu_units)
Returns the value of the gas constant in the units specified by parameter.
double SSStar_Vol0
parameter that is used in the VCS_SSVOL_CONSTANT model.
int equilibrate_HP(doublereal Htarget, int XY, double Tlow, double Thigh, int estimateEquil=0, int printLvl=0, doublereal err=1.0E-6, int maxsteps=VCS_MAXSTEPS, int loglevel=-99)
Equilibrate the solution using the current element abundances stored in the MultiPhase object using e...
doublereal electricPotential() const
Returns the electric potential of this phase (V).
size_t m_numComponents
Number of components calculated for the problem.
int iest
Specification of the initial estimate method.
int SS0_Model
Integer representing the models for the species standard state Naught temperature dependence...
double SS0_S0
Base entropy used in the VCS_SS0_CONSTANT_CP model.
std::vector< double > w
Total number of moles of the kth species.
size_t nElements() const
Number of elements.
Cantera::MultiPhase * m_mix
Pointer to the MultiPhase mixture that will be equilibrated.
void beginLogGroup(const std::string &title, int loglevel)
Create a new group for log messages.
virtual void getParameters(int &n, doublereal *const c) const
Get the equation of state parameters in a vector.
size_t numComponents() const
reports the number of components in the equilibration problem
int equilibrate_TP(int estimateEquil=0, int printLvl=0, doublereal err=1.0e-6, int maxsteps=VCS_MAXSTEPS, int loglevel=-99)
Equilibrate the solution using the current element abundances stored in the MultiPhase object using c...
Declarations for a simple class that implements an Ansi C wall clock timer (see Cantera::clockWC).
int SSStar_Vol_Model
Models for the standard state volume of each species.
*std::vector< double > FormulaMatrixCol
Column of the formula matrix, comprising the element composition of the species.
bool UseCanteraCalls
If true, this object will call Cantera to do its member calculations.
void setPhaseMoles(const size_t n, const doublereal moles)
Set the number of moles of phase with index n.
std::string PhaseName
String name for the phase.
doublereal speciesMoles(size_t kGlob) const
Returns the moles of global species k. units = kmol.
#define VCS_PHASE_EXIST_ALWAYS
Always exists because it contains inerts which can't exist in any other phase.
const size_t npos
index returned by functions to indicate "no position"
std::string speciesName(const size_t kGlob) const
Name of species with global index kGlob.
size_t IndexSpeciesPhase
Index of this species in the current phase.
int SSStar_Model
Integer value representing the star state model.
void prob_report(int print_lvl)
Print out the problem specification in all generality as it currently exists in the VCS_PROB object...
#define VCS_DATA_PTR(vvv)
Points to the data in a std::vector<> object.
int Activity_Coeff_Model
Integer value representing the activity coefficient model These are defined in vcs_VolPhase.h and start with VCS_AC_...
void setExistence(const int existence)
Set the existence flag in the object.
doublereal phaseMoles(const size_t n) const
Return the number of moles in phase n.
doublereal temperature() const
Temperature [K].
#define VCS_SSVOL_IDEALGAS
Models for the standard state volume of each species.
std::string SpName
Name of the species.
int m_NumBasisOptimizations
Number of basis optimizations used. This is an output variable.
size_t numElemConstraints() const
Reports the number of element constraints in the equilibration problem.
The class provides the wall clock timer in seconds.
int m_timing_print_lvl
printing level of timing information
std::vector< int > SpeciesUnknownType
Specifies the species unknown type.
virtual void getStandardChemPotentials(doublereal *mu) const
Get the array of chemical potentials at unit activity for the species at their standard states at the...
void set_gai()
Calculate the element abundance vector from the mole numbers.
virtual void getPartialMolarVolumes(doublereal *vbar) const
Return an array of partial molar volumes for the species in the mixture.
std::vector< double > m_gibbsSpecies
Vector of chemical potentials of the species.
size_t transferElementsFM(const Cantera::ThermoPhase *const tPhase)
Transfer all of the element information from the ThermoPhase object to the vcs_VolPhase object...
int equilibrate(int XY, int estimateEquil=0, int printLvl=0, doublereal err=1.0e-6, int maxsteps=VCS_MAXSTEPS, int loglevel=-99)
Equilibrate the solution using the current element abundances stored in the MultiPhase object...
int p_activityConvention
Convention for the activity formulation.
Properties of a single species.
#define VCS_PHASE_EXIST_YES
Phase is a normal phase that currently exists.
vcs_VolPhase * OwningPhase
Pointer to the owning phase object.
std::string name() const
Return the name of the phase.
Pure Virtual base class for the species thermo manager classes.
friend int vcs_Cantera_update_vprob(Cantera::MultiPhase *mphase, VCSnonideal::VCS_PROB *vprob)
Translate a MultiPhase information into a VCS_PROB problem definition object.
void getChemPotentials(doublereal *mu) const
Returns a vector of Chemical potentials.
virtual int reportType(size_t index=npos) const =0
This utility function reports the type of parameterization used for the species with index number ind...
int vcs_Cantera_to_vprob(Cantera::MultiPhase *mphase, VCSnonideal::VCS_PROB *vprob)
Translate a MultiPhase object into a VCS_PROB problem definition object.
std::vector< double > Charge
Charge of each species.
const doublereal Undef
Fairly random number to be used to initialize variables against to see if they are subsequently defin...
void reportCSV(const std::string &reportFile)
Report the equilibrium answer in a comma separated table format.
Base class for a phase with thermodynamic properties.
const int cSurf
A surface phase. Used by class SurfPhase.
size_t NPhase
Number of phases in the problem.
bool usingCanteraCalls() const
Returns whether the object is using cantera calls.
Contains const definitions for types of species reference-state thermodynamics managers (see Species ...
int vcs_Cantera_update_vprob(Cantera::MultiPhase *mphase, VCSnonideal::VCS_PROB *vprob)
Translate a MultiPhase information into a VCS_PROB problem definition object.
Header file for the internal object that holds the vcs equilibrium problem (see Class VCS_SOLVE and E...
Header for the object representing each phase within vcs.
#define VCS_SPECIES_TYPE_MOLNUM
Unknown refers to mole number of a single species.
std::vector< size_t > m_speciesMapIndex
Index vector that keeps track of the species vector rearrangement.
Phase information and Phase calculations for vcs.
void uploadMoleFractionsFromPhases()
Update the locally-stored composition within this object to match the current compositions of the pha...
A class for multiphase mixtures.
virtual void getActivities(doublereal *a) const
Get the array of non-dimensional activities at the current solution temperature, pressure, and solution concentration.
void addPhaseElements(vcs_VolPhase *volPhase)
Add elements to the local element list.
Internal declarations for the VCSnonideal package.
doublereal entropy() const
The entropy of the mixture [J/K].
double secondsWC()
Returns the wall clock time in seconds since the last reset.
double SS0_Cp0
Base heat capacity used in the VCS_SS0_CONSTANT_CP model.
std::string fp2str(const double x, const std::string &fmt)
Convert a double into a c++ string.
size_t m_numSpeciesTot
Total number of species in the problems.
virtual void getChemPotentials(doublereal *mu) const
Get the species chemical potentials. Units: J/kmol.
double G0_calc_one(size_t kspec) const
Gibbs free energy calculation at a temperature for the reference state of a species, return a value for one species.
Header for the Interface class for the vcs thermo equilibrium solver package,.
int prob_type
Problem type. I.e., the identity of what is held constant.
std::vector< size_t > PhaseID
Mapping between the species and the phases.
int m_printLvl
Print level from the VCSnonlinear package.
Header file for an ideal solid solution model with incompressible thermodynamics (see Thermodynamic P...
void * SSStar_Vol_Params
Pointer to a list of parameters that is malloced for volume models.
size_t nspecies
Total number of species in the problems.
double SS0_T0
Base temperature used in the VCS_SS0_CONSTANT_CP model.
void setTemperature(const doublereal T)
Set the temperature [K].
DoubleStarStar FormulaMatrix
Formula Matrix for the problem.
size_t component(size_t m) const
Return the index of the ith component.
size_t spGlobalIndexVCS(const size_t spIndex) const
Return the Global VCS index of the kth species in the phase.
Base class for exceptions thrown by Cantera classes.
int m_VCS_UnitsFormat
Units for the chemical potential data, pressure data, volume, and species amounts.
#define SIMPLE
Constant Cp thermo.
doublereal IntEnergy() const
The internal energy of the mixture [J].
size_t m_numElemConstraints
Number of element constraints in the problem.
void setTotalMoles(const double totalMols)
Sets the total moles in the phase.
const int cEdge
An edge between two 2D surfaces.
int m_printLvl
Print level for print routines.
size_t phiVarIndex() const
Return the index of the species that represents the the voltage of the phase.
double Vol
Volume of the entire system.
void setPressure(doublereal P)
Set the pressure [Pa].
VCSnonideal::VCS_PROB * m_vprob
Object which contains the problem statement.
This is the main structure used to hold the internal data used in vcs_solve_TP(), and to solve TP sys...
doublereal moleFraction(const size_t kGlob) const
Returns the mole fraction of global species k.
double SS0_TSave
Internal storage of the last temperature used in the calculation of the reference naught Gibbs free e...
void endLogGroup(const std::string &title)
Close the current group of log messages.
size_t nSpecies() const
Returns the number of species in the phase.
Interface class for the vcsnonlinear solver.
void addLogEntry(const std::string &tag, const std::string &value)
Add an entry to an HTML log file.
size_t nSpecies() const
Return the number of species in the phase.
std::vector< vcs_VolPhase * > VPhaseList
Array of phase structures.
bool m_singleSpecies
If true, this phase consists of a single species.
void resize(const size_t phaseNum, const size_t numSpecies, const size_t numElem, const char *const phaseName, const double molesInert=0.0)
The resize() function fills in all of the initial information if it is not given in the constructor...
bool vcs_doubleEqual(double d1, double d2)
Simple routine to check whether two doubles are equal up to roundoff error.
#define VCS_STATECALC_OLD
State Calculation based on the old or base mole numbers.
size_t addOnePhaseSpecies(vcs_VolPhase *volPhase, size_t k, size_t kT)
This routines adds entries for the formula matrix for one species.
void setMolesFromVCS(const int stateCalc, const double *molesSpeciesVCS=0)
Set the moles within the phase.
static void print_char(const char letter, const int num)
print char repeatedly to log file
int p_VCS_UnitsFormat
Units for the chemical potential data, pressure data, volume, and species amounts.
#define plogendl()
define this Cantera function to replace cout << endl;
doublereal enthalpy() const
The enthalpy of the mixture [J].
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
doublereal maxTemp() const
Maximum temperature for which all solution phases have valid thermo data.
void * Activity_Coeff_Params
Pointer to a list of parameters that is malloced for activity coefficient models. ...
DoubleStarStar m_stoichCoeffRxnMatrix
Stoichiometric coefficient matrix for the reaction mechanism expressed in Reduced Canonical Form...
double SS0_feSave
Internal storage of the last calculation of the reference naught Gibbs free energy at SS0_TSave...
double totalMolesInert() const
returns the value of the total kmol of inert in the phase
virtual int eosType() const
Equation of state type flag.
int determine_PhaseStability(int iph, double &funcStab, int printLvl=0, int logLevel=-99)
Determine the phase stability of a phase at the current conditions.
std::string phaseName(const size_t iph) const
Returns the name of the n'th phase.
void setElectricPotential(const double phi)
set the electric potential of the phase
virtual void getActivityCoefficients(doublereal *ac) const
Get the array of non-dimensional molar-based activity coefficients at the current solution temperatur...
void getMolalities(doublereal *const molal) const
This function will return the molalities of the species.
virtual int activityConvention() const
This method returns the convention used in specification of the activities, of which there are curren...
int equilibrate_TV(int XY, doublereal xtarget, int estimateEquil=0, int printLvl=0, doublereal err=1.0E-6, int maxsteps=VCS_MAXSTEPS, int logLevel=-99)
Equilibrate the solution using the current element abundances stored in the MultiPhase object using c...
Contains declarations for string manipulation functions within Cantera.
Interface class for the vcs thermo equilibrium solver package, which generally describes the problem ...
std::vector< std::string > SpName
Vector of strings containing the species names.
#define DATA_PTR(vec)
Creates a pointer to the start of the raw data for a vector.
std::string string16_EOSType(int EOSType)
Return a string representing the equation of state.
int m_Iterations
Number of iterations. This is an output variable.
double totalMoles() const
Return the total moles in the phase.
VCSnonideal::VCS_SOLVE * m_vsolvePtr
Pointer to the object that does all of the equilibration work.
#define plogf
define this Cantera function to replace printf
void setPtrThermoPhase(Cantera::ThermoPhase *tp_ptr)
Set the pointer for Cantera's ThermoPhase parameter.
std::vector< double > gai
Element abundances for jth element.
virtual SpeciesThermo & speciesThermo(int k=-1)
Return a changeable reference to the calculation manager for species reference-state thermodynamic pr...
#define VCS_SPECIES_TYPE_INTERFACIALVOLTAGE
Unknown refers to the voltage level of a phase.
void setState_TP(const double temperature_Kelvin, const double pressure_PA)
Sets the temperature and pressure in this object and underlying ThermoPhase objects.
void getStoichVector(size_t rxn, Cantera::vector_fp &nu)
Get the stoichiometric reaction coefficients for a single reaction index.
virtual void reportParams(size_t index, int &type, doublereal *const c, doublereal &minTemp, doublereal &maxTemp, doublereal &refPressure) const =0
This utility function reports back the type of parameterization and all of the parameters for the spe...
thermo_t & phase(size_t n)
Return a reference to phase n.
doublereal minTemp() const
Minimum temperature for which all solution phases have valid thermo data.
doublereal pressure() const
Pressure [Pa].
size_t ne
Number of element constraints in the equilibrium problem.
int equilibrate_SP(doublereal Starget, double Tlow, double Thigh, int estimateEquil=0, int printLvl=0, doublereal err=1.0E-6, int maxsteps=VCS_MAXSTEPS, int loglevel=-99)
Equilibrate the solution using the current element abundances stored in the MultiPhase object using c...
size_t IndexPhase
Index of the phase that this species belongs to.
size_t nSpecies() const
Number of species, summed over all phases.
size_t speciesIndex(size_t k, size_t p) const
Return the global index of the species belonging to phase number p with local index k within the phas...
int m_eqnState
Type of the equation of state.
double T
Temperature (Kelvin)
double SS0_H0
Base enthalpy used in the VCS_SS0_CONSTANT_CP model.
const int cIdealGas
Equation of state types:
std::string speciesName(size_t k) const
Name of the species with index k.
int vcs(VCS_PROB *vprob, int ifunc, int ipr, int ip1, int maxit)
Solve an equilibrium problem.
doublereal volume() const
The total mixture volume [m^3].
A class for 2D double arrays stored in column-major (Fortran-compatible) form.
bool m_gasPhase
If true, this phase is a gas-phase like phase.
size_t nElements() const
Number of elements.
std::vector< double > mf
Mole fraction vector.
friend int vcs_Cantera_to_vprob(Cantera::MultiPhase *mphase, VCSnonideal::VCS_PROB *vprob)
Translate a MultiPhase object into a VCS_PROB problem definition object.
doublereal charge(size_t k) const
Dimensionless electrical charge of a single molecule of species k The charge is normalized by the the...
size_t nPhases() const
Number of phases.