@@ -164,12 +164,12 @@ struct BinaryDiff
164
164
}
165
165
}
166
166
for (int i = 0 ; i < NUM_SPECIES; ++i) {
167
- amrex::Real term1 = 0 ;
168
- for (int j = 0 ; j < NUM_SPECIES; ++j) {
169
- if (i != j) {
170
- term1 += Yloc[j];
171
- }
167
+ amrex::Real term1 = 0 ;
168
+ for (int j = 0 ; j < NUM_SPECIES; ++j) {
169
+ if (i != j) {
170
+ term1 += Yloc[j];
172
171
}
172
+ }
173
173
Ddiag[i] = tparm->wt [i] * term1 / Ddiag[i] * scale;
174
174
}
175
175
}
@@ -190,9 +190,7 @@ struct BinaryDiff<eos::SRK>
190
190
TransParm<eos::SRK, SimpleTransport> const * tparm)
191
191
{
192
192
193
- amrex::Real sum_of_Yloc = 0.0 ;
194
193
for (int i = 0 ; i < NUM_SPECIES; ++i) {
195
- sum_of_Yloc += Yloc[i];
196
194
Ddiag[i] = 0.0 ;
197
195
}
198
196
@@ -219,7 +217,12 @@ struct BinaryDiff<eos::SRK>
219
217
}
220
218
}
221
219
for (int i = 0 ; i < NUM_SPECIES; ++i) {
222
- const amrex::Real term1 = sum_of_Yloc - Yloc[i];
220
+ amrex::Real term1 = 0 ;
221
+ for (int j = 0 ; j < NUM_SPECIES; ++j) {
222
+ if (i != j) {
223
+ term1 += Yloc[j];
224
+ }
225
+ }
223
226
Ddiag[i] = tparm->wt [i] * term1 / Ddiag[i];
224
227
}
225
228
}
@@ -296,7 +299,7 @@ struct SimpleTransport
296
299
const bool wtr_get_chi,
297
300
const amrex::Real Tloc,
298
301
const amrex::Real rholoc,
299
- amrex::Real* Yloc,
302
+ const amrex::Real* Yloc,
300
303
amrex::Real* Ddiag,
301
304
amrex::Real* chi_mix,
302
305
amrex::Real& mu,
@@ -306,6 +309,7 @@ struct SimpleTransport
306
309
{
307
310
amrex::Real trace = 1 .e -15 ;
308
311
amrex::Real Xloc[NUM_SPECIES] = {0.0 };
312
+ amrex::Real Yloc_mod[NUM_SPECIES] = {0.0 };
309
313
amrex::Real muloc[NUM_SPECIES] = {0.0 };
310
314
amrex::Real xiloc[NUM_SPECIES] = {0.0 };
311
315
amrex::Real logT[NUM_FIT - 1 ] = {0.0 };
@@ -314,23 +318,22 @@ struct SimpleTransport
314
318
logT[1 ] = logT[0 ] * logT[0 ];
315
319
logT[2 ] = logT[0 ] * logT[1 ];
316
320
321
+ // Modify Yloc to avoid potential divide by 0 for pure components
317
322
amrex::Real sum = 0.0 ;
318
-
319
323
for (int i = 0 ; i < NUM_SPECIES; ++i) {
320
324
sum += Yloc[i];
321
325
}
322
-
323
326
for (int i = 0 ; i < NUM_SPECIES; ++i) {
324
- Yloc[i] += trace * (sum / NUM_SPECIES - Yloc[i]);
327
+ Yloc_mod[i] = Yloc[i] + trace * (sum / NUM_SPECIES - Yloc[i]);
325
328
}
326
329
327
330
amrex::Real wbar = 0.0 ;
328
331
for (int i = 0 ; i < NUM_SPECIES; ++i) {
329
- wbar += Yloc [i] * tparm->iwt [i];
332
+ wbar += Yloc_mod [i] * tparm->iwt [i];
330
333
}
331
334
wbar = 1.0 / wbar;
332
335
for (int i = 0 ; i < NUM_SPECIES; ++i) {
333
- Xloc[i] = Yloc [i] * wbar * tparm->iwt [i];
336
+ Xloc[i] = Yloc_mod [i] * wbar * tparm->iwt [i];
334
337
}
335
338
if (wtr_get_mu) {
336
339
for (int i = 0 ; i < NUM_SPECIES; ++i) {
@@ -382,7 +385,7 @@ struct SimpleTransport
382
385
wtr_get_mu, wtr_get_lam, Tloc, Xloc, rholoc, wbar, mu, lam, tparm);
383
386
384
387
if (wtr_get_Ddiag) {
385
- BinaryDiff<EosType>()(Xloc, Yloc , logT, rholoc, Tloc, Ddiag, tparm);
388
+ BinaryDiff<EosType>()(Xloc, Yloc_mod , logT, rholoc, Tloc, Ddiag, tparm);
386
389
}
387
390
388
391
if (wtr_get_chi) {
0 commit comments