diff --git a/opm/core/simulator/AdaptiveSimulatorTimer.cpp b/opm/core/simulator/AdaptiveSimulatorTimer.cpp index 93a64a91..576e4fae 100644 --- a/opm/core/simulator/AdaptiveSimulatorTimer.cpp +++ b/opm/core/simulator/AdaptiveSimulatorTimer.cpp @@ -24,6 +24,7 @@ #include #include +#include #include 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 0.95 ) return maxTimeStep; + + // otherwise choose lastDt + return std::min( lastDt, maxTimeStep ); } } // namespace Opm diff --git a/opm/core/simulator/AdaptiveSimulatorTimer.hpp b/opm/core/simulator/AdaptiveSimulatorTimer.hpp index 09b3f570..3336a69c 100644 --- a/opm/core/simulator/AdaptiveSimulatorTimer.hpp +++ b/opm/core/simulator/AdaptiveSimulatorTimer.hpp @@ -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 diff --git a/opm/core/simulator/AdaptiveTimeStepping_impl.hpp b/opm/core/simulator/AdaptiveTimeStepping_impl.hpp index fa45bbc3..96a83d08 100644 --- a/opm/core/simulator/AdaptiveTimeStepping_impl.hpp +++ b/opm/core/simulator/AdaptiveTimeStepping_impl.hpp @@ -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 diff --git a/opm/core/simulator/PIDTimeStepControl.cpp b/opm/core/simulator/PIDTimeStepControl.cpp index 23943145..65664d1b 100644 --- a/opm/core/simulator/PIDTimeStepControl.cpp +++ b/opm/core/simulator/PIDTimeStepControl.cpp @@ -21,6 +21,7 @@ #include #include +#include #include 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 ) * - std::pow( tol_ / errors_[ 2 ], kI ) * - std::pow( errors_[0]*errors_[0]/errors_[ 1 ]/errors_[ 2 ], kD )); + 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; } }