diff --git a/opm/parser/eclipse/EclipseState/Schedule/Network/Balance.hpp b/opm/parser/eclipse/EclipseState/Schedule/Network/Balance.hpp index 0672e91ba..fb3120855 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/Network/Balance.hpp +++ b/opm/parser/eclipse/EclipseState/Schedule/Network/Balance.hpp @@ -27,6 +27,8 @@ namespace Opm { class DeckKeyword; struct Tuning; +class UnitSystem; + namespace Network { class Balance { diff --git a/opm/parser/eclipse/Units/UnitSystem.hpp b/opm/parser/eclipse/Units/UnitSystem.hpp index abf3023e8..1f8fb83cd 100644 --- a/opm/parser/eclipse/Units/UnitSystem.hpp +++ b/opm/parser/eclipse/Units/UnitSystem.hpp @@ -110,6 +110,8 @@ namespace Opm { Dimension parse(const std::string& dimension) const; + double from_si( const std::string& dimension, double ); + double to_si( const std::string& dimension, double ); double from_si( measure, double ) const; double to_si( measure, double ) const; void from_si( measure, std::vector& ) const; diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/Network/Balance.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/Network/Balance.cpp index 0aca511d3..1ee9419d9 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/Network/Balance.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/Network/Balance.cpp @@ -22,6 +22,7 @@ #include #include #include +#include namespace Opm { namespace Network { @@ -64,11 +65,15 @@ Balance::Balance(const Tuning& tuning, const DeckKeyword& keyword) { Balance::Balance(bool network_active, const Tuning& tuning) : calc_mode(CalcMode::TimeStepStart) , calc_interval(0) - , m_thp_tolerance( NB::THP_CONVERGENCE_LIMIT::defaultValue ) + , m_thp_tolerance(NB::THP_CONVERGENCE_LIMIT::defaultValue) , m_thp_max_iter( NB::MAX_ITER_THP::defaultValue ) { + NB parser_keyword{}; + UnitSystem default_units(UnitSystem::UnitType::UNIT_TYPE_METRIC); + if (network_active) { - this->ptol = NB::PRESSURE_CONVERGENCE_LIMIT::defaultValue; + const auto& item = parser_keyword.getRecord(0).get(NB::PRESSURE_CONVERGENCE_LIMIT::itemName); + this->ptol = default_units.to_si( item.dimensions()[0], item.getDefault()); this->m_pressure_max_iter = NB::MAX_ITER::defaultValue; this->m_min_tstep = tuning.TSMINZ; } else { diff --git a/src/opm/parser/eclipse/Units/UnitSystem.cpp b/src/opm/parser/eclipse/Units/UnitSystem.cpp index 0f3810986..f9546dc55 100644 --- a/src/opm/parser/eclipse/Units/UnitSystem.cpp +++ b/src/opm/parser/eclipse/Units/UnitSystem.cpp @@ -1437,6 +1437,16 @@ namespace { + this->measure_table_to_si_offset[ static_cast< int >( m ) ]; } + double UnitSystem::from_si( const std::string& dimension, double value) { + const auto& dim = this->parse(dimension); + return dim.convertSiToRaw(value); + } + + double UnitSystem::to_si( const std::string& dimension, double value) { + const auto& dim = this->parse(dimension); + return dim.convertRawToSi(value); + } + void UnitSystem::from_si( measure m, std::vector& data ) const { double factor = this->measure_table_from_si[ static_cast< int >( m ) ]; double offset = this->measure_table_to_si_offset[ static_cast< int >( m ) ];