atomes 1.3.1
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
initc.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: 'initc.c'
24*
25* Contains:
26*
27
28 - Curve data buffer initialization
29
30*
31* List of functions:
32
33 void clean_curves_data (int calc, int start, int end);
34 void alloc_curves (int rid);
35 void initcwidgets ();
36 void prepostcalc (GtkWidget * widg, gboolean status, int run, int adv, double opc);
37 void alloc_analysis_curves (int pid, atomes_analysis * this_analysis);
38 void init_atomes_analysis (project * this_proj, gboolean apply_defaults);
39 void initialize_this_analysis (project * this_proj, int ana);
40
41 atomes_analysis * setup_analysis (gchar * name, int analysis, gboolean req_md, gboolean graph, int num_curves, int n_compat, int * compat, gchar * x_title);
42
43*/
44
45#include "global.h"
46#include "callbacks.h"
47#include "project.h"
48
49extern void clean_this_curve_window (int cid, int rid);
51
61void clean_curves_data (int calc, int start, int end)
62{
63 int i;
64 if (active_project -> analysis[calc])
65 {
66 if (active_project -> analysis[calc] -> curves)
67 {
68 for (i=start; i<end; i++)
69 {
71 }
72 }
73 }
74}
75
87void prepostcalc (GtkWidget * widg, gboolean status, int run, int adv, double opc)
88{
89 if (run < NCALCS && run > -1) active_project -> analysis[run] -> calc_ok = adv;
90 if (! status)
91 {
92 clock_gettime (CLOCK_MONOTONIC, & start_time);
93#ifdef GTK3
94 if (widg != NULL) gdk_window_set_opacity (gtk_widget_get_window(widg), opc);
95#endif
96/* if (adv)
97 {
98 // bar[run]
99 mess = g_strdup_printf (_("Please wait calculation in progress"));
100 pop = show_popup (mess, widg);
101 g_free (mess);
102 mess = g_strdup_printf (_("Computing"));
103 //statusval = gtk_statusbar_push (statusbar, run, mess);
104 g_free (mess);
105 show_the_widgets (pop);
106 }*/
107 }
108 else
109 {
110 if (adv && run > -1)
111 {
112 //gtk_statusbar_remove (statusbar, run, statusval);
113 //destroy_this_widget(pop);
114 }
115 if (run > -1)
116 {
117 clock_gettime (CLOCK_MONOTONIC, & stop_time);
118 active_project -> analysis[run] -> calc_time = get_calc_time (start_time, stop_time);
119 }
120#ifdef GTK3
121 if (widg != NULL) gdk_window_set_opacity (gtk_widget_get_window(widg), opc);
122#endif
123 }
124}
125
134void alloc_analysis_curves (int pid, atomes_analysis * this_analysis)
135{
136 int i;
137 if (this_analysis -> idcc != NULL)
138 {
139 g_free (this_analysis -> idcc);
140 this_analysis -> idcc = NULL;
141 }
142 this_analysis -> idcc = g_malloc0(this_analysis -> numc*sizeof*this_analysis -> idcc);
143 for (i = 0; i < this_analysis -> numc; i++)
144 {
145 this_analysis -> idcc[i].a = pid;
146 this_analysis -> idcc[i].b = this_analysis -> aid;
147 this_analysis -> idcc[i].c = i;
148 }
149 if (this_analysis -> curves != NULL)
150 {
151 g_free (this_analysis -> curves);
152 this_analysis -> curves = NULL;
153 }
154 this_analysis -> curves = g_malloc0(this_analysis -> numc*sizeof*this_analysis -> curves);
155 for (i = 0; i < this_analysis -> numc; i++)
156 {
157 this_analysis -> curves[i] = g_malloc0(sizeof*this_analysis -> curves[i]);
158 }
159}
160
176atomes_analysis * setup_analysis (int pid, gchar * name, int analysis, gboolean req_md, gboolean graph, int num_curves, int n_compat, int * compat, gchar * x_title)
177{
178 atomes_analysis * new_analysis = g_malloc0(sizeof*new_analysis);
179 new_analysis -> name = g_strdup_printf ("%s", name);
180 new_analysis -> aid = analysis;
181 new_analysis -> requires_md = req_md;
182 new_analysis -> graph_res = graph;
183 if (graph)
184 {
185 new_analysis -> c_sets = n_compat;
186 new_analysis -> compat_id = duplicate_int (n_compat, compat);
187 if (num_curves)
188 {
189 new_analysis -> numc = num_curves;
190 alloc_analysis_curves (pid, new_analysis);
191 }
192 if (x_title) new_analysis -> x_title = g_strdup_printf ("%s", x_title);
193 }
194 return new_analysis;
195}
196
197/*
198 From global.h:
199
200 #define NCALCS 11 -> but 10
201
202 #define GDR 0
203 #define SQD 1
204 #define SKD 2
205 #define GDK 3
206 #define BND 4
207 #define ANG 5
208 #define RIN 6
209 #define CHA 7
210 #define SPH 8
211 #define MSD 9
212 #define SKT 10
213*/
214
223void init_atomes_analysis (project * this_proj, gboolean apply_defaults)
224{
225 int i = this_proj -> nspec;
226 int pid = this_proj -> id;
227 /* Compatible analysis:
228 - always include self first, and others if required
229 - x axis must be similar or allow comparison (ex: distance)
230 */
231 int * comp_list;
232 this_proj -> analysis = g_malloc0(NCALCS*sizeof*this_proj -> analysis);
233 // g(r)
234 comp_list = allocint (2);
235 comp_list[0] = GDR;
236 comp_list[1] = GDK;
237 this_proj -> analysis[GDR] = setup_analysis (pid, "g(r)/G(r)", GDR, FALSE, TRUE, 16+5*i*i + ((i ==2) ? 6 : 0), 2, comp_list, "r [Å]");
238 // g(r) FFT - same compatibility list
239 this_proj -> analysis[GDK] = setup_analysis (pid, _("g(r)/G(r) from FFT[S(q)]"), GDK, FALSE, TRUE, 16+5*i*i + ((i ==2) ? 6 : 0), 2, comp_list, "r [Å]");
240
241 // s(q)
242 comp_list[0] = SQD;
243 comp_list[1] = SKD;
244 this_proj -> analysis[SQD] = setup_analysis (pid, _("S(q) from FFT[g(r)]"), SQD, FALSE, TRUE, 8+4*i*i + ((i ==2) ? 8 : 0), 2, comp_list, "q [Å<sup>-1</sup>]");
245 // s(k) - same compatibility list
246 this_proj -> analysis[SKD] = setup_analysis (pid, _("S(q) from Debye Equation"), SKD, FALSE, TRUE, 8+4*i*i + ((i ==2) ? 8 : 0), 2, comp_list, "q [Å<sup>-1</sup>]");
247
248 g_free (comp_list);
249
250 comp_list = allocint (1);
251 // Bond length distribution(s)
252 comp_list[0] = BND;
253 this_proj -> analysis[BND] = setup_analysis (pid, _("Bond Properties"), BND, FALSE, TRUE, i*i, 1, comp_list, "D<sub>ij</sub> [Å]");
254
255 // Angle distribution(s)
256 comp_list[0] = ANG;
257 this_proj -> analysis[ANG] = setup_analysis (pid, _("Angle Distributions"), ANG, FALSE, TRUE, i*i*i + i*i*i*i, 1, comp_list, "θ [°]");
258
259 // Ring statistic(s)
260 comp_list[0] = RIN;
261 this_proj -> analysis[RIN] = setup_analysis (pid, _("Ring Statistics"), RIN, FALSE, TRUE, 20*(i+1), 1, comp_list, _("Size <i>n</i> of the ring [total number of nodes]"));
262
263 // Chain statistic(s)
264 comp_list[0] = CHA;
265 this_proj -> analysis[CHA] = setup_analysis (pid, _("Chain Statistics"), CHA, FALSE, TRUE, i+1, 1, comp_list, _("Size <i>n</i> of the chain [total number of nodes]"));
266
267 // Spherical harmonic(s)
268 comp_list[0] = SPH;
269 this_proj -> analysis[SPH] = setup_analysis (pid, _("Spherical Harmonics"), SPH, FALSE, TRUE, 0, 1, comp_list, "Q<sub>l</sub>");
270
271 if (this_proj -> steps > 1)
272 {
273 // Mean square displacement
274 comp_list[0] = MSD;
275 this_proj -> analysis[MSD] = setup_analysis (pid, _("Mean Squared Displacement"), MSD, TRUE, TRUE, 14*i+6, 1, comp_list, NULL);
276
277 // Dynamic structure factor
278 // Number of graphs depends on the number of correlation states, not appearing here
279 comp_list[0] = SKT;
280 // this_proj -> analysis[SKT] = setup_analysis (pid, _("Dynamic Structure Factor"), SKT, TRUE, TRUE, 0, 1, comp_list, NULL);
281 }
282
283 g_free (comp_list);
284
285 if (apply_defaults) apply_analysis_default_parameters_to_project (this_proj);
286}
287
296void initialize_this_analysis (project * this_proj, int ana)
297{
298 int i = this_proj -> nspec;
299 int * comp_list;
300 if (! this_proj -> analysis)
301 {
302 this_proj -> analysis = g_malloc0(NCALCS*sizeof*this_proj -> analysis);
303 }
304 switch (ana)
305 {
306 case GDR:
307 // g(r)
308 comp_list = allocint (2);
309 comp_list[0] = GDR;
310 comp_list[1] = GDK;
311 this_proj -> analysis[GDR] = setup_analysis (this_proj -> id, "g(r)/G(r)", GDR, FALSE, TRUE, 16+5*i*i + ((i ==2) ? 6 : 0), 2, comp_list, "r [Å]");
312 break;
313 case SQD:
314 // S(q)
315 comp_list = allocint (2);
316 comp_list[0] = SQD;
317 comp_list[1] = SKD;
318 this_proj -> analysis[SQD] = setup_analysis (this_proj -> id, _("S(q) from FFT[g(r)]"), SQD, FALSE, TRUE, 8+4*i*i + ((i ==2) ? 8 : 0), 2, comp_list, "q [Å<sup>-1</sup>]");
319 break;
320 case SKD:
321 // S(k)
322 comp_list = allocint (2);
323 comp_list[0] = SQD;
324 comp_list[1] = SKD;
325 this_proj -> analysis[SKD] = setup_analysis (this_proj -> id, _("S(q) from Debye Equation"), SKD, FALSE, TRUE, 8+4*i*i + ((i ==2) ? 8 : 0), 2, comp_list, "q [Å<sup>-1</sup>]");
326 break;
327 case GDK:
328 // g(r) FFT S(q)
329 comp_list = allocint (2);
330 comp_list[0] = GDR;
331 comp_list[1] = GDK;
332 this_proj -> analysis[GDK] = setup_analysis (this_proj -> id, _("g(r)/G(r) from FFT[S(q)]"), GDK, FALSE, TRUE, 16+5*i*i + ((i ==2) ? 6 : 0), 2, comp_list, "r [Å]");
333 break;
334 case BND:
335 // Bond length distribution(s)
336 comp_list = allocint (1);
337 comp_list[0] = BND;
338 this_proj -> analysis[BND] = setup_analysis (this_proj -> id, _("Bond Properties"), BND, FALSE, TRUE, i*i, 1, comp_list, "D<sub>ij</sub> [Å]");
339 break;
340 case ANG:
341 // Angle distribution(s)
342 comp_list = allocint (1);
343 comp_list[0] = ANG;
344 this_proj -> analysis[ANG] = setup_analysis (this_proj -> id, _("Angle Distributions"), ANG, FALSE, TRUE, i*i*i + i*i*i*i, 1, comp_list, "θ [°]");
345 break;
346 case RIN:
347 // Ring statistics
348 comp_list = allocint (1);
349 comp_list[0] = RIN;
350 this_proj -> analysis[RIN] = setup_analysis (this_proj -> id, _("Ring Statistics"), RIN, FALSE, TRUE, 20*(i+1), 1, comp_list, _("Size <i>n</i> of the ring [total number of nodes]"));
351 break;
352 case CHA:
353 // Chain statistics
354 comp_list = allocint (1);
355 comp_list[0] = CHA;
356 this_proj -> analysis[CHA] = setup_analysis (this_proj -> id, _("Chain Statistics"), CHA, FALSE, TRUE, i+1, 1, comp_list, _("Size <i>n</i> of the chain [total number of nodes]"));
357 break;
358 case SPH:
359 // Spherical harmonics as order parameters
360 comp_list = allocint (1);
361 comp_list[0] = SPH;
362 this_proj -> analysis[SPH] = setup_analysis (this_proj -> id, _("Spherical Harmonics"), SPH, FALSE, TRUE, 0, 1, comp_list, "Q<sub>l</sub>");
363 break;
364 case MSD:
365 // Mean square displacement
366 comp_list = allocint (1);
367 comp_list[0] = MSD;
368 if (this_proj -> steps > 1) this_proj -> analysis[MSD] = setup_analysis (this_proj -> id, _("Mean Squared Displacement"), MSD, TRUE, TRUE, 14*i+6, 1, comp_list, NULL);
369 break;
370 case SKT:
371 comp_list = allocint (1);
372 comp_list[0] = SKT;
373 // Total number of graphs depends on the number of correlation states, not appearing here
374 // if (this_proj -> steps > 1) this_proj -> analysis[SKT] = setup_analysis (this_proj -> id, _("Dynamic Structure Factor"), SKT, TRUE, TRUE, 0, 2, comp_list, NULL);
375 break;
376 }
377 g_free (comp_list);
378}
Callback declarations for main window.
int * duplicate_int(int num, int *old_val)
copy a list of int
Definition global.c:547
struct timespec start_time
Definition global.c:198
int * allocint(int val)
allocate an int * pointer
Definition global.c:301
double get_calc_time(struct timespec start, struct timespec stop)
get calculation time in s
Definition global.c:630
struct timespec stop_time
Definition global.c:199
Global variable declarations Global convenience function declarations Global data structure defin...
#define SKT
Definition global.h:347
#define SQD
Definition global.h:338
#define RIN
Definition global.h:343
#define SPH
Definition global.h:345
#define ANG
Definition global.h:342
#define CHA
Definition global.h:344
#define SKD
Definition global.h:339
#define BND
Definition global.h:341
#define GDK
Definition global.h:340
project * active_project
Definition project.c:47
#define NCALCS
#define MSD
Definition global.h:346
#define GDR
Definition global.h:337
atomes_analysis * setup_analysis(int pid, gchar *name, int analysis, gboolean req_md, gboolean graph, int num_curves, int n_compat, int *compat, gchar *x_title)
allocate atomes_analysis data structure
Definition initc.c:176
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 init_atomes_analysis(project *this_proj, gboolean apply_defaults)
initialize analysis data structures for atomes
Definition initc.c:223
void initialize_this_analysis(project *this_proj, int ana)
initialize an analysis data structure for atomes
Definition initc.c:296
void apply_analysis_default_parameters_to_project(project *this_proj)
apply default analysis parameters to project
Definition init_p.c:94
void clean_curves_data(int calc, int start, int end)
clean curve data on a range of curve id
Definition initc.c:61
void alloc_analysis_curves(int pid, atomes_analysis *this_analysis)
allocating analysis curve data
Definition initc.c:134
void clean_this_curve_window(int cid, int rid)
free curve window data
Definition curve.c:348
Function declarations for reading atomes project file Function declarations for saving atomes proje...
int status
Definition w_advance.c:173