Cantera  2.1.2
vcs_defs.h
Go to the documentation of this file.
1 /**
2  * @file vcs_defs.h
3  * Defines and definitions within the vcs 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_DEFS_H
12 #define VCS_DEFS_H
13 
14 namespace VCSnonideal
15 {
16 
17 /*
18  * COMMON DEFINITIONS -> Protect them against redefinitions
19  */
20 //@{
21 
22 #ifndef SQUARE
23 # define SQUARE(x) ((x) * (x))
24 #endif
25 
26 #ifndef DSIGN
27 # define DSIGN(x) (( (x) == (0.0) ) ? (0.0) : ( ((x) > 0.0) ? 1.0 : -1.0 ))
28 #endif
29 
30 //@}
31 
32 /*!
33  * ERROR CODES
34  *
35  */
36 //@{
37 #define VCS_SUCCESS 0
38 #define VCS_NOMEMORY 1
39 #define VCS_FAILED_CONVERGENCE -1
40 #define VCS_SHOULDNT_BE_HERE -2
41 #define VCS_PUB_BAD -3
42 #define VCS_THERMO_OUTOFRANGE -4
43 #define VCS_FAILED_LOOKUP -5
44 #define VCS_MP_FAIL -6
45 //@}
46 
47 /*!
48  * @name Type of the underlying equilibrium solve
49  *
50  * @{
51  */
52 
53 //! Current, it is always done holding T and P constant.
54 #define VCS_PROBTYPE_TP 0
55 //@}
56 
57 /*!
58  * @name Sizes of Phases and Cutoff Mole Numbers
59  *
60  * All size parameters are listed here
61  * @{
62  */
63 
64 //! Cutoff relative mole fraction value,
65 //! below which species are deleted from the equilibrium problem.
66 #ifndef VCS_RELDELETE_SPECIES_CUTOFF
67 #define VCS_RELDELETE_SPECIES_CUTOFF 1.0e-64
68 #endif
69 
70 //! Cutoff relative mole number value,
71 //! below which species are deleted from the equilibrium problem.
72 #ifndef VCS_DELETE_MINORSPECIES_CUTOFF
73 #define VCS_DELETE_MINORSPECIES_CUTOFF 1.0e-140
74 #endif
75 
76 //! Relative value of multiphase species mole number for a
77 //! multiphase species which is small.
78 #ifndef VCS_SMALL_MULTIPHASE_SPECIES
79 #define VCS_SMALL_MULTIPHASE_SPECIES 1.0e-25
80 #endif
81 
82 //! Cutoff relative moles below which a phase is deleted
83 //! from the equilibrium problem.
84 #ifndef VCS_DELETE_PHASE_CUTOFF
85 #define VCS_DELETE_PHASE_CUTOFF 1.0e-13
86 #endif
87 
88 //! Relative mole number of species in a phase that is created
89 //! We want this to be comfortably larger than the VCS_DELETE_PHASE_CUTOFF value
90 //! so that the phase can have a chance to survive.
91 #ifndef VCS_POP_PHASE_MOLENUM
92 #define VCS_POP_PHASE_MOLENUM 1.0e-11
93 #endif
94 
95 
96 //! Cutoff moles below which a phase or species which
97 //! comprises the bulk of an element's total concentration
98 //! is deleted.
99 #ifndef VCS_DELETE_ELEMENTABS_CUTOFF
100 #define VCS_DELETE_ELEMENTABS_CUTOFF 1.0e-280
101 #endif
102 
103 //! Maximum steps in the inner loop
104 #ifndef VCS_MAXSTEPS
105 #define VCS_MAXSTEPS 50000
106 #endif
107 
108 //@}
109 
110 /*!
111  * @name State of Dimensional Units for Gibbs free energies
112  *
113  * @{
114  */
115 //! nondimensional
116 #define VCS_NONDIMENSIONAL_G 1
117 //! dimensioned
118 #define VCS_DIMENSIONAL_G 0
119 //@}
120 
121 
122 //! @name Species Categories used during the iteration
123 /*!
124  * These defines are valid values for spStatus()
125  */
126 //@{
127 
128 //! Species is a component which can never be nonzero because of a
129 //! stoichiometric constraint
130 /*!
131  * An example of this would be a species that contains Ni. But,
132  * the amount of Ni elements is exactly zero.
133  */
134 #define VCS_SPECIES_COMPONENT_STOICHZERO 3
135 
136 //! Species is a component which can be nonzero
137 #define VCS_SPECIES_COMPONENT 2
138 
139 //! Species is a major species
140 /*!
141  * A major species is either a species in a multicomponent phase with
142  * significant concentration or it's a Stoich Phase
143  */
144 #define VCS_SPECIES_MAJOR 1
145 
146 //! Species is a major species
147 /*!
148  * A major species is either a species in a multicomponent phase with
149  * significant concentration or it's a Stoich Phase
150  */
151 #define VCS_SPECIES_MINOR 0
152 
153 //! Species lies in a multicomponent phase, with a small phase concentration
154 /*!
155  * The species lies in a multicomponent phase that exists.
156  * It concentration is currently very low, necessitating a
157  * different method of calculation.
158  */
159 #define VCS_SPECIES_SMALLMS -1
160 
161 //! Species lies in a multicomponent phase with concentration zero
162 /*!
163  * The species lies in a multicomponent phase which currently doesn't exist.
164  * It concentration is currently zero.
165  */
166 #define VCS_SPECIES_ZEROEDMS -2
167 
168 //! Species is a SS phase, that is currently zeroed out.
169 /*!
170  * The species lies in a single-species phase which
171  * is currently zeroed out.
172  */
173 #define VCS_SPECIES_ZEROEDSS -3
174 
175 //! Species has such a small mole fraction it is deleted even though its
176 //! phase may possibly exist.
177 /*!
178  * The species is believed to have such a small mole fraction
179  * that it best to throw the calculation of it out.
180  * It will be added back in at the end of the calculation.
181  */
182 #define VCS_SPECIES_DELETED -4
183 
184 //! Species refers to an electron in the metal.
185 /*!
186  * The unknown is equal to the electric potential of the phase
187  * in which it exists.
188  */
189 #define VCS_SPECIES_INTERFACIALVOLTAGE -5
190 
191 //! Species lies in a multicomponent phase that is zeroed atm
192 /*!
193  * The species lies in a multicomponent phase that is currently
194  * deleted and will stay deleted due to a choice from a higher level.
195  * These species will formally always have zero mole numbers in the
196  * solution vector.
197  */
198 #define VCS_SPECIES_ZEROEDPHASE -6
199 
200 //! Species lies in a multicomponent phase that is active, but species concentration is zero
201 /*!
202  * The species lies in a multicomponent phase which currently does exist.
203  * It concentration is currently identically zero, though the phase exists. Note, this
204  * is a temporary condition that exists at the start of an equilibrium problem.
205  * The species is soon "birthed" or "deleted".
206  */
207 #define VCS_SPECIES_ACTIVEBUTZERO -7
208 
209 //! Species lies in a multicomponent phase that is active,
210 //! but species concentration is zero due to stoich constraint
211 /*!
212  * The species lies in a multicomponent phase which currently does exist. Its concentration is currently
213  * identically zero, though the phase exists. This is a permanent condition due to stoich constraints.
214  *
215  * An example of this would be a species that contains Ni. But,
216  * the amount of Ni elements in the current problem statement is exactly zero.
217  */
218 #define VCS_SPECIES_STOICHZERO -8
219 
220 //@}
221 
222 //! @name Phase Categories used during the iteration
223 /*!
224  * These defines are valid values for the phase existence flag
225  */
226 //@{
227 //! Always exists because it contains inerts which can't exist in any other phase
228 #define VCS_PHASE_EXIST_ALWAYS 3
229 
230 //! Phase is a normal phase that currently exists
231 #define VCS_PHASE_EXIST_YES 2
232 
233 //! Phase is a normal phase that exists in a small concentration
234 /*!
235  * Concentration is so small that it must be calculated using an alternate
236  * method
237  */
238 #define VCS_PHASE_EXIST_MINORCONC 1
239 
240 //! Phase doesn't currently exist in the mixture
241 #define VCS_PHASE_EXIST_NO 0
242 
243 //! Phase currently is zeroed due to a programmatic issue
244 /*!
245  * We zero phases because we want to follow phase stability boundaries.
246  */
247 #define VCS_PHASE_EXIST_ZEROEDPHASE -6
248 
249 //@}
250 
251 /*!
252  * @name Units for the chemical potential data and pressure variables
253  *
254  * @verbatim
255  Chem_Pot Pres vol moles
256  -------------------------------------------------
257  VCS_UNITS_KCALMOL = kcal/mol Pa m**3 kmol
258  VCS_UNITS_UNITLESS = MU / RT -> no units Pa m**3 kmol
259  VCS_UNITS_KJMOL = kJ / mol Pa m**3 kmol
260  VCS_UNITS_KELVIN = KELVIN -> MU / R Pa m**3 kmol
261  VCS_UNITS_MKS = Joules / Kmol (Cantera) Pa m**3 kmol
262 
263  Energy:
264  VCS_UNITS_KCALMOL = kcal/mol
265  VCS_UNITS_UNITLESS = MU / RT -> no units
266  VCS_UNITS_KJMOL = kJ / mol
267  VCS_UNITS_KELVIN = KELVIN -> MU / R
268  VCS_UNITS_MKS = J / kmol
269 
270  Pressure: (Pref and Pres)
271  VCS_UNITS_KCALMOL = Pa
272  VCS_UNITS_UNITLESS = Pa
273  VCS_UNITS_KJMOL = Pa
274  VCS_UNITS_KELVIN = Pa
275  VCS_UNITS_MKS = Pa = kg / m s2
276  @endverbatim
277  * @{
278  */
279 #define VCS_UNITS_KCALMOL -1
280 #define VCS_UNITS_UNITLESS 0
281 #define VCS_UNITS_KJMOL 1
282 #define VCS_UNITS_KELVIN 2
283 #define VCS_UNITS_MKS 3
284 //@}
285 
286 /*!
287  * @name Types of Element Constraint Equations
288  *
289  * There may be several different types of element constraints handled
290  * by the equilibrium program. These defines are used to assign each
291  * constraint to one category.
292  * @{
293  */
294 
295 
296 //! An element constraint that is current turned off
297 #define VCS_ELEM_TYPE_TURNEDOFF -1
298 
299 //! Normal element constraint consisting of positive coefficients for the
300 //! formula matrix.
301 /*!
302  * All species have positive coefficients within the formula matrix.
303  * With this constraint, we may employ various strategies to handle
304  * small values of the element number successfully.
305  */
306 #define VCS_ELEM_TYPE_ABSPOS 0
307 
308 //! This refers to conservation of electrons
309 /*!
310  * Electrons may have positive or negative values in the Formula matrix.
311  */
312 #define VCS_ELEM_TYPE_ELECTRONCHARGE 1
313 
314 //! This refers to a charge neutrality of a single phase
315 /*!
316  * Charge neutrality may have positive or negative values in the Formula matrix.
317  */
318 #define VCS_ELEM_TYPE_CHARGENEUTRALITY 2
319 
320 //! Constraint associated with maintaining a fixed lattice stoichiometry in the
321 //! solids
322 /*!
323  * The constraint may have positive or negative values. The lattice 0 species will
324  * have negative values while higher lattices will have positive values
325  */
326 #define VCS_ELEM_TYPE_LATTICERATIO 3
327 
328 //! Constraint associated with maintaining frozen kinetic equilibria in
329 //! some functional groups within molecules
330 /*!
331  * We seek here to say that some functional groups or ionic states should be
332  * treated as if they are separate elements given the time scale of the problem.
333  * This will be abs positive constraint. We have not implemented any examples yet.
334  * A requirement will be that we must be able to add and subtract these constraints.
335  */
336 #define VCS_ELEM_TYPE_KINETICFROZEN 4
337 
338 //! Constraint associated with the maintenance of a surface phase
339 /*!
340  * We don't have any examples of this yet either. However, surfaces only exist
341  * because they are interfaces between bulk layers. If we want to treat surfaces
342  * within thermodynamic systems we must come up with a way to constrain their total
343  * number.
344  */
345 #define VCS_ELEM_TYPE_SURFACECONSTRAINT 5
346 //! Other constraint equations
347 /*!
348  * currently there are none
349  */
350 #define VCS_ELEM_TYPE_OTHERCONSTRAINT 6
351 //@}
352 
353 /*!
354  * @name Types of Species Unknowns in the problem
355  *
356  * @{
357  */
358 //! Unknown refers to mole number of a single species
359 #define VCS_SPECIES_TYPE_MOLNUM 0
360 
361 //! Unknown refers to the voltage level of a phase
362 /*!
363  * Typically, these species are electrons in metals. There is an
364  * infinite supply of them. However, their electrical potential
365  * is sometimes allowed to vary, for example if the open circuit voltage
366  * is sought after.
367  */
368 #define VCS_SPECIES_TYPE_INTERFACIALVOLTAGE -5
369 //@}
370 
371 /*!
372  * @name Types of State Calculations within VCS
373  * These values determine where the
374  * results are stored within the VCS_SOLVE
375  * object.
376  * @{
377  */
378 //! State Calculation is currently in an unknown state
379 #define VCS_STATECALC_UNKNOWN -1
380 //! State Calculation based on the old or base mole numbers
381 #define VCS_STATECALC_OLD 0
382 
383 //! State Calculation based on the new or tentative mole numbers
384 #define VCS_STATECALC_NEW 1
385 
386 //! State Calculation based on tentative mole numbers
387 //! for a phase which is currently zeroed, but is being
388 //! evaluated for whether it should pop back into existence
389 #define VCS_STATECALC_PHASESTABILITY 2
390 
391 //! State Calculation based on a temporary set of mole numbers
392 #define VCS_STATECALC_TMP 3
393 //@}
394 
395 
396 }
397 
398 #endif