示例#1
0
    def test_construction(self):
        # Ok.
        world = World(self.mesh, Material.Py())
        self.assertEqual(len(world.bodies), 1)

        # Not ok: Need direct Material if no body is given.
        try:
            World(self.mesh)
            self.fail()
        except:
            pass

        # Not ok: Duplicate Material
        try:
            world = World(self.mesh, Material.Py(), Material.Py())
            self.fail()
        except:
            pass

        # Not ok: Material and Body(s) given
        try:
            world = World(self.mesh, Material.Py(),
                          Body("body1", Material.Py()))
            self.fail()
        except:
            pass
示例#2
0
class WorldTest(unittest.TestCase):

    def setUp(self):
        self.mesh = RectangularMesh((100, 100, 1), (1e-9, 1e-9, 1e-9))
        self.world = World(
            self.mesh,
            Body("body1", Material.Py(), Everywhere()),
            Body("body2", Material.Py(), Cylinder((0, 0, 0), (0, 50e-9, 0), 20e-9))
        )

    def test_findBody(self):
        body1 = self.world.findBody("body1")
        self.assertTrue(isinstance(body1, Body))
        self.assertEqual(body1.id, "body1")
        try:
            self.world.findBody("body3")
            self.fail()
        except:
            pass

    def test_getters(self):
        self.assertEqual(len(self.world.bodies), 2)
        self.assertTrue(isinstance(self.world.mesh, RectangularMesh))

    def test_construction(self):
        # Ok.
        world = World(self.mesh, Material.Py())
        self.assertEqual(len(world.bodies), 1)

        # Not ok: Need direct Material if no body is given.
        try:
            World(self.mesh)
            self.fail()
        except:
            pass

        # Not ok: Duplicate Material
        try:
            world = World(self.mesh, Material.Py(), Material.Py())
            self.fail()
        except:
            pass

        # Not ok: Material and Body(s) given
        try:
            world = World(self.mesh, Material.Py(), Body("body1", Material.Py()))
            self.fail()
        except:
            pass
示例#3
0
class WorldTest(unittest.TestCase):
    def setUp(self):
        self.mesh = RectangularMesh((100, 100, 1), (1e-9, 1e-9, 1e-9))
        self.world = World(
            self.mesh, Body("body1", Material.Py(), Everywhere()),
            Body("body2", Material.Py(),
                 Cylinder((0, 0, 0), (0, 50e-9, 0), 20e-9)))

    def test_findBody(self):
        body1 = self.world.findBody("body1")
        self.assertTrue(isinstance(body1, Body))
        self.assertEqual(body1.id, "body1")
        try:
            self.world.findBody("body3")
            self.fail()
        except:
            pass

    def test_getters(self):
        self.assertEqual(len(self.world.bodies), 2)
        self.assertTrue(isinstance(self.world.mesh, RectangularMesh))

    def test_construction(self):
        # Ok.
        world = World(self.mesh, Material.Py())
        self.assertEqual(len(world.bodies), 1)

        # Not ok: Need direct Material if no body is given.
        try:
            World(self.mesh)
            self.fail()
        except:
            pass

        # Not ok: Duplicate Material
        try:
            world = World(self.mesh, Material.Py(), Material.Py())
            self.fail()
        except:
            pass

        # Not ok: Material and Body(s) given
        try:
            world = World(self.mesh, Material.Py(),
                          Body("body1", Material.Py()))
            self.fail()
        except:
            pass
示例#4
0
 def setUp(self):
     self.mesh = RectangularMesh((100, 100, 1), (1e-9, 1e-9, 1e-9))
     self.world = World(
       self.mesh,
       Body("body1", Material.Py(), Everywhere()),
       Body("body2", Material.Py(), Cylinder((0,0,0), (0,50e-9,0), 20e-9))
     )
示例#5
0
 def setUp(self):
     world = World(RectangularMesh((10, 10, 10), (1e-9, 1e-9, 1e-9)))
     self.solver = create_solver(world, [ExternalField])
示例#6
0
 def setUp(self):
     self.mesh = RectangularMesh((100, 100, 1), (1e-9, 1e-9, 1e-9))
     self.world = World(
         self.mesh, Body("body1", Material.Py(), Everywhere()),
         Body("body2", Material.Py(),
              Cylinder((0, 0, 0), (0, 50e-9, 0), 20e-9)))