From 8541048f83f618df31181f4e5f48cf2af29b9bb3 Mon Sep 17 00:00:00 2001 From: Kai Bao Date: Thu, 24 Oct 2024 10:45:00 +0200 Subject: [PATCH] fixing the running of co2_ptflash_ecfv --- examples/problems/co2ptflashproblem.hh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/examples/problems/co2ptflashproblem.hh b/examples/problems/co2ptflashproblem.hh index 318b772b2..15059b2b9 100644 --- a/examples/problems/co2ptflashproblem.hh +++ b/examples/problems/co2ptflashproblem.hh @@ -498,6 +498,24 @@ private: fs.setViscosity(FluidSystem::gasPhaseIdx, FluidSystem::viscosity(fs, paramCache, FluidSystem::gasPhaseIdx)); } + // determine the component total fractions + // TODO: duplicated code here, while should be refactored out when we swithing + // to starting from total mole fractions + Dune::FieldVector z(0.0); + Scalar sumMoles = 0.0; + for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) { + for (unsigned compIdx = 0; compIdx < numComponents; ++compIdx) { + Scalar tmp = Opm::getValue(fs.molarity(phaseIdx, compIdx) * fs.saturation(phaseIdx)); + z[compIdx] += Opm::max(tmp, 1e-8); + sumMoles += tmp; + } + } + z /= sumMoles; + + for (unsigned compIdx = 0; compIdx < numComponents - 1; ++compIdx) { + fs.setMoleFraction(compIdx, z[compIdx]); + } + // Set initial K and L for (unsigned compIdx = 0; compIdx < numComponents; ++compIdx) { const Evaluation Ktmp = fs.wilsonK_(compIdx);