Skip to content

Commit 66de40f

Browse files
authored
Merge branch 'development' into gcm-dev
2 parents a1211bc + 7d6ba7c commit 66de40f

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

Source/Transport/Simple.H

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,7 @@ struct BinaryDiff
146146
{
147147
const amrex::Real scale = Constants::PATM / (Constants::RU * Tloc);
148148

149-
amrex::Real sum_of_Yloc = 0.0;
150149
for (int i = 0; i < NUM_SPECIES; ++i) {
151-
sum_of_Yloc += Yloc[i];
152150
Ddiag[i] = 0.0;
153151
}
154152

@@ -160,14 +158,18 @@ struct BinaryDiff
160158
tparm->fitdbin[four_idx_ij + 1] * logT[0] +
161159
tparm->fitdbin[four_idx_ij + 2] * logT[1] +
162160
tparm->fitdbin[four_idx_ij + 3] * logT[2];
163-
164161
dbintemp = std::exp(-dbintemp);
165162
Ddiag[i] += Xloc[j] * dbintemp;
166163
Ddiag[j] += Xloc[i] * dbintemp;
167164
}
168165
}
169166
for (int i = 0; i < NUM_SPECIES; ++i) {
170-
const amrex::Real term1 = sum_of_Yloc - Yloc[i];
167+
amrex::Real term1 = 0;
168+
for (int j = 0; j < NUM_SPECIES; ++j) {
169+
if (i != j) {
170+
term1 += Yloc[j];
171+
}
172+
}
171173
Ddiag[i] = tparm->wt[i] * term1 / Ddiag[i] * scale;
172174
}
173175
}
@@ -188,9 +190,7 @@ struct BinaryDiff<eos::SRK>
188190
TransParm<eos::SRK, SimpleTransport> const* tparm)
189191
{
190192

191-
amrex::Real sum_of_Yloc = 0.0;
192193
for (int i = 0; i < NUM_SPECIES; ++i) {
193-
sum_of_Yloc += Yloc[i];
194194
Ddiag[i] = 0.0;
195195
}
196196

@@ -217,7 +217,12 @@ struct BinaryDiff<eos::SRK>
217217
}
218218
}
219219
for (int i = 0; i < NUM_SPECIES; ++i) {
220-
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+
}
221226
Ddiag[i] = tparm->wt[i] * term1 / Ddiag[i];
222227
}
223228
}
@@ -294,7 +299,7 @@ struct SimpleTransport
294299
const bool wtr_get_chi,
295300
const amrex::Real Tloc,
296301
const amrex::Real rholoc,
297-
amrex::Real* Yloc,
302+
const amrex::Real* Yloc,
298303
amrex::Real* Ddiag,
299304
amrex::Real* chi_mix,
300305
amrex::Real& mu,
@@ -304,6 +309,7 @@ struct SimpleTransport
304309
{
305310
amrex::Real trace = 1.e-15;
306311
amrex::Real Xloc[NUM_SPECIES] = {0.0};
312+
amrex::Real Yloc_mod[NUM_SPECIES] = {0.0};
307313
amrex::Real muloc[NUM_SPECIES] = {0.0};
308314
amrex::Real xiloc[NUM_SPECIES] = {0.0};
309315
amrex::Real logT[NUM_FIT - 1] = {0.0};
@@ -312,23 +318,22 @@ struct SimpleTransport
312318
logT[1] = logT[0] * logT[0];
313319
logT[2] = logT[0] * logT[1];
314320

321+
// Modify Yloc to avoid potential divide by 0 for pure components
315322
amrex::Real sum = 0.0;
316-
317323
for (int i = 0; i < NUM_SPECIES; ++i) {
318324
sum += Yloc[i];
319325
}
320-
321326
for (int i = 0; i < NUM_SPECIES; ++i) {
322-
Yloc[i] += trace * (sum / NUM_SPECIES - Yloc[i]);
327+
Yloc_mod[i] = Yloc[i] + trace * (sum / NUM_SPECIES - Yloc[i]);
323328
}
324329

325330
amrex::Real wbar = 0.0;
326331
for (int i = 0; i < NUM_SPECIES; ++i) {
327-
wbar += Yloc[i] * tparm->iwt[i];
332+
wbar += Yloc_mod[i] * tparm->iwt[i];
328333
}
329334
wbar = 1.0 / wbar;
330335
for (int i = 0; i < NUM_SPECIES; ++i) {
331-
Xloc[i] = Yloc[i] * wbar * tparm->iwt[i];
336+
Xloc[i] = Yloc_mod[i] * wbar * tparm->iwt[i];
332337
}
333338
if (wtr_get_mu) {
334339
for (int i = 0; i < NUM_SPECIES; ++i) {
@@ -380,7 +385,7 @@ struct SimpleTransport
380385
wtr_get_mu, wtr_get_lam, Tloc, Xloc, rholoc, wbar, mu, lam, tparm);
381386

382387
if (wtr_get_Ddiag) {
383-
BinaryDiff<EosType>()(Xloc, Yloc, logT, rholoc, Tloc, Ddiag, tparm);
388+
BinaryDiff<EosType>()(Xloc, Yloc_mod, logT, rholoc, Tloc, Ddiag, tparm);
384389
}
385390

386391
if (wtr_get_chi) {

Submodules/amrex

Submodule amrex updated 68 files

0 commit comments

Comments
 (0)