use unit::convert::to instead of hard coded 86400 factor.
This commit is contained in:
parent
355e68c63b
commit
b250383ae0
@ -24,6 +24,7 @@
|
||||
#include <algorithm>
|
||||
#include <numeric>
|
||||
|
||||
#include <opm/core/utility/Units.hpp>
|
||||
#include <opm/core/simulator/AdaptiveSimulatorTimer.hpp>
|
||||
|
||||
namespace Opm
|
||||
@ -131,15 +132,27 @@ namespace Opm
|
||||
}
|
||||
|
||||
/// \brief report start and end time as well as used steps so far
|
||||
void AdaptiveSimulatorTimer::report(std::ostream& os) const
|
||||
void AdaptiveSimulatorTimer::
|
||||
report(std::ostream& os) const
|
||||
{
|
||||
const double factor = 86400.0;
|
||||
os << "Sub steps started at time = " << start_time_/factor << " (days)" << std::endl;
|
||||
os << "Sub steps started at time = " << unit::convert::to( start_time_, unit::day ) << " (days)" << std::endl;
|
||||
for( size_t i=0; i<steps_.size(); ++i )
|
||||
{
|
||||
os << " step[ " << i << " ] = " << steps_[ i ]/factor << " (days)" << std::endl;
|
||||
os << " step[ " << i << " ] = " << unit::convert::to( steps_[ i ], unit::day ) << " (days)" << std::endl;
|
||||
}
|
||||
std::cout << "sub steps end time = " << simulationTimeElapsed()/factor << " (days)" << std::endl;
|
||||
std::cout << "sub steps end time = " << unit::convert::to( simulationTimeElapsed(), unit::day ) << " (days)" << std::endl;
|
||||
}
|
||||
|
||||
double AdaptiveSimulatorTimer::
|
||||
computeInitialTimeStep( const double lastDt ) const
|
||||
{
|
||||
const double maxTimeStep = total_time_ - start_time_;
|
||||
const double fraction = (lastDt / maxTimeStep);
|
||||
// when lastDt and maxTimeStep are close together, choose the max time step
|
||||
if( fraction > 0.95 ) return maxTimeStep;
|
||||
|
||||
// otherwise choose lastDt
|
||||
return std::min( lastDt, maxTimeStep );
|
||||
}
|
||||
|
||||
} // namespace Opm
|
||||
|
@ -94,16 +94,7 @@ namespace Opm
|
||||
double suggestedMax_;
|
||||
double suggestedAverage_;
|
||||
|
||||
double computeInitialTimeStep( const double lastDt ) const
|
||||
{
|
||||
const double maxTimeStep = total_time_ - start_time_;
|
||||
const double fraction = (lastDt / maxTimeStep);
|
||||
// when lastDt and maxTimeStep are close together, choose the max time step
|
||||
if( fraction > 0.95 ) return maxTimeStep;
|
||||
|
||||
// otherwise choose lastDt
|
||||
return std::min( lastDt, maxTimeStep );
|
||||
}
|
||||
double computeInitialTimeStep( const double lastDt ) const;
|
||||
};
|
||||
|
||||
} // namespace Opm
|
||||
|
@ -83,7 +83,7 @@ namespace Opm {
|
||||
const double dtEstimate =
|
||||
timeStepControl_->computeTimeStepSize( timer.currentStepLength(), linearIterations, state );
|
||||
if( timestep_verbose_ )
|
||||
std::cout << "Suggested time step size = " << dtEstimate/86400.0 << " (days)" << std::endl;
|
||||
std::cout << "Suggested time step size = " << unit::convert::to(dtEstimate, unit::day) << " (days)" << std::endl;
|
||||
|
||||
// set new time step length
|
||||
timer.provideTimeStepEstimate( dtEstimate );
|
||||
@ -119,7 +119,7 @@ namespace Opm {
|
||||
if( timestep_verbose_ )
|
||||
{
|
||||
timer.report( std::cout );
|
||||
std::cout << "Last suggested step size = " << last_timestep_/86400.0 << " (days)" << std::endl;
|
||||
std::cout << "Last suggested step size = " << unit::convert::to( last_timestep_, unit::day ) << " (days)" << std::endl;
|
||||
}
|
||||
|
||||
if( ! std::isfinite( last_timestep_ ) ) // check for NaN
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
|
||||
#include <opm/core/utility/Units.hpp>
|
||||
#include <opm/core/simulator/PIDTimeStepControl.hpp>
|
||||
|
||||
namespace Opm
|
||||
@ -74,9 +75,10 @@ namespace Opm
|
||||
if( error > tol_ )
|
||||
{
|
||||
// adjust dt by given tolerance
|
||||
const double newDt = dt * tol_ / error;
|
||||
if( verbose_ )
|
||||
std::cout << "Computed step size (tol): " << (dt * tol_ / error )/86400.0 << " (days)" << std::endl;
|
||||
return (dt * tol_ / error );
|
||||
std::cout << "Computed step size (tol): " << unit::convert::to( newDt, unit::day ) << " (days)" << std::endl;
|
||||
return newDt;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -84,11 +86,11 @@ namespace Opm
|
||||
const double kP = 0.075 ;
|
||||
const double kI = 0.175 ;
|
||||
const double kD = 0.01 ;
|
||||
double newDt = (dt * std::pow( errors_[ 1 ] / errors_[ 2 ], kP ) *
|
||||
const double newDt = (dt * std::pow( errors_[ 1 ] / errors_[ 2 ], kP ) *
|
||||
std::pow( tol_ / errors_[ 2 ], kI ) *
|
||||
std::pow( errors_[0]*errors_[0]/errors_[ 1 ]/errors_[ 2 ], kD ));
|
||||
if( verbose_ )
|
||||
std::cout << "Computed step size (pow): " << newDt/86400.0 << " (days)" << std::endl;
|
||||
std::cout << "Computed step size (pow): " << unit::convert::to( newDt, unit::day ) << " (days)" << std::endl;
|
||||
return newDt;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user