adding POLYMW to phase class in Runspec

This commit is contained in:
Kai Bao
2018-03-08 22:15:47 +01:00
parent c8bc4d9649
commit bb4936c6c1
4 changed files with 41 additions and 5 deletions

View File

@@ -36,6 +36,7 @@ enum class Phase {
SOLVENT = 3,
POLYMER = 4,
ENERGY = 5,
POLYMW = 6
};
Phase get_phase( const std::string& );
@@ -44,12 +45,13 @@ std::ostream& operator<<( std::ostream&, const Phase& );
class Phases {
public:
Phases() noexcept = default;
Phases( bool oil, bool gas, bool wat, bool solvent = false, bool polymer = false, bool energy = false ) noexcept;
Phases( bool oil, bool gas, bool wat, bool solvent = false, bool polymer = false, bool energy = false,
bool polymw = false ) noexcept;
bool active( Phase ) const noexcept;
size_t size() const noexcept;
private:
std::bitset< 6 > bits;
std::bitset< 7 > bits;
};

View File

@@ -34,6 +34,7 @@ Phase get_phase( const std::string& str ) {
if( str == "SOLVENT" ) return Phase::SOLVENT;
if( str == "POLYMER" ) return Phase::POLYMER;
if( str == "ENERGY" ) return Phase::ENERGY;
if( str == "POLYMW" ) return Phase::POLYMW;
throw std::invalid_argument( "Unknown phase '" + str + "'" );
}
@@ -46,6 +47,7 @@ std::ostream& operator<<( std::ostream& stream, const Phase& p ) {
case Phase::SOLVENT: return stream << "SOLVENT";
case Phase::POLYMER: return stream << "POLYMER";
case Phase::ENERGY: return stream << "ENERGY";
case Phase::POLYMW: return stream << "POLYMW";
}
@@ -54,13 +56,14 @@ std::ostream& operator<<( std::ostream& stream, const Phase& p ) {
using un = std::underlying_type< Phase >::type;
Phases::Phases( bool oil, bool gas, bool wat, bool sol, bool pol, bool energy ) noexcept :
Phases::Phases( bool oil, bool gas, bool wat, bool sol, bool pol, bool energy, bool polymw ) noexcept :
bits( (oil ? (1 << static_cast< un >( Phase::OIL ) ) : 0) |
(gas ? (1 << static_cast< un >( Phase::GAS ) ) : 0) |
(wat ? (1 << static_cast< un >( Phase::WATER ) ) : 0) |
(sol ? (1 << static_cast< un >( Phase::SOLVENT ) ) : 0) |
(pol ? (1 << static_cast< un >( Phase::POLYMER ) ) : 0) |
(energy ? (1 << static_cast< un >( Phase::ENERGY ) ) : 0) )
(energy ? (1 << static_cast< un >( Phase::ENERGY ) ) : 0) |
(polymw ? (1 << static_cast< un >( Phase::POLYMW ) ) : 0) )
{}
@@ -95,7 +98,8 @@ Runspec::Runspec( const Deck& deck ) :
deck.hasKeyword( "WATER" ),
deck.hasKeyword( "SOLVENT" ),
deck.hasKeyword( "POLYMER" ),
deck.hasKeyword( "THERMAL" ) ) ),
deck.hasKeyword( "THERMAL" ),
deck.hasKeyword( "POLYMW" ) ) ),
m_tabdims( deck ),
endscale( deck ),
welldims( deck )

View File

@@ -118,6 +118,8 @@ namespace Opm {
throw std::invalid_argument( "Production of 'POLYMER' requested." );
case Phase::ENERGY:
throw std::invalid_argument( "Production of 'ENERGY' requested." );
case Phase::POLYMW:
throw std::invalid_argument( "Production of 'POLYMW' requested.");
}
throw std::logic_error( "Unreachable state. Invalid Phase value. "

View File

@@ -39,6 +39,7 @@ BOOST_AUTO_TEST_CASE(PhaseFromString) {
BOOST_CHECK_EQUAL( Phase::WATER, get_phase("WATER") );
BOOST_CHECK_EQUAL( Phase::WATER, get_phase("WAT") );
BOOST_CHECK_EQUAL( Phase::GAS , get_phase("GAS") );
BOOST_CHECK_EQUAL( Phase::POLYMW , get_phase("POLYMW") );
}
BOOST_AUTO_TEST_CASE(TwoPhase) {
@@ -59,6 +60,7 @@ BOOST_AUTO_TEST_CASE(TwoPhase) {
BOOST_CHECK( phases.active( Phase::OIL ) );
BOOST_CHECK( !phases.active( Phase::GAS ) );
BOOST_CHECK( phases.active( Phase::WATER ) );
BOOST_CHECK( !phases.active( Phase::POLYMW ) );
BOOST_CHECK_EQUAL( ECL_OIL_PHASE + ECL_WATER_PHASE , runspec.eclPhaseMask( ));
}
@@ -403,6 +405,7 @@ BOOST_AUTO_TEST_CASE(Solvent) {
BOOST_CHECK( phases.active( Phase::GAS ) );
BOOST_CHECK( phases.active( Phase::WATER ) );
BOOST_CHECK( phases.active( Phase::SOLVENT ) );
BOOST_CHECK( !phases.active( Phase::POLYMW) );
}
@@ -428,6 +431,31 @@ BOOST_AUTO_TEST_CASE(Polymer) {
BOOST_CHECK( phases.active( Phase::GAS ) );
BOOST_CHECK( phases.active( Phase::WATER ) );
BOOST_CHECK( phases.active( Phase::POLYMER ) );
BOOST_CHECK( !phases.active( Phase::POLYMW) );
}
BOOST_AUTO_TEST_CASE(PolymerMolecularWeight) {
const std::string input = R"(
RUNSPEC
OIL
WATER
POLYMER
POLYMW
)";
Parser parser;
ParseContext parseContext;
auto deck = parser.parseString(input, parseContext);
Runspec runspec( deck );
const auto& phases = runspec.phases();
BOOST_CHECK_EQUAL( 4, phases.size() );
BOOST_CHECK( phases.active( Phase::OIL ) );
BOOST_CHECK( !phases.active( Phase::GAS ) );
BOOST_CHECK( phases.active( Phase::WATER ) );
BOOST_CHECK( phases.active( Phase::POLYMER ) );
BOOST_CHECK( phases.active( Phase::POLYMW) );
}