Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
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()
sw = mixtures.SalineWater(network=net)
# Retrieve handles to each species for use below
Cl, Na, H2O = sw.components.values()
# physics
phys = op.physics.GenericPhysics(network=net, phase=sw, 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',
model=flow, regen_mode='normal')
current = op.models.physics.ionic_conductance.electroneutrality
phys.add_model(propname='throat.ionic_conductance', ions=[Na.name, Cl.name],
model=current, regen_mode='normal')
eA_dif = op.models.physics.diffusive_conductance.ordinary_diffusion
phys.add_model(propname='throat.diffusive_conductance.' + Na.name,
pore_diffusivity='pore.diffusivity.' + Na.name,
throat_diffusivity='throat.diffusivity.' + Na.name,
model=eA_dif, regen_mode='normal')
def __init__(self, network=None, project=None, settings={}, name=None,
**kwargs):
if project is None:
project = network.project
hg = Mercury(network=network)
super().__init__(network=network, project=project, **kwargs)
op = Porosimetry(project=project, phase=hg)
self.settings['mip'] = op.name
mod = models.physics.capillary_pressure.washburn
for geom in project.geometries().values():
phys = GenericPhysics(network=network, phase=hg, geometry=geom)
phys.add_model(propname='throat.entry_pressure', model=mod)
if not project.geometries():
hg.add_model(propname='throat.entry_pressure', model=mod)
topotools.find_surface_pores(network=network)
op.set_inlets(pores=network.pores('surface'))
logger.info('Running MIP simulation')
op.run()
self.update(op)
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']
phys.add_model(propname='throat.late_filling',
model=op.models.physics.multiphase.late_filling,
pressure='throat.pressure',
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)
fd.set_value_BC(pores=net.pores('back'), values=0.1)
fd.setup(t_final=100, t_output=10, t_step=0.5)
fd.run()
phase.update(fd.results())
# output results to a vtk file
def _new_object(self, objtype, name=None):
r"""
"""
if objtype.startswith('net'):
obj = openpnm.network.GenericNetwork(project=self, name=name)
elif objtype.startswith('geo'):
obj = openpnm.geometry.GenericGeometry(project=self, name=name,
pores=[], throats=[])
elif objtype.startswith('pha'):
obj = openpnm.phases.GenericPhase(project=self, name=name)
elif objtype.startswith('phy'):
obj = openpnm.physics.GenericPhysics(project=self, name=name)
elif objtype.startswith('alg'):
obj = openpnm.algorithm.GenericAlgorithm(project=self, name=name)
else:
obj = openpnm.core.Base(project=self, name=name)
return obj