Cantera  2.1.2
vcs_prob.h
Go to the documentation of this file.
1 /**
2  * @file vcs_prob.h
3  * Header for the Interface class for the vcs thermo equilibrium solver package,
4  */
5 /*
6  * Copyright (2005) Sandia Corporation. Under the terms of
7  * Contract DE-AC04-94AL85000 with Sandia Corporation, the
8  * U.S. Government retains certain rights in this software.
9  */
10 
11 #ifndef _VCS_PROB_H
12 #define _VCS_PROB_H
13 
14 #include "vcs_DoubleStarStar.h"
15 #include "vcs_IntStarStar.h"
16 #include "cantera/equil/vcs_defs.h"
17 #include <string>
18 
19 namespace VCSnonideal
20 {
21 
22 class vcs_VolPhase;
23 class VCS_SPECIES_THERMO;
24 
25 //! Interface class for the vcs thermo equilibrium solver package,
26 //! which generally describes the problem to be solved.
27 class VCS_PROB
28 {
29 public:
30  //! Problem type. I.e., the identity of what is held constant.
31  /*!
32  * Currently, T and P are held constant, and this input is ignored
33  */
34  int prob_type;
35 
36  //! Total number of species in the problems
37  size_t nspecies;
38 
39  //! Species number used to malloc data structures
40  size_t NSPECIES0;
41 
42  //! Number of element constraints in the equilibrium problem
43  size_t ne;
44 
45  //! Number of element constraints used to malloc data structures
46  //! involving elements
47  size_t NE0;
48 
49  //! Number of phases in the problem
50  size_t NPhase;
51 
52  //! Number of phases used to malloc data structures
53  size_t NPHASE0;
54 
55  //! Vector of chemical potentials of the species
56  /*!
57  * This is a calculated output quantity. length = number of species.
58  * units = m_VCS_UnitsFormat
59  */
60  std::vector<double> m_gibbsSpecies;
61 
62  //! Total number of moles of the kth species.
63  /*!
64  * This is both an input and an output variable.
65  * On input, this is an estimate of the mole numbers.
66  * The actual element abundance vector contains the problem specification.
67  *
68  * On output, this contains the solution for the total number of moles
69  * of the kth species.
70  *
71  * units = m_VCS_UnitsFormat
72  */
73  std::vector<double> w;
74 
75  //! Mole fraction vector
76  /*!
77  * This is a calculated vector, calculated from w[].
78  * length number of species.
79  */
80  std::vector<double> mf;
81 
82  //! Element abundances for jth element
83  /*!
84  * This is input from the input file and is considered a constant from
85  * thereon within the vcs_solve_TP(). units = m_VCS_UnitsFormat
86  */
87  std::vector<double> gai;
88 
89  //! Formula Matrix for the problem
90  /*!
91  * FormulaMatrix[j][kspec] = Number of elements, j, in the kspec species
92  */
94 
95  //! Specifies the species unknown type
96  /*!
97  * There are two types. One is the straightforward species, with the
98  * mole number w[k], as the unknown. The second is the an interfacial
99  * voltage where w[k] refers to the interfacial voltage in volts.
100  *
101  * These species types correspond to metallic electrons corresponding to
102  * electrodes. The voltage and other interfacial conditions sets up an
103  * interfacial current, which is set to zero in this initial treatment.
104  * Later we may have non-zero interfacial currents.
105  */
106  std::vector<int> SpeciesUnknownType;
107 
108  //! Temperature (Kelvin)
109  /*!
110  * Specification of the temperature for the equilibrium problem
111  */
112  double T;
113 
114  //! Pressure
115  /*!
116  * units given by m_VCS_UnitsFormat
117  * -> are now PA
118  */
119  double PresPA;
120 
121  //! Volume of the entire system
122  /*!
123  * units given by m_VCS_UnitsFormat
124  * Note, this is an output variable atm
125  */
126  double Vol;
127 
128  //! Partial Molar Volumes of species
129  /*!
130  * This is a calculated vector, calculated from w[].
131  * length number of species.
132  */
133  std::vector<double> VolPM;
134 
135  //! Units for the chemical potential data, pressure data, volume,
136  //! and species amounts
137  /*!
138  * All internally stored quantities will have these units. Also, printed
139  * quantities will display in these units.
140  *
141  * | | | Chem_Pot | Pres | vol | moles|
142  * |---|----------------------|-------------------------|------|-------|------|
143  * |-1 | `VCS_UNITS_KCALMOL` | kcal/mol | atm | cm**3 | gmol |
144  * | 0 | `VCS_UNITS_UNITLESS` | MU / RT -> no units | atm | cm**3 | gmol |
145  * | 1 | `VCS_UNITS_KJMOL` | kJ / mol | atm | cm**3 | gmol |
146  * | 2 | `VCS_UNITS_KELVIN` | KELVIN -> MU / R | atm | cm**3 | gmol |
147  * | 3 | `VCS_UNITS_MKS` | Joules / Kmol (Cantera) | Pa | m**3 | kmol |
148  *
149  * see vcs_defs.h for more information
150  */
152 
153  //! Specification of the initial estimate method
154  /*!
155  * * 0: user estimate
156  * * 1: user estimate if satisifies elements
157  * * -1: machine estimate
158  */
159  int iest;
160 
161  //! Tolerance requirement for major species
162  double tolmaj;
163 
164  //! Tolerance requirement for minor species
165  double tolmin;
166 
167  //! Mapping between the species and the phases
168  std::vector<size_t> PhaseID;
169 
170  //! Vector of strings containing the species names
171  std::vector<std::string> SpName;
172 
173  //! vector of strings containing the element names
174  std::vector<std::string> ElName;
175 
176  //! vector of Element types
177  std::vector<int> m_elType;
178 
179  //! Specifies whether an element constraint is active
180  /*!
181  * The default is true
182  * Length = nelements
183  */
184  std::vector<int> ElActive;
185 
186  //! Molecular weight of species
187  /*!
188  * WtSpecies[k] = molecular weight of species in gm/mol
189  */
190  std::vector<double> WtSpecies;
191 
192  //! Charge of each species
193  std::vector<double> Charge;
194 
195  //! Array of phase structures
196  std::vector<vcs_VolPhase*> VPhaseList;
197 
198  // String containing the title of the run
199  std::string Title;
200 
201  //! Vector of pointers to thermo structures which identify the model and
202  //! parameters for evaluating the thermodynamic functions for that
203  //! particular species
204  std::vector<VCS_SPECIES_THERMO*> SpeciesThermo;
205 
206  //! Number of iterations. This is an output variable
208 
209  //! Number of basis optimizations used. This is an output variable.
211 
212  //! Print level for print routines
214 
215  //! Debug print lvl
217 
218  //! Constructor
219  /*!
220  * This constructor initializes the sizes within the object
221  * to parameter values.
222  *
223  * @param nsp number of species
224  * @param nel number of elements
225  * @param nph number of phases
226  */
227  VCS_PROB(size_t nsp, size_t nel, size_t nph);
228 
229  ~VCS_PROB();
230 
231  //! Resizes all of the phase lists within the structure
232  /*!
233  * Note, this doesn't change the number of phases in the problem.
234  * It will change #NPHASE0 if `nPhase` is greater than #NPHASE0.
235  *
236  * @param nPhase size to dimension all the phase lists to
237  * @param force If true, this will dimension the size to be equal to `nPhase`
238  * even if `nPhase` is less than the current value of NPHASE0
239  */
240  void resizePhase(size_t nPhase, int force);
241 
242  //! Resizes all of the species lists within the structure
243  /*!
244  * Note, this doesn't change the number of species in the problem.
245  * It will change #NSPECIES0 if `nsp` is greater than #NSPECIES0.
246  *
247  * @param nsp size to dimension all the species lists to
248  * @param force If true, this will dimension the size to be equal to `nsp`
249  * even if `nsp` is less than the current value of #NSPECIES0
250  */
251  void resizeSpecies(size_t nsp, int force);
252 
253  //! Resizes all of the element lists within the structure
254  /*!
255  * Note, this doesn't change the number of element constraints in the
256  * problem. It will change #NE0 if `nel` is greater than #NE0.
257  *
258  * @param nel size to dimension all the elements lists
259  * @param force If true, this will dimension the size to be equal to `nel`
260  * even if `nel` is less than the current value of #NE0
261  */
262  void resizeElements(size_t nel, int force);
263 
264  //! Calculate the element abundance vector from the mole numbers
265  void set_gai();
266 
267  //! Print out the problem specification in all generality
268  //! as it currently exists in the VCS_PROB object
269  /*!
270  * @param print_lvl Parameter lvl for printing
271  * * 0 - no printing
272  * * 1 - all printing
273  */
274  void prob_report(int print_lvl);
275 
276  //! Add elements to the local element list
277  /*!
278  * This routine sorts through the elements defined in the vcs_VolPhase
279  * object. It then adds the new elements to the VCS_PROB object, and
280  * creates a global map, which is stored in the vcs_VolPhase object. Id
281  * and matching of elements is done strictly via the element name, with
282  * case not mattering.
283  *
284  * The routine also fills in the position of the element
285  * in the vcs_VolPhase object's ElGlobalIndex field.
286  *
287  * @param volPhase Object containing the phase to be added.
288  * The elements in this phase are parsed for
289  * addition to the global element list
290  */
291  void addPhaseElements(vcs_VolPhase* volPhase);
292 
293  //! This routine resizes the number of elements in the VCS_PROB object by
294  //! adding a new element to the end of the element list
295  /*!
296  * The element name is added. Formula vector entries ang element
297  * abundances for the new element are set to zero.
298  *
299  * Returns the index number of the new element.
300  *
301  * @param elNameNew New name of the element
302  * @param elType Type of the element
303  * @param elactive boolean indicating whether the element is active
304  *
305  * @return returns the index number of the new element
306  */
307  size_t addElement(const char* elNameNew, int elType, int elactive);
308 
309  //! This routines adds entries for the formula matrix for one species
310  /*!
311  * This routines adds entries for the formula matrix for this object
312  * for one species
313  *
314  * This object also fills in the index filed, IndSpecies, within
315  * the volPhase object.
316  *
317  * @param volPhase object containing the species
318  * @param k Species number within the volPhase k
319  * @param kT global Species number within this object
320  *
321  */
322  size_t addOnePhaseSpecies(vcs_VolPhase* volPhase, size_t k, size_t kT);
323 
324  void reportCSV(const std::string& reportFile);
325 
326  //! Set the debug level
327  /*!
328  * @param vcs_debug_print_lvl input debug level
329  */
331 };
332 
333 }
334 
335 #endif
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
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
Header file for class IntStarStar.
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
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
double tolmaj
Tolerance requirement for major species.
Definition: vcs_prob.h:162
std::vector< int > SpeciesUnknownType
Specifies the species unknown type.
Definition: vcs_prob.h:106
void set_gai()
Calculate the element abundance vector from the mole numbers.
Definition: vcs_prob.cpp:155
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
size_t NPhase
Number of phases in the problem.
Definition: vcs_prob.h:50
Phase information and Phase calculations for vcs.
Definition: vcs_VolPhase.h:97
Defines and definitions within the vcs package.
Header file for class DoubleStarStar.
void addPhaseElements(vcs_VolPhase *volPhase)
Add elements to the local element list.
Definition: vcs_prob.cpp:318
std::vector< std::string > ElName
vector of strings containing the element names
Definition: vcs_prob.h:174
double tolmin
Tolerance requirement for minor species.
Definition: vcs_prob.h:165
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
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
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
double Vol
Volume of the entire system.
Definition: vcs_prob.h:126
double PresPA
Pressure.
Definition: vcs_prob.h:119
std::vector< vcs_VolPhase * > VPhaseList
Array of phase structures.
Definition: vcs_prob.h:196
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
size_t NSPECIES0
Species number used to malloc data structures.
Definition: vcs_prob.h:40
Interface class for the vcs thermo equilibrium solver package, which generally describes the problem ...
Definition: vcs_prob.h:27
std::vector< std::string > SpName
Vector of strings containing the species names.
Definition: vcs_prob.h:171
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
std::vector< double > gai
Element abundances for jth element.
Definition: vcs_prob.h:87
VCS_PROB(size_t nsp, size_t nel, size_t nph)
Constructor.
Definition: vcs_prob.cpp:27
size_t ne
Number of element constraints in the equilibrium problem.
Definition: vcs_prob.h:43
double T
Temperature (Kelvin)
Definition: vcs_prob.h:112
std::vector< double > VolPM
Partial Molar Volumes of species.
Definition: vcs_prob.h:133
A class for 2D double arrays stored in column-major (Fortran-compatible) form.
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