PMEAL / OpenPNM

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

Units and set parameters to Algorithms #900

Closed angelswat closed 6 years ago

angelswat commented 6 years ago

Hi @jgostick , @TomTranter.

I have a question about the units of parameters setted in Algorithms. For example, there're algorithms like ohmic conduction, stokes flows, fourier conduction, etc. In all of them, there are two parameters to set, BCVALUE in inlets and outlets. But I do not understand what units and what type of parameter I have to set. Only I know that I can set Dirichlet and Neumann parameters. I want to apply these algorithms but I need to know it.

Please, help me. Thanks.

jgostick commented 6 years ago

Units are not easy to implement in python...we've looked at the available packages at several points over the past few years and they just arent' suitable for one reason or another. So, the end results is that users must keep track of their own units. You are solving for n = gX, then the units you chose for g and X will dictate the rate n. That said, openpnm tries to use SI for all internal 'predefined' calculations.

angelswat commented 6 years ago

Hi,

In all algorithms, there are boundary conditions. Then, what´s the difference between these? That is, example, in ohmic conduction, how set the boundary conditions?? or in stokes flow.

The comments of code, have not helped me.

Thanks.

ma-sadeghi commented 6 years ago

@angelswat You might find this table useful:

Algorithm Dirichlet BC Units Neumann BC Units
Ohmic Conduction Voltage Volts Current Amperes
Stokes Flow Pressure Pascals Flow rate m^3/s
Fickian Diffusion Concentration kg/m^3 Mass flow rate kg/s
Fourier Conduction Temperature Kelvins Energy flow rate Watts

These are the default BC types and their corresponding units. Of course, you can technically use any units that you prefer. But, it could turn out to be tricky as you need to make sure every model (for instance, those returning thermal conductivity, diffusivity, etc.) you add to your simulation uses the same units. So, we strongly encourage you to stick to the SI units. Let me know if you need more clarification.

angelswat commented 6 years ago

@ma-sadeghi Thanks so much!

Sorry, I´ve another question. When I work with these algorithms, there´re values that I´ve to set, example, thermal conductance, diffusive conductance, electrical conductance, etc. The format is:

phys_water['throat.electrical_conductance']=XXXX

What units have all them? I want to set those parameters but I don´t know the units. Help me please.

Thanks.

ma-sadeghi commented 6 years ago

@angelswat No worries. If you use OpenPNM's built-in models for calculating these parameters, the units are automatically resolved (and assumed to be SI). In the latest version 2.0 (not yet released, but available on dev-V2-alpha1 branch) the physics-related models are located in openpnm.models.physics. For instance, you can use hagen_poiseuille model for calculating throat.hydraulic_conductance by the following command:

import openpnm as op
hagen_poiseuille = op.models.physics.hydraulic_conductance.hagen_poiseuille
phys_water.add_model(propname='throat.hydraulic_conductance', model=hagen_poiseuille)

Similarly in the latest stable version (1.6.2), you have:

import OpenPNM as op
hagen_poiseuille = op.physics.models.hydraulic_conductance.hagen_poiseuille
phys_water.add_model(propname='throat.hydraulic_conductance', model=hagen_poiseuille)

Back to your original question, at any rate, if you want to manually set the these parameters, here's the general rule for figuring out their units:

Units of (conductance) * Units of (Dirichlet BC) = Units of (Neumann BC)

For instance:

Units of (electrical_conductance) * Volts = Amperes.

So the units of throat.electrical_conductance must be Amperes per volts. Similarly in FourierConduction:

Units of (thermal_conductance) * Kelvins = Watts.

So the units of throat.thermal_conductance must be Watts per Kelvins.

jgostick commented 6 years ago

ok, so I will close this now. We cannot really support units and we're basically hoping that numpy decides to do this someday. Until then, users must mind their own units....sorry.