diff --git a/dumux/discretization/box/maxwellstefanslaw.hh b/dumux/discretization/box/maxwellstefanslaw.hh index 46340d701b41a2800d82ad10a0dea05a1871e156..c2cfc168f385fd33e71fa8b664f515ac4d30dd5d 100644 --- a/dumux/discretization/box/maxwellstefanslaw.hh +++ b/dumux/discretization/box/maxwellstefanslaw.hh @@ -180,7 +180,7 @@ private: reducedDiffusionMatrix[compIIdx][compIIdx] += xi/tin; // now set the rest of the entries (off-diagonal and additional entries for diagonal) - for (int compJIdx = 0; compJIdx < numComponents-1; compJIdx++) + for (int compJIdx = 0; compJIdx < numComponents; compJIdx++) { //we don't want to calculate e.g. water in water diffusion if (compIIdx == compJIdx) @@ -201,7 +201,8 @@ private: const auto tij = problem.spatialParams().harmonicMean(tijInside, tijOutside, scvf.unitOuterNormal()); reducedDiffusionMatrix[compIIdx][compIIdx] += xj/tij; - reducedDiffusionMatrix[compIIdx][compJIdx] +=xi*(1/tin - 1/tij); + if (compJIdx < numComponents-1) + reducedDiffusionMatrix[compIIdx][compJIdx] +=xi*(1/tin - 1/tij); } } return reducedDiffusionMatrix; diff --git a/dumux/discretization/cellcentered/tpfa/maxwellstefanslaw.hh b/dumux/discretization/cellcentered/tpfa/maxwellstefanslaw.hh index ad226ea7baeaa86908cab08f1f95fc21ec12179a..dd9bbc918ea3827a0da28b0df069eee803ab485f 100644 --- a/dumux/discretization/cellcentered/tpfa/maxwellstefanslaw.hh +++ b/dumux/discretization/cellcentered/tpfa/maxwellstefanslaw.hh @@ -234,7 +234,8 @@ private: Scalar tij = getDiffusionCoefficient(phaseIdx, compIIdx, compJIdx, problem, element, volVars, scv); tij = EffDiffModel::effectiveDiffusivity(volVars.porosity(), volVars.saturation(phaseIdx), tij); reducedDiffusionMatrix[compIIdx][compIIdx] += xj/tij; - reducedDiffusionMatrix[compIIdx][compJIdx] += xi*(1/tin - 1/tij); + if (compJIdx < numComponents-1) + reducedDiffusionMatrix[compIIdx][compJIdx] += xi*(1/tin - 1/tij); } } return reducedDiffusionMatrix; diff --git a/dumux/discretization/staggered/freeflow/maxwellstefanslaw.hh b/dumux/discretization/staggered/freeflow/maxwellstefanslaw.hh index 89bfb5ec920f04b4de2349710782b8a309b42069..d8ea50c0d95b8846d53d2970e3a26ab02627b862 100644 --- a/dumux/discretization/staggered/freeflow/maxwellstefanslaw.hh +++ b/dumux/discretization/staggered/freeflow/maxwellstefanslaw.hh @@ -231,7 +231,8 @@ private: const auto xj = volVars.moleFraction(compJIdx); const Scalar tij = volVars.effectiveDiffusivity(compIIdx, compJIdx); reducedDiffusionMatrix[compIIdx][compIIdx] += xj/tij; - reducedDiffusionMatrix[compIIdx][compJIdx] += xi*(1/tin - 1/tij); + if (compJIdx < numComponents-1) + reducedDiffusionMatrix[compIIdx][compJIdx] += xi*(1/tin - 1/tij); } } return reducedDiffusionMatrix;