atomes 1.1.16
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-2024 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#ifdef GTK4
315 tmp_cp2k -> extra_opts[i][(i==2)?2:3] = (double) gtk_check_button_get_active (but);
316#else
317 tmp_cp2k -> extra_opts[i][(i==2)?2:3] = (double) gtk_toggle_button_get_active (but);
318#endif
320}
321
322GtkWidget * create_vdw_box (int id);
323
332G_MODULE_EXPORT void changed_cp2k_option_box (GtkComboBox * box, gpointer data)
333{
334 int i, j, k;
335 i = GPOINTER_TO_INT(data);
336 if (i < 2)
337 {
338 j = k = 1;
339 }
340 else
341 {
342 j = 0;
343 k = i - CP2VDW;
344 }
345 tmp_cp2k -> extra_opts[j][k] = (double) gtk_combo_box_get_active (box);
346 if (i == CP2VDW)
347 {
349 cp2k_vdw_box[1] = create_vdw_box ((int)tmp_cp2k -> extra_opts[0][0]);
350 add_box_child_start (GTK_ORIENTATION_VERTICAL, cp2k_vdw_box[0], cp2k_vdw_box[1], FALSE, FALSE, 0);
352 }
354}
355
363GtkWidget * create_vdw_box (int id)
364{
365 GtkWidget * vbox, * hbox;
366 GtkWidget * widg;
367 gchar * cp2k_vdw_vars[2] = {"Type of potential:", "Cutoff:"};
368 int i, j, k;
369 vbox = create_vbox(5);
370 i = (id == 0) ? 2 : 3;
371 for (j=0; j<i; j++)
372 {
373 hbox = create_hbox(5);
374 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 0);
375 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);
376 switch (j)
377 {
378 case 0:
379 widg = create_combo ();
380 for (k=0; k<3; k++) combo_text_append (widg, cp2k_vdw_text[id][k]);
381 gtk_combo_box_set_active (GTK_COMBO_BOX(widg), (int)tmp_cp2k -> extra_opts[0][j+1]);
382 g_signal_connect (G_OBJECT (widg), "changed", G_CALLBACK(changed_cp2k_option_box), GINT_TO_POINTER(CP2VDW+1));
383 break;
384 case 1:
385 widg = create_entry (G_CALLBACK(update_cp2k_option), 100, 15, FALSE, GINT_TO_POINTER(CP2VDW));
386 tmp_cp2k -> extra_opts[0][j+1] = default_vdw_cut[id];
387 update_entry_double (GTK_ENTRY(widg), tmp_cp2k -> extra_opts[0][j+1]);
388 break;
389 case 2:
390 widg = check_button ("Apply long range corrections", -1, -1, tmp_cp2k -> extra_opts[0][j+1],
391 G_CALLBACK(update_cp2k_option_check), GINT_TO_POINTER(0));
392 break;
393 }
394 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, widg, FALSE, FALSE, 5);
395 }
396 return vbox;
397}
398
468G_MODULE_EXPORT void cp2k_option_dialog (GtkWidget *but, gpointer data)
469{
470 int i, j;
471 i = GPOINTER_TO_INT(data);
472 GtkWidget * vbox, * hbox;
473 GtkWidget * widg;
474 gchar * cp2k_vdw_options[2] = {"Non-local potential", "Pair potential"};
475 gchar * cp2k_roks_options[2] = {"Energy scaling:", "Spin configuration <sup>*</sup>:"};
476 gchar * cp2k_orb_options[2] = {"Number of HOMO levels (-1 for all):", "Number of LUMO levels (-1 for all):"};
477
478 gchar * str = g_strdup_printf ("%s - options", global_opts[i]);
479 GtkWidget * dial = dialogmodal (str, GTK_WINDOW(qm_assistant));
480 g_free (str);
482 switch (i)
483 {
484 case CP2VDW:
485 hbox = create_hbox (5);
486 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 10);
487 widg = create_combo ();
488 for (j=0; j<2; j++) combo_text_append (widg, cp2k_vdw_options[j]);
489 gtk_combo_box_set_active (GTK_COMBO_BOX(widg), (int)tmp_cp2k -> extra_opts[0][0]);
490 g_signal_connect (G_OBJECT (widg), "changed", G_CALLBACK(changed_cp2k_option_box), GINT_TO_POINTER(CP2VDW));
491 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);
492 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, widg, FALSE, FALSE, 5);
494 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, cp2k_vdw_box[0], FALSE, FALSE, 10);
495 cp2k_vdw_box[1] = create_vdw_box ((int)tmp_cp2k -> extra_opts[0][0]);
496 add_box_child_start (GTK_ORIENTATION_VERTICAL, cp2k_vdw_box[0], cp2k_vdw_box[1], FALSE, FALSE, 0);
497 break;
498 case CP2ROK:
499 for (j=0; j<2; j++)
500 {
501 hbox = create_hbox (5);
502 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 5);
503 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label(cp2k_roks_options[j], 200, -1, 0.0, 0.5), FALSE, FALSE, 5);
504 if (j==0)
505 {
506 widg = create_entry (G_CALLBACK(update_cp2k_option), 100, 15, FALSE, GINT_TO_POINTER(i+j));
507 update_entry_double (GTK_ENTRY(widg), tmp_cp2k -> extra_opts[1][j]);
508 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, widg, FALSE, FALSE, 10);
509 }
510 else
511 {
512 widg = create_combo ();
513 combo_text_append (widg, "alpha - α");
514 combo_text_append (widg, "beta - β");
515 gtk_combo_box_set_active (GTK_COMBO_BOX(widg), (int)tmp_cp2k -> extra_opts[1][1]);
516 g_signal_connect (G_OBJECT (widg), "changed", G_CALLBACK(changed_cp2k_option_box), GINT_TO_POINTER(j));
517 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, widg, FALSE, FALSE, 10);
518 }
519 }
520 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, gtk_label_new ("* for the singly occupied orbitals"), FALSE, FALSE, 5);
521 break;
522 case CP2POR:
523 for (j=0; j<2; j++)
524 {
525 hbox = create_hbox (5);
526 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 5);
527 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label(cp2k_orb_options[j], 250, -1, 0.0, 0.5), FALSE, FALSE, 5);
528 widg = create_entry (G_CALLBACK(update_cp2k_option), 100, 15, FALSE, GINT_TO_POINTER(i+j));
529 update_entry_int (GTK_ENTRY(widg), tmp_cp2k -> extra_opts[2][j]);
530 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, widg, FALSE, FALSE, 0);
531 }
532 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],
533 G_CALLBACK(update_cp2k_option_check), GINT_TO_POINTER(2)), FALSE, FALSE, 5);
534 break;
535 case CP2CON:
536 create_selection_button (vbox, tmp_cp2k -> fixat[0], 1, GINT_TO_POINTER(-1));
537 //create_mol_selection_button (vbox, 2);
538 break;
539 }
540 run_this_gtk_dialog (dial, G_CALLBACK(run_destroy_dialog), NULL);
541}
542
551G_MODULE_EXPORT void update_cp2k_parameter (GtkEntry * res, gpointer data)
552{
553 int i;
554 i = GPOINTER_TO_INT(data);
555 const gchar * m = entry_get_text (res);
556 double v = string_to_double ((gpointer)m);
557 if (tmp_cp2k -> opts[i] != v)
558 {
559 tmp_cp2k -> opts[i] = v;
561 }
562 if (i==CP2CUT || i==CP2SCN || i==CP2SCO || i==CP2DLT || i==CP2GEF)
563 {
564 update_entry_double (res, tmp_cp2k -> opts[i]);
565 }
566 else
567 {
568 update_entry_int (res, tmp_cp2k -> opts[i]);
569 }
570}
571
572#ifdef GTK4
581G_MODULE_EXPORT void update_cp2k_check (GtkCheckButton * but, gpointer data)
582#else
591G_MODULE_EXPORT void update_cp2k_check (GtkToggleButton * but, gpointer data)
592#endif
593{
594 int i, j;
595 i = GPOINTER_TO_INT(data);
596#ifdef GTK4
597 tmp_cp2k -> opts[i] = (double) gtk_check_button_get_active (but);
598#else
599 tmp_cp2k -> opts[i] = (double) gtk_toggle_button_get_active (but);
600#endif
601 if (i == CP2RES)
602 {
603 for (j=0; j<2; j++) widget_set_sensitive (checked_box[j], (int)tmp_cp2k -> opts[CP2RES]);
604 }
605 else if (i==CP2SPI || i==CP2VDW || i==CP2ROK || i==CP2POR || i==CP2CON)
606 {
607 switch (i)
608 {
609 case CP2SPI:
610 j = 0;
611 break;
612 case CP2VDW:
613 j = 1;
614 break;
615 case CP2ROK:
616 j = 2;
617 break;
618 case CP2POR:
619 j = 3;
620 break;
621 case CP2CON:
622 j = 4;
623 break;
624 }
625 widget_set_sensitive (option_box[j], (int)tmp_cp2k -> opts[i]);
626 }
628}
629
638G_MODULE_EXPORT void cp2k_file_info (GtkTextBuffer * textbuf, gpointer data)
639{
640 int i, j, k;
641 i = GPOINTER_TO_INT(data) - CP2FRE;
642 GtkTextIter bStart;
643 GtkTextIter bEnd;
644 gtk_text_buffer_get_start_iter (textbuf, & bStart);
645 gtk_text_buffer_get_end_iter (textbuf, & bEnd);
646 if (i < 5)
647 {
648 if (tmp_cp2k -> files[i] != NULL) g_free (tmp_cp2k -> files[i]);
649 tmp_cp2k -> files[i] = g_strdup_printf ("%s", gtk_text_buffer_get_text (textbuf, & bStart, & bEnd, FALSE));
650 if (g_strcmp0 (tmp_cp2k -> files[i], "") == 0) tmp_cp2k -> files[i] = NULL;
651 }
652 else
653 {
654 j = gtk_combo_box_get_active (GTK_COMBO_BOX(cp2k_spec_combo));
655 k = i + CP2FRE - 10;
656 if (tmp_cp2k -> spec_files[j][k] != NULL) g_free (tmp_cp2k -> spec_files[j][k]);
657 tmp_cp2k -> spec_files[j][k] = g_strdup_printf ("%s", gtk_text_buffer_get_text (textbuf, & bStart, & bEnd, FALSE));
658 if (g_strcmp0 (tmp_cp2k -> spec_files[j][k], "") == 0)
659 {
660 tmp_cp2k -> spec_files[j][k] = NULL;
661 gtk_combo_box_set_active (GTK_COMBO_BOX(spec_data_combo[k]), tmp_cp2k -> spec_data[j][k]);
663 }
664 else if (spec_data_combo[k] != NULL)
665 {
666 gtk_combo_box_set_active (GTK_COMBO_BOX(spec_data_combo[k]), -1);
668 }
669 }
671}
672
680GtkWidget * create_cp2k_spec_box (int spec)
681{
682 gchar * info[2] = {"<b>-</b> Select and use set of parameters from the database: ",
683 "<b>-</b> Define and use other set of parameters: "};
684 gchar * data_name[2][2] = {{"\t\tAvailable basis set for ", "\t\tAvailable pseudo-potential for "},
685 {"\t\tBasis set for ", "\t\tPseudo-potential for "}};
686 GtkWidget * vbox = create_vbox (BSEP);
687 GtkWidget * hbox;
688 gchar * str;
689 int i, j;
690 for (i=0; i<2; i++)
691 {
692 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label(info[i], -1, -1, 0.0, 0.5), FALSE, FALSE, 5);
693 for (j=0; j<2; j++)
694 {
695 str = g_strdup_printf ("%s%s", data_name[i][j], qm_proj -> chemistry -> label[spec]);
696 hbox = cpmd_box (vbox, str, 5, 5, 300);
697 g_free (str);
698 if (i==0)
699 {
700 spec_data_combo[j] = NULL;
701 if (tmp_cp2k -> spec_data[spec][j] > -1)
702 {
704 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, spec_data_combo[j], FALSE, FALSE, 5);
705 }
706 else
707 {
708 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label("<b>None</b>", -1, -1, 0.5, 0.5), FALSE, FALSE, 5);
709 }
710 }
711 else
712 {
713 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, create_text_view (350, -1, 1, 0, G_CALLBACK(cp2k_file_info),
714 GINT_TO_POINTER(j+10), tmp_cp2k -> spec_files[spec][j]),
715 FALSE, FALSE, 5);
716 }
717 }
718 }
719 return vbox;
720}
721
722gboolean cp2k_with_motion ();
723GtkWidget * vbox_cp2k (int s);
724gchar * page_name_cp2k (int p);
725
734G_MODULE_EXPORT void changed_cp2k_box (GtkComboBox * box, gpointer data)
735{
736 int i, j;
737 gboolean motion;
738 i = GPOINTER_TO_INT(data);
739 j = gtk_combo_box_get_active (box);
740 if (j != (int)tmp_cp2k -> opts[i])
741 {
742 if (i == CP2SYM)
743 {
745 cp2k_spec_box[1] = create_cp2k_spec_box (gtk_combo_box_get_active (box));
747 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, cp2k_spec_box[0], cp2k_spec_box[1], FALSE, FALSE, 0);
748 }
749 else
750 {
751 if (i == CP2RUN) motion = cp2k_with_motion ();
752 tmp_cp2k -> opts[i] = (double) gtk_combo_box_get_active (box);
753
754 if (i == CP2RUN)
755 {
756 if (motion && ! cp2k_with_motion())
757 {
758 gtk_assistant_remove_page (GTK_ASSISTANT(qm_assistant), 5);
759 }
760 else if (! motion && cp2k_with_motion())
761 {
762 GtkAssistant * assist = GTK_ASSISTANT(qm_assistant);
763 idopt = CP2SYM;
764 motionb = -1;
765 optionb = 3;
766 idunit = 1;
767 icomb = 8;
768 GtkWidget * page = vbox_cp2k (3);
769 show_the_widgets (page);
770 gtk_assistant_insert_page (assist, page, 5);
771 gtk_assistant_set_page_title (assist, page, page_name_cp2k(4));
772 gtk_assistant_set_page_type (assist, page, GTK_ASSISTANT_PAGE_CONTENT);
773 gtk_assistant_set_page_complete (assist, page, TRUE);
775 }
776 }
777 else if (i == CP2ENS)
778 {
779 if (j == 2 || j == 3)
780 {
782 }
783 else
784 {
786 }
787 }
789 }
790 }
791}
792
801void cp2k_option_box (GtkWidget * box, int id)
802{
803 optionb ++;
805 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, box, option_box[optionb], FALSE, FALSE, 5);
806 if (id != CP2SPI)
807 {
808 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, option_box[optionb],
809 create_button ("Options", IMG_STOCK, DPROPERTIES, 200, -1, GTK_RELIEF_NORMAL, G_CALLBACK(cp2k_option_dialog), GINT_TO_POINTER(id)),
810 FALSE, FALSE, 50);
811 }
812 widget_set_sensitive (option_box[optionb], (int)tmp_cp2k -> opts[id]);
813}
814
822GtkWidget * cp2k_section_box (int s)
823{
824 int i, j, k;
825 GtkWidget * hbox;
826 GtkWidget * widg;
827 GtkWidget * vbox = create_vbox (BSEP);
828 for (i=0; i<NC2OP; i++)
829 {
830 if (cp2k_opts_type[s][i] > 0)
831 {
832 idopt ++;
833 j = idopt;
834 if (j == CP2NST)
835 {
837 add_box_child_start (GTK_ORIENTATION_VERTICAL, motion_box[motionb], cp2k_thermo_box, FALSE, FALSE, 5);
839 }
840 else if (j == CP2FRE || j == CP2FWV)
841 {
842 checkb ++;
844 }
845 else if (j == CP2SPM)
846 {
847 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, option_box[optionb], markup_label(global_opts[idopt], 100, 30, 0.0, 0.5), FALSE, FALSE, 50);
848 }
849 else if (j == CP2PFO || j == CP2PLO)
850 {
851 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);
853 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, print_box, FALSE, FALSE, 0);
854 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, print_box, markup_label(global_opts[idopt], 150, 30, 0.0, 0.5), FALSE, FALSE, 50);
855 }
856 else if (j > CP2ROK && j < CP2PBC)
857 {
858 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, print_box, markup_label(global_opts[idopt], 150, 30, 0.0, 0.5), FALSE, FALSE, 50);
859 }
860 else if (j == CP2ENS || j == CP2GMI)
861 {
862 motionb ++;
864 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, motion_box[motionb], FALSE, FALSE, 5);
866 }
867 else if (j > CP2ENS && j < CP2OUF)
868 {
870 }
871 else if (j == CP2SCN || j == CP2SCO)
872 {
873 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label(global_opts[idopt], 150, 30, 0.0, 0.5), FALSE, FALSE, 30);
874 }
875 else
876 {
877 hbox = cpmd_box (vbox, global_opts[idopt], 5, 5, 300);
878 }
879 switch (cp2k_opts_type[s][i])
880 {
881 case 1:
882 ident ++;
883 widg = create_entry (G_CALLBACK(update_cp2k_parameter), 100, 15, FALSE, GINT_TO_POINTER(j));
884 if (j==CP2CUT || j==CP2SCN || j==CP2SCO || j==CP2DLT || j==CP2GEF)
885 {
886 update_entry_double (GTK_ENTRY(widg), tmp_cp2k -> opts[j]);
887 }
888 else
889 {
890 update_entry_int (GTK_ENTRY(widg), tmp_cp2k -> opts[j]);
891 }
892 break;
893 case 2:
894 icomb ++;
895 widg = create_combo ();
896 for (k=0; k<cp2k_default_num[icomb]; k++) combo_text_append (widg, cp2k_default_text[icomb][k]);
897 gtk_combo_box_set_active (GTK_COMBO_BOX(widg), (int)tmp_cp2k -> opts[j]);
898 g_signal_connect (G_OBJECT (widg), "changed", G_CALLBACK(changed_cp2k_box), GINT_TO_POINTER(j));
899 break;
900 case 3:
901 widg = check_button (NULL, -1, -1, tmp_cp2k -> opts[j], G_CALLBACK(update_cp2k_check), GINT_TO_POINTER(j));
902 break;
903 case 4:
904 widg = create_text_view (200, -1, 1, 0, G_CALLBACK(cp2k_file_info), GINT_TO_POINTER(j), tmp_cp2k -> files[j-CP2FRE]);
905 break;
906 default:
907 break;
908 }
909 if (j==CP2FRE || j==CP2FWV)
910 {
911 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, checked_box[checkb], widg, FALSE, FALSE, 5);
913 }
914 else if (j==CP2SPM)
915 {
916 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, option_box[optionb], widg, FALSE, FALSE, 5);
917 }
918 else if (j > CP2ROK && j < CP2PBC)
919 {
920 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, print_box, widg, FALSE, FALSE, 5);
921 if (j == CP2POR) cp2k_option_box (print_box, j);
922 }
923 else
924 {
925 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, widg, FALSE, FALSE, 5);
926 if (j==CP2SPI || j==CP2VDW || j==CP2ROK || j==CP2CON) cp2k_option_box (hbox, j);
927 }
928
929 if (j==CP2KTI || j==CP2CUT || j==CP2DLT || j==CP2TMP || j==CP2GEF || j==CP2OUF)
930 {
931 idunit ++;
932 widg = gtk_label_new (cp2k_unit[idunit]);
933 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, widg, FALSE, FALSE, 5);
934 }
935
936 if (idopt == CP2SYM)
937 {
938 gchar * str = g_strdup_printf (" %s provides official CP2K atomic basis sets and pseudo-potentials, are included:", PACKAGE);
939 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label(str, -1, -1, 0.0, 0.5), FALSE, FALSE, 20);
940 g_free (str);
941 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"
942 "<sup><tt>\t - GTH_BASIS_SETS\t\t(CP2K v9.1, released: <b>2021-12-31</b>)</tt></sup>\n"
943 "<sup><tt>\t - BASIS_SET\t\t(CP2K v9.1, released: <b>2021-12-31</b>)</tt></sup>\n"
944 "<sup><tt>\t - POTENTIAL\t\t(CP2K v9.1, released: <b>2021-12-31</b>)</tt></sup>",
945 -1, -1, 0.1, 0.5), FALSE, FALSE, 0);
946 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"
947 " Alternatively it is possible to define and use your own set of parameters.",
948 -1, -1, 0.0, 0.5), FALSE, FALSE, 20);
949 hbox = cpmd_box (vbox, "\t\t\t\tChemical species", 20, 5, 300);
951 for (k=0; k<qm_proj -> nspec; k++) combo_text_append (cp2k_spec_combo, qm_proj -> chemistry -> label[k]);
952 gtk_combo_box_set_active (GTK_COMBO_BOX(cp2k_spec_combo), 0);
953 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, cp2k_spec_combo, FALSE, FALSE, 5);
954 cp2k_spec_box[0] = create_hbox (0);
955 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, cp2k_spec_box[0], FALSE, FALSE, 0);
957 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, cp2k_spec_box[0], cp2k_spec_box[1], FALSE, FALSE, 0);
958 g_signal_connect (G_OBJECT (cp2k_spec_combo), "changed", G_CALLBACK(changed_cp2k_box), GINT_TO_POINTER(j));
959 }
960 }
961 }
962 return vbox;
963}
964
972gchar * cp_section_name (int p)
973{
974 if (p < 4)
975 {
976 return g_strdup_printf ("Details of the <b>%s</b> section that %s", cpsect[p], cpelemts[p+1]);
977 }
978 else
979 {
980 return g_strdup_printf ("%s", cpelemts[p+1]);
981 }
982}
983
991GtkWidget * vbox_cp2k (int s)
992{
993 GtkWidget * vbox = create_vbox (BSEP);
994 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label(cp_section_name(s), -1, 20, 0.0, 0.5), FALSE, FALSE, 10);
995 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, cp2k_section_box(s), FALSE, FALSE, 0);
996 if (s== 0) add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, qm_preview_box (1, s, 0), FALSE, FALSE, 5);
997 return vbox;
998}
999
1008G_MODULE_EXPORT void select_input_type (GtkToggleButton * but, gpointer data)
1009{
1010 tmp_cp2k -> input_type = GPOINTER_TO_INT (data);
1011 widget_set_sensitive (fileinf[! tmp_cp2k -> input_type], FALSE);
1012 widget_set_sensitive (fileinf[tmp_cp2k -> input_type], TRUE);
1014}
1015
1023GtkWidget * file_info (int id)
1024{
1025 GtkWidget * main_box;
1026 gchar * filename[4] = {"CP2K main input file '*.inp'", "forces.inc", "system.inc", "motion.inc"};
1027 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'",
1028 "<b>&amp;FORCE_EVAL</b>\n...\n<b>@INCLUDE</b> 'system.inc'\n<b>&amp;END FORCE_EVAL</b>",
1029 "<b>&amp;SUBSYS</b>\n...\n<b>&amp;END SUBSYS</b>",
1030 "<b>&amp;MOTION</b>\n...\n<b>&amp;END MOTION</b>"};
1031 GtkWidget * vbox, * vbx, * hbx;
1032 GtkWidget * vframe;
1033 if (id == 0)
1034 {
1035 main_box = create_vbox (BSEP);
1036 hbx = create_hbox (0);
1037 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbx, stock_image(AFILE), FALSE, FALSE, 5);
1038 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbx, gtk_label_new ("CP2K input file '*.inp'"), FALSE, FALSE, 5);
1039 vframe = gtk_frame_new (NULL);
1040 gtk_frame_set_label_widget (GTK_FRAME(vframe), hbx);
1041#ifdef GTK3
1042 gtk_frame_set_shadow_type (GTK_FRAME(vframe), GTK_SHADOW_ETCHED_IN);
1043#endif
1044 add_box_child_start (GTK_ORIENTATION_VERTICAL, main_box, vframe, FALSE, FALSE, 10);
1045 vbox = create_vbox (BSEP);
1047 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label("! Information", 200, -1, 0.0, 0.5), FALSE, FALSE, 5);
1048 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);
1049 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);
1050 hbx = create_hbox (0);
1051 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbx, FALSE, FALSE, 5);
1052 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);
1053 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);
1054 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);
1055 }
1056 else
1057 {
1058 main_box = create_hbox (0);
1059 vbox = create_vbox (BSEP);
1060 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, main_box, vbox, FALSE, FALSE, 0);
1061 int i;
1062 for (i=0; i<4; i++)
1063 {
1064 hbx = create_hbox (0);
1065 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbx, stock_image(AFILE), FALSE, FALSE, 5);
1066 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbx, gtk_label_new (filename[i]), FALSE, FALSE, 5);
1067 vframe = gtk_frame_new (NULL);
1068 gtk_frame_set_label_widget (GTK_FRAME(vframe), hbx);
1069#ifdef GTK3
1070 gtk_frame_set_shadow_type (GTK_FRAME(vframe), GTK_SHADOW_ETCHED_IN);
1071#endif
1072 vbx = create_vbox (BSEP);
1073 add_container_child (CONTAINER_FRA, vframe, vbx);
1074 if (i == 0) add_box_child_start (GTK_ORIENTATION_VERTICAL, vbx, markup_label("! Information", 200, -1, 0.0, 0.5), FALSE, FALSE, 5);
1075 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbx, markup_label(filetext[i], 200, -1, 0.0, 0.5), FALSE, FALSE, 5);
1076 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, vframe, FALSE, FALSE, 5);
1077 if (i == 0)
1078 {
1079 vbox = create_vbox (BSEP);
1080 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, main_box, vbox, FALSE, FALSE, 20);
1081 }
1082 }
1083 }
1084 return main_box;
1085}
1086
1093GtkWidget * init_cp2k ()
1094{
1095 GtkWidget * vbox = create_vbox (BSEP);
1096 gchar * text = "The CP2K input system offers to have the information gathered in a single, rather long, file\n"
1097 "or separated in several files each of them dedicated to a particular section of the input: ";
1098 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, gtk_label_new (text), FALSE, FALSE, 20);
1099 GtkWidget * hbox = create_hbox (0);
1100 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 0);
1101 GtkWidget * hbx;
1102 gchar * ftext[2] = {"Single input file", "Multiple files"};
1103 int i, j;
1104 j = tmp_cp2k -> input_type;
1105 for (i=0; i<2; i++)
1106 {
1107 vfbox[i] = create_vbox (BSEP);
1108 gtk_widget_set_size_request (vfbox[i], (i==0) ? 200 : 400, -1);
1109 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, vfbox[i], FALSE, FALSE, (i==0) ? 50 : 10);
1110 fileinf[i] = file_info (i);
1111 add_box_child_start (GTK_ORIENTATION_VERTICAL, vfbox[i], fileinf[i], FALSE, FALSE, (i==0) ? 0 : 15);
1112 hbx = create_hbox (0);
1113 add_box_child_start (GTK_ORIENTATION_VERTICAL, vfbox[i], hbx, FALSE, FALSE, 0);
1114
1115#ifdef GTK4
1116 filebut[i] = check_button (ftext[i], -1, -1, (i != j) ? FALSE : TRUE, G_CALLBACK(select_input_type), GINT_TO_POINTER(i));
1117 if (i) gtk_check_button_set_group ((GtkCheckButton *)filebut[i], (GtkCheckButton *)filebut[0]);
1118#else
1119 if (! i)
1120 {
1121 filebut[i] = radio_button (ftext[i], -1, -1, (i != j) ? FALSE : TRUE, G_CALLBACK(select_input_type), GINT_TO_POINTER(i));
1122 }
1123 else
1124 {
1125 filebut[i] = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON(filebut[0]), ftext[i]);
1126 }
1127#endif
1128 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbx, filebut[i], FALSE, FALSE, (i==0) ? 50 : 120);
1129 }
1130 tmp_cp2k -> input_type = j;
1131 widget_set_sensitive (fileinf[tmp_cp2k -> input_type], TRUE);
1132 widget_set_sensitive (fileinf[! tmp_cp2k -> input_type], FALSE);
1134 return vbox;
1135}
1136
1144gchar * page_name_cp2k (int p)
1145{
1146 if (p == 0)
1147 {
1148 return g_strdup_printf ("The CP2K input structure");
1149 }
1150 else if (p < 5)
1151 {
1152 return g_strdup_printf ("The %s section", cpsect[p-1]);
1153 }
1154 else if (p == 5)
1155 {
1156 return g_strdup_printf ("The MOTION section - thermostat(s)");
1157 }
1158 else
1159 {
1160 return g_strdup_printf ("The MOTION section - restart(s)");
1161 }
1162}
1163
1170{
1171 if (GTK_IS_WIDGET(motion_box[0])) hide_the_widgets (motion_box[0]);
1172 if (GTK_IS_WIDGET(motion_box[1])) hide_the_widgets (motion_box[1]);
1173 if (tmp_cp2k -> opts[CP2RUN] == 2.0 || tmp_cp2k -> opts[CP2RUN] == 3.0 || tmp_cp2k -> opts[CP2RUN] == 6.0)
1174 {
1175 int i = (tmp_cp2k -> opts[CP2RUN] == 2.0) ? 1 : 0;
1176 if (GTK_IS_WIDGET(motion_box[i])) show_the_widgets (motion_box[i]);
1177 return TRUE;
1178 }
1179 else
1180 {
1181 return FALSE;
1182 }
1183}
1184
1191{
1192 int i;
1193 gchar * info;
1194 GtkAssistant * assist = GTK_ASSISTANT(qm_assistant);
1195 GtkWidget * page;
1196 idopt = -1;
1197 ident = -1;
1198 icomb = -1;
1199 idunit = -1;
1200 checkb = -1;
1201 optionb = -1;
1202 motionb = -1;
1203 for (i=0; i<(cp2k_with_motion() ? 5: 4); i++)
1204 {
1205 if (i > 0)
1206 {
1207 page = vbox_cp2k (i-1);
1208 }
1209 else
1210 {
1211 page = init_cp2k ();
1212 }
1213 gtk_assistant_append_page (assist, page);
1214 gtk_assistant_set_page_title (assist, page, page_name_cp2k(i));
1215 gtk_assistant_set_page_type (assist, page, GTK_ASSISTANT_PAGE_CONTENT);
1216 gtk_assistant_set_page_complete (assist, page, TRUE);
1217 }
1218 GtkWidget * conclu = create_vbox (BSEP);
1219 info = g_strdup_printf ("<b> Finalize the creation of the CP2K input files now !</b>");
1220 add_box_child_start (GTK_ORIENTATION_VERTICAL, conclu, markup_label(info, -1, -1, 0.5, 0.5), TRUE, TRUE, 100);
1221 g_free (info);
1222 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);
1223 gtk_assistant_append_page (assist, conclu);
1224 gtk_assistant_set_page_title (assist, conclu, "Create the input files now !");
1225 gtk_assistant_set_page_type (assist, conclu, GTK_ASSISTANT_PAGE_CONFIRM);
1226 gtk_assistant_set_page_complete (assist, conclu, TRUE);
1227 gtk_assistant_update_buttons_state (assist);
1228}
1229
1237{
1238 box_info * box = & qm_proj -> cell.box[0];
1239 if (box -> param[0][0] == box -> param[0][1] &&
1240 box -> param[0][0] == box -> param[0][2] &&
1241 box -> param[0][1] == box -> param[0][2])
1242 {
1243 if (box -> param[1][0] == box -> param[1][1] &&
1244 box -> param[1][0] == box -> param[1][2] &&
1245 box -> param[1][1] == box -> param[1][2] &&
1246 box -> param[1][0] == 90.0) return 0;
1247 if (box -> param[1][0] == box -> param[1][1] &&
1248 box -> param[1][0] == box -> param[1][2] &&
1249 box -> param[1][1] == box -> param[1][2] &&
1250 box -> param[1][0] != 90.0) return 3;
1251 }
1252 if (box -> param[1][0] == box -> param[1][1] &&
1253 box -> param[1][0] == box -> param[1][2] &&
1254 box -> param[1][1] == box -> param[1][2] &&
1255 box -> param[1][0] == 90.0)
1256 {
1257 if (box -> param[0][0] == box -> param[0][1] && box -> param[0][0] != box -> param[0][2]) return 4;
1258 if (box -> param[0][0] == box -> param[0][2] && box -> param[0][0] != box -> param[0][1]) return 5;
1259 if (box -> param[0][1] == box -> param[0][2] && box -> param[0][1] != box -> param[0][0]) return 6;
1260 }
1261 if (box -> param[1][0] == box -> param[1][1] &&
1262 box -> param[1][0] == box -> param[1][2] &&
1263 box -> param[1][1] == box -> param[1][2])
1264 {
1265 if (box -> param[0][0] != box -> param[0][1] &&
1266 box -> param[0][0] != box -> param[0][2] &&
1267 box -> param[0][1] != box -> param[0][2]) return 2;
1268 }
1269 if (box -> param[1][0] == box -> param[1][1] && box -> param[1][0] == 90.0)
1270 {
1271 if (box -> param[1][2] == 60.0)
1272 {
1273 if (box -> param[0][0] == box -> param[0][1] && box -> param[0][0] != box -> param[0][2]) return 1;
1274 }
1275 }
1276 if (box -> param[1][0] == box -> param[1][2] && box -> param[1][0] == 90.0)
1277 {
1278 if (box -> param[1][1] != 90.0)
1279 {
1280 if (box -> param[0][0] != box -> param[0][1] &&
1281 box -> param[0][0] != box -> param[0][2] &&
1282 box -> param[0][1] != box -> param[0][2]) return 7;
1283 }
1284 }
1285 if (box -> param[0][0] != box -> param[0][1] &&
1286 box -> param[0][0] != box -> param[0][2] &&
1287 box -> param[0][1] != box -> param[0][2])
1288 {
1289 if (box -> param[1][0] != box -> param[1][1] &&
1290 box -> param[1][0] != box -> param[1][2] &&
1291 box -> param[1][1] != box -> param[1][2]) return 8;
1292 }
1293 return 9;
1294}
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
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:822
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:972
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:1430
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:680
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:1190
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:1093
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:591
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:638
GtkWidget * qm_preview_box(int c, int s, int l)
prepare preview section widgets
Definition cpmd_init.c:890
int find_cp2k_sym()
find the CP2K symmetry parameter based on the cell properties
Definition cp2k_init.c:1236
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:332
G_MODULE_EXPORT void update_cp2k_parameter(GtkEntry *res, gpointer data)
update some CP2K parameters
Definition cp2k_init.c:551
GtkWidget * vbox_cp2k(int s)
create the CP2K assistant page vertical box
Definition cp2k_init.c:991
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:1008
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:363
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:734
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:801
gboolean cp2k_with_motion()
CP2K MD calculation ?
Definition cp2k_init.c:1169
cp2k * tmp_cp2k
Definition cp2k_init.c:86
GtkWidget * thermo_box()
create the thermostat configuration widgets
Definition cpmd_nose.c:1888
gchar * page_name_cp2k(int p)
get CP2K assistant page name
Definition cp2k_init.c:1144
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:1023
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:468
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:492
@ IMG_STOCK
Definition global.h:264
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
GtkWidget * dialogmodal(gchar *str, GtkWindow *parent)
Create a new dialog modal window.
Definition gtk-misc.c:510
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 update_entry_int(GtkEntry *entry, int intval)
update the content of a GtkEntry as int
Definition gtk-misc.c:614
GtkWidget * stock_image(const gchar *stock_id)
create a GtkImage for the Gtk database
Definition gtk-misc.c:1364
GtkWidget * radio_button(gchar *text, int dimx, int dimy, gboolean state, GCallback handler, gpointer data)
create a radio button
Definition gtk-misc.c:1834
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_FRA
Definition global.h:254
#define DPROPERTIES
Definition global.h:206
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
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
#define AFILE
Definition global.h:224
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
void show_the_widgets(GtkWidget *widg)
show GtkWidget
Definition gtk-misc.c:173
void motion(glwin *view, gint x, gint y, GdkModifierType state)
mouse motion in the OpenGL window
Definition glview.c:626
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 global.h:790
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