9#include <util/math/Constants.h>
34 if (lattice_ == UnitCell<2>::Hexagonal) {
37 if (lattice_ == UnitCell<2>::Rectangular) {
53 void UnitCell<2>::setBasis()
62 for (i=0; i < 2; ++i) {
63 rBasis_[i][i] = parameters_[0];
64 kBasis_[i][i] = twoPi/parameters_[0];
65 drBasis_[0](i,i) = 1.0;
70 for (i=0; i < 2; ++i) {
71 rBasis_[i][i] = parameters_[i];
72 kBasis_[i][i] = twoPi/parameters_[i];
73 drBasis_[i](i,i) = 1.0;
78 double a = parameters_[0];
79 double rt3 = sqrt(3.0);
83 rBasis_[1][0] = -0.5*a;
84 rBasis_[1][1] = 0.5*rt3*a;
86 drBasis_[0](0, 0) = 1.0;
87 drBasis_[0](0, 1) = 0.0;
88 drBasis_[0](1, 0) = -0.5;
89 drBasis_[0](1, 1) = 0.5*rt3;
91 kBasis_[0][0] = twoPi/a;
92 kBasis_[0][1] = twoPi/(rt3*a);
94 kBasis_[1][1] = twoPi/(0.5*rt3*a);
98 double a = parameters_[0];
99 double gamma = parameters_[1];
102 double cg = cos(gamma);
103 double sg = sin(gamma);
108 rBasis_[1][0] = cg*a;
109 rBasis_[1][1] = sg*a;
111 drBasis_[0](0, 0) = 1.0;
112 drBasis_[0](0, 1) = 0.0;
113 drBasis_[0](1, 0) = cg;
114 drBasis_[0](1, 1) = sg;
115 drBasis_[1](1, 0) = -sg*a;
116 drBasis_[1](1, 1) = cg*a;
118 kBasis_[0][0] = twoPi/a;
119 kBasis_[0][1] = -twoPi*cg/(sg*a);
121 kBasis_[1][1] = twoPi/(a*sg);
126 double a = parameters_[0];
127 double b = parameters_[1];
128 double gamma = parameters_[2];
131 double cg = cos(gamma);
132 double sg = sin(gamma);
136 rBasis_[1][0] = cg*b;
137 rBasis_[1][1] = sg*b;
139 drBasis_[0](0, 0) = 1.0;
140 drBasis_[0](0, 1) = 0.0;
141 drBasis_[1](1, 0) = cg;
142 drBasis_[1](1, 1) = sg;
143 drBasis_[1](1, 0) = -sg*b;
144 drBasis_[1](1, 1) = cg*b;
146 kBasis_[0][0] = twoPi/a;
147 kBasis_[0][1] = -twoPi*cg/(sg*a);
149 kBasis_[1][1] = twoPi/(b*sg);
165 lattice_ = other.lattice_;
225 if (buffer ==
"Square" || buffer ==
"square") {
228 if (buffer ==
"Rectangular" || buffer ==
"rectangular") {
231 if (buffer ==
"Rhombic" || buffer ==
"rhombic") {
234 if (buffer ==
"Hexagonal" || buffer ==
"hexagonal") {
237 if (buffer ==
"Oblique" || buffer ==
"oblique") {
240 UTIL_THROW(
"Invalid UnitCell<2>::LatticeSystem value input");
255 out <<
"rectangular";
bool isInitialized_
Has this unit cell been fully initialized?
FArray< RealVec< D >, D > rBasis_
Array of Bravais lattice basis vectors.
FSArray< double, 6 > parameters() const
Get the parameters of this unit cell.
FArray< double, 6 > parameters_
Parameters used to describe the unit cell.
void setLattice()
Compute all protected data, given latticeSystem and parameters.
int nParameter_
Number of parameters required to specify unit cell.
void set(UnitCell< 2 >::LatticeSystem lattice)
Set the lattice system, but not unit cell parameters.
LatticeSystem lattice() const
Return lattice system enumeration value.
Base template for UnitCell<D> classes, D=1, 2 or 3.
static const double Pi
Trigonometric constant Pi.
A fixed capacity (static) contiguous array with a variable logical size.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
Periodic fields and crystallography.
PSCF package top-level namespace.
std::istream & operator>>(std::istream &in, Pair< Data > &pair)
Input a Pair from an istream.
std::ostream & operator<<(std::ostream &out, const Pair< Data > &pair)
Output a Pair to an ostream, without line breaks.