Esempio n. 1
0
    def test_eval(self):
        npv = EclNPV(self.case)
        npv.compile("[FOPT]")
        npv1 = npv.evalNPV()

        npv2 = 0
        sum = EclSum(self.case)
        trange = sum.timeRange()
        fopr = sum.blockedProduction("FOPT" , trange)
        for v in fopr:
            npv2 += v
        self.assertAlmostEqual( npv1 , npv2 )
        
        npv.compile("[FOPT] - 0.5*[FOPT] - 0.5*[FOPT]")
        npv1 = npv.evalNPV()
        self.assertTrue( abs(npv1) < 1e-2 )

        npv.compile("[WOPT:OP_1] - 0.5*[WOPT:OP_1] - 0.5*[WOPT:OP_1]")
        npv1 = npv.evalNPV()
        self.assertTrue( abs(npv1) < 1e-2 )
Esempio n. 2
0
    def test_expression(self):
        npv = EclNPV( self.case )
        self.assertIsNone( npv.getExpression() )
        npv.setExpression( "[FOPT]*$OIL_PRICE - [FGIT]*$GAS_PRICE")
        self.assertEqual( npv.getExpression() , "[FOPT]*$OIL_PRICE - [FGIT]*$GAS_PRICE")
        self.assertIn( "FOPT" , npv.getKeyList() )
        self.assertIn( "FGIT" , npv.getKeyList() )

        with self.assertRaises(ValueError):
            npv.parseExpression("[FOPT")

        with self.assertRaises(ValueError):
            npv.parseExpression("FOPT]")

        with self.assertRaises(KeyError):
            npv.parseExpression("[FoPT]")
            
        with self.assertRaises(ValueError):
            npv.parseExpression("[FOPR]")
            
        parsedExpression = npv.parseExpression("[FOPT]")
        self.assertEqual( parsedExpression , "FOPT[i]")
        self.assertEqual( 1 , len(npv.getKeyList() ))


        parsedExpression = npv.parseExpression("[FOPT]*2 + [FGPT] - [WOPT:OP_1]")
        self.assertEqual( parsedExpression , "FOPT[i]*2 + FGPT[i] - WOPT_OP_1[i]")
        keyList = npv.getKeyList()
        self.assertEqual( 3 , len(keyList))
        self.assertIn( "FOPT" , keyList )
        self.assertIn( "FGPT" , keyList )
        self.assertIn( "WOPT:OP_1" , keyList )
Esempio n. 3
0
 def test_eval_npv(self):
     npv = EclNPV( self.case )
     with self.assertRaises(ValueError):
         npv.eval()