108 void update(
const ElementContext& elemCtx,
unsigned dofIdx,
unsigned timeIdx)
110 ParentType::update(elemCtx, dofIdx,
timeIdx);
111 EnergyIntensiveQuantities::updateTemperatures_(fluidState_, elemCtx, dofIdx,
timeIdx);
113 const auto& priVars = elemCtx.primaryVars(dofIdx,
timeIdx);
114 const auto& problem = elemCtx.problem();
116 const Scalar
flashTolerance = Parameters::Get<Parameters::FlashTolerance<Scalar>>();
117 const int flashVerbosity = Parameters::Get<Parameters::FlashVerbosity>();
118 const std::string
flashTwoPhaseMethod = Parameters::Get<Parameters::FlashTwoPhaseMethod>();
123 ComponentVector
z(0.);
125 Evaluation
lastZ = 1.0;
130 z[numComponents - 1] =
lastZ;
132 Evaluation
sumz = 0.0;
144 Evaluation
p = priVars.makeEvaluation(pressure0Idx,
timeIdx);
149 const auto *
hint = elemCtx.thermodynamicHint(dofIdx,
timeIdx);
155 const Evaluation&
Ltmp =
hint->fluidState().L();
156 fluidState_.setLvalue(
Ltmp);
158 else if (
timeIdx == 0 && elemCtx.thermodynamicHint(dofIdx, 1)) {
160 const auto&
hint2 = elemCtx.thermodynamicHint(dofIdx, 1);
165 const Evaluation&
Ltmp =
hint2->fluidState().L();
166 fluidState_.setLvalue(
Ltmp);
170 const Evaluation
Ktmp = fluidState_.wilsonK_(
compIdx);
173 const Evaluation&
Ltmp = -1.0;
174 fluidState_.setLvalue(
Ltmp);
182 std::cout <<
" updating the intensive quantities for Cell " <<
spatialIdx << std::endl;
184 const auto&
eos_type = problem.getEosType();
190 std::cout <<
" \n After flash solve for cell " <<
spatialIdx << std::endl;
191 ComponentVector x,
y;
197 std::cout <<
" x for component: " <<
comp_idx <<
" is:" << std::endl;
198 std::cout << x[
comp_idx] << std::endl;
200 std::cout <<
" y for component: " <<
comp_idx <<
"is:" << std::endl;
203 const Evaluation&
L = fluidState_.L();
204 std::cout <<
" L is:" << std::endl;
205 std::cout <<
L << std::endl;
211 paramCache.updatePhase(fluidState_, FluidSystem::oilPhaseIdx);
213 const Scalar
R = Opm::Constants<Scalar>::R;
214 Evaluation
Z_L = (
paramCache.molarVolume(FluidSystem::oilPhaseIdx) * fluidState_.pressure(FluidSystem::oilPhaseIdx) )/
215 (
R * fluidState_.temperature(FluidSystem::oilPhaseIdx));
216 paramCache.updatePhase(fluidState_, FluidSystem::gasPhaseIdx);
217 Evaluation
Z_V = (
paramCache.molarVolume(FluidSystem::gasPhaseIdx) * fluidState_.pressure(FluidSystem::gasPhaseIdx) )/
218 (
R * fluidState_.temperature(FluidSystem::gasPhaseIdx));
223 if constexpr (waterEnabled) {
224 Sw = priVars.makeEvaluation(water0Idx,
timeIdx);
226 Evaluation
L = fluidState_.L();
227 Evaluation So = Opm::max((1 - Sw) * (
L *
Z_L / (
L *
Z_L + (1 -
L) *
Z_V)), 0.0);
228 Evaluation Sg = Opm::max(1 - So - Sw, 0.0);
233 fluidState_.setSaturation(FluidSystem::oilPhaseIdx, So);
234 fluidState_.setSaturation(FluidSystem::gasPhaseIdx, Sg);
235 if constexpr (waterEnabled) {
237 fluidState_.setSaturation(FluidSystem::waterPhaseIdx, Sw);
240 fluidState_.setCompressFactor(FluidSystem::oilPhaseIdx,
Z_L);
241 fluidState_.setCompressFactor(FluidSystem::gasPhaseIdx,
Z_V);
245 std::cout <<
"So = " << So << std::endl;
246 std::cout <<
"Sg = " << Sg << std::endl;
247 std::cout <<
"Z_L = " <<
Z_L << std::endl;
248 std::cout <<
"Z_V = " <<
Z_V << std::endl;
257 MaterialLaw::relativePermeabilities(relativePermeability_,
259 Opm::Valgrind::CheckDefined(relativePermeability_);
263 if (
phaseIdx ==
static_cast<unsigned int>(FluidSystem::oilPhaseIdx)
264 ||
phaseIdx ==
static_cast<unsigned int>(FluidSystem::gasPhaseIdx)) {
273 Opm::Valgrind::CheckDefined(mobility_[
phaseIdx]);
276 fluidState_.setDensity(
phaseIdx, rho);
284 porosity_ = problem.porosity(elemCtx, dofIdx,
timeIdx);
285 Opm::Valgrind::CheckDefined(porosity_);
288 intrinsicPerm_ = problem.intrinsicPermeability(elemCtx, dofIdx,
timeIdx);
291 FluxIntensiveQuantities::update_(elemCtx, dofIdx,
timeIdx);
294 EnergyIntensiveQuantities::update_(fluidState_,
paramCache, elemCtx, dofIdx,
timeIdx);
297 DiffusionIntensiveQuantities::update_(fluidState_,
paramCache, elemCtx, dofIdx,
timeIdx);