unitcell

class javelin.unitcell.UnitCell(*args)[source]

The UnitCell object can be set with either 1, 3 or 6 parameters corresponding to cubic a parameters, (a, b, c) or (a, b, c, alpha, beta, gamma), where angles are in degrees.

>>> cubic = UnitCell(5)
>>> cubic.cell
(5.0, 5.0, 5.0, 90.0, 90.0, 90.0)
>>> orthorhombic = UnitCell(5, 6, 7)
>>> orthorhombic.cell
(5.0, 6.0, 7.0, 90.0, 90.0, 90.0)
>>> unitcell = UnitCell(4.0, 3.0, 6.0, 89.0, 90.0, 97.0)
>>> unitcell.cell
(4.0, 3.0, 6.0, 89.0, 90.0, 97.0)

UnitCell objects can be set after being created simply by

>>> unitcell = UnitCell()
>>> unitcell.cell = 6
>>> unitcell.cell
(6.0, 6.0, 6.0, 90.0, 90.0, 90.0)
>>> unitcell.cell = 3, 4, 5
>>> unitcell.cell
(3.0, 4.0, 5.0, 90.0, 90.0, 90.0)
>>> unitcell.cell = 6, 7, 8, 91.0, 90, 89
>>> unitcell.cell
(6.0, 7.0, 8.0, 91.0, 90.0, 89.0)
>>> # or using a list or tuple
>>> unitcell.cell = [8, 7, 6, 89, 90, 90]
>>> unitcell.cell
(8.0, 7.0, 6.0, 89.0, 90.0, 90.0)
B

Returns the B matrix

Binv

Returns the inverse B matrix

G

Returns the metric tensor G

Gstar

Returns the reciprocal metric tensor G*

cartesian(u)[source]

Return Cartesian coordinates of a lattice vector.

>>> unitcell = UnitCell(3,4,5,90,90,120)
>>> unitcell.cartesian([1,0,0])
array([  2.59807621e+00,  -1.50000000e+00,   3.25954010e-16])

A array of atoms position can also be passed

>>> positions = [[1,0,0], [0,0,0.5]]
>>> unitcell.cartesian(positions)
array([[  2.59807621e+00,  -1.50000000e+00,   3.25954010e-16],
       [  0.00000000e+00,   0.00000000e+00,   2.50000000e+00]])
cell

Return the unit cell parameters (a, b, c, alpha, beta, gamma) in degrees.

d(h, k, l)[source]

Returns d-spacing for given h,k,l

dstar(h, k, l)[source]

Returns d*=1/d for given h,k,l

fractional(u)[source]

Return Cartesian coordinates of a lattice vector.

>>> unitcell = UnitCell(3,4,5,90,90,120)
>>> unitcell.fractional([0,4,0])
array([  0.00000000e+00,   1.00000000e+00,  -4.89858720e-17])

A array of atoms position can also be passed

>>> positions = [[0,2,0], [0,0,5]]
>>> unitcell.fractional(positions)
array([[  0.00000000e+00,   5.00000000e-01,  -2.44929360e-17],
       [  0.00000000e+00,   0.00000000e+00,   1.00000000e+00]])
recAngle(h1, k1, l1, h2, k2, l2, degrees=False)[source]

Calculates the angle between two reciprocal vectors

reciprocalCell

Return the reciprocal unit cell parameters (a*, b*, c*, alpha*, beta*, gamma*) in degrees.

reciprocalVolume

Returns the unit cell reciprocal volume

volume

Returns the unit cell volume