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