atomes 1.1.15
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
spcall.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: 'spcall.c'
24*
25* Contains:
26*
27
28 - The callbacks for the spherical harmonics calculation dialog
29
30*
31* List of functions:
32
33 void initsh (int str);
34 void update_spherical_view (project * this_proj);
35
36 G_MODULE_EXPORT void on_calc_sph_released (GtkWidget * widg, gpointer data);
37
38*/
39
40#include "global.h"
41#include "bind.h"
42#include "interface.h"
43#include "callbacks.h"
44#include "project.h"
45#include "curve.h"
46
47extern void alloc_curves (int c);
48extern gboolean run_distance_matrix (GtkWidget * widg, int calc, int up_ngb);
49
57void initsh (int str)
58{
59 int i, j, k;
60 if (str)
61 {
62 active_project -> numwid -= active_project -> numc[SP];
63 active_project -> numc[SP] = active_project -> nspec;
64 for (i=0; i<active_project -> nspec; i++)
65 {
66 active_project -> numc[SP] += active_coord -> ntg[1][i];
67 }
69 active_project -> numwid += active_project -> numc[SP];
70 j = 0;
71 for (i = 0 ; i < active_project -> nspec ; i++)
72 {
73 active_project -> curves[SP][i+j] -> name = g_strdup_printf("Q(l) [%s] (l=0 -> %d)",
74 active_chem -> label[i],
75 active_project -> num_delta[SP]);
76 j += active_coord -> ntg[1][i];
77 }
78 k = 1;
79 for (i=0 ; i < active_project -> nspec; i++)
80 {
81 for (j=0 ; j < active_coord -> ntg[1][i]; j++)
82 {
83 active_project -> curves[SP][j+k] -> name = g_strdup_printf("Q(l) %s (l=0 -> %d)",
84 exact_name(env_name (active_project, j, i, 0, NULL)),
85 active_project -> num_delta[SP]);
86 }
87 k += active_coord -> ntg[1][i]+1;
88 }
90 active_project -> initok[SP] = TRUE;
91 }
92}
93
102{
103 int i, j, k, l, m;
104 gchar * str;
105 gchar * tab;
106 gchar * cid;
107
108 if (this_proj -> text_buffer[SP+OT] == NULL) this_proj -> text_buffer[SP+OT] = add_buffer (NULL, NULL, NULL);
109 view_buffer (this_proj -> text_buffer[SP+OT]);
110
111 print_info ("\n\nSpherical harmonics\n\n", "heading", this_proj -> text_buffer[SP+OT]);
112 m = 0;
113 for (i=0; i<this_proj -> nspec; i++)
114 {
115 print_info ("\nResults for the ", NULL, this_proj -> text_buffer[SP+OT]);
116 print_info (exact_name(active_chem -> label[i]), textcolor(i), this_proj -> text_buffer[SP+OT]);
117 print_info (" atoms: \n\n", NULL, this_proj -> text_buffer[SP+OT]);
118 // Here print average spec info
119
120 print_info ("\tl\t", "bold_italic", this_proj -> text_buffer[SP+OT]);
121 print_info ("Q(","bold", this_proj -> text_buffer[SP+OT]);
122 print_info ("l", "bold_italic", this_proj -> text_buffer[SP+OT]);
123 print_info (")","bold", this_proj -> text_buffer[SP+OT]);
124 print_info (active_chem -> label[i], textcolor(i), this_proj -> text_buffer[SP+OT]);
125 print_info ("[All]", "bold", this_proj -> text_buffer[SP+OT]);
126 for (j=0 ; j < active_coord -> ntg[1][i]; j++)
127 {
128 print_info ("\tQ(","bold", this_proj -> text_buffer[SP+OT]);
129 print_info ("l", "bold_italic", this_proj -> text_buffer[SP+OT]);
130 print_info (")","bold", this_proj -> text_buffer[SP+OT]);
131 env_name (this_proj, j, i, 1, this_proj -> text_buffer[SP+OT]);
132 }
133 print_info ("\n", NULL, this_proj -> text_buffer[SP+OT]);
134 k = 1;
135 tab = NULL;
136 cid = NULL;
137 for (j=0; j<this_proj -> num_delta[SP]/2+1 ; j++)
138 {
139 k ++;
140 if (k - 2*(k/2) == 0)
141 {
142 tab = g_strdup_printf ("grey_back");
143 cid = g_strdup_printf ("bold_grey_back");
144 }
145 else
146 {
147 tab = NULL;
148 cid = g_strdup_printf ("bold");
149 }
150 print_info ("\t", NULL, this_proj -> text_buffer[SP+OT]);
151 if (j < 5)
152 {
153 print_info (" ",cid, this_proj -> text_buffer[SP+OT]);
154 }
155 str = g_strdup_printf("%d", 2*j);
156 print_info (str, cid, this_proj -> text_buffer[SP+OT]);
157 g_free (str);
158 for (l=0; l<active_coord -> ntg[1][i]+1; l++)
159 {
160 str = g_strdup_printf("\t%f", this_proj -> curves[SP][l+m] -> data[1][j]);
161 print_info (str, tab, this_proj -> text_buffer[SP+OT]);
162 g_free (str);
163 }
164 print_info ("\n", NULL, this_proj -> text_buffer[SP+OT]);
165 if (tab != NULL)
166 {
167 g_free (tab);
168 }
169 if (cid != NULL)
170 {
171 g_free (cid);
172 }
173 }
174 m += active_coord -> ntg[1][i]+1;
175 }
176
177 print_info (calculation_time(TRUE, this_proj -> calc_time[SP]), NULL, this_proj -> text_buffer[SP+OT]);
178}
179
188G_MODULE_EXPORT void on_calc_sph_released (GtkWidget * widg, gpointer data)
189{
190 int i, j, k, l, m;
191
192 if (! active_project -> initok[SP]) initsh(1);
193 if (! active_project -> dmtx) active_project -> dmtx = run_distance_matrix (widg, 0, 0);
194
195 if (active_project -> dmtx)
196 {
197 clean_curves_data (SP, 0, active_project -> numc[SP]);
198 prepostcalc (widg, FALSE, SP, 0, opac);
199 k = 0;
200 l = active_project -> nspec;
201 m = active_project -> num_delta[SP];
202 clock_gettime (CLOCK_MONOTONIC, & start_time);
203 for (i=0; i<active_project -> nspec; i++)
204 {
205 for (j=0; j< active_coord -> ntg[1][i]; j++)
206 {
207 if (j==0) k ++;
208 l += sphericals_ (& m, & i, & j, & k, active_coord -> partial_geo[i][j]);
209 k ++;
210 }
211 }
212 clock_gettime (CLOCK_MONOTONIC, & stop_time);
214 if (l != active_project -> numc[SP])
215 {
216 i = 0;
217 }
218 else
219 {
220 i = 1;
221 }
222 prepostcalc (widg, TRUE, SP, i, 1.0);
223 if (! i)
224 {
225 show_error ("Unexpected error when analyzing the spherical harmonics", 0, widg);
226 }
227 else
228 {
231 }
232 }
233 else
234 {
235 show_error ("The nearest neighbors table calculation has failed", 0, widg);
236 }
238}
Binding to the Fortran90 subroutines.
int sphericals_(int *, int *, int *, int *, 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
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:656
double opac
Definition global.c:194
double get_calc_time(struct timespec start, struct timespec stop)
get calculation time in s
Definition global.c:643
struct timespec stop_time
Definition global.c:192
GtkWidget * curvetoolbox
Definition global.c:205
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:1171
coord_info * active_coord
Definition project.c:49
chemical_data * active_chem
Definition project.c:48
#define OT
Definition global.h:321
#define SP
Definition global.h:330
project * active_project
Definition project.c:47
void show_the_widgets(GtkWidget *widg)
show GtkWidget
Definition gtk-misc.c:173
void view_buffer(GtkTextBuffer *buffer)
set a text buffer in the main window or an image
Definition gui.c:309
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
gchar * textcolor(int i)
setup text color keyword
Definition interface.c:763
void show_error(char *error, int val, GtkWidget *win)
show error message
Definition interface.c:293
gchar * env_name(project *this_proj, int g, int s, int f, GtkTextBuffer *buffer)
ouput the name of a coordination sphere
Definition interface.c:889
void print_info(gchar *str, gchar *stag, GtkTextBuffer *buffer)
print information in GtkTextBuffer
Definition interface.c:738
gchar * exact_name(gchar *name)
short cut to print string without spaces
Definition interface.c:370
Messaging function declarations.
Function declarations for reading atomes project file Function declarations for saving atomes proje...
G_MODULE_EXPORT void on_calc_sph_released(GtkWidget *widg, gpointer data)
compute spherical harmonics
Definition spcall.c:188
gboolean run_distance_matrix(GtkWidget *widg, int calc, int up_ngb)
compute distance matrix
Definition bdcall.c:310
void initsh(int str)
initialize the curve widgets for the spherical harmonics
Definition spcall.c:57
void alloc_curves(int c)
allocating curve data
Definition initc.c:74
void update_spherical_view(project *this_proj)
update the text view for spherical harmonics
Definition spcall.c:101
int c
Definition tab-1.c:95