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