nanotools.cell module

This module defines the Cell class.

class nanotools.cell.Cell(avec=None, boundary=NOTHING, bravais=None, grid=None, resolution=<Quantity(0.2, 'angstrom')>)[source]

Bases: Base

Cell class.

The Cell class hold information about the simulation domain.

Examples:

avec = np.eye(3)
resolution = 0.10
cell = Cell(avec=avec, resolution=resolution)
avec

Three vectors defining a parallelepipedic domain.

Examples:

cell.avec = [0.,2.8,2.8,2.8,0.,2.8,2.8,2.8,0.]
Type:

2D array

boundary

6-element vector giving the boundary conditions in each directions [-u, +u, -v, +v, -w, +w], where u, v and w are the directions given by the three lattice vectors respectively. Both the positive and negative directions must be periodic if either of them is periodic. The following boundary conditions are supported:

  • 0: periodic

  • 1: Dirichlet

Examples:

cell.boundary = [0,0,0,0,0,0]
Type:

1D array

bravais

Bravais lattice symbol. This is used to determine the k-point path in linear band structure calculations. We follow the conventions in <10.1016/j.commatsci.2010.05.010>. The allowed values are: “CUB”,”FCC”,”BCC”,”TET”,”BCT1”,”BCT2”, “ORC”,”ORCF1”,”ORCF2”,”ORCF3”,”ORCI”,”ORCC”,”HEX”,”RHL1”,”RHL2”, “MCL”,”MCLC1”,”MCLC2”,”MCLC3”,”MCLC4”,”MCLC5”,”TRI”.

Examples:

cell.bravais = "BCT2"
Type:

string

grid

Number of grid points along each dimension. Determined from resolution if not given.

Examples:

cell.grid = [35, 35, 35]
Type:

1D array

resolution

Resolution of the grid used to discretize the domain. It is initalized from grid if not specified.

Examples:

cell.resolution = 0.12
Type:

float

get_bravais_lattice(tol=0.001)[source]

Returns the Bravais lattice type.

get_dx(axis)[source]

Returns the grid node-to-node distance along a given dimension.

Parameters:

axis (int) – Dimension index.

Returns:

Step size along dimension axis.

Return type:

dx (float)

get_grid(axis, fractional=False)[source]

Returns the coordinates of the grid nodes along a given dimension.

If the lattice vectors are not orthogonal, an average along the dimension axis is returned.

Parameters:

axis (int) – Axis along which the grid node coordinates are sought.

Returns:

An array containing the grid node coordinates.

Return type:

x (1D array)

get_grids(shape='linear')[source]

Returns the 3D grid node coordinates.

Parameters:

shape – string If shape is linear, then a single (n x 3) array containing the [x,y,z] coordinates is returned. Otherwise, three 3D arrays containing the x, y and z coordinates of every nodes are returned.

Returns:

x-coordinates y (3D array): y-coordinates z (3D array): z-coordinates xyz (2D array): x-, y- and z-coordinates

Return type:

x (3D array)

get_length(axis)[source]

Returns the length of a lattice vector.

Parameters:

axis (int) – Lattice vector index.

Returns:

Length of the lattice vector.

Return type:

l (float)

get_lengths()[source]

Returns the lengths of all lattice vectors.

Args:

Returns:

Lengths of all lattice vectors.

Return type:

l (1D array)

get_resolution()[source]

Return the real space grid resolution.

get_standard_lattice(tol=0.001)[source]

Computes the standard Bravais lattice vectors.

Finds the standard Bravais lattice following the conventions proposed in this reference.

Parameters:

tol (float) – tolerance for lengths and angles equality.

Returns:

A (3 x 3) array containing the standard Bravais lattice vectors.

get_volume()[source]

Returns the cell volume.

is_orthogonal()[source]

Checks if the lattice vectors are orthogonal.

is_periodic(axis=None)[source]

Returns True if the cell is periodic and False otherwise.

reciprocal()[source]

Computes the reciprocal lattice vectors.

Returns:

  • bvec (2D array)

    Reciprocal row-vectors.

set_avec(avec)[source]

Sets the avec attribute.

The Bravais and grid attributes are reset accordingly.

Parameters:

avec (2D array) – Lattice row-vectors.

set_grid(grid)[source]

Redefine grid attribute based on resolution attribute.

set_resolution(resolution)[source]

Sets the resolution attribute.

The grid attributes are reset accordingly.

Parameters:

resolution (float) – Real space resolution.

set_volume(v)[source]

Rescale avec to a specific volume.

nanotools.cell.get3DCrystalStructure(primitiveCellVectors, tol=0.001)[source]

Returns the crystal structure of given three linearly independent lattice vectors.

Parameters:
  • primitiveCellVectors (2D array) – Lattice vectors (row-vectors).

  • tol (float) – Tolerance.

Returns:

Crystal structure.

Return type:

crystalStructure (string)

nanotools.cell.getStandardPrimitiveCellVectors(crystalStructure, primitiveCellVectors, tol=0.001)[source]

For 0D or 1D system,there is only 1, case.

5 cases for 2D system:

case 1: {‘Square2D’,’SQU2D’} case 2: {‘Rectangular2D’,’Rectangle2D’,’REC2D’} case 3: {‘Hexagonal2D’,’Hexagon2D’,’HEX2D’} case 4: {‘Rhombic2D’,’Rhombus2D’,’CenteredRectangular2D’,’RHO2D’} case 5: {‘Oblique2D’,’OBL2D’}

14 cases for 3D system:

case 01: {‘Cubic’,’CUB’,’SimpleCubic’,’SC’,’cP’}) case 02: {‘FaceCenteredCubic’,’FCC’,’cF’}) case 03: {‘BodyCenteredCubic’,’BCC’,’cI’}) case 04: {‘Tetragonal’,’TET’,’tP’}) case 05: {‘BodyCenteredTetragonal’,’BCT’,’tI’}) case 06: {‘Orthorhombic’,’ORC’,’oP’}) case 07: {‘FaceCenteredOrthorhombic’,’ORCF’,’oF’}) case 08: {‘BodyCenteredOrthorhombic’,’ORCI’,’oI’}) case 09: {‘CCenteredOrthorhombic’,’ORCC’,’oS’}) case 10: {‘Hexagonal’,’HEX’,’HCP’,’hP’}) case 11: {‘Rhombohedral’,’RHL’,’hR’}) case 12: {‘Monoclinic’,’MCL’,’mP’}) case 13: {‘CCenteredMonoclinic’,’MCLC’,’mS’}) case 14: {‘Triclinic’,’TRI’,’aP’})