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