atomes 1.2.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-2025 by CNRS and University of Strasbourg */
15
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] = {"provides an informal description of the system and the calculation to be performed",
114 "provides the general control parameters for the calculation to be performed",
115 "provides the exchange and correlation functional (DFT) parameters",
116 "describes the implementation of the van der Waals interactions",
117 "provides details about the physical properties to be calculated",
118 "describes the symmetry and periodicity of the system",
119 "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]= {{"Fictitious electronic mass:", "Local Spin Density", "Van der Walls interactions", " ", " ", " "},
124 {"DFT functional:", "Density cutoff<sup>*</sup>:", " ", " ", " ", " "},
125 {" ", " ", " ", " ", " ", " "},
126 {" ", " ", " ", " ", " ", " "},
127 {"Use Angströms (default a.u.)", "Lattice:", "Symmetry:", "Parameters:", "Angles:", "Cutoff for the plane wave basis:"},
128 {"Use constraints", "Fix:", "Use dummy atoms:", "Atom type:", "Maximum angular momentum <i>l</i>:", "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] = {{"Slater exchange only", "Local Density Approximation","Becke 88", "Becke + Perdew", "Becke + Lee-Yang-Parr", "Extended B88+PW91+LYP88", "Perdew + Wang 91",
151 "Perdew + Burke-Ernzerhof", "PBE revised for solids", "Revised - PBE", "Hamprecht-Cohen-Tozer-Handy", "Optimized Becke 88", "Handy-Cohen + LYP",
152 "Tao-Perdew-Staroverov-Scuseria", "Parameter-free PBE", "Becke one-parameter hybrid + LYP", "Becke three-parameters hybrid + LYP", "Extend hybrid + LYP", "Heyd-Scuseria-Ernzerhof 06"},
153 {"Box parameters (a,b,c and α,β,γ)", "Lattice vectors", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "},
154 {"Isolated", "Cubic", "Face centered cubic (FCC)", "Body centered cubic (BCC)", "Hexagonal", "Trigonal",
155 "Tetragonal", "Body centered tetragonal (BCT)", "Orthorombic", "Monoclinic", "Triclinic", " ", " ", " ", " ", " ", " ", " ", " "},
156 {"Default (a, b/a, c/a)", "Absolute (a, b, c)", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "},
157 {"Default (cos α, cos β, cos γ)", "Degrees (α, β, γ)", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "},
158 {"All atoms", "Some atoms", "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 * calc_opts[NCPMDCALC][NOPTPC]={{"Convergence criteria<sup>*</sup>:", "Optimizer:", "Max steps:", "Integration step:", " ", " ", " "},
170 {"Convergence criteria<sup>*</sup>:", "Optimizer:", "Max steps:", "Integration step:", " ", " ", " "},
171 {"Max MD steps: ", "Time step:", "Barostat:", "Ions", "Factor:", "Fictitious electrons", "Factor:"},
172 {"Max MD steps: ", "Time step:", "Barostat:", "Ions", "Factor:", " ", " "},
173 {"Number of unoccupied states:", "3D visualization<sup>*</sup>", "Number of objects<sup>**</sup>:", " ", " ", " ", " "},
174 {"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]= {"Wavefunction optimization",
193 "Geometry optimization",
194 "CPMD Molecular Dynamics",
195 "Born-Oppenheimer Molecular Dynamics",
196 "Kohn-Sham eigen values",
197 "Vibrational analysis",
198 "Calculation of physical properties"};
199
200int calc_box_num[NCACOMBO]={2, 2, 3, 3, 3};
201
202gchar * calc_box_name[NCACOMBO][3] = {{"Preconditioned Gradient", "Direct Inversion of Iterative Subspace", " "},
203 {"Quasi-Newton method", "Direct Inversion of Iterative Subspace", " "},
204 {"None", "Parrinello-Rahman", "Parrinello-Rahman + NPT"},
205 {"None", "Parrinello-Rahman", "Parrinello-Rahman + NPT"},
206 {"Finite differences of first derivatives", "Linear response of ionic displacement", "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 * rest_kw[2] = {"RANDOM", "ATOMS"};
215gchar * rest_opts[3] = {"Random", "Atomic pseudo wavefunctions", "Use a RESTART.* file"};
216gchar * nosetype[3] = {"Gobal", "Local", "Molecule"};
217gchar * nosekey[2] = {" ", "LOCAL"};
218gchar * thermo_name[2][5] = {{"None", "Controlled", "Nosé-Hoover chains", " ", " "},
219 {"None", "Adaptive Langevin", "Canonical sampling through velocity rescaling", "GLE", "Nosé-Hoover chains"}};
220int num_thermo[2] = {3, 5};
221int type_thermo[2] = {2, 2};
222gchar * termoke[2] = {"TEMPCONTROL", "NOSE"};
223
224GtkWidget * qm_preview_but;
225GtkWidget * calc_combo;
228GtkWidget * calc_label;
229GtkWidget * latbox;
230GtkWidget * but_at[2];
231GtkWidget * spatbox;
232GtkWidget * ppbox[2];
233GtkWidget * calc_box[NCPMDCALC];
235gboolean is_cpmd;
236
248GtkWidget * cpmd_box (GtkWidget * box, gchar * lab, int v_space, int h_space, int dim)
249{
250 GtkWidget * hbox = create_hbox (0);
251 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, v_space);
252 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label(lab, dim, 30, 0.0, 0.5), FALSE, FALSE, h_space);
253 return hbox;
254}
255
263void print_all_sections (GtkTextBuffer * buf)
264{
265 int i;
266 for (i=0; i<MAXDATAQM+2; i++)
267 {
268 if (i != 5 && i != 6)
269 {
270 if (buf == NULL)
271 {
272 print_the_section (i, 0, qmbuffer[i]);
273 }
274 else if (i == 0 || i > 2)
275 {
276 print_the_section (i, 1, buf);
277 }
278 }
279 else if (i == 5 && (int)tmp_cpmd -> default_opts[2])
280 {
281 if (buf == NULL)
282 {
283 print_the_section (i, 0, qmbuffer[i]);
284 }
285 else
286 {
287 print_the_section (i, 1, buf);
288 }
289 }
290 else if (i == 6 && tmp_cpmd -> calc_type == 4)
291 {
292 if (buf == NULL)
293 {
294 print_the_section (i, 0, qmbuffer[i]);
295 }
296 else
297 {
298 print_the_section (i, 1, buf);
299 }
300 }
301 }
302}
303
312G_MODULE_EXPORT void update_cpmd_parameter (GtkEntry * res, gpointer data)
313{
314 int i;
315 i = GPOINTER_TO_INT(data);
316 const gchar * m = entry_get_text (res);
317 double v = string_to_double ((gpointer)m);
318 tmp_cpmd -> default_opts[i] = v;
319 if (i == DEFGC)
320 {
322 }
323 else
324 {
326 }
327 print_all_sections (NULL);
328}
329
330#ifdef GTK4
339G_MODULE_EXPORT void update_cpmd_check (GtkCheckButton * but, gpointer data)
340#else
349G_MODULE_EXPORT void update_cpmd_check (GtkToggleButton * but, gpointer data)
350#endif
351{
352 int i = GPOINTER_TO_INT(data);
353 gboolean j = button_get_status ((GtkWidget *)but);
354 if (i == DEFCO || i == DEFDU)
355 {
356 widget_set_sensitive (but_at[(i == DEFCO) ? 0 : 1], j);
357 }
358 tmp_cpmd -> default_opts[i] = (double) j;
359 print_all_sections (NULL);
360}
361
370G_MODULE_EXPORT void changed_opt_box (GtkComboBox * box, gpointer data)
371{
372 int i, j, k;
373 j = GPOINTER_TO_INT(data);
374 i = combo_get_active ((GtkWidget *)box);
375 if (j != DEFLM && j != DEFLO)
376 {
377 if (i != (int)tmp_cpmd -> default_opts[j])
378 {
379 tmp_cpmd -> default_opts[j] = (double)i;
380 if (j == DEFSP)
381 {
382 k = (int)tmp_cpmd -> default_opts[j];
383 combo_set_active (ppbox[0], tmp_cpmd -> pp[k][0]);
384 combo_set_active (ppbox[1], tmp_cpmd -> pp[k][1]);
385 }
386 else if (j == DEFFI)
387 {
389 if (tmp_cpmd -> fixlist != NULL)
390 {
391 g_free (tmp_cpmd -> fixlist);
392 tmp_cpmd -> fixlist = NULL;
393 if (tmp_cpmd -> fixcoord != NULL)
394 {
395 g_free (tmp_cpmd -> fixcoord);
396 tmp_cpmd -> fixcoord = NULL;
397 }
398 }
399 tmp_cpmd -> fixat = 0;
401 }
402 }
403 }
404 else
405 {
406 if (i != tmp_cpmd -> pp[(int)tmp_cpmd -> default_opts[DEFSP]][j-DEFLM])
407 {
408 tmp_cpmd -> pp[(int)tmp_cpmd -> default_opts[DEFSP]][j-DEFLM] = i;
409 }
410 }
411 if (j == DEFVE)
412 {
414 }
415 print_all_sections (NULL);
416}
417
425GtkWidget * prepare_qm_option_box (int s)
426{
427 int i, j, k, l;
428 GtkWidget * hbox;
429 GtkWidget * widg;
430 gchar * str;
431 gchar * atom_but[2] = {"Configure constraints", "Configure dummy atoms"};
432 GtkWidget * vbox = create_vbox (BSEP);
433 for (i=0; i<NSECOP; i++)
434 {
435 if (default_opts_type[s][i] > 0)
436 {
437 ident ++;
438 if (ident == DEFAB || ident == DEFDG || ident == DEFSY)
439 {
440 hbox = cpmd_box (latbox, default_opts[s][i], 5, 20, (s == 1) ? 150 : 220);
441 }
442 else if (ident == DEFCO || ident == DEFDU)
443 {
444 hbox = cpmd_box (vbox, default_opts[s][i], 20, 20, 180);
445 }
446 else if (ident == DEFLM || ident == DEFLO)
447 {
448 hbox = cpmd_box (spatbox, default_opts[s][i], 5, 20, 220);
449 }
450 else
451 {
452 hbox = cpmd_box (vbox, default_opts[s][i], (ident == DEFSP) ? 20 : 5, 5, (s == 1) ? 150 : 220);
453 }
454 j = ident;
455 switch (default_opts_type[s][i])
456 {
457 case 1:
458 widg = create_entry (G_CALLBACK(update_cpmd_parameter), 100, 15, FALSE, GINT_TO_POINTER(j));
459 if (j == DEFGC)
460 {
461 update_entry_long_double (GTK_ENTRY(widg), tmp_cpmd -> default_opts[j]);
462 }
463 else
464 {
465 update_entry_double (GTK_ENTRY(widg), tmp_cpmd -> default_opts[j]);
466 }
467 break;
468 case 2:
469 icomb ++;
470 if (ident == DEFLM || ident == DEFLO)
471 {
473 }
474 else
475 {
476 widg = create_combo ();
477 }
478 l = (ident == DEFSP) ? qm_proj -> nspec : defaut_num[icomb];
479 for (k=0; k<l; k++)
480 {
481 if (icomb == 0)
482 {
483 str = g_strdup_printf ("%s (%s)", default_text[0][k], default_keywords[0][k]);
484 }
485 else if (ident == DEFSP)
486 {
487 str = g_strdup_printf ("%s atom(s)", qm_proj -> chemistry -> label[k]);
488 }
489 else
490 {
491 str = g_strdup_printf ("%s", default_text[icomb][k]);
492 }
493 if (ident == DEFLM || ident == DEFLO)
494 {
496 }
497 else
498 {
499 combo_text_append (widg, str);
500 }
501 g_free (str);
502 }
503 if (ident == DEFLM || ident == DEFLO)
504 {
506 g_signal_connect (G_OBJECT (ppbox[ident - DEFLM]), "changed", G_CALLBACK(changed_opt_box), GINT_TO_POINTER(j));
507 }
508 else
509 {
510 combo_set_active (widg, (int)tmp_cpmd -> default_opts[j]);
511 g_signal_connect (G_OBJECT (widg), "changed", G_CALLBACK(changed_opt_box), GINT_TO_POINTER(j));
512 }
513 break;
514 case 3:
515 widg = check_button (NULL, -1, -1, tmp_cpmd -> default_opts[j], G_CALLBACK(update_cpmd_check), GINT_TO_POINTER(j));
516 break;
517 }
518 if (ident == DEFLM || ident == DEFLO)
519 {
520 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, ppbox[ident - DEFLM], FALSE, FALSE, 0);
521 }
522 else
523 {
524 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, widg, FALSE, FALSE, 0);
525 }
526 if (j==DEFEM || j==DEFGC || j==DEFCU)
527 {
528 if (j==DEFEM || j==DEFGC)
529 {
530 widg = gtk_label_new ("a.u.");
531 }
532 else
533 {
534 widg = gtk_label_new ("Ry");
535 }
536 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, widg, FALSE, FALSE, 5);
537 }
538 else if (j == DEFVE)
539 {
541 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, latbox, FALSE, FALSE, 15);
543 }
544 else if (j == DEFCO || j == DEFDU)
545 {
546 k = (j==DEFCO) ? 0 : 1;
547 but_at[k] = create_button (atom_but[k], IMG_NONE, NULL, 175, -1, GTK_RELIEF_NORMAL, G_CALLBACK(atom_button), GINT_TO_POINTER(j));
549 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, but_at[k], FALSE, FALSE, 20);
550 if (j == DEFCO)
551 {
552 ident ++;
553 icomb ++;
554 }
555 }
556 else if (j == DEFSP)
557 {
559 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, spatbox, FALSE, FALSE, 15);
560 }
561 }
562 }
563 return vbox;
564}
565
574G_MODULE_EXPORT void update_calc_parameter (GtkEntry * res, gpointer data)
575{
576 int i, j;
577 i = GPOINTER_TO_INT(data);
578 const gchar * m = entry_get_text (res);
579 double v = string_to_double ((gpointer)m);
580 if (i==STEPO || i==STEPG || i==STEPC || i==STEPB || i==KSUNO || i==NBAND)
581 {
582 j = (int) v;
583 tmp_cpmd -> calc_opts[i] = (double) j;
585 }
586 else
587 {
588 tmp_cpmd -> calc_opts[i] = v;
589 if (i == CONVO || i == CONVG)
590 {
592 }
593 else
594 {
596 }
597 }
598 for (i=1; i<4; i++) print_the_section (i, 0, qmbuffer[i]);
599}
600
609G_MODULE_EXPORT void changed_calc_opt_box (GtkComboBox * box, gpointer data)
610{
611 int i, j;
612 j = GPOINTER_TO_INT(data);
613 i = combo_get_active ((GtkWidget *)box);
614 if (i != tmp_cpmd -> calc_opts[j])
615 {
616 tmp_cpmd -> calc_opts[j] = i;
617 for (j=1; j<4; j++) print_the_section (j, 0, qmbuffer[j]);
618 }
619}
620
621#ifdef GTK4
630G_MODULE_EXPORT void update_calc_check (GtkCheckButton * but, gpointer data)
631#else
640G_MODULE_EXPORT void update_calc_check (GtkToggleButton * but, gpointer data)
641#endif
642{
643 int i = GPOINTER_TO_INT(data);
644 tmp_cpmd -> calc_opts[i] = (double) button_get_status ((GtkWidget *)but);
645 for (i=1; i<4; i++) print_the_section (i, 0, qmbuffer[i]);
646}
647
655GtkWidget * calc_qm_option_box (int c)
656{
657 int i, j, k, l;
658 GtkWidget * hbox;
659 GtkWidget * widg;
660 gchar * str;
661 GtkWidget * vbox = create_vbox (BSEP);
662 for (i=0; i<NOPTPC; i++)
663 {
664 if (default_type[c][i] > 0)
665 {
666 idopt ++;
667 l = 0;
668 if (idopt == ANNIC || idopt == ANNIB)
669 {
670 hbox = cpmd_box (vbox, "Annealing:", 0, 5, 220);
671 }
672 if (idopt == ANNIC || idopt == ANNEC || idopt == ANNIB)
673 {
674 hbox = cpmd_box (vbox, calc_opts[c][i], 0, 25, 120);
675 l = 30;
676 }
677 else if (idopt == AFAIC || idopt == AFAEC || idopt == AFAIB)
678 {
679 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, gtk_label_new(calc_opts[c][i]), FALSE, FALSE, 10);
680 l = 30;
681 }
682 else
683 {
684 hbox = cpmd_box (vbox, calc_opts[c][i], 0, 5, 220);
685 }
686 j = idopt;
687 switch (default_type[c][i])
688 {
689 case 1:
690 widg = create_entry (G_CALLBACK(update_calc_parameter), 100, 15, FALSE, GINT_TO_POINTER(j));
691 if (j==STEPO || j==STEPG || j==STEPC || j==STEPB || j==KSUNO || j==NBAND)
692 {
693 update_entry_int (GTK_ENTRY(widg), (int) tmp_cpmd -> calc_opts[j]);
694 }
695 else
696 {
697 update_entry_double (GTK_ENTRY(widg), tmp_cpmd -> calc_opts[j]);
698 }
699 break;
700 case 2:
701 icalc ++;
702 widg = create_combo ();
703 for (k=0; k<calc_box_num[icalc]; k++)
704 {
705 str = g_strdup_printf ("%s", calc_box_name[icalc][k]);
706 combo_text_append (widg, str);
707 g_free (str);
708 }
709 combo_set_active (widg, (int)tmp_cpmd -> calc_opts[j]);
710 g_signal_connect (G_OBJECT (widg), "changed", G_CALLBACK(changed_calc_opt_box), GINT_TO_POINTER(j));
711 break;
712 case 3:
713 widg = check_button (NULL, -1, -1, tmp_cpmd -> calc_opts[j], G_CALLBACK(update_calc_check), GINT_TO_POINTER(j));
714 break;
715 }
716 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, widg, FALSE, FALSE, l);
717 if (j==TSTPO || j==TSTPG || j==TSTPC || j==TSTPB)
718 {
719 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, gtk_label_new ("a.u."), FALSE, FALSE, 5);
720 }
721 else if (j==NBAND)
722 {
723 gchar * ksout = "\t * electronic density(ies) or/and wavefunction(s)\n"
724 "\t ** as many index(es) to be supplied on the next line:\n"
725 "\t\t &gt; 0 for electronic density\n\t\t &lt; 0 for wavefunction";
726 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label(ksout, -1, -1, 0.0, 0.5), FALSE, FALSE, 10);
727 }
728 }
729 }
730 return vbox;
731}
732
741G_MODULE_EXPORT void changed_calc_box (GtkComboBox * box, gpointer data)
742{
743 int i;
744 i = combo_get_active ((GtkWidget *)box);
745 if (i != tmp_cpmd -> calc_type)
746 {
747 gtk_label_set_text (GTK_LABEL(calc_label), g_strdup_printf ("<u>%s option(s)</u>", calc_ds[i]));
748 gtk_label_set_use_markup (GTK_LABEL(calc_label), TRUE);
749 hide_the_widgets (calc_box[tmp_cpmd -> calc_type]);
751 tmp_cpmd -> calc_type = i;
752 if (tmp_cpmd -> calc_type != 2)
753 {
755 }
756 else
757 {
759 }
760 for (i=1; i<4; i++) print_the_section (i, 0, qmbuffer[i]);
761 }
762}
763
772G_MODULE_EXPORT void changed_info (GtkTextBuffer * textbuf, gpointer data)
773{
774 GtkTextIter bStart;
775 GtkTextIter bEnd;
776 gtk_text_buffer_get_start_iter (textbuf, & bStart);
777 gtk_text_buffer_get_end_iter (textbuf, & bEnd);
778 if (tmp_cpmd -> info != NULL) g_free (tmp_cpmd -> info);
779 tmp_cpmd -> info = g_strdup_printf ("%s", gtk_text_buffer_get_text (textbuf, & bStart, & bEnd, FALSE));
780 print_the_section (0, 0, qmbuffer[0]);
781}
782
788GtkWidget * info_box ()
789{
790 GtkWidget * vbox = create_vbox (BSEP);
791 GtkWidget * hbox = create_hbox (0);
792 GtkWidget * scrollsets = create_scroll (NULL, 355, 250, GTK_SHADOW_ETCHED_IN);
793 GtkWidget * aview = create_text_view (-1, -1, 1, 0, G_CALLBACK(changed_info), NULL, NULL);
794 if (tmp_cpmd -> info != NULL) print_info (tmp_cpmd -> info, NULL, gtk_text_view_get_buffer(GTK_TEXT_VIEW(aview)));
796 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, scrollsets, FALSE, FALSE, 85);
797 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 0);
798
799 return vbox;
800}
801
809GtkWidget * section_box (int s)
810{
811 int i;
812 gchar * str;
813 GtkWidget * hbox;
814 GtkWidget * vbox = create_vbox (BSEP);
815 if (s == 0)
816 {
817 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, info_box(), FALSE, FALSE, 50);
818 }
819 else if (s == 1)
820 {
821 // CPMD Calculation
822 /* Calc type combo_box: */
823 idopt = -1;
824 icalc = -1;
825 ident = -1;
826 icomb = -1;
827 hbox = create_hbox (0);
828 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);
830 for (i=0; i<NCPMDCALC; i++) combo_text_append (calc_combo, calc_ds[i]);
831 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, calc_combo, FALSE, FALSE, 10);
832 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 0);
833
834 /* Calc related options: */
835 str = g_strdup_printf ("<u>%s option(s)</u>", calc_ds[tmp_cpmd -> calc_type]);
836 calc_label = markup_label(str, -1, -1, 0.0, 0.5);
837 g_free (str);
838 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, calc_label, FALSE, FALSE, 10);
839 for (i=0; i<NCPMDCALC; i++)
840 {
842 gtk_widget_set_size_request (calc_box[i], -1, 200);
843 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, calc_box[i], FALSE, FALSE, 0);
844 }
845 g_signal_connect (G_OBJECT (calc_combo), "changed", G_CALLBACK(changed_calc_box), NULL);
846 combo_set_active (calc_combo, tmp_cpmd -> calc_type);
847 }
848 else if (s == 2)
849 {
850 // CPMD - thermostat(s)
851 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, thermo_box(), FALSE, FALSE, 5);
852 }
853 else if (s == 3)
854 {
855 // CPMD - restart
856 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, restart_box(), FALSE, FALSE, 0);
857 }
858
859 /* General CPMD section options: */
860 if (s > 0 && s != 2 && s != 3)
861 {
862 i = (s == 1) ? s : s - 2;
863 str = g_strdup_printf ("<u>General %s section option(s)</u>",cpmd_elements[i]);
864 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label(str, 525, -1, 0.0, 0.5), FALSE, FALSE, 10);
865 g_free (str);
867 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, qm_option_box[i-1], FALSE, FALSE, 0);
868 }
869 return vbox;
870}
871
881GtkWidget * qm_preview_box (int c, int s, int l)
882{
883 GtkWidget * vbox = create_vbox (BSEP);
884 GtkWidget * scrollsets = create_scroll (NULL, 250, (c) ? 280 : 410, GTK_SHADOW_ETCHED_IN);
885 GtkWidget * aview = create_text_view (-1, -1, 0, 1, NULL, NULL, NULL);
886 qmbuffer[s] = gtk_text_view_get_buffer (GTK_TEXT_VIEW(aview));
888 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, scrollsets, FALSE, FALSE, l);
889 if (c == 0)
890 {
891 print_the_section (s, 0, qmbuffer[s]);
892 }
893 else
894 {
895 print_cp2k (s, qmbuffer[s]);
896 }
897 return vbox;
898}
899
907gchar * section_name (int p)
908{
909 if (p > 0 && p < 4)
910 {
911 return g_strdup_printf ("Details of the <b>%s</b> section that %s", cpmd_elements[1], cdescr[1]);
912 }
913 else if (p == 0)
914 {
915 return g_strdup_printf ("Details of the <b>%s</b> section that %s", cpmd_elements[p], cdescr[p]);
916 }
917 else
918 {
919 return g_strdup_printf ("Details of the <b>%s</b> section that %s", cpmd_elements[p-2], cdescr[p-2]);
920 }
921}
922
930GtkWidget * vbox_cpmd (int s)
931{
932 GtkWidget * vbox;
933 GtkWidget * hbox;
935 hbox = create_hbox (0);
936 if (s < 2 || s > 3)
937 {
938 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label(section_name(s), -1, 20, 0.0, 0.5), FALSE, FALSE, 20);
939 }
940 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, (s < 2 ||s > 3) ? 5 : 0);
941 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, section_box(s), FALSE, FALSE, 0);
942 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, qm_preview_box (0, s, (s < 2 ||s > 3) ? 0 : 65), FALSE, FALSE, 0);
943 return vbox;
944}
945
953gchar * page_name (int p)
954{
955 if (p > 0 && p <4)
956 {
957 if (p == 1)
958 {
959 return g_strdup_printf ("The %s section - Calculation options", cpmd_elements[1]);
960 }
961 else if (p == 2)
962 {
963 return g_strdup_printf ("The %s section - Thermostat options", cpmd_elements[1]);
964 }
965 else
966 {
967 return g_strdup_printf ("The %s section - RESTART options", cpmd_elements[1]);
968 }
969 }
970 else if (p == 0)
971 {
972 return g_strdup_printf ("The %s section", cpmd_elements[p]);
973 }
974 else
975 {
976 return g_strdup_printf ("The %s section", cpmd_elements[p-2]);
977 }
978}
979
986{
987 int i;
988 gchar * info;
989 GtkAssistant * assist = GTK_ASSISTANT(qm_assistant);
990 GtkWidget * page;
991 for (i=0; i<MAXDATAQM+2; i++)
992 {
993 page = vbox_cpmd (i);
994 gtk_assistant_append_page (assist, page);
995 gtk_assistant_set_page_title (assist, page, page_name(i));
996 gtk_assistant_set_page_type (assist, page, GTK_ASSISTANT_PAGE_CONTENT);
997 if (i != 3)
998 {
999 gtk_assistant_set_page_complete (assist, page, TRUE);
1000 }
1001 else
1002 {
1003 gtk_assistant_set_page_complete (assist, page, are_all_atoms_thermostated ());
1004 }
1005 }
1006
1007 GtkWidget * conclu = create_vbox (BSEP);
1008 info = g_strdup_printf ("<b> Finalize the creation of the CPMD input file now !</b>");
1009 add_box_child_start (GTK_ORIENTATION_VERTICAL, conclu, markup_label(info, -1, -1, 0.5, 0.5), TRUE, TRUE, 100);
1010 g_free (info);
1011 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);
1012 gtk_assistant_append_page (assist, conclu);
1013 gtk_assistant_set_page_title (assist, conclu, "Create the input file now !");
1014 gtk_assistant_set_page_type (assist, conclu, GTK_ASSISTANT_PAGE_CONFIRM);
1015 gtk_assistant_set_page_complete (assist, conclu, TRUE);
1016 gtk_assistant_update_buttons_state (assist);
1017}
1018
1025{
1026 int i, j;
1027 for (i=0; i<qm_proj -> natomes; i++)
1028 {
1029 for (j=0; j<2; j++)
1030 {
1031 qm_proj -> atoms[0][i].pick[j] = FALSE;
1032 qm_proj -> atoms[0][i].label[j] = FALSE;
1033 }
1034 }
1035 qm_view -> picked = 0;
1037}
1038
1047G_MODULE_EXPORT void on_qm_assistant_cancel (GtkAssistant * assistant, gpointer data)
1048{
1049 destroy_this_widget (GTK_WIDGET(assistant));
1051 // restore selection if any from calc.c
1053}
1054
1055#ifdef GTK4
1064G_MODULE_EXPORT gboolean on_qm_assistant_cancel_event (GtkWindow * assistant, gpointer data)
1065#else
1075G_MODULE_EXPORT gboolean on_qm_assistant_cancel_event (GtkWidget * assistant, GdkEvent * event, gpointer data)
1076#endif
1077{
1078 on_qm_assistant_cancel (((GtkAssistant *)assistant), data);
1079 return TRUE;
1080}
1081
1090G_MODULE_EXPORT void on_qm_assistant_close (GtkAssistant * assistant, gpointer data)
1091{
1092 // Apply changes ... then close window
1093 destroy_this_widget (GTK_WIDGET(assistant));
1094 // Saving
1095
1096 // Cleaning
1098 // restore selection if any from calc.c
1100}
1101
1110G_MODULE_EXPORT gint on_qm_assistant_go_forward (gint current_page, gpointer data)
1111{
1112 int i = GPOINTER_TO_INT(data);
1113 if (i == 0)
1114 {
1115 switch (current_page)
1116 {
1117 case MAXDATAQM+4:
1118 return -1;
1119 break;
1120 case 2:
1121 if (tmp_cpmd -> calc_type == 2 || tmp_cpmd -> calc_type == 3)
1122 {
1123 return 3;
1124 }
1125 else
1126 {
1127 return 4;
1128 }
1129 break;
1130 case 5:
1131 if ((int)tmp_cpmd -> default_opts[2])
1132 {
1133 return current_page+1;
1134 }
1135 else if (tmp_cpmd -> calc_type == 6)
1136 {
1137 return current_page+2;
1138 }
1139 else
1140 {
1141 return current_page+3;
1142 }
1143 break;
1144 case 6:
1145 if (tmp_cpmd -> calc_type == 6)
1146 {
1147 return current_page+1;
1148 }
1149 else
1150 {
1151 return current_page+2;
1152 }
1153 default:
1154 return current_page+1;
1155 break;
1156 }
1157 }
1158 else
1159 {
1160 switch (current_page)
1161 {
1162 case MAXDATAQM+4:
1163 return -1;
1164 break;
1165 default:
1166 return current_page+1;
1167 break;
1168 }
1169 }
1170}
1171
1181G_MODULE_EXPORT void on_qm_assistant_prepare (GtkAssistant * assistant, GtkWidget * page, gpointer data)
1182{
1183 int i = gtk_assistant_get_current_page (assistant);
1184 // field_unselect_all ();
1185 switch (i)
1186 {
1187 case 0:
1189 break;
1190 default:
1192 break;
1193 }
1194}
1195
1205gboolean go_for_it (int i, int j, gboolean print[2])
1206{
1207 if (tmp_cp2k -> input_type && i<=j-3) return TRUE;
1208 if (i==0) return TRUE;
1209 if (i==j-2 && print[0]) return TRUE;
1210 if (i==j-1 && print[1]) return TRUE;
1211 return FALSE;
1212}
1213
1222G_MODULE_EXPORT void show_qm_file_preview (GtkButton * but, gpointer data)
1223{
1224 int i, j, k, c;
1225 c = GPOINTER_TO_INT(data);
1226 gchar * ptitle[5] = {"CP2K input file", "forces.inc", "system.inc", "motion.inc", "coord.inc"};
1227 gchar * wtite[2] = {" input file preview", " input files preview"};
1228 gchar * str;
1229 GtkWidget * scrollsets;
1230 GtkWidget * aview;
1231 GtkWidget * notebook;
1232 k = 0;
1233 gboolean print[2];
1234 if (c)
1235 {
1236 j = 6;
1237 notebook = gtk_notebook_new ();
1238 if (tmp_cp2k -> opts[CP2RUN] > 1.0 && tmp_cp2k -> opts[CP2RUN] < 4.0) k = 1;
1239 if (tmp_cp2k -> input_type)
1240 {
1241 str = g_strdup_printf ("%s %s", co_type[c], wtite[1]);
1242 }
1243 else
1244 {
1245 str = g_strdup_printf ("%s %s", co_type[c], wtite[0]);
1246 }
1247 print[0] = print[1] = FALSE;
1248 for (i=0; i<qm_proj -> nspec; i++)
1249 {
1250 if (tmp_cp2k -> spec_data[i][0] != -1)
1251 {
1252 print[0] = TRUE;
1253 break;
1254 }
1255 }
1256 for (i=0; i<qm_proj -> nspec; i++)
1257 {
1258 if (tmp_cp2k -> spec_data[i][1] != -1)
1259 {
1260 print[1] = TRUE;
1261 break;
1262 }
1263 }
1264 }
1265 else
1266 {
1267 j = 1;
1268 str = g_strdup_printf ("%s %s", co_type[c], wtite[0]);
1269 }
1270 GtkWidget * preview = dialogmodal (str, GTK_WINDOW (qm_assistant));
1271 g_free (str);
1272 if (c)
1273 {
1274 add_box_child_start (GTK_ORIENTATION_VERTICAL, dialog_get_content_area(preview), notebook, FALSE, FALSE, 0);
1275 }
1276 else
1277 {
1278 scrollsets = create_scroll (dialog_get_content_area(preview), 700, 350, GTK_SHADOW_ETCHED_IN);
1279 }
1280 for (i=0; i<j+k; i++)
1281 {
1282 if (! c || (c && go_for_it(i, j+k, print)))
1283 {
1284 aview = create_text_view (-1, -1, 0, 1, NULL, NULL, NULL);
1285 if (c)
1286 {
1287 scrollsets = create_scroll (NULL, 700, 350, GTK_SHADOW_ETCHED_IN);
1289 if (i > j+k-3)
1290 {
1291 str = g_strdup_printf ("%s", tmp_cp2k -> files[i-(j+k-3)]);
1292 }
1293 else
1294 {
1295 str = g_strdup_printf ("%s", ptitle[(i == j-3+k) ? 4 : i]);
1296 }
1297 gtk_notebook_append_page (GTK_NOTEBOOK(notebook), scrollsets, gtk_label_new (str));
1298 g_free (str);
1299 }
1300 else
1301 {
1303 }
1304 }
1305 if (c)
1306 {
1307 if (tmp_cp2k -> input_type || i != j+k-3)
1308 {
1309 print_cp2k ((i >= j+k-3) ? i+1-k: i, gtk_text_view_get_buffer(GTK_TEXT_VIEW(aview)));
1310 }
1311 }
1312 else
1313 {
1314 print_all_sections (gtk_text_view_get_buffer(GTK_TEXT_VIEW(aview)));
1315 }
1316 }
1317 run_this_gtk_dialog (preview, G_CALLBACK(run_destroy_dialog), NULL);
1318}
1319
1320#ifdef GTK4
1330G_MODULE_EXPORT void run_saving_qm (GtkNativeDialog * info, gint response_id, gpointer data)
1331{
1332 GtkFileChooser * chooser = GTK_FILE_CHOOSER((GtkFileChooserNative *)info);
1333#else
1343G_MODULE_EXPORT void run_saving_qm (GtkDialog * info, gint response_id, gpointer data)
1344{
1345 GtkFileChooser * chooser = GTK_FILE_CHOOSER((GtkWidget *)info);
1346#endif
1347 int i, j, k, l;
1348 int c = GPOINTER_TO_INT(data);
1349 gboolean result = FALSE;
1350 gboolean done = FALSE;
1351 GtkTextBuffer * buffer = NULL;
1352 GtkTextIter bStart;
1353 GtkTextIter bEnd;
1354 GError * err = NULL;
1355 gchar * text;
1356 gchar * filename;
1357 gchar * direname;
1358 gchar * cp2sp[2] = {"basis.inc", "pseudo.inc"};
1359 gchar * cp2file[4] = {"forces.inc", "system.inc", "motion.inc", "coord.inc"};
1360 switch (response_id)
1361 {
1362 case GTK_RESPONSE_ACCEPT:
1363 filename = file_chooser_get_file_name (chooser);
1364 direname = file_chooser_get_current_folder (chooser);
1365 if (filename != NULL)
1366 {
1367 done = TRUE;
1368 if (! c || (c && ! tmp_cp2k -> input_type)) buffer = add_buffer (NULL, NULL, NULL);
1369 switch (c)
1370 {
1371 case 0:
1372 print_all_sections (buffer);
1373 break;
1374 case 1:
1375 j = 6;
1376 k = 0;
1377 if (tmp_cp2k -> opts[CP2RUN] > 1.0 && tmp_cp2k -> opts[CP2RUN] < 4.0) k = 1;
1378 for (i=0; i<j+k; i++)
1379 {
1380 if (i != j+k-3 || tmp_cp2k -> input_type)
1381 {
1382 l = (i >= j+k-3) ? i+1-k: i;
1383 if (tmp_cp2k -> input_type)
1384 {
1385 buffer = add_buffer (NULL, NULL, NULL);
1386 if (i > 0) filename = g_strdup_printf ("%s/%s", direname, cp2file[l-1]);
1387 print_cp2k (l, buffer);
1388 gtk_text_buffer_get_start_iter (buffer, & bStart);
1389 gtk_text_buffer_get_end_iter (buffer, & bEnd);
1390 text = gtk_text_buffer_get_text (buffer, & bStart, & bEnd, FALSE);
1391 gtk_text_buffer_set_modified (buffer, FALSE);
1392 result = g_file_set_contents (filename, text, -1, & err);
1393 g_free (text);
1394 g_object_unref (buffer);
1395 if (! result && err)
1396 {
1397 show_error (g_strdup_printf ("Error while saving input file: %s\n Error: %s", filename, err -> message), 0, qm_assistant);
1398 g_error_free (err);
1399 }
1400 g_free (filename);
1401 }
1402 else if (l != 5 && l != 6)
1403 {
1404 print_cp2k (l, buffer);
1405 }
1406 }
1407 }
1408 break;
1409 }
1410 if (! c || (c && ! tmp_cp2k -> input_type))
1411 {
1412 gtk_text_buffer_get_start_iter (buffer, & bStart);
1413 gtk_text_buffer_get_end_iter (buffer, & bEnd);
1414 text = gtk_text_buffer_get_text (buffer, & bStart, & bEnd, FALSE);
1415 gtk_text_buffer_set_modified (buffer, FALSE);
1416 result = g_file_set_contents (filename, text, -1, & err);
1417 g_free (text);
1418 g_object_unref (buffer);
1419 if (! result && err)
1420 {
1421 /* error saving file, show message to user */
1422 show_error (g_strdup_printf ("Error while saving input file: %s\n Error: %s", filename, err -> message), 0, qm_assistant);
1423 g_error_free (err);
1424 }
1425 g_free (filename);
1426 }
1427 if (c)
1428 {
1429 // save pseudo and basis auto
1430 for (i=0; i<2; i++)
1431 {
1432 buffer = add_buffer (NULL, NULL, NULL);
1433 filename = g_strdup_printf ("%s/%s", direname, cp2sp[i]);
1434 print_cp2k (i+5, buffer);
1435 gtk_text_buffer_get_start_iter (buffer, & bStart);
1436 gtk_text_buffer_get_end_iter (buffer, & bEnd);
1437 text = gtk_text_buffer_get_text (buffer, & bStart, & bEnd, FALSE);
1438 result = g_file_set_contents (filename, text, -1, & err);
1439 g_free (text);
1440 if (! result && err)
1441 {
1442 /* error saving file, show message to user */
1443 show_error (g_strdup_printf ("Error while saving file %s: %s", cp2sp[i], err -> message), 0, qm_assistant);
1444 g_error_free (err);
1445 break;
1446 }
1447 g_free (filename);
1448 g_object_unref (buffer);
1449 }
1450 }
1451 }
1452 break;
1453 default:
1454 done = TRUE;
1455 break;
1456 }
1457 if (done)
1458 {
1459#ifdef GTK4
1461#else
1462 destroy_this_dialog (info);
1463#endif
1464 }
1465 if (c && result)
1466 {
1467 if (tmp_cp2k -> input_type)
1468 {
1469 if (tmp_cp2k -> opts[CP2RUN] > 1.0 && tmp_cp2k -> opts[CP2RUN] < 4.0)
1470 {
1471 show_info ("The input files 'forces.inc', 'system.inc', 'motion.inc' and 'coord.inc'\n"
1472 "as well as the files 'basis.inc' and 'pseudo.inc'\n"
1473 "for the atomic basis set and peudo-potentials\n"
1474 "were saved in the same directory as the main input file.", 0, qm_assistant);
1475 }
1476 else
1477 {
1478 show_info ("The input files 'forces.inc', 'system.inc', and 'coord.inc'\n"
1479 "as well as the files 'basis.inc' and 'pseudo.inc'\n"
1480 "for the atomic basis set and peudo-potentials\n"
1481 "were saved in the same directory as the main input file.", 0, qm_assistant);
1482 }
1483 }
1484 else
1485 {
1486 show_info ("The files 'basis.inc' and 'pseudo.inc'\n"
1487 "for the atomic basis set and peudo-potentials\n"
1488 "were saved in the same directory as the main input file.", 0, qm_assistant);
1489 }
1490 }
1491}
1492
1501G_MODULE_EXPORT void on_qm_assistant_apply (GtkAssistant * assistant, gpointer data)
1502{
1503 int c = GPOINTER_TO_INT(data);
1504 gchar * text;
1505#ifdef GTK4
1506 GtkFileChooserNative * info;
1507#else
1508 GtkWidget * info;
1509#endif
1510 GtkFileFilter * filter1, * filter2;
1511 gchar * qm_type[2] = {"CPMD", "CP2K"};
1512 const gchar * qm_name[2] = {"CPMD input file (*.in)", "CP2K input file (*.inp)"};
1513 const gchar * qm_ext[2] = {".in", ".inp"};
1514
1515 text = g_strdup_printf ("Saving %s input file(s)", qm_type[c]);
1516 info = create_file_chooser (text,
1517 GTK_WINDOW(assistant),
1518 GTK_FILE_CHOOSER_ACTION_SAVE,
1519 "Save");
1520 GtkFileChooser * chooser = GTK_FILE_CHOOSER(info);
1521 g_free (text);
1522#ifdef GTK3
1523 gtk_file_chooser_set_do_overwrite_confirmation (chooser, TRUE);
1524#endif
1526 filter1 = gtk_file_filter_new();
1527 gtk_file_filter_set_name (GTK_FILE_FILTER(filter1), qm_name[c]);
1528 text = g_strdup_printf ("*%s", qm_ext[c]);
1529 gtk_file_filter_add_pattern (GTK_FILE_FILTER(filter1), text);
1530 g_free (text);
1531 gtk_file_chooser_add_filter (chooser, filter1);
1532 filter2 = gtk_file_filter_new();
1533 gtk_file_filter_set_name (GTK_FILE_FILTER(filter2), "All files (*)");
1534 gtk_file_filter_add_pattern (GTK_FILE_FILTER(filter2), "*");
1535 gtk_file_chooser_add_filter (chooser, filter2);
1536 text = g_strdup_printf ("%s%s", prepare_for_title(qm_proj -> name), qm_ext[c]);
1538 gtk_file_chooser_set_current_name (chooser, text);
1539 g_free (text);
1540#ifdef GTK4
1541 run_this_gtk_native_dialog ((GtkNativeDialog *)info, G_CALLBACK(run_saving_qm), NULL);
1542#else
1543 run_this_gtk_dialog (info, G_CALLBACK(run_saving_qm), data);
1544#endif
1545}
1546
1556void create_qm_input_file (int c, int p, int s)
1557{
1558 gchar * qm_type[2] = {"first-principles", "QM-MM"};
1559 qm_assistant = gtk_assistant_new ();
1560 gtk_widget_set_size_request (qm_assistant, 800, 600);
1561 int i, j;
1562 //field_color = TRUE;
1563 field_object = -1;
1564 //selected_aspec = -1;
1567 for (i=0; i<MAXDATAQM+2; i++) qmbuffer[i] = NULL;
1568 if (c == 0)
1569 {
1570 is_cpmd = TRUE;
1571 if (qm_proj -> cpmd_input[s] == NULL)
1572 {
1573 qm_proj -> cpmd_input[s] = g_malloc0 (sizeof*qm_proj -> cpmd_input[s]);
1574 qm_proj -> cpmd_input[s] -> calc_type = 0;
1575 qm_proj -> cpmd_input[s] -> thermostats = 0;
1576 qm_proj -> cpmd_input[s] -> ions_thermostat = NULL;
1577 qm_proj -> cpmd_input[s] -> elec_thermostat = NULL;
1578 qm_proj -> cpmd_input[s] -> dummies = 0;
1579 qm_proj -> cpmd_input[s] -> dummy = NULL;
1580 qm_proj -> cpmd_input[s] -> fixat = 0;
1581 qm_proj -> cpmd_input[s] -> fixlist = NULL;
1582 qm_proj -> cpmd_input[s] -> fixcoord = NULL;
1583 qm_proj -> cpmd_input[s] -> restart[0] = 0;
1584 qm_proj -> cpmd_input[s] -> restart[1] = 100;
1585 qm_proj -> cpmd_input[s] -> restart[2] = 2;
1586 qm_proj -> cpmd_input[s] -> restart[3] = 0;
1587 qm_proj -> cpmd_input[s] -> restart[4] = 1;
1588 for (i=5; i<9; i++) qm_proj -> cpmd_input[s] -> restart[i] = 0;
1589 qm_proj -> cpmd_input[s] -> restart[9] = 0;
1590 for (i=0; i<17; i++) qm_proj -> cpmd_input[s] -> default_opts[i] = default_cpmd_options[i];
1591 for (i=0; i<24; i++) qm_proj -> cpmd_input[s] -> calc_opts[i] = default_calc_options[i];
1592 qm_proj -> cpmd_input[s] -> pp = allocdint (qm_proj -> nspec, 2);
1593 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;
1594 qm_proj -> cpmd_input[s] -> info = g_strdup_printf (" Project name: %s\n"
1595 " Total number of atoms: %d\n"
1596 " Number of chemical species: %d",
1597 prepare_for_title(qm_proj -> name), qm_proj -> natomes, qm_proj -> nspec);
1598 }
1599 tmp_cpmd = qm_proj -> cpmd_input[s];
1600 }
1601 else
1602 {
1603 is_cpmd = FALSE;
1604 if (qm_proj -> cp2k_input[s] == NULL)
1605 {
1606 qm_proj -> cp2k_input[s] = g_malloc0 (sizeof*qm_proj -> cp2k_input[s]);
1607 qm_proj -> cp2k_input[s] -> input_type = 0;
1608 for (i=0; i<2; i++)
1609 {
1610 qm_proj -> cp2k_input[s] -> fixat[i] = 0;
1611 qm_proj -> cp2k_input[s] -> fixlist[i] = NULL;
1612 qm_proj -> cp2k_input[s] -> fixcoord[i] = NULL;
1613 }
1614 qm_proj -> cp2k_input[s] -> thermostats = 0;
1615 qm_proj -> cp2k_input[s] -> ions_thermostat = NULL;
1616 for (i=0; i<5; i++) qm_proj -> cp2k_input[s] -> files[i] = NULL;
1617 for (i=0; i<41; i++) qm_proj -> cp2k_input[s] -> opts[i] = default_cp2k_options[i];
1618 qm_proj -> cp2k_input[s] -> opts[CP2SYM] = find_cp2k_sym ();
1619 for (i=0; i<3; i++)
1620 {
1621 for (j=0;j<4;j++) qm_proj -> cp2k_input[s] -> extra_opts[i][j] = default_cp2k_extra[i][j];
1622 if (i == 0) qm_proj -> cp2k_input[s] -> extra_opts[i][2] = default_vdw_cut[0];
1623 }
1624 qm_proj -> cp2k_input[s] -> spec_data = allocdint(qm_proj -> nspec, 2);
1625 qm_proj -> cp2k_input[s] -> spec_files = g_malloc (qm_proj -> nspec*sizeof*qm_proj -> cp2k_input[s] -> spec_files);
1626 for (i=0; i<qm_proj -> nspec; i++)
1627 {
1628 qm_proj -> cp2k_input[s] -> spec_data[i][0] = cp2k_is_basis_in_database (i);
1629 qm_proj -> cp2k_input[s] -> spec_data[i][1] = cp2k_is_pseudo_in_database (i);
1630 qm_proj -> cp2k_input[s] -> spec_files[i] = g_malloc0 (2*sizeof*qm_proj -> cp2k_input[s] -> spec_files[i]);
1631 qm_proj -> cp2k_input[s] -> spec_files[i][0] = NULL;
1632 qm_proj -> cp2k_input[s] -> spec_files[i][1] = NULL;
1633 }
1634 gchar * defname[2]={"basis.inc", "pseudo.inc"};
1635 for (j=0;j<2;j++)
1636 {
1637 for (i=0; i<qm_proj -> nspec; i++)
1638 {
1639 if (qm_proj -> cp2k_input[s] -> spec_data[i][j] > -1)
1640 {
1641 qm_proj -> cp2k_input[s] -> files[1+j] = g_strdup_printf ("%s", defname[j]);
1642 break;
1643 }
1644 }
1645 }
1646 qm_proj -> cp2k_input[s] -> info = g_strdup_printf (" Project name: %s\n"
1647 " Total number of atoms: %d\n"
1648 " Number of chemical species: %d",
1649 prepare_for_title(qm_proj -> name), qm_proj -> natomes, qm_proj -> nspec);
1650 }
1651 tmp_cp2k = qm_proj -> cp2k_input[s];
1652 }
1653 qm_coord = qm_proj -> coord;
1654 qm_view = qm_proj -> modelgl;
1655
1656 gtk_window_set_resizable (GTK_WINDOW (qm_assistant), FALSE);
1657 gtk_window_set_modal (GTK_WINDOW (qm_assistant), TRUE);
1658 gchar * str = g_strdup_printf ("Basic %s - %s - calculation assistant", co_type[c], qm_type[s]);
1659 gtk_window_set_title (GTK_WINDOW(qm_assistant), str);
1660 g_free (str);
1661
1662 GtkWidget * intro = create_vbox (BSEP);
1663 gchar * info = g_strdup_printf ("\t<b>This assistant will help you to setup a %s %s\n"
1664 "\tcalculation using <i>%s</i> 3D model as starting point</b>\n"
1665 "\nPlease note that the %s code offers so many calculation options that it is not possible\n"
1666 "to provide a description and offer a comprehensive usage guide for each of them. \n"
1667 "Therefore this assistant only provides help towards basics and / or frequently used %s instructions. \n\n"
1668 "<b>In any case if you intent to use the %s code please refer to the user manual.</b>",
1669 qm_type[s], co_type[c], qm_proj -> name, co_type[c], co_type[c], co_type[c]);
1670 add_box_child_start (GTK_ORIENTATION_VERTICAL, intro, markup_label(info, -1, -1, 0.5, 0.5), TRUE, TRUE, 50);
1671 g_free (info);
1672
1673 add_box_child_start (GTK_ORIENTATION_VERTICAL, intro,
1674 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),
1675 FALSE, FALSE, 0);
1676 gtk_assistant_append_page (GTK_ASSISTANT (qm_assistant), intro);
1677 str = g_strdup_printf ("%s calculation set-up", co_type[c]);
1678 gtk_assistant_set_page_title (GTK_ASSISTANT (qm_assistant), intro, str);
1679 g_free (str);
1680 gtk_assistant_set_page_type (GTK_ASSISTANT (qm_assistant), intro, GTK_ASSISTANT_PAGE_INTRO);
1681 gtk_assistant_set_page_complete (GTK_ASSISTANT (qm_assistant), intro, qm_assist_init);
1682 if (c == 0)
1683 {
1684 add_cpmd_pages ();
1685 }
1686 else
1687 {
1688 add_cp2k_pages ();
1689 }
1690 gtk_assistant_set_forward_page_func (GTK_ASSISTANT (qm_assistant), on_qm_assistant_go_forward, GINT_TO_POINTER(c), NULL);
1691 qm_preview_but = create_button ("Preview", IMG_STOCK, EDITF, -1, -1, GTK_RELIEF_NORMAL, G_CALLBACK(show_qm_file_preview), GINT_TO_POINTER(c));
1692 gtk_assistant_add_action_widget (GTK_ASSISTANT (qm_assistant), qm_preview_but);
1693 g_signal_connect (G_OBJECT (qm_assistant), "prepare", G_CALLBACK(on_qm_assistant_prepare), GINT_TO_POINTER(c));
1694 g_signal_connect (G_OBJECT (qm_assistant), "cancel", G_CALLBACK(on_qm_assistant_cancel), GINT_TO_POINTER(c));
1695 g_signal_connect (G_OBJECT (qm_assistant), "close", G_CALLBACK(on_qm_assistant_close), GINT_TO_POINTER(c));
1696 g_signal_connect (G_OBJECT (qm_assistant), "apply", G_CALLBACK(on_qm_assistant_apply), GINT_TO_POINTER(c));
1697 add_gtk_close_event (qm_assistant, G_CALLBACK(on_qm_assistant_cancel_event), GINT_TO_POINTER(c));
1698
1699 gtk_assistant_set_page_complete (GTK_ASSISTANT (qm_assistant),
1700 gtk_assistant_get_nth_page(GTK_ASSISTANT (qm_assistant), 0), TRUE);
1703 if (c == 0)
1704 {
1705 for (i=0; i<NCPMDCALC; i++) hide_the_widgets (calc_box[i]);
1706 show_the_widgets (calc_box[tmp_cpmd -> calc_type]);
1707 if (tmp_cpmd -> calc_type != 2) hide_the_widgets (electron_box);
1708 }
1710}
1711
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:1228
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
Variable declarations for the creation of the CPMD input file.
#define NSECOP
Definition cpmd.h:37
#define DEFFI
Definition cpmd.h:50
#define DEFLO
Definition cpmd.h:54
#define CONVO
Definition cpmd.h:56
#define TSTPO
Definition cpmd.h:59
#define CONVG
Definition cpmd.h:60
#define NCACOMBO
Definition cpmd.h:32
#define STEPO
Definition cpmd.h:58
#define STEPG
Definition cpmd.h:62
#define DEFDU
Definition cpmd.h:51
#define DEFSP
Definition cpmd.h:52
#define TSTPB
Definition cpmd.h:75
#define DEFCU
Definition cpmd.h:48
#define DEFDG
Definition cpmd.h:47
#define TSTPG
Definition cpmd.h:66
#define AFAIB
Definition cpmd.h:78
#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
#define TSTPC
Definition cpmd.h:68
#define DEFLM
Definition cpmd.h:53
#define DEFEM
Definition cpmd.h:38
#define NSYM
Definition cpmd.h:34
#define ANNIB
Definition cpmd.h:77
#define AFAEC
Definition cpmd.h:73
#define AFAIC
Definition cpmd.h:71
#define KSUNO
Definition cpmd.h:79
#define DEFCO
Definition cpmd.h:49
GtkWidget * sel_but[3]
Definition cpmd_nose.c:137
#define STEPC
Definition cpmd.h:67
#define NOPTPC
Definition cpmd.h:35
#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
dummy_atom * dummy
Definition cpmd_atoms.c:73
GtkWidget * calc_qm_option_box(int c)
CPMD input assistant prepare the calculation option widgets.
Definition cpmd_init.c:655
void print_cp2k(int f, GtkTextBuffer *buffer)
print the CP2K input file section
double default_calc_options[24]
Definition cpmd_init.c:163
GtkWidget * qm_option_box[MAXDATAQM-1]
Definition cpmd_init.c:234
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:640
GtkWidget * info_box()
create CPMD input file information widgets
Definition cpmd_init.c:788
int type_thermo[2]
Definition cpmd_init.c:221
GtkWidget * prepare_qm_option_box(int s)
CPM input file creation prepare section general options widgets.
Definition cpmd_init.c:425
gchar * thermo_name[2][5]
Definition cpmd_init.c:218
GtkWidget * section_box(int s)
create CPMD section box
Definition cpmd_init.c:809
G_MODULE_EXPORT void changed_calc_opt_box(GtkComboBox *box, gpointer data)
change CPMD calculation option
Definition cpmd_init.c:609
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:248
GtkWidget * electron_box
Definition cpmd_nose.c:139
gboolean qm_assist_init
Definition cpmd_init.c:226
G_MODULE_EXPORT void changed_info(GtkTextBuffer *textbuf, gpointer data)
update CPMD input file preview
Definition cpmd_init.c:772
gchar * rest_opts[3]
Definition cpmd_init.c:215
gboolean is_cpmd
Definition cpmd_init.c:235
GtkWidget * calc_combo
Definition cpmd_init.c:225
G_MODULE_EXPORT void on_qm_assistant_cancel(GtkAssistant *assistant, gpointer data)
cancel QM / QM-MM input file creation
Definition cpmd_init.c:1047
gchar * page_name(int p)
get CPMD input creation assistant page name
Definition cpmd_init.c:953
gchar * co_type[2]
Definition cpmd_init.c:101
GtkWidget * ppbox[2]
Definition cpmd_init.c:232
gchar * rest_kw[2]
Definition cpmd_init.c:214
gchar * calc_ds[NCPMDCALC]
Definition cpmd_init.c:192
gboolean are_all_atoms_thermostated()
are all atom(s) in the model thermostated ?
Definition cpmd_nose.c:198
gchar * termoke[2]
Definition cpmd_init.c:222
void create_selection_combo(int id, int num, int type, GCallback handler)
create thermostat selection combo box
Definition cpmd_nose.c:1499
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:1110
gchar * default_text[9][NDFT]
Definition cpmd_init.c:150
G_MODULE_EXPORT void update_cpmd_check(GtkToggleButton *but, gpointer data)
update CPMD QM option toggle callback GTK3
Definition cpmd_init.c:349
void add_cp2k_pages()
add pages to the CP2 assistant
Definition cp2k_init.c:1182
gchar * calc_box_name[NCACOMBO][3]
Definition cpmd_init.c:202
G_MODULE_EXPORT void changed_calc_box(GtkComboBox *box, gpointer data)
change CPMD calculation type
Definition cpmd_init.c:741
gchar * nosekey[2]
Definition cpmd_init.c:217
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:1343
G_MODULE_EXPORT void show_qm_file_preview(GtkButton *but, gpointer data)
show QM / QM-MM input file preview
Definition cpmd_init.c:1222
gchar * cdescr[MAXDATAQM]
Definition cpmd_init.c:113
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:907
void print_the_section(int s, int p, GtkTextBuffer *buffer)
print CPMD input section
Definition cpmd_print.c:695
cpmd * tmp_cpmd
Definition cpmd_init.c:103
GtkWidget * latbox
Definition cpmd_init.c:229
GtkWidget * qm_preview_box(int c, int s, int l)
prepare preview section widgets
Definition cpmd_init.c:881
int num_thermo[2]
Definition cpmd_init.c:220
int qm_saved_label_format[2]
Definition cpmd_init.c:227
double default_cpmd_options[17]
Definition cpmd_init.c:121
GtkWidget * calc_box[NCPMDCALC]
Definition cpmd_init.c:233
GtkWidget * vbox_cpmd(int s)
create CPMD input creation section widgets
Definition cpmd_init.c:930
gchar * calc_opts[NCPMDCALC][NOPTPC]
Definition cpmd_init.c:169
GtkWidget * qm_preview_but
Definition cpmd_init.c:224
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:1075
int defaut_num[9]
Definition cpmd_init.c:138
void proj_unselect_all_atoms()
unselect all atom(s) in the target project of the assistant
Definition cpmd_init.c:1024
int calc_box_num[NCACOMBO]
Definition cpmd_init.c:200
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:1501
G_MODULE_EXPORT void update_calc_parameter(GtkEntry *res, gpointer data)
update CPMD calculation option value entry callback
Definition cpmd_init.c:574
gchar * default_keywords[9][NDFT]
Definition cpmd_init.c:140
gchar * cpmd_elements[MAXDATAQM]
Definition cpmd_init.c:105
void print_all_sections(GtkTextBuffer *buf)
print all sections of the CPMD input file
Definition cpmd_init.c:263
GtkWidget * but_at[2]
Definition cpmd_init.c:230
int default_opts_type[MAXDATAQM-1][NSECOP]
Definition cpmd_init.c:131
gchar * default_opts[MAXDATAQM-1][NSECOP]
Definition cpmd_init.c:123
void create_qm_input_file(int c, int p, int s)
initialize an ab-initio MD input file creation assistant
Definition cpmd_init.c:1556
GtkWidget * calc_label
Definition cpmd_init.c:228
int default_type[NCPMDCALC][NOPTPC]
Definition cpmd_init.c:176
GtkWidget * thermo_box()
create the thermostat configuration widgets
Definition cpmd_nose.c:1884
G_MODULE_EXPORT void on_qm_assistant_close(GtkAssistant *assistant, gpointer data)
close QM / QM-MM input creation assistant
Definition cpmd_init.c:1090
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:1181
gchar * calc_kw[NCPMDCALC]
Definition cpmd_init.c:184
G_MODULE_EXPORT void changed_opt_box(GtkComboBox *box, gpointer data)
change CPMD QM option
Definition cpmd_init.c:370
void add_cpmd_pages()
add pages to the CPMD input file creation assistant
Definition cpmd_init.c:985
GtkWidget * spatbox
Definition cpmd_init.c:231
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:1205
gchar * nosetype[3]
Definition cpmd_init.c:216
G_MODULE_EXPORT void update_cpmd_parameter(GtkEntry *res, gpointer data)
update CPMD QM option value entry callback
Definition cpmd_init.c:312
G_MODULE_EXPORT void atom_button(GtkButton *but, gpointer data)
gchar * calc_box_keys[NCACOMBO][3]
Definition cpmd_init.c:208
void label(cairo_t *cr, double val, int axe, int p, project *this_proj)
draw axis label
Definition labels.c:56
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:979
GtkWidget * aview
Definition dlp_field.c:970
int ** allocdint(int xal, int yal)
allocate an int ** pointer
Definition global.c:330
double string_to_double(gpointer string)
convert string to double
Definition global.c:624
Global variable declarations Global convenience function declarations Global data structure defin...
#define EDITF
Definition global.h:206
void run_this_gtk_dialog(GtkWidget *dial, GCallback handler, gpointer data)
run a GTK (3 and 4) basic GtkDialog
Definition gtk-misc.c:501
@ IMG_NONE
Definition global.h:262
@ IMG_STOCK
Definition global.h:266
void file_chooser_set_current_folder(GtkFileChooser *chooser)
set current folder in a GtkFilechooser
Definition gtk-misc.c:2323
int combo_get_active(GtkWidget *combo)
retrieve the active item's position
Definition gtk-misc.c:909
GtkWidget * create_entry(GCallback handler, int dim, int cdim, gboolean key_release, gpointer data)
Create a GtkEntry.
Definition gtk-misc.c:1375
void update_entry_double(GtkEntry *entry, double doubleval)
update the content of a GtkEntry as double
Definition gtk-misc.c:643
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:1260
GtkTextBuffer * add_buffer(GCallback handler, gpointer data, gchar *text)
create a GtkTextBuffer
Definition gtk-misc.c:1232
GtkWidget * create_scroll(GtkWidget *box, int dimx, int dimy, int shadow)
create a scroll window
Definition gtk-misc.c:2095
GtkWidget * dialogmodal(gchar *str, GtkWindow *parent)
Create a new dialog modal window.
Definition gtk-misc.c:520
gboolean is_the_widget_visible(GtkWidget *widg)
test if a GtkWidget exist, then return if it is visible or not
Definition gtk-misc.c:724
void combo_set_active(GtkWidget *combo, int pos)
set the active item's position
Definition gtk-misc.c:932
gchar * file_chooser_get_file_name(GtkFileChooser *chooser)
get a file name from a GtkFileChooser (single file selected)
Definition gtk-misc.c:2271
const gchar * entry_get_text(GtkEntry *entry)
get the text in a GtkEntry
Definition gtk-misc.c:607
#define BSEP
Definition global.h:247
void opengl_project_changed(int id)
change the OpenGL project
Definition update_p.c:245
void update_entry_int(GtkEntry *entry, int intval)
update the content of a GtkEntry as int
Definition gtk-misc.c:624
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:2522
gchar * file_chooser_get_current_folder(GtkFileChooser *chooser)
get the current folder for a GtkFileChooser
Definition gtk-misc.c:2287
GtkWidget * check_button(gchar *text, int dimx, int dimy, gboolean state, GCallback handler, gpointer data)
create a check button
Definition gtk-misc.c:1893
@ CONTAINER_SCR
Definition global.h:253
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:1955
GtkWidget * create_combo()
create a GtkCombox widget, note deprecated in GTK4
Definition gtk-misc.c:984
GtkWidget * dialog_get_content_area(GtkWidget *widg)
prepare GtkWidget to insert content in a GtkDialog window
Definition gtk-misc.c:835
GtkWidget * markup_label(gchar *text, int dimx, int dimy, float ax, float ay)
create a GtkLabel with pango markup
Definition gtk-misc.c:1646
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:308
void widget_set_sensitive(GtkWidget *widg, gboolean sensitive)
Set sensitivity for a GtkWidget, ensuring it is a GtkWidget.
Definition gtk-misc.c:215
void destroy_this_dialog(GtkDialog *dialog)
destroy a GtkDialog
Definition gtk-misc.c:2200
GtkWidget * create_hbox(int spacing)
create a GtkBox with horizontal orientation
Definition gtk-misc.c:823
void combo_text_append(GtkWidget *combo, gchar *text)
append text in GtkComboBox widget
Definition gtk-misc.c:961
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:2237
GtkWidget * destroy_this_widget(GtkWidget *widg)
destroy a GtkWidget
Definition gtk-misc.c:2169
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:235
void hide_the_widgets(GtkWidget *widg)
hide GtkWidget
Definition gtk-misc.c:198
GtkWidget * create_vbox(int spacing)
create a GtkBox with vertical orientation
Definition gtk-misc.c:811
int button_get_status(GtkWidget *button)
get status of check / toggle button
Definition gtk-misc.c:1855
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:2358
void destroy_this_native_dialog(GtkNativeDialog *dialog)
destroy a GtkNativeDialog
Definition gtk-misc.c:2219
void show_the_widgets(GtkWidget *widg)
show GtkWidget
Definition gtk-misc.c:182
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:662
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:234
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:799
Messaging function declarations.
Function declarations for reading atomes project file Function declarations for saving atomes proje...
Definition glwin.h:351
Definition global.h:776
Definition glwin.h:965
int c
Definition tab-1.c:95
GtkFileFilter * filter1
Definition w_data.c:52
GtkFileFilter * filter2
Definition w_data.c:52
GtkWidget * res[2]
Definition w_encode.c:212
GtkWidget * hbox
Definition workspace.c:71
GtkWidget * vbox
Definition workspace.c:72
GtkWidget * lab
Definition workspace.c:73