atomes 1.3.1
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
cpmd_init.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: 'cpmd_init.c'
24*
25* Contains:
26*
27
28 - The functions to initialize the QM / QM-MM input file creation assistant
29
30*
31* List of functions:
32
33 G_MODULE_EXPORT gint on_qm_assistant_go_forward (gint current_page, gpointer data);
34
35 gboolean go_for_it (int i, int j, gboolean print[2]);
36
37 G_MODULE_EXPORT gboolean on_qm_assistant_cancel_event (GtkWindow * assistant, gpointer data);
38 G_MODULE_EXPORT gboolean on_qm_assistant_cancel_event (GtkWidget * assistant, GdkEvent * event, gpointer data);
39
40 gchar * section_name (int p);
41 gchar * page_name (int p);
42
43 void print_all_sections (GtkTextBuffer * buf);
44 void add_cpmd_pages ();
45 void proj_unselect_all_atoms ();
46 void create_qm_input_file (int c, int p, int s);
47
48 G_MODULE_EXPORT void update_cpmd_parameter (GtkEntry * res, gpointer data);
49 G_MODULE_EXPORT void update_cpmd_check (GtkCheckButton * but, gpointer data);
50 G_MODULE_EXPORT void update_cpmd_check (GtkToggleButton * but, gpointer data);
51 G_MODULE_EXPORT void changed_opt_box (GtkComboBox * box, gpointer data);
52 G_MODULE_EXPORT void update_calc_parameter (GtkEntry * res, gpointer data);
53 G_MODULE_EXPORT void changed_calc_opt_box (GtkComboBox * box, gpointer data);
54 G_MODULE_EXPORT void update_calc_check (GtkCheckButton * but, gpointer data);
55 G_MODULE_EXPORT void update_calc_check (GtkToggleButton * but, gpointer data);
56 G_MODULE_EXPORT void changed_calc_box (GtkComboBox * box, gpointer data);
57 G_MODULE_EXPORT void changed_info (GtkTextBuffer * textbuf, gpointer data);
58 G_MODULE_EXPORT void on_qm_assistant_cancel (GtkAssistant * assistant, gpointer data);
59 G_MODULE_EXPORT void on_qm_assistant_close (GtkAssistant * assistant, gpointer data);
60 G_MODULE_EXPORT void on_qm_assistant_prepare (GtkAssistant * assistant, GtkWidget * page, gpointer data);
61 G_MODULE_EXPORT void show_qm_file_preview (GtkButton * but, gpointer data);
62 G_MODULE_EXPORT void run_saving_qm (GtkNativeDialog * info, gint response_id, gpointer data);
63 G_MODULE_EXPORT void run_saving_qm (GtkDialog * info, gint response_id, gpointer data);
64 G_MODULE_EXPORT void on_qm_assistant_apply (GtkAssistant * assistant, gpointer data);
65
66 GtkWidget * cpmd_box (GtkWidget * box, gchar * lab, int v_space, int h_space, int dim);
67 GtkWidget * prepare_qm_option_box (int s);
68 GtkWidget * calc_qm_option_box (int c);
69 GtkWidget * info_box ();
70 GtkWidget * section_box (int s);
71 GtkWidget * qm_preview_box (int c, int s, int l);
72 GtkWidget * vbox_cpmd (int s);
73
74*/
75
76#include "global.h"
77#include "callbacks.h"
78#include "interface.h"
79#include "project.h"
80#include "glwindow.h"
81#include "glview.h"
82#include "calc.h"
83#include "cpmd.h"
84#include "cp2k.h"
85
86extern void print_cp2k (int f, GtkTextBuffer * buffer);
87extern void add_cp2k_pages ();
88
89extern ColRGBA init_color (int id, int numid);
90extern GtkWidget * electron_box;
91extern GtkWidget * thermo_box ();
92extern void field_unselect_all ();
93extern void print_the_section (int s, int p, GtkTextBuffer * buffer);
94extern void init_thermos ();
95extern gboolean are_all_atoms_thermostated ();
96extern void create_selection_combo (int id, int num, int type, GCallback handler);
97extern G_MODULE_EXPORT void atom_button (GtkButton * but, gpointer data);
98extern GtkWidget * restart_box ();
99extern void restore_ogl_selection (glwin * view);
100
101gchar * co_type[2] = {"CPMD", "CP2K"};
102
104
105gchar * cpmd_elements[MAXDATAQM] = {"INFO",
106 "CPMD",
107 "DFT",
108 "VDW",
109 "PROP",
110 "SYSTEM",
111 "ATOMS"};
112
113gchar * cdescr[MAXDATAQM] = {i18n("provides an informal description of the system and the calculation to be performed"),
114 i18n("provides the general control parameters for the calculation to be performed"),
115 i18n("provides the exchange and correlation functional (DFT) parameters"),
116 i18n("describes the implementation of the van der Waals interactions"),
117 i18n("provides details about the physical properties to be calculated"),
118 i18n("describes the symmetry and periodicity of the system"),
119 i18n("describes the atomic species, pseudo-potentials and coordinates")};
120
121double default_cpmd_options[17] = {400.0, 0.0, 0.0, 4.0, 0.000001, 0.0, 0.0, 0.0, 0.0, 0.0, 70.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0};
122
123gchar * default_opts[MAXDATAQM-1][NSECOP]= {{i18n("Fictitious electronic mass:"), i18n("Local Spin Density"), i18n("van der Walls interactions"), " ", " ", " "},
124 {i18n("DFT functional:"), i18n("Density cutoff<sup>*</sup>:"), " ", " ", " ", " "},
125 {" ", " ", " ", " ", " ", " "},
126 {" ", " ", " ", " ", " ", " "},
127 {i18n("Use Angströms (default a.u.)"), i18n("Lattice:"), i18n("Symmetry:"), i18n("Parameters:"), i18n("Angles:"), i18n("Cutoff for the plane wave basis:")},
128 {i18n("Use constraints"), i18n("Freeze:"), i18n("Use dummy atoms:"), i18n("Atom type:"), i18n("Maximum angular momentum <i>l</i>:"), i18n("Local angular momentum <i>l</i>:")}};
129
130// 0 = None, 1 = Entry, 2 = Combo, 3 = yes/no
131int default_opts_type[MAXDATAQM-1][NSECOP] = {{1, 3, 3, 0, 0, 0},
132 {2, 1, 0, 0, 0, 0},
133 {0, 0, 0, 0, 0, 0},
134 {0, 0, 0, 0, 0, 0},
135 {3, 2, 2, 2 ,2, 1},
136 {3, 0, 3, 2, 2, 2}};
137// NDF is the max by far
138int defaut_num[9]={NDFT, 2, NSYM, 2, 2, 3, -1, 3, 3};
139
140gchar * default_keywords[9][NDFT] = {{"SONLY", "LDA", "BONLY", "BP", "BLYP", "XLYP", "PW91", "PBE", "PBES", "REVPBE", "HCTH", "OPTX", "OLYP", "TPSS", "PBE0", "B1LYP", "B3LYP", "X3LYP", "HSE06"},
141 {" ", " VECTORS", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "},
142 {" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "},
143 {" ", " ABSOLUTE", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "},
144 {" ", " DEGREE", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "},
145 {"ALL", "ATOMS", "COORDINATES", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "},
146 {" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "},
147 {"S", "P", "D", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "},
148 {"S", "P", "D", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "}};
149
150gchar * default_text[9][NDFT] = {{i18n("Slater Exchange Only"), i18n("Local Density Approximation"), "Becke 88", "Becke + Perdew", "Becke + Lee-Yang-Parr", i18n("Extended B88+PW91+LYP88"), "Perdew + Wang 91",
151 "Perdew + Burke-Ernzerhof", i18n("PBE Revised for Solids"), i18n("Revised - PBE"), "Hamprecht-Cohen-Tozer-Handy", i18n("Optimized Becke 88"), "Handy-Cohen + LYP",
152 "Tao-Perdew-Staroverov-Scuseria", i18n("Parameter-free PBE"), i18n("Becke One-parameter Hybrid + LYP"), i18n("Becke Three-parameters Hybrid + LYP"), i18n("Extended Hybrid + LYP"), "Heyd-Scuseria-Ernzerhof 06"},
153 {i18n("Box Parameters (a,b,c and α,β,γ)"), i18n("Lattice Vectors"), " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "},
154 {i18n("Isolated"), i18n("Cubic"), i18n("Face Centered Cubic (FCC)"), i18n("Body Centered Cubic (BCC)"), i18n("Hexagonal"), i18n("Trigonal"),
155 i18n("Tetragonal"), i18n("Body Centered Tetragonal (BCT)"), i18n("Orthorombic"), i18n("Monoclinic"), i18n("Triclinic"), " ", " ", " ", " ", " ", " ", " ", " "},
156 {i18n("Default (a, b/a, c/a)"), i18n("Absolute (a, b, c)"), " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "},
157 {i18n("Default (cos α, cos β, cos γ)"), i18n("Degrees (α, β, γ)"), " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "},
158 {i18n("All Atoms"), i18n("Some Atoms"), i18n("Some Coordinates"), " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "},
159 {" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "},
160 {"s", "p", "d", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "},
161 {"s", "p", "d", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "}};
162
163double default_calc_options[24] = {0.00001, 0.0, 10000.0, 3.0,
164 0.0005, 0.0, 10000.0, 3.0,
165 10000.0, 5.0, 0.0, 0.0, 0.9, 0.0, 0.9,
166 10000.0, 5.0, 0.0, 0.0, 0.9,
167 50.0, 0.0, 0.0, 0.0};
168
169gchar * cpmd_calc_opts[NCPMDCALC][NOPTPC]={{i18n("Convergence criteria<sup>*</sup>:"), i18n("Optimizer:"), i18n("Max steps:"), i18n("Integration step:"), " ", " ", " "},
170 {i18n("Convergence criteria<sup>*</sup>:"), i18n("Optimizer:"), i18n("Max steps:"), i18n("Integration step:"), " ", " ", " "},
171 {i18n("Max MD steps: "), i18n("Time step:"), i18n("Barostat:"), i18n("Ions"), i18n("Factor:"), i18n("Fictitious electrons"), i18n("Factor:")},
172 {i18n("Max MD steps: "), i18n("Time step:"), i18n("Barostat:"), i18n("Ions"), i18n("Factor:"), " ", " "},
173 {i18n("Number of unoccupied states:"), i18n("3D visualization<sup>*</sup>"), i18n("Number of objects<sup>**</sup>:"), " ", " ", " ", " "},
174 {i18n("Property to compute:"), " ", " ", " ", " ", " ", " "}};
175
176int default_type[NCPMDCALC][NOPTPC]={{1, 2, 1, 1, 0, 0, 0},
177 {1, 2, 1, 1, 0, 0, 0},
178 {1, 1, 2, 3, 1, 3, 1},
179 {1, 1, 2, 3, 1, 0, 0},
180 {1, 3, 1, 0, 0, 0, 0},
181 {2, 0, 0, 0, 0, 0, 0},
182 {0, 0, 0, 0, 0, 0, 0}};
183
184gchar * calc_kw[NCPMDCALC]= {"OPTIMIZE WAVEFUNCTION",
185 "OPTIMIZE GEOMETRY",
186 "MOLECULAR DYNAMICS",
187 "MOLECULAR DYNAMICS BO",
188 "KOHN-SHAM ENERGIES",
189 "VIBRATIONAL ANALYSIS",
190 "PROPERTIES"};
191
192gchar * calc_ds[NCPMDCALC]= {i18n("Wavefunction Optimization"),
193 i18n("Geometry Optimization"),
194 i18n("CPMD Molecular Dynamics"),
195 i18n("Born-Oppenheimer Molecular Dynamics"),
196 i18n("Kohn-Sham Eigen Values"),
197 i18n("Vibrational Analysis"),
198 i18n("Calculation of Physical Properties")};
199
200int calc_box_num[NCACOMBO]={2, 2, 3, 3, 3};
201
202gchar * calc_box_name[NCACOMBO][3] = {{i18n("Preconditioned Gradient"), i18n("Direct Inversion of Iterative Subspace"), " "},
203 {i18n("Quasi-Newton method"), i18n("Direct Inversion of Iterative Subspace"), " "},
204 {i18n("None"), "Parrinello-Rahman", "Parrinello-Rahman + NPT"},
205 {i18n("None"), "Parrinello-Rahman", "Parrinello-Rahman + NPT"},
206 {i18n("Finite differences of first derivatives"), i18n("Linear response of ionic displacement"), i18n("Precalculated Hessian")}};
207
208gchar * calc_box_keys[NCACOMBO][3] = {{"PCG", "ODIIS", " "},
209 {"BFGS", "GDIIS", " "},
210 {" ", "PARRINELLO-RAHMAN", "PARRINELLO-RAHMAN NPT"},
211 {" ", "PARRINELLO-RAHMAN", "PARRINELLO-RAHMAN NPT"},
212 {"FD", "LR", "IN"}};
213
214gchar * nosetype[3] = {i18n("Gobal"), i18n("Local"), i18n("Molecule")};
215gchar * thermo_name[2][5] = {{i18n("None"), i18n("Controlled"), i18n("Nosé-Hoover chains"), " ", " "},
216 {i18n("None"), i18n("Adaptive Langevin"), i18n("Canonical sampling through velocity rescaling"), "GLE", i18n("Nosé-Hoover chains")}};
217int num_thermo[2] = {3, 5};
218int type_thermo[2] = {2, 2};
219
220GtkWidget * qm_preview_but;
221GtkWidget * calc_combo;
224GtkWidget * calc_label;
225GtkWidget * latbox;
226GtkWidget * but_at[2];
227GtkWidget * spatbox;
228GtkWidget * ppbox[2];
229GtkWidget * calc_box[NCPMDCALC];
231gboolean is_cpmd;
232
244GtkWidget * cpmd_box (GtkWidget * box, gchar * lab, int v_space, int h_space, int dim)
245{
246 GtkWidget * hbox = create_hbox (0);
247 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, v_space);
248 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label(lab, dim, 30, 0.0, 0.5), FALSE, FALSE, h_space);
249 return hbox;
250}
251
259void print_all_sections (GtkTextBuffer * buf)
260{
261 int i;
262 for (i=0; i<MAXDATAQM+2; i++)
263 {
264 if (i != 5 && i != 6)
265 {
266 if (buf == NULL)
267 {
268 print_the_section (i, 0, qmbuffer[i]);
269 }
270 else if (i == 0 || i > 2)
271 {
272 print_the_section (i, 1, buf);
273 }
274 }
275 else if (i == 5 && (int)tmp_cpmd -> default_opts[2])
276 {
277 if (buf == NULL)
278 {
279 print_the_section (i, 0, qmbuffer[i]);
280 }
281 else
282 {
283 print_the_section (i, 1, buf);
284 }
285 }
286 else if (i == 6 && tmp_cpmd -> calc_type == 4)
287 {
288 if (buf == NULL)
289 {
290 print_the_section (i, 0, qmbuffer[i]);
291 }
292 else
293 {
294 print_the_section (i, 1, buf);
295 }
296 }
297 }
298}
299
308G_MODULE_EXPORT void update_cpmd_parameter (GtkEntry * res, gpointer data)
309{
310 int i;
311 i = GPOINTER_TO_INT(data);
312 const gchar * m = entry_get_text (res);
313 double v = string_to_double ((gpointer)m);
314 tmp_cpmd -> default_opts[i] = v;
315 if (i == DEFGC)
316 {
318 }
319 else
320 {
322 }
323 print_all_sections (NULL);
324}
325
326#ifdef GTK4
335G_MODULE_EXPORT void update_cpmd_check (GtkCheckButton * but, gpointer data)
336#else
345G_MODULE_EXPORT void update_cpmd_check (GtkToggleButton * but, gpointer data)
346#endif
347{
348 int i = GPOINTER_TO_INT(data);
349 gboolean j = button_get_status ((GtkWidget *)but);
350 if (i == DEFCO || i == DEFDU)
351 {
352 widget_set_sensitive (but_at[(i == DEFCO) ? 0 : 1], j);
353 }
354 tmp_cpmd -> default_opts[i] = (double) j;
355 print_all_sections (NULL);
356}
357
366G_MODULE_EXPORT void changed_opt_box (GtkComboBox * box, gpointer data)
367{
368 int i, j, k;
369 j = GPOINTER_TO_INT(data);
370 i = combo_get_active ((GtkWidget *)box);
371 if (j != DEFLM && j != DEFLO)
372 {
373 if (i != (int)tmp_cpmd -> default_opts[j])
374 {
375 tmp_cpmd -> default_opts[j] = (double)i;
376 if (j == DEFSP)
377 {
378 k = (int)tmp_cpmd -> default_opts[j];
379 combo_set_active (ppbox[0], tmp_cpmd -> pp[k][0]);
380 combo_set_active (ppbox[1], tmp_cpmd -> pp[k][1]);
381 }
382 else if (j == DEFFI)
383 {
385 if (tmp_cpmd -> fixlist != NULL)
386 {
387 g_free (tmp_cpmd -> fixlist);
388 tmp_cpmd -> fixlist = NULL;
389 if (tmp_cpmd -> fixcoord != NULL)
390 {
391 g_free (tmp_cpmd -> fixcoord);
392 tmp_cpmd -> fixcoord = NULL;
393 }
394 }
395 tmp_cpmd -> fixat = 0;
397 }
398 }
399 }
400 else
401 {
402 if (i != tmp_cpmd -> pp[(int)tmp_cpmd -> default_opts[DEFSP]][j-DEFLM])
403 {
404 tmp_cpmd -> pp[(int)tmp_cpmd -> default_opts[DEFSP]][j-DEFLM] = i;
405 }
406 }
407 if (j == DEFVE)
408 {
410 }
411 print_all_sections (NULL);
412}
413
421GtkWidget * prepare_qm_option_box (int s)
422{
423 int i, j, k, l;
424 GtkWidget * hbox;
425 GtkWidget * widg;
426 gchar * str;
427 GtkWidget * vbox = create_vbox (BSEP);
428 for (i=0; i<NSECOP; i++)
429 {
430 if (default_opts_type[s][i] > 0)
431 {
432 if ((s == 0 && (i == 0 || i == 1 || i == 2))
433 || (s == 1 && (i == 0 || i == 1))
434 || (s == 4) || (s == 5))
435 {
436 str = g_strdup_printf ("%s", _(default_opts[s][i]));
437 }
438 else
439 {
440 str = g_strdup_printf ("%s", default_opts[s][i]);
441 }
442 ident ++;
443 if (ident == DEFAB || ident == DEFDG || ident == DEFSY)
444 {
445 hbox = cpmd_box (latbox, str, 5, 20, (s == 1) ? 150 : 220);
446 }
447 else if (ident == DEFCO || ident == DEFDU)
448 {
449 hbox = cpmd_box (vbox, str, 20, 20, 180);
450 }
451 else if (ident == DEFLM || ident == DEFLO)
452 {
453 hbox = cpmd_box (spatbox, str, 5, 20, 220);
454 }
455 else
456 {
457 hbox = cpmd_box (vbox, str, (ident == DEFSP) ? 20 : 5, 5, (s == 1) ? 150 : 220);
458 }
459 g_free (str);
460 j = ident;
461 switch (default_opts_type[s][i])
462 {
463 case 1:
464 widg = create_entry (G_CALLBACK(update_cpmd_parameter), 100, 15, FALSE, GINT_TO_POINTER(j));
465 if (j == DEFGC)
466 {
467 update_entry_long_double (GTK_ENTRY(widg), tmp_cpmd -> default_opts[j]);
468 }
469 else
470 {
471 update_entry_double (GTK_ENTRY(widg), tmp_cpmd -> default_opts[j]);
472 }
473 break;
474 case 2:
475 icomb ++;
476 if (ident == DEFLM || ident == DEFLO)
477 {
479 }
480 else
481 {
482 widg = create_combo ();
483 }
484 l = (ident == DEFSP) ? qm_proj -> nspec : defaut_num[icomb];
485 for (k=0; k<l; k++)
486 {
487 if (icomb == 0)
488 {
489 if (k == 0 || k == 1 || k == 5 || k == 8 || k == 9 || k == 11 || k == 14 || k == 15 || k == 16 || k == 17)
490 {
491 str = g_strdup_printf ("%s (%s)", _(default_text[0][k]), default_keywords[0][k]);
492 }
493 else
494 {
495 str = g_strdup_printf ("%s (%s)", default_text[0][k], default_keywords[0][k]);
496 }
497 }
498 else if (ident == DEFSP)
499 {
500 str = g_strdup_printf (_("%s atom(s)"), qm_proj -> chemistry -> label[k]);
501 }
502 else
503 {
504 str = g_strdup_printf ("%s", (icomb < 6) ? _(default_text[icomb][k]) : default_text[icomb][k]);
505 }
506 if (ident == DEFLM || ident == DEFLO)
507 {
509 }
510 else
511 {
512 combo_text_append (widg, str);
513 }
514 g_free (str);
515 }
516 if (ident == DEFLM || ident == DEFLO)
517 {
519 g_signal_connect (G_OBJECT (ppbox[ident - DEFLM]), "changed", G_CALLBACK(changed_opt_box), GINT_TO_POINTER(j));
520 }
521 else
522 {
523 combo_set_active (widg, (int)tmp_cpmd -> default_opts[j]);
524 g_signal_connect (G_OBJECT (widg), "changed", G_CALLBACK(changed_opt_box), GINT_TO_POINTER(j));
525 }
526 break;
527 case 3:
528 widg = check_button (NULL, -1, -1, tmp_cpmd -> default_opts[j], G_CALLBACK(update_cpmd_check), GINT_TO_POINTER(j));
529 break;
530 }
531 if (ident == DEFLM || ident == DEFLO)
532 {
533 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, ppbox[ident - DEFLM], FALSE, FALSE, 0);
534 }
535 else
536 {
537 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, widg, FALSE, FALSE, 0);
538 }
539 if (j==DEFEM || j==DEFGC || j==DEFCU)
540 {
541 if (j==DEFEM || j==DEFGC)
542 {
543 widg = gtk_label_new ("a.u.");
544 }
545 else
546 {
547 widg = gtk_label_new ("Ry");
548 }
549 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, widg, FALSE, FALSE, 5);
550 }
551 else if (j == DEFVE)
552 {
554 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, latbox, FALSE, FALSE, 15);
556 }
557 else if (j == DEFCO || j == DEFDU)
558 {
559 k = (j==DEFCO) ? 0 : 1;
560 but_at[k] = create_button ((j == DEFCO) ? _("Configure constraints") : _("Configure dummy atoms"),
561 IMG_NONE, NULL, 175, -1, GTK_RELIEF_NORMAL, G_CALLBACK(atom_button), GINT_TO_POINTER(j));
563 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, but_at[k], FALSE, FALSE, 20);
564 if (j == DEFCO)
565 {
566 ident ++;
567 icomb ++;
568 }
569 }
570 else if (j == DEFSP)
571 {
573 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, spatbox, FALSE, FALSE, 15);
574 }
575 }
576 }
577 return vbox;
578}
579
588G_MODULE_EXPORT void update_calc_parameter (GtkEntry * res, gpointer data)
589{
590 int i, j;
591 i = GPOINTER_TO_INT(data);
592 const gchar * m = entry_get_text (res);
593 double v = string_to_double ((gpointer)m);
594 if (i==STEPO || i==STEPG || i==STEPC || i==STEPB || i==KSUNO || i==NBAND)
595 {
596 j = (int) v;
597 tmp_cpmd -> calc_opts[i] = (double) j;
599 }
600 else
601 {
602 tmp_cpmd -> calc_opts[i] = v;
603 if (i == CONVO || i == CONVG)
604 {
606 }
607 else
608 {
610 }
611 }
612 for (i=1; i<4; i++) print_the_section (i, 0, qmbuffer[i]);
613}
614
623G_MODULE_EXPORT void changed_calc_opt_box (GtkComboBox * box, gpointer data)
624{
625 int i, j;
626 j = GPOINTER_TO_INT(data);
627 i = combo_get_active ((GtkWidget *)box);
628 if (i != tmp_cpmd -> calc_opts[j])
629 {
630 tmp_cpmd -> calc_opts[j] = i;
631 for (j=1; j<4; j++) print_the_section (j, 0, qmbuffer[j]);
632 }
633}
634
635#ifdef GTK4
644G_MODULE_EXPORT void update_calc_check (GtkCheckButton * but, gpointer data)
645#else
654G_MODULE_EXPORT void update_calc_check (GtkToggleButton * but, gpointer data)
655#endif
656{
657 int i = GPOINTER_TO_INT(data);
658 tmp_cpmd -> calc_opts[i] = (double) button_get_status ((GtkWidget *)but);
659 for (i=1; i<4; i++) print_the_section (i, 0, qmbuffer[i]);
660}
661
669GtkWidget * calc_qm_option_box (int c)
670{
671 int i, j, k, l;
672 GtkWidget * hbox;
673 GtkWidget * widg;
674 gchar * str;
675 GtkWidget * vbox = create_vbox (BSEP);
676 for (i=0; i<NOPTPC; i++)
677 {
678 if (default_type[c][i] > 0)
679 {
680 idopt ++;
681 l = 0;
682 if (idopt == ANNIC || idopt == ANNIB)
683 {
684 hbox = cpmd_box (vbox, _("Annealing:"), 0, 5, 220);
685 }
686 if (idopt == ANNIC || idopt == ANNEC || idopt == ANNIB)
687 {
688 hbox = cpmd_box (vbox, _(cpmd_calc_opts[c][i]), 0, 25, 120);
689 l = 30;
690 }
691 else if (idopt == AFAIC || idopt == AFAEC || idopt == AFAIB)
692 {
693 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, gtk_label_new(_(cpmd_calc_opts[c][i])), FALSE, FALSE, 10);
694 l = 30;
695 }
696 else
697 {
698 hbox = cpmd_box (vbox, _(cpmd_calc_opts[c][i]), 0, 5, 220);
699 }
700 j = idopt;
701 switch (default_type[c][i])
702 {
703 case 1:
704 widg = create_entry (G_CALLBACK(update_calc_parameter), 100, 15, FALSE, GINT_TO_POINTER(j));
705 if (j==STEPO || j==STEPG || j==STEPC || j==STEPB || j==KSUNO || j==NBAND)
706 {
707 update_entry_int (GTK_ENTRY(widg), (int) tmp_cpmd -> calc_opts[j]);
708 }
709 else
710 {
711 update_entry_double (GTK_ENTRY(widg), tmp_cpmd -> calc_opts[j]);
712 }
713 break;
714 case 2:
715 icalc ++;
716 widg = create_combo ();
717 for (k=0; k<calc_box_num[icalc]; k++)
718 {
719 if ((icalc == 0 && (k == 0 || k == 1))
720 || (icalc == 1 && (k == 0 || k == 1))
721 || (icalc == 2 && k == 0)
722 || (icalc == 3 && k == 0)
723 || (icalc == 4))
724 {
725 str = g_strdup_printf ("%s", _(calc_box_name[icalc][k]));
726 }
727 else
728 {
729 str = g_strdup_printf ("%s", calc_box_name[icalc][k]);
730 }
731 combo_text_append (widg, str);
732 g_free (str);
733 }
734 combo_set_active (widg, (int)tmp_cpmd -> calc_opts[j]);
735 g_signal_connect (G_OBJECT (widg), "changed", G_CALLBACK(changed_calc_opt_box), GINT_TO_POINTER(j));
736 break;
737 case 3:
738 widg = check_button (NULL, -1, -1, tmp_cpmd -> calc_opts[j], G_CALLBACK(update_calc_check), GINT_TO_POINTER(j));
739 break;
740 }
741 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, widg, FALSE, FALSE, l);
742 if (j==TSTPO || j==TSTPG || j==TSTPC || j==TSTPB)
743 {
744 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, gtk_label_new ("a.u."), FALSE, FALSE, 5);
745 }
746 else if (j==NBAND)
747 {
748 gchar * ksout = _("\t * electronic density(ies) or/and wavefunction(s)\n"
749 "\t ** as many index(es) to be supplied on the next line:\n"
750 "\t\t &gt; 0 for electronic density\n\t\t &lt; 0 for wavefunction");
751 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label(ksout, -1, -1, 0.0, 0.5), FALSE, FALSE, 10);
752 }
753 }
754 }
755 return vbox;
756}
757
766G_MODULE_EXPORT void changed_calc_box (GtkComboBox * box, gpointer data)
767{
768 int i;
769 i = combo_get_active ((GtkWidget *)box);
770 if (i != tmp_cpmd -> calc_type)
771 {
772 gtk_label_set_text (GTK_LABEL(calc_label), g_strdup_printf (_("<u>%s option(s)</u>"), _(calc_ds[i])));
773 gtk_label_set_use_markup (GTK_LABEL(calc_label), TRUE);
774 hide_the_widgets (calc_box[tmp_cpmd -> calc_type]);
776 tmp_cpmd -> calc_type = i;
777 if (tmp_cpmd -> calc_type != 2)
778 {
780 }
781 else
782 {
784 }
785 for (i=1; i<4; i++) print_the_section (i, 0, qmbuffer[i]);
786 }
787}
788
797G_MODULE_EXPORT void changed_info (GtkTextBuffer * textbuf, gpointer data)
798{
799 GtkTextIter bStart;
800 GtkTextIter bEnd;
801 gtk_text_buffer_get_start_iter (textbuf, & bStart);
802 gtk_text_buffer_get_end_iter (textbuf, & bEnd);
803 if (tmp_cpmd -> info != NULL) g_free (tmp_cpmd -> info);
804 tmp_cpmd -> info = g_strdup_printf ("%s", gtk_text_buffer_get_text (textbuf, & bStart, & bEnd, FALSE));
805 print_the_section (0, 0, qmbuffer[0]);
806}
807
813GtkWidget * info_box ()
814{
815 GtkWidget * vbox = create_vbox (BSEP);
816 GtkWidget * hbox = create_hbox (0);
817 GtkWidget * scrollsets = create_scroll (NULL, 355, 250, GTK_SHADOW_ETCHED_IN);
818 GtkWidget * aview = create_text_view (-1, -1, 1, 0, G_CALLBACK(changed_info), NULL, NULL);
819 if (tmp_cpmd -> info != NULL) print_info (tmp_cpmd -> info, NULL, gtk_text_view_get_buffer(GTK_TEXT_VIEW(aview)));
821 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, scrollsets, FALSE, FALSE, 85);
822 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 0);
823
824 return vbox;
825}
826
834GtkWidget * section_box (int s)
835{
836 int i;
837 gchar * str;
838 GtkWidget * hbox;
839 GtkWidget * vbox = create_vbox (BSEP);
840 if (s == 0)
841 {
842 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, info_box(), FALSE, FALSE, 50);
843 }
844 else if (s == 1)
845 {
846 // CPMD Calculation
847 /* Calc type combo_box: */
848 idopt = -1;
849 icalc = -1;
850 ident = -1;
851 icomb = -1;
852 hbox = create_hbox (0);
853 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label(_("<b>Calculation to be performed:</b>"), -1, -1, 0.0, 0.5), FALSE, FALSE, 10);
855 for (i=0; i<NCPMDCALC; i++) combo_text_append (calc_combo, _(calc_ds[i]));
856 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, calc_combo, FALSE, FALSE, 10);
857 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 0);
858
859 /* Calc related options: */
860 str = g_strdup_printf (_("<u>%s option(s)</u>"), _(calc_ds[tmp_cpmd -> calc_type]));
861 calc_label = markup_label(str, -1, -1, 0.0, 0.5);
862 g_free (str);
863 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, calc_label, FALSE, FALSE, 10);
864 for (i=0; i<NCPMDCALC; i++)
865 {
867 gtk_widget_set_size_request (calc_box[i], -1, 200);
868 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, calc_box[i], FALSE, FALSE, 0);
869 }
870 g_signal_connect (G_OBJECT (calc_combo), "changed", G_CALLBACK(changed_calc_box), NULL);
871 combo_set_active (calc_combo, tmp_cpmd -> calc_type);
872 }
873 else if (s == 2)
874 {
875 // CPMD - thermostat(s)
876 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, thermo_box(), FALSE, FALSE, 5);
877 }
878 else if (s == 3)
879 {
880 // CPMD - restart
881 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, restart_box(), FALSE, FALSE, 0);
882 }
883
884 /* General CPMD section options: */
885 if (s > 0 && s != 2 && s != 3)
886 {
887 i = (s == 1) ? s : s - 2;
888 str = g_strdup_printf (_("<u>General %s section option(s)</u>"),cpmd_elements[i]);
889 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label(str, 525, -1, 0.0, 0.5), FALSE, FALSE, 10);
890 g_free (str);
892 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, qm_option_box[i-1], FALSE, FALSE, 0);
893 }
894 return vbox;
895}
896
906GtkWidget * qm_preview_box (int c, int s, int l)
907{
908 GtkWidget * vbox = create_vbox (BSEP);
909 GtkWidget * scrollsets = create_scroll (NULL, 250, (c) ? 280 : 410, GTK_SHADOW_ETCHED_IN);
910 GtkWidget * aview = create_text_view (-1, -1, 0, 1, NULL, NULL, NULL);
911 qmbuffer[s] = gtk_text_view_get_buffer (GTK_TEXT_VIEW(aview));
913 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, scrollsets, FALSE, FALSE, l);
914 if (c == 0)
915 {
916 print_the_section (s, 0, qmbuffer[s]);
917 }
918 else
919 {
920 print_cp2k (s, qmbuffer[s]);
921 }
922 return vbox;
923}
924
932gchar * section_name (int p)
933{
934 if (p > 0 && p < 4)
935 {
936 return g_strdup_printf (_("Details of the <b>%s</b> section that %s"), cpmd_elements[1], _(cdescr[1]));
937 }
938 else if (p == 0)
939 {
940 return g_strdup_printf (_("Details of the <b>%s</b> section that %s"), cpmd_elements[p], _(cdescr[p]));
941 }
942 else
943 {
944 return g_strdup_printf (_("Details of the <b>%s</b> section that %s"), cpmd_elements[p-2], _(cdescr[p-2]));
945 }
946}
947
955GtkWidget * vbox_cpmd (int s)
956{
957 GtkWidget * vbox;
958 GtkWidget * hbox;
960 hbox = create_hbox (0);
961 if (s < 2 || s > 3)
962 {
963 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label(section_name(s), -1, 20, 0.0, 0.5), FALSE, FALSE, 20);
964 }
965 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, (s < 2 ||s > 3) ? 5 : 0);
966 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, section_box(s), FALSE, FALSE, 0);
967 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, qm_preview_box (0, s, (s < 2 ||s > 3) ? 0 : 65), FALSE, FALSE, 0);
968 return vbox;
969}
970
978gchar * page_name (int p)
979{
980 if (p > 0 && p <4)
981 {
982 if (p == 1)
983 {
984 return g_strdup_printf (_("The %s section - Calculation options"), cpmd_elements[1]);
985 }
986 else if (p == 2)
987 {
988 return g_strdup_printf (_("The %s section - Thermostat options"), cpmd_elements[1]);
989 }
990 else
991 {
992 return g_strdup_printf (_("The %s section - RESTART options"), cpmd_elements[1]);
993 }
994 }
995 else if (p == 0)
996 {
997 return g_strdup_printf (_("The %s section"), cpmd_elements[p]);
998 }
999 else
1000 {
1001 return g_strdup_printf (_("The %s section"), cpmd_elements[p-2]);
1002 }
1003}
1004
1011{
1012 int i;
1013 gchar * info;
1014 GtkAssistant * assist = GTK_ASSISTANT(qm_assistant);
1015 GtkWidget * page;
1016 for (i=0; i<MAXDATAQM+2; i++)
1017 {
1018 page = vbox_cpmd (i);
1019 gtk_assistant_append_page (assist, page);
1020 gtk_assistant_set_page_title (assist, page, page_name(i));
1021 gtk_assistant_set_page_type (assist, page, GTK_ASSISTANT_PAGE_CONTENT);
1022 if (i != 3)
1023 {
1024 gtk_assistant_set_page_complete (assist, page, TRUE);
1025 }
1026 else
1027 {
1028 gtk_assistant_set_page_complete (assist, page, are_all_atoms_thermostated ());
1029 }
1030 }
1031
1032 GtkWidget * conclu = create_vbox (BSEP);
1033 info = g_strdup_printf (_("<b> Finalize the creation of the CPMD input file now !</b>"));
1034 add_box_child_start (GTK_ORIENTATION_VERTICAL, conclu, markup_label(info, -1, -1, 0.5, 0.5), TRUE, TRUE, 100);
1035 g_free (info);
1036 add_box_child_start (GTK_ORIENTATION_VERTICAL, conclu, markup_label(_("\n \t<b>Note: </b>You can re-open this assitant later if required to adjust your choices\n"), -1, -1, 0.0, 0.5), FALSE, FALSE, 0);
1037 gtk_assistant_append_page (assist, conclu);
1038 gtk_assistant_set_page_title (assist, conclu, _("Create the input file now !"));
1039 gtk_assistant_set_page_type (assist, conclu, GTK_ASSISTANT_PAGE_CONFIRM);
1040 gtk_assistant_set_page_complete (assist, conclu, TRUE);
1041 gtk_assistant_update_buttons_state (assist);
1042}
1043
1050{
1051 int i, j;
1052 for (i=0; i<qm_proj -> natomes; i++)
1053 {
1054 for (j=0; j<2; j++)
1055 {
1056 qm_proj -> atoms[0][i].pick[j] = FALSE;
1057 qm_proj -> atoms[0][i].label[j] = FALSE;
1058 }
1059 }
1060 qm_view -> picked = 0;
1062}
1063
1072G_MODULE_EXPORT void on_qm_assistant_cancel (GtkAssistant * assistant, gpointer data)
1073{
1074 destroy_this_widget (GTK_WIDGET(assistant));
1076 // restore selection if any from calc.c
1078}
1079
1080#ifdef GTK4
1089G_MODULE_EXPORT gboolean on_qm_assistant_cancel_event (GtkWindow * assistant, gpointer data)
1090#else
1100G_MODULE_EXPORT gboolean on_qm_assistant_cancel_event (GtkWidget * assistant, GdkEvent * event, gpointer data)
1101#endif
1102{
1103 on_qm_assistant_cancel (((GtkAssistant *)assistant), data);
1104 return TRUE;
1105}
1106
1115G_MODULE_EXPORT void on_qm_assistant_close (GtkAssistant * assistant, gpointer data)
1116{
1117 // Apply changes ... then close window
1118 destroy_this_widget (GTK_WIDGET(assistant));
1119 // Saving
1120
1121 // Cleaning
1123 // restore selection if any from calc.c
1125}
1126
1135G_MODULE_EXPORT gint on_qm_assistant_go_forward (gint current_page, gpointer data)
1136{
1137 int i = GPOINTER_TO_INT(data);
1138 if (i == 0)
1139 {
1140 switch (current_page)
1141 {
1142 case MAXDATAQM+4:
1143 return -1;
1144 break;
1145 case 2:
1146 if (tmp_cpmd -> calc_type == 2 || tmp_cpmd -> calc_type == 3)
1147 {
1148 return 3;
1149 }
1150 else
1151 {
1152 return 4;
1153 }
1154 break;
1155 case 5:
1156 if ((int)tmp_cpmd -> default_opts[2])
1157 {
1158 return current_page+1;
1159 }
1160 else if (tmp_cpmd -> calc_type == 6)
1161 {
1162 return current_page+2;
1163 }
1164 else
1165 {
1166 return current_page+3;
1167 }
1168 break;
1169 case 6:
1170 if (tmp_cpmd -> calc_type == 6)
1171 {
1172 return current_page+1;
1173 }
1174 else
1175 {
1176 return current_page+2;
1177 }
1178 default:
1179 return current_page+1;
1180 break;
1181 }
1182 }
1183 else
1184 {
1185 switch (current_page)
1186 {
1187 case MAXDATAQM+4:
1188 return -1;
1189 break;
1190 default:
1191 return current_page+1;
1192 break;
1193 }
1194 }
1195}
1196
1206G_MODULE_EXPORT void on_qm_assistant_prepare (GtkAssistant * assistant, GtkWidget * page, gpointer data)
1207{
1208 int i = gtk_assistant_get_current_page (assistant);
1209 // field_unselect_all ();
1210 switch (i)
1211 {
1212 case 0:
1214 break;
1215 default:
1217 break;
1218 }
1219}
1220
1230gboolean go_for_it (int i, int j, gboolean print[2])
1231{
1232 if (tmp_cp2k -> input_type && i<=j-3) return TRUE;
1233 if (i==0) return TRUE;
1234 if (i==j-2 && print[0]) return TRUE;
1235 if (i==j-1 && print[1]) return TRUE;
1236 return FALSE;
1237}
1238
1247G_MODULE_EXPORT void show_qm_file_preview (GtkButton * but, gpointer data)
1248{
1249 int i, j, k, l, c;
1250 c = GPOINTER_TO_INT(data);
1251 gchar * ptitle[5] = {i18n("CP2K input file"),
1252 "forces.inc", "system.inc", "motion.inc", "coord.inc"};
1253 gchar * wtite[2] = {i18n(" input file preview"), i18n(" input files preview")};
1254 gchar * str;
1255 GtkWidget * scrollsets;
1256 GtkWidget * aview;
1257 GtkWidget * notebook;
1258 k = 0;
1259 gboolean print[2];
1260 if (c)
1261 {
1262 j = 6;
1263 notebook = gtk_notebook_new ();
1264 if (tmp_cp2k -> opts[CP2RUN] > 1.0 && tmp_cp2k -> opts[CP2RUN] < 4.0) k = 1;
1265 str = g_strdup_printf ("%s %s", co_type[c], _(wtite[tmp_cp2k -> input_type]));
1266 print[0] = print[1] = FALSE;
1267 for (i=0; i<qm_proj -> nspec; i++)
1268 {
1269 if (tmp_cp2k -> spec_data[i][0] != -1)
1270 {
1271 print[0] = TRUE;
1272 break;
1273 }
1274 }
1275 for (i=0; i<qm_proj -> nspec; i++)
1276 {
1277 if (tmp_cp2k -> spec_data[i][1] != -1)
1278 {
1279 print[1] = TRUE;
1280 break;
1281 }
1282 }
1283 }
1284 else
1285 {
1286 j = 1;
1287 str = g_strdup_printf ("%s %s", co_type[c], _(wtite[0]));
1288 }
1289 GtkWidget * preview = dialogmodal (str, GTK_WINDOW (qm_assistant));
1290 g_free (str);
1291 if (c)
1292 {
1293 add_box_child_start (GTK_ORIENTATION_VERTICAL, dialog_get_content_area(preview), notebook, FALSE, FALSE, 0);
1294 }
1295 else
1296 {
1297 scrollsets = create_scroll (dialog_get_content_area(preview), 700, 350, GTK_SHADOW_ETCHED_IN);
1298 }
1299 for (i=0; i<j+k; i++)
1300 {
1301 if (! c || (c && go_for_it(i, j+k, print)))
1302 {
1303 aview = create_text_view (-1, -1, 0, 1, NULL, NULL, NULL);
1304 if (c)
1305 {
1306 scrollsets = create_scroll (NULL, 700, 350, GTK_SHADOW_ETCHED_IN);
1308 if (i > j+k-3)
1309 {
1310 str = g_strdup_printf ("%s", tmp_cp2k -> files[i-(j+k-3)]);
1311 }
1312 else
1313 {
1314 l = (i == j-3+k) ? 4 : i;
1315 str = g_strdup_printf ("%s", (l) ? ptitle[l] : _(ptitle[l]));
1316 }
1317 gtk_notebook_append_page (GTK_NOTEBOOK(notebook), scrollsets, gtk_label_new (str));
1318 g_free (str);
1319 }
1320 else
1321 {
1323 }
1324 }
1325 if (c)
1326 {
1327 if (tmp_cp2k -> input_type || i != j+k-3)
1328 {
1329 print_cp2k ((i >= j+k-3) ? i+1-k: i, gtk_text_view_get_buffer(GTK_TEXT_VIEW(aview)));
1330 }
1331 }
1332 else
1333 {
1334 print_all_sections (gtk_text_view_get_buffer(GTK_TEXT_VIEW(aview)));
1335 }
1336 }
1337 run_this_gtk_dialog (preview, G_CALLBACK(run_destroy_dialog), NULL);
1338}
1339
1340#ifdef GTK4
1350G_MODULE_EXPORT void run_saving_qm (GtkNativeDialog * info, gint response_id, gpointer data)
1351{
1352 GtkFileChooser * chooser = GTK_FILE_CHOOSER((GtkFileChooserNative *)info);
1353#else
1363G_MODULE_EXPORT void run_saving_qm (GtkDialog * info, gint response_id, gpointer data)
1364{
1365 GtkFileChooser * chooser = GTK_FILE_CHOOSER((GtkWidget *)info);
1366#endif
1367 int i, j, k, l;
1368 int c = GPOINTER_TO_INT(data);
1369 gboolean result = FALSE;
1370 gboolean done = FALSE;
1371 GtkTextBuffer * buffer = NULL;
1372 GtkTextIter bStart;
1373 GtkTextIter bEnd;
1374 GError * err = NULL;
1375 gchar * text;
1376 gchar * filename;
1377 gchar * direname;
1378 gchar * cp2sp[2] = {"basis.inc", "pseudo.inc"};
1379 gchar * cp2file[4] = {"forces.inc", "system.inc", "motion.inc", "coord.inc"};
1380 switch (response_id)
1381 {
1382 case GTK_RESPONSE_ACCEPT:
1383 filename = file_chooser_get_file_name (chooser);
1384 direname = file_chooser_get_current_folder (chooser);
1385 if (filename != NULL)
1386 {
1387 done = TRUE;
1388 if (! c || (c && ! tmp_cp2k -> input_type)) buffer = add_buffer (NULL, NULL, NULL);
1389 switch (c)
1390 {
1391 case 0:
1392 print_all_sections (buffer);
1393 break;
1394 case 1:
1395 j = 6;
1396 k = 0;
1397 if (tmp_cp2k -> opts[CP2RUN] > 1.0 && tmp_cp2k -> opts[CP2RUN] < 4.0) k = 1;
1398 for (i=0; i<j+k; i++)
1399 {
1400 if (i != j+k-3 || tmp_cp2k -> input_type)
1401 {
1402 l = (i >= j+k-3) ? i+1-k: i;
1403 if (tmp_cp2k -> input_type)
1404 {
1405 buffer = add_buffer (NULL, NULL, NULL);
1406 if (i > 0) filename = g_strdup_printf ("%s/%s", direname, cp2file[l-1]);
1407 print_cp2k (l, buffer);
1408 gtk_text_buffer_get_start_iter (buffer, & bStart);
1409 gtk_text_buffer_get_end_iter (buffer, & bEnd);
1410 text = gtk_text_buffer_get_text (buffer, & bStart, & bEnd, FALSE);
1411 gtk_text_buffer_set_modified (buffer, FALSE);
1412 result = g_file_set_contents (filename, text, -1, & err);
1413 g_free (text);
1414 g_object_unref (buffer);
1415 if (! result && err)
1416 {
1417 show_error (g_strdup_printf (_("Error while saving input file: %s\n Error: %s"), filename, err -> message), 0, qm_assistant);
1418 g_error_free (err);
1419 }
1420 g_free (filename);
1421 }
1422 else if (l != 5 && l != 6)
1423 {
1424 print_cp2k (l, buffer);
1425 }
1426 }
1427 }
1428 break;
1429 }
1430 if (! c || (c && ! tmp_cp2k -> input_type))
1431 {
1432 gtk_text_buffer_get_start_iter (buffer, & bStart);
1433 gtk_text_buffer_get_end_iter (buffer, & bEnd);
1434 text = gtk_text_buffer_get_text (buffer, & bStart, & bEnd, FALSE);
1435 gtk_text_buffer_set_modified (buffer, FALSE);
1436 result = g_file_set_contents (filename, text, -1, & err);
1437 g_free (text);
1438 g_object_unref (buffer);
1439 if (! result && err)
1440 {
1441 /* error saving file, show message to user */
1442 show_error (g_strdup_printf (_("Error while saving input file: %s\n Error: %s"), filename, err -> message), 0, qm_assistant);
1443 g_error_free (err);
1444 }
1445 g_free (filename);
1446 }
1447 if (c)
1448 {
1449 // save pseudo and basis auto
1450 for (i=0; i<2; i++)
1451 {
1452 buffer = add_buffer (NULL, NULL, NULL);
1453 filename = g_strdup_printf ("%s/%s", direname, cp2sp[i]);
1454 print_cp2k (i+5, buffer);
1455 gtk_text_buffer_get_start_iter (buffer, & bStart);
1456 gtk_text_buffer_get_end_iter (buffer, & bEnd);
1457 text = gtk_text_buffer_get_text (buffer, & bStart, & bEnd, FALSE);
1458 result = g_file_set_contents (filename, text, -1, & err);
1459 g_free (text);
1460 if (! result && err)
1461 {
1462 /* error saving file, show message to user */
1463 show_error (g_strdup_printf (_("Error while saving file %s: %s"), cp2sp[i], err -> message), 0, qm_assistant);
1464 g_error_free (err);
1465 break;
1466 }
1467 g_free (filename);
1468 g_object_unref (buffer);
1469 }
1470 }
1471 }
1472 break;
1473 default:
1474 done = TRUE;
1475 break;
1476 }
1477 if (done)
1478 {
1479#ifdef GTK4
1481#else
1482 destroy_this_dialog (info);
1483#endif
1484 }
1485 if (c && result)
1486 {
1487 if (tmp_cp2k -> input_type)
1488 {
1489 if (tmp_cp2k -> opts[CP2RUN] > 1.0 && tmp_cp2k -> opts[CP2RUN] < 4.0)
1490 {
1491 show_info (_("The input files 'forces.inc', 'system.inc', 'motion.inc' and 'coord.inc'\n"
1492 "as well as the files 'basis.inc' and 'pseudo.inc'\n"
1493 "for the atomic basis set and peudo-potentials\n"
1494 "were saved in the same directory as the main input file."),
1495 0, qm_assistant);
1496 }
1497 else
1498 {
1499 show_info (_("The input files 'forces.inc', 'system.inc', and 'coord.inc'\n"
1500 "as well as the files 'basis.inc' and 'pseudo.inc'\n"
1501 "for the atomic basis set and peudo-potentials\n"
1502 "were saved in the same directory as the main input file."),
1503 0, qm_assistant);
1504 }
1505 }
1506 else
1507 {
1508 show_info (_("The files 'basis.inc' and 'pseudo.inc'\n"
1509 "for the atomic basis set and peudo-potentials\n"
1510 "were saved in the same directory as the main input file."),
1511 0, qm_assistant);
1512 }
1513 }
1514}
1515
1524G_MODULE_EXPORT void on_qm_assistant_apply (GtkAssistant * assistant, gpointer data)
1525{
1526 int c = GPOINTER_TO_INT(data);
1527 gchar * text;
1528#ifdef GTK4
1529 GtkFileChooserNative * info;
1530#else
1531 GtkWidget * info;
1532#endif
1533 GtkFileFilter * filter1, * filter2;
1534 gchar * qm_type[2] = {"CPMD", "CP2K"};
1535 const gchar * qm_name[2] = {i18n("CPMD input file (*.in)"), i18n("CP2K input file (*.inp)")};
1536 const gchar * qm_ext[2] = {".in", ".inp"};
1537
1538 text = g_strdup_printf (_("Saving %s input file(s)"), qm_type[c]);
1539 info = create_file_chooser (text,
1540 GTK_WINDOW(assistant),
1541 GTK_FILE_CHOOSER_ACTION_SAVE,
1542 _("Save"));
1543 GtkFileChooser * chooser = GTK_FILE_CHOOSER(info);
1544 g_free (text);
1545#ifdef GTK3
1546 gtk_file_chooser_set_do_overwrite_confirmation (chooser, TRUE);
1547#endif
1549 filter1 = gtk_file_filter_new();
1550 gtk_file_filter_set_name (GTK_FILE_FILTER(filter1), _(qm_name[c]));
1551 text = g_strdup_printf ("*%s", qm_ext[c]);
1552 gtk_file_filter_add_pattern (GTK_FILE_FILTER(filter1), text);
1553 g_free (text);
1554 gtk_file_chooser_add_filter (chooser, filter1);
1555 filter2 = gtk_file_filter_new();
1556 gtk_file_filter_set_name (GTK_FILE_FILTER(filter2), _("All files (*)"));
1557 gtk_file_filter_add_pattern (GTK_FILE_FILTER(filter2), "*");
1558 gtk_file_chooser_add_filter (chooser, filter2);
1559 text = g_strdup_printf ("%s%s", prepare_for_title(qm_proj -> name), qm_ext[c]);
1561 gtk_file_chooser_set_current_name (chooser, text);
1562 g_free (text);
1563#ifdef GTK4
1564 run_this_gtk_native_dialog ((GtkNativeDialog *)info, G_CALLBACK(run_saving_qm), NULL);
1565#else
1566 run_this_gtk_dialog (info, G_CALLBACK(run_saving_qm), data);
1567#endif
1568}
1569
1579void create_qm_input_file (int c, int p, int s)
1580{
1581 gchar * qm_type[2] = {i18n("first-principles"), "QM-MM"};
1582 qm_assistant = gtk_assistant_new ();
1583 gtk_widget_set_size_request (qm_assistant, 800, 600);
1584 int i, j;
1585 //field_color = TRUE;
1586 field_object = -1;
1587 //selected_aspec = -1;
1590 for (i=0; i<MAXDATAQM+2; i++) qmbuffer[i] = NULL;
1591 if (c == 0)
1592 {
1593 is_cpmd = TRUE;
1594 if (qm_proj -> cpmd_input[s] == NULL)
1595 {
1596 qm_proj -> cpmd_input[s] = g_malloc0(sizeof*qm_proj -> cpmd_input[s]);
1597 qm_proj -> cpmd_input[s] -> calc_type = 0;
1598 qm_proj -> cpmd_input[s] -> thermostats = 0;
1599 qm_proj -> cpmd_input[s] -> ions_thermostat = NULL;
1600 qm_proj -> cpmd_input[s] -> elec_thermostat = NULL;
1601 qm_proj -> cpmd_input[s] -> dummies = 0;
1602 qm_proj -> cpmd_input[s] -> dummy = NULL;
1603 qm_proj -> cpmd_input[s] -> fixat = 0;
1604 qm_proj -> cpmd_input[s] -> fixlist = NULL;
1605 qm_proj -> cpmd_input[s] -> fixcoord = NULL;
1606 qm_proj -> cpmd_input[s] -> restart[0] = 0;
1607 qm_proj -> cpmd_input[s] -> restart[1] = 100;
1608 qm_proj -> cpmd_input[s] -> restart[2] = 2;
1609 qm_proj -> cpmd_input[s] -> restart[3] = 0;
1610 qm_proj -> cpmd_input[s] -> restart[4] = 1;
1611 for (i=5; i<9; i++) qm_proj -> cpmd_input[s] -> restart[i] = 0;
1612 qm_proj -> cpmd_input[s] -> restart[9] = 0;
1613 for (i=0; i<17; i++) qm_proj -> cpmd_input[s] -> default_opts[i] = default_cpmd_options[i];
1614 for (i=0; i<24; i++) qm_proj -> cpmd_input[s] -> calc_opts[i] = default_calc_options[i];
1615 qm_proj -> cpmd_input[s] -> pp = allocdint (qm_proj -> nspec, 2);
1616 for (i=0; i<qm_proj -> nspec; i++) qm_proj -> cpmd_input[s] -> pp[i][0] = qm_proj -> cpmd_input[s] -> pp[i][1] = 1;
1617 qm_proj -> cpmd_input[s] -> info = g_strdup_printf (_(" Project name: %s\n"
1618 " Total number of atoms: %d\n"
1619 " Number of chemical species: %d"),
1620 prepare_for_title(qm_proj -> name), qm_proj -> natomes, qm_proj -> nspec);
1621 }
1622 tmp_cpmd = qm_proj -> cpmd_input[s];
1623 }
1624 else
1625 {
1626 is_cpmd = FALSE;
1627 if (qm_proj -> cp2k_input[s] == NULL)
1628 {
1629 qm_proj -> cp2k_input[s] = g_malloc0(sizeof*qm_proj -> cp2k_input[s]);
1630 qm_proj -> cp2k_input[s] -> input_type = 0;
1631 for (i=0; i<2; i++)
1632 {
1633 qm_proj -> cp2k_input[s] -> fixat[i] = 0;
1634 qm_proj -> cp2k_input[s] -> fixlist[i] = NULL;
1635 qm_proj -> cp2k_input[s] -> fixcoord[i] = NULL;
1636 }
1637 qm_proj -> cp2k_input[s] -> thermostats = 0;
1638 qm_proj -> cp2k_input[s] -> ions_thermostat = NULL;
1639 for (i=0; i<5; i++) qm_proj -> cp2k_input[s] -> files[i] = NULL;
1640 for (i=0; i<41; i++) qm_proj -> cp2k_input[s] -> opts[i] = default_cp2k_options[i];
1641 qm_proj -> cp2k_input[s] -> opts[CP2SYM] = find_cp2k_sym ();
1642 for (i=0; i<3; i++)
1643 {
1644 for (j=0;j<4;j++) qm_proj -> cp2k_input[s] -> extra_opts[i][j] = default_cp2k_extra[i][j];
1645 if (i == 0) qm_proj -> cp2k_input[s] -> extra_opts[i][2] = default_vdw_cut[0];
1646 }
1647 qm_proj -> cp2k_input[s] -> spec_data = allocdint (qm_proj -> nspec, 2);
1648 qm_proj -> cp2k_input[s] -> spec_files = g_malloc0(qm_proj -> nspec*sizeof*qm_proj -> cp2k_input[s] -> spec_files);
1649 for (i=0; i<qm_proj -> nspec; i++)
1650 {
1651 qm_proj -> cp2k_input[s] -> spec_data[i][0] = cp2k_is_basis_in_database (i);
1652 qm_proj -> cp2k_input[s] -> spec_data[i][1] = cp2k_is_pseudo_in_database (i);
1653 qm_proj -> cp2k_input[s] -> spec_files[i] = g_malloc0(2*sizeof*qm_proj -> cp2k_input[s] -> spec_files[i]);
1654 qm_proj -> cp2k_input[s] -> spec_files[i][0] = NULL;
1655 qm_proj -> cp2k_input[s] -> spec_files[i][1] = NULL;
1656 }
1657 gchar * defname[2]={"basis.inc", "pseudo.inc"};
1658 for (j=0;j<2;j++)
1659 {
1660 for (i=0; i<qm_proj -> nspec; i++)
1661 {
1662 if (qm_proj -> cp2k_input[s] -> spec_data[i][j] > -1)
1663 {
1664 qm_proj -> cp2k_input[s] -> files[1+j] = g_strdup_printf ("%s", defname[j]);
1665 break;
1666 }
1667 }
1668 }
1669 qm_proj -> cp2k_input[s] -> info = g_strdup_printf (_(" Project name: %s\n"
1670 " Total number of atoms: %d\n"
1671 " Number of chemical species: %d"),
1672 prepare_for_title(qm_proj -> name), qm_proj -> natomes, qm_proj -> nspec);
1673 }
1674 tmp_cp2k = qm_proj -> cp2k_input[s];
1675 }
1676 qm_coord = qm_proj -> coord;
1677 qm_view = qm_proj -> modelgl;
1678
1679 gtk_window_set_resizable (GTK_WINDOW (qm_assistant), FALSE);
1680 gtk_window_set_modal (GTK_WINDOW (qm_assistant), TRUE);
1681 gchar * str = g_strdup_printf (_("Basic %s - %s - calculation assistant"), co_type[c], (s) ? qm_type[s] : _(qm_type[s]));
1682 gtk_window_set_title (GTK_WINDOW(qm_assistant), str);
1683 g_free (str);
1684
1685 GtkWidget * intro = create_vbox (BSEP);
1686 gchar * info = g_strdup_printf (_("\t<b>This assistant will help you to setup a %s %s\n"
1687 "\tcalculation using <i>%s</i> 3D model as starting point</b>\n"
1688 "\nPlease note that the %s code offers so many calculation options that it is not possible\n"
1689 "to provide a description and offer a comprehensive usage guide for each of them. \n"
1690 "Therefore this assistant only provides help towards basics and / or frequently used %s instructions. \n\n"
1691 "<b>In any case if you intent to use the %s code please refer to the user manual.</b>"),
1692 (s) ? qm_type[s] : _(qm_type[s]), co_type[c], qm_proj -> name, co_type[c], co_type[c], co_type[c]);
1693 add_box_child_start (GTK_ORIENTATION_VERTICAL, intro, markup_label(info, -1, -1, 0.5, 0.5), TRUE, TRUE, 50);
1694 g_free (info);
1695
1696 add_box_child_start (GTK_ORIENTATION_VERTICAL, intro,
1697 markup_label(_("\n \t<b>Note: </b>You can re-open this assistant later if required to adjust your choices\n"), -1, -1, 0.0, 0.5),
1698 FALSE, FALSE, 0);
1699 gtk_assistant_append_page (GTK_ASSISTANT (qm_assistant), intro);
1700 str = g_strdup_printf ("%s calculation set-up", co_type[c]);
1701 gtk_assistant_set_page_title (GTK_ASSISTANT (qm_assistant), intro, str);
1702 g_free (str);
1703 gtk_assistant_set_page_type (GTK_ASSISTANT (qm_assistant), intro, GTK_ASSISTANT_PAGE_INTRO);
1704 gtk_assistant_set_page_complete (GTK_ASSISTANT (qm_assistant), intro, qm_assist_init);
1705 if (c == 0)
1706 {
1707 add_cpmd_pages ();
1708 }
1709 else
1710 {
1711 add_cp2k_pages ();
1712 }
1713 gtk_assistant_set_forward_page_func (GTK_ASSISTANT (qm_assistant), on_qm_assistant_go_forward, GINT_TO_POINTER(c), NULL);
1714 qm_preview_but = create_button (_("Preview"), IMG_STOCK, EDITF, -1, -1, GTK_RELIEF_NORMAL, G_CALLBACK(show_qm_file_preview), GINT_TO_POINTER(c));
1715 gtk_assistant_add_action_widget (GTK_ASSISTANT (qm_assistant), qm_preview_but);
1716 g_signal_connect (G_OBJECT (qm_assistant), "prepare", G_CALLBACK(on_qm_assistant_prepare), GINT_TO_POINTER(c));
1717 g_signal_connect (G_OBJECT (qm_assistant), "cancel", G_CALLBACK(on_qm_assistant_cancel), GINT_TO_POINTER(c));
1718 g_signal_connect (G_OBJECT (qm_assistant), "close", G_CALLBACK(on_qm_assistant_close), GINT_TO_POINTER(c));
1719 g_signal_connect (G_OBJECT (qm_assistant), "apply", G_CALLBACK(on_qm_assistant_apply), GINT_TO_POINTER(c));
1720 add_gtk_close_event (qm_assistant, G_CALLBACK(on_qm_assistant_cancel_event), GINT_TO_POINTER(c));
1721
1722 gtk_assistant_set_page_complete (GTK_ASSISTANT (qm_assistant),
1723 gtk_assistant_get_nth_page(GTK_ASSISTANT (qm_assistant), 0), TRUE);
1726 if (c == 0)
1727 {
1728 for (i=0; i<NCPMDCALC; i++) hide_the_widgets (calc_box[i]);
1729 show_the_widgets (calc_box[tmp_cpmd -> calc_type]);
1730 if (tmp_cpmd -> calc_type != 2) hide_the_widgets (electron_box);
1731 }
1733}
1734
GtkTextBuffer * qmbuffer[MAXDATAQM+2]
Definition calc.c:70
#define MAXDATAQM
Definition calc.c:55
int ident
Definition calc.c:74
GtkWidget * qm_assistant
Definition calc.c:66
int idopt
Definition calc.c:72
glwin * qm_view
Definition calc.c:68
project * qm_proj
Definition calc.c:67
int icomb
Definition calc.c:75
int icalc
Definition calc.c:73
coord_info * qm_coord
Definition calc.c:69
Variable declarations for the MD input preparation assistants.
Callback declarations for main window.
integer(kind=c_int) function chemistry()
Definition chemistry.F90:22
Variable declarations for the creation of the CP2K input file(s).
int cp2k_is_pseudo_in_database(int sp)
does this chemical species have pseudopotential(s) in store ?
Definition cp2k_files.c:221
double default_cp2k_extra[3][4]
Definition cp2k_init.c:95
#define CP2RUN
Definition cp2k.h:43
int cp2k_is_basis_in_database(int sp)
does this chemical species have basis set(s) in store ?
Definition cp2k_files.c:196
int find_cp2k_sym()
find the CP2K symmetry parameter based on the cell properties
Definition cp2k_init.c:1245
double default_vdw_cut[2]
Definition cp2k_init.c:94
double default_cp2k_options[41]
Definition cp2k_init.c:88
#define CP2SYM
Definition cp2k.h:73
cp2k * tmp_cp2k
Definition cp2k_init.c:86
GtkWidget * qm_preview_box(int c, int s, int l)
prepare preview section widgets
Definition cpmd_init.c:906
Variable declarations for the creation of the CPMD input file.
#define NSECOP
Definition cpmd.h:37
#define DEFFI
Definition cpmd.h:50
double default_calc_options[24]
Definition cpmd_init.c:163
#define DEFLO
Definition cpmd.h:54
#define CONVO
Definition cpmd.h:56
#define TSTPO
Definition cpmd.h:59
int type_thermo[2]
Definition cpmd_init.c:218
gchar * thermo_name[2][5]
Definition cpmd_init.c:215
gboolean is_cpmd
Definition cpmd_init.c:231
#define CONVG
Definition cpmd.h:60
#define NCACOMBO
Definition cpmd.h:32
gchar * calc_ds[NCPMDCALC]
Definition cpmd_init.c:192
gchar * default_text[9][NDFT]
Definition cpmd_init.c:150
#define STEPO
Definition cpmd.h:58
#define STEPG
Definition cpmd.h:62
gchar * calc_box_name[NCACOMBO][3]
Definition cpmd_init.c:202
#define DEFDU
Definition cpmd.h:51
#define DEFSP
Definition cpmd.h:52
#define TSTPB
Definition cpmd.h:75
gchar * cdescr[MAXDATAQM]
Definition cpmd_init.c:113
cpmd * tmp_cpmd
Definition cpmd_init.c:103
#define DEFCU
Definition cpmd.h:48
#define DEFDG
Definition cpmd.h:47
int num_thermo[2]
Definition cpmd_init.c:217
#define TSTPG
Definition cpmd.h:66
#define AFAIB
Definition cpmd.h:78
double default_cpmd_options[17]
Definition cpmd_init.c:121
gchar * calc_opts[NCPMDCALC][NOPTPC]
#define NBAND
Definition cpmd.h:81
#define NCPMDCALC
Definition cpmd.h:31
#define DEFGC
Definition cpmd.h:42
#define DEFSY
Definition cpmd.h:45
#define NDFT
Definition cpmd.h:33
int defaut_num[9]
Definition cpmd_init.c:138
int calc_box_num[NCACOMBO]
Definition cpmd_init.c:200
#define TSTPC
Definition cpmd.h:68
gchar * default_keywords[9][NDFT]
Definition cpmd_init.c:140
gchar * cpmd_elements[MAXDATAQM]
Definition cpmd_init.c:105
#define DEFLM
Definition cpmd.h:53
#define DEFEM
Definition cpmd.h:38
int default_opts_type[MAXDATAQM-1][NSECOP]
Definition cpmd_init.c:131
gchar * default_opts[MAXDATAQM-1][NSECOP]
Definition cpmd_init.c:123
#define NSYM
Definition cpmd.h:34
#define ANNIB
Definition cpmd.h:77
#define AFAEC
Definition cpmd.h:73
#define AFAIC
Definition cpmd.h:71
int default_type[NCPMDCALC][NOPTPC]
Definition cpmd_init.c:176
#define KSUNO
Definition cpmd.h:79
#define DEFCO
Definition cpmd.h:49
gchar * calc_kw[NCPMDCALC]
Definition cpmd_init.c:184
GtkWidget * sel_but[3]
Definition cpmd_nose.c:137
#define STEPC
Definition cpmd.h:67
#define NOPTPC
Definition cpmd.h:35
gchar * nosetype[3]
Definition cpmd_init.c:214
#define DEFVE
Definition cpmd.h:44
#define STEPB
Definition cpmd.h:74
#define ANNIC
Definition cpmd.h:70
#define DEFAB
Definition cpmd.h:46
#define ANNEC
Definition cpmd.h:72
gchar * calc_box_keys[NCACOMBO][3]
Definition cpmd_init.c:208
dummy_atom * dummy
Definition cpmd_atoms.c:73
void print_the_section(int s, int p, GtkTextBuffer *buffer)
print CPMD input section
Definition cpmd_print.c:697
G_MODULE_EXPORT void atom_button(GtkWidget *but, gpointer data)
CPMD input file, add constraint(s) or dummy atom(s) - creating the dialog.
Definition cpmd_atoms.c:603
G_MODULE_EXPORT void changed_opt_box(GtkComboBox *box, gpointer data)
change CPMD QM option
Definition cpmd_init.c:366
GtkWidget * calc_qm_option_box(int c)
CPMD input assistant prepare the calculation option widgets.
Definition cpmd_init.c:669
void print_cp2k(int f, GtkTextBuffer *buffer)
print the CP2K input file section
GtkWidget * qm_option_box[MAXDATAQM-1]
Definition cpmd_init.c:230
void field_unselect_all()
unselect all atoms
Definition dlp_viz.c:130
G_MODULE_EXPORT void update_calc_check(GtkToggleButton *but, gpointer data)
update CPMD calculation option toggle callback GTK3
Definition cpmd_init.c:654
GtkWidget * info_box()
create CPMD input file information widgets
Definition cpmd_init.c:813
GtkWidget * prepare_qm_option_box(int s)
CPM input file creation prepare section general options widgets.
Definition cpmd_init.c:421
gchar * cpmd_calc_opts[NCPMDCALC][NOPTPC]
Definition cpmd_init.c:169
GtkWidget * section_box(int s)
create CPMD section box
Definition cpmd_init.c:834
G_MODULE_EXPORT void changed_calc_opt_box(GtkComboBox *box, gpointer data)
change CPMD calculation option
Definition cpmd_init.c:623
GtkWidget * cpmd_box(GtkWidget *box, gchar *lab, int v_space, int h_space, int dim)
prepare a labelled box widget for the CPMD input creation assistant
Definition cpmd_init.c:244
GtkWidget * electron_box
Definition cpmd_nose.c:139
gboolean qm_assist_init
Definition cpmd_init.c:222
G_MODULE_EXPORT void changed_info(GtkTextBuffer *textbuf, gpointer data)
update CPMD input file preview
Definition cpmd_init.c:797
GtkWidget * calc_combo
Definition cpmd_init.c:221
G_MODULE_EXPORT void on_qm_assistant_cancel(GtkAssistant *assistant, gpointer data)
cancel QM / QM-MM input file creation
Definition cpmd_init.c:1072
gchar * page_name(int p)
get CPMD input creation assistant page name
Definition cpmd_init.c:978
gchar * co_type[2]
Definition cpmd_init.c:101
GtkWidget * ppbox[2]
Definition cpmd_init.c:228
gboolean are_all_atoms_thermostated()
are all atom(s) in the model thermostated ?
Definition cpmd_nose.c:198
void create_selection_combo(int id, int num, int type, GCallback handler)
create thermostat selection combo box
Definition cpmd_nose.c:1506
G_MODULE_EXPORT gint on_qm_assistant_go_forward(gint current_page, gpointer data)
QM / QM-MM assistant go to the next page.
Definition cpmd_init.c:1135
G_MODULE_EXPORT void update_cpmd_check(GtkToggleButton *but, gpointer data)
update CPMD QM option toggle callback GTK3
Definition cpmd_init.c:345
void add_cp2k_pages()
add pages to the CP2 assistant
Definition cp2k_init.c:1199
G_MODULE_EXPORT void changed_calc_box(GtkComboBox *box, gpointer data)
change CPMD calculation type
Definition cpmd_init.c:766
G_MODULE_EXPORT void run_saving_qm(GtkDialog *info, gint response_id, gpointer data)
apply QM / QM-MM assistant and create input file(s) - running the dialog GTK3
Definition cpmd_init.c:1363
G_MODULE_EXPORT void show_qm_file_preview(GtkButton *but, gpointer data)
show QM / QM-MM input file preview
Definition cpmd_init.c:1247
GtkWidget * restart_box()
prepare the CPMD input preparation assistant restart widgets
ColRGBA init_color(int id, int numid)
initialize color based id number over total number of elements
Definition initcoord.c:81
gchar * section_name(int p)
get CPMD input creation section name
Definition cpmd_init.c:932
void print_the_section(int s, int p, GtkTextBuffer *buffer)
print CPMD input section
Definition cpmd_print.c:697
GtkWidget * latbox
Definition cpmd_init.c:225
GtkWidget * qm_preview_box(int c, int s, int l)
prepare preview section widgets
Definition cpmd_init.c:906
int qm_saved_label_format[2]
Definition cpmd_init.c:223
GtkWidget * calc_box[NCPMDCALC]
Definition cpmd_init.c:229
GtkWidget * vbox_cpmd(int s)
create CPMD input creation section widgets
Definition cpmd_init.c:955
GtkWidget * qm_preview_but
Definition cpmd_init.c:220
void restore_ogl_selection(glwin *view)
restore a saved atom selection
Definition calc.c:218
G_MODULE_EXPORT gboolean on_qm_assistant_cancel_event(GtkWidget *assistant, GdkEvent *event, gpointer data)
QM / QM-MM input file creation cancel event GTK3.
Definition cpmd_init.c:1100
void proj_unselect_all_atoms()
unselect all atom(s) in the target project of the assistant
Definition cpmd_init.c:1049
G_MODULE_EXPORT void on_qm_assistant_apply(GtkAssistant *assistant, gpointer data)
apply QM / QM-MM assistant and create input file(s) - creating the dialog
Definition cpmd_init.c:1524
G_MODULE_EXPORT void update_calc_parameter(GtkEntry *res, gpointer data)
update CPMD calculation option value entry callback
Definition cpmd_init.c:588
void print_all_sections(GtkTextBuffer *buf)
print all sections of the CPMD input file
Definition cpmd_init.c:259
GtkWidget * but_at[2]
Definition cpmd_init.c:226
void create_qm_input_file(int c, int p, int s)
initialize an ab-initio MD input file creation assistant
Definition cpmd_init.c:1579
GtkWidget * calc_label
Definition cpmd_init.c:224
GtkWidget * thermo_box()
create the thermostat configuration widgets
Definition cpmd_nose.c:1891
G_MODULE_EXPORT void on_qm_assistant_close(GtkAssistant *assistant, gpointer data)
close QM / QM-MM input creation assistant
Definition cpmd_init.c:1115
void init_thermos()
G_MODULE_EXPORT void on_qm_assistant_prepare(GtkAssistant *assistant, GtkWidget *page, gpointer data)
prepare QM / QM-MM assistant pages before display
Definition cpmd_init.c:1206
G_MODULE_EXPORT void changed_opt_box(GtkComboBox *box, gpointer data)
change CPMD QM option
Definition cpmd_init.c:366
void add_cpmd_pages()
add pages to the CPMD input file creation assistant
Definition cpmd_init.c:1010
GtkWidget * spatbox
Definition cpmd_init.c:227
gboolean go_for_it(int i, int j, gboolean print[2])
add tab to the QM / QM-MM file preview window notebook
Definition cpmd_init.c:1230
G_MODULE_EXPORT void update_cpmd_parameter(GtkEntry *res, gpointer data)
update CPMD QM option value entry callback
Definition cpmd_init.c:308
G_MODULE_EXPORT void atom_button(GtkButton *but, gpointer data)
int atoms[NUM_STYLES][2]
gchar * text
Definition datab.c:105
void init_default_shaders(glwin *view)
re-initialize the default OpenGL shaders
int field_object
Definition dlp_field.c:1069
GtkWidget * aview
Definition dlp_field.c:1060
int ** allocdint(int xal, int yal)
allocate an int ** pointer
Definition global.c:317
#define i18n(String)
Definition global.c:80
double string_to_double(gpointer string)
convert string to double
Definition global.c:611
Global variable declarations Global convenience function declarations Global data structure defin...
#define EDITF
Definition global.h:220
void run_this_gtk_dialog(GtkWidget *dial, GCallback handler, gpointer data)
run a GTK (3 and 4) basic GtkDialog
Definition gtk-misc.c:533
@ IMG_NONE
Definition global.h:276
@ IMG_STOCK
Definition global.h:280
void file_chooser_set_current_folder(GtkFileChooser *chooser)
set current folder in a GtkFilechooser
Definition gtk-misc.c:2358
int combo_get_active(GtkWidget *combo)
retrieve the active item's position
Definition gtk-misc.c:935
GtkWidget * create_entry(GCallback handler, int dim, int cdim, gboolean key_release, gpointer data)
Create a GtkEntry.
Definition gtk-misc.c:1401
void update_entry_double(GtkEntry *entry, double doubleval)
update the content of a GtkEntry as double
Definition gtk-misc.c:688
GtkWidget * create_text_view(int dimx, int dimy, int edit, int mono, GCallback handler, gpointer data, gchar *text)
create a GtkTextView and display some text
Definition gtk-misc.c:1286
GtkTextBuffer * add_buffer(GCallback handler, gpointer data, gchar *text)
create a GtkTextBuffer
Definition gtk-misc.c:1258
GtkWidget * create_scroll(GtkWidget *box, int dimx, int dimy, int shadow)
create a scroll window
Definition gtk-misc.c:2139
GtkWidget * dialogmodal(gchar *str, GtkWindow *parent)
Create a new dialog modal window.
Definition gtk-misc.c:552
void combo_set_active(GtkWidget *combo, int pos)
set the active item's position
Definition gtk-misc.c:958
gchar * file_chooser_get_file_name(GtkFileChooser *chooser)
get a file name from a GtkFileChooser (single file selected)
Definition gtk-misc.c:2306
const gchar * entry_get_text(GtkEntry *entry)
get the text in a GtkEntry
Definition gtk-misc.c:652
#define BSEP
Definition global.h:261
void opengl_project_changed(int id)
change the OpenGL project
Definition update_p.c:296
void update_entry_int(GtkEntry *entry, int intval)
update the content of a GtkEntry as int
Definition gtk-misc.c:669
void add_gtk_close_event(GtkWidget *widg, GCallback handler, gpointer data)
add a close event signal and callback to a GtkWidget
Definition gtk-misc.c:2557
gchar * file_chooser_get_current_folder(GtkFileChooser *chooser)
get the current folder for a GtkFileChooser
Definition gtk-misc.c:2322
GtkWidget * check_button(gchar *text, int dimx, int dimy, gboolean state, GCallback handler, gpointer data)
create a check button
Definition gtk-misc.c:1937
@ CONTAINER_SCR
Definition global.h:267
GtkWidget * create_button(gchar *text, int image_format, gchar *image, int dimx, int dimy, int relief, GCallback handler, gpointer data)
create a simple button
Definition gtk-misc.c:1999
GtkWidget * create_combo()
create a GtkCombox widget, note deprecated in GTK4
Definition gtk-misc.c:1010
GtkWidget * dialog_get_content_area(GtkWidget *widg)
prepare GtkWidget to insert content in a GtkDialog window
Definition gtk-misc.c:861
GtkWidget * markup_label(gchar *text, int dimx, int dimy, float ax, float ay)
create a GtkLabel with pango markup
Definition gtk-misc.c:1672
void add_box_child_start(int orientation, GtkWidget *widg, GtkWidget *child, gboolean expand, gboolean fill, int padding)
Add a GtkWidget in a GtkBox at the initial position.
Definition gtk-misc.c:340
void widget_set_sensitive(GtkWidget *widg, gboolean sensitive)
Set sensitivity for a GtkWidget, ensuring it is a GtkWidget.
Definition gtk-misc.c:247
void destroy_this_dialog(GtkDialog *dialog)
destroy a GtkDialog
Definition gtk-misc.c:2235
GtkWidget * create_hbox(int spacing)
create a GtkBox with horizontal orientation
Definition gtk-misc.c:849
void combo_text_append(GtkWidget *combo, gchar *text)
append text in GtkComboBox widget
Definition gtk-misc.c:987
G_MODULE_EXPORT void run_destroy_dialog(GtkDialog *dialog, gint response_id, gpointer data)
to destroy a GtkDialog when the dialog emit the closing signal
Definition gtk-misc.c:2272
GtkWidget * destroy_this_widget(GtkWidget *widg)
destroy a GtkWidget
Definition gtk-misc.c:2213
gchar * prepare_for_title(gchar *init)
prepare a string for a window title, getting rid of all markup
Definition tools.c:71
void add_container_child(int type, GtkWidget *widg, GtkWidget *child)
Add a GtkWidget into another GtkWidget.
Definition gtk-misc.c:267
void hide_the_widgets(GtkWidget *widg)
hide GtkWidget
Definition gtk-misc.c:224
GtkWidget * create_vbox(int spacing)
create a GtkBox with vertical orientation
Definition gtk-misc.c:837
int button_get_status(GtkWidget *button)
get status of check / toggle button
Definition gtk-misc.c:1899
GtkWidget * create_file_chooser(const gchar *title, GtkWindow *parent, GtkFileChooserAction act, const gchar *act_name)
create a GtkFileChooser, utility to select file(s)
Definition gtk-misc.c:2393
void destroy_this_native_dialog(GtkNativeDialog *dialog)
destroy a GtkNativeDialog
Definition gtk-misc.c:2254
void show_the_widgets(GtkWidget *widg)
show GtkWidget
Definition gtk-misc.c:202
project * get_project_by_id(int p)
get project pointer using id number
Definition project.c:120
void update_entry_long_double(GtkEntry *entry, double doubleval)
update the content of a GtkEntry as long double
Definition gtk-misc.c:707
Variable declarations related to the OpenGL window Function declarations related to the OpenGL wind...
Function declarations for the creation of the OpenGL window.
void show_info(char *information, int val, GtkWidget *win)
add / show information message to widget
Definition interface.c:240
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.
Function declarations for reading atomes project file Function declarations for saving atomes proje...
Definition glwin.h:350
Definition global.h:849
Definition glwin.h:967
GtkFileFilter * filter1
Definition w_data.c:53
GtkFileFilter * filter2
Definition w_data.c:53
GtkWidget * res[2]
Definition w_encode.c:342
GtkWidget * hbox
Definition workspace.c:71
GtkWidget * vbox
Definition workspace.c:72
GtkWidget * lab
Definition workspace.c:73