atomes 1.1.15
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-2024 by CNRS and University of Strasbourg */
15
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;
101#ifdef GTK4
102 j = gtk_check_button_get_active (but);
103#else
104 j = gtk_toggle_button_get_active (but);
105#endif
106 tmp_cpmd -> restart[i] = (j) ? 1 : 0;
107 if (i == 3 || i == 6)
108 {
109 if (tmp_cpmd -> restart[i]) tmp_cpmd -> restart[i] = 10;
110 update_entry_int (GTK_ENTRY(sace[i/6]), (tmp_cpmd -> restart[i]) ? TRUE : FALSE);
112 }
113 for (i=1; i<4; i++) print_the_section (i, 0, qmbuffer[i]);
114}
115
124G_MODULE_EXPORT void changed_restart_box (GtkComboBox * box, gpointer data)
125{
126 tmp_cpmd -> restart[0] = gtk_combo_box_get_active (box);
127 int i;
128 for (i=1; i<4; i++) print_the_section (i, 0, qmbuffer[i]);
129}
130
136GtkWidget * restart_box ()
137{
138 int i;
139 GtkWidget * vbox = create_vbox (BSEP);
140 GtkWidget * hbox;
141 // Thermostat type ions
142 gtk_widget_set_size_request (vbox, 525, 350);
143
144 // Initialization: Random / Atom / Restart
145 hbox = cpmd_box (vbox, "<u>Initialization for the Wavefunction:</u>", 20, 5, 230);
146
147 GtkWidget * box = create_combo ();
148 for (i=0; i<3; i++)
149 {
151 }
152 gtk_combo_box_set_active (GTK_COMBO_BOX(box), tmp_cpmd -> restart[0]);
153 g_signal_connect (G_OBJECT (box), "changed", G_CALLBACK(changed_restart_box), NULL);
154 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, box, FALSE, FALSE, 5);
155
156 // Save restart every
157 hbox = cpmd_box (vbox, "Save the information required for a restart every:", 5, 5, 340);
158 GtkWidget * widg = create_entry (G_CALLBACK(update_restart_parameter), 100, 15, FALSE, GINT_TO_POINTER(1));
159 update_entry_int (GTK_ENTRY(widg), tmp_cpmd -> restart[1]);
160 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, widg, FALSE, FALSE, 0);
161 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, gtk_label_new("steps"), FALSE, FALSE, 10);
162
163 // Num of restart:
164 hbox = cpmd_box (vbox, "Number of restart file(s): ", 0, 5, 340);
165 widg = create_entry (G_CALLBACK(update_restart_parameter), 100, 15, FALSE, GINT_TO_POINTER(2));
166 update_entry_int (GTK_ENTRY(widg), tmp_cpmd -> restart[2]);
167 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, widg, FALSE, FALSE, 0);
168
169 // Trajectory:
170 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox,
171 check_button("Create a trajectory", -1, -1, tmp_cpmd -> restart[3], G_CALLBACK(update_restart_check), GINT_TO_POINTER(3)),
172 FALSE, FALSE, 20);
174 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox,trap_box[0], FALSE, FALSE, 0);
175
176 hbox = cpmd_box (trap_box[0], "Save the atomic coordinates every: ", 0, 25, 300);
177 sace[0] = create_entry (G_CALLBACK(update_restart_parameter), 100, 15, FALSE, GINT_TO_POINTER(3));
178 update_entry_int (GTK_ENTRY(sace[0]), tmp_cpmd -> restart[3]);
179 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, sace[0], FALSE, FALSE, 0);
180 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, gtk_label_new("steps"), FALSE, FALSE, 10);
181 hbox = cpmd_box (trap_box[0], "Write XYZ format", 0, 25, 300);
182 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox,
183 check_button(NULL, -1, -1, tmp_cpmd -> restart[4], G_CALLBACK(update_restart_check), GINT_TO_POINTER(4)),
184 FALSE, FALSE, 0);
185 hbox = cpmd_box (trap_box[0], "Write atomic forces", 0, 25, 300);
186 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox,
187 check_button(NULL, -1, -1, tmp_cpmd -> restart[5], G_CALLBACK(update_restart_check), GINT_TO_POINTER(5)),
188 FALSE, FALSE, 0);
189 widget_set_sensitive (trap_box[0], tmp_cpmd -> restart[3]);
190
191 // Print information
192 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox,
193 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)),
194 FALSE, FALSE, 20);
196 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, trap_box[1], FALSE, FALSE, 0);
197 hbox = cpmd_box (trap_box[1], "Save the extra information every: ", 0, 25, 300);
198 sace[1] = create_entry (G_CALLBACK(update_restart_parameter), 100, 15, FALSE, GINT_TO_POINTER(6));
199 update_entry_int (GTK_ENTRY(sace[1]), tmp_cpmd -> restart[6]);
200 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, sace[1], FALSE, FALSE, 0);
201 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, gtk_label_new("steps"), FALSE, FALSE, 10);
202 hbox = cpmd_box (trap_box[1], "Select the information to print:", 5, 25, 300);
203 widget_set_sensitive (trap_box[1], tmp_cpmd -> restart[6]);
204 hbox = create_hbox (0);
205 add_box_child_start (GTK_ORIENTATION_VERTICAL, trap_box[1], hbox, FALSE, FALSE, 0);
206 gchar * print_str[3]={"Information", "Coordinates", "Forces"};
207 for (i=0; i<3; i++)
208 {
209 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox,
210 check_button(print_str[i], -1, -1, tmp_cpmd -> restart[i+7], G_CALLBACK(update_restart_check), GINT_TO_POINTER(i+7)),
211 FALSE, FALSE, 5);
212 }
213 return vbox;
214}
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.
gchar * rest_opts[3]
Definition cpmd_init.c:215
cpmd * tmp_cpmd
Definition cpmd_init.c:103
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:248
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:695
GtkWidget * sace[2]
G_MODULE_EXPORT void changed_restart_box(GtkComboBox *box, gpointer data)
CPMD input file change restart type.
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...
GtkWidget * create_entry(GCallback handler, int dim, int cdim, gboolean key_release, gpointer data)
Create a GtkEntry.
Definition gtk-misc.c:1314
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 * check_button(gchar *text, int dimx, int dimy, gboolean state, GCallback handler, gpointer data)
create a check button
Definition gtk-misc.c:1799
GtkWidget * create_combo()
create a GtkCombox widget, note deprecated in GTK4
Definition gtk-misc.c:923
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
GtkWidget * create_vbox(int spacing)
create a GtkBox with vertical orientation
Definition gtk-misc.c:801
Messaging function declarations.
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