20 #ifndef JDFTX_CORE_WIGNERSEITZ_H 21 #define JDFTX_CORE_WIGNERSEITZ_H 25 #include <core/matrix3.h> 40 {
static const double tol = 1e-8;
45 for(
const Face* f: faceHalf)
46 {
double d = 0.5 * (1. +
dot(f->eqn, xWS));
47 if(d<-tol || d>1.+tol)
48 { xWS -= floor(d) * f->img;
58 {
static const double tol = 1e-8;
63 for(
const Face* f: faceHalf)
64 {
double xDotEqn = 0.;
65 for(
int k=0; k<3; k++)
66 xDotEqn += f->eqn[k] * ivWS[k] * invS[k];
67 double d = 0.5 * (1. + xDotEqn);
68 if(d<-tol || d>1.+tol)
69 {
int id = int(floor(d));
70 for(
int k=0; k<3; k++)
71 ivWS[k] -=
id * f->img[k] * S[k];
83 {
double minDistSq = DBL_MAX;
84 for(
const Face* f: faceHalf)
85 if(iDir<0 || !f->img[iDir])
86 {
double dDiff = 0.5*(1. - fabs(
dot(f->eqn, x)));
87 if(dDiff < 0.)
return 0.;
88 double distSq = dDiff*dDiff * RTR.metric_length_squared(f->img);
89 if(distSq<minDistSq) minDistSq = distSq;
91 return sqrt(minDistSq);
97 {
static const double tol = 1e-8;
98 double minDistSq = DBL_MAX;
99 for(
const Face* f: faceHalf)
100 if(iDir<0 || !f->img[iDir])
101 {
double dDiff = 0.5*(1. - fabs(
dot(f->eqn, x)));
102 if(dDiff < -tol)
return false;
103 double distSq = dDiff*dDiff * RTR.metric_length_squared(f->img);
104 if(distSq<minDistSq) minDistSq = distSq;
106 return minDistSq<tol;
141 std::list<Vertex*> vertex;
142 std::set<Edge*> edge;
143 std::set<Face*> face;
144 std::vector<Face*> faceHalf;
149 std::list<Edge*> edge;
154 { std::array<Vertex*,2> vertex;
155 std::array<Face*,2> face;
162 std::list<Edge*> edge;
171 void addEdge(Face* f, Vertex* vStart, Vertex* vEnd,
bool lastEdge=
false);
174 #endif // JDFTX_CORE_WIGNERSEITZ_H ScalarField sqrt(const ScalarField &)
Elementwise square root (preserve input)
double inRadius(int iDir=-1) const
complex dot(const Tptr &X, const Tptr &Y)
Definition: Operators.h:196
WignerSeitz(const matrix3<> &R)
Construct Wigner-Seitz cell given lattice vectors.
void checkGraph() const
Check if the data structure is valid (all links are reciprocated etc.)
vector3 restrict(const vector3<> &x) const
Find the point within the Wigner-Seitz cell equivalent to x (lattice coordinates) ...
Definition: WignerSeitz.h:39
void writeWireframePlot(const char *filename) const
Write a wireframe plot to file (for gnuplot)
void writeGraph(FILE *fp=stdout) const
Output vertex, edge and face connectivity info:
static const double geomRelTol
relative tolerance for orthogonality and volume checks
Definition: WignerSeitz.h:129
vector3< int > restrict(const vector3< int > &iv, const vector3< int > &S, const vector3<> &invS) const
Find the point within the Wigner-Seitz cell equivalent to iv (mesh coordinates with sample count S) ...
Definition: WignerSeitz.h:57
Wigner-Seitz construction for a 3D lattice (2D lattice may be handled with orthogonal 3rd direction) ...
Definition: WignerSeitz.h:32
static bool isOrthogonal(const vector3<> &, const vector3<> &)
Check whether lattice vectors are orthogonal (within relative tolerance geomRelTol) ...
double boundaryDistance(const vector3<> &x, int iDir=-1) const
Definition: WignerSeitz.h:82
void writeWireframeDX(const char *filename) const
Write a wireframe plot for Data Explorer (.dx)
bool onBoundary(const vector3<> &x, int iDir=-1) const
Definition: WignerSeitz.h:96
double circumRadius(int iDir=-1) const