Cantera  2.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
vcs_prob.cpp
Go to the documentation of this file.
1 /**
2  * @file vcs_prob.cpp
3  * Implementation for the Interface class for the vcs thermo
4  * equilibrium solver package,
5  */
6 /*
7  * Copyright (2005) Sandia Corporation. Under the terms of
8  * Contract DE-AC04-94AL85000 with Sandia Corporation, the
9  * U.S. Government retains certain rights in this software.
10  */
11 
12 #include "cantera/equil/vcs_prob.h"
16 #include "cantera/equil/vcs_defs.h"
18 
19 #include <cstdio>
20 
21 using namespace std;
22 
23 namespace Cantera
24 {
25 
26 VCS_PROB::VCS_PROB(size_t nsp, size_t nel, size_t nph) :
27  prob_type(VCS_PROBTYPE_TP),
28  nspecies(nsp),
29  NSPECIES0(0),
30  ne(nel),
31  NE0(0),
32  NPhase(nph),
33  NPHASE0(0),
34  T(298.15),
35  PresPA(1.0),
36  Vol(0.0),
37  m_VCS_UnitsFormat(VCS_UNITS_UNITLESS),
38 /* Set the units for the chemical potential data to be
39  * unitless */
40  iest(-1), /* The default is to not expect an initial estimate
41  * of the species concentrations */
42  tolmaj(1.0E-8),
43  tolmin(1.0E-6),
44  m_Iterations(0),
45  m_NumBasisOptimizations(0),
46  m_printLvl(0),
47  vcs_debug_print_lvl(0)
48 {
50  if (nspecies <= 0) {
51  throw CanteraError("VCS_PROB::VCS_PROB",
52  "number of species is zero or neg");
53  }
54  NE0 = ne;
55  if (ne <= 0) {
56  throw CanteraError("VCS_PROB::VCS_PROB",
57  "number of elements is zero or neg");
58  }
59  NPHASE0 = NPhase;
60  if (NPhase <= 0) {
61  throw CanteraError("VCS_PROB::VCS_PROB",
62  "number of phases is zero or neg");
63  }
64  if (nspecies < NPhase) {
65  throw CanteraError("VCS_PROB::VCS_PROB",
66  "number of species is less than number of phases");
67  }
68 
69  m_gibbsSpecies.resize(nspecies, 0.0);
70  w.resize(nspecies, 0.0);
71  mf.resize(nspecies, 0.0);
72  gai.resize(ne, 0.0);
75  VolPM.resize(nspecies, 0.0);
76  PhaseID.resize(nspecies, npos);
77  SpName.resize(nspecies, "");
78  ElName.resize(ne, "");
80  ElActive.resize(ne, 1);
81  WtSpecies.resize(nspecies, 0.0);
82  Charge.resize(nspecies, 0.0);
83  SpeciesThermo.resize(nspecies,0);
84  for (size_t kspec = 0; kspec < nspecies; kspec++) {
85  VCS_SPECIES_THERMO* ts_tmp = new VCS_SPECIES_THERMO(0, 0);
86  if (ts_tmp == 0) {
87  throw CanteraError("VCS_PROB::VCS_PROB",
88  "Failed to init a ts struct");
89  }
90  SpeciesThermo[kspec] = ts_tmp;
91  }
92  VPhaseList.resize(nph, 0);
93  for (size_t iphase = 0; iphase < NPhase; iphase++) {
94  VPhaseList[iphase] = new vcs_VolPhase();
95  }
96 }
97 
98 VCS_PROB::~VCS_PROB()
99 {
100  for (size_t i = 0; i < nspecies; i++) {
101  delete SpeciesThermo[i];
102  SpeciesThermo[i] = 0;
103  }
104  for (size_t iph = 0; iph < NPhase; iph++) {
105  delete VPhaseList[iph];
106  VPhaseList[iph] = 0;
107  }
108 }
109 
110 void VCS_PROB::resizePhase(size_t nPhase, int force)
111 {
112  if (force || nPhase > NPHASE0) {
113  NPHASE0 = nPhase;
114  }
115 }
116 
117 void VCS_PROB::resizeSpecies(size_t nsp, int force)
118 {
119  if (force || nsp > NSPECIES0) {
120  m_gibbsSpecies.resize(nsp, 0.0);
121  w.resize(nsp, 0.0);
122  mf.resize(nsp, 0.0);
123  FormulaMatrix.resize(nsp, NE0, 0.0);
125  VolPM.resize(nsp, 0.0);
126  PhaseID.resize(nsp, 0);
127  SpName.resize(nsp, "");
128  WtSpecies.resize(nsp, 0.0);
129  Charge.resize(nsp, 0.0);
130  NSPECIES0 = nsp;
131  if (nspecies > NSPECIES0) {
132  throw CanteraError("VCS_PROB::resizeSpecies", "shouldn't be here");
133  }
134  }
135 }
136 
137 void VCS_PROB::resizeElements(size_t nel, int force)
138 {
139  if (force || nel > NE0) {
140  gai.resize(nel, 0.0);
141  FormulaMatrix.resize(NSPECIES0, nel, 0.0);
142  ElName.resize(nel, "");
143  m_elType.resize(nel, VCS_ELEM_TYPE_ABSPOS);
144  ElActive.resize(nel, 1);
145  NE0 = nel;
146  ne = std::min(ne, NE0);
147  }
148 }
149 
151 {
152  gai.assign(gai.size(), 0.0);
153  double* ElemAbund = VCS_DATA_PTR(gai);
154 
155  for (size_t j = 0; j < ne; j++) {
156  for (size_t kspec = 0; kspec < nspecies; kspec++) {
158  ElemAbund[j] += FormulaMatrix(kspec,j) * w[kspec];
159  }
160  }
161  }
162 }
163 
164 void VCS_PROB::prob_report(int print_lvl)
165 {
166  m_printLvl = print_lvl;
167  /*
168  * Printout the species information: PhaseID's and mole nums
169  */
170  if (m_printLvl > 0) {
171  writeline('=', 80, true, true);
172  writeline('=', 20, false);
173  plogf(" VCS_PROB: PROBLEM STATEMENT ");
174  writeline('=', 31);
175  writeline('=', 80);
176  plogf("\n");
177  if (prob_type == 0) {
178  plogf("\tSolve a constant T, P problem:\n");
179  plogf("\t\tT = %g K\n", T);
180  double pres_atm = PresPA / 1.01325E5;
181 
182  plogf("\t\tPres = %g atm\n", pres_atm);
183  } else {
184  throw CanteraError("VCS_PROB::prob_report", "Unknown problem type");
185  }
186  plogf("\n");
187  plogf(" Phase IDs of species\n");
188  plogf(" species phaseID phaseName ");
189  plogf(" Initial_Estimated_Moles Species_Type\n");
190  for (size_t i = 0; i < nspecies; i++) {
191  vcs_VolPhase* Vphase = VPhaseList[PhaseID[i]];
192  plogf("%16s %5d %16s", SpName[i].c_str(), PhaseID[i],
193  Vphase->PhaseName.c_str());
194  if (iest >= 0) {
195  plogf(" %-10.5g", w[i]);
196  } else {
197  plogf(" N/A");
198  }
200  plogf(" Mol_Num");
202  plogf(" Voltage");
203  } else {
204  plogf(" ");
205  }
206  plogf("\n");
207  }
208 
209  /*
210  * Printout of the Phase structure information
211  */
212  writeline('-', 80, true, true);
213  plogf(" Information about phases\n");
214  plogf(" PhaseName PhaseNum SingSpec GasPhase "
215  " EqnState NumSpec");
216  plogf(" TMolesInert TKmoles\n");
217 
218  for (size_t iphase = 0; iphase < NPhase; iphase++) {
219  vcs_VolPhase* Vphase = VPhaseList[iphase];
220  std::string EOS_cstr = string16_EOSType(Vphase->m_eqnState);
221  plogf("%16s %5d %5d %8d ", Vphase->PhaseName.c_str(),
222  Vphase->VP_ID_, Vphase->m_singleSpecies, Vphase->m_gasPhase);
223  plogf("%16s %8d %16e ", EOS_cstr.c_str(),
224  Vphase->nSpecies(), Vphase->totalMolesInert());
225  if (iest >= 0) {
226  plogf("%16e\n", Vphase->totalMoles());
227  } else {
228  plogf(" N/A\n");
229  }
230  }
231 
232  plogf("\nElemental Abundances: ");
233  plogf(" Target_kmol ElemType ElActive\n");
234  double fac = 1.0;
235  if (m_VCS_UnitsFormat == VCS_UNITS_MKS) {
236  fac = 1.0;
237  }
238  for (size_t i = 0; i < ne; ++i) {
239  writeline(' ', 26, false);
240  plogf("%-2.2s", ElName[i].c_str());
241  plogf("%20.12E ", fac * gai[i]);
242  plogf("%3d %3d\n", m_elType[i], ElActive[i]);
243  }
244 
245  plogf("\nChemical Potentials: ");
246  if (m_VCS_UnitsFormat == VCS_UNITS_UNITLESS) {
247  plogf("(unitless)");
248  } else if (m_VCS_UnitsFormat == VCS_UNITS_KCALMOL) {
249  plogf("(kcal/gmol)");
250  } else if (m_VCS_UnitsFormat == VCS_UNITS_KJMOL) {
251  plogf("(kJ/gmol)");
252  } else if (m_VCS_UnitsFormat == VCS_UNITS_KELVIN) {
253  plogf("(Kelvin)");
254  } else if (m_VCS_UnitsFormat == VCS_UNITS_MKS) {
255  plogf("(J/kmol)");
256  }
257  plogf("\n");
258  plogf(" Species (phase) "
259  " SS0ChemPot StarChemPot\n");
260  for (size_t iphase = 0; iphase < NPhase; iphase++) {
261  vcs_VolPhase* Vphase = VPhaseList[iphase];
262  Vphase->setState_TP(T, PresPA);
263  for (size_t kindex = 0; kindex < Vphase->nSpecies(); kindex++) {
264  size_t kglob = Vphase->spGlobalIndexVCS(kindex);
265  plogf("%16s ", SpName[kglob].c_str());
266  if (kindex == 0) {
267  plogf("%16s", Vphase->PhaseName.c_str());
268  } else {
269  plogf(" ");
270  }
271 
272  plogf("%16g %16g\n", Vphase->G0_calc_one(kindex),
273  Vphase->GStar_calc_one(kindex));
274  }
275  }
276  writeline('=', 80, true, true);
277  writeline('=', 20, false);
278  plogf(" VCS_PROB: END OF PROBLEM STATEMENT ");
279  writeline('=', 24);
280  writeline('=', 80);
281  plogf("\n");
282  }
283 }
284 
286 {
287  size_t neVP = volPhase->nElemConstraints();
288  /*
289  * Loop through the elements in the vol phase object
290  */
291  for (size_t eVP = 0; eVP < neVP; eVP++) {
292  size_t foundPos = npos;
293  std::string enVP = volPhase->elementName(eVP);
294  /*
295  * Search for matches with the existing elements.
296  * If found, then fill in the entry in the global
297  * mapping array.
298  */
299  for (size_t e = 0; e < ne; e++) {
300  std::string en = ElName[e];
301  if (!strcmp(enVP.c_str(), en.c_str())) {
302  volPhase->setElemGlobalIndex(eVP, e);
303  foundPos = e;
304  }
305  }
306  if (foundPos == npos) {
307  int elType = volPhase->elementType(eVP);
308  int elactive = volPhase->elementActive(eVP);
309  size_t e = addElement(enVP.c_str(), elType, elactive);
310  volPhase->setElemGlobalIndex(eVP, e);
311  }
312  }
313 }
314 
315 size_t VCS_PROB::addElement(const char* elNameNew, int elType, int elactive)
316 {
317  if (!elNameNew) {
318  throw CanteraError("VCS_PROB::addElement",
319  "error: element must have a name");
320  }
321  size_t nel = ne + 1;
322  resizeElements(nel, 1);
323  ne = nel;
324  ElName[ne-1] = elNameNew;
325  m_elType[ne-1] = elType;
326  ElActive[ne-1] = elactive;
327  return ne - 1;
328 }
329 
330 size_t VCS_PROB::addOnePhaseSpecies(vcs_VolPhase* volPhase, size_t k, size_t kT)
331 {
332  if (kT > nspecies) {
333  /*
334  * Need to expand the number of species here
335  */
336  throw CanteraError("VCS_PROB::addOnePhaseSpecies", "Shouldn't be here");
337  }
338  const Array2D& fm = volPhase->getFormulaMatrix();
339  for (size_t eVP = 0; eVP < volPhase->nElemConstraints(); eVP++) {
340  size_t e = volPhase->elemGlobalIndex(eVP);
341  AssertThrowMsg(e != npos, "VCS_PROB::addOnePhaseSpecies",
342  "element not found");
343  FormulaMatrix(kT,e) = fm(k,eVP);
344  }
345  /*
346  * Tell the phase object about the current position of the
347  * species within the global species vector
348  */
349  volPhase->setSpGlobalIndexVCS(k, kT);
350  return kT;
351 }
352 
353 void VCS_PROB::reportCSV(const std::string& reportFile)
354 {
355  FILE* FP = fopen(reportFile.c_str(), "w");
356  if (!FP) {
357  throw CanteraError("VCS_PROB::reportCSV", "Failure to open file");
358  }
359 
360  std::vector<double> volPM(nspecies, 0.0);
361  std::vector<double> activity(nspecies, 0.0);
362  std::vector<double> ac(nspecies, 0.0);
363  std::vector<double> mu(nspecies, 0.0);
364  std::vector<double> mu0(nspecies, 0.0);
365  std::vector<double> molalities(nspecies, 0.0);
366 
367  double vol = 0.0;
368  size_t iK = 0;
369  for (size_t iphase = 0; iphase < NPhase; iphase++) {
370  size_t istart = iK;
371  vcs_VolPhase* volP = VPhaseList[iphase];
372  size_t nSpeciesPhase = volP->nSpecies();
373  volPM.resize(nSpeciesPhase, 0.0);
374  volP->sendToVCS_VolPM(VCS_DATA_PTR(volPM));
375 
376  double TMolesPhase = volP->totalMoles();
377  double VolPhaseVolumes = 0.0;
378  for (size_t k = 0; k < nSpeciesPhase; k++) {
379  iK++;
380  VolPhaseVolumes += volPM[istart + k] * mf[istart + k];
381  }
382  VolPhaseVolumes *= TMolesPhase;
383  vol += VolPhaseVolumes;
384  }
385 
386  fprintf(FP,"--------------------- VCS_MULTIPHASE_EQUIL FINAL REPORT"
387  " -----------------------------\n");
388  fprintf(FP,"Temperature = %11.5g kelvin\n", T);
389  fprintf(FP,"Pressure = %11.5g Pascal\n", PresPA);
390  fprintf(FP,"Total Volume = %11.5g m**3\n", vol);
391  fprintf(FP,"Number Basis optimizations = %d\n", m_NumBasisOptimizations);
392  fprintf(FP,"Number VCS iterations = %d\n", m_Iterations);
393 
394  iK = 0;
395  for (size_t iphase = 0; iphase < NPhase; iphase++) {
396  size_t istart = iK;
397 
398  vcs_VolPhase* volP = VPhaseList[iphase];
399  const ThermoPhase* tp = volP->ptrThermoPhase();
400  string phaseName = volP->PhaseName;
401  size_t nSpeciesPhase = volP->nSpecies();
402  volP->sendToVCS_VolPM(VCS_DATA_PTR(volPM));
403  double TMolesPhase = volP->totalMoles();
404  activity.resize(nSpeciesPhase, 0.0);
405  ac.resize(nSpeciesPhase, 0.0);
406 
407  mu0.resize(nSpeciesPhase, 0.0);
408  mu.resize(nSpeciesPhase, 0.0);
409  volPM.resize(nSpeciesPhase, 0.0);
410  molalities.resize(nSpeciesPhase, 0.0);
411 
412  int actConvention = tp->activityConvention();
413  tp->getActivities(VCS_DATA_PTR(activity));
414  tp->getActivityCoefficients(VCS_DATA_PTR(ac));
415  tp->getStandardChemPotentials(VCS_DATA_PTR(mu0));
416 
417  tp->getPartialMolarVolumes(VCS_DATA_PTR(volPM));
418  tp->getChemPotentials(VCS_DATA_PTR(mu));
419  double VolPhaseVolumes = 0.0;
420  for (size_t k = 0; k < nSpeciesPhase; k++) {
421  VolPhaseVolumes += volPM[k] * mf[istart + k];
422  }
423  VolPhaseVolumes *= TMolesPhase;
424  vol += VolPhaseVolumes;
425 
426  if (actConvention == 1) {
427  const MolalityVPSSTP* mTP = static_cast<const MolalityVPSSTP*>(tp);
428  tp->getChemPotentials(VCS_DATA_PTR(mu));
429  mTP->getMolalities(VCS_DATA_PTR(molalities));
430  tp->getChemPotentials(VCS_DATA_PTR(mu));
431 
432  if (iphase == 0) {
433  fprintf(FP," Name, Phase, PhaseMoles, Mole_Fract, "
434  "Molalities, ActCoeff, Activity,"
435  "ChemPot_SS0, ChemPot, mole_num, PMVol, Phase_Volume\n");
436 
437  fprintf(FP," , , (kmol), , "
438  " , , ,"
439  " (J/kmol), (J/kmol), (kmol), (m**3/kmol), (m**3)\n");
440  }
441  for (size_t k = 0; k < nSpeciesPhase; k++) {
442  std::string sName = tp->speciesName(k);
443  fprintf(FP,"%12s, %11s, %11.3e, %11.3e, %11.3e, %11.3e, %11.3e,"
444  "%11.3e, %11.3e, %11.3e, %11.3e, %11.3e\n",
445  sName.c_str(),
446  phaseName.c_str(), TMolesPhase,
447  mf[istart + k], molalities[k], ac[k], activity[k],
448  mu0[k]*1.0E-6, mu[k]*1.0E-6,
449  mf[istart + k] * TMolesPhase,
450  volPM[k], VolPhaseVolumes);
451  }
452 
453  } else {
454  if (iphase == 0) {
455  fprintf(FP," Name, Phase, PhaseMoles, Mole_Fract, "
456  "Molalities, ActCoeff, Activity,"
457  " ChemPotSS0, ChemPot, mole_num, PMVol, Phase_Volume\n");
458 
459  fprintf(FP," , , (kmol), , "
460  " , , ,"
461  " (J/kmol), (J/kmol), (kmol), (m**3/kmol), (m**3)\n");
462  }
463  for (size_t k = 0; k < nSpeciesPhase; k++) {
464  molalities[k] = 0.0;
465  }
466  for (size_t k = 0; k < nSpeciesPhase; k++) {
467  std::string sName = tp->speciesName(k);
468  fprintf(FP,"%12s, %11s, %11.3e, %11.3e, %11.3e, %11.3e, %11.3e, "
469  "%11.3e, %11.3e,% 11.3e, %11.3e, %11.3e\n",
470  sName.c_str(),
471  phaseName.c_str(), TMolesPhase,
472  mf[istart + k], molalities[k], ac[k],
473  activity[k], mu0[k]*1.0E-6, mu[k]*1.0E-6,
474  mf[istart + k] * TMolesPhase,
475  volPM[k], VolPhaseVolumes);
476  }
477  }
478 
479  if (DEBUG_MODE_ENABLED) {
480  /*
481  * Check consistency: These should be equal
482  */
483  tp->getChemPotentials(VCS_DATA_PTR(m_gibbsSpecies)+istart);
484  for (size_t k = 0; k < nSpeciesPhase; k++) {
485  if (!vcs_doubleEqual(m_gibbsSpecies[istart+k], mu[k])) {
486  fclose(FP);
487  throw CanteraError("VCS_PROB::reportCSV", "incompatibility");
488  }
489  }
490  }
491  iK += nSpeciesPhase;
492  }
493  fclose(FP);
494 }
495 
497 {
498  vcs_debug_print_lvl = lvl;
499 }
500 
501 }
std::vector< int > ElActive
Specifies whether an element constraint is active.
Definition: vcs_prob.h:181
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.
Definition: vcs_prob.h:187
double GStar_calc_one(size_t kspec) const
Gibbs free energy calculation for standard state of one species.
size_t nElemConstraints() const
Returns the number of element constraints.
bool vcs_doubleEqual(double d1, double d2)
Simple routine to check whether two doubles are equal up to roundoff error.
Definition: vcs_util.cpp:185
int m_printLvl
Print level for print routines.
Definition: vcs_prob.h:210
bool m_singleSpecies
If true, this phase consists of a single species.
Definition: vcs_VolPhase.h:584
double totalMolesInert() const
returns the value of the total kmol of inert in the phase
void resize(size_t n, size_t m, doublereal v=0.0)
Resize the array, and fill the new entries with 'v'.
Definition: Array.h:121
const size_t npos
index returned by functions to indicate "no position"
Definition: ct_defs.h:165
std::vector< int > SpeciesUnknownType
Specifies the species unknown type.
Definition: vcs_prob.h:103
#define VCS_DATA_PTR(vvv)
Points to the data in a std::vector<> object.
Definition: vcs_internal.h:18
int elementType(const size_t e) const
Type of the element constraint with index e.
std::vector< std::string > ElName
vector of strings containing the element names
Definition: vcs_prob.h:171
int iest
Specification of the initial estimate method.
Definition: vcs_prob.h:156
std::vector< double > w
Total number of moles of the kth species.
Definition: vcs_prob.h:70
size_t NSPECIES0
Species number used to malloc data structures.
Definition: vcs_prob.h:37
size_t nSpecies() const
Return the number of species in the phase.
size_t addOnePhaseSpecies(vcs_VolPhase *volPhase, size_t k, size_t kT)
This routines adds entries for the formula matrix for one species.
Definition: vcs_prob.cpp:330
void resizePhase(size_t nPhase, int force)
Resizes all of the phase lists within the structure.
Definition: vcs_prob.cpp:110
std::string PhaseName
String name for the phase.
Definition: vcs_VolPhase.h:696
double totalMoles() const
Return the total moles in the phase.
Pure Virtual base class for the species thermo manager classes.
std::vector< vcs_VolPhase * > VPhaseList
Array of phase structures.
Definition: vcs_prob.h:193
int m_Iterations
Number of iterations. This is an output variable.
Definition: vcs_prob.h:204
#define AssertThrowMsg(expr, procedure, message)
Assertion must be true or an error is thrown.
Definition: ctexceptions.h:301
A class for 2D arrays stored in column-major (Fortran-compatible) form.
Definition: Array.h:29
Header for intermediate ThermoPhase object for phases which employ molality based activity coefficien...
#define VCS_PROBTYPE_TP
Current, it is always done holding T and P constant.
Definition: vcs_defs.h:38
void resizeElements(size_t nel, int force)
Resizes all of the element lists within the structure.
Definition: vcs_prob.cpp:137
std::vector< size_t > PhaseID
Mapping between the species and the phases.
Definition: vcs_prob.h:165
size_t VP_ID_
Original ID of the phase in the problem.
Definition: vcs_VolPhase.h:581
std::vector< double > VolPM
Partial Molar Volumes of species.
Definition: vcs_prob.h:130
Header for the object representing each phase within vcs.
#define VCS_SPECIES_TYPE_MOLNUM
Unknown refers to mole number of a single species.
Definition: vcs_defs.h:343
#define VCS_ELEM_TYPE_ABSPOS
Normal element constraint consisting of positive coefficients for the formula matrix.
Definition: vcs_defs.h:290
Defines and definitions within the vcs package.
void addPhaseElements(vcs_VolPhase *volPhase)
Add elements to the local element list.
Definition: vcs_prob.cpp:285
Array2D FormulaMatrix
Formula Matrix for the problem.
Definition: vcs_prob.h:90
void setDebugPrintLvl(int vcs_debug_print_lvl)
Set the debug level.
Definition: vcs_prob.cpp:496
Internal declarations for the VCSnonideal package.
int m_VCS_UnitsFormat
Units for the chemical potential data, pressure data, volume, and species amounts.
Definition: vcs_prob.h:148
const Array2D & getFormulaMatrix() const
Get a constant form of the Species Formula Matrix.
Header for the Interface class for the vcs thermo equilibrium solver package,.
size_t NPHASE0
Number of phases used to malloc data structures.
Definition: vcs_prob.h:50
int m_eqnState
Type of the equation of state.
Definition: vcs_VolPhase.h:597
size_t nspecies
Total number of species in the problems.
Definition: vcs_prob.h:34
std::vector< double > mf
Mole fraction vector.
Definition: vcs_prob.h:77
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:99
void prob_report(int print_lvl)
Print out the problem specification in all generality as it currently exists in the VCS_PROB object...
Definition: vcs_prob.cpp:164
bool m_gasPhase
If true, this phase is a gas-phase like phase.
Definition: vcs_VolPhase.h:591
std::string string16_EOSType(int EOSType)
Return a string representing the equation of state.
std::vector< double > Charge
Charge of each species.
Definition: vcs_prob.h:190
int m_NumBasisOptimizations
Number of basis optimizations used. This is an output variable.
Definition: vcs_prob.h:207
size_t addElement(const char *elNameNew, int elType, int elactive)
This routine resizes the number of elements in the VCS_PROB object by adding a new element to the end...
Definition: vcs_prob.cpp:315
double PresPA
Pressure.
Definition: vcs_prob.h:116
Phase information and Phase calculations for vcs.
Definition: vcs_VolPhase.h:86
std::vector< int > m_elType
vector of Element types
Definition: vcs_prob.h:174
size_t ne
Number of element constraints in the equilibrium problem.
Definition: vcs_prob.h:40
int prob_type
Problem type. I.e., the identity of what is held constant.
Definition: vcs_prob.h:31
std::vector< double > gai
Element abundances for jth element.
Definition: vcs_prob.h:84
std::vector< std::string > SpName
Vector of strings containing the species names.
Definition: vcs_prob.h:168
size_t NE0
Number of element constraints used to malloc data structures involving elements.
Definition: vcs_prob.h:44
void setSpGlobalIndexVCS(const size_t spIndex, const size_t spGlobalIndex)
set the Global VCS index of the kth species in the phase
std::vector< double > m_gibbsSpecies
Vector of chemical potentials of the species.
Definition: vcs_prob.h:57
double T
Temperature (Kelvin)
Definition: vcs_prob.h:109
void resizeSpecies(size_t nsp, int force)
Resizes all of the species lists within the structure.
Definition: vcs_prob.cpp:117
#define plogf
define this Cantera function to replace printf
Definition: vcs_internal.h:24
#define VCS_SPECIES_TYPE_INTERFACIALVOLTAGE
Unknown refers to the voltage level of a phase.
Definition: vcs_defs.h:352
void set_gai()
Calculate the element abundance vector from the mole numbers.
Definition: vcs_prob.cpp:150
size_t elemGlobalIndex(const size_t e) const
Returns the global index of the local element index for the phase.
std::string elementName(const size_t e) const
Name of the element constraint with index e.
size_t NPhase
Number of phases in the problem.
Definition: vcs_prob.h:47
size_t spGlobalIndexVCS(const size_t spIndex) const
Return the Global VCS index of the kth species in the phase.
void setState_TP(const double temperature_Kelvin, const double pressure_PA)
Sets the temperature and pressure in this object and underlying ThermoPhase objects.
int vcs_debug_print_lvl
Debug print lvl.
Definition: vcs_prob.h:213
void setElemGlobalIndex(const size_t eLocal, const size_t eGlobal)
sets a local phase element to a global index value