atomes 1.1.14
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
modelinfo.c
Go to the documentation of this file.
1/* This file is part of the 'atomes' software
2
3'atomes' is free software: you can redistribute it and/or modify it under the terms
4of the GNU Affero General Public License as published by the Free Software Foundation,
5either version 3 of the License, or (at your option) any later version.
6
7'atomes' is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
8without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9See the GNU General Public License for more details.
10
11You should have received a copy of the GNU Affero General Public License along with 'atomes'.
12If not, see <https://www.gnu.org/licenses/>
13
14Copyright (C) 2022-2024 by CNRS and University of Strasbourg */
15
22/*
23* This file: 'modelinfo.c'
24*
25* Contains:
26*
27
28 - Functions to display model information in GtkTextBuffer
29
30*
31* List of functions:
32
33 void print_spg_name (gchar * str , GtkTextBuffer * buffer);
34 void print_spg_setting (gchar * init, GtkTextBuffer * buffer);
35 void model_info (project * this_proj, GtkTextBuffer * buffer);
36 void print_this_ogl_stuff (gchar * text, GLenum name, GtkTextBuffer * buf);
37 void opengl_info (project * this_proj, GtkTextBuffer * buf);
38
39*/
40
41#include "global.h"
42#include "interface.h"
43
44extern gchar * groups[230] ;
45extern char * vect_comp[3];
46extern gchar * substitute_string (gchar * init, gchar * o_motif, gchar * n_motif);
47extern gchar * get_num_string (gchar * str);
48
57void print_spg_name (gchar * str , GtkTextBuffer * buffer)
58{
59 str = substitute_string (str, "</", "y");
60 str = substitute_string (str, "<", "w");
61 str = substitute_string (str, ">", "x");
62 if (strstr(str, "wsubx"))
63 {
64 gchar * sta = g_strdup_printf ("%s", str);
65 sta = strtok (sta, "wsubx");
66 print_info (sta, "bold", buffer);
67 while (sta)
68 {
69 sta = strtok (NULL, "ysubx");
70 if (sta)
71 {
72 print_info (sta, "sub_bold", buffer);
73 sta = strtok (NULL, "ysubx");
74 if (sta)
75 {
76 print_info (sta, "bold", buffer);
77 }
78 }
79 }
80 }
81 else
82 {
83 print_info (str, "bold", buffer);
84 }
85 g_free (str);
86}
87
96void print_spg_setting (gchar * init, GtkTextBuffer * buffer)
97{
98 gchar * str = g_strdup_printf ("%s", init);
99 str = substitute_string (str, "_", " ");
100 str = get_num_string (str);
101 str = substitute_string (str, " ", NULL);
102 print_spg_name (str, buffer);
103}
104
113void model_info (project * this_proj, GtkTextBuffer * buffer)
114{
115 int i, j, k;
116 double v;
117 gchar * str;
118 if (g_strcmp0(this_proj -> projfile, "(null)") == 0) this_proj -> projfile = NULL;
119 if (this_proj -> projfile != NULL)
120 {
121 print_info ("\n\tProject file: ", "italic", buffer);
122 print_info (this_proj -> projfile, NULL, buffer);
123 }
124
125 if (this_proj -> tfile > -1 && this_proj -> coordfile != NULL)
126 {
127 print_info ("\n\tCoordinates file: ", "italic", buffer);
128 print_info (this_proj -> coordfile, NULL, buffer);
129 print_info ("\n\tFile type: ", "italic", buffer);
130 print_info (coord_files[this_proj -> tfile], NULL, buffer);
131 this_proj -> tfile = 0;
132 }
133 print_info ("\n\nModel properties\n\n\n", "heading", buffer);
134 if (this_proj -> steps > 1)
135 {
136 print_info ("\tNumber of MD steps = ", "italic", buffer);
137 str = g_strdup_printf ("%d\n", this_proj -> steps);
138 print_info (str, "bold", buffer);
139 g_free (str);
140 }
141 print_info ("\tNumber of atoms = ", "italic", buffer);
142 str = g_strdup_printf ("%d\n", this_proj -> natomes);
143 print_info (str, "bold", buffer);
144 g_free (str);
145 print_info ("\tNumber of species = ", "italic", buffer);
146 str = g_strdup_printf ("%d\n\n", this_proj -> nspec);
147 print_info (str, "bold", buffer);
148 g_free (str);
149 if (this_proj -> cell.volume > 0.0)
150 {
151 gchar * latv[2][3]={{"a", "b", "c"},
152 {"α", "β", "γ"}};
153 if (this_proj -> cell.npt)
154 {
155 print_info ("\tAv. lattice parameters:\n\n", NULL, buffer);
156 }
157 else
158 {
159 print_info ("\tLattice parameters:\n\n", NULL, buffer);
160 }
161 for (i=0; i<2; i++)
162 {
163 print_info ("\t", NULL, buffer);
164 for (j=0; j<3; j++)
165 {
166 str = g_strdup_printf ("\t %s=", latv[i][j]);
167 print_info (str, "bold_italic", buffer);
168 g_free (str);
169 if (this_proj -> cell.npt)
170 {
171 v = 0.0;
172 for (k=0; k<this_proj -> steps; k++) v += this_proj -> cell.box[k].param[i][j];
173 v /= this_proj -> steps;
174 }
175 else
176 {
177 v = this_proj -> cell.box[0].param[i][j];
178 }
179 str = g_strdup_printf ("%10.5lf", v);
180 print_info (str, "bold_green", buffer);
181 g_free (str);
182 }
183 print_info ("\n", NULL, buffer);
184 }
185 print_info ("\n", NULL, buffer);
186 if (this_proj -> cell.npt)
187 {
188 print_info ("\tAv. lattice vectors:\n\n\t\t", NULL, buffer);
189 }
190 else
191 {
192 print_info ("\tLattice vectors:\n\n\t\t", NULL, buffer);
193 }
194 for (i=0; i<3; i++)
195 {
196 str = g_strdup_printf (" %s ", vect_comp[i]);
197 print_info (str, NULL, buffer);
198 g_free (str);
199 }
200 print_info ("\n", NULL, buffer);
201 for (i=0; i<3; i++)
202 {
203 str = g_strdup_printf ("\t\t%s", latv[0][i]);
204 print_info (str, NULL, buffer);
205 g_free (str);
206 for (j=0; j<3; j++)
207 {
208 if (this_proj -> cell.npt)
209 {
210 v = 0.0;
211 for (k=0; k<this_proj -> steps; k++) v += this_proj -> cell.box[k].vect[i][j];
212 v /= this_proj -> steps;
213 }
214 else
215 {
216 v = this_proj -> cell.box[0].vect[i][j];
217 }
218 str = g_strdup_printf ("%10.5lf", v);
219 print_info (str, "bold_orange", buffer);
220 g_free (str);
221 }
222 print_info ("\n", NULL, buffer);
223 }
224 if (this_proj -> cell.sp_group)
225 {
226 print_info ("\n", NULL, buffer);
227 print_info ("\tCrystal information:\n\n", "italic", buffer);
228 str = g_strdup_printf ("%d", this_proj -> cell.sp_group -> id);
229 print_info ("\t\tSpace group N°: ","italic", buffer);
230 print_info (str, "bold", buffer);
231 g_free (str);
232 print_info ("\n", NULL, buffer);
233 print_info ("\t\tSpace group: ","italic", buffer);
234 print_spg_name (g_strdup_printf ("%s", groups[this_proj -> cell.sp_group -> id-1]), buffer);
235 print_info ("\n", NULL, buffer);
236 print_info ("\t\tSpace group setting: ","italic", buffer);
237 print_spg_setting (this_proj -> cell.sp_group -> setting, buffer);
238 print_info ("\n", NULL, buffer);
239 print_info ("\t\tHermman-Mauguin: ","italic", buffer);
240 print_spg_setting (this_proj -> cell.sp_group -> hms, buffer);
241 print_info ("\n", NULL, buffer);
242 print_info ("\t\tBravais lattice: ","italic", buffer);
243 print_info (this_proj -> cell.sp_group -> bravais, "bold", buffer);
244 print_info ("\n", NULL, buffer);
245 }
246
247 print_info ("\n", NULL, buffer);
248 if (this_proj -> cell.npt)
249 {
250 print_info ("\tAv. volume = ", "italic", buffer);
251 }
252 else
253 {
254 print_info ("\tVolume = ", "italic", buffer);
255 }
256 str = g_strdup_printf ("%14.6lf", this_proj -> cell.volume);
257 print_info (str, "bold", buffer);
258 g_free (str);
259 print_info (" Å", NULL, buffer);
260 print_info ("3", "sup", buffer);
261 if (this_proj -> cell.npt)
262 {
263 print_info ("\n\tAv. density = ", "italic", buffer);
264 }
265 else
266 {
267 print_info ("\n\tDensity = ", "italic", buffer);
268 }
269 str = g_strdup_printf ("%14.6lf", this_proj -> cell.density);
270 print_info (str, "bold", buffer);
271 g_free (str);
272 print_info (" g / cm", NULL, buffer);
273 print_info ("3", "sup", buffer);
274 if (this_proj -> cell.npt)
275 {
276 print_info ("\n\tAv. number density = ", "italic", buffer);
277 }
278 else
279 {
280 print_info ("\n\tNumber density = ", "italic", buffer);
281 }
282 str = g_strdup_printf ("%14.6lf", this_proj -> natomes / this_proj -> cell.volume);
283 print_info (str, "bold", buffer);
284 g_free (str);
285 print_info (" Atoms / Å", NULL, buffer);
286 print_info ("3", "sup", buffer);
287 }
288 print_info ("\n\n\tEmpirical formula:\t", "italic", buffer);
289 for (i=0; i<this_proj -> nspec; i++)
290 {
291 print_info (this_proj -> chemistry -> label[i], "bold", buffer);
292 if (this_proj -> chemistry -> formula[i] != 1)
293 {
294 str = g_strdup_printf ("%d", this_proj -> chemistry -> formula[i]);
295 print_info (str, "sub", buffer);
296 g_free (str);
297 }
298 print_info (" ", NULL, buffer);
299 }
300 if (this_proj -> cell.volume != 0.0)
301 {
302 print_info ("\n\n\tAtom\t Number Fraction\tNumber density (atoms / Å", "italic", buffer);
303 print_info ("3", "sup", buffer);
304 print_info (")\n", "italic", buffer);
305 }
306 else
307 {
308 print_info ("\n\n\tAtom\t Number Fraction", "italic", buffer);
309 }
310
311 for (i=0; i<this_proj -> nspec; i++)
312 {
313 str = g_strdup_printf ("\n\t%s\t%7d\t%11.6lf",
314 this_proj -> chemistry -> label[i], this_proj -> chemistry -> nsps[i],
315 (double)this_proj -> chemistry -> nsps[i]/this_proj -> natomes);
316 print_info (str, textcolor(i), buffer);
317 g_free (str);
318 if (this_proj -> cell.volume != 0.0)
319 {
320 str = g_strdup_printf ("\t%11.6lf", this_proj -> chemistry -> nsps[i]/this_proj -> cell.volume);
321 print_info (str, textcolor(i), buffer);
322 g_free (str);
323 }
324 }
325}
326
336void print_this_ogl_stuff (gchar * text, GLenum name, GtkTextBuffer * buf)
337{
338 int i;
339 gchar * str;
340 print_info (text, NULL, buf);
341 glGetIntegerv (name, & i);
342 str = g_strdup_printf ("%d\n", i);
343 print_info (str, "bold_blue", buf);
344 g_free (str);
345}
346
355void opengl_info (project * this_proj, GtkTextBuffer * buf)
356{
357 int i, j, k, l;
358 i = j = k = l = -1;
359
360 gtk_gl_area_make_current ((GtkGLArea * )this_proj -> modelgl -> plot);
361 gchar * str;
362 print_info ("\n\nOpenGL driver information\n\n", "heading", buf);
363 print_info ("\tOpenGL Version \t\t\t: ", NULL, buf);
364 str = g_strdup_printf ("%s\n", (const char*)glGetString(GL_VERSION));
365 print_info (str, "bold_blue", buf);
366 g_free (str);
367 print_info ("\tOpenGL Driver\t\t\t\t: ", NULL, buf);
368 str = g_strdup_printf ("%s\n", (const char*)glGetString(GL_VENDOR));
369 print_info (str, "bold_blue", buf);
370 g_free (str);
371 print_info ("\tOpenGL Hardware \t\t\t: ", NULL, buf);
372 str = g_strdup_printf ("%s\n", (const char*)glGetString(GL_RENDERER));
373 print_info (str, "bold_blue", buf);
374 g_free (str);
375
376 print_info ("\tOpenGL Shading Version \t\t\t: ", NULL, buf);
377 str = g_strdup_printf ("%s\n\n", (const char*)glGetString (GL_SHADING_LANGUAGE_VERSION));
378 print_info (str, "bold_blue", buf);
379 g_free (str);
380
381 print_info ("\tOpenGL Window information:\n\n", NULL, buf);
382 print_info ("\t\tColor Bits (R,G,B,A)\t\t: ", NULL, buf);
383 glGetIntegerv (GL_RED_BITS, & i);
384 glGetIntegerv (GL_GREEN_BITS, & j);
385 glGetIntegerv (GL_BLUE_BITS, & k);
386 glGetIntegerv (GL_ALPHA_BITS, & l);
387 str = g_strdup_printf ("%d, %d, %d, %d\n", i, j, k, l);
388 print_info (str, "bold_blue", buf);
389 g_free (str);
390 print_this_ogl_stuff ("\t\tDepth Bits \t\t\t: ", GL_DEPTH_BITS, buf);
391 print_this_ogl_stuff ("\t\tStencil Bits \t\t\t: ", GL_STENCIL_BITS, buf);
392 print_this_ogl_stuff ("\t\tMax. Lights Allowed \t\t: ", GL_MAX_LIGHTS, buf);
393 print_this_ogl_stuff ("\t\tMax. Texture Size \t\t: ", GL_MAX_TEXTURE_SIZE, buf);
394 print_this_ogl_stuff ("\t\tMax. Clipping Planes \t\t: ", GL_MAX_CLIP_PLANES, buf);
395 print_this_ogl_stuff ("\t\tMax. Modelview Matrix Stacks \t: ", GL_MAX_MODELVIEW_STACK_DEPTH, buf);
396 print_this_ogl_stuff ("\t\tMax. Projection Matrix Stacks \t: ", GL_MAX_PROJECTION_STACK_DEPTH, buf);
397 print_this_ogl_stuff ("\t\tMax. Attribute Stacks \t\t: ", GL_MAX_ATTRIB_STACK_DEPTH, buf);
398 print_this_ogl_stuff ("\t\tMax. Texture Stacks \t\t: ", GL_MAX_TEXTURE_STACK_DEPTH, buf);
399
400 print_info ("\n\tGeometry Shader information:\n\n", NULL, buf);
401 print_this_ogl_stuff ("\t\tMax. output vertices \t\t: ", GL_MAX_GEOMETRY_OUTPUT_VERTICES, buf);
402 print_this_ogl_stuff ("\t\tMax. output components \t\t: ", GL_MAX_GEOMETRY_OUTPUT_COMPONENTS, buf);
403 print_this_ogl_stuff ("\t\tMax. total output components \t: ", GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS, buf);
404
405 print_info ("\n\tTotal number of OpenGL Extensions\t: ", NULL, buf);
406 glGetIntegerv (GL_NUM_EXTENSIONS, & i);
407 str = g_strdup_printf ("%d\n", i);
408 print_info (str, "bold_blue", buf);
409 g_free (str);
410 print_info ("\tExtensions list:\n", NULL, buf);
411 for (j=0; j<i; j++)
412 {
413 str = g_strdup_printf ("\t\t N°%d\t:\t%s\n", j+1, (const char*)glGetStringi(GL_EXTENSIONS,j));
414 print_info (str, NULL, buf);
415 g_free (str);
416 }
417}
integer(kind=c_int) function chemistry()
Definition chemistry.F90:22
void label(cairo_t *cr, double val, int axe, int p, project *this_proj)
draw axis label
Definition labels.c:56
gchar * text
Definition datab.c:105
gchar * projfile
Definition global.c:140
Global variable declarations Global convenience function declarations Global data structure defin...
char * coord_files[NCFORMATS+1]
Definition callbacks.c:86
image * plot
Definition ogl_draw.c:66
gchar * textcolor(int i)
setup text color keyword
Definition interface.c:763
void print_info(gchar *str, gchar *stag, GtkTextBuffer *buffer)
print information in GtkTextBuffer
Definition interface.c:738
Messaging function declarations.
gchar * groups[230]
Definition cbuild_sg.c:43
char * vect_comp[3]
Definition edit_menu.c:82
gchar * substitute_string(gchar *init, gchar *o_motif, gchar *n_motif)
substitute all patterns in string
Definition w_library.c:372
gchar * get_num_string(gchar *str)
get description string for entry string
void model_info(project *this_proj, GtkTextBuffer *buffer)
display model information in GtkTexBuffer
Definition modelinfo.c:113
void opengl_info(project *this_proj, GtkTextBuffer *buf)
display OpenGL information in a GtkTextBuffer
Definition modelinfo.c:355
void print_this_ogl_stuff(gchar *text, GLenum name, GtkTextBuffer *buf)
print OpenGL stuff in a GtkTextBuffer
Definition modelinfo.c:336
void print_spg_setting(gchar *init, GtkTextBuffer *buffer)
print space group name in a GtkTextBuffer
Definition modelinfo.c:96
void print_spg_name(gchar *str, GtkTextBuffer *buffer)
print space group name in a GtkTextBuffer
Definition modelinfo.c:57