19 for (
size_t j = 0; j <
m_nelem; ++j) {
21 for (
size_t i = 0; i <
m_nsp; ++i) {
36 for (
size_t i = 0; i < top; ++i) {
43 "Problem with charge neutrality condition");
52 bool multisign =
false;
53 for (
size_t kspec = 0; kspec <
m_nsp; kspec++) {
87 for (
size_t j = 0; j <
m_nelem; ++j) {
88 elemAbundPhase[j] = 0.0;
89 for (
size_t i = 0; i <
m_nsp; ++i) {
103 plogf(
" --- vcsc_elcorr: Element abundances correction routine");
105 plogf(
" (m_numComponents != m_nelem)");
110 for (
size_t i = 0; i <
m_nelem; ++i) {
113 double l2before = 0.0;
114 for (
size_t i = 0; i <
m_nelem; ++i) {
115 l2before += x[i] * x[i];
117 l2before = sqrt(l2before/
m_nelem);
122 bool changed =
false;
123 for (
size_t i = 0; i <
m_nelem; ++i) {
125 bool multisign =
false;
126 for (
size_t kspec = 0; kspec <
m_nsp; kspec++) {
138 if (numNonZero < 2) {
139 for (
size_t kspec = 0; kspec <
m_nsp; kspec++) {
149 int numCompNonZero = 0;
150 size_t compID =
npos;
160 if (numCompNonZero == 1) {
186 for (
size_t i = 0; i <
m_nelem; ++i) {
189 for (
size_t kspec = 0; kspec <
m_nsp; kspec++) {
192 if (atomComp > 0.0) {
196 plogf(
" --- vcs_elcorr: Reduced species %s from %g to %g "
197 "due to %s max bounds constraint\n",
211 plogf(
" --- vcs_elcorr: Zeroed species %s and changed "
212 "status to %d due to max bounds constraint\n",
233 if (fabs(x[i]) > 1.0E-13) {
250 par = std::min(par, 100.0);
252 if (par < 1.0 && par > 0.0) {
291 for (
size_t kspec = 0; kspec <
m_nsp; kspec++) {
295 double saveDir = 0.0;
296 bool goodSpec =
true;
299 if (fabs(dir) > 1.0E-10) {
351 for (
size_t i = 0; i <
m_nelem; ++i) {
377 for (
size_t i = 0; i <
m_nelem; ++i) {
380 bool useZeroed =
true;
420 double l2after = 0.0;
421 for (
size_t i = 0; i <
m_nelem; ++i) {
424 l2after = sqrt(l2after/
m_nelem);
426 plogf(
" --- Elem_Abund: Correct Initial "
428 for (
size_t i = 0; i <
m_nelem; ++i) {
433 plogf(
" --- Diff_Norm: %20.12E %20.12E\n",
Headers for the DenseMatrix object, which deals with dense rectangular matrices and description of th...
Base class for exceptions thrown by Cantera classes.
A class for full (non-sparse) matrices with Fortran-compatible data storage, which adds matrix operat...
std::vector< std::string > m_speciesName
Species string name for the kth species.
vector_int m_elType
Type of the element constraint.
size_t m_nelem
Number of element constraints in the problem.
vector_int m_speciesStatus
Major -Minor status vector for the species in the problem.
int vcs_elcorr(double aa[], double x[])
vector_fp m_molNumSpecies_old
Total moles of the species.
vector_fp m_elemAbundances
Element abundances vector.
vector_int m_speciesUnknownType
Specifies the species unknown type.
void vcs_elab()
Computes the current elemental abundances vector.
void vcs_elabPhase(size_t iphase, double *const elemAbundPhase)
size_t m_numSpeciesRdc
Current number of species in the problems.
int m_debug_print_lvl
Debug printing lvl.
vector_fp m_elemAbundancesGoal
Element abundances vector Goals.
void vcs_reinsert_deleted(size_t kspec)
std::vector< size_t > m_phaseID
Mapping from the species number to the phase number.
Array2D m_formulaMatrix
Formula matrix for the problem.
size_t m_numComponents
Number of components calculated for the problem.
vector_int m_elementActive
Specifies whether an element constraint is active.
std::vector< char > m_SSPhase
Boolean indicating whether a species belongs to a single-species phase.
size_t m_nsp
Total number of species in the problems.
bool vcs_elabcheck(int ibound)
double vcs_tmoles()
Calculates the total number of moles of species in all phases.
std::vector< std::string > m_elementName
Vector of strings containing the element names.
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
const size_t npos
index returned by functions to indicate "no position"
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
Namespace for the Cantera kernel.
void scale(InputIter begin, InputIter end, OutputIter out, S scale_factor)
Multiply elements of an array by a scale factor.
int solve(DenseMatrix &A, double *b, size_t nrhs, size_t ldb)
Solve Ax = b. Array b is overwritten on exit with x.
#define VCS_SPECIES_TYPE_INTERFACIALVOLTAGE
Unknown refers to the voltage level of a phase.
#define VCS_DELETE_MINORSPECIES_CUTOFF
Cutoff relative mole number value, below which species are deleted from the equilibrium problem.
#define VCS_ELEM_TYPE_ABSPOS
Normal element constraint consisting of positive coefficients for the formula matrix.
#define VCS_SPECIES_ACTIVEBUTZERO
Species lies in a multicomponent phase that is active, but species concentration is zero.
#define VCS_ELEM_TYPE_ELECTRONCHARGE
This refers to conservation of electrons.
#define VCS_SPECIES_ZEROEDSS
Species is a SS phase, that is currently zeroed out.
#define VCS_ELEM_TYPE_CHARGENEUTRALITY
This refers to a charge neutrality of a single phase.
#define plogf
define this Cantera function to replace printf
Header file for the internal object that holds the vcs equilibrium problem (see Class VCS_SOLVE and E...