Cantera  2.0
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 zereod 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 interfacial voltage
187  * drop across the interface on the SHE (standard
188  * hyrdogen electrode) scale (volts).
189  */
190 #define VCS_SPECIES_INTERFACIALVOLTAGE -5
191 
192 //! Species lies in a multicomponent phase that is zeroed atm
193 /*!
194  * The species lies in a multicomponent phase that is currently
195  * deleted and will stay deleted due to a choice from a higher level.
196  * These species will formally always have zero mole numbers in the
197  * solution vector.
198  */
199 #define VCS_SPECIES_ZEROEDPHASE -6
200 
201 //! Species lies in a multicomponent phase that is active, but species concentration is zero
202 /*!
203  * The species lies in a multicomponent phase which currently does exist.
204  * It concentration is currently identically zero, though the phase exists. Note, this
205  * is a temporary condition that exists at the start of an equilibrium problem.
206  * The species is soon "birthed" or "deleted".
207  */
208 #define VCS_SPECIES_ACTIVEBUTZERO -7
209 
210 //! Species lies in a multicomponent phase that is active,
211 //! but species concentration is zero due to stoich constraint
212 /*!
213  * The species lies in a multicomponent phase which currently does exist. Its concentration is currently
214  * identically zero, though the phase exists. This is a permanent condition due to stoich constraints.
215  *
216  * An example of this would be a species that contains Ni. But,
217  * the amount of Ni elements in the current problem statement is exactly zero.
218  */
219 #define VCS_SPECIES_STOICHZERO -8
220 
221 //@}
222 
223 //! @name Phase Categories used during the iteration
224 /*!
225  * These defines are valid values for the phase existence flag
226  */
227 //@{
228 //! Always exists because it contains inerts which can't exist in any other phase
229 #define VCS_PHASE_EXIST_ALWAYS 3
230 
231 //! Phase is a normal phase that currently exists
232 #define VCS_PHASE_EXIST_YES 2
233 
234 //! Phase is a normal phase that exists in a small concentration
235 /*!
236  * Concentration is so small that it must be calculated using an alternate
237  * method
238  */
239 #define VCS_PHASE_EXIST_MINORCONC 1
240 
241 //! Phase doesn't currently exist in the mixture
242 #define VCS_PHASE_EXIST_NO 0
243 
244 //! Phase currently is zeroed due to a programmatic issue
245 /*!
246  * We zero phases because we want to follow phase stability boundaries.
247  */
248 #define VCS_PHASE_EXIST_ZEROEDPHASE -6
249 
250 //@}
251 
252 /*!
253  * @name Units for the chemical potential data and pressure variables
254  *
255  * @verbatim
256  Chem_Pot Pres vol moles
257  -------------------------------------------------
258  VCS_UNITS_KCALMOL = kcal/mol Pa m**3 kmol
259  VCS_UNITS_UNITLESS = MU / RT -> no units Pa m**3 kmol
260  VCS_UNITS_KJMOL = kJ / mol Pa m**3 kmol
261  VCS_UNITS_KELVIN = KELVIN -> MU / R Pa m**3 kmol
262  VCS_UNITS_MKS = Joules / Kmol (Cantera) Pa m**3 kmol
263 
264  Energy:
265  VCS_UNITS_KCALMOL = kcal/mol
266  VCS_UNITS_UNITLESS = MU / RT -> no units
267  VCS_UNITS_KJMOL = kJ / mol
268  VCS_UNITS_KELVIN = KELVIN -> MU / R
269  VCS_UNITS_MKS = J / kmol
270 
271  Pressure: (Pref and Pres)
272  VCS_UNITS_KCALMOL = Pa
273  VCS_UNITS_UNITLESS = Pa
274  VCS_UNITS_KJMOL = Pa
275  VCS_UNITS_KELVIN = Pa
276  VCS_UNITS_MKS = Pa = kg / m s2
277  @endverbatim
278  * @{
279  */
280 #define VCS_UNITS_KCALMOL -1
281 #define VCS_UNITS_UNITLESS 0
282 #define VCS_UNITS_KJMOL 1
283 #define VCS_UNITS_KELVIN 2
284 #define VCS_UNITS_MKS 3
285 //@}
286 
287 /*!
288  * @name Types of Element Constraint Equations
289  *
290  * There may be several different types of element constraints handled
291  * by the equilibrium program. These defines are used to assign each
292  * constraint to one category.
293  * @{
294  */
295 
296 
297 //! An element constraint that is current turned off
298 #define VCS_ELEM_TYPE_TURNEDOFF -1
299 
300 //! Normal element constraint consisting of positive coefficients for the
301 //! formula matrix.
302 /*!
303  * All species have positive coefficients within the formula matrix.
304  * With this constraint, we may employ various strategies to handle
305  * small values of the element number successfully.
306  */
307 #define VCS_ELEM_TYPE_ABSPOS 0
308 
309 //! This refers to conservation of electrons
310 /*!
311  * Electrons may have positive or negative values in the Formula matrix.
312  */
313 #define VCS_ELEM_TYPE_ELECTRONCHARGE 1
314 
315 //! This refers to a charge neutrality of a single phase
316 /*!
317  * Charge neutrality may have positive or negative values in the Formula matrix.
318  */
319 #define VCS_ELEM_TYPE_CHARGENEUTRALITY 2
320 
321 //! Constraint associated with maintaining a fixed lattice stoichiometry in the
322 //! solids
323 /*!
324  * The constraint may have positive or negative values. The lattice 0 species will
325  * have negative values while higher lattices will have positive values
326  */
327 #define VCS_ELEM_TYPE_LATTICERATIO 3
328 
329 //! Constraint associated with maintaining frozen kinetic equilibria in
330 //! some functional groups within molecules
331 /*!
332  * We seek here to say that some functional groups or ionic states should be
333  * treated as if they are separate elements given the time scale of the problem.
334  * This will be abs positive constraint. We have not implemented any examples yet.
335  * A requirement will be that we must be able to add and subtract these constraints.
336  */
337 #define VCS_ELEM_TYPE_KINETICFROZEN 4
338 
339 //! Constraint associated with the maintenance of a surface phase
340 /*!
341  * We don't have any examples of this yet either. However, surfaces only exist
342  * because they are interfaces between bulk layers. If we want to treat surfaces
343  * within thermodynamic systems we must come up with a way to constrain their total
344  * number.
345  */
346 #define VCS_ELEM_TYPE_SURFACECONSTRAINT 5
347 //! Other constraint equations
348 /*!
349  * currently there are none
350  */
351 #define VCS_ELEM_TYPE_OTHERCONSTRAINT 6
352 //@}
353 
354 /*!
355  * @name Types of Species Unknowns in the problem
356  *
357  * @{
358  */
359 //! Unknown refers to mole number of a single species
360 #define VCS_SPECIES_TYPE_MOLNUM 0
361 
362 //! Unknown refers to the voltage level of a phase
363 /*!
364  * Typically, these species are electrons in metals. There is an
365  * infinite supply of them. However, their electrical potential
366  * is ddefined by the interface voltage.
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