31 bool multisign =
false;
38 for (
size_t i = 0; i < top; ++i) {
47 "Problem with charge neutrality condition");
98 elemAbundPhase[j] = 0.0;
113 double xx, par, saveDir, dir;
116 double l2before = 0.0, l2after = 0.0;
120 plogf(
" --- vcsc_elcorr: Element abundances correction routine");
122 plogf(
" (m_numComponents != m_numElemConstraints)");
132 l2before += x[i] * x[i];
134 l2before = sqrt(l2before/m_numElemConstraints);
144 bool changed =
false;
145 bool multisign =
false;
161 if (numNonZero < 2) {
172 int numCompNonZero = 0;
173 size_t compID =
npos;
183 if (numCompNonZero == 1) {
185 for (
size_t kspec = m_numComponents; kspec <
m_numSpeciesTot; kspec++) {
217 if (atomComp > 0.0) {
223 plogf(
" --- vcs_elcorr: Reduced species %s from %g to %g "
224 "due to %s max bounds constraint\n",
240 plogf(
" --- vcs_elcorr: Zeroed species %s and changed "
241 "status to %d due to max bounds constraint\n",
265 if (fabs(x[i]) > 1.0E-13) {
272 int err =
vcsUtil_mlequ(aa, m_numElemConstraints, m_numComponents, x, 1);
274 plogf(
"vcs_elcorr ERROR: mlequ returned error condition\n");
275 return VCS_FAILED_CONVERGENCE;
293 if (par < 1.0 && par > 0.0) {
348 if (fabs(dir) > 1.0E-10) {
441 bool useZeroed =
true;
498 l2after = sqrt(l2after/m_numElemConstraints);
500 plogf(
" --- Elem_Abund: Correct Initial "
507 plogf(
" --- Diff_Norm: %20.12E %20.12E\n",
#define VCS_ELEM_TYPE_ELECTRONCHARGE
This refers to conservation of electrons.
void vcs_elab()
Computes the current elemental abundances vector.
size_t m_numComponents
Number of components calculated for the problem.
const size_t npos
index returned by functions to indicate "no position"
#define VCS_DATA_PTR(vvv)
Points to the data in a std::vector<> object.
void vcs_reinsert_deleted(size_t kspec)
int m_debug_print_lvl
Debug printing lvl.
std::vector< double > m_elemAbundancesGoal
Element abundances vector Goals.
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.
std::vector< double > m_elemAbundances
Element abundances vector.
int vcs_elcorr(double aa[], double x[])
#define VCS_DELETE_MINORSPECIES_CUTOFF
Cutoff relative mole number value, below which species are deleted from the equilibrium problem...
Internal declarations for the VCSnonideal package.
DoubleStarStar m_formulaMatrix
Formula matrix for the problem.
std::vector< double > m_molNumSpecies_old
Total moles of the species.
size_t m_numSpeciesTot
Total number of species in the problems.
int vcsUtil_mlequ(double *c, size_t idem, size_t n, double *b, size_t m)
Invert an n x n matrix and solve m rhs's.
#define VCS_ELEM_TYPE_CHARGENEUTRALITY
This refers to a charge neutrality of a single phase.
std::vector< std::string > m_elementName
Vector of strings containing the element names.
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...
std::vector< int > m_elementActive
Specifies whether an element constraint is active.
size_t m_numElemConstraints
Number of element constraints in the problem.
std::vector< int > m_speciesStatus
Major -Minor status vector for the species in the problem.
std::vector< size_t > m_phaseID
Mapping from the species number to the phase number.
double vcs_tmoles()
Calculates the total number of moles of species in all phases.
void vcs_elabPhase(size_t iphase, double *const elemAbundPhase)
void scale(InputIter begin, InputIter end, OutputIter out, S scale_factor)
Multiply elements of an array by a scale factor.
std::vector< char > m_SSPhase
Boolean indicating whether a species belongs to a single-species phase.
bool vcs_elabcheck(int ibound)
#define plogf
define this Cantera function to replace printf
std::vector< int > m_elType
Type of the element constraint.
#define VCS_SPECIES_TYPE_INTERFACIALVOLTAGE
Unknown refers to the voltage level of a phase.
std::vector< int > m_speciesUnknownType
Specifies the species unknown type.
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
std::vector< std::string > m_speciesName
Species string name for the kth species.
size_t m_numSpeciesRdc
Current number of species in the problems.