atomes 1.3.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-2026 by CNRS and University of Strasbourg */
15
21
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.", i18n("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] = {{i18n("Single Point Energy Calculation"),
118 i18n("Single Point Energy and Forces Calculation"),
119 i18n("Geometry Optimization"), i18n("Molecular Dynamics"),
120 i18n("Vibrational Analysis"), i18n("Linear Response Calculation"), i18n("Ehrenfest Dynamics"), " ", " ", " ", " "},
121 {i18n("Low"), i18n("Medium"), i18n("High"), " ", " ", " ", " ", " ", " ", " ", " "},
122 {i18n("Gaussian and Plane Waves Method"),
123 i18n("Gaussian and Augmented Plane Waves Method"),
124 i18n("Gaussian and Augmented Plane Waves Method Only for XC"), " ", " ", " ", " ", " ", " ", " ", " "},
125 {i18n("Generate an Atomic Density Using the Atomic Code"),
126 i18n("Diagonalize the Core Hamiltonian"),
127 i18n("Use Random Wave-function Coefficients"),
128 i18n("Use the RESTART File"), " ", " ", " ", " ", " ", " ", " "},
129 {i18n("Broyden Mixing Approximating the Inverse Hessian"),
130 i18n("Conjugate Gradients"), i18n("Direct Inversion in the Iterative Subspace"), " ", " ", " ", " ", " ", " ", " ", " "},
131 {"Becke + Lee-Yang-Parr", i18n("Becke Three-parameters Hybrid + LYP"), i18n("Bayesian Error Estimation + van der Walls"),
132 "Becke + Perdew", "Hamprecht-Cohen-Tozer-Handy", i18n("Local Density Approximation"), "Handy-Cohen + LYP", "Padé",
133 "Perdew + Burke-Ernzerhof", i18n("Parameter-free PBE"), "Tao-Perdew-Staroverov-Scuseria"},
134 {i18n("3 Dimensional (XYZ)"), i18n("2 Dimensional (XY)"), i18n("2 Dimensional (XZ)"), i18n("2 Dimensional (YZ)"),
135 i18n("1 Dimensional (X)"), i18n("1 Dimensional (Y)"), i18n("1 Dimensional (Z)"), i18n("Isolated System"), " ", " ", " "},
136 {i18n("Box Parameters (a,b,c and α,β,γ)"), i18n("Lattice Vectors"), " ", " ", " ", " ", " ", " ", " ", " ", " "},
137 {i18n("Cubic (a = b = c, α = β = γ = 90°)"), i18n("Hexagonal (a = b ≠ c, α = β = 90°, γ = 60°)"),
138 i18n("Orthorhombic (a ≠ b ≠ c, α = β = γ = 90°)"), i18n("Rhombohedral (a = b = c, α = β = γ ≠ 90°)"),
139 i18n("Tetragonal (a = b ≠ c, α = β = γ = 90°)"), i18n("Tetragonal (a = c ≠ b, α = β = γ = 90°)"), i18n("Tetragonal (a ≠ b = c, α = β = γ = 90°)"),
140 i18n("Monoclinic (a ≠ b ≠ c ≠ a, α = γ = 90°, β ≠ 90°)"), i18n("Triclinic (a ≠ b ≠ c ≠ a, α ≠ β ≠ γ ≠ α ≠ 90°)"), i18n("No Cell Symmetry"), " "},
141 {i18n("Constant kinetic energy"), i18n("Langevin dynamics (constant temperature)"), i18n("Constant pressure ensemble (no thermostat)"),
142 i18n("Constant pressure ensemble using an isotropic cell (no thermostat)"), i18n("Constant temperature and pressure using a flexible cell"),
143 i18n("Constant temperature and pressure using an isotropic cell"), i18n("Constant energy (µ-canonical)"), i18n("Constant temperature and volume (canonical)"),
144 i18n("Adiabatic dynamics in constant temperature and volume ensemble (CAFES)"), " ", " "},
145 {i18n("Diagonalization of a full Hessian matrix"), i18n("Conjugate gradients"), " ", " ", " ", " ", " ", " ", " ", " ", " "}};
146
147gchar * cp2k_vdw_text[2][3] = {{i18n("Dion-Rydberg-Schroeder-Langreth-Lundqvist non-local van der Waals density functional"),
148 i18n("Lee-Murray-Kong-Lundqvist-Langreth non-local van der Waals density functional"),
149 i18n("Revised Vydrov-van Voorhis non-local van der Waals density functional")},
150 {i18n("Grimme D2 method"), i18n("Grimme D3 method (zero damping)"), i18n("Grimme D3 method (Becke-Johnson damping)")}};
151
152int var_by_cp2sections[4] = {8, 20, 3, 10};
153gchar * global_opts[40] = {i18n("Run type:"),
154 i18n("Max CPU time:"),
155 i18n("Print level:"),
156 i18n("Use restart information:"),
157 i18n("File that contains the restart information:"),
158 i18n("File that contains the basis set(s):"),
159 i18n("File that contains the pseudo-potential(s):"),
160 i18n("File that contains the wave-function:"),
161 i18n("Charge:"),
162 i18n("Density cutoff for the finest grid level:"),
163 i18n("Number of multi-grids:"),
164 i18n("Quickstep method:"),
165 i18n("Initial guess for the wave-function:"),
166 i18n("Maximum inner-SCF cycle(s):"),
167 i18n("Convergence threshold:"),
168 i18n("Maximum outer-SCF cycle(s):"),
169 i18n("Convergence threshold:"),
170 i18n("Orbital transformation minimizer:"),
171 i18n("DFT functional:"),
172 i18n("Spin unrestricted calculation"),
173 i18n("Multiplicity"),
174 i18n("Use van der Waals interactions"),
175 i18n("Restricted Open Kohn-Sham 'ROKS'"),
176 i18n("Forces"),
177 i18n("Stress tensor"),
178 i18n("Mulliken population"),
179 i18n("Löwdin population"),
180 i18n("Orbitals"),
181 i18n("Periodicity:"),
182 i18n("Lattice parameters:"),
183 i18n("Symmetry:"),
184 i18n("Ensemble:"),
185 i18n("Maximum number of MD steps:"),
186 i18n("MD time step:"),
187 i18n("Initial temperature:"),
188 i18n("Geometry optimizer:"),
189 i18n("Maximum number of optimization steps:"),
190 i18n("Atomic forces convergence criterion:"),
191 i18n("Save information every:"),
192 i18n("Add constraint(s)")};
193
194gchar * cpelemts[7] = {i18n("The CP2K input structure"),
195 i18n("provides the general control parameters for the calculation to be performed"),
196 i18n("describes how the interatomic forces will be evaluated"),
197 i18n("describes the model: symmetry, periodicity and atomic species, pseudo-potentials and coordinates"),
198 i18n("describes the displacement of the atoms for molecular dynamics and geometry optimization"),
199 i18n("To describe the thermostat(s) for molecular dynamics"),
200 i18n("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] = {i18n("Type of potential:"), i18n("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
423
455
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_roks_options[2] = {i18n("Energy scaling:"), i18n("Spin configuration <sup>*</sup>:")};
471 gchar * cp2k_orb_options[2] = {i18n("Number of HOMO levels (-1 for all):"), i18n("Number of LUMO levels (-1 for all):")};
472
473 gchar * str = g_strdup_printf (_("%s - options"), i18n(global_opts[i]));
474 GtkWidget * dial = dialogmodal (str, GTK_WINDOW(qm_assistant));
475 g_free (str);
477 switch (i)
478 {
479 case CP2VDW:
480 hbox = create_hbox (5);
481 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 10);
482 widg = create_combo ();
483 combo_text_append (widg, _("Non-local potential"));
484 combo_text_append (widg, _("Pair potential"));
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] = {i18n("<b>-</b> Select and use set of parameters from the database: "),
675 i18n("<b>-</b> Define and use other set of parameters: ")};
676 gchar * data_name[2][2] = {{i18n("\t\tAvailable basis set for "), i18n("\t\tAvailable pseudo-potential for ")},
677 {i18n("\t\tBasis set for "), i18n("\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 str = g_strdup_printf ("<b>%s</b>", _("None"));
701 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label(str, -1, -1, 0.5, 0.5), FALSE, FALSE, 5);
702 g_free (str);
703 }
704 }
705 else
706 {
707 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, create_text_view (350, -1, 1, 0, G_CALLBACK(cp2k_file_info),
708 GINT_TO_POINTER(j+10), tmp_cp2k -> spec_files[spec][j]), FALSE, FALSE, 5);
709 }
710 }
711 }
712 return vbox;
713}
714
715gboolean cp2k_with_motion ();
716GtkWidget * vbox_cp2k (int s);
717gchar * page_name_cp2k (int p);
718
727G_MODULE_EXPORT void changed_cp2k_box (GtkComboBox * box, gpointer data)
728{
729 int i, j;
730 gboolean motion;
731 i = GPOINTER_TO_INT(data);
732 j = combo_get_active ((GtkWidget *)box);
733 if (j != (int)tmp_cp2k -> opts[i])
734 {
735 if (i == CP2SYM)
736 {
740 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, cp2k_spec_box[0], cp2k_spec_box[1], FALSE, FALSE, 0);
741 }
742 else
743 {
744 if (i == CP2RUN) motion = cp2k_with_motion ();
745 tmp_cp2k -> opts[i] = (double) combo_get_active ((GtkWidget *)box);
746
747 if (i == CP2RUN)
748 {
749 if (motion && ! cp2k_with_motion())
750 {
751 gtk_assistant_remove_page (GTK_ASSISTANT(qm_assistant), 5);
752 }
753 else if (! motion && cp2k_with_motion())
754 {
755 GtkAssistant * assist = GTK_ASSISTANT(qm_assistant);
756 idopt = CP2SYM;
757 motionb = -1;
758 optionb = 3;
759 idunit = 1;
760 icomb = 8;
761 GtkWidget * page = vbox_cp2k (3);
762 show_the_widgets (page);
763 gtk_assistant_insert_page (assist, page, 5);
764 gtk_assistant_set_page_title (assist, page, page_name_cp2k(4));
765 gtk_assistant_set_page_type (assist, page, GTK_ASSISTANT_PAGE_CONTENT);
766 gtk_assistant_set_page_complete (assist, page, TRUE);
768 }
769 }
770 else if (i == CP2ENS)
771 {
772 if (j == 2 || j == 3)
773 {
775 }
776 else
777 {
779 }
780 }
782 }
783 }
784}
785
794void cp2k_option_box (GtkWidget * box, int id)
795{
796 optionb ++;
798 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, box, option_box[optionb], FALSE, FALSE, 5);
799 if (id != CP2SPI)
800 {
801 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, option_box[optionb],
802 create_button (_("Options"), IMG_STOCK, DPROPERTIES, 200, -1, GTK_RELIEF_NORMAL, G_CALLBACK(cp2k_option_dialog), GINT_TO_POINTER(id)),
803 FALSE, FALSE, 50);
804 }
805 widget_set_sensitive (option_box[optionb], (int)tmp_cp2k -> opts[id]);
806}
807
815GtkWidget * cp2k_section_box (int s)
816{
817 int i, j, k;
818 GtkWidget * hbox;
819 GtkWidget * widg;
820 GtkWidget * vbox = create_vbox (BSEP);
821 for (i=0; i<NC2OP; i++)
822 {
823 if (cp2k_opts_type[s][i] > 0)
824 {
825 idopt ++;
826 j = idopt;
827 if (j == CP2NST)
828 {
830 add_box_child_start (GTK_ORIENTATION_VERTICAL, motion_box[motionb], cp2k_thermo_box, FALSE, FALSE, 5);
831 hbox = cpmd_box (motion_box[motionb], _(global_opts[idopt]), 5, 5, 300);
832 }
833 else if (j == CP2FRE || j == CP2FWV)
834 {
835 checkb ++;
836 checked_box[checkb] = cpmd_box (vbox, _(global_opts[idopt]), 5, 5, 300);
837 }
838 else if (j == CP2SPM)
839 {
840 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, option_box[optionb], markup_label(_(global_opts[idopt]), 100, 30, 0.0, 0.5), FALSE, FALSE, 50);
841 }
842 else if (j == CP2PFO || j == CP2PLO)
843 {
844 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);
846 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, print_box, FALSE, FALSE, 0);
847 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, print_box, markup_label(_(global_opts[idopt]), 150, 30, 0.0, 0.5), FALSE, FALSE, 50);
848 }
849 else if (j > CP2ROK && j < CP2PBC)
850 {
851 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, print_box, markup_label(_(global_opts[idopt]), 150, 30, 0.0, 0.5), FALSE, FALSE, 50);
852 }
853 else if (j == CP2ENS || j == CP2GMI)
854 {
855 motionb ++;
857 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, motion_box[motionb], FALSE, FALSE, 5);
858 hbox = cpmd_box (motion_box[motionb], _(global_opts[idopt]), 5, 5, 300);
859 }
860 else if (j > CP2ENS && j < CP2OUF)
861 {
862 hbox = cpmd_box (motion_box[motionb], _(global_opts[idopt]), 5, 5, 300);
863 }
864 else if (j == CP2SCN || j == CP2SCO)
865 {
866 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label(_(global_opts[idopt]), 150, 30, 0.0, 0.5), FALSE, FALSE, 30);
867 }
868 else
869 {
870 hbox = cpmd_box (vbox, _(global_opts[idopt]), 5, 5, 300);
871 }
872 switch (cp2k_opts_type[s][i])
873 {
874 case 1:
875 ident ++;
876 widg = create_entry (G_CALLBACK(update_cp2k_parameter), 100, 15, FALSE, GINT_TO_POINTER(j));
877 if (j==CP2CUT || j==CP2SCN || j==CP2SCO || j==CP2DLT || j==CP2GEF)
878 {
879 update_entry_double (GTK_ENTRY(widg), tmp_cp2k -> opts[j]);
880 }
881 else
882 {
883 update_entry_int (GTK_ENTRY(widg), tmp_cp2k -> opts[j]);
884 }
885 break;
886 case 2:
887 icomb ++;
888 widg = create_combo ();
889 for (k=0; k<cp2k_default_num[icomb]; k++)
890 {
891 if (icomb == 5 && (k == 0 || k == 3 || k == 4 || k == 6 || k == 7 || k == 8 || k == 10))
892 {
894 }
895 else
896 {
898 }
899 }
900 combo_set_active (widg, (int)tmp_cp2k -> opts[j]);
901 g_signal_connect (G_OBJECT (widg), "changed", G_CALLBACK(changed_cp2k_box), GINT_TO_POINTER(j));
902 break;
903 case 3:
904 widg = check_button (NULL, -1, -1, tmp_cp2k -> opts[j], G_CALLBACK(update_cp2k_check), GINT_TO_POINTER(j));
905 break;
906 case 4:
907 widg = create_text_view (200, -1, 1, 0, G_CALLBACK(cp2k_file_info), GINT_TO_POINTER(j), tmp_cp2k -> files[j-CP2FRE]);
908 break;
909 default:
910 break;
911 }
912 if (j==CP2FRE || j==CP2FWV)
913 {
914 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, checked_box[checkb], widg, FALSE, FALSE, 5);
916 }
917 else if (j==CP2SPM)
918 {
919 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, option_box[optionb], widg, FALSE, FALSE, 5);
920 }
921 else if (j > CP2ROK && j < CP2PBC)
922 {
923 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, print_box, widg, FALSE, FALSE, 5);
924 if (j == CP2POR) cp2k_option_box (print_box, j);
925 }
926 else
927 {
928 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, widg, FALSE, FALSE, 5);
929 if (j==CP2SPI || j==CP2VDW || j==CP2ROK || j==CP2CON) cp2k_option_box (hbox, j);
930 }
931
932 if (j==CP2KTI || j==CP2CUT || j==CP2DLT || j==CP2TMP || j==CP2GEF || j==CP2OUF)
933 {
934 idunit ++;
935 widg = gtk_label_new ((idunit == 5) ? _(cp2k_unit[idunit]) : cp2k_unit[idunit]);
936 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, widg, FALSE, FALSE, 5);
937 }
938
939 if (idopt == CP2SYM)
940 {
941 gchar * str = g_strdup_printf (_(" %s provides official CP2K atomic basis sets and pseudo-potentials, are included:"), PACKAGE);
942 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label(str, -1, -1, 0.0, 0.5), FALSE, FALSE, 20);
943 g_free (str);
944 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox,
945 markup_label(_("<sup><tt>\t - BASIS_MOLOPT\t\t(CP2K v9.1, released: <b>2021-12-31</b>)</tt></sup>\n"
946 "<sup><tt>\t - GTH_BASIS_SETS\t\t(CP2K v9.1, released: <b>2021-12-31</b>)</tt></sup>\n"
947 "<sup><tt>\t - BASIS_SET\t\t(CP2K v9.1, released: <b>2021-12-31</b>)</tt></sup>\n"
948 "<sup><tt>\t - POTENTIAL\t\t(CP2K v9.1, released: <b>2021-12-31</b>)</tt></sup>"), -1, -1, 0.1, 0.5), FALSE, FALSE, 0);
949 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox,
950 markup_label(_(" Following your selection the files that contains the parameters for your calculation will be generated automatically.\n"
951 " Alternatively it is possible to define and use your own set of parameters."), -1, -1, 0.0, 0.5), FALSE, FALSE, 20);
952 hbox = cpmd_box (vbox, _("\t\t\t\tChemical species"), 20, 5, 300);
954 for (k=0; k<qm_proj -> nspec; k++) combo_text_append (cp2k_spec_combo, qm_proj -> chemistry -> label[k]);
956 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, cp2k_spec_combo, FALSE, FALSE, 5);
957 cp2k_spec_box[0] = create_hbox (0);
958 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, cp2k_spec_box[0], FALSE, FALSE, 0);
960 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, cp2k_spec_box[0], cp2k_spec_box[1], FALSE, FALSE, 0);
961 g_signal_connect (G_OBJECT (cp2k_spec_combo), "changed", G_CALLBACK(changed_cp2k_box), GINT_TO_POINTER(j));
962 }
963 }
964 }
965 return vbox;
966}
967
975gchar * cp_section_name (int p)
976{
977 if (p < 4)
978 {
979 return g_strdup_printf (_("Details of the <b>%s</b> section that %s"), cpsect[p], cpelemts[p+1]);
980 }
981 else
982 {
983 return g_strdup_printf ("%s", cpelemts[p+1]);
984 }
985}
986
994GtkWidget * vbox_cp2k (int s)
995{
996 GtkWidget * vbox = create_vbox (BSEP);
997 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label(cp_section_name(s), -1, 20, 0.0, 0.5), FALSE, FALSE, 10);
998 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, cp2k_section_box(s), FALSE, FALSE, 0);
999 if (s== 0) add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, qm_preview_box (1, s, 0), FALSE, FALSE, 5);
1000 return vbox;
1001}
1002
1011G_MODULE_EXPORT void select_input_type (GtkToggleButton * but, gpointer data)
1012{
1013#ifdef GTK4
1014 tmp_cp2k -> input_type = GPOINTER_TO_INT (data);
1015#else
1016 tmp_cp2k -> input_type = ! tmp_cp2k -> input_type;
1017#endif
1018 widget_set_sensitive (fileinf[! tmp_cp2k -> input_type], FALSE);
1019 widget_set_sensitive (fileinf[tmp_cp2k -> input_type], TRUE);
1021}
1022
1030GtkWidget * file_info (int id)
1031{
1032 GtkWidget * main_box;
1033 gchar * filename[4] = {i18n("CP2K main input file '*.inp'"),
1034 "forces.inc", "system.inc", "motion.inc"};
1035 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'",
1036 "<b>&amp;FORCE_EVAL</b>\n...\n<b>@INCLUDE</b> 'system.inc'\n<b>&amp;END FORCE_EVAL</b>",
1037 "<b>&amp;SUBSYS</b>\n...\n<b>&amp;END SUBSYS</b>",
1038 "<b>&amp;MOTION</b>\n...\n<b>&amp;END MOTION</b>"};
1039 GtkWidget * vbox, * vbx, * hbx;
1040 GtkWidget * vframe;
1041 if (id == 0)
1042 {
1043 main_box = create_vbox (BSEP);
1044 hbx = create_hbox (0);
1045 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbx, stock_image(AFILE), FALSE, FALSE, 5);
1046 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbx, gtk_label_new (_("CP2K input file '*.inp'")), FALSE, FALSE, 5);
1047 vframe = gtk_frame_new (NULL);
1048 gtk_frame_set_label_widget (GTK_FRAME(vframe), hbx);
1049#ifdef GTK3
1050 gtk_frame_set_shadow_type (GTK_FRAME(vframe), GTK_SHADOW_ETCHED_IN);
1051#endif
1052 add_box_child_start (GTK_ORIENTATION_VERTICAL, main_box, vframe, FALSE, FALSE, 10);
1053 vbox = create_vbox (BSEP);
1055 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label(_("! Information"), 200, -1, 0.0, 0.5), FALSE, FALSE, 5);
1056 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);
1057 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);
1058 hbx = create_hbox (0);
1059 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbx, FALSE, FALSE, 5);
1060 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);
1061 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);
1062 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);
1063 }
1064 else
1065 {
1066 main_box = create_hbox (0);
1067 vbox = create_vbox (BSEP);
1068 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, main_box, vbox, FALSE, FALSE, 0);
1069 int i;
1070 for (i=0; i<4; i++)
1071 {
1072 hbx = create_hbox (0);
1073 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbx, stock_image(AFILE), FALSE, FALSE, 5);
1074 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbx, gtk_label_new ((! i) ? _(filename[i]) : filename[i]), FALSE, FALSE, 5);
1075 vframe = gtk_frame_new (NULL);
1076 gtk_frame_set_label_widget (GTK_FRAME(vframe), hbx);
1077#ifdef GTK3
1078 gtk_frame_set_shadow_type (GTK_FRAME(vframe), GTK_SHADOW_ETCHED_IN);
1079#endif
1080 vbx = create_vbox (BSEP);
1081 add_container_child (CONTAINER_FRA, vframe, vbx);
1082 if (i == 0) add_box_child_start (GTK_ORIENTATION_VERTICAL, vbx, markup_label(_("! Information"), 200, -1, 0.0, 0.5), FALSE, FALSE, 5);
1083 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbx, markup_label(filetext[i], 200, -1, 0.0, 0.5), FALSE, FALSE, 5);
1084 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, vframe, FALSE, FALSE, 5);
1085 if (i == 0)
1086 {
1087 vbox = create_vbox (BSEP);
1088 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, main_box, vbox, FALSE, FALSE, 20);
1089 }
1090 }
1091 }
1092 return main_box;
1093}
1094
1101GtkWidget * init_cp2k ()
1102{
1103 GtkWidget * vbox = create_vbox (BSEP);
1104 gchar * text = _("The CP2K input system offers to have the information gathered in a single, rather long, file\n"
1105 "or separated in several files each of them dedicated to a particular section of the input: ");
1106 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, gtk_label_new (text), FALSE, FALSE, 20);
1107 GtkWidget * hbox = create_hbox (0);
1108 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 0);
1109 GtkWidget * hbx;
1110 gchar * ftext[2] = {i18n("Single input file"), i18n("Multiple files")};
1111 int i, j;
1112 j = tmp_cp2k -> input_type;
1113 for (i=0; i<2; i++)
1114 {
1115 vfbox[i] = create_vbox (BSEP);
1116 gtk_widget_set_size_request (vfbox[i], (i==0) ? 200 : 400, -1);
1117 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, vfbox[i], FALSE, FALSE, (i==0) ? 50 : 10);
1118 fileinf[i] = file_info (i);
1119 add_box_child_start (GTK_ORIENTATION_VERTICAL, vfbox[i], fileinf[i], FALSE, FALSE, (i==0) ? 0 : 15);
1120 hbx = create_hbox (0);
1121 add_box_child_start (GTK_ORIENTATION_VERTICAL, vfbox[i], hbx, FALSE, FALSE, 0);
1122
1123#ifdef GTK4
1124 filebut[i] = check_button (_(ftext[i]), -1, -1, (i != j) ? FALSE : TRUE, G_CALLBACK(select_input_type), GINT_TO_POINTER(i));
1125 if (i) gtk_check_button_set_group ((GtkCheckButton *)filebut[i], (GtkCheckButton *)filebut[0]);
1126#else
1127 if (! i)
1128 {
1129 filebut[i] = radio_button (_(ftext[i]), -1, -1, (i != j) ? FALSE : TRUE, G_CALLBACK(select_input_type), NULL);
1130 }
1131 else
1132 {
1133 filebut[i] = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON(filebut[0]), _(ftext[i]));
1134 }
1135#endif
1136 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbx, filebut[i], FALSE, FALSE, (i==0) ? 50 : 120);
1137 }
1138 tmp_cp2k -> input_type = j;
1139 widget_set_sensitive (fileinf[tmp_cp2k -> input_type], TRUE);
1140 widget_set_sensitive (fileinf[! tmp_cp2k -> input_type], FALSE);
1142 return vbox;
1143}
1144
1152gchar * page_name_cp2k (int p)
1153{
1154 if (p == 0)
1155 {
1156 return g_strdup_printf (_("The CP2K input structure"));
1157 }
1158 else if (p < 5)
1159 {
1160 return g_strdup_printf (_("The %s section"), cpsect[p-1]);
1161 }
1162 else if (p == 5)
1163 {
1164 return g_strdup_printf (_("The MOTION section - thermostat(s)"));
1165 }
1166 else
1167 {
1168 return g_strdup_printf (_("The MOTION section - restart(s)"));
1169 }
1170}
1171
1178{
1179 int i;
1180 for (i=0; i<2; i++) hide_the_widgets (motion_box[i]);
1182 if (tmp_cp2k -> opts[CP2RUN] == 2.0 || tmp_cp2k -> opts[CP2RUN] == 3.0 || tmp_cp2k -> opts[CP2RUN] == 6.0)
1183 {
1184 i = (tmp_cp2k -> opts[CP2RUN] == 2.0) ? 1 : 0;
1186 return TRUE;
1187 }
1188 else
1189 {
1190 return FALSE;
1191 }
1192}
1193
1200{
1201 int i;
1202 gchar * info;
1203 GtkAssistant * assist = GTK_ASSISTANT(qm_assistant);
1204 GtkWidget * page;
1205 idopt = -1;
1206 ident = -1;
1207 icomb = -1;
1208 idunit = -1;
1209 checkb = -1;
1210 optionb = -1;
1211 motionb = -1;
1212 for (i=0; i<(cp2k_with_motion() ? 5: 4); i++)
1213 {
1214 if (i > 0)
1215 {
1216 page = vbox_cp2k (i-1);
1217 }
1218 else
1219 {
1220 page = init_cp2k ();
1221 }
1222 gtk_assistant_append_page (assist, page);
1223 gtk_assistant_set_page_title (assist, page, page_name_cp2k(i));
1224 gtk_assistant_set_page_type (assist, page, GTK_ASSISTANT_PAGE_CONTENT);
1225 gtk_assistant_set_page_complete (assist, page, TRUE);
1226 }
1227 GtkWidget * conclu = create_vbox (BSEP);
1228 info = g_strdup_printf (_("<b> Finalize the creation of the CP2K input files now !</b>"));
1229 add_box_child_start (GTK_ORIENTATION_VERTICAL, conclu, markup_label(info, -1, -1, 0.5, 0.5), TRUE, TRUE, 100);
1230 g_free (info);
1231 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);
1232 gtk_assistant_append_page (assist, conclu);
1233 gtk_assistant_set_page_title (assist, conclu, _("Create the input files now !"));
1234 gtk_assistant_set_page_type (assist, conclu, GTK_ASSISTANT_PAGE_CONFIRM);
1235 gtk_assistant_set_page_complete (assist, conclu, TRUE);
1236 gtk_assistant_update_buttons_state (assist);
1237}
1238
1246{
1247 box_info * box = & qm_proj -> cell.box[0];
1248 if (box -> param[0][0] == box -> param[0][1] &&
1249 box -> param[0][0] == box -> param[0][2] &&
1250 box -> param[0][1] == box -> param[0][2])
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) return 0;
1256 if (box -> param[1][0] == box -> param[1][1] &&
1257 box -> param[1][0] == box -> param[1][2] &&
1258 box -> param[1][1] == box -> param[1][2] &&
1259 box -> param[1][0] != 90.0) return 3;
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 box -> param[1][0] == 90.0)
1265 {
1266 if (box -> param[0][0] == box -> param[0][1] && box -> param[0][0] != box -> param[0][2]) return 4;
1267 if (box -> param[0][0] == box -> param[0][2] && box -> param[0][0] != box -> param[0][1]) return 5;
1268 if (box -> param[0][1] == box -> param[0][2] && box -> param[0][1] != box -> param[0][0]) return 6;
1269 }
1270 if (box -> param[1][0] == box -> param[1][1] &&
1271 box -> param[1][0] == box -> param[1][2] &&
1272 box -> param[1][1] == box -> param[1][2])
1273 {
1274 if (box -> param[0][0] != box -> param[0][1] &&
1275 box -> param[0][0] != box -> param[0][2] &&
1276 box -> param[0][1] != box -> param[0][2]) return 2;
1277 }
1278 if (box -> param[1][0] == box -> param[1][1] && box -> param[1][0] == 90.0)
1279 {
1280 if (box -> param[1][2] == 60.0)
1281 {
1282 if (box -> param[0][0] == box -> param[0][1] && box -> param[0][0] != box -> param[0][2]) return 1;
1283 }
1284 }
1285 if (box -> param[1][0] == box -> param[1][2] && box -> param[1][0] == 90.0)
1286 {
1287 if (box -> param[1][1] != 90.0)
1288 {
1289 if (box -> param[0][0] != box -> param[0][1] &&
1290 box -> param[0][0] != box -> param[0][2] &&
1291 box -> param[0][1] != box -> param[0][2]) return 7;
1292 }
1293 }
1294 if (box -> param[0][0] != box -> param[0][1] &&
1295 box -> param[0][0] != box -> param[0][2] &&
1296 box -> param[0][1] != box -> param[0][2])
1297 {
1298 if (box -> param[1][0] != box -> param[1][1] &&
1299 box -> param[1][0] != box -> param[1][2] &&
1300 box -> param[1][1] != box -> param[1][2]) return 8;
1301 }
1302 return 9;
1303}
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
gchar * cp2k_default_text[11][11]
Definition cp2k_init.c:117
#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
double default_cp2k_extra[3][4]
Definition cp2k_init.c:95
#define CP2RUN
Definition cp2k.h:43
gchar * cp2k_vdw_keywords[2][3]
Definition cp2k_init.c:115
#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
gchar * cp2k_default_keywords[11][11]
Definition cp2k_init.c:101
double default_vdw_cut[2]
Definition cp2k_init.c:94
#define CP2PFO
Definition cp2k.h:66
#define CP2CUT
Definition cp2k.h:52
double default_cp2k_options[41]
Definition cp2k_init.c:88
#define CP2SYM
Definition cp2k.h:73
cp2k * tmp_cp2k
Definition cp2k_init.c:86
#define CP2SCN
Definition cp2k.h:57
#define CP2TMP
Definition cp2k.h:77
#define CP2NTHERM
Definition cp2k.h:86
int cp2k_default_num[12]
Definition cp2k_init.c:99
#define CP2SCO
Definition cp2k.h:59
GtkWidget * cp2k_spec_combo
Definition cp2k_init.c:235
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:244
void print_cp2k(int f, GtkTextBuffer *buffer)
print the CP2K input file section
GtkWidget * option_box[4]
Definition cp2k_init.c:231
GtkWidget * cp2k_section_box(int s)
create the CP2K assistant section box
Definition cp2k_init.c:815
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:975
void create_selection_button(GtkWidget *box, int num, int id, gpointer data)
create thermostat atom(s) selection button
Definition cpmd_nose.c:1433
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:244
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
int checkb
Definition cp2k_init.c:221
void add_cp2k_pages()
add pages to the CP2 assistant
Definition cp2k_init.c:1199
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:1101
#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:906
int find_cp2k_sym()
find the CP2K symmetry parameter based on the cell properties
Definition cp2k_init.c:1245
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:994
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:1011
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:727
G_MODULE_EXPORT void update_cp2k_option_check(GtkToggleButton *but, gpointer data)
CP2K option toggle callback GTK3.
Definition cp2k_init.c:309
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:794
gboolean cp2k_with_motion()
CP2K MD calculation ?
Definition cp2k_init.c:1177
GtkWidget * thermo_box()
create the thermostat configuration widgets
Definition cpmd_nose.c:1891
gchar * page_name_cp2k(int p)
get CP2K assistant page name
Definition cp2k_init.c:1152
char * k_thermo[CP2NTHERM][4]
Definition cp2k_init.c:207
GtkWidget * spec_data_combo[2]
Definition cp2k_init.c:236
GtkWidget * file_info(int id)
create the assistant page that present the input file(s) properties
Definition cp2k_init.c:1030
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]
gchar * text
Definition datab.c:105
#define i18n(String)
Definition global.c:80
double string_to_double(gpointer string)
convert string to double
Definition global.c:611
Global variable declarations Global convenience function declarations Global data structure defin...
void run_this_gtk_dialog(GtkWidget *dial, GCallback handler, gpointer data)
run a GTK (3 and 4) basic GtkDialog
Definition gtk-misc.c:533
@ IMG_STOCK
Definition global.h:280
int combo_get_active(GtkWidget *combo)
retrieve the active item's position
Definition gtk-misc.c:935
GtkWidget * create_entry(GCallback handler, int dim, int cdim, gboolean key_release, gpointer data)
Create a GtkEntry.
Definition gtk-misc.c:1401
void update_entry_double(GtkEntry *entry, double doubleval)
update the content of a GtkEntry as double
Definition gtk-misc.c:688
GtkWidget * create_text_view(int dimx, int dimy, int edit, int mono, GCallback handler, gpointer data, gchar *text)
create a GtkTextView and display some text
Definition gtk-misc.c:1286
GtkWidget * dialogmodal(gchar *str, GtkWindow *parent)
Create a new dialog modal window.
Definition gtk-misc.c:552
void combo_set_active(GtkWidget *combo, int pos)
set the active item's position
Definition gtk-misc.c:958
const gchar * entry_get_text(GtkEntry *entry)
get the text in a GtkEntry
Definition gtk-misc.c:652
#define BSEP
Definition global.h:261
void update_entry_int(GtkEntry *entry, int intval)
update the content of a GtkEntry as int
Definition gtk-misc.c:669
GtkWidget * stock_image(const gchar *stock_id)
create a GtkImage for the Gtk database
Definition gtk-misc.c:1451
GtkWidget * radio_button(gchar *text, int dimx, int dimy, gboolean state, GCallback handler, gpointer data)
create a radio button
Definition gtk-misc.c:1970
GtkWidget * check_button(gchar *text, int dimx, int dimy, gboolean state, GCallback handler, gpointer data)
create a check button
Definition gtk-misc.c:1937
@ CONTAINER_FRA
Definition global.h:270
#define DPROPERTIES
Definition global.h:222
GtkWidget * create_button(gchar *text, int image_format, gchar *image, int dimx, int dimy, int relief, GCallback handler, gpointer data)
create a simple button
Definition gtk-misc.c:1999
GtkWidget * create_combo()
create a GtkCombox widget, note deprecated in GTK4
Definition gtk-misc.c:1010
GtkWidget * dialog_get_content_area(GtkWidget *widg)
prepare GtkWidget to insert content in a GtkDialog window
Definition gtk-misc.c:861
GtkWidget * markup_label(gchar *text, int dimx, int dimy, float ax, float ay)
create a GtkLabel with pango markup
Definition gtk-misc.c:1672
void add_box_child_start(int orientation, GtkWidget *widg, GtkWidget *child, gboolean expand, gboolean fill, int padding)
Add a GtkWidget in a GtkBox at the initial position.
Definition gtk-misc.c:340
void widget_set_sensitive(GtkWidget *widg, gboolean sensitive)
Set sensitivity for a GtkWidget, ensuring it is a GtkWidget.
Definition gtk-misc.c:247
GtkWidget * create_hbox(int spacing)
create a GtkBox with horizontal orientation
Definition gtk-misc.c:849
void combo_text_append(GtkWidget *combo, gchar *text)
append text in GtkComboBox widget
Definition gtk-misc.c:987
G_MODULE_EXPORT void run_destroy_dialog(GtkDialog *dialog, gint response_id, gpointer data)
to destroy a GtkDialog when the dialog emit the closing signal
Definition gtk-misc.c:2272
GtkWidget * destroy_this_widget(GtkWidget *widg)
destroy a GtkWidget
Definition gtk-misc.c:2213
#define AFILE
Definition global.h:240
void add_container_child(int type, GtkWidget *widg, GtkWidget *child)
Add a GtkWidget into another GtkWidget.
Definition gtk-misc.c:267
void hide_the_widgets(GtkWidget *widg)
hide GtkWidget
Definition gtk-misc.c:224
GtkWidget * create_vbox(int spacing)
create a GtkBox with vertical orientation
Definition gtk-misc.c:837
int button_get_status(GtkWidget *button)
get status of check / toggle button
Definition gtk-misc.c:1899
void show_the_widgets(GtkWidget *widg)
show GtkWidget
Definition gtk-misc.c:202
void motion(glwin *view, gint x, gint y, GdkModifierType state)
mouse motion in the OpenGL window
Definition glview.c:648
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:350
Definition global.h:868
GtkWidget * res[2]
Definition w_encode.c:342
GtkWidget * hbox
Definition workspace.c:71
GtkWidget * vbox
Definition workspace.c:72
GtkWidget * lab
Definition workspace.c:73