atomes 1.3.1
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
sktcall.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-2026 by CNRS and University of Strasbourg */
15
21
22/*
23* This file: 'sktcall.c'
24*
25* Contains:
26*
27
28 - The callbacks for the dynamic structure factor calculation dialog
29
30*
31* List of functions:
32
33 void init_sqw (project * this_proj);
34 void recup_sqw_list_ (int nq, double qval[nq]);
35 void init_skt (project * this_proj, int opening);
36 void update_skt_view (project * this_proj);
37
38 G_MODULE_EXPORT void on_calc_skt_released (GtkWidget * widg, gpointer data);
39
40*/
41
42#include <gtk/gtk.h>
43#include <string.h>
44#include <stdlib.h>
45
46#include "global.h"
47#include "bind.h"
48#include "interface.h"
49#include "callbacks.h"
50#include "curve.h"
51#include "project.h"
52
53extern void alloc_analysis_curves (int pid, atomes_analysis * this_analysis);
54extern void update_sq_view (project * this_proj, int sqk);
55extern void update_dynamic_view (project * this_proj, GtkTextBuffer * calc_buffer);
56extern gboolean skt_all_sets;
57
65void init_sqw (project * this_proj)
66{
67 int g, h, i, k, l, m;
68 g = 8+4*this_proj -> nspec*this_proj -> nspec;
69 if (this_proj -> nspec == 2) g += 8;
70 for (h=0; h < this_proj -> sqw_n_data_sets; h++)
71 {
72 i = this_proj -> skt_sets + h*g;
73 this_proj -> analysis[SKT] -> curves[0+i] -> name = g_strdup_printf ("S(q,ω) %s - q= %f", _("Neutrons"), this_proj -> sqw_q_id[h]);
74 this_proj -> analysis[SKT] -> curves[1+i] -> name = g_strdup_printf ("S(q,ω) %s - q= %f - %s", _("Neutrons"), this_proj -> sqw_q_id[h], _("smoothed"));
75 this_proj -> analysis[SKT] -> curves[2+i] -> name = g_strdup_printf ("Q(q,ω) %s - q= %f", _("Neutrons"), this_proj -> sqw_q_id[h]);
76 this_proj -> analysis[SKT] -> curves[3+i] -> name = g_strdup_printf ("Q(q,ω) %s - q= %f - %s", _("Neutrons"), this_proj -> sqw_q_id[h], _("smoothed"));
77 this_proj -> analysis[SKT] -> curves[4+i] -> name = g_strdup_printf ("S(q,ω) %s - q= %f", _("X-rays"), this_proj -> sqw_q_id[h]);
78 this_proj -> analysis[SKT] -> curves[5+i] -> name = g_strdup_printf ("S(q,ω) %s - q= %f - %s", _("X-rays"), this_proj -> sqw_q_id[h], _("smoothed"));
79 this_proj -> analysis[SKT] -> curves[6+i] -> name = g_strdup_printf ("Q(q,ω) %s - q= %f", _("X-rays"), this_proj -> sqw_q_id[h]);
80 this_proj -> analysis[SKT] -> curves[7+i] -> name = g_strdup_printf ("Q(q,ω) %s - q= %f - %s", _("X-rays"), this_proj -> sqw_q_id[h], _("smoothed"));
81 k = i + 8;
82 for ( l = 0 ; l < this_proj -> nspec ; l++ )
83 {
84 for ( m = 0 ; m < this_proj -> nspec ; m++ )
85 {
86 this_proj -> analysis[SKT] -> curves[k] -> name = g_strdup_printf ("AL(q,ω)[%s,%s] - q= %f", active_chem -> label[l], active_chem -> label[m], this_proj -> sqw_q_id[h]);
87 k ++;
88 this_proj -> analysis[SKT] -> curves[k] -> name = g_strdup_printf ("AL(q,ω)[%s,%s] - q= %f - %s", active_chem -> label[l], active_chem -> label[m], this_proj -> sqw_q_id[h], _("smoothed"));
89 k ++;
90 }
91 }
92 for ( l = 0 ; l < this_proj -> nspec ; l++ )
93 {
94 for ( m = 0 ; m < this_proj -> nspec ; m++ )
95 {
96 this_proj -> analysis[SKT] -> curves[k] -> name = g_strdup_printf ("FZ(q,ω)[%s,%s] - q= %f", active_chem -> label[l], active_chem -> label[m], this_proj -> sqw_q_id[h]);
97 k ++;
98 this_proj -> analysis[SKT] -> curves[k] -> name = g_strdup_printf ("FZ(q,ω)[%s,%s] - q= %f - %s", active_chem -> label[l], active_chem -> label[m], this_proj -> sqw_q_id[h], _("smoothed"));
99 k ++;
100 }
101 }
102 if ( this_proj -> nspec == 2 )
103 {
104 this_proj -> analysis[SKT] -> curves[k] -> name = g_strdup_printf ("BT(q,ω)[NN] - q= %f", this_proj -> sqw_q_id[h]);
105 k ++;
106 this_proj -> analysis[SKT] -> curves[k] -> name = g_strdup_printf ("BT(q,ω)[NN] - q= %f - %s", this_proj -> sqw_q_id[h], _("smoothed"));
107 k ++;
108 this_proj -> analysis[SKT] -> curves[k] -> name = g_strdup_printf ("BT(q,ω)[NC] - q= %f", this_proj -> sqw_q_id[h]);
109 k ++;
110 this_proj -> analysis[SKT] -> curves[k] -> name = g_strdup_printf ("BT(q,ω)[NC] - q= %f - %s", this_proj -> sqw_q_id[h], _("smoothed"));
111 k ++;
112 this_proj -> analysis[SKT] -> curves[k] -> name = g_strdup_printf ("BT(q,ω)[CC] - q= %f", this_proj -> sqw_q_id[h]);
113 k ++;
114 this_proj -> analysis[SKT] -> curves[k] -> name = g_strdup_printf ("BT(q,ω)[CC] - q= %f - %s", this_proj -> sqw_q_id[h], _("smoothed"));
115 k ++;
116 this_proj -> analysis[SKT] -> curves[k] -> name = g_strdup_printf ("BT(q,ω)[ZZ] - q= %f", this_proj -> sqw_q_id[h]);
117 k ++;
118 this_proj -> analysis[SKT] -> curves[k] -> name = g_strdup_printf ("BT(q,ω)[ZZ] - q= %f - %s", this_proj -> sqw_q_id[h], _("smoothed"));
119 }
120 }
121 for (h=this_proj -> skt_sets; h < this_proj -> analysis[SKT] -> numc; h++)
122 {
123 init_curve_title (this_proj, SKT, h);
124 }
125}
126
135void recup_sqw_list_ (int nq, double qval[nq])
136{
137 if (nq != active_project -> sqw_n_data_sets)
138 {
139 // This should happen, error ?
140 }
141 int i;
142 for (i=0; i<* qval; i++)
143 {
144 active_project -> sqw_q_id[i] = qval[i];
145 }
147 // Update calculation dialog ?
148}
149
158void init_skt (project * this_proj, int opening)
159{
160 int g, h, i, j, k, l, m;
161 if (this_proj -> analysis[SKT] -> curves)
162 {
163 for (i=0; i<this_proj -> analysis[SKT] -> numc; i++)
164 {
165 hide_the_widgets(this_proj -> analysis[SKT] -> curves[i] -> window);
166 }
167 }
168 this_proj -> skt_sets = 8+4*this_proj -> nspec*this_proj -> nspec;
169 if (this_proj -> nspec == 2) this_proj -> skt_sets += 8;
170 this_proj -> sqw_sets = this_proj -> skt_sets;
171 g = this_proj -> skt_sets;
172 if (this_proj -> skt_all_sets)
173 {
174 this_proj -> skt_sets *= (this_proj -> steps - this_proj -> skt_corr_threshold);
175 }
176 else
177 {
178 this_proj -> skt_sets *= this_proj -> skt_n_data_sets;
179 }
180 this_proj -> sqw_sets *= this_proj -> sqw_n_data_sets;
181 this_proj -> analysis[SKT] -> numc = this_proj -> skt_sets + this_proj -> sqw_sets;
182 alloc_analysis_curves (this_proj -> id, this_proj -> analysis[SKT]);
183 for (h=0; h < ((this_proj -> skt_all_sets) ? this_proj -> steps - this_proj -> skt_corr_threshold : this_proj -> skt_n_data_sets); h++)
184 {
185 i = h*g;
186 j = (this_proj -> skt_all_sets) ? h+1 : active_project -> skt_step_id[h];
187 this_proj -> analysis[SKT] -> curves[0+i] -> name = g_strdup_printf ("S(q,ẟt) %s - ẟt= %d", _("Neutrons"), j);
188 this_proj -> analysis[SKT] -> curves[1+i] -> name = g_strdup_printf ("S(q,ẟt) %s - ẟt= %d - %s", _("Neutrons"), j, _("smoothed"));
189 this_proj -> analysis[SKT] -> curves[2+i] -> name = g_strdup_printf ("Q(q,ẟt) %s - ẟt= %d", _("Neutrons"), j);
190 this_proj -> analysis[SKT] -> curves[3+i] -> name = g_strdup_printf ("Q(q,ẟt) %s - ẟt= %d - %s", _("Neutrons"), j, _("smoothed"));
191 this_proj -> analysis[SKT] -> curves[4+i] -> name = g_strdup_printf ("S(q,ẟt) %s - ẟt= %d", _("X-rays"), j);
192 this_proj -> analysis[SKT] -> curves[5+i] -> name = g_strdup_printf ("S(q,ẟt) %s - ẟt= %d - %s", _("X-rays"), j, _("smoothed"));
193 this_proj -> analysis[SKT] -> curves[6+i] -> name = g_strdup_printf ("Q(q,ẟt) %s - ẟt= %d", _("X-rays"), j);
194 this_proj -> analysis[SKT] -> curves[7+i] -> name = g_strdup_printf ("Q(q,ẟt) %s - ẟt= %d - %s", _("X-rays"), j, _("smoothed"));
195
196 k = 8+i;
197 for ( l = 0 ; l < this_proj -> nspec ; l++ )
198 {
199 for ( m = 0 ; m < this_proj -> nspec ; m++ )
200 {
201 this_proj -> analysis[SKT] -> curves[k] -> name = g_strdup_printf ("AL(q,ẟt)[%s,%s] - ẟt= %d", active_chem -> label[l], active_chem -> label[m], j);
202 k ++;
203 this_proj -> analysis[SKT] -> curves[k] -> name = g_strdup_printf ("AL(q,ẟt)[%s,%s] - ẟt= %d - %s", active_chem -> label[l], active_chem -> label[m], j, _("smoothed"));
204 k ++;
205 }
206 }
207 for ( l = 0 ; l < this_proj -> nspec ; l++ )
208 {
209 for ( m = 0 ; m < this_proj -> nspec ; m++ )
210 {
211 this_proj -> analysis[SKT] -> curves[k] -> name = g_strdup_printf ("FZ(q,ẟt)[%s,%s] - ẟt= %d", active_chem -> label[l], active_chem -> label[m], j);
212 k ++;
213 this_proj -> analysis[SKT] -> curves[k] -> name = g_strdup_printf ("FZ(q,ẟt)[%s,%s] - ẟt= %d - %s", active_chem -> label[l], active_chem -> label[m], j, _("smoothed"));
214 k ++;
215 }
216 }
217 if ( this_proj -> nspec == 2 )
218 {
219 this_proj -> analysis[SKT] -> curves[k] -> name = g_strdup_printf ("BT(q,ẟt)[NN] - ẟt= %d", j);
220 k ++;
221 this_proj -> analysis[SKT] -> curves[k] -> name = g_strdup_printf ("BT(q,ẟt)[NN] - ẟt= %d - %s", j, _("smoothed"));
222 k ++;
223 this_proj -> analysis[SKT] -> curves[k] -> name = g_strdup_printf ("BT(q,ẟt)[NC] - ẟt= %d", j);
224 k ++;
225 this_proj -> analysis[SKT] -> curves[k] -> name = g_strdup_printf ("BT(q,ẟt)[NC] - ẟt= %d - %s", j,_("smoothed"));
226 k ++;
227 this_proj -> analysis[SKT] -> curves[k] -> name = g_strdup_printf ("BT(q,ẟt)[CC] - ẟt= %d", j);
228 k ++;
229 this_proj -> analysis[SKT] -> curves[k] -> name = g_strdup_printf ("BT(q,ẟt)[CC] - ẟt= %d - %s", j, _("smoothed"));
230 k ++;
231 this_proj -> analysis[SKT] -> curves[k] -> name = g_strdup_printf ("BT(q,ẟt)[ZZ] - ẟt= %d", j);
232 k ++;
233 this_proj -> analysis[SKT] -> curves[k] -> name = g_strdup_printf ("BT(q,ẟt)[ZZ] - t= %d - %s", j, _("smoothed"));
234 }
235 }
236 if (opening) init_sqw (this_proj);
237 add_curve_widgets (this_proj, SKT);
238 this_proj -> analysis[SKT] -> init_ok = TRUE;
239}
240
248void update_skt_view (project * this_proj)
249{
250 int i;
251 gchar * str;
252 update_sq_view (this_proj, SKT);
253 print_info ("\n", NULL, this_proj -> analysis[SKT] -> calc_buffer);
254 print_info (_("\tMolecular dynamics information:\n\n"), NULL, this_proj -> analysis[SKT] -> calc_buffer);
255 update_dynamic_view (this_proj, this_proj -> analysis[SKT] -> calc_buffer);
256
257 print_info (_("\n\n\tIntermediate scattering - F(q,δt)\n\n"), NULL, this_proj -> analysis[SKT] -> calc_buffer);
258
259 print_info (_("\t - Correlation threshold δt"), "bold", this_proj -> analysis[SKT] -> calc_buffer);
260 print_info ("min", "sup_bold", this_proj -> analysis[SKT] -> calc_buffer);
261 print_info (" = ", "bold", this_proj -> analysis[SKT] -> calc_buffer);
262 str = g_strdup_printf ("%d", this_proj -> skt_corr_threshold);
263 print_info (str, "bold_blue", this_proj -> analysis[SKT] -> calc_buffer);
264 g_free (str);
265 print_info ("\n", NULL, this_proj -> analysis[SKT] -> calc_buffer);
266 if (this_proj -> skt_all_sets)
267 {
268 print_info (_("\t - All "), "bold", this_proj -> analysis[SKT] -> calc_buffer);
269 str = g_strdup_printf ("%d", this_proj -> skt_sets);
270 print_info (str, "bold_blue", this_proj -> analysis[SKT] -> calc_buffer);
271 g_free (str);
272 print_info (_(" correlated calculations saved"), "bold", this_proj -> analysis[SKT] -> calc_buffer);
273 print_info ("\n", NULL, this_proj -> analysis[SKT] -> calc_buffer);
274 }
275 else
276 {
277 print_info (_("\t - Results saved for "), "bold", this_proj -> analysis[SKT] -> calc_buffer);
278 str = g_strdup_printf ("%d", this_proj -> skt_n_data_sets);
279 print_info (str, "bold_blue", this_proj -> analysis[SKT] -> calc_buffer);
280 g_free (str);
281 print_info (_(" correlated calculations:\n\n"), "bold", this_proj -> analysis[SKT] -> calc_buffer);
282 for (i=0; i<this_proj -> skt_n_data_sets; i++)
283 {
284 print_info (" \t\t ", NULL, this_proj -> analysis[SKT] -> calc_buffer);
285 str = g_strdup_printf ("%d", i);
286 print_info (str, NULL, this_proj -> analysis[SKT] -> calc_buffer);
287 g_free (str);
288 print_info (") δt\t=\t", NULL, this_proj -> analysis[SKT] -> calc_buffer);
289 str = g_strdup_printf ("%d\n", this_proj -> skt_step_id[i]);
290 print_info (str, "bold_green", this_proj -> analysis[SKT] -> calc_buffer);
291 g_free (str);
292 }
293 }
294 print_info ("\n", NULL, this_proj -> analysis[SKT] -> calc_buffer);
295 print_info (_("\tDynamic structure factor - S(q,ω)\n\n"), NULL, this_proj -> analysis[SKT] -> calc_buffer);
296 print_info ("\t - ", "bold", this_proj -> analysis[SKT] -> calc_buffer);
297 str = g_strdup_printf ("%d", this_proj -> sqw_n_data_sets);
298 print_info (str, "bold_blue", this_proj -> analysis[SKT] -> calc_buffer);
299 g_free (str);
300 print_info (_(" q vectors were analyzed:\n\n"), "bold", this_proj -> analysis[SKT] -> calc_buffer);
301 for (i=0; i<this_proj -> sqw_n_data_sets; i++)
302 {
303 print_info (" \t\t ", NULL, this_proj -> analysis[SKT] -> calc_buffer);
304 str = g_strdup_printf ("%d", i);
305 print_info (str, NULL, this_proj -> analysis[SKT] -> calc_buffer);
306 g_free (str);
307 print_info (") q\t=\t", NULL, this_proj -> analysis[SKT] -> calc_buffer);
308 str = g_strdup_printf ("%f", this_proj -> sqw_q_id[i]);
309 print_info (str, "bold_red", this_proj -> analysis[SKT] -> calc_buffer);
310 g_free (str);
311 print_info (" Å", "bold", this_proj -> analysis[SKT] -> calc_buffer);
312 print_info ("-1", "sup_bold", this_proj -> analysis[SKT] -> calc_buffer);
313 print_info ("\n", "bold", this_proj -> analysis[SKT] -> calc_buffer);
314 }
315 print_info (calculation_time(TRUE, this_proj -> analysis[SKT] -> calc_time), NULL, this_proj -> analysis[SKT] -> calc_buffer);
316}
317
326G_MODULE_EXPORT void on_calc_skt_released (GtkWidget * widg, gpointer data)
327{
328 // Initializing the graph for this calculation, if not done already
330
331 // Cleaning previous results, if any
332 clean_curves_data (SKT, 0, active_project -> analysis[SKT] -> numc);
333 active_project -> analysis[SKT] -> delta = (active_project -> analysis[SKT] -> max - active_project -> analysis[SKT] -> min) / active_project -> analysis[SKT] -> num_delta;
334
335 // Calculation time for dynamic structure factor analysis starts here !
336 prepostcalc (widg, FALSE, SKT, 0, opac);
337 int i;
338 i = cqvf_ (& active_project -> analysis[SKT] -> max,
339 & active_project -> analysis[SKT] -> min,
340 & active_project -> analysis[SKT] -> num_delta,
341 & active_project -> sk_advanced[1][0],
342 & active_project -> sk_advanced[1][1]);
343 if (i == 1)
344 {
345 for (i=0; i<active_project -> analysis[SKT] -> numc; i++)
346 {
347 active_project -> analysis[SKT] -> curves[i] -> ndata = 0;
348 }
349 double detla_t = active_project -> analysis[MSD] -> delta*active_project -> analysis[MSD] -> num_delta;
350 int res_skt = s_of_k_t_ (& active_project -> analysis[SKT] -> num_delta,
351 & active_project -> xcor,
352 & active_project -> skt_corr_threshold,
353 & active_project -> skt_n_data_sets,
354 active_project -> skt_step_id,
355 & detla_t,
356 & active_project -> sqw_n_data_sets,
357 active_project -> sqw_q_id,
358 & active_project -> sqw_freq);
359 g_free (xsk);
360 xsk = NULL;
361 prepostcalc (widg, TRUE, SKT, res_skt, 1.0);
362 if (! res_skt)
363 {
364 show_error (_("The dynamic structure factor calculation has failed"), 0, widg);
365 }
366 else
367 {
370 }
371 }
372 else
373 {
374 prepostcalc (widg, TRUE, SKT, i, 1.0);
375 show_error (_("Problem during the selection of the k-points\nused to sample the reciprocal lattice"), 0, widg);
376 }
378}
Binding to the Fortran90 subroutines.
int cqvf_(double *, double *, int *, double *, double *)
int s_of_k_t_(int *, int *, int *, int *, int *, double *, int *, double *, int *)
Callback declarations for main window.
void fill_tool_model()
fill the tool window tree model
Definition tools.c:91
Variable declarations for the curve widget Functions for interactions with the curve widget.
void add_curve_widgets(project *this_proj, int rid)
add curve widgets to the project
Definition cwidget.c:283
void clean_curves_data(int calc, int start, int end)
clean curve data on a range of curve id
Definition initc.c:61
void init_curve_title(project *this_proj, int rid, int cid)
init curve title and axis titles
Definition cwidget.c:260
double * xsk
Definition global.c:180
gchar * calculation_time(gboolean modelv, double ctime)
get calculation time, human readable
Definition global.c:643
double opac
Definition global.c:201
GtkWidget * curvetoolbox
Definition global.c:211
Global variable declarations Global convenience function declarations Global data structure defin...
#define SKT
Definition global.h:347
chemical_data * active_chem
Definition project.c:48
#define min(a, b)
Definition global.h:93
void hide_the_widgets(GtkWidget *widg)
hide GtkWidget
Definition gtk-misc.c:224
project * active_project
Definition project.c:47
#define MSD
Definition global.h:346
void show_the_widgets(GtkWidget *widg)
show GtkWidget
Definition gtk-misc.c:202
#define max(a, b)
Definition global.h:92
void prepostcalc(GtkWidget *widg, gboolean status, int run, int adv, double opc)
to just before and just after running a calculation
Definition initc.c:87
void show_error(char *error, int val, GtkWidget *win)
show error message
Definition interface.c:299
void print_info(gchar *str, gchar *stag, GtkTextBuffer *buffer)
print information in GtkTextBuffer
Definition interface.c:869
Messaging function declarations.
Function declarations for reading atomes project file Function declarations for saving atomes proje...
G_MODULE_EXPORT void on_calc_skt_released(GtkWidget *widg, gpointer data)
callback to compute the dynamic structure factor analysis
Definition sktcall.c:326
void update_sq_view(project *this_proj, int sqk)
update the text view for s(q) / s(k) calculation
Definition sqcall.c:124
void init_skt(project *this_proj, int opening)
initialize the curve widgets for the s(k,t) and s(q,w) calculations
Definition sktcall.c:158
void recup_sqw_list_(int nq, double qval[nq])
retrieve exact q vector values from Fortran
Definition sktcall.c:135
gboolean skt_all_sets
void init_sqw(project *this_proj)
initialize the curve widgets for the s(k,t) and s(q,w) calculations
Definition sktcall.c:65
void alloc_analysis_curves(int pid, atomes_analysis *this_analysis)
allocating analysis curve data
Definition initc.c:134
void update_skt_view(project *this_proj)
update the text view for s(k,t) and s(q,w) calculation
Definition sktcall.c:248
void update_dynamic_view(project *this_proj, GtkTextBuffer *calc_buffer)
print molecular dynamics information
Definition msdcall.c:124