atomes 1.2.1
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
cp2k_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: 'cp2k_init.c'
24*
25* Contains:
26*
27
28 - The initialization of the CP2K input assistant
29
30*
31* List of functions:
32
33 int find_cp2k_sym ();
34
35 gboolean cp2k_with_motion ();
36
37 gchar * cp_section_name (int p);
38 gchar * page_name_cp2k (int p);
39
40 void print_start_buffer ();
41 void create_mol_selection_button (GtkWidget * box, int id);
42 void cp2k_option_box (GtkWidget * box, int id);
43 void add_cp2k_pages ();
44
45 G_MODULE_EXPORT void update_cp2k_option (GtkEntry * res, gpointer data);
46 G_MODULE_EXPORT void update_cp2k_option_check (GtkCheckButton * but, gpointer data);
47 G_MODULE_EXPORT void update_cp2k_option_check (GtkToggleButton * but, gpointer data);
48 G_MODULE_EXPORT void changed_cp2k_option_box (GtkComboBox * box, gpointer data);
49 G_MODULE_EXPORT void mol_selection_button (GtkButton * but, gpointer data);
50 G_MODULE_EXPORT void cp2k_option_dialog (GtkWidget *but, gpointer data);
51 G_MODULE_EXPORT void update_cp2k_parameter (GtkEntry * res, gpointer data);
52 G_MODULE_EXPORT void update_cp2k_check (GtkCheckButton * but, gpointer data);
53 G_MODULE_EXPORT void update_cp2k_check (GtkToggleButton * but, gpointer data);
54 G_MODULE_EXPORT void cp2k_file_info (GtkTextBuffer * textbuf, gpointer data);
55 G_MODULE_EXPORT void changed_cp2k_box (GtkComboBox * box, gpointer data);
56 G_MODULE_EXPORT void select_input_type (GtkToggleButton * but, gpointer data);
57
58 GtkWidget * create_vdw_box (int id);
59 GtkWidget * create_cp2k_spec_box (int spec);
60 GtkWidget * cp2k_section_box (int s);
61 GtkWidget * vbox_cp2k (int s);
62 GtkWidget * file_info (int id);
63 GtkWidget * init_cp2k ();
64
65*/
66
67#include "global.h"
68#include "callbacks.h"
69#include "interface.h"
70#include "project.h"
71#include "glwindow.h"
72#include "glview.h"
73#include "calc.h"
74#include "cp2k.h"
75#include "cpmd.h"
76
77extern GtkWidget * thermo_box ();
78extern void print_cp2k (int f, GtkTextBuffer * buffer);
79extern ColRGBA init_color (int id, int numid);
80extern GtkWidget * qm_preview_box (int c, int s, int l);
81extern void field_unselect_all ();
82extern GtkWidget * cpmd_box (GtkWidget * box, gchar * lab, int v_space, int h_space, int dim);
83extern void create_selection_button (GtkWidget * box, int num, int id, gpointer data);
84extern void cp2k_fix_molecule ();
85
87
88double default_cp2k_options[41] = {0.0, 86400.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 300.0,
89 4.0, 0.0, 0.0, 50.0, 0.000001, 20.0, 0.00001, 2.0, 0.0, 0.0,
90 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
91 0.0, 7.0, 10000.0, 2.5, 300.0, 1.0, 10000.0, 0.0001, 10.0, 0.0,
92 0.0};
93
94double default_vdw_cut[2] = {-2.00000000E+000, 1.05835442E+001};
95double default_cp2k_extra[3][4] = {{0.0, 0.0, 0.0, 0.0}, {0.0, 0.0, 0.0, 0.0}, {-1.0, -1.0, 1.0, 0.0}};
96
97gchar * cp2k_unit[6]={"s", "Ry", "fs", "K", "a.u.", "steps"};
98
99int cp2k_default_num[12] = {7, 3, 3, 4, 3, 11, 8, 4, 10, 9, 4, 2};
100
101gchar * cp2k_default_keywords[11][11] = {{"ENERGY", "ENERGY_FORCES", "GEOMETRY_OPTIMIZATION", "MOLECULAR_DYNAMICS",
102 "VIBRATIONAL_ANALYSIS", "LINEAR_RESPONSE", "EHRENFEST_DYN", " ", " ", " ", " "},
103 {"LOW", "MEDIUM", "HIGH", " ", " ", " ", " ", " ", " ", " ", " "},
104 {"GPW", "GAPW", "GAPW_XC", " ", " ", " ", " ", " ", " ", " ", " "},
105 {"ATOMIC", "CORE", "RANDOM", "RESTART", " ", " ", " ", " ", " ", " ", " "},
106 {"BROYDEN", "CG", "DIIS", " ", " ", " ", " ", " ", " ", " ", " "},
107 {"BLYP", "B3LYP", "BEEFVDW", "BP", "HCTH120", "LDA", "OLYP", "PADE", "PBE", "PBE0", "TPSS"},
108 {"XYZ", "XY", "XZ", "YZ", "X", "Y", "Z", "NONE", " ", " ", " "},
109 {" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "},
110 {"CUBIC", "HEXAGONAL", "ORTHORHOMBIC", "RHOMBOHEDRAL",
111 "TETRAGONAL_AB", "TETRAGONAL_AC", "TETRAGONAL_BC", "MONOCLINIC", "TRICLINIC", "NONE", " "},
112 {"ISOKIN", "LANGEVIN", "NPE_F", "NPE_I", "NPT_F", "NPT_I", "NVE", "NVT", "NVT_ADIABATIC", " ", " "},
113 {"BFGS", "CG", " ", " ", " ", " ", " ", " ", " ", " ", " "}};
114
115gchar * cp2k_vdw_keywords[2][3] = {{"DRSLL", "LMKLL", "RVV10"}, {"DFTD2", "DFTD3", "DFTD3(BJ)"}};
116
117gchar * cp2k_default_text[11][11] = {{"Single point energy calculation",
118 "Single point energy and forces calculation",
119 "Geometry optimization", "Molecular dynamics",
120 "Vibrational analysis", "Linear response calculation", "Ehrenfest dynamics", " ", " ", " ", " "},
121 {"Low", "Medium", "High", " ", " ", " ", " ", " ", " ", " ", " "},
122 {"Gaussian and plane waves method",
123 "Gaussian and augmented plane waves method",
124 "Gaussian and augmented plane waves method only for XC", " ", " ", " ", " ", " ", " ", " ", " "},
125 {"Generate an atomic density using the atomic code",
126 "Diagonalize the core Hamiltonian",
127 "Use random wave-function coefficients",
128 "Use the RESTART file", " ", " ", " ", " ", " ", " ", " "},
129 {"Broyden mixing approximating the inverse Hessian",
130 "Conjugate Gradients", "Direct inversion in the iterative subspace", " ", " ", " ", " ", " ", " ", " ", " "},
131 {"Becke + Lee-Yang-Parr", "Becke three-parameters hybrid + LYP", "Bayesian error estimation + van der Walls",
132 "Becke + Perdew", "Hamprecht-Cohen-Tozer-Handy", "Local Density Approximation", "Handy-Cohen + LYP", "Padé",
133 "Perdew + Burke-Ernzerhof", "Parameter-free PBE", "Tao-Perdew-Staroverov-Scuseria"},
134 {"3 dimensional (XYZ)", "2 dimensional (XY)", "2 dimensional (XZ)", "2 dimensional (YZ)",
135 "1 dimensional (X)", "1 dimensional (Y)", "1 dimensional (Z)", "Isolated system", " ", " ", " "},
136 {"Box parameters (a,b,c and α,β,γ)", "Lattice vectors", " ", " ", " ", " ", " ", " ", " ", " ", " "},
137 {"Cubic (a = b = c, α = β = γ = 90°)", "Hexagonal (a = b ≠ c, α = β = 90°, γ = 60°)",
138 "Orthorhombic (a ≠ b ≠ c, α = β = γ = 90°)", "Rhombohedral (a = b = c, α = β = γ ≠ 90°)",
139 "Tetragonal (a = b ≠ c, α = β = γ = 90°)", "Tetragonal (a = c ≠ b, α = β = γ = 90°)", "Tetragonal (a ≠ b = c, α = β = γ = 90°)",
140 "Monoclinic (a ≠ b ≠ c ≠ a, α = γ = 90°, β ≠ 90°)", "Triclinic (a ≠ b ≠ c ≠ a, α ≠ β ≠ γ ≠ α ≠ 90°)", "No cell symmetry", " "},
141 {"Constant kinetic energy", "Langevin dynamics (constant temperature)", "Constant pressure ensemble (no thermostat)",
142 "Constant pressure ensemble using an isotropic cell (no thermostat)", "Constant temperature and pressure using a flexible cell",
143 "Constant temperature and pressure using an isotropic cell", "Constant energy (µ-canonical)", "Constant temperature and volume (canonical)",
144 "Adiabatic dynamics in constant temperature and volume ensemble (CAFES)", " ", " "},
145 {"Diagonalization of a full Hessian matrix", "Conjugate gradients", " ", " ", " ", " ", " ", " ", " ", " ", " "}};
146
147gchar * cp2k_vdw_text[2][3] = {{"Dion-Rydberg-Schroeder-Langreth-Lundqvist non-local van der Waals density functional",
148 "Lee-Murray-Kong-Lundqvist-Langreth non-local van der Waals density functional",
149 "Revised Vydrov-van Voorhis non-local van der Waals density functional"},
150 {"Grimme D2 method", "Grimme D3 method (zero damping)", "Grimme D3 method (Becke-Johnson damping)"}};
151
152int var_by_cp2sections[4] = {8, 20, 3, 10};
153gchar * global_opts[40] = {"Run type:",
154 "Max CPU time:",
155 "Print level:",
156 "Use restart information:",
157 "File that contains the restart information:",
158 "File that contains the basis set(s):",
159 "File that contains the pseudo-potential(s):",
160 "File that contains the wave-function:",
161 "Charge:",
162 "Density cutoff for the finest grid level:",
163 "Number of multi-grids:",
164 "Quickstep method:",
165 "Initial guess for the wave-function:",
166 "Maximum inner-SCF cycle(s):",
167 "Convergence threshold:",
168 "Maximum outer-SCF cycle(s):",
169 "Convergence threshold:",
170 "Orbital transformation minimizer:",
171 "DFT functional:",
172 "Spin unrestricted calculation",
173 "Multiplicity",
174 "Use van der Waals interactions",
175 "Restricted Open Kohn-Sham 'ROKS'",
176 "Forces",
177 "Stress tensor",
178 "Mulliken population",
179 "Löwdin population",
180 "Orbitals",
181 "Periodicity:",
182 "Lattice parameters:",
183 "Symmetry:",
184 "Ensemble:",
185 "Maximum number of MD steps:",
186 "MD time step:",
187 "Initial temperature:",
188 "Geometry optimizer:",
189 "Maximum number of optimization steps:",
190 "Atomic forces convergence criterion:",
191 "Save information every:",
192 "Add constraint(s)"};
193
194gchar * cpelemts[7] = {"The CP2K input structure",
195 "provides the general control parameters for the calculation to be performed",
196 "describes how the interatomic forces will be evaluated",
197 "describes the model: symmetry, periodicity and atomic species, pseudo-potentials and coordinates",
198 "describes the displacement of the atoms for molecular dynamics of geometry optimization",
199 "To describe the thermostat(s) for molecular dynamics",
200 "To describe the parameters required for restart"};
201
202gchar * cpsect[4] = {"GLOBAL",
203 "FORCE_EVAL",
204 "SUBSYS",
205 "MOTION"};
206
207char * k_thermo[CP2NTHERM][4] = {{"TIMECON_LANGEVIN", "TIMECON_NH", "MASS", "CHI"},
208 {"TIMECON", " ", " ", " "},
209 {" ", " ", " ", " "},
210 {"LENGTH", "MTS", "TIMECON", "YOSHIDA"}};
211
212#define NC2OP 20
213
214// 0 = None, 1 = Entry, 2 = Combo (-2 thermostats), 3 = yes/no, 4 = textbuffer
215int cp2k_opts_type[4][NC2OP] = {{ 2, 1, 2, 3, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, // GLOBAL
216 { 1, 1, 1, 2, 2, 1, 1, 1, 1, 2, 2, 3, 1, 3, 3, 3, 3, 3, 3, 3}, // FEVAL
217 { 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, // SUBSYS
218 { 2, -2, 1, 1, 1, 2, 1, 1, 1, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}; // MOTION
219
224GtkWidget * print_box;
225GtkWidget * vfbox[2];
226GtkWidget * filebut[2];
227GtkWidget * fileinf[2];
228GtkWidget * cp2k_combo;
229GtkWidget * cp2k_label;
230GtkWidget * checked_box[2];
231GtkWidget * option_box[4];
232GtkWidget * motion_box[2];
233GtkWidget * cp2k_vdw_box[2];
234GtkWidget * cp2k_spec_box[2];
235GtkWidget * cp2k_spec_combo;
236GtkWidget * spec_data_combo[2];
237GtkWidget * cp2k_thermo_box;
238
246{
247 if (qmbuffer[0])
248 {
249 GtkTextIter bStart;
250 GtkTextIter bEnd;
251 gtk_text_buffer_get_start_iter (qmbuffer[0], & bStart);
252 gtk_text_buffer_get_end_iter (qmbuffer[0], & bEnd);
253 gtk_text_buffer_delete (qmbuffer[0], & bStart, & bEnd);
254 print_cp2k (0, qmbuffer[0]);
255 }
256}
257
266G_MODULE_EXPORT void update_cp2k_option (GtkEntry * res, gpointer data)
267{
268 int i;
269 i = GPOINTER_TO_INT(data);
270 const gchar * m = entry_get_text (res);
271 double v = string_to_double ((gpointer)m);
272 switch (i)
273 {
274 case CP2VDW:
275 if (v > 0.0) tmp_cp2k -> extra_opts[0][2] = v;
276 update_entry_double (res, tmp_cp2k -> extra_opts[0][2]);
277 break;
278 case CP2ROK:
279 if (v > 0.0) tmp_cp2k -> extra_opts[1][0] = v;
280 update_entry_double (res, tmp_cp2k -> extra_opts[1][0]);
281 break;
282 default:
283 if ((int)v == -1 || (int)v > 0) tmp_cp2k -> extra_opts[2][i-CP2POR] = v;
284 update_entry_int (res, tmp_cp2k -> extra_opts[2][i-CP2POR]);
285 break;
286 }
288}
289
290#ifdef GTK4
299G_MODULE_EXPORT void update_cp2k_option_check (GtkCheckButton * but, gpointer data)
300#else
309G_MODULE_EXPORT void update_cp2k_option_check (GtkToggleButton * but, gpointer data)
310#endif
311{
312 int i;
313 i = GPOINTER_TO_INT(data);
314 tmp_cp2k -> extra_opts[i][(i==2)?2:3] = (double) button_get_status ((GtkWidget *)but);
316}
317
318GtkWidget * create_vdw_box (int id);
319
328G_MODULE_EXPORT void changed_cp2k_option_box (GtkComboBox * box, gpointer data)
329{
330 int i, j, k;
331 i = GPOINTER_TO_INT(data);
332 if (i < 2)
333 {
334 j = k = 1;
335 }
336 else
337 {
338 j = 0;
339 k = i - CP2VDW;
340 }
341 tmp_cp2k -> extra_opts[j][k] = (double) combo_get_active ((GtkWidget *)box);
342 if (i == CP2VDW)
343 {
345 cp2k_vdw_box[1] = create_vdw_box ((int)tmp_cp2k -> extra_opts[0][0]);
346 add_box_child_start (GTK_ORIENTATION_VERTICAL, cp2k_vdw_box[0], cp2k_vdw_box[1], FALSE, FALSE, 0);
348 }
350}
351
359GtkWidget * create_vdw_box (int id)
360{
361 GtkWidget * vbox, * hbox;
362 GtkWidget * widg;
363 gchar * cp2k_vdw_vars[2] = {"Type of potential:", "Cutoff:"};
364 int i, j, k;
365 vbox = create_vbox(5);
366 i = (id == 0) ? 2 : 3;
367 for (j=0; j<i; j++)
368 {
369 hbox = create_hbox(5);
370 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 0);
371 if (j < 2) add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label(cp2k_vdw_vars[j], 150, -1, 0.0, 0.5), FALSE, FALSE, 30);
372 switch (j)
373 {
374 case 0:
375 widg = create_combo ();
376 for (k=0; k<3; k++) combo_text_append (widg, cp2k_vdw_text[id][k]);
377 combo_set_active (widg, (int)tmp_cp2k -> extra_opts[0][j+1]);
378 g_signal_connect (G_OBJECT (widg), "changed", G_CALLBACK(changed_cp2k_option_box), GINT_TO_POINTER(CP2VDW+1));
379 break;
380 case 1:
381 widg = create_entry (G_CALLBACK(update_cp2k_option), 100, 15, FALSE, GINT_TO_POINTER(CP2VDW));
382 tmp_cp2k -> extra_opts[0][j+1] = default_vdw_cut[id];
383 update_entry_double (GTK_ENTRY(widg), tmp_cp2k -> extra_opts[0][j+1]);
384 break;
385 case 2:
386 widg = check_button ("Apply long range corrections", -1, -1, tmp_cp2k -> extra_opts[0][j+1],
387 G_CALLBACK(update_cp2k_option_check), GINT_TO_POINTER(0));
388 break;
389 }
390 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, widg, FALSE, FALSE, 5);
391 }
392 return vbox;
393}
394
464G_MODULE_EXPORT void cp2k_option_dialog (GtkWidget *but, gpointer data)
465{
466 int i, j;
467 i = GPOINTER_TO_INT(data);
468 GtkWidget * vbox, * hbox;
469 GtkWidget * widg;
470 gchar * cp2k_vdw_options[2] = {"Non-local potential", "Pair potential"};
471 gchar * cp2k_roks_options[2] = {"Energy scaling:", "Spin configuration <sup>*</sup>:"};
472 gchar * cp2k_orb_options[2] = {"Number of HOMO levels (-1 for all):", "Number of LUMO levels (-1 for all):"};
473
474 gchar * str = g_strdup_printf ("%s - options", global_opts[i]);
475 GtkWidget * dial = dialogmodal (str, GTK_WINDOW(qm_assistant));
476 g_free (str);
478 switch (i)
479 {
480 case CP2VDW:
481 hbox = create_hbox (5);
482 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 10);
483 widg = create_combo ();
484 for (j=0; j<2; j++) combo_text_append (widg, cp2k_vdw_options[j]);
485 combo_set_active (widg, (int)tmp_cp2k -> extra_opts[0][0]);
486 g_signal_connect (G_OBJECT (widg), "changed", G_CALLBACK(changed_cp2k_option_box), GINT_TO_POINTER(CP2VDW));
487 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label("Type of functional for the van der Waals interactions", 200, -1, 0.0, 0.5), FALSE, FALSE, 20);
488 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, widg, FALSE, FALSE, 5);
490 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, cp2k_vdw_box[0], FALSE, FALSE, 10);
491 cp2k_vdw_box[1] = create_vdw_box ((int)tmp_cp2k -> extra_opts[0][0]);
492 add_box_child_start (GTK_ORIENTATION_VERTICAL, cp2k_vdw_box[0], cp2k_vdw_box[1], FALSE, FALSE, 0);
493 break;
494 case CP2ROK:
495 for (j=0; j<2; j++)
496 {
497 hbox = create_hbox (5);
498 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 5);
499 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label(cp2k_roks_options[j], 200, -1, 0.0, 0.5), FALSE, FALSE, 5);
500 if (j==0)
501 {
502 widg = create_entry (G_CALLBACK(update_cp2k_option), 100, 15, FALSE, GINT_TO_POINTER(i+j));
503 update_entry_double (GTK_ENTRY(widg), tmp_cp2k -> extra_opts[1][j]);
504 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, widg, FALSE, FALSE, 10);
505 }
506 else
507 {
508 widg = create_combo ();
509 combo_text_append (widg, "alpha - α");
510 combo_text_append (widg, "beta - β");
511 combo_set_active (widg, (int)tmp_cp2k -> extra_opts[1][1]);
512 g_signal_connect (G_OBJECT (widg), "changed", G_CALLBACK(changed_cp2k_option_box), GINT_TO_POINTER(j));
513 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, widg, FALSE, FALSE, 10);
514 }
515 }
516 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, gtk_label_new ("* for the singly occupied orbitals"), FALSE, FALSE, 5);
517 break;
518 case CP2POR:
519 for (j=0; j<2; j++)
520 {
521 hbox = create_hbox (5);
522 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 5);
523 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label(cp2k_orb_options[j], 250, -1, 0.0, 0.5), FALSE, FALSE, 5);
524 widg = create_entry (G_CALLBACK(update_cp2k_option), 100, 15, FALSE, GINT_TO_POINTER(i+j));
525 update_entry_int (GTK_ENTRY(widg), tmp_cp2k -> extra_opts[2][j]);
526 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, widg, FALSE, FALSE, 0);
527 }
528 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, check_button ("Write cube files, if not then only print eigenvalues", -1, -1, tmp_cp2k -> extra_opts[2][2],
529 G_CALLBACK(update_cp2k_option_check), GINT_TO_POINTER(2)), FALSE, FALSE, 5);
530 break;
531 case CP2CON:
532 create_selection_button (vbox, tmp_cp2k -> fixat[0], 1, GINT_TO_POINTER(-1));
533 //create_mol_selection_button (vbox, 2);
534 break;
535 }
536 run_this_gtk_dialog (dial, G_CALLBACK(run_destroy_dialog), NULL);
537}
538
547G_MODULE_EXPORT void update_cp2k_parameter (GtkEntry * res, gpointer data)
548{
549 int i;
550 i = GPOINTER_TO_INT(data);
551 const gchar * m = entry_get_text (res);
552 double v = string_to_double ((gpointer)m);
553 if (tmp_cp2k -> opts[i] != v)
554 {
555 tmp_cp2k -> opts[i] = v;
557 }
558 if (i==CP2CUT || i==CP2SCN || i==CP2SCO || i==CP2DLT || i==CP2GEF)
559 {
560 update_entry_double (res, tmp_cp2k -> opts[i]);
561 }
562 else
563 {
564 update_entry_int (res, tmp_cp2k -> opts[i]);
565 }
566}
567
568#ifdef GTK4
577G_MODULE_EXPORT void update_cp2k_check (GtkCheckButton * but, gpointer data)
578#else
587G_MODULE_EXPORT void update_cp2k_check (GtkToggleButton * but, gpointer data)
588#endif
589{
590 int i, j;
591 i = GPOINTER_TO_INT(data);
592 tmp_cp2k -> opts[i] = (double) button_get_status ((GtkWidget *)but);
593 if (i == CP2RES)
594 {
595 for (j=0; j<2; j++) widget_set_sensitive (checked_box[j], (int)tmp_cp2k -> opts[CP2RES]);
596 }
597 else if (i==CP2SPI || i==CP2VDW || i==CP2ROK || i==CP2POR || i==CP2CON)
598 {
599 switch (i)
600 {
601 case CP2SPI:
602 j = 0;
603 break;
604 case CP2VDW:
605 j = 1;
606 break;
607 case CP2ROK:
608 j = 2;
609 break;
610 case CP2POR:
611 j = 3;
612 break;
613 case CP2CON:
614 j = 4;
615 break;
616 }
617 widget_set_sensitive (option_box[j], (int)tmp_cp2k -> opts[i]);
618 }
620}
621
630G_MODULE_EXPORT void cp2k_file_info (GtkTextBuffer * textbuf, gpointer data)
631{
632 int i, j, k;
633 i = GPOINTER_TO_INT(data) - CP2FRE;
634 GtkTextIter bStart;
635 GtkTextIter bEnd;
636 gtk_text_buffer_get_start_iter (textbuf, & bStart);
637 gtk_text_buffer_get_end_iter (textbuf, & bEnd);
638 if (i < 5)
639 {
640 if (tmp_cp2k -> files[i] != NULL) g_free (tmp_cp2k -> files[i]);
641 tmp_cp2k -> files[i] = g_strdup_printf ("%s", gtk_text_buffer_get_text (textbuf, & bStart, & bEnd, FALSE));
642 if (g_strcmp0 (tmp_cp2k -> files[i], "") == 0) tmp_cp2k -> files[i] = NULL;
643 }
644 else
645 {
647 k = i + CP2FRE - 10;
648 if (tmp_cp2k -> spec_files[j][k] != NULL) g_free (tmp_cp2k -> spec_files[j][k]);
649 tmp_cp2k -> spec_files[j][k] = g_strdup_printf ("%s", gtk_text_buffer_get_text (textbuf, & bStart, & bEnd, FALSE));
650 if (g_strcmp0 (tmp_cp2k -> spec_files[j][k], "") == 0)
651 {
652 tmp_cp2k -> spec_files[j][k] = NULL;
653 combo_set_active (spec_data_combo[k], tmp_cp2k -> spec_data[j][k]);
655 }
656 else if (spec_data_combo[k] != NULL)
657 {
660 }
661 }
663}
664
672GtkWidget * create_cp2k_spec_box (int spec)
673{
674 gchar * info[2] = {"<b>-</b> Select and use set of parameters from the database: ",
675 "<b>-</b> Define and use other set of parameters: "};
676 gchar * data_name[2][2] = {{"\t\tAvailable basis set for ", "\t\tAvailable pseudo-potential for "},
677 {"\t\tBasis set for ", "\t\tPseudo-potential for "}};
678 GtkWidget * vbox = create_vbox (BSEP);
679 GtkWidget * hbox;
680 gchar * str;
681 int i, j;
682 for (i=0; i<2; i++)
683 {
684 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label(info[i], -1, -1, 0.0, 0.5), FALSE, FALSE, 5);
685 for (j=0; j<2; j++)
686 {
687 str = g_strdup_printf ("%s%s", data_name[i][j], qm_proj -> chemistry -> label[spec]);
688 hbox = cpmd_box (vbox, str, 5, 5, 300);
689 g_free (str);
690 if (i==0)
691 {
692 spec_data_combo[j] = NULL;
693 if (tmp_cp2k -> spec_data[spec][j] > -1)
694 {
696 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, spec_data_combo[j], FALSE, FALSE, 5);
697 }
698 else
699 {
700 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label("<b>None</b>", -1, -1, 0.5, 0.5), FALSE, FALSE, 5);
701 }
702 }
703 else
704 {
705 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, create_text_view (350, -1, 1, 0, G_CALLBACK(cp2k_file_info),
706 GINT_TO_POINTER(j+10), tmp_cp2k -> spec_files[spec][j]),
707 FALSE, FALSE, 5);
708 }
709 }
710 }
711 return vbox;
712}
713
714gboolean cp2k_with_motion ();
715GtkWidget * vbox_cp2k (int s);
716gchar * page_name_cp2k (int p);
717
726G_MODULE_EXPORT void changed_cp2k_box (GtkComboBox * box, gpointer data)
727{
728 int i, j;
729 gboolean motion;
730 i = GPOINTER_TO_INT(data);
731 j = combo_get_active ((GtkWidget *)box);
732 if (j != (int)tmp_cp2k -> opts[i])
733 {
734 if (i == CP2SYM)
735 {
739 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, cp2k_spec_box[0], cp2k_spec_box[1], FALSE, FALSE, 0);
740 }
741 else
742 {
743 if (i == CP2RUN) motion = cp2k_with_motion ();
744 tmp_cp2k -> opts[i] = (double) combo_get_active ((GtkWidget *)box);
745
746 if (i == CP2RUN)
747 {
748 if (motion && ! cp2k_with_motion())
749 {
750 gtk_assistant_remove_page (GTK_ASSISTANT(qm_assistant), 5);
751 }
752 else if (! motion && cp2k_with_motion())
753 {
754 GtkAssistant * assist = GTK_ASSISTANT(qm_assistant);
755 idopt = CP2SYM;
756 motionb = -1;
757 optionb = 3;
758 idunit = 1;
759 icomb = 8;
760 GtkWidget * page = vbox_cp2k (3);
761 show_the_widgets (page);
762 gtk_assistant_insert_page (assist, page, 5);
763 gtk_assistant_set_page_title (assist, page, page_name_cp2k(4));
764 gtk_assistant_set_page_type (assist, page, GTK_ASSISTANT_PAGE_CONTENT);
765 gtk_assistant_set_page_complete (assist, page, TRUE);
767 }
768 }
769 else if (i == CP2ENS)
770 {
771 if (j == 2 || j == 3)
772 {
774 }
775 else
776 {
778 }
779 }
781 }
782 }
783}
784
793void cp2k_option_box (GtkWidget * box, int id)
794{
795 optionb ++;
797 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, box, option_box[optionb], FALSE, FALSE, 5);
798 if (id != CP2SPI)
799 {
800 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, option_box[optionb],
801 create_button ("Options", IMG_STOCK, DPROPERTIES, 200, -1, GTK_RELIEF_NORMAL, G_CALLBACK(cp2k_option_dialog), GINT_TO_POINTER(id)),
802 FALSE, FALSE, 50);
803 }
804 widget_set_sensitive (option_box[optionb], (int)tmp_cp2k -> opts[id]);
805}
806
814GtkWidget * cp2k_section_box (int s)
815{
816 int i, j, k;
817 GtkWidget * hbox;
818 GtkWidget * widg;
819 GtkWidget * vbox = create_vbox (BSEP);
820 for (i=0; i<NC2OP; i++)
821 {
822 if (cp2k_opts_type[s][i] > 0)
823 {
824 idopt ++;
825 j = idopt;
826 if (j == CP2NST)
827 {
829 add_box_child_start (GTK_ORIENTATION_VERTICAL, motion_box[motionb], cp2k_thermo_box, FALSE, FALSE, 5);
831 }
832 else if (j == CP2FRE || j == CP2FWV)
833 {
834 checkb ++;
836 }
837 else if (j == CP2SPM)
838 {
839 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, option_box[optionb], markup_label(global_opts[idopt], 100, 30, 0.0, 0.5), FALSE, FALSE, 50);
840 }
841 else if (j == CP2PFO || j == CP2PLO)
842 {
843 if (j == CP2PFO) add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label("<u>Print:</u>", -1, -1, 0.0, 0.5), FALSE, FALSE, 5);
845 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, print_box, FALSE, FALSE, 0);
846 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, print_box, markup_label(global_opts[idopt], 150, 30, 0.0, 0.5), FALSE, FALSE, 50);
847 }
848 else if (j > CP2ROK && j < CP2PBC)
849 {
850 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, print_box, markup_label(global_opts[idopt], 150, 30, 0.0, 0.5), FALSE, FALSE, 50);
851 }
852 else if (j == CP2ENS || j == CP2GMI)
853 {
854 motionb ++;
856 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, motion_box[motionb], FALSE, FALSE, 5);
858 }
859 else if (j > CP2ENS && j < CP2OUF)
860 {
862 }
863 else if (j == CP2SCN || j == CP2SCO)
864 {
865 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label(global_opts[idopt], 150, 30, 0.0, 0.5), FALSE, FALSE, 30);
866 }
867 else
868 {
869 hbox = cpmd_box (vbox, global_opts[idopt], 5, 5, 300);
870 }
871 switch (cp2k_opts_type[s][i])
872 {
873 case 1:
874 ident ++;
875 widg = create_entry (G_CALLBACK(update_cp2k_parameter), 100, 15, FALSE, GINT_TO_POINTER(j));
876 if (j==CP2CUT || j==CP2SCN || j==CP2SCO || j==CP2DLT || j==CP2GEF)
877 {
878 update_entry_double (GTK_ENTRY(widg), tmp_cp2k -> opts[j]);
879 }
880 else
881 {
882 update_entry_int (GTK_ENTRY(widg), tmp_cp2k -> opts[j]);
883 }
884 break;
885 case 2:
886 icomb ++;
887 widg = create_combo ();
888 for (k=0; k<cp2k_default_num[icomb]; k++) combo_text_append (widg, cp2k_default_text[icomb][k]);
889 combo_set_active (widg, (int)tmp_cp2k -> opts[j]);
890 g_signal_connect (G_OBJECT (widg), "changed", G_CALLBACK(changed_cp2k_box), GINT_TO_POINTER(j));
891 break;
892 case 3:
893 widg = check_button (NULL, -1, -1, tmp_cp2k -> opts[j], G_CALLBACK(update_cp2k_check), GINT_TO_POINTER(j));
894 break;
895 case 4:
896 widg = create_text_view (200, -1, 1, 0, G_CALLBACK(cp2k_file_info), GINT_TO_POINTER(j), tmp_cp2k -> files[j-CP2FRE]);
897 break;
898 default:
899 break;
900 }
901 if (j==CP2FRE || j==CP2FWV)
902 {
903 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, checked_box[checkb], widg, FALSE, FALSE, 5);
905 }
906 else if (j==CP2SPM)
907 {
908 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, option_box[optionb], widg, FALSE, FALSE, 5);
909 }
910 else if (j > CP2ROK && j < CP2PBC)
911 {
912 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, print_box, widg, FALSE, FALSE, 5);
913 if (j == CP2POR) cp2k_option_box (print_box, j);
914 }
915 else
916 {
917 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, widg, FALSE, FALSE, 5);
918 if (j==CP2SPI || j==CP2VDW || j==CP2ROK || j==CP2CON) cp2k_option_box (hbox, j);
919 }
920
921 if (j==CP2KTI || j==CP2CUT || j==CP2DLT || j==CP2TMP || j==CP2GEF || j==CP2OUF)
922 {
923 idunit ++;
924 widg = gtk_label_new (cp2k_unit[idunit]);
925 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, widg, FALSE, FALSE, 5);
926 }
927
928 if (idopt == CP2SYM)
929 {
930 gchar * str = g_strdup_printf (" %s provides official CP2K atomic basis sets and pseudo-potentials, are included:", PACKAGE);
931 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label(str, -1, -1, 0.0, 0.5), FALSE, FALSE, 20);
932 g_free (str);
933 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label("<sup><tt>\t - BASIS_MOLOPT\t\t(CP2K v9.1, released: <b>2021-12-31</b>)</tt></sup>\n"
934 "<sup><tt>\t - GTH_BASIS_SETS\t\t(CP2K v9.1, released: <b>2021-12-31</b>)</tt></sup>\n"
935 "<sup><tt>\t - BASIS_SET\t\t(CP2K v9.1, released: <b>2021-12-31</b>)</tt></sup>\n"
936 "<sup><tt>\t - POTENTIAL\t\t(CP2K v9.1, released: <b>2021-12-31</b>)</tt></sup>",
937 -1, -1, 0.1, 0.5), FALSE, FALSE, 0);
938 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label(" Following your selection the files that contains the parameters for your calculation will be generated automatically.\n"
939 " Alternatively it is possible to define and use your own set of parameters.",
940 -1, -1, 0.0, 0.5), FALSE, FALSE, 20);
941 hbox = cpmd_box (vbox, "\t\t\t\tChemical species", 20, 5, 300);
943 for (k=0; k<qm_proj -> nspec; k++) combo_text_append (cp2k_spec_combo, qm_proj -> chemistry -> label[k]);
945 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, cp2k_spec_combo, FALSE, FALSE, 5);
946 cp2k_spec_box[0] = create_hbox (0);
947 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, cp2k_spec_box[0], FALSE, FALSE, 0);
949 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, cp2k_spec_box[0], cp2k_spec_box[1], FALSE, FALSE, 0);
950 g_signal_connect (G_OBJECT (cp2k_spec_combo), "changed", G_CALLBACK(changed_cp2k_box), GINT_TO_POINTER(j));
951 }
952 }
953 }
954 return vbox;
955}
956
964gchar * cp_section_name (int p)
965{
966 if (p < 4)
967 {
968 return g_strdup_printf ("Details of the <b>%s</b> section that %s", cpsect[p], cpelemts[p+1]);
969 }
970 else
971 {
972 return g_strdup_printf ("%s", cpelemts[p+1]);
973 }
974}
975
983GtkWidget * vbox_cp2k (int s)
984{
985 GtkWidget * vbox = create_vbox (BSEP);
986 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label(cp_section_name(s), -1, 20, 0.0, 0.5), FALSE, FALSE, 10);
987 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, cp2k_section_box(s), FALSE, FALSE, 0);
988 if (s== 0) add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, qm_preview_box (1, s, 0), FALSE, FALSE, 5);
989 return vbox;
990}
991
1000G_MODULE_EXPORT void select_input_type (GtkToggleButton * but, gpointer data)
1001{
1002 tmp_cp2k -> input_type = GPOINTER_TO_INT (data);
1003 widget_set_sensitive (fileinf[! tmp_cp2k -> input_type], FALSE);
1004 widget_set_sensitive (fileinf[tmp_cp2k -> input_type], TRUE);
1006}
1007
1015GtkWidget * file_info (int id)
1016{
1017 GtkWidget * main_box;
1018 gchar * filename[4] = {"CP2K main input file '*.inp'", "forces.inc", "system.inc", "motion.inc"};
1019 gchar * filetext[4] = {"<b>&amp;GLOBAL</b>\n...\n<b>&amp;END GLOBAL</b>\n\n<b>@INCLUDE</b> 'forces.inc'\n\n<b>@INCLUDE</b> 'motion.inc'",
1020 "<b>&amp;FORCE_EVAL</b>\n...\n<b>@INCLUDE</b> 'system.inc'\n<b>&amp;END FORCE_EVAL</b>",
1021 "<b>&amp;SUBSYS</b>\n...\n<b>&amp;END SUBSYS</b>",
1022 "<b>&amp;MOTION</b>\n...\n<b>&amp;END MOTION</b>"};
1023 GtkWidget * vbox, * vbx, * hbx;
1024 GtkWidget * vframe;
1025 if (id == 0)
1026 {
1027 main_box = create_vbox (BSEP);
1028 hbx = create_hbox (0);
1029 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbx, stock_image(AFILE), FALSE, FALSE, 5);
1030 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbx, gtk_label_new ("CP2K input file '*.inp'"), FALSE, FALSE, 5);
1031 vframe = gtk_frame_new (NULL);
1032 gtk_frame_set_label_widget (GTK_FRAME(vframe), hbx);
1033#ifdef GTK3
1034 gtk_frame_set_shadow_type (GTK_FRAME(vframe), GTK_SHADOW_ETCHED_IN);
1035#endif
1036 add_box_child_start (GTK_ORIENTATION_VERTICAL, main_box, vframe, FALSE, FALSE, 10);
1037 vbox = create_vbox (BSEP);
1039 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label("! Information", 200, -1, 0.0, 0.5), FALSE, FALSE, 5);
1040 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label("<b>&amp;GLOBAL</b>\n...\n<b>&amp;END GLOBAL</b>", 100, -1, 0.0, 0.5), FALSE, FALSE, 5);
1041 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label("<b>&amp;FORCE_EVAL</b>\n...", 200, -1, 0.0, 0.5), FALSE, FALSE, 5);
1042 hbx = create_hbox (0);
1043 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbx, FALSE, FALSE, 5);
1044 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbx, markup_label("<b>&amp;SUBSYS</b>\n...\n<b>&amp;END SUBSYS</b>", 150, -1, 0.0, 0.5), FALSE, FALSE, 10);
1045 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label("<b>&amp;END FORCE_EVAL</b>", 200, -1, 0.0, 0.5), FALSE, FALSE, 0);
1046 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label("<b>&amp;MOTION</b>\n...\n<b>&amp;END MOTION</b>", 200, -1, 0.0, 0.5), FALSE, FALSE, 5);
1047 }
1048 else
1049 {
1050 main_box = create_hbox (0);
1051 vbox = create_vbox (BSEP);
1052 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, main_box, vbox, FALSE, FALSE, 0);
1053 int i;
1054 for (i=0; i<4; i++)
1055 {
1056 hbx = create_hbox (0);
1057 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbx, stock_image(AFILE), FALSE, FALSE, 5);
1058 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbx, gtk_label_new (filename[i]), FALSE, FALSE, 5);
1059 vframe = gtk_frame_new (NULL);
1060 gtk_frame_set_label_widget (GTK_FRAME(vframe), hbx);
1061#ifdef GTK3
1062 gtk_frame_set_shadow_type (GTK_FRAME(vframe), GTK_SHADOW_ETCHED_IN);
1063#endif
1064 vbx = create_vbox (BSEP);
1065 add_container_child (CONTAINER_FRA, vframe, vbx);
1066 if (i == 0) add_box_child_start (GTK_ORIENTATION_VERTICAL, vbx, markup_label("! Information", 200, -1, 0.0, 0.5), FALSE, FALSE, 5);
1067 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbx, markup_label(filetext[i], 200, -1, 0.0, 0.5), FALSE, FALSE, 5);
1068 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, vframe, FALSE, FALSE, 5);
1069 if (i == 0)
1070 {
1071 vbox = create_vbox (BSEP);
1072 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, main_box, vbox, FALSE, FALSE, 20);
1073 }
1074 }
1075 }
1076 return main_box;
1077}
1078
1085GtkWidget * init_cp2k ()
1086{
1087 GtkWidget * vbox = create_vbox (BSEP);
1088 gchar * text = "The CP2K input system offers to have the information gathered in a single, rather long, file\n"
1089 "or separated in several files each of them dedicated to a particular section of the input: ";
1090 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, gtk_label_new (text), FALSE, FALSE, 20);
1091 GtkWidget * hbox = create_hbox (0);
1092 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 0);
1093 GtkWidget * hbx;
1094 gchar * ftext[2] = {"Single input file", "Multiple files"};
1095 int i, j;
1096 j = tmp_cp2k -> input_type;
1097 for (i=0; i<2; i++)
1098 {
1099 vfbox[i] = create_vbox (BSEP);
1100 gtk_widget_set_size_request (vfbox[i], (i==0) ? 200 : 400, -1);
1101 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, vfbox[i], FALSE, FALSE, (i==0) ? 50 : 10);
1102 fileinf[i] = file_info (i);
1103 add_box_child_start (GTK_ORIENTATION_VERTICAL, vfbox[i], fileinf[i], FALSE, FALSE, (i==0) ? 0 : 15);
1104 hbx = create_hbox (0);
1105 add_box_child_start (GTK_ORIENTATION_VERTICAL, vfbox[i], hbx, FALSE, FALSE, 0);
1106
1107#ifdef GTK4
1108 filebut[i] = check_button (ftext[i], -1, -1, (i != j) ? FALSE : TRUE, G_CALLBACK(select_input_type), GINT_TO_POINTER(i));
1109 if (i) gtk_check_button_set_group ((GtkCheckButton *)filebut[i], (GtkCheckButton *)filebut[0]);
1110#else
1111 if (! i)
1112 {
1113 filebut[i] = radio_button (ftext[i], -1, -1, (i != j) ? FALSE : TRUE, G_CALLBACK(select_input_type), GINT_TO_POINTER(i));
1114 }
1115 else
1116 {
1117 filebut[i] = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON(filebut[0]), ftext[i]);
1118 }
1119#endif
1120 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbx, filebut[i], FALSE, FALSE, (i==0) ? 50 : 120);
1121 }
1122 tmp_cp2k -> input_type = j;
1123 widget_set_sensitive (fileinf[tmp_cp2k -> input_type], TRUE);
1124 widget_set_sensitive (fileinf[! tmp_cp2k -> input_type], FALSE);
1126 return vbox;
1127}
1128
1136gchar * page_name_cp2k (int p)
1137{
1138 if (p == 0)
1139 {
1140 return g_strdup_printf ("The CP2K input structure");
1141 }
1142 else if (p < 5)
1143 {
1144 return g_strdup_printf ("The %s section", cpsect[p-1]);
1145 }
1146 else if (p == 5)
1147 {
1148 return g_strdup_printf ("The MOTION section - thermostat(s)");
1149 }
1150 else
1151 {
1152 return g_strdup_printf ("The MOTION section - restart(s)");
1153 }
1154}
1155
1162{
1163 if (GTK_IS_WIDGET(motion_box[0])) hide_the_widgets (motion_box[0]);
1164 if (GTK_IS_WIDGET(motion_box[1])) hide_the_widgets (motion_box[1]);
1165 if (tmp_cp2k -> opts[CP2RUN] == 2.0 || tmp_cp2k -> opts[CP2RUN] == 3.0 || tmp_cp2k -> opts[CP2RUN] == 6.0)
1166 {
1167 int i = (tmp_cp2k -> opts[CP2RUN] == 2.0) ? 1 : 0;
1168 if (GTK_IS_WIDGET(motion_box[i])) show_the_widgets (motion_box[i]);
1169 return TRUE;
1170 }
1171 else
1172 {
1173 return FALSE;
1174 }
1175}
1176
1183{
1184 int i;
1185 gchar * info;
1186 GtkAssistant * assist = GTK_ASSISTANT(qm_assistant);
1187 GtkWidget * page;
1188 idopt = -1;
1189 ident = -1;
1190 icomb = -1;
1191 idunit = -1;
1192 checkb = -1;
1193 optionb = -1;
1194 motionb = -1;
1195 for (i=0; i<(cp2k_with_motion() ? 5: 4); i++)
1196 {
1197 if (i > 0)
1198 {
1199 page = vbox_cp2k (i-1);
1200 }
1201 else
1202 {
1203 page = init_cp2k ();
1204 }
1205 gtk_assistant_append_page (assist, page);
1206 gtk_assistant_set_page_title (assist, page, page_name_cp2k(i));
1207 gtk_assistant_set_page_type (assist, page, GTK_ASSISTANT_PAGE_CONTENT);
1208 gtk_assistant_set_page_complete (assist, page, TRUE);
1209 }
1210 GtkWidget * conclu = create_vbox (BSEP);
1211 info = g_strdup_printf ("<b> Finalize the creation of the CP2K input files now !</b>");
1212 add_box_child_start (GTK_ORIENTATION_VERTICAL, conclu, markup_label(info, -1, -1, 0.5, 0.5), TRUE, TRUE, 100);
1213 g_free (info);
1214 add_box_child_start (GTK_ORIENTATION_VERTICAL, conclu, 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), FALSE, FALSE, 0);
1215 gtk_assistant_append_page (assist, conclu);
1216 gtk_assistant_set_page_title (assist, conclu, "Create the input files now !");
1217 gtk_assistant_set_page_type (assist, conclu, GTK_ASSISTANT_PAGE_CONFIRM);
1218 gtk_assistant_set_page_complete (assist, conclu, TRUE);
1219 gtk_assistant_update_buttons_state (assist);
1220}
1221
1229{
1230 box_info * box = & qm_proj -> cell.box[0];
1231 if (box -> param[0][0] == box -> param[0][1] &&
1232 box -> param[0][0] == box -> param[0][2] &&
1233 box -> param[0][1] == box -> param[0][2])
1234 {
1235 if (box -> param[1][0] == box -> param[1][1] &&
1236 box -> param[1][0] == box -> param[1][2] &&
1237 box -> param[1][1] == box -> param[1][2] &&
1238 box -> param[1][0] == 90.0) return 0;
1239 if (box -> param[1][0] == box -> param[1][1] &&
1240 box -> param[1][0] == box -> param[1][2] &&
1241 box -> param[1][1] == box -> param[1][2] &&
1242 box -> param[1][0] != 90.0) return 3;
1243 }
1244 if (box -> param[1][0] == box -> param[1][1] &&
1245 box -> param[1][0] == box -> param[1][2] &&
1246 box -> param[1][1] == box -> param[1][2] &&
1247 box -> param[1][0] == 90.0)
1248 {
1249 if (box -> param[0][0] == box -> param[0][1] && box -> param[0][0] != box -> param[0][2]) return 4;
1250 if (box -> param[0][0] == box -> param[0][2] && box -> param[0][0] != box -> param[0][1]) return 5;
1251 if (box -> param[0][1] == box -> param[0][2] && box -> param[0][1] != box -> param[0][0]) return 6;
1252 }
1253 if (box -> param[1][0] == box -> param[1][1] &&
1254 box -> param[1][0] == box -> param[1][2] &&
1255 box -> param[1][1] == box -> param[1][2])
1256 {
1257 if (box -> param[0][0] != box -> param[0][1] &&
1258 box -> param[0][0] != box -> param[0][2] &&
1259 box -> param[0][1] != box -> param[0][2]) return 2;
1260 }
1261 if (box -> param[1][0] == box -> param[1][1] && box -> param[1][0] == 90.0)
1262 {
1263 if (box -> param[1][2] == 60.0)
1264 {
1265 if (box -> param[0][0] == box -> param[0][1] && box -> param[0][0] != box -> param[0][2]) return 1;
1266 }
1267 }
1268 if (box -> param[1][0] == box -> param[1][2] && box -> param[1][0] == 90.0)
1269 {
1270 if (box -> param[1][1] != 90.0)
1271 {
1272 if (box -> param[0][0] != box -> param[0][1] &&
1273 box -> param[0][0] != box -> param[0][2] &&
1274 box -> param[0][1] != box -> param[0][2]) return 7;
1275 }
1276 }
1277 if (box -> param[0][0] != box -> param[0][1] &&
1278 box -> param[0][0] != box -> param[0][2] &&
1279 box -> param[0][1] != box -> param[0][2])
1280 {
1281 if (box -> param[1][0] != box -> param[1][1] &&
1282 box -> param[1][0] != box -> param[1][2] &&
1283 box -> param[1][1] != box -> param[1][2]) return 8;
1284 }
1285 return 9;
1286}
GtkTextBuffer * qmbuffer[MAXDATAQM+2]
Definition calc.c:70
int ident
Definition calc.c:74
GtkWidget * qm_assistant
Definition calc.c:66
int idopt
Definition calc.c:72
project * qm_proj
Definition calc.c:67
int icomb
Definition calc.c:75
Variable declarations for the MD input preparation assistants.
Callback declarations for main window.
integer(kind=c_int) function chemistry()
Definition chemistry.F90:22
#define PACKAGE
Definition config.h:46
Variable declarations for the creation of the CP2K input file(s)
#define CP2VDW
Definition cp2k.h:64
#define CP2FWV
Definition cp2k.h:50
#define CP2PLO
Definition cp2k.h:69
#define CP2GEF
Definition cp2k.h:80
#define CP2FRE
Definition cp2k.h:47
#define CP2GMI
Definition cp2k.h:78
#define CP2DLT
Definition cp2k.h:76
#define CP2ENS
Definition cp2k.h:74
#define CP2SPM
Definition cp2k.h:63
#define CP2RUN
Definition cp2k.h:43
#define CP2OUF
Definition cp2k.h:81
#define CP2KTI
Definition cp2k.h:44
#define CP2PBC
Definition cp2k.h:71
#define CP2ROK
Definition cp2k.h:65
#define CP2RES
Definition cp2k.h:46
#define CP2POR
Definition cp2k.h:70
GtkWidget * prepare_basis_combo(int sp, int obj)
prepare basis set / pseudopotential combo box
Definition cp2k_files.c:289
#define CP2NST
Definition cp2k.h:75
#define CP2CON
Definition cp2k.h:82
#define CP2SPI
Definition cp2k.h:62
#define CP2PFO
Definition cp2k.h:66
#define CP2CUT
Definition cp2k.h:52
#define CP2SYM
Definition cp2k.h:73
#define CP2SCN
Definition cp2k.h:57
#define CP2TMP
Definition cp2k.h:77
#define CP2NTHERM
Definition cp2k.h:86
#define CP2SCO
Definition cp2k.h:59
GtkWidget * cp2k_combo
Definition cp2k_init.c:228
G_MODULE_EXPORT void update_cp2k_option(GtkEntry *res, gpointer data)
update CP2K option entry callback
Definition cp2k_init.c:266
int idunit
Definition cp2k_init.c:220
void cp2k_fix_molecule()
CP2K assistant fixing fragment(s) - creating the dialog.
Definition cp2k_mol.c:243
void print_cp2k(int f, GtkTextBuffer *buffer)
print the CP2K input file section
GtkWidget * option_box[4]
Definition cp2k_init.c:231
gchar * cp2k_default_text[11][11]
Definition cp2k_init.c:117
GtkWidget * cp2k_section_box(int s)
create the CP2K assistant section box
Definition cp2k_init.c:814
void field_unselect_all()
unselect all atoms
Definition dlp_viz.c:130
GtkWidget * vfbox[2]
Definition cp2k_init.c:225
int cp2k_opts_type[4][NC2OP]
Definition cp2k_init.c:215
gchar * cp_section_name(int p)
get CP2K section name
Definition cp2k_init.c:964
GtkWidget * cp2k_spec_combo
Definition cp2k_init.c:235
void create_selection_button(GtkWidget *box, int num, int id, gpointer data)
create thermostat atom(s) selection button
Definition cpmd_nose.c:1426
GtkWidget * checked_box[2]
Definition cp2k_init.c:230
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 * create_cp2k_spec_box(int spec)
create a CP2K chemical species option combo box
Definition cp2k_init.c:672
gchar * cpelemts[7]
Definition cp2k_init.c:194
GtkWidget * cp2k_spec_box[2]
Definition cp2k_init.c:234
GtkWidget * filebut[2]
Definition cp2k_init.c:226
int motionb
Definition cp2k_init.c:223
double default_cp2k_extra[3][4]
Definition cp2k_init.c:95
int checkb
Definition cp2k_init.c:221
void add_cp2k_pages()
add pages to the CP2 assistant
Definition cp2k_init.c:1182
int optionb
Definition cp2k_init.c:222
GtkWidget * fileinf[2]
Definition cp2k_init.c:227
GtkWidget * init_cp2k()
initialize the CP2K input creation assistant
Definition cp2k_init.c:1085
gchar * cp2k_vdw_keywords[2][3]
Definition cp2k_init.c:115
#define NC2OP
Definition cp2k_init.c:212
G_MODULE_EXPORT void update_cp2k_check(GtkToggleButton *but, gpointer data)
update some CP2K parameter toggle callback GTK3
Definition cp2k_init.c:587
ColRGBA init_color(int id, int numid)
initialize color based id number over total number of elements
Definition initcoord.c:81
G_MODULE_EXPORT void cp2k_file_info(GtkTextBuffer *textbuf, gpointer data)
update the C2PK information textview
Definition cp2k_init.c:630
GtkWidget * qm_preview_box(int c, int s, int l)
prepare preview section widgets
Definition cpmd_init.c:881
int find_cp2k_sym()
find the CP2K symmetry parameter based on the cell properties
Definition cp2k_init.c:1228
GtkWidget * cp2k_vdw_box[2]
Definition cp2k_init.c:233
G_MODULE_EXPORT void changed_cp2k_option_box(GtkComboBox *box, gpointer data)
change a GtkComboBox while creating a CP2K input file
Definition cp2k_init.c:328
G_MODULE_EXPORT void update_cp2k_parameter(GtkEntry *res, gpointer data)
update some CP2K parameters
Definition cp2k_init.c:547
GtkWidget * vbox_cp2k(int s)
create the CP2K assistant page vertical box
Definition cp2k_init.c:983
gchar * cp2k_default_keywords[11][11]
Definition cp2k_init.c:101
double default_vdw_cut[2]
Definition cp2k_init.c:94
gchar * global_opts[40]
Definition cp2k_init.c:153
gchar * cp2k_vdw_text[2][3]
Definition cp2k_init.c:147
void print_start_buffer()
update of the GtkTextBuffer showing the CP2K input
Definition cp2k_init.c:245
gchar * cp2k_unit[6]
Definition cp2k_init.c:97
G_MODULE_EXPORT void select_input_type(GtkToggleButton *but, gpointer data)
select the input file type
Definition cp2k_init.c:1000
GtkWidget * motion_box[2]
Definition cp2k_init.c:232
GtkWidget * cp2k_label
Definition cp2k_init.c:229
GtkWidget * create_vdw_box(int id)
create the VdW informaiton and option(s) widgets
Definition cp2k_init.c:359
gchar * cpsect[4]
Definition cp2k_init.c:202
G_MODULE_EXPORT void changed_cp2k_box(GtkComboBox *box, gpointer data)
change CP2K option
Definition cp2k_init.c:726
G_MODULE_EXPORT void update_cp2k_option_check(GtkToggleButton *but, gpointer data)
CP2K option toggle callback GTK3.
Definition cp2k_init.c:309
double default_cp2k_options[41]
Definition cp2k_init.c:88
int var_by_cp2sections[4]
Definition cp2k_init.c:152
void cp2k_option_box(GtkWidget *box, int id)
create a CP2K option combo box
Definition cp2k_init.c:793
gboolean cp2k_with_motion()
CP2K MD calculation ?
Definition cp2k_init.c:1161
cp2k * tmp_cp2k
Definition cp2k_init.c:86
GtkWidget * thermo_box()
create the thermostat configuration widgets
Definition cpmd_nose.c:1884
gchar * page_name_cp2k(int p)
get CP2K assistant page name
Definition cp2k_init.c:1136
char * k_thermo[CP2NTHERM][4]
Definition cp2k_init.c:207
GtkWidget * spec_data_combo[2]
Definition cp2k_init.c:236
int cp2k_default_num[12]
Definition cp2k_init.c:99
GtkWidget * file_info(int id)
create the assistant page that present the input file(s) properties
Definition cp2k_init.c:1015
GtkWidget * cp2k_thermo_box
Definition cp2k_init.c:237
G_MODULE_EXPORT void cp2k_option_dialog(GtkWidget *but, gpointer data)
CP2K option dialog - creating the dialog.
Definition cp2k_init.c:464
GtkWidget * print_box
Definition cp2k_init.c:224
Variable declarations for the creation of the CPMD input file.
gchar * param[2]
void label(cairo_t *cr, double val, int axe, int p, project *this_proj)
draw axis label
Definition labels.c:56
gchar * text
Definition datab.c:105
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...
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_STOCK
Definition global.h:266
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
GtkWidget * dialogmodal(gchar *str, GtkWindow *parent)
Create a new dialog modal window.
Definition gtk-misc.c:520
void combo_set_active(GtkWidget *combo, int pos)
set the active item's position
Definition gtk-misc.c:932
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 update_entry_int(GtkEntry *entry, int intval)
update the content of a GtkEntry as int
Definition gtk-misc.c:624
GtkWidget * stock_image(const gchar *stock_id)
create a GtkImage for the Gtk database
Definition gtk-misc.c:1425
GtkWidget * radio_button(gchar *text, int dimx, int dimy, gboolean state, GCallback handler, gpointer data)
create a radio button
Definition gtk-misc.c:1926
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_FRA
Definition global.h:256
#define DPROPERTIES
Definition global.h:208
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
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
#define AFILE
Definition global.h:226
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
void show_the_widgets(GtkWidget *widg)
show GtkWidget
Definition gtk-misc.c:182
void motion(glwin *view, gint x, gint y, GdkModifierType state)
mouse motion in the OpenGL window
Definition glview.c:637
Variable declarations related to the OpenGL window Function declarations related to the OpenGL wind...
Function declarations for the creation of the OpenGL window.
Messaging function declarations.
Function declarations for reading atomes project file Function declarations for saving atomes proje...
Definition glwin.h:351
Definition global.h:795
int c
Definition tab-1.c:95
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