Exemplo n.º 1
0
    void GridProperties<T>::handleOPERATERecord( const DeckRecord& record, BoxManager& boxManager) {
        const std::string& srcArray    = record.getItem("ARRAY").get< std::string >(0);
        const std::string& targetArray = record.getItem("TARGET_ARRAY").get< std::string >(0);
        const std::string& operation   = record.getItem("OPERATION").get< std::string >(0);
        double alpha = record.getItem("PARAM1").get< double >(0);
        double beta = record.getItem("PARAM2").get< double >(0);

        if (!supportsKeyword( targetArray))
            throw std::invalid_argument("Fatal error processing OPERATE record - invalid/undefined keyword: " + targetArray);

        {
            auto& result_prop = getKeyword(targetArray);
            if (srcArray == targetArray)
                result_prop.runPostProcessor();
            else {
                if (operation == "MULTIPLY" || operation == "POLY")
                    result_prop.runPostProcessor();
            }

            std::vector<T>& targetData= result_prop.getData();
            const std::vector<T>& srcData = getKeyword( srcArray ).getData();
            operate_fptr func = operations.at( operation );

            setKeywordBox(record, boxManager);
            for (auto index : boxManager.getActiveBox())
                targetData[index] = func( targetData[index] , srcData[index] , alpha, beta );
        }
    }
Exemplo n.º 2
0
    void GridProperties<T>::handleMULTIPLYRecord( const DeckRecord& record, BoxManager& boxManager) {
        const std::string& field = record.getItem("field").get< std::string >(0);
        assertKeyword(field);

        GridProperty<T>& property = getKeyword( field );
        T factor  = convertInputValue( record.getItem("factor").get< double >(0) );
        setKeywordBox(record, boxManager);
        property.scale( factor , boxManager.getActiveBox() );
    }
Exemplo n.º 3
0
    void GridProperties<T>::handleADDRecord( const DeckRecord& record, BoxManager& boxManager) {
        const std::string& field = record.getItem("field").get< std::string >(0);
        assertKeyword(field);

        GridProperty<T>& property = getKeyword( field );
        T shiftValue  = convertInputValue( property , record.getItem("shift").get< double >(0) );
        setKeywordBox(record, boxManager);
        property.add( shiftValue , boxManager.getActiveBox() );
    }
Exemplo n.º 4
0
    void GridProperties<T>::handleMINVALUERecord( const DeckRecord& record, BoxManager& boxManager) {
        const std::string& field = record.getItem("field").get< std::string >(0);

        if (hasKeyword( field )) {
            GridProperty<T>& property = getKeyword( field );
            T value  = convertInputValue( property, record.getItem("value").get< double >(0) );
            setKeywordBox(record, boxManager);
            property.minvalue( value , boxManager.getActiveBox() );
        } else
            throw std::invalid_argument("Fatal error processing MINVALUE keyword. Tried to limit not defined keyword " + field);
    }
Exemplo n.º 5
0
    WellProductionProperties WellProductionProperties::history(double BHPLimit, const DeckRecord& record, const Phases &phases)
    {
        // Modes supported in WCONHIST just from {O,W,G}RAT values
        //
        // Note: The default value of observed {O,W,G}RAT is zero
        // (numerically) whence the following control modes are
        // unconditionally supported.
        WellProductionProperties p(record);
        p.predictionMode = false;

        namespace wp = WellProducer;
        if(phases.active(Phase::OIL))
            p.addProductionControl( wp::ORAT );

        if(phases.active(Phase::WATER))
            p.addProductionControl( wp::WRAT );

        if(phases.active(Phase::GAS))
            p.addProductionControl( wp::GRAT );

        for( auto cmode : { wp::LRAT, wp::RESV, wp::GRUP } ) {
            p.addProductionControl( cmode );
        }

        /*
          We do not update the BHPLIMIT based on the BHP value given
          in WCONHIST, that is purely a historical value; instead we
          copy the old value of the BHP limit from the previous
          timestep.

          To actually set the BHPLIMIT in historical mode you must
          use the WELTARG keyword.
        */
        p.BHPLimit = BHPLimit;

        const auto& cmodeItem = record.getItem("CMODE");
        if (!cmodeItem.defaultApplied(0)) {
            const auto cmode = WellProducer::ControlModeFromString( cmodeItem.getTrimmedString( 0 ) );

            if (p.hasProductionControl( cmode ))
                p.controlMode = cmode;
            else
                throw std::invalid_argument("Setting CMODE to unspecified control");
        }

        if ( record.getItem( "BHP" ).hasValue(0) )
            p.BHPH = record.getItem("BHP").getSIDouble(0);
        if ( record.getItem( "THP" ).hasValue(0) )
            p.THPH = record.getItem("THP").getSIDouble(0);

        return p;
    }
Exemplo n.º 6
0
    void GridProperties<T>::handleMULTIREGRecord( const DeckRecord& record, const GridProperty<int>& regionProperty ) {
        const std::string& targetArray = record.getItem("ARRAY").get< std::string >(0);
        assertKeyword( targetArray );

        GridProperty<T>& targetProperty = getOrCreateProperty( targetArray  );
        double inputValue = record.getItem("FACTOR").get<double>(0);
        int regionValue = record.getItem("REGION_NUMBER").get<int>(0);
        T factor = convertInputValue( inputValue );
        std::vector<bool> mask;

        regionProperty.initMask( regionValue , mask);
        targetProperty.maskedMultiply( factor , mask);
    }
Exemplo n.º 7
0
    void GridProperties<T>::handleEQUALSRecord( const DeckRecord& record, BoxManager& boxManager) {
        const std::string& field = record.getItem("field").get< std::string >(0);
        double      value  = record.getItem("value").get< double >(0);

        if (supportsKeyword( field )) {
            GridProperty<T>& property = getOrCreateProperty( field );
            T targetValue = convertInputValue( property , value );

            setKeywordBox(record, boxManager);
            property.setScalar( targetValue , boxManager.getActiveBox() );
        } else
            throw std::invalid_argument("Fatal error processing EQUALS keyword. Tried to set not defined keyword " + field);
    }
Exemplo n.º 8
0
    void GridProperties<T>::handleCOPYRecord( const DeckRecord& record, BoxManager& boxManager) {
        const std::string& srcField = record.getItem("src").get< std::string >(0);
        const std::string& targetField = record.getItem("target").get< std::string >(0);

        if (hasKeyword( srcField )) {
            setKeywordBox(record, boxManager);
            copyKeyword( srcField , targetField , boxManager.getActiveBox() );
        } else {
            if (!supportsKeyword( srcField))
                throw std::invalid_argument("Fatal error processing COPY keyword."
                                            " Tried to copy from not defined keyword " + srcField);
        }
    }
Exemplo n.º 9
0
    void GridProperties<T>::handleADDREGRecord( const DeckRecord& record, const GridProperty<int>& regionProperty ) {
        const std::string& targetArray = record.getItem("ARRAY").get< std::string >(0);
        assertKeyword(targetArray);

        GridProperty<T>& targetProperty = getKeyword( targetArray  );
        double inputValue = record.getItem("SHIFT").get<double>(0);
        int regionValue = record.getItem("REGION_NUMBER").get<int>(0);
        T shiftValue = convertInputValue( targetProperty , inputValue );
        std::vector<bool> mask;

        regionProperty.initMask( regionValue , mask);
        targetProperty.maskedAdd( shiftValue , mask);
    }
Exemplo n.º 10
0
    void GridProperties<T>::handleEQUALREGRecord( const DeckRecord& record, const GridProperty<int>& regionProperty ) {
        const std::string& targetArray = record.getItem("ARRAY").get< std::string >(0);
        if (supportsKeyword( targetArray )) {
            GridProperty<T>& targetProperty = getOrCreateProperty( targetArray  );
            double inputValue = record.getItem("VALUE").get<double>(0);
            int regionValue = record.getItem("REGION_NUMBER").get<int>(0);
            T targetValue = convertInputValue( targetProperty , inputValue );
            std::vector<bool> mask;

            regionProperty.initMask( regionValue , mask);
            targetProperty.maskedSet( targetValue , mask);
        } else
            throw std::invalid_argument("Fatal error processing EQUALREG record - invalid/undefined keyword: " + targetArray);
    }
Exemplo n.º 11
0
 EquilRecord::EquilRecord( const DeckRecord& record ) :
         datum_depth( record.getItem( 0 ).getSIDouble( 0 ) ),
         datum_depth_ps( record.getItem( 1 ).getSIDouble( 0 ) ),
         water_oil_contact_depth( record.getItem( 2 ).getSIDouble( 0 ) ),
         water_oil_contact_capillary_pressure( record.getItem( 3 ).getSIDouble( 0 ) ),
         gas_oil_contact_depth( record.getItem( 4 ).getSIDouble( 0 ) ),
         gas_oil_contact_capillary_pressure( record.getItem( 5 ).getSIDouble( 0 ) ),
         live_oil_init_proc( record.getItem( 6 ).get< int >( 0 ) <= 0 ),
         wet_gas_init_proc( record.getItem( 7 ).get< int >( 0 ) <= 0 ),
         init_target_accuracy( record.getItem( 8 ).get< int >( 0 ) )
 {}
Exemplo n.º 12
0
static std::shared_ptr< Deck > deckWithGRUPTREE() {
    DeckPtr deck = createDeck();
    DeckKeyword gruptreeKeyword("GRUPTREE");

    DeckRecord recordChildOfField;
    auto itemChild1 = DeckItem::make< std::string >( "CHILD_GROUP" );
    itemChild1.push_back(std::string("BARNET"));
    auto itemParent1 = DeckItem::make< std::string >( "PARENT_GROUP" );
    itemParent1.push_back(std::string("FAREN"));

    recordChildOfField.addItem( std::move( itemChild1 ) );
    recordChildOfField.addItem( std::move( itemParent1 ) );
    gruptreeKeyword.addRecord( std::move( recordChildOfField ) );
    deck->addKeyword( std::move( gruptreeKeyword ) );

    return deck;
}
Exemplo n.º 13
0
static Opm::EquilRecord mkEquilRecord( double datd, double datp,
                                       double zwoc, double pcow_woc,
                                       double zgoc, double pcgo_goc ) {
    using namespace Opm;

    auto dd = DeckItem::make< double >( "datdep" );
    dd.push_back( datd  );
    auto dd_dim = std::make_shared< Opm::Dimension >( "dddim", 1 );
    dd.push_backDimension( dd_dim, dd_dim );

    auto dp = DeckItem::make< double >( "datps" );
    dp.push_back( datp );
    auto dp_dim = std::make_shared< Opm::Dimension >( "dpdim", 1 );
    dp.push_backDimension( dp_dim, dp_dim );

    auto zw = DeckItem::make< double >( "zwoc" );
    zw.push_back( zwoc );
    auto zw_dim = std::make_shared< Opm::Dimension >( "zwdim", 1 );
    zw.push_backDimension( zw_dim, zw_dim );

    auto pcow = DeckItem::make< double >( "pcow" );
    pcow.push_back( pcow_woc );
    auto pcow_dim = std::make_shared< Opm::Dimension >( "pcowdim", 1 );
    pcow.push_backDimension( pcow_dim, pcow_dim );

    auto zg = DeckItem::make< double >( "zgoc" );
    zg.push_back( zgoc );
    auto zg_dim = std::make_shared< Opm::Dimension >( "zgdim", 1 );
    zg.push_backDimension( zg_dim, zg_dim );

    auto pcgo = DeckItem::make< double >( "pcgo" );
    pcgo.push_back( pcgo_goc );
    auto pcgo_dim = std::make_shared< Opm::Dimension >( "pcgodim", 1 );
    pcgo.push_backDimension( pcgo_dim, pcgo_dim );

    auto i1 = DeckItem::make< int >( "i1" );
    auto i2 = DeckItem::make< int >( "i2" );
    auto i3 = DeckItem::make< int >( "i3" );
    i1.push_back( 0 );
    i2.push_back( 0 );
    i3.push_back( 0 );

    DeckRecord rec;
    rec.addItem( std::move( dd ) );
    rec.addItem( std::move( dp ) );
    rec.addItem( std::move( zw ) );
    rec.addItem( std::move( pcow ) );
    rec.addItem( std::move( zg ) );
    rec.addItem( std::move( pcgo ) );
    rec.addItem( std::move( i1 ) );
    rec.addItem( std::move( i2 ) );
    rec.addItem( std::move( i3 ) );

    return EquilRecord( rec );
}
Exemplo n.º 14
0
    void GridProperties<T>::handleCOPYREGRecord( const DeckRecord& record, const GridProperty<int>& regionProperty ) {
        const std::string& srcArray    = record.getItem("ARRAY").get< std::string >(0);
        const std::string& targetArray = record.getItem("TARGET_ARRAY").get< std::string >(0);

        if (!supportsKeyword( targetArray))
            throw std::invalid_argument("Fatal error processing COPYREG record - invalid/undefined keyword: " + targetArray);

        if (!hasKeyword( srcArray ))
            throw std::invalid_argument("Fatal error processing COPYREG record - invalid/undefined keyword: " + srcArray);

        {
            int regionValue = record.getItem("REGION_NUMBER").get< int >(0);
            std::vector<bool> mask;
            GridProperty<T>& targetProperty = getOrCreateProperty( targetArray );
            GridProperty<T>& srcProperty = getKeyword( srcArray );

            regionProperty.initMask( regionValue , mask);
            targetProperty.maskedCopy( srcProperty , mask );
        }
    }
Exemplo n.º 15
0
    inline std::vector< Completion >
    fromCOMPDAT( const EclipseGrid& grid,
                 const DeckRecord& compdatRecord,
                 const Well& well,
                 int prev_complnum ) {

        std::vector< Completion > completions;

        // We change from eclipse's 1 - n, to a 0 - n-1 solution
        // I and J can be defaulted with 0 or *, in which case they are fetched
        // from the well head
        const auto& itemI = compdatRecord.getItem( "I" );
        const auto defaulted_I = itemI.defaultApplied( 0 ) || itemI.get< int >( 0 ) == 0;
        const int I = !defaulted_I ? itemI.get< int >( 0 ) - 1 : well.getHeadI();

        const auto& itemJ = compdatRecord.getItem( "J" );
        const auto defaulted_J = itemJ.defaultApplied( 0 ) || itemJ.get< int >( 0 ) == 0;
        const int J = !defaulted_J ? itemJ.get< int >( 0 ) - 1 : well.getHeadJ();

        int K1 = compdatRecord.getItem("K1").get< int >(0) - 1;
        int K2 = compdatRecord.getItem("K2").get< int >(0) - 1;
        WellCompletion::StateEnum state = WellCompletion::StateEnumFromString( compdatRecord.getItem("STATE").getTrimmedString(0) );
        Value<double> connectionTransmissibilityFactor("ConnectionTransmissibilityFactor");
        Value<double> diameter("Diameter");
        Value<double> skinFactor("SkinFactor");

        {
            const auto& connectionTransmissibilityFactorItem = compdatRecord.getItem("CONNECTION_TRANSMISSIBILITY_FACTOR");
            const auto& diameterItem = compdatRecord.getItem("DIAMETER");
            const auto& skinFactorItem = compdatRecord.getItem("SKIN");

            if (connectionTransmissibilityFactorItem.hasValue(0) && connectionTransmissibilityFactorItem.getSIDouble(0) > 0)
                connectionTransmissibilityFactor.setValue(connectionTransmissibilityFactorItem.getSIDouble(0));

            if (diameterItem.hasValue(0))
                diameter.setValue( diameterItem.getSIDouble(0));

            if (skinFactorItem.hasValue(0))
                skinFactor.setValue( skinFactorItem.get< double >(0));
        }

        const WellCompletion::DirectionEnum direction = WellCompletion::DirectionEnumFromString(compdatRecord.getItem("DIR").getTrimmedString(0));

        for (int k = K1; k <= K2; k++) {
            completions.emplace_back( I, J, k,
                                      int( completions.size() + prev_complnum ) + 1,
                                      grid.getCellDepth( I,J,k ),
                                      state,
                                      connectionTransmissibilityFactor,
                                      diameter,
                                      skinFactor,
                                      direction );
        }

        return completions;
    }
Exemplo n.º 16
0
    void GridProperties<T>::handleOPERATERRecord( const DeckRecord& record, const GridProperty<int>& regionProperty) {
        const std::string& result_array = record.getItem("RESULT_ARRAY").get< std::string >(0);
        const std::string& parameter_array = record.getItem("ARRAY_PARAMETER").get< std::string >(0);
        const std::string& operation   = record.getItem("OPERATION").get< std::string >(0);
        double alpha = record.getItem("PARAM1").get< double >(0);
        double beta = record.getItem("PARAM2").get< double >(0);
        int region_value = record.getItem("REGION_NUMBER").get<int>(0);

        if (!supportsKeyword( result_array))
            throw std::invalid_argument("Fatal error processing OPERATER record - invalid/undefined keyword: " + result_array);

        {
            auto& result_prop = getKeyword(result_array);
            if (parameter_array == result_array)
                result_prop.runPostProcessor();
            else {
                if (operation == "MULTIPLY" || operation == "POLY")
                    result_prop.runPostProcessor();
            }

            std::vector<T>& result_data = result_prop.getData();
            const std::vector<T>& parameter_data = getKeyword( parameter_array ).getData();
            operate_fptr func = operations.at( operation );
            std::vector<bool> mask;

            regionProperty.initMask(region_value, mask);
            for (size_t index = 0; index < mask.size(); index++) {
                if (mask[index])
                    result_data[index] = func(result_data[index], parameter_data[index], alpha, beta);
            }
        }
    }
Exemplo n.º 17
0
    MULTREGTRecord::MULTREGTRecord( const DeckRecord& deckRecord, const std::string& defaultRegion) :
        m_srcRegion("SRC_REGION"),
        m_targetRegion("TARGET_REGION"),
        m_region("REGION" , defaultRegion)
    {
        const auto& srcItem = deckRecord.getItem("SRC_REGION");
        const auto& targetItem = deckRecord.getItem("TARGET_REGION");
        const auto& tranItem = deckRecord.getItem("TRAN_MULT");
        const auto& dirItem = deckRecord.getItem("DIRECTIONS");
        const auto& nncItem = deckRecord.getItem("NNC_MULT");
        const auto& defItem = deckRecord.getItem("REGION_DEF");


        if (!srcItem.defaultApplied(0))
            m_srcRegion.setValue( srcItem.get< int >(0) );

        if (!targetItem.defaultApplied(0))
            m_targetRegion.setValue( targetItem.get< int >(0) );

        m_transMultiplier = tranItem.get< double >(0);
        m_directions = FaceDir::FromMULTREGTString( dirItem.get< std::string >(0) );
        m_nncBehaviour = MULTREGT::NNCBehaviourFromString( nncItem.get< std::string >(0));

        if (!defItem.defaultApplied(0))
            m_region.setValue( MULTREGT::RegionNameFromDeckValue ( defItem.get< std::string >(0) ));
    }
Exemplo n.º 18
0
    void ParserRecord::applyUnitsToDeck( Deck& deck, DeckRecord& deckRecord ) const {
        for( const auto& item : *this ) {
            if( !item.hasDimension() ) continue;

            auto& deckItem = deckRecord.getItem( item.name() );

            for (size_t idim = 0; idim < item.numDimensions(); idim++) {
                auto activeDimension  = deck.getActiveUnitSystem().getNewDimension( item.getDimension(idim) );
                auto defaultDimension = deck.getDefaultUnitSystem().getNewDimension( item.getDimension(idim) );
                deckItem.push_backDimension( activeDimension , defaultDimension );
            }
        }
    }
Exemplo n.º 19
0
    boost::posix_time::ptime TimeMap::timeFromEclipse( const DeckRecord& dateRecord ) {
        static const std::string errorMsg("The datarecord must consist of the for values "
                                          "\"DAY(int), MONTH(string), YEAR(int), TIME(string)\".\n");
        if (dateRecord.size() != 4) {
            throw std::invalid_argument( errorMsg);
        }

        const auto& dayItem = dateRecord.getItem( 0 );
        const auto& monthItem = dateRecord.getItem( 1 );
        const auto& yearItem = dateRecord.getItem( 2 );
        const auto& timeItem = dateRecord.getItem( 3 );

        try {
            int day = dayItem.get< int >(0);
            const std::string& month = monthItem.get< std::string >(0);
            int year = yearItem.get< int >(0);
            std::string eclipseTimeString = timeItem.get< std::string >(0);

            return TimeMap::timeFromEclipse(day, month, year, eclipseTimeString);
        } catch (...) {
            throw std::invalid_argument( errorMsg );
        }
    }
Exemplo n.º 20
0
    void ParserRecord::applyUnitsToDeck( Deck& deck, DeckRecord& deckRecord ) const {
        for (auto iter=begin(); iter != end(); ++iter) {
            if ((*iter)->hasDimension()) {
                auto& deckItem = deckRecord.getItem( (*iter)->name() );
                std::shared_ptr<const ParserItem> parserItem = get( (*iter)->name() );

                for (size_t idim=0; idim < (*iter)->numDimensions(); idim++) {
                    std::shared_ptr<const Dimension> activeDimension  = deck.getActiveUnitSystem().getNewDimension( parserItem->getDimension(idim) );
                    std::shared_ptr<const Dimension> defaultDimension = deck.getDefaultUnitSystem().getNewDimension( parserItem->getDimension(idim) );
                    deckItem.push_backDimension( activeDimension , defaultDimension );
                }
            }
        }
    }
    WellProductionProperties WellProductionProperties::history(double BHPLimit, const DeckRecord& record)
    {
        // Modes supported in WCONHIST just from {O,W,G}RAT values
        //
        // Note: The default value of observed {O,W,G}RAT is zero
        // (numerically) whence the following control modes are
        // unconditionally supported.
        WellProductionProperties p(record);
        p.predictionMode = false;

        for (auto const& modeKey : {"ORAT", "WRAT", "GRAT", "LRAT", "RESV", "GRUP"}) {
            auto cmode = WellProducer::ControlModeFromString( modeKey );
            p.addProductionControl( cmode );
        }

        /*
          We do not update the BHPLIMIT based on the BHP value given
          in WCONHIST, that is purely a historical value; instead we
          copy the old value of the BHP limit from the previous
          timestep.

          To actually set the BHPLIMIT in historical mode you must
          use the WELTARG keyword.
        */
        p.BHPLimit = BHPLimit;

        const auto& cmodeItem = record.getItem("CMODE");
        if (!cmodeItem.defaultApplied(0)) {
            const WellProducer::ControlModeEnum cmode = WellProducer::ControlModeFromString( cmodeItem.get< std::string >(0) );

            if (p.hasProductionControl( cmode ))
                p.controlMode = cmode;
            else
                throw std::invalid_argument("Setting CMODE to unspecified control");
        }

        return p;
    }
Exemplo n.º 22
0
    WellProductionProperties WellProductionProperties::prediction( const DeckRecord& record, bool addGroupProductionControl)
    {
        WellProductionProperties p(record);
        p.predictionMode = true;

        p.LiquidRate     = record.getItem("LRAT"     ).getSIDouble(0);
        p.ResVRate       = record.getItem("RESV"     ).getSIDouble(0);
        p.BHPLimit       = record.getItem("BHP"      ).getSIDouble(0);
        p.THPLimit       = record.getItem("THP"      ).getSIDouble(0);
        p.ALQValue       = record.getItem("ALQ"      ).get< double >(0); //NOTE: Unit of ALQ is never touched
        p.VFPTableNumber = record.getItem("VFP_TABLE").get< int >(0);

        namespace wp = WellProducer;
        using mode = std::pair< const char*, wp::ControlModeEnum >;
        static const mode modes[] = {
            { "ORAT", wp::ORAT }, { "WRAT", wp::WRAT }, { "GRAT", wp::GRAT },
            { "LRAT", wp::LRAT }, { "RESV", wp::RESV }, { "THP", wp::THP }
        };

        for( const auto& cmode : modes ) {
            if( !record.getItem( cmode.first ).defaultApplied( 0 ) )
                 p.addProductionControl( cmode.second );
        }

        // There is always a BHP constraint, when not specified, will use the default value
        p.addProductionControl( wp::BHP );

        if (addGroupProductionControl) {
            p.addProductionControl(WellProducer::GRUP);
        }


        {
            const auto& cmodeItem = record.getItem("CMODE");
            if (cmodeItem.hasValue(0)) {
                const WellProducer::ControlModeEnum cmode = WellProducer::ControlModeFromString( cmodeItem.getTrimmedString(0) );

                if (p.hasProductionControl( cmode ))
                    p.controlMode = cmode;
                else
                    throw std::invalid_argument("Setting CMODE to unspecified control");
            }
        }
        return p;
    }
Exemplo n.º 23
0
    void Well::handleWPIMULT(const DeckRecord& record, size_t time_step) {

        auto match = [=]( const Connection &c) -> bool {
            if (!match_ge(c.complnum, record, "FIRST")) return false;
            if (!match_le(c.complnum, record, "LAST"))  return false;
            if (!match_eq(c.getI()  , record, "I", -1)) return false;
            if (!match_eq(c.getJ()  , record, "J", -1)) return false;
            if (!match_eq(c.getK()  , record, "K", -1)) return false;

            return true;
        };

        WellConnections * new_connections = this->newWellConnections(time_step);
        double wellPi = record.getItem("WELLPI").get< double >(0);

        for (auto c : this->getConnections(time_step)) {
            if (match(c))
                c.wellPi *= wellPi;

            new_connections->add(c);
        }

        this->updateWellConnections(time_step, new_connections);
    }
Exemplo n.º 24
0
    void Well::handleCOMPLUMP(const DeckRecord& record, size_t time_step)  {

        auto match = [=]( const Connection& c ) -> bool {
            if (!match_eq(c.getI(), record, "I" , -1))  return false;
            if (!match_eq(c.getJ(), record, "J" , -1))  return false;
            if (!match_ge(c.getK(), record, "K1", -1)) return false;
            if (!match_le(c.getK(), record, "K2", -1)) return false;

            return true;
        };

        WellConnections * new_connections = this->newWellConnections(time_step);
        const int complnum = record.getItem("N").get<int>(0);
        if (complnum <= 0)
            throw std::invalid_argument("Completion number must be >= 1. COMPLNUM=" + std::to_string(complnum) + "is invalid");

        for (auto c : this->getConnections(time_step)) {
            if (match(c))
                c.complnum = complnum;

            new_connections->add(c);
        }
        this->updateWellConnections(time_step, new_connections);
    }
Exemplo n.º 25
0
    std::pair<std::string , std::vector<CompletionPtr> > Completion::completionsFromCOMPDATRecord( const DeckRecord& compdatRecord ) {
        std::vector<CompletionPtr> completions;
        std::string well = compdatRecord.getItem("WELL").getTrimmedString(0);
        // We change from eclipse's 1 - n, to a 0 - n-1 solution
        int I = compdatRecord.getItem("I").get< int >(0) - 1;
        int J = compdatRecord.getItem("J").get< int >(0) - 1;
        int K1 = compdatRecord.getItem("K1").get< int >(0) - 1;
        int K2 = compdatRecord.getItem("K2").get< int >(0) - 1;
        WellCompletion::StateEnum state = WellCompletion::StateEnumFromString( compdatRecord.getItem("STATE").getTrimmedString(0) );
        Value<double> connectionTransmissibilityFactor("ConnectionTransmissibilityFactor");
        Value<double> diameter("Diameter");
        Value<double> skinFactor("SkinFactor");

        {
            const auto& connectionTransmissibilityFactorItem = compdatRecord.getItem("CONNECTION_TRANSMISSIBILITY_FACTOR");
            const auto& diameterItem = compdatRecord.getItem("DIAMETER");
            const auto& skinFactorItem = compdatRecord.getItem("SKIN");

            if (connectionTransmissibilityFactorItem.hasValue(0) && connectionTransmissibilityFactorItem.getSIDouble(0) > 0)
                connectionTransmissibilityFactor.setValue(connectionTransmissibilityFactorItem.getSIDouble(0));

            if (diameterItem.hasValue(0))
                diameter.setValue( diameterItem.getSIDouble(0));

            if (skinFactorItem.hasValue(0))
                skinFactor.setValue( skinFactorItem.get< double >(0));
        }

        const WellCompletion::DirectionEnum direction = WellCompletion::DirectionEnumFromString(compdatRecord.getItem("DIR").getTrimmedString(0));

        for (int k = K1; k <= K2; k++) {
            CompletionPtr completion(new Completion(I , J , k , state , connectionTransmissibilityFactor, diameter, skinFactor, direction ));
            completions.push_back( completion );
        }

        return std::pair<std::string , std::vector<CompletionPtr> >( well , completions );
    }
    WellProductionProperties WellProductionProperties::prediction( const DeckRecord& record, bool addGroupProductionControl)
    {
        WellProductionProperties p(record);
        p.predictionMode = true;

        p.LiquidRate     = record.getItem("LRAT"     ).getSIDouble(0);
        p.ResVRate       = record.getItem("RESV"     ).getSIDouble(0);
        p.BHPLimit       = record.getItem("BHP"      ).getSIDouble(0);
        p.THPLimit       = record.getItem("THP"      ).getSIDouble(0);
        p.ALQValue       = record.getItem("ALQ"      ).get< double >(0); //NOTE: Unit of ALQ is never touched
        p.VFPTableNumber = record.getItem("VFP_TABLE").get< int >(0);

        for (auto const& modeKey : {"ORAT", "WRAT", "GRAT", "LRAT","RESV", "BHP" , "THP"}) {
             if (!record.getItem(modeKey).defaultApplied(0)) {
                 auto cmode = WellProducer::ControlModeFromString( modeKey );
                 p.addProductionControl( cmode );
            }
        }

        if (addGroupProductionControl) {
            p.addProductionControl(WellProducer::GRUP);
        }


        {
            const auto& cmodeItem = record.getItem("CMODE");
            if (cmodeItem.hasValue(0)) {
                const WellProducer::ControlModeEnum cmode = WellProducer::ControlModeFromString( cmodeItem.get< std::string >(0) );

                if (p.hasProductionControl( cmode ))
                    p.controlMode = cmode;
                else
                    throw std::invalid_argument("Setting CMODE to unspecified control");
            }
        }
        return p;
    }
Exemplo n.º 27
0
 WellProductionProperties::
 WellProductionProperties( const DeckRecord& record ) :
     OilRate( record.getItem( "ORAT" ).getSIDouble( 0 ) ),
     WaterRate( record.getItem( "WRAT" ).getSIDouble( 0 ) ),
     GasRate( record.getItem( "GRAT" ).getSIDouble( 0 ) )
 {}