From aa50717d7b6162ede9b139b55233ad6356b9a701 Mon Sep 17 00:00:00 2001 From: Harry Moffat Date: Wed, 16 Apr 2008 22:07:36 +0000 Subject: [PATCH] Fixed an issue with the interface for specifying whether the solution is estimated or not. --- Cantera/src/equil/vcs_MultiPhaseEquil.cpp | 8 +++--- Cantera/src/equil/vcs_TP.cpp | 2 +- Cantera/src/equil/vcs_inest.cpp | 33 +++++++++++++++-------- 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/Cantera/src/equil/vcs_MultiPhaseEquil.cpp b/Cantera/src/equil/vcs_MultiPhaseEquil.cpp index 0ff824c79..d8133a091 100644 --- a/Cantera/src/equil/vcs_MultiPhaseEquil.cpp +++ b/Cantera/src/equil/vcs_MultiPhaseEquil.cpp @@ -598,9 +598,9 @@ namespace VCSnonideal { // Set the estimation technique if (estimateEquil) { - m_vprob->iest = 0; - } else { m_vprob->iest = -1; + } else { + m_vprob->iest = 0; } // Check obvious bounds on the temperature and pressure @@ -1097,7 +1097,7 @@ namespace VCSnonideal { vprob->m_VCS_UnitsFormat = VCS_UNITS_MKS; // Set the initial estimate to a machine generated estimate for now // We will work out the details later. - vprob->iest = 0; + vprob->iest = -1; vprob->T = mphase->temperature(); vprob->Pres = mphase->pressure(); vprob->Vol = mphase->volume(); @@ -1477,7 +1477,7 @@ namespace VCSnonideal { vprob->prob_type = 0; // Whether we have an estimate or not gets overwritten on // the call to the equilibrium solver. - vprob->iest = 0; + vprob->iest = -1; vprob->T = mphase->temperature(); vprob->Pres = mphase->pressure(); vprob->Vol = mphase->volume(); diff --git a/Cantera/src/equil/vcs_TP.cpp b/Cantera/src/equil/vcs_TP.cpp index 34203c60f..beaa9c1b0 100644 --- a/Cantera/src/equil/vcs_TP.cpp +++ b/Cantera/src/equil/vcs_TP.cpp @@ -76,7 +76,7 @@ int VCS_SOLVE::vcs_TP(int ipr, int ip1, int maxit, double T_arg, double pres_arg * Decide whether we need an initial estimate of the solution * If so, go get one. If not, then */ - if (iest) { + if (iest == -1) { retn = vcs_inest_TP(); if (retn != VCS_SUCCESS) { plogf("vcs_inest_TP returned a failure flag\n"); diff --git a/Cantera/src/equil/vcs_inest.cpp b/Cantera/src/equil/vcs_inest.cpp index 273e07cf5..5154579c6 100644 --- a/Cantera/src/equil/vcs_inest.cpp +++ b/Cantera/src/equil/vcs_inest.cpp @@ -108,8 +108,9 @@ namespace VCSnonideal { plogf(" %15.5g %12.3g\n", molNum[kspec], -ff[kspec]); } plogf("%s Element Abundance Agreement returned from linear " - "programming (vcs_inest initial guess):\n", + "programming (vcs_inest initial guess):", pprefix); + plogendl(); plogf("%s Element Goal Actual\n", pprefix); int jj = 0; for (int j = 0; j < m_numElemConstraints; j++) { @@ -123,6 +124,7 @@ namespace VCSnonideal { jj++; } } + plogendl(); } #endif @@ -272,7 +274,7 @@ namespace VCSnonideal { plogf(" (ssPhase doesn't exist -> stability not checked)"); } } - plogf("\n"); + plogendl(); } } } @@ -372,7 +374,8 @@ namespace VCSnonideal { plogf("%s SPECIES MOLE_NUMBER\n", pprefix); for (kspec = 0; kspec < nspecies; ++kspec) { plogf("%s ", pprefix); plogf("%-12.12s", SpName[kspec].c_str()); - plogf(" %g\n", molNum[kspec]); + plogf(" %g", molNum[kspec]); + plogendl(); } } #endif @@ -421,8 +424,9 @@ namespace VCSnonideal { */ #ifdef DEBUG_MODE if (vcs_debug_print_lvl >= 2) { - plogf("%sGo find an initial estimate for the equilibrium problem\n", + plogf("%sGo find an initial estimate for the equilibrium problem", pprefix); + plogendl(); } #endif inest(VCS_DATA_PTR(aw), VCS_DATA_PTR(sa), VCS_DATA_PTR(sm), @@ -446,7 +450,8 @@ namespace VCSnonideal { #ifdef DEBUG_MODE if (vcs_debug_print_lvl >= 2) { plogf("%sInitial guess failed element abundances\n", pprefix); - plogf("%sCall vcs_elcorr to attempt fix\n", pprefix); + plogf("%sCall vcs_elcorr to attempt fix", pprefix); + plogendl(); } #endif vcs_elcorr(VCS_DATA_PTR(sm), VCS_DATA_PTR(aw)); @@ -455,18 +460,21 @@ namespace VCSnonideal { plogf("%sInitial guess still fails element abundance equations\n", pprefix); plogf("%s - Inability to ever satisfy element abundance " - "constraints is probable\n", pprefix); + "constraints is probable", pprefix); + plogendl(); retn = -1; } else { #ifdef DEBUG_MODE if (vcs_debug_print_lvl >= 2) { if (rangeCheck) { - plogf("%sInitial guess now satisfies element abundances\n", pprefix); + plogf("%sInitial guess now satisfies element abundances", pprefix); + plogendl(); } else { plogf("%sElement Abundances RANGE ERROR\n", pprefix); plogf("%s - Initial guess satisfies NC=%d element abundances, " - "BUT not NE=%d element abundances\n", pprefix, + "BUT not NE=%d element abundances", pprefix, m_numComponents, m_numElemConstraints); + plogendl(); } } #endif @@ -476,12 +484,14 @@ namespace VCSnonideal { #ifdef DEBUG_MODE if (vcs_debug_print_lvl >= 2) { if (rangeCheck) { - plogf("%sInitial guess satisfies element abundances\n", pprefix); + plogf("%sInitial guess satisfies element abundances", pprefix); + plogendl(); } else { plogf("%sElement Abundances RANGE ERROR\n", pprefix); plogf("%s - Initial guess satisfies NC=%d element abundances, " - "BUT not NE=%d element abundances\n", pprefix, + "BUT not NE=%d element abundances", pprefix, m_numComponents, m_numElemConstraints); + plogendl(); } } #endif @@ -489,9 +499,10 @@ namespace VCSnonideal { #ifdef DEBUG_MODE if (vcs_debug_print_lvl >= 2) { - plogf("%sTotal Dimensionless Gibbs Free Energy = %15.7E\n", pprefix, + plogf("%sTotal Dimensionless Gibbs Free Energy = %15.7E", pprefix, vcs_Total_Gibbs(VCS_DATA_PTR(soln), VCS_DATA_PTR(m_gibbsSpecies), VCS_DATA_PTR(TPhMoles))); + plogendl(); } #endif