fermisurfer  2.0.0
fermisurfer
initialize.cpp
Go to the documentation of this file.
1 /*
2 The MIT License (MIT)
3 
4 Copyright (c) 2014 Mitsuaki KAWAMURA
5 
6 Permission is hereby granted, free of charge, to any person obtaining a copy
7 of this software and associated documentation files (the "Software"), to deal
8 in the Software without restriction, including without limitation the rights
9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 copies of the Software, and to permit persons to whom the Software is
11 furnished to do so, subject to the following conditions:
12 
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15 
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 THE SOFTWARE.
23 */
24 /**@file
25 @brief Functions that initilize variables.
26 */
27 #include <wx/wx.h>
28 #if defined(HAVE_CONFIG_H)
29 #include <config.h>
30 #endif
31 #if defined(HAVE_GL_GL_H)
32 #include <GL/gl.h>
33 #elif defined(HAVE_OPENGL_GL_H)
34 #include <OpenGL/gl.h>
35 #endif
36 #include "variable.hpp"
37 #include "basic_math.hpp"
38 /**
39  @brief Specify corners of tetrahedron
40 
41  Modify : ::corner
42 */
44 {
45  int i, j;
46  int corner1[16][6][4] = {
47  /*
48  [0] min = 0-7
49  */
50  { { 0, 1, 3, 7 },
51  { 0, 1, 5, 7 },
52  { 0, 2, 3, 7 },
53  { 0, 2, 6, 7 },
54  { 0, 4, 5, 7 },
55  { 0, 4, 6, 7 } },
56  /*
57  [1] min = 1-6
58  */
59  { { 1, 0, 2, 6 },
60  { 1, 0, 4, 6 },
61  { 1, 3, 2, 6 },
62  { 1, 3, 7, 6 },
63  { 1, 5, 4, 6 },
64  { 1, 5, 7, 6 } },
65  /*
66  [2] min = 2-5
67  */
68  { { 2, 0, 1, 5 },
69  { 2, 0, 4, 5 },
70  { 2, 3, 1, 5 },
71  { 2, 3, 7, 5 },
72  { 2, 6, 4, 5 },
73  { 2, 6, 7, 5 } },
74  /*
75  [3] min = 3-4
76  */
77  { { 4, 0, 1, 3 },
78  { 4, 0, 2, 3 },
79  { 4, 5, 1, 3 },
80  { 4, 5, 7, 3 },
81  { 4, 6, 2, 3 },
82  { 4, 6, 7, 3 } },
83  /*
84  [4] min = 0-7, max = 3-4
85  */
86  { { 0, 4, 5, 6 },
87  { 1, 2, 3, 7 },
88  { 0, 7, 2, 6 },
89  { 0, 7, 1, 5 },
90  { 0, 7, 1, 2 },
91  { 0, 7, 6, 5 } },
92  /*
93  [5] min = 1-6, max = 3-4
94  */
95  { { 0, 4, 5, 6 },
96  { 1, 2, 3, 7 },
97  { 1, 6, 5, 7 },
98  { 1, 6, 7, 2 },
99  { 1, 6, 2, 0 },
100  { 1, 6, 0, 5 } },
101  /*
102  [6] min = 2-5, max = 3-4
103  */
104  { { 0, 4, 5, 6 },
105  { 1, 2, 3, 7 },
106  { 2, 5, 7, 6 },
107  { 2, 5, 6, 0 },
108  { 2, 5, 0, 1 },
109  { 2, 5, 1, 7 } },
110  /*
111  [7] min = 3-4, max = 0-7
112  */
113  { { 0, 1, 2, 4 },
114  { 7, 3, 5, 6 },
115  { 3, 4, 1, 5 },
116  { 3, 4, 5, 6 },
117  { 3, 4, 6, 2 },
118  { 3, 4, 2, 1 } },
119  /*
120  [8] min = 2-5, max = 0-7
121  */
122  { { 0, 1, 2, 4 },
123  { 7, 3, 5, 6 },
124  { 2, 5, 1, 3 },
125  { 2, 5, 3, 6 },
126  { 2, 5, 6, 4 },
127  { 2, 5, 4, 1 } },
128  /*
129  [9] min = 1-6, max = 0-7
130  */
131  { { 0, 1, 2, 4 },
132  { 7, 3, 5, 6 },
133  { 1, 6, 2, 3 },
134  { 1, 6, 3, 5 },
135  { 1, 6, 5, 4 },
136  { 1, 6, 4, 2 } },
137  /*
138  [10] min = 0-7, max = 1-6
139  */
140  { { 1, 0, 3, 5 },
141  { 6, 2, 4, 7 },
142  { 0, 7, 2, 3 },
143  { 0, 7, 3, 5 },
144  { 0, 7, 5, 4 },
145  { 0, 7, 4, 2 } },
146  /*
147  [11] min = 3-4, max = 1-6
148  */
149  { { 1, 0, 3, 5 },
150  { 6, 2, 4, 7 },
151  { 3, 4, 0, 2 },
152  { 3, 4, 2, 7 },
153  { 3, 4, 7, 5 },
154  { 3, 4, 5, 0 } },
155  /*
156  [12] min = 2-5, max = 1-6
157  */
158  { { 1, 0, 3, 5 },
159  { 6, 2, 4, 7 },
160  { 2, 5, 0, 3 },
161  { 2, 5, 3, 7 },
162  { 2, 5, 7, 4 },
163  { 2, 5, 4, 0 } },
164  /*
165  [13] min = 0-7, max = 2-5
166  */
167  { { 2, 0, 3, 6 },
168  { 5, 1, 4, 7 },
169  { 0, 7, 1, 3 },
170  { 0, 7, 3, 6 },
171  { 0, 7, 6, 4 },
172  { 0, 7, 4, 1 } },
173  /*
174  [14] min = 1-6, max = 2-5
175  */
176  { { 2, 0, 3, 6 },
177  { 5, 1, 4, 7 },
178  { 1, 6, 0, 3 },
179  { 1, 6, 3, 7 },
180  { 1, 6, 7, 4 },
181  { 1, 6, 4, 0 } },
182  /*
183  [15] min = 3-4, max = 2-5
184  */
185  { { 2, 0, 3, 6 },
186  { 5, 1, 4, 7 },
187  { 3, 4, 0, 1 },
188  { 3, 4, 1, 7 },
189  { 3, 4, 7, 6 },
190  { 3, 4, 6, 0 } },
191  };
192  /**/
193  for (i = 0; i < 6; ++i) {
194  for (j = 0; j < 4; ++j) {
195  corner[i][j] = corner1[itet][i][j];
196  }
197  }
198 }
199 /**
200  @brief Compute Bragg vetor
201 
202  Modify : ::bragg, ::brnrm
203 */
205 {
206  int i0, i1, i2, i, ibr, sw[4];
207  float ldiag[4], bdiag[4][3];
208  /**/
209  ibr = 0;
210  /**/
211  for (i0 = -1; i0 <= 1; ++i0) {
212  for (i1 = -1; i1 <= 1; ++i1) {
213  for (i2 = -1; i2 <= 1; ++i2) {
214  /*
215  Excepte Gamma points
216  */
217  if (i0 == 0 && i1 == 0 && i2 == 0) continue;
218  /*
219  Fractional -> Cartecian
220  */
221  for (i = 0; i < 3; ++i)
222  bragg[ibr][i] = ((GLfloat)i0 * bvec[0][i]
223  + (GLfloat)i1 * bvec[1][i]
224  + (GLfloat)i2 * bvec[2][i]) * 0.5f;
225  /*
226  And its norm
227  */
228  brnrm[ibr] = bragg[ibr][0] * bragg[ibr][0]
229  + bragg[ibr][1] * bragg[ibr][1]
230  + bragg[ibr][2] * bragg[ibr][2];
231  /**/
232  ibr = ibr + 1;
233  }/*for (i2 = -1; i2 <= 1; ++i2)*/
234  }/*for (i1 = -1; i1 <= 1; ++i1)*/
235  }/*for (i0 = -1; i0 <= 1; ++i0)*/
236  /*
237  Search min. of brnrm
238  */
239  brnrm_min = brnrm[0];
240  for (ibr = 1; ibr < 26; ibr++) {
241  if (brnrm_min > brnrm[ibr]) brnrm_min = brnrm[ibr];
242  }
243  *terminal << wxString::Format(wxT(" Minimum Bragg norm : %f\n"), brnrm_min);
244  //
245  // Serch shortest diagonal line
246  //
247  for (i = 0; i < 3; i++) {
248  bdiag[0][i] = bvec[0][i] / (float)ng0[0] + bvec[1][i] / (float)ng0[1] + bvec[2][i] / (float)ng0[2];
249  bdiag[1][i] = bvec[0][i] / (float)ng0[0] + bvec[1][i] / (float)ng0[1] - bvec[2][i] / (float)ng0[2];
250  bdiag[2][i] = bvec[0][i] / (float)ng0[0] - bvec[1][i] / (float)ng0[1] + bvec[2][i] / (float)ng0[2];
251  bdiag[3][i] = -bvec[0][i] / (float)ng0[0] + bvec[1][i] / (float)ng0[1] + bvec[2][i] / (float)ng0[2];
252  }
253  for (i = 0; i < 4; i++)
254  ldiag[i] = bdiag[i][0] * bdiag[i][0] + bdiag[i][1] * bdiag[i][1] + bdiag[i][2] * bdiag[i][2];
255  eigsort(4, ldiag, sw);
256  itet = sw[0];
257 }/* bragg_vector */
258 /**
259  @brief Print max and minimum @f$\varepsilon_{n k}, \Delta_{n k}@f$
260  in the whole Brillouine zone
261 */
263 {
264  int ib, i0, i1, i2;
265  GLfloat eigmin, eigmax, matmin, matmax;
266  /**/
267  *terminal << wxT("\n");
268  *terminal << wxT(" ## Max. and Min. of each bands #######################\n");
269  *terminal << wxT("\n");
270  *terminal << wxT(" Band Eig_Min. Eig_Max Mat_Min Mat_Max\n");
271  for (ib = 0; ib < nb; ib++) {
272  eigmax = eig0[ib][0][0][0];
273  eigmin = eig0[ib][0][0][0];
274  matmax = mat0[ib][0][0][0][0];
275  matmin = mat0[ib][0][0][0][0];
276  for (i0 = 0; i0 < ng0[0]; ++i0) {
277  for (i1 = 0; i1 < ng0[1]; ++i1) {
278  for (i2 = 0; i2 < ng0[2]; ++i2) {
279  if (eig0[ib][i0][i1][i2] > eigmax) eigmax = eig0[ib][i0][i1][i2];
280  if (eig0[ib][i0][i1][i2] < eigmin) eigmin = eig0[ib][i0][i1][i2];
281  if (mat0[ib][i0][i1][i2][0] > matmax) matmax = mat0[ib][i0][i1][i2][0];
282  if (mat0[ib][i0][i1][i2][0] < matmin) matmin = mat0[ib][i0][i1][i2][0];
283  }/*for (i2 = 0; i2 < ng0[2]; ++i2)*/
284  }/*for (i1 = 0; i1 < ng0[1]; ++i1)*/
285  }/*for (i0 = 0; i0 < ng0[0]; ++i0)*/
286  *terminal << wxString::Format(wxT(" %d %f %f %f %f\n"),
287  ib + 1, eigmin, eigmax, matmin, matmax);
288  }/*for (ib = 0; ib < nb; ib++)*/
289 }/* max_and_min_bz */
eig0
GLfloat **** eig0
Eigenvalues [nb][ng0[0]][ng0[1]][ng0[2]].
Definition: fermisurfer.cpp:102
mat0
GLfloat ***** mat0
Matrix element [nb][ng0[0]][ng0[1]][ng0[2]][3].
Definition: fermisurfer.cpp:103
eigsort
void eigsort(int n, GLfloat *key, int *swap)
Simple sort.
Definition: basic_math.cpp:88
bragg_vector
void bragg_vector()
Compute Bragg vetor.
Definition: initialize.cpp:204
basic_math.hpp
variable.hpp
Global variables.
bragg
GLfloat bragg[26][3]
Bragg plane vectors.
Definition: fermisurfer.cpp:129
init_corner
void init_corner()
Specify corners of tetrahedron.
Definition: initialize.cpp:43
itet
int itet
Counter for tetrahedron.
Definition: fermisurfer.cpp:147
nb
int nb
The number of Bands.
Definition: fermisurfer.cpp:99
max_and_min_bz
void max_and_min_bz()
Print max and minimum in the whole Brillouine zone.
Definition: initialize.cpp:262
brnrm_min
GLfloat brnrm_min
Minimum scale of the reciplocal space.
Definition: fermisurfer.cpp:131
corner
int corner[6][4]
Corners of tetrahedron.
Definition: fermisurfer.cpp:217
bvec
GLfloat bvec[3][3]
Reciprocal lattice vector.
Definition: fermisurfer.cpp:101
brnrm
GLfloat brnrm[26]
Norms of Bragg plane vectors.
Definition: fermisurfer.cpp:130
terminal
wxTextCtrl * terminal
Definition: fermisurfer.cpp:237
ng0
int ng0[3]
-point grid in the input file
Definition: fermisurfer.cpp:97