Unit Cell class

class UnitCell

An UnitCell represent the box containing the atoms, and its periodicity

A unit cell is fully represented by three lengths (a, b, c); and three angles (alpha, beta, gamma). The angles are stored in degrees, and the lengths in Angstroms.

A cell also has a matricial representation, by projecting the three base vector into an orthonormal base. We choose to represent such matrix as an upper triangular matrix:

| a_x   b_x   c_x |
|  0    b_y   c_y |
|  0     0    c_z |

Public Types

enum CellShape

Possible shapes for the unit cell.

Values:

ORTHORHOMBIC = 0

Orthorhombic cell, with the three angles equals to 90°

TRICLINIC = 1

Triclinic cell, with any values for the angles.

INFINITE = 2

Infinite cell, to use when there is no cell.

Public Functions

UnitCell()

Construct an INFINITE unit cell, with all lengths set to 0

UnitCell(double a)

Construct a cubic unit cell of side size a

UnitCell(double a, double b, double c)

Construct an ORTHOROMBIC unit cell of side size a, b, c

UnitCell(double a, double b, double c, double alpha, double beta, double gamma)

Construct a unit cell of side size a, b, c, and cell angles alpha, beta, gamma.

If all of alpha, beta and gamma are 90.0, then the cell is ORTHOROMBIC. Else a TRICLINIC cell is created.

UnitCell(const Matrix3D &matrix)

Construct a unit cell via from an upper triangular matrix.

If a matrix of all zeros is given, then an infinite cell is created.

If only the diagonal of the matrix is non-zero, then the cell is ORTHOROMBIC. Else a TRICLINIC cell is created.

Matrix3D matrix() const

Get the cell matrix, defined as the upper triangular matrix

| a_x   b_x   c_x |
|  0    b_y   c_y |
|  0     0    c_z |

CellShape shape() const

Get the cell shape

void set_shape(CellShape shape)

Set the cell shape to shape

Exceptions
  • Error: if shape is ORTHORHOMBIC and some angles are not 90°, or if shape is INFINITE and some lengths are not 0.0.

double a() const

Get the first lenght (a) of the cell

void set_a(double val)

Set the first lenght (a) of the cell

Exceptions
  • Error: if the cell shape is INFINITE.

double b() const

Get the second lenght (b) of the cell

void set_b(double val)

Set the second lenght (b) of the cell

Exceptions
  • Error: if the cell shape is INFINITE.

double c() const

Get the third lenght (c) of the cell

void set_c(double val)

Set the third lenght (c) of the cell

Exceptions
  • Error: if the cell shape is INFINITE.

double alpha() const

Get the first angle (alpha) of the cell

void set_alpha(double val)

Set the first angle (alpha) of the cell

Exceptions
  • Error: if the cell shape is not TRICLINIC.

double beta() const

Get the second angle (beta) of the cell

void set_beta(double val)

Set the second angle (beta) of the cell if possible

Exceptions
  • Error: if the cell shape is not TRICLINIC.

double gamma() const

Get the third angle (gamma) of the cell

void set_gamma(double val)

Set the third angle (gamma) of the cell if possible

Exceptions
  • Error: if the cell shape is not TRICLINIC.

double volume() const

Get the unit cell volume

Vector3D wrap(const Vector3D &vector) const

Wrap the vector in the unit cell, using periodic boundary conditions.

For an orthorombic unit cell, this make sure that all the vector components are between -L/2 and L/2 where L is the corresponding cell length.