From 18a8b5bb906d8986ae17620e71a85b54f6bed8d7 Mon Sep 17 00:00:00 2001 From: Vegard Kippe Date: Mon, 16 Sep 2024 14:38:28 +0200 Subject: [PATCH] Add energy balance tolerances + use standard tolerances as defaults for now --- opm/simulators/flow/BlackoilModel.hpp | 5 ++++- opm/simulators/flow/BlackoilModelParameters.cpp | 7 +++++++ opm/simulators/flow/BlackoilModelParameters.hpp | 14 ++++++++++++-- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/opm/simulators/flow/BlackoilModel.hpp b/opm/simulators/flow/BlackoilModel.hpp index 2ccf4a093..22509ff91 100644 --- a/opm/simulators/flow/BlackoilModel.hpp +++ b/opm/simulators/flow/BlackoilModel.hpp @@ -1010,6 +1010,7 @@ namespace Opm { const auto tol_cnv = use_relaxed_cnv ? param_.tolerance_cnv_relaxed_ : param_.tolerance_cnv_; const auto tol_mb = use_relaxed_mb ? param_.tolerance_mb_relaxed_ : param_.tolerance_mb_; const auto tol_cnv_energy = use_relaxed_cnv ? param_.tolerance_cnv_energy_relaxed_ : param_.tolerance_cnv_energy_; + const auto tol_eb = use_relaxed_mb ? param_.tolerance_energy_balance_relaxed_ : param_.tolerance_energy_balance_; // Finish computation std::vector CNV(numComp); @@ -1033,8 +1034,10 @@ namespace Opm { }; Scalar tol[2] = { tol_mb, tol_cnv, }; - if (has_energy_ && compIdx == contiEnergyEqIdx) + if (has_energy_ && compIdx == contiEnergyEqIdx) { + tol[0] = tol_eb; tol[1] = tol_cnv_energy; + } for (int ii : {0, 1}) { if (std::isnan(res[ii])) { diff --git a/opm/simulators/flow/BlackoilModelParameters.cpp b/opm/simulators/flow/BlackoilModelParameters.cpp index b2abb3890..f4be5d768 100644 --- a/opm/simulators/flow/BlackoilModelParameters.cpp +++ b/opm/simulators/flow/BlackoilModelParameters.cpp @@ -38,6 +38,8 @@ BlackoilModelParameters::BlackoilModelParameters() relaxed_max_pv_fraction_ = Parameters::Get>(); tolerance_mb_ = Parameters::Get>(); tolerance_mb_relaxed_ = std::max(tolerance_mb_, Parameters::Get>()); + tolerance_energy_balance_ = Parameters::Get>(); + tolerance_energy_balance_relaxed_ = std::max(tolerance_energy_balance_, Parameters::Get>()); tolerance_cnv_ = Parameters::Get>(); tolerance_cnv_relaxed_ = std::max(tolerance_cnv_, Parameters::Get>()); tolerance_cnv_energy_ = Parameters::Get>(); @@ -112,6 +114,11 @@ void BlackoilModelParameters::registerParameters() Parameters::Register> ("Relaxed tolerated mass balance error that applies for iterations " "after the iterations with the strict tolerance"); + Parameters::Register> + ("Tolerated energy balance error relative to (scaled) total energy present"); + Parameters::Register> + ("Relaxed tolerated energy balance error that applies for iterations " + "after the iterations with the strict tolerance"); Parameters::Register> ("Local convergence tolerance (Maximum of local saturation errors)"); Parameters::Register> diff --git a/opm/simulators/flow/BlackoilModelParameters.hpp b/opm/simulators/flow/BlackoilModelParameters.hpp index ff61fd9af..377e2699b 100644 --- a/opm/simulators/flow/BlackoilModelParameters.hpp +++ b/opm/simulators/flow/BlackoilModelParameters.hpp @@ -46,6 +46,12 @@ struct ToleranceMb { static constexpr Scalar value = 1e-7; }; template struct ToleranceMbRelaxed { static constexpr Scalar value = 1e-6; }; +template +struct ToleranceEnergyBalance { static constexpr Scalar value = 1e-7; }; + +template +struct ToleranceEnergyBalanceRelaxed { static constexpr Scalar value = 1e-6; }; + template struct ToleranceCnv { static constexpr Scalar value = 1e-2; }; @@ -53,10 +59,10 @@ template struct ToleranceCnvRelaxed { static constexpr Scalar value = 1.0; }; template -struct ToleranceCnvEnergy { static constexpr Scalar value = 1e-4; }; +struct ToleranceCnvEnergy { static constexpr Scalar value = 1e-2; }; template -struct ToleranceCnvEnergyRelaxed { static constexpr Scalar value = 2.0e-4; }; +struct ToleranceCnvEnergyRelaxed { static constexpr Scalar value = 1.0; }; template struct ToleranceWells { static constexpr Scalar value = 1e-4; }; @@ -153,6 +159,10 @@ public: Scalar tolerance_mb_; /// Relaxed mass balance tolerance (can be used when iter >= min_strict_mb_iter_). Scalar tolerance_mb_relaxed_; + /// Relative energy balance tolerance (total energy balance error). + Scalar tolerance_energy_balance_; + /// Relaxed energy balance tolerance (can be used when iter >= min_strict_mb_iter_). + Scalar tolerance_energy_balance_relaxed_; /// Local convergence tolerance (max of local saturation errors). Scalar tolerance_cnv_; /// Relaxed local convergence tolerance (can be used when iter >= min_strict_cnv_iter_ && cnvViolatedPV < relaxed_max_pv_fraction_).