atomes 1.1.14
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-2024 by CNRS and University of Strasbourg */
15
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 initmsd ();
34 void update_msd_view (project * this_proj);
35
36 G_MODULE_EXPORT void on_calc_msd_released (GtkWidget * widg, gpointer data);
37
38*/
39
40#include <gtk/gtk.h>
41#include <string.h>
42#include <stdlib.h>
43
44#include "global.h"
45#include "bind.h"
46#include "interface.h"
47#include "callbacks.h"
48#include "curve.h"
49#include "project.h"
50
56void initmsd ()
57{
58 int i, j;
59
60 j = 0;
61 for ( i = 0 ; i < active_project -> nspec ; i++ )
62 {
63 active_project -> curves[MS][j] -> name = g_strdup_printf ("MSD[%s]", active_chem -> label[i]);
64 j=j+1;
65 active_project -> curves[MS][j] -> name = g_strdup_printf ("MSD(nac)[%s]", active_chem -> label[i]);
66 j=j+1;
67 }
68 for ( i = 0 ; i < active_project -> nspec ; i++ )
69 {
70 active_project -> curves[MS][j] -> name = g_strdup_printf ("MSD(x)[%s]", active_chem -> label[i]);
71 j=j+1;
72 active_project -> curves[MS][j] -> name = g_strdup_printf ("MSD(y)[%s]", active_chem -> label[i]);
73 j=j+1;
74 active_project -> curves[MS][j] -> name = g_strdup_printf ("MSD(z)[%s]", active_chem -> label[i]);
75 j=j+1;
76 active_project -> curves[MS][j] -> name = g_strdup_printf ("MSD(xy)[%s]", active_chem -> label[i]);
77 j=j+1;
78 active_project -> curves[MS][j] -> name = g_strdup_printf ("MSD(xz)[%s]", active_chem -> label[i]);
79 j=j+1;
80 active_project -> curves[MS][j] -> name = g_strdup_printf ("MSD(yz)[%s]", active_chem -> label[i]);
81 j=j+1;
82 }
83 for ( i = 0 ; i < active_project -> nspec ; i++ )
84 {
85 active_project -> curves[MS][j] -> name = g_strdup_printf ("MSD(x/nac)[%s]", active_chem -> label[i]);
86 j=j+1;
87 active_project -> curves[MS][j] -> name = g_strdup_printf ("MSD(y/nac)[%s]", active_chem -> label[i]);
88 j=j+1;
89 active_project -> curves[MS][j] -> name = g_strdup_printf ("MSD(z/nac)[%s]", active_chem -> label[i]);
90 j=j+1;
91 active_project -> curves[MS][j] -> name = g_strdup_printf ("MSD(xy/nac)[%s]", active_chem -> label[i]);
92 j=j+1;
93 active_project -> curves[MS][j] -> name = g_strdup_printf ("MSD(xz/nac)[%s]", active_chem -> label[i]);
94 j=j+1;
95 active_project -> curves[MS][j] -> name = g_strdup_printf ("MSD(yz/nac)[%s]", active_chem -> label[i]);
96 j=j+1;
97 }
98 active_project -> curves[MS][j] -> name = g_strdup_printf ("Correction[x]");
99 j=j+1;
100 active_project -> curves[MS][j] -> name = g_strdup_printf ("Correction[y]");
101 j=j+1;
102 active_project -> curves[MS][j] -> name = g_strdup_printf ("Correction[z]");
103 j=j+1;
104 active_project -> curves[MS][j] -> name = g_strdup_printf ("Drift[x]");
105 j=j+1;
106 active_project -> curves[MS][j] -> name = g_strdup_printf ("Drift[y]");
107 j=j+1;
108 active_project -> curves[MS][j] -> name = g_strdup_printf ("Drift[z]");
109
111 active_project -> initok[MS]=TRUE;
112}
113
121void update_msd_view (project * this_proj)
122{
123 gchar * str;
124 if (this_proj -> text_buffer[MS+OT] == NULL) this_proj -> text_buffer[MS+OT] = add_buffer (NULL, NULL, NULL);
125 view_buffer (this_proj -> text_buffer[MS+OT]);
126 print_info ("\n\nMean Square Displacement\n\n", "heading", this_proj -> text_buffer[MS+OT]);
127 print_info ("Calculation details:\n\n", NULL, this_proj -> text_buffer[MS+OT]);
128 print_info ("\t - Number of configurations: ", "bold", this_proj -> text_buffer[MS+OT]);
129 str = g_strdup_printf ("%d", this_proj -> steps);
130 print_info (str, "bold_blue", this_proj -> text_buffer[MS+OT]);
131 g_free (str);
132 print_info ("\n\n\t - Number of time steps between each configuration: ", "bold", this_proj -> text_buffer[MS+OT]);
133 str = g_strdup_printf ("%d", this_proj -> num_delta[MS]);
134 print_info (str, "bold_blue", this_proj -> text_buffer[MS+OT]);
135 g_free (str);
136 print_info ("\n\n\t - Time step δt used to integrate Newton's equations of motion: ", "bold", this_proj -> text_buffer[MS+OT]);
137 str = g_strdup_printf ("%f", this_proj -> delta[MS]);
138 print_info (str, "bold_blue", this_proj -> text_buffer[MS+OT]);
139 g_free (str);
140 print_info (" ", "bold", this_proj -> text_buffer[MS+OT]);
141 print_info (untime[this_proj -> tunit], "bold_red", this_proj -> text_buffer[MS+OT]);
142 print_info (calculation_time(TRUE, this_proj -> calc_time[MS]), NULL, this_proj -> text_buffer[MS+OT]);
143}
144
153G_MODULE_EXPORT void on_calc_msd_released (GtkWidget * widg, gpointer data)
154{
155 int i;
156
157 if (! active_project -> initok[MS]) initmsd ();
158 clean_curves_data (MS, 0, active_project -> numc[MS]);
159 prepostcalc (widg, FALSE, MS, 0, opac);
160 active_project -> min[MS] = active_project -> delta[MS]*active_project -> num_delta[MS];
161 active_project -> max[MS] = (active_project -> steps -1)*active_project -> delta[MS]*active_project -> num_delta[MS];
162 clock_gettime (CLOCK_MONOTONIC, & start_time);
163 i = msd_ (& active_project -> delta[MS], & active_project -> num_delta[MS]);
164 clock_gettime (CLOCK_MONOTONIC, & stop_time);
166 prepostcalc (widg, TRUE, MS, i, 1.0);
167 if (! i)
168 {
169 show_error ("The MSD calculation has failed", 0, widg);
170 }
171 else
172 {
174 gtk_widget_show (curvetoolbox);
175 }
177}
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:87
Variable declarations for the curve widget Functions for interactions with the curve widget.
void label(cairo_t *cr, double val, int axe, int p, project *this_proj)
draw axis label
Definition labels.c:56
void addcurwidgets(int pid, int rid, int st)
add curve widgets to the project
Definition cwidget.c:259
void clean_curves_data(int calc, int start, int end)
clean curve data on a range of curve id
Definition initc.c:55
char * untime[6]
Definition global.c:149
struct timespec start_time
Definition global.c:191
int activep
Definition global.c:159
gchar * calculation_time(gboolean modelv, double ctime)
get calculation time, human readable
Definition global.c:649
double opac
Definition global.c:194
double get_calc_time(struct timespec start, struct timespec stop)
get calculation time in s
Definition global.c:636
struct timespec stop_time
Definition global.c:192
GtkWidget * curvetoolbox
Definition global.c:218
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:1151
chemical_data * active_chem
Definition project.c:48
#define OT
Definition global.h:293
#define MS
Definition global.h:303
#define min(a, b)
Definition global.h:75
project * active_project
Definition project.c:47
#define max(a, b)
Definition global.h:74
void view_buffer(GtkTextBuffer *buffer)
set a text buffer in the main window or an image
Definition gui.c:182
void prepostcalc(GtkWidget *widg, gboolean status, int run, int adv, double opc)
to just before and just after running a calculation
Definition initc.c:154
void show_error(char *error, int val, GtkWidget *win)
show error message
Definition interface.c:293
void print_info(gchar *str, gchar *stag, GtkTextBuffer *buffer)
print information in GtkTextBuffer
Definition interface.c:738
Messaging function declarations.
G_MODULE_EXPORT void on_calc_msd_released(GtkWidget *widg, gpointer data)
compute MSD
Definition msdcall.c:153
void initmsd()
initialize the curve widgets for the MSD
Definition msdcall.c:56
void update_msd_view(project *this_proj)
update the project text view for the MSD calculation
Definition msdcall.c:121
Function declarations for reading atomes project file Function declarations for saving atomes proje...