9#include <util/math/Constants.h>
32 if (lattice_ == UnitCell<2>::Hexagonal) {
35 if (lattice_ == UnitCell<2>::Rectangular) {
38 if (lattice_ == UnitCell<2>::Rhombic) {
41 if (lattice_ == UnitCell<2>::Oblique) {
51 void UnitCell<2>::setBasis()
58 if (lattice_ == UnitCell<2>::Square) {
60 for (i=0; i < 2; ++i) {
61 rBasis_[i][i] = parameters_[0];
62 kBasis_[i][i] = twoPi/parameters_[0];
63 drBasis_[0](i,i) = 1.0;
66 if (lattice_ == UnitCell<2>::Rectangular) {
68 for (i=0; i < 2; ++i) {
69 rBasis_[i][i] = parameters_[i];
70 kBasis_[i][i] = twoPi/parameters_[i];
71 drBasis_[i](i,i) = 1.0;
74 if (lattice_ == UnitCell<2>::Hexagonal) {
76 double a = parameters_[0];
77 double rt3 = sqrt(3.0);
81 rBasis_[1][0] = -0.5*a;
82 rBasis_[1][1] = 0.5*rt3*a;
84 drBasis_[0](0, 0) = 1.0;
85 drBasis_[0](0, 1) = 0.0;
86 drBasis_[0](1, 0) = -0.5;
87 drBasis_[0](1, 1) = 0.5*rt3;
89 kBasis_[0][0] = twoPi/a;
90 kBasis_[0][1] = twoPi/(rt3*a);
92 kBasis_[1][1] = twoPi/(0.5*rt3*a);
94 if (lattice_ == UnitCell<2>::Rhombic) {
96 double a = parameters_[0];
97 double gamma = parameters_[1];
100 double cg = cos(gamma);
101 double sg = sin(gamma);
106 rBasis_[1][0] = cg*a;
107 rBasis_[1][1] = sg*a;
109 drBasis_[0](0, 0) = 1.0;
110 drBasis_[0](0, 1) = 0.0;
111 drBasis_[0](1, 0) = cg;
112 drBasis_[0](1, 1) = sg;
113 drBasis_[1](1, 0) = -sg*a;
114 drBasis_[1](1, 1) = cg*a;
116 kBasis_[0][0] = twoPi/a;
117 kBasis_[0][1] = -twoPi*cg/(sg*a);
119 kBasis_[1][1] = twoPi/(a*sg);
122 if (lattice_ == UnitCell<2>::Oblique) {
124 double a = parameters_[0];
125 double b = parameters_[1];
126 double gamma = parameters_[2];
129 double cg = cos(gamma);
130 double sg = sin(gamma);
134 rBasis_[1][0] = cg*b;
135 rBasis_[1][1] = sg*b;
137 drBasis_[0](0, 0) = 1.0;
138 drBasis_[0](0, 1) = 0.0;
139 drBasis_[1](1, 0) = cg;
140 drBasis_[1](1, 1) = sg;
141 drBasis_[1](1, 0) = -sg*b;
142 drBasis_[1](1, 1) = cg*b;
144 kBasis_[0][0] = twoPi/a;
145 kBasis_[0][1] = -twoPi*cg/(sg*a);
147 kBasis_[1][1] = twoPi/(b*sg);
163 if (buffer ==
"Square" || buffer ==
"square") {
166 if (buffer ==
"Rectangular" || buffer ==
"rectangular") {
169 if (buffer ==
"Rhombic" || buffer ==
"rhombic") {
172 if (buffer ==
"Hexagonal" || buffer ==
"hexagonal") {
175 if (buffer ==
"Oblique" || buffer ==
"oblique") {
178 UTIL_THROW(
"Invalid UnitCell<2>::LatticeSystem value input");
193 out <<
"rectangular";
217 isInitialized_ =
false;
218 lattice_ = other.lattice_;
221 for (
int i = 0; i < nParameter_; ++i) {
233 isInitialized_ =
false;
244 isInitialized_ =
false;
247 for (
int i = 0; i < nParameter_; ++i) {
248 parameters_[i] = parameters[i];
int nParameter_
Number of parameters required to specify unit cell.
FArray< double, 6 > parameters_
Parameters used to describe the unit cell.
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.
C++ namespace for polymer self-consistent field theory (PSCF).
Utility classes for scientific computation.
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.