Skip to content
This repository has been archived by the owner on Apr 23, 2021. It is now read-only.

PR: Feature lattice prim cell #205

Merged
merged 12 commits into from
Sep 28, 2015
19 changes: 15 additions & 4 deletions doc/source/api/cuds.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ Pure Python implementation

.. autosummary::

~primitive_cell.PrimitiveCell
~primitive_cell.BravaisLattice
~lattice.Lattice
~lattice.LatticeNode
~particles.Particles
Expand All @@ -53,11 +55,20 @@ Pure Python implementation

.. autosummary::

~lattice.make_hexagonal_lattice
~lattice.make_square_lattice
~lattice.make_rectangular_lattice
~lattice.make_cubic_lattice
~lattice.make_orthorombicp_lattice
~lattice.make_body_centered_cubic_lattice
~lattice.make_face_centered_cubic_lattice
~lattice.make_rhombohedral_lattice
~lattice.make_tetragonal_lattice
~lattice.make_body_centered_tetragonal_lattice
~lattice.make_hexagonal_lattice
~lattice.make_orthorhombic_lattice
~lattice.make_body_centered_orthorhombic_lattice
~lattice.make_face_centered_orthorhombic_lattice
~lattice.make_base_centered_orthorhombic_lattice
~lattice.make_monoclinic_lattice
~lattice.make_base_centered_monoclinic_lattice
~lattice.make_triclinic_lattice

.. rubric:: Implementation

Expand Down
Binary file modified doc/source/images/containers.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/source/images/h5cuds.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/source/images/h5lattice.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions doc/source/uml/h5lattice.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ class H5Lattice as "H5Lattice(Group)" {
lattice : Table = Nodes
data : Table = ContainerData
-- Node Attributes --
type: str
base_vect : float[3]
size : int[3]
prim_cell: array of float[3]
bravais_lattice: int
size: int[3]
origin: float[3]
cuds_version: int
}
Expand Down
12 changes: 9 additions & 3 deletions doc/source/uml/lattice.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
@startuml
abstract class ABCLattice {
name: str
type: str
base_vect: float[3]
prim_cell: PrimitiveCell
size: int[3]
origin: float[3]
data: DataContainer
{abstract} get_node(index: int[3]) LatticeNode
{abstract} update_nodes(nodes: iterable of LatticeNode)
{abstract} iter_nodes(indices: iterable of int[3] {optional}): iterator of LatticeNode
{abstract} get_coordinate((index: int[3]): float[3]
get_coordinate((index: int[3]): float[3]

{abstract} count_of(key: CUDSItem): integer
}

class PrimitiveCell {
p1: float[3]
p2: float[3]
p3: float[3]
bravais_lattice: int
}
@enduml
23 changes: 14 additions & 9 deletions simphony/cuds/abc_lattice.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,14 @@ class ABCLattice(object):
----------
name : str
name of lattice
type : str
type of lattice
base_vect : float[3]
base vector of lattice
prim_cell : PrimitiveCell
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a suggestion that can be ignored, but I prefer the attribute name primitive_cell instead of prim_cell

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

primitive cell specifying the 3D Bravais lattice
size : int[3]
lattice dimensions
origin : float[3]
lattice origin
data : DataContainer
high level CUBA data assigned to lattice

"""
__metaclass__ = ABCMeta

Expand Down Expand Up @@ -66,20 +63,28 @@ def iter_nodes(self, indices=None): # pragma: no cover

"""

@abstractmethod
def get_coordinate(self, index): # pragma: no cover
@property
def prim_cell(self):
return self._prim_cell

def get_coordinate(self, ind):
"""Get coordinate of the given index coordinate.

Parameters
----------
index : int[3]
ind : int[3]
node index coordinate

Returns
-------
coordinates : float[3]

"""
p1 = self.prim_cell.p1
p2 = self.prim_cell.p2
p3 = self.prim_cell.p3
return (self.origin[0] + ind[0]*p1[0] + ind[1]*p2[0] + ind[2]*p3[0],
self.origin[1] + ind[0]*p1[1] + ind[1]*p2[1] + ind[2]*p3[1],
self.origin[2] + ind[0]*p1[2] + ind[1]*p2[2] + ind[2]*p3[2])

@abstractmethod
def count_of(self, item_type): # pragma: no cover
Expand Down
Loading