From 6106d560ba046b88b2b9b06f63178c6989a7a101 Mon Sep 17 00:00:00 2001 From: Tor Harald Sandve Date: Mon, 21 Sep 2015 14:04:41 +0200 Subject: [PATCH] Compute matbal_scale for the solvent model The material balance scaling is extended to the solvent model The gas value is used as default and an updateEquationsScaling() method is added. Minor modifications is done to the BlackoilModelBase.hpp and BlackoilModelBase_impl.hpp in order to re-use code from the base case. --- opm/autodiff/BlackoilModelBase_impl.hpp | 2 +- opm/autodiff/BlackoilSolventModel.hpp | 1 + opm/autodiff/BlackoilSolventModel_impl.hpp | 18 +++++++++++++++--- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/opm/autodiff/BlackoilModelBase_impl.hpp b/opm/autodiff/BlackoilModelBase_impl.hpp index 9d63708fe..4fb07ef74 100644 --- a/opm/autodiff/BlackoilModelBase_impl.hpp +++ b/opm/autodiff/BlackoilModelBase_impl.hpp @@ -948,7 +948,7 @@ namespace detail { if (param_.update_equations_scaling_) { - updateEquationsScaling(); + asImpl().updateEquationsScaling(); } } diff --git a/opm/autodiff/BlackoilSolventModel.hpp b/opm/autodiff/BlackoilSolventModel.hpp index deda06f4b..6881c72f6 100644 --- a/opm/autodiff/BlackoilSolventModel.hpp +++ b/opm/autodiff/BlackoilSolventModel.hpp @@ -198,6 +198,7 @@ namespace Opm { void computeWellConnectionPressures(const SolutionState& state, const WellState& xw); + void updateEquationsScaling(); void computeMassFlux(const int actph , diff --git a/opm/autodiff/BlackoilSolventModel_impl.hpp b/opm/autodiff/BlackoilSolventModel_impl.hpp index 970ed43ea..f4d8e5127 100644 --- a/opm/autodiff/BlackoilSolventModel_impl.hpp +++ b/opm/autodiff/BlackoilSolventModel_impl.hpp @@ -98,6 +98,9 @@ namespace Opm { if (has_vapoil_) { OPM_THROW(std::runtime_error, "Solvent option only works with dead gas\n"); } + + residual_.matbalscale.resize(fluid_.numPhases() + 1, 0.0031); // use the same as gas + } } @@ -224,9 +227,18 @@ namespace Opm { } - - - + template + void + BlackoilSolventModel::updateEquationsScaling() + { + Base::updateEquationsScaling(); + assert(MaxNumPhases + 1 == resdual.matbalscale.size()); + if (has_solvent_) { + const ADB& temp_b = rq_[solvent_pos_].b; + ADB::V B = 1. / temp_b.value(); + residual_.matbalscale[solvent_pos_] = B.mean(); + } + } template void BlackoilSolventModel::addWellContributionToMassBalanceEq(const std::vector& cq_s,