25 size_t len = vec.size();
30 std::vector<double>::const_iterator pos;
31 for (pos = vec.begin(); pos != vec.end(); ++pos) {
32 sum += (*pos) * (*pos);
34 return std::sqrt(sum / len);
37 size_t vcs_optMax(
const double* x,
const double* xSize,
size_t j,
size_t n)
42 assert(xSize[j] > 0.0);
44 for (
size_t i = j + 1; i < n; ++i) {
45 assert(xSize[i] > 0.0);
46 if ((x[i] * xSize[i]) > big) {
48 big = x[i] * xSize[i];
52 for (
size_t i = j + 1; i < n; ++i) {
64 warn_deprecated(
"vcs_max_int",
"Unused. To be removed after Cantera 2.2.");
66 if (vector == NULL || length <= 0) {
70 for (
int i = 1; i < length; i++) {
71 retn = std::max(retn, vector[i]);
79 case VCS_UNITS_KCALMOL:
81 case VCS_UNITS_UNITLESS:
84 return GasConstant * 1e-6;
85 case VCS_UNITS_KELVIN:
92 "uknown units: " +
int2str(mu_units));
98 switch (speciesStatus) {
100 return "Component Species";
102 return "Major Species";
104 return "Minor Species";
107 return "Set Zeroed-Phase";
109 return "Purposely Zeroed-Phase Species (not in problem)";
113 return "Zeroed-MS Phase";
115 return "Zeroed-MS Phase Species";
119 return "Zeroed-SS Phase";
121 return "Zeroed-SS Phase Species";
125 return "Deleted Species";
126 }
else if (length < 40) {
127 return "Deleted-Small Species";
129 return "Deleted-Small Species in a MS phase";
133 return "Tmp Zeroed in MS";
135 return "Zeroed Species in an active MS phase (tmp)";
139 return "Stoich Zeroed in MS";
141 return "Zeroed Species in an active MS phase (Stoich Constraint)";
145 return "InterfaceVoltage";
147 return "InterfaceVoltage Species";
150 return "unknown species type";
156 size_t ls = 0, rs = 0;
157 size_t len = strlen(str);
158 if ((len) >= space) {
159 for (
size_t i = 0; i < space; i++) {
163 if (alignment == 1) {
165 }
else if (alignment == 2) {
168 ls = (space - len) / 2;
169 rs = space - len - ls;
172 for (
size_t i = 0; i < ls; i++) {
178 for (
size_t i = 0; i < rs; i++) {
187 double denom = fabs(d1) + fabs(d2) + 1.0;
188 double fac = fabs(d1 - d2) / denom;
bool vcs_doubleEqual(double d1, double d2)
Simple routine to check whether two doubles are equal up to roundoff error.
std::string int2str(const int n, const std::string &fmt)
Convert an int to a string using a format converter.
int vcs_max_int(const int *vector, int length)
Returns the maximum integer in a list.
#define VCS_SPECIES_ZEROEDMS
Species lies in a multicomponent phase with concentration zero.
#define VCS_SPECIES_MINOR
Species is a major species.
void warn_deprecated(const std::string &method, const std::string &extra)
Print a warning indicating that method is deprecated.
double vcsUtil_gasConstant(int mu_units)
Returns the value of the gas constant in the units specified by parameter.
#define VCS_SPECIES_INTERFACIALVOLTAGE
Species refers to an electron in the metal.
#define VCS_SPECIES_ZEROEDSS
Species is a SS phase, that is currently zeroed out.
Defines and definitions within the vcs package.
#define VCS_SPECIES_ZEROEDPHASE
Species lies in a multicomponent phase that is zeroed atm.
Internal declarations for the VCSnonideal package.
double vcs_l2norm(const std::vector< double > vec)
determine the l2 norm of a vector of doubles
void vcs_print_stringTrunc(const char *str, size_t space, int alignment)
Print a string within a given space limit.
Base class for exceptions thrown by Cantera classes.
#define VCS_SPECIES_ACTIVEBUTZERO
Species lies in a multicomponent phase that is active, but species concentration is zero...
#define VCS_SPECIES_MAJOR
Species is a major species.
#define VCS_SPECIES_STOICHZERO
Species lies in a multicomponent phase that is active, but species concentration is zero due to stoic...
size_t vcs_optMax(const double *x, const double *xSize, size_t j, size_t n)
Finds the location of the maximum component in a double vector.
Contains declarations for string manipulation functions within Cantera.
const doublereal GasConst_cal_mol_K
Universal gas constant in cal/mol/K.
const char * vcs_speciesType_string(int speciesStatus, int length)
Returns a const char string representing the type of the species given by the first argument...
#define plogf
define this Cantera function to replace printf
#define VCS_SPECIES_COMPONENT
Species is a component which can be nonzero.
#define VCS_SPECIES_DELETED
Species has such a small mole fraction it is deleted even though its phase may possibly exist...
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...