atomes 1.3.1
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
msdcall.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: 'msdcall.c'
24*
25* Contains:
26*
27
28 - The callbacks for the MSD calculation dialog
29
30*
31* List of functions:
32
33 void init_msd (project * this_proj);
34 void update_dynamic_view (project * this_proj, GtkTextBuffer * calc_buffer);
35 void update_msd_view (project * this_proj);
36
37 G_MODULE_EXPORT void on_calc_msd_released (GtkWidget * widg, gpointer data);
38
39*/
40
41#include <gtk/gtk.h>
42#include <string.h>
43#include <stdlib.h>
44
45#include "global.h"
46#include "bind.h"
47#include "interface.h"
48#include "callbacks.h"
49#include "curve.h"
50#include "project.h"
51
59void init_msd (project * this_proj)
60{
61 int i, j;
62 j = 0;
63 for ( i = 0 ; i < this_proj -> nspec ; i++ )
64 {
65 this_proj -> analysis[MSD] -> curves[j] -> name = g_strdup_printf ("%s[%s]", _("MSD"), active_chem -> label[i]);
66 j=j+1;
67 this_proj -> analysis[MSD] -> curves[j] -> name = g_strdup_printf ("%s(%s)[%s]", _("MSD"), _("nac"), active_chem -> label[i]);
68 j=j+1;
69 }
70 for ( i = 0 ; i < this_proj -> nspec ; i++ )
71 {
72 this_proj -> analysis[MSD] -> curves[j] -> name = g_strdup_printf ("%s(x)[%s]", _("MSD"), active_chem -> label[i]);
73 j=j+1;
74 this_proj -> analysis[MSD] -> curves[j] -> name = g_strdup_printf ("%s(y)[%s]", _("MSD"), active_chem -> label[i]);
75 j=j+1;
76 this_proj -> analysis[MSD] -> curves[j] -> name = g_strdup_printf ("%s(z)[%s]", _("MSD"), active_chem -> label[i]);
77 j=j+1;
78 this_proj -> analysis[MSD] -> curves[j] -> name = g_strdup_printf ("%s(xy)[%s]", _("MSD"), active_chem -> label[i]);
79 j=j+1;
80 this_proj -> analysis[MSD] -> curves[j] -> name = g_strdup_printf ("%s(xz)[%s]", _("MSD"), active_chem -> label[i]);
81 j=j+1;
82 this_proj -> analysis[MSD] -> curves[j] -> name = g_strdup_printf ("%s(yz)[%s]", _("MSD"), active_chem -> label[i]);
83 j=j+1;
84 }
85 for ( i = 0 ; i < this_proj -> nspec ; i++ )
86 {
87 this_proj -> analysis[MSD] -> curves[j] -> name = g_strdup_printf ("%s(x/%s)[%s]", _("MSD"), _("nac"), active_chem -> label[i]);
88 j=j+1;
89 this_proj -> analysis[MSD] -> curves[j] -> name = g_strdup_printf ("%s(y/%s)[%s]", _("MSD"), _("nac"), active_chem -> label[i]);
90 j=j+1;
91 this_proj -> analysis[MSD] -> curves[j] -> name = g_strdup_printf ("%s(z/%s)[%s]", _("MSD"), _("nac"), active_chem -> label[i]);
92 j=j+1;
93 this_proj -> analysis[MSD] -> curves[j] -> name = g_strdup_printf ("%s(xy/%s)[%s]", _("MSD"), _("nac"), active_chem -> label[i]);
94 j=j+1;
95 this_proj -> analysis[MSD] -> curves[j] -> name = g_strdup_printf ("%s(xz/%s)[%s]", _("MSD"), _("nac"), active_chem -> label[i]);
96 j=j+1;
97 this_proj -> analysis[MSD] -> curves[j] -> name = g_strdup_printf ("%s(yz/%s)[%s]", _("MSD"), _("nac"), active_chem -> label[i]);
98 j=j+1;
99 }
100 this_proj -> analysis[MSD] -> curves[j] -> name = g_strdup_printf ("%s[x]", _("Correction"));
101 j=j+1;
102 this_proj -> analysis[MSD] -> curves[j] -> name = g_strdup_printf ("%s[y]", _("Correction"));
103 j=j+1;
104 this_proj -> analysis[MSD] -> curves[j] -> name = g_strdup_printf ("%s[z]", _("Correction"));
105 j=j+1;
106 this_proj -> analysis[MSD] -> curves[j] -> name = g_strdup_printf ("%s[x]", _("Drift"));
107 j=j+1;
108 this_proj -> analysis[MSD] -> curves[j] -> name = g_strdup_printf ("%s[y]", _("Drift"));
109 j=j+1;
110 this_proj -> analysis[MSD] -> curves[j] -> name = g_strdup_printf ("%s[z]", _("Drift"));
111
112 add_curve_widgets (this_proj, MSD);
113 this_proj -> analysis[MSD] -> init_ok = TRUE;
114}
115
124void update_dynamic_view (project * this_proj, GtkTextBuffer * calc_buffer)
125{
126 gchar * str;
127 print_info (_("\t - Number of configurations: "), "bold", calc_buffer);
128 str = g_strdup_printf ("%d", this_proj -> steps);
129 print_info (str, "bold_blue", calc_buffer);
130 g_free (str);
131 print_info (_("\n\n\t - Number of time steps between each configuration: "), "bold", calc_buffer);
132 str = g_strdup_printf ("%d", this_proj -> analysis[MSD] -> num_delta);
133 print_info (str, "bold_blue", calc_buffer);
134 g_free (str);
135 print_info (_("\n\n\t - Time step δt used to integrate Newton's equations of motion: "), "bold", calc_buffer);
136 str = g_strdup_printf ("%f", this_proj -> analysis[MSD] -> delta);
137 print_info (str, "bold_blue", calc_buffer);
138 g_free (str);
139 print_info (" ", "bold", calc_buffer);
140 print_info (untime[this_proj -> tunit], "bold_red", calc_buffer);
141}
142
149void update_msd_view (project * this_proj)
150{
151 if (this_proj -> analysis[MSD] -> calc_buffer == NULL) this_proj -> analysis[MSD] -> calc_buffer = add_buffer (NULL, NULL, NULL);
152 view_buffer (this_proj -> analysis[MSD] -> calc_buffer);
153 print_info (_("\n\nMean Square Displacement\n\n"), "heading", this_proj -> analysis[MSD] -> calc_buffer);
154 print_info (_("Calculation details:\n\n"), NULL, this_proj -> analysis[MSD] -> calc_buffer);
155 update_dynamic_view (this_proj, this_proj -> analysis[MSD] -> calc_buffer);
156 print_info ("\n", NULL, this_proj -> analysis[MSD] -> calc_buffer);
157 print_info (calculation_time(TRUE, this_proj -> analysis[MSD] -> calc_time), NULL, this_proj -> analysis[MSD] -> calc_buffer);
158}
159
168G_MODULE_EXPORT void on_calc_msd_released (GtkWidget * widg, gpointer data)
169{
170 int i;
171 if (! active_project -> analysis[MSD] -> init_ok) init_msd (active_project);
172 clean_curves_data (MSD, 0, active_project -> analysis[MSD] -> numc);
173 prepostcalc (widg, FALSE, MSD, 0, opac);
174 active_project -> analysis[MSD] -> min = active_project -> analysis[MSD] -> delta*active_project -> analysis[MSD] -> num_delta;
175 active_project -> analysis[MSD] -> max = (active_project -> steps - 1)*active_project -> analysis[MSD] -> delta*active_project -> analysis[MSD] -> num_delta;
176 i = msd_ (& active_project -> analysis[MSD] -> delta, & active_project -> analysis[MSD] -> num_delta);
177 prepostcalc (widg, TRUE, MSD, i, 1.0);
178 if (! i)
179 {
180 show_error (_("The MSD calculation has failed"), 0, widg);
181 }
182 else
183 {
186 }
188}
Binding to the Fortran90 subroutines.
int msd_(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
char * untime[5]
Definition global.c:153
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...
GtkTextBuffer * add_buffer(GCallback handler, gpointer data, gchar *text)
create a GtkTextBuffer
Definition gtk-misc.c:1258
chemical_data * active_chem
Definition project.c:48
#define min(a, b)
Definition global.h:93
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 view_buffer(GtkTextBuffer *buffer)
set a text buffer in the main window or an image
Definition gui.c:311
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.
G_MODULE_EXPORT void on_calc_msd_released(GtkWidget *widg, gpointer data)
compute MSD
Definition msdcall.c:168
void init_msd(project *this_proj)
initialize the curve widgets for the MSD
Definition msdcall.c:59
void update_msd_view(project *this_proj)
update the project text view for the MSD calculation
Definition msdcall.c:149
void update_dynamic_view(project *this_proj, GtkTextBuffer *calc_buffer)
print molecular dynamics information
Definition msdcall.c:124
Function declarations for reading atomes project file Function declarations for saving atomes proje...