PMEAL / OpenPNM

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

pore.diameter #1367

Closed fablion closed 4 years ago

fablion commented 4 years ago

Hi everyone,

I've just started to use openpnm. I've also started to learn Python for several month on my personal time (I'm chemist engineer in environmental company but we are working on decontamination of soil contaminated by non aqueous phase liquids). So i'm sorry if my question is too easy for you or is not well ask on github (that I also use for the first time to ask a question).

In order to discover openpnm, I start with the tutorials (gettings started and intermediate), available here (https://github.com/PMEAL/OpenPNM-Examples/blob/master/Tutorials/). After several difficulties to use directly these tutorials, I discovered that some codes of openpnm have been modified between V1 and V2 and tutorials don't seem to have been updated, unfortunately.

Now I finally manage to use intermediate tutorials by modifying code proposed in tutorials. But I still have something that I don't understand : when I add a model to geom1 in order to create pore.diameter, I get positive and negative values for geom1. Is there a mistake in my code? Is it the planned result? Or is there a bug?

import openpnm as op
import scipy as sp

pn=op.network.Cubic(shape=[20,20,10], spacing=0.0001, connectivity=8)

Ps1=pn.pores(['top','bottom'])
Ts1=pn.find_neighbor_throats(pores=Ps1, mode='union')
geom1=op.geometry.GenericGeometry(network=pn, pores=Ps1,throats=Ts1,name='surface_')

Ps2=pn.pores(['top','bottom'],mode='not')
Ts2=pn.find_neighbor_throats(pores=Ps2, mode='xnor')
geom2=op.geometry.GenericGeometry(network=pn, pores=Ps2,throats=Ts2,name='core')

geom1['pore.seed']=sp.rand(geom1.Np)
geom2['pore.seed']=sp.rand(geom2.Np)

seeds=pn['pore.seed']

geom1.add_model(propname='pore.diameter', model=op.models.geometry.pore_size.normal, scale=0.00002, loc=0.000001,seeds='pore.seed') #here is the problem
geom2.add_model(propname='pore.diameter', model=op.models.geometry.pore_size.weibull,shape=1.2,scale=0.00005, loc=0.000001,seeds='pore.seed')

Here is the result in console:

geom1['pore.diameter']
Out[70]: 
array([ 1.86507434e-06, -4.67631775e-06,  1.96460326e-05, -1.97257488e-06,
        1.45760746e-06, -1.59778114e-05, -8.17822113e-06, -1.13343597e-05,
        2.72612214e-05, -1.79235360e-05, -6.16164938e-06, -1.07099427e-05,
       -5.29780804e-07,  2.27174728e-05, -4.73623559e-06,  3.87946799e-05,
        3.42710697e-05,  3.86924265e-05,  6.26081047e-06,  1.55855594e-06,
        1.96801280e-05, -2.34795416e-06,  2.12828049e-05,  1.28270320e-05,
       -1.44113086e-05,  9.25961722e-06, -4.69539359e-05, -1.72506479e-06,
        3.25450258e-06, -1.40503752e-05,  1.61024819e-05, -1.35029319e-05,
[...]

Can anyone help me?

Thanks

Fabien

fablion commented 4 years ago

Understood... The code create a normal distribution with loc variable as mean. So the curve is "centered" on 0,00001 with my code. And given the standard deviation, half of the numbers are negative.

Is it a way to change all negative values in positive values ? with absolute value?

Thanks

ma-sadeghi commented 4 years ago

@fablion OpenPNM-Examples is no longer maintained, you can use the Tutorials in the main repo here.

fablion commented 4 years ago

Many thanks!

Edit : A suggestion for future new users like me who are not familiar with github : write in the name of the folder that the folder is outdated (or remove completely the OpenPNM-examples folder).

After your message, I scrolled down and read the "Readme" file that explains the folder is no longer maintained. For people who are not familiar with github, we can forgot to scroll down to read the text. Thanks

ma-sadeghi commented 4 years ago

@fablion Thanks for your suggestion, will definitely talk to the rest of the team to clarify the ambiguity.