MCPcopy Create free account
hub / github.com/Cantera/cantera / vcs_prep

Method vcs_prep

src/equil/vcs_solve.cpp:1472–1625  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1470}
1471
1472int VCS_SOLVE::vcs_prep(int printLvl)
1473{
1474 int retn = VCS_SUCCESS;
1475 m_debug_print_lvl = printLvl;
1476
1477 // Calculate the Single Species status of phases
1478 // Also calculate the number of species per phase
1479 vcs_SSPhase();
1480
1481 // Set an initial estimate for the number of noncomponent species equal to
1482 // nspecies - nelements. This may be changed below
1483 if (m_nelem > m_nsp) {
1484 m_numRxnTot = 0;
1485 } else {
1486 m_numRxnTot = m_nsp - m_nelem;
1487 }
1488 m_numRxnRdc = m_numRxnTot;
1489 m_numSpeciesRdc = m_nsp;
1490 for (size_t i = 0; i < m_numRxnRdc; ++i) {
1491 m_indexRxnToSpecies[i] = m_nelem + i;
1492 }
1493
1494 for (size_t kspec = 0; kspec < m_nsp; ++kspec) {
1495 size_t pID = m_phaseID[kspec];
1496 size_t spPhIndex = m_speciesLocalPhaseIndex[kspec];
1497 vcs_VolPhase* vPhase = m_VolPhaseList[pID].get();
1498 vcs_SpeciesProperties* spProp = vPhase->speciesProperty(spPhIndex);
1499 double sz = 0.0;
1500 size_t eSize = spProp->FormulaMatrixCol.size();
1501 for (size_t e = 0; e < eSize; e++) {
1502 sz += fabs(spProp->FormulaMatrixCol[e]);
1503 }
1504 if (sz > 0.0) {
1505 m_spSize[kspec] = sz;
1506 } else {
1507 m_spSize[kspec] = 1.0;
1508 }
1509 }
1510
1511 // DETERMINE THE NUMBER OF COMPONENTS
1512 //
1513 // Obtain a valid estimate of the mole fraction. This will be used as an
1514 // initial ordering vector for prioritizing which species are defined as
1515 // components.
1516 //
1517 // If a mole number estimate was supplied from the input file, use that mole
1518 // number estimate.
1519 //
1520 // If a solution estimate wasn't supplied from the input file, supply an
1521 // initial estimate for the mole fractions based on the relative reverse
1522 // ordering of the chemical potentials.
1523 //
1524 // For voltage unknowns, set these to zero for the moment.
1525 double test = -1.0e-10;
1526 bool modifiedSoln = false;
1527 if (m_doEstimateEquil < 0) {
1528 double sum = 0.0;
1529 for (size_t kspec = 0; kspec < m_nsp; ++kspec) {

Callers

nothing calls this directly

Calls 7

speciesPropertyMethod · 0.80
elementMolesMethod · 0.80
getMethod · 0.45
sizeMethod · 0.45
resizeMethod · 0.45
zeroMethod · 0.45
nElementsMethod · 0.45

Tested by

no test coverage detected