From ce8498c4d7989d19aaf3a9190963aed1715ed974 Mon Sep 17 00:00:00 2001 From: Kai Bao Date: Fri, 11 Nov 2016 13:26:22 +0100 Subject: [PATCH] checking the residual for the well control equations. --- opm/autodiff/BlackoilModelBase_impl.hpp | 10 ++++++++-- opm/autodiff/BlackoilModelParameters.cpp | 2 ++ opm/autodiff/BlackoilModelParameters.hpp | 3 +++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/opm/autodiff/BlackoilModelBase_impl.hpp b/opm/autodiff/BlackoilModelBase_impl.hpp index cfd777df9..99a61f384 100644 --- a/opm/autodiff/BlackoilModelBase_impl.hpp +++ b/opm/autodiff/BlackoilModelBase_impl.hpp @@ -1840,6 +1840,7 @@ namespace detail { const double tol_mb = param_.tolerance_mb_; const double tol_cnv = param_.tolerance_cnv_; const double tol_wells = param_.tolerance_wells_; + const double tol_well_control = param_.tolerance_well_control_; const int nc = Opm::AutoDiffGrid::numCells(grid_); const int np = asImpl().numPhases(); @@ -1893,7 +1894,7 @@ namespace detail { const double residualWell = detail::infinityNormWell(residual_.well_eq, linsolver_.parallelInformation()); - converged_Well = converged_Well && (residualWell < Opm::unit::barsa); + converged_Well = converged_Well && (residualWell < tol_well_control); const bool converged = converged_MB && converged_CNV && converged_Well; // Residual in Pascal can have high values and still be ok. @@ -1913,6 +1914,7 @@ namespace detail { for (int idx = 0; idx < np; ++idx) { msg += " W-FLUX(" + materialName(idx).substr(0, 1) + ")"; } + msg += " WELL-CONT"; // std::cout << " WELL-CONT "; OpmLog::note(msg); } @@ -1929,6 +1931,7 @@ namespace detail { for (int idx = 0; idx < np; ++idx) { ss << std::setw(11) << well_flux_residual[idx]; } + ss << std::setw(11) << residualWell; // std::cout << std::setw(11) << residualWell; ss.precision(oprec); ss.flags(oflags); @@ -1976,6 +1979,7 @@ namespace detail { getWellConvergence(const int iteration) { const double tol_wells = param_.tolerance_wells_; + const double tol_well_control = param_.tolerance_well_control_; const int nc = Opm::AutoDiffGrid::numCells(grid_); const int np = asImpl().numPhases(); @@ -2010,7 +2014,7 @@ namespace detail { const double residualWell = detail::infinityNormWell(residual_.well_eq, linsolver_.parallelInformation()); - converged_Well = converged_Well && (residualWell < Opm::unit::barsa); + converged_Well = converged_Well && (residualWell < tol_well_control); const bool converged = converged_Well; // if one of the residuals is NaN, throw exception, so that the solver can be restarted @@ -2040,6 +2044,7 @@ namespace detail { for (int idx = 0; idx < np; ++idx) { msg += " W-FLUX(" + materialName(idx).substr(0, 1) + ")"; } + msg += " WELL-CONT"; OpmLog::note(msg); } std::ostringstream ss; @@ -2049,6 +2054,7 @@ namespace detail { for (int idx = 0; idx < np; ++idx) { ss << std::setw(11) << well_flux_residual[idx]; } + ss << std::setw(11) << residualWell; ss.precision(oprec); ss.flags(oflags); OpmLog::note(ss.str()); diff --git a/opm/autodiff/BlackoilModelParameters.cpp b/opm/autodiff/BlackoilModelParameters.cpp index 818a6da0e..5227c2a99 100644 --- a/opm/autodiff/BlackoilModelParameters.cpp +++ b/opm/autodiff/BlackoilModelParameters.cpp @@ -46,6 +46,7 @@ namespace Opm tolerance_mb_ = param.getDefault("tolerance_mb", tolerance_mb_); tolerance_cnv_ = param.getDefault("tolerance_cnv", tolerance_cnv_); tolerance_wells_ = param.getDefault("tolerance_wells", tolerance_wells_ ); + tolerance_well_control_ = param.getDefault("tolerance_well_control", tolerance_well_control_); solve_welleq_initially_ = param.getDefault("solve_welleq_initially",solve_welleq_initially_); update_equations_scaling_ = param.getDefault("update_equations_scaling", update_equations_scaling_); compute_well_potentials_ = param.getDefault("compute_well_potentials", compute_well_potentials_); @@ -65,6 +66,7 @@ namespace Opm tolerance_mb_ = 1.0e-5; tolerance_cnv_ = 1.0e-2; tolerance_wells_ = 1.0e-3; + tolerance_well_control_ = 1.0e-7; solve_welleq_initially_ = true; update_equations_scaling_ = false; compute_well_potentials_ = false; diff --git a/opm/autodiff/BlackoilModelParameters.hpp b/opm/autodiff/BlackoilModelParameters.hpp index 7f00ec927..2f880cc16 100644 --- a/opm/autodiff/BlackoilModelParameters.hpp +++ b/opm/autodiff/BlackoilModelParameters.hpp @@ -42,6 +42,9 @@ namespace Opm double tolerance_cnv_; /// Well convergence tolerance. double tolerance_wells_; + /// Tolerance for the well control equations + // TODO: it might need to distinguish between rate control and pressure control later + double tolerance_well_control_; /// Solve well equation initially bool solve_welleq_initially_;