How to use the openpnm.algorithms.ReactiveTransport 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 test_natural_exponential(self):
        self.phys['pore.item1'] = 0.8e-11
        self.phys['pore.item2'] = 0.5
        self.phys['pore.item3'] = 2
        self.phys['pore.item4'] = -0.34
        self.phys['pore.item5'] = 2e-14
        self.phys.add_model(propname='pore.source1',
                            model=pm.generic_source_term.natural_exponential,
                            A1='pore.item1',
                            A2='pore.item2',
                            A3='pore.item3',
                            A4='pore.item4',
                            A5='pore.item5',
                            quantity='pore.mole_fraction',
                            regen_mode='normal')
        self.alg = op.algorithms.ReactiveTransport(network=self.net,
                                                   phase=self.phase)
        self.alg.set_dirichlet_BC(values=0.4, pores=self.BC_pores)
        self.alg.set_source(propname='pore.source1',
                            pores=self.source_pores)
        self.alg.settings.update({'conductance': 'throat.diffusive_conductance',
                                  'quantity': 'pore.mole_fraction'})
        self.alg.run()
        self.phase.update(self.alg.results())
        self.phys.regenerate_models(propnames='pore.source1')
        X = self.phase['pore.mole_fraction']
        r1 = np.round(np.sum(0.8e-11 * np.exp(0.5 * X[self.source_pores]**2 -
                      0.34) + 2e-14), 20)
        r2 = np.round(np.sum(self.phys['pore.source1.rate'][self.source_pores]), 20)
#        r3 = np.round(self.alg.rate(pores=self.S_pores)[0], 20)
        assert r1 == r2
#        assert r2 == -r3
github PMEAL / OpenPNM / tests / unit / models / physics / GenericSourceTerm.py View on Github external
def test_linear(self):
        self.phys['pore.item1'] = 0.5e-11
        self.phys['pore.item2'] = 1.5e-12
        self.phys.add_model(propname='pore.source1',
                            model=pm.generic_source_term.linear,
                            A1='pore.item1',
                            A2='pore.item2',
                            quantity='pore.mole_fraction',
                            regen_mode='normal')
        self.alg = op.algorithms.ReactiveTransport(network=self.net,
                                                   phase=self.phase)
        self.alg.settings.update({'conductance': 'throat.diffusive_conductance',
                                  'quantity': 'pore.mole_fraction'})
        self.alg.set_dirichlet_BC(values=0.4, pores=self.BC_pores)
        self.alg.set_source(propname='pore.source1',
                            pores=self.source_pores)
        self.alg.run()
        self.phase.update(self.alg.results())
        self.phys.regenerate_models(propnames='pore.source1')
        X = self.phase['pore.mole_fraction']
        r1 = np.round(np.sum(0.5e-11 * X[self.source_pores] + 1.5e-12), 20)
        r2 = np.round(np.sum(self.phys['pore.source1.rate'][self.source_pores]), 20)
#        r3 = np.round(self.alg.rate(pores=self.S_pores)[0], 20)
        assert r1 == r2
#        assert r2 == -r3
github PMEAL / OpenPNM / tests / unit / models / physics / GenericSourceTerm.py View on Github external
self.phys['pore.item2'] = 10
        self.phys['pore.item3'] = 4
        self.phys['pore.item4'] = 1.4
        self.phys['pore.item5'] = 0.133
        self.phys['pore.item6'] = -5.1e-13
        self.phys.add_model(propname='pore.source1',
                            model=pm.generic_source_term.logarithm,
                            A1='pore.item1',
                            A2='pore.item2',
                            A3='pore.item3',
                            A4='pore.item4',
                            A5='pore.item5',
                            A6='pore.item6',
                            quantity='pore.mole_fraction',
                            regen_mode='normal')
        self.alg = op.algorithms.ReactiveTransport(network=self.net,
                                                   phase=self.phase)
        self.alg.set_dirichlet_BC(values=0.4, pores=self.BC_pores)
        self.alg.set_source(propname='pore.source1',
                            pores=self.source_pores)
        self.alg.settings.update({'conductance': 'throat.diffusive_conductance',
                                  'quantity': 'pore.mole_fraction'})
        self.alg.run()
        self.phase.update(self.alg.results())
        self.phys.regenerate_models(propnames='pore.source1')
        X = self.phase['pore.mole_fraction']
        r1 = np.round(np.sum(0.16e-13*np.log(4*X[self.source_pores]**(1.4) +
                             0.133) / np.log(10) - 5.1e-13), 20)
        r2 = np.round(np.sum(self.phys['pore.source1.rate'][self.source_pores]), 20)
#        r3 = np.round(self.alg.rate(pores=self.S_pores)[0], 20)
        assert r1 == r2
#        assert r2 == -r3
github PMEAL / OpenPNM / tests / unit / models / physics / GenericSourceTerm.py View on Github external
self.phys['pore.item2'] = 3
        self.phys['pore.item3'] = 0.5
        self.phys['pore.item4'] = 2
        self.phys['pore.item5'] = -0.34
        self.phys['pore.item6'] = 2e-14
        self.phys.add_model(propname='pore.source1',
                            model=pm.generic_source_term.exponential,
                            A1='pore.item1',
                            A2='pore.item2',
                            A3='pore.item3',
                            A4='pore.item4',
                            A5='pore.item5',
                            A6='pore.item6',
                            quantity='pore.mole_fraction',
                            regen_mode='normal')
        self.alg = op.algorithms.ReactiveTransport(network=self.net,
                                                   phase=self.phase)
        self.alg.set_dirichlet_BC(values=0.4, pores=self.BC_pores)
        self.alg.set_source(propname='pore.source1',
                            pores=self.source_pores)
        self.alg.settings.update({'conductance': 'throat.diffusive_conductance',
                                  'quantity': 'pore.mole_fraction'})
        self.alg.run()
        self.phase.update(self.alg.results())
        self.phys.regenerate_models(propnames='pore.source1')
        X = self.phase['pore.mole_fraction']
        r1 = np.round(np.sum(0.8e-11 * 3 ** (0.5 * X[self.source_pores]**2 -
                      0.34) + 2e-14), 20)
        r2 = np.round(np.sum(self.phys['pore.source1.rate'][self.source_pores]), 20)
#        r3 = np.round(self.alg.rate(pores=self.S_pores)[0], 20)
        assert r1 == r2
#        assert r2 == -r3
github PMEAL / OpenPNM / tests / unit / models / physics / GenericSourceTerm.py View on Github external
def test_power_law(self):
        self.phys['pore.item1'] = 0.5e-12
        self.phys['pore.item2'] = 2.5
        self.phys['pore.item3'] = -1.4e-11
        self.phys.add_model(propname='pore.source1',
                            model=pm.generic_source_term.power_law,
                            A1='pore.item1',
                            A2='pore.item2',
                            A3='pore.item3',
                            quantity='pore.mole_fraction',
                            regen_mode='normal')
        self.alg = op.algorithms.ReactiveTransport(network=self.net,
                                                   phase=self.phase)
        self.alg.set_dirichlet_BC(values=0.4, pores=self.BC_pores)
        self.alg.set_source(propname='pore.source1',
                            pores=self.source_pores)
        self.alg.settings.update({'conductance': 'throat.diffusive_conductance',
                                  'quantity': 'pore.mole_fraction'})
        self.alg.run()
        self.phase.update(self.alg.results())
        self.phys.regenerate_models(propnames='pore.source1')
        X = self.phase['pore.mole_fraction']
        r1 = np.sum(0.5e-12 * X[self.source_pores]**2.5 - 1.4e-11)
        r2 = np.sum(self.phys['pore.source1.rate'][self.source_pores])
#        r3 = np.round(self.alg.rate(pores=self.S_pores)[0], 20)
        assert r1 == r2
#        assert r2 == -r3
github PMEAL / OpenPNM / tests / unit / models / physics / GenericSourceTerm.py View on Github external
self.phys['pore.item2'] = 3
        self.phys['pore.item3'] = 0.5
        self.phys['pore.item4'] = 2
        self.phys['pore.item5'] = -0.34
        self.phys['pore.item6'] = 2e-14
        self.phys.add_model(propname='pore.source1',
                            model=pm.generic_source_term.exponential,
                            A1='pore.item1',
                            A2='pore.item2',
                            A3='pore.item3',
                            A4='pore.item4',
                            A5='pore.item5',
                            A6='pore.item6',
                            quantity='pore.mole_fraction',
                            regen_mode='normal')
        self.alg = op.algorithms.ReactiveTransport(network=self.net,
                                                   phase=self.phase)
        self.alg.set_dirichlet_BC(values=0.4, pores=self.BC_pores)
        self.alg.set_source(propname='pore.source1',
                            pores=self.source_pores)
        self.alg.settings.update({'conductance': 'throat.diffusive_conductance',
                                  'quantity': 'pore.mole_fraction'})
        self.alg.run()
        self.phase.update(self.alg.results())
        self.phys.regenerate_models(propnames='pore.source1')
        X = self.phase['pore.mole_fraction']
        r1 = np.round(np.sum(0.8e-11 * 3 ** (0.5 * X[self.source_pores]**2 -
                      0.34) + 2e-14), 20)
        r2 = np.round(np.sum(self.phys['pore.source1.rate'][self.source_pores]), 20)
#        r3 = np.round(self.alg.rate(pores=self.S_pores)[0], 20)
        assert r1 == r2
#        assert r2 == -r3
github PMEAL / OpenPNM / tests / unit / models / physics / GenericSourceTerm.py View on Github external
def test_natural_logarithm(self):
        self.phys['pore.item1'] = 0.16e-14
        self.phys['pore.item2'] = 4
        self.phys['pore.item3'] = 1.4
        self.phys['pore.item4'] = 0.133
        self.phys['pore.item5'] = -5.1e-14
        self.phys.add_model(propname='pore.source1',
                            model=pm.generic_source_term.natural_logarithm,
                            A1='pore.item1',
                            A2='pore.item2',
                            A3='pore.item3',
                            A4='pore.item4',
                            A5='pore.item5',
                            quantity='pore.mole_fraction',
                            regen_mode='on_demand')
        self.alg = op.algorithms.ReactiveTransport(network=self.net,
                                                   phase=self.phase)
        self.alg.set_dirichlet_BC(values=0.4, pores=self.BC_pores)
        self.alg.set_source(propname='pore.source1',
                            pores=self.source_pores)
        self.alg.settings.update({'conductance': 'throat.diffusive_conductance',
                                  'quantity': 'pore.mole_fraction'})
        self.alg.run()
        self.phase.update(self.alg.results())
        self.phys.regenerate_models(propnames='pore.source1')
        X = self.phase['pore.mole_fraction']
        r1 = np.round(np.sum(0.16e-14*np.log(4*X[self.source_pores]**(1.4) +
                             0.133) - 5.1e-14), 20)
        r2 = np.round(np.sum(self.phys['pore.source1.rate'][self.source_pores]), 20)
#        r3 = np.round(self.alg.rate(pores=self.S_pores)[0], 20)
        assert r1 == r2
#        assert r2 == -r3
github PMEAL / OpenPNM / openpnm / algorithms / OhmicConduction.py View on Github external
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)

    def setup(self, phase=None, quantity='', conductance='', **kwargs):
        r"""
github PMEAL / OpenPNM / example_NP.py View on Github external
phys.regenerate_models()

eB_dif = op.models.physics.diffusive_conductance.ordinary_diffusion
phys.add_model(propname='throat.diffusive_conductance.Cl',
               pore_diffusivity='pore.diffusivity.Cl',
               throat_diffusivity='throat.diffusivity.Cl',
               model=eB_dif, regen_mode='normal')
phys.regenerate_models()

# algorithms
sf = op.algorithms.ReactiveTransport(network=net, phase=sw)
sf.set_value_BC(pores=net.pores('back'), values=20)
sf.set_value_BC(pores=net.pores('front'), values=1.00)
sf.settings['rxn_tolerance'] = 1e-12

p = op.algorithms.ReactiveTransport(network=net, phase=sw)
p.set_value_BC(pores=net.pores('left'), values=0.01)
p.set_value_BC(pores=net.pores('right'), values=0.0)
p.settings['rxn_tolerance'] = 1e-12
p.settings['relaxation_quantity'] = 1

eA = op.algorithms.ReactiveTransport(network=net, phase=sw, name='Na')
eA.set_value_BC(pores=net.pores('back'), values=300)
eA.set_value_BC(pores=net.pores('front'), values=100)
eA.settings['rxn_tolerance'] = 1e-12
eA.settings['relaxation_quantity'] = 1

eB = op.algorithms.ReactiveTransport(network=net, phase=sw, name='Cl')
eB.set_value_BC(pores=net.pores('back'), values=300)
eB.set_value_BC(pores=net.pores('front'), values=100)
eB.settings['rxn_tolerance'] = 1e-12
eB.settings['relaxation_quantity'] = 1