How to use the openpnm.models.geometry function in openpnm

To help you get started, we’ve selected a few openpnm examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github PMEAL / porespy / test / unit / test_io.py View on Github external
def test_openpnm_to_im(self):
        net = op.network.Cubic(shape=[5, 5, 5])
        geom = op.geometry.StickAndBall(network=net,
                                        pores=net.Ps, throats=net.Ts)
        geom.add_model(propname="pore.volume",
                       model=op.models.geometry.pore_volume.cube)
        geom.add_model(propname="throat.volume",
                       model=op.models.geometry.throat_volume.cylinder)
        geom.regenerate_models()

        im = ps.io.openpnm_to_im(network=net, pore_shape="cube",
                                 throat_shape="cylinder", rtol=0.01)
        porosity_actual = im.astype(bool).sum() / np.prod(im.shape)

        volume_void = net["pore.volume"].sum() + net["throat.volume"].sum()
        volume_total = np.prod(net.spacing * net.shape)
        porosity_desired = volume_void / volume_total

        assert_allclose(actual=porosity_actual, desired=porosity_desired,
                        rtol=0.05)
github PMEAL / porespy / test / unit / test_network_extraction.py View on Github external
def test_generate_voxel_image(self):
        net = op.network.Cubic(shape=[5, 5, 5])
        geom = op.geometry.StickAndBall(network=net,
                                        pores=net.Ps, throats=net.Ts)
        geom.add_model(propname="pore.volume",
                       model=op.models.geometry.pore_volume.cube)
        geom.add_model(propname="throat.volume",
                       model=op.models.geometry.throat_volume.cylinder)
        im = ps.networks.generate_voxel_image(network=net,
                                              pore_shape="cube",
                                              throat_shape="cylinder",
                                              rtol=0.01)
        porosity_actual = im.astype(bool).sum() / np.prod(im.shape)

        volume_void = net["pore.volume"].sum() + net["throat.volume"].sum()
        volume_total = np.prod(net.spacing * net.shape)
        porosity_desired = volume_void / volume_total

        assert_allclose(actual=porosity_actual, desired=porosity_desired,
                        rtol=0.05)
github PMEAL / OpenPNM / openpnm / materials / BundleOfTubes.py View on Github external
self.settings['spacing'] = spacing
            spacing = sp.array([spacing, spacing, length])
        else:
            raise Exception('spacing not understood, must be float')

        net = Cubic(shape=shape, spacing=spacing, project=self, **kwargs)
        Ps_top = net.pores('top')
        Ps_bot = net.pores('bottom')
        Ts = net.find_connecting_throat(P1=Ps_top, P2=Ps_bot)
        Ts = net.tomask(throats=Ts)
        trim(network=net, throats=~Ts)

        geom = GenericGeometry(network=net, pores=net.Ps, throats=net.Ts)

        geom.add_model(propname='throat.seed',
                       model=mods.geometry.throat_seed.random)
        if psd_params['loc'] is None:
            psd_params['loc'] = spacing[0]/2
        if psd_params['scale'] is None:
            psd_params['scale'] = spacing[0]/10
        if psd_params['distribution'] in ['norm', 'normal', 'gaussian']:
            geom.add_model(propname='throat.size_distribution',
                           seeds='throat.seed',
                           model=mods.geometry.throat_size.normal,
                           loc=psd_params['loc'], scale=psd_params['scale'])
        elif psd_params['distribution'] in ['weibull']:
            geom.add_model(propname='throat.size_distribution',
                           seeds='throat.seed',
                           model=mods.geometry.throat_size.weibull,
                           loc=psd_params['loc'],
                           scale=psd_params['scale'],
                           shape=psd_params['shape'])
github PMEAL / porespy / porespy / networks / __getnet__.py View on Github external
PT2 = sp.sqrt(sp.sum(((p_coords[P12[:, 1]]-t_coords) * voxel_size)**2, axis=1))
    net['throat.total_length'] = PT1 + PT2
    PT1 = PT1-p_dia_local[P12[:, 0]]/2*voxel_size
    PT2 = PT2-p_dia_local[P12[:, 1]]/2*voxel_size
    net['throat.length'] = PT1 + PT2
    dist = (p_coords[P12[:, 0]]-p_coords[P12[:, 1]])*voxel_size
    net['throat.direct_length'] = sp.sqrt(sp.sum(dist**2, axis=1))
    # Make a dummy openpnm network to get the conduit lengths
    pn = op.network.GenericNetwork()
    pn.update(net)
    pn.add_model(propname='throat.endpoints',
                 model=op_gm.throat_endpoints.spherical_pores,
                 pore_diameter='pore.inscribed_diameter',
                 throat_diameter='throat.inscribed_diameter')
    pn.add_model(propname='throat.conduit_lengths',
                 model=op_gm.throat_length.conduit_lengths)
    pn.add_model(propname='pore.area',
                 model=op_gm.pore_area.sphere)
    net['throat.endpoints.head'] = pn['throat.endpoints.head']
    net['throat.endpoints.tail'] = pn['throat.endpoints.tail']
    net['throat.conduit_lengths.pore1'] = pn['throat.conduit_lengths.pore1']
    net['throat.conduit_lengths.pore2'] = pn['throat.conduit_lengths.pore2']
    net['throat.conduit_lengths.throat'] = pn['throat.conduit_lengths.throat']
    net['pore.area'] = pn['pore.area']
    prj = pn.project
    prj.clear()
    wrk = op.Workspace()
    wrk.close_project(prj)

    return net
github PMEAL / OpenPNM / openpnm / materials / BereaCubic.py View on Github external
geom.add_model(propname='pore.seed',
                       model=gm.pore_seed.spatially_correlated,
                       weights=[1, 1, 1])
        geom.add_model(propname='pore.diameter',
                       model=gm.pore_size.weibull,
                       shape=2.2, scale=2e-5, loc=1e-6)
        geom.add_model(propname='pore.volume',
                       model=gm.pore_volume.sphere)
        geom.add_model(propname='throat.length',
                       model=gm.throat_length.piecewise)
        geom.add_model(propname='throat.diameter',
                       model=gm.throat_size.from_neighbor_pores,
                       pore_prop='pore.diameter', mode='min')
        geom.add_model(propname='throat.volume',
                       model=gm.throat_volume.cylinder)

        geom.regenerate_models()
github PMEAL / OpenPNM / openpnm / materials / VoronoiFibers.py View on Github external
def __init__(self, network, **kwargs):
        super().__init__(network=network, **kwargs)
        rm = 'normal'
        net_Ps = network.pores(self.name)
        self['pore.diameter'] = sp.ones(self.Np)*network.fiber_rad*2
        self['pore.indiameter'] = self['pore.diameter']
        self['pore.incenter'] = network['pore.coords'][net_Ps]
        self['pore.centroid'] = network['pore.coords'][net_Ps]
        self._throat_props()
        self.add_model(propname='pore.volume',
                       model=gm.pore_volume.sphere,
                       regen_mode=rm)
        self.add_model(propname='pore.area',
                       model=gm.pore_area.sphere,
                       regen_mode=rm)
        self['throat.diameter'] = sp.ones(self.Nt)*network.fiber_rad*2
        self['throat.indiameter'] = self['throat.diameter']
        self.add_model(propname='throat.endpoints',
                       model=gm.throat_endpoints.spherical_pores,
                       regen_mode=rm)
        self.add_model(propname='throat.area',
                       model=gm.throat_area.cylinder,
                       regen_mode=rm)
        self.add_model(propname='throat.length',
                       model=gm.throat_length.piecewise,
                       regen_mode=rm)
        self['throat.c2c'] = self['throat.length']+network.fiber_rad*2
        self.add_model(propname='throat.volume',
                       model=gm.throat_volume.cylinder,
                       regen_mode=rm)
github PMEAL / OpenPNM / openpnm / geometry / StickAndBall.py View on Github external
self.add_model(propname='pore.volume',
                       model=mods.geometry.pore_volume.sphere,
                       pore_diameter='pore.diameter')

        self.add_model(propname='throat.max_size',
                       model=mods.misc.from_neighbor_pores,
                       mode='min',
                       pore_prop='pore.diameter')

        self.add_model(propname='throat.diameter',
                       model=mods.misc.scaled,
                       factor=0.5,
                       prop='throat.max_size')

        self.add_model(propname='throat.length',
                       model=mods.geometry.throat_length.straight,
                       L_negative=1e-12,
                       pore_diameter='pore.diameter')

        self.add_model(propname='throat.surface_area',
                       model=mods.geometry.throat_surface_area.cylinder,
                       throat_diameter='throat.diameter',
                       throat_length='throat.length')

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

        self.add_model(propname='throat.area',
                       model=mods.geometry.throat_area.cylinder,
                       throat_diameter='throat.diameter')
github PMEAL / OpenPNM / openpnm / geometry / Boundary.py View on Github external
pore_prop='pore.diameter',
                       mode='max')
        self['pore.volume'] = 1e-36
        self['pore.seed'] = 1.0
        self['throat.seed'] = 1.0
        self['throat.volume'] = 1e-36
        self.add_model(propname='throat.length',
                       model=gm.throat_length.straight)
        if shape == 'spheres':
            self.add_model(propname='throat.area',
                           model=gm.throat_area.cylinder)
            self.add_model(propname='throat.surface_area',
                           model=gm.throat_surface_area.cylinder)
        elif shape == 'cubes':
            self.add_model(propname='throat.area',
                           model=gm.throat_area.cuboid)
            self.add_model(propname='throat.surface_area',
                            model=gm.throat_surface_area.cuboid)
github PMEAL / OpenPNM / openpnm / materials / VoronoiFibers.py View on Github external
regen_mode=rm)
        self.add_model(propname='throat.length',
                       model=gm.throat_length.piecewise,
                       regen_mode=rm)
        self['throat.c2c'] = self['throat.length']+network.fiber_rad*2
        self.add_model(propname='throat.volume',
                       model=gm.throat_volume.cylinder,
                       regen_mode=rm)
        self.add_model(propname='throat.perimeter',
                       model=gm.throat_perimeter.cylinder,
                       regen_mode=rm)
        self.add_model(propname='throat.surface_area',
                       model=gm.throat_surface_area.cylinder,
                       regen_mode=rm)
        self.add_model(propname='throat.shape_factor',
                       model=gm.throat_shape_factor.compactness,
                       regen_mode=rm)
        self.add_model(propname='throat.conduit_lengths',
                       model=gm.throat_length.conduit_lengths)
github PMEAL / OpenPNM / openpnm / materials / VoronoiFibers.py View on Github external
model=gm.pore_area.sphere,
                       regen_mode=rm)
        self['throat.diameter'] = sp.ones(self.Nt)*network.fiber_rad*2
        self['throat.indiameter'] = self['throat.diameter']
        self.add_model(propname='throat.endpoints',
                       model=gm.throat_endpoints.spherical_pores,
                       regen_mode=rm)
        self.add_model(propname='throat.area',
                       model=gm.throat_area.cylinder,
                       regen_mode=rm)
        self.add_model(propname='throat.length',
                       model=gm.throat_length.piecewise,
                       regen_mode=rm)
        self['throat.c2c'] = self['throat.length']+network.fiber_rad*2
        self.add_model(propname='throat.volume',
                       model=gm.throat_volume.cylinder,
                       regen_mode=rm)
        self.add_model(propname='throat.perimeter',
                       model=gm.throat_perimeter.cylinder,
                       regen_mode=rm)
        self.add_model(propname='throat.surface_area',
                       model=gm.throat_surface_area.cylinder,
                       regen_mode=rm)
        self.add_model(propname='throat.shape_factor',
                       model=gm.throat_shape_factor.compactness,
                       regen_mode=rm)
        self.add_model(propname='throat.conduit_lengths',
                       model=gm.throat_length.conduit_lengths)