<commit_before>import openpnm as op
import openpnm.models.geometry.throat_volume as mods
import numpy as np
from numpy.testing import assert_approx_equal


class ThroatVolumeTest:
    def setup_class(self):
        self.net = op.network.Cubic(shape=[5, 5, 5], spacing=1.0)
        self.geo = op.geometry.GenericGeometry(network=self.net,
                                               pores=self.net.Ps,
                                               throats=self.net.Ts)
        self.air = op.phases.Air(network=self.net)
        self.phys = op.physics.GenericPhysics(network=self.net,
                                              phase=self.air,
                                              geometry=self.geo)
        self.geo['throat.diameter'] = 0.1
        self.geo['throat.length'] = 1.0
        self.geo['throat.area'] = 0.03

    def test_cylinder(self):
        self.geo.add_model(propname='throat.volume',
                           model=mods.cylinder,
                           regen_mode='normal')
        a = np.array([0.007853981])
        b = np.unique(self.geo['throat.volume'])
        assert_approx_equal(a, b)

    def test_cube(self):
        self.geo.add_model(propname='throat.volume',
                           model=mods.cuboid)
        a = np.array([0.01])
        b = np.unique(self.geo['throat.volume'])
        assert_approx_equal(a, b)

    def test_rectangle(self):
        self.geo.add_model(propname='throat.volume',
                           model=mods.rectangle)
        a = np.array([0.1])
        b = np.unique(self.geo['throat.volume'])
        assert_approx_equal(a, b)

    def test_extrusion(self):
        self.geo.add_model(propname='throat.volume',<commit_msg>Added unit tests for both lens and pendular_ring model<commit_after>import openpnm as op
import openpnm.models.geometry.throat_volume as mods
import numpy as np
from numpy.testing import assert_approx_equal


class ThroatVolumeTest:
    def setup_class(self):
        self.net = op.network.Cubic(shape=[5, 5, 5], spacing=1.0)
        self.geo = op.geometry.GenericGeometry(network=self.net,
                                               pores=self.net.Ps,
                                               throats=self.net.Ts)
        self.air = op.phases.Air(network=self.net)
        self.phys = op.physics.GenericPhysics(network=self.net,
                                              phase=self.air,
                                              geometry=self.geo)
        self.geo['throat.diameter'] = 0.1
        self.geo['throat.length'] = 1.0
        self.geo['throat.area'] = 0.03

    def test_lens_and_pendular_ring(self):
        net = op.network.Cubic(shape=[2, 1, 1])
        net['pore.diameter'] = 0.5
        net['throat.diameter'] = 0.25
        mod = op.models.geometry.throat_volume.lens
        net.add_model(propname='throat.lens_volume',
                      model=mod)
        Vlens = net['throat.lens_volume']
        assert Vlens == 2*(0.006733852203712552)
        mod = op.models.geometry.throat_volume.pendular_ring
        net.add_model(propname='throat.ring_volume',
                      model=mod)
        Vcyl = 2*(0.01315292522620208)
        Vring = net['throat.ring_volume']
        assert (Vcyl - Vring) == 2*(0.006733852203712552)

    def test_cylinder(self):
        self.geo.add_model(propname='throat.volume',
                           model=mods.cylinder,
                           regen_mode='normal')
        a = np.array([0.007853981])
        b = np.unique(self.geo['throat.volume'])
        assert_approx_equal(a, b)

    def test_cube(self):
        self.geo.add_model(propname='throat.volume',
                           model=mods.cuboid)
        a = np.array([0.01])
        b = np.unique(self.geo['throat.volume'])
        assert_approx_equal(a, b)

    def test_rectangle(self):
        self.geo.add_model(propname='throat.volume',
                           model=mods.rectangle)
        a = np.array([0.1])
        b = np.unique(self.geo['throat.volume'])
        assert_approx_equal(a, b)

    def test_extrusion(self):
        self.geo.add_model(propname='throat.volume',
{'fraction_non_alphanumeric': 0.11959410485624547, 'fraction_numerical': 0.02923411452041556, 'mean_word_length': 1.789757412398922, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2359487', 'n_tokens_mistral': 1400, 'n_tokens_neox': 1278, 'n_words': 188}