112 void update(
const ElementContext& elemCtx,
unsigned dofIdx,
unsigned timeIdx)
114 ParentType::update(elemCtx, dofIdx,
timeIdx);
115 EnergyIntensiveQuantities::updateTemperatures_(fluidState_, elemCtx, dofIdx,
timeIdx);
117 const auto& priVars = elemCtx.primaryVars(dofIdx,
timeIdx);
118 const auto& problem = elemCtx.problem();
120 const Scalar
flashTolerance = Parameters::Get<Parameters::FlashTolerance<Scalar>>();
121 const int flashVerbosity = Parameters::Get<Parameters::FlashVerbosity>();
122 const std::string
flashTwoPhaseMethod = Parameters::Get<Parameters::FlashTwoPhaseMethod>();
127 ComponentVector
z(0.);
129 Evaluation
lastZ = 1.0;
134 z[numComponents - 1] =
lastZ;
136 Evaluation
sumz = 0.0;
148 Evaluation
p = priVars.makeEvaluation(pressure0Idx,
timeIdx);
154 const auto*
hint = elemCtx.thermodynamicHint(dofIdx,
timeIdx);
160 const Evaluation&
Ltmp =
hint->fluidState().L();
161 fluidState_.setLvalue(
Ltmp);
163 else if (
timeIdx == 0 && elemCtx.thermodynamicHint(dofIdx, 1)) {
165 const auto&
hint2 = elemCtx.thermodynamicHint(dofIdx, 1);
170 const Evaluation&
Ltmp =
hint2->fluidState().L();
171 fluidState_.setLvalue(
Ltmp);
175 const Evaluation
Ktmp = fluidState_.wilsonK_(
compIdx);
178 const Evaluation&
Ltmp = -1.0;
179 fluidState_.setLvalue(
Ltmp);
187 std::cout <<
" updating the intensive quantities for Cell " <<
spatialIdx << std::endl;
189 const auto&
eos_type = problem.getEosType();
195 std::cout <<
" \n After flash solve for cell " <<
spatialIdx << std::endl;
196 ComponentVector x,
y;
202 std::cout <<
" x for component: " <<
comp_idx <<
" is:" << std::endl;
203 std::cout << x[
comp_idx] << std::endl;
205 std::cout <<
" y for component: " <<
comp_idx <<
"is:" << std::endl;
208 const Evaluation&
L = fluidState_.L();
209 std::cout <<
" L is:" << std::endl;
210 std::cout <<
L << std::endl;
215 paramCache.updatePhase(fluidState_, FluidSystem::oilPhaseIdx);
217 const Scalar
R = Opm::Constants<Scalar>::R;
218 const Evaluation
Z_L = (
paramCache.molarVolume(FluidSystem::oilPhaseIdx) *
219 fluidState_.pressure(FluidSystem::oilPhaseIdx)) /
220 (
R * fluidState_.temperature(FluidSystem::oilPhaseIdx));
221 paramCache.updatePhase(fluidState_, FluidSystem::gasPhaseIdx);
222 const Evaluation
Z_V = (
paramCache.molarVolume(FluidSystem::gasPhaseIdx) *
223 fluidState_.pressure(FluidSystem::gasPhaseIdx)) /
224 (
R * fluidState_.temperature(FluidSystem::gasPhaseIdx));
228 if constexpr (waterEnabled) {
229 Sw = priVars.makeEvaluation(water0Idx,
timeIdx);
231 const Evaluation
L = fluidState_.L();
232 Evaluation So = max((1 - Sw) * (
L *
Z_L / (
L *
Z_L + (1 -
L) *
Z_V)), 0.0);
233 Evaluation Sg = max(1 - So - Sw, 0.0);
238 fluidState_.setSaturation(FluidSystem::oilPhaseIdx, So);
239 fluidState_.setSaturation(FluidSystem::gasPhaseIdx, Sg);
240 if constexpr (waterEnabled) {
242 fluidState_.setSaturation(FluidSystem::waterPhaseIdx, Sw);
245 fluidState_.setCompressFactor(FluidSystem::oilPhaseIdx,
Z_L);
246 fluidState_.setCompressFactor(FluidSystem::gasPhaseIdx,
Z_V);
250 std::cout <<
"So = " << So << std::endl;
251 std::cout <<
"Sg = " << Sg << std::endl;
252 std::cout <<
"Z_L = " <<
Z_L << std::endl;
253 std::cout <<
"Z_V = " <<
Z_V << std::endl;
262 MaterialLaw::relativePermeabilities(relativePermeability_,
264 Valgrind::CheckDefined(relativePermeability_);
268 if (
phaseIdx ==
static_cast<unsigned int>(FluidSystem::oilPhaseIdx) ||
269 phaseIdx ==
static_cast<unsigned int>(FluidSystem::gasPhaseIdx))
279 Valgrind::CheckDefined(mobility_[
phaseIdx]);
282 fluidState_.setDensity(
phaseIdx, rho);
290 porosity_ = problem.porosity(elemCtx, dofIdx,
timeIdx);
291 Valgrind::CheckDefined(porosity_);
294 intrinsicPerm_ = problem.intrinsicPermeability(elemCtx, dofIdx,
timeIdx);
297 FluxIntensiveQuantities::update_(elemCtx, dofIdx,
timeIdx);
300 EnergyIntensiveQuantities::update_(fluidState_,
paramCache, elemCtx, dofIdx,
timeIdx);
303 DiffusionIntensiveQuantities::update_(fluidState_,
paramCache, elemCtx, dofIdx,
timeIdx);