PMEAL / OpenPNM

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

Add `ContinuumGeometry` class for direct numerical simulations #1428

Open ma-sadeghi opened 4 years ago

ma-sadeghi commented 4 years ago

For carrying out direct numerical simulations, it would be handy if we had a DNS geometry tailored for that purpose. It would simply be a bunch of cubic models (volume, area, etc.).

jgostick commented 4 years ago

We are currently putting DNS calculations in PoreSpy, using OpenPNM in the background.

ma-sadeghi commented 4 years ago

@jgostick I mean DNS coupled with PNM, like in CL simulation where we have void as PNM coupled with Nafion as DNS.

jgostick commented 4 years ago

I like this idea, a geometry class called Continuum which does all the stuff needed to create a 'pore-less' region. This could also be used to do porous continuum using different pore-scale models to get effective diffusivity of the region.

jgostick commented 4 years ago

This would require some pore-scale models like bruggeman for calculating the effective diffusivity of the "nodes". We had a few models towards this idea in V1 but I purge them in the transition to V2.

mkaguer commented 3 years ago

Question for this issue, @jgostick or @ma-sadeghi. Do we only want this geometry to work for cubic lattice structures? I can imagine rectangular lattice structures with different spacing in each direction but that would complicate things.

jgostick commented 3 years ago

Eventually we'd like anisotropic meshes, but we can get to that later. BTW, I fiddled with this a bit on a branch. I'll push it so we can use it as a starting point.

mkaguer commented 3 years ago

Ok great, thanks.

ma-sadeghi commented 1 year ago
import openpnm as op
import openpnm.models as mods
import openpnm.models.geometry as gmods
from openpnm.geometry import GenericGeometry

class Continuum(GenericGeometry):
    r"""
    Continuum subclass of GenericGeometry.

    This subclass is meant to be used for regions that are treated as
    continuum rather than an actual pore network.

    Parameters
    ----------
    network : GenericNetwork
        The network with which this Geometry should be associated
    pores : array_like
        The pores in the domain where this Geometry applies
    throats : array_like
        The throats in the domain where this Geometry applies
    name : str
        The name of the object, which is also used as the label where this
        geometry is defined.

    """

    def __init__(self, **kwargs):
        super().__init__(**kwargs)

        spacing = op.topotools.get_spacing(self.network).mean()

        self.add_model(propname='pore.diameter',
                       model=mods.misc.constant,
                       value=spacing)

        self.add_model(propname='pore.volume',
                       model=mods.geometry.pore_volume.cube,
                       pore_diameter='pore.diameter')

        self.add_model(propname='throat.diameter',
                       model=mods.misc.from_neighbor_pores,
                       prop='pore.diameter', mode='mean')

        self.add_model(propname='throat.length',
                       model=mods.misc.constant,
                       value=1e-50)

        self.add_model(propname='throat.cross_sectional_area',
                       model=mods.geometry.throat_cross_sectional_area.cuboid,
                       throat_diameter='throat.diameter')

        self.add_model(propname='throat.volume',
                       model=mods.geometry.throat_volume.cuboid,
                       throat_diameter='throat.diameter',
                       throat_length='throat.length')

        self.add_model(propname='throat.diffusive_size_factors',
                       model=gmods.diffusive_size_factors.cubes_and_cuboids,
                       pore_diameter="pore.diameter",
                       throat_diameter="throat.diameter")

        self.add_model(propname='throat.hydraulic_size_factors',
                       model=gmods.hydraulic_size_factors.cubes_and_cuboids,
                       pore_diameter="pore.diameter",
                       throat_diameter="throat.diameter")