34 for (
size_t i = 0; i < top; ++i) {
43 "Problem with charge neutrality condition");
53 bool multisign =
false;
92 elemAbundPhase[j] = 0.0;
110 plogf(
" --- vcsc_elcorr: Element abundances correction routine");
112 plogf(
" (m_numComponents != m_numElemConstraints)");
120 double l2before = 0.0;
122 l2before += x[i] * x[i];
124 l2before = sqrt(l2before/m_numElemConstraints);
133 bool changed =
false;
136 bool multisign =
false;
149 if (numNonZero < 2) {
160 int numCompNonZero = 0;
161 size_t compID =
npos;
171 if (numCompNonZero == 1) {
173 for (
size_t kspec = m_numComponents; kspec <
m_numSpeciesTot; kspec++) {
205 if (atomComp > 0.0) {
209 plogf(
" --- vcs_elcorr: Reduced species %s from %g to %g "
210 "due to %s max bounds constraint\n",
224 plogf(
" --- vcs_elcorr: Zeroed species %s and changed "
225 "status to %d due to max bounds constraint\n",
248 if (fabs(x[i]) > 1.0E-13) {
256 vector_int ipiv(std::min(m_numComponents, m_numElemConstraints));
257 ct_dgetrf(m_numComponents, m_numComponents, aa, m_numElemConstraints,
260 plogf(
"vcs_elcorr ERROR: matrix factorization\n");
261 return VCS_FAILED_CONVERGENCE;
263 ct_dgetrs(ctlapack::NoTranspose, m_numComponents, 1, aa,
264 m_numElemConstraints, &ipiv[0], x, m_numElemConstraints, info);
274 par = std::min(par, 100.0);
276 if (par < 1.0 && par > 0.0) {
327 double saveDir = 0.0;
328 bool goodSpec =
true;
331 if (fabs(dir) > 1.0E-10) {
420 bool useZeroed =
true;
469 double l2after = 0.0;
473 l2after = sqrt(l2after/m_numElemConstraints);
475 plogf(
" --- Elem_Abund: Correct Initial "
482 plogf(
" --- Diff_Norm: %20.12E %20.12E\n",
#define VCS_ELEM_TYPE_ELECTRONCHARGE
This refers to conservation of electrons.
std::vector< size_t > m_phaseID
Mapping from the species number to the phase number.
std::vector< int > m_elType
Type of the element constraint.
const size_t npos
index returned by functions to indicate "no position"
int vcs_elcorr(double aa[], double x[])
void vcs_elabPhase(size_t iphase, double *const elemAbundPhase)
double vcs_tmoles()
Calculates the total number of moles of species in all phases.
size_t m_numSpeciesRdc
Current number of species in the problems.
std::vector< double > m_molNumSpecies_old
Total moles of the species.
std::vector< int > vector_int
Vector of ints.
std::vector< std::string > m_elementName
Vector of strings containing the element names.
Header file for the internal object that holds the vcs equilibrium problem (see Class VCS_SOLVE and E...
#define VCS_SPECIES_ZEROEDSS
Species is a SS phase, that is currently zeroed out.
#define VCS_ELEM_TYPE_ABSPOS
Normal element constraint consisting of positive coefficients for the formula matrix.
#define VCS_DELETE_MINORSPECIES_CUTOFF
Cutoff relative mole number value, below which species are deleted from the equilibrium problem...
std::vector< double > m_elemAbundances
Element abundances vector.
size_t m_numElemConstraints
Number of element constraints in the problem.
size_t m_numSpeciesTot
Total number of species in the problems.
std::vector< int > m_speciesUnknownType
Specifies the species unknown type.
#define VCS_ELEM_TYPE_CHARGENEUTRALITY
This refers to a charge neutrality of a single phase.
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...
int m_debug_print_lvl
Debug printing lvl.
size_t m_numComponents
Number of components calculated for the problem.
void vcs_reinsert_deleted(size_t kspec)
std::vector< char > m_SSPhase
Boolean indicating whether a species belongs to a single-species phase.
std::vector< std::string > m_speciesName
Species string name for the kth species.
Array2D m_formulaMatrix
Formula matrix for the problem.
std::vector< int > m_elementActive
Specifies whether an element constraint is active.
void vcs_elab()
Computes the current elemental abundances vector.
void scale(InputIter begin, InputIter end, OutputIter out, S scale_factor)
Multiply elements of an array by a scale factor.
std::vector< int > m_speciesStatus
Major -Minor status vector for the species in the problem.
#define plogf
define this Cantera function to replace printf
#define VCS_SPECIES_TYPE_INTERFACIALVOLTAGE
Unknown refers to the voltage level of a phase.
std::vector< double > m_elemAbundancesGoal
Element abundances vector Goals.
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
bool vcs_elabcheck(int ibound)