PMEAL / OpenPNM

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

Problems with the latest version #1724

Closed alexeytopolnitskiy closed 4 years ago

alexeytopolnitskiy commented 4 years ago

Hello! I have some problems after updating to the latest version (2.5.1).

Снимок экрана 2020-10-29 в 15 33 50
  1. First problem with model loading.

    Снимок экрана 2020-10-29 в 15 34 41

    In your tutorial it is said to use import_data function but it is not listed in possible variants for PoresPy (but this function is in source code so it looks weird).

  2. Second problem with permeability calculation. Before the updating everything worked fine but now it does not return anything.

    Снимок экрана 2020-10-29 в 15 33 20

    Also there are some warning that I do not know how to solve.

Can you comment and give some advices on that?

jgostick commented 4 years ago

Regarding your first problem, I'm guess that you're jupyter notebook is using the pip or conda release, while the new import_data function is currently only on the dev branch. Our docs on github point to the 'default' branch, which we have set to 'dev'. I only now occurs to me that this could lead to problems. We'll discuss this at the next dev meeting. To get the dev branch on your local machine so that you always have the latest version, I have created these instructions.

Regarding your second item, this is a normal warning. OpenPNM is not able to accurately calculate the domain area and length. It only knows where the pore centers are, so can find the length between them, but this neglects the 'extra' bit of domain that extends beyond the surface pores. If your domain is large this is a negligible amount, but as it gets smaller this becomes more significant. We honestly don't have a way or plan to fix this...you're only option is to enter the area and length of the domain by hand when you call the calc_effective_permeability function (see doc string). This question comes up often enough that I think we should make an example detailing the situation and link to it in the warning message!

alexeytopolnitskiy commented 4 years ago

@jgostick Thank you for you reply. I do enter sizes of domain and length before the perm.run(( but I still do not understand why the function does not return me anything (empty list). In previous version it returned me some adequate results but now nothing. What can I do with that?

jgostick commented 4 years ago

Ahh, I see now...k is an empty array. That is odd! Let me try to reproduce.

jgostick commented 4 years ago

Can you post some minimal code here to make this happen? My script works just fine, so perhaps you're doing something differently?

alexeytopolnitskiy commented 4 years ago
### 1. Extract network
net = ps.networks.snow(
    im=fibsem,
    voxel_size = 20, ## 20nm?
    boundary_faces=['left','right'], ##
    marching_cubes_area=True)

### 2. Import network
pn, geo = op.io.PoreSpy.load(net)

### 3. Check network health --- remove isolated pores or cluster of pores
h = pn.check_network_health()
op.topotools.trim(network=pn, pores=h['trim_pores'])
h = pn.check_network_health()

### 4. Assign phase for simulation --- air in this case
air = op.phases.Air(network=pn)

### 5. Assign pore-scale physics model
phys_air = op.physics.GenericPhysics(network=pn, phase=air, geometry=geo)

### 6. Assign pore-scale models
model = op.models.physics.hydraulic_conductance.hagen_poiseuille
phys_air.add_model(propname='throat.hydraulic_conductance',
                   model=model,
                   pore_viscosity='pore.viscosity',
                   pore_area='pore.area',
                   throat_area='throat.area',
                   conduit_lengths='throat.conduit_lengths')

### 7. Assign algorithm (StokesFlow) and boundary conditions
perm = op.algorithms.StokesFlow(network=pn)
perm.setup(phase=air)
perm.set_value_BC(pores=pn.pores('left'), values=101325)
perm.set_value_BC(pores=pn.pores('right'), values=0)

perm.domain_area = (300 * 250) * 20**2
perm.domain_length = 250 * 20

perm.run()
K = perm.calc_effective_permeability()

fibsem is my 3D model consists of 0s for solid and 1s for pores. Its size is [250,300,250] and the voxel size is 20nm. I need to calculate permeability in each direction. Hope you can give me some advices on doing it appropriately.

jgostick commented 4 years ago

can you also share the fibsem image? I wonder if the problem is this?

alexeytopolnitskiy commented 4 years ago
Снимок экрана 2020-10-31 в 10 17 49

Actually, porosity calculation is ok, but smth strange with permeability

Снимок экрана 2020-10-31 в 10 20 08
jgostick commented 4 years ago

I'm still unable to reproduce why this is returning an empty array. But I can say that assigning domain area and length as attributes of the class do NOT do anything. You have to pass these values into the calc_effective_permeability function. We are planning to eventually remove this function from the class. We decided to do this because of the challenges with calculating area and length properly, and also because this function assumes that the user inputted the boundary conditions correctly. We are going to move this functionality to a new class ( a metric) dedicated to just finding K of the network.

alexeytopolnitskiy commented 4 years ago

@jgostick I think I found the problem. My cube was not available for permeability calculations because there were no pores at boundaries. I got this after several reviews. But I have one more question. Am I right that pressure gradient must in Pa and viscosity of the phase must be in *kg/(ms)** for calculation of permeability? But could you clarify what is unit for discharge, which I use for calculation? perm.rate(pores=pn.pores('front'), mode='group')[0]

jgostick commented 4 years ago

Ahhh, that's interesting. I wonder why openpnm didn't throw a warning like a singular matrix?

RE units, unfortunately they are not natively supported for numpy arrays, and are a huge pain. We just assume SI everywhere. The rate is in m3/s.