9#include <util/math/Constants.h>
33 if (lattice_ == UnitCell<2>::Hexagonal) {
52 void UnitCell<2>::setBasis()
61 for (i=0; i < 2; ++i) {
62 rBasis_[i][i] = parameters_[0];
63 kBasis_[i][i] = twoPi/parameters_[0];
64 drBasis_[0](i,i) = 1.0;
69 for (i=0; i < 2; ++i) {
70 rBasis_[i][i] = parameters_[i];
71 kBasis_[i][i] = twoPi/parameters_[i];
72 drBasis_[i](i,i) = 1.0;
77 double a = parameters_[0];
78 double rt3 = sqrt(3.0);
82 rBasis_[1][0] = -0.5*a;
83 rBasis_[1][1] = 0.5*rt3*a;
85 drBasis_[0](0, 0) = 1.0;
86 drBasis_[0](0, 1) = 0.0;
87 drBasis_[0](1, 0) = -0.5;
88 drBasis_[0](1, 1) = 0.5*rt3;
90 kBasis_[0][0] = twoPi/a;
91 kBasis_[0][1] = twoPi/(rt3*a);
93 kBasis_[1][1] = twoPi/(0.5*rt3*a);
97 double a = parameters_[0];
98 double gamma = parameters_[1];
101 double cg = cos(gamma);
102 double sg = sin(gamma);
107 rBasis_[1][0] = cg*a;
108 rBasis_[1][1] = sg*a;
110 drBasis_[0](0, 0) = 1.0;
111 drBasis_[0](0, 1) = 0.0;
112 drBasis_[0](1, 0) = cg;
113 drBasis_[0](1, 1) = sg;
114 drBasis_[1](1, 0) = -sg*a;
115 drBasis_[1](1, 1) = cg*a;
117 kBasis_[0][0] = twoPi/a;
118 kBasis_[0][1] = -twoPi*cg/(sg*a);
120 kBasis_[1][1] = twoPi/(a*sg);
125 double a = parameters_[0];
126 double b = parameters_[1];
127 double gamma = parameters_[2];
130 double cg = cos(gamma);
131 double sg = sin(gamma);
135 rBasis_[1][0] = cg*b;
136 rBasis_[1][1] = sg*b;
139 drBasis_[0](0, 0) = 1.0;
140 drBasis_[0](0, 1) = 0.0;
142 drBasis_[1](1, 0) = cg;
143 drBasis_[1](1, 1) = sg;
145 drBasis_[2](1, 0) = -sg*b;
146 drBasis_[2](1, 1) = cg*b;
148 kBasis_[0][0] = twoPi/a;
149 kBasis_[0][1] = -twoPi*cg/(sg*a);
151 kBasis_[1][1] = twoPi/(b*sg);
167 lattice_ = other.lattice_;
227 if (buffer ==
"Square" || buffer ==
"square") {
230 if (buffer ==
"Rectangular" || buffer ==
"rectangular") {
233 if (buffer ==
"Rhombic" || buffer ==
"rhombic") {
236 if (buffer ==
"Hexagonal" || buffer ==
"hexagonal") {
239 if (buffer ==
"Oblique" || buffer ==
"oblique") {
242 UTIL_THROW(
"Invalid UnitCell<2>::LatticeSystem value input");
257 out <<
"rectangular";
int nParameter_
Number of parameters required to specify unit cell.
FArray< double, 6 > parameters_
Parameters used to describe the unit cell.
void setLattice()
Compute all protected data, given latticeSystem and parameters.
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.
LatticeSystem lattice() const
Return lattice system enumeration value.
void set(UnitCell< 2 >::LatticeSystem lattice)
Set the lattice system, but not unit cell parameters.
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.
int size() const
Return logical size of this array (i.e., number of elements).
#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.
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.