本文整理汇总了Python中simphony.cuds.primitive_cell.PrimitiveCell.for_tetragonal_lattice方法的典型用法代码示例。如果您正苦于以下问题:Python PrimitiveCell.for_tetragonal_lattice方法的具体用法?Python PrimitiveCell.for_tetragonal_lattice怎么用?Python PrimitiveCell.for_tetragonal_lattice使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类simphony.cuds.primitive_cell.PrimitiveCell
的用法示例。
在下文中一共展示了PrimitiveCell.for_tetragonal_lattice方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_primitive_cell_for_tetragonal_lattice
# 需要导入模块: from simphony.cuds.primitive_cell import PrimitiveCell [as 别名]
# 或者: from simphony.cuds.primitive_cell.PrimitiveCell import for_tetragonal_lattice [as 别名]
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))
示例2: make_tetragonal_lattice
# 需要导入模块: from simphony.cuds.primitive_cell import PrimitiveCell [as 别名]
# 或者: from simphony.cuds.primitive_cell.PrimitiveCell import for_tetragonal_lattice [as 别名]
def make_tetragonal_lattice(name, hxy, hz, size, origin=(0, 0, 0)):
"""Create and return a 3D tetragonal lattice.
Parameters
----------
name : str
hxy : float
lattice spacing in the xy-plane
hz : float
lattice spacing in the z-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_tetragonal_lattice(hxy, hz)
return Lattice(name, pc, size, origin)
示例3: from_dataset
# 需要导入模块: from simphony.cuds.primitive_cell import PrimitiveCell [as 别名]
# 或者: from simphony.cuds.primitive_cell.PrimitiveCell import for_tetragonal_lattice [as 别名]
def from_dataset(cls, name, data_set, data=None):
""" Create a new Lattice and try to guess the ``primitive_cell``
Parameters
----------
name : str
data_set : tvtk.ImageData or tvtk.PolyData
The dataset to wrap in the CUDS api. If it is a PolyData,
the points are assumed to be arranged in C-contiguous order
data : DataContainer
The data attribute to attach to the container. Default is None.
Returns
-------
lattice : VTKLattice
Raises
------
TypeError :
If data_set is not either tvtk.ImageData or tvtk.PolyData
IndexError:
If the lattice nodes are not arranged in C-contiguous order
"""
if isinstance(data_set, tvtk.ImageData):
spacing = data_set.spacing
unique_spacing = numpy.unique(spacing)
if len(unique_spacing) == 1:
primitive_cell = PrimitiveCell.for_cubic_lattice(spacing[0])
elif len(unique_spacing) == 2:
a, c = unique_spacing
if sum(spacing == a) == 2:
primitive_cell = PrimitiveCell.for_tetragonal_lattice(a, c)
else:
primitive_cell = PrimitiveCell.for_tetragonal_lattice(c, a)
else:
factory = PrimitiveCell.for_orthorhombic_lattice
primitive_cell = factory(*spacing)
return cls(name=name, primitive_cell=primitive_cell,
data=data, data_set=data_set)
if not isinstance(data_set, tvtk.PolyData):
# Not ImageData nor PolyData
message = 'Cannot convert {} to a cuds Lattice'
raise TypeError(message.format(type(data_set)))
# data_set is an instance of tvtk.PolyData
points = data_set.points.to_array()
# Assumed C-contiguous order of points
p1, p2, p3 = guess_primitive_vectors(points)
# This will raise a TypeError if no bravais lattice type matches
bravais_lattice = find_lattice_type(p1, p2, p3)
primitive_cell = PrimitiveCell(p1, p2, p3, bravais_lattice)
return cls(name=name, primitive_cell=primitive_cell,
data=data, data_set=data_set)
示例4: rotate_primitive_cell
# 需要导入模块: from simphony.cuds.primitive_cell import PrimitiveCell [as 别名]
# 或者: from simphony.cuds.primitive_cell.PrimitiveCell import for_tetragonal_lattice [as 别名]
datasets.append(create_polydata_from_pc(*pcs))
# BCC lattice in a rotated coor. sys.
pcs = rotate_primitive_cell(PrimitiveCell.for_body_centered_cubic_lattice(1.))
datasets.append(create_polydata_from_pc(*pcs))
# FCC lattice in a rotated coor. sys.
pcs = rotate_primitive_cell(PrimitiveCell.for_face_centered_cubic_lattice(1.))
datasets.append(create_polydata_from_pc(*pcs))
# rhombohedral lattice in a rotated coor. sys.
pcs = rotate_primitive_cell(PrimitiveCell.for_rhombohedral_lattice(1., 1.))
datasets.append(create_polydata_from_pc(*pcs))
# tetragonal lattice in a rotated coor. sys.
pcs = rotate_primitive_cell(PrimitiveCell.for_tetragonal_lattice(0.5, 1.))
datasets.append(create_polydata_from_pc(*pcs))
# body_centered_tetragonal lattice in a rotated coor. sys.
factory = PrimitiveCell.for_body_centered_tetragonal_lattice
pcs = rotate_primitive_cell(factory(1., 0.5))
datasets.append(create_polydata_from_pc(*pcs))
# hexagonal lattice in a rotated coor. sys.
pcs = rotate_primitive_cell(PrimitiveCell.for_hexagonal_lattice(1., 0.5))
datasets.append(create_polydata_from_pc(*pcs))
# orthorhombic lattice in a rotated coor. sys.
factory = PrimitiveCell.for_orthorhombic_lattice
pcs = rotate_primitive_cell(factory(0.5, 0.8, 1.,))
datasets.append(create_polydata_from_pc(*pcs))