atomes 1.3.1
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
cpmd_restart.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: 'cpmd_restart.c'
24*
25* Contains:
26*
27
28 - The functions to configure the restart section for the CPMD input file creation assistant
29
30*
31* List of functions:
32
33 G_MODULE_EXPORT void update_restart_parameter (GtkEntry * res, gpointer data);
34 G_MODULE_EXPORT void update_restart_check (GtkCheckButton * but, gpointer data);
35 G_MODULE_EXPORT void update_restart_check (GtkToggleButton * but, gpointer data);
36 G_MODULE_EXPORT void changed_restart_box (GtkComboBox * box, gpointer data);
37
38 GtkWidget * restart_box ();
39
40*/
41
42#include "global.h"
43#include "callbacks.h"
44#include "interface.h"
45#include "calc.h"
46#include "cpmd.h"
47
48extern void print_the_section (int s, int p, GtkTextBuffer * buffer);
49extern GtkWidget * cpmd_box (GtkWidget * box, gchar * lab, int v_space, int h_space, int dim);
50
59G_MODULE_EXPORT void update_restart_parameter (GtkEntry * res, gpointer data)
60{
61 int i, j;
62 i = GPOINTER_TO_INT(data);
63 const gchar * m = entry_get_text (res);
64 double v = string_to_double ((gpointer)m);
65 j = (int)v;
66 if (j != tmp_cpmd -> restart[i])
67 {
68 tmp_cpmd -> restart[i] = j;
69 }
70 update_entry_int (res, tmp_cpmd -> restart[i]);
71 for (i=1; i<4; i++) print_the_section (i, 0, qmbuffer[i]);
72}
73
74GtkWidget * sace[2];
75GtkWidget * trap_box[2];
76
77#ifdef GTK4
86G_MODULE_EXPORT void update_restart_check (GtkCheckButton * but, gpointer data)
87#else
96G_MODULE_EXPORT void update_restart_check (GtkToggleButton * but, gpointer data)
97#endif
98{
99 int i = GPOINTER_TO_INT(data);
100 gboolean j = button_get_status ((GtkWidget *)but);
101 tmp_cpmd -> restart[i] = (j) ? 1 : 0;
102 if (i == 3 || i == 6)
103 {
104 if (tmp_cpmd -> restart[i]) tmp_cpmd -> restart[i] = 10;
105 update_entry_int (GTK_ENTRY(sace[i/6]), (tmp_cpmd -> restart[i]) ? TRUE : FALSE);
107 }
108 for (i=1; i<4; i++) print_the_section (i, 0, qmbuffer[i]);
109}
110
119G_MODULE_EXPORT void changed_restart_box (GtkComboBox * box, gpointer data)
120{
121 tmp_cpmd -> restart[0] = combo_get_active ((GtkWidget *)box);
122 int i;
123 for (i=1; i<4; i++) print_the_section (i, 0, qmbuffer[i]);
124}
125
131GtkWidget * restart_box ()
132{
133 int i;
134 GtkWidget * vbox = create_vbox (BSEP);
135 GtkWidget * hbox;
136 // Thermostat type ions
137 gtk_widget_set_size_request (vbox, 525, 350);
138
139 // Initialization: Random / Atom / Restart
140 hbox = cpmd_box (vbox, _("<u>Initialization for the Wavefunction:</u>"), 20, 5, 230);
141
142 GtkWidget * box = create_combo ();
143 combo_text_append (box, _("Random"));
144 combo_text_append (box, _("Atomic Pseudo Wavefunctions"));
145 combo_text_append (box, _("Use a RESTART.* File"));
146 combo_set_active (box, tmp_cpmd -> restart[0]);
147 g_signal_connect (G_OBJECT (box), "changed", G_CALLBACK(changed_restart_box), NULL);
148 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, box, FALSE, FALSE, 5);
149
150 // Save restart every
151 hbox = cpmd_box (vbox, _("Save the information required for a restart every:"), 5, 5, 340);
152 GtkWidget * widg = create_entry (G_CALLBACK(update_restart_parameter), 100, 15, FALSE, GINT_TO_POINTER(1));
153 update_entry_int (GTK_ENTRY(widg), tmp_cpmd -> restart[1]);
154 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, widg, FALSE, FALSE, 0);
155 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, gtk_label_new(_("steps")), FALSE, FALSE, 10);
156
157 // Num of restart:
158 hbox = cpmd_box (vbox, _("Number of restart file(s): "), 0, 5, 340);
159 widg = create_entry (G_CALLBACK(update_restart_parameter), 100, 15, FALSE, GINT_TO_POINTER(2));
160 update_entry_int (GTK_ENTRY(widg), tmp_cpmd -> restart[2]);
161 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, widg, FALSE, FALSE, 0);
162
163 // Trajectory:
164 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox,
165 check_button(_("Create a trajectory"), -1, -1, tmp_cpmd -> restart[3], G_CALLBACK(update_restart_check), GINT_TO_POINTER(3)),
166 FALSE, FALSE, 20);
168 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox,trap_box[0], FALSE, FALSE, 0);
169
170 hbox = cpmd_box (trap_box[0], _("Save the atomic coordinates every: "), 0, 25, 300);
171 sace[0] = create_entry (G_CALLBACK(update_restart_parameter), 100, 15, FALSE, GINT_TO_POINTER(3));
172 update_entry_int (GTK_ENTRY(sace[0]), tmp_cpmd -> restart[3]);
173 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, sace[0], FALSE, FALSE, 0);
174 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, gtk_label_new(_("steps")), FALSE, FALSE, 10);
175 hbox = cpmd_box (trap_box[0], _("Write XYZ format"), 0, 25, 300);
176 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox,
177 check_button(NULL, -1, -1, tmp_cpmd -> restart[4], G_CALLBACK(update_restart_check), GINT_TO_POINTER(4)),
178 FALSE, FALSE, 0);
179 hbox = cpmd_box (trap_box[0], _("Write atomic forces"), 0, 25, 300);
180 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox,
181 check_button(NULL, -1, -1, tmp_cpmd -> restart[5], G_CALLBACK(update_restart_check), GINT_TO_POINTER(5)),
182 FALSE, FALSE, 0);
183 widget_set_sensitive (trap_box[0], tmp_cpmd -> restart[3]);
184
185 // Print information
186 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox,
187 check_button(_("Print extra data in the global output file"), -1, -1, tmp_cpmd -> restart[6], G_CALLBACK(update_restart_check), GINT_TO_POINTER(6)),
188 FALSE, FALSE, 20);
190 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, trap_box[1], FALSE, FALSE, 0);
191 hbox = cpmd_box (trap_box[1], _("Save the extra information every: "), 0, 25, 300);
192 sace[1] = create_entry (G_CALLBACK(update_restart_parameter), 100, 15, FALSE, GINT_TO_POINTER(6));
193 update_entry_int (GTK_ENTRY(sace[1]), tmp_cpmd -> restart[6]);
194 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, sace[1], FALSE, FALSE, 0);
195 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, gtk_label_new(_("steps")), FALSE, FALSE, 10);
196 hbox = cpmd_box (trap_box[1], _("Select the information to print:"), 5, 25, 300);
197 widget_set_sensitive (trap_box[1], tmp_cpmd -> restart[6]);
198 hbox = create_hbox (0);
199 add_box_child_start (GTK_ORIENTATION_VERTICAL, trap_box[1], hbox, FALSE, FALSE, 0);
200 gchar * print_str[3]={i18n("Information"), i18n("Coordinates"), i18n("Forces")};
201 for (i=0; i<3; i++)
202 {
203 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox,
204 check_button(_(print_str[i]), -1, -1, tmp_cpmd -> restart[i+7], G_CALLBACK(update_restart_check), GINT_TO_POINTER(i+7)),
205 FALSE, FALSE, 5);
206 }
207 return vbox;
208}
GtkTextBuffer * qmbuffer[MAXDATAQM+2]
Definition calc.c:70
Variable declarations for the MD input preparation assistants.
Callback declarations for main window.
Variable declarations for the creation of the CPMD input file.
cpmd * tmp_cpmd
Definition cpmd_init.c:103
void print_the_section(int s, int p, GtkTextBuffer *buffer)
print CPMD input section
Definition cpmd_print.c:697
GtkWidget * trap_box[2]
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
G_MODULE_EXPORT void update_restart_check(GtkToggleButton *but, gpointer data)
CPMD input file restart option toggle callback GTK3.
G_MODULE_EXPORT void update_restart_parameter(GtkEntry *res, gpointer data)
CPMD input file update restart parameter value entry callback.
GtkWidget * restart_box()
prepare the CPMD input preparation assistant restart widgets
void print_the_section(int s, int p, GtkTextBuffer *buffer)
print CPMD input section
Definition cpmd_print.c:697
GtkWidget * sace[2]
G_MODULE_EXPORT void changed_restart_box(GtkComboBox *box, gpointer data)
CPMD input file change restart type.
#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...
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 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 * check_button(gchar *text, int dimx, int dimy, gboolean state, GCallback handler, gpointer data)
create a check button
Definition gtk-misc.c:1937
GtkWidget * create_combo()
create a GtkCombox widget, note deprecated in GTK4
Definition gtk-misc.c:1010
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
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
Messaging function declarations.
Definition glwin.h:350
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