00001 /** 00002 * @file vcs_defs.h 00003 * Defines and definitions within the vcs package 00004 */ 00005 /* 00006 * $Id: vcs_defs.h 368 2010-01-04 00:46:26Z hkmoffa $ 00007 */ 00008 00009 /* 00010 * Copywrite (2005) Sandia Corporation. Under the terms of 00011 * Contract DE-AC04-94AL85000 with Sandia Corporation, the 00012 * U.S. Government retains certain rights in this software. 00013 */ 00014 00015 #ifndef VCS_DEFS_H 00016 #define VCS_DEFS_H 00017 00018 namespace VCSnonideal { 00019 00020 /* 00021 * COMMON DEFINITIONS -> Protect them against redefinitions 00022 */ 00023 //@{ 00024 #ifndef TRUE 00025 # define TRUE 1 00026 #endif 00027 00028 #ifndef FALSE 00029 # define FALSE 0 00030 #endif 00031 00032 #ifndef MAX 00033 # define MAX(x,y) (( (x) > (y) ) ? (x) : (y)) 00034 #endif 00035 00036 #ifndef MIN 00037 # define MIN(x,y) (( (x) < (y) ) ? (x) : (y)) 00038 #endif 00039 00040 #ifndef SWAP 00041 # define SWAP(x1, x2, temp) ((temp) = (x1), (x1) = (x2), (x2) = (temp)) 00042 #endif 00043 00044 #ifndef SQUARE 00045 # define SQUARE(x) ((x) * (x)) 00046 #endif 00047 00048 #ifndef DSIGN 00049 # define DSIGN(x) (( (x) == (0.0) ) ? (0.0) : ( ((x) > 0.0) ? 1.0 : -1.0 )) 00050 #endif 00051 00052 //@} 00053 00054 /*! 00055 * ERROR CODES 00056 * 00057 */ 00058 //@{ 00059 #define VCS_SUCCESS 0 00060 #define VCS_NOMEMORY 1 00061 #define VCS_FAILED_CONVERGENCE -1 00062 #define VCS_SHOULDNT_BE_HERE -2 00063 #define VCS_PUB_BAD -3 00064 #define VCS_THERMO_OUTOFRANGE -4 00065 #define VCS_FAILED_LOOKUP -5 00066 #define VCS_MP_FAIL -6 00067 //@} 00068 00069 /*! 00070 * @name Type of the underlying equilibrium solve 00071 * 00072 * @{ 00073 */ 00074 00075 //! Current, it is always done holding T and P constant. 00076 #define VCS_PROBTYPE_TP 0 00077 //@} 00078 00079 /*! 00080 * @name Sizes of Phases and Cutoff Mole Numbers 00081 * 00082 * @{ 00083 */ 00084 00085 //! Cutoff relative mole fraction value, 00086 //! below which species are deleted from the equilibrium problem. 00087 #ifndef VCS_RELDELETE_SPECIES_CUTOFF 00088 #define VCS_RELDELETE_SPECIES_CUTOFF 1.0e-64 00089 #endif 00090 00091 //! Cutoff relative mole number value, 00092 //! below which species are deleted from the equilibrium problem. 00093 #ifndef VCS_DELETE_MINORSPECIES_CUTOFF 00094 #define VCS_DELETE_MINORSPECIES_CUTOFF 1.0e-140 00095 #endif 00096 00097 //! Relative value of multiphase species mole number for a 00098 //! multiphase species which is small. 00099 #ifndef VCS_SMALL_MULTIPHASE_SPECIES 00100 #define VCS_SMALL_MULTIPHASE_SPECIES 1.0e-25 00101 #endif 00102 00103 //! Cutoff relative moles below which a phase is deleted 00104 //! from the equilibrium problem. 00105 #ifndef VCS_DELETE_PHASE_CUTOFF 00106 #define VCS_DELETE_PHASE_CUTOFF 1.0e-12 00107 #endif 00108 00109 //! Cutoff moles below which a phase or species which 00110 //! comprises the bulk of an element's total concentration 00111 //! is deleted. 00112 #ifndef VCS_DELETE_ELEMENTABS_CUTOFF 00113 #define VCS_DELETE_ELEMENTABS_CUTOFF 1.0e-280 00114 #endif 00115 00116 //@} 00117 00118 /*! 00119 * @name State of Dimensional Units for Gibbs free energies 00120 * 00121 * @{ 00122 */ 00123 //! nondimensional 00124 #define VCS_NONDIMENSIONAL_G 1 00125 //! dimensioned 00126 #define VCS_DIMENSIONAL_G 0 00127 //@} 00128 00129 00130 //! @name Species Categories used during the iteration 00131 /*! 00132 * These defines are valid values for spStatus() 00133 */ 00134 //@{ 00135 //! Species is a component 00136 #define VCS_SPECIES_COMPONENT 2 00137 00138 //! Species is a major species 00139 /*! 00140 * A major species is either a species in a multicomponent phase with 00141 * significant concentration or its a Stoich Phase 00142 */ 00143 #define VCS_SPECIES_MAJOR 1 00144 00145 //! Species is a major species 00146 /*! 00147 * A major species is either a species in a multicomponent phase with 00148 * significant concentration or its a Stoich Phase 00149 */ 00150 #define VCS_SPECIES_MINOR 0 00151 00152 //! Species lies in a multicomponent phase, with a small phase concentration 00153 /*! 00154 * The species lies in a multicomponent phase that exists. 00155 * It concentration is currently very low, necessitating a 00156 * different method of calculation. 00157 */ 00158 #define VCS_SPECIES_SMALLMS -1 00159 00160 //! Species lies in a multicomponent phase with concentration zero 00161 /*! 00162 * The species lies in a multicomponent phase which currently doesn't exist. 00163 * It concentration is currently zero. 00164 */ 00165 #define VCS_SPECIES_ZEROEDMS -2 00166 00167 //! Species is a SS phase, that is currently zeroed out. 00168 /*! 00169 * The species lies in a single-species phase which 00170 * is currently zereod out. 00171 */ 00172 #define VCS_SPECIES_ZEROEDSS -3 00173 00174 //! Species has such a small mole fraction it is deleted even though its 00175 //! phase may possibly exist. 00176 /*! 00177 * The species is believed to have such a small mole fraction 00178 * that it best to throw the calculation of it out. 00179 * It will be added back in at the end of the calculation. 00180 */ 00181 #define VCS_SPECIES_DELETED -4 00182 00183 //! Species refers to an electron in the metal 00184 /*! 00185 * The unknown is equal to the interfacial voltage 00186 * drop across the interface on the SHE (standard 00187 * hyrdogen electrode) scale (volts). 00188 */ 00189 #define VCS_SPECIES_INTERFACIALVOLTAGE -5 00190 00191 //! Species lies in a multicomponent phase that is zeroed atm 00192 /*! 00193 * The species lies in a multicomponent phase that is currently 00194 * deleted and will stay deleted due to a choice from a higher level. 00195 * These species will formally always have zero mole numbers in the 00196 * solution vector. 00197 */ 00198 #define VCS_SPECIES_ZEROEDPHASE -6 00199 00200 //! Species lies in a multicomponent phase that is active, but species concentration is zero 00201 /*! 00202 * The species lies in a multicomponent phase which currently does exist. 00203 * It concentration is currently identically zero, though the phase exists. Note, this 00204 * is a temporary condition that exists at the start of an equilibrium problem. 00205 * The species is soon "birthed" or "deleted". 00206 */ 00207 #define VCS_SPECIES_ACTIVEBUTZERO -7 00208 00209 //! Species lies in a multicomponent phase that is active, 00210 //! but species concentration is zero due to stoich constraint 00211 /*! 00212 * The species lies in a multicomponent phase which 00213 * currently does exist. Its concentration is currently 00214 * identically zero, though the phase exists. This is 00215 * a permament condition due to stoich constraints 00216 */ 00217 #define VCS_SPECIES_STOICHZERO -8 00218 00219 //@} 00220 00221 //! @name Phase Categories used during the iteration 00222 /*! 00223 * These defines are valid values for the phase existence flag 00224 */ 00225 //@{ 00226 //! Always exists because it contains inerts which can't exist in any other phase 00227 #define VCS_PHASE_EXIST_ALWAYS 3 00228 00229 //! Phase is a normal phase that currently exists 00230 #define VCS_PHASE_EXIST_YES 2 00231 00232 //! Phase is a normal phase that exists in a small concentration 00233 /*! 00234 * Concentration is so small that it must be calculated using an alternate 00235 * method 00236 */ 00237 #define VCS_PHASE_EXIST_MINORCONC 1 00238 00239 //! Phase doesn't currently exist in the mixture 00240 #define VCS_PHASE_EXIST_NO 0 00241 00242 //! Phase currently is zeroed due to a programmatic issue 00243 /*! 00244 * We zero phases because we want to follow phase stability boundaries. 00245 */ 00246 #define VCS_PHASE_EXIST_ZEROEDPHASE -6 00247 00248 //@} 00249 00250 /*! 00251 * @name Units for the chemical potential data and pressure variables 00252 * 00253 * @verbatim 00254 Chem_Pot Pres vol moles 00255 ------------------------------------------------- 00256 VCS_UNITS_KCALMOL = kcal/mol Pa m**3 kmol 00257 VCS_UNITS_UNITLESS = MU / RT -> no units Pa m**3 kmol 00258 VCS_UNITS_KJMOL = kJ / mol Pa m**3 kmol 00259 VCS_UNITS_KELVIN = KELVIN -> MU / R Pa m**3 kmol 00260 VCS_UNITS_MKS = Joules / Kmol (Cantera) Pa m**3 kmol 00261 00262 Energy: 00263 VCS_UNITS_KCALMOL = kcal/mol 00264 VCS_UNITS_UNITLESS = MU / RT -> no units 00265 VCS_UNITS_KJMOL = kJ / mol 00266 VCS_UNITS_KELVIN = KELVIN -> MU / R 00267 VCS_UNITS_MKS = J / kmol 00268 00269 Pressure: (Pref and Pres) 00270 VCS_UNITS_KCALMOL = Pa 00271 VCS_UNITS_UNITLESS = Pa 00272 VCS_UNITS_KJMOL = Pa 00273 VCS_UNITS_KELVIN = Pa 00274 VCS_UNITS_MKS = Pa = kg / m s2 00275 @endverbatim 00276 * @{ 00277 */ 00278 #define VCS_UNITS_KCALMOL -1 00279 #define VCS_UNITS_UNITLESS 0 00280 #define VCS_UNITS_KJMOL 1 00281 #define VCS_UNITS_KELVIN 2 00282 #define VCS_UNITS_MKS 3 00283 //@} 00284 00285 /*! 00286 * @name Types of Element Constraint Equations 00287 * 00288 * There may be several different types of element constraints handled 00289 * by the equilibrium program. These defines are used to assign each 00290 * constraint to one category. 00291 * @{ 00292 */ 00293 //! Normal element constraint consisting of positive coefficients for the 00294 //! formula matrix. 00295 /*! 00296 * All species have positive coefficients within the formula matrix. 00297 * With this constraint, we may employ various strategies to handle 00298 * small values of the element number successfully. 00299 */ 00300 #define VCS_ELEM_TYPE_ABSPOS 0 00301 00302 //! This refers to conservation of electrons 00303 /*! 00304 * Electrons may have positive or negative values in the Formula matrix. 00305 */ 00306 #define VCS_ELEM_TYPE_ELECTRONCHARGE 1 00307 00308 //! This refers to a charge neutrality of a single phase 00309 /*! 00310 * Charge neutrality may have positive or negative values in the Formula matrix. 00311 */ 00312 #define VCS_ELEM_TYPE_CHARGENEUTRALITY 2 00313 00314 //! Other constraint equations 00315 /*! 00316 * currently there are none 00317 */ 00318 #define VCS_ELEM_TYPE_OTHERCONSTRAINT 3 00319 //@} 00320 00321 /*! 00322 * @name Types of Species Unknowns in the problem 00323 * 00324 * @{ 00325 */ 00326 //! Unknown refers to mole number of a single species 00327 #define VCS_SPECIES_TYPE_MOLNUM 0 00328 00329 //! Unknown refers to the voltage level of a phase 00330 /*! 00331 * Typically, these species are electrons in metals. There is an 00332 * infinite supply of them. However, their electrical potential 00333 * is ddefined by the interface voltage. 00334 */ 00335 #define VCS_SPECIES_TYPE_INTERFACIALVOLTAGE -5 00336 //@} 00337 00338 /*! 00339 * @name Types of State Calculations within VCS 00340 * These values determine where the 00341 * results are storred within the VCS_SOLVE 00342 * object. 00343 * @{ 00344 */ 00345 //! State Calculation is currently in an unknown state 00346 #define VCS_STATECALC_UNKNOWN -1 00347 //! State Calculation based on the old or base mole numbers 00348 #define VCS_STATECALC_OLD 0 00349 00350 //! State Calculation based on the new or tentative mole numbers 00351 #define VCS_STATECALC_NEW 1 00352 00353 //! State Calculation based on tentative mole numbers 00354 //! for a phase which is currently zeroed, but is being 00355 //! evaluated for whether it should pop back into existence 00356 #define VCS_STATECALC_PHASESTABILITY 2 00357 00358 //! State Calculation based on a temporary set of mole numbers 00359 #define VCS_STATECALC_TMP 3 00360 //@} 00361 00362 00363 } 00364 00365 #endif