PMEAL / OpenPNM

A Python package for performing pore network modeling of porous media
http://openpnm.org
MIT License
456 stars 174 forks source link

Problem with the Berea Sandstone example Using Porespy #1373

Closed DMaxJ closed 4 years ago

DMaxJ commented 4 years ago

There seems to be a problem in the example here for Berea Sandstone simulation with OpenPNM and Porespy.

path = ' '
file_format = '.raw'
file_name = 'Berea'
file = file_name + file_format
fetch_file = os.path.join(path, file)
im = imageio.mimread(fetch_file)

When the code above is executed it produces the error

ValueError: Could not find a format to read the specified file in mode 'I' 

The file is downloaded from the Imperial website and used without altering anything. What needs to be done to be able to read .RAW (binarized) files directly?

DMaxJ commented 4 years ago

I have a found a way to solve it. I used the following code

f_name = 'Berea.raw'
shape=[400, 400, 400]
im0 = np.fromfile(f_name, dtype='bool', sep='')
im = im0.reshape(shape)

Is there any better way to do that?

I have checked for the porosity and it shows .80354 which is alright because I did not change the downloaded file (where the pores and the solids values are altered as required by the Maximal Ball algorithm).

jgostick commented 4 years ago

Reading in 3D image files is always "fun". I usually open up badly behaving files in imagej, then save as a properly formatted TIF file first. Your 2nd way is actually pretty clean. I can't imagine a better way than that...technically it's 2 lines of code:

im = np.fromfile('Berea.raw', dtype='bool', sep='')
im = im.reshape([400, 400, 400])
ZHHYKU commented 4 years ago

I used the Berea.raw and outputs using SNOW are the same as those in this example except the effective permeability. The value of K is: [945.72132788] mD, however in the example, K is: [1145.01717908] mD. I am confused about why I get different K value with the same code..

jgostick commented 4 years ago

It all depends on the pore-scale conductance models used. Our code is continually evolving, and sometimes openpnm and porespy get out of sync, so it depends on what versions you are using. I realize this is not a good answer, but we only only a few people (me + 1 or 2 grad students) working on this so can't always keep up.

Nikolina3 commented 4 years ago

Hi! I used your code for extracting pore network from Berea Sandstone using SNOW algorithm and keep getting the wrong permeability K=54772 md. For loading the image i used these lines of code: f_name = 'Berea.raw' shape=[400, 400, 400] im0 = np.fromfile(f_name, dtype='bool', sep='') im = im0.reshape(shape) For calculating the permeability i copied your code and didn't change anything. Can you please help me with this problem?

ahmedsrizk95 commented 3 years ago

I want to ask in which direction is the estimated permeability when using .raw files? Actually, opening the .raw file using np.fromfile needs reshaping of the image in a way that z direction is the positioned in the first index of the reshape function which is im.reshape([z, x, y]). Now how openpnm deals with this?