Skip to content

Commit 7daad1f

Browse files
committed
[Equil] replace references to Phase::name by Phase::id
* reference phases using Phase::id instead * create private vcs_VolPhase::m_phaseID * vcs_VolPhase::PhaseID() replaces vcs_VolPhase::PhaseName * clarify conflation of 'phase id' in vcs_solve (which references a numeric phase number) rather than a string 'phase id' as used elsewhere * i.e. VCS_SOLVE::m_phaseNum replaces VCS_SOLVE::m_phaseID
1 parent ea65ba6 commit 7daad1f

14 files changed

+126
-117
lines changed

include/cantera/equil/vcs_VolPhase.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,11 @@ class vcs_VolPhase
9292
/*!
9393
* @param phaseNum index of the phase in the vcs problem
9494
* @param numSpecies Number of species in the phase
95-
* @param phaseName String name for the phase
95+
* @param phaseID String identifier for the phase
9696
* @param molesInert kmoles of inert in the phase (defaults to zero)
9797
*/
9898
void resize(const size_t phaseNum, const size_t numSpecies,
99-
const size_t numElem, const char* const phaseName,
99+
const size_t numElem, const char* const phaseID,
100100
const double molesInert = 0.0);
101101

102102
void elemResize(const size_t numElemConstraints);
@@ -623,10 +623,13 @@ class vcs_VolPhase
623623
size_t m_numSpecies;
624624

625625
public:
626-
//! String name for the phase
627-
std::string PhaseName;
626+
//! String identifier for the phase
627+
std::string PhaseID();
628628

629629
private:
630+
//! String identifier of the phase
631+
std::string m_phaseID;
632+
630633
//! Total moles of inert in the phase
631634
double m_totalMolesInert;
632635

include/cantera/equil/vcs_solve.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ class VCS_SOLVE
527527
* in the private data structure. All references to the species
528528
* properties must employ the ind[] index vector.
529529
* 4. Initialization of arrays to zero.
530-
* 5. Check to see if the problem is well posed (If all the element
530+
* 5. Check to see if the problem is well posed (If all the element
531531
* abundances are zero, the algorithm will fail)
532532
*
533533
* @param printLvl Print level of the routine
@@ -1354,7 +1354,7 @@ class VCS_SOLVE
13541354
vector_int m_speciesStatus;
13551355

13561356
//! Mapping from the species number to the phase number
1357-
std::vector<size_t> m_phaseID;
1357+
std::vector<size_t> m_phaseNum;
13581358

13591359
//! Boolean indicating whether a species belongs to a single-species phase
13601360
// vector<bool> can't be used here because it doesn't work with std::swap

src/equil/vcs_Gibbs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ double VCS_SOLVE::vcs_GibbsPhase(size_t iphase, const double* const w,
4242
double g = 0.0;
4343
double phaseMols = 0.0;
4444
for (size_t kspec = 0; kspec < m_numSpeciesRdc; ++kspec) {
45-
if (m_phaseID[kspec] == iphase && m_speciesUnknownType[kspec] != VCS_SPECIES_TYPE_INTERFACIALVOLTAGE) {
45+
if (m_phaseNum[kspec] == iphase && m_speciesUnknownType[kspec] != VCS_SPECIES_TYPE_INTERFACIALVOLTAGE) {
4646
g += w[kspec] * fe[kspec];
4747
phaseMols += w[kspec];
4848
}

src/equil/vcs_MultiPhaseEquil.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ int vcs_MultiPhaseEquil::equilibrate_TP(int estimateEquil,
469469
} else {
470470
plogf(" %15.3e %15.3e ", m_mix->speciesMoles(i), m_mix->moleFraction(i));
471471
if (m_mix->speciesMoles(i) <= 0.0) {
472-
size_t iph = m_vsolve.m_phaseID[i];
472+
size_t iph = m_vsolve.m_phaseNum[i];
473473
vcs_VolPhase* VPhase = m_vsolve.m_VolPhaseList[iph].get();
474474
if (VPhase->nSpecies() > 1) {
475475
plogf(" -1.000e+300\n");

src/equil/vcs_VolPhase.cpp

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ vcs_VolPhase::vcs_VolPhase(VCS_SOLVE* owningSolverObject) :
2828
m_numElemConstraints(0),
2929
m_elemGlobalIndex(0),
3030
m_numSpecies(0),
31+
m_phaseID("<phase-id>"),
3132
m_totalMolesInert(0.0),
3233
m_isIdealSoln(false),
3334
m_existence(VCS_PHASE_EXIST_NO),
@@ -58,8 +59,13 @@ vcs_VolPhase::~vcs_VolPhase()
5859
}
5960
}
6061

62+
std::string vcs_VolPhase::PhaseID()
63+
{
64+
return m_phaseID;
65+
}
66+
6167
void vcs_VolPhase::resize(const size_t phaseNum, const size_t nspecies,
62-
const size_t numElem, const char* const phaseName,
68+
const size_t numElem, const char* const phaseID,
6369
const double molesInert)
6470
{
6571
AssertThrowMsg(nspecies > 0, "vcs_VolPhase::resize", "nspecies Error");
@@ -68,17 +74,17 @@ void vcs_VolPhase::resize(const size_t phaseNum, const size_t nspecies,
6874
m_phiVarIndex = npos;
6975

7076
if (phaseNum == VP_ID_) {
71-
if (strcmp(PhaseName.c_str(), phaseName)) {
77+
if (strcmp(m_phaseID.c_str(), phaseID)) {
7278
throw CanteraError("vcs_VolPhase::resize",
73-
"Strings are different: " + PhaseName + " " +
74-
phaseName + " :unknown situation");
79+
"Strings are different: " + m_phaseID + " " +
80+
phaseID + " :unknown situation");
7581
}
7682
} else {
7783
VP_ID_ = phaseNum;
78-
if (!phaseName) {
79-
PhaseName = fmt::format("Phase_{}", VP_ID_);
84+
if (!phaseID) {
85+
m_phaseID = fmt::format("Phase_{}", VP_ID_);
8086
} else {
81-
PhaseName = phaseName;
87+
m_phaseID = phaseID;
8288
}
8389
}
8490
if (nspecies > 1) {
@@ -589,7 +595,7 @@ void vcs_VolPhase::setPtrThermoPhase(ThermoPhase* tp_ptr)
589595
if (m_numSpecies != 0) {
590596
plogf("Warning Nsp != NVolSpeces: %d %d \n", nsp, m_numSpecies);
591597
}
592-
resize(VP_ID_, nsp, nelem, PhaseName.c_str());
598+
resize(VP_ID_, nsp, nelem, m_phaseID.c_str());
593599
}
594600
TP_ptr->getMoleFractions(&Xmol_[0]);
595601
creationMoleNumbers_ = Xmol_;

src/equil/vcs_elem.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ void VCS_SOLVE::vcs_elabPhase(size_t iphase, double* const elemAbundPhase)
8787
for (size_t j = 0; j < m_nelem; ++j) {
8888
elemAbundPhase[j] = 0.0;
8989
for (size_t i = 0; i < m_nsp; ++i) {
90-
if (m_speciesUnknownType[i] != VCS_SPECIES_TYPE_INTERFACIALVOLTAGE && m_phaseID[i] == iphase) {
90+
if (m_speciesUnknownType[i] != VCS_SPECIES_TYPE_INTERFACIALVOLTAGE && m_phaseNum[i] == iphase) {
9191
elemAbundPhase[j] += m_formulaMatrix(i,j) * m_molNumSpecies_old[i];
9292
}
9393
}

src/equil/vcs_inest.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ void VCS_SOLVE::vcs_inest(double* const aw, double* const sa, double* const sm,
8383
}
8484
for (size_t kspec = 0; kspec < m_numComponents; ++kspec) {
8585
if (m_speciesUnknownType[kspec] == VCS_SPECIES_TYPE_MOLNUM) {
86-
m_tPhaseMoles_new[m_phaseID[kspec]] += m_molNumSpecies_old[kspec];
86+
m_tPhaseMoles_new[m_phaseNum[kspec]] += m_molNumSpecies_old[kspec];
8787
}
8888
}
8989
double TMolesMultiphase = 0.0;
@@ -103,7 +103,7 @@ void VCS_SOLVE::vcs_inest(double* const aw, double* const sa, double* const sm,
103103
for (size_t kspec = 0; kspec < m_numComponents; ++kspec) {
104104
if (m_speciesUnknownType[kspec] == VCS_SPECIES_TYPE_MOLNUM) {
105105
if (! m_SSPhase[kspec]) {
106-
size_t iph = m_phaseID[kspec];
106+
size_t iph = m_phaseNum[kspec];
107107
m_feSpecies_new[kspec] += log(m_molNumSpecies_new[kspec] / m_tPhaseMoles_old[iph]);
108108
}
109109
} else {
@@ -140,7 +140,7 @@ void VCS_SOLVE::vcs_inest(double* const aw, double* const sa, double* const sm,
140140
// the phase exists, it stays. If it doesn't exist in the estimate, it
141141
// doesn't come into existence here.
142142
if (! m_SSPhase[kspec]) {
143-
size_t iph = m_phaseID[kspec];
143+
size_t iph = m_phaseNum[kspec];
144144
if (m_deltaGRxn_new[irxn] > xtphMax[iph]) {
145145
m_deltaGRxn_new[irxn] = 0.8 * xtphMax[iph];
146146
}

src/equil/vcs_phaseStability.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ size_t VCS_SOLVE::vcs_popPhaseID(std::vector<size_t> & phasePopPhaseIDs)
125125
if (existence > 0) {
126126
if (m_debug_print_lvl >= 2) {
127127
plogf(" --- %18s %5d NA %11.3e\n",
128-
Vphase->PhaseName, existence, m_tPhaseMoles_old[iph]);
128+
Vphase->PhaseID(), existence, m_tPhaseMoles_old[iph]);
129129
}
130130
} else {
131131
if (Vphase->m_singleSpecies) {
@@ -154,7 +154,7 @@ size_t VCS_SOLVE::vcs_popPhaseID(std::vector<size_t> & phasePopPhaseIDs)
154154

155155
if (m_debug_print_lvl >= 2) {
156156
plogf(" --- %18s %5d %10.3g %10.3g %s\n",
157-
Vphase->PhaseName, existence, Fephase,
157+
Vphase->PhaseID(), existence, Fephase,
158158
m_tPhaseMoles_old[iph], anote);
159159
}
160160
} else {
@@ -171,13 +171,13 @@ size_t VCS_SOLVE::vcs_popPhaseID(std::vector<size_t> & phasePopPhaseIDs)
171171
}
172172
if (m_debug_print_lvl >= 2) {
173173
plogf(" --- %18s %5d %11.3g %11.3g\n",
174-
Vphase->PhaseName, existence, Fephase,
174+
Vphase->PhaseID(), existence, Fephase,
175175
m_tPhaseMoles_old[iph]);
176176
}
177177
} else {
178178
if (m_debug_print_lvl >= 2) {
179179
plogf(" --- %18s %5d blocked %11.3g\n",
180-
Vphase->PhaseName,
180+
Vphase->PhaseID(),
181181
existence, m_tPhaseMoles_old[iph]);
182182
}
183183
}
@@ -215,7 +215,7 @@ int VCS_SOLVE::vcs_popPhaseRxnStepSizes(const size_t iphasePop)
215215
"called for a phase that exists!");
216216
if (m_debug_print_lvl >= 2) {
217217
plogf(" --- vcs_popPhaseRxnStepSizes() called to pop phase %s %d into existence\n",
218-
Vphase->PhaseName, iphasePop);
218+
Vphase->PhaseID(), iphasePop);
219219
}
220220
// Section for a single-species phase
221221
if (Vphase->m_singleSpecies) {
@@ -307,7 +307,7 @@ int VCS_SOLVE::vcs_popPhaseRxnStepSizes(const size_t iphasePop)
307307
}
308308
} else {
309309
if (m_elType[j] == VCS_ELEM_TYPE_ABSPOS) {
310-
size_t jph = m_phaseID[j];
310+
size_t jph = m_phaseNum[j];
311311
if ((jph != iphasePop) && (!m_SSPhase[j])) {
312312
double fdeltaJ = fabs(deltaJ);
313313
if (m_molNumSpecies_old[j] > 0.0) {

src/equil/vcs_prep.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ void VCS_SOLVE::vcs_SSPhase()
1616
{
1717
vector_int numPhSpecies(m_numPhases, 0);
1818
for (size_t kspec = 0; kspec < m_nsp; ++kspec) {
19-
numPhSpecies[m_phaseID[kspec]]++;
19+
numPhSpecies[m_phaseNum[kspec]]++;
2020
}
2121

2222
// Handle the special case of a single species in a phase that has been
@@ -37,7 +37,7 @@ void VCS_SOLVE::vcs_SSPhase()
3737
// information concerning the phase ID of species. SSPhase = Boolean
3838
// indicating whether a species is in a single species phase or not.
3939
for (size_t kspec = 0; kspec < m_nsp; kspec++) {
40-
size_t iph = m_phaseID[kspec];
40+
size_t iph = m_phaseNum[kspec];
4141
vcs_VolPhase* Vphase = m_VolPhaseList[iph].get();
4242
if (Vphase->m_singleSpecies) {
4343
m_SSPhase[kspec] = true;
@@ -70,7 +70,7 @@ int VCS_SOLVE::vcs_prep(int printLvl)
7070
}
7171

7272
for (size_t kspec = 0; kspec < m_nsp; ++kspec) {
73-
size_t pID = m_phaseID[kspec];
73+
size_t pID = m_phaseNum[kspec];
7474
size_t spPhIndex = m_speciesLocalPhaseIndex[kspec];
7575
vcs_VolPhase* vPhase = m_VolPhaseList[pID].get();
7676
vcs_SpeciesProperties* spProp = vPhase->speciesProperty(spPhIndex);

src/equil/vcs_prob.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ void VCS_SOLVE::prob_report(int print_lvl)
4141
plogf("\t\tPres = %g atm\n", pres_atm);
4242
plogf("\n");
4343
plogf(" Phase IDs of species\n");
44-
plogf(" species phaseID phaseName ");
44+
plogf(" species phaseNum phaseID ");
4545
plogf(" Initial_Estimated_Moles Species_Type\n");
4646
for (size_t i = 0; i < m_nsp; i++) {
47-
vcs_VolPhase* Vphase = m_VolPhaseList[m_phaseID[i]].get();
48-
plogf("%16s %5d %16s", m_mix->speciesName(i), m_phaseID[i],
49-
Vphase->PhaseName);
47+
vcs_VolPhase* Vphase = m_VolPhaseList[m_phaseNum[i]].get();
48+
plogf("%16s %5d %16s", m_mix->speciesName(i), m_phaseNum[i],
49+
Vphase->PhaseID());
5050
if (m_doEstimateEquil >= 0) {
5151
plogf(" %-10.5g", m_molNumSpecies_old[i]);
5252
} else {
@@ -65,13 +65,13 @@ void VCS_SOLVE::prob_report(int print_lvl)
6565
// Printout of the Phase structure information
6666
writeline('-', 80, true, true);
6767
plogf(" Information about phases\n");
68-
plogf(" PhaseName PhaseNum SingSpec GasPhase "
68+
plogf(" PhaseID PhaseNum SingSpec GasPhase "
6969
" EqnState NumSpec");
7070
plogf(" TMolesInert TKmoles\n");
7171

7272
for (size_t iphase = 0; iphase < m_numPhases; iphase++) {
7373
vcs_VolPhase* Vphase = m_VolPhaseList[iphase].get();
74-
plogf("%16s %5d %5d %8d ", Vphase->PhaseName,
74+
plogf("%16s %5d %5d %8d ", Vphase->PhaseID(),
7575
Vphase->VP_ID_, Vphase->m_singleSpecies, Vphase->m_gasPhase);
7676
plogf("%16s %8d %16e ", Vphase->eos_name(),
7777
Vphase->nSpecies(), Vphase->totalMolesInert());
@@ -101,7 +101,7 @@ void VCS_SOLVE::prob_report(int print_lvl)
101101
size_t kglob = Vphase->spGlobalIndexVCS(kindex);
102102
plogf("%16s ", m_mix->speciesName(kglob));
103103
if (kindex == 0) {
104-
plogf("%16s", Vphase->PhaseName);
104+
plogf("%16s", Vphase->PhaseID());
105105
} else {
106106
plogf(" ");
107107
}

src/equil/vcs_report.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ int VCS_SOLVE::vcs_report(int iconv)
8484
plogf(" Inert Gas Species ");
8585
} else {
8686
plogf(" Inert Species in phase %16s ",
87-
m_VolPhaseList[i]->PhaseName);
87+
m_VolPhaseList[i]->PhaseID());
8888
}
8989
plogf("%14.7E %14.7E %12.4E\n", TPhInertMoles[i],
9090
TPhInertMoles[i] / m_tPhaseMoles_old[i], 0.0);
@@ -162,7 +162,7 @@ int VCS_SOLVE::vcs_report(int iconv)
162162
plogf(" %10.10s", m_elementName[j]);
163163
}
164164
plogf(" | |\n");
165-
plogf(" PhaseName |KMolTarget |");
165+
plogf(" PhaseID |KMolTarget |");
166166
for (size_t j = 0; j < m_nelem; j++) {
167167
plogf(" %10.3g", m_elemAbundancesGoal[j]);
168168
}
@@ -171,7 +171,7 @@ int VCS_SOLVE::vcs_report(int iconv)
171171
for (size_t iphase = 0; iphase < m_numPhases; iphase++) {
172172
plogf(" %3d ", iphase);
173173
vcs_VolPhase* VPhase = m_VolPhaseList[iphase].get();
174-
plogf("%-12.12s |",VPhase->PhaseName);
174+
plogf("%-12.12s |", VPhase->PhaseID());
175175
plogf("%10.3e |", m_tPhaseMoles_old[iphase]);
176176
totalMoles += m_tPhaseMoles_old[iphase];
177177
if (m_tPhaseMoles_old[iphase] != VPhase->totalMoles() &&
@@ -230,7 +230,7 @@ int VCS_SOLVE::vcs_report(int iconv)
230230
writeline('-', 147, true, true);
231231
for (size_t i = 0; i < m_nsp; ++i) {
232232
size_t j = x_order[i].second;
233-
size_t pid = m_phaseID[j];
233+
size_t pid = m_phaseNum[j];
234234
plogf(" %-12.12s", m_speciesName[j]);
235235
plogf(" %14.7E ", m_molNumSpecies_old[j]);
236236
plogf("%14.7E ", m_SSfeSpecies[j]);

src/equil/vcs_rxnadj.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ size_t VCS_SOLVE::vcs_RxnStepSizes(int& forceComponentCalc, size_t& kSpecial)
6060
if (m_deltaGRxn_new[irxn] < -1.0e-4) {
6161
// First decide if this species is part of a multiphase that
6262
// is nontrivial in size.
63-
size_t iph = m_phaseID[kspec];
63+
size_t iph = m_phaseNum[kspec];
6464
double tphmoles = m_tPhaseMoles_old[iph];
6565
double trphmoles = tphmoles / m_totalMolNum;
6666
vcs_VolPhase* Vphase = m_VolPhaseList[iph].get();
@@ -250,7 +250,7 @@ size_t VCS_SOLVE::vcs_RxnStepSizes(int& forceComponentCalc, size_t& kSpecial)
250250
m_deltaMolNumSpecies[j] = dss * m_stoichCoeffRxnMatrix(j,irxn);
251251
}
252252

253-
iphDel = m_phaseID[k];
253+
iphDel = m_phaseNum[k];
254254
kSpecial = k;
255255

256256
if (k != kspec) {
@@ -315,7 +315,7 @@ double VCS_SOLVE::vcs_Hessian_diag_adj(size_t irxn, double hessianDiag_Ideal)
315315
double VCS_SOLVE::vcs_Hessian_actCoeff_diag(size_t irxn)
316316
{
317317
size_t kspec = m_indexRxnToSpecies[irxn];
318-
size_t kph = m_phaseID[kspec];
318+
size_t kph = m_phaseNum[kspec];
319319
double np_kspec = std::max(m_tPhaseMoles_old[kph], 1e-13);
320320
double* sc_irxn = m_stoichCoeffRxnMatrix.ptrColumn(irxn);
321321

@@ -327,14 +327,14 @@ double VCS_SOLVE::vcs_Hessian_actCoeff_diag(size_t irxn)
327327
for (size_t j = 0; j < m_numComponents; j++) {
328328
if (!m_SSPhase[j]) {
329329
for (size_t k = 0; k < m_numComponents; ++k) {
330-
if (m_phaseID[k] == m_phaseID[j]) {
331-
double np = m_tPhaseMoles_old[m_phaseID[k]];
330+
if (m_phaseNum[k] == m_phaseNum[j]) {
331+
double np = m_tPhaseMoles_old[m_phaseNum[k]];
332332
if (np > 0.0) {
333333
s += sc_irxn[k] * sc_irxn[j] * m_np_dLnActCoeffdMolNum(j,k) / np;
334334
}
335335
}
336336
}
337-
if (kph == m_phaseID[j]) {
337+
if (kph == m_phaseNum[j]) {
338338
s += sc_irxn[j] * (m_np_dLnActCoeffdMolNum(j,kspec) + m_np_dLnActCoeffdMolNum(kspec,j)) / np_kspec;
339339
}
340340
}

0 commit comments

Comments
 (0)