atomes 1.2.1
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-2025 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, "wsubx");
74 if (sta) print_info (sta, "bold", buffer);
75 }
76 }
77 }
78 else
79 {
80 print_info (str, "bold", buffer);
81 }
82 g_free (str);
83}
84
93void print_spg_setting (gchar * init, GtkTextBuffer * buffer)
94{
95 gchar * str = g_strdup_printf ("%s", init);
96 str = substitute_string (str, "_", " ");
97 str = get_num_string (str);
98 str = substitute_string (str, " ", NULL);
99 print_spg_name (str, buffer);
100}
101
110void model_info (project * this_proj, GtkTextBuffer * buffer)
111{
112 int i, j, k;
113 double v;
114 gchar * str;
115 if (g_strcmp0(this_proj -> projfile, "(null)") == 0) this_proj -> projfile = NULL;
116 if (this_proj -> projfile != NULL)
117 {
118 print_info ("\n\tProject file: ", "italic", buffer);
119 print_info (this_proj -> projfile, NULL, buffer);
120 }
121
122 if (this_proj -> tfile > -1 && this_proj -> coordfile != NULL)
123 {
124 print_info ("\n\tCoordinates file: ", "italic", buffer);
125 print_info (this_proj -> coordfile, NULL, buffer);
126 print_info ("\n\tFile type: ", "italic", buffer);
127 print_info (coord_files[this_proj -> tfile], NULL, buffer);
128 this_proj -> tfile = 0;
129 }
130 print_info ("\n\nModel properties\n\n\n", "heading", buffer);
131 if (this_proj -> steps > 1)
132 {
133 print_info ("\tNumber of MD steps = ", "italic", buffer);
134 str = g_strdup_printf ("%d\n", this_proj -> steps);
135 print_info (str, "bold", buffer);
136 g_free (str);
137 }
138 print_info ("\tNumber of atoms = ", "italic", buffer);
139 str = g_strdup_printf ("%d\n", this_proj -> natomes);
140 print_info (str, "bold", buffer);
141 g_free (str);
142 print_info ("\tNumber of species = ", "italic", buffer);
143 str = g_strdup_printf ("%d\n\n", this_proj -> nspec);
144 print_info (str, "bold", buffer);
145 g_free (str);
146 if (this_proj -> cell.volume > 0.0)
147 {
148 gchar * latv[2][3]={{"a", "b", "c"},
149 {"α", "β", "γ"}};
150 if (this_proj -> cell.npt)
151 {
152 print_info ("\tAv. lattice parameters:\n\n", NULL, buffer);
153 }
154 else
155 {
156 print_info ("\tLattice parameters:\n\n", NULL, buffer);
157 }
158 for (i=0; i<2; i++)
159 {
160 print_info ("\t", NULL, buffer);
161 for (j=0; j<3; j++)
162 {
163 str = g_strdup_printf ("\t %s=", latv[i][j]);
164 print_info (str, "bold_italic", buffer);
165 g_free (str);
166 if (this_proj -> cell.npt)
167 {
168 v = 0.0;
169 for (k=0; k<this_proj -> steps; k++) v += this_proj -> cell.box[k].param[i][j];
170 v /= this_proj -> steps;
171 }
172 else
173 {
174 v = this_proj -> cell.box[0].param[i][j];
175 }
176 str = g_strdup_printf ("%10.5lf", v);
177 print_info (str, "bold_green", buffer);
178 g_free (str);
179 }
180 print_info ("\n", NULL, buffer);
181 }
182 print_info ("\n", NULL, buffer);
183 if (this_proj -> cell.npt)
184 {
185 print_info ("\tAv. lattice vectors:\n\n\t\t", NULL, buffer);
186 }
187 else
188 {
189 print_info ("\tLattice vectors:\n\n\t\t", NULL, buffer);
190 }
191 for (i=0; i<3; i++)
192 {
193 str = g_strdup_printf (" %s ", vect_comp[i]);
194 print_info (str, NULL, buffer);
195 g_free (str);
196 }
197 print_info ("\n", NULL, buffer);
198 for (i=0; i<3; i++)
199 {
200 str = g_strdup_printf ("\t\t%s", latv[0][i]);
201 print_info (str, NULL, buffer);
202 g_free (str);
203 for (j=0; j<3; j++)
204 {
205 if (this_proj -> cell.npt)
206 {
207 v = 0.0;
208 for (k=0; k<this_proj -> steps; k++) v += this_proj -> cell.box[k].vect[i][j];
209 v /= this_proj -> steps;
210 }
211 else
212 {
213 v = this_proj -> cell.box[0].vect[i][j];
214 }
215 str = g_strdup_printf ("%10.5lf", v);
216 print_info (str, "bold_orange", buffer);
217 g_free (str);
218 }
219 print_info ("\n", NULL, buffer);
220 }
221 if (this_proj -> cell.sp_group)
222 {
223 print_info ("\n", NULL, buffer);
224 print_info ("\tCrystal information:\n\n", "italic", buffer);
225 str = g_strdup_printf ("%d", this_proj -> cell.sp_group -> id);
226 print_info ("\t\tSpace group N°: ","italic", buffer);
227 print_info (str, "bold", buffer);
228 g_free (str);
229 print_info ("\n", NULL, buffer);
230 print_info ("\t\tSpace group: ","italic", buffer);
231 print_spg_name (g_strdup_printf ("%s", groups[this_proj -> cell.sp_group -> id-1]), buffer);
232 print_info ("\n", NULL, buffer);
233 print_info ("\t\tSpace group setting: ","italic", buffer);
234 print_spg_setting (this_proj -> cell.sp_group -> setting, buffer);
235 print_info ("\n", NULL, buffer);
236 print_info ("\t\tHermman-Mauguin: ","italic", buffer);
237 print_spg_setting (this_proj -> cell.sp_group -> hms, buffer);
238 print_info ("\n", NULL, buffer);
239 print_info ("\t\tBravais lattice: ","italic", buffer);
240 print_info (this_proj -> cell.sp_group -> bravais, "bold", buffer);
241 print_info ("\n", NULL, buffer);
242 }
243
244 print_info ("\n", NULL, buffer);
245 if (this_proj -> cell.npt)
246 {
247 print_info ("\tAv. volume = ", "italic", buffer);
248 }
249 else
250 {
251 print_info ("\tVolume = ", "italic", buffer);
252 }
253 str = g_strdup_printf ("%14.6lf", this_proj -> cell.volume);
254 print_info (str, "bold", buffer);
255 g_free (str);
256 print_info (" Å", NULL, buffer);
257 print_info ("3", "sup", buffer);
258 if (this_proj -> cell.npt)
259 {
260 print_info ("\n\tAv. density = ", "italic", buffer);
261 }
262 else
263 {
264 print_info ("\n\tDensity = ", "italic", buffer);
265 }
266 str = g_strdup_printf ("%14.6lf", this_proj -> cell.density);
267 print_info (str, "bold", buffer);
268 g_free (str);
269 print_info (" g / cm", NULL, buffer);
270 print_info ("3", "sup", buffer);
271 if (this_proj -> cell.npt)
272 {
273 print_info ("\n\tAv. number density = ", "italic", buffer);
274 }
275 else
276 {
277 print_info ("\n\tNumber density = ", "italic", buffer);
278 }
279 str = g_strdup_printf ("%14.6lf", this_proj -> natomes / this_proj -> cell.volume);
280 print_info (str, "bold", buffer);
281 g_free (str);
282 print_info (" Atoms / Å", NULL, buffer);
283 print_info ("3", "sup", buffer);
284 }
285 print_info ("\n\n\tEmpirical formula:\t", "italic", buffer);
286 for (i=0; i<this_proj -> nspec; i++)
287 {
288 print_info (this_proj -> chemistry -> label[i], "bold", buffer);
289 if (this_proj -> chemistry -> formula[i] != 1)
290 {
291 str = g_strdup_printf ("%d", this_proj -> chemistry -> formula[i]);
292 print_info (str, "sub", buffer);
293 g_free (str);
294 }
295 print_info (" ", NULL, buffer);
296 }
297 if (this_proj -> cell.volume != 0.0)
298 {
299 print_info ("\n\n\tAtom\t Number Fraction\tNumber density (atoms / Å", "italic", buffer);
300 print_info ("3", "sup", buffer);
301 print_info (")\n", "italic", buffer);
302 }
303 else
304 {
305 print_info ("\n\n\tAtom\t Number Fraction", "italic", buffer);
306 }
307
308 for (i=0; i<this_proj -> nspec; i++)
309 {
310 str = g_strdup_printf ("\n\t%s\t%7d\t%11.6lf",
311 this_proj -> chemistry -> label[i], this_proj -> chemistry -> nsps[i],
312 (double)this_proj -> chemistry -> nsps[i]/this_proj -> natomes);
313 print_info (str, textcolor(i), buffer);
314 g_free (str);
315 if (this_proj -> cell.volume != 0.0)
316 {
317 str = g_strdup_printf ("\t%11.6lf", this_proj -> chemistry -> nsps[i]/this_proj -> cell.volume);
318 print_info (str, textcolor(i), buffer);
319 g_free (str);
320 }
321 }
322}
323
333void print_this_ogl_stuff (gchar * text, GLenum name, GtkTextBuffer * buf)
334{
335 int i;
336 gchar * str;
337 print_info (text, NULL, buf);
338 glGetIntegerv (name, & i);
339 str = g_strdup_printf ("%d\n", i);
340 print_info (str, "bold_blue", buf);
341 g_free (str);
342}
343
352void opengl_info (project * this_proj, GtkTextBuffer * buf)
353{
354 int i, j, k, l;
355 i = j = k = l = -1;
356
357 gtk_gl_area_make_current ((GtkGLArea *)this_proj -> modelgl -> plot);
358 gchar * str;
359 print_info ("\n\nOpenGL driver information\n\n", "heading", buf);
360 print_info ("\tOpenGL Version \t\t\t: ", NULL, buf);
361 str = g_strdup_printf ("%s\n", (const char*)glGetString(GL_VERSION));
362 print_info (str, "bold_blue", buf);
363 g_free (str);
364 print_info ("\tOpenGL Driver\t\t\t\t: ", NULL, buf);
365 str = g_strdup_printf ("%s\n", (const char*)glGetString(GL_VENDOR));
366 print_info (str, "bold_blue", buf);
367 g_free (str);
368 print_info ("\tOpenGL Hardware \t\t\t: ", NULL, buf);
369 str = g_strdup_printf ("%s\n", (const char*)glGetString(GL_RENDERER));
370 print_info (str, "bold_blue", buf);
371 g_free (str);
372
373 print_info ("\tOpenGL Shading Version \t\t\t: ", NULL, buf);
374 str = g_strdup_printf ("%s\n\n", (const char*)glGetString (GL_SHADING_LANGUAGE_VERSION));
375 print_info (str, "bold_blue", buf);
376 g_free (str);
377
378 print_info ("\tOpenGL Window information:\n\n", NULL, buf);
379 print_info ("\t\tColor Bits (R,G,B,A)\t\t: ", NULL, buf);
380 glGetIntegerv (GL_RED_BITS, & i);
381 glGetIntegerv (GL_GREEN_BITS, & j);
382 glGetIntegerv (GL_BLUE_BITS, & k);
383 glGetIntegerv (GL_ALPHA_BITS, & l);
384 str = g_strdup_printf ("%d, %d, %d, %d\n", i, j, k, l);
385 print_info (str, "bold_blue", buf);
386 g_free (str);
387 print_this_ogl_stuff ("\t\tDepth Bits \t\t\t: ", GL_DEPTH_BITS, buf);
388 print_this_ogl_stuff ("\t\tStencil Bits \t\t\t: ", GL_STENCIL_BITS, buf);
389 print_this_ogl_stuff ("\t\tMax. Lights Allowed \t\t: ", GL_MAX_LIGHTS, buf);
390 print_this_ogl_stuff ("\t\tMax. Texture Size \t\t: ", GL_MAX_TEXTURE_SIZE, buf);
391 print_this_ogl_stuff ("\t\tMax. Clipping Planes \t\t: ", GL_MAX_CLIP_PLANES, buf);
392 print_this_ogl_stuff ("\t\tMax. Modelview Matrix Stacks \t: ", GL_MAX_MODELVIEW_STACK_DEPTH, buf);
393 print_this_ogl_stuff ("\t\tMax. Projection Matrix Stacks \t: ", GL_MAX_PROJECTION_STACK_DEPTH, buf);
394 print_this_ogl_stuff ("\t\tMax. Attribute Stacks \t\t: ", GL_MAX_ATTRIB_STACK_DEPTH, buf);
395 print_this_ogl_stuff ("\t\tMax. Texture Stacks \t\t: ", GL_MAX_TEXTURE_STACK_DEPTH, buf);
396
397 print_info ("\n\tGeometry Shader information:\n\n", NULL, buf);
398 print_this_ogl_stuff ("\t\tMax. output vertices \t\t: ", GL_MAX_GEOMETRY_OUTPUT_VERTICES, buf);
399 print_this_ogl_stuff ("\t\tMax. output components \t\t: ", GL_MAX_GEOMETRY_OUTPUT_COMPONENTS, buf);
400 print_this_ogl_stuff ("\t\tMax. total output components \t: ", GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS, buf);
401
402 print_info ("\n\tTotal number of OpenGL Extensions\t: ", NULL, buf);
403 glGetIntegerv (GL_NUM_EXTENSIONS, & i);
404 str = g_strdup_printf ("%d\n", i);
405 print_info (str, "bold_blue", buf);
406 g_free (str);
407 print_info ("\tExtensions list:\n", NULL, buf);
408 for (j=0; j<i; j++)
409 {
410 str = g_strdup_printf ("\t\t N°%d\t:\t%s\n", j+1, (const char*)glGetStringi(GL_EXTENSIONS,j));
411 print_info (str, NULL, buf);
412 g_free (str);
413 }
414}
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:141
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:70
gchar * textcolor(int i)
setup text color keyword
Definition interface.c:824
void print_info(gchar *str, gchar *stag, GtkTextBuffer *buffer)
print information in GtkTextBuffer
Definition interface.c:799
Messaging function declarations.
gchar * groups[230]
Definition cbuild_sg.c:43
char * vect_comp[3]
Definition edit_menu.c:83
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:110
void opengl_info(project *this_proj, GtkTextBuffer *buf)
display OpenGL information in a GtkTextBuffer
Definition modelinfo.c:352
void print_this_ogl_stuff(gchar *text, GLenum name, GtkTextBuffer *buf)
print OpenGL stuff in a GtkTextBuffer
Definition modelinfo.c:333
void print_spg_setting(gchar *init, GtkTextBuffer *buffer)
print space group name in a GtkTextBuffer
Definition modelinfo.c:93
void print_spg_name(gchar *str, GtkTextBuffer *buffer)
print space group name in a GtkTextBuffer
Definition modelinfo.c:57