24 vcs_MultiPhaseEquil::vcs_MultiPhaseEquil() :
31 vcs_MultiPhaseEquil::vcs_MultiPhaseEquil(
MultiPhase* mix,
int printLvl) :
32 m_vprob(mix->nSpecies(), mix->nElements(), mix->nPhases()),
49 int printLvl, doublereal err,
50 int maxsteps,
int loglevel)
53 if ((XY != TV) && (XY != HV) && (XY != UV) && (XY != SV)) {
54 throw CanteraError(
"vcs_MultiPhaseEquil::equilibrate_TV",
55 "Wrong XY flag: {}", XY);
62 int strt = estimateEquil;
69 int printLvlSub = std::max(0, printLvl - 1);
70 for (
int n = 0; n < maxiter; n++) {
75 iSuccess =
equilibrate_TP(strt, printLvlSub, err, maxsteps, loglevel);
79 printLvlSub, err, maxsteps, loglevel);
83 printLvlSub, err, maxsteps, loglevel);
87 printLvlSub, err, maxsteps, loglevel);
107 double Verr = fabs((Vtarget - Vnow)/Vtarget);
114 double dVdP = (V2 - V1) / (P2 - P1);
119 Pnew = Pnow + (Vtarget - Vnow) / dVdP;
120 if (Pnew < 0.2 * Pnow) {
123 if (Pnew > 3.0 * Pnow) {
129 double dVdP = (
m_mix->
volume() - Vnow)/(0.01*Pnow);
130 Pnew = Pnow + 0.5*(Vtarget - Vnow)/dVdP;
131 if (Pnew < 0.5* Pnow) {
134 if (Pnew > 1.7 * Pnow) {
141 "No convergence for V");
145 int XY,
double Tlow,
double Thigh,
147 int printLvl, doublereal err,
148 int maxsteps,
int loglevel)
152 if (XY != HP && XY != UP) {
153 throw CanteraError(
"vcs_MultiPhaseEquil::equilibrate_HP",
156 int strt = estimateEquil;
163 if (Thigh <= 0.0 || Thigh > 1.0E6) {
167 doublereal cpb = 1.0;
168 doublereal Hlow =
Undef;
169 doublereal Hhigh =
Undef;
171 int printLvlSub = std::max(printLvl - 1, 0);
173 for (
int n = 0; n < maxiter; n++) {
178 iSuccess =
equilibrate_TP(strt, printLvlSub, err, maxsteps, loglevel);
183 double Tmoles = pmoles[0];
184 double HperMole = Hnow/Tmoles;
186 plogf(
"T = %g, Hnow = %g ,Tmoles = %g, HperMole = %g",
187 Tnow, Hnow, Tmoles, HperMole);
194 if (Hnow < Htarget) {
209 cpb = (Hhigh - Hlow)/(Thigh - Tlow);
210 dT = (Htarget - Hnow)/cpb;
211 double dTa = fabs(dT);
212 double dTmax = 0.5*fabs(Thigh - Tlow);
217 double Tnew = sqrt(Tlow*Thigh);
218 dT =
clip(Tnew - Tnow, -200.0, 200.0);
220 double acpb = std::max(fabs(cpb), 1.0E-6);
221 double denom = std::max(fabs(Htarget), acpb);
222 double Herr = Htarget - Hnow;
223 double HConvErr = fabs((Herr)/denom);
225 plogf(
" equilibrate_HP: It = %d, Tcurr = %g Hcurr = %g, Htarget = %g\n",
226 n, Tnow, Hnow, Htarget);
227 plogf(
" H rel error = %g, cp = %g, HConvErr = %g\n",
228 Herr, cpb, HConvErr);
231 if (HConvErr < err) {
233 plogf(
" equilibrate_HP: CONVERGENCE: Hfinal = %g Tfinal = %g, Its = %d \n",
235 plogf(
" H rel error = %g, cp = %g, HConvErr = %g\n",
236 Herr, cpb, HConvErr);
240 double Tnew = Tnow + dT;
246 if (!estimateEquil) {
249 double Tnew = 0.5*(Tnow + Thigh);
250 if (fabs(Tnew - Tnow) < 1.0) {
258 "No convergence for T");
262 double Tlow,
double Thigh,
264 int printLvl, doublereal err,
265 int maxsteps,
int loglevel)
268 int strt = estimateEquil;
275 if (Thigh <= 0.0 || Thigh > 1.0E6) {
279 doublereal cpb = 1.0, dT;
280 doublereal Slow =
Undef;
281 doublereal Shigh =
Undef;
283 Tlow = std::min(Tnow, Tlow);
284 Thigh = std::max(Tnow, Thigh);
285 int printLvlSub = std::max(printLvl - 1, 0);
287 for (
int n = 0; n < maxiter; n++) {
292 int iSuccess =
equilibrate_TP(strt, printLvlSub, err, maxsteps, loglevel);
297 double Tmoles = pmoles[0];
298 double SperMole = Snow/Tmoles;
300 plogf(
"T = %g, Snow = %g ,Tmoles = %g, SperMole = %g\n",
301 Tnow, Snow, Tmoles, SperMole);
308 if (Snow < Starget) {
313 if (Slow > Starget && Snow < Slow) {
329 cpb = (Shigh - Slow)/(Thigh - Tlow);
330 dT = (Starget - Snow)/cpb;
331 double Tnew = Tnow + dT;
332 double dTa = fabs(dT);
333 double dTmax = 0.5*fabs(Thigh - Tlow);
334 if (Tnew > Thigh || Tnew < Tlow) {
335 dTmax = 1.5*fabs(Thigh - Tlow);
337 dTmax = std::min(dTmax, 300.);
342 double Tnew = sqrt(Tlow*Thigh);
346 double acpb = std::max(fabs(cpb), 1.0E-6);
347 double denom = std::max(fabs(Starget), acpb);
348 double Serr = Starget - Snow;
349 double SConvErr = fabs((Serr)/denom);
351 plogf(
" equilibrate_SP: It = %d, Tcurr = %g Scurr = %g, Starget = %g\n",
352 n, Tnow, Snow, Starget);
353 plogf(
" S rel error = %g, cp = %g, SConvErr = %g\n",
354 Serr, cpb, SConvErr);
357 if (SConvErr < err) {
359 plogf(
" equilibrate_SP: CONVERGENCE: Sfinal = %g Tfinal = %g, Its = %d \n",
361 plogf(
" S rel error = %g, cp = %g, HConvErr = %g\n",
362 Serr, cpb, SConvErr);
366 double Tnew = Tnow + dT;
372 if (!estimateEquil) {
375 double Tnew = 0.5*(Tnow + Thigh);
376 if (fabs(Tnew - Tnow) < 1.0) {
384 "No convergence for T");
388 int printLvl, doublereal err,
389 int maxsteps,
int loglevel)
393 return equilibrate_TP(estimateEquil, printLvl, err, maxsteps, loglevel);
394 }
else if (XY == HP || XY == UP) {
403 estimateEquil, printLvl, err, maxsteps, loglevel);
404 }
else if (XY == SP) {
409 estimateEquil, printLvl, err, maxsteps, loglevel);
410 }
else if (XY == TV) {
413 estimateEquil, printLvl, err, maxsteps, loglevel);
414 }
else if (XY == HV) {
417 estimateEquil, printLvl, err, maxsteps, loglevel);
418 }
else if (XY == UV) {
421 estimateEquil, printLvl, err, maxsteps, loglevel);
422 }
else if (XY == SV) {
425 printLvl, err, maxsteps, loglevel);
428 "Unsupported Option");
433 int printLvl, doublereal err,
434 int maxsteps,
int loglevel)
436 int maxit = maxsteps;
459 "Temperature less than zero on input");
463 "Pressure less than zero on input");
488 double phaseMole = 0.0;
490 for (
size_t k = 0; k < tref.
nSpecies(); k++, kGlob++) {
498 plogf(
"\n Results from vcs:\n");
500 plogf(
"\nVCS FAILED TO CONVERGE!\n");
506 plogf(
"----------------------------------------" 507 "---------------------\n");
508 plogf(
" Name Mole_Number(kmol)");
509 plogf(
" Mole_Fraction Chem_Potential (J/kmol)\n");
510 plogf(
"--------------------------------------------------" 523 plogf(
" -1.000e+300\n");
532 plogf(
"------------------------------------------" 533 "-------------------\n");
535 plogf(
"Total time = %12.6e seconds\n", te);
545 FILE* FP = fopen(reportFile.c_str(),
"w");
548 "Failure to open file");
560 for (
size_t iphase = 0; iphase < nphase; iphase++) {
564 VolPM.resize(nSpecies, 0.0);
569 double VolPhaseVolumes = 0.0;
570 for (
size_t k = 0; k < nSpecies; k++) {
571 VolPhaseVolumes += VolPM[k] * mf[istart + k];
573 VolPhaseVolumes *= TMolesPhase;
574 vol += VolPhaseVolumes;
577 fprintf(FP,
"--------------------- VCS_MULTIPHASE_EQUIL FINAL REPORT" 578 " -----------------------------\n");
581 fprintf(FP,
"Total Volume = %11.5g m**3\n", vol);
585 for (
size_t iphase = 0; iphase < nphase; iphase++) {
588 string phaseName = tref.
name();
592 activity.resize(nSpecies, 0.0);
593 ac.resize(nSpecies, 0.0);
594 mu0.resize(nSpecies, 0.0);
595 mu.resize(nSpecies, 0.0);
596 VolPM.resize(nSpecies, 0.0);
597 molalities.resize(nSpecies, 0.0);
604 double VolPhaseVolumes = 0.0;
605 for (
size_t k = 0; k < nSpecies; k++) {
606 VolPhaseVolumes += VolPM[k] * mf[istart + k];
608 VolPhaseVolumes *= TMolesPhase;
609 vol += VolPhaseVolumes;
611 if (actConvention == 1) {
617 fprintf(FP,
" Name, Phase, PhaseMoles, Mole_Fract, " 618 "Molalities, ActCoeff, Activity," 619 "ChemPot_SS0, ChemPot, mole_num, PMVol, Phase_Volume\n");
621 fprintf(FP,
" , , (kmol), , " 623 " (J/kmol), (J/kmol), (kmol), (m**3/kmol), (m**3)\n");
625 for (
size_t k = 0; k < nSpecies; k++) {
627 fprintf(FP,
"%12s, %11s, %11.3e, %11.3e, %11.3e, %11.3e, %11.3e," 628 "%11.3e, %11.3e, %11.3e, %11.3e, %11.3e\n",
630 phaseName.c_str(), TMolesPhase,
631 mf[istart + k], molalities[k], ac[k], activity[k],
632 mu0[k]*1.0E-6, mu[k]*1.0E-6,
633 mf[istart + k] * TMolesPhase,
634 VolPM[k], VolPhaseVolumes);
638 fprintf(FP,
" Name, Phase, PhaseMoles, Mole_Fract, " 639 "Molalities, ActCoeff, Activity," 640 " ChemPotSS0, ChemPot, mole_num, PMVol, Phase_Volume\n");
642 fprintf(FP,
" , , (kmol), , " 644 " (J/kmol), (J/kmol), (kmol), (m**3/kmol), (m**3)\n");
646 for (
size_t k = 0; k < nSpecies; k++) {
649 for (
size_t k = 0; k < nSpecies; k++) {
651 fprintf(FP,
"%12s, %11s, %11.3e, %11.3e, %11.3e, %11.3e, %11.3e, " 652 "%11.3e, %11.3e,% 11.3e, %11.3e, %11.3e\n",
654 phaseName.c_str(), TMolesPhase,
655 mf[istart + k], molalities[k], ac[k],
656 activity[k], mu0[k]*1.0E-6, mu[k]*1.0E-6,
657 mf[istart + k] * TMolesPhase,
658 VolPM[k], VolPhaseVolumes);
664 for (
size_t k = 0; k < nSpecies; k++) {
666 fprintf(FP,
"ERROR: incompatibility!\n");
668 throw CanteraError(
"vcs_MultiPhaseEquil::reportCSV",
"incompatibility!");
683 size_t totNumPhases = mphase->
nPhases();
684 size_t totNumSpecies = mphase->
nSpecies();
690 vprob->
NPhase = totNumPhases;
697 vprob->Title =
"MultiPhase Object";
703 for (
size_t iphase = 0; iphase < totNumPhases; iphase++) {
709 std::string eos = tPhase->
type();
710 bool gasPhase = (eos ==
"IdealGas");
713 size_t nSpPhase = tPhase->
nSpecies();
715 string phaseName = tPhase->
name();
725 VolPhase->
resize(iphase, nSpPhase, nelem, phaseName.c_str(), 0.0);
741 if (eos ==
"IdealGas") {
743 }
else if (eos ==
"ConstDensity") {
745 }
else if (eos ==
"StoichSubstance") {
747 }
else if (eos ==
"IdealSolidSoln") {
749 }
else if (eos ==
"Surf" || eos ==
"Edge") {
751 "Surface/edge phase not handled yet.");
754 writelog(
"Unknown Cantera EOS to VCSnonideal: '{}'\n", eos);
776 for (
size_t k = 0; k < nSpPhase; k++) {
797 tMoles += vprob->
w[kT];
822 sProp->NumElements = vprob->
ne;
827 for (
size_t e = 0; e < vprob->
ne; e++) {
848 double minTemp, maxTemp, refPressure;
849 sp.
reportParams(k, spType, c, minTemp, maxTemp, refPressure);
864 plogf(
"vcs_Cantera_convert: Species Type %d not known \n",
889 for (
size_t k = 0; k < nSpPhase; k++) {
891 vprob->
mf[kTa] = vprob->
w[kTa] / tMoles;
896 for (
size_t k = 0; k < nSpPhase; k++) {
898 vprob->
mf[kTa]= 1.0 / (double) nSpPhase;
906 for (
size_t k = 0; k < nSpPhase; k++) {
916 vprob->
gai.resize(vprob->
ne, 0.0);
921 writeline(
'=', 80,
true,
true);
922 writeline(
'=', 16,
false);
923 plogf(
" Cantera_to_vprob: START OF PROBLEM STATEMENT ");
926 plogf(
" Phase IDs of species\n");
927 plogf(
" species phaseID phaseName ");
928 plogf(
" Initial_Estimated_kMols\n");
929 for (
size_t i = 0; i < vprob->
nspecies; i++) {
930 size_t iphase = vprob->
PhaseID[i];
933 plogf(
"%16s %5d %16s", vprob->
SpName[i].c_str(), iphase,
936 plogf(
" Volts = %-10.5g\n", vprob->
w[i]);
938 plogf(
" %-10.5g\n", vprob->
w[i]);
943 writeline(
'-', 80,
true,
true);
944 plogf(
" Information about phases\n");
945 plogf(
" PhaseName PhaseNum SingSpec GasPhase EqnState NumSpec");
946 plogf(
" TMolesInert Tmoles(kmol)\n");
948 for (
size_t iphase = 0; iphase < vprob->
NPhase; iphase++) {
950 plogf(
"%16s %5d %5d %8d %16s %8d %16e ", VolPhase->
PhaseName.c_str(),
957 writeline(
'=', 80,
true,
true);
958 writeline(
'=', 16,
false);
959 plogf(
" Cantera_to_vprob: END OF PROBLEM STATEMENT ");
969 size_t totNumPhases = mphase->
nPhases();
981 for (
size_t iphase = 0; iphase < totNumPhases; iphase++) {
994 size_t nSpPhase = tPhase->
nSpecies();
995 tmpMoles.resize(nSpPhase);
996 for (
size_t k = 0; k < nSpPhase; k++) {
1012 if ((nSpPhase == 1) && (volPhase->
phiVarIndex() == 0)) {
1029 writeline(
'=', 80,
true,
true);
1030 writeline(
'=', 20,
false);
1031 plogf(
" Cantera_to_vprob: START OF PROBLEM STATEMENT ");
1035 plogf(
" Phase IDs of species\n");
1036 plogf(
" species phaseID phaseName ");
1037 plogf(
" Initial_Estimated_kMols\n");
1038 for (
size_t i = 0; i < vprob->
nspecies; i++) {
1039 size_t iphase = vprob->
PhaseID[i];
1041 plogf(
"%16s %5d %16s", vprob->
SpName[i].c_str(), iphase,
1044 plogf(
" Volts = %-10.5g\n", vprob->
w[i]);
1046 plogf(
" %-10.5g\n", vprob->
w[i]);
1051 writeline(
'-', 80,
true,
true);
1052 plogf(
" Information about phases\n");
1053 plogf(
" PhaseName PhaseNum SingSpec GasPhase EqnState NumSpec");
1054 plogf(
" TMolesInert Tmoles(kmol)\n");
1056 for (
size_t iphase = 0; iphase < vprob->
NPhase; iphase++) {
1058 plogf(
"%16s %5d %5d %8d %16s %8d %16e ", VolPhase->
PhaseName.c_str(),
1065 writeline(
'=', 80,
true,
true);
1066 writeline(
'=', 20,
false);
1067 plogf(
" Cantera_to_vprob: END OF PROBLEM STATEMENT ");
1078 "Unused. To be removed after Cantera 2.3.");
1080 nu.resize(nsp, 0.0);
1081 for (
size_t i = 0; i < nsp; i++) {
1086 if (rxn > nsp - nc) {
1089 size_t j = indSpecies[rxn + nc];
1091 for (
size_t kc = 0; kc < nc; kc++) {
1100 "Unused. To be removed after Cantera 2.3.");
1107 "Unused. To be removed after Cantera 2.3.");
1114 "Unused. To be removed after Cantera 2.3.");
1126 "Broken and unused. To be removed after Cantera 2.3.");
1135 plogf(
"problems\n");
1143 throw CanteraError(
"vcs_MultiPhaseEquil::determine_PhaseStability",
1144 "Temperature less than zero on input");
1148 throw CanteraError(
"vcs_MultiPhaseEquil::determine_PhaseStability",
1149 "Pressure less than zero on input");
1169 plogf(
"\n Results from vcs_PS:\n");
1175 plogf(
"Phase %d named %s is stable, function value = %g > 0\n", iph, sss.c_str(), funcStab);
1177 plogf(
"Phase %d named %s is not stable + function value = %g < 0\n", iph, sss.c_str(), funcStab);
1180 plogf(
"----------------------------------------" 1181 "---------------------\n");
1182 plogf(
" Name Mole_Number(kmol)");
1183 plogf(
" Mole_Fraction Chem_Potential (J/kmol)\n");
1184 plogf(
"-------------------------------------------------------------\n");
1199 plogf(
"------------------------------------------" 1200 "-------------------\n");
1202 plogf(
"Total time = %12.6e seconds\n", te);
#define VCS_PHASE_EXIST_NO
Phase doesn't currently exist in the mixture.
bool vcs_doubleEqual(double d1, double d2)
Simple routine to check whether two doubles are equal up to roundoff error.
ThermoPhase object for the ideal molal equation of state (see Thermodynamic Properties and class Idea...
vector_fp FormulaMatrixCol
Column of the formula matrix, comprising the element composition of the species.
size_t nElements() const
Number of elements.
int m_printLvl
Print level for print routines.
virtual void reportParams(size_t index, int &type, doublereal *const c, doublereal &minTemp, doublereal &maxTemp, doublereal &refPressure) const
This utility function reports back the type of parameterization and all of the parameters for the spe...
bool m_singleSpecies
If true, this phase consists of a single species.
VCS_SPECIES_THERMO * SpeciesThermo
Pointer to the thermo structure for this species.
double totalMolesInert() const
Returns the value of the total kmol of inert in the phase.
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...
vcs_VolPhase * OwningPhase
Pointer to the owning phase object.
MultiPhase * m_mix
Pointer to the MultiPhase mixture that will be equilibrated.
size_t nPhases() const
Number of phases.
Declarations for a simple class that implements an Ansi C wall clock timer (see Cantera::clockWC).
doublereal speciesMoles(size_t kGlob) const
Returns the moles of global species k. units = kmol.
void setPhaseMoles(const size_t n, const doublereal moles)
Set the number of moles of phase with index n.
Array2D m_stoichCoeffRxnMatrix
Stoichiometric coefficient matrix for the reaction mechanism expressed in Reduced Canonical Form...
doublereal temperature() const
Temperature [K].
double SS0_Cp0
Base heat capacity used in the VCS_SS0_CONSTANT_CP model.
size_t numComponents() const
reports the number of components in the equilibration problem
#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"
virtual void getChemPotentials(doublereal *mu) const
Get the species chemical potentials. Units: J/kmol.
double Vol
Volume of the entire system.
int p_activityConvention
Convention for the activity formulation.
int iest
Specification of the initial estimate method.
void writelog(const std::string &fmt, const Args &... args)
Write a formatted message to the screen.
size_t nSpecies() const
Number of species, summed over all phases.
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...
size_t component(size_t m) const
Return the index of the ith component.
size_t IndexSpeciesPhase
Index of this species in the current phase.
friend int vcs_Cantera_update_vprob(MultiPhase *mphase, VCS_PROB *vprob)
Translate a MultiPhase information into a VCS_PROB problem definition object.
int m_printLvl
Print level from the VCSnonlinear package.
T clip(const T &value, const T &lower, const T &upper)
Clip value such that lower <= value <= upper.
#define VCS_SSVOL_IDEALGAS
Models for the standard state volume of each species.
void warn_deprecated(const std::string &method, const std::string &extra)
Print a warning indicating that method is deprecated.
size_t spGlobalIndexVCS(const size_t spIndex) const
Return the Global VCS index of the kth species in the phase.
size_t nSpecies() const
Returns the number of species in the phase.
doublereal volume() const
The total mixture volume [m^3].
size_t addOnePhaseSpecies(vcs_VolPhase *volPhase, size_t k, size_t kT)
This routines adds entries for the formula matrix for one species.
The class provides the wall clock timer in seconds.
size_t transferElementsFM(const ThermoPhase *const tPhase)
Transfer all of the element information from the ThermoPhase object to the vcs_VolPhase object...
doublereal pressure() const
Pressure [Pa].
std::string PhaseName
String name for the phase.
#define VCS_PHASE_EXIST_YES
Phase is a normal phase that currently exists.
double WtSpecies
Molecular Weight of the species (gm/mol)
virtual void getPartialMolarVolumes(doublereal *vbar) const
Return an array of partial molar volumes for the species in the mixture.
virtual void getParameters(int &n, doublereal *const c) const
Get the equation of state parameters in a vector.
virtual MultiSpeciesThermo & speciesThermo(int k=-1)
Return a changeable reference to the calculation manager for species reference-state thermodynamic pr...
std::vector< vcs_VolPhase * > VPhaseList
Array of phase structures.
int m_Iterations
Number of iterations. This is an output variable.
void setExistence(const int existence)
Set the existence flag in the object.
void reportCSV(const std::string &reportFile)
Report the equilibrium answer in a comma separated table format.
int vcs_Cantera_update_vprob(MultiPhase *mphase, VCS_PROB *vprob)
Translate a MultiPhase information into a VCS_PROB problem definition object.
const doublereal Undef
Fairly random number to be used to initialize variables against to see if they are subsequently defin...
void setPtrThermoPhase(ThermoPhase *tp_ptr)
Set the pointer for Cantera's ThermoPhase parameter.
std::vector< size_t > PhaseID
Mapping between the species and the phases.
virtual void getActivities(doublereal *a) const
Get the array of non-dimensional activities at the current solution temperature, pressure, and solution concentration.
Base class for a phase with thermodynamic properties.
size_t VP_ID_
Original ID of the phase in the problem.
int vcs_Cantera_to_vprob(MultiPhase *mphase, VCS_PROB *vprob)
Translate a MultiPhase object into a VCS_PROB problem definition object.
void setMolesFromVCS(const int stateCalc, const double *molesSpeciesVCS=0)
Set the moles within the phase.
Contains const definitions for types of species reference-state thermodynamics managers (see Species ...
Header for the object representing each phase within vcs.
virtual int reportType(size_t index) const
This utility function reports the type of parameterization used for the species with index number ind...
#define VCS_SPECIES_TYPE_MOLNUM
Unknown refers to mole number of a single species.
size_t numElemConstraints() const
Reports the number of element constraints in the equilibration problem.
double SSStar_Vol0
parameter that is used in the VCS_SSVOL_CONSTANT model.
void uploadMoleFractionsFromPhases()
Update the locally-stored composition within this object to match the current compositions of the pha...
A class for multiphase mixtures.
vector_fp gai
Element abundances for jth element.
int SSStar_Vol_Model
Models for the standard state volume of each species.
std::string SpName
Name of the species.
void addPhaseElements(vcs_VolPhase *volPhase)
Add elements to the local element list.
Array2D FormulaMatrix
Formula Matrix for the problem.
double SS0_S0
Base entropy used in the VCS_SS0_CONSTANT_CP model.
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...
std::vector< size_t > m_speciesMapIndex
Index vector that keeps track of the species vector rearrangement.
void getMolalities(doublereal *const molal) const
This function will return the molalities of the species.
doublereal moleFraction(const size_t kGlob) const
Returns the mole fraction of global species k.
double secondsWC()
Returns the wall clock time in seconds since the last reset.
std::string speciesName(size_t k) const
Name of the species with index k.
size_t IndexPhase
Index of the phase that this species belongs to.
std::string eos_name() const
Return the name corresponding to the equation of state.
Properties of a single species.
vector_int SpeciesUnknownType
Specifies the species unknown type.
size_t m_numElemConstraints
Number of element constraints in the problem.
int m_eqnState
Type of the equation of state.
doublereal electricPotential() const
Returns the electric potential of this phase (V).
Header file for an ideal solid solution model with incompressible thermodynamics (see Thermodynamic P...
size_t m_numSpeciesTot
Total number of species in the problems.
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...
vector_fp Charge
Charge of each species.
double SS0_H0
Base enthalpy used in the VCS_SS0_CONSTANT_CP model.
doublereal maxTemp() const
Maximum temperature for which all solution phases have valid thermo data.
virtual int activityConvention() const
This method returns the convention used in specification of the activities, of which there are curren...
void setElectricPotential(const double phi)
set the electric potential of the phase
size_t nspecies
Total number of species in the problems.
void setTemperature(const doublereal T)
Set the temperature [K].
vector_fp w
Total number of moles of the kth species.
size_t nSpecies() const
Return the number of species in the phase.
Base class for exceptions thrown by Cantera classes.
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...
void getChemPotentials(doublereal *mu) const
Returns a vector of Chemical potentials.
int vcs(VCS_PROB *vprob, int ifunc, int ipr, int ip1, int maxit)
Solve an equilibrium problem.
#define SIMPLE
Constant Cp thermo.
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...
int m_timing_print_lvl
printing level of timing information
size_t m_numComponents
Number of components calculated for the problem.
void prob_report(int print_lvl)
Print out the problem specification in all generality as it currently exists in the VCS_PROB object...
bool m_gasPhase
If true, this phase is a gas-phase like phase.
void getStoichVector(size_t rxn, vector_fp &nu)
Get the stoichiometric reaction coefficients for a single reaction index.
virtual void getActivityCoefficients(doublereal *ac) const
Get the array of non-dimensional molar-based activity coefficients at the current solution temperatur...
double totalMoles() const
Return the total moles in the phase.
vector_fp WtSpecies
Molecular weight of species.
void setPressure(doublereal P)
Set the pressure [Pa].
vector_fp mf
Mole fraction vector.
int determine_PhaseStability(int iph, double &funcStab, int printLvl=0, int logLevel=-99)
Determine the phase stability of a phase at the current conditions.
size_t phiVarIndex() const
Return the index of the species that represents the the voltage of the phase.
int m_NumBasisOptimizations
Number of basis optimizations used. This is an output variable.
Interface class for the vcsnonlinear solver.
Phase information and Phase calculations for vcs.
size_t ne
Number of element constraints in the equilibrium problem.
vector_fp m_gibbsSpecies
Vector of chemical potentials of the species.
int prob_type
Problem type.
virtual std::string type() const
String indicating the thermodynamic model implemented.
VCS_SOLVE m_vsolve
The object that does all of the equilibration work.
doublereal entropy() const
The entropy of the mixture [J/K].
std::vector< VCS_SPECIES_THERMO * > SpeciesThermo
Vector of pointers to thermo structures which identify the model and parameters for evaluating the th...
int vcs_PS(VCS_PROB *vprob, int iph, int printLvl, double &feStable)
#define VCS_STATECALC_OLD
State Calculation based on the old or base mole numbers.
#define plogendl()
define this Cantera function to replace cout << endl;
double SS0_T0
Base temperature used in the VCS_SS0_CONSTANT_CP model.
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
int SSStar_Model
Integer value representing the star state model.
std::vector< std::string > SpName
Vector of strings containing the species names.
int SS0_Model
Integer representing the models for the species standard state Naught temperature dependence...
double VolPM
Partial molar volume of the species.
doublereal minTemp() const
Minimum temperature for which all solution phases have valid thermo data.
VCS_PROB m_vprob
Object which contains the problem statement.
doublereal IntEnergy() const
The internal energy of the mixture [J].
vcs_SpeciesProperties * speciesProperty(const size_t kindex)
Retrieve the kth Species structure for the species belonging to this phase.
const doublereal GasConstant
Universal Gas Constant. [J/kmol/K].
int SurfaceSpecies
True if this species belongs to a surface phase.
std::string name() const
Return the name of the phase.
friend int vcs_Cantera_to_vprob(MultiPhase *mphase, VCS_PROB *vprob)
Translate a MultiPhase object into a VCS_PROB problem definition object.
Contains declarations for string manipulation functions within Cantera.
double T
Temperature (Kelvin)
double Charge
Charge state of the species -> This may be duplication of what's in the FormulaMatrixCol entries...
virtual void getStandardChemPotentials(doublereal *mu) const
Get the array of chemical potentials at unit activity for the species at their standard states at the...
#define plogf
define this Cantera function to replace printf
std::string phaseName(const size_t iph) const
Returns the name of the n'th phase.
#define VCS_SPECIES_TYPE_INTERFACIALVOLTAGE
Unknown refers to the voltage level of a phase.
void set_gai()
Calculate the element abundance vector from the mole numbers.
thermo_t & phase(size_t n)
Return a reference to phase n.
A species thermodynamic property manager for a phase.
doublereal molecularWeight(size_t k) const
Molecular weight of species k.
doublereal phaseMoles(const size_t n) const
Return the number of moles in phase n.
size_t NPhase
Number of phases in the problem.
Namespace for the Cantera kernel.
Interface class for the vcs thermo equilibrium solver package, which generally describes the problem ...
void setState_TP(const double temperature_Kelvin, const double pressure_PA)
Sets the temperature and pressure in this object and underlying ThermoPhase objects.
doublereal charge(size_t k) const
Dimensionless electrical charge of a single molecule of species k The charge is normalized by the the...
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...
int speciesUnknownType(const size_t k) const
Returns the type of the species unknown.
double SS0_TSave
Internal storage of the last temperature used in the calculation of the reference naught Gibbs free e...
doublereal enthalpy() const
The enthalpy of the mixture [J].
double SS0_feSave
Internal storage of the last calculation of the reference naught Gibbs free energy at SS0_TSave...
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.
void setTotalMoles(const double totalMols)
Sets the total moles in the phase.
std::string speciesName(const size_t kGlob) const
Name of species with global index kGlob.