| Bsoft 2.0.5 Bernard's software package

UnitCell.h
Go to the documentation of this file.
1
9 #include "Matrix3.h"
10 #include "utilities.h"
11
12 #ifndef _UnitCell_
13 /************************************************************************
14 @Object: struct UnitCell
15 @Description:
16 Unit cell parameters.
17 @Features:
18 The convention is as follows:
19 a lies on the x-axis,
20 b lies in the x,y plane.
21 *************************************************************************/
22 class UnitCell {
23 private:
24 double data[6];
25 public:
26 UnitCell() { for ( int i=0; i<3; i++ ) data[i] = 0; for ( int i=3; i<6; i++ ) data[i] = M_PI_2; }
27 UnitCell(double* v) { for ( int i=0; i<6; i++ ) data[i] = v[i]; }
28 UnitCell(double a, double b, double c, double alf, double bet, double gam) {
29 data[0] = a; data[1] = b; data[2] = c;
30 data[3] = alf; data[4] = bet; data[5] = gam;
31 }
32 // UnitCell operator=(const UnitCell& uc) { for ( int i=0; i<6; i++ ) data[i] = uc.data[i]; return *this; }
33 double& operator[](int i) { if ( i < 0 ) i = 0; if ( i > 5 ) i = 5; return data[i]; }
34 bool check() { double e=1; for ( int i=0; i<6; i++ ) e *= data[i]; return e > 0; }
35 void size(double a, double b, double c) { data[0] = a; data[1] = b; data[2] = c; }
36 void a(double d) { data[0] = d; }
37 void b(double d) { data[1] = d; }
38 void c(double d) { data[2] = d; }
39 void alpha(double d) { data[3] = d; }
40 void beta(double d) { data[4] = d; }
41 void gamma(double d) { data[5] = d; }
42 double a() { return data[0]; }
43 double b() { return data[1]; }
44 double c() { return data[2]; }
45 double alpha() { return data[3]; }
46 double beta() { return data[4]; }
47 double gamma() { return data[5]; }
48 void set_angle_range() {
49 for ( int i=3; i<6; i++ ) {
50 while ( data[i] < -M_PI ) data[i] += TWOPI;
51 while ( data[i] > M_PI ) data[i] -= TWOPI;
52 }
53 }
54 void degrees_to_radians() { for ( int i=3; i<6; i++ ) data[i] *= M_PI/180.0; }
55 void radians_to_degrees() { for ( int i=3; i<6; i++ ) data[i] *= 180.0/M_PI; }
56 double volume() { return data[0]*data[1]*data[2]*(1 - cos(data[3])*cos(data[3])
57 - cos(data[4])*cos(data[4]) - cos(data[5])*cos(data[5])
58 + 2*cos(data[3])*cos(data[4])*cos(data[5])); }
59 Matrix3 skew_matrix();
60 Matrix3 skew_rotation(int invert);
61 } ;
62 #define _UnitCell_
63 #endif
64
65
M_PI_2
#define M_PI_2
Definition: utilities.h:62
UnitCell
Definition: UnitCell.h:22
UnitCell::c
double c()
Definition: UnitCell.h:44
UnitCell::volume
double volume()
Definition: UnitCell.h:56
UnitCell::gamma
void gamma(double d)
Definition: UnitCell.h:41
utilities.h
Header file for general utilities.
UnitCell::beta
void beta(double d)
Definition: UnitCell.h:40
Matrix3
Definition: Matrix3.h:17
UnitCell::a
double a()
Definition: UnitCell.h:42
UnitCell::a
void a(double d)
Definition: UnitCell.h:36
UnitCell::b
double b()
Definition: UnitCell.h:43
UnitCell::beta
double beta()
Definition: UnitCell.h:46
UnitCell::set_angle_range
void set_angle_range()
Definition: UnitCell.h:48
Matrix3.h
3x3 Matrix manipulation functions
UnitCell::UnitCell
UnitCell(double *v)
Definition: UnitCell.h:27
UnitCell::gamma
double gamma()
Definition: UnitCell.h:47
M_PI
#define M_PI
Definition: utilities.h:59
UnitCell::UnitCell
UnitCell(double a, double b, double c, double alf, double bet, double gam)
Definition: UnitCell.h:28
UnitCell::UnitCell
UnitCell()
Definition: UnitCell.h:26
UnitCell::skew_rotation
Matrix3 skew_rotation(int invert)
Definition: UnitCell.cpp:65
UnitCell::b
void b(double d)
Definition: UnitCell.h:37
UnitCell::operator[]
double & operator[](int i)
Definition: UnitCell.h:33
UnitCell::alpha
void alpha(double d)
Definition: UnitCell.h:39
UnitCell::degrees_to_radians
void degrees_to_radians()
Definition: UnitCell.h:54
UnitCell::skew_matrix
Matrix3 skew_matrix()
Calculates the skew matrix from the unit cell parameters.
Definition: UnitCell.cpp:26
UnitCell::size
void size(double a, double b, double c)
Definition: UnitCell.h:35
UnitCell::check
bool check()
Definition: UnitCell.h:34
TWOPI
#define TWOPI
Definition: utilities.h:68
UnitCell::alpha
double alpha()
Definition: UnitCell.h:45
UnitCell::c
void c(double d)
Definition: UnitCell.h:38
UnitCell::radians_to_degrees
void radians_to_degrees()
Definition: UnitCell.h:55