atomes 1.1.16
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-2024 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;
354#ifdef GTK4
355 j = gtk_check_button_get_active (but);
356#else
357 j = gtk_toggle_button_get_active (but);
358#endif
359 if (i == DEFCO || i == DEFDU)
360 {
361 widget_set_sensitive (but_at[(i == DEFCO) ? 0 : 1], j);
362 }
363 tmp_cpmd -> default_opts[i] = (double) j;
364 print_all_sections (NULL);
365}
366
375G_MODULE_EXPORT void changed_opt_box (GtkComboBox * box, gpointer data)
376{
377 int i, j, k;
378 j = GPOINTER_TO_INT(data);
379 i = gtk_combo_box_get_active (box);
380 if (j != DEFLM && j != DEFLO)
381 {
382 if (i != (int)tmp_cpmd -> default_opts[j])
383 {
384 tmp_cpmd -> default_opts[j] = (double)i;
385 if (j == DEFSP)
386 {
387 k = (int)tmp_cpmd -> default_opts[j];
388 gtk_combo_box_set_active (GTK_COMBO_BOX(ppbox[0]), tmp_cpmd -> pp[k][0]);
389 gtk_combo_box_set_active (GTK_COMBO_BOX(ppbox[1]), tmp_cpmd -> pp[k][1]);
390 }
391 else if (j == DEFFI)
392 {
394 if (tmp_cpmd -> fixlist != NULL)
395 {
396 g_free (tmp_cpmd -> fixlist);
397 tmp_cpmd -> fixlist = NULL;
398 if (tmp_cpmd -> fixcoord != NULL)
399 {
400 g_free (tmp_cpmd -> fixcoord);
401 tmp_cpmd -> fixcoord = NULL;
402 }
403 }
404 tmp_cpmd -> fixat = 0;
406 }
407 }
408 }
409 else
410 {
411 if (i != tmp_cpmd -> pp[(int)tmp_cpmd -> default_opts[DEFSP]][j-DEFLM])
412 {
413 tmp_cpmd -> pp[(int)tmp_cpmd -> default_opts[DEFSP]][j-DEFLM] = i;
414 }
415 }
416 if (j == DEFVE)
417 {
419 }
420 print_all_sections (NULL);
421}
422
430GtkWidget * prepare_qm_option_box (int s)
431{
432 int i, j, k, l;
433 GtkWidget * hbox;
434 GtkWidget * widg;
435 gchar * str;
436 gchar * atom_but[2] = {"Configure constraints", "Configure dummy atoms"};
437 GtkWidget * vbox = create_vbox (BSEP);
438 for (i=0; i<NSECOP; i++)
439 {
440 if (default_opts_type[s][i] > 0)
441 {
442 ident ++;
443 if (ident == DEFAB || ident == DEFDG || ident == DEFSY)
444 {
445 hbox = cpmd_box (latbox, default_opts[s][i], 5, 20, (s == 1) ? 150 : 220);
446 }
447 else if (ident == DEFCO || ident == DEFDU)
448 {
449 hbox = cpmd_box (vbox, default_opts[s][i], 20, 20, 180);
450 }
451 else if (ident == DEFLM || ident == DEFLO)
452 {
453 hbox = cpmd_box (spatbox, default_opts[s][i], 5, 20, 220);
454 }
455 else
456 {
457 hbox = cpmd_box (vbox, default_opts[s][i], (ident == DEFSP) ? 20 : 5, 5, (s == 1) ? 150 : 220);
458 }
459 j = ident;
460 switch (default_opts_type[s][i])
461 {
462 case 1:
463 widg = create_entry (G_CALLBACK(update_cpmd_parameter), 100, 15, FALSE, GINT_TO_POINTER(j));
464 if (j == DEFGC)
465 {
466 update_entry_long_double (GTK_ENTRY(widg), tmp_cpmd -> default_opts[j]);
467 }
468 else
469 {
470 update_entry_double (GTK_ENTRY(widg), tmp_cpmd -> default_opts[j]);
471 }
472 break;
473 case 2:
474 icomb ++;
475 if (ident == DEFLM || ident == DEFLO)
476 {
478 }
479 else
480 {
481 widg = create_combo ();
482 }
483 l = (ident == DEFSP) ? qm_proj -> nspec : defaut_num[icomb];
484 for (k=0; k<l; k++)
485 {
486 if (icomb == 0)
487 {
488 str = g_strdup_printf ("%s (%s)", default_text[0][k], default_keywords[0][k]);
489 }
490 else if (ident == DEFSP)
491 {
492 str = g_strdup_printf ("%s atom(s)", qm_proj -> chemistry -> label[k]);
493 }
494 else
495 {
496 str = g_strdup_printf ("%s", default_text[icomb][k]);
497 }
498 if (ident == DEFLM || ident == DEFLO)
499 {
501 }
502 else
503 {
504 combo_text_append (widg, str);
505 }
506 g_free (str);
507 }
508 if (ident == DEFLM || ident == DEFLO)
509 {
510 gtk_combo_box_set_active (GTK_COMBO_BOX(ppbox[ident - DEFLM]), tmp_cpmd -> pp[(int)tmp_cpmd -> default_opts[DEFSP]][ident - DEFLM]);
511 g_signal_connect (G_OBJECT (ppbox[ident - DEFLM]), "changed", G_CALLBACK(changed_opt_box), GINT_TO_POINTER(j));
512 }
513 else
514 {
515 gtk_combo_box_set_active (GTK_COMBO_BOX(widg), (int)tmp_cpmd -> default_opts[j]);
516 g_signal_connect (G_OBJECT (widg), "changed", G_CALLBACK(changed_opt_box), GINT_TO_POINTER(j));
517 }
518 break;
519 case 3:
520 widg = check_button (NULL, -1, -1, tmp_cpmd -> default_opts[j], G_CALLBACK(update_cpmd_check), GINT_TO_POINTER(j));
521 break;
522 }
523 if (ident == DEFLM || ident == DEFLO)
524 {
525 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, ppbox[ident - DEFLM], FALSE, FALSE, 0);
526 }
527 else
528 {
529 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, widg, FALSE, FALSE, 0);
530 }
531 if (j==DEFEM || j==DEFGC || j==DEFCU)
532 {
533 if (j==DEFEM || j==DEFGC)
534 {
535 widg = gtk_label_new ("a.u.");
536 }
537 else
538 {
539 widg = gtk_label_new ("Ry");
540 }
541 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, widg, FALSE, FALSE, 5);
542 }
543 else if (j == DEFVE)
544 {
546 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, latbox, FALSE, FALSE, 15);
548 }
549 else if (j == DEFCO || j == DEFDU)
550 {
551 k = (j==DEFCO) ? 0 : 1;
552 but_at[k] = create_button (atom_but[k], IMG_NONE, NULL, 175, -1, GTK_RELIEF_NORMAL, G_CALLBACK(atom_button), GINT_TO_POINTER(j));
554 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, but_at[k], FALSE, FALSE, 20);
555 if (j == DEFCO)
556 {
557 ident ++;
558 icomb ++;
559 }
560 }
561 else if (j == DEFSP)
562 {
564 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, spatbox, FALSE, FALSE, 15);
565 }
566 }
567 }
568 return vbox;
569}
570
579G_MODULE_EXPORT void update_calc_parameter (GtkEntry * res, gpointer data)
580{
581 int i, j;
582 i = GPOINTER_TO_INT(data);
583 const gchar * m = entry_get_text (res);
584 double v = string_to_double ((gpointer)m);
585 if (i==STEPO || i==STEPG || i==STEPC || i==STEPB || i==KSUNO || i==NBAND)
586 {
587 j = (int) v;
588 tmp_cpmd -> calc_opts[i] = (double) j;
590 }
591 else
592 {
593 tmp_cpmd -> calc_opts[i] = v;
594 if (i == CONVO || i == CONVG)
595 {
597 }
598 else
599 {
601 }
602 }
603 for (i=1; i<4; i++) print_the_section (i, 0, qmbuffer[i]);
604}
605
614G_MODULE_EXPORT void changed_calc_opt_box (GtkComboBox * box, gpointer data)
615{
616 int i, j;
617 j = GPOINTER_TO_INT(data);
618 i = gtk_combo_box_get_active (box);
619 if (i != tmp_cpmd -> calc_opts[j])
620 {
621 tmp_cpmd -> calc_opts[j] = i;
622 for (j=1; j<4; j++) print_the_section (j, 0, qmbuffer[j]);
623 }
624}
625
626#ifdef GTK4
635G_MODULE_EXPORT void update_calc_check (GtkCheckButton * but, gpointer data)
636#else
645G_MODULE_EXPORT void update_calc_check (GtkToggleButton * but, gpointer data)
646#endif
647{
648 int i = GPOINTER_TO_INT(data);
649#ifdef GTK4
650 tmp_cpmd -> calc_opts[i] = (double) gtk_check_button_get_active (but);
651#else
652 tmp_cpmd -> calc_opts[i] = (double) gtk_toggle_button_get_active (but);
653#endif
654 for (i=1; i<4; i++) print_the_section (i, 0, qmbuffer[i]);
655}
656
664GtkWidget * calc_qm_option_box (int c)
665{
666 int i, j, k, l;
667 GtkWidget * hbox;
668 GtkWidget * widg;
669 gchar * str;
670 GtkWidget * vbox = create_vbox (BSEP);
671 for (i=0; i<NOPTPC; i++)
672 {
673 if (default_type[c][i] > 0)
674 {
675 idopt ++;
676 l = 0;
677 if (idopt == ANNIC || idopt == ANNIB)
678 {
679 hbox = cpmd_box (vbox, "Annealing:", 0, 5, 220);
680 }
681 if (idopt == ANNIC || idopt == ANNEC || idopt == ANNIB)
682 {
683 hbox = cpmd_box (vbox, calc_opts[c][i], 0, 25, 120);
684 l = 30;
685 }
686 else if (idopt == AFAIC || idopt == AFAEC || idopt == AFAIB)
687 {
688 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, gtk_label_new(calc_opts[c][i]), FALSE, FALSE, 10);
689 l = 30;
690 }
691 else
692 {
693 hbox = cpmd_box (vbox, calc_opts[c][i], 0, 5, 220);
694 }
695 j = idopt;
696 switch (default_type[c][i])
697 {
698 case 1:
699 widg = create_entry (G_CALLBACK(update_calc_parameter), 100, 15, FALSE, GINT_TO_POINTER(j));
700 if (j==STEPO || j==STEPG || j==STEPC || j==STEPB || j==KSUNO || j==NBAND)
701 {
702 update_entry_int (GTK_ENTRY(widg), (int) tmp_cpmd -> calc_opts[j]);
703 }
704 else
705 {
706 update_entry_double (GTK_ENTRY(widg), tmp_cpmd -> calc_opts[j]);
707 }
708 break;
709 case 2:
710 icalc ++;
711 widg = create_combo ();
712 for (k=0; k<calc_box_num[icalc]; k++)
713 {
714 str = g_strdup_printf ("%s", calc_box_name[icalc][k]);
715 combo_text_append (widg, str);
716 g_free (str);
717 }
718 gtk_combo_box_set_active (GTK_COMBO_BOX(widg), (int)tmp_cpmd -> calc_opts[j]);
719 g_signal_connect (G_OBJECT (widg), "changed", G_CALLBACK(changed_calc_opt_box), GINT_TO_POINTER(j));
720 break;
721 case 3:
722 widg = check_button (NULL, -1, -1, tmp_cpmd -> calc_opts[j], G_CALLBACK(update_calc_check), GINT_TO_POINTER(j));
723 break;
724 }
725 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, widg, FALSE, FALSE, l);
726 if (j==TSTPO || j==TSTPG || j==TSTPC || j==TSTPB)
727 {
728 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, gtk_label_new ("a.u."), FALSE, FALSE, 5);
729 }
730 else if (j==NBAND)
731 {
732 gchar * ksout = "\t * electronic density(ies) or/and wavefunction(s)\n"
733 "\t ** as many index(es) to be supplied on the next line:\n"
734 "\t\t &gt; 0 for electronic density\n\t\t &lt; 0 for wavefunction";
735 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label(ksout, -1, -1, 0.0, 0.5), FALSE, FALSE, 10);
736 }
737 }
738 }
739 return vbox;
740}
741
750G_MODULE_EXPORT void changed_calc_box (GtkComboBox * box, gpointer data)
751{
752 int i;
753 i = gtk_combo_box_get_active (box);
754 if (i != tmp_cpmd -> calc_type)
755 {
756 gtk_label_set_text (GTK_LABEL(calc_label), g_strdup_printf ("<u>%s option(s)</u>", calc_ds[i]));
757 gtk_label_set_use_markup (GTK_LABEL(calc_label), TRUE);
758 hide_the_widgets (calc_box[tmp_cpmd -> calc_type]);
760 tmp_cpmd -> calc_type = i;
761 if (tmp_cpmd -> calc_type != 2)
762 {
764 }
765 else
766 {
768 }
769 for (i=1; i<4; i++) print_the_section (i, 0, qmbuffer[i]);
770 }
771}
772
781G_MODULE_EXPORT void changed_info (GtkTextBuffer * textbuf, gpointer data)
782{
783 GtkTextIter bStart;
784 GtkTextIter bEnd;
785 gtk_text_buffer_get_start_iter (textbuf, & bStart);
786 gtk_text_buffer_get_end_iter (textbuf, & bEnd);
787 if (tmp_cpmd -> info != NULL) g_free (tmp_cpmd -> info);
788 tmp_cpmd -> info = g_strdup_printf ("%s", gtk_text_buffer_get_text (textbuf, & bStart, & bEnd, FALSE));
789 print_the_section (0, 0, qmbuffer[0]);
790}
791
797GtkWidget * info_box ()
798{
799 GtkWidget * vbox = create_vbox (BSEP);
800 GtkWidget * hbox = create_hbox (0);
801 GtkWidget * scrollsets = create_scroll (NULL, 355, 250, GTK_SHADOW_ETCHED_IN);
802 GtkWidget * aview = create_text_view (-1, -1, 1, 0, G_CALLBACK(changed_info), NULL, NULL);
803 if (tmp_cpmd -> info != NULL) print_info (tmp_cpmd -> info, NULL, gtk_text_view_get_buffer(GTK_TEXT_VIEW(aview)));
805 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, scrollsets, FALSE, FALSE, 85);
806 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 0);
807
808 return vbox;
809}
810
818GtkWidget * section_box (int s)
819{
820 int i;
821 gchar * str;
822 GtkWidget * hbox;
823 GtkWidget * vbox = create_vbox (BSEP);
824 if (s == 0)
825 {
826 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, info_box(), FALSE, FALSE, 50);
827 }
828 else if (s == 1)
829 {
830 // CPMD Calculation
831 /* Calc type combo_box: */
832 idopt = -1;
833 icalc = -1;
834 ident = -1;
835 icomb = -1;
836 hbox = create_hbox (0);
837 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);
839 for (i=0; i<NCPMDCALC; i++) combo_text_append (calc_combo, calc_ds[i]);
840 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, calc_combo, FALSE, FALSE, 10);
841 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 0);
842
843 /* Calc related options: */
844 str = g_strdup_printf ("<u>%s option(s)</u>", calc_ds[tmp_cpmd -> calc_type]);
845 calc_label = markup_label(str, -1, -1, 0.0, 0.5);
846 g_free (str);
847 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, calc_label, FALSE, FALSE, 10);
848 for (i=0; i<NCPMDCALC; i++)
849 {
851 gtk_widget_set_size_request (calc_box[i], -1, 200);
852 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, calc_box[i], FALSE, FALSE, 0);
853 }
854 g_signal_connect (G_OBJECT (calc_combo), "changed", G_CALLBACK(changed_calc_box), NULL);
855 gtk_combo_box_set_active (GTK_COMBO_BOX(calc_combo), tmp_cpmd -> calc_type);
856 }
857 else if (s == 2)
858 {
859 // CPMD - thermostat(s)
860 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, thermo_box(), FALSE, FALSE, 5);
861 }
862 else if (s == 3)
863 {
864 // CPMD - restart
865 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, restart_box(), FALSE, FALSE, 0);
866 }
867
868 /* General CPMD section options: */
869 if (s > 0 && s != 2 && s != 3)
870 {
871 i = (s == 1) ? s : s - 2;
872 str = g_strdup_printf ("<u>General %s section option(s)</u>",cpmd_elements[i]);
873 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label(str, 525, -1, 0.0, 0.5), FALSE, FALSE, 10);
874 g_free (str);
876 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, qm_option_box[i-1], FALSE, FALSE, 0);
877 }
878 return vbox;
879}
880
890GtkWidget * qm_preview_box (int c, int s, int l)
891{
892 GtkWidget * vbox = create_vbox (BSEP);
893 GtkWidget * scrollsets = create_scroll (NULL, 250, (c) ? 280 : 410, GTK_SHADOW_ETCHED_IN);
894 GtkWidget * aview = create_text_view (-1, -1, 0, 1, NULL, NULL, NULL);
895 qmbuffer[s] = gtk_text_view_get_buffer (GTK_TEXT_VIEW(aview));
897 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, scrollsets, FALSE, FALSE, l);
898 if (c == 0)
899 {
900 print_the_section (s, 0, qmbuffer[s]);
901 }
902 else
903 {
904 print_cp2k (s, qmbuffer[s]);
905 }
906 return vbox;
907}
908
916gchar * section_name (int p)
917{
918 if (p > 0 && p < 4)
919 {
920 return g_strdup_printf ("Details of the <b>%s</b> section that %s", cpmd_elements[1], cdescr[1]);
921 }
922 else if (p == 0)
923 {
924 return g_strdup_printf ("Details of the <b>%s</b> section that %s", cpmd_elements[p], cdescr[p]);
925 }
926 else
927 {
928 return g_strdup_printf ("Details of the <b>%s</b> section that %s", cpmd_elements[p-2], cdescr[p-2]);
929 }
930}
931
939GtkWidget * vbox_cpmd (int s)
940{
941 GtkWidget * vbox;
942 GtkWidget * hbox;
944 hbox = create_hbox (0);
945 if (s < 2 || s > 3)
946 {
947 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label(section_name(s), -1, 20, 0.0, 0.5), FALSE, FALSE, 20);
948 }
949 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, (s < 2 ||s > 3) ? 5 : 0);
950 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, section_box(s), FALSE, FALSE, 0);
951 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, qm_preview_box (0, s, (s < 2 ||s > 3) ? 0 : 65), FALSE, FALSE, 0);
952 return vbox;
953}
954
962gchar * page_name (int p)
963{
964 if (p > 0 && p <4)
965 {
966 if (p == 1)
967 {
968 return g_strdup_printf ("The %s section - Calculation options", cpmd_elements[1]);
969 }
970 else if (p == 2)
971 {
972 return g_strdup_printf ("The %s section - Thermostat options", cpmd_elements[1]);
973 }
974 else
975 {
976 return g_strdup_printf ("The %s section - RESTART options", cpmd_elements[1]);
977 }
978 }
979 else if (p == 0)
980 {
981 return g_strdup_printf ("The %s section", cpmd_elements[p]);
982 }
983 else
984 {
985 return g_strdup_printf ("The %s section", cpmd_elements[p-2]);
986 }
987}
988
995{
996 int i;
997 gchar * info;
998 GtkAssistant * assist = GTK_ASSISTANT(qm_assistant);
999 GtkWidget * page;
1000 for (i=0; i<MAXDATAQM+2; i++)
1001 {
1002 page = vbox_cpmd (i);
1003 gtk_assistant_append_page (assist, page);
1004 gtk_assistant_set_page_title (assist, page, page_name(i));
1005 gtk_assistant_set_page_type (assist, page, GTK_ASSISTANT_PAGE_CONTENT);
1006 if (i != 3)
1007 {
1008 gtk_assistant_set_page_complete (assist, page, TRUE);
1009 }
1010 else
1011 {
1012 gtk_assistant_set_page_complete (assist, page, are_all_atoms_thermostated ());
1013 }
1014 }
1015
1016 GtkWidget * conclu = create_vbox (BSEP);
1017 info = g_strdup_printf ("<b> Finalize the creation of the CPMD input file now !</b>");
1018 add_box_child_start (GTK_ORIENTATION_VERTICAL, conclu, markup_label(info, -1, -1, 0.5, 0.5), TRUE, TRUE, 100);
1019 g_free (info);
1020 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);
1021 gtk_assistant_append_page (assist, conclu);
1022 gtk_assistant_set_page_title (assist, conclu, "Create the input file now !");
1023 gtk_assistant_set_page_type (assist, conclu, GTK_ASSISTANT_PAGE_CONFIRM);
1024 gtk_assistant_set_page_complete (assist, conclu, TRUE);
1025 gtk_assistant_update_buttons_state (assist);
1026}
1027
1034{
1035 int i, j;
1036 for (i=0; i<qm_proj -> natomes; i++)
1037 {
1038 for (j=0; j<2; j++)
1039 {
1040 qm_proj -> atoms[0][i].pick[j] = FALSE;
1041 qm_proj -> atoms[0][i].label[j] = FALSE;
1042 }
1043 }
1044 qm_view -> picked = 0;
1046}
1047
1056G_MODULE_EXPORT void on_qm_assistant_cancel (GtkAssistant * assistant, gpointer data)
1057{
1058 destroy_this_widget (GTK_WIDGET(assistant));
1060 // restore selection if any from calc.c
1062}
1063
1064#ifdef GTK4
1073G_MODULE_EXPORT gboolean on_qm_assistant_cancel_event (GtkWindow * assistant, gpointer data)
1074#else
1084G_MODULE_EXPORT gboolean on_qm_assistant_cancel_event (GtkWidget * assistant, GdkEvent * event, gpointer data)
1085#endif
1086{
1087 on_qm_assistant_cancel (((GtkAssistant *)assistant), data);
1088 return TRUE;
1089}
1090
1099G_MODULE_EXPORT void on_qm_assistant_close (GtkAssistant * assistant, gpointer data)
1100{
1101 // Apply changes ... then close window
1102 destroy_this_widget (GTK_WIDGET(assistant));
1103 // Saving
1104
1105 // Cleaning
1107 // restore selection if any from calc.c
1109}
1110
1119G_MODULE_EXPORT gint on_qm_assistant_go_forward (gint current_page, gpointer data)
1120{
1121 int i = GPOINTER_TO_INT(data);
1122 if (i == 0)
1123 {
1124 switch (current_page)
1125 {
1126 case MAXDATAQM+4:
1127 return -1;
1128 break;
1129 case 2:
1130 if (tmp_cpmd -> calc_type == 2 || tmp_cpmd -> calc_type == 3)
1131 {
1132 return 3;
1133 }
1134 else
1135 {
1136 return 4;
1137 }
1138 break;
1139 case 5:
1140 if ((int)tmp_cpmd -> default_opts[2])
1141 {
1142 return current_page+1;
1143 }
1144 else if (tmp_cpmd -> calc_type == 6)
1145 {
1146 return current_page+2;
1147 }
1148 else
1149 {
1150 return current_page+3;
1151 }
1152 break;
1153 case 6:
1154 if (tmp_cpmd -> calc_type == 6)
1155 {
1156 return current_page+1;
1157 }
1158 else
1159 {
1160 return current_page+2;
1161 }
1162 default:
1163 return current_page+1;
1164 break;
1165 }
1166 }
1167 else
1168 {
1169 switch (current_page)
1170 {
1171 case MAXDATAQM+4:
1172 return -1;
1173 break;
1174 default:
1175 return current_page+1;
1176 break;
1177 }
1178 }
1179}
1180
1190G_MODULE_EXPORT void on_qm_assistant_prepare (GtkAssistant * assistant, GtkWidget * page, gpointer data)
1191{
1192 int i = gtk_assistant_get_current_page (assistant);
1193 // field_unselect_all ();
1194 switch (i)
1195 {
1196 case 0:
1198 break;
1199 default:
1201 break;
1202 }
1203}
1204
1214gboolean go_for_it (int i, int j, gboolean print[2])
1215{
1216 if (tmp_cp2k -> input_type && i<=j-3) return TRUE;
1217 if (i==0) return TRUE;
1218 if (i==j-2 && print[0]) return TRUE;
1219 if (i==j-1 && print[1]) return TRUE;
1220 return FALSE;
1221}
1222
1231G_MODULE_EXPORT void show_qm_file_preview (GtkButton * but, gpointer data)
1232{
1233 int i, j, k, c;
1234 c = GPOINTER_TO_INT(data);
1235 gchar * ptitle[5] = {"CP2K input file", "forces.inc", "system.inc", "motion.inc", "coord.inc"};
1236 gchar * wtite[2] = {" input file preview", " input files preview"};
1237 gchar * str;
1238 GtkWidget * scrollsets;
1239 GtkWidget * aview;
1240 GtkWidget * notebook;
1241 k = 0;
1242 gboolean print[2];
1243 if (c)
1244 {
1245 j = 6;
1246 notebook = gtk_notebook_new ();
1247 if (tmp_cp2k -> opts[CP2RUN] > 1.0 && tmp_cp2k -> opts[CP2RUN] < 4.0) k = 1;
1248 if (tmp_cp2k -> input_type)
1249 {
1250 str = g_strdup_printf ("%s %s", co_type[c], wtite[1]);
1251 }
1252 else
1253 {
1254 str = g_strdup_printf ("%s %s", co_type[c], wtite[0]);
1255 }
1256 print[0] = print[1] = FALSE;
1257 for (i=0; i<qm_proj -> nspec; i++)
1258 {
1259 if (tmp_cp2k -> spec_data[i][0] != -1)
1260 {
1261 print[0] = TRUE;
1262 break;
1263 }
1264 }
1265 for (i=0; i<qm_proj -> nspec; i++)
1266 {
1267 if (tmp_cp2k -> spec_data[i][1] != -1)
1268 {
1269 print[1] = TRUE;
1270 break;
1271 }
1272 }
1273 }
1274 else
1275 {
1276 j = 1;
1277 str = g_strdup_printf ("%s %s", co_type[c], wtite[0]);
1278 }
1279 GtkWidget * preview = dialogmodal (str, GTK_WINDOW (qm_assistant));
1280 g_free (str);
1281 if (c)
1282 {
1283 add_box_child_start (GTK_ORIENTATION_VERTICAL, dialog_get_content_area(preview), notebook, FALSE, FALSE, 0);
1284 }
1285 else
1286 {
1287 scrollsets = create_scroll (dialog_get_content_area(preview), 700, 350, GTK_SHADOW_ETCHED_IN);
1288 }
1289 for (i=0; i<j+k; i++)
1290 {
1291 if (! c || (c && go_for_it(i, j+k, print)))
1292 {
1293 aview = create_text_view (-1, -1, 0, 1, NULL, NULL, NULL);
1294 if (c)
1295 {
1296 scrollsets = create_scroll (NULL, 700, 350, GTK_SHADOW_ETCHED_IN);
1298 if (i > j+k-3)
1299 {
1300 str = g_strdup_printf ("%s", tmp_cp2k -> files[i-(j+k-3)]);
1301 }
1302 else
1303 {
1304 str = g_strdup_printf ("%s", ptitle[(i == j-3+k) ? 4 : i]);
1305 }
1306 gtk_notebook_append_page (GTK_NOTEBOOK(notebook), scrollsets, gtk_label_new (str));
1307 g_free (str);
1308 }
1309 else
1310 {
1312 }
1313 }
1314 if (c)
1315 {
1316 if (tmp_cp2k -> input_type || i != j+k-3)
1317 {
1318 print_cp2k ((i >= j+k-3) ? i+1-k: i, gtk_text_view_get_buffer(GTK_TEXT_VIEW(aview)));
1319 }
1320 }
1321 else
1322 {
1323 print_all_sections (gtk_text_view_get_buffer(GTK_TEXT_VIEW(aview)));
1324 }
1325 }
1326 run_this_gtk_dialog (preview, G_CALLBACK(run_destroy_dialog), NULL);
1327}
1328
1329#ifdef GTK4
1339G_MODULE_EXPORT void run_saving_qm (GtkNativeDialog * info, gint response_id, gpointer data)
1340{
1341 GtkFileChooser * chooser = GTK_FILE_CHOOSER((GtkFileChooserNative *)info);
1342#else
1352G_MODULE_EXPORT void run_saving_qm (GtkDialog * info, gint response_id, gpointer data)
1353{
1354 GtkFileChooser * chooser = GTK_FILE_CHOOSER((GtkWidget *)info);
1355#endif
1356 int i, j, k, l;
1357 int c = GPOINTER_TO_INT(data);
1358 gboolean result = FALSE;
1359 gboolean done = FALSE;
1360 GtkTextBuffer * buffer = NULL;
1361 GtkTextIter bStart;
1362 GtkTextIter bEnd;
1363 GError * err = NULL;
1364 gchar * text;
1365 gchar * filename;
1366 gchar * direname;
1367 gchar * cp2sp[2] = {"basis.inc", "pseudo.inc"};
1368 gchar * cp2file[4] = {"forces.inc", "system.inc", "motion.inc", "coord.inc"};
1369 switch (response_id)
1370 {
1371 case GTK_RESPONSE_ACCEPT:
1372 filename = file_chooser_get_file_name (chooser);
1373 direname = file_chooser_get_current_folder (chooser);
1374 if (filename != NULL)
1375 {
1376 done = TRUE;
1377 if (! c || (c && ! tmp_cp2k -> input_type)) buffer = add_buffer (NULL, NULL, NULL);
1378 switch (c)
1379 {
1380 case 0:
1381 print_all_sections (buffer);
1382 break;
1383 case 1:
1384 j = 6;
1385 k = 0;
1386 if (tmp_cp2k -> opts[CP2RUN] > 1.0 && tmp_cp2k -> opts[CP2RUN] < 4.0) k = 1;
1387 for (i=0; i<j+k; i++)
1388 {
1389 if (i != j+k-3 || tmp_cp2k -> input_type)
1390 {
1391 l = (i >= j+k-3) ? i+1-k: i;
1392 if (tmp_cp2k -> input_type)
1393 {
1394 buffer = add_buffer (NULL, NULL, NULL);
1395 if (i > 0) filename = g_strdup_printf ("%s/%s", direname, cp2file[l-1]);
1396 print_cp2k (l, buffer);
1397 gtk_text_buffer_get_start_iter (buffer, & bStart);
1398 gtk_text_buffer_get_end_iter (buffer, & bEnd);
1399 text = gtk_text_buffer_get_text (buffer, & bStart, & bEnd, FALSE);
1400 gtk_text_buffer_set_modified (buffer, FALSE);
1401 result = g_file_set_contents (filename, text, -1, & err);
1402 g_free (text);
1403 g_object_unref (buffer);
1404 if (! result && err)
1405 {
1406 show_error (g_strdup_printf ("Error while saving input file: %s\n Error: %s", filename, err -> message), 0, qm_assistant);
1407 g_error_free (err);
1408 }
1409 g_free (filename);
1410 }
1411 else if (l != 5 && l != 6)
1412 {
1413 print_cp2k (l, buffer);
1414 }
1415 }
1416 }
1417 break;
1418 }
1419 if (! c || (c && ! tmp_cp2k -> input_type))
1420 {
1421 gtk_text_buffer_get_start_iter (buffer, & bStart);
1422 gtk_text_buffer_get_end_iter (buffer, & bEnd);
1423 text = gtk_text_buffer_get_text (buffer, & bStart, & bEnd, FALSE);
1424 gtk_text_buffer_set_modified (buffer, FALSE);
1425 result = g_file_set_contents (filename, text, -1, & err);
1426 g_free (text);
1427 g_object_unref (buffer);
1428 if (! result && err)
1429 {
1430 /* error saving file, show message to user */
1431 show_error (g_strdup_printf ("Error while saving input file: %s\n Error: %s", filename, err -> message), 0, qm_assistant);
1432 g_error_free (err);
1433 }
1434 g_free (filename);
1435 }
1436 if (c)
1437 {
1438 // save pseudo and basis auto
1439 for (i=0; i<2; i++)
1440 {
1441 buffer = add_buffer (NULL, NULL, NULL);
1442 filename = g_strdup_printf ("%s/%s", direname, cp2sp[i]);
1443 print_cp2k (i+5, buffer);
1444 gtk_text_buffer_get_start_iter (buffer, & bStart);
1445 gtk_text_buffer_get_end_iter (buffer, & bEnd);
1446 text = gtk_text_buffer_get_text (buffer, & bStart, & bEnd, FALSE);
1447 result = g_file_set_contents (filename, text, -1, & err);
1448 g_free (text);
1449 if (! result && err)
1450 {
1451 /* error saving file, show message to user */
1452 show_error (g_strdup_printf ("Error while saving file %s: %s", cp2sp[i], err -> message), 0, qm_assistant);
1453 g_error_free (err);
1454 break;
1455 }
1456 g_free (filename);
1457 g_object_unref (buffer);
1458 }
1459 }
1460 }
1461 break;
1462 default:
1463 done = TRUE;
1464 break;
1465 }
1466 if (done)
1467 {
1468#ifdef GTK4
1470#else
1471 destroy_this_dialog (info);
1472#endif
1473 }
1474 if (c && result)
1475 {
1476 if (tmp_cp2k -> input_type)
1477 {
1478 if (tmp_cp2k -> opts[CP2RUN] > 1.0 && tmp_cp2k -> opts[CP2RUN] < 4.0)
1479 {
1480 show_info ("The input files 'forces.inc', 'system.inc', 'motion.inc' and 'coord.inc'\n"
1481 "as well as the files 'basis.inc' and 'pseudo.inc'\n"
1482 "for the atomic basis set and peudo-potentials\n"
1483 "were saved in the same directory as the main input file.", 0, qm_assistant);
1484 }
1485 else
1486 {
1487 show_info ("The input files 'forces.inc', 'system.inc', and 'coord.inc'\n"
1488 "as well as the files 'basis.inc' and 'pseudo.inc'\n"
1489 "for the atomic basis set and peudo-potentials\n"
1490 "were saved in the same directory as the main input file.", 0, qm_assistant);
1491 }
1492 }
1493 else
1494 {
1495 show_info ("The files 'basis.inc' and 'pseudo.inc'\n"
1496 "for the atomic basis set and peudo-potentials\n"
1497 "were saved in the same directory as the main input file.", 0, qm_assistant);
1498 }
1499 }
1500}
1501
1510G_MODULE_EXPORT void on_qm_assistant_apply (GtkAssistant * assistant, gpointer data)
1511{
1512 int c = GPOINTER_TO_INT(data);
1513 gchar * text;
1514#ifdef GTK4
1515 GtkFileChooserNative * info;
1516#else
1517 GtkWidget * info;
1518#endif
1519 GtkFileFilter * filter1, * filter2;
1520 gchar * qm_type[2] = {"CPMD", "CP2K"};
1521 const gchar * qm_name[2] = {"CPMD input file (*.in)", "CP2K input file (*.inp)"};
1522 const gchar * qm_ext[2] = {".in", ".inp"};
1523
1524 text = g_strdup_printf ("Saving %s input file(s)", qm_type[c]);
1525 info = create_file_chooser (text,
1526 GTK_WINDOW(assistant),
1527 GTK_FILE_CHOOSER_ACTION_SAVE,
1528 "Save");
1529 GtkFileChooser * chooser = GTK_FILE_CHOOSER(info);
1530 g_free (text);
1531#ifdef GTK3
1532 gtk_file_chooser_set_do_overwrite_confirmation (chooser, TRUE);
1533#endif
1535 filter1 = gtk_file_filter_new();
1536 gtk_file_filter_set_name (GTK_FILE_FILTER(filter1), qm_name[c]);
1537 text = g_strdup_printf ("*%s", qm_ext[c]);
1538 gtk_file_filter_add_pattern (GTK_FILE_FILTER(filter1), text);
1539 g_free (text);
1540 gtk_file_chooser_add_filter (chooser, filter1);
1541 filter2 = gtk_file_filter_new();
1542 gtk_file_filter_set_name (GTK_FILE_FILTER(filter2), "All files (*)");
1543 gtk_file_filter_add_pattern (GTK_FILE_FILTER(filter2), "*");
1544 gtk_file_chooser_add_filter (chooser, filter2);
1545 text = g_strdup_printf ("%s%s", prepare_for_title(qm_proj -> name), qm_ext[c]);
1547 gtk_file_chooser_set_current_name (chooser, text);
1548 g_free (text);
1549#ifdef GTK4
1550 run_this_gtk_native_dialog ((GtkNativeDialog *)info, G_CALLBACK(run_saving_qm), NULL);
1551#else
1552 run_this_gtk_dialog (info, G_CALLBACK(run_saving_qm), data);
1553#endif
1554}
1555
1565void create_qm_input_file (int c, int p, int s)
1566{
1567 gchar * qm_type[2] = {"first-principles", "QM-MM"};
1568 qm_assistant = gtk_assistant_new ();
1569 gtk_widget_set_size_request (qm_assistant, 800, 600);
1570 int i, j;
1571 //field_color = TRUE;
1572 field_object = -1;
1573 //selected_aspec = -1;
1576 for (i=0; i<MAXDATAQM+2; i++) qmbuffer[i] = NULL;
1577 if (c == 0)
1578 {
1579 is_cpmd = TRUE;
1580 if (qm_proj -> cpmd_input[s] == NULL)
1581 {
1582 qm_proj -> cpmd_input[s] = g_malloc0 (sizeof*qm_proj -> cpmd_input[s]);
1583 qm_proj -> cpmd_input[s] -> calc_type = 0;
1584 qm_proj -> cpmd_input[s] -> thermostats = 0;
1585 qm_proj -> cpmd_input[s] -> ions_thermostat = NULL;
1586 qm_proj -> cpmd_input[s] -> elec_thermostat = NULL;
1587 qm_proj -> cpmd_input[s] -> dummies = 0;
1588 qm_proj -> cpmd_input[s] -> dummy = NULL;
1589 qm_proj -> cpmd_input[s] -> fixat = 0;
1590 qm_proj -> cpmd_input[s] -> fixlist = NULL;
1591 qm_proj -> cpmd_input[s] -> fixcoord = NULL;
1592 qm_proj -> cpmd_input[s] -> restart[0] = 0;
1593 qm_proj -> cpmd_input[s] -> restart[1] = 100;
1594 qm_proj -> cpmd_input[s] -> restart[2] = 2;
1595 qm_proj -> cpmd_input[s] -> restart[3] = 0;
1596 qm_proj -> cpmd_input[s] -> restart[4] = 1;
1597 for (i=5; i<9; i++) qm_proj -> cpmd_input[s] -> restart[i] = 0;
1598 qm_proj -> cpmd_input[s] -> restart[9] = 0;
1599 for (i=0; i<17; i++) qm_proj -> cpmd_input[s] -> default_opts[i] = default_cpmd_options[i];
1600 for (i=0; i<24; i++) qm_proj -> cpmd_input[s] -> calc_opts[i] = default_calc_options[i];
1601 qm_proj -> cpmd_input[s] -> pp = allocdint (qm_proj -> nspec, 2);
1602 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;
1603 qm_proj -> cpmd_input[s] -> info = g_strdup_printf (" Project name: %s\n"
1604 " Total number of atoms: %d\n"
1605 " Number of chemical species: %d",
1606 prepare_for_title(qm_proj -> name), qm_proj -> natomes, qm_proj -> nspec);
1607 }
1608 tmp_cpmd = qm_proj -> cpmd_input[s];
1609 }
1610 else
1611 {
1612 is_cpmd = FALSE;
1613 if (qm_proj -> cp2k_input[s] == NULL)
1614 {
1615 qm_proj -> cp2k_input[s] = g_malloc0 (sizeof*qm_proj -> cp2k_input[s]);
1616 qm_proj -> cp2k_input[s] -> input_type = 0;
1617 for (i=0; i<2; i++)
1618 {
1619 qm_proj -> cp2k_input[s] -> fixat[i] = 0;
1620 qm_proj -> cp2k_input[s] -> fixlist[i] = NULL;
1621 qm_proj -> cp2k_input[s] -> fixcoord[i] = NULL;
1622 }
1623 qm_proj -> cp2k_input[s] -> thermostats = 0;
1624 qm_proj -> cp2k_input[s] -> ions_thermostat = NULL;
1625 for (i=0; i<5; i++) qm_proj -> cp2k_input[s] -> files[i] = NULL;
1626 for (i=0; i<41; i++) qm_proj -> cp2k_input[s] -> opts[i] = default_cp2k_options[i];
1627 qm_proj -> cp2k_input[s] -> opts[CP2SYM] = find_cp2k_sym ();
1628 for (i=0; i<3; i++)
1629 {
1630 for (j=0;j<4;j++) qm_proj -> cp2k_input[s] -> extra_opts[i][j] = default_cp2k_extra[i][j];
1631 if (i == 0) qm_proj -> cp2k_input[s] -> extra_opts[i][2] = default_vdw_cut[0];
1632 }
1633 qm_proj -> cp2k_input[s] -> spec_data = allocdint(qm_proj -> nspec, 2);
1634 qm_proj -> cp2k_input[s] -> spec_files = g_malloc (qm_proj -> nspec*sizeof*qm_proj -> cp2k_input[s] -> spec_files);
1635 for (i=0; i<qm_proj -> nspec; i++)
1636 {
1637 qm_proj -> cp2k_input[s] -> spec_data[i][0] = cp2k_is_basis_in_database (i);
1638 qm_proj -> cp2k_input[s] -> spec_data[i][1] = cp2k_is_pseudo_in_database (i);
1639 qm_proj -> cp2k_input[s] -> spec_files[i] = g_malloc0 (2*sizeof*qm_proj -> cp2k_input[s] -> spec_files[i]);
1640 qm_proj -> cp2k_input[s] -> spec_files[i][0] = NULL;
1641 qm_proj -> cp2k_input[s] -> spec_files[i][1] = NULL;
1642 }
1643 gchar * defname[2]={"basis.inc", "pseudo.inc"};
1644 for (j=0;j<2;j++)
1645 {
1646 for (i=0; i<qm_proj -> nspec; i++)
1647 {
1648 if (qm_proj -> cp2k_input[s] -> spec_data[i][j] > -1)
1649 {
1650 qm_proj -> cp2k_input[s] -> files[1+j] = g_strdup_printf ("%s", defname[j]);
1651 break;
1652 }
1653 }
1654 }
1655 qm_proj -> cp2k_input[s] -> info = g_strdup_printf (" Project name: %s\n"
1656 " Total number of atoms: %d\n"
1657 " Number of chemical species: %d",
1658 prepare_for_title(qm_proj -> name), qm_proj -> natomes, qm_proj -> nspec);
1659 }
1660 tmp_cp2k = qm_proj -> cp2k_input[s];
1661 }
1662 qm_coord = qm_proj -> coord;
1663 qm_view = qm_proj -> modelgl;
1664
1665 gtk_window_set_resizable (GTK_WINDOW (qm_assistant), FALSE);
1666 gtk_window_set_modal (GTK_WINDOW (qm_assistant), TRUE);
1667 gchar * str = g_strdup_printf ("Basic %s - %s - calculation assistant", co_type[c], qm_type[s]);
1668 gtk_window_set_title (GTK_WINDOW(qm_assistant), str);
1669 g_free (str);
1670
1671 GtkWidget * intro = create_vbox (BSEP);
1672 gchar * info = g_strdup_printf ("\t<b>This assistant will help you to setup a %s %s\n"
1673 "\tcalculation using <i>%s</i> 3D model as starting point</b>\n"
1674 "\nPlease note that the %s code offers so many calculation options that it is not possible\n"
1675 "to provide a description and offer a comprehensive usage guide for each of them. \n"
1676 "Therefore this assistant only provides help towards basics and / or frequently used %s instructions. \n\n"
1677 "<b>In any case if you intent to use the %s code please refer to the user manual.</b>",
1678 qm_type[s], co_type[c], qm_proj -> name, co_type[c], co_type[c], co_type[c]);
1679 add_box_child_start (GTK_ORIENTATION_VERTICAL, intro, markup_label(info, -1, -1, 0.5, 0.5), TRUE, TRUE, 50);
1680 g_free (info);
1681
1682 add_box_child_start (GTK_ORIENTATION_VERTICAL, intro,
1683 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),
1684 FALSE, FALSE, 0);
1685 gtk_assistant_append_page (GTK_ASSISTANT (qm_assistant), intro);
1686 str = g_strdup_printf ("%s calculation set-up", co_type[c]);
1687 gtk_assistant_set_page_title (GTK_ASSISTANT (qm_assistant), intro, str);
1688 g_free (str);
1689 gtk_assistant_set_page_type (GTK_ASSISTANT (qm_assistant), intro, GTK_ASSISTANT_PAGE_INTRO);
1690 gtk_assistant_set_page_complete (GTK_ASSISTANT (qm_assistant), intro, qm_assist_init);
1691 if (c == 0)
1692 {
1693 add_cpmd_pages ();
1694 }
1695 else
1696 {
1697 add_cp2k_pages ();
1698 }
1699 gtk_assistant_set_forward_page_func (GTK_ASSISTANT (qm_assistant), on_qm_assistant_go_forward, GINT_TO_POINTER(c), NULL);
1700 qm_preview_but = create_button ("Preview", IMG_STOCK, EDITF, -1, -1, GTK_RELIEF_NORMAL, G_CALLBACK(show_qm_file_preview), GINT_TO_POINTER(c));
1701 gtk_assistant_add_action_widget (GTK_ASSISTANT (qm_assistant), qm_preview_but);
1702 g_signal_connect (G_OBJECT (qm_assistant), "prepare", G_CALLBACK(on_qm_assistant_prepare), GINT_TO_POINTER(c));
1703 g_signal_connect (G_OBJECT (qm_assistant), "cancel", G_CALLBACK(on_qm_assistant_cancel), GINT_TO_POINTER(c));
1704 g_signal_connect (G_OBJECT (qm_assistant), "close", G_CALLBACK(on_qm_assistant_close), GINT_TO_POINTER(c));
1705 g_signal_connect (G_OBJECT (qm_assistant), "apply", G_CALLBACK(on_qm_assistant_apply), GINT_TO_POINTER(c));
1706 add_gtk_close_event (qm_assistant, G_CALLBACK(on_qm_assistant_cancel_event), GINT_TO_POINTER(c));
1707
1708 gtk_assistant_set_page_complete (GTK_ASSISTANT (qm_assistant),
1709 gtk_assistant_get_nth_page(GTK_ASSISTANT (qm_assistant), 0), TRUE);
1712 if (c == 0)
1713 {
1714 for (i=0; i<NCPMDCALC; i++) hide_the_widgets (calc_box[i]);
1715 show_the_widgets (calc_box[tmp_cpmd -> calc_type]);
1716 if (tmp_cpmd -> calc_type != 2) hide_the_widgets (electron_box);
1717 }
1719}
1720
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:1236
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:664
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:645
GtkWidget * info_box()
create CPMD input file information widgets
Definition cpmd_init.c:797
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:430
gchar * thermo_name[2][5]
Definition cpmd_init.c:218
GtkWidget * section_box(int s)
create CPMD section box
Definition cpmd_init.c:818
G_MODULE_EXPORT void changed_calc_opt_box(GtkComboBox *box, gpointer data)
change CPMD calculation option
Definition cpmd_init.c:614
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:781
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:1056
gchar * page_name(int p)
get CPMD input creation assistant page name
Definition cpmd_init.c:962
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:1503
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:1119
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:1190
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:750
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:1352
G_MODULE_EXPORT void show_qm_file_preview(GtkButton *but, gpointer data)
show QM / QM-MM input file preview
Definition cpmd_init.c:1231
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:916
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:890
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:939
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:1084
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:1033
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:1510
G_MODULE_EXPORT void update_calc_parameter(GtkEntry *res, gpointer data)
update CPMD calculation option value entry callback
Definition cpmd_init.c:579
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:1565
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:1888
G_MODULE_EXPORT void on_qm_assistant_close(GtkAssistant *assistant, gpointer data)
close QM / QM-MM input creation assistant
Definition cpmd_init.c:1099
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:1190
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:375
void add_cpmd_pages()
add pages to the CPMD input file creation assistant
Definition cpmd_init.c:994
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:1214
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:204
void run_this_gtk_dialog(GtkWidget *dial, GCallback handler, gpointer data)
run a GTK (3 and 4) basic GtkDialog
Definition gtk-misc.c:492
@ IMG_NONE
Definition global.h:260
@ IMG_STOCK
Definition global.h:264
void file_chooser_set_current_folder(GtkFileChooser *chooser)
set current folder in a GtkFilechooser
Definition gtk-misc.c:2188
GtkWidget * create_entry(GCallback handler, int dim, int cdim, gboolean key_release, gpointer data)
Create a GtkEntry.
Definition gtk-misc.c:1314
void update_entry_double(GtkEntry *entry, double doubleval)
update the content of a GtkEntry as double
Definition gtk-misc.c:633
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:1199
GtkTextBuffer * add_buffer(GCallback handler, gpointer data, gchar *text)
create a GtkTextBuffer
Definition gtk-misc.c:1171
GtkWidget * create_scroll(GtkWidget *box, int dimx, int dimy, int shadow)
create a scroll window
Definition gtk-misc.c:1960
GtkWidget * dialogmodal(gchar *str, GtkWindow *parent)
Create a new dialog modal window.
Definition gtk-misc.c:510
gboolean is_the_widget_visible(GtkWidget *widg)
test if a GtkWidget exist, then return if it is visible or not
Definition gtk-misc.c:714
gchar * file_chooser_get_file_name(GtkFileChooser *chooser)
get a file name from a GtkFileChooser (single file selected)
Definition gtk-misc.c:2136
const gchar * entry_get_text(GtkEntry *entry)
get the text in a GtkEntry
Definition gtk-misc.c:597
#define BSEP
Definition global.h:245
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:614
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:2387
gchar * file_chooser_get_current_folder(GtkFileChooser *chooser)
get the current folder for a GtkFileChooser
Definition gtk-misc.c:2152
GtkWidget * check_button(gchar *text, int dimx, int dimy, gboolean state, GCallback handler, gpointer data)
create a check button
Definition gtk-misc.c:1799
@ CONTAINER_SCR
Definition global.h:251
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:1863
GtkWidget * create_combo()
create a GtkCombox widget, note deprecated in GTK4
Definition gtk-misc.c:923
GtkWidget * dialog_get_content_area(GtkWidget *widg)
prepare GtkWidget to insert content in a GtkDialog window
Definition gtk-misc.c:825
GtkWidget * markup_label(gchar *text, int dimx, int dimy, float ax, float ay)
Definition gtk-misc.c:1585
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:299
void widget_set_sensitive(GtkWidget *widg, gboolean sensitive)
Set sensitivity for a GtkWidget, ensuring it is a GtkWidget.
Definition gtk-misc.c:206
void destroy_this_dialog(GtkDialog *dialog)
destroy a GtkDialog
Definition gtk-misc.c:2065
GtkWidget * create_hbox(int spacing)
create a GtkBox with horizontal orientation
Definition gtk-misc.c:813
void combo_text_append(GtkWidget *combo, gchar *text)
append text in GtkComboBox widget
Definition gtk-misc.c:900
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:2102
GtkWidget * destroy_this_widget(GtkWidget *widg)
destroy a GtkWidget
Definition gtk-misc.c:2034
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:226
void hide_the_widgets(GtkWidget *widg)
hide GtkWidget
Definition gtk-misc.c:189
GtkWidget * create_vbox(int spacing)
create a GtkBox with vertical orientation
Definition gtk-misc.c:801
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:2223
void destroy_this_native_dialog(GtkNativeDialog *dialog)
destroy a GtkNativeDialog
Definition gtk-misc.c:2084
void show_the_widgets(GtkWidget *widg)
show GtkWidget
Definition gtk-misc.c:173
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:652
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:738
Messaging function declarations.
Function declarations for reading atomes project file Function declarations for saving atomes proje...
Definition global.h:771
Definition glwin.h:875
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