Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
r"""
Pore seed models are use to calculate random numbers for each pore, which can
subsequently be used in statistical distributions to calculate actual pore
sizes.
.. autofunction:: openpnm.models.geometry.pore_seed.random
.. autofunction:: openpnm.models.geometry.pore_seed.spatially_correlated
"""
import scipy as _sp
from openpnm.models import misc as _misc
from openpnm.utils import logging as _logging
_logger = _logging.getLogger(__name__)
def random(target, seed=None, num_range=[0, 1]):
return _misc.random(target, element='pore', seed=seed, num_range=num_range)
random.__doc__ = _misc.random.__doc__
def spatially_correlated(target, weights=None, strel=None):
r"""
Generates pore seeds that are spatailly correlated with their neighbors.
Parameters
----------
target : OpenPNM Object
from openpnm.algorithms import TransientReactiveTransport, AdvectionDiffusion
from openpnm.utils import logging
logger = logging.getLogger(__name__)
class TransientAdvectionDiffusion(TransientReactiveTransport,
AdvectionDiffusion):
r"""
A subclass of GenericTransport to perform steady and transient simulations
of pure diffusion and advection diffusion problems.
"""
def __init__(self, settings={}, phase=None, **kwargs):
def_set = {'phase': None,
'gui': {'setup': {'phase': None,
'quantity': '',
'diffusive_conductance': '',
'hydraulic_conductance': '',
import inspect
from networkx import DiGraph, simple_cycles, draw_spectral
from networkx.algorithms.dag import lexicographical_topological_sort
from openpnm.utils import PrintableDict, logging, Workspace
ws = Workspace()
logger = logging.getLogger(__name__)
class ModelsDict(PrintableDict):
r"""
This subclassed dictionary is assigned to the ``models`` attribute of
all objects that inherit from the ``ModelsMixin`` class. Each dictionary
entry corresponds to an entry in the target object's dictionary, and
contains the models and associated parameters for generating the model.
The main features of this subclass are three methods the help resolve the
order in which models should be called: ``dependency_list``,
``dependency_graph``, and ``dependency_map``.
"""
def dependency_list(self):
a model for finding the largest possible sphere that can be placed on each
site.
.. autofunction:: openpnm.models.geometry.pore_size.weibull
.. autofunction:: openpnm.models.geometry.pore_size.normal
.. autofunction:: openpnm.models.geometry.pore_size.random
.. autofunction:: openpnm.models.geometry.pore_size.generic_distribution
.. autofunction:: openpnm.models.geometry.pore_size.largest_sphere
.. autofunction:: openpnm.models.geometry.pore_size.equivalent_diameter
"""
from openpnm.utils import logging as _logging
from openpnm.models import misc as _misc
import numpy as _np
_logger = _logging.getLogger(__name__)
def weibull(target, shape, scale, loc, seeds='pore.seed'):
return _misc.weibull(target=target, shape=shape, scale=scale, loc=loc,
seeds=seeds)
weibull.__doc__ = _misc.weibull.__doc__
def normal(target, scale, loc, seeds='pore.seed'):
return _misc.normal(target=target, scale=scale, loc=loc,
seeds=seeds)
normal.__doc__ = _misc.normal.__doc__
r"""
.. autofunction:: openpnm.models.misc.statistical_distributions.random
.. autofunction:: openpnm.models.misc.statistical_distributions.weibull
.. autofunction:: openpnm.models.misc.statistical_distributions.normal
.. autofunction:: openpnm.models.misc.statistical_distributions.generic_distribution
"""
import numpy as np
import scipy.stats as spts
from openpnm.utils import logging
logger = logging.getLogger(__name__)
def random(target, element, seed=None, num_range=[0, 1]):
r"""
Create an array of random numbers of a specified size.
Parameters
----------
target : OpenPNM Object
The object which this model is associated with. This controls the
length of the calculated array, and also provides access to other
necessary properties.
seed : int
The starting seed value to send to Scipy's random number generator.
The default is None, which means different distribution is returned
from h5py import File as hdfFile
from flatdict import FlatDict
from openpnm.io import Dict, GenericIO
from openpnm.utils import logging
logger = logging.getLogger(__name__)
class HDF5(GenericIO):
r"""
The HDF5 (Hierarchical Data Format) file is good for high-peformance, long
term data storage
"""
@classmethod
def to_hdf5(cls, network=None, phases=[], element=['pore', 'throat'],
filename='', interleave=True, flatten=False, categorize_by=[]):
r"""
Creates an HDF5 file containing data from the specified objects,
and categorized according to the given arguments.
Parameters
import numpy as np
from openpnm.algorithms import ReactiveTransport
from openpnm.utils import logging
logger = logging.getLogger(__name__)
class NonNewtonianStokesFlow(ReactiveTransport):
r"""
A subclass of GenericLinearTransport to simulate viscous flow. The 2
main roles of this subclass are to set the default property names and to
implement a method for calculating the hydraulic permeability of the
network.
"""
def __init__(self, settings={}, phase=None, **kwargs):
def_set = {'phase': None,
'quantity': 'pore.pressure',
'conductance': 'throat.nonNewtonian_hydraulic_conductance',
'tolerance': 1e-5,
from openpnm.algorithms import TransientReactiveTransport, ChargeConservation
from openpnm.utils import logging
logger = logging.getLogger(__name__)
class TransientChargeConservation(TransientReactiveTransport,
ChargeConservation):
r"""
A subclass of GenericTransport to perform steady and transient simulations
of pure diffusion and advection-diffusion problems.
"""
def __init__(self, settings={}, phase=None, **kwargs):
def_set = {'phase': None,
'gui': {'setup': {'phase': None,
'quantity': '',
'conductance': '',
'charge_conservation': '',
from openpnm.phases.mixtures import GenericMixture, species
from openpnm.models.phases.mixtures import mole_weighted_average
import openpnm.models as mods
from openpnm.utils import logging
logger = logging.getLogger(__name__)
class DryAir(GenericMixture):
r"""
"""
def __init__(self, network, **kwargs):
super().__init__(network=network, components=[], **kwargs)
N2 = species.gases.N2(network=network, name='N2_'+self.name)
O2 = species.gases.O2(network=network, name='O2_'+self.name)
self.settings['components'] = [O2.name, N2.name]
self.set_mole_fraction(component=N2, values=0.791)
self.set_mole_fraction(component=O2, values=0.209)
self.add_model(propname='pore.diffusivity.N2',
model=mods.phases.mixtures.fuller_diffusivity)
self.add_model(propname='pore.diffusivity.O2',
import pickle
import time
from openpnm.utils import Workspace, Project
from openpnm.utils import logging
from openpnm.io import GenericIO
logger = logging.getLogger(__name__)
ws = Workspace()
class OpenpnmIO(GenericIO):
r"""
This class contains methods used for saving and loading OpenPNM Workspaces,
Projects, and objects.
Notes
-----
The methods in this class use the ``pickle`` module from the standard
library, which have known security issues. Do not open '.pnm' files
from untrusted sources.
"""