Python: added tests and made Octave InputPropTest.m general

* removed non-general hard-coded grid sizes and added timing to Octave test
* added two Pythonbenchmarks (sync and async) for the same test
This commit is contained in:
Gaute Lindkvist
2019-06-04 10:34:31 +02:00
parent b6427d84c3
commit 930abbf02f
9 changed files with 34 additions and 71 deletions

View File

@@ -1,32 +0,0 @@
import sys
import os
sys.path.insert(1, os.path.join(sys.path[0], '..'))
import rips
import itertools
resInsight = rips.Instance.find()
#gridCount = resInsight.gridInfo.getGridCount(caseId=0)
#gridDimensions = resInsight.gridInfo.getAllGridDimensions(caseId=0)
resultChunks = resInsight.properties.activeCellResults(0, 'STATIC_NATIVE', 'PORO', 0)
results = []
for resultChunk in resultChunks:
for value in resultChunk.values:
results.append(value)
print("Transferred " + str(len(results)) + " poro results")
resultChunks = resInsight.properties.activeCellResults(0, 'STATIC_NATIVE', 'PERMX', 0)
permres = []
for resultChunk in resultChunks:
for value in resultChunk.values:
permres.append(value)
print("Transferred " + str(len(permres)) + " permx results")
poropermx = []
for (poro, permx) in zip(results, permres):
poropermx.append(poro * permx)
resInsight.properties.setActiveCellResults(poropermx, 0, 'GENERATED', 'PORO*PERMX2', 0)

View File

@@ -2,6 +2,7 @@ import sys
import os
sys.path.insert(1, os.path.join(sys.path[0], '..'))
import rips
import time
def createResult(poroChunks, permxChunks):
for (poroChunk, permxChunk) in zip(poroChunks, permxChunks):
@@ -12,6 +13,7 @@ def createResult(poroChunks, permxChunks):
resInsight = rips.Instance.find()
start = time.time()
case = resInsight.project.case(id=0)
poroChunks = case.properties.activeCellProperty('STATIC_NATIVE', 'PORO', 0)
@@ -19,4 +21,7 @@ permxChunks = case.properties.activeCellProperty('STATIC_NATIVE', 'PERMX', 0)
case.properties.setActiveCellPropertyAsync(createResult(poroChunks, permxChunks), 'GENERATED', 'POROPERMXAS', 0)
end = time.time()
print("Time elapsed: ", end - start)
print("Transferred all results back")

View File

@@ -1,22 +0,0 @@
import sys
import os
sys.path.insert(1, os.path.join(sys.path[0], '..'))
import rips
import itertools
resInsight = rips.Instance.find()
#gridCount = resInsight.gridInfo.getGridCount(caseId=0)
#gridDimensions = resInsight.gridInfo.getAllGridDimensions(caseId=0)
poroChunks = resInsight.properties.activeCellResults(0, 'STATIC_NATIVE', 'PORO', 0)
permxChunks = resInsight.properties.activeCellResults(0, 'STATIC_NATIVE', 'PERMX', 0)
results = []
for (poroChunk, permxChunk) in zip(poroChunks, permxChunks):
print("Received chunks")
for (poro, permx) in zip(poroChunk.values, permxChunk.values):
results.append(poro * permx)
print("Transferred " + str(len(results)) + " poro and permx results")
resInsight.properties.setActiveCellResults(results, 0, 'GENERATED', 'PORO*PERMX2', 0)

View File

@@ -2,9 +2,10 @@ import sys
import os
sys.path.insert(1, os.path.join(sys.path[0], '..'))
import rips
import time
resInsight = rips.Instance.find()
start = time.time()
case = resInsight.project.case(id=0)
poroChunks = case.properties.activeCellProperty('STATIC_NATIVE', 'PORO', 0)
@@ -25,4 +26,7 @@ for (poro, permx) in zip(poroResults, permxResults):
case.properties.setActiveCellProperty(results, 'GENERATED', 'POROPERMXSY', 0)
end = time.time()
print("Time elapsed: ", end - start)
print("Transferred all results back")

View File

@@ -5,16 +5,16 @@ import rips
import itertools
import time
start = time.time()
resInsight = rips.Instance.find()
start = time.time()
case = resInsight.project.case(id=0)
grid = case.grid(index = 0)
timeSteps = case.timeSteps()
averages = []
for i in range(0, len(timeSteps)):
for i in range(0, len(timeSteps.dates)):
resultChunks = case.properties.activeCellProperty('DYNAMIC_NATIVE', 'SOIL', i)
mysum = 0.0
count = 0

View File

@@ -52,5 +52,5 @@ class Case:
return self.stub.GetCellInfoForActiveCells(request)
def timeSteps(self):
return self.stub.GetTimeSteps(self.request).dates
return self.stub.GetTimeSteps(self.request)

View File

@@ -74,7 +74,8 @@ class Properties:
time_step = timeStep,
grid_index = gridIndex,
porosity_model = porosityModelEnum)
return self.propertiesStub.GetGridProperty(request)
for chunk in self.propertiesStub.GetGridProperty(request):
yield chunk
def setActiveCellPropertyAsync(self, values_iterator, propertyType, propertyName, timeStep, gridIndex = 0, porosityModel = 'MATRIX_MODEL'):
propertyTypeEnum = Properties_pb2.PropertyType.Value(propertyType)