Unit Cell

class chemfiles::UnitCell

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

A unit cell is fully represented by three lenghts (a, b, c); and three angles (alpha, beta, gamma). The angles are stored in degrees, and the lenghts 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 |

An unit cell also have a cell type, represented by the CellType enum.

Public Functions

UnitCell(const UnitCell & other)

Copy constructor.

UnitCell(UnitCell && other)

Move constructor.

UnitCell()

Construct an INFINITE unit cell.

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 TRICLINIC unit cell of side size a, b, c, and cell angles alpha, beta, gamma

UnitCell(CellType type)

Construct a cell of type type, with all lenghts set to 0 and all angles set to 90°

UnitCell(CellType type, double a)

Construct a cell of type type, with all lenghts set to a and all angles set to 90°

UnitCell(CellType type, double a, double b, double c)

Construct a cell of type type, with lenghts set to a ,b, d, and all angles set to 90°

Matrix3D matricial() const

Get a matricial representation of the cell.

void raw_matricial(double[3][3]) const

Populate C-style matricial representation of the cell. The array should have a 3 x 3 size.

CellType type() const

Get the cell type.

void type(CellType t)

Set the cell type to t.

double a() const

Get the first lenght (a) of the cell.

void a(double val)

Set the first lenght (a) of the cell.

double b() const

Get the second lenght (b) of the cell.

void b(double val)

Set the second lenght (b) of the cell.

double c() const

Get the third lenght (c) of the cell.

void c(double val)

Set the third lenght (c) of the cell.

double alpha() const

Get the first angle (alpha) of the cell.

void alpha(double val)

Set the first angle (alpha) of the cell if possible.

double beta() const

Get the second angle (beta) of the cell.

void beta(double val)

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

double gamma() const

Get the third angle (gamma) of the cell.

void gamma(double val)

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

double volume() const

Get the unit cell volume.

bool periodic_x() const

Get the cell periodicity for the x axis.

bool periodic_y() const

Get the cell periodicity for the y axis.

bool periodic_z() const

Get the cell periodicity for the z axis.

bool full_periodic() const

True if the cell is periodic in the three dimmensions.

void periodic_x(bool p)

Set the cell periodicity for the x axis.

void periodic_y(bool p)

Set the cell periodicity for the y axis.

void periodic_z(bool p)

Set the cell periodicity for the z axis.

void full_periodic(bool p)

Set the cell periodicity in three dimmensions.

Vector3D wrap(const Vector3D & vect) const

Wrap the vector vect in the unit cell.

CellType enum

Values:

  • ORTHOROMBIC = = 0 -

    Orthorombic 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.