mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
fix the running when solution does not change between time steps
The PID time step control will not pose any constraint on the time step size by returning a largest possible time step size.
This commit is contained in:
@@ -27,11 +27,15 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
#include <opm/common/ErrorMacros.hpp>
|
#include <opm/common/ErrorMacros.hpp>
|
||||||
|
#include <opm/common/OpmLog/OpmLog.hpp>
|
||||||
#include <opm/input/eclipse/Units/Units.hpp>
|
#include <opm/input/eclipse/Units/Units.hpp>
|
||||||
#include <opm/simulators/timestepping/TimeStepControl.hpp>
|
#include <opm/simulators/timestepping/TimeStepControl.hpp>
|
||||||
|
|
||||||
|
#include <fmt/format.h>
|
||||||
|
|
||||||
namespace Opm
|
namespace Opm
|
||||||
{
|
{
|
||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
@@ -141,17 +145,22 @@ namespace Opm
|
|||||||
errors_[ 2 ] = error;
|
errors_[ 2 ] = error;
|
||||||
for( int i=0; i<2; ++i ) {
|
for( int i=0; i<2; ++i ) {
|
||||||
assert(std::isfinite(errors_[i]));
|
assert(std::isfinite(errors_[i]));
|
||||||
assert(errors_[i]>0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( error > tol_ )
|
if( errors_[2] > tol_ )
|
||||||
{
|
{
|
||||||
// adjust dt by given tolerance
|
// adjust dt by given tolerance
|
||||||
const double newDt = dt * tol_ / error;
|
const double newDt = dt * tol_ / error;
|
||||||
if( verbose_ )
|
if ( verbose_ )
|
||||||
std::cout << "Computed step size (tol): " << unit::convert::to( newDt, unit::day ) << " (days)" << std::endl;
|
OpmLog::info(fmt::format("Computed step size (tol): {} days", unit::convert::to( newDt, unit::day )));
|
||||||
return newDt;
|
return newDt;
|
||||||
}
|
}
|
||||||
|
else if (errors_[1] == 0 || errors_[2] == 0.)
|
||||||
|
{
|
||||||
|
if ( verbose_ )
|
||||||
|
OpmLog::info("The solution between time steps does not change, there is no time step constraint from the PID time step control ");
|
||||||
|
return std::numeric_limits<double>::max();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// values taking from turek time stepping paper
|
// values taking from turek time stepping paper
|
||||||
@@ -162,7 +171,7 @@ namespace Opm
|
|||||||
std::pow( tol_ / errors_[ 2 ], kI ) *
|
std::pow( tol_ / errors_[ 2 ], kI ) *
|
||||||
std::pow( errors_[0]*errors_[0]/errors_[ 1 ]/errors_[ 2 ], kD ));
|
std::pow( errors_[0]*errors_[0]/errors_[ 1 ]/errors_[ 2 ], kD ));
|
||||||
if( verbose_ )
|
if( verbose_ )
|
||||||
std::cout << "Computed step size (pow): " << unit::convert::to( newDt, unit::day ) << " (days)" << std::endl;
|
OpmLog::info(fmt::format("Computed step size (pow): {} days", unit::convert::to( newDt, unit::day )));
|
||||||
return newDt;
|
return newDt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user