1 /* GabeditKPoints.c */
2 /**********************************************************************************************************
3 Copyright (c) 2002-2013 Abdul-Rahman Allouche. All rights reserved
4
5 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6 documentation files (the Gabedit), to deal in the Software without restriction, including without limitation
7 the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
8 and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9
10 The above copyright notice and this permission notice shall be included in all copies or substantial portions
11 of the Software.
12
13 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
14 TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
15 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
16 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 DEALINGS IN THE SOFTWARE.
18 ************************************************************************************************************/
19
20 #include "../../Config.h"
21 #include <math.h>
22 #include <stdlib.h>
23 #include <stdio.h>
24 #include <ctype.h>
25 #include <string.h>
26 #include "../../spglib/spglib.h"
27 #include "../Common/Global.h"
28 #include "../Utils/Constants.h"
29 #include "../Utils/Utils.h"
30 #include "../Utils/AtomsProp.h"
31 #include "../Crystallography/Crystallo.h"
32 #include "../Crystallography/GabeditSPG.h"
33 #include "../Crystallography/GabeditKPoints.h"
34
35
36 /*************************************************************************************/
g_list_free_all(GList * list,GDestroyNotify free_func)37 static void g_list_free_all (GList * list, GDestroyNotify free_func)
38 {
39 g_list_foreach (list, (GFunc) free_func, NULL);
40 g_list_free (list);
41 }
42 /********************************************************************************/
freeGabeditKPoints(GabeditKPointsPath * kpoints)43 void freeGabeditKPoints(GabeditKPointsPath* kpoints)
44 {
45 if(!kpoints) return;
46 if(kpoints->path) g_list_free(kpoints->path);
47 if(kpoints->points) g_list_free_all(kpoints->points, g_free);
48 if(kpoints->strPathPrim) g_free(kpoints->strPathPrim);
49 if(kpoints->strPathConv) g_free(kpoints->strPathConv);
50 if(kpoints->strPointsPrim) g_free(kpoints->strPointsPrim);
51 if(kpoints->strPointsConv) g_free(kpoints->strPointsConv);
52 if(kpoints->strAtomsConv) g_free(kpoints->strAtomsConv);
53 if(kpoints->strAtomsPrim) g_free(kpoints->strAtomsPrim);
54 if(kpoints->spaceGroupName) g_free(kpoints->spaceGroupName);
55 /* freeCrystallo(kpoints); */
56 }
57 /********************************************************************************/
initGabeditKPoints(GabeditKPointsPath * kpoints)58 void initGabeditKPoints(GabeditKPointsPath* kpoints)
59 {
60 gint i,j;
61 if(!kpoints) return;
62 kpoints->points = NULL;
63 kpoints->path = NULL;
64 kpoints->strPathPrim = NULL;
65 kpoints->strPathConv = NULL;
66 kpoints->strPointsPrim = NULL;
67 kpoints->strPointsConv = NULL;
68 kpoints->strAtomsConv = NULL;
69 kpoints->strAtomsPrim = NULL;
70 kpoints->spaceGroupName = NULL;
71 for(i=0;i<3;i++)
72 for(j=0;j<3;j++) kpoints->Q[i][j] = kpoints->Qm1[i][j] = 0.0;
73 for(i=0;i<3;i++) kpoints->Q[i][i] = kpoints->Qm1[i][i] = 1.0;
74 }
75 /***********************************************************************************************/
getQFromPearsonSymbol(gdouble Q[][3],gdouble Qm1[][3],gchar * pearsonSymbol)76 static gboolean getQFromPearsonSymbol(gdouble Q[][3], gdouble Qm1[][3], gchar* pearsonSymbol)
77 {
78
79 gchar name[5];
80 gint i,j;
81 gboolean ok = FALSE;
82 if(!pearsonSymbol || strlen(pearsonSymbol)<2) return FALSE;
83 sprintf(name,"%c%c",tolower(pearsonSymbol[0]), toupper(pearsonSymbol[1]));
84 ok = TRUE;
85 if(!strcmp(name,"cP") || !strcmp(name,"tP") || !strcmp(name,"oP") || !strcmp(name,"mP"))
86 {
87 for(i=0;i<3;i++) Q[i][i] = Qm1[i][i] = 1.0;
88 for(i=0;i<3;i++) for(j=i+1;j<3;j++) Q[i][j] = Qm1[i][j] = Q[j][i] = Qm1[j][i] = 0.0;
89 }
90 else if(!strcmp(name,"cF") || !strcmp(name,"oF") )
91 {
92 for(i=0;i<3;i++) for(j=0;j<3;j++) Q[i][j] = 0.5;
93 for(i=0;i<3;i++) Q[i][i] = -0.5;
94
95 for(i=0;i<3;i++) for(j=0;j<3;j++) Qm1[i][j] = 1.0;
96 for(i=0;i<3;i++) Qm1[i][i] = 0.0;
97 }
98 else if(!strcmp(name,"oI") || !strcmp(name,"cI") )
99 {
100 for(i=0;i<3;i++) for(j=0;j<3;j++) Q[i][j] = 0.5;
101 for(i=0;i<3;i++) Q[i][i] = 0.0;
102 for(i=0;i<3;i++) for(j=0;j<3;j++) Qm1[i][j] = 1.0;
103 for(i=0;i<3;i++) Qm1[i][i] = -1.0;
104 }
105 else if(!strcmp(name,"tI"))
106 {
107 for(i=0;i<3;i++) for(j=0;j<3;j++) Q[i][j] = 0.5;
108 Q[0][0] = -0.5;
109 Q[2][0] = Q[2][2] = 0.0;
110 Q[2][1] = 1.0;
111
112 for(i=0;i<3;i++) for(j=0;j<3;j++) Qm1[i][j] = 1.0;
113 Qm1[0][0] = Qm1[2][2] = -1.0;
114 Qm1[0][2] = 0;
115 Qm1[1][0] = 0;
116 Qm1[1][1] = 0;
117 }
118 else if(!strcmp(name,"hP"))
119 {
120 for(i=0;i<3;i++) for(j=0;j<3;j++) Q[i][j] = 0.0;
121 for(i=0;i<3;i++) Q[i][i] = 1.0;
122 Q[1][0] = 1.0;
123
124 for(i=0;i<3;i++) for(j=0;j<3;j++) Qm1[i][j] = 0.0;
125 for(i=0;i<3;i++) Qm1[i][i] = 1.0;
126 Qm1[1][0] = -1.0;
127 }
128 else if(!strcmp(name,"hR"))
129 {
130 for(i=0;i<3;i++) for(j=0;j<3;j++) Q[i][j] = 1.0/3.0;
131 Q[0][0] = 2.0/3.0;
132 Q[1][0] = -1.0/3.0;
133 Q[2][0] = -1.0/3.0;
134 Q[2][1] = -2.0/3.0;
135 for(i=0;i<3;i++) for(j=0;j<3;j++) Qm1[i][j] = 1.0;
136 Qm1[0][1] = -1.0;
137 Qm1[0][2] = 0.0;
138 Qm1[1][0] = 0.0;
139 Qm1[1][2] = -1.0;
140 }
141 else if(!strcmp(name,"oC") || !strcmp(name,"oA") )
142 {
143 for(i=0;i<3;i++) for(j=0;j<3;j++) Q[i][j] = 0.5;
144 Q[0][1] = -0.5;
145 Q[0][2] = 0.0;
146 Q[1][2] = 0.0;
147 Q[2][0] = 0.0;
148 Q[2][1] = 0.0;
149 Q[2][2] = 1.0;
150 for(i=0;i<3;i++) for(j=0;j<3;j++) Qm1[i][j] = 1.0;
151 Qm1[0][2] = 0.0;
152 Qm1[1][0] = -1.0;
153 Qm1[1][2] = 0.0;
154 Qm1[2][0] = 0.0;
155 Qm1[2][1] = 0.0;
156 }
157 else if(!strcmp(name,"mC"))
158 {
159 for(i=0;i<3;i++) for(j=0;j<3;j++) Q[i][j] = 0.5;
160 Q[0][2] = 0.0;
161 Q[1][0] = -1.0;
162 Q[1][2] = 0.0;
163 Q[2][0] = 0.0;
164 Q[2][1] = 0.0;
165 Q[2][2] = 1.0;
166 for(i=0;i<3;i++) for(j=0;j<3;j++) Qm1[i][j] = 1.0;
167 Qm1[0][1] = -1.0;
168 Qm1[0][2] = 0.0;
169 Qm1[1][2] = 0.0;
170 Qm1[2][0] = 0.0;
171 Qm1[2][1] = 0.0;
172 }
173 else {
174 for(i=0;i<3;i++) Q[i][i] = Qm1[i][i] = 1.0;
175 for(i=0;i<3;i++) for(j=i+1;j<3;j++) Q[i][j] = Qm1[i][j] = Q[j][i] = Qm1[j][i] = 0.0;
176 }
177 return ok;
178 }
179 /***********************************************************************************************/
addAPoint(GList ** pPoints,gchar * name,gdouble x1,gdouble x2,gdouble x3)180 static void addAPoint(GList** pPoints, gchar* name, gdouble x1, gdouble x2, gdouble x3)
181 {
182 GabeditKPoint* point = g_malloc(sizeof(GabeditKPoint));
183 sprintf(point->name,"%s",name);
184 point->C[0] = x1;
185 point->C[1] = x2;
186 point->C[2] = x3;
187 //fprintf(stderr," END addAPoint %s %f %f %f\n",point->name, point->C[0], point->C[1], point->C[2]);
188 //fprintf(stderr," END addAPoint x123 %s %f %f %f\n",name, x1,x2,x3);
189 *pPoints=g_list_append(*pPoints, (gpointer) point);
190 }
191 /***********************************************************************************************/
setPoints(GList ** pPoints,gchar * extendedPearsonSymbol,Crystal * crystal)192 static gboolean setPoints(GList** pPoints, gchar* extendedPearsonSymbol, Crystal* crystal)
193 {
194 gboolean ok = TRUE;
195 if(!strcmp(extendedPearsonSymbol,"aP2")){
196 addAPoint(pPoints, "GAMMA", 0.0, 0.0, 0.0);
197 addAPoint(pPoints, "Z", 0.0, 0.0, 1.0/2);
198 addAPoint(pPoints, "Y", 0.0, 1.0/2, 0.0);
199 addAPoint(pPoints, "X", 1.0/2, 0.0, 0.0);
200 addAPoint(pPoints, "V", 1.0/2, 1.0/2, 0.0);
201 addAPoint(pPoints, "U", 1.0/2, 0.0, 1.0/2);
202 addAPoint(pPoints, "T", 0.0, 1.0/2, 1.0/2);
203 addAPoint(pPoints, "R", 1.0/2, 1.0/2, 1.0/2);
204 }
205 else if(!strcmp(extendedPearsonSymbol,"aP3")){
206 addAPoint(pPoints, "GAMMA", 0.0, 0.0, 0.0);
207 addAPoint(pPoints, "Z", 0.0, 0.0, 1.0/2);
208 addAPoint(pPoints, "Y", 0.0, 1.0/2, 0.0);
209 addAPoint(pPoints, "Y_2", 0.0, -1.0/2, 0.0);
210 addAPoint(pPoints, "X", 1.0/2, 0.0, 0.0);
211 addAPoint(pPoints, "V_2", 1.0/2, -1.0/2, 0.0);
212 addAPoint(pPoints, "U_2", -1.0/2, 0.0, 1.0/2);
213 addAPoint(pPoints, "T_2", 0.0, -1.0/2, 1.0/2);
214 addAPoint(pPoints, "R_2", -1.0/2, -1.0/2, 1.0/2);
215 }
216 else if(!strcmp(extendedPearsonSymbol,"cF1")){
217 addAPoint(pPoints, "GAMMA", 0.0, 0.0, 0.0);
218 addAPoint(pPoints, "X", 1.0/2, 0.0, 1.0/2);
219 addAPoint(pPoints, "L", 1.0/2, 1.0/2, 1.0/2);
220 addAPoint(pPoints, "W", 1.0/2, 1.0/4, 3.0/4);
221 addAPoint(pPoints, "W_2", 3.0/4, 1.0/4, 1.0/2);
222 addAPoint(pPoints, "K", 3.0/8, 3.0/8, 3.0/4);
223 addAPoint(pPoints, "U", 5.0/8, 1.0/4, 5.0/8);
224 }
225 else if(!strcmp(extendedPearsonSymbol,"cF2")){
226 addAPoint(pPoints, "GAMMA", 0.0, 0.0, 0.0);
227 addAPoint(pPoints, "X", 1.0/2, 0.0, 1.0/2);
228 addAPoint(pPoints, "L", 1.0/2, 1.0/2, 1.0/2);
229 addAPoint(pPoints, "W", 1.0/2, 1.0/4, 3.0/4);
230 addAPoint(pPoints, "W_2", 3.0/4, 1.0/4, 1.0/2);
231 addAPoint(pPoints, "K", 3.0/8, 3.0/8, 3.0/4);
232 addAPoint(pPoints, "U", 5.0/8, 1.0/4, 5.0/8);
233 }
234 else if(!strcmp(extendedPearsonSymbol,"cI1")){
235 addAPoint(pPoints, "GAMMA", 0.0, 0.0, 0.0);
236 addAPoint(pPoints, "H", 1.0/2, -1.0/2, 1.0/2);
237 addAPoint(pPoints, "P", 1.0/4, 1.0/4, 1.0/4);
238 addAPoint(pPoints, "N", 0.0, 0.0, 1.0/2);
239 }
240 else if(!strcmp(extendedPearsonSymbol,"cP1")){
241 addAPoint(pPoints, "GAMMA", 0.0, 0.0, 0.0);
242 addAPoint(pPoints, "R", 1.0/2, 1.0/2, 1.0/2);
243 addAPoint(pPoints, "M", 1.0/2, 1.0/2, 0.0);
244 addAPoint(pPoints, "X", 0.0, 1.0/2, 0.0);
245 addAPoint(pPoints, "X_1", 1.0/2, 0.0, 0.0);
246 }
247 else if(!strcmp(extendedPearsonSymbol,"cP2")){
248 addAPoint(pPoints, "GAMMA", 0.0, 0.0, 0.0);
249 addAPoint(pPoints, "R", 1.0/2, 1.0/2, 1.0/2);
250 addAPoint(pPoints, "M", 1.0/2, 1.0/2, 0.0);
251 addAPoint(pPoints, "X", 0.0, 1.0/2, 0.0);
252 addAPoint(pPoints, "X_1", 1.0/2, 0.0, 0.0);
253 }
254 else if(!strcmp(extendedPearsonSymbol,"hP1")){
255 addAPoint(pPoints, "GAMMA", 0.0, 0.0, 0.0);
256 addAPoint(pPoints, "A", 0.0, 0.0, 1.0/2);
257 addAPoint(pPoints, "K", 1.0/3, 1.0/3, 0.0);
258 addAPoint(pPoints, "H", 1.0/3, 1.0/3, 1.0/2);
259 addAPoint(pPoints, "H_2", 1.0/3, 1.0/3, -1.0/2);
260 addAPoint(pPoints, "M", 1.0/2, 0.0, 0.0);
261 addAPoint(pPoints, "L", 1.0/2, 0.0, 1.0/2);
262 }
263 else if(!strcmp(extendedPearsonSymbol,"hP2")){
264 addAPoint(pPoints, "GAMMA", 0.0, 0.0, 0.0);
265 addAPoint(pPoints, "A", 0.0, 0.0, 1.0/2);
266 addAPoint(pPoints, "K", 1.0/3, 1.0/3, 0.0);
267 addAPoint(pPoints, "H", 1.0/3, 1.0/3, 1.0/2);
268 addAPoint(pPoints, "H_2", 1.0/3, 1.0/3, -1.0/2);
269 addAPoint(pPoints, "M", 1.0/2, 0.0, 0.0);
270 addAPoint(pPoints, "L", 1.0/2, 0.0, 1.0/2);
271 }
272 else if(!strcmp(extendedPearsonSymbol,"hR1")){
273 gdouble delta=crystal->a*crystal->a/4/(crystal->c*crystal->c);
274 gdouble nu=1.0/3.0+delta;
275 gdouble eta=5.0/6.0-2*delta;
276 addAPoint(pPoints, "GAMMA", 0.0, 0.0, 0.0);
277 addAPoint(pPoints, "T", 1.0/2, 1.0/2, 1.0/2);
278 addAPoint(pPoints, "L", 1.0/2, 0.0, 0.0);
279 addAPoint(pPoints, "L_2", 0.0, -1.0/2, 0.0);
280 addAPoint(pPoints, "L_4", 0.0, 0.0, -1.0/2);
281 addAPoint(pPoints, "F", 1.0/2, 0.0, 1.0/2);
282 addAPoint(pPoints, "F_2", 1.0/2, 1.0/2, 0.0);
283 addAPoint(pPoints, "S_0", nu, -nu, 0.0);
284 addAPoint(pPoints, "S_2", 1-nu, 0.0, nu);
285 addAPoint(pPoints, "S_4", nu, 0.0, -nu);
286 addAPoint(pPoints, "S_6", 1-nu, nu, 0.0);
287 addAPoint(pPoints, "H_0", 1.0/2, -1+eta, 1-eta);
288 addAPoint(pPoints, "H_2", eta, 1-eta, 1.0/2);
289 addAPoint(pPoints, "H_4", eta, 1.0/2, 1-eta);
290 addAPoint(pPoints, "H_6", 1.0/2, 1-eta, -1+eta);
291 addAPoint(pPoints, "M_0", nu, -1+eta, nu);
292 addAPoint(pPoints, "M_2", 1-nu, 1-eta, 1-nu);
293 addAPoint(pPoints, "M_4", eta, nu, nu);
294 addAPoint(pPoints, "M_6", 1-nu, 1-nu, 1-eta);
295 addAPoint(pPoints, "M_8", nu, nu, -1+eta);
296 }
297 else if(!strcmp(extendedPearsonSymbol,"hR2")){
298
299 gdouble xi=1.0/6.0-crystal->c*crystal->c/9/(crystal->a*crystal->a);
300 gdouble eta=1.0/2.0-2*xi;
301 gdouble nu=1.0/2.0+xi;
302
303 addAPoint(pPoints, "GAMMA", 0.0, 0.0, 0.0);
304 addAPoint(pPoints, "T", 1.0/2, -1.0/2, 1.0/2);
305 addAPoint(pPoints, "P_0", eta, -1+eta, eta);
306 addAPoint(pPoints, "P_2", eta, eta, eta);
307 addAPoint(pPoints, "R_0", 1-eta, -eta, -eta);
308 addAPoint(pPoints, "M", 1-nu, -nu, 1-nu);
309 addAPoint(pPoints, "M_2", nu, -1+nu, -1+nu);
310 addAPoint(pPoints, "L", 1.0/2, 0.0, 0.0);
311 addAPoint(pPoints, "F", 1.0/2, -1.0/2, 0.0);
312 }
313 else if(!strcmp(extendedPearsonSymbol,"mC1")){
314 gdouble beta=crystal->beta*M_PI/180.0;
315 gdouble a=crystal->a;
316 gdouble b=crystal->b;
317 gdouble c=crystal->c;
318 gdouble cbeta = cos(beta);
319 gdouble sbeta = sin(beta);
320 gdouble xi = (2.0+a/c*cbeta)/4/(sbeta*sbeta);
321 gdouble eta = 1.0/2.0-2*xi*c*cbeta/a;
322 gdouble psi = 3.0/4.0-b*b/4/a/a/sbeta/sbeta;
323 gdouble phi = psi-(3.0/4-psi)*a*cbeta/c;
324
325 addAPoint(pPoints, "GAMMA", 0.0, 0.0, 0.0);
326 addAPoint(pPoints, "Y_2", -1.0/2, 1.0/2, 0.0);
327 addAPoint(pPoints, "Y_4", 1.0/2, -1.0/2, 0.0);
328 addAPoint(pPoints, "A", 0.0, 0.0, 1.0/2);
329 addAPoint(pPoints, "M_2", -1.0/2, 1.0/2, 1.0/2);
330 addAPoint(pPoints, "V", 1.0/2, 0.0, 0.0);
331 addAPoint(pPoints, "V_2", 0.0, 1.0/2, 0.0);
332 addAPoint(pPoints, "L_2", 0.0, 1.0/2, 1.0/2);
333 addAPoint(pPoints, "C", 1-psi, 1-psi, 0.0);
334 addAPoint(pPoints, "C_2", -1+psi, psi, 0.0);
335 addAPoint(pPoints, "C_4", psi, -1+psi, 0.0);
336 addAPoint(pPoints, "D", -1+phi, phi, 1.0/2);
337 addAPoint(pPoints, "D_2", 1-phi, 1-phi, 1.0/2);
338 addAPoint(pPoints, "E", -1+xi, 1-xi, 1-eta);
339 addAPoint(pPoints, "E_2", -xi, xi, eta);
340 addAPoint(pPoints, "E_4", xi, -xi, 1-eta);
341 }
342 else if(!strcmp(extendedPearsonSymbol,"mC2")){
343 gdouble beta=crystal->beta*M_PI/180.0;
344 gdouble a=crystal->a;
345 gdouble b=crystal->b;
346 gdouble c=crystal->c;
347 gdouble cbeta = cos(beta);
348 gdouble sbeta = sin(beta);
349 gdouble mu = 1.0/4.0*(1+a*a/b/b);
350 gdouble delta = -a*c*cbeta/2/b/b;
351 gdouble xi = 1.0/4.0*(a*a/b/b+(1+a/c*cbeta)/(sbeta*sbeta));
352 gdouble eta = 1.0/2.0 -2.0*xi*c*cbeta/a;
353 gdouble phi = 1+xi-2*mu;
354 gdouble psi = eta-2*delta;
355
356 addAPoint(pPoints, "GAMMA", 0.0, 0.0, 0.0);
357 addAPoint(pPoints, "Y", 1.0/2, 1.0/2, 0.0);
358 addAPoint(pPoints, "A", 0.0, 0.0, 1.0/2);
359 addAPoint(pPoints, "M", 1.0/2, 1.0/2, 1.0/2);
360 addAPoint(pPoints, "V_2", 0.0, 1.0/2, 0.0);
361 addAPoint(pPoints, "L_2", 0.0, 1.0/2, 1.0/2);
362 addAPoint(pPoints, "F", -1+phi, 1-phi, 1-psi);
363 addAPoint(pPoints, "F_2", 1-phi, phi, psi);
364 addAPoint(pPoints, "F_4", phi, 1-phi, 1-psi);
365 addAPoint(pPoints, "H", -xi, xi, eta);
366 addAPoint(pPoints, "H_2", xi, 1-xi, 1-eta);
367 addAPoint(pPoints, "H_4", xi, -xi, 1-eta);
368 addAPoint(pPoints, "G", -mu, mu, delta);
369 addAPoint(pPoints, "G_2", mu, 1-mu, -delta);
370 addAPoint(pPoints, "G_4", mu, -mu, -delta);
371 addAPoint(pPoints, "G_6", 1-mu, mu, delta);
372 }
373 else if(!strcmp(extendedPearsonSymbol,"mC3")){
374 gdouble beta=crystal->beta*M_PI/180.0;
375 gdouble a=crystal->a;
376 gdouble b=crystal->b;
377 gdouble c=crystal->c;
378 gdouble cbeta = cos(beta);
379 gdouble sbeta = sin(beta);
380 gdouble xi = 1.0/4.0*(a*a/b/b+(1+a/c*cbeta)/(sbeta*sbeta));
381 gdouble rho = 1.0-xi*b*b/a/a;
382 gdouble eta = 1.0/2.0 -2.0*xi*c*cbeta/a;
383 gdouble mu = eta/2+a*a/4/b/b+a*c*cbeta/2/b/b;
384 gdouble nu=2*mu-xi;
385 gdouble omega=c/2/a/cbeta*(1-4*nu+a*a*sbeta*sbeta/b/b);
386 gdouble delta = -1.0/4.0+omega/2-xi*c*cbeta/a;
387
388 addAPoint(pPoints, "GAMMA", 0.0, 0.0, 0.0);
389 addAPoint(pPoints, "Y", 1.0/2, 1.0/2, 0.0);
390 addAPoint(pPoints, "A", 0.0, 0.0, 1.0/2);
391 addAPoint(pPoints, "M_2", -1.0/2, 1.0/2, 1.0/2);
392 addAPoint(pPoints, "V", 1.0/2, 0.0, 0.0);
393 addAPoint(pPoints, "V_2", 0.0, 1.0/2, 0.0);
394 addAPoint(pPoints, "L_2", 0.0, 1.0/2, 1.0/2);
395 addAPoint(pPoints, "I", -1+rho, rho, 1.0/2);
396 addAPoint(pPoints, "I_2", 1-rho, 1-rho, 1.0/2);
397 addAPoint(pPoints, "K", -nu, nu, omega);
398 addAPoint(pPoints, "K_2", -1+nu, 1-nu, 1-omega);
399 addAPoint(pPoints, "K_4", 1-nu, nu, omega);
400 addAPoint(pPoints, "H", -xi, xi, eta);
401 addAPoint(pPoints, "H_2", xi, 1-xi, 1-eta);
402 addAPoint(pPoints, "H_4", xi, -xi, 1-eta);
403 addAPoint(pPoints, "N", -mu, mu, delta);
404 addAPoint(pPoints, "N_2", mu, 1-mu, -delta);
405 addAPoint(pPoints, "N_4", mu, -mu, -delta);
406 addAPoint(pPoints, "N_6", 1-mu, mu, delta);
407 }
408 else if(!strcmp(extendedPearsonSymbol,"mP1")){
409 gdouble beta=crystal->beta*M_PI/180.0;
410 gdouble a=crystal->a;
411 gdouble c=crystal->c;
412 gdouble cbeta = cos(beta);
413 gdouble sbeta = sin(beta);
414 gdouble eta = (1.0+a/c*cbeta)/2/(sbeta*sbeta);
415 gdouble nu = 1.0/2.0+eta*c*cbeta/a;
416
417 addAPoint(pPoints, "GAMMA", 0.0, 0.0, 0.0);
418 addAPoint(pPoints, "Z", 0.0, 1.0/2, 0.0);
419 addAPoint(pPoints, "B", 0.0, 0.0, 1.0/2);
420 addAPoint(pPoints, "B_2", 0.0, 0.0, -1.0/2);
421 addAPoint(pPoints, "Y", 1.0/2, 0.0, 0.0);
422 addAPoint(pPoints, "Y_2", -1.0/2, 0.0, 0.0);
423 addAPoint(pPoints, "C", 1.0/2, 1.0/2, 0.0);
424 addAPoint(pPoints, "C_2", -1.0/2, 1.0/2, 0.0);
425 addAPoint(pPoints, "D", 0.0, 1.0/2, 1.0/2);
426 addAPoint(pPoints, "D_2", 0.0, 1.0/2, -1.0/2);
427 addAPoint(pPoints, "A", -1.0/2, 0.0, 1.0/2);
428 addAPoint(pPoints, "E", -1.0/2, 1.0/2, 1.0/2);
429 addAPoint(pPoints, "H", -eta, 0.0, 1-nu);
430 addAPoint(pPoints, "H_2", -1+eta, 0.0, nu);
431 addAPoint(pPoints, "H_4", -eta, 0.0, -nu);
432 addAPoint(pPoints, "M", -eta, 1.0/2, 1-nu);
433 addAPoint(pPoints, "M_2", -1+eta, 1.0/2, nu);
434 addAPoint(pPoints, "M_4", -eta, 1.0/2, -nu);
435 }
436 else if(!strcmp(extendedPearsonSymbol,"oA1")){
437 gdouble b=crystal->b;
438 gdouble c=crystal->c;
439 gdouble xi = 1.0/4.0*(1+b*b/c/c);
440
441 addAPoint(pPoints, "GAMMA", 0.0, 0.0, 0.0);
442 addAPoint(pPoints, "Y", -1.0/2, 1.0/2, 0.0);
443 addAPoint(pPoints, "T", -1.0/2, 1.0/2, 1.0/2);
444 addAPoint(pPoints, "Z", 0.0, 0.0, 1.0/2);
445 addAPoint(pPoints, "S", 0.0, 1.0/2, 0.0);
446 addAPoint(pPoints, "R", 0.0, 1.0/2, 1.0/2);
447 addAPoint(pPoints, "SIGMA_0", xi, xi, 0.0);
448 addAPoint(pPoints, "C_0", -xi, 1-xi, 0.0);
449 addAPoint(pPoints, "A_0", xi, xi, 1.0/2);
450 addAPoint(pPoints, "E_0", -xi, 1-xi, 1.0/2);
451 }
452 else if(!strcmp(extendedPearsonSymbol,"oA2")){
453 gdouble b=crystal->b;
454 gdouble c=crystal->c;
455 gdouble xi = 1.0/4.0*(1+c*c/b/b);
456 addAPoint(pPoints, "GAMMA", 0.0, 0.0, 0.0);
457 addAPoint(pPoints, "Y", 1.0/2, 1.0/2, 0.0);
458 addAPoint(pPoints, "T", 1.0/2, 1.0/2, 1.0/2);
459 addAPoint(pPoints, "T_2", 1.0/2, 1.0/2, -1.0/2);
460 addAPoint(pPoints, "Z", 0.0, 0.0, 1.0/2);
461 addAPoint(pPoints, "Z_2", 0.0, 0.0, -1.0/2);
462 addAPoint(pPoints, "S", 0.0, 1.0/2, 0.0);
463 addAPoint(pPoints, "R", 0.0, 1.0/2, 1.0/2);
464 addAPoint(pPoints, "R_2", 0.0, 1.0/2, -1.0/2);
465 addAPoint(pPoints, "DELTA_0", -xi, xi, 0.0);
466 addAPoint(pPoints, "F_0", xi, 1-xi, 0.0);
467 addAPoint(pPoints, "B_0", -xi, xi, 1.0/2);
468 addAPoint(pPoints, "B_2", -xi, xi, -1.0/2);
469 addAPoint(pPoints, "G_0", xi, 1-xi, 1.0/2);
470 addAPoint(pPoints, "G_2", xi, 1-xi, -1.0/2);
471 }
472 else if(!strcmp(extendedPearsonSymbol,"oC1")){
473 gdouble a=crystal->a;
474 gdouble b=crystal->b;
475 gdouble xi = 1.0/4.0*(1+a*a/b/b);
476 addAPoint(pPoints, "GAMMA", 0.0, 0.0, 0.0);
477 addAPoint(pPoints, "Y", -1.0/2, 1.0/2, 0.0);
478 addAPoint(pPoints, "T", -1.0/2, 1.0/2, 1.0/2);
479 addAPoint(pPoints, "Z", 0.0, 0.0, 1.0/2);
480 addAPoint(pPoints, "S", 0.0, 1.0/2, 0.0);
481 addAPoint(pPoints, "R", 0.0, 1.0/2, 1.0/2);
482 addAPoint(pPoints, "SIGMA_0", xi, xi, 0.0);
483 addAPoint(pPoints, "C_0", -xi, 1-xi, 0.0);
484 addAPoint(pPoints, "A_0", xi, xi, 1.0/2);
485 addAPoint(pPoints, "E_0", -xi, 1-xi, 1.0/2);
486 }
487 else if(!strcmp(extendedPearsonSymbol,"oC2")){
488 gdouble a=crystal->a;
489 gdouble b=crystal->b;
490 gdouble xi = 1.0/4.0*(1+b*b/a/a);
491 addAPoint(pPoints, "GAMMA", 0.0, 0.0, 0.0);
492 addAPoint(pPoints, "Y", 1.0/2, 1.0/2, 0.0);
493 addAPoint(pPoints, "T", 1.0/2, 1.0/2, 1.0/2);
494 addAPoint(pPoints, "T_2", 1.0/2, 1.0/2, -1.0/2);
495 addAPoint(pPoints, "Z", 0.0, 0.0, 1.0/2);
496 addAPoint(pPoints, "Z_2", 0.0, 0.0, -1.0/2);
497 addAPoint(pPoints, "S", 0.0, 1.0/2, 0.0);
498 addAPoint(pPoints, "R", 0.0, 1.0/2, 1.0/2);
499 addAPoint(pPoints, "R_2", 0.0, 1.0/2, -1.0/2);
500 addAPoint(pPoints, "DELTA_0", -xi, xi, 0.0);
501 addAPoint(pPoints, "F_0", xi, 1-xi, 0.0);
502 addAPoint(pPoints, "B_0", -xi, xi, 1.0/2);
503 addAPoint(pPoints, "B_2", -xi, xi, -1.0/2);
504 addAPoint(pPoints, "G_0", xi, 1-xi, 1.0/2);
505 addAPoint(pPoints, "G_2", xi, 1-xi, -1.0/2);
506 }
507 else if(!strcmp(extendedPearsonSymbol,"oF1")){
508 gdouble a=crystal->a;
509 gdouble b=crystal->b;
510 gdouble c=crystal->c;
511 gdouble a2 = a*a;
512 gdouble b2 = b*b;
513 gdouble c2 = c*c;
514 gdouble xi = 1.0/4.0*(1+a2/b2-a2/c2);
515 gdouble eta = 1.0/4.0*(1+a2/b2+a2/c2);
516 addAPoint(pPoints, "GAMMA", 0.0, 0.0, 0.0);
517 addAPoint(pPoints, "T", 1, 1.0/2, 1.0/2);
518 addAPoint(pPoints, "Z", 1.0/2, 1.0/2, 0.0);
519 addAPoint(pPoints, "Y", 1.0/2, 0.0, 1.0/2);
520 addAPoint(pPoints, "SIGMA_0", 0.0, eta, eta);
521 addAPoint(pPoints, "U_0", 1, 1-eta, 1-eta);
522 addAPoint(pPoints, "A_0", 1.0/2, 1.0/2+xi, xi);
523 addAPoint(pPoints, "C_0", 1.0/2, 1.0/2-xi, 1-xi);
524 addAPoint(pPoints, "L", 1.0/2, 1.0/2, 1.0/2);
525 }
526 else if(!strcmp(extendedPearsonSymbol,"oF2")){
527 gdouble a=crystal->a;
528 gdouble b=crystal->b;
529 gdouble c=crystal->c;
530 gdouble a2 = a*a;
531 gdouble b2 = b*b;
532 gdouble c2 = c*c;
533 gdouble xi = 1.0/4.0*(1+c2/a2-c2/b2);
534 gdouble eta = 1.0/4.0*(1+c2/a2+c2/b2);
535 addAPoint(pPoints, "GAMMA", 0.0, 0.0, 0.0);
536 addAPoint(pPoints, "T", 0.0, 1.0/2, 1.0/2);
537 addAPoint(pPoints, "Z", 1.0/2, 1.0/2, 1);
538 addAPoint(pPoints, "Y", 1.0/2, 0.0, 1.0/2);
539 addAPoint(pPoints, "LAMBDA_0", eta, eta, 0.0);
540 addAPoint(pPoints, "Q_0", 1-eta, 1-eta, 1);
541 addAPoint(pPoints, "G_0", 1.0/2-xi, 1-xi, 1.0/2);
542 addAPoint(pPoints, "H_0", 1.0/2+xi, xi, 1.0/2);
543 addAPoint(pPoints, "L", 1.0/2, 1.0/2, 1.0/2);
544 }
545 else if(!strcmp(extendedPearsonSymbol,"oF3")){
546 gdouble a=crystal->a;
547 gdouble b=crystal->b;
548 gdouble c=crystal->c;
549 gdouble a2 = a*a;
550 gdouble b2 = b*b;
551 gdouble c2 = c*c;
552 gdouble eta = 1.0/4.0*(1.0+a2/b2-a2/c2);
553 gdouble delta = 1.0/4.0*(1.0+b2/a2-b2/c2);
554 gdouble phi = 1.0/4.0*(1.0+c2/b2-c2/a2);
555 addAPoint(pPoints, "GAMMA", 0.0, 0.0, 0.0);
556 addAPoint(pPoints, "T", 0.0, 1.0/2, 1.0/2);
557 addAPoint(pPoints, "Z", 1.0/2, 1.0/2, 0.0);
558 addAPoint(pPoints, "Y", 1.0/2, 0.0, 1.0/2);
559 addAPoint(pPoints, "A_0", 1.0/2, 1.0/2+eta, eta);
560 addAPoint(pPoints, "C_0", 1.0/2, 1.0/2-eta, 1-eta);
561 addAPoint(pPoints, "B_0", 1.0/2+delta, 1.0/2, delta);
562 addAPoint(pPoints, "D_0", 1.0/2-delta, 1.0/2, 1-delta);
563 addAPoint(pPoints, "G_0", phi, 1.0/2+phi, 1.0/2);
564 addAPoint(pPoints, "H_0", 1-phi, 1.0/2-phi, 1.0/2);
565 addAPoint(pPoints, "L", 1.0/2, 1.0/2, 1.0/2);
566 }
567 else if(!strcmp(extendedPearsonSymbol,"oI1")){
568 gdouble a=crystal->a;
569 gdouble b=crystal->b;
570 gdouble c=crystal->c;
571 gdouble a2 = a*a;
572 gdouble b2 = b*b;
573 gdouble c2 = c*c;
574 gdouble xi = 1.0/4.0*(1.0+a2/c2);
575 gdouble eta = 1.0/4.0*(1.0+b2/c2);
576 gdouble delta = 1.0/4.0*(1.0+(b2-a2)/4/c2);
577 gdouble mu = (a2+b2)/4/c2;
578 addAPoint(pPoints, "GAMMA", 0.0, 0.0, 0.0);
579 addAPoint(pPoints, "X", 1.0/2, 1.0/2, -1.0/2);
580 addAPoint(pPoints, "S", 1.0/2, 0.0, 0.0);
581 addAPoint(pPoints, "R", 0.0, 1.0/2, 0.0);
582 addAPoint(pPoints, "T", 0.0, 0.0, 1.0/2);
583 addAPoint(pPoints, "W", 1.0/4, 1.0/4, 1.0/4);
584 addAPoint(pPoints, "SIGMA_0", -xi, xi, xi);
585 addAPoint(pPoints, "F_2", xi, 1-xi, -xi);
586 addAPoint(pPoints, "Y_0", eta, -eta, eta);
587 addAPoint(pPoints, "U_0", 1-eta, eta, -eta);
588 addAPoint(pPoints, "L_0", -mu, mu, 1.0/2-delta);
589 addAPoint(pPoints, "M_0", mu, -mu, 1.0/2+delta);
590 addAPoint(pPoints, "J_0", 1.0/2-delta, 1.0/2+delta, -mu);
591 }
592 else if(!strcmp(extendedPearsonSymbol,"oI2")){
593 gdouble a=crystal->a;
594 gdouble b=crystal->b;
595 gdouble c=crystal->c;
596 gdouble a2 = a*a;
597 gdouble b2 = b*b;
598 gdouble c2 = c*c;
599 gdouble xi = 1.0/4.0*(1.0+b2/a2);
600 gdouble eta = 1.0/4.0*(1.0+c2/a2);
601 gdouble delta = 1.0/4.0*(1.0+(c2-b2)/4/a2);
602 gdouble mu = (b2+c2)/4/a2;
603 addAPoint(pPoints, "GAMMA", 0.0, 0.0, 0.0);
604 addAPoint(pPoints, "X", -1.0/2, 1.0/2, 1.0/2);
605 addAPoint(pPoints, "S", 1.0/2, 0.0, 0.0);
606 addAPoint(pPoints, "R", 0.0, 1.0/2, 0.0);
607 addAPoint(pPoints, "T", 0.0, 0.0, 1.0/2);
608 addAPoint(pPoints, "W", 1.0/4, 1.0/4, 1.0/4);
609 addAPoint(pPoints, "Y_0", xi, -xi, xi);
610 addAPoint(pPoints, "U_2", -xi, xi, 1-xi);
611 addAPoint(pPoints, "LAMBDA_0", eta, eta, -eta);
612 addAPoint(pPoints, "G_2", -eta, 1-eta, eta);
613 addAPoint(pPoints, "K", 1.0/2-delta, -mu, mu);
614 addAPoint(pPoints, "K_2", 1.0/2+delta, mu, -mu);
615 addAPoint(pPoints, "K_4", -mu, 1.0/2-delta, 1.0/2+delta);
616 }
617 else if(!strcmp(extendedPearsonSymbol,"oI3")){
618 gdouble a=crystal->a;
619 gdouble b=crystal->b;
620 gdouble c=crystal->c;
621 gdouble a2 = a*a;
622 gdouble b2 = b*b;
623 gdouble c2 = c*c;
624 gdouble xi = 1.0/4.0*(1.0+c2/b2);
625 gdouble eta = 1.0/4.0*(1.0+a2/b2);
626 gdouble delta = 1.0/4.0*(1.0+(a2-c2)/4/b2);
627 gdouble mu = (c2+a2)/4/b2;
628 addAPoint(pPoints, "GAMMA", 0.0, 0.0, 0.0);
629 addAPoint(pPoints, "X", 1.0/2, -1.0/2, 1.0/2);
630 addAPoint(pPoints, "S", 1.0/2, 0.0, 0.0);
631 addAPoint(pPoints, "R", 0.0, 1.0/2, 0.0);
632 addAPoint(pPoints, "T", 0.0, 0.0, 1.0/2);
633 addAPoint(pPoints, "W", 1.0/4, 1.0/4, 1.0/4);
634 addAPoint(pPoints, "SIGMA_0", -eta, eta, eta);
635 addAPoint(pPoints, "F_0", eta, -eta, 1-eta);
636 addAPoint(pPoints, "LAMBDA_0", xi, xi, -xi);
637 addAPoint(pPoints, "G_0", 1-xi, -xi, xi);
638 addAPoint(pPoints, "V_0", mu, 1.0/2-delta, -mu);
639 addAPoint(pPoints, "H_0", -mu, 1.0/2+delta, mu);
640 addAPoint(pPoints, "H_2", 1.0/2+delta, -mu, 1.0/2-delta);
641 }
642 else if(!strcmp(extendedPearsonSymbol,"oP1")){
643 addAPoint(pPoints, "GAMMA", 0.0, 0.0, 0.0);
644 addAPoint(pPoints, "X", 1.0/2, 0.0, 0.0);
645 addAPoint(pPoints, "Z", 0.0, 0.0, 1.0/2);
646 addAPoint(pPoints, "U", 1.0/2, 0.0, 1.0/2);
647 addAPoint(pPoints, "Y", 0.0, 1.0/2, 0.0);
648 addAPoint(pPoints, "S", 1.0/2, 1.0/2, 0.0);
649 addAPoint(pPoints, "T", 0.0, 1.0/2, 1.0/2);
650 addAPoint(pPoints, "R", 1.0/2, 1.0/2, 1.0/2);
651 }
652 else if(!strcmp(extendedPearsonSymbol,"tI1")){
653 gdouble eta = 1.0/4.0*(1.0+crystal->c*crystal->c/(crystal->a*crystal->a));
654 addAPoint(pPoints, "GAMMA", 0.0, 0.0, 0.0);
655 addAPoint(pPoints, "M", -1.0/2, 1.0/2, 1.0/2);
656 addAPoint(pPoints, "X", 0.0, 0.0, 1.0/2);
657 addAPoint(pPoints, "P", 1.0/4, 1.0/4, 1.0/4);
658 addAPoint(pPoints, "Z", eta, eta, -eta);
659 addAPoint(pPoints, "Z_0", -eta, 1-eta, eta);
660 addAPoint(pPoints, "N", 0.0, 1.0/2, 0.0);
661 }
662 else if(!strcmp(extendedPearsonSymbol,"tI2")){
663 gdouble eta = 1.0/4.0*(1.0+crystal->a*crystal->a/(crystal->c*crystal->c));
664 gdouble xi = crystal->a*crystal->a/(crystal->c*crystal->c)/2.0;
665 addAPoint(pPoints, "GAMMA", 0.0, 0.0, 0.0);
666 addAPoint(pPoints, "M", 1.0/2, 1.0/2, -1.0/2);
667 addAPoint(pPoints, "X", 0.0, 0.0, 1.0/2);
668 addAPoint(pPoints, "P", 1.0/4, 1.0/4, 1.0/4);
669 addAPoint(pPoints, "N", 0.0, 1.0/2, 0.0);
670 addAPoint(pPoints, "S_0", -eta, eta, eta);
671 addAPoint(pPoints, "S", eta, 1-eta, -eta);
672 addAPoint(pPoints, "R", -xi, xi, 1.0/2);
673 addAPoint(pPoints, "G", 1.0/2, 1.0/2, -xi);
674 }
675 else if(!strcmp(extendedPearsonSymbol,"tP1")){
676 addAPoint(pPoints, "GAMMA", 0.0, 0.0, 0.0);
677 addAPoint(pPoints, "Z", 0.0, 0.0, 1.0/2);
678 addAPoint(pPoints, "M", 1.0/2, 1.0/2, 0.0);
679 addAPoint(pPoints, "A", 1.0/2, 1.0/2, 1.0/2);
680 addAPoint(pPoints, "R", 0.0, 1.0/2, 1.0/2);
681 addAPoint(pPoints, "X", 0.0, 1.0/2, 0.0);
682 }
683 else ok = FALSE;
684 return ok;
685 }
686 /***********************************************************************************************/
addAPath(GList ** pPath,GList * points,gchar * n1,gchar * n2)687 static void addAPath(GList** pPath, GList* points, gchar* n1, gchar* n2)
688 {
689 GList * l = NULL;
690 GabeditKPoint* point1 = NULL;
691 GabeditKPoint* point2 = NULL;
692 for(l = g_list_first(points); l != NULL; l = l->next)
693 {
694 GabeditKPoint* point = (GabeditKPoint*) l->data;
695 if(point && !strcmp(point->name,n1)) point1 = point;
696 if(point && !strcmp(point->name,n2)) point2 = point;
697 if(point1 && point2) break;
698 }
699 *pPath=g_list_append(*pPath, (gpointer) point1);
700 *pPath=g_list_append(*pPath, (gpointer) point2);
701 }
setPath(GList ** pPath,GList * points,gchar * extendedPearsonSymbol)702 static gboolean setPath(GList** pPath, GList* points, gchar* extendedPearsonSymbol)
703 {
704 gboolean ok = TRUE;
705 if(!strcmp(extendedPearsonSymbol,"aP2")){
706 addAPath(pPath, points, "GAMMA", "X");
707 addAPath(pPath, points, "Y", "GAMMA");
708 addAPath(pPath, points, "GAMMA", "Z");
709 addAPath(pPath, points, "R", "GAMMA");
710 addAPath(pPath, points, "GAMMA", "T");
711 addAPath(pPath, points, "U", "GAMMA");
712 addAPath(pPath, points, "GAMMA", "V");
713 }
714 else if(!strcmp(extendedPearsonSymbol,"aP3")){
715 addAPath(pPath, points, "GAMMA", "X");
716 addAPath(pPath, points, "Y", "GAMMA");
717 addAPath(pPath, points, "GAMMA", "Z");
718 addAPath(pPath, points, "R_2", "GAMMA");
719 addAPath(pPath, points, "GAMMA", "T_2");
720 addAPath(pPath, points, "U_2", "GAMMA");
721 addAPath(pPath, points, "GAMMA", "V_2");
722 }
723 else if(!strcmp(extendedPearsonSymbol,"cF1")){
724 addAPath(pPath, points, "GAMMA", "X");
725 addAPath(pPath, points, "X", "U");
726 addAPath(pPath, points, "K", "GAMMA");
727 addAPath(pPath, points, "GAMMA", "L");
728 addAPath(pPath, points, "L", "W");
729 addAPath(pPath, points, "W", "X");
730 addAPath(pPath, points, "X", "W_2");
731 }
732 else if(!strcmp(extendedPearsonSymbol,"cF2")){
733 addAPath(pPath, points, "GAMMA", "X");
734 addAPath(pPath, points, "X", "U");
735 addAPath(pPath, points, "K", "GAMMA");
736 addAPath(pPath, points, "GAMMA", "L");
737 addAPath(pPath, points, "L", "W");
738 addAPath(pPath, points, "W", "X");
739 }
740 else if(!strcmp(extendedPearsonSymbol,"cI1")){
741 addAPath(pPath, points, "GAMMA", "H");
742 addAPath(pPath, points, "H", "N");
743 addAPath(pPath, points, "N", "GAMMA");
744 addAPath(pPath, points, "GAMMA", "P");
745 addAPath(pPath, points, "P", "H");
746 addAPath(pPath, points, "P", "N");
747 }
748 else if(!strcmp(extendedPearsonSymbol,"cP1")){
749 addAPath(pPath, points, "GAMMA", "X");
750 addAPath(pPath, points, "X", "M");
751 addAPath(pPath, points, "M", "GAMMA");
752 addAPath(pPath, points, "GAMMA", "R");
753 addAPath(pPath, points, "R", "X");
754 addAPath(pPath, points, "R", "M");
755 addAPath(pPath, points, "M", "X_1");
756 }
757 else if(!strcmp(extendedPearsonSymbol,"cP2")){
758 addAPath(pPath, points, "GAMMA", "X");
759 addAPath(pPath, points, "X", "M");
760 addAPath(pPath, points, "M", "GAMMA");
761 addAPath(pPath, points, "GAMMA", "R");
762 addAPath(pPath, points, "R", "X");
763 addAPath(pPath, points, "R", "M");
764 }
765 else if(!strcmp(extendedPearsonSymbol,"hP1")){
766 addAPath(pPath, points, "GAMMA", "M");
767 addAPath(pPath, points, "M", "K");
768 addAPath(pPath, points, "K", "GAMMA");
769 addAPath(pPath, points, "GAMMA", "A");
770 addAPath(pPath, points, "A", "L");
771 addAPath(pPath, points, "L", "H");
772 addAPath(pPath, points, "H", "A");
773 addAPath(pPath, points, "L", "M");
774 addAPath(pPath, points, "H", "K");
775 addAPath(pPath, points, "K", "H_2");
776 }
777 else if(!strcmp(extendedPearsonSymbol,"hP2")){
778 addAPath(pPath, points, "GAMMA", "M");
779 addAPath(pPath, points, "M", "K");
780 addAPath(pPath, points, "K", "GAMMA");
781 addAPath(pPath, points, "GAMMA", "A");
782 addAPath(pPath, points, "A", "L");
783 addAPath(pPath, points, "L", "H");
784 addAPath(pPath, points, "H", "A");
785 addAPath(pPath, points, "L", "M");
786 addAPath(pPath, points, "H", "K");
787 }
788 else if(!strcmp(extendedPearsonSymbol,"hR1")){
789 addAPath(pPath, points, "GAMMA", "T");
790 addAPath(pPath, points, "T", "H_2");
791 addAPath(pPath, points, "H_0", "L");
792 addAPath(pPath, points, "L", "GAMMA");
793 addAPath(pPath, points, "GAMMA", "S_0");
794 addAPath(pPath, points, "S_2", "F");
795 addAPath(pPath, points, "F", "GAMMA");
796 }
797 else if(!strcmp(extendedPearsonSymbol,"hR2")){
798 addAPath(pPath, points, "GAMMA", "L");
799 addAPath(pPath, points, "L", "T");
800 addAPath(pPath, points, "T", "P_0");
801 addAPath(pPath, points, "P_2", "GAMMA");
802 addAPath(pPath, points, "GAMMA", "F");
803 }
804 else if(!strcmp(extendedPearsonSymbol,"mC1")){
805 addAPath(pPath, points, "GAMMA", "C");
806 addAPath(pPath, points, "C_2", "Y_2");
807 addAPath(pPath, points, "Y_2", "GAMMA");
808 addAPath(pPath, points, "GAMMA", "M_2");
809 addAPath(pPath, points, "M_2", "D");
810 addAPath(pPath, points, "D_2", "A");
811 addAPath(pPath, points, "A", "GAMMA");
812 addAPath(pPath, points, "L_2", "GAMMA");
813 addAPath(pPath, points, "GAMMA", "V_2");
814 }
815 else if(!strcmp(extendedPearsonSymbol,"mC2")){
816 addAPath(pPath, points, "GAMMA", "Y");
817 addAPath(pPath, points, "Y", "M");
818 addAPath(pPath, points, "M", "A");
819 addAPath(pPath, points, "A", "GAMMA");
820 addAPath(pPath, points, "L_2", "GAMMA");
821 addAPath(pPath, points, "GAMMA", "V_2");
822 }
823 else if(!strcmp(extendedPearsonSymbol,"mC3")){
824 addAPath(pPath, points, "GAMMA", "A");
825 addAPath(pPath, points, "A", "I_2");
826 addAPath(pPath, points, "I", "M_2");
827 addAPath(pPath, points, "M_2", "GAMMA");
828 addAPath(pPath, points, "GAMMA", "Y");
829 addAPath(pPath, points, "L_2", "GAMMA");
830 addAPath(pPath, points, "GAMMA", "V_2");
831 }
832 else if(!strcmp(extendedPearsonSymbol,"mP1")){
833 addAPath(pPath, points, "GAMMA", "Z");
834 addAPath(pPath, points, "Z", "D");
835 addAPath(pPath, points, "D", "B");
836 addAPath(pPath, points, "B", "GAMMA");
837 addAPath(pPath, points, "GAMMA", "A");
838 addAPath(pPath, points, "A", "E");
839 addAPath(pPath, points, "E", "Z");
840 addAPath(pPath, points, "Z", "C_2");
841 addAPath(pPath, points, "C_2", "Y_2");
842 addAPath(pPath, points, "Y_2", "GAMMA");
843 }
844 else if(!strcmp(extendedPearsonSymbol,"oA1")){
845 addAPath(pPath, points, "GAMMA", "Y");
846 addAPath(pPath, points, "Y", "C_0");
847 addAPath(pPath, points, "SIGMA_0", "GAMMA");
848 addAPath(pPath, points, "GAMMA", "Z");
849 addAPath(pPath, points, "Z", "A_0");
850 addAPath(pPath, points, "E_0", "T");
851 addAPath(pPath, points, "T", "Y");
852 addAPath(pPath, points, "GAMMA", "S");
853 addAPath(pPath, points, "S", "R");
854 addAPath(pPath, points, "R", "Z");
855 addAPath(pPath, points, "Z", "T");
856 }
857 else if(!strcmp(extendedPearsonSymbol,"oA2")){
858 addAPath(pPath, points, "GAMMA", "Y");
859 addAPath(pPath, points, "Y", "F_0");
860 addAPath(pPath, points, "DELTA_0", "GAMMA");
861 addAPath(pPath, points, "GAMMA", "Z");
862 addAPath(pPath, points, "Z", "B_0");
863 addAPath(pPath, points, "G_0", "T");
864 addAPath(pPath, points, "T", "Y");
865 addAPath(pPath, points, "GAMMA", "S");
866 addAPath(pPath, points, "S", "R");
867 addAPath(pPath, points, "R", "Z");
868 addAPath(pPath, points, "Z", "T");
869 }
870 else if(!strcmp(extendedPearsonSymbol,"oC1")){
871 addAPath(pPath, points, "GAMMA", "Y");
872 addAPath(pPath, points, "Y", "C_0");
873 addAPath(pPath, points, "SIGMA_0", "GAMMA");
874 addAPath(pPath, points, "GAMMA", "Z");
875 addAPath(pPath, points, "Z", "A_0");
876 addAPath(pPath, points, "E_0", "T");
877 addAPath(pPath, points, "T", "Y");
878 addAPath(pPath, points, "GAMMA", "S");
879 addAPath(pPath, points, "S", "R");
880 addAPath(pPath, points, "R", "Z");
881 addAPath(pPath, points, "Z", "T");
882 }
883 else if(!strcmp(extendedPearsonSymbol,"oC2")){
884 addAPath(pPath, points, "GAMMA", "Y");
885 addAPath(pPath, points, "Y", "F_0");
886 addAPath(pPath, points, "DELTA_0", "GAMMA");
887 addAPath(pPath, points, "GAMMA", "Z");
888 addAPath(pPath, points, "Z", "B_0");
889 addAPath(pPath, points, "G_0", "T");
890 addAPath(pPath, points, "T", "Y");
891 addAPath(pPath, points, "GAMMA", "S");
892 addAPath(pPath, points, "S", "R");
893 addAPath(pPath, points, "R", "Z");
894 addAPath(pPath, points, "Z", "T");
895 }
896 else if(!strcmp(extendedPearsonSymbol,"oF1")){
897 addAPath(pPath, points, "GAMMA", "Y");
898 addAPath(pPath, points, "Y", "T");
899 addAPath(pPath, points, "T", "Z");
900 addAPath(pPath, points, "Z", "GAMMA");
901 addAPath(pPath, points, "GAMMA", "SIGMA_0");
902 addAPath(pPath, points, "U_0", "T");
903 addAPath(pPath, points, "Y", "C_0");
904 addAPath(pPath, points, "A_0", "Z");
905 addAPath(pPath, points, "GAMMA", "L");
906 }
907 else if(!strcmp(extendedPearsonSymbol,"oF2")){
908 addAPath(pPath, points, "GAMMA", "T");
909 addAPath(pPath, points, "T", "Z");
910 addAPath(pPath, points, "Z", "Y");
911 addAPath(pPath, points, "Y", "GAMMA");
912 addAPath(pPath, points, "GAMMA", "LAMBDA_0");
913 addAPath(pPath, points, "Q_0", "Z");
914 addAPath(pPath, points, "T", "G_0");
915 addAPath(pPath, points, "H_0", "Y");
916 addAPath(pPath, points, "GAMMA", "L");
917 }
918 else if(!strcmp(extendedPearsonSymbol,"oF3")){
919 addAPath(pPath, points, "GAMMA", "Y");
920 addAPath(pPath, points, "Y", "C_0");
921 addAPath(pPath, points, "A_0", "Z");
922 addAPath(pPath, points, "Z", "B_0");
923 addAPath(pPath, points, "D_0", "T");
924 addAPath(pPath, points, "T", "G_0");
925 addAPath(pPath, points, "H_0", "Y");
926 addAPath(pPath, points, "T", "GAMMA");
927 addAPath(pPath, points, "GAMMA", "Z");
928 addAPath(pPath, points, "GAMMA", "L");
929 }
930 else if(!strcmp(extendedPearsonSymbol,"oI1")){
931 addAPath(pPath, points, "GAMMA", "X");
932 addAPath(pPath, points, "X", "F_2");
933 addAPath(pPath, points, "SIGMA_0", "GAMMA");
934 addAPath(pPath, points, "GAMMA", "Y_0");
935 addAPath(pPath, points, "U_0", "X");
936 addAPath(pPath, points, "GAMMA", "R");
937 addAPath(pPath, points, "R", "W");
938 addAPath(pPath, points, "W", "S");
939 addAPath(pPath, points, "S", "GAMMA");
940 addAPath(pPath, points, "GAMMA", "T");
941 addAPath(pPath, points, "T", "W");
942 }
943 else if(!strcmp(extendedPearsonSymbol,"oI2")){
944 addAPath(pPath, points, "GAMMA", "X");
945 addAPath(pPath, points, "X", "U_2");
946 addAPath(pPath, points, "Y_0", "GAMMA");
947 addAPath(pPath, points, "GAMMA", "LAMBDA_0");
948 addAPath(pPath, points, "G_2", "X");
949 addAPath(pPath, points, "GAMMA", "R");
950 addAPath(pPath, points, "R", "W");
951 addAPath(pPath, points, "W", "S");
952 addAPath(pPath, points, "S", "GAMMA");
953 addAPath(pPath, points, "GAMMA", "T");
954 addAPath(pPath, points, "T", "W");
955 }
956 else if(!strcmp(extendedPearsonSymbol,"oI3")){
957 addAPath(pPath, points, "GAMMA", "X");
958 addAPath(pPath, points, "X", "F_0");
959 addAPath(pPath, points, "SIGMA_0", "GAMMA");
960 addAPath(pPath, points, "GAMMA", "LAMBDA_0");
961 addAPath(pPath, points, "G_0", "X");
962 addAPath(pPath, points, "GAMMA", "R");
963 addAPath(pPath, points, "R", "W");
964 addAPath(pPath, points, "W", "S");
965 addAPath(pPath, points, "S", "GAMMA");
966 addAPath(pPath, points, "GAMMA", "T");
967 addAPath(pPath, points, "T", "W");
968 }
969 else if(!strcmp(extendedPearsonSymbol,"oP1")){
970 addAPath(pPath, points, "GAMMA", "X");
971 addAPath(pPath, points, "X", "S");
972 addAPath(pPath, points, "S", "Y");
973 addAPath(pPath, points, "Y", "GAMMA");
974 addAPath(pPath, points, "GAMMA", "Z");
975 addAPath(pPath, points, "Z", "U");
976 addAPath(pPath, points, "U", "R");
977 addAPath(pPath, points, "R", "T");
978 addAPath(pPath, points, "T", "Z");
979 addAPath(pPath, points, "X", "U");
980 addAPath(pPath, points, "Y", "T");
981 addAPath(pPath, points, "S", "R");
982 }
983 else if(!strcmp(extendedPearsonSymbol,"tI1")){
984 addAPath(pPath, points, "GAMMA", "X");
985 addAPath(pPath, points, "X", "M");
986 addAPath(pPath, points, "M", "GAMMA");
987 addAPath(pPath, points, "GAMMA", "Z");
988 addAPath(pPath, points, "Z_0", "M");
989 addAPath(pPath, points, "X", "P");
990 addAPath(pPath, points, "P", "N");
991 addAPath(pPath, points, "N", "GAMMA");
992 }
993 else if(!strcmp(extendedPearsonSymbol,"tI2")){
994 addAPath(pPath, points, "GAMMA", "X");
995 addAPath(pPath, points, "X", "P");
996 addAPath(pPath, points, "P", "N");
997 addAPath(pPath, points, "N", "GAMMA");
998 addAPath(pPath, points, "GAMMA", "M");
999 addAPath(pPath, points, "M", "S");
1000 addAPath(pPath, points, "S_0", "GAMMA");
1001 addAPath(pPath, points, "X", "R");
1002 addAPath(pPath, points, "G", "M");
1003 }
1004 else if(!strcmp(extendedPearsonSymbol,"tP1")){
1005 addAPath(pPath, points, "GAMMA", "X");
1006 addAPath(pPath, points, "X", "M");
1007 addAPath(pPath, points, "M", "GAMMA");
1008 addAPath(pPath, points, "GAMMA", "Z");
1009 addAPath(pPath, points, "Z", "R");
1010 addAPath(pPath, points, "R", "A");
1011 addAPath(pPath, points, "A", "Z");
1012 addAPath(pPath, points, "X", "R");
1013 addAPath(pPath, points, "M", "A");
1014 }
1015 else ok = FALSE;
1016 return ok;
1017 }
1018 /***********************************************************************************************/
getConvPointsFromPrimOnes(gdouble Cc[],gdouble Cp[],gdouble Q[][3])1019 static void getConvPointsFromPrimOnes(gdouble Cc[], gdouble Cp[], gdouble Q[][3])
1020 {
1021 gint i,j;
1022 for(i=0;i<3;i++)
1023 {
1024 Cc[i] = 0;
1025 for(j=0;j<3;j++) Cc[i] += Cp[j]*Q[j][i];
1026 }
1027 }
1028 /***********************************************************************************************/
computeConvPoints(GabeditKPointsPath * kpointsPath)1029 static gboolean computeConvPoints(GabeditKPointsPath* kpointsPath)
1030 {
1031 GList * l = NULL;
1032 gdouble C[3];
1033 gint i;
1034 for(l = g_list_first(kpointsPath->points); l != NULL; l = l->next)
1035 {
1036 GabeditKPoint* point = (GabeditKPoint*) l->data;
1037 if(point)
1038 {
1039 getConvPointsFromPrimOnes(C, point->C, kpointsPath->Q);
1040 for(i=0;i<3;i++) point->C[i] = C[i];
1041 }
1042 }
1043 return TRUE;
1044 }
1045 /***********************************************************************************************/
getStrAllKPoints(GabeditKPointsPath * kpoints)1046 gchar* getStrAllKPoints(GabeditKPointsPath* kpoints)
1047 {
1048 GList * l = NULL;
1049 gchar* tmp = g_strdup("# k points\n");
1050 for(l = g_list_first(kpoints->points); l != NULL; l = l->next)
1051 {
1052 GabeditKPoint* p = (GabeditKPoint*) l->data;
1053 if(p)
1054 {
1055 gchar* t = tmp;
1056 tmp = g_strdup_printf("%s"
1057 "%0.8lf %0.8lf %0.8lf #%s"
1058 "\n",
1059 t,
1060 p->C[0], p->C[1],p->C[2], p->name
1061 );
1062 if(t) g_free(t);
1063 }
1064 }
1065 return tmp;
1066 }
1067 /***********************************************************************************************/
getStrKPointsPath(GabeditKPointsPath * kpoints)1068 gchar* getStrKPointsPath(GabeditKPointsPath* kpoints)
1069 {
1070 GList * l = NULL;
1071 gchar* tmp = g_strdup_printf("k-points along high symmetry lines (VASP Format)\n40 ! 40 intersections\nLine-mode\nrec\n");
1072 for(l = g_list_first(kpoints->path); l != NULL; l = l->next)
1073 {
1074 GabeditKPoint* p1 = (GabeditKPoint*) l->data;
1075 GabeditKPoint* p2 = NULL;
1076 l = l->next;
1077 if(l==NULL) break;
1078 p2 = (GabeditKPoint*) l->data;
1079 if(p1 && p2)
1080 {
1081 gchar* t = tmp;
1082 tmp = g_strdup_printf("%s"
1083 "%0.8lf %0.8lf %0.8lf ! %s\n"
1084 "%0.8lf %0.8lf %0.8lf ! %s\n"
1085 "\n",
1086 t,
1087 p1->C[0], p1->C[1],p1->C[2], p1->name,
1088 p2->C[0], p2->C[1],p2->C[2], p2->name
1089 );
1090 if(t) g_free(t);
1091 }
1092 }
1093 return tmp;
1094 }
1095 /***********************************************************************************************/
getKPointsPath(Crystal * crystal,gdouble symprec)1096 GabeditKPointsPath getKPointsPath(Crystal* crystal, gdouble symprec)
1097 {
1098 gchar extendedPearsonSymbol[10];
1099 SpglibDataset * spgDataSet = NULL;
1100 GabeditKPointsPath kpoints;
1101 initGabeditKPoints(&kpoints);
1102
1103 if(!crystal || !crystal->atoms) return kpoints;
1104
1105 spgDataSet = standardizeFromDataSetSPG(crystal, symprec);
1106 crystalloComputeLengthsAndAngles(crystal);
1107
1108 generateExtendedPearsonSymbol(extendedPearsonSymbol, crystal, symprec);
1109
1110 setPoints(&kpoints.points, extendedPearsonSymbol, crystal);
1111 getQFromPearsonSymbol(kpoints.Q,kpoints.Qm1, extendedPearsonSymbol);
1112 sprintf(kpoints.pearsonSymbol,"%s",extendedPearsonSymbol);
1113
1114 kpoints.strPointsPrim = getStrAllKPoints(&kpoints);
1115 setPath(&kpoints.path, kpoints.points,extendedPearsonSymbol);
1116 kpoints.strPathPrim = getStrKPointsPath(&kpoints);
1117
1118 computeConvPoints(&kpoints);
1119
1120 /* fprintf(stderr,"Extended Pearson Symbol = %s\n", extendedPearsonSymbol);*/
1121 if(kpoints.path) g_list_free(kpoints.path);
1122 kpoints.path = NULL;
1123 setPath(&kpoints.path, kpoints.points,extendedPearsonSymbol);
1124
1125 kpoints.strPointsConv = getStrAllKPoints(&kpoints);
1126 kpoints.strPathConv = getStrKPointsPath(&kpoints);
1127
1128 kpoints.spaceGroupName = g_strdup_printf("%s", spgDataSet->international_symbol);
1129 kpoints.spaceGroupNumber = spgDataSet->spacegroup_number;
1130
1131 crystalloCartnToFract(crystal->atoms);
1132 kpoints.strAtomsConv = crystalloGetVASPAtomsPositions(crystal->atoms);
1133 crystalloFractToCartn(crystal->atoms);
1134
1135 /*crystalloPrimitiveCell(&crystal->atoms, symprec);*/
1136
1137 crystalloPrimitiveCellHinuma(&crystal->atoms, extendedPearsonSymbol);
1138
1139 crystalloCartnToFract(crystal->atoms);
1140 kpoints.strAtomsPrim = crystalloGetVASPAtomsPositions(crystal->atoms);
1141 crystalloFractToCartn(crystal->atoms);
1142
1143 spg_free_dataset(spgDataSet);
1144 return kpoints;
1145 }
1146 /***********************************************************************************************/
getVASPKPointsPath(Crystal * crystal,gdouble symprec)1147 gchar* getVASPKPointsPath(Crystal* crystal, gdouble symprec)
1148 {
1149 GabeditKPointsPath kpoints = getKPointsPath(crystal, symprec);
1150 gchar* str = NULL;
1151 if(kpoints.strPointsConv) str = g_strdup_printf(
1152 "# References :\n"
1153 "# Hinuma et al. Comput. Mat. Science 128 (2017) 140–184\n"
1154 "# Spglib , Togo et al. https://arxiv.org/abs/1808.01590\n"
1155 "\n"
1156 "# Space group : %s (%d)\n"
1157 "# Extended Pearson symbol = %s\n"
1158 "#---------- Conventional cell ----------------------------------------------------------\n"
1159 "%s\n"
1160 "%s\n"
1161 "%s\n"
1162 "#---------- Primitive cell -------------------------------------------------------------\n"
1163 "%s\n"
1164 "%s\n"
1165 "%s",
1166 kpoints.spaceGroupName, kpoints.spaceGroupNumber,
1167 kpoints.pearsonSymbol,
1168 kpoints.strAtomsConv,
1169 kpoints.strPathConv,
1170 kpoints.strPointsConv,
1171 kpoints.strAtomsPrim,
1172 kpoints.strPathPrim,
1173 kpoints.strPointsPrim
1174 );
1175 else str = g_strdup_printf("Error");
1176 freeGabeditKPoints(&kpoints);
1177 return str;
1178 }
1179