Esempio n. 1
0
    def test_descending_particle_number(self):
        """testing if the particle number thing works in this class too
        in the descending manner; it should be correctly inherited from
        the parent class 'Particle'
        """

        particle1 = base_classes.Kaolinite(
            x=0,
            y=0,
            length=5000,
            thickness=2,
            inclination=np.math.pi / 4,
        )
        particle2 = base_classes.Kaolinite(
            x=10,
            y=10,
            length=5000,
            thickness=2,
            inclination=np.math.pi / 4,
        )
        del particle2
        self.assertEqual(particle1.num + 1, base_classes.Kaolinite.last_num)
        particle3 = base_classes.Kaolinite(
            x=10,
            y=10,
            length=5000,
            thickness=2,
            inclination=np.math.pi / 4,
        )
        self.assertEqual(particle1.num + 1, particle3.num)
Esempio n. 2
0
    def test_move(self):
        """testing if the Montmorillonite instance moves correctly with
        the given derivatives; this is inherited from the parent class
        'Particle'
        """

        particle = base_classes.Kaolinite(
            x=0,
            y=0,
            inclination=np.math.pi / 4,
            thickness=2,
            length=6000 * np.sqrt(2),
        )
        particle.move(delta_x=1000, delta_y=1000, delta_theta=np.math.pi / 4)
        self.assertEqual(particle.x, 1000)
        self.assertEqual(particle.y, 1000)
        self.assertEqual(particle.inclination, np.math.pi / 2)
        self.assertEqual(particle.midpoint, shapes.Point(1000, 1000))
        self.assertEqual(
            particle.midline,
            shapes.LineSegment(shapes.Point(1000, 1000 + 3000 * np.sqrt(2)),
                               shapes.Point(1000, 1000 - 3000 * np.sqrt(2))))
        v1 = shapes.Point(1001, 1000 + 3000 * np.sqrt(2))
        v2 = shapes.Point(999, 1000 + 3000 * np.sqrt(2))
        v3 = shapes.Point(999, 1000 - 3000 * np.sqrt(2))
        v4 = shapes.Point(1001, 1000 - 3000 * np.sqrt(2))
        self.assertEqual(particle.shape, shapes.Rectangle(v1, v2, v3, v4))
Esempio n. 3
0
    def test_segmentalize(self):
        """testing if the 'segments' attribute of the Montmorillonite
        instance is created correctly using the 'segmentalize' method
        of the parent class 'Clay'; it should generate three segments
        which all have the same 'num' attribute and are all instances
        of 'Montmorillonite' class; also testing if the next created
        particle comes with a correct 'num' attribute regardless of its
        type
        """

        particle = base_classes.Kaolinite(
            x=0,
            y=0,
            inclination=np.math.pi / 4,
            thickness=1,
            length=6000 * np.sqrt(2),
        )
        self.assertEqual(len(particle.segments), 3)
        for seg in particle.segments:
            self.assertTrue(seg.is_segment)
        self.assertEqual(particle.segments[1].midpoint, shapes.Point(0, 0))
        self.assertAlmostEqual(particle.segments[0].length, 2000 * np.sqrt(2))
        self.assertEqual(
            particle.segments[2].midline,
            shapes.LineSegment(shapes.Point(1000, 1000),
                               shapes.Point(3000, 3000)))
Esempio n. 4
0
    def test_equality_condition(self):
        """testing if the equality condition works here to; it is
        inherited from the parent class 'Particle'
        """

        particle1 = base_classes.Kaolinite(
            x=0,
            y=0,
            length=5000,
            thickness=2,
            inclination=np.math.pi / 4,
        )
        particle2 = base_classes.Kaolinite(
            x=0,
            y=0,
            length=5000,
            thickness=2,
            inclination=np.math.pi / 4,
        )
        self.assertNotEqual(particle1, particle2)
Esempio n. 5
0
    def test_standardizing_inclination(self):
        """testing if a non-standard given inclination becomes standard
        """

        particle = base_classes.Kaolinite(
            x=501,
            y=74,
            inclination=-3 * np.math.pi / 4,
            thickness=1,
            length=10000,
        )
        self.assertEqual(particle.inclination, np.math.pi / 4)
Esempio n. 6
0
    def test_midpoint(self):
        """testing if the midpoint attribute of the Montmorillonite
        instance is created correctly
        """

        particle = base_classes.Kaolinite(
            x=500,
            y=70,
            inclination=-3 * np.math.pi / 4,
            thickness=2,
            length=10000,
        )
        self.assertEqual(particle.midpoint, shapes.Point(500, 70))
Esempio n. 7
0
    def test_mass(self):
        """testing if the Montmorillonite instance returns a correct
        mass; this is inherited from the parent class 'Particle'
        """

        particle = base_classes.Kaolinite(
            x=0,
            y=0,
            inclination=np.math.pi / 4,
            thickness=2,
            length=6000 * np.sqrt(2),
        )
        exp = base_classes.Kaolinite.density * 2 * 6000 * np.sqrt(2)
        self.assertAlmostEqual(particle.mass, exp)
Esempio n. 8
0
    def test_box_num(self):
        """testing if the box_number method works here too; it is
        inherited from the parent class 'Particle'
        """

        particle = base_classes.Kaolinite(
            x=6023,
            y=5634,
            length=5000,
            thickness=2,
            inclination=np.math.pi / 4,
        )
        bn = particle.box_num(nc=100, box_length=10, box_width=10)
        self.assertEqual(bn, 56902)
Esempio n. 9
0
    def test_hashable(self):
        """testing if the particle being hashable works here too; it is
        inherited from the parent class 'Particle'
        """

        particle = base_classes.Kaolinite(
            x=0,
            y=0,
            length=5000,
            thickness=2,
            inclination=np.math.pi / 4,
        )
        s = {particle}
        self.assertTrue(s)
Esempio n. 10
0
    def test_midline(self):
        """testing if the midline attribute of the Montmorillonite
        instance is created correctly
        """

        particle = base_classes.Kaolinite(
            x=500,
            y=70,
            inclination=-3 * np.math.pi / 4,
            thickness=2,
            length=10000,
        )
        end1 = shapes.Point(500 - 2500 * np.sqrt(2), 70 - 2500 * np.sqrt(2))
        end2 = shapes.Point(500 + 2500 * np.sqrt(2), 70 + 2500 * np.sqrt(2))
        exp = shapes.LineSegment(end1, end2)
        self.assertEqual(particle.midline, exp)
Esempio n. 11
0
    def test_shape(self):
        """testing if the 'shape' attribute of the Montmorillonite
        instance is created correctly
        """

        particle = base_classes.Kaolinite(
            x=100,
            y=100,
            inclination=np.math.pi / 2,
            thickness=2,
            length=10000,
        )
        v1 = shapes.Point(101, 5100)
        v2 = shapes.Point(99, 5100)
        v3 = shapes.Point(99, -4900)
        v4 = shapes.Point(101, -4900)
        exp = shapes.Rectangle(v1, v2, v3, v4)
        self.assertEqual(particle.shape, exp)
Esempio n. 12
0
    def test_attribute_assigning(self):
        """testing if all the attributes that a Montmorillonite instance
        should contain are present here; this also includes all the
        attributes and properties of the parent classes 'Particle' and
        'Clay'
        """

        particle = base_classes.Kaolinite(
            x=501,
            y=74,
            inclination=-3 * np.math.pi / 4,
            thickness=2,
            length=10000,
        )
        self.assertEqual(particle.x, 501)
        self.assertEqual(particle.y, 74)
        self.assertAlmostEqual(particle.inclination, np.math.pi / 4)
        self.assertEqual(particle.thickness, 2)
        self.assertEqual(particle.length, 10000)
        self.assertFalse(particle.is_segment)
        self.assertTrue(particle.midline)
        self.assertTrue(particle.midpoint)
        self.assertTrue(particle.segments)
quartz_sand1 = {
    'type': 'quartz',
    'size_upper_bound': 10000,
    'size_lower_bound': 8000,
    'quantity': 25
}
container = base_classes.Container(length=100000,
                                   width=100000,
                                   particles_info=[kaolinite_clay2],
                                   time_step=0.01,
                                   simulation_type='tt',
                                   fluid_characteristics=None)
particle1 = base_classes.Quartz(x=5000, y=5000, length=10000, hierarchy=0)
particle2 = base_classes.Kaolinite(x=53000,
                                   y=53000,
                                   length=5000,
                                   thickness=2,
                                   inclination=-1 * np.math.pi / 4,
                                   hierarchy=1)
particle3 = base_classes.Kaolinite(x=50000,
                                   y=50000,
                                   length=5000,
                                   thickness=2,
                                   inclination=np.math.pi / 4,
                                   hierarchy=1)
particle4 = base_classes.Kaolinite(x=5000,
                                   y=5000,
                                   length=9000,
                                   thickness=2,
                                   inclination=-1 * np.math.pi / 2,
                                   hierarchy=1)
container.particles.extend([particle2, particle3, particle4])