atomes 1.3.1
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
init_p.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: 'init_p.c'
24*
25* Contains:
26*
27
28 - The functions to initialize an atomes project
29
30*
31* List of functions:
32
33 void init_curves_and_calc (project * this_proj);
34 void apply_analysis_default_parameters_to_project (project * this_proj, gboolean with_analysis);
35 void apply_default_parameters_to_project (project * this_proj);
36 void init_project (gboolean alloc_box);
37
38*/
39
40#include "global.h"
41#include "bind.h"
42#include "callbacks.h"
43#include "interface.h"
44#include "preferences.h"
45#include "project.h"
46#include "curve.h"
47#include "glview.h"
48#include "glwindow.h"
49
50extern void init_camera (project * this_proj);
51extern void setup_default_image (project * this_proj, image * img);
52extern void clean_atom_style (project * this_proj);
54extern void init_shaders (glwin * view);
55extern G_MODULE_EXPORT void box_advanced (GtkWidget * widg, gpointer data);
56extern G_MODULE_EXPORT void axis_advanced (GtkWidget * widg, gpointer data);
57extern G_MODULE_EXPORT void representation_advanced (GtkWidget * widg, gpointer data);
58extern G_MODULE_EXPORT void opengl_advanced (GtkWidget * widg, gpointer data);
59extern void update_gradient_widgets (gradient_edition * gradient_win, background * back);
60extern G_MODULE_EXPORT void gradient_advanced (GtkWidget * widg, gpointer data);
61
69void init_curves_and_calc (project * this_proj)
70{
71 int i;
72 if (this_proj -> analysis)
73 {
74 for (i=0; i<NCALCS; i++)
75 {
76 if (this_proj -> analysis[i])
77 {
78 this_proj -> analysis[i] -> avail_ok = FALSE;
79 this_proj -> analysis[i] -> init_ok = FALSE;
80 this_proj -> analysis[i] -> calc_ok = FALSE;
81 }
82 }
83 }
84}
85
95{
96 int i, j;
97 for (i=0; i<6; i++)
98 {
99 if (this_proj -> analysis[i]) this_proj -> analysis[i] -> num_delta = default_num_delta[i];
100 }
101 if (this_proj -> analysis[RIN])
102 {
103 active_project -> analysis[RIN] -> delta = 1.0;
104 active_project -> analysis[RIN] -> min = 1.0;
105 }
106 if (this_proj -> analysis[CHA])
107 {
108 active_project -> analysis[CHA] -> delta = 1.0;
109 active_project -> analysis[CHA] -> min = 1.0;
110 }
111 if (this_proj -> analysis[SPH])
112 {
113 active_project -> analysis[SPH] -> delta = 2.0;
114 this_proj -> analysis[SPH] -> num_delta = default_num_delta[6];
115 }
116 if (this_proj -> analysis[MSD]) this_proj -> analysis[MSD] -> num_delta = default_num_delta[7];
117 if (this_proj -> analysis[MSD]) this_proj -> analysis[MSD] -> delta = default_delta_t[0];
118
119 // Other analysis parameters
120 for (i=0; i<5; i++)
121 {
122 this_proj -> rsparam[i][0] = default_rsparam[1];
123 this_proj -> rsparam[i][1] = default_rsparam[2];
124 for (j=2; j<5; j++) this_proj -> rsparam[i][j] = default_rsparam[j+2];
125 }
126 this_proj -> rsearch[0] = default_rsparam[0];
127 this_proj -> rsearch[1] = default_rsparam[3];
128 this_proj -> csparam[0] = default_csparam[0];
129 for (i=1; i<4; i++) this_proj -> csparam[i]= default_csparam[i+2];
130 this_proj -> csparam[5] = default_csparam[1];
131 this_proj -> csearch = default_csparam[2];
132 this_proj -> tunit = default_delta_t[1];
133 this_proj -> skt_all_sets = default_skt_sets;
134 this_proj -> skt_n_data_sets = default_skt_n_sets;
135 this_proj -> sqw_n_data_sets = default_sqw_n_sets;
136 this_proj -> sqw_freq = default_sqw_freq;
137}
138
146void apply_default_parameters_to_project (project * this_proj, gboolean with_analysis)
147{
148 int i, j, k, l;
149 if (with_analysis)
150 {
151 // Calc parameters
152 if (this_proj -> chemistry)
153 {
154 this_proj -> chemistry -> grtotcutoff = default_totcut;
156 gboolean cupdate = FALSE;
157 while (cut)
158 {
159 i = cut -> Z[0];
160 j = cut -> Z[1];
161 for (k=0; k<this_proj -> nspec; k++)
162 {
163 if ((int)this_proj -> chemistry -> chem_prop[CHEM_Z][k] == i)
164 {
165 cupdate = TRUE;
166 break;
167 }
168 }
169 if (cupdate)
170 {
171 cupdate = FALSE;
172 for (l=0; l<this_proj -> nspec; l++)
173 {
174 if ((int)this_proj -> chemistry -> chem_prop[CHEM_Z][l] == j)
175 {
176 cupdate = TRUE;
177 break;
178 }
179 }
180 }
181 if (cupdate)
182 {
183 this_proj -> chemistry -> cutoffs[k][l] = this_proj -> chemistry -> cutoffs[l][k] = cut -> cutoff;
184 }
185 cut = cut -> next;
186 }
187 if (this_proj -> analysis)
188 {
190 }
191 }
192 // Other analysis parameters
193
194 for (i=0; i<5; i++)
195 {
196 this_proj -> rsparam[i][0] = default_rsparam[1];
197 this_proj -> rsparam[i][1] = default_rsparam[2];
198 for (j=2; j<5; j++) this_proj -> rsparam[i][j] = default_rsparam[j+2];
199 }
200 this_proj -> rsearch[0] = default_rsparam[0];
201 this_proj -> rsearch[1] = default_rsparam[3];
202 this_proj -> csparam[0] = default_csparam[0];
203 for (i=1; i<4; i++) this_proj -> csparam[i]= default_csparam[i+2];
204 this_proj -> csparam[5] = default_csparam[1];
205 this_proj -> csearch = default_csparam[2];
206 this_proj -> tunit = default_delta_t[1];
207 this_proj -> skt_all_sets = default_skt_sets;
208 this_proj -> skt_n_data_sets = default_skt_n_sets;
209 this_proj -> sqw_n_data_sets = default_sqw_n_sets;
210 this_proj -> sqw_freq = default_sqw_freq;
211 }
212
213 if (this_proj -> modelgl)
214 {
215 image * img = this_proj -> modelgl -> anim -> last -> img;
216 if (img)
217 {
218 preferences = FALSE;
219 setup_default_image (this_proj, img);
220 preferences = TRUE;
221 i = -1;
222 if (this_proj -> id != activep)
223 {
224 i = activep;
225 active_project_changed (this_proj -> id);
226 }
227 init_camera (this_proj);
228 if (i != -1) active_project_changed (i);
230 clean_atom_style (this_proj);
231 init_shaders (this_proj -> modelgl);
232 update (this_proj -> modelgl);
233 if (this_proj -> modelgl -> box_win)
234 {
235 if (this_proj -> modelgl -> box_win -> win) this_proj -> modelgl -> box_win -> win = destroy_this_widget (this_proj -> modelgl -> box_win -> win);
236 g_free (this_proj -> modelgl -> box_win);
237 this_proj -> modelgl -> box_win = NULL;
238 box_advanced (NULL, this_proj -> modelgl);
239 }
240 if (this_proj -> modelgl -> axis_win)
241 {
242 if (this_proj -> modelgl -> axis_win -> win) this_proj -> modelgl -> axis_win -> win = destroy_this_widget (this_proj -> modelgl -> axis_win -> win);
243 g_free (this_proj -> modelgl -> axis_win);
244 this_proj -> modelgl -> axis_win = NULL;
245 axis_advanced (NULL, this_proj -> modelgl);
246 }
247 if (this_proj -> modelgl -> rep_win)
248 {
249 if (this_proj -> modelgl -> rep_win -> win) this_proj -> modelgl -> rep_win -> win = destroy_this_widget (this_proj -> modelgl -> rep_win -> win);
250 g_free (this_proj -> modelgl -> rep_win);
251 this_proj -> modelgl -> rep_win = NULL;
252 representation_advanced (NULL, this_proj -> modelgl);
253 }
254 if (this_proj -> modelgl -> opengl_win)
255 {
256 if (this_proj -> modelgl -> opengl_win -> win) this_proj -> modelgl -> opengl_win -> win = destroy_this_widget (this_proj -> modelgl -> opengl_win -> win);
257 g_free (this_proj -> modelgl -> opengl_win);
258 this_proj -> modelgl -> opengl_win = NULL;
259 opengl_advanced (NULL, this_proj -> modelgl);
260 }
261 if (this_proj -> modelgl -> gradient_win) update_gradient_widgets (this_proj -> modelgl -> gradient_win, img -> back);
262 }
263 }
264}
265
273void init_project (gboolean alloc_box)
274{
275 project * new_proj = g_malloc0(sizeof*new_proj);
276 nprojects ++;
277 activep = nprojects - 1;
278 new_proj -> id = activep;
279 new_proj -> name = g_strdup_printf("%s%2d", _("Project N°"), activep);
281 new_proj -> tfile = -1;
282 new_proj -> newproj = TRUE;
283 new_proj -> steps = 1;
284 new_proj -> tunit = (int)default_delta_t[1];
285
286 // Other calculation related parameters : to be added to user preferences
287 new_proj -> xcor = 1;
288 new_proj -> sk_advanced[0][0] = new_proj -> sk_advanced[1][0] = 1.0;
289 new_proj -> sk_advanced[0][1] = new_proj -> sk_advanced[1][1] = 15.0;
290 // new_proj -> skt_corr_threshold = 10;
291 // new_proj -> skt_n_data_sets = 5;
292 // new_proj -> sqw_n_data_sets = 5;
293
294 //
295 new_proj -> coord = g_malloc0(sizeof*new_proj -> coord);
296 if (alloc_box) new_proj -> cell.box = g_malloc0(sizeof*new_proj -> cell.box);
297
299 if (nprojects == 1)
300 {
301 workzone.first = g_malloc0(sizeof*workzone.first);
302 workzone.first = new_proj;
303 workzone.last = g_malloc0(sizeof*workzone.last);
304 }
305 else
306 {
307 new_proj -> prev = workzone.last;
308 workzone.last -> next = new_proj;
309 }
310 workzone.last = new_proj;
311 active_project_changed (new_proj -> id);
313 new_proj -> newproj = FALSE;
314}
Binding to the Fortran90 subroutines.
Callback declarations for main window.
integer(kind=c_int) function chemistry()
Definition chemistry.F90:22
Variable declarations for the curve widget Functions for interactions with the curve widget.
int activep
Definition global.c:162
int nprojects
Definition global.c:161
Global variable declarations Global convenience function declarations Global data structure defin...
workspace workzone
Definition project.c:46
#define RIN
Definition global.h:343
void remove_edition_actions()
remove all edition actions
Definition gui.c:564
#define SPH
Definition global.h:345
#define CHA
Definition global.h:344
GtkWidget * destroy_this_widget(GtkWidget *widg)
destroy a GtkWidget
Definition gtk-misc.c:2213
#define min(a, b)
Definition global.h:93
#define CHEM_Z
Definition global.h:316
project * active_project
Definition project.c:47
#define NCALCS
#define MSD
Definition global.h:346
void update(glwin *view)
update the rendering of the OpenGL window
Definition glview.c:461
Variable declarations related to the OpenGL window Function declarations related to the OpenGL wind...
Function declarations for the creation of the OpenGL window.
void setup_default_image(project *this_proj, image *img)
setup default image parameters
Definition glview.c:1344
G_MODULE_EXPORT void opengl_advanced(GtkWidget *widg, gpointer data)
create OpenGL rendering advanced window
Definition w_advance.c:1733
void init_curves_and_calc(project *this_proj)
for a project reset analysis, curves, data to not performed
Definition init_p.c:69
void init_shaders(glwin *view)
initialize all the OpenGL shaders
void init_camera(project *this_proj)
initialize the OpenGL camera settings
Definition glview.c:1180
G_MODULE_EXPORT void gradient_advanced(GtkWidget *widg, gpointer data)
Background configuration window.
Definition w_colors.c:434
void clean_atom_style(project *this_proj)
clean all atom(s) possible alternative rendering styles
Definition m_style.c:78
G_MODULE_EXPORT void axis_advanced(GtkWidget *widg, gpointer data)
create the axis advanced parameters window
Definition w_axis.c:783
void apply_default_parameters_to_project(project *this_proj, gboolean with_analysis)
apply default parameters to project
Definition init_p.c:146
void apply_analysis_default_parameters_to_project(project *this_proj)
apply default analysis parameters to project
Definition init_p.c:94
void update_gradient_widgets(gradient_edition *gradient_win, background *back)
update the widgets of the gradient window
Definition w_colors.c:84
G_MODULE_EXPORT void box_advanced(GtkWidget *widg, gpointer data)
create the box edition window
Definition w_box.c:334
void setup_default_species_parameters_for_image(project *this_proj, image *img)
setup default chemical species related parameters for image
Definition glview.c:1226
G_MODULE_EXPORT void representation_advanced(GtkWidget *widg, gpointer data)
open advanced representation dialog
Definition m_rep.c:425
void init_project(gboolean alloc_box)
initialize a new project
Definition init_p.c:273
Messaging function declarations.
void prep_calc_actions()
prepare analysis widgets
Definition update_p.c:59
int * default_csparam
int default_skt_n_sets
int * default_num_delta
int default_sqw_n_sets
int * default_rsparam
double default_totcut
int default_sqw_freq
gboolean default_skt_sets
bond_cutoff * default_bond_cutoff
double * default_delta_t
gboolean preferences
Preference variable declarations.
Function declarations for reading atomes project file Function declarations for saving atomes proje...
void active_project_changed(int id)
change the active project
Definition update_p.c:220
gboolean skt_all_sets
Definition glwin.h:967
Definition glwin.h:364
atom_search * csearch
Definition w_search.c:2719
GtkWidget * img
Definition workspace.c:70