Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
from openpnm.algorithms import ReactiveTransport
from openpnm.utils import logging
logger = logging.getLogger(__name__)
class NernstPlanck(ReactiveTransport):
r"""
A class to simulate transport of charged species (such as ions) in dilute
solutions.
"""
def __init__(self, settings={}, phase=None, ion='', **kwargs):
def_set = {'phase': None,
'quantity': 'pore.concentration.'+ion,
'conductance': 'throat.ad_dif_mig_conductance.'+ion,
'ion': ion}
super().__init__(**kwargs)
# self.name = electrolyte # This interfers with component name
self.settings.update(def_set)
from openpnm.algorithms import TransientReactiveTransport, OhmicConduction
from openpnm.utils import logging
logger = logging.getLogger(__name__)
class TransientOhmicConduction(TransientReactiveTransport, OhmicConduction):
r"""
A subclass of GenericTransport to simulate Ohmic conduction.
"""
def __init__(self, settings={}, phase=None, **kwargs):
def_set = {'phase': None,
'gui': {'setup': {'phase': None,
'quantity': '',
'conductance': '',
't_initial': None,
't_final': None,
't_step': None,
from openpnm.algorithms import TransientReactiveTransport
from openpnm.utils import logging
logger = logging.getLogger(__name__)
class TransientNernstPlanck(TransientReactiveTransport):
r"""
A subclass of GenericTransport to perform steady and transient simulations
of pure diffusion, advection-diffusion and advection-diffusion with
migration.
"""
def __init__(self, settings={}, phase=None, ion='', **kwargs):
def_set = {'phase': None,
'quantity': 'pore.concentration.'+ion,
'conductance': 'throat.ad_dif_mig_conductance.'+ion,
'ion': ion,
'gui': {'setup': {'phase': None,
from openpnm.algorithms import ReactiveTransport
from openpnm.utils import logging
logger = logging.getLogger(__name__)
class OhmicConduction(ReactiveTransport):
r"""
A subclass of GenericLinearTransport to simulate electron and ionic
conduction. The 2 main roles of this subclass are to set the default
property names and to implement a method for calculating the effective
conductivity of the network.
"""
def __init__(self, settings={}, **kwargs):
super().__init__(**kwargs)
self.settings.update({'quantity': 'pore.voltage',
'conductance': 'throat.electrical_conductance'})
self.settings.update(settings)
from openpnm.algorithms import TransientReactiveTransport, StokesFlow
from openpnm.utils import logging
logger = logging.getLogger(__name__)
class TransientStokesFlow(TransientReactiveTransport, StokesFlow):
r"""
A subclass of GenericTransport to simulate Stokes flow.
"""
def __init__(self, settings={}, **kwargs):
super().__init__(**kwargs)
# Apply any received settings to overwrite defaults
self.settings.update(settings)
import numpy as np
from openpnm.algorithms import ReactiveTransport
from openpnm.utils import logging
logger = logging.getLogger(__name__)
class Dispersion(ReactiveTransport):
r"""
A subclass of GenericTransport to simulate advection diffusion
"""
def __init__(self, settings={}, phase=None, **kwargs):
def_set = {'phase': None,
'quantity': 'pore.concentration',
'conductance': 'throat.dispersive_conductance',
'gui': {'setup': {'phase': None,
'quantity': '',
'conductance': ''},
'set_rate_BC': {'pores': None,
from openpnm.phases.mixtures import GenericMixture, species
import openpnm.models as mods
from openpnm.utils import logging
logger = logging.getLogger(__name__)
class HumidAir(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)
H2O = species.liquids.H2O(network=network, name='H2O_'+self.name)
self.settings['components'] = [O2.name, N2.name, H2O.name]
self.set_mole_fraction(component=N2, values=0.791)
self.set_mole_fraction(component=O2, values=0.209)
self.set_mole_fraction(component=H2O, values=0.000)
self.add_model(propname='pore.molar_mass',
import scipy as sp
import scipy.spatial as sptl
import scipy.sparse as sprs
from skimage.filters import rank_order
from openpnm.network import GenericNetwork
from openpnm import topotools
from openpnm.utils import logging
logger = logging.getLogger(__name__)
class DelaunayVoronoiDual(GenericNetwork):
r"""
Combined and interconnected Voronoi and Delaunay tessellations
A Delaunay tessellation is performed on a set of base points then the
corresponding Voronoi diagram is generated. Finally, each Delaunay node
is connected to it's neighboring Voronoi vertices to create interaction
between the two networks.
All pores and throats are labelled according to their network (i.e.
'pore.delaunay'), so they can be each assigned to a different Geometry.
The dual-nature of this network is meant for modeling transport in the void
and solid space simultaneously by treating one network (i.e. Delaunay) as
import scipy as sp
import numpy as np
import matplotlib.pyplot as plt
from scipy.sparse import csgraph as csg
from openpnm.algorithms import GenericAlgorithm
from openpnm.utils import logging
logger = logging.getLogger(__name__)
class Drainage(GenericAlgorithm):
r"""
Simulates a capillary drainage experiment by applying a list of increasing
capillary pressures and invading all throats that are accessible and
invadable at the given pressure.
Parameters
----------
network : OpenPNM Network Object
The network upon which the simulation will be run
name : string (optional)
The name to apply to the Algorithm for quick identification
import json
import os
import pickle
from pathlib import Path
import jsonschema
import scipy as sp
from openpnm.utils import logging
from openpnm.io import GenericIO
from openpnm.models.geometry import (pore_area, pore_volume, throat_area,
throat_perimeter, throat_surface_area,
throat_volume)
from openpnm.network import GenericNetwork
logger = logging.getLogger(__name__)
class JSONGraphFormat(GenericIO):
r"""
Class for reading and writing OpenPNM networks to JSON Graph Format (JGF).
Notes
-----
The JGF standard must contain data formatted according to
http://jsongraphformat.info and enforced by JSON schema validation.
Users must transfer any phase data to the network manually if they wish to
keep it.
"""
@classmethod