How to use the openpnm.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 / OpenPNM / tests / unit / models / physics / GenericSourceTerm.py View on Github external
def setup_class(self):
        self.net = op.network.Cubic(shape=[5, 5, 5])
        Ps = self.net.Ps
        Ts = self.net.Ts
        self.geo = op.geometry.GenericGeometry(network=self.net, pores=Ps,
                                               throats=Ts)
        self.phase = op.phases.GenericPhase(network=self.net)
        self.phys = op.physics.GenericPhysics(network=self.net,
                                              phase=self.phase,
                                              geometry=self.geo)
        self.phys['throat.diffusive_conductance'] = 5e-8
        self.phase['pore.mole_fraction'] = 0.0
        self.BC_pores = np.arange(20, 30)
        self.source_pores = np.arange(55, 85)
github PMEAL / OpenPNM / test_mp.py View on Github external
cap_model = 'sinusoidal'
fiber_rad = 5e-5
snap_off = False
partial = False
coop_fill = False
trapping = False
lpf = False

sp.random.seed(0)
pn = op.network.Cubic(shape=[5, 5, 5], spacing=3e-4, name='pn11')
pn.add_boundary_pores()
proj = pn.project

Ps = pn.pores()
Ts = pn.throats()
geom = op.geometry.StickAndBall(network=pn, pores=Ps, throats=Ts,
                                name='intern')
geom.add_model(propname='throat.normal', model=gm.throat_normal.pore_coords,
               regen_mode='normal')
air = op.phases.Air(network=pn)
water = op.phases.Water(network=pn)
water['throat.viscosity'] = water['pore.viscosity'][0]

mod = op.models.physics.hydraulic_conductance.hagen_poiseuille
phys_air = op.physics.GenericPhysics(network=pn, phase=air,
                                     geometry=geom)
phys_water = op.physics.GenericPhysics(network=pn, phase=water,
                                       geometry=geom)
phys_water.add_model(propname='throat.conductance',
                     model=mod,
                     viscosity='throat.viscosity')
github PMEAL / OpenPNM / example_script_OP.py View on Github external
import openpnm as op
ws = op.Workspace()
proj = ws.new_project()
pn = op.network.Cubic(shape=[10, 10, 10], project=proj, spacing=1e-4)
geom = op.geometry.StickAndBall(network=pn, pores=pn.Ps, throats=pn.Ts)
geom['pore.volume'][pn.pores('left')] = 0
hg = op.phases.Mercury(network=pn)
phys = op.physics.GenericPhysics(network=pn, phase=hg, geometry=geom)
phys.add_model(propname='throat.entry_pressure',
               model=op.models.physics.capillary_pressure.washburn)
phys.add_model(propname='pore.pc_star',
               model=op.models.misc.from_neighbor_throats,
               throat_prop='throat.entry_pressure',
               mode='min')
phys.add_model(propname='pore.late_filling',
               model=op.models.physics.multiphase.late_filling,
               pressure='pore.pressure',
               Pc_star='pore.pc_star',
               eta=1, Swp_star=0.4,
               regen_mode='deferred')
phys['throat.pc_star'] = phys['throat.entry_pressure']
github PMEAL / OpenPNM / docs / pyplots / getting_started_mip_curve.py View on Github external
import numpy as np
import openpnm as op
pn = op.network.Cubic(shape=[10, 10, 10], spacing=0.0001)
Ps = pn.pores('all')
Ts = pn.throats('all')
geo = op.geometry.StickAndBall(network=pn, pores=Ps, throats=Ts)
hg = op.phases.Mercury(network=pn)
h2o = op.phases.Water(network=pn)
phys1 = op.physics.GenericPhysics(network=pn, phase=hg, geometry=geo)
phys2 = op.physics.GenericPhysics(network=pn, phase=h2o, geometry=geo)
model = op.models.physics.capillary_pressure.washburn
hg.add_model(propname='throat.entry_pressure',
             model=model,
             contact_angle='pore.contact_angle',
             surface_tension='pore.surface_tension')
model = op.models.physics.hydraulic_conductance.hagen_poiseuille
h2o.add_model(propname='throat.hydraulic_conductance',
              model=model,
              throat_viscosity='throat.viscosity',
              pore_diameter='pore.diameter',
              throat_length='throat.length',
              throat_diameter='throat.area')
github PMEAL / OpenPNM / example_transientAD.py View on Github external
proj = ws.new_project()
# ws.settings['loglevel'] = 20


# network, geometry, phase
np.random.seed(0)

net = op.network.Cubic(shape=[8, 8, 1], spacing=9e-4, project=proj)
prs = (net['pore.back'] * net['pore.right'] + net['pore.back'] *
       net['pore.left'] + net['pore.front'] * net['pore.right'] +
       net['pore.front'] * net['pore.left'])
thrts = net['throat.surface']
op.topotools.trim(network=net, pores=net.Ps[prs], throats=net.Ts[thrts])


geo = op.geometry.StickAndBall(network=net, pores=net.Ps, throats=net.Ts)
pore_d = op.models.misc.constant
throat_d = op.models.misc.constant
geo.add_model(propname='pore.diameter', model=pore_d, value=1.5e-4)
geo.add_model(propname='throat.diameter', model=throat_d, value=1e-4)
geo.regenerate_models()

water = op.phases.Water(network=net)


# physics
phys = op.physics.GenericPhysics(network=net, phase=water, geometry=geo)

flow = op.models.physics.hydraulic_conductance.hagen_poiseuille
phys.add_model(propname='throat.hydraulic_conductance',
               pore_viscosity='pore.viscosity',
               throat_viscosity='throat.viscosity',
github PMEAL / OpenPNM / example_script_3.py View on Github external
import openpnm as op
import scipy as sp
ws = op.core.Workspace()
ws.settings['local_data'] = True

sp.random.seed(0)
pn = op.network.Cubic(shape=[15, 15, 15], spacing=0.0001, name='pn11')
pn.add_boundary_pores()

geom = op.geometry.StickAndBall(network=pn, pores=pn.Ps, throats=pn.Ts,
                                settings={'test': 1})

water = op.phases.Water(network=pn)
water['throat.viscosity'] = water['pore.viscosity'][0]

phys_water = op.physics.GenericPhysics(network=pn, phase=water, geometry=geom)
mod = op.physics.models.hydraulic_conductance.hagen_poiseuille
phys_water.add_model(propname='throat.conductance',
                     model=mod, viscosity='throat.viscosity')
phys_water.regenerate_models()

alg = op.algorithms.FickianDiffusion(network=pn, phase=water)
alg.setup(conductance='throat.conductance', quantity='pore.mole_fraction')
alg.set_BC(pores=pn.pores('top'), bctype='dirichlet', bcvalues=0.5)
alg.set_BC(pores=pn.pores('bottom'), bctype='dirichlet', bcvalues=0.0)
alg['pore.mole_fraction'] = 0
github PMEAL / OpenPNM / example_script_two_subdomains.py View on Github external
import pytest
import openpnm as op
ws = op.Workspace()
proj = ws.new_project()

pn = op.network.Cubic(shape=[10, 10, 10], spacing=1e-4, project=proj)
Ps = pn['pore.coords'][:, 0] < pn['pore.coords'][:, 0].mean()
Ts = pn.find_neighbor_throats(pores=Ps, mode='xnor')
geo1 = op.geometry.StickAndBall(network=pn, pores=Ps, throats=Ts)

Ps = pn['pore.coords'][:, 0] >= pn['pore.coords'][:, 0].mean()
Ts = pn.find_neighbor_throats(pores=Ps, mode='or')
geo2 = op.geometry.StickAndBall(network=pn, pores=Ps, throats=Ts)

pn['pore.foo'] = 1
# Can't create a subdict below foo
with pytest.raises(Exception):
    pn['pore.foo.bar'] = 1
# Can create a subdict directly
pn['pore.baz.bar'] = 2
# Can't create a new item already used as subdict
with pytest.raises(Exception):
    pn['pore.baz'] = 2

# Also works on subdomains
github PMEAL / OpenPNM / example_transient_Fickian_diffusion.py View on Github external
import openpnm as op
import numpy as np

# work space and project
ws = op.Workspace()
ws.settings["loglevel"] = 30
proj = ws.new_project()

# network
np.random.seed(7)
net = op.network.Cubic(shape=[51, 19, 1], spacing=1e-4, project=proj)

# geometry
geo = op.geometry.StickAndBall(network=net, pores=net.Ps, throats=net.Ts)

# phase
phase = op.phases.Water(network=net)

# physics
phys = op.physics.GenericPhysics(network=net, phase=phase, geometry=geo)
phase['pore.diffusivity'] = 2e-09
phase['throat.diffusivity'] = 2e-09

mod = op.models.physics.diffusive_conductance.ordinary_diffusion
phys.add_model(propname='throat.diffusive_conductance',
               model=mod, regen_mode='normal')

# algorithms: Fickian diffusion
fd = op.algorithms.TransientFickianDiffusion(network=net, phase=phase)
fd.set_value_BC(pores=net.pores('front'), values=0.5)
github PMEAL / OpenPNM / example_transient_Fickian_diffusion.py View on Github external
import openpnm as op
import scipy as sp

ws = op.core.Workspace()
ws.settings['local_data'] = True

# NETWORK
sp.random.seed(17)
nx, ny, nz = 30, 60, 1
pn = op.network.Cubic(shape=[nx, ny, nz], spacing=1e-4, name='pn11')

# GEOMETRIES
geom = op.geometry.StickAndBall(network=pn, pores=pn.Ps, throats=pn.Ts)

# PHASES
water = op.phases.Water(network=pn)

# PHYSICS
phys_water = op.physics.GenericPhysics(network=pn, phase=water, geometry=geom)

water['throat.viscosity'] = water['pore.viscosity'][0]
mod = op.models.physics.hydraulic_conductance.hagen_poiseuille
phys_water.add_model(propname='throat.hydraulic_conductance',
                     model=mod, viscosity='throat.viscosity')

geom['pore.area'] = sp.pi*(geom['pore.diameter']**2)/4.0
mod2 = op.models.physics.diffusive_conductance.bulk_diffusion
phys_water.add_model(propname='throat.diffusive_conductance',
                     model=mod2, diffusivity='pore.diffusivity')