当前位置: 首页>>代码示例>>Python>>正文


Python primitive_cell.PrimitiveCell类代码示例

本文整理汇总了Python中simphony.cuds.primitive_cell.PrimitiveCell的典型用法代码示例。如果您正苦于以下问题:Python PrimitiveCell类的具体用法?Python PrimitiveCell怎么用?Python PrimitiveCell使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PrimitiveCell类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_primitive_cell_for_cubic_lattice

    def test_primitive_cell_for_cubic_lattice(self):
        with self.assertRaises(ValueError):
            PrimitiveCell.for_cubic_lattice(-1)

        pc = PrimitiveCell.for_cubic_lattice(self.a)
        self.assertIsInstance(pc, PrimitiveCell)
        self.assertEqual(pc.bravais_lattice, BravaisLattice.CUBIC)
        assert_array_equal(pc.p1, (self.a, 0, 0))
        assert_array_equal(pc.p2, (0, self.a, 0))
        assert_array_equal(pc.p3, (0, 0, self.a))
开发者ID:simphony,项目名称:simphony-common,代码行数:10,代码来源:test_primitive_cell.py

示例2: test_primitive_cell_for_triclinic_lattice

    def test_primitive_cell_for_triclinic_lattice(self):
        with self.assertRaises(ValueError):
            PrimitiveCell.for_triclinic_lattice(-1, -2, -3, 0.5, 0.6, 0.7)

        with self.assertRaises(ValueError):
            PrimitiveCell.for_triclinic_lattice(1, 2, 3, 0, np.pi, np.pi)

        with self.assertRaises(ValueError):
            PrimitiveCell.for_triclinic_lattice(1, 2, 3, 0.1, 0.2, 0.8)

        with self.assertRaises(ValueError):
            # angles too big
            PrimitiveCell.for_triclinic_lattice(1, 2, 3, 2.1, 2.1, 2.1)

        cosa = np.cos(self.alpha)
        cosb = np.cos(self.beta)
        sinb = np.sin(self.beta)
        cosg = np.cos(self.gamma)
        sing = np.sin(self.gamma)

        p1 = (self.a, 0, 0)
        p2 = (self.b*cosg, self.b*sing, 0)
        p3 = (self.c*cosb, self.c*(cosa-cosb*cosg) / sing,
              self.c*np.sqrt(sinb**2 - ((cosa-cosb*cosg) / sing)**2))

        pc = PrimitiveCell.for_triclinic_lattice(
            self.a, self.b, self.c, self.alpha, self.beta, self.gamma)
        self.assertIsInstance(pc, PrimitiveCell)
        self.assertEqual(pc.bravais_lattice,
                         BravaisLattice.TRICLINIC)
        assert_array_equal(pc.p1, p1)
        assert_array_equal(pc.p2, p2)
        assert_array_equal(pc.p3, p3)
开发者ID:simphony,项目名称:simphony-common,代码行数:33,代码来源:test_primitive_cell.py

示例3: test_primitive_cell_for_orthorhombic_lattice

    def test_primitive_cell_for_orthorhombic_lattice(self):
        with self.assertRaises(ValueError):
            PrimitiveCell.for_orthorhombic_lattice(-1, -2, -3)

        pc = PrimitiveCell.for_orthorhombic_lattice(self.a, self.b, self.c)
        self.assertIsInstance(pc, PrimitiveCell)
        self.assertEqual(pc.bravais_lattice,
                         BravaisLattice.ORTHORHOMBIC)
        assert_array_equal(pc.p1, (self.a, 0, 0))
        assert_array_equal(pc.p2, (0, self.b, 0))
        assert_array_equal(pc.p3, (0, 0, self.c))
开发者ID:simphony,项目名称:simphony-common,代码行数:11,代码来源:test_primitive_cell.py

示例4: test_primitive_cell_for_tetragonal_lattice

    def test_primitive_cell_for_tetragonal_lattice(self):
        with self.assertRaises(ValueError):
            PrimitiveCell.for_tetragonal_lattice(-1, -2)

        pc = PrimitiveCell.for_tetragonal_lattice(self.a, self.c)
        self.assertIsInstance(pc, PrimitiveCell)
        self.assertEqual(pc.bravais_lattice,
                         BravaisLattice.TETRAGONAL)
        assert_array_equal(pc.p1, (self.a, 0, 0))
        assert_array_equal(pc.p2, (0, self.a, 0))
        assert_array_equal(pc.p3, (0, 0, self.c))
开发者ID:simphony,项目名称:simphony-common,代码行数:11,代码来源:test_primitive_cell.py

示例5: test_primitive_cell_for_monoclinic_lattice

    def test_primitive_cell_for_monoclinic_lattice(self):
        with self.assertRaises(ValueError):
            PrimitiveCell.for_monoclinic_lattice(-1, -2, -3, np.pi/4)

        with self.assertRaises(ValueError):
            PrimitiveCell.for_monoclinic_lattice(1, 2, 3, np.pi)

        pc = PrimitiveCell.for_monoclinic_lattice(
            self.a, self.b, self.c, self.beta)
        self.assertIsInstance(pc, PrimitiveCell)
        self.assertEqual(pc.bravais_lattice,
                         BravaisLattice.MONOCLINIC)
        assert_array_equal(pc.p1,
                           (self.a*np.sin(self.beta), 0,
                            self.a*np.cos(self.beta)))
        assert_array_equal(pc.p2, (0, self.b, 0))
        assert_array_equal(pc.p3, (0, 0, self.c))
开发者ID:simphony,项目名称:simphony-common,代码行数:17,代码来源:test_primitive_cell.py

示例6: test_primitive_cell_for_rhombohedral_lattice

    def test_primitive_cell_for_rhombohedral_lattice(self):
        with self.assertRaises(ValueError):
            PrimitiveCell.for_rhombohedral_lattice(-1, np.pi/4)

        with self.assertRaises(ValueError):
            PrimitiveCell.for_rhombohedral_lattice(1, np.pi)

        with self.assertRaises(ValueError):
            # angle too big
            PrimitiveCell.for_rhombohedral_lattice(1, np.pi*2./3.+0.1)

        cosa = np.cos(self.alpha)
        sina = np.sin(self.alpha)

        p1 = (self.a, 0, 0)
        p2 = (self.a*cosa, self.a*sina, 0)
        p3 = (self.a*cosa, self.a*(cosa-cosa**2) / sina,
              self.a*np.sqrt(sina**2 - ((cosa-cosa**2) / sina)**2))

        pc = PrimitiveCell.for_rhombohedral_lattice(self.a, self.alpha)
        self.assertIsInstance(pc, PrimitiveCell)
        self.assertEqual(pc.bravais_lattice,
                         BravaisLattice.RHOMBOHEDRAL)
        assert_array_equal(pc.p1, p1)
        assert_array_equal(pc.p2, p2)
        assert_array_equal(pc.p3, p3)
开发者ID:simphony,项目名称:simphony-common,代码行数:26,代码来源:test_primitive_cell.py

示例7: setUp

 def setUp(self):
     self.addTypeEqualityFunc(
         DataContainer, partial(compare_data_containers, testcase=self))
     self.addTypeEqualityFunc(
         LatticeNode, partial(compare_lattice_nodes, testcase=self))
     self.primitive_cell = PrimitiveCell.for_cubic_lattice(0.2)
     self.size = (5, 10, 15)
     self.origin = (-2.0, 0.0, 1.0)
     self.container = self.container_factory(
         'my_name', self.primitive_cell, self.size, self.origin)
开发者ID:kitchoi,项目名称:simphony-common,代码行数:10,代码来源:abc_check_lattice.py

示例8: test_lattice_source_name

    def test_lattice_source_name(self):
        # given
        primitive_cell = PrimitiveCell.for_cubic_lattice(0.1)
        lattice = VTKLattice.empty('my_lattice', primitive_cell,
                                   (5, 10, 12), (0, 0, 0))

        # when
        source = self.tested_class(cuds=lattice)

        # then
        self.assertEqual(source.name, 'my_lattice (CUDS Lattice)')
开发者ID:simphony,项目名称:simphony-mayavi,代码行数:11,代码来源:test_cuds_source.py

示例9: test_primitive_cell_for_base_centered_monoclinic_lattice

    def test_primitive_cell_for_base_centered_monoclinic_lattice(self):
        with self.assertRaises(ValueError):
            PrimitiveCell.for_base_centered_monoclinic_lattice(
                -1, -2, -3, 0.5)

        with self.assertRaises(ValueError):
            PrimitiveCell.for_base_centered_monoclinic_lattice(
                1, 2, 3, np.pi)

        p1 = (self.a*np.sin(self.beta), 0, self.a*np.cos(self.beta))
        p2 = (self.a*np.sin(self.beta)/2, self.b/2,
              self.a*np.cos(self.beta)/2)

        pc = PrimitiveCell.for_base_centered_monoclinic_lattice(
            self.a, self.b, self.c, self.beta)
        self.assertIsInstance(pc, PrimitiveCell)
        self.assertEqual(pc.bravais_lattice,
                         BravaisLattice.BASE_CENTERED_MONOCLINIC)
        assert_array_equal(pc.p1, p1)
        assert_array_equal(pc.p2, p2)
        assert_array_equal(pc.p3, (0, 0, self.c))
开发者ID:simphony,项目名称:simphony-common,代码行数:21,代码来源:test_primitive_cell.py

示例10: test_source_from_a_vtk_lattice

    def test_source_from_a_vtk_lattice(self):
        # given
        primitive_cell = PrimitiveCell.for_cubic_lattice(0.1)
        lattice = VTKLattice.empty(
            'test', primitive_cell, (5, 10, 12), (0, 0, 0))

        # when
        source = self.tested_class(cuds=lattice)

        # then
        self.assertIs(source._vtk_cuds, lattice)
        self.assertIs(source.data, lattice.data_set)
开发者ID:simphony,项目名称:simphony-mayavi,代码行数:12,代码来源:test_cuds_source.py

示例11: test_exception_guess_vectors_with_unsorted_points

    def test_exception_guess_vectors_with_unsorted_points(self):
        # given
        primitive_cell = PrimitiveCell.for_rhombohedral_lattice(0.1, 0.7)

        # when
        p1, p2, p3 = self._get_primitive_vectors(primitive_cell)
        points = create_points_from_pc(p1, p2, p3, (4, 5, 3))
        numpy.random.shuffle(points)

        # then
        with self.assertRaises(ValueError):
            lattice_tools.guess_primitive_vectors(points)
开发者ID:simphony,项目名称:simphony-common,代码行数:12,代码来源:test_lattice_tools.py

示例12: make_face_centered_cubic_lattice

def make_face_centered_cubic_lattice(name, h, size, origin=(0, 0, 0)):
    """Create and return a 3D face-centered cubic lattice.

    Parameters
    ----------
    name : str
    h : float
        lattice spacing
    size : int[3]
        Number of lattice nodes in each axis direction.
    origin : float[3], default value = (0, 0, 0)
        lattice origin

    Returns
    -------
    lattice : Lattice
        A reference to a Lattice object.
    """
    pc = PrimitiveCell.for_face_centered_cubic_lattice(h)
    return Lattice(name, pc, size, origin)
开发者ID:kitchoi,项目名称:simphony-common,代码行数:20,代码来源:lattice.py

示例13: test_version

    def test_version(self):
        filename = os.path.join(self.temp_dir, "test_file.cuds")
        group_name = "dummy_component_name"
        with tables.open_file(filename, "w") as handle:
            group = handle.create_group(handle.root, group_name)

            # given/when
            H5Lattice.create_new(group, PrimitiveCell.for_cubic_lattice(0.2), size=(5, 10, 15), origin=(-2, 0, 1))

            # then
            self.assertTrue(isinstance(group._v_attrs.cuds_version, int))

        # when
        with tables.open_file(filename, "a") as handle:
            handle.get_node("/{}".format(group_name))._v_attrs.cuds_version = -1

        # then
        with tables.open_file(filename, "a") as handle:
            with self.assertRaises(ValueError):
                H5Lattice(handle.get_node("/" + group_name))
开发者ID:kitchoi,项目名称:simphony-common,代码行数:20,代码来源:test_h5_lattice.py

示例14: make_orthorhombic_lattice

def make_orthorhombic_lattice(name, hs, size, origin=(0, 0, 0)):
    """Create and return a 3D orthorhombic lattice.

    Parameters
    ----------
    name : str
    hs : float[3]
        lattice spacings in each axis direction
    size : int[3]
        Number of lattice nodes in each axis direction.
    origin : float[3], default value = (0, 0, 0)
        lattice origin

    Returns
    -------
    lattice : Lattice
        A reference to a Lattice object.

    """
    pc = PrimitiveCell.for_orthorhombic_lattice(hs[0], hs[1], hs[2])
    return Lattice(name, pc, size, origin)
开发者ID:kitchoi,项目名称:simphony-common,代码行数:21,代码来源:lattice.py

示例15: make_monoclinic_lattice

def make_monoclinic_lattice(name, hs, beta, size, origin=(0, 0, 0)):
    """Create and return a 3D monoclinic lattice.

    Parameters
    ----------
    name : str
    hs : float[3]
        lattice spacings in each axis direction
    beta: float
        angle between the (conventional) unit cell edges (in radians),
    size : int[3]
        Number of lattice nodes in each axis direction.
    origin : float[3], default value = (0, 0, 0)
        lattice origin

    Returns
    -------
    lattice : Lattice
        A reference to a Lattice object.
    """
    pc = PrimitiveCell.for_monoclinic_lattice(hs[0], hs[1], hs[2], beta)
    return Lattice(name, pc, size, origin)
开发者ID:kitchoi,项目名称:simphony-common,代码行数:22,代码来源:lattice.py


注:本文中的simphony.cuds.primitive_cell.PrimitiveCell类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。