Modified the algorithm to produce less minor-major species swaps.

This commit is contained in:
Harry Moffat 2008-05-19 21:21:40 +00:00
parent f344c89131
commit 6065f17b45
3 changed files with 64 additions and 28 deletions

View file

@ -40,8 +40,8 @@ namespace VCSnonideal {
* @param ss ss[j] = Gramm-Schmidt orthog work space (ne in length)
* @param test This is a small negative number.
*/
void VCS_SOLVE::inest(double * const aw, double * const sa, double * const sm,
double * const ss, double test) {
void VCS_SOLVE::vcs_inest(double * const aw, double * const sa, double * const sm,
double * const ss, double test) {
int conv, k, lt, ikl, kspec, iph, irxn;
double s;
double s1 = 0.0;
@ -448,8 +448,8 @@ namespace VCSnonideal {
plogendl();
}
#endif
inest(VCS_DATA_PTR(aw), VCS_DATA_PTR(sa), VCS_DATA_PTR(sm),
VCS_DATA_PTR(ss), test);
vcs_inest(VCS_DATA_PTR(aw), VCS_DATA_PTR(sa), VCS_DATA_PTR(sm),
VCS_DATA_PTR(ss), test);
/*
* Calculate the elemental abundances
*/

View file

@ -799,8 +799,8 @@ private:
* @param ss ss[j] = Gramm-Schmidt orthog work space (ne in length)
* @param test This is a small negative number.
*/
void inest(double * const aw, double * const sa, double * const sm,
double * const ss, double test);
void vcs_inest(double * const aw, double * const sa, double * const sm,
double * const ss, double test);
@ -1401,7 +1401,7 @@ public:
* - 3 one line per every successful solve_TP calculation
* - 4 one line for every successful operation -> solve_TP gets a summary report
* - 5 each iteration in solve_TP gets a report with one line per species
* - 6 Each decision in solve_TP gets a line in addition to 4
* - 6 Each decision in solve_TP gets a line per species in addition to 4
* - 10 Additionally Hessian matrix is printed out
*
* Levels of printing above 4 are only accessible when DEBUG_MODE is turned on

View file

@ -314,23 +314,59 @@ namespace VCSnonideal {
/************** EVALUATE INITIAL MAJOR-MINOR VECTOR **********************/
/*************************************************************************/
m_numRxnMinorZeroed = 0;
#ifdef DEBUG_MODE
if (m_debug_print_lvl >= 2) {
plogf(" --- MAJOR-MINOR decision is reavaluated: All species are minor except for:\n");
} else if (m_debug_print_lvl >= 5) {
plogf(" --- MAJOR-MINOR decision is reavaluated");
plogendl();
}
#endif
for (irxn = 0; irxn < m_numRxnRdc; ++irxn) {
kspec = m_indexRxnToSpecies[irxn];
m_rxnStatus[irxn] = vcs_species_type(kspec);
if (m_rxnStatus[irxn] == VCS_SPECIES_MINOR) {
m_rxnStatus[irxn] = VCS_SPECIES_MAJOR;
#ifdef DEBUG_MODE
if (m_debug_print_lvl >= 2) {
plogf(" --- Minor species changed to major: ");
plogf("%-12s", m_speciesName[kspec].c_str());
plogendl();
#ifdef DEBUG_MODE
if (m_debug_print_lvl >= 2) {
if (m_rxnStatus[irxn] != VCS_SPECIES_MINOR) {
switch (m_rxnStatus[irxn]) {
case VCS_SPECIES_MAJOR:
plogf(" --- Major Species : %-s\n", m_speciesName[kspec].c_str());
break;
case VCS_SPECIES_ZEROEDPHASE:
plogf(" --- Zeroed-Phase Species : %-s\n", m_speciesName[kspec].c_str());
break;
case VCS_SPECIES_ZEROEDMS:
plogf(" --- Zeroed-MS Phase Species: %-s\n", m_speciesName[kspec].c_str());
break;
case VCS_SPECIES_ZEROEDSS:
plogf(" --- Zeroed-SS Phase Species: %-s\n", m_speciesName[kspec].c_str());
break;
case VCS_SPECIES_DELETED:
plogf(" --- Deleted-Small Species : %-s\n", m_speciesName[kspec].c_str());
break;
case VCS_SPECIES_INTERFACIALVOLTAGE:
plogf(" --- InterfaceVoltage Species: %-s\n", m_speciesName[kspec].c_str());
break;
default:
plogf(" --- Unknown type - ERROR %d\n", m_rxnStatus[irxn]);
plogendl();
std::exit(-1);
}
}
#endif
}
#endif
if (m_rxnStatus[irxn] != VCS_SPECIES_MAJOR) {
++m_numRxnMinorZeroed;
}
}
#ifdef DEBUG_MODE
if (m_debug_print_lvl >= 2) {
plogf(" ---");
plogendl();
}
#endif
im = (m_numRxnMinorZeroed == m_numRxnRdc);
lec = FALSE;
if (! vcs_elabcheck(0)) {
@ -781,21 +817,21 @@ namespace VCSnonideal {
* we can't call vcs_species_type() because the phase moles
* would be wrong.
*/
if (m_molNumSpecies_new[kspec] < 0.005 * m_totalMolNum) {
iph = m_phaseID[kspec];
if (m_molNumSpecies_new[kspec] < (m_tPhaseMoles_old[iph] * 0.01)) {
// if (m_molNumSpecies_new[kspec] < 0.005 * m_totalMolNum) {
//iph = m_phaseID[kspec];
//if (m_molNumSpecies_new[kspec] < (m_tPhaseMoles_old[iph] * 0.01)) {
#ifdef DEBUG_MODE
if (m_debug_print_lvl >= 2) {
plogf(" --- Major species changed to minor: ");
plogf("%-12s", m_speciesName[kspec].c_str());
plogendl();
}
//if (m_debug_print_lvl >= 2) {
// plogf(" --- Major species changed to minor: ");
// plogf("%-12s", m_speciesName[kspec].c_str());
// plogendl();
//}
#endif
m_rxnStatus[irxn] = VCS_SPECIES_MINOR;
++m_numRxnMinorZeroed;
im = (m_numRxnMinorZeroed == m_numRxnRdc);
}
}
//m_rxnStatus[irxn] = VCS_SPECIES_MINOR;
//++m_numRxnMinorZeroed;
//im = (m_numRxnMinorZeroed == m_numRxnRdc);
//}
//}
} else {
/*
* Section for single species phases: