From 1e897d9d99858747768615cd8398e805a860d359 Mon Sep 17 00:00:00 2001 From: Bernd Flemisch <bernd@iws.uni-stuttgart.de> Date: Fri, 7 Mar 2014 14:04:00 +0000 Subject: [PATCH] [NCP Flash] set at least one mole fraction to a positive value to prevent breakdown of the linear solver in completeFluidState_. Reviewed by Philipp. git-svn-id: svn://svn.iws.uni-stuttgart.de/DUMUX/dumux/trunk@12586 2fb0f335-1f38-0410-981e-8018bf24f1b0 --- dumux/material/constraintsolvers/ncpflash.hh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/dumux/material/constraintsolvers/ncpflash.hh b/dumux/material/constraintsolvers/ncpflash.hh index 2b0bf2e50e..15358ab120 100644 --- a/dumux/material/constraintsolvers/ncpflash.hh +++ b/dumux/material/constraintsolvers/ncpflash.hh @@ -443,11 +443,19 @@ protected: if (value < 0) fluidState.setPressure(phaseIdx, 0.0); + bool allMoleFractionsAreZero = true; for (int compIdx = 0; compIdx < numComponents; ++compIdx) { value = fluidState.moleFraction(phaseIdx, compIdx); - if (value < 0) + if (value > 0) + allMoleFractionsAreZero = false; + else if (value < 0) fluidState.setMoleFraction(phaseIdx, compIdx, 0.0); } + + // set at least one mole fraction to a positive value + // to prevent breakdown of the linear solver in completeFluidState_ + if (allMoleFractionsAreZero) + fluidState.setMoleFraction(phaseIdx, /*compIdx=*/0, 1e-10); } // last saturation -- GitLab