27 vcs_MultiPhaseEquil::vcs_MultiPhaseEquil() :
34 vcs_MultiPhaseEquil::vcs_MultiPhaseEquil(
MultiPhase* mix,
int printLvl) :
35 m_vprob(mix->nSpecies(), mix->nElements(), mix->nPhases()),
53 int printLvl, doublereal err,
54 int maxsteps,
int loglevel)
57 if ((XY != TV) && (XY != HV) && (XY != UV) && (XY != SV)) {
58 throw CanteraError(
"vcs_MultiPhaseEquil::equilibrate_TV",
59 "Wrong XY flag:" +
int2str(XY));
66 int strt = estimateEquil;
73 doublereal Vnow, Verr;
74 int printLvlSub = std::max(0, printLvl - 1);
75 for (
int n = 0; n < maxiter; n++) {
80 iSuccess =
equilibrate_TP(strt, printLvlSub, err, maxsteps, loglevel);
84 printLvlSub, err, maxsteps, loglevel);
88 printLvlSub, err, maxsteps, loglevel);
92 printLvlSub, err, maxsteps, loglevel);
112 Verr = fabs((Vtarget - Vnow)/Vtarget);
120 double dVdP = (V2 - V1) / (P2 - P1);
125 Pnew = Pnow + (Vtarget - Vnow) / dVdP;
126 if (Pnew < 0.2 * Pnow) {
129 if (Pnew > 3.0 * Pnow) {
136 double dVdP = (
m_mix->
volume() - Vnow)/(0.01*Pnow);
137 Pnew = Pnow + 0.5*(Vtarget - Vnow)/dVdP;
138 if (Pnew < 0.5* Pnow) {
141 if (Pnew > 1.7 * Pnow) {
149 "No convergence for V");
157 int XY,
double Tlow,
double Thigh,
159 int printLvl, doublereal err,
160 int maxsteps,
int loglevel)
164 if (XY != HP && XY != UP) {
165 throw CanteraError(
"vcs_MultiPhaseEquil::equilibrate_HP",
168 int strt = estimateEquil;
175 if (Thigh <= 0.0 || Thigh > 1.0E6) {
179 doublereal cpb = 1.0, Tnew;
180 doublereal Hlow =
Undef;
181 doublereal Hhigh =
Undef;
183 int printLvlSub = std::max(printLvl - 1, 0);
185 for (
int n = 0; n < maxiter; n++) {
190 iSuccess =
equilibrate_TP(strt, printLvlSub, err, maxsteps, loglevel);
195 double Tmoles = pmoles[0];
196 double HperMole = Hnow/Tmoles;
198 plogf(
"T = %g, Hnow = %g ,Tmoles = %g, HperMole = %g",
199 Tnow, Hnow, Tmoles, HperMole);
208 if (Hnow < Htarget) {
222 double dT, dTa, dTmax, Tnew;
224 cpb = (Hhigh - Hlow)/(Thigh - Tlow);
225 dT = (Htarget - Hnow)/cpb;
227 dTmax = 0.5*fabs(Thigh - Tlow);
232 Tnew = sqrt(Tlow*Thigh);
233 dT =
clip(Tnew - Tnow, -200.0, 200.0);
235 double acpb = std::max(fabs(cpb), 1.0E-6);
236 double denom = std::max(fabs(Htarget), acpb);
237 double Herr = Htarget - Hnow;
238 double HConvErr = fabs((Herr)/denom);
240 plogf(
" equilibrate_HP: It = %d, Tcurr = %g Hcurr = %g, Htarget = %g\n",
241 n, Tnow, Hnow, Htarget);
242 plogf(
" H rel error = %g, cp = %g, HConvErr = %g\n",
243 Herr, cpb, HConvErr);
246 if (HConvErr < err) {
248 plogf(
" equilibrate_HP: CONVERGENCE: Hfinal = %g Tfinal = %g, Its = %d \n",
250 plogf(
" H rel error = %g, cp = %g, HConvErr = %g\n",
251 Herr, cpb, HConvErr);
262 if (!estimateEquil) {
265 Tnew = 0.5*(Tnow + Thigh);
266 if (fabs(Tnew - Tnow) < 1.0) {
275 "No convergence for T");
282 double Tlow,
double Thigh,
284 int printLvl, doublereal err,
285 int maxsteps,
int loglevel)
288 int strt = estimateEquil;
295 if (Thigh <= 0.0 || Thigh > 1.0E6) {
299 doublereal cpb = 1.0, dT, dTa, dTmax, Tnew;
300 doublereal Slow =
Undef;
301 doublereal Shigh =
Undef;
303 Tlow = std::min(Tnow, Tlow);
304 Thigh = std::max(Tnow, Thigh);
305 int printLvlSub = std::max(printLvl - 1, 0);
307 for (
int n = 0; n < maxiter; n++) {
313 int iSuccess =
equilibrate_TP(strt, printLvlSub, err, maxsteps, loglevel);
318 double Tmoles = pmoles[0];
319 double SperMole = Snow/Tmoles;
320 plogf(
"T = %g, Snow = %g ,Tmoles = %g, SperMole = %g\n",
321 Tnow, Snow, Tmoles, SperMole);
327 if (Snow < Starget) {
332 if (Slow > Starget) {
351 cpb = (Shigh - Slow)/(Thigh - Tlow);
352 dT = (Starget - Snow)/cpb;
355 dTmax = 0.5*fabs(Thigh - Tlow);
356 if (Tnew > Thigh || Tnew < Tlow) {
357 dTmax = 1.5*fabs(Thigh - Tlow);
359 dTmax = std::min(dTmax, 300.);
364 Tnew = sqrt(Tlow*Thigh);
368 double acpb = std::max(fabs(cpb), 1.0E-6);
369 double denom = std::max(fabs(Starget), acpb);
370 double Serr = Starget - Snow;
371 double SConvErr = fabs((Serr)/denom);
373 plogf(
" equilibrate_SP: It = %d, Tcurr = %g Scurr = %g, Starget = %g\n",
374 n, Tnow, Snow, Starget);
375 plogf(
" S rel error = %g, cp = %g, SConvErr = %g\n",
376 Serr, cpb, SConvErr);
379 if (SConvErr < err) {
381 plogf(
" equilibrate_SP: CONVERGENCE: Sfinal = %g Tfinal = %g, Its = %d \n",
383 plogf(
" S rel error = %g, cp = %g, HConvErr = %g\n",
384 Serr, cpb, SConvErr);
395 if (!estimateEquil) {
398 Tnew = 0.5*(Tnow + Thigh);
399 if (fabs(Tnew - Tnow) < 1.0) {
408 "No convergence for T");
412 int printLvl, doublereal err,
413 int maxsteps,
int loglevel)
417 return equilibrate_TP(estimateEquil, printLvl, err, maxsteps, loglevel);
418 }
else if (XY == HP || XY == UP) {
427 estimateEquil, printLvl, err, maxsteps, loglevel);
428 }
else if (XY == SP) {
433 estimateEquil, printLvl, err, maxsteps, loglevel);
434 }
else if (XY == TV) {
437 estimateEquil, printLvl, err, maxsteps, loglevel);
438 }
else if (XY == HV) {
441 estimateEquil, printLvl, err, maxsteps, loglevel);
442 }
else if (XY == UV) {
445 estimateEquil, printLvl, err, maxsteps, loglevel);
446 }
else if (XY == SV) {
449 printLvl, err, maxsteps, loglevel);
452 "Unsupported Option");
457 int printLvl, doublereal err,
458 int maxsteps,
int loglevel)
460 int maxit = maxsteps;
491 "Temperature less than zero on input");
496 "Pressure less than zero on input");
528 double phaseMole = 0.0;
530 for (
size_t k = 0; k < tref.
nSpecies(); k++, kGlob++) {
538 plogf(
"\n Results from vcs:\n");
540 plogf(
"\nVCS FAILED TO CONVERGE!\n");
546 plogf(
"----------------------------------------"
547 "---------------------\n");
548 plogf(
" Name Mole_Number");
554 plogf(
" Mole_Fraction Chem_Potential");
556 plogf(
" (kcal/mol)\n");
558 plogf(
" (Dimensionless)\n");
560 plogf(
" (kJ/mol)\n");
562 plogf(
" (Kelvin)\n");
564 plogf(
" (J/kmol)\n");
566 plogf(
"--------------------------------------------------"
579 plogf(
" -1.000e+300\n");
588 plogf(
"------------------------------------------"
589 "-------------------\n");
592 plogf(
"Total time = %12.6e seconds\n", te);
604 FILE* FP = fopen(reportFile.c_str(),
"w");
607 "Failure to open file");
615 std::vector<double> VolPM;
616 std::vector<double> activity;
617 std::vector<double> ac;
618 std::vector<double> mu;
619 std::vector<double> mu0;
620 std::vector<double> molalities;
623 for (
size_t iphase = 0; iphase < nphase; iphase++) {
627 VolPM.resize(nSpecies, 0.0);
632 double VolPhaseVolumes = 0.0;
633 for (
size_t k = 0; k < nSpecies; k++) {
634 VolPhaseVolumes += VolPM[k] * mf[istart + k];
636 VolPhaseVolumes *= TMolesPhase;
637 vol += VolPhaseVolumes;
640 fprintf(FP,
"--------------------- VCS_MULTIPHASE_EQUIL FINAL REPORT"
641 " -----------------------------\n");
642 fprintf(FP,
"Temperature = %11.5g kelvin\n", Temp);
643 fprintf(FP,
"Pressure = %11.5g Pascal\n", pres);
644 fprintf(FP,
"Total Volume = %11.5g m**3\n", vol);
648 for (
size_t iphase = 0; iphase < nphase; iphase++) {
651 string phaseName = tref.
name();
656 activity.resize(nSpecies, 0.0);
657 ac.resize(nSpecies, 0.0);
659 mu0.resize(nSpecies, 0.0);
660 mu.resize(nSpecies, 0.0);
661 VolPM.resize(nSpecies, 0.0);
662 molalities.resize(nSpecies, 0.0);
671 double VolPhaseVolumes = 0.0;
672 for (
size_t k = 0; k < nSpecies; k++) {
673 VolPhaseVolumes += VolPM[k] * mf[istart + k];
675 VolPhaseVolumes *= TMolesPhase;
676 vol += VolPhaseVolumes;
679 if (actConvention == 1) {
685 fprintf(FP,
" Name, Phase, PhaseMoles, Mole_Fract, "
686 "Molalities, ActCoeff, Activity,"
687 "ChemPot_SS0, ChemPot, mole_num, PMVol, Phase_Volume\n");
689 fprintf(FP,
" , , (kmol), , "
691 " (J/kmol), (J/kmol), (kmol), (m**3/kmol), (m**3)\n");
693 for (
size_t k = 0; k < nSpecies; k++) {
695 fprintf(FP,
"%12s, %11s, %11.3e, %11.3e, %11.3e, %11.3e, %11.3e,"
696 "%11.3e, %11.3e, %11.3e, %11.3e, %11.3e\n",
698 phaseName.c_str(), TMolesPhase,
699 mf[istart + k], molalities[k], ac[k], activity[k],
700 mu0[k]*1.0E-6, mu[k]*1.0E-6,
701 mf[istart + k] * TMolesPhase,
702 VolPM[k], VolPhaseVolumes);
707 fprintf(FP,
" Name, Phase, PhaseMoles, Mole_Fract, "
708 "Molalities, ActCoeff, Activity,"
709 " ChemPotSS0, ChemPot, mole_num, PMVol, Phase_Volume\n");
711 fprintf(FP,
" , , (kmol), , "
713 " (J/kmol), (J/kmol), (kmol), (m**3/kmol), (m**3)\n");
715 for (
size_t k = 0; k < nSpecies; k++) {
718 for (
size_t k = 0; k < nSpecies; k++) {
720 fprintf(FP,
"%12s, %11s, %11.3e, %11.3e, %11.3e, %11.3e, %11.3e, "
721 "%11.3e, %11.3e,% 11.3e, %11.3e, %11.3e\n",
723 phaseName.c_str(), TMolesPhase,
724 mf[istart + k], molalities[k], ac[k],
725 activity[k], mu0[k]*1.0E-6, mu[k]*1.0E-6,
726 mf[istart + k] * TMolesPhase,
727 VolPM[k], VolPhaseVolumes);
736 for (
size_t k = 0; k < nSpecies; k++) {
738 fprintf(FP,
"ERROR: incompatibility!\n");
740 throw CanteraError(
"vcs_MultiPhaseEquil::reportCSV",
"incompatibility!");
760 size_t totNumPhases = mphase->
nPhases();
761 size_t totNumSpecies = mphase->
nSpecies();
767 vprob->
NPhase = totNumPhases;
775 vprob->Title =
"MultiPhase Object";
783 for (
size_t iphase = 0; iphase < totNumPhases; iphase++) {
801 size_t nSpPhase = tPhase->
nSpecies();
805 string phaseName = tPhase->
name();
818 VolPhase->
resize(iphase, nSpPhase, nelem, phaseName.c_str(), 0.0);
844 case cIncompressible:
848 throw CanteraError(
"VCSnonideal",
"cSurf not handled yet.");
849 case cStoichSubstance:
854 plogf(
"cPureFluid not recognized yet by VCSnonideal\n");
858 throw CanteraError(
"VCSnonideal",
"cEdge not handled yet.");
859 case cIdealSolidSolnPhase0:
860 case cIdealSolidSolnPhase1:
861 case cIdealSolidSolnPhase2:
866 plogf(
"Unknown Cantera EOS to VCSnonideal: %d\n", eos);
871 "vcs functions asked for, but unimplemented");
895 vector<double> muPhase(tPhase->
nSpecies(),0.0);
901 for (
size_t k = 0; k < nSpPhase; k++) {
935 tMoles += vprob->
w[kT];
967 sProp->NumElements = vprob->
ne;
969 sProp->SpeciesThermo = ts_ptr;
972 for (
size_t e = 0; e < vprob->
ne; e++) {
975 sProp->Charge = tPhase->
charge(k);
976 sProp->SurfaceSpecies =
false;
1000 double minTemp, maxTemp, refPressure;
1001 sp.
reportParams(k, spType, c, minTemp, maxTemp, refPressure);
1016 plogf(
"vcs_Cantera_convert: Species Type %d not known \n",
1023 "Cantera calls not being used -> aborting");
1035 std::vector<double> phaseTermCoeff(nSpPhase, 0.0);
1050 for (
size_t k = 0; k < nSpPhase; k++) {
1052 vprob->
mf[kTa] = vprob->
w[kTa] / tMoles;
1059 for (
size_t k = 0; k < nSpPhase; k++) {
1061 vprob->
mf[kTa]= 1.0 / (double) nSpPhase;
1071 for (
size_t k = 0; k < nSpPhase; k++) {
1073 ts_ptr = sProp->SpeciesThermo;
1085 vprob->
gai.resize(vprob->
ne, 0.0);
1092 writeline(
'=', 80,
true,
true);
1093 writeline(
'=', 16,
false);
1094 plogf(
" Cantera_to_vprob: START OF PROBLEM STATEMENT ");
1097 plogf(
" Phase IDs of species\n");
1098 plogf(
" species phaseID phaseName ");
1099 plogf(
" Initial_Estimated_kMols\n");
1100 for (
size_t i = 0; i < vprob->
nspecies; i++) {
1101 size_t iphase = vprob->
PhaseID[i];
1104 plogf(
"%16s %5d %16s", vprob->
SpName[i].c_str(), iphase,
1107 plogf(
" Volts = %-10.5g\n", vprob->
w[i]);
1109 plogf(
" %-10.5g\n", vprob->
w[i]);
1116 writeline(
'-', 80,
true,
true);
1117 plogf(
" Information about phases\n");
1118 plogf(
" PhaseName PhaseNum SingSpec GasPhase EqnState NumSpec");
1119 plogf(
" TMolesInert Tmoles(kmol)\n");
1121 for (
size_t iphase = 0; iphase < vprob->
NPhase; iphase++) {
1124 plogf(
"%16s %5d %5d %8d %16s %8d %16e ", VolPhase->
PhaseName.c_str(),
1131 writeline(
'=', 80,
true,
true);
1132 writeline(
'=', 16,
false);
1133 plogf(
" Cantera_to_vprob: END OF PROBLEM STATEMENT ");
1144 size_t totNumPhases = mphase->
nPhases();
1146 std::vector<double> tmpMoles;
1156 for (
size_t iphase = 0; iphase < totNumPhases; iphase++) {
1166 vector<double> muPhase(tPhase->
nSpecies(),0.0);
1171 size_t nSpPhase = tPhase->
nSpecies();
1173 tmpMoles.resize(nSpPhase);
1174 for (
size_t k = 0; k < nSpPhase; k++) {
1192 if ((nSpPhase == 1) && (volPhase->
phiVarIndex() == 0)) {
1214 writeline(
'=', 80,
true,
true);
1215 writeline(
'=', 20,
false);
1216 plogf(
" Cantera_to_vprob: START OF PROBLEM STATEMENT ");
1220 plogf(
" Phase IDs of species\n");
1221 plogf(
" species phaseID phaseName ");
1222 plogf(
" Initial_Estimated_kMols\n");
1223 for (
size_t i = 0; i < vprob->
nspecies; i++) {
1224 size_t iphase = vprob->
PhaseID[i];
1227 plogf(
"%16s %5d %16s", vprob->
SpName[i].c_str(), iphase,
1230 plogf(
" Volts = %-10.5g\n", vprob->
w[i]);
1232 plogf(
" %-10.5g\n", vprob->
w[i]);
1239 writeline(
'-', 80,
true,
true);
1240 plogf(
" Information about phases\n");
1241 plogf(
" PhaseName PhaseNum SingSpec GasPhase EqnState NumSpec");
1242 plogf(
" TMolesInert Tmoles(kmol)\n");
1244 for (
size_t iphase = 0; iphase < vprob->
NPhase; iphase++) {
1247 plogf(
"%16s %5d %5d %8d %16s %8d %16e ", VolPhase->
PhaseName.c_str(),
1254 writeline(
'=', 80,
true,
true);
1255 writeline(
'=', 20,
false);
1256 plogf(
" Cantera_to_vprob: END OF PROBLEM STATEMENT ");
1268 nu.resize(nsp, 0.0);
1269 for (
size_t i = 0; i < nsp; i++) {
1274 if (rxn > nsp - nc) {
1277 size_t j = indSpecies[rxn + nc];
1279 for (
size_t kc = 0; kc < nc; kc++) {
1319 plogf(
"problems\n");
1329 throw CanteraError(
"vcs_MultiPhaseEquil::determine_PhaseStability",
1330 "Temperature less than zero on input");
1334 throw CanteraError(
"vcs_MultiPhaseEquil::determine_PhaseStability",
1335 "Pressure less than zero on input");
1362 plogf(
"\n Results from vcs_PS:\n");
1369 plogf(
"Phase %d named %s is stable, function value = %g > 0\n", iph, sss.c_str(), funcStab);
1371 plogf(
"Phase %d named %s is not stable + function value = %g < 0\n", iph, sss.c_str(), funcStab);
1374 plogf(
"----------------------------------------"
1375 "---------------------\n");
1376 plogf(
" Name Mole_Number");
1382 plogf(
" Mole_Fraction Chem_Potential");
1384 plogf(
" (kcal/mol)\n");
1386 plogf(
" (Dimensionless)\n");
1388 plogf(
" (kJ/mol)\n");
1390 plogf(
" (Kelvin)\n");
1392 plogf(
" (J/kmol)\n");
1394 plogf(
"-------------------------------------------------------------\n");
1409 plogf(
"------------------------------------------"
1410 "-------------------\n");
1413 plogf(
"Total time = %12.6e seconds\n", te);
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.
std::vector< double > WtSpecies
Molecular weight of species.
#define VCS_PHASE_EXIST_NO
Phase doesn't currently exist in the mixture.
doublereal molecularWeight(size_t k) const
Molecular weight of species k.
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...
std::string int2str(const int n, const std::string &fmt)
Convert an int to a string using a format converter.
doublereal electricPotential() const
Returns the electric potential of this phase (V).
int m_printLvl
Print level for print routines.
bool m_singleSpecies
If true, this phase consists of a single species.
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.
size_t nElements() const
Number of elements.
MultiPhase * m_mix
Pointer to the MultiPhase mixture that will be equilibrated.
double totalMolesInert() const
returns the value of the total kmol of inert in the phase
virtual void getParameters(int &n, doublereal *const c) const
Get the equation of state parameters in a vector.
Declarations for a simple class that implements an Ansi C wall clock timer (see Cantera::clockWC).
int p_VCS_UnitsFormat
Units for the chemical potential data, pressure data, volume, and species amounts.
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 speciesMoles(size_t kGlob) const
Returns the moles of global species k. units = kmol.
double SS0_Cp0
Base heat capacity used in the VCS_SS0_CONSTANT_CP model.
#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 numComponents() const
reports the number of components in the equilibration problem
std::vector< int > SpeciesUnknownType
Specifies the species unknown type.
#define VCS_DATA_PTR(vvv)
Points to the data in a std::vector<> object.
double Vol
Volume of the entire system.
int p_activityConvention
Convention for the activity formulation.
int iest
Specification of the initial estimate method.
doublereal phaseMoles(const size_t n) const
Return the number of moles in phase n.
std::vector< double > w
Total number of moles of the kth species.
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...
int speciesUnknownType(const size_t k) const
Returns the type of the species unknown.
doublereal temperature() const
Temperature [K].
size_t IndexSpeciesPhase
Index of this species in the current phase.
size_t nSpecies() const
Return the number of species in the 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.
double vcsUtil_gasConstant(int mu_units)
Returns the value of the gas constant in the units specified by parameter.
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...
virtual void getStandardChemPotentials(doublereal *mu) const
Get the array of chemical potentials at unit activity for the species at their standard states at the...
std::string PhaseName
String name for the phase.
virtual void getPartialMolarVolumes(doublereal *vbar) const
Return an array of partial molar volumes for the species in the mixture.
#define VCS_PHASE_EXIST_YES
Phase is a normal phase that currently exists.
double totalMoles() const
Return the total moles in the phase.
std::string name() const
Return the name of the phase.
Pure Virtual base class for the species thermo manager classes.
void getChemPotentials(doublereal *mu) const
Returns a vector of Chemical potentials.
std::vector< vcs_VolPhase * > VPhaseList
Array of phase structures.
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 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.
Base class for a phase with thermodynamic properties.
const int cSurf
A surface phase. Used by class SurfPhase.
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.
#define VCS_SPECIES_TYPE_MOLNUM
Unknown refers to mole number of a single species.
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...
size_t phiVarIndex() const
Return the index of the species that represents the the voltage of the phase.
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.
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.
doublereal entropy() const
The entropy of the mixture [J/K].
int m_VCS_UnitsFormat
Units for the chemical potential data, pressure data, volume, and species amounts.
double secondsWC()
Returns the wall clock time in seconds since the last reset.
size_t IndexPhase
Index of the phase that this species belongs to.
size_t numElemConstraints() const
Reports the number of element constraints in the equilibration problem.
size_t component(size_t m) const
Return the index of the ith component.
Properties of a single species.
virtual void getChemPotentials(doublereal *mu) const
Get the species chemical potentials. Units: J/kmol.
*std::vector< double > FormulaMatrixCol
Column of the formula matrix, comprising the element composition of the species.
size_t m_numElemConstraints
Number of element constraints in the problem.
int m_eqnState
Type of the equation of state.
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.
double SS0_H0
Base enthalpy used in the VCS_SS0_CONSTANT_CP model.
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].
std::vector< double > mf
Mole fraction vector.
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...
int vcs(VCS_PROB *vprob, int ifunc, int ipr, int ip1, int maxit)
Solve an equilibrium problem.
#define SIMPLE
Constant Cp thermo.
doublereal IntEnergy() const
The internal energy of the mixture [J].
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
const int cEdge
An edge between two 2D surfaces.
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.
void setPressure(doublereal P)
Set the pressure [Pa].
std::string string16_EOSType(int EOSType)
Return a string representing the equation of state.
doublereal moleFraction(const size_t kGlob) const
Returns the mole fraction of global species k.
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::vector< double > Charge
Charge of each species.
int m_NumBasisOptimizations
Number of basis optimizations used. This is an output variable.
size_t nSpecies() const
Returns the number of species in the phase.
Interface class for the vcsnonlinear solver.
Phase information and Phase calculations for vcs.
size_t ne
Number of element constraints in the equilibrium problem.
int prob_type
Problem type. I.e., the identity of what is held constant.
VCS_SOLVE m_vsolve
The object that does all of the equilibration work.
std::vector< VCS_SPECIES_THERMO * > SpeciesThermo
Vector of pointers to thermo structures which identify the model and parameters for evaluating the th...
#define VCS_STATECALC_OLD
State Calculation based on the old or base mole numbers.
std::vector< double > gai
Element abundances for jth element.
#define plogendl()
define this Cantera function to replace cout << endl;
double SS0_T0
Base temperature used in the VCS_SS0_CONSTANT_CP model.
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.
int SSStar_Model
Integer value representing the star state model.
std::vector< std::string > SpName
Vector of strings containing the species names.
doublereal maxTemp() const
Maximum temperature for which all solution phases have valid thermo data.
virtual int eosType() const
Equation of state type flag.
int SS0_Model
Integer representing the models for the species standard state Naught temperature dependence...
VCS_PROB m_vprob
Object which contains the problem statement.
std::string phaseName(const size_t iph) const
Returns the name of the n'th phase.
vcs_SpeciesProperties * speciesProperty(const size_t kindex)
Retrieve the kth Species structure for the species belonging to this phase.
virtual void getActivityCoefficients(doublereal *ac) const
Get the array of non-dimensional molar-based activity coefficients at the current solution temperatur...
friend int vcs_Cantera_to_vprob(MultiPhase *mphase, VCS_PROB *vprob)
Translate a MultiPhase object into a VCS_PROB problem definition object.
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...
std::vector< double > m_gibbsSpecies
Vector of chemical potentials of the species.
Contains declarations for string manipulation functions within Cantera.
double T
Temperature (Kelvin)
#define DATA_PTR(vec)
Creates a pointer to the start of the raw data for a vector.
#define plogf
define this Cantera function to replace printf
bool UseCanteraCalls
If true, this object will call Cantera to do its member calculations.
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 set_gai()
Calculate the element abundance vector from the mole numbers.
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 NPhase
Number of phases in the problem.
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...
size_t spGlobalIndexVCS(const size_t spIndex) const
Return the Global VCS index of the kth species in the phase.
bool usingCanteraCalls() const
Returns whether the object is using cantera calls.
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.
const int cIdealGas
Equation of state types:
std::string speciesName(size_t k) const
Name of the species with index k.
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...
doublereal volume() const
The total mixture volume [m^3].
double SS0_TSave
Internal storage of the last temperature used in the calculation of the reference naught Gibbs free e...
double SS0_feSave
Internal storage of the last calculation of the reference naught Gibbs free energy at SS0_TSave...
void setTotalMoles(const double totalMols)
Sets the total moles in the phase.
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.