UnitCell

UnitCell — Unit cell

Synopsis

#include "cell.h"


typedef             UnitCell;
enum                LatticeType;
typedef             UnitCellTransformation;

UnitCell *          cell_new                            (void);
UnitCell *          cell_new_from_cell                  (UnitCell *orig);
UnitCell *          cell_new_from_direct_axes           (struct rvec as,
                                                         struct rvec bs,
                                                         struct rvec cs);
UnitCell *          cell_new_from_parameters            (double a,
                                                         double b,
                                                         double c,
                                                         double alpha,
                                                         double beta,
                                                         double gamma);
UnitCell *          cell_new_from_reciprocal_axes       (struct rvec as,
                                                         struct rvec bs,
                                                         struct rvec cs);
void                cell_free                           (UnitCell *cell);

int                 cell_get_cartesian                  (UnitCell *cell,
                                                         double *ax,
                                                         double *ay,
                                                         double *az,
                                                         double *bx,
                                                         double *by,
                                                         double *bz,
                                                         double *cx,
                                                         double *cy,
                                                         double *cz);
int                 cell_get_parameters                 (UnitCell *cell,
                                                         double *a,
                                                         double *b,
                                                         double *c,
                                                         double *alpha,
                                                         double *beta,
                                                         double *gamma);
const char *        cell_get_pointgroup                 (UnitCell *cell);
int                 cell_get_reciprocal                 (UnitCell *cell,
                                                         double *asx,
                                                         double *asy,
                                                         double *asz,
                                                         double *bsx,
                                                         double *bsy,
                                                         double *bsz,
                                                         double *csx,
                                                         double *csy,
                                                         double *csz);
char                cell_get_centering                  (UnitCell *cell);
LatticeType         cell_get_lattice_type               (UnitCell *cell);
char                cell_get_unique_axis                (UnitCell *cell);

void                cell_set_cartesian                  (UnitCell *cell,
                                                         double ax,
                                                         double ay,
                                                         double az,
                                                         double bx,
                                                         double by,
                                                         double bz,
                                                         double cx,
                                                         double cy,
                                                         double cz);
void                cell_set_cartesian_a                (UnitCell *cell,
                                                         double ax,
                                                         double ay,
                                                         double az);
void                cell_set_cartesian_b                (UnitCell *cell,
                                                         double bx,
                                                         double by,
                                                         double bz);
void                cell_set_cartesian_c                (UnitCell *cell,
                                                         double cx,
                                                         double cy,
                                                         double cz);
void                cell_set_parameters                 (UnitCell *cell,
                                                         double a,
                                                         double b,
                                                         double c,
                                                         double alpha,
                                                         double beta,
                                                         double gamma);
void                cell_set_pointgroup                 (UnitCell *cell,
                                                         const char *sym);
void                cell_set_reciprocal                 (UnitCell *cell,
                                                         double asx,
                                                         double asy,
                                                         double asz,
                                                         double bsx,
                                                         double bsy,
                                                         double bsz,
                                                         double csx,
                                                         double csy,
                                                         double csz);
void                cell_set_centering                  (UnitCell *cell,
                                                         char centering);
void                cell_set_lattice_type               (UnitCell *cell,
                                                         LatticeType lattice_type);
void                cell_set_unique_axis                (UnitCell *cell,
                                                         char unique_axis);

UnitCell *          cell_transform                      (UnitCell *cell,
                                                         UnitCellTransformation *t);
UnitCell *          cell_transform_inverse              (UnitCell *cell,
                                                         UnitCellTransformation *t);
void                tfn_combine                         (UnitCellTransformation *t,
                                                         double *na,
                                                         double *nb,
                                                         double *nc);
UnitCellTransformation * tfn_identity                   (void);
UnitCellTransformation * tfn_from_intmat                (IntegerMatrix *m);
UnitCellTransformation * tfn_inverse                    (UnitCellTransformation *t);
void                tfn_print                           (UnitCellTransformation *t);
double *            tfn_vector                          (double a,
                                                         double b,
                                                         double c);
void                tfn_free                            (UnitCellTransformation *t);

const char *        cell_rep                            (UnitCell *cell);

Description

This structure represents a unit cell.

Details

UnitCell

typedef struct _unitcell UnitCell;

This data structure is opaque. You must use the available accessor functions to read and write its contents.


enum LatticeType

typedef enum {
	L_TRICLINIC,
	L_MONOCLINIC,
	L_ORTHORHOMBIC,
	L_TETRAGONAL,
	L_RHOMBOHEDRAL,
	L_HEXAGONAL,
	L_CUBIC
} LatticeType;

An enumeration of the possible lattice types: triclinic, monoclinic, orthorhombic, tetragonal, rhombohedral, hexagonal and cubic.

L_TRICLINIC

Triclinic lattice

L_MONOCLINIC

Monoclinic lattice

L_ORTHORHOMBIC

Orthorhombic lattice

L_TETRAGONAL

Tetragonal lattice

L_RHOMBOHEDRAL

Rhombohedral lattice

L_HEXAGONAL

Hexagonal lattice

L_CUBIC

Cubic lattice

UnitCellTransformation

typedef struct _unitcelltransformation UnitCellTransformation;

This opaque data structure represents a tranformation of a unit cell, such as a rotation or a centering operation.


cell_new ()

UnitCell *          cell_new                            (void);

Create a new UnitCell.

Returns :

the new unit cell, or NULL on failure.

cell_new_from_cell ()

UnitCell *          cell_new_from_cell                  (UnitCell *orig);

cell_new_from_direct_axes ()

UnitCell *          cell_new_from_direct_axes           (struct rvec as,
                                                         struct rvec bs,
                                                         struct rvec cs);

cell_new_from_parameters ()

UnitCell *          cell_new_from_parameters            (double a,
                                                         double b,
                                                         double c,
                                                         double alpha,
                                                         double beta,
                                                         double gamma);

cell_new_from_reciprocal_axes ()

UnitCell *          cell_new_from_reciprocal_axes       (struct rvec as,
                                                         struct rvec bs,
                                                         struct rvec cs);

cell_free ()

void                cell_free                           (UnitCell *cell);

Frees a UnitCell, and all internal resources concerning that cell.

cell :

A UnitCell to free.

cell_get_cartesian ()

int                 cell_get_cartesian                  (UnitCell *cell,
                                                         double *ax,
                                                         double *ay,
                                                         double *az,
                                                         double *bx,
                                                         double *by,
                                                         double *bz,
                                                         double *cx,
                                                         double *cy,
                                                         double *cz);

cell_get_parameters ()

int                 cell_get_parameters                 (UnitCell *cell,
                                                         double *a,
                                                         double *b,
                                                         double *c,
                                                         double *alpha,
                                                         double *beta,
                                                         double *gamma);

cell_get_pointgroup ()

const char *        cell_get_pointgroup                 (UnitCell *cell);

cell_get_reciprocal ()

int                 cell_get_reciprocal                 (UnitCell *cell,
                                                         double *asx,
                                                         double *asy,
                                                         double *asz,
                                                         double *bsx,
                                                         double *bsy,
                                                         double *bsz,
                                                         double *csx,
                                                         double *csy,
                                                         double *csz);

cell_get_centering ()

char                cell_get_centering                  (UnitCell *cell);

cell_get_lattice_type ()

LatticeType         cell_get_lattice_type               (UnitCell *cell);

cell_get_unique_axis ()

char                cell_get_unique_axis                (UnitCell *cell);

cell_set_cartesian ()

void                cell_set_cartesian                  (UnitCell *cell,
                                                         double ax,
                                                         double ay,
                                                         double az,
                                                         double bx,
                                                         double by,
                                                         double bz,
                                                         double cx,
                                                         double cy,
                                                         double cz);

cell_set_cartesian_a ()

void                cell_set_cartesian_a                (UnitCell *cell,
                                                         double ax,
                                                         double ay,
                                                         double az);

cell_set_cartesian_b ()

void                cell_set_cartesian_b                (UnitCell *cell,
                                                         double bx,
                                                         double by,
                                                         double bz);

cell_set_cartesian_c ()

void                cell_set_cartesian_c                (UnitCell *cell,
                                                         double cx,
                                                         double cy,
                                                         double cz);

cell_set_parameters ()

void                cell_set_parameters                 (UnitCell *cell,
                                                         double a,
                                                         double b,
                                                         double c,
                                                         double alpha,
                                                         double beta,
                                                         double gamma);

cell_set_pointgroup ()

void                cell_set_pointgroup                 (UnitCell *cell,
                                                         const char *sym);

cell_set_reciprocal ()

void                cell_set_reciprocal                 (UnitCell *cell,
                                                         double asx,
                                                         double asy,
                                                         double asz,
                                                         double bsx,
                                                         double bsy,
                                                         double bsz,
                                                         double csx,
                                                         double csy,
                                                         double csz);

cell_set_centering ()

void                cell_set_centering                  (UnitCell *cell,
                                                         char centering);

cell_set_lattice_type ()

void                cell_set_lattice_type               (UnitCell *cell,
                                                         LatticeType lattice_type);

cell_set_unique_axis ()

void                cell_set_unique_axis                (UnitCell *cell,
                                                         char unique_axis);

cell_transform ()

UnitCell *          cell_transform                      (UnitCell *cell,
                                                         UnitCellTransformation *t);

Applies t to cell. Note that the lattice type, centering and unique axis information will not be preserved.

cell :

A UnitCell.

t :

A UnitCellTransformation.

Returns :

Transformed copy of cell.

cell_transform_inverse ()

UnitCell *          cell_transform_inverse              (UnitCell *cell,
                                                         UnitCellTransformation *t);

Applies the inverse of t to cell.

cell :

A UnitCell.

t :

A UnitCellTransformation.

Returns :

Transformed copy of cell.

tfn_combine ()

void                tfn_combine                         (UnitCellTransformation *t,
                                                         double *na,
                                                         double *nb,
                                                         double *nc);

Updates t such that it represents its previous transformation followed by a new transformation, corresponding to letting a = naa*a + nab*b + nac*c. Likewise, a = nba*a + nbb*b + nbc*c and c = nca*a + ncb*b + ncc*c.

t :

A UnitCellTransformation

na :

Pointer to three doubles representing naa, nab, nac

nb :

Pointer to three doubles representing nba, nbb, nbc

nc :

Pointer to three doubles representing nca, ncb, ncc

tfn_identity ()

UnitCellTransformation * tfn_identity                   (void);

Returns :

A UnitCellTransformation corresponding to an identity operation.

tfn_from_intmat ()

UnitCellTransformation * tfn_from_intmat                (IntegerMatrix *m);

m :

An IntegerMatrix

Returns :

A UnitCellTransformation corresponding to m.

tfn_inverse ()

UnitCellTransformation * tfn_inverse                    (UnitCellTransformation *t);

Calculates the inverse of t. That is, if you apply cell_transform() to a UnitCell using t, and then apply cell_transform() to the result using tfn_inverse(t) instead of t, you will recover the same lattice vectors (but note that the lattice type, centering and unique axis information will be lost).

t :

A UnitCellTransformation.

Returns :

The inverse of t.

tfn_print ()

void                tfn_print                           (UnitCellTransformation *t);

Prints information about t to stderr.


tfn_vector ()

double *            tfn_vector                          (double a,
                                                         double b,
                                                         double c);

This is a convenience function to use when sending vectors to tfn_combine(): tfn_combine(tfn, tfn_vector(1,0,0), tfn_vector(0,2,0), tfn_vector(0,0,1));

a :

Amount of "a" to include in new vector

b :

Amount of "b" to include in new vector

c :

Amount of "c" to include in new vector

tfn_free ()

void                tfn_free                            (UnitCellTransformation *t);

Frees all resources associated with t.


cell_rep ()

const char *        cell_rep                            (UnitCell *cell);