Fixed signed/unsigned comparison warnings in VCS Equilibrium solver
This commit is contained in:
parent
45eb5702e6
commit
d4b4cec673
18 changed files with 141 additions and 160 deletions
|
|
@ -35,7 +35,7 @@ namespace VCSnonideal {
|
|||
{
|
||||
double g = 0.0;
|
||||
|
||||
for (int iph = 0; iph < m_numPhases; iph++) {
|
||||
for (size_t iph = 0; iph < m_numPhases; iph++) {
|
||||
vcs_VolPhase *Vphase = m_VolPhaseList[iph];
|
||||
if ((TPhInertMoles[iph] > 0.0) && (tPhMoles[iph] > 0.0)) {
|
||||
g += TPhInertMoles[iph] *
|
||||
|
|
@ -46,7 +46,7 @@ namespace VCSnonideal {
|
|||
}
|
||||
}
|
||||
|
||||
for (int kspec = 0; kspec < m_numSpeciesRdc; ++kspec) {
|
||||
for (size_t kspec = 0; kspec < m_numSpeciesRdc; ++kspec) {
|
||||
if (m_speciesUnknownType[kspec] != VCS_SPECIES_TYPE_INTERFACIALVOLTAGE) {
|
||||
g += molesSp[kspec] * chemPot[kspec];
|
||||
}
|
||||
|
|
@ -68,7 +68,7 @@ namespace VCSnonideal {
|
|||
const double * const fe) {
|
||||
double g = 0.0;
|
||||
double phaseMols = 0.0;
|
||||
for (int kspec = 0; kspec < m_numSpeciesRdc; ++kspec) {
|
||||
for (size_t kspec = 0; kspec < m_numSpeciesRdc; ++kspec) {
|
||||
if (m_phaseID[kspec] == iphase) {
|
||||
if (m_speciesUnknownType[kspec] != VCS_SPECIES_TYPE_INTERFACIALVOLTAGE) {
|
||||
g += w[kspec] * fe[kspec];
|
||||
|
|
|
|||
|
|
@ -649,7 +649,7 @@ namespace VCSnonideal {
|
|||
*/
|
||||
m_mix->uploadMoleFractionsFromPhases();
|
||||
size_t kGlob = 0;
|
||||
for (int ip = 0; ip < m_vprob->NPhase; ip++) {
|
||||
for (size_t ip = 0; ip < m_vprob->NPhase; ip++) {
|
||||
double phaseMole = 0.0;
|
||||
Cantera::ThermoPhase &tref = m_mix->phase(ip);
|
||||
for (size_t k = 0; k < tref.nSpecies(); k++, kGlob++) {
|
||||
|
|
@ -690,7 +690,7 @@ namespace VCSnonideal {
|
|||
plogf(" (J/kmol)\n");
|
||||
plogf("--------------------------------------------------"
|
||||
"-----------\n");
|
||||
for (int i = 0; i < m_vprob->nspecies; i++) {
|
||||
for (size_t i = 0; i < m_vprob->nspecies; i++) {
|
||||
plogf("%-12s", m_vprob->SpName[i].c_str());
|
||||
if (m_vprob->SpeciesUnknownType[i] == VCS_SPECIES_TYPE_INTERFACIALVOLTAGE) {
|
||||
plogf(" %15.3e %15.3e ", 0.0, m_vprob->mf[i]);
|
||||
|
|
@ -1119,7 +1119,7 @@ namespace VCSnonideal {
|
|||
sProp->SpeciesThermo = ts_ptr;
|
||||
sProp->WtSpecies = tPhase->molecularWeight(k);
|
||||
sProp->FormulaMatrixCol.resize(vprob->ne, 0.0);
|
||||
for (int e = 0; e < vprob->ne; e++) {
|
||||
for (size_t e = 0; e < vprob->ne; e++) {
|
||||
sProp->FormulaMatrixCol[e] = vprob->FormulaMatrix[e][kT];
|
||||
}
|
||||
sProp->Charge = tPhase->charge(k);
|
||||
|
|
@ -1250,7 +1250,7 @@ namespace VCSnonideal {
|
|||
plogf(" Phase IDs of species\n");
|
||||
plogf(" species phaseID phaseName ");
|
||||
plogf(" Initial_Estimated_kMols\n");
|
||||
for (int i = 0; i < vprob->nspecies; i++) {
|
||||
for (size_t i = 0; i < vprob->nspecies; i++) {
|
||||
size_t iphase = vprob->PhaseID[i];
|
||||
|
||||
vcs_VolPhase *VolPhase = vprob->VPhaseList[iphase];
|
||||
|
|
@ -1267,7 +1267,7 @@ namespace VCSnonideal {
|
|||
plogf(" PhaseName PhaseNum SingSpec GasPhase EqnState NumSpec");
|
||||
plogf(" TMolesInert Tmoles(kmol)\n");
|
||||
|
||||
for (int iphase = 0; iphase < vprob->NPhase; iphase++) {
|
||||
for (size_t iphase = 0; iphase < vprob->NPhase; iphase++) {
|
||||
vcs_VolPhase *VolPhase = vprob->VPhaseList[iphase];
|
||||
std::string sEOS = string16_EOSType(VolPhase->m_eqnState);
|
||||
plogf("%16s %5d %5d %8d %16s %8d %16e ", VolPhase->PhaseName.c_str(),
|
||||
|
|
|
|||
|
|
@ -143,14 +143,14 @@ namespace VCSnonideal {
|
|||
// ff[i] = R * spt->GStar_R_calc(i, Temp, pres);
|
||||
//}
|
||||
|
||||
for (int iph = 0; iph < m_numPhases; iph++) {
|
||||
for (size_t iph = 0; iph < m_numPhases; iph++) {
|
||||
vcs_VolPhase* vph = m_VolPhaseList[iph];
|
||||
vph->setState_TP(m_temperature, m_pressurePA);
|
||||
vph->sendToVCS_GStar(VCS_DATA_PTR(m_SSfeSpecies));
|
||||
}
|
||||
|
||||
if (m_VCS_UnitsFormat == VCS_UNITS_UNITLESS) {
|
||||
for (int i = 0; i < m_numSpeciesTot; ++i) {
|
||||
for (size_t i = 0; i < m_numSpeciesTot; ++i) {
|
||||
m_SSfeSpecies[i] /= Temp;
|
||||
}
|
||||
}
|
||||
|
|
@ -168,8 +168,7 @@ namespace VCSnonideal {
|
|||
*
|
||||
***************************************************************************/
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < m_numSpeciesTot; ++i) {
|
||||
for (size_t i = 0; i < m_numSpeciesTot; ++i) {
|
||||
/*
|
||||
* For single species phases, initialize the chemical
|
||||
* potential with the value of the standard state chemical
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ namespace VCSnonideal {
|
|||
* Destructor for the VolPhase object.
|
||||
*/
|
||||
vcs_VolPhase::~vcs_VolPhase() {
|
||||
for (int k = 0; k < m_numSpecies; k++) {
|
||||
for (size_t k = 0; k < m_numSpecies; k++) {
|
||||
vcs_SpeciesProperties *sp = ListSpeciesPtr[k];
|
||||
delete sp;
|
||||
sp = 0;
|
||||
|
|
@ -164,7 +164,7 @@ namespace VCSnonideal {
|
|||
|
||||
m_formulaMatrix.resize(m_numElemConstraints, m_numSpecies, 0.0);
|
||||
for (size_t e = 0; e < m_numElemConstraints; e++) {
|
||||
for (int k = 0; k < m_numSpecies; k++) {
|
||||
for (size_t k = 0; k < m_numSpecies; k++) {
|
||||
m_formulaMatrix[e][k] = b.m_formulaMatrix[e][k];
|
||||
}
|
||||
}
|
||||
|
|
@ -292,7 +292,7 @@ namespace VCSnonideal {
|
|||
IndSpecies.resize(nspecies, -1);
|
||||
|
||||
if ((int) ListSpeciesPtr.size() >= m_numSpecies) {
|
||||
for (int i = 0; i < m_numSpecies; i++) {
|
||||
for (size_t i = 0; i < m_numSpecies; i++) {
|
||||
if (ListSpeciesPtr[i]) {
|
||||
delete ListSpeciesPtr[i];
|
||||
ListSpeciesPtr[i] = 0;
|
||||
|
|
@ -306,7 +306,7 @@ namespace VCSnonideal {
|
|||
|
||||
Xmol.resize(nspecies, 0.0);
|
||||
fractionCreationDelta_.resize(nspecies, 0.0);
|
||||
for (int i = 0; i < nspecies; i++) {
|
||||
for (size_t i = 0; i < nspecies; i++) {
|
||||
Xmol[i] = 1.0/nspecies;
|
||||
fractionCreationDelta_[i] = 1.0/nspecies;
|
||||
}
|
||||
|
|
@ -473,12 +473,12 @@ namespace VCSnonideal {
|
|||
*/
|
||||
void vcs_VolPhase::setMoleFractions(const double * const xmol) {
|
||||
double sum = -1.0;
|
||||
for (int k = 0; k < m_numSpecies; k++) {
|
||||
for (size_t k = 0; k < m_numSpecies; k++) {
|
||||
Xmol[k] = xmol[k];
|
||||
sum+= xmol[k];
|
||||
}
|
||||
if (std::fabs(sum) > 1.0E-13) {
|
||||
for (int k = 0; k < m_numSpecies; k++) {
|
||||
for (size_t k = 0; k < m_numSpecies; k++) {
|
||||
Xmol[k] /= sum;
|
||||
}
|
||||
}
|
||||
|
|
@ -544,7 +544,7 @@ namespace VCSnonideal {
|
|||
}
|
||||
v_totalMoles = totalMoles;
|
||||
double sum = 0.0;
|
||||
for (int k = 0; k < m_numSpecies; k++) {
|
||||
for (size_t k = 0; k < m_numSpecies; k++) {
|
||||
Xmol[k] = moleFractions[k];
|
||||
sum += moleFractions[k];
|
||||
}
|
||||
|
|
@ -553,7 +553,7 @@ namespace VCSnonideal {
|
|||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (sum != 1.0) {
|
||||
for (int k = 0; k < m_numSpecies; k++) {
|
||||
for (size_t k = 0; k < m_numSpecies; k++) {
|
||||
Xmol[k] /= sum;
|
||||
}
|
||||
}
|
||||
|
|
@ -803,7 +803,7 @@ namespace VCSnonideal {
|
|||
if (!m_UpToDate_GStar) {
|
||||
_updateGStar();
|
||||
}
|
||||
for (int k = 0; k < m_numSpecies; k++) {
|
||||
for (size_t k = 0; k < m_numSpecies; k++) {
|
||||
size_t kglob = IndSpecies[k];
|
||||
gstar[kglob] = StarChemicalPotential[k];
|
||||
}
|
||||
|
|
@ -967,7 +967,6 @@ namespace VCSnonideal {
|
|||
*
|
||||
*/
|
||||
void vcs_VolPhase::_updateLnActCoeffJac() {
|
||||
int k, j;
|
||||
double deltaMoles_j = 0.0;
|
||||
|
||||
/*
|
||||
|
|
@ -985,7 +984,7 @@ namespace VCSnonideal {
|
|||
/*
|
||||
* Loop over the columns species to be deltad
|
||||
*/
|
||||
for (j = 0; j < m_numSpecies; j++) {
|
||||
for (size_t j = 0; j < m_numSpecies; j++) {
|
||||
/*
|
||||
* Calculate a value for the delta moles of species j
|
||||
* -> NOte Xmol[] and Tmoles are always positive or zero
|
||||
|
|
@ -998,7 +997,7 @@ namespace VCSnonideal {
|
|||
* mole fractions based on this.
|
||||
*/
|
||||
v_totalMoles = TMoles_base + deltaMoles_j;
|
||||
for (k = 0; k < m_numSpecies; k++) {
|
||||
for (size_t k = 0; k < m_numSpecies; k++) {
|
||||
Xmol[k] = Xmol_Base[k] * TMoles_base / v_totalMoles;
|
||||
}
|
||||
Xmol[j] = (moles_j_base + deltaMoles_j) / v_totalMoles;
|
||||
|
|
@ -1013,7 +1012,7 @@ namespace VCSnonideal {
|
|||
* Calculate the column of the matrix
|
||||
*/
|
||||
double * const lnActCoeffCol = dLnActCoeffdMolNumber[j];
|
||||
for (k = 0; k < m_numSpecies; k++) {
|
||||
for (size_t k = 0; k < m_numSpecies; k++) {
|
||||
lnActCoeffCol[k] = (ActCoeff[k] - ActCoeff_Base[k]) /
|
||||
((ActCoeff[k] + ActCoeff_Base[k]) * 0.5 * deltaMoles_j);
|
||||
}
|
||||
|
|
@ -1150,7 +1149,7 @@ namespace VCSnonideal {
|
|||
/***************************************************************************/
|
||||
|
||||
void vcs_VolPhase::setFractionCreationDeltas(const double * const F_k) {
|
||||
for (int k = 0; k < m_numSpecies; k++) {
|
||||
for (size_t k = 0; k < m_numSpecies; k++) {
|
||||
fractionCreationDelta_[k] = F_k[k];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,9 +17,9 @@ namespace VCSnonideal {
|
|||
* back into the global structure
|
||||
*/
|
||||
void VCS_SOLVE::vcs_elab() {
|
||||
for (int j = 0; j < m_numElemConstraints; ++j) {
|
||||
for (size_t j = 0; j < m_numElemConstraints; ++j) {
|
||||
m_elemAbundances[j] = 0.0;
|
||||
for (int i = 0; i < m_numSpeciesTot; ++i) {
|
||||
for (size_t i = 0; i < m_numSpeciesTot; ++i) {
|
||||
if (m_speciesUnknownType[i] != VCS_SPECIES_TYPE_INTERFACIALVOLTAGE) {
|
||||
m_elemAbundances[j] += m_formulaMatrix[j][i] * m_molNumSpecies_old[i];
|
||||
}
|
||||
|
|
@ -87,7 +87,7 @@ namespace VCSnonideal {
|
|||
*/
|
||||
numNonZero = 0;
|
||||
multisign = false;
|
||||
for (int kspec = 0; kspec < m_numSpeciesTot; kspec++) {
|
||||
for (size_t kspec = 0; kspec < m_numSpeciesTot; kspec++) {
|
||||
eval = m_formulaMatrix[i][kspec];
|
||||
if (eval < 0.0) {
|
||||
multisign = true;
|
||||
|
|
@ -139,10 +139,9 @@ namespace VCSnonideal {
|
|||
* in m_molNumSpecies_old[].
|
||||
*************************************************************************/
|
||||
{
|
||||
int i, j;
|
||||
for (j = 0; j < m_numElemConstraints; ++j) {
|
||||
for (size_t j = 0; j < m_numElemConstraints; ++j) {
|
||||
elemAbundPhase[j] = 0.0;
|
||||
for (i = 0; i < m_numSpeciesTot; ++i) {
|
||||
for (size_t i = 0; i < m_numSpeciesTot; ++i) {
|
||||
if (m_speciesUnknownType[i] != VCS_SPECIES_TYPE_INTERFACIALVOLTAGE) {
|
||||
if (m_phaseID[i] == iphase) {
|
||||
elemAbundPhase[j] += m_formulaMatrix[j][i] * m_molNumSpecies_old[i];
|
||||
|
|
@ -199,7 +198,7 @@ namespace VCSnonideal {
|
|||
*
|
||||
*************************************************************************/
|
||||
{
|
||||
int i, j, retn = 0, goodSpec, its;
|
||||
int retn = 0, goodSpec, its;
|
||||
double xx, par, saveDir, dir;
|
||||
|
||||
#ifdef DEBUG_MODE
|
||||
|
|
@ -233,7 +232,7 @@ namespace VCSnonideal {
|
|||
int numNonZero = 0;
|
||||
bool changed = false;
|
||||
bool multisign = false;
|
||||
for (i = 0; i < m_numElemConstraints; ++i) {
|
||||
for (size_t i = 0; i < m_numElemConstraints; ++i) {
|
||||
numNonZero = 0;
|
||||
multisign = false;
|
||||
for (size_t kspec = 0; kspec < m_numSpeciesTot; kspec++) {
|
||||
|
|
@ -298,7 +297,7 @@ namespace VCSnonideal {
|
|||
* the number of components.
|
||||
*/
|
||||
changed = false;
|
||||
for (i = 0; i < m_numElemConstraints; ++i) {
|
||||
for (size_t i = 0; i < m_numElemConstraints; ++i) {
|
||||
int elType = m_elType[i];
|
||||
if (elType == VCS_ELEM_TYPE_ABSPOS) {
|
||||
for (size_t kspec = 0; kspec < m_numSpeciesTot; kspec++) {
|
||||
|
|
@ -350,15 +349,15 @@ namespace VCSnonideal {
|
|||
* of length nc, not ne, as there may be degenerate rows when
|
||||
* nc .ne. ne.
|
||||
*/
|
||||
for (i = 0; i < m_numComponents; ++i) {
|
||||
for (size_t i = 0; i < m_numComponents; ++i) {
|
||||
x[i] = m_elemAbundances[i] - m_elemAbundancesGoal[i];
|
||||
if (fabs(x[i]) > 1.0E-13) retn = 1;
|
||||
for (j = 0; j < m_numComponents; ++j) {
|
||||
for (size_t j = 0; j < m_numComponents; ++j) {
|
||||
aa[j + i*m_numElemConstraints] = m_formulaMatrix[j][i];
|
||||
}
|
||||
}
|
||||
i = vcsUtil_mlequ(aa, m_numElemConstraints, m_numComponents, x, 1);
|
||||
if (i == 1) {
|
||||
int err = vcsUtil_mlequ(aa, m_numElemConstraints, m_numComponents, x, 1);
|
||||
if (err == 1) {
|
||||
plogf("vcs_elcorr ERROR: mlequ returned error condition\n");
|
||||
return VCS_FAILED_CONVERGENCE;
|
||||
}
|
||||
|
|
@ -366,7 +365,7 @@ namespace VCSnonideal {
|
|||
* Now apply the new direction without creating negative species.
|
||||
*/
|
||||
par = 0.5;
|
||||
for (i = 0; i < m_numComponents; ++i) {
|
||||
for (size_t i = 0; i < m_numComponents; ++i) {
|
||||
if (m_molNumSpecies_old[i] > 0.0) {
|
||||
xx = -x[i] / m_molNumSpecies_old[i];
|
||||
if (par < xx) par = xx;
|
||||
|
|
@ -379,7 +378,7 @@ namespace VCSnonideal {
|
|||
if (par < 1.0 && par > 0.0) {
|
||||
retn = 2;
|
||||
par *= 0.9999;
|
||||
for (i = 0; i < m_numComponents; ++i) {
|
||||
for (size_t i = 0; i < m_numComponents; ++i) {
|
||||
double tmp = m_molNumSpecies_old[i] + par * x[i];
|
||||
if (tmp > 0.0) {
|
||||
m_molNumSpecies_old[i] = tmp;
|
||||
|
|
@ -392,7 +391,7 @@ namespace VCSnonideal {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
for (i = 0; i < m_numComponents; ++i) {
|
||||
for (size_t i = 0; i < m_numComponents; ++i) {
|
||||
double tmp = m_molNumSpecies_old[i] + x[i];
|
||||
if (tmp > 0.0) {
|
||||
m_molNumSpecies_old[i] = tmp;
|
||||
|
|
@ -429,7 +428,7 @@ namespace VCSnonideal {
|
|||
}
|
||||
saveDir = 0.0;
|
||||
goodSpec = TRUE;
|
||||
for (i = 0; i < m_numComponents; ++i) {
|
||||
for (size_t i = 0; i < m_numComponents; ++i) {
|
||||
dir = m_formulaMatrix[i][kspec] * (m_elemAbundancesGoal[i] - m_elemAbundances[i]);
|
||||
if (fabs(dir) > 1.0E-10) {
|
||||
if (dir > 0.0) {
|
||||
|
|
@ -454,7 +453,7 @@ namespace VCSnonideal {
|
|||
if (goodSpec) {
|
||||
its = 0;
|
||||
xx = 0.0;
|
||||
for (i = 0; i < m_numComponents; ++i) {
|
||||
for (size_t i = 0; i < m_numComponents; ++i) {
|
||||
if (m_formulaMatrix[i][kspec] != 0.0) {
|
||||
xx += (m_elemAbundancesGoal[i] - m_elemAbundances[i]) / m_formulaMatrix[i][kspec];
|
||||
its++;
|
||||
|
|
@ -482,7 +481,7 @@ namespace VCSnonideal {
|
|||
goto L_CLEANUP;
|
||||
}
|
||||
|
||||
for (i = 0; i < m_numElemConstraints; ++i) {
|
||||
for (size_t i = 0; i < m_numElemConstraints; ++i) {
|
||||
if (m_elType[i] == VCS_ELEM_TYPE_CHARGENEUTRALITY ||
|
||||
(m_elType[i] == VCS_ELEM_TYPE_ABSPOS && m_elemAbundancesGoal[i] == 0.0)) {
|
||||
for (size_t kspec = 0; kspec < m_numSpeciesRdc; kspec++) {
|
||||
|
|
@ -519,7 +518,7 @@ namespace VCSnonideal {
|
|||
* in the species concentrations to match the desired
|
||||
* electron charge exactly.
|
||||
*/
|
||||
for (i = 0; i < m_numElemConstraints; ++i) {
|
||||
for (size_t i = 0; i < m_numElemConstraints; ++i) {
|
||||
double dev = m_elemAbundancesGoal[i] - m_elemAbundances[i];
|
||||
if (m_elType[i] == VCS_ELEM_TYPE_ELECTRONCHARGE && (fabs(dev) > 1.0E-300)) {
|
||||
bool useZeroed = true;
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ namespace VCSnonideal {
|
|||
plogendl();
|
||||
plogf("%s Element Goal Actual\n", pprefix);
|
||||
int jj = 0;
|
||||
for (int j = 0; j < m_numElemConstraints; j++) {
|
||||
for (size_t j = 0; j < m_numElemConstraints; j++) {
|
||||
if (m_elementActive[j]) {
|
||||
double tmp = 0.0;
|
||||
for (kspec = 0; kspec < nspecies; ++kspec) {
|
||||
|
|
|
|||
|
|
@ -104,12 +104,11 @@ namespace VCSnonideal {
|
|||
* the algorithm would have problems.
|
||||
*/
|
||||
void VCS_SOLVE::vcs_nondim_TP() {
|
||||
int i;
|
||||
double tf;
|
||||
if (m_unitsState == VCS_DIMENSIONAL_G) {
|
||||
m_unitsState = VCS_NONDIMENSIONAL_G;
|
||||
tf = 1.0 / vcs_nondimMult_TP(m_VCS_UnitsFormat, m_temperature);
|
||||
for (i = 0; i < m_numSpeciesTot; ++i) {
|
||||
for (size_t i = 0; i < m_numSpeciesTot; ++i) {
|
||||
/*
|
||||
* Modify the standard state and total chemical potential data,
|
||||
* FF(I), to make it dimensionless, i.e., mu / RT.
|
||||
|
|
@ -134,7 +133,7 @@ namespace VCSnonideal {
|
|||
* or the other is specified here.
|
||||
*/
|
||||
double esum = 0.0;
|
||||
for (i = 0; i < m_numElemConstraints; ++i) {
|
||||
for (size_t i = 0; i < m_numElemConstraints; ++i) {
|
||||
if (m_elType[i] == VCS_ELEM_TYPE_ABSPOS) {
|
||||
esum += fabs(m_elemAbundancesGoal[i]);
|
||||
}
|
||||
|
|
@ -171,16 +170,16 @@ namespace VCSnonideal {
|
|||
plogendl();
|
||||
}
|
||||
#endif
|
||||
for (i = 0; i < m_numSpeciesTot; ++i) {
|
||||
for (size_t i = 0; i < m_numSpeciesTot; ++i) {
|
||||
if (m_speciesUnknownType[i] != VCS_SPECIES_TYPE_INTERFACIALVOLTAGE) {
|
||||
m_molNumSpecies_old[i] *= (1.0 / m_totalMoleScale);
|
||||
}
|
||||
}
|
||||
for (i = 0; i < m_numElemConstraints; ++i) {
|
||||
for (size_t i = 0; i < m_numElemConstraints; ++i) {
|
||||
m_elemAbundancesGoal[i] *= (1.0 / m_totalMoleScale);
|
||||
}
|
||||
|
||||
for (int iph = 0; iph < m_numPhases; iph++) {
|
||||
for (size_t iph = 0; iph < m_numPhases; iph++) {
|
||||
TPhInertMoles[iph] *= (1.0 / m_totalMoleScale);
|
||||
if (TPhInertMoles[iph] != 0.0) {
|
||||
vcs_VolPhase *vphase = m_VolPhaseList[iph];
|
||||
|
|
@ -205,12 +204,11 @@ namespace VCSnonideal {
|
|||
*/
|
||||
void VCS_SOLVE::vcs_redim_TP(void)
|
||||
{
|
||||
int i;
|
||||
double tf;
|
||||
if (m_unitsState != VCS_DIMENSIONAL_G) {
|
||||
m_unitsState = VCS_DIMENSIONAL_G;
|
||||
tf = vcs_nondimMult_TP(m_VCS_UnitsFormat, m_temperature);
|
||||
for (i = 0; i < m_numSpeciesTot; ++i) {
|
||||
for (size_t i = 0; i < m_numSpeciesTot; ++i) {
|
||||
/*
|
||||
* Modify the standard state and total chemical potential data,
|
||||
* FF(I), to make it have units, i.e. mu = RT * mu_star
|
||||
|
|
@ -230,16 +228,16 @@ namespace VCSnonideal {
|
|||
plogendl();
|
||||
}
|
||||
#endif
|
||||
for (i = 0; i < m_numSpeciesTot; ++i) {
|
||||
for (size_t i = 0; i < m_numSpeciesTot; ++i) {
|
||||
if (m_speciesUnknownType[i] != VCS_SPECIES_TYPE_INTERFACIALVOLTAGE) {
|
||||
m_molNumSpecies_old[i] *= m_totalMoleScale;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < m_numElemConstraints; ++i) {
|
||||
for (size_t i = 0; i < m_numElemConstraints; ++i) {
|
||||
m_elemAbundancesGoal[i] *= m_totalMoleScale;
|
||||
}
|
||||
|
||||
for (int iph = 0; iph < m_numPhases; iph++) {
|
||||
for (size_t iph = 0; iph < m_numPhases; iph++) {
|
||||
TPhInertMoles[iph] *= m_totalMoleScale;
|
||||
if (TPhInertMoles[iph] != 0.0) {
|
||||
vcs_VolPhase *vphase = m_VolPhaseList[iph];
|
||||
|
|
|
|||
|
|
@ -75,9 +75,8 @@ namespace VCSnonideal {
|
|||
* @return returns the phase id of the phase that pops back into
|
||||
* existence. Returns -1 if there are no phases
|
||||
*/
|
||||
int VCS_SOLVE::vcs_popPhaseID() {
|
||||
int iphasePop = -1;
|
||||
int iph;
|
||||
size_t VCS_SOLVE::vcs_popPhaseID() {
|
||||
size_t iphasePop = -1;
|
||||
size_t irxn, kspec;
|
||||
doublereal FephaseMax = -1.0E30;
|
||||
doublereal Fephase = -1.0E30;
|
||||
|
|
@ -92,7 +91,7 @@ namespace VCSnonideal {
|
|||
plogf(" --------------------------------------------------------------\n");
|
||||
}
|
||||
#endif
|
||||
for (iph = 0; iph < m_numPhases; iph++) {
|
||||
for (size_t iph = 0; iph < m_numPhases; iph++) {
|
||||
Vphase = m_VolPhaseList[iph];
|
||||
int existence = Vphase->exists();
|
||||
#ifdef DEBUG_MODE
|
||||
|
|
@ -219,7 +218,6 @@ namespace VCSnonideal {
|
|||
size_t irxn = kspec - m_numComponents;
|
||||
|
||||
doublereal s;
|
||||
int j, k;
|
||||
// Calculate the initial moles of the phase being born.
|
||||
// Here we set it to 10x of the value which would cause the phase to be
|
||||
// zeroed out within the algorithm. We may later adjust the value.
|
||||
|
|
@ -243,14 +241,14 @@ namespace VCSnonideal {
|
|||
if (Vphase->m_singleSpecies) {
|
||||
s = 0.0;
|
||||
double *dnPhase_irxn = m_deltaMolNumPhase[irxn];
|
||||
for (j = 0; j < m_numComponents; ++j) {
|
||||
for (size_t j = 0; j < m_numComponents; ++j) {
|
||||
if (!m_SSPhase[j]) {
|
||||
if (m_molNumSpecies_old[j] > 0.0) {
|
||||
s += SQUARE(m_stoichCoeffRxnMatrix[irxn][j]) / m_molNumSpecies_old[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
for (j = 0; j < m_numPhases; j++) {
|
||||
for (size_t j = 0; j < m_numPhases; j++) {
|
||||
Vphase = m_VolPhaseList[j];
|
||||
if (! Vphase->m_singleSpecies) {
|
||||
if (m_tPhaseMoles_old[j] > 0.0)
|
||||
|
|
@ -276,7 +274,7 @@ namespace VCSnonideal {
|
|||
/*
|
||||
* section to do damping of the m_deltaMolNumSpecies[]
|
||||
*/
|
||||
for (j = 0; j < m_numComponents; ++j) {
|
||||
for (size_t j = 0; j < m_numComponents; ++j) {
|
||||
double stoicC = m_stoichCoeffRxnMatrix[irxn][j];
|
||||
if (stoicC != 0.0) {
|
||||
if (m_elType[j] == VCS_ELEM_TYPE_ABSPOS) {
|
||||
|
|
@ -318,10 +316,10 @@ namespace VCSnonideal {
|
|||
fracDelta = Vphase->fractionCreationDeltas();
|
||||
|
||||
double sumFrac = 0.0;
|
||||
for (k = 0; k < Vphase->nSpecies(); k++) {
|
||||
for (size_t k = 0; k < Vphase->nSpecies(); k++) {
|
||||
sumFrac += fracDelta[k];
|
||||
}
|
||||
for (k = 0; k < Vphase->nSpecies(); k++) {
|
||||
for (size_t k = 0; k < Vphase->nSpecies(); k++) {
|
||||
X_est[k] = fracDelta[k] / sumFrac;
|
||||
}
|
||||
|
||||
|
|
@ -331,12 +329,12 @@ namespace VCSnonideal {
|
|||
double * molNumSpecies_tmp = DATA_PTR(m_deltaGRxn_tmp);
|
||||
|
||||
|
||||
for (k = 0; k < Vphase->nSpecies(); k++) {
|
||||
for (size_t k = 0; k < Vphase->nSpecies(); k++) {
|
||||
kspec = Vphase->spGlobalIndexVCS(k);
|
||||
double delmol = deltaMolNumPhase * X_est[k];
|
||||
if (kspec >= m_numComponents) {
|
||||
irxn = kspec - m_numComponents;
|
||||
for (j = 0; j < m_numComponents; ++j) {
|
||||
for (size_t j = 0; j < m_numComponents; ++j) {
|
||||
double stoicC = m_stoichCoeffRxnMatrix[irxn][j];
|
||||
if (stoicC != 0.0) {
|
||||
if (m_elType[j] == VCS_ELEM_TYPE_ABSPOS) {
|
||||
|
|
@ -348,7 +346,7 @@ namespace VCSnonideal {
|
|||
}
|
||||
|
||||
doublereal ratioComp = 0.0;
|
||||
for (j = 0; j < m_numComponents; ++j) {
|
||||
for (size_t j = 0; j < m_numComponents; ++j) {
|
||||
double deltaJ = m_molNumSpecies_old[j] - molNumSpecies_tmp[j];
|
||||
if (molNumSpecies_tmp[j] < 0.0) {
|
||||
ratioComp = 1.0;
|
||||
|
|
@ -387,7 +385,7 @@ namespace VCSnonideal {
|
|||
return 3;
|
||||
}
|
||||
|
||||
for (k = 0; k < Vphase->nSpecies(); k++) {
|
||||
for (size_t k = 0; k < Vphase->nSpecies(); k++) {
|
||||
kspec = Vphase->spGlobalIndexVCS(k);
|
||||
if (kspec < m_numComponents) {
|
||||
m_speciesStatus[kspec] = VCS_SPECIES_COMPONENT;
|
||||
|
|
|
|||
|
|
@ -297,7 +297,7 @@ namespace VCSnonideal {
|
|||
*/
|
||||
bool VCS_SOLVE::vcs_wellPosed(VCS_PROB *vprob) {
|
||||
double sum = 0.0;
|
||||
for (int e = 0; e < vprob->ne; e++) {
|
||||
for (size_t e = 0; e < vprob->ne; e++) {
|
||||
sum = sum + vprob->gai[e];
|
||||
}
|
||||
if (sum < 1.0E-20) {
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ namespace VCSnonideal {
|
|||
WtSpecies.resize(nspecies, 0.0);
|
||||
Charge.resize(nspecies, 0.0);
|
||||
SpeciesThermo.resize(nspecies,0);
|
||||
for (int kspec = 0; kspec < nspecies; kspec++) {
|
||||
for (size_t kspec = 0; kspec < nspecies; kspec++) {
|
||||
VCS_SPECIES_THERMO *ts_tmp = new VCS_SPECIES_THERMO(0, 0);
|
||||
if (ts_tmp == 0) {
|
||||
plogf("Failed to init a ts struct\n");
|
||||
|
|
@ -96,7 +96,7 @@ namespace VCSnonideal {
|
|||
SpeciesThermo[kspec] = ts_tmp;
|
||||
}
|
||||
VPhaseList.resize(nph, 0);
|
||||
for (int iphase = 0; iphase < NPhase; iphase++) {
|
||||
for (size_t iphase = 0; iphase < NPhase; iphase++) {
|
||||
VPhaseList[iphase] = new vcs_VolPhase();
|
||||
}
|
||||
}
|
||||
|
|
@ -193,13 +193,12 @@ namespace VCSnonideal {
|
|||
*/
|
||||
void VCS_PROB::set_gai ()
|
||||
{
|
||||
int kspec, j;
|
||||
double *ElemAbund = VCS_DATA_PTR(gai);
|
||||
double *const *const fm = FormulaMatrix.baseDataAddr();
|
||||
vcs_dzero(ElemAbund, ne);
|
||||
|
||||
for (j = 0; j < ne; j++) {
|
||||
for (kspec = 0; kspec < nspecies; kspec++) {
|
||||
for (size_t j = 0; j < ne; j++) {
|
||||
for (size_t kspec = 0; kspec < nspecies; kspec++) {
|
||||
ElemAbund[j] += fm[j][kspec] * w[kspec];
|
||||
}
|
||||
}
|
||||
|
|
@ -223,7 +222,6 @@ namespace VCSnonideal {
|
|||
*/
|
||||
void VCS_PROB::prob_report(int print_lvl) {
|
||||
m_printLvl = print_lvl;
|
||||
int i, iphase;
|
||||
vcs_VolPhase *Vphase = 0;
|
||||
/*
|
||||
* Printout the species information: PhaseID's and mole nums
|
||||
|
|
@ -250,7 +248,7 @@ namespace VCSnonideal {
|
|||
plogf(" Phase IDs of species\n");
|
||||
plogf(" species phaseID phaseName ");
|
||||
plogf(" Initial_Estimated_Moles Species_Type\n");
|
||||
for (i = 0; i < nspecies; i++) {
|
||||
for (size_t i = 0; i < nspecies; i++) {
|
||||
Vphase = VPhaseList[PhaseID[i]];
|
||||
plogf("%16s %5d %16s", SpName[i].c_str(), PhaseID[i],
|
||||
Vphase->PhaseName.c_str());
|
||||
|
|
@ -275,7 +273,7 @@ namespace VCSnonideal {
|
|||
" EqnState NumSpec");
|
||||
plogf(" TMolesInert TKmoles\n");
|
||||
|
||||
for (iphase = 0; iphase < NPhase; iphase++) {
|
||||
for (size_t iphase = 0; iphase < NPhase; iphase++) {
|
||||
Vphase = VPhaseList[iphase];
|
||||
std::string EOS_cstr = string16_EOSType(Vphase->m_eqnState);
|
||||
plogf("%16s %5d %5d %8d ", Vphase->PhaseName.c_str(),
|
||||
|
|
@ -293,7 +291,7 @@ namespace VCSnonideal {
|
|||
//fac = 1.0E3;
|
||||
fac = 1.0;
|
||||
}
|
||||
for (i = 0; i < ne; ++i) {
|
||||
for (size_t i = 0; i < ne; ++i) {
|
||||
print_space(26); plogf("%-2.2s", ElName[i].c_str());
|
||||
plogf("%20.12E ", fac * gai[i]);
|
||||
plogf("%3d %3d\n", m_elType[i], ElActive[i]);
|
||||
|
|
@ -314,7 +312,7 @@ namespace VCSnonideal {
|
|||
plogf("\n");
|
||||
plogf(" Species (phase) "
|
||||
" SS0ChemPot StarChemPot\n");
|
||||
for (iphase = 0; iphase < NPhase; iphase++) {
|
||||
for (size_t iphase = 0; iphase < NPhase; iphase++) {
|
||||
Vphase = VPhaseList[iphase];
|
||||
Vphase->setState_TP(T, PresPA);
|
||||
for (size_t kindex = 0; kindex < Vphase->nSpecies(); kindex++) {
|
||||
|
|
|
|||
|
|
@ -249,7 +249,7 @@ namespace VCSnonideal {
|
|||
}
|
||||
plogf(" | Gibbs Total |\n");
|
||||
print_line("-", m_numElemConstraints*10 + 58);
|
||||
for (int iphase = 0; iphase < m_numPhases; iphase++) {
|
||||
for (size_t iphase = 0; iphase < m_numPhases; iphase++) {
|
||||
plogf(" %3d ", iphase);
|
||||
vcs_VolPhase *VPhase = m_VolPhaseList[iphase];
|
||||
plogf("%-12.12s |",VPhase->PhaseName.c_str());
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ static void print_funcEval(FILE *fp, double xval, double fval, int its)
|
|||
FILE *fp = 0;
|
||||
#endif
|
||||
double x1, x2, xnew, f1, f2, fnew, slope;
|
||||
int its = 0;
|
||||
size_t its = 0;
|
||||
int posStraddle = 0;
|
||||
int retn = VCS_SUCCESS;
|
||||
int foundPosF = FALSE;
|
||||
|
|
|
|||
|
|
@ -665,7 +665,7 @@ namespace VCSnonideal {
|
|||
/*
|
||||
* Loop over all of the phases in the problem
|
||||
*/
|
||||
for (int iphase = 0; iphase < m_numPhases; iphase++) {
|
||||
for (size_t iphase = 0; iphase < m_numPhases; iphase++) {
|
||||
vcs_VolPhase *Vphase = m_VolPhaseList[iphase];
|
||||
/*
|
||||
* We don't need to call single species phases;
|
||||
|
|
|
|||
|
|
@ -87,7 +87,6 @@ int VCS_SOLVE::vcs_setMolesLinProg() {
|
|||
double nu;
|
||||
double delta_xi, dxi_min = 1.0e10;
|
||||
bool redo = true;
|
||||
int jcomp;
|
||||
int retn;
|
||||
int iter = 0;
|
||||
bool abundancesOK = true;
|
||||
|
|
@ -156,7 +155,7 @@ int VCS_SOLVE::vcs_setMolesLinProg() {
|
|||
dg_rt = m_SSfeSpecies[ik];
|
||||
dxi_min = 1.0e10;
|
||||
const double *sc_irxn = m_stoichCoeffRxnMatrix[irxn];
|
||||
for (jcomp = 0; jcomp < m_numElemConstraints; jcomp++) {
|
||||
for (size_t jcomp = 0; jcomp < m_numElemConstraints; jcomp++) {
|
||||
dg_rt += m_SSfeSpecies[jcomp] * sc_irxn[jcomp];
|
||||
}
|
||||
// fwd or rev direction.
|
||||
|
|
@ -167,7 +166,7 @@ int VCS_SOLVE::vcs_setMolesLinProg() {
|
|||
dxi_min = m_molNumSpecies_old[ik];
|
||||
}
|
||||
|
||||
for (jcomp = 0; jcomp < m_numComponents; jcomp++) {
|
||||
for (size_t jcomp = 0; jcomp < m_numComponents; jcomp++) {
|
||||
nu = sc_irxn[jcomp];
|
||||
|
||||
// set max change in progress variable by
|
||||
|
|
@ -196,7 +195,7 @@ int VCS_SOLVE::vcs_setMolesLinProg() {
|
|||
double dsLocal = idir*dxi_min;
|
||||
m_molNumSpecies_old[ik] += dsLocal;
|
||||
m_molNumSpecies_old[ik] = MAX(0.0, m_molNumSpecies_old[ik]);
|
||||
for (jcomp = 0; jcomp < m_numComponents; jcomp++) {
|
||||
for (size_t jcomp = 0; jcomp < m_numComponents; jcomp++) {
|
||||
bool full = false;
|
||||
if (m_molNumSpecies_old[jcomp] > 1.0E-15) {
|
||||
full = true;
|
||||
|
|
|
|||
|
|
@ -92,7 +92,6 @@ namespace VCSnonideal {
|
|||
m_numElemConstraints = nelements;
|
||||
m_numComponents = nelements;
|
||||
|
||||
int iph;
|
||||
string ser = "VCS_SOLVE: ERROR:\n\t";
|
||||
if (nspecies0 <= 0) {
|
||||
plogf("%s Number of species is nonpositive\n", ser.c_str());
|
||||
|
|
@ -208,7 +207,7 @@ namespace VCSnonideal {
|
|||
* Malloc Phase Info
|
||||
*/
|
||||
m_VolPhaseList.resize(nphase0, 0);
|
||||
for (iph = 0; iph < nphase0; iph++) {
|
||||
for (size_t iph = 0; iph < nphase0; iph++) {
|
||||
m_VolPhaseList[iph] = new vcs_VolPhase(this);
|
||||
}
|
||||
|
||||
|
|
@ -455,8 +454,6 @@ namespace VCSnonideal {
|
|||
* initialize the current equilibrium problem
|
||||
*/
|
||||
int VCS_SOLVE::vcs_prob_specifyFully(const VCS_PROB *pub) {
|
||||
int i, j, kspec;
|
||||
size_t iph;
|
||||
vcs_VolPhase *Vphase = 0;
|
||||
const char *ser =
|
||||
"vcs_pub_to_priv ERROR :ill defined interface -> bailout:\n\t";
|
||||
|
|
@ -516,8 +513,8 @@ namespace VCSnonideal {
|
|||
/*
|
||||
* FormulaMatrix[] -> Copy the formula matrix over
|
||||
*/
|
||||
for (i = 0; i < nspecies; i++) {
|
||||
for (j = 0; j < nelements; j++) {
|
||||
for (size_t i = 0; i < nspecies; i++) {
|
||||
for (size_t j = 0; j < nelements; j++) {
|
||||
m_formulaMatrix[j][i] = pub->FormulaMatrix[j][i];
|
||||
}
|
||||
}
|
||||
|
|
@ -536,7 +533,7 @@ namespace VCSnonideal {
|
|||
* Malloc and Copy the VCS_SPECIES_THERMO structures
|
||||
*
|
||||
*/
|
||||
for (kspec = 0; kspec < nspecies; kspec++) {
|
||||
for (size_t kspec = 0; kspec < nspecies; kspec++) {
|
||||
if (m_speciesThermoList[kspec] != NULL) {
|
||||
delete m_speciesThermoList[kspec];
|
||||
}
|
||||
|
|
@ -573,12 +570,12 @@ namespace VCSnonideal {
|
|||
* Formulate the Goal Element Abundance Vector
|
||||
*/
|
||||
if (pub->gai.size() != 0) {
|
||||
for (i = 0; i < nelements; i++) m_elemAbundancesGoal[i] = pub->gai[i];
|
||||
for (size_t i = 0; i < nelements; i++) m_elemAbundancesGoal[i] = pub->gai[i];
|
||||
} else {
|
||||
if (m_doEstimateEquil == 0) {
|
||||
for (j = 0; j < nelements; j++) {
|
||||
for (size_t j = 0; j < nelements; j++) {
|
||||
m_elemAbundancesGoal[j] = 0.0;
|
||||
for (kspec = 0; kspec < nspecies; kspec++) {
|
||||
for (size_t kspec = 0; kspec < nspecies; kspec++) {
|
||||
if (m_speciesUnknownType[kspec] != VCS_SPECIES_TYPE_INTERFACIALVOLTAGE) {
|
||||
m_elemAbundancesGoal[j] += m_formulaMatrix[j][kspec] * m_molNumSpecies_old[kspec];
|
||||
}
|
||||
|
|
@ -608,7 +605,7 @@ namespace VCSnonideal {
|
|||
/*
|
||||
* TPhInertMoles[] -> must be copied over here
|
||||
*/
|
||||
for (iph = 0; iph < nph; iph++) {
|
||||
for (size_t iph = 0; iph < nph; iph++) {
|
||||
Vphase = pub->VPhaseList[iph];
|
||||
TPhInertMoles[iph] = Vphase->totalMolesInert();
|
||||
}
|
||||
|
|
@ -630,7 +627,7 @@ namespace VCSnonideal {
|
|||
* m_speciesIndexVector[] is an index variable that keep track
|
||||
* of solution vector rotations.
|
||||
*/
|
||||
for (i = 0; i < nspecies; i++) {
|
||||
for (size_t i = 0; i < nspecies; i++) {
|
||||
m_speciesMapIndex[i] = i;
|
||||
}
|
||||
|
||||
|
|
@ -638,12 +635,12 @@ namespace VCSnonideal {
|
|||
* IndEl[] is an index variable that keep track of element vector
|
||||
* rotations.
|
||||
*/
|
||||
for (i = 0; i < nelements; i++) m_elementMapIndex[i] = i;
|
||||
for (size_t i = 0; i < nelements; i++) m_elementMapIndex[i] = i;
|
||||
|
||||
/*
|
||||
* Define all species to be major species, initially.
|
||||
*/
|
||||
for (i = 0; i < nspecies; i++) {
|
||||
for (size_t i = 0; i < nspecies; i++) {
|
||||
// m_rxnStatus[i] = VCS_SPECIES_MAJOR;
|
||||
m_speciesStatus[i] = VCS_SPECIES_MAJOR;
|
||||
}
|
||||
|
|
@ -653,8 +650,8 @@ namespace VCSnonideal {
|
|||
*/
|
||||
if (pub->PhaseID.size() != 0) {
|
||||
std::vector<size_t> numPhSp(nph, 0);
|
||||
for (kspec = 0; kspec < nspecies; kspec++) {
|
||||
iph = pub->PhaseID[kspec];
|
||||
for (size_t kspec = 0; kspec < nspecies; kspec++) {
|
||||
size_t iph = pub->PhaseID[kspec];
|
||||
if (iph < 0 || iph >= nph) {
|
||||
plogf("%sSpecies to Phase Mapping, PhaseID, has a bad value\n",
|
||||
ser);
|
||||
|
|
@ -666,7 +663,7 @@ namespace VCSnonideal {
|
|||
m_speciesLocalPhaseIndex[kspec] = numPhSp[iph];
|
||||
numPhSp[iph]++;
|
||||
}
|
||||
for (iph = 0; iph < nph; iph++) {
|
||||
for (size_t iph = 0; iph < nph; iph++) {
|
||||
Vphase = pub->VPhaseList[iph];
|
||||
if (numPhSp[iph] != Vphase->nSpecies()) {
|
||||
plogf("%sNumber of species in phase %d, %s, doesn't match\n",
|
||||
|
|
@ -676,7 +673,7 @@ namespace VCSnonideal {
|
|||
}
|
||||
} else {
|
||||
if (m_numPhases == 1) {
|
||||
for (kspec = 0; kspec < nspecies; kspec++) {
|
||||
for (size_t kspec = 0; kspec < nspecies; kspec++) {
|
||||
m_phaseID[kspec] = 0;
|
||||
m_speciesLocalPhaseIndex[kspec] = kspec;
|
||||
}
|
||||
|
|
@ -695,7 +692,7 @@ namespace VCSnonideal {
|
|||
/*
|
||||
* Copy over the element names and types
|
||||
*/
|
||||
for (i = 0; i < nelements; i++) {
|
||||
for (size_t i = 0; i < nelements; i++) {
|
||||
m_elementName[i] = pub->ElName[i];
|
||||
m_elType[i] = pub->m_elType[i];
|
||||
m_elementActive[i] = pub->ElActive[i];
|
||||
|
|
@ -708,7 +705,7 @@ namespace VCSnonideal {
|
|||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < nelements; i++) {
|
||||
for (size_t i = 0; i < nelements; i++) {
|
||||
if (m_elType[i] == VCS_ELEM_TYPE_CHARGENEUTRALITY) {
|
||||
if (m_elemAbundancesGoal[i] != 0.0) {
|
||||
if (fabs(m_elemAbundancesGoal[i]) > 1.0E-9) {
|
||||
|
|
@ -728,14 +725,14 @@ namespace VCSnonideal {
|
|||
/*
|
||||
* Copy over the species names
|
||||
*/
|
||||
for (i = 0; i < nspecies; i++) {
|
||||
for (size_t i = 0; i < nspecies; i++) {
|
||||
m_speciesName[i] = pub->SpName[i];
|
||||
}
|
||||
/*
|
||||
* Copy over all of the phase information
|
||||
* Use the object's assignment operator
|
||||
*/
|
||||
for (iph = 0; iph < nph; iph++) {
|
||||
for (size_t iph = 0; iph < nph; iph++) {
|
||||
*(m_VolPhaseList[iph]) = *(pub->VPhaseList[iph]);
|
||||
/*
|
||||
* Fix up the species thermo pointer in the vcs_SpeciesThermo object
|
||||
|
|
@ -753,7 +750,7 @@ namespace VCSnonideal {
|
|||
/*
|
||||
* Specify the Activity Convention information
|
||||
*/
|
||||
for (iph = 0; iph < nph; iph++) {
|
||||
for (size_t iph = 0; iph < nph; iph++) {
|
||||
Vphase = m_VolPhaseList[iph];
|
||||
m_phaseActConvention[iph] = Vphase->p_activityConvention;
|
||||
if (Vphase->p_activityConvention != 0) {
|
||||
|
|
@ -974,7 +971,7 @@ namespace VCSnonideal {
|
|||
pub->PresPA = m_pressurePA;
|
||||
pub->Vol = m_totalVol;
|
||||
size_t kT = 0;
|
||||
for (int iph = 0; iph < pub->NPhase; iph++) {
|
||||
for (size_t iph = 0; iph < pub->NPhase; iph++) {
|
||||
vcs_VolPhase *pubPhase = pub->VPhaseList[iph];
|
||||
vcs_VolPhase *vPhase = m_VolPhaseList[iph];
|
||||
pubPhase->setTotalMolesInert(vPhase->totalMolesInert());
|
||||
|
|
@ -1074,7 +1071,7 @@ namespace VCSnonideal {
|
|||
double VCS_SOLVE::vcs_VolTotal(const double tkelvin, const double pres,
|
||||
const double w[], double volPM[]) {
|
||||
double VolTot = 0.0;
|
||||
for (int iphase = 0; iphase < m_numPhases; iphase++) {
|
||||
for (size_t iphase = 0; iphase < m_numPhases; iphase++) {
|
||||
vcs_VolPhase *Vphase = m_VolPhaseList[iphase];
|
||||
Vphase->setState_TP(tkelvin, pres);
|
||||
Vphase->setMolesFromVCS(VCS_STATECALC_OLD, w);
|
||||
|
|
|
|||
|
|
@ -516,7 +516,7 @@ public:
|
|||
* @return returns the phase id of the phase that pops back into
|
||||
* existence. Returns -1 if there are no phases
|
||||
*/
|
||||
int vcs_popPhaseID();
|
||||
size_t vcs_popPhaseID();
|
||||
|
||||
//! Calculates the deltas of the reactions due to phases popping
|
||||
//! into existence
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ namespace VCSnonideal {
|
|||
dchange[iph] += dsLocal[k];
|
||||
}
|
||||
}
|
||||
for (int iphase = 0; iphase < m_numPhases; iphase++) {
|
||||
for (size_t iphase = 0; iphase < m_numPhases; iphase++) {
|
||||
double denom = MAX(m_totalMolNum, 1.0E-4);
|
||||
if (!vcs_doubleEqual(dchange[iphase]/denom, delTPhMoles[iphase]/denom)) {
|
||||
plogf("checkDelta1: we have found a problem\n");
|
||||
|
|
@ -114,7 +114,7 @@ namespace VCSnonideal {
|
|||
double *sc_irxn = NULL; /* Stoichiometric coefficients for cur rxn */
|
||||
double *dnPhase_irxn;
|
||||
double atomComp;
|
||||
int iphasePop;
|
||||
size_t iphasePop;
|
||||
#ifdef DEBUG_MODE
|
||||
char ANOTE[128];
|
||||
/*
|
||||
|
|
@ -397,7 +397,7 @@ namespace VCSnonideal {
|
|||
*
|
||||
*/
|
||||
soldel = -1;
|
||||
if (iphasePop >= 0) {
|
||||
if (iphasePop != -1) {
|
||||
soldel = vcs_popPhaseRxnStepSizes(iphasePop);
|
||||
if (soldel == 3) {
|
||||
iphasePop = -1;
|
||||
|
|
@ -409,7 +409,7 @@ namespace VCSnonideal {
|
|||
#endif
|
||||
}
|
||||
}
|
||||
if (iphasePop < 0) {
|
||||
if (iphasePop == -1) {
|
||||
/*
|
||||
* Figure out the new reaction step sizes
|
||||
* for the major species (do minor species in the future too)
|
||||
|
|
@ -488,7 +488,7 @@ namespace VCSnonideal {
|
|||
#ifdef DEBUG_MODE
|
||||
ANOTE[0] = '\0';
|
||||
#endif
|
||||
if (iphasePop >= 0) {
|
||||
if (iphasePop != -1) {
|
||||
if (iph == iphasePop) {
|
||||
dx = m_deltaMolNumSpecies[kspec];
|
||||
m_molNumSpecies_new[kspec] = m_molNumSpecies_old[kspec] + m_deltaMolNumSpecies[kspec];
|
||||
|
|
@ -546,7 +546,7 @@ namespace VCSnonideal {
|
|||
}
|
||||
#endif
|
||||
} else {
|
||||
for (int j = 0; j < m_numElemConstraints; ++j) {
|
||||
for (size_t j = 0; j < m_numElemConstraints; ++j) {
|
||||
int elType = m_elType[j];
|
||||
if (elType == VCS_ELEM_TYPE_ABSPOS) {
|
||||
atomComp = m_formulaMatrix[j][kspec];
|
||||
|
|
@ -840,7 +840,7 @@ namespace VCSnonideal {
|
|||
++m_numRxnMinorZeroed;
|
||||
allMinorZeroedSpecies = (m_numRxnMinorZeroed == m_numRxnRdc);
|
||||
|
||||
for (int kk = 0; kk < m_numSpeciesTot; kk++) {
|
||||
for (size_t kk = 0; kk < m_numSpeciesTot; kk++) {
|
||||
m_deltaMolNumSpecies[kk] = 0.0;
|
||||
m_molNumSpecies_new[kk] = m_molNumSpecies_old[kk];
|
||||
}
|
||||
|
|
@ -2084,7 +2084,6 @@ namespace VCSnonideal {
|
|||
int VCS_SOLVE::delta_species(const size_t kspec, double * const delta_ptr) {
|
||||
size_t irxn = kspec - m_numComponents;
|
||||
int retn = 1;
|
||||
int j;
|
||||
double tmp;
|
||||
double delta = *delta_ptr;
|
||||
#ifdef DEBUG_MODE
|
||||
|
|
@ -2101,7 +2100,7 @@ namespace VCSnonideal {
|
|||
*/
|
||||
double dx = delta;
|
||||
double *sc_irxn = m_stoichCoeffRxnMatrix[irxn];
|
||||
for (j = 0; j < m_numComponents; ++j) {
|
||||
for (size_t j = 0; j < m_numComponents; ++j) {
|
||||
if (m_molNumSpecies_old[j] > 0.0) {
|
||||
tmp = sc_irxn[j] * dx;
|
||||
if (-tmp > m_molNumSpecies_old[j]) {
|
||||
|
|
@ -2129,7 +2128,7 @@ namespace VCSnonideal {
|
|||
m_tPhaseMoles_old[iph] += dx;
|
||||
vcs_setFlagsVolPhase(iph, false, VCS_STATECALC_OLD);
|
||||
|
||||
for (j = 0; j < m_numComponents; ++j) {
|
||||
for (size_t j = 0; j < m_numComponents; ++j) {
|
||||
tmp = sc_irxn[j] * dx;
|
||||
if (tmp != 0.0) {
|
||||
iph = m_phaseID[j];
|
||||
|
|
@ -2253,7 +2252,7 @@ namespace VCSnonideal {
|
|||
if (! m_SSPhase[klast]) {
|
||||
if (Vphase->exists() != VCS_PHASE_EXIST_ALWAYS) {
|
||||
bool stillExists = false;
|
||||
for (int k = 0; k < m_numSpeciesRdc; k++) {
|
||||
for (size_t k = 0; k < m_numSpeciesRdc; k++) {
|
||||
if (m_speciesUnknownType[k] != VCS_SPECIES_TYPE_INTERFACIALVOLTAGE) {
|
||||
if (m_phaseID[k] == iph) {
|
||||
if (m_molNumSpecies_old[k] > 0.0) {
|
||||
|
|
@ -2432,9 +2431,9 @@ namespace VCSnonideal {
|
|||
}
|
||||
}
|
||||
}
|
||||
int jcomp;
|
||||
|
||||
double deltaLarge, dj, dxWant, dxPerm = 0.0, dxPerm2 = 0.0;
|
||||
for (int kcomp = 0; kcomp < m_numComponents; ++kcomp) {
|
||||
for (size_t kcomp = 0; kcomp < m_numComponents; ++kcomp) {
|
||||
if (m_phaseID[kcomp] == iph) {
|
||||
#ifdef DEBUG_MODE
|
||||
if (m_debug_print_lvl >= 2) {
|
||||
|
|
@ -2452,7 +2451,7 @@ namespace VCSnonideal {
|
|||
if (dxWant + m_molNumSpecies_old[kspec] < 0.0) {
|
||||
dxPerm = -m_molNumSpecies_old[kspec];
|
||||
}
|
||||
for (jcomp = 0; kcomp < m_numComponents; ++kcomp) {
|
||||
for (size_t jcomp = 0; kcomp < m_numComponents; ++kcomp) {
|
||||
if (jcomp != kcomp) {
|
||||
if (m_phaseID[jcomp] == iph) {
|
||||
dxPerm = 0.0;
|
||||
|
|
@ -3190,7 +3189,7 @@ namespace VCSnonideal {
|
|||
if (m_speciesUnknownType[kspec] != VCS_SPECIES_TYPE_INTERFACIALVOLTAGE) {
|
||||
maxConcPossKspec = 1.0E10;
|
||||
nonZeroesKspec = 0;
|
||||
for (int j = 0; j < m_numElemConstraints; ++j) {
|
||||
for (size_t j = 0; j < m_numElemConstraints; ++j) {
|
||||
if (m_elementActive[j]) {
|
||||
if (m_elType[j] == VCS_ELEM_TYPE_ABSPOS) {
|
||||
double nu = m_formulaMatrix[j][kspec];
|
||||
|
|
@ -3642,7 +3641,7 @@ namespace VCSnonideal {
|
|||
* which is so low that species will always be zero
|
||||
*
|
||||
*/
|
||||
for (int j = 0; j < m_numElemConstraints; ++j) {
|
||||
for (size_t j = 0; j < m_numElemConstraints; ++j) {
|
||||
int elType = m_elType[j];
|
||||
if (elType == VCS_ELEM_TYPE_ABSPOS) {
|
||||
double atomComp = m_formulaMatrix[j][kspec];
|
||||
|
|
@ -3676,7 +3675,7 @@ namespace VCSnonideal {
|
|||
* existence.
|
||||
*/
|
||||
if (irxn >= 0) {
|
||||
for (int j = 0; j < m_numComponents; ++j) {
|
||||
for (size_t j = 0; j < m_numComponents; ++j) {
|
||||
double stoicC = m_stoichCoeffRxnMatrix[irxn][j];
|
||||
if (stoicC != 0.0) {
|
||||
double negChangeComp = - stoicC;
|
||||
|
|
@ -3798,7 +3797,7 @@ namespace VCSnonideal {
|
|||
return VCS_SPECIES_MAJOR;
|
||||
} else {
|
||||
double szAdj = m_scSize[irxn] * std::sqrt((double)m_numRxnTot);
|
||||
for (int k = 0; k < m_numComponents; ++k) {
|
||||
for (size_t k = 0; k < m_numComponents; ++k) {
|
||||
if (!(m_SSPhase[k])) {
|
||||
if (m_stoichCoeffRxnMatrix[irxn][k] != 0.0) {
|
||||
if (m_molNumSpecies_old[kspec] * szAdj >= m_molNumSpecies_old[k] * 0.01) {
|
||||
|
|
@ -4437,19 +4436,18 @@ namespace VCSnonideal {
|
|||
* Reconciles Phase existence flags with total moles in each phase.
|
||||
*/
|
||||
double VCS_SOLVE::vcs_tmoles() {
|
||||
int i;
|
||||
double sum;
|
||||
vcs_VolPhase *Vphase;
|
||||
for (i = 0; i < m_numPhases; i++) {
|
||||
for (size_t i = 0; i < m_numPhases; i++) {
|
||||
m_tPhaseMoles_old[i] = TPhInertMoles[i];
|
||||
}
|
||||
for (i = 0; i < m_numSpeciesTot; i++) {
|
||||
for (size_t i = 0; i < m_numSpeciesTot; i++) {
|
||||
if (m_speciesUnknownType[i] == VCS_SPECIES_TYPE_MOLNUM) {
|
||||
m_tPhaseMoles_old[m_phaseID[i]] += m_molNumSpecies_old[i];
|
||||
}
|
||||
}
|
||||
sum = 0.0;
|
||||
for (i = 0; i < m_numPhases; i++) {
|
||||
for (size_t i = 0; i < m_numPhases; i++) {
|
||||
sum += m_tPhaseMoles_old[i];
|
||||
Vphase = m_VolPhaseList[i];
|
||||
// Took out because we aren't updating mole fractions in Vphase
|
||||
|
|
@ -4471,7 +4469,7 @@ namespace VCSnonideal {
|
|||
for (i = 0; i < m_numPhases; i++) {
|
||||
double m_tPhaseMoles_old_a = TPhInertMoles[i];
|
||||
|
||||
for (int k = 0; k < m_numSpeciesTot; k++) {
|
||||
for (size_t k = 0; k < m_numSpeciesTot; k++) {
|
||||
if (m_speciesUnknownType[k] == VCS_SPECIES_TYPE_MOLNUM) {
|
||||
if (m_phaseID[k] == i) {
|
||||
m_tPhaseMoles_old_a += m_molNumSpecies_old[k];
|
||||
|
|
@ -4499,7 +4497,7 @@ namespace VCSnonideal {
|
|||
*/
|
||||
void VCS_SOLVE::vcs_updateVP(const int vcsState) {
|
||||
vcs_VolPhase *Vphase;
|
||||
for (int i = 0; i < m_numPhases; i++) {
|
||||
for (size_t i = 0; i < m_numPhases; i++) {
|
||||
Vphase = m_VolPhaseList[i];
|
||||
if (vcsState == VCS_STATECALC_OLD) {
|
||||
Vphase->setMolesFromVCSCheck(VCS_STATECALC_OLD,
|
||||
|
|
@ -4570,7 +4568,6 @@ namespace VCSnonideal {
|
|||
*
|
||||
*/
|
||||
bool VCS_SOLVE::vcs_evaluate_speciesType() {
|
||||
int kspec;
|
||||
bool allMinorZeroedSpecies;
|
||||
|
||||
m_numRxnMinorZeroed = 0;
|
||||
|
|
@ -4582,7 +4579,7 @@ namespace VCSnonideal {
|
|||
plogendl();
|
||||
}
|
||||
#endif
|
||||
for (kspec = 0; kspec < m_numSpeciesTot; ++kspec) {
|
||||
for (size_t kspec = 0; kspec < m_numSpeciesTot; ++kspec) {
|
||||
m_speciesStatus[kspec] = vcs_species_type(kspec);
|
||||
#ifdef DEBUG_MODE
|
||||
if (m_debug_print_lvl >= 5) {
|
||||
|
|
@ -4864,7 +4861,6 @@ namespace VCSnonideal {
|
|||
* This can probably be solved by successive iteration.
|
||||
* This should be implemented.
|
||||
*/
|
||||
int k;
|
||||
//alterZeroedPhases = false;
|
||||
if (alterZeroedPhases && false) {
|
||||
for (iph = 0; iph < m_numPhases; iph++) {
|
||||
|
|
@ -4872,7 +4868,7 @@ namespace VCSnonideal {
|
|||
vcs_VolPhase *Vphase = m_VolPhaseList[iph];
|
||||
if (! Vphase->m_singleSpecies) {
|
||||
double sum = 0.0;
|
||||
for (k = 0; k < Vphase->nSpecies(); k++) {
|
||||
for (size_t k = 0; k < Vphase->nSpecies(); k++) {
|
||||
kspec = Vphase->spGlobalIndexVCS(k);
|
||||
if (m_speciesUnknownType[kspec] != VCS_SPECIES_TYPE_INTERFACIALVOLTAGE) {
|
||||
sum += molNumSpecies[kspec];
|
||||
|
|
@ -4886,7 +4882,7 @@ namespace VCSnonideal {
|
|||
|
||||
if (lneed) {
|
||||
double poly = 0.0;
|
||||
for (k = 0; k < Vphase->nSpecies(); k++) {
|
||||
for (size_t k = 0; k < Vphase->nSpecies(); k++) {
|
||||
kspec = Vphase->spGlobalIndexVCS(k);
|
||||
// We may need to look at deltaGRxn for components!
|
||||
if (kspec >= m_numComponents) {
|
||||
|
|
@ -4901,7 +4897,7 @@ namespace VCSnonideal {
|
|||
* All of the m_deltaGRxn_new[]'s will be equal. If deltaGRxn[] is
|
||||
* negative, then the phase will come back into existence.
|
||||
*/
|
||||
for (k = 0; k < Vphase->nSpecies(); k++) {
|
||||
for (size_t k = 0; k < Vphase->nSpecies(); k++) {
|
||||
kspec = Vphase->spGlobalIndexVCS(k);
|
||||
if (kspec >= m_numComponents) {
|
||||
irxn = kspec - m_numComponents;
|
||||
|
|
@ -5302,15 +5298,14 @@ namespace VCSnonideal {
|
|||
/*******************************************************************************/
|
||||
|
||||
void VCS_SOLVE::vcs_setFlagsVolPhases(const bool upToDate, const int stateCalc) {
|
||||
int iph;
|
||||
vcs_VolPhase *Vphase;
|
||||
if (!upToDate) {
|
||||
for (iph = 0; iph < m_numPhases; iph++) {
|
||||
for (size_t iph = 0; iph < m_numPhases; iph++) {
|
||||
Vphase = m_VolPhaseList[iph];
|
||||
Vphase->setMolesOutOfDate(stateCalc);
|
||||
}
|
||||
} else {
|
||||
for (iph = 0; iph < m_numPhases; iph++) {
|
||||
for (size_t iph = 0; iph < m_numPhases; iph++) {
|
||||
Vphase = m_VolPhaseList[iph];
|
||||
Vphase->setMolesCurrent(stateCalc);
|
||||
}
|
||||
|
|
@ -5338,9 +5333,8 @@ namespace VCSnonideal {
|
|||
* VCS_STATECALC_OLD).
|
||||
*/
|
||||
void VCS_SOLVE::vcs_updateMolNumVolPhases(const int stateCalc) {
|
||||
int iph;
|
||||
vcs_VolPhase *Vphase;
|
||||
for (iph = 0; iph < m_numPhases; iph++) {
|
||||
for (size_t iph = 0; iph < m_numPhases; iph++) {
|
||||
Vphase = m_VolPhaseList[iph];
|
||||
Vphase->updateFromVCS_MoleNumbers(stateCalc);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -321,7 +321,7 @@ namespace VCSnonideal {
|
|||
* @param m number of rhs's
|
||||
*/
|
||||
int vcsUtil_mlequ(double *c, size_t idem, size_t n, double *b, size_t m) {
|
||||
int i, j, k, l;
|
||||
size_t k;
|
||||
double R;
|
||||
if (n > idem || n <= 0) {
|
||||
plogf("vcsUtil_mlequ ERROR: badly dimensioned matrix: %d %d\n", n, idem);
|
||||
|
|
@ -334,7 +334,7 @@ namespace VCSnonideal {
|
|||
* will be on the diagonal. We can therfore just invert the
|
||||
* diagonal at the end of the program to solve the equation system.
|
||||
*/
|
||||
for (i = 0; i < n; ++i) {
|
||||
for (size_t i = 0; i < n; ++i) {
|
||||
if (c[i + i * idem] == 0.0) {
|
||||
/*
|
||||
* Do a simple form of row pivoting to find a non-zero pivot
|
||||
|
|
@ -345,16 +345,16 @@ namespace VCSnonideal {
|
|||
plogf("vcsUtil_mlequ ERROR: Encountered a zero column: %d\n", i);
|
||||
return 1;
|
||||
FOUND_PIVOT: ;
|
||||
for (j = 0; j < n; ++j) c[i + j * idem] += c[k + j * idem];
|
||||
for (j = 0; j < m; ++j) b[i + j * idem] += b[k + j * idem];
|
||||
for (size_t j = 0; j < n; ++j) c[i + j * idem] += c[k + j * idem];
|
||||
for (size_t j = 0; j < m; ++j) b[i + j * idem] += b[k + j * idem];
|
||||
}
|
||||
|
||||
for (l = 0; l < n; ++l) {
|
||||
for (size_t l = 0; l < n; ++l) {
|
||||
if (l != i && c[l + i * idem] != 0.0) {
|
||||
R = c[l + i * idem] / c[i + i * idem];
|
||||
c[l + i * idem] = 0.0;
|
||||
for (j = i+1; j < n; ++j) c[l + j * idem] -= c[i + j * idem] * R;
|
||||
for (j = 0; j < m; ++j) b[l + j * idem] -= b[i + j * idem] * R;
|
||||
for (size_t j = i+1; j < n; ++j) c[l + j * idem] -= c[i + j * idem] * R;
|
||||
for (size_t j = 0; j < m; ++j) b[l + j * idem] -= b[i + j * idem] * R;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -362,8 +362,8 @@ namespace VCSnonideal {
|
|||
* The negative in the last expression is due to the form of B upon
|
||||
* input
|
||||
*/
|
||||
for (i = 0; i < n; ++i) {
|
||||
for (j = 0; j < m; ++j) {
|
||||
for (size_t i = 0; i < n; ++i) {
|
||||
for (size_t j = 0; j < m; ++j) {
|
||||
b[i + j * idem] = -b[i + j * idem] / c[i + i*idem];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue